kinescript

Depth on any layer.

3D is drawn by the same Skia renderer as everything else, with no extra dependency. On a GPU, the gl extra draws model layers on OpenGL through a depth buffer, from the same JSON. Scenes that use no depth draw exactly as before.

Camera and depth
Any layer takes z, rotateX and rotateY. A scene camera pans, dollies, orbits and rolls with perspective, follows a target, shakes like a handheld camera and pulls focus with depth of field; fixed layers ignore it, and fog fades far layers.
Stages
A group with "sort": "pixel" shows the nearest of its layers at each pixel, so models and cards pass through each other with a clean edge. With "shadows" its models cast shadows on the floor, the walls and each other.
Lit models
Cubes (rounded with r), spheres, cylinders, cones, capsules, tori and planes, a lathe turned from a profile and a tube along a path, or several merged as parts that animate. repeat draws copies of a model, each placed and coloured by an expression of its number. Materials take shine, metal, rim, toon bands, glow and transparency. Lights come as presets or your own amounts, with up to three more lights and an env to reflect; edges draws outlines and creases.
Textures
An image, a video that plays on the model, or a group of layers drawn on it at each frame's time, wrapped round any shape with repeat and offset.
Extruded text and paths
Letters in any font, shaped as a text layer is so Arabic joins and right-to-left runs read in order, and SVG path data, filled or stroked, pushed out to a depth with an optional bevel.
Model files
.glb, .gltf and .obj with their colours, textures, emission, transparency, metal and roughness, and a soft ground shadow under any model. animation plays a glTF file's clips, skins and morph targets on the layer's clock. Meshopt-compressed files are read as they are, Draco-compressed ones with the draco extra.
Cutaways
cut takes one side off a model, as far as an animated at, and closes the opening with a flat cap; a part inside another shows its own colour on the cut. repeat with spread scatters seeded copies in a disc, ring, box, ball or shell, and a tube runs in depth through points, along a seeded walk or as rays.
Guided tours
use: "tour" turns a list of stops into an explainer: the camera flies to each stop's focus and swings round it while its voice line plays, with a caption card and a note pinned to the part. Each stop lasts as long as its line, and dim washes out the models it does not focus. pin keeps any layer on a point of a turning model. kine docs explainers has a complete scene.

With the gl extra on a GPU, each model draws through a depth buffer, so its crossing parts meet at a clean edge; a cel-shaded test scene of 76,000 triangles drew in 5 to 9 ms a frame instead of 155 to 193 (RTX 5060 Ti). Textured and see-through models draw there too, and so does a stage's shadow map: a frame of the product scene below drew in 100 to 110 ms in 2.3.0 and draws in about 5. A model's moving copies are placed there from one copy's mesh, and a stage's models that follow one another are merged there: a frame of a tour of 24 models drew in 14.5 to 15.0 ms and draws in 7.9 to 8.4. Without the extra, and for exploding models, "edges": "all" and see-through models with edge lines, triangles are sorted by depth in Skia, and crossing parts meet at a stepped seam. Either way, separate layers hide each other per pixel only inside a stage.

Card flip

Each card is a group turned by rotateY, and its two sides hide their backs with "backface": "hidden". Cards two and three start at card-1.in+0.25 and card-2.in+0.25, so the flips are staggered by reference.

0.0 s
  1. bg
  2. title
  3. card-1
  4. card-2
  5. card-3
  6. how
