I’ve noticed that when loading a 3MF file with the 3MF loader, the resulting group and child meshes do not contain any normal attributes - this seems to work fine if using the baked materials inside the 3MF, but if you try and set a custom material like MeshNormalMaterial, the meshes render as solid black.
reproducable at three.js/webgl_loader_3mf_materials.html at 8f18f8a28ec771d1d4631a665b6db6cc9a203162 · ErinTheSmall/three.js · GitHub
edited from the default example with:
loader.load( './models/3mf/cube_gears.3mf', function ( object ) {
object.quaternion.setFromEuler( new THREE.Euler( - Math.PI / 2, 0, 0 ) ); // z-up conversion
object.traverse( function ( child ) {
if (child instanceof THREE.Mesh) {
child.material = new THREE.MeshNormalMaterial();
child.geometry.computeVertexNormals(true);
}
child.castShadow = true;
} );
scene.add( object );
} );
This can sort of be fixed by running .computeVertexNormals() on the mesh, but that produces incorrect normals, and lighting issues
if you remove .computeVertexNormals() but keep the custom material I get this:
and if you remove the “child.material = new THREE.MeshNormalMaterial();” you get the baked textures of the 3mf working fine :
traversing through objects children and setting the material does seem to work for OBJ’s loaded with OBJ loader, as their children meshes do have the normal attribute set when loaded