This is an FYI post.
It appears that since r170 the new code has misplaced initializing the materials library with default materials.Even though this new code works with .mpd
files it does not assign materials properly for .ldr
files. At least r169 still works fine for me.
As for the new versions, my test shows that the following code change works fine, where the initialization line was moved out of the load
function and into the setConditionalLineMaterial
function:
setConditionalLineMaterial( type ) {
this.ConditionalLineMaterial = type;
this.missingConditionalEdgeColorMaterial = new this.ConditionalLineMaterial( { name: Loader.DEFAULT_MATERIAL_NAME, fog: true, color: 0xFF00FF } );
// Initializes the materials library with default materials
this.setMaterials( [] );
return this;
}
Maybe find a way to test this yourself.
What is stated in my previous post does not seem to be the only issue with LDRAW in the latest revisions of the three.js library.
Switching from r170 to r171 will have the LDrawConditionalLineNodeMaterial.js
throw an import error since NodeMaterial
is not any longer included in three/tsl
.
Even after correcting this import then WebGPURenderer keeps throwing errors.
Either this is all a little bit messed up in the library or I might be doing it all wrong.
1 Like
Might be a new bug. Did you report it here? Issues · mrdoob/three.js · GitHub
It is not as easy as that and that is the reason why I am posting it here.
Currently, the library seems to be solely focusing on supporting only .mpd
models which are included in the library itself. That probably makes it difficult for them to test other models, like .ldr
or .l3b
, since these models require access to ldraw source like the test repository that you can see in my code below:
ldraw_loader.setPartsLibraryPath( 'https://raw.githubusercontent.com/gkjohnson/ldraw-parts-library/master/complete/ldraw/' );
ldraw_loader.separateObjects = true;
ldraw_loader.smoothNormals = true;
await ldraw_loader.preloadMaterials( 'https://raw.githubusercontent.com/gkjohnson/ldraw-parts-library/master/colors/ldcfgalt.ldr' );
Accessing external repository would create lots of traffic due to the current code and the maintainers are probably aware of that and looking to avoid it.
So, I am leaving it for the maintainers to actually figure out what might be wrong.
1 Like