aframevr / aframe

:a: Web framework for building virtual reality experiences.
https://aframe.io/
MIT License
16.68k stars 3.98k forks source link

GLTF loader doesn't handle errors properly #3237

Open joshmarinacci opened 6 years ago

joshmarinacci commented 6 years ago

When you download a file, at least on mac, by default the disk permissions of an unzipped directory is 700 instead of 755. This will give you a 403 error if you try to load it via a local webserver. However, when using the GLTF loader the console never shows this 403 error. Instead you just get a timeout.

Looking at the code to the GLTF loader:

https://github.com/aframevr/aframe/blob/master/src/components/gltf-model.js

The error handling code is not printing the error message to the console. I'm not sure it's even being called. Does 'warn' need to be upgraded to something stronger?

Also, by default, the model is only visible below the user. Is it being placed at 0,0,0? It's not clear how to move it once loaded.

joshmarinacci commented 6 years ago

if you set position='0 0 -3' on the same entity that i'm loading the model for, then i can see it.

ngokevin commented 6 years ago

We should handle here if we preload: https://github.com/aframevr/aframe/blob/master/src/core/a-assets.js#L126

donmccurdy commented 6 years ago

@ngokevin do you know why warn output would not show up? Is that disabled for minified builds?

this particular error could be caught at preload step but many errors would not.

ngokevin commented 6 years ago

It never reaches that point due to <a-assets> timeout.

joshmarinacci commented 6 years ago

so a-assets is hiding the underlying XHR error?

On Nov 16, 2017, at 3:41 PM, Kevin Ngo notifications@github.com wrote:

It never reaches that point due to timeout.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/aframevr/aframe/issues/3237#issuecomment-345098997, or mute the thread https://github.com/notifications/unsubscribe-auth/AAQ5yuxbI7dTmC-noq3DcWGWg_6oZoXFks5s3MhHgaJpZM4QhPvy.

donmccurdy commented 6 years ago

@joshmarinacci that sounds like the problem, but can you post the specific errors you're seeing in the console and/or Network tab?

ngokevin commented 6 years ago

The exact fix is to add a console.log here: https://github.com/aframevr/aframe/blob/master/src/core/a-assets.js#L126

rhokstar commented 6 years ago

Hi guys,

FWIW, I'm using Cesium's obj2gltf to convert obj to gltf 2.0. I've been trying to load an object into aframe locally but I cannot properly diagnose what's wrong with the scene because components:gltf-model:warn THREE.GLTFLoader: Unable to parse model.. I've tried chmod 755 model.gtlf and that doesn't work either.

Just to sanity check the model, I used @donmccurdy gltf 2.0 loader and the model loads correctly with textures.

donmccurdy commented 6 years ago

Could you post a demo, and/or get a screenshot of the Network tab in your browser's developer tools after refreshing the page? (you can drag .ZIP files into GitHub comments). And are you using a local webserver?

rhokstar commented 6 years ago

image

Yes, I'm using live-server. adidas.gltf.zip

donmccurdy commented 6 years ago

Hi @rhokstar — the model adidas.gltf is working OK with gltf-model for me in A-Frame 0.7.0:

Demo: https://tmp-svtfxinske.now.sh/ Code:

<!DOCTYPE html>
<script src="https://aframe.io/releases/0.7.0/aframe.min.js"></script>
<a-scene>
  <a-entity gltf-model="src: url(adidas.gltf);" scale="0.01 0.01 0.01"></a-entity>
  <a-entity camera look-controls wasd-controls position="0 0 1"></a-entity>
</a-scene>

Can you post the rest of the HTML from your scene? I'm on MacOS, so perhaps something is different about file permissions but I'd be surprised to see that 304 in your network tab. Perhaps also disable caching at the top of the Network tab.