mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
102.57k stars 35.37k forks source link

FBXLoader failure #11973

Closed makc closed 7 years ago

makc commented 7 years ago
TypeError: Cannot read property 'children' of undefined
    at parseMaterial (http://super/3d/js/loaders/FBXLoader.js:434:43)
    at parseMaterials (http://secret/3d/js/loaders/FBXLoader.js:403:20)
    at THREE.FBXLoader.parse (http://web/3d/js/loaders/FBXLoader.js:120:20)
    at http://server/3d/js/loaders/FBXLoader.js:59:23
    at XMLHttpRequest.<anonymous> (https://cdnjs.cloudflare.com/ajax/libs/three.js/86/three.js:29871:21)

I am trying to find what file was that.

makc commented 7 years ago

They say it was this one.

takahirox commented 7 years ago

I don't really wanna sign up that site. Can you (personally) share the file with us?

makc commented 7 years ago

Let's see... looks like I can: Dentist's office.FBX.zip

takahirox commented 7 years ago

Thanks. I confirmed. I'll look into...

takahirox commented 7 years ago

I ran into the same error even I converted the file to ascii with Autodesk FBX Converter. So probably it isn't a binary parser issue.

Seems like missing some connection data. Can the file be loaded with other libs/viewers?

makc commented 7 years ago

I asked them if the file may be truncated (as in: broken download). They said:

I tried the model on the desktop 3D viewer on windows and it opened fine

I tried the same to confirm, and my autodesk viewer does not claim any error: screen shot 2017-08-19 at 11 09 00

takahirox commented 7 years ago

OK, I see.

I speculate the file includes unused materials which don't have any connections. Probably we can ignore them.

Would you please try FBXLoader in my branch that I updated?

https://github.com/takahirox/three.js/blob/FixFBXLoader/examples/js/loaders/FBXLoader.js

makc commented 7 years ago

Can't test the project atm, but FBXLoader does now call onLoad with the file, at the very least.

var loader = new THREE.FBXLoader;
loader.load ('Dentist\'s%20office.FBX', function (done) {
    console.log (done);
}, undefined, function (crap) {
    console.log (crap);
});

Btw, getting a bunch of warnings here

THREE.MeshBasicMaterial: 'emissiveIntensity' is not a property of this material. THREE.FBXLoader: No implementation given for material type unknown in FBXLoader.js. Defaulting to basic material.

looeee commented 7 years ago

These two at least are very common and pretty self explanatory.

No implementation given for material type unknown in FBXLoader.js. Defaulting to basic material

THREE.MeshBasicMaterial: 'emissiveIntensity' is not a property of this material.

However given how common this is I think it would be more useful if the default was something other than MeshBasicMaterial.

looeee commented 7 years ago

By the way I've tried importing this into 3ds max and then re-exporting and it loads

dentists-chair

Both files are the same FBX version (7400), however interestingly the re-export is much larger (44mb vs 22mb)

I can't attach the re-exported file here as it's too big (it says there's a limit of 10mb, so how did @makc attach the original? 🤔 ).

makc commented 7 years ago

@looeee Idk, I just dropped the zip into the input field. maybe you are emailing it, and it's your email limit?

makc commented 7 years ago

@looeee still, I cant get textures on 20 mb model: screen shot 2017-08-19 at 18 26 56

they are loaded but do not show up. was it the same for you before you re-exported?

looeee commented 7 years ago

@makc nope, was uploading on github on Chrome. It popped up an error saying I should try again with a file less than 10mb.

If you want I can share the file with you via Dropbox.

As for loading the original file, I was testing it on my loader here. It showed the same errors as you, then spewed a few more errors, something about textures but it crashed my console window before I could copy them.

From memory they were something like

Data64:blablabla..... Couldn't load texture someurl/door-fexture.jpg

takahirox commented 7 years ago

About default material, agreed. I think MeshStandardMaterial would be better.

makc commented 7 years ago

@takahirox and what about textures? how come they are loaded (network tab says so) but do not make it into materials? is it because the property name is not 'map' (for MeshBasicMaterial) ?

takahirox commented 7 years ago

What are the texture names?

makc commented 7 years ago

There are too many of them: screen shot 2017-08-20 at 1 56 13

it also says this a lot: screen shot 2017-08-20 at 1 57 24

(this is with the loader from your repo fork)

takahirox commented 7 years ago

What I wanna know are not image files but texture names like "3dsMax|maps|texmap_reflectionGlossiness"

makc commented 7 years ago

those I can only see in warnings, I did not make the file :) there are:

on repeat, not sure if I missed others

makc commented 7 years ago

missed 3dsMax|maps|texmap_refraction

takahirox commented 7 years ago

Oops, they aren't texture names but parameters in connection that we call relationship. Anyways, they're what I wanted to know, thanks.

Currently we recognize the valid textures by using perfect match with only some types.

Probably we'd be better to do partial match with more types.

takahirox commented 7 years ago

I've update FBXLoader in my branch. Would you please try again?

Not sure how reflection[Glossiness] should be handled tho. Is that for roughness? Or envMap? I handle it as envMap so far.

And I ignore refraction so far. If I'm right, it'd be for refraction of env map but Three.js doesn't support refractionMap yet both reflection and refraction at a time but just either one.

makc commented 7 years ago

env map but Three.js doesn't support refractionMap

then what do you think are these:

THREE.CubeRefractionMapping THREE.EquirectangularRefractionMapping

takahirox commented 7 years ago

They aren't texture settings.

makc commented 7 years ago

ORLY?

takahirox commented 7 years ago

Ah, I meant they aren't textures themselves but texture mapping parameters. I'm not sure how to apply the textures which indicates 'refraction'.

For examples, the bump textures should be set to material.bumpMap but where refraction textures set to?

makc commented 7 years ago

The answer was in the same demo :)

The property names might differ for different materials, check the docs.

takahirox commented 7 years ago

Wait, doesn't a material have both reflection and refraction textures in FBX file? I already set reflection texture to envMap so I'm not where refraction texture set to. reflection is not for envMap but for others? (roughness?)

Can you list up what textures each material uses in the FBX file? Like

makc commented 7 years ago

Now that, I think, 3js does not support ootb. @mrdoob or anyone feel free to correct me.

takahirox commented 7 years ago

What's ootb?

makc commented 7 years ago

out of the box. of course you can always just write your own shader.

takahirox commented 7 years ago

Updated my comments above to clarify.

makc commented 7 years ago

Can you list up what textures each material uses in the FBX file? Like

no, I am not fbx wizard or anything ) I see the same file you do, and have no more information about this file than you have.

takahirox commented 7 years ago

Can you open another issue for FBX texture handling enhancement? I wanna fix the original "loading failure" issue and close this thread for now.