3D
Vertex 3D stays vector-native: meshes are small JSON documents, projected every frame through a perspective camera into flat-shaded vector polygons. So 3D works in every renderer (WebGL2 draws all faces in one batched call; Canvas2D, SVG frames and PNG screenshots work too), in replays, rewinds and over the network.
"space": {
"camera": { "x": 0, "y": -70, "z": -160, "yaw": 0, "pitch": 0.3, "fov": 65, "near": 2, "far": 1600 },
"light": [0.5, 1, 0.3], "ambient": 0.45,
"fog": { "color": "#9ec4e8", "near": 300, "far": 1500 }
},
"shapes": {
"crate": { "mesh": { "v": [[-10,-10,-10], [10,-10,-10], ...], "f": [[0,1,2,3], ...] }, "fill": "#c96" },
"logo": { "extrude": { "d": "M0 0 L40 0 L20 30 Z", "depth": 8 }, "fill": "#7df" }
},
"entities": [ { "shape": "crate", "x": 0, "y": 0, "z": 100, "ry": 0.5, "vry": 1 } ],
"systems": ["rules", "motion", "motion3d", { "collide3d": [["player", "gem"]] }, { "chase": { "id": "player" } }]
- Coordinates: x right, y down (so "up" is negative y), z forward. Rotations
rx,ry(yaw),rz; velocitiesvz,vrx,vry,vrz(integrated bymotion3d). - Meshes:
vvertices,ffaces (any polygon, concave is fine), optional per-facecolors. Builders in JS:box,sphere,cylinder,plane(w, d, nx, nz, heightFn),extrude(d, depth). - Faces are back-face culled, clipped at the near plane, sorted back to front and flat-shaded.
shade: falsedisables lighting,doubleSided: truekeeps back faces. chasecamera follows an entity's yaw; or movespace.camerafrom rules.collide3duses oriented boxes from each mesh’s local bounds and emits ordinaryhitevents. Boxes follow rotation and scale; concave meshes still use their enclosing box.- 2D entities and the HUD draw on top of the 3D scene (use them for UI).
projectPoint(world, x, y, z)gives screen coordinates for labels over 3D objects.
Limits: painter's sorting is per face, so intersecting or very large faces can sort wrongly (split big faces, e.g. use plane with more subdivisions); no textures (by design: color per face); lighting is flat (one directional light + ambient + fog). 3D uses trig, so it is an "extended" feature: deterministic within an implementation, visually identical across them (SPEC.md §8).
See examples/skyline/skyline.json.