@algorisys/tinyfly 0.86.2 → 0.87.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 -4
- package/bin/tinyfly.mjs +44 -6
- package/lib/addons/adapters.js +168 -120
- package/lib/addons/characters.js +2 -2
- package/lib/addons/maps.js +1 -1
- package/lib/addons/scene-3d-webgl.js +52 -49
- package/lib/addons/scene-3d.js +2 -2
- package/lib/addons/shading-o5T_v9DT.js +89 -0
- package/lib/addons/{sketch-CA8ZXhxI.js → sketch-CYPUbk3Q.js} +2 -2
- package/lib/browser/tinyfly-scene-3d-webgl.iife.js +4 -2
- package/lib/browser/tinyfly-scene-3d.iife.js +2 -2
- package/lib/browser/tinyfly.iife.js +4 -4
- package/lib/browser/tinyfly.js +3161 -3102
- package/lib/browser/tinyfly.umd.js +4 -4
- package/lib/headless/headless.js +162 -17
- package/lib/types/adapters/canvas/bloom.d.ts +33 -0
- package/lib/types/adapters/canvas/index.d.ts +2 -0
- package/lib/types/adapters/canvas/offscreen.d.ts +13 -0
- package/lib/types/browser/index.d.ts +2 -0
- package/lib/types/headless/index.d.ts +1 -0
- package/lib/types/headless/loop-check.d.ts +41 -0
- package/lib/types/headless/node-video.d.ts +8 -0
- package/lib/types/headless/video-scene.d.ts +7 -1
- package/lib/types/scene-3d/scene-types.d.ts +2 -1
- package/lib/types/scene-3d/webgl/gl-data.d.ts +1 -0
- package/lib/types/scene-3d/webgl/shaders.d.ts +1 -1
- package/package.json +1 -1
- package/lib/addons/shading-ByG9UXd0.js +0 -85
package/README.md
CHANGED
|
@@ -96,6 +96,8 @@ A lightweight, API-driven animation engine and visual editor for creating high-p
|
|
|
96
96
|
- **Camera** - Animate a pan/zoom/rotate over the whole stage (a reserved `Camera` layer driven by ordinary tracks). One-click add, a **🎥 Camera inspector** (Pan/Zoom/Rotation keyframed at the playhead), on-stage **✋ Pan** dragging, and a dedicated 🎥 lane at the top of the timeline; applies in every preview, export, and embed. Ready-made Push In / Pan Across / Orbit Reveal samples
|
|
97
97
|
- **Polygon & star shapes** - ⬡ Polygon and ★ Star elements are parametric paths — edit sides / points / inner ratio in Properties and they regenerate and rescale; they render and export like any path
|
|
98
98
|
- **Pen tool** - ✒️ Draw custom bezier paths: click for corners, click-drag for curves (Alt for a cusp), drag existing anchors/handles to adjust, snap points to grid/guides, click the first point or Enter to finish
|
|
99
|
+
- **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)
|
|
100
|
+
- **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)
|
|
99
101
|
- **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)
|
|
100
102
|
- **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)
|
|
101
103
|
- **Shape morph** - 🌀 Tween one path into another over the timeline (engine-level path interpolation); plays in every renderer, export, and embed
|
|
@@ -232,7 +234,7 @@ GSAP-shaped functions at the top level. Teaching embeds are included: add
|
|
|
232
234
|
itself.
|
|
233
235
|
|
|
234
236
|
```html
|
|
235
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
237
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.87.0/cdn/tinyfly.iife.js"></script>
|
|
236
238
|
<script>
|
|
237
239
|
tinyfly.to('.box', { x: 200, rotate: 90, duration: 1, ease: 'power2.out' })
|
|
238
240
|
|
|
@@ -268,7 +270,7 @@ A teaching figure needs no code at all:
|
|
|
268
270
|
<script type="application/json" data-tinyfly-timeline>{ …timeline JSON with markers… }</script>
|
|
269
271
|
<figcaption>Appending to a full slice</figcaption>
|
|
270
272
|
</figure>
|
|
271
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
273
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.87.0/cdn/tinyfly.iife.js" data-tinyfly-auto></script>
|
|
272
274
|
```
|
|
273
275
|
|
|
274
276
|
See [Teaching Animations](docs/teaching.md).
|
|
@@ -367,7 +369,7 @@ Without a build step, the player bundle puts the same functions on a `tinyfly` g
|
|
|
367
369
|
<div data-tinyfly="box" style="width: 60px; height: 60px; background: #4a9eff;"></div>
|
|
368
370
|
</div>
|
|
369
371
|
|
|
370
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
372
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.87.0/cdn/tinyfly-player.iife.js"></script>
|
|
371
373
|
<script>
|
|
372
374
|
tinyfly.play('#animation', './animation.json', { loop: -1 })
|
|
373
375
|
</script>
|
|
@@ -476,7 +478,7 @@ Or skip the code entirely with declarative embeds (see [Teaching Animations](doc
|
|
|
476
478
|
<svg viewBox="0 0 720 200">…</svg>
|
|
477
479
|
<script type="application/json" data-tinyfly-timeline>{ …timeline JSON… }</script>
|
|
478
480
|
</figure>
|
|
479
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
481
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.87.0/cdn/tinyfly-embed.iife.js" data-tinyfly-auto></script>
|
|
480
482
|
```
|
|
481
483
|
|
|
482
484
|
### Audio / Video Sync
|
package/bin/tinyfly.mjs
CHANGED
|
@@ -14,13 +14,16 @@
|
|
|
14
14
|
* Print the markup with that frame written in, for places that run no
|
|
15
15
|
* JavaScript (RSS, email, print, previews).
|
|
16
16
|
*
|
|
17
|
-
* tinyfly video <scene.mjs> [-o <out.mp4>] [--stills <dir>] [--
|
|
18
|
-
* [--crf <n>] [--no-audio] [--srt <file>] [--vtt <file>]
|
|
17
|
+
* tinyfly video <scene.mjs> [-o <out.mp4>] [--stills <dir>] [--frames <i,j,…> | --times <ms,ms,…>]
|
|
18
|
+
* [--loop-check] [--scale <n>] [--fps <n>] [--crf <n>] [--no-audio] [--srt <file>] [--vtt <file>]
|
|
19
19
|
* Render a scene module to an MP4 without a browser. The module's default
|
|
20
20
|
* export is a VideoScene (or a function returning one): a timeline and
|
|
21
21
|
* canvas targets, a draw(ctx, frame) function, or both. --stills writes
|
|
22
|
-
* one PNG per marker step instead of a video
|
|
23
|
-
*
|
|
22
|
+
* one PNG per marker step instead of a video, or one per frame / time
|
|
23
|
+
* given with --frames or --times. --loop-check renders five frames and
|
|
24
|
+
* says whether the video loops (exit 1 when it does not). Needs ffmpeg on
|
|
25
|
+
* the PATH (not for stills or --loop-check) and the optional package
|
|
26
|
+
* @napi-rs/canvas.
|
|
24
27
|
*/
|
|
25
28
|
import { readFileSync, writeFileSync } from 'node:fs'
|
|
26
29
|
import { basename, dirname, extname, join, resolve } from 'node:path'
|
|
@@ -51,12 +54,25 @@ const numberFlag = (name) => {
|
|
|
51
54
|
return number
|
|
52
55
|
}
|
|
53
56
|
|
|
57
|
+
/** A comma-separated list of numbers (frames or ms), or undefined when the flag is absent. */
|
|
58
|
+
function listFlag(name) {
|
|
59
|
+
const value = flag(name)
|
|
60
|
+
if (value === undefined) return undefined
|
|
61
|
+
const numbers = value.split(',').map((part) => Number(part.trim()))
|
|
62
|
+
if (numbers.length === 0 || numbers.some((n) => !Number.isFinite(n) || n < 0)) {
|
|
63
|
+
console.error(`tinyfly: ${name} needs numbers separated by commas (got ${value})`)
|
|
64
|
+
process.exit(2)
|
|
65
|
+
}
|
|
66
|
+
return numbers
|
|
67
|
+
}
|
|
68
|
+
|
|
54
69
|
const usage = () => {
|
|
55
70
|
console.error(
|
|
56
71
|
'Usage:\n' +
|
|
57
72
|
' tinyfly validate <timeline.json> [<timeline.json> …] [--markup <file>]\n' +
|
|
58
73
|
' tinyfly render <timeline.json> <markup file> [--at start|end|<ms>|<marker id>]\n' +
|
|
59
|
-
' tinyfly video <scene.mjs> [-o <out.mp4>] [--stills <dir>] [--
|
|
74
|
+
' tinyfly video <scene.mjs> [-o <out.mp4>] [--stills <dir>] [--frames <i,j,…> | --times <ms,…>] [--loop-check]\n' +
|
|
75
|
+
' [--scale <n>] [--fps <n>] [--crf <n>] [--no-audio] [--srt <file>] [--vtt <file>]'
|
|
60
76
|
)
|
|
61
77
|
process.exit(2)
|
|
62
78
|
}
|
|
@@ -114,8 +130,15 @@ async function video() {
|
|
|
114
130
|
const fps = numberFlag('--fps')
|
|
115
131
|
const crf = numberFlag('--crf')
|
|
116
132
|
const silent = has('--no-audio')
|
|
133
|
+
const loopCheck = has('--loop-check')
|
|
134
|
+
const framesList = listFlag('--frames')
|
|
135
|
+
const timesList = listFlag('--times')
|
|
117
136
|
const [sceneFile] = rest
|
|
118
137
|
if (!sceneFile || rest.length > 1) usage()
|
|
138
|
+
if ((framesList || timesList) && !stillsDir) {
|
|
139
|
+
console.error('tinyfly: --frames and --times choose stills: add --stills <dir>')
|
|
140
|
+
process.exit(2)
|
|
141
|
+
}
|
|
119
142
|
|
|
120
143
|
const headless = await import('../lib/headless/headless.js')
|
|
121
144
|
const scenePath = resolve(sceneFile)
|
|
@@ -134,8 +157,23 @@ async function video() {
|
|
|
134
157
|
if (vttFile) writeFileSync(vttFile, headless.toWebVTT(cues))
|
|
135
158
|
console.error(`captions: ${cues.length} cue(s)`)
|
|
136
159
|
}
|
|
160
|
+
if (loopCheck) {
|
|
161
|
+
const report = await headless.checkLoop(scene, { baseDir, scale, fps })
|
|
162
|
+
const db = (value) => (Number.isFinite(value) ? `${value.toFixed(2)} dB` : 'identical')
|
|
163
|
+
console.error(`frame at the duration vs the first: ${db(report.closure)}`)
|
|
164
|
+
console.error(`last → first (the seam): ${db(report.seam)}`)
|
|
165
|
+
console.error(`ordinary steps: ${db(report.steps[0])}, ${db(report.steps[1])}`)
|
|
166
|
+
console.error(`${report.loops ? '✓' : '✗'} ${report.verdict}`)
|
|
167
|
+
if (!report.loops) process.exit(1)
|
|
168
|
+
return
|
|
169
|
+
}
|
|
137
170
|
if (stillsDir) {
|
|
138
|
-
|
|
171
|
+
// Stills at chosen frames or times, else one per marker step.
|
|
172
|
+
const sceneFps = fps ?? scene.fps ?? 30
|
|
173
|
+
const times = framesList
|
|
174
|
+
? framesList.map((frame) => ({ id: `frame-${frame}`, time: (frame * 1000) / sceneFps }))
|
|
175
|
+
: timesList?.map((time) => ({ id: `t-${time}ms`, time }))
|
|
176
|
+
const files = await headless.renderStills(scene, { dir: stillsDir, baseDir, scale, times })
|
|
139
177
|
console.error(`stills: ${files.length} PNG(s) in ${stillsDir}`)
|
|
140
178
|
return
|
|
141
179
|
}
|