1) To ensure your code functions properly, simply invoke toggleWireFrame
on each individual mesh.
toggleWireFrame(meshA);
toggleWireFrame(meshB);
This approach is useful when dealing with meshes comprised of multiple sub-meshes that all need their wireframes toggled. Such hierarchies are common when importing models from formats like OBJ.
2) Alternatively, if you prefer to toggle all mesh wireframes with just one call:
Try invoking
toggleWireFrame(scene);
or even
toggleWireFrame(myObject3D);
where myObject3D
represents an instance of Object3D
serving as the parent for the target meshes.
The traverse()
method works by traversing through all descendants of a given object. Ensure that all desired meshes share this common ancestor based on the provided examples.
3) An additional option involves using an array to store materials upon creation. Subsequently, iterate through this array to alter the wireframe attribute when the user toggles a corresponding checkbox.