VERTEXDocsGitHub

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" } }]

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.

Edit this page