Closed wtaisto closed 4 years ago
The issue seems to be that there are UV nodes without any data. I'm not sure if this is something we should handle or if it's a bug in your exporter. What program are you exporting from?
It should be possible to fix this by adding appropriate checked to the parseUVs
method inside the loader. In particular, the line var buffer = UVNode.UV.a;
causes errors since UVNode.UV
is undefined.
When I view your file in FBX review I see a simple green roof:
Is this the entire model? Inside the FBX there's 16 geometries, which seem high, including "Line" type geometries which I haven't seen before.
I'm not sure if this is something we should handle or if it's a bug in your exporter.
@looeee I noticed that online converters parse this FBX file, so it seems FBXLoader
should, too.
Yes, that is the entirety of the model. It comes from a timber-build construction program called Cadwork. The software uses 3d volumetric objects like boards and panels as it's primitives, so each "board" comes out as it's own named geometry, which is required for my context.
I've noticed that when I try and convert these FBX's to GLTF's (both via FBX2glTF and Aspose.3d), the resulting GLTF's also generate other errors when rendering in three.js; so your observation about empty nodes is probably leading to that too.
I have limited ability to push back requests to the creators of Cadwork; a fix to the three.js source to gracefully ignore the missing objects would be incredibly appreciated. My limited reading of the three.js source did seem to imply a null check at the line you mentioned could fix it as I didn't notice anything downstream which would be effected.
BTW, when I run FBX2glTF on these files, they load, but then I get the error below when render is next invoked (but the GLTF's display fine in other viewers):
vue.runtime.esm.js:1888 TypeError: Cannot read property 'getUniforms' of undefined
at setProgram (three.module.js:24649)
at WebGLRenderer.renderBufferDirect (three.module.js:23698)
at renderObject (three.module.js:24415)
at renderObjects (three.module.js:24385)
at WebGLRenderer.render (three.module.js:24183)
at VueComponent.<anonymous> (Test3d.vue:161)
at Array.<anonymous> (vue.runtime.esm.js:1980)
at flushCallbacks (vue.runtime.esm.js:1906)
The file generated by FBX2glTF loads fine for me in https://gltf-viewer.donmccurdy.com/ although I get a warning when converting the file:
unsupported transform inheritance type 'eInheritRrSs'
Previously I've only encountered this warning when dealing with Maya FBX files. What app are you using to create the FBX?
a null check at the line you mentioned could fix it
Unfortunately not quite that simple, as I tested this.
@looeee I noticed that online converters parse this FBX file, so it seems FBXLoader should, too.
I'd love to make the loader work for every single program with an FBX exporter, but unfortunately, I don't have time. My goal was limited to supporting Autodesk programs and Blender.
If someone else is interested in taking over the work to support files generated by other programs, or edge case from Autodesk and Blender, I have a collection of files that currently don't load correctly which I'll share with anyone interested (I'm not sure of the licensing on these files so I won't share them publicly).
@wtaisto that means you're on your own with this, although if you do try to fix the loader feel free to reach out for advice. In the meantime, converting your files to glTF does work.
The parser indicates UVs exist, but the UV data is not actually present.
As a temporary workaround, it appears you can make the following change to parseGeoNode()
in your copy of the loader:
if ( geoNode.LayerElementUV ) {
geoInfo.uv = [];
var i = 0;
while ( geoNode.LayerElementUV[ i ] ) {
if ( geoNode.LayerElementUV[ i ].UV ) { // temporary workaround
geoInfo.uv.push( this.parseUVs( geoNode.LayerElementUV[ i ] ) );
}
i ++;
}
}
This is a workaround only.
Thank you all, so very much for your feedback. I've shifted to a workaround of taking my (apparently poorly exported) FBX files and running them through FBX2glTF before loading them and just operating on the GLB versions, which the rest of my toolchain accepts and works great.
@looeee This may be an inconsistency in the FBX file, or it may be the loader is creating a UV node it should not. In any event, I think you can remove the bug label and close this if you do not intend to pursue it further.
In any event, I think you can remove the bug label and close this if you do not intend to pursue it further.
Hopefully, someone else will fix it. I wasn't the first person to work on the FBXLoader, and there's no reason to presume I'll be the last. Even aside from bug fixes, there's loads more work that could be done on the loader to improve efficiency and speed.
If you want to close this to keep the number of issues down, that's fine. But otherwise, I think it's useful to have a list of open issues since that might inspire someone else to try and fix them.
I have a series of exports from a small-ish CAD software in FBX. When I try to load any of them in the browser with three.FBXLoader (including the attached fbx file), I get errors and the file does not appear. I can view the files without problems in Autodesk FBX Review software.
My loading code:
Chrome console output:
Roof.zip
Three.js version
Browser
OS
Hardware Requirements (graphics card, VR Device, ...)