card-flip.json1920 x 1080, 6 s
{  "canvas": {"w": 1920, "h": 1080, "fps": 30, "duration": 6, "bg": "#0a0c10"},  "grade": {"vignette": 0.3},  "camera": {"z": [[0, 260], ["end", 0]], "rotateY": [[0, -18], ["end", 14]], "rotateX": [[0, 12], ["end", 4]]},  "layers": [    {"id": "bg", "type": "shader", "preset": "score", "opacity": 0.5, "fixed": true},    {"id": "title", "type": "text", "text": "Change a line. Flip a card.", "x": "50%", "y": "19%", "size": 80,     "weight": 700, "fixed": true, "at": 0.2, "enter": {"name": "left", "dist": 28, "dur": 0.32}},    {"id": "card-1", "type": "group", "x": "20%", "y": "54%", "at": 0.4, "enter": {"name": "push", "dur": 0.6},     "rotateY": [[0.9, 0], [1.7, 180, "outBack"], [3.9, 180], [4.7, 360, "outBack"]],     "children": [       {"id": "card-1-front", "type": "group", "anchor": "center", "w": 500, "h": 290, "radius": 24,        "fill": "#f2f0e8", "backface": "hidden",        "children": [{"id": "card-1-old", "type": "text", "text": "- \"dur\": 2.5", "font": "IBM Plex Mono",                      "size": 52, "weight": 500, "fill": "#0a0c10"}]},       {"id": "card-1-back", "type": "group", "anchor": "center", "w": 500, "h": 290, "radius": 24,        "fill": "#b9f45d", "rotateY": 180, "backface": "hidden",        "children": [{"id": "card-1-new", "type": "text", "text": "+ \"dur\": 4.5", "font": "IBM Plex Mono",                      "size": 52, "weight": 500, "fill": "#0a0c10"}]}     ]},    {"id": "card-2", "type": "group", "x": "50%", "y": "54%", "at": "card-1.in+0.25",     "enter": {"name": "push", "dur": 0.6},     "rotateY": [[0.9, 0], [1.7, 180, "outBack"], [3.9, 180], [4.7, 360, "outBack"]],     "children": [       {"id": "card-2-front", "type": "group", "anchor": "center", "w": 500, "h": 290, "radius": 24,        "fill": "#f2f0e8", "backface": "hidden",        "children": [{"id": "card-2-old", "type": "text", "text": "- \"text\": \"Q3\"", "font": "IBM Plex Mono",                      "size": 52, "weight": 500, "fill": "#0a0c10"}]},       {"id": "card-2-back", "type": "group", "anchor": "center", "w": 500, "h": 290, "radius": 24,        "fill": "#b9f45d", "rotateY": 180, "backface": "hidden",        "children": [{"id": "card-2-new", "type": "text", "text": "+ \"text\": \"Q4\"", "font": "IBM Plex Mono",                      "size": 52, "weight": 500, "fill": "#0a0c10"}]}     ]},    {"id": "card-3", "type": "group", "x": "80%", "y": "54%", "at": "card-2.in+0.25",     "enter": {"name": "push", "dur": 0.6},     "rotateY": [[0.9, 0], [1.7, 180, "outBack"], [3.9, 180], [4.7, 360, "outBack"]],     "children": [       {"id": "card-3-front", "type": "group", "anchor": "center", "w": 500, "h": 290, "radius": 24,        "fill": "#f2f0e8", "backface": "hidden",        "children": [{"id": "card-3-old", "type": "text", "text": "- \"size\": 64", "font": "IBM Plex Mono",                      "size": 52, "weight": 500, "fill": "#0a0c10"}]},       {"id": "card-3-back", "type": "group", "anchor": "center", "w": 500, "h": 290, "radius": 24,        "fill": "#b9f45d", "rotateY": 180, "backface": "hidden",        "children": [{"id": "card-3-new", "type": "text", "text": "+ \"size\": 96", "font": "IBM Plex Mono",                      "size": 52, "weight": 500, "fill": "#0a0c10"}]}     ]},    {"id": "how", "type": "text", "text": "\"rotateY\": [[0.9, 0], [1.7, 180, \"outBack\"]]   \"backface\": \"hidden\"",     "font": "IBM Plex Mono", "x": "50%", "y": "86%", "size": 32, "weight": 400, "fill": "$muted", "fixed": true,     "at": 1.0, "enter": "fade"}  ]}

Camera dolly

Four planes at z 0, -1600, -3200 and -4800. The camera's z is keyframed to hold at each plane, and each plane ends before the camera reaches it.

0.0 s
  1. bg
  2. render
  3. look
  4. check
  5. write
