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

Fix GLTF File load #165

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix GLTF File load #165

wants to merge 1 commit into from

Conversation

giorgioma
Copy link

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 )

@@ -110,7 +130,7 @@ export async function loadDaeAsync({
async function loadFileContentsAsync(loader, uri, funcName): Promise<any> {
try {
const fileContents = await readAsStringAsync(uri);
return loader.parse(fileContents);
return new Promise((res, rej) => loader.parse(fileContents, uri, res, rej));
Copy link
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

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
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

@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
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