Skip to main content
A body is a THREE.Group with two children:
  • surface: a THREE.Mesh with a MeshStandardMaterial. The scene needs a light.
  • outline: a THREE.LineSegments with the body’s edges.

Rendering asks for geometry

The kernel makes a display mesh only for a body that is displayed. A body is displayed when it is drawn, or when updateMatrixWorld walks it:
  • Drawn: its surface or outline runs onBeforeRender. The new mesh is installed after that render, so the next frame shows it.
  • Walked: scene.updateMatrixWorld() reaches it. The mesh is installed at once.
  • Marked: you call OpenGeometry.markDisplayed(bodies) for bodies that your own layers draw. See Use your Three.js scene.
A body that is neither drawn nor walked for a full render pass is not displayed. It gets no new mesh until it is displayed again. So render in a loop. Or render once, await OpenGeometry.settled(), and render again:
settled resolves when every displayed body has its mesh. failed lists the bodies whose mesh failed, with the error. If nothing was rendered, settled returns at once.

Mesh now

OpenGeometry.flush({ geometry: 'sync' }) meshes every displayed body on the calling thread before it returns. Add bodies to mesh only those. Use it in tests, in Node, or when one edited body must be current before the next frame. See flush.

Level of detail

The kernel picks the mesh detail from the camera. A body that is small on the screen gets a coarser mesh. While the camera moves, the kernel accepts a coarser mesh; when it stops, it refines.
  • OpenGeometry.observeCamera(renderer, camera): tell the kernel which camera draws each frame.
  • OpenGeometry.setCameraMotion(true): tell the kernel that the camera moves, for example from your controls.
  • OpenGeometry.setDisplayDeflection(world): set a fixed deflection in world metres for every body. Call it with no value to go back to the camera.
  • appearance.deflection: set a fixed deflection for one body.
Deflection is the largest distance between the mesh and the exact surface.

Smooth edges

The outline leaves out smooth edges. An edge is smooth when its two faces are tangent-continuous, or when two planes fold by less than the smooth angle. The default smooth angle is 20°. Planar faces average their normals across smooth edges, so a polygon that approximates a curve shades as one curve. Set appearance.smoothAngle to change the angle for one body, in degrees from 0 up to but not including 90. 0 keeps every fold line.

Appearance

Pass appearance in the options, or call setAppearance later: Do not change a body’s materials yourself. Use setAppearance.
Last modified on November 10, 2026