I have a complex geometric 3D object I exported from Blender, and need to put it in three.js, but leaving nothing but the wireframe/skeleton, how can I achieve this? I need to be able to change between wireframe and the “normal” look of the object
You could use a function like this:
function setWireframe( object, boolean ) {
object.traverse( ( child ) => {
if ( child.isMesh ) {
if ( ! Array.isArray( child.material ) ) {
if ( child.material.wireframe !== undefined ) child.material.wireframe = boolean;
} else child.material.forEach( ( mat ) => {
if ( mat.wireframe !== undefined ) mat.wireframe = boolean;
} );
}
} );
}
Then you can call it like this to turn wireframe on:
setWireframe( objectLoadedFromBlender, true );
4 Likes
Hey, that is pretty good. Thank you!