Skip to content

Fix GLTF File load#165

Open
giorgioma wants to merge 1 commit intoexpo:masterfrom
giorgioma:master
Open

Fix GLTF File load#165
giorgioma wants to merge 1 commit intoexpo:masterfrom
giorgioma:master

Conversation

@giorgioma
Copy link
Copy Markdown

Hi! I was unable to load any glTF files on my bare workflow expo app (I did not try on managed workflow), so I made a fix, i am now able to load common files
I tested with a couple of glTF files provided by Khronos )

try {
const fileContents = await readAsStringAsync(uri);
return loader.parse(fileContents);
return new Promise((res, rej) => loader.parse(fileContents, uri, res, rej));
Copy link
Copy Markdown
Author

@giorgioma giorgioma Apr 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GLTFLoader parse from three.js does not return anything, it just calls the res & rej functions when done...
This might affect others loaders included, but i did not test them

@lamazzing
Copy link
Copy Markdown

Hi Giorgio, first of all thank you so much for working on this issue. I've been trying to use the forked package to load gltf models but couldn't make it work, all packages seem to be installed well but I still can't read the models. Do you perhaps have a working example with the expo bare workflow, it would really be helpful. Thanks

@giorgioma
Copy link
Copy Markdown
Author

Snack is using yarn so I am not able to include the correct github module version from my repo...
I still can share the rest of the code https://snack.expo.io/70V_Zrs_8
You will need to use it on your project and update package.json to use the correct dependencies

@lamazzing
Copy link
Copy Markdown

@giorgioma thank you so much, that's awesome. The package is working with the gltf model in the example, just had to add an atob function. Still couldn't manage to make it work with textures like in this case https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/Avocado
or this https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/Duck

Getting this error:
Unhandled promise rejection: Error: Creating blobs from 'ArrayBuffer' and 'ArrayBufferView' are not supported

@giorgioma
Copy link
Copy Markdown
Author

giorgioma commented Apr 30, 2020

I am guessing it depends on which gLTF export format you are using...
I have only used files with embedded textures, but I am not sure which version you have used
If they are not already available, have you tried opening the files you want with a gLTF compatible software (e.g. blender ), including the textures and exporting everything again as a single file with embedded textures?

Just a note: for loading subsequent files (e.g. external textures described inside the gLTF file) some extra work might be done (I am quite sure the external textures in the file includes only a partial/local URL, not a full url pointing to the github repo that you are using for the example, so the files you are trying to load are not found locally from your packager )

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

Successfully merging this pull request may close these issues.

2 participants