Skip to main content
OpenGeometry makes no scene, camera, renderer or controls. Your app owns them. Bodies are THREE.Group objects that you add like any other.

Connect the camera

Tell the kernel which camera draws each frame, and when it moves. Level of detail then follows the camera:
  • observeCamera(renderer, camera) uses the first camera seen per renderer frame.
  • setCameraMotion(true) lets the kernel use coarser meshes while the camera moves. Call it from your controls’ change event.

Draw bodies through your own layers

Large scenes often draw many bodies through one InstancedMesh or BatchedMesh. The kernel must still know which bodies are on screen, because it makes meshes only for displayed bodies.
  1. Hand the drawing to your layer: OpenGeometry.setHostDrawn(bodies, true). Each body’s visible becomes false, so Three.js skips it and everything under it. The kernel keeps the body’s own visibility apart.
  2. Make a group of those bodies: const group = OpenGeometry.hostGroup(bodies).
  3. In the layer’s onBeforeRender, call group.drawn(). It counts every member as displayed for this render pass, at a cost that does not grow with the number of members.
  4. After each body’s geometrychanged event, build your layer from body.surface.geometry and body.surface.matrixWorld.
  5. When a body leaves the layer, call OpenGeometry.setHostDrawn([body], false). Its visible goes back to its own visibility.
  • group.set(bodies) replaces the members. group.dispose() ends the group.
  • For a few bodies, OpenGeometry.markDisplayed(bodies) does the same as group.drawn() without a group.
  • Do not set visible on a host-drawn body. A dispose, a rollback or a reset changes its own visibility instead.
  • markDisplayed skips a body with visible = false that is not host-drawn.

Placement events

Each body dispatches placementchanged when a flush moves it. A layer that copies world matrices listens to it.

Moving a surface mesh yourself

A body’s surface and outline meshes are static: their matrixAutoUpdate is false. If your code writes their position, rotation, quaternion or scale, call updateMatrix() on that mesh after the write. To move a body, use transform.

Free memory

OpenGeometry.releaseIdleGeometry() frees cached display meshes of bodies that do not show them. Call it after a large part of the model leaves the view.
Last modified on November 10, 2026