Home / Modules / World / Object3DUtils

Object3DUtils

Pure logic

Removes and disposes Three.js object hierarchies, including geometry and material resources.

CategoryWorld
Dependency tierPure logic
Internal depsnone
Related modulesnone
Demo scenefactory-showroom · Factory showroom ↓
Take just this module
modules/world/Object3DUtils.js

Copy it together with its internal dependencies, preserving the relative directory structure.

Factory showroom

three

Auto-rotating showcase — no controls needed.

Source

export function disposeObject3D(object) {
  if (!object) return;
  object.parent?.remove(object);
  object.traverse?.((node) => {
    node.geometry?.dispose?.();
    if (Array.isArray(node.material)) {
      node.material.forEach((material) => material.dispose?.());
    } else {
      node.material?.dispose?.();
    }
  });
}