dolly.json1920 x 1080, 9 s
{  "canvas": {"w": 1920, "h": 1080, "fps": 30, "duration": 9, "bg": "#0a0c10"},  "grade": {"vignette": 0.3},  "camera": {"z": [[0, 500], [1, 0, "outCubic"], [2, 0], [3, -1600], [4, -1600], [5, -3200], [6, -3200], [7, -4800]],             "x": [[0, -50], ["end", 50, "linear"]], "y": [[0, 20], ["end", -20, "linear"]]},  "layers": [    {"id": "bg", "type": "shader", "preset": "score", "opacity": 0.45, "fixed": true},    {"id": "render", "type": "group", "x": "50%", "y": "50%", "z": -4800, "allowOffscreen": true,     "children": [       {"id": "render-frame", "type": "rect", "w": 1500, "h": 820, "radius": 28, "stroke": "#f2f0e84d", "strokeWidth": 4,        "opacity": [[4, 0.4], [5, 1]]},       {"id": "render-z", "type": "text", "text": "\"z\": -4800", "font": "IBM Plex Mono", "x": -700, "y": -360,        "anchor": "topleft", "size": 34, "weight": 500, "fill": "$muted", "opacity": [[6.5, 0], [7, 1]]},       {"id": "render-verb", "type": "text", "text": "Render.", "y": -40, "size": 230, "weight": 700,        "opacity": [[6.5, 0], [7, 1]]},       {"id": "render-cmd", "type": "text", "text": "kine render scene.json", "font": "IBM Plex Mono", "y": 150,        "size": 48, "weight": 500, "fill": "$accent2", "opacity": [[6.5, 0], [7, 1]]}     ]},    {"id": "look", "type": "group", "x": "50%", "y": "50%", "z": -3200, "until": 6.5, "allowOffscreen": true,     "children": [       {"id": "look-frame", "type": "rect", "w": 1500, "h": 820, "radius": 28, "stroke": "#f2f0e84d", "strokeWidth": 4,        "opacity": [[2, 0.4], [3, 1]]},       {"id": "look-z", "type": "text", "text": "\"z\": -3200", "font": "IBM Plex Mono", "x": -700, "y": -360,        "anchor": "topleft", "size": 34, "weight": 500, "fill": "$muted", "opacity": [[4.5, 0], [5, 1], [6, 1], [6.25, 0]]},       {"id": "look-verb", "type": "text", "text": "Look.", "y": -40, "size": 230, "weight": 700,        "opacity": [[4.5, 0], [5, 1], [6, 1], [6.25, 0]]},       {"id": "look-cmd", "type": "text", "text": "kine look scene.json --boxes", "font": "IBM Plex Mono", "y": 150,        "size": 48, "weight": 500, "fill": "$accent2", "opacity": [[4.5, 0], [5, 1], [6, 1], [6.25, 0]]}     ]},    {"id": "check", "type": "group", "x": "50%", "y": "50%", "z": -1600, "until": 4.5, "allowOffscreen": true,     "children": [       {"id": "check-frame", "type": "rect", "w": 1500, "h": 820, "radius": 28, "stroke": "#f2f0e84d", "strokeWidth": 4},       {"id": "check-z", "type": "text", "text": "\"z\": -1600", "font": "IBM Plex Mono", "x": -700, "y": -360,        "anchor": "topleft", "size": 34, "weight": 500, "fill": "$muted", "opacity": [[2.5, 0], [3, 1], [4, 1], [4.25, 0]]},       {"id": "check-verb", "type": "text", "text": "Check.", "y": -40, "size": 230, "weight": 700,        "opacity": [[2.5, 0], [3, 1], [4, 1], [4.25, 0]]},       {"id": "check-cmd", "type": "text", "text": "kine check scene.json", "font": "IBM Plex Mono", "y": 150,        "size": 48, "weight": 500, "fill": "$accent2", "opacity": [[2.5, 0], [3, 1], [4, 1], [4.25, 0]]}     ]},    {"id": "write", "type": "group", "x": "50%", "y": "50%", "z": 0, "until": 2.5, "allowOffscreen": true,     "children": [       {"id": "write-frame", "type": "rect", "w": 1500, "h": 820, "radius": 28, "stroke": "#f2f0e84d", "strokeWidth": 4},       {"id": "write-z", "type": "text", "text": "\"z\": 0", "font": "IBM Plex Mono", "x": -700, "y": -360,        "anchor": "topleft", "size": 34, "weight": 500, "fill": "$muted", "opacity": [[0.2, 0], [0.6, 1], [2, 1], [2.25, 0]]},       {"id": "write-verb", "type": "text", "text": "Write.", "y": -40, "size": 230, "weight": 700,        "opacity": [[0.2, 0], [0.6, 1], [2, 1], [2.25, 0]]},       {"id": "write-cmd", "type": "text", "text": "scene.json", "font": "IBM Plex Mono", "y": 150,        "size": 48, "weight": 500, "fill": "$accent2", "opacity": [[0.2, 0], [0.6, 1], [2, 1], [2.25, 0]]}     ]}  ]}

