@algorisys/tinyfly 0.94.0 → 0.97.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +6 -6
  2. package/docs/acting.md +170 -0
  3. package/docs/api-reference.md +3 -1
  4. package/docs/editor-guide.md +1 -1
  5. package/docs/examples.md +1 -1
  6. package/docs/getting-started.md +1 -1
  7. package/docs/gsap-compat.md +1 -1
  8. package/docs/llm-guide.md +41 -2
  9. package/docs/maps.md +2 -2
  10. package/docs/props.md +202 -0
  11. package/docs/scene-3d.md +141 -0
  12. package/docs/teaching.md +1 -1
  13. package/lib/addons/characters.js +6188 -2261
  14. package/lib/addons/scene-3d.js +140 -138
  15. package/lib/browser/tinyfly-scene-3d.iife.js +1 -1
  16. package/lib/browser/tinyfly.iife.js +17 -9
  17. package/lib/browser/tinyfly.js +8077 -4095
  18. package/lib/browser/tinyfly.umd.js +17 -9
  19. package/lib/engine/tinyfly-engine.js +612 -600
  20. package/lib/engine/tinyfly-engine.umd.cjs +2 -2
  21. package/lib/types/characters/acting/index.d.ts +1 -0
  22. package/lib/types/characters/acting/surface-script.d.ts +92 -0
  23. package/lib/types/characters/capabilities.d.ts +22 -0
  24. package/lib/types/characters/character-script-3d.d.ts +80 -0
  25. package/lib/types/characters/character.d.ts +19 -0
  26. package/lib/types/characters/chart.d.ts +108 -0
  27. package/lib/types/characters/code-panel.d.ts +21 -46
  28. package/lib/types/characters/ground-path.d.ts +32 -0
  29. package/lib/types/characters/index.d.ts +6 -0
  30. package/lib/types/characters/props/clip.d.ts +5 -0
  31. package/lib/types/characters/props/draw.d.ts +60 -0
  32. package/lib/types/characters/props/effects.d.ts +12 -0
  33. package/lib/types/characters/props/families/aircraft.d.ts +37 -0
  34. package/lib/types/characters/props/families/animals.d.ts +156 -0
  35. package/lib/types/characters/props/families/birds.d.ts +86 -0
  36. package/lib/types/characters/props/families/environment.d.ts +71 -0
  37. package/lib/types/characters/props/families/vehicle.d.ts +129 -0
  38. package/lib/types/characters/props/hidden.d.ts +49 -0
  39. package/lib/types/characters/props/index.d.ts +24 -0
  40. package/lib/types/characters/props/mesh-3d.d.ts +24 -0
  41. package/lib/types/characters/props/presets.d.ts +34 -0
  42. package/lib/types/characters/props/prop-surface.d.ts +63 -0
  43. package/lib/types/characters/props/ride-3d.d.ts +71 -0
  44. package/lib/types/characters/props/ride.d.ts +79 -0
  45. package/lib/types/characters/props/rig.d.ts +224 -0
  46. package/lib/types/characters/props/scene-objects.d.ts +2 -0
  47. package/lib/types/characters/props/script-3d.d.ts +85 -0
  48. package/lib/types/characters/props/script.d.ts +145 -0
  49. package/lib/types/characters/props/shapes.d.ts +96 -0
  50. package/lib/types/characters/props/slice.d.ts +66 -0
  51. package/lib/types/characters/props/target.d.ts +129 -0
  52. package/lib/types/characters/surface/edit-log.d.ts +47 -0
  53. package/lib/types/characters/surface/index.d.ts +11 -0
  54. package/lib/types/characters/surface/pieces.d.ts +61 -0
  55. package/lib/types/characters/surface/ride.d.ts +31 -0
  56. package/lib/types/characters/surface/surface-box.d.ts +18 -0
  57. package/lib/types/characters/surface/surface.d.ts +79 -0
  58. package/lib/types/characters/whiteboard.d.ts +131 -0
  59. package/lib/types/engine/authoring/index.d.ts +1 -0
  60. package/lib/types/engine/authoring/spring-follow.d.ts +25 -0
  61. package/lib/types/scene-3d/object-kind.d.ts +4 -1
  62. package/lib/types/scene-3d/scene-types.d.ts +41 -1
  63. package/llms-full.txt +699 -11
  64. package/llms.txt +28 -27
  65. package/package.json +1 -1
  66. package/skills/tinyfly/SKILL.md +37 -9
package/llms-full.txt CHANGED
@@ -204,7 +204,7 @@ with a GSAP-style call (durations are in seconds here):
204
204
  ```html
205
205
  <div class="box" style="width:60px;height:60px;background:#4a9eff"></div>
206
206
 
207
- <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.94.0/cdn/tinyfly.iife.js"></script>
207
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.97.0/cdn/tinyfly.iife.js"></script>
208
208
  <script>
209
209
  tinyfly.to('.box', { x: 200, duration: 1 })
210
210
  </script>
@@ -412,7 +412,7 @@ Without a build step, the all-in-one bundle exposes the same functions on a
412
412
  global — `tinyfly.to()`, `tinyfly.timeline()` and so on:
413
413
 
414
414
  ```html
415
- <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.94.0/cdn/tinyfly.iife.js"></script>
415
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.97.0/cdn/tinyfly.iife.js"></script>
416
416
  <script>
417
417
  tinyfly.to('.box', { x: 200, duration: 1 })
418
418
  </script>
@@ -2278,7 +2278,7 @@ For simple website embedding without a build system.
2278
2278
  </html>
2279
2279
  ```
2280
2280
 
2281
- Build the player with `npm run build:player` to generate `lib/player/tinyfly-player.iife.js`, or load it from the CDN: `https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.94.0/cdn/tinyfly-player.iife.js`.
2281
+ Build the player with `npm run build:player` to generate `lib/player/tinyfly-player.iife.js`, or load it from the CDN: `https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.97.0/cdn/tinyfly-player.iife.js`.
2282
2282
 
2283
2283
  ---
2284
2284
 
@@ -3011,11 +3011,13 @@ new WebGL2Renderer(gl, { overlay? }) // @algorisys/tinyf
3011
3011
  loadScene3D(scene, { kinds: [characterObjects] }) // object kinds beyond the built-ins: ObjectKind { kind, validate?, prepare?, resolve }
3012
3012
  // from @algorisys/tinyfly/characters:
3013
3013
  characterObjects // the `character` object kind (pen or solid look)
3014
+ propObjects // the `prop` object kind: { kind: 'prop', prop: 'car', options?, values?, look?, style? }
3015
+ propPreset(name, options?) / PROP_PRESETS // a prop preset by name (did-you-mean on a wrong one)
3014
3016
  drawCharacterInView(ctx, character, pose, projection, { height, time? }) / characterJointsInView(…)
3015
3017
  skeletonInView(plan, pose, { height }, projection) / stagePlanSpace(plan, pose, { height }) / solvePlanSpace(plan, pose, height)
3016
3018
  ```
3017
3019
 
3018
- Types: `Scene3D`, `Object3D` (`group`, `mesh`, `camera`, `light`, `character`), `Geometry3D`,
3020
+ Types: `Scene3D`, `Object3D` (`group`, `mesh`, `camera`, `light`, `character`, `prop`), `Geometry3D`,
3019
3021
  `Material3D`, `ResolvedScene3D`, `DrawTriangle`. Tracks address objects as
3020
3022
  `<sceneId>/<objectId>`; see [3D Scenes](scene-3d.md) for the properties.
3021
3023
 
@@ -6464,7 +6466,7 @@ The dialog shows the generated HTML/JavaScript code with a **Copy Code** button.
6464
6466
  **Steps to embed:**
6465
6467
  1. Build the player: `npm run build:player`
6466
6468
  2. Copy `lib/player/tinyfly-player.iife.js` to your project (or load
6467
- `https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.94.0/cdn/tinyfly-player.iife.js`
6469
+ `https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.97.0/cdn/tinyfly-player.iife.js`
6468
6470
  instead; see [Deployment](DEPLOYMENT.md))
6469
6471
  3. Copy the generated code into your HTML
6470
6472
  4. Adjust the script `src` path if needed
@@ -7334,6 +7336,213 @@ Both are safe to call twice.
7334
7336
 
7335
7337
  ---
7336
7338
 
