@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/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.94.0/cdn/tinyfly-embed.iife.js" data-tinyfly-auto></script>
28
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.97.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