-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Open
Description
Description
Right now it’s too hard to clean memory of meshes, even if the user explicitly disposes geometry, materials and textures and remove all references.
The reason is:
- A mesh “does not know” with which materials it was rendered (
scene.overrideMaterial) - Each
PassNode/ override material can create one or moreRenderObjects behind the scenes. - Those
RenderObjects can only be destroyed when the corresponding material is disposed. - As a result, it’s not enough to dispose just the resources (geometry, materials, textures).
You must also dispose all nodes that useoverrideMaterial(includingLightNodeand PP nodes), orRenderObjects will stay alive and keep meshes strongly referenced.
It would be great to have a way to notify Renderer that a mesh is no longer needed, so it can remove all RenderObject instances associated with that mesh (mesh.dispose?)
Here is a video explanation from this PR: #32395 (comment)
output2.mp4
mrdoob