7339
+ <!-- docs/props.md -->
7340
+
7341
+ # Props: Everyday Objects with Behaviours
7342
+
7343
+ Stories need a world: cars and buses, bikes and tractors, trees and houses,
7344
+ helicopters and planes. In tinyfly these are **props**: objects that act, the
7345
+ way the figures do, and that can be seen from any side.
7346
+
7347
+ ```js
7348
+ import { car, propTarget, propScript, drawProp, drawPropEffects } from '@algorisys/tinyfly/characters'
7349
+
7350
+ const prop = car()
7351
+ const target = propTarget({ x: 200, y: 300, prop, scale: 52, values: { turn: 1 }, look: 'pencil' })
7352
+ const script = propScript('car', prop, [
7353
+ { do: 'honk' },
7354
+ { do: 'turn', toward: 'viewer' },
7355
+ { do: 'turn', toward: 'right' },
7356
+ { do: 'drive', to: 480 },
7357
+ { do: 'bump' },
7358
+ { do: 'brake', to: 620 },
7359
+ ], { from: 200, ground: 300, scale: 52, start: { turn: 1 }, exaggeration: 1.5 })
7360
+
7361
+ // each frame:
7362
+ drawProp(ctx, target, { time, state }, 'car')
7363
+ drawPropEffects(ctx, script.effects, time)
7364
+ ```
7365
+
7366
+ ## What a prop is
7367
+
7368
+ A prop is a **3D rig of simple parts on pivots**: boxes, cylinders, ellipsoids,
7369
+ side profiles made solid (`extrude`), flat panels and tubes. Named **controls**
7370
+ move the parts (`wheelSpin` turns the wheels, `door` swings the doors), and
7371
+ **anchors** mark where other things attach (`seat`, `door`, `chimney`).
7372
+
7373
+ It is seen through the same kind of view as the v2 character, so it **turns
7374
+ toward the camera**:
7375
+
7376
+ - `turn` 0 faces the viewer, 1 screen-right, 2 away, 3 (or −1) screen-left,
7377
+ with every angle in between drawn in 3D.
7378
+ - `tilt` sets how far the camera looks down on it (12° gives the ¾ look).
7379
+
7380
+ It is drawn with the characters' pens, so `look: 'clean' | 'pencil' |
7381
+ 'silhouette'` match the figures beside it. Each part has its own pencil seed,
7382
+ so lines don't jump as parts change drawing order while turning. Faces are
7383
+ shaded by how they face the light, outlines follow the silhouette and the
7384
+ creases, and a **contact shadow** keeps it on the ground. The shadow shrinks
7385
+ as the prop lifts.
7386
+
7387
+ Every prop has these common controls (plus its own):
7388
+
7389
+ | Control | Unit | What it does |
7390
+ |---|---|---|
7391
+ | `turn` | quarter turns | which way it faces |
7392
+ | `tilt` | degrees | how far the camera looks down on it |
7393
+ | `pitch` | degrees | nose up (+) or down (−) |
7394
+ | `roll` | degrees | tipped onto a side |
7395
+ | `squash` | factor | squash and stretch about the ground, keeping volume |
7396
+ | `lift` | metres | off the ground |
7397
+ | `lean` | shear | the top sheared forward (speed) or back (drag) |
7398
+ | `size` | factor | its size: 0 gone, 1 as built |
7399
+
7400
+ `describeTarget(target)` lists them all with the prop's own controls and its
7401
+ actions; `checkTracks` checks tracks against them.
7402
+
7403
+ ## Behaviours and the 12 principles
7404
+
7405
+ `propScript(id, prop, beats, options)` compiles beats into tracks through the
7406
+ same acting pass the figures use. Families write their actions as key poses of
7407
+ the controls, and the pass adds the rest. The principles, and where they live:
7408
+
7409
+ | Principle | In props |
7410
+ |---|---|
7411
+ | Squash and stretch | `squash` (volume-preserving): bumps, landings, pops, honks |
7412
+ | Anticipation | a drive rocks back and squats before it lunges; a helicopter's skids squash as it spools up |
7413
+ | Staging, solid drawing | `turn` and `tilt`: any view, drawn in 3D |
7414
+ | Straight ahead and pose to pose | keyed beats, plus procedural motion (gusts, hovering bob) |
7415
+ | Follow-through, overlapping action | the acting rig's depths (the canopy trails the trunk); `springFollow` (a car's antenna trails on a spring) |
7416
+ | Slow in and slow out | eases, and the acting style |
7417
+ | Arcs | lift curves, flight paths, a plane's loop |
7418
+ | Secondary action | effects: dust, exhaust, skid marks, honk lines, leaves, smoke |
7419
+ | Timing | acting styles (`full`, `snappy`, `limited`), drawing on twos |
7420
+ | Exaggeration | `exaggeration`: 0.5 restrained, 1 as designed, 2 a cartoon |
7421
+ | Appeal | the families' design |
7422
+
7423
+ Options:
7424
+ - `from` / `ground`: where its middle was placed (its `x`/`y` tracks are offsets).
7425
+ - `scale`: px per metre, as its target draws it.
7426
+ - `style`: an acting style (default `snappy`).
7427
+ - `exaggeration`: as above.
7428
+ - `start`: its starting control values.
7429
+
7430
+ The result gives `tracks`, `beats` (with `contact` / `release` times, as figure
7431
+ beats do) and `effects` (cues for `drawPropEffects`).
7432
+
7433
+ Beats have the fields `do`, `at`, `for`, `to`, `toward`, `speed`, `open`, `on`,
7434
+ `height` and `wind`. `checkPropBeats(beats, prop)` reports wrong names with the
7435
+ one probably meant, and `propScript` throws on them.
7436
+
7437
+ **Every prop can:**
7438
+ - `hold`
7439
+ - `turn` (`toward`: viewer, right, away, left, or a number)
7440
+ - `pop`: spring into being, stretched, with overshoot
7441
+ - `vanish`
7442
+
7443
+ ## The families
7444
+
7445
+ | Preset | Actions |
7446
+ |---|---|
7447
+ | `car()`, `truck()`, `bus()`, `tractor()`, `cart()`, `trainCar()`, `bike()`, `motorbike()` | `drive` (`to`), `brake` (`to`, a skid with locked wheels), `bump`, `honk`, `door` (`open`), `lights` (`on`) — doors and lights where it has them |
7448
+ | `tree()` | `sway` (`wind`, `for`), `shake`, `shedLeaves` |
7449
+ | `house()` | `door` (`open`), `lights` (`on`), `smoke` (`for`, runs in the background), `shake` |
7450
+ | `helicopter()` | `takeOff` (`height`), `fly` (`to`, `height`), `hover`, `land` |
7451
+ | `airplane()` | `takeOff` (`to`, `height`), `fly` (`to`, `height`), `loop`, `land` (`to`) |
7452
+ | `horse()` | `walk`, `trot`, `canter`, `gallop` (`to`), `rear`, `buck`, `neigh`, `graze`, `sit`, `jump`, `nod`, `swish` |
7453
+ | `dog()` | `walk`, `trot`, `run` (`to`), `bark`, `wag`, `sniff`, `sit`, `jump`, `nod`, `swish` |
7454
+ | `cat()` | `walk`, `trot`, `run` (`to`), `meow`, `arch`, `pounce` (`to`), `sit`, `jump`, `nod`, `swish` |
7455
+ | `cow()` | `walk`, `trot` (`to`), `moo`, `graze`, `sit`, `jump`, `nod`, `swish` |
7456
+ | `songbird()`, `crow()` | `hop`, `walk` (`to`), `peck` (`for`), `flap` (`for`), `fly` (`to`, `height`), `land` (`height`, `to`), `tweet` / `caw` |
7457
+ | `chicken()` | `walk` (`to`), `peck`, `flap`, `flutter`, `cluck` (it cannot fly) |
7458
+
7459
+ **Line art.** `propTarget({ …, style: 'stick' })` (or `drawSolvedProp(…, { style: 'stick' })`)
7460
+ draws a prop as line art to go with stick figures: tubes (legs, necks, tails,
7461
+ frames) as single even strokes, other shapes outlined and filled with the
7462
+ paper colour (`paper`), dark details kept dark. Both looks work with it.
7463
+
7464
+ **Animals.** `quadruped(spec)` builds a four-legged animal from proportions;
7465
+ `horse()`, `dog()`, `cat()` and `cow()` are presets. A horse is a prop too: a barrel body, neck, head, four jointed
7466
+ legs and a tail. A rig's `derive` works its legs out from its gait (`gait`: 0
7467
+ walk, 1 trot, 2 canter, 3 gallop) and the phase of its stride (`walk`), each
7468
+ gait with its own footfall pattern (four beats; diagonal pairs; three beats
7469
+ with a rock; the gallop). The phase is keyed with the distance, so the hooves
7470
+ keep pace with the ground. Rearing pitches it up about its hind hooves; its
7471
+ tail trails on a spring.
7472
+
7473
+ **Birds.** `bird(spec)` builds one from proportions; `songbird()`, `crow()` and
7474
+ `chicken()` are presets. Its wings fold back along the body at rest and open
7475
+ out with `spread`. They beat from the shoulders: `flap` raises or lowers them,
7476
+ and while `flapping` is on, the rig's `derive` beats them from a phase,
7477
+ `wingbeat`, keyed steadily so the wings keep their rhythm (a songbird nine beats
7478
+ a second, a crow four). Its head pecks from a neck joint (`peck`; a chicken's
7479
+ neck stretches down to reach), and it walks with its head bobbing or hops.
7480
+ `fly` takes off with a crouch and a leap (no crouch if it is already in the
7481
+ air) and flies to `height` metres; `land` comes down to the ground or to a
7482
+ perch (`height`). Perch it with anchors:
7483
+
7484
+ ```js
7485
+ const branch = propAt(treeTarget, { time: 0 }, 'tree').anchor('branch')
7486
+ const perch = (GROUND - branch.y) / birdScale // metres above the ground
7487
+ propScript('robin', songbird(), [
7488
+ { do: 'fly', to: 380, height: 0.25 }, { do: 'land' }, { do: 'hop', to: 410 }, { do: 'peck' },
7489
+ { do: 'fly', to: branch.x, height: perch }, { do: 'land', height: perch }, { do: 'tweet' },
7490
+ ], { from: branch.x, ground: GROUND, scale: birdScale, start: { turn: 1, lift: perch } })
7491
+ ```
7492
+
7493
+ Wheels **roll exactly the distance driven**: `wheelSpin` is keyed in step with
7494
+ the motion, and wheels of different sizes (a tractor's) turn at their own
7495
+ rates. Rotors and propellers spin from `rotor`, keyed exactly, and blur into a
7496
+ disc at speed.
7497
+
7498
+ Make your own from the family generators: `vehicle(spec)` takes:
7499
+ - a body side profile and a width
7500
+ - a glass cabin with pillars
7501
+ - wheels (any radius; `side: 0` for a bike's middle line; `style: 'spoked'`)
7502
+ - doors, lights, side windows, frame tubes, an antenna, a seat and extra parts
7503
+
7504
+ `tree(spec)` and `house(spec)` take sizes and colours.
7505
+
7506
+ ## Figures with props
7507
+
7508
+ - **Riding.** `propRide({ prop, propId, propTracks, anchor: 'seat', figure, figureId, start, end, offset })`
7509
+ writes a figure's `x`/`y` (and `turn`/`facing`) so it is carried at an
7510
+ anchor and turns with the prop. `spliceTracks(heroTracks, ride, { from, to })`
7511
+ puts that into the figure's script. Pass a rider to `drawProp(…, { rider })`
7512
+ and it is drawn between the prop's far and near parts: a driver behind the
7513
+ windscreen, a figure in a doorway behind a door until it opens.
7514
+ - **Towing.** `propTow({ leader, leaderId, leaderTracks, hitch: 'hitch', towed, towedId, anchor: 'shafts', start, end })`
7515
+ makes a prop follow another: a cart behind a horse turns with it, keeps its
7516
+ shaft tips on the horse's hitch, and rolls its wheels the distance it covers.
7517
+ - **Reaching.** Figure beats aim at anchors:
7518
+ `propAt(target, frame, id).anchor('door')` gives the scene point for a
7519
+ `put`, `grab` or `push`.
7520
+
7521
+ See the gallery cards **Road Trip**, **Windy Day**, **Helicopter**,
7522
+ **Traffic**, **Horse & Cart**, **Farmyard**, **Birds** and **3D Scene: Village**.
7523
+
7524
+ ## In 3D scenes
7525
+
7526
+ Props stand in `@algorisys/tinyfly/scene-3d` scenes too:
7527
+ `{ kind: 'prop', prop: 'car', position, rotation, values }` with
7528
+ `loadScene3D(scene, { kinds: [characterObjects, propObjects] })`. The scene's
7529
+ camera sees them in perspective from anywhere, drawn with the same pens; each
7530
+ prop is drawn a column at a time, so figures walking round a bus or a house
7531
+ sort rightly against it. A part's `layer` says which of two parts that sit
7532
+ into each other is drawn over in 3D (a cabin over a car's body).
7533
+ `propScript3D(id, prop, beats, { scene, position, heading })` scripts them in
7534
+ world metres: `{ do: 'drive', to: [x, z] }`, `{ do: 'walk', through: [[x, z], …] }`,
7535
+ `{ do: 'fly', to, height }`, `{ do: 'face', toward }`, and their actions,
7536
+ with wheels and strides keyed with the distance (from each prop's `moves`).
7537
+ `propPreset(name, options)` makes a preset by name. See
7538
+ [3D Scenes](scene-3d.md#props) and the gallery card **3D Scene: Village**.
7539
+
7540
+ ## Not yet
7541
+
7542
+ - Pedalling and steering poses for riders
7543
+
7544
+ ---
7545
+
7337
7546
  <!-- docs/llm-guide.md -->
7338
7547
 
7339
7548
  # Building Animations with an LLM
@@ -7356,14 +7565,45 @@ npx @algorisys/tinyfly capabilities --json # the same as data
7356
7565
  It lists the easings, track kinds, every property each canvas shape can
7357
7566
  animate (with units and ranges), the stick figure's joints, poses,
7358
7567
  expressions, gags, gaits, beat actions, dances, flips and hand shapes, the v2
7359
- character's poses, the code panel's languages, anchors and edits, camera
7360
- shots and the teaching helpers. It is generated from the code, so it can't
7568
+ character's poses, the code panel's languages, every surface's anchors and
7569
+ edits (code panel, whiteboard, chart), camera shots and the teaching
7570
+ helpers. It is generated from the code, so it can't
7361
7571
  fall behind: **a name in it is accepted, and a name not in it is rejected.**
7362
7572
  It is also the last part of `llms-full.txt`.
7363
7573
 
7364
7574
  From code, the same catalog is `capabilities()` (and `capabilitiesMarkdown()`)
7365
7575
  in `@algorisys/tinyfly/characters`.
7366
7576
 
7577
+ ## Props
7578
+
7579
+ For objects in a story (vehicles, trees, houses, aircraft, animals, birds),
7580
+ use the presets (`car()`, `tree()`, `helicopter()`, `dog()`, `crow()`…) with
7581
+ `propTarget` and `propScript`; the catalog lists each preset's actions,
7582
+ controls and anchors, and `checkPropBeats` checks prop beats. `style: 'stick'`
7583
+ draws any prop as line art to go with stick figures. A bird's `lift` is in
7584
+ metres: to perch it on a branch or a roof, work the height out from that
7585
+ prop's anchor (`propAt(tree, frame, 'tree').anchor('branch')`). In a 3D
7586
+ scene a prop is an object, `{ kind: 'prop', prop: 'car', position, rotation: [0, 90, 0] }` (`rotateY` is a track, not a field),
7587
+ loaded with `kinds: [characterObjects, propObjects]`; its controls are tracks
7588
+ on the object. Script it in world metres with `propScript3D` (`to: [x, z]`,
7589
+ `through: [[x, z], …]`, `face`), not with `propScript`, whose `to` is screen px.
7590
+ Characters in a 3D scene walk the same way with `characterScript3D`
7591
+ (`{ do: 'walk', to: [x, z] }`, `pose`, `gag`, `face`, `place`); a rider is
7592
+ seated with `propRide3D` and spliced into its script with `spliceTracks`. See `docs/props.md`.
7593
+
7594
+ ## Surfaces
7595
+
7596
+ Code panels (`codePanel()`), whiteboards (`whiteboard()`), charts
7597
+ (`chart()`) and props (`propSurface(propTarget(…))`) are surfaces: their places have names (`line:7`,
7598
+ `token:4:Println`, `text:eq`, `term:eq:+ 4`, `bar:q4`) and their edits are
7599
+ called by name (`surface.edit('highlight', 'line:4', { at })`). Write a scene
7600
+ on one with `surfaceScript()`: beats aim at `{ surface, anchor }` and say what
7601
+ the surface does in answer with `then`, at a moment of the beat (`at:
7602
+ 'contact'`, `'release'`…). A whiteboard's texts and marks and a chart's data
7603
+ are declared up front, each with an id the places use. The catalog lists each
7604
+ surface's places and edits. See "A whole scene as data", "Whiteboards" and
7605
+ "Charts" in `docs/acting.md`.
7606
+
7367
7607
  ## Your own behaviours
7368
7608
 
7369
7609
  Write new actions with `defineAction()` (from beats, or as timed pose steps),
@@ -7430,6 +7670,9 @@ Fix, render again.
7430
7670
  positions. A beat script's `to` is a scene x, and its tracks are offsets
7431
7671
  from `from` (and `ground` for y).
7432
7672
  - **Scene y grows downward.** A floor higher up the screen has a smaller y.
7673
+ - **Walk figures in front of props, not through them.** A prop stands on its
7674
+ middle; its front comes forward of that. Use its front line as the
7675
+ figure's `ground` (a house's `anchor:doorstep`).
7433
7676
  - **Angles are degrees.** Stick-figure arms: 0 hangs down, 90 straight out,
7434
7677
  180 straight up; in profile the left arm's forward is negative.
7435
7678
  - **Aim beats at anchors, not guessed numbers**: `code.line(7)`,
@@ -7438,6 +7681,11 @@ Fix, render again.
7438
7681
  `result.beats[i].contact` (and `release`): wipe the line, fling the word or
7439
7682
  type the text at those times.
7440
7683
  - **Record panel edits before `code.ride()`**, which reads the moves they make.
7684
+ - **Or write it all as data with `surfaceScript`**: name places
7685
+ (`target: { surface: 'code', anchor: 'token:3:var' }`) and put the surface's
7686
+ answer on the beat (`then: { surface: 'code', edit: 'fling', anchor: 'token:3:var', at: 'release' }`).
7687
+ A cue's `at` is a moment name (`start`, `contact`, `release`, `end`), never
7688
+ ms. It records the edits and rides the lines for you, in beat order.
7441
7689
 
7442
7690
  ## Set up your assistant
7443
7691
 
@@ -7499,7 +7747,7 @@ path for all of that:
7499
7747
  </figure>
7500
7748
 
7501
7749
  <!-- once, anywhere on the page (a site-wide footer is fine) -->
7502
- <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.94.0/cdn/tinyfly-embed.iife.js" data-tinyfly-auto></script>
7750
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.97.0/cdn/tinyfly-embed.iife.js" data-tinyfly-auto></script>
7503
7751
  ```
