0

I have used THREE.js GLTFLoader to load glb file then I used USDZ Exporter to export it to usdz then when I tried to open it on browser it opened on saferi but didn't shown on arkit on object mode and on AR Mode appear above my head this is a simple file

https://drive.google.com/file/d/1uAZNZLWI-zdtjcetfT2tIBh9a0tyzGyi/view?usp=sharing

This is my trial

const loader = new GLTFLoader().setPath(`${origin}${folderPath}`);
        loader.load(modelName, async function (gltf) {

            model = gltf.scene;
            scene.add(model);
      const exporter = new USDZExporter();
            const arraybuffer = await exporter.parse(model );
            const blob = new Blob([arraybuffer], { type: 'application/octet-stream' });

            const link = document.getElementById('usdz-link');
            link.style.display = ''
            link.href = URL.createObjectURL(blob);

also I have tried to center the glb model by this code

        const box = new THREE.Box3().setFromObject(gltf.scene);
        const center = box.getCenter(new THREE.Vector3());
        var sceneCopy=gltf.scene.clone();
        sceneCopy.position.x += (gltf.scene.position.x - center.x);
        sceneCopy.position.y += (gltf.scene.position.y - center.y);
        sceneCopy.position.z += (gltf.scene.position.z - center.z);

and then used sceneCopy to be exported to usdz but unfortunately this didn't help me

1 Answers1

0

I think we answered this one through slack, but I'll repost here for closure..

The offset of the model needs to be close to the origin for it to appear correctly in the quicklook viewer on iPad/iPhone.

You can manually set the offset by changing these three lines... https://github.com/wallabyway/quicklook-example/blob/6f1e1453b983e0effc4ad82b2eda5eac905865a9/alliedbim-piping.gltf#L1023-L1025

which is the opposite of these 3 values:

the opposite to these 3 values: https://github.com/wallabyway/quicklook-example/blob/6f1e1453b983e0effc4ad82b2eda5eac905865a9/alliedbim-piping.gltf#L1044-L1046

Basically, when you use filtering in forge-convert-utils, the center option doesn't take into account the offset.

There is a GitHub repo feature request to fix this...

https://github.com/petrbroz/forge-convert-utils/issues/44

and a branch with a possible solution. https://github.com/petrbroz/forge-convert-utils/commit/bb4bd0a13c685c34966a3bf5c2784ba9b1343a7d

michael beale
  • 1,014
  • 1
  • 6
  • 5