Threejs How To Remove Wireframe With Wireframehelper
I have a function to add wireframe for the objects, so I am using the following function to do it, on the first condition it is working and I can apply wireframe function wirefram
Solution 1:
I think this is what you want. You need a global variable to store the wireframe object assign a value to it just once (if statement) and then selectively add it or remove it from the scene.
var wfh;
function wireframe (state) {
if ( state=='on' )
{
if ( wfh === `undefined` ) // so you dont add a new wfh each time you call wireframe
wfh = new THREE.WireframeHelper( mesh, 0xf00e0e );
scene.add( wfh );
}
else if ( state=='off' )
{
scene.remove( wfh );
}
}
Post a Comment for "Threejs How To Remove Wireframe With Wireframehelper"