7504
7752
 
7505
7753
  Every `[data-tinyfly-embed]` mounts when the page is ready, with no per-post
@@ -8574,8 +8822,8 @@ On a page with no build step, load the maps add-on after the browser bundle; it
8574
8822
  adds to the same `tinyfly` global:
8575
8823
 
8576
8824
  ```html
8577
- <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.94.0/cdn/tinyfly.iife.js"></script>
8578
- <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.94.0/cdn/tinyfly-maps.iife.js"></script>
8825
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.97.0/cdn/tinyfly.iife.js"></script>
8826
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.97.0/cdn/tinyfly-maps.iife.js"></script>
8579
8827
  ```
8580
8828
 
8581
8829
  It is a separate script because the offline world map it carries adds about
@@ -9098,6 +9346,11 @@ one). Scripts are deterministic, so two personas can be timed against each
9098
9346
  other by reading one's `beats` before writing the other's (the **Code Review**
9099
9347
  example does).
9100
9348
 
9349
+ ## Props
9350
+
9351
+ Vehicles, trees, houses and aircraft act from beats through the same acting
9352
+ pass, and figures can ride them: see [Props](props.md).
9353
+
9101
9354
  ## Acting on code
9102
9355
 
9103
9356
  `codePanel()` makes a code listing a scene object. Its layout is plain
