THREE.Group with two children:
surface: aTHREE.Meshwith aMeshStandardMaterial. The scene needs a light.outline: aTHREE.LineSegmentswith 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 whenupdateMatrixWorld walks it:
- Drawn: its
surfaceoroutlinerunsonBeforeRender. 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.
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.
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. Setappearance.smoothAngle to change the angle for one body, in degrees from 0 up to but not including 90. 0 keeps every fold line.
Appearance
Passappearance in the options, or call setAppearance later:
Do not change a body’s materials yourself. Use
setAppearance.
