Documentation is work in progress and not completeEditor
3D System

ThreeDShapeElement

ThreeDShapeElement is the primary facade for the 3D system. Each instance encapsulates a full Three.js environment and exposes the small surface the React layer needs.

Constructor

constructor(mountContainer: HTMLElement, options: ThreeDShapeElementOptions = {})
ParameterTypeDescription
mountContainerHTMLElementThe DOM element that will receive the WebGLRenderer canvas
options.geometryTypeGeometryType (optional)Primitive type to create initially. Defaults to 'box'
options.sceneStateSceneStateSnapshot (optional)If provided, the scene is restored from this snapshot instead of creating a new primitive

If sceneState is provided the constructor calls restoreScene(); otherwise it calls engine.addPrimitive() with the given geometry type.

Public Methods

MethodSignatureDescription
getEngine()(): ThreeDEngineReturns the underlying engine for direct API access
resize()(width, height): voidResizes the renderer and updates the camera aspect ratio
setInteracting()(active: boolean): voidEnables or disables orbit controls and marks dirty. When false, the shape acts as a static viewport
isInteracting()(): booleanReturns the current interaction state
getSceneSnapshot()(): SceneStateSnapshotSerializes the current scene for persistence
pause()(): voidStops the render loop, for off-screen optimization
resume()(): voidRestarts the render loop
dispose()(): voidDestroys the engine, releases all GPU resources and removes the canvas from the DOM. Must be called when the shape is deleted

Lifecycle

  • Construction — ThreeDShapeRenderer creates the element in a useEffect and passes the container div.
  • Active use — the user interacts via the properties panel or by entering 3D edit mode. Orbit, gizmo, material and geometry changes flow through getEngine().
  • Visibility toggling — when element.visible becomes false, pause() is called; when it becomes true, resume() is called.
  • Destruction — the useEffect cleanup calls dispose(), which cascades through ThreeDEngine.dispose() to release every resource.

Programmatic Creation

const container = document.getElementById('my-3d-host')!;
const shape = new ThreeDShapeElement(container, { geometryType: 'sphere' });

// Access the engine for advanced operations
const engine = shape.getEngine();
engine.updateMaterial('some-id', { ...DEFAULT_MATERIAL_CONFIG, color: '#ff0000' });

// When done
shape.dispose();