@@ -9214,6 +9467,171 @@ writes them out as one track per prop (`line.N.highlight`, `line.N.strike`,
9214
9467
  keyword lists for Go, Rust, C#, JavaScript, TypeScript and Python (strings,
9215
9468
  numbers and line comments too); `plain` leaves the text uncoloured.
9216
9469
 
9470
+ ### Places and edits by name
9471
+
9472
+ A code panel is a *surface*: every place on it has a name, so a scene can be
9473
+ written as plain data. `anchor(name)` gives the box there, `piece(name)` the
9474
+ word there, and `edit(name, anchor, options)` does the same as the methods
9475
+ above:
9476
+
9477
+ ```js
9478
+ code.anchor('line:7') // = code.line(7)
9479
+ code.anchor('token:4:Println') // = code.token(4, 'Println'); token:4#2:x is the second x
9480
+ code.anchor('spot:3:4') // = code.spot(3, 4)
9481
+
9482
+ code.edit('highlight', ['line:2', 'line:3'], { at: 100 })
9483
+ code.edit('fling', 'token:4:Println', { at: grab.release })
9484
+ code.edit('drop', 'token:1:int', { at: 1600, into: 'spot:3:2' })
9485
+ code.edit('move', 'token:4:fmt.', { at: 600, to: 'box' })
9486
+ ```
9487
+
9488
+ A wrong name says what it meant (`Unknown anchor "lin": did you mean "line"?`),
9489
+ and an edit given the wrong kind of place says which kind it takes. The
9490
+ anchors and edits are listed under "Surfaces" in `capabilities()`. Boards,
9491
+ charts and props that change state are planned as surfaces that work the
9492
+ same way.
9493
+
9494
+ ### A whole scene as data
9495
+
9496
+ `surfaceScript()` takes beats that name places and say what the surface does
9497
+ in answer, so the reactions above need no wiring by hand. A beat's `target`,
9498
+ `to` and `onto` can be a place (`{ surface, anchor }`: its box, its centre x,
9499
+ its top), and `then` holds the surface's cues, each at a moment of the beat:
9500
+
9501
+ ```js
9502
+ const result = surfaceScript('hero', { code }, [
9503
+ { do: 'leap', to: 300, onto: { surface: 'code', anchor: 'line:5' } },
9504
+ { do: 'grab', target: { surface: 'code', anchor: 'token:4:Println' },
9505
+ then: { surface: 'code', edit: 'carry', anchor: 'token:4:Println', until: { beat: 2, at: 'release' } } },
9506
+ { do: 'throw', to: 700,
9507
+ then: { surface: 'code', edit: 'fling', anchor: 'token:4:Println', at: 'release' } },
9508
+ { do: 'swipe', target: { surface: 'code', anchor: 'line:2' },
9509
+ then: { surface: 'code', edit: 'remove', anchor: 'line:2', style: 'blur', duration: 600 } },
9510
+ ], { from: 600, ground: code.box.bottom, height: 100 })
9511
+
9512
+ const timeline = deserializeTimeline({ id: 'scene', tracks: result.tracks })
9513
+ ```
9514
+
9515
+ A cue's `at` is `start`, `contact`, `release` or `end` (default: the beat's
9516
+ contact, or its start when it has none). `until` ends it at a moment of the
9517
+ same beat or of a later one (`{ beat: 2, at: 'release' }`) and sets the
9518
+ edit's duration. Every other field is the edit's own option (`text`, `into`,
9519
+ `style`, `on`). `carry` is the one cue that is not a surface edit: the piece
9520
+ follows the figure's hand (`handPath`) until `until`; pass `figureStyle` when
9521
+ the figure is drawn with more than a `height`.
9522
+
9523
+ It does what the hand-wired version does, in the same order: the beats go to
9524
+ `scriptTracks` with places swapped for their boxes as laid out, each cue runs
9525
+ `surface.edit()` in beat order, and the figure rides the surfaces it stands
9526
+ on (`ride: false` turns that off). The Code Tidy demo written this way gives
9527
+ the same tracks, key for key. `result.tracks` holds the figure's tracks and
9528
+ every surface's (named by its key in `{ code }`); `checkSurfaceBeats(beats, surfaces)`
9529
+ lists the problems without compiling.
9530
+
9531
+ ### Whiteboards
9532
+
9533
+ `whiteboard()` is a second surface, for lessons that are not code: a board
9534
+ (or `theme: 'chalkboard'`) whose texts and hand-drawn marks are declared as
9535
+ data, each with an id, and named as places like a code panel's lines:
9536
+
9537
+ ```js
9538
+ const board = whiteboard({
9539
+ x: 20, y: 20, width: 470, height: 300, theme: 'chalkboard', fontSize: 30,
9540
+ items: [
9541
+ { id: 'eq', text: '2x + 4 = 12', at: [40, 30] },
9542
+ { id: 'move', text: '2x = 12 - 4', at: [40, 100], hidden: true },
9543
+ { id: 'ring', mark: 'circle', around: 'term:eq:+ 4', hidden: true },
9544
+ { id: 'across', mark: 'arrow', from: 'mark:ring', to: 'term:move:- 4', color: 'orange', hidden: true },
9545
+ ],
9546
+ })
9547
+
9548
+ surfaceScript('teacher', { board }, [
9549
+ { do: 'point', target: { surface: 'board', anchor: 'term:eq:+ 4' },
9550
+ then: { surface: 'board', edit: 'draw', anchor: 'mark:ring', until: 'end' } },
9551
+ { do: 'write', target: { surface: 'board', anchor: 'text:move' },
9552
+ then: { surface: 'board', edit: 'write', anchor: 'text:move', until: 'release' } },
9553
+ ], { from: 640, ground: 400, height: 190, facing: -1 })
9554
+ ```
9555
+
9556
+ Its places are `box`, `text:ID`, `term:ID:TEXT` (part of a text; `term:ID#K:TEXT`
9557
+ for the Kth) and `mark:ID`. Marks are `circle`, `box`, `underline` (each
9558
+ `around` a place) and `arrow` (`from` one place `to` another), and can only
9559
+ name items declared before them. Its edits: `write` (a hidden text, by hand;
9560
+ or new `text` into a term's place), `draw` (a hidden mark), `erase`, `strike`,
9561
+ and `move` and `fling` for a term, which comes loose as a piece (`carry` works
9562
+ too). Text is laid out in fixed-width cells, never measured, and each mark's
9563
+ wobble comes from a seed made of its id, so a board is drawn the same
9564
+ everywhere. Colours are theme names (`red`, `blue`, `green`, `orange`, and
9565
+ `yellow` on chalk) or any CSS colour. The Board Lesson demo solves an
9566
+ equation this way.
9567
+
9568
+ ### Charts
9569
+
9570
+ `chart()` is a surface for talking through data: a bar or line chart whose
9571
+ values are declared as data, scaled once when it is made (`max`, or a round
9572
+ number above the largest value).
9573
+
9574
+ ```js
9575
+ const sales = chart({
9576
+ x: 20, y: 20, width: 480, height: 340, kind: 'bar', theme: 'dark', title: 'Sales', max: 100, suffix: 'k',
9577
+ data: [
9578
+ { id: 'q3', label: 'Q3', value: 30 },
9579
+ { id: 'q4', label: 'Q4', value: 20 },
9580
+ ],
9581
+ })
9582
+
9583
+ surfaceScript('hero', { sales }, [
9584
+ { do: 'point', target: { surface: 'sales', anchor: 'bar:q3' },
9585
+ then: { surface: 'sales', edit: 'highlight', anchor: 'bar:q3' } },
9586
+ { do: 'leap', to: { surface: 'sales', anchor: 'bar:q4' }, onto: { surface: 'sales', anchor: 'bar:q4' } },
9587
+ { do: 'cheer', for: 1600,
9588
+ then: { surface: 'sales', edit: 'set', anchor: 'bar:q4', value: 85, at: 'start', until: 'end' } },
9589
+ ], { from: 640, ground: 400, height: 90, facing: -1 })
9590
+ ```
9591
+
9592
+ Its places are `bar:ID` (on a bar chart) or `point:ID` (on a line chart),
9593
+ `label:ID`, `value:ID` and `box`, and they follow the values:
9594
+ `sales.anchor('bar:q4', time)` is the bar as it stands then. Its edits:
9595
+ `set` (a new `value`; the value label counts along), `show` (grow a
9596
+ `hidden` bar in from the axis, or draw the line out to a point; `on: false`
9597
+ takes it back) and `highlight`. A bar's top is a floor: a figure standing on
9598
+ it is carried up and down as it grows and shrinks, as in the Chart Talk demo.
9599
+
9600
+ ### Props as surfaces
9601
+
9602
+ A prop's controls are state a figure can change: `propSurface(propTarget(…))`
9603
+ makes a car, a house or a tree a surface. Its places are `anchor:NAME` (the
9604
+ rig's anchors: `door`, `doorstep`, `seat`, `branch`…), `part:ID` (one part as
9605
+ seen: `window-1`, `wheel-0-left`), `control:NAME` (where the parts a control
9606
+ moves or lights are) and `box`. Its edits are `set` (a control to a `value`)
9607
+ and `switch` (a control to its full value, open or on, or back to rest with
9608
+ `on: false`).
9609
+
9610
+ ```js
9611
+ const home = propTarget({ x: 430, y: 320, prop: house(), values: { turn: 0.25 } })
9612
+ const homeSurface = propSurface(home)
9613
+ const floor = homeSurface.anchor('anchor:doorstep').y
9614
+
9615
+ surfaceScript('hero', { home: homeSurface }, [
9616
+ { do: 'walk', to: homeSurface.anchor('anchor:door').x - 70 },
9617
+ { do: 'grab', target: { surface: 'home', anchor: 'anchor:door' },
9618
+ then: { surface: 'home', edit: 'switch', anchor: 'control:door', until: 'end' } },
9619
+ { do: 'point', target: { surface: 'home', anchor: 'part:window-1' },
9620
+ then: { surface: 'home', edit: 'switch', anchor: 'control:lights' } },
9621
+ ], { from: 40, ground: floor, height: 100 })
9622
+ ```
9623
+
9624
+ A prop stands on its middle, and seen from a little above its front comes
9625
+ forward of that line. A figure that walks on the prop's own `y` is inside
9626
+ its footprint and seems to walk through the wall; walk it on the prop's
9627
+ front line instead (a house's `doorstep`, as above). Places are worked out
9628
+ from the prop's values at a time, so they follow a door as it swings; pass
9629
+ the prop's own script as `propSurface(target, { tracks })` and they follow
9630
+ it as it drives off. Do not key a control both in its own script and here.
9631
+ A part turned away from the viewer has no place on screen (a car's
9632
+ headlights in profile); the error names the anchors to aim at instead. The
9633
+ Home Time demo is this scene.
9634
+
9217
9635
  ## Camera
9218
9636
 
9219
9637
  Video scenes can be seen through a camera: `camera: true` reads the tracks of
@@ -9878,10 +10296,151 @@ plays in 3D: `stickToHuman(danceFrame(style, beat))` gives the pose, and
9878
10296
  `lift` and ground contact behave as they do front-on; seen front-on through a
9879
10297
  flat camera, a character is exactly the 2D figure.
9880
10298
 
10299
+ **Walking in metres.** `characterScript3D(id, beats, { scene, position, heading, height })`
10300
+ scripts a character in world metres, as `propScript3D` does props:
10301
+
10302
+ ```js
10303
+ import { characterScript3D } from '@algorisys/tinyfly/characters'
10304
+
10305
+ const tum = characterScript3D('tum', [
10306
+ { do: 'walk', to: [1.4, 1.6] }, // a gait, to a point [x, z] metres
10307
+ { do: 'pose', pose: 'wave', for: 500 }, // a named pose (or pose fields)
10308
+ { do: 'run', through: [[3.5, 0], [2.5, -3], [-3, 0]] }, // along a smooth path
10309
+ { do: 'face', toward: [0, 3] }, // a point, or a heading in degrees
10310
+ { do: 'gag', gag: 'take' },
10311
+ ], { scene: 'village', position: [0.6, 0.2], heading: 0 })
10312
+ ```
10313
+
10314
+ A move is a gait (`walk`, `run`, `sneak`, `strut`, `tired`, `bouncy`,
10315
+ `doubleBounce`, `shove`); it turns to face the way first and goes at the
10316
+ gait's pace for its height (or `speed`, `for`). It keys `walk` (the gait's
10317
+ phase) with the distance, one stride per cycle, so the feet stay planted, plus
10318
+ `walking` (eased in and out) and `gait`. The character object turns those into
10319
+ the stepping pose as it draws, on the pose it holds: a wave carries on while it
10320
+ walks. Objects take `gait` and `walking` as fields too.
10321
+
10322
+ **Riding.** `propRide3D({ prop, propId, propTracks, scene, placement, anchor, riderId, pose, start, end, mount?, dismount? })`
10323
+ keeps a rider's hips on a prop's seat anchor (a horse's `saddle`, a bike's or
10324
+ a cart's `seat`) as the prop moves, turns, bobs with its stride and pitches,
10325
+ writing the rider's `x`, `y`, `z` and `rotateY`; `mount: { from: [x, z] }` and
10326
+ `dismount: { to: [x, z] }` hop it on and off. `spliceTracks(riderTracks, ride, { from, to })`
10327
+ puts the ride into the rider's script, which holds the riding pose
10328
+ (`RIDING_POSES.astride` or `.seated`) meanwhile and `place`s it where it got
10329
+ off. A character in a scene is drawn part by part, each part at its own depth
10330
+ (`characterPartsInView`), so a leg astride a horse shows on each side of it.
10331
+ A seat inside a closed cabin (a car's) is not handled yet: its glass is opaque
10332
+ in 3D.
10333
+
9881
10334
  Outside scenes, `drawCharacterInView(ctx, character, pose, projection, { height })`
9882
10335
  draws a character through any camera (`projection.toView` / `toScreen`), and
9883
10336
  `skeletonInView` / `stagePlanSpace` give its joints.
9884
10337
 
10338
+ ## Props
10339
+
10340
+ Props (cars, trucks, trees, houses, aircraft, horses, dogs, birds…) stand in
10341
+ scenes too, named by their preset in plain data and drawn with the same pens
10342
+ as the characters, solid or as line art:
10343
+
10344
+ ```js
10345
+ import { characterObjects, propObjects } from '@algorisys/tinyfly/characters'
10346
+
10347
+ const scene = loadScene3D({
10348
+ id: 'village', camera: 'cam', /* … */
10349
+ objects: [
10350
+ /* camera, lights, ground … */
10351
+ { id: 'car', kind: 'prop', prop: 'car', position: [0, 0, 3], rotation: [0, 90, 0], values: { door: 1 } },
10352
+ { id: 'barn', kind: 'prop', prop: 'house', position: [3.5, 0, -5], options: { colors: { walls: '#c0583f' } } },
10353
+ { id: 'crow', kind: 'prop', prop: 'crow', position: [0, 3, 0], values: { spread: 1, flapping: 1 }, style: 'stick' },
10354
+ ],
10355
+ }, { kinds: [characterObjects, propObjects] })
10356
+ ```
10357
+
10358
+ | Field | |
10359
+ |---|---|
10360
+ | `prop` | the preset's name (`car`, `truck`, `bus`, `tractor`, `cart`, `trainCar`, `bike`, `motorbike`, `tree`, `house`, `helicopter`, `airplane`, `horse`, `dog`, `cat`, `cow`, `songbird`, `crow`, `chicken`); a wrong one is refused with the one probably meant |
10361
+ | `options` | the preset's options (colours, sizes) |
10362
+ | `values` | its control values as placed (`door`, `lights`, `spread`, …) |
10363
+ | `look` | `clean` (default), `pencil` or `silhouette`, drawn with the figures' pens; or `mesh`, built of the scene's own meshes |
10364
+ | `shading`, `outline` | the mesh look's shading (`toon` by default) and outline width in px (default 2) |
10365
+ | `style` | `solid` (default) or `stick` (line art) |
10366
+ | `ink`, `paper` | outline colour, and the paper a stick prop is filled with |
10367
+ | `shadow` | its contact shadow (default true) |
10368
+
10369
+ A prop is built in metres, faces +z and stands on its object's ground; the
10370
+ scene's camera turns it (its own `turn` and `tilt` are not used), and faces
10371
+ are culled toward the camera's eye, so it is right in perspective close up.
10372
+ Its controls are tracks on its object: `village/car` `wheelSpin`,
10373
+ `village/horse` `walk` and `walking`, `village/crow` `wingbeat`. Keep wheels
10374
+ and strides honest the way the 2D scripts do: key `wheelSpin` as the distance
10375
+ over the wheel radius (`car().wheelRadius`), and a horse's `walk` phase as the
10376
+ distance over `horseStrideLength('walk')`.
10377
+
10378
+ **Scripting props in metres.** `propScript3D(id, prop, beats, { scene, position, heading })`
10379
+ compiles beats with world targets into the object's tracks (`x`, `z`,
10380
+ `rotateY` and its controls):
10381
+
10382
+ ```js
10383
+ import { propScript3D, car, horse, crow } from '@algorisys/tinyfly/characters'
10384
+
10385
+ const drive = propScript3D('car', car(), [
10386
+ { do: 'drive', to: [9, 3] }, // a point on the ground, [x, z] metres
10387
+ { do: 'honk' }, // any action, as in 2D (controls only)
10388
+ { do: 'drive', through: [[11, 4.6], [9, 6.2], [-9, 6.2]] }, // a smooth path through points
10389
+ { do: 'face', toward: [0, 0] }, // a point, or a heading in degrees
10390
+ ], { scene: 'village', position: [-9, 3], heading: 90 })
10391
+ const flight = propScript3D('crow', crow(), [{ do: 'fly', to: [2, 1], height: 0 }], { scene: 'village', position: [0, 5], values: { lift: 3 } })
10392
+ const timeline = deserializeTimeline({ id: 'village', tracks: [...drive.tracks, ...flight.tracks] })
10393
+ ```
10394
+
10395
+ A move (a prop's `moves`: `drive`; `walk`, `trot`, `canter`, `gallop` or
10396
+ `run`; a bird's `walk` and `fly`; an aircraft's `fly`) turns to face the way
10397
+ first, then goes at its own speed (or `speed`, metres per second, or `for`
10398
+ ms), easing in and out. Its wheels and strides are keyed with the distance at
10399
+ every moment, so wheels roll and feet step exactly; a wingbeat or a rotor
10400
+ keeps time. A flier's `height` is how high it goes (`0` lands it); between
10401
+ flights it stays up with its wings beating. `face`, `hold` and the prop's own
10402
+ actions (`honk`, `bark`, `peck`, `door`…) work as in 2D. `checkPropBeats3D`
10403
+ names what was probably meant; `end` gives where it finished, for the next
10404
+ script.
10405
+
10406
+ **Lit by the scene.** A pen-drawn prop is lit by the scene's lights as its
10407
+ meshes are (ambient, directional, point and spot, with fog): each face at its
10408
+ place in the world, so a low orange sun warms its sunlit sides and a night's
10409
+ blue moon darkens it. Glowing parts (lit windows, headlights: a house's or a
10410
+ car's `lights` control) glow over the top, so they shine in the dark. A scene
10411
+ with no lights keeps the props' own light, which follows the camera; line art
10412
+ (`style: 'stick'`) stays unlit. A pen-drawn character's skin takes the light
10413
+ reaching its chest from the camera's side (at most its own colour) and the fog
10414
+ there: lit from behind the camera its face shows, against a low sun it goes
10415
+ dark, at night it dims. Its ink is its own, so give a character a light ink in
10416
+ a dark scene (`character: { ink: '#dfe5f0' }`). The solid look is lit as
10417
+ meshes are.
10418
+
10419
+ **The mesh look.** `look: 'mesh'` builds a prop of the scene's own meshes, as
10420
+ a character's `look: 'solid'` does: each part's shape is built once and placed
10421
+ each frame, lit and outlined like everything else, glass see-through (so a
10422
+ driver shows behind a windscreen), glowing parts as light of their own, hidden
10423
+ faces left out, its shadow a soft disc. With the WebGL2 renderer its depth
10424
+ order is exact, pixel by pixel; the canvas renderer sorts it triangle by
10425
+ triangle, which can slip where a small part lies on a big face (a window on a
10426
+ wall). For the canvas, the pen looks sort better (below); for exact depth, use
10427
+ the mesh look with WebGL2.
10428
+
10429
+ **How props sort.** A pen-drawn prop is not drawn whole at one depth. It is
10430
+ cut into columns about a metre across (along its length and width), and each
10431
+ column sorts at its own depth among the scene's other things, so a figure
10432
+ walking past a bus is covered by its front end and covers its back. Inside a
10433
+ column, faces are drawn far to near, each with its own outlines. Faces no one
10434
+ can see are left out: those inside another solid part, or lying against one
10435
+ (a house's wall tops under its roof, a tyre's tread inside the fender). A
10436
+ face lying on another part's face (a light, a window, a door) is drawn just
10437
+ after it. Where a part sits partly into another, its `layer` says which is
10438
+ drawn over (a car's cabin over its body, a roof over its walls). What is
10439
+ nearer than the camera's near plane is cut away, so a camera can come close or
10440
+ go inside. A pen-drawn character is still drawn whole at its middle's depth,
10441
+ and painter's order has limits: for exact order use the solid look and the
10442
+ WebGL2 renderer.
10443
+
9885
10444
  **Other object kinds** come the same way: an `ObjectKind` validates its
9886
10445
  objects, prepares them once, and each frame returns meshes (shaded and sorted
9887
10446
  with the scene's) and drawables (drawn whole at their depth). Pass it in
@@ -12372,7 +12931,7 @@ magnet.addEventListener('pointerleave', () => {
12372
12931
 
12373
12932
  <!-- capabilities: generated from the library -->
12374
12933
 
12375
- # tinyfly capabilities (v0.94.0)
12934
+ # tinyfly capabilities (v0.97.0)
12376
12935
 
12377
12936
  Generated from the library itself: every name below is accepted, and names not listed are rejected (beat scripts, code panels and `checkTracks` say which name was probably meant).
12378
12937
 
@@ -12583,6 +13142,53 @@ Nothing is registered globally: pass your definitions where they are used.
12583
13142
  - `stickFigureTarget({ …, cast: { actions, gaits } })`: a figure that draws the gaits and lists the actions in describeTarget
12584
13143
  - `persona({ name, summary?, height?, look?, acting?, gait?, mood?, stance?, energy?, actions?, gaits? })`: a character’s look, acting style and habits: .figure({ x, y }), .script(id, beats, { from, ground }), .check(beats), .handPath(…), .describe(); `go` walks in its gait, `stand` returns to its stance and face
12585
13144
 
13145
+ ## Props (everyday objects with behaviours)
13146
+
13147
+ A prop is a 3D rig of simple parts drawn with the characters’ pens (clean, pencil, silhouette), so it turns toward the camera (`turn`), and its beats go through the same acting pass (anticipation, overshoot, overlap; `exaggeration` scales them).
13148
+
13149
+ - `car() · truck() · bus() · tractor() · cart() · trainCar() · bike() · motorbike()`: wheeled vehicles (vehicle(spec) makes your own)
13150
+ - `tree() · house()`: environment (tree(spec), house(spec))
13151
+ - `helicopter() · airplane()`: aircraft
13152
+ - `horse() · dog() · cat() · cow()`: animals (quadruped(spec) makes your own): gaits with footfall patterns keyed in step with the distance, sit, jump, their calls, species actions
13153
+ - `songbird() · crow() · chicken()`: birds (bird(spec) makes your own): hop, walk, peck, flap, fly and land (a chicken flutters), their calls; wings fold and beat in rhythm
13154
+ - `{ kind: 'prop', prop: 'car', position, rotation, values } with loadScene3D(scene, { kinds: [characterObjects, propObjects] })`: props in 3D scenes, by preset name, seen in perspective by the scene camera; controls are tracks on the object
13155
+ - `characterScript3D(id, beats, { scene, position?, heading?, height?, pose? })`: a v2 character in a 3D scene in world metres: gaits to [x, z] or through points (its walk phase keyed with the distance), face, hold, pose, gag; checkCharacterBeats3D checks the beats
13156
+ - `propRide3D({ prop, propId, propTracks, scene, placement, anchor, riderId, pose, start, end, mount?, dismount? })`: a character riding a prop in a 3D scene: hips on a seat anchor (saddle, seat) as it moves, hopping on and off; RIDING_POSES.astride / .seated
13157
+ - `propScript3D(id, prop, beats, { scene, position?, heading?, values? })`: props scripted in world metres for 3D scenes: moves to [x, z] or through points (wheels and strides keyed with the distance), face, hold, and their actions; checkPropBeats3D checks the beats
13158
+ - `propPreset(name, options?)`: a prop preset by name (did-you-mean on a wrong one)
13159
+ - `propTarget({ …, style: 'stick' })`: line art to go with stick figures: tubes as single strokes, shapes outlined over paper
13160
+ - `propTow({ leader, leaderId, leaderTracks, hitch, towed, towedId, anchor, start, end })`: a prop towed by another (a cart behind a horse): turns with it, its wheels roll exactly
13161
+ - `propTarget({ x, y, prop, scale?, values?, look?, ink? })`: a canvas target that draws a prop (x, y: its middle on the ground; scale px per metre, default 60)
13162
+ - `propScript(id, prop, beats, { from, ground, scale, style?, exaggeration?, start? })`: beats → acted tracks, with contact times and effect cues; checkPropBeats(beats, prop) checks them
13163
+ - `drawProp(ctx, target, frame, id, { rider? })`: draw it as it is in a frame (a rider is drawn between its far and near parts)
13164
+ - `propAt(target, frame, id).anchor(name)`: where an anchor (seat, door, chimney…) is, in scene px
13165
+ - `propRide({ prop, propId, propTracks, anchor, figure, figureId, start, end, offset? })`: a figure carried at an anchor, turning with the prop; spliceTracks() puts it into the figure’s tracks
13166
+ - `drawPropEffects(ctx, effects, time)`: dust, exhaust, skid marks, honk lines, leaves, smoke
13167
+
13168
+ Prop beat fields: `do`, `at`, `for`, `to`, `toward`, `speed`, `open`, `on`, `height`, `wind`. Every prop has the controls `turn`, `tilt`, `pitch`, `roll`, `squash`, `lift`, `lean`, `size` and the actions `hold`, `turn`, `pop`, `vanish`.
13169
+
13170
+ | Preset | Family | Actions (needs) | Controls | Anchors |
13171
+ |---|---|---|---|---|
13172
+ | `car()` | vehicle | `drive` (to), `brake` (to), `bump`, `honk`, `door` (open), `lights` (on) | `wheelSpin`, `door`, `lights`, `antenna` | seat, front, back, roof, door |
13173
+ | `truck()` | vehicle | `drive` (to), `brake` (to), `bump`, `honk`, `door` (open), `lights` (on) | `wheelSpin`, `door`, `lights` | seat, front, back, roof, door |
13174
+ | `bus()` | vehicle | `drive` (to), `brake` (to), `bump`, `honk`, `door` (open), `lights` (on) | `wheelSpin`, `door`, `lights` | seat, front, back, roof, door |
13175
+ | `tractor()` | vehicle | `drive` (to), `brake` (to), `bump`, `honk`, `lights` (on) | `wheelSpin`, `lights` | seat, front, back, roof |
13176
+ | `cart()` | vehicle | `drive` (to), `brake` (to), `bump`, `honk` | `wheelSpin` | seat, front, back, roof, shafts |
13177
+ | `trainCar()` | vehicle | `drive` (to), `brake` (to), `bump`, `honk`, `lights` (on) | `wheelSpin`, `lights` | seat, front, back, roof |
13178
+ | `bike()` | vehicle | `drive` (to), `brake` (to), `bump`, `honk` | `wheelSpin` | seat, front, back, roof |
13179
+ | `motorbike()` | vehicle | `drive` (to), `brake` (to), `bump`, `honk`, `lights` (on) | `wheelSpin`, `lights` | seat, front, back, roof |
13180
+ | `tree()` | plant | `sway`, `shake`, `shedLeaves` | `sway`, `canopySway` | canopy, top, base, branch |
13181
+ | `house()` | building | `door` (open), `lights` (on), `shake`, `smoke` | `door`, `lights` | door, doorstep, ridge, chimney |
13182
+ | `helicopter()` | aircraft | `takeOff`, `fly` (to), `hover`, `land` | `rotor`, `blur` | seat, door, rotor, skids, hook |
13183
+ | `airplane()` | aircraft | `takeOff` (to), `fly` (to), `loop`, `land` (to) | `rotor`, `blur` | seat, nose, tail, wingtip |
13184
+ | `horse()` | animal | `walk` (to), `trot` (to), `canter` (to), `gallop` (to), `neigh`, `sit`, `jump`, `nod`, `swish`, `graze`, `rear`, `buck` | `walk`, `walking`, `gait`, `neck`, `tail`, `wag`, `fl.swing`, `fl.knee`, `fl.ankle`, `fr.swing`, `fr.knee`, `fr.ankle`, `hl.swing`, `hl.knee`, `hl.ankle`, `hr.swing`, `hr.knee`, `hr.ankle` | back, head, mouth, front, hitch, saddle |
13185
+ | `dog()` | animal | `walk` (to), `trot` (to), `run` (to), `gallop` (to), `bark`, `sit`, `jump`, `nod`, `swish`, `wag`, `sniff` | `walk`, `walking`, `gait`, `neck`, `tail`, `wag`, `fl.swing`, `fl.knee`, `fl.ankle`, `fr.swing`, `fr.knee`, `fr.ankle`, `hl.swing`, `hl.knee`, `hl.ankle`, `hr.swing`, `hr.knee`, `hr.ankle` | back, head, mouth, front, leash |
13186
+ | `cat()` | animal | `walk` (to), `trot` (to), `run` (to), `gallop` (to), `meow`, `sit`, `jump`, `nod`, `swish`, `arch`, `pounce` (to) | `walk`, `walking`, `gait`, `neck`, `tail`, `wag`, `fl.swing`, `fl.knee`, `fl.ankle`, `fr.swing`, `fr.knee`, `fr.ankle`, `hl.swing`, `hl.knee`, `hl.ankle`, `hr.swing`, `hr.knee`, `hr.ankle` | back, head, mouth, front |
13187
+ | `cow()` | animal | `walk` (to), `trot` (to), `moo`, `sit`, `jump`, `nod`, `swish`, `graze` | `walk`, `walking`, `gait`, `neck`, `tail`, `wag`, `fl.swing`, `fl.knee`, `fl.ankle`, `fr.swing`, `fr.knee`, `fr.ankle`, `hl.swing`, `hl.knee`, `hl.ankle`, `hr.swing`, `hr.knee`, `hr.ankle` | back, head, mouth, front |
13188
+ | `songbird()` | bird | `hop` (to), `walk` (to), `peck`, `flap`, `tweet`, `fly` (to), `land` | `spread`, `flap`, `wingbeat`, `flapping`, `peck`, `step`, `stepping`, `leg.left`, `leg.right` | beak, head, back, feet |
13189
+ | `crow()` | bird | `hop` (to), `walk` (to), `peck`, `flap`, `caw`, `fly` (to), `land` | `spread`, `flap`, `wingbeat`, `flapping`, `peck`, `step`, `stepping`, `leg.left`, `leg.right` | beak, head, back, feet |
13190
+ | `chicken()` | bird | `hop` (to), `walk` (to), `peck`, `flap`, `cluck`, `flutter` | `spread`, `flap`, `wingbeat`, `flapping`, `peck`, `step`, `stepping`, `leg.left`, `leg.right` | beak, head, back, feet |
13191
+
12586
13192
  ## Character (v2 human)
12587
13193
 
12588
13194
  Poses: `rest`, `wave`, `cheer`, `point`, `handsOnHips`, `think`, `shrug`, `sit`, `kneel`, `crouch`, `crawl`, `lieDown`. Expressions: `neutral`, `happy`, `joyful`, `sad`, `crying`, `surprised`, `shocked`, `angry`, `furious`, `worried`, `scared`, `confused`, `skeptical`, `thinking`, `sleepy`, `disgusted`, `smug`, `wink`. Gags: `take`, `doubleTake`, `windUp`, `land`, `tremble`, `deflate`.
@@ -12610,6 +13216,88 @@ Poses: `rest`, `wave`, `cheer`, `point`, `handsOnHips`, `think`, `shrug`, `sit`,
12610
13216
  - `drop(piece, n, column, { at, duration? })`: put a piece into a line (into its own line it slides, the text closing behind it)
12611
13217
  - `ride(tracks, figureId, { ground })`: a figure’s tracks with it carried by the line it stands on
12612
13218
 
13219
+ ## Surfaces
13220
+
13221
+ Scene objects figures act on. Places are named `kind:args`: `surface.anchor(name)` gives the box there (stand on `top`, point at `x`, `y`; pass it as a beat `target`), `surface.piece(name)` makes the part there come loose, and `surface.edit(name, anchor, options)` changes the surface at a time (`at`, ms).
13222
+
13223
+ Beats name places and say what surfaces do in answer (`surfaceScript`):
13224
+
13225
+ - `surfaceScript(figureId, { name: surface }, beats, options)`: compiles beats that act on surfaces: returns the script result with `tracks` (the figure’s, ridden, then every surface’s, keyed by its name) and `figureTracks`; options are scriptTracks’ plus `figureStyle` (for carry) and `ride` (default true)
13226
+ - `checkSurfaceBeats(beats, surfaces, cast?)`: every problem checkBeats finds, plus unknown surfaces, places, edits and moments, with suggestions
13227
+ - `{ surface, anchor }`: a named place, where a beat takes `target` (its box), `to` (its centre x) or `onto` (its top); as laid out, before any edit moves it
13228
+ - `then: { surface, edit, anchor, at?, until?, …options }`: what the surface does in answer to the beat (or a list of them): one of its edits, or `carry` (the piece follows the hand until `until`); the other fields are the edit’s options
13229
+ - `at`: a moment of the beat: start, contact, release, end (default contact, or start when the beat has none); not ms
13230
+ - `until`: a moment of this beat, or { beat: index, at? } of a later one; sets the edit’s duration (carry needs it)
13231
+
13232
+ ### code
13233
+
13234
+ `codePanel({ code, language?, x, y, fontSize?, lineHeight?, width?, hidden? })`
13235
+
13236
+ Anchors:
13237
+ - `box`: the whole panel
13238
+ - `line:N`: line N’s text (lines count from 1): stand on top, point at x, y, swipe left to right
13239
+ - `token:N:TEXT`: the first TEXT on line N (token:N#K:TEXT for the Kth): a word, which can come loose as a piece
13240
+ - `spot:N:C`: a place in line N before column C (0 is before its first character); spot:N:C:W is W characters wide. Aim a put or a write here
13241
+
13242
+ Edits:
13243
+ - `highlight`: line anchors; { at, duration?, on? }: tint lines (on: false clears)
13244
+ - `strike`: line anchors; { at, duration? }: strike lines through, left to right
13245
+ - `remove`: line anchors; { at, duration?, style?: wipe | fly | blur, from?: left | right, close? }: take lines away; the lines below close the gap
13246
+ - `type`: line anchors given in `hidden`; { at, duration? }: type them in
13247
+ - `insert`: a spot; { at, text, duration? }: type new text into the line there; the line makes room
13248
+ - `write`: a token; { at, text, duration? }: write new text into the word’s place
13249
+ - `drop`: a token; { at, into: a spot, duration? }: put the word into a line there
13250
+ - `move`: a token; { at, to: an anchor name or { x, y }, duration? }: move the word there
13251
+ - `fling`: a token; { at, velocity?, spin?, gravity?, duration? }: throw or kick the word away on a spinning arc
13252
+
13253
+ ### board
13254
+
13255
+ `whiteboard({ x, y, width, height, theme?: whiteboard | chalkboard, fontSize?, items: [{ id, text, at: [x, y], size?, color?, hidden? } | { id, mark: circle | box | underline | arrow, around? | from?, to?, color?, hidden? }] })`
13256
+
13257
+ Anchors:
13258
+ - `box`: the whole board
13259
+ - `text:ID`: a text item: write along it from left to right, point at it
13260
+ - `term:ID:TEXT`: the first TEXT in text ID (term:ID#K:TEXT for the Kth): a term, which can come loose as a piece
13261
+ - `mark:ID`: a mark (circle, box, underline or arrow)
13262
+
13263
+ Edits:
13264
+ - `write`: text anchors given `hidden`; { at, duration? }: write them in by hand. Or a term; { at, text, duration? }: write new text in its place (move or erase the term first)
13265
+ - `draw`: mark anchors given `hidden`; { at, duration? }: draw them in
13266
+ - `erase`: text, term or mark anchors; { at, duration? }: wipe them off
13267
+ - `strike`: text or term anchors; { at, duration? }: cross them out
13268
+ - `move`: a term; { at, to: an anchor name or { x, y }, duration? }: move the term there
13269
+ - `fling`: a term; { at, velocity?, spin?, gravity?, duration? }: throw or knock the term off on a spinning arc
13270
+
13271
+ ### chart
13272
+
13273
+ `chart({ x, y, width, height, kind: bar | line, data: [{ id, label?, value, hidden? }], max?, title?, theme?: light | dark, decimals?, prefix?, suffix?, values? })`
13274
+
13275
+ Anchors:
13276
+ - `box`: the whole chart
13277
+ - `bar:ID`: a bar (bar charts), as it stands at the time: stand on its top (it carries a figure as it grows), point at it
13278
+ - `point:ID`: a point on the line (line charts), as it stands at the time
13279
+ - `label:ID`: its label under the axis
13280
+ - `value:ID`: its value label, above it
13281
+
13282
+ Edits:
13283
+ - `set`: bar or point anchors; { at, value, duration? }: animate to a new value; its value label counts along
13284
+ - `show`: bar or point anchors given `hidden`; { at, duration?, on? }: grow a bar in from the axis, or draw the line out to a point (on: false takes it back)
13285
+ - `highlight`: bar or point anchors; { at, duration?, on? }: colour it out (on: false clears)
13286
+
13287
+ ### prop
13288
+
13289
+ `propSurface(propTarget({ x, y, prop }), { tracks? }): its controls and anchors are those the catalog lists for its preset`
13290
+
13291
+ Anchors:
13292
+ - `box`: the prop’s whole box
13293
+ - `anchor:NAME`: one of its rig’s anchors (door, seat, branch, ridge…), as posed at the time
13294
+ - `part:ID`: one of its parts as seen at the time (window-1, door-left, wheel-0-left…)
13295
+ - `control:NAME`: where the parts a control moves or lights are (control:door is the doors, control:lights the lamps)
13296
+
13297
+ Edits:
13298
+ - `set`: control anchors; { at, value, duration? }: move a control to a value
13299
+ - `switch`: control anchors; { at, on?, duration? }: a control to its full value (open, on), or back to its rest value with on: false
13300
+
12613
13301
  ## Camera shots (`cameraTracks(shots, { stage })`)
12614
13302
 
12615
13303
  - **frame**: `{ at, duration?, easing?, frame: { focus?: { x, y }, scale?, rotate? } }: push in, pull out, or cut (duration 0)`