I want make a Object3D dynamically clipping another Object3D, not basic planes clipping.
by the way, what is the proper way to remove a mesh(Object3D) from scene. The Docs hasn’t mentioned it, I think it’s essential for beginners.
is this OK?
Hi!
Are you looking for operations with geometries? Like “union”, “subtract”, “intersect”.
If so, take a look at this forum topic Looking for Updated plug-in for CSG
no. Three.js can not do that by itself. You would need to write additional code or find a third-party project that implements those features on top of Three.js.
I would suggest you re-think your approach, consider what your goal is, and look for alternative ways to achieve it, perhaps Constructive Solid Geometry is not the only way to get what you want.
If your material has a texture, you need to dispose of that, too, using the dispose method of the Texture class. If you only remove the object from the scene, the memory allocated to your mesh won’t be freed up entirely, as the renderer still holds references to them (if I’ve understood things correctly).
Generally speaking, when it comes to cleaning up a scene, I would advise you to take a look at the docs and see which classes have a dispose method.
I think his remark was in regard to the question of the correct order of operations for disposing of an element, and not your case, per se. As for not being able to dispose of something because it is undefined, do a console log on the parent object; that should help you get a grip of the data structure of your object and how you have to go about disposing of things. The example I posted above was just pseudo code for the very simple case where you have a scene that contains a mesh that contains a geometry and a material.
Regarding clipping, did you try playing with depth tests?
Regarding disposing. You have to keep in mind that not all objects are represented in the main memory, some exist on the gpu. You could release the references to a geometry and let it be garbage collected, but without calling dispose the geometry will remain on the gpu. You can’t actually just destroy an object in JS, as long as you have a reference for it it will exist. Disposing thus consists of two different things. Get it off the gpu, get it out of your memory (GC).