I need to retrieve the wireframe of an object that I have loaded using OBJMTLLoder
. Below is the code snippet I am currently using:
var loader = new THREE.OBJMTLLoader();
loader.load( 'obj/male02/male02.obj', 'obj/male02/male02_dds.mtl', function ( object ) {
object.traverse( function ( child ) {
if ( child instanceof THREE.Mesh )
{
child.geometry.computeFaceNormals();
var geometry = child.geometry;
console.log(geometry);
geometry.dynamic = true;
material = new THREE.MeshLambertMaterial();
mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
var useWireFrame = true;
if (useWireFrame) {
mesh.traverse(function (child) {
if (child instanceof THREE.Mesh) child.material.wireframe = true;
});
}
}
object.position.y = - 80;
scene.add( object );
});
} );
The current setup works fine and displays the wireframe on my object. However, the object's material changes to MeshLambertMaterial
. My goal is to obtain the wireframe with the default material of the loaded object. I have tried using various Materials mentioned in the Three.js documentation, but none of them preserve the default object material.