@algorisys/tinyfly 0.94.0 → 0.95.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.
- package/README.md +6 -6
- package/docs/acting.md +5 -0
- package/docs/api-reference.md +3 -1
- package/docs/editor-guide.md +1 -1
- package/docs/examples.md +1 -1
- package/docs/getting-started.md +1 -1
- package/docs/gsap-compat.md +1 -1
- package/docs/llm-guide.md +17 -0
- package/docs/maps.md +2 -2
- package/docs/props.md +202 -0
- package/docs/scene-3d.md +141 -0
- package/docs/teaching.md +1 -1
- package/lib/addons/characters.js +5329 -2337
- package/lib/addons/scene-3d.js +140 -138
- package/lib/browser/tinyfly-scene-3d.iife.js +1 -1
- package/lib/browser/tinyfly.iife.js +15 -9
- package/lib/browser/tinyfly.js +7108 -4061
- package/lib/browser/tinyfly.umd.js +15 -9
- package/lib/engine/tinyfly-engine.js +612 -600
- package/lib/engine/tinyfly-engine.umd.cjs +2 -2
- package/lib/types/characters/capabilities.d.ts +17 -0
- package/lib/types/characters/character-script-3d.d.ts +80 -0
- package/lib/types/characters/character.d.ts +19 -0
- package/lib/types/characters/ground-path.d.ts +32 -0
- package/lib/types/characters/index.d.ts +3 -0
- package/lib/types/characters/props/clip.d.ts +5 -0
- package/lib/types/characters/props/draw.d.ts +60 -0
- package/lib/types/characters/props/effects.d.ts +12 -0
- package/lib/types/characters/props/families/aircraft.d.ts +37 -0
- package/lib/types/characters/props/families/animals.d.ts +156 -0
- package/lib/types/characters/props/families/birds.d.ts +86 -0
- package/lib/types/characters/props/families/environment.d.ts +71 -0
- package/lib/types/characters/props/families/vehicle.d.ts +129 -0
- package/lib/types/characters/props/hidden.d.ts +49 -0
- package/lib/types/characters/props/index.d.ts +23 -0
- package/lib/types/characters/props/mesh-3d.d.ts +24 -0
- package/lib/types/characters/props/presets.d.ts +34 -0
- package/lib/types/characters/props/ride-3d.d.ts +71 -0
- package/lib/types/characters/props/ride.d.ts +79 -0
- package/lib/types/characters/props/rig.d.ts +224 -0
- package/lib/types/characters/props/scene-objects.d.ts +2 -0
- package/lib/types/characters/props/script-3d.d.ts +85 -0
- package/lib/types/characters/props/script.d.ts +145 -0
- package/lib/types/characters/props/shapes.d.ts +96 -0
- package/lib/types/characters/props/slice.d.ts +66 -0
- package/lib/types/characters/props/target.d.ts +129 -0
- package/lib/types/engine/authoring/index.d.ts +1 -0
- package/lib/types/engine/authoring/spring-follow.d.ts +25 -0
- package/lib/types/scene-3d/object-kind.d.ts +4 -1
- package/lib/types/scene-3d/scene-types.d.ts +41 -1
- package/llms-full.txt +428 -9
- package/llms.txt +28 -27
- package/package.json +1 -1
- package/skills/tinyfly/SKILL.md +8 -0
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ A lightweight, API-driven animation engine and visual editor for creating high-p
|
|
|
61
61
|
- **The drawing hand** - `drawnPathTarget()` draws a sketched stroke on from a `draw` track while a cartoon hand holds the pencil at its end in a writing grip; the same hand can hold the eraser. `handAt()` gives one hand for a whole scene: it follows each stroke, lifts and glides to the next, and enters and leaves the page
|
|
62
62
|
- **Erasing** - An eraser rubs out part of a target (`erasable()`, animated by an `erase` track) or of anything drawn in code (`withErased()`); clip-based, so it works in the browser and headless alike
|
|
63
63
|
- **Cartoon hands** - A hand rig in 3D, drawn flat: thumb and fingers posed by numbers (`index.curl`, `thumb.across`, `spread`, `turn`), ready-made shapes (fist, point, thumbs-up, peace, OK, pinch, wave, pencil grip…), left and right, four or five fingers, in every look; the animator's hand and (opt-in) character gloves are built on it. See [docs/cartoon-hands.md](docs/cartoon-hands.md)
|
|
64
|
-
- **Cartoon acting** - `actTracks()` turns the same key poses into acted motion: wind-ups, overshoot that settles or wobbles, joints that overlap (hips lead, wrists drag), eyes that dart ahead and blink on head turns, moving holds and jump squash, in `full`, `snappy` or `limited` styles. Gags come as data (`gag('take')`, double take, wind-up, tremble). A line of action (`bend`) curves the spine, and gaits have personality (bouncy, double bounce, sneak, strut, tired, run). Lip-sync works from text, Latin or Devanagari. `scriptTracks()` compiles a story written as beats (`{ do: 'walk', to: 640 }`, `{ do: 'take' }`, `{ do: 'say', say: '…' }`) into all of it. `cameraTracks()` films it with push-ins, cuts, shakes and follows. The cartoon zip (`{ do: 'zip' }`) has the legs wheel in place before it is gone. Figures can act on code, Animator vs Animation style: `codePanel()` lays a listing out so every line and word is a place in the scene, and beats leap onto lines, point at them and swipe them away (`{ do: 'swipe', target: code.line(7) }`), with the line wiped, knocked off the panel or blurred out of focus on the frames the hand crosses it. Words come loose too: a figure grabs `var` and throws it, kicks another out of a loop, carries a stray `;` to where it belongs, pushes a word along its line (the text closing up behind it), and writes `mut` into a line by hand. A figure standing on a line rides it when a gap above closes (`code.ride()`). Your own behaviours are plain values: `defineAction()` (from beats or timed pose steps), `defineGait()`, and `persona()` for a recurring character's look, acting style, gait, usual face and stance. In the editor, a Character's **Acting** section acts its keyed poses in a style and adds gags, walks in a gait and lip-synced lines, with drawing on twos as a timeline setting. Characters come in builds (slim, kid, broad, curvy, stocky), and the v2 human has its own line of action, gaits and gags, posed in 3D so they read from every view. It also adds speed lines from earlier frames (`drawStickSmear()`), dust puffs, impact stars, and drawing on twos for video (`drawingRate`). Output is plain keyframes. See [docs/acting.md](docs/acting.md)
|
|
64
|
+
- **Cartoon acting** - `actTracks()` turns the same key poses into acted motion: wind-ups, overshoot that settles or wobbles, joints that overlap (hips lead, wrists drag), eyes that dart ahead and blink on head turns, moving holds and jump squash, in `full`, `snappy` or `limited` styles. Gags come as data (`gag('take')`, double take, wind-up, tremble). A line of action (`bend`) curves the spine, and gaits have personality (bouncy, double bounce, sneak, strut, tired, run). Lip-sync works from text, Latin or Devanagari. `scriptTracks()` compiles a story written as beats (`{ do: 'walk', to: 640 }`, `{ do: 'take' }`, `{ do: 'say', say: '…' }`) into all of it. `cameraTracks()` films it with push-ins, cuts, shakes and follows. The cartoon zip (`{ do: 'zip' }`) has the legs wheel in place before it is gone. Figures can act on code, Animator vs Animation style: `codePanel()` lays a listing out so every line and word is a place in the scene, and beats leap onto lines, point at them and swipe them away (`{ do: 'swipe', target: code.line(7) }`), with the line wiped, knocked off the panel or blurred out of focus on the frames the hand crosses it. Words come loose too: a figure grabs `var` and throws it, kicks another out of a loop, carries a stray `;` to where it belongs, pushes a word along its line (the text closing up behind it), and writes `mut` into a line by hand. A figure standing on a line rides it when a gap above closes (`code.ride()`). Props give the story a world: cars, trucks, buses, tractors, carts, train carriages, bikes, motorbikes, trees, houses, a helicopter and a plane, a horse, dogs, cats, cows and birds are 3D rigs drawn with the figures' pens, so they turn toward the camera and boil in pencil, or as line art beside stick figures. They act from beats through the same principles (they rock back before they go, dip on the stop, skid, bump, sway, take off and loop; animals walk, trot and gallop with their feet keeping pace, sit and jump; birds hop, peck, flap and fly up to a perch), with an exaggeration dial, and figures can ride them. See [docs/props.md](docs/props.md). Your own behaviours are plain values: `defineAction()` (from beats or timed pose steps), `defineGait()`, and `persona()` for a recurring character's look, acting style, gait, usual face and stance. In the editor, a Character's **Acting** section acts its keyed poses in a style and adds gags, walks in a gait and lip-synced lines, with drawing on twos as a timeline setting. Characters come in builds (slim, kid, broad, curvy, stocky), and the v2 human has its own line of action, gaits and gags, posed in 3D so they read from every view. It also adds speed lines from earlier frames (`drawStickSmear()`), dust puffs, impact stars, and drawing on twos for video (`drawingRate`). Output is plain keyframes. See [docs/acting.md](docs/acting.md)
|
|
65
65
|
- **Pencil story example** - `examples/pencil-story-hindi/index.html` tells a short Hindi story (प्यासा राहगीर, the thirsty traveller) Pencilmation-style with the browser bundle alone: the hand draws the scene and writes the narration, then rubs out the pot
|
|
66
66
|
- **Captions** - `toSRT()` / `toWebVTT()` from narration cues or from a timeline's markers
|
|
67
67
|
|
|
@@ -100,7 +100,7 @@ A lightweight, API-driven animation engine and visual editor for creating high-p
|
|
|
100
100
|
- **Loop check** - `tinyfly video scene.mjs --loop-check` renders five frames and says whether a video loops: whether the frame at the duration matches the first, and whether the last → first seam looks like any other step (exit 1 when it does not). `--frames 0,79,88` renders stills at chosen frames. See [docs/video-rendering.md](docs/video-rendering.md#loops)
|
|
101
101
|
- **Bloom** - `bloom: true` on a video scene adds a deterministic glow around bright things (bright pass, blur, add; no `ctx.filter`), and 3D materials take `emissive` light that shines in the dark and feeds it. `applyBloom(ctx)` works on any 2D canvas. See [docs/video-rendering.md](docs/video-rendering.md#bloom)
|
|
102
102
|
- **Light trails** - `trailSamples` + `drawTrail` draw comets and light streaks on any 2D canvas: a tapering, fading band with a round head, smooth at any speed, and deterministic (the trail is where the thing was, asked of the timeline, not a frame history). 3D scenes get `line` and `trail` objects whose segments sort by depth among the meshes. See [docs/video-rendering.md](docs/video-rendering.md#light-trails) and [docs/scene-3d.md](docs/scene-3d.md#lines-and-trails)
|
|
103
|
-
- **3D scenes** - `@algorisys/tinyfly/scene-3d`: cameras, lights and meshes (box, sphere, cylinder, cone, torus, floor, any SVG path extruded) as JSON in metres, animated by ordinary tracks (`stage/box`), cut between cameras with one keyframe, drawn on a plain canvas with flat, smooth or toon shading, ink outlines and fog: in the browser, in Workers, and to MP4 in Node. Characters stand in scenes and dance, seen by any camera, in their pen looks (clean, pencil) or as solid figures (`characterObjects`). In the editor, a 🧊 3D Scene element builds them without code: add shapes, characters and lights, key them, dance from the playhead, cut between cameras. No WebGL needed (about 7 KB gzipped, its own entry and CDN script); for big or tangled scenes the optional WebGL2 renderer (`@algorisys/tinyfly/scene-3d/webgl`) adds a depth buffer and light per pixel. See [docs/scene-3d.md](docs/scene-3d.md)
|
|
103
|
+
- **3D scenes** - `@algorisys/tinyfly/scene-3d`: cameras, lights and meshes (box, sphere, cylinder, cone, torus, floor, any SVG path extruded) as JSON in metres, animated by ordinary tracks (`stage/box`), cut between cameras with one keyframe, drawn on a plain canvas with flat, smooth or toon shading, ink outlines and fog: in the browser, in Workers, and to MP4 in Node. Characters stand in scenes and dance, seen by any camera, in their pen looks (clean, pencil) or as solid figures (`characterObjects`); props (cars, houses, trees, animals, birds) stand in them by preset name (`propObjects`), sorted a column at a time so figures walk round them rightly, and lit by the scene's lights (a sunset, a night with lit windows). Both are scripted in world metres (`propScript3D`, `characterScript3D`): drive or walk to a point or along a path, wheels and feet keeping pace with the ground. In the editor, a 🧊 3D Scene element builds them without code: add shapes, characters and lights, key them, dance from the playhead, cut between cameras. No WebGL needed (about 7 KB gzipped, its own entry and CDN script); for big or tangled scenes the optional WebGL2 renderer (`@algorisys/tinyfly/scene-3d/webgl`) adds a depth buffer and light per pixel. See [docs/scene-3d.md](docs/scene-3d.md)
|
|
104
104
|
- **3D transforms** - Cards, images, text and shapes turn in 3D (`rotateX`, `rotateY`, `z`, `perspective`, `backfaceVisibility`) and land on the same pixels in DOM, SVG, Canvas (true perspective, also headless) and WebGL, checked against each browser's own CSS. One documented transform order everywhere; Tilt / Turn / Depth / Perspective fields in the editor; 3D Card Flip and Cover Flow samples. Quaternion tracks with `interpolation: "slerp"` turn without gimbal lock; the engine's `vec3`, `quat` and `mat4` helpers are plain arrays. The first steps of [3D support](docs/3d-support-plan.md). See [docs/3d-rotations.md](docs/3d-rotations.md)
|
|
105
105
|
- **Shape morph** - 🌀 Tween one path into another over the timeline (engine-level path interpolation); plays in every renderer, export, and embed
|
|
106
106
|
- **Grid, snapping & guides** - ▦ 20px grid, 🧲 snapping of drag/resize to grid/element-edges/artboard with live alignment guides, and 📏 rulers with draggable guides
|
|
@@ -237,7 +237,7 @@ GSAP-shaped functions at the top level. Teaching embeds are included: add
|
|
|
237
237
|
itself.
|
|
238
238
|
|
|
239
239
|
```html
|
|
240
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
240
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.95.0/cdn/tinyfly.iife.js"></script>
|
|
241
241
|
<script>
|
|
242
242
|
tinyfly.to('.box', { x: 200, rotate: 90, duration: 1, ease: 'power2.out' })
|
|
243
243
|
|
|
@@ -273,7 +273,7 @@ A teaching figure needs no code at all:
|
|
|
273
273
|
<script type="application/json" data-tinyfly-timeline>{ …timeline JSON with markers… }</script>
|
|
274
274
|
<figcaption>Appending to a full slice</figcaption>
|
|
275
275
|
</figure>
|
|
276
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
276
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.95.0/cdn/tinyfly.iife.js" data-tinyfly-auto></script>
|
|
277
277
|
```
|
|
278
278
|
|
|
279
279
|
See [Teaching Animations](docs/teaching.md).
|
|
@@ -372,7 +372,7 @@ Without a build step, the player bundle puts the same functions on a `tinyfly` g
|
|
|
372
372
|
<div data-tinyfly="box" style="width: 60px; height: 60px; background: #4a9eff;"></div>
|
|
373
373
|
</div>
|
|
374
374
|
|
|
375
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
375
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.95.0/cdn/tinyfly-player.iife.js"></script>
|
|
376
376
|
<script>
|
|
377
377
|
tinyfly.play('#animation', './animation.json', { loop: -1 })
|
|
378
378
|
</script>
|
|
@@ -481,7 +481,7 @@ Or skip the code entirely with declarative embeds (see [Teaching Animations](doc
|
|
|
481
481
|
<svg viewBox="0 0 720 200">…</svg>
|
|
482
482
|
<script type="application/json" data-tinyfly-timeline>{ …timeline JSON… }</script>
|
|
483
483
|
</figure>
|
|
484
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
484
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.95.0/cdn/tinyfly-embed.iife.js" data-tinyfly-auto></script>
|
|
485
485
|
```
|
|
486
486
|
|
|
487
487
|
### Audio / Video Sync
|
package/docs/acting.md
CHANGED
|
@@ -316,6 +316,11 @@ one). Scripts are deterministic, so two personas can be timed against each
|
|
|
316
316
|
other by reading one's `beats` before writing the other's (the **Code Review**
|
|
317
317
|
example does).
|
|
318
318
|
|
|
319
|
+
## Props
|
|
320
|
+
|
|
321
|
+
Vehicles, trees, houses and aircraft act from beats through the same acting
|
|
322
|
+
pass, and figures can ride them: see [Props](props.md).
|
|
323
|
+
|
|
319
324
|
## Acting on code
|
|
320
325
|
|
|
321
326
|
`codePanel()` makes a code listing a scene object. Its layout is plain
|
package/docs/api-reference.md
CHANGED
|
@@ -658,11 +658,13 @@ new WebGL2Renderer(gl, { overlay? }) // @algorisys/tinyf
|
|
|
658
658
|
loadScene3D(scene, { kinds: [characterObjects] }) // object kinds beyond the built-ins: ObjectKind { kind, validate?, prepare?, resolve }
|
|
659
659
|
// from @algorisys/tinyfly/characters:
|
|
660
660
|
characterObjects // the `character` object kind (pen or solid look)
|
|
661
|
+
propObjects // the `prop` object kind: { kind: 'prop', prop: 'car', options?, values?, look?, style? }
|
|
662
|
+
propPreset(name, options?) / PROP_PRESETS // a prop preset by name (did-you-mean on a wrong one)
|
|
661
663
|
drawCharacterInView(ctx, character, pose, projection, { height, time? }) / characterJointsInView(…)
|
|
662
664
|
skeletonInView(plan, pose, { height }, projection) / stagePlanSpace(plan, pose, { height }) / solvePlanSpace(plan, pose, height)
|
|
663
665
|
```
|
|
664
666
|
|
|
665
|
-
Types: `Scene3D`, `Object3D` (`group`, `mesh`, `camera`, `light`, `character`), `Geometry3D`,
|
|
667
|
+
Types: `Scene3D`, `Object3D` (`group`, `mesh`, `camera`, `light`, `character`, `prop`), `Geometry3D`,
|
|
666
668
|
`Material3D`, `ResolvedScene3D`, `DrawTriangle`. Tracks address objects as
|
|
667
669
|
`<sceneId>/<objectId>`; see [3D Scenes](scene-3d.md) for the properties.
|
|
668
670
|
|
package/docs/editor-guide.md
CHANGED
|
@@ -1058,7 +1058,7 @@ The dialog shows the generated HTML/JavaScript code with a **Copy Code** button.
|
|
|
1058
1058
|
**Steps to embed:**
|
|
1059
1059
|
1. Build the player: `npm run build:player`
|
|
1060
1060
|
2. Copy `lib/player/tinyfly-player.iife.js` to your project (or load
|
|
1061
|
-
`https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
1061
|
+
`https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.95.0/cdn/tinyfly-player.iife.js`
|
|
1062
1062
|
instead; see [Deployment](DEPLOYMENT.md))
|
|
1063
1063
|
3. Copy the generated code into your HTML
|
|
1064
1064
|
4. Adjust the script `src` path if needed
|
package/docs/examples.md
CHANGED
|
@@ -694,7 +694,7 @@ For simple website embedding without a build system.
|
|
|
694
694
|
</html>
|
|
695
695
|
```
|
|
696
696
|
|
|
697
|
-
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.
|
|
697
|
+
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.95.0/cdn/tinyfly-player.iife.js`.
|
|
698
698
|
|
|
699
699
|
---
|
|
700
700
|
|
package/docs/getting-started.md
CHANGED
|
@@ -185,7 +185,7 @@ with a GSAP-style call (durations are in seconds here):
|
|
|
185
185
|
```html
|
|
186
186
|
<div class="box" style="width:60px;height:60px;background:#4a9eff"></div>
|
|
187
187
|
|
|
188
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
188
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.95.0/cdn/tinyfly.iife.js"></script>
|
|
189
189
|
<script>
|
|
190
190
|
tinyfly.to('.box', { x: 200, duration: 1 })
|
|
191
191
|
</script>
|
package/docs/gsap-compat.md
CHANGED
|
@@ -74,7 +74,7 @@ Without a build step, the all-in-one bundle exposes the same functions on a
|
|
|
74
74
|
global — `tinyfly.to()`, `tinyfly.timeline()` and so on:
|
|
75
75
|
|
|
76
76
|
```html
|
|
77
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
77
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.95.0/cdn/tinyfly.iife.js"></script>
|
|
78
78
|
<script>
|
|
79
79
|
tinyfly.to('.box', { x: 200, duration: 1 })
|
|
80
80
|
</script>
|
package/docs/llm-guide.md
CHANGED
|
@@ -26,6 +26,23 @@ It is also the last part of `llms-full.txt`.
|
|
|
26
26
|
From code, the same catalog is `capabilities()` (and `capabilitiesMarkdown()`)
|
|
27
27
|
in `@algorisys/tinyfly/characters`.
|
|
28
28
|
|
|
29
|
+
## Props
|
|
30
|
+
|
|
31
|
+
For objects in a story (vehicles, trees, houses, aircraft, animals, birds),
|
|
32
|
+
use the presets (`car()`, `tree()`, `helicopter()`, `dog()`, `crow()`…) with
|
|
33
|
+
`propTarget` and `propScript`; the catalog lists each preset's actions,
|
|
34
|
+
controls and anchors, and `checkPropBeats` checks prop beats. `style: 'stick'`
|
|
35
|
+
draws any prop as line art to go with stick figures. A bird's `lift` is in
|
|
36
|
+
metres: to perch it on a branch or a roof, work the height out from that
|
|
37
|
+
prop's anchor (`propAt(tree, frame, 'tree').anchor('branch')`). In a 3D
|
|
38
|
+
scene a prop is an object, `{ kind: 'prop', prop: 'car', position, rotation: [0, 90, 0] }` (`rotateY` is a track, not a field),
|
|
39
|
+
loaded with `kinds: [characterObjects, propObjects]`; its controls are tracks
|
|
40
|
+
on the object. Script it in world metres with `propScript3D` (`to: [x, z]`,
|
|
41
|
+
`through: [[x, z], …]`, `face`), not with `propScript`, whose `to` is screen px.
|
|
42
|
+
Characters in a 3D scene walk the same way with `characterScript3D`
|
|
43
|
+
(`{ do: 'walk', to: [x, z] }`, `pose`, `gag`, `face`, `place`); a rider is
|
|
44
|
+
seated with `propRide3D` and spliced into its script with `spliceTracks`. See `docs/props.md`.
|
|
45
|
+
|
|
29
46
|
## Your own behaviours
|
|
30
47
|
|
|
31
48
|
Write new actions with `defineAction()` (from beats, or as timed pose steps),
|
package/docs/maps.md
CHANGED
|
@@ -14,8 +14,8 @@ On a page with no build step, load the maps add-on after the browser bundle; it
|
|
|
14
14
|
adds to the same `tinyfly` global:
|
|
15
15
|
|
|
16
16
|
```html
|
|
17
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
18
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
17
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.95.0/cdn/tinyfly.iife.js"></script>
|
|
18
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.95.0/cdn/tinyfly-maps.iife.js"></script>
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
It is a separate script because the offline world map it carries adds about
|
package/docs/props.md
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# Props: Everyday Objects with Behaviours
|
|
2
|
+
|
|
3
|
+
Stories need a world: cars and buses, bikes and tractors, trees and houses,
|
|
4
|
+
helicopters and planes. In tinyfly these are **props**: objects that act, the
|
|
5
|
+
way the figures do, and that can be seen from any side.
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import { car, propTarget, propScript, drawProp, drawPropEffects } from '@algorisys/tinyfly/characters'
|
|
9
|
+
|
|
10
|
+
const prop = car()
|
|
11
|
+
const target = propTarget({ x: 200, y: 300, prop, scale: 52, values: { turn: 1 }, look: 'pencil' })
|
|
12
|
+
const script = propScript('car', prop, [
|
|
13
|
+
{ do: 'honk' },
|
|
14
|
+
{ do: 'turn', toward: 'viewer' },
|
|
15
|
+
{ do: 'turn', toward: 'right' },
|
|
16
|
+
{ do: 'drive', to: 480 },
|
|
17
|
+
{ do: 'bump' },
|
|
18
|
+
{ do: 'brake', to: 620 },
|
|
19
|
+
], { from: 200, ground: 300, scale: 52, start: { turn: 1 }, exaggeration: 1.5 })
|
|
20
|
+
|
|
21
|
+
// each frame:
|
|
22
|
+
drawProp(ctx, target, { time, state }, 'car')
|
|
23
|
+
drawPropEffects(ctx, script.effects, time)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## What a prop is
|
|
27
|
+
|
|
28
|
+
A prop is a **3D rig of simple parts on pivots**: boxes, cylinders, ellipsoids,
|
|
29
|
+
side profiles made solid (`extrude`), flat panels and tubes. Named **controls**
|
|
30
|
+
move the parts (`wheelSpin` turns the wheels, `door` swings the doors), and
|
|
31
|
+
**anchors** mark where other things attach (`seat`, `door`, `chimney`).
|
|
32
|
+
|
|
33
|
+
It is seen through the same kind of view as the v2 character, so it **turns
|
|
34
|
+
toward the camera**:
|
|
35
|
+
|
|
36
|
+
- `turn` 0 faces the viewer, 1 screen-right, 2 away, 3 (or −1) screen-left,
|
|
37
|
+
with every angle in between drawn in 3D.
|
|
38
|
+
- `tilt` sets how far the camera looks down on it (12° gives the ¾ look).
|
|
39
|
+
|
|
40
|
+
It is drawn with the characters' pens, so `look: 'clean' | 'pencil' |
|
|
41
|
+
'silhouette'` match the figures beside it. Each part has its own pencil seed,
|
|
42
|
+
so lines don't jump as parts change drawing order while turning. Faces are
|
|
43
|
+
shaded by how they face the light, outlines follow the silhouette and the
|
|
44
|
+
creases, and a **contact shadow** keeps it on the ground. The shadow shrinks
|
|
45
|
+
as the prop lifts.
|
|
46
|
+
|
|
47
|
+
Every prop has these common controls (plus its own):
|
|
48
|
+
|
|
49
|
+
| Control | Unit | What it does |
|
|
50
|
+
|---|---|---|
|
|
51
|
+
| `turn` | quarter turns | which way it faces |
|
|
52
|
+
| `tilt` | degrees | how far the camera looks down on it |
|
|
53
|
+
| `pitch` | degrees | nose up (+) or down (−) |
|
|
54
|
+
| `roll` | degrees | tipped onto a side |
|
|
55
|
+
| `squash` | factor | squash and stretch about the ground, keeping volume |
|
|
56
|
+
| `lift` | metres | off the ground |
|
|
57
|
+
| `lean` | shear | the top sheared forward (speed) or back (drag) |
|
|
58
|
+
| `size` | factor | its size: 0 gone, 1 as built |
|
|
59
|
+
|
|
60
|
+
`describeTarget(target)` lists them all with the prop's own controls and its
|
|
61
|
+
actions; `checkTracks` checks tracks against them.
|
|
62
|
+
|
|
63
|
+
## Behaviours and the 12 principles
|
|
64
|
+
|
|
65
|
+
`propScript(id, prop, beats, options)` compiles beats into tracks through the
|
|
66
|
+
same acting pass the figures use. Families write their actions as key poses of
|
|
67
|
+
the controls, and the pass adds the rest. The principles, and where they live:
|
|
68
|
+
|
|
69
|
+
| Principle | In props |
|
|
70
|
+
|---|---|
|
|
71
|
+
| Squash and stretch | `squash` (volume-preserving): bumps, landings, pops, honks |
|
|
72
|
+
| Anticipation | a drive rocks back and squats before it lunges; a helicopter's skids squash as it spools up |
|
|
73
|
+
| Staging, solid drawing | `turn` and `tilt`: any view, drawn in 3D |
|
|
74
|
+
| Straight ahead and pose to pose | keyed beats, plus procedural motion (gusts, hovering bob) |
|
|
75
|
+
| Follow-through, overlapping action | the acting rig's depths (the canopy trails the trunk); `springFollow` (a car's antenna trails on a spring) |
|
|
76
|
+
| Slow in and slow out | eases, and the acting style |
|
|
77
|
+
| Arcs | lift curves, flight paths, a plane's loop |
|
|
78
|
+
| Secondary action | effects: dust, exhaust, skid marks, honk lines, leaves, smoke |
|
|
79
|
+
| Timing | acting styles (`full`, `snappy`, `limited`), drawing on twos |
|
|
80
|
+
| Exaggeration | `exaggeration`: 0.5 restrained, 1 as designed, 2 a cartoon |
|
|
81
|
+
| Appeal | the families' design |
|
|
82
|
+
|
|
83
|
+
Options:
|
|
84
|
+
- `from` / `ground`: where its middle was placed (its `x`/`y` tracks are offsets).
|
|
85
|
+
- `scale`: px per metre, as its target draws it.
|
|
86
|
+
- `style`: an acting style (default `snappy`).
|
|
87
|
+
- `exaggeration`: as above.
|
|
88
|
+
- `start`: its starting control values.
|
|
89
|
+
|
|
90
|
+
The result gives `tracks`, `beats` (with `contact` / `release` times, as figure
|
|
91
|
+
beats do) and `effects` (cues for `drawPropEffects`).
|
|
92
|
+
|
|
93
|
+
Beats have the fields `do`, `at`, `for`, `to`, `toward`, `speed`, `open`, `on`,
|
|
94
|
+
`height` and `wind`. `checkPropBeats(beats, prop)` reports wrong names with the
|
|
95
|
+
one probably meant, and `propScript` throws on them.
|
|
96
|
+
|
|
97
|
+
**Every prop can:**
|
|
98
|
+
- `hold`
|
|
99
|
+
- `turn` (`toward`: viewer, right, away, left, or a number)
|
|
100
|
+
- `pop`: spring into being, stretched, with overshoot
|
|
101
|
+
- `vanish`
|
|
102
|
+
|
|
103
|
+
## The families
|
|
104
|
+
|
|
105
|
+
| Preset | Actions |
|
|
106
|
+
|---|---|
|
|
107
|
+
| `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 |
|
|
108
|
+
| `tree()` | `sway` (`wind`, `for`), `shake`, `shedLeaves` |
|
|
109
|
+
| `house()` | `door` (`open`), `lights` (`on`), `smoke` (`for`, runs in the background), `shake` |
|
|
110
|
+
| `helicopter()` | `takeOff` (`height`), `fly` (`to`, `height`), `hover`, `land` |
|
|
111
|
+
| `airplane()` | `takeOff` (`to`, `height`), `fly` (`to`, `height`), `loop`, `land` (`to`) |
|
|
112
|
+
| `horse()` | `walk`, `trot`, `canter`, `gallop` (`to`), `rear`, `buck`, `neigh`, `graze`, `sit`, `jump`, `nod`, `swish` |
|
|
113
|
+
| `dog()` | `walk`, `trot`, `run` (`to`), `bark`, `wag`, `sniff`, `sit`, `jump`, `nod`, `swish` |
|
|
114
|
+
| `cat()` | `walk`, `trot`, `run` (`to`), `meow`, `arch`, `pounce` (`to`), `sit`, `jump`, `nod`, `swish` |
|
|
115
|
+
| `cow()` | `walk`, `trot` (`to`), `moo`, `graze`, `sit`, `jump`, `nod`, `swish` |
|
|
116
|
+
| `songbird()`, `crow()` | `hop`, `walk` (`to`), `peck` (`for`), `flap` (`for`), `fly` (`to`, `height`), `land` (`height`, `to`), `tweet` / `caw` |
|
|
117
|
+
| `chicken()` | `walk` (`to`), `peck`, `flap`, `flutter`, `cluck` (it cannot fly) |
|
|
118
|
+
|
|
119
|
+
**Line art.** `propTarget({ …, style: 'stick' })` (or `drawSolvedProp(…, { style: 'stick' })`)
|
|
120
|
+
draws a prop as line art to go with stick figures: tubes (legs, necks, tails,
|
|
121
|
+
frames) as single even strokes, other shapes outlined and filled with the
|
|
122
|
+
paper colour (`paper`), dark details kept dark. Both looks work with it.
|
|
123
|
+
|
|
124
|
+
**Animals.** `quadruped(spec)` builds a four-legged animal from proportions;
|
|
125
|
+
`horse()`, `dog()`, `cat()` and `cow()` are presets. A horse is a prop too: a barrel body, neck, head, four jointed
|
|
126
|
+
legs and a tail. A rig's `derive` works its legs out from its gait (`gait`: 0
|
|
127
|
+
walk, 1 trot, 2 canter, 3 gallop) and the phase of its stride (`walk`), each
|
|
128
|
+
gait with its own footfall pattern (four beats; diagonal pairs; three beats
|
|
129
|
+
with a rock; the gallop). The phase is keyed with the distance, so the hooves
|
|
130
|
+
keep pace with the ground. Rearing pitches it up about its hind hooves; its
|
|
131
|
+
tail trails on a spring.
|
|
132
|
+
|
|
133
|
+
**Birds.** `bird(spec)` builds one from proportions; `songbird()`, `crow()` and
|
|
134
|
+
`chicken()` are presets. Its wings fold back along the body at rest and open
|
|
135
|
+
out with `spread`. They beat from the shoulders: `flap` raises or lowers them,
|
|
136
|
+
and while `flapping` is on, the rig's `derive` beats them from a phase,
|
|
137
|
+
`wingbeat`, keyed steadily so the wings keep their rhythm (a songbird nine beats
|
|
138
|
+
a second, a crow four). Its head pecks from a neck joint (`peck`; a chicken's
|
|
139
|
+
neck stretches down to reach), and it walks with its head bobbing or hops.
|
|
140
|
+
`fly` takes off with a crouch and a leap (no crouch if it is already in the
|
|
141
|
+
air) and flies to `height` metres; `land` comes down to the ground or to a
|
|
142
|
+
perch (`height`). Perch it with anchors:
|
|
143
|
+
|
|
144
|
+
```js
|
|
145
|
+
const branch = propAt(treeTarget, { time: 0 }, 'tree').anchor('branch')
|
|
146
|
+
const perch = (GROUND - branch.y) / birdScale // metres above the ground
|
|
147
|
+
propScript('robin', songbird(), [
|
|
148
|
+
{ do: 'fly', to: 380, height: 0.25 }, { do: 'land' }, { do: 'hop', to: 410 }, { do: 'peck' },
|
|
149
|
+
{ do: 'fly', to: branch.x, height: perch }, { do: 'land', height: perch }, { do: 'tweet' },
|
|
150
|
+
], { from: branch.x, ground: GROUND, scale: birdScale, start: { turn: 1, lift: perch } })
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Wheels **roll exactly the distance driven**: `wheelSpin` is keyed in step with
|
|
154
|
+
the motion, and wheels of different sizes (a tractor's) turn at their own
|
|
155
|
+
rates. Rotors and propellers spin from `rotor`, keyed exactly, and blur into a
|
|
156
|
+
disc at speed.
|
|
157
|
+
|
|
158
|
+
Make your own from the family generators: `vehicle(spec)` takes:
|
|
159
|
+
- a body side profile and a width
|
|
160
|
+
- a glass cabin with pillars
|
|
161
|
+
- wheels (any radius; `side: 0` for a bike's middle line; `style: 'spoked'`)
|
|
162
|
+
- doors, lights, side windows, frame tubes, an antenna, a seat and extra parts
|
|
163
|
+
|
|
164
|
+
`tree(spec)` and `house(spec)` take sizes and colours.
|
|
165
|
+
|
|
166
|
+
## Figures with props
|
|
167
|
+
|
|
168
|
+
- **Riding.** `propRide({ prop, propId, propTracks, anchor: 'seat', figure, figureId, start, end, offset })`
|
|
169
|
+
writes a figure's `x`/`y` (and `turn`/`facing`) so it is carried at an
|
|
170
|
+
anchor and turns with the prop. `spliceTracks(heroTracks, ride, { from, to })`
|
|
171
|
+
puts that into the figure's script. Pass a rider to `drawProp(…, { rider })`
|
|
172
|
+
and it is drawn between the prop's far and near parts: a driver behind the
|
|
173
|
+
windscreen, a figure in a doorway behind a door until it opens.
|
|
174
|
+
- **Towing.** `propTow({ leader, leaderId, leaderTracks, hitch: 'hitch', towed, towedId, anchor: 'shafts', start, end })`
|
|
175
|
+
makes a prop follow another: a cart behind a horse turns with it, keeps its
|
|
176
|
+
shaft tips on the horse's hitch, and rolls its wheels the distance it covers.
|
|
177
|
+
- **Reaching.** Figure beats aim at anchors:
|
|
178
|
+
`propAt(target, frame, id).anchor('door')` gives the scene point for a
|
|
179
|
+
`put`, `grab` or `push`.
|
|
180
|
+
|
|
181
|
+
See the gallery cards **Road Trip**, **Windy Day**, **Helicopter**,
|
|
182
|
+
**Traffic**, **Horse & Cart**, **Farmyard**, **Birds** and **3D Scene: Village**.
|
|
183
|
+
|
|
184
|
+
## In 3D scenes
|
|
185
|
+
|
|
186
|
+
Props stand in `@algorisys/tinyfly/scene-3d` scenes too:
|
|
187
|
+
`{ kind: 'prop', prop: 'car', position, rotation, values }` with
|
|
188
|
+
`loadScene3D(scene, { kinds: [characterObjects, propObjects] })`. The scene's
|
|
189
|
+
camera sees them in perspective from anywhere, drawn with the same pens; each
|
|
190
|
+
prop is drawn a column at a time, so figures walking round a bus or a house
|
|
191
|
+
sort rightly against it. A part's `layer` says which of two parts that sit
|
|
192
|
+
into each other is drawn over in 3D (a cabin over a car's body).
|
|
193
|
+
`propScript3D(id, prop, beats, { scene, position, heading })` scripts them in
|
|
194
|
+
world metres: `{ do: 'drive', to: [x, z] }`, `{ do: 'walk', through: [[x, z], …] }`,
|
|
195
|
+
`{ do: 'fly', to, height }`, `{ do: 'face', toward }`, and their actions,
|
|
196
|
+
with wheels and strides keyed with the distance (from each prop's `moves`).
|
|
197
|
+
`propPreset(name, options)` makes a preset by name. See
|
|
198
|
+
[3D Scenes](scene-3d.md#props) and the gallery card **3D Scene: Village**.
|
|
199
|
+
|
|
200
|
+
## Not yet
|
|
201
|
+
|
|
202
|
+
- Pedalling and steering poses for riders
|
package/docs/scene-3d.md
CHANGED
|
@@ -242,10 +242,151 @@ plays in 3D: `stickToHuman(danceFrame(style, beat))` gives the pose, and
|
|
|
242
242
|
`lift` and ground contact behave as they do front-on; seen front-on through a
|
|
243
243
|
flat camera, a character is exactly the 2D figure.
|
|
244
244
|
|
|
245
|
+
**Walking in metres.** `characterScript3D(id, beats, { scene, position, heading, height })`
|
|
246
|
+
scripts a character in world metres, as `propScript3D` does props:
|
|
247
|
+
|
|
248
|
+
```js
|
|
249
|
+
import { characterScript3D } from '@algorisys/tinyfly/characters'
|
|
250
|
+
|
|
251
|
+
const tum = characterScript3D('tum', [
|
|
252
|
+
{ do: 'walk', to: [1.4, 1.6] }, // a gait, to a point [x, z] metres
|
|
253
|
+
{ do: 'pose', pose: 'wave', for: 500 }, // a named pose (or pose fields)
|
|
254
|
+
{ do: 'run', through: [[3.5, 0], [2.5, -3], [-3, 0]] }, // along a smooth path
|
|
255
|
+
{ do: 'face', toward: [0, 3] }, // a point, or a heading in degrees
|
|
256
|
+
{ do: 'gag', gag: 'take' },
|
|
257
|
+
], { scene: 'village', position: [0.6, 0.2], heading: 0 })
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
A move is a gait (`walk`, `run`, `sneak`, `strut`, `tired`, `bouncy`,
|
|
261
|
+
`doubleBounce`, `shove`); it turns to face the way first and goes at the
|
|
262
|
+
gait's pace for its height (or `speed`, `for`). It keys `walk` (the gait's
|
|
263
|
+
phase) with the distance, one stride per cycle, so the feet stay planted, plus
|
|
264
|
+
`walking` (eased in and out) and `gait`. The character object turns those into
|
|
265
|
+
the stepping pose as it draws, on the pose it holds: a wave carries on while it
|
|
266
|
+
walks. Objects take `gait` and `walking` as fields too.
|
|
267
|
+
|
|
268
|
+
**Riding.** `propRide3D({ prop, propId, propTracks, scene, placement, anchor, riderId, pose, start, end, mount?, dismount? })`
|
|
269
|
+
keeps a rider's hips on a prop's seat anchor (a horse's `saddle`, a bike's or
|
|
270
|
+
a cart's `seat`) as the prop moves, turns, bobs with its stride and pitches,
|
|
271
|
+
writing the rider's `x`, `y`, `z` and `rotateY`; `mount: { from: [x, z] }` and
|
|
272
|
+
`dismount: { to: [x, z] }` hop it on and off. `spliceTracks(riderTracks, ride, { from, to })`
|
|
273
|
+
puts the ride into the rider's script, which holds the riding pose
|
|
274
|
+
(`RIDING_POSES.astride` or `.seated`) meanwhile and `place`s it where it got
|
|
275
|
+
off. A character in a scene is drawn part by part, each part at its own depth
|
|
276
|
+
(`characterPartsInView`), so a leg astride a horse shows on each side of it.
|
|
277
|
+
A seat inside a closed cabin (a car's) is not handled yet: its glass is opaque
|
|
278
|
+
in 3D.
|
|
279
|
+
|
|
245
280
|
Outside scenes, `drawCharacterInView(ctx, character, pose, projection, { height })`
|
|
246
281
|
draws a character through any camera (`projection.toView` / `toScreen`), and
|
|
247
282
|
`skeletonInView` / `stagePlanSpace` give its joints.
|
|
248
283
|
|
|
284
|
+
## Props
|
|
285
|
+
|
|
286
|
+
Props (cars, trucks, trees, houses, aircraft, horses, dogs, birds…) stand in
|
|
287
|
+
scenes too, named by their preset in plain data and drawn with the same pens
|
|
288
|
+
as the characters, solid or as line art:
|
|
289
|
+
|
|
290
|
+
```js
|
|
291
|
+
import { characterObjects, propObjects } from '@algorisys/tinyfly/characters'
|
|
292
|
+
|
|
293
|
+
const scene = loadScene3D({
|
|
294
|
+
id: 'village', camera: 'cam', /* … */
|
|
295
|
+
objects: [
|
|
296
|
+
/* camera, lights, ground … */
|
|
297
|
+
{ id: 'car', kind: 'prop', prop: 'car', position: [0, 0, 3], rotation: [0, 90, 0], values: { door: 1 } },
|
|
298
|
+
{ id: 'barn', kind: 'prop', prop: 'house', position: [3.5, 0, -5], options: { colors: { walls: '#c0583f' } } },
|
|
299
|
+
{ id: 'crow', kind: 'prop', prop: 'crow', position: [0, 3, 0], values: { spread: 1, flapping: 1 }, style: 'stick' },
|
|
300
|
+
],
|
|
301
|
+
}, { kinds: [characterObjects, propObjects] })
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
| Field | |
|
|
305
|
+
|---|---|
|
|
306
|
+
| `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 |
|
|
307
|
+
| `options` | the preset's options (colours, sizes) |
|
|
308
|
+
| `values` | its control values as placed (`door`, `lights`, `spread`, …) |
|
|
309
|
+
| `look` | `clean` (default), `pencil` or `silhouette`, drawn with the figures' pens; or `mesh`, built of the scene's own meshes |
|
|
310
|
+
| `shading`, `outline` | the mesh look's shading (`toon` by default) and outline width in px (default 2) |
|
|
311
|
+
| `style` | `solid` (default) or `stick` (line art) |
|
|
312
|
+
| `ink`, `paper` | outline colour, and the paper a stick prop is filled with |
|
|
313
|
+
| `shadow` | its contact shadow (default true) |
|
|
314
|
+
|
|
315
|
+
A prop is built in metres, faces +z and stands on its object's ground; the
|
|
316
|
+
scene's camera turns it (its own `turn` and `tilt` are not used), and faces
|
|
317
|
+
are culled toward the camera's eye, so it is right in perspective close up.
|
|
318
|
+
Its controls are tracks on its object: `village/car` `wheelSpin`,
|
|
319
|
+
`village/horse` `walk` and `walking`, `village/crow` `wingbeat`. Keep wheels
|
|
320
|
+
and strides honest the way the 2D scripts do: key `wheelSpin` as the distance
|
|
321
|
+
over the wheel radius (`car().wheelRadius`), and a horse's `walk` phase as the
|
|
322
|
+
distance over `horseStrideLength('walk')`.
|
|
323
|
+
|
|
324
|
+
**Scripting props in metres.** `propScript3D(id, prop, beats, { scene, position, heading })`
|
|
325
|
+
compiles beats with world targets into the object's tracks (`x`, `z`,
|
|
326
|
+
`rotateY` and its controls):
|
|
327
|
+
|
|
328
|
+
```js
|
|
329
|
+
import { propScript3D, car, horse, crow } from '@algorisys/tinyfly/characters'
|
|
330
|
+
|
|
331
|
+
const drive = propScript3D('car', car(), [
|
|
332
|
+
{ do: 'drive', to: [9, 3] }, // a point on the ground, [x, z] metres
|
|
333
|
+
{ do: 'honk' }, // any action, as in 2D (controls only)
|
|
334
|
+
{ do: 'drive', through: [[11, 4.6], [9, 6.2], [-9, 6.2]] }, // a smooth path through points
|
|
335
|
+
{ do: 'face', toward: [0, 0] }, // a point, or a heading in degrees
|
|
336
|
+
], { scene: 'village', position: [-9, 3], heading: 90 })
|
|
337
|
+
const flight = propScript3D('crow', crow(), [{ do: 'fly', to: [2, 1], height: 0 }], { scene: 'village', position: [0, 5], values: { lift: 3 } })
|
|
338
|
+
const timeline = deserializeTimeline({ id: 'village', tracks: [...drive.tracks, ...flight.tracks] })
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
A move (a prop's `moves`: `drive`; `walk`, `trot`, `canter`, `gallop` or
|
|
342
|
+
`run`; a bird's `walk` and `fly`; an aircraft's `fly`) turns to face the way
|
|
343
|
+
first, then goes at its own speed (or `speed`, metres per second, or `for`
|
|
344
|
+
ms), easing in and out. Its wheels and strides are keyed with the distance at
|
|
345
|
+
every moment, so wheels roll and feet step exactly; a wingbeat or a rotor
|
|
346
|
+
keeps time. A flier's `height` is how high it goes (`0` lands it); between
|
|
347
|
+
flights it stays up with its wings beating. `face`, `hold` and the prop's own
|
|
348
|
+
actions (`honk`, `bark`, `peck`, `door`…) work as in 2D. `checkPropBeats3D`
|
|
349
|
+
names what was probably meant; `end` gives where it finished, for the next
|
|
350
|
+
script.
|
|
351
|
+
|
|
352
|
+
**Lit by the scene.** A pen-drawn prop is lit by the scene's lights as its
|
|
353
|
+
meshes are (ambient, directional, point and spot, with fog): each face at its
|
|
354
|
+
place in the world, so a low orange sun warms its sunlit sides and a night's
|
|
355
|
+
blue moon darkens it. Glowing parts (lit windows, headlights: a house's or a
|
|
356
|
+
car's `lights` control) glow over the top, so they shine in the dark. A scene
|
|
357
|
+
with no lights keeps the props' own light, which follows the camera; line art
|
|
358
|
+
(`style: 'stick'`) stays unlit. A pen-drawn character's skin takes the light
|
|
359
|
+
reaching its chest from the camera's side (at most its own colour) and the fog
|
|
360
|
+
there: lit from behind the camera its face shows, against a low sun it goes
|
|
361
|
+
dark, at night it dims. Its ink is its own, so give a character a light ink in
|
|
362
|
+
a dark scene (`character: { ink: '#dfe5f0' }`). The solid look is lit as
|
|
363
|
+
meshes are.
|
|
364
|
+
|
|
365
|
+
**The mesh look.** `look: 'mesh'` builds a prop of the scene's own meshes, as
|
|
366
|
+
a character's `look: 'solid'` does: each part's shape is built once and placed
|
|
367
|
+
each frame, lit and outlined like everything else, glass see-through (so a
|
|
368
|
+
driver shows behind a windscreen), glowing parts as light of their own, hidden
|
|
369
|
+
faces left out, its shadow a soft disc. With the WebGL2 renderer its depth
|
|
370
|
+
order is exact, pixel by pixel; the canvas renderer sorts it triangle by
|
|
371
|
+
triangle, which can slip where a small part lies on a big face (a window on a
|
|
372
|
+
wall). For the canvas, the pen looks sort better (below); for exact depth, use
|
|
373
|
+
the mesh look with WebGL2.
|
|
374
|
+
|
|
375
|
+
**How props sort.** A pen-drawn prop is not drawn whole at one depth. It is
|
|
376
|
+
cut into columns about a metre across (along its length and width), and each
|
|
377
|
+
column sorts at its own depth among the scene's other things, so a figure
|
|
378
|
+
walking past a bus is covered by its front end and covers its back. Inside a
|
|
379
|
+
column, faces are drawn far to near, each with its own outlines. Faces no one
|
|
380
|
+
can see are left out: those inside another solid part, or lying against one
|
|
381
|
+
(a house's wall tops under its roof, a tyre's tread inside the fender). A
|
|
382
|
+
face lying on another part's face (a light, a window, a door) is drawn just
|
|
383
|
+
after it. Where a part sits partly into another, its `layer` says which is
|
|
384
|
+
drawn over (a car's cabin over its body, a roof over its walls). What is
|
|
385
|
+
nearer than the camera's near plane is cut away, so a camera can come close or
|
|
386
|
+
go inside. A pen-drawn character is still drawn whole at its middle's depth,
|
|
387
|
+
and painter's order has limits: for exact order use the solid look and the
|
|
388
|
+
WebGL2 renderer.
|
|
389
|
+
|
|
249
390
|
**Other object kinds** come the same way: an `ObjectKind` validates its
|
|
250
391
|
objects, prepares them once, and each frame returns meshes (shaded and sorted
|
|
251
392
|
with the scene's) and drawables (drawn whole at their depth). Pass it in
|
package/docs/teaching.md
CHANGED
|
@@ -25,7 +25,7 @@ path for all of that:
|
|
|
25
25
|
</figure>
|
|
26
26
|
|
|
27
27
|
<!-- once, anywhere on the page (a site-wide footer is fine) -->
|
|
28
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
28
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.95.0/cdn/tinyfly-embed.iife.js" data-tinyfly-auto></script>
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
Every `[data-tinyfly-embed]` mounts when the page is ready, with no per-post
|