Lit models

Five primitives on one floor, each showing one material key: shine, metal, toon bands, rim light, and a cone with its own dramatic light. Each one builds in over a soft ground shadow.

0.0 s
  1. light
  2. gloss
  3. gloss-key
  4. steel
  5. steel-key
  6. toon
  7. toon-key
  8. rim
  9. rim-key
  10. drama
  11. drama-key
materials.json1920 x 1080, 6 s
{  "canvas": {"w": 1920, "h": 1080, "fps": 30, "duration": 6, "bg": "#f2f0e8"},  "camera": {"rotateX": 14, "rotateY": [[0, -10], ["end", 10]], "z": [[0, 160], ["end", 0]]},  "light": "studio",  "layers": [    {"id": "light", "type": "text", "text": "\"light\": \"studio\"", "font": "IBM Plex Mono", "x": "50%", "y": "17%",     "size": 40, "weight": 500, "fill": "#4a4f5c", "fixed": true, "at": 0.2, "enter": "fade"},    {"id": "gloss", "type": "model", "shape": "sphere", "r": 125, "x": 330, "y": 560, "detail": "high",     "fill": "$accent", "shine": 0.9, "ground": {"opacity": 0.5, "y": 690}, "enter": {"name": "build", "dur": 1.0}},    {"id": "gloss-key", "type": "text", "text": "\"shine\": 0.9", "font": "IBM Plex Mono", "x": 330, "y": 795,     "size": 32, "weight": 500, "fill": "#0a0c10", "at": 0.6, "enter": "fade"},    {"id": "steel", "type": "model", "shape": "sphere", "r": 125, "x": 645, "y": 560, "detail": "high",     "fill": "#e2e4ea", "metal": 0.6, "shine": 0.9, "ground": {"opacity": 0.5, "y": 690}, "at": 0.15,     "enter": {"name": "build", "dur": 1.0}},    {"id": "steel-key", "type": "text", "text": "\"metal\": 0.6", "font": "IBM Plex Mono", "x": 645, "y": 795,     "size": 32, "weight": 500, "fill": "#0a0c10", "at": 0.75, "enter": "fade"},    {"id": "toon", "type": "model", "shape": "torus", "r": 115, "tube": 46, "x": 960, "y": 560, "detail": "high",     "fill": "$accent2", "bands": 3, "rotateX": [[0, 70], ["end", -20]], "rotateY": [[0, 0], ["end", 90]],     "ground": {"opacity": 0.5, "y": 690}, "at": 0.3, "enter": {"name": "build", "dur": 1.0}},    {"id": "toon-key", "type": "text", "text": "\"bands\": 3", "font": "IBM Plex Mono", "x": 960, "y": 795,     "size": 32, "weight": 500, "fill": "#0a0c10", "at": 0.9, "enter": "fade"},    {"id": "rim", "type": "model", "shape": "cube", "w": 180, "x": 1275, "y": 560, "fill": "#242832", "rim": 1,     "rotateX": -20, "rotateY": [[0, 20], ["end", 200]], "ground": {"opacity": 0.5, "y": 690}, "at": 0.45,     "enter": {"name": "build", "dur": 1.0}},    {"id": "rim-key", "type": "text", "text": "\"rim\": 1", "font": "IBM Plex Mono", "x": 1275, "y": 795,     "size": 32, "weight": 500, "fill": "#0a0c10", "at": 1.05, "enter": "fade"},    {"id": "drama", "type": "model", "shape": "cone", "r": 100, "h": 220, "x": 1580, "y": 570, "fill": "#9299a8",     "light": "dramatic", "rotate": [[0, -8], ["end", 8]], "ground": {"opacity": 0.5, "y": 690}, "at": 0.6,     "enter": {"name": "build", "dur": 1.0}},    {"id": "drama-key", "type": "text", "text": "\"light\": \"dramatic\"", "font": "IBM Plex Mono", "x": 1580, "y": 795,     "size": 32, "weight": 500, "fill": "#0a0c10", "at": 1.2, "enter": "fade"}  ]}

Extruded title

The brand mark as a stroked SVG path pushed out to 56 px with a sphere for the cue dot, merged as parts of one model, and the wordmark as extruded text with a 3 px bevel.

0.0 s
  1. mark
  2. word
{  "canvas": {"w": 1920, "h": 1080, "fps": 30, "duration": 5, "bg": "#0a0c10"},  "camera": {"rotateY": [[0, 8], ["end", -6]], "rotateX": [[0, -4], ["end", 2]]},  "light": "studio",  "layers": [    {"id": "mark", "type": "model", "x": "50%", "y": "36%",     "rotateY": [[0, -70], [2.2, 0, "outCubic"]], "rotateX": [[0, 25], [2.2, 0, "outCubic"]],     "enter": {"name": "build", "dur": 1.2},     "parts": [       {"shape": "path", "d": "M52 36L52 164M150 36C117 36 117 100 84 100C117 100 117 164 150 164",        "strokeWidth": 18, "h": 380, "depth": 56, "bevel": 4, "fill": "#f2f0e8", "shine": 0.5},       {"shape": "sphere", "r": 44, "x": -44, "z": 74, "fill": "$accent", "shine": 0.8}     ]},    {"id": "word", "type": "model", "shape": "text", "text": "kinescript", "x": "50%", "y": "77%", "size": 190,     "weight": 700, "letterSpacing": -4, "depth": 46, "bevel": 3, "fill": "#f2f0e8", "shine": 0.5, "at": 0.6,     "rotateX": [[0, 70], [2, 0, "outCubic"]], "enter": {"name": "build", "dur": 1.2}}  ]}

A glTF model

A rocket read from a .glb file with 15,264 triangles and its own colours. It builds in from the bottom and turns over its ground shadow. examples/make_media.py writes the file.

0.0 s
  1. rocket
  2. label
{  "canvas": {"w": 1920, "h": 1080, "fps": 30, "duration": 6, "bg": "#f2f0e8"},  "camera": {"rotateX": 16, "rotateY": [[0, -10], ["end", 10]]},  "light": "studio",  "layers": [    {"id": "rocket", "type": "model", "src": "media/rocket.glb", "x": "50%", "y": "46%", "h": 600,     "rotateY": [[0, -30], ["end", 330]], "rotate": [[0, 0], [3, 5, "inOutSine"], ["end", 0, "inOutSine"]],     "ground": {"opacity": 0.6}, "enter": {"name": "build", "dur": 1.6}},    {"id": "label", "type": "text", "text": "media/rocket.glb", "x": "50%", "y": "92%", "size": 34, "weight": 500,     "fill": "#0a0c10", "fixed": true, "at": 1.2, "enter": "fade"}  ]}

Product turntable

A can read from a .glb file, its label a texture inside the file, turns on a table in a stage. "shadows" puts its shadow on the table, env gives the steel lid something to reflect, and aperture with "focus": 110, the can's front, keeps its label sharp while two more cans blur behind it. examples/make_media.py writes the file.

0.0 s
  1. stage
  2. title
{  "canvas": {"w": 1920, "h": 1080, "fps": 30, "duration": 6, "bg": {"radial": [0.5, 0.3], "stops": ["#2a2e38", "#0b0c10"]}},  "camera": {"rotateX": 12, "y": -20, "aperture": 22, "focus": 110},  "light": {"preset": "studio", "follow": "world", "azimuth": -40, "elevation": 42},  "env": "studio",  "layers": [    {"id": "stage", "type": "group", "x": "50%", "y": "50%", "sort": "pixel", "shadows": {"opacity": 0.5, "soft": 4},     "children": [      {"id": "floor", "type": "rect", "y": 261, "z": -600, "w": 4200, "h": 2400, "rotateX": 90, "fill": "#1d2129"},      {"id": "turntable", "type": "model", "shape": "cylinder", "r": 300, "h": 24, "y": 249, "fill": "#e8e2d4",       "shine": 0.25, "rotateY": [[0, 0], ["end", 300]]},      {"id": "can", "type": "model", "src": "media/can.glb", "h": 470, "rotateY": [[0, -30], ["end", 270]]},      {"id": "left", "type": "model", "src": "media/can.glb", "h": 470, "x": -760, "y": 26, "z": -1300, "rotateY": 40},      {"id": "right", "type": "model", "src": "media/can.glb", "h": 470, "x": 820, "y": 26, "z": -1600, "rotateY": -70}]},    {"id": "title", "type": "text", "text": "one glTF file, its label a texture, turning on a table",     "x": "50%", "y": "92%", "size": 34, "weight": 400, "fill": "$muted", "fixed": true, "at": 0.4, "enter": "fade"}  ]}