Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load .glb and .gltf models #182

Open
haydenlinder opened this issue Nov 9, 2020 · 2 comments
Open

Unable to load .glb and .gltf models #182

haydenlinder opened this issue Nov 9, 2020 · 2 comments

Comments

@haydenlinder
Copy link

Related pull request: #165 (which was mentioned in this issue)

I am unable to load .glb or .gltf models in iOS.
Works on web.
Have not tested on Android.

Here's my App.js:

import ExpoTHREE from 'expo-three';
// inside component with access to the scene 
//  ...
    useEffect(() => {
        ExpoTHREE.loadAsync(
            uri,
            event => {
                console.log(event);
            },
            req => {
                console.log('requesting resource: ',req);
                return uri;
            }
        )
        .then(model => {
            scene.add(model.scene);
        })
        .catch(er => {
            console.log('error': ', er);
        })
    }, [])
//  ...

Note that I had to change the following in /node_modules/three/jsm/loders/GLTFLoader (see this issue: #144)

var ar = new Uint8Array(bufferView)
new Blob( [ ar ] , ... )

When I run on my physical iOS device I get this output from the event callback:

Event {
  "isTrusted": false,
  "lengthComputable": true,
  "loaded": 5972220,
  "total": 5972220,
}
@haydenlinder haydenlinder changed the title Unable to load .glb and .gltf Unable to load .glb and .gltf models Nov 9, 2020
@BrandonBlanchard
Copy link

BrandonBlanchard commented Dec 18, 2020

I've been able to get around the "isTrusted" part of this by using the asset.uri rather than the asset localUri.

const getUrl = async () => {
  const asset = Asset.fromModule(
    require('../../../../../public/3d/models/model.glb')
  );
  await asset.downloadAsync();

  return asset.uri;
};

const model = useAsyncMemo<GLTF>(() => loadAssetAsync(fileUrl), [fileUrl]);

Once the loader completes the model shows for a brief moment and then disappears. I've validated the model using the vs code gltf extension so I doubt the issue is there. This also occurs with the following filetypes .glb, .gltf, .fbx.

A fix or a way to work around this would be great!

@kyaroru
Copy link

kyaroru commented Aug 24, 2021

Can refer to this : #151 (comment) 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants