@algorisys/tinyfly 0.101.0 → 0.103.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 +17 -6
- package/bin/tinyfly.mjs +9 -3
- package/docs/DEPLOYMENT.md +2 -0
- package/docs/api-reference.md +61 -0
- package/docs/dance.md +150 -1
- package/docs/editor-guide.md +11 -4
- package/docs/examples.md +22 -1
- package/docs/getting-started.md +1 -1
- package/docs/gsap-compat.md +1 -1
- package/docs/llm-guide.md +38 -3
- package/docs/maps.md +2 -2
- package/docs/scene-3d.md +138 -6
- package/docs/teaching.md +1 -1
- package/docs/video-rendering.md +44 -1
- package/lib/addons/adapters.js +168 -123
- package/lib/addons/characters.js +5802 -5506
- package/lib/addons/scene-3d-webgl.js +30 -30
- package/lib/addons/scene-3d.js +650 -341
- package/lib/browser/tinyfly-scene-3d-webgl.iife.js +2 -2
- package/lib/browser/tinyfly-scene-3d.iife.js +2 -2
- package/lib/browser/tinyfly.iife.js +14 -14
- package/lib/browser/tinyfly.js +5798 -5467
- package/lib/browser/tinyfly.umd.js +14 -14
- package/lib/engine/tinyfly-engine.js +1207 -1172
- package/lib/engine/tinyfly-engine.umd.cjs +2 -2
- package/lib/headless/headless.js +150 -6
- package/lib/types/adapters/canvas/framing.d.ts +27 -0
- package/lib/types/adapters/canvas/index.d.ts +1 -0
- package/lib/types/characters/capabilities.d.ts +1 -0
- package/lib/types/characters/character-script-3d.d.ts +34 -4
- package/lib/types/characters/dance-circle.d.ts +59 -0
- package/lib/types/characters/dance-contact.d.ts +52 -0
- package/lib/types/characters/human-dance.d.ts +86 -0
- package/lib/types/characters/index.d.ts +5 -1
- package/lib/types/characters/rig/reach.d.ts +6 -3
- package/lib/types/characters/staging-3d.d.ts +56 -0
- package/lib/types/engine/authoring/framing.d.ts +48 -0
- package/lib/types/engine/authoring/index.d.ts +1 -0
- package/lib/types/headless/audio-mix.d.ts +40 -0
- package/lib/types/headless/ffmpeg-args.d.ts +2 -0
- package/lib/types/headless/frame-renderer.d.ts +7 -1
- package/lib/types/headless/index.d.ts +1 -0
- package/lib/types/headless/node-audio.d.ts +19 -0
- package/lib/types/headless/node-video.d.ts +2 -0
- package/lib/types/headless/video-scene.d.ts +12 -0
- package/lib/types/scene-3d/index.d.ts +3 -0
- package/lib/types/scene-3d/lighting.d.ts +58 -0
- package/lib/types/scene-3d/resolve-scene.d.ts +5 -1
- package/lib/types/scene-3d/scene-3d-adapter.d.ts +2 -0
- package/lib/types/scene-3d/scene-types.d.ts +14 -2
- package/lib/types/scene-3d/shots.d.ts +162 -0
- package/lib/types/scene-3d/software-renderer.d.ts +40 -0
- package/llms-full.txt +474 -23
- package/llms.txt +29 -29
- package/package.json +1 -1
- package/skills/tinyfly/SKILL.md +32 -1
- package/lib/types/characters/polyline.d.ts +0 -12
- package/lib/types/characters/sketch.d.ts +0 -54
- package/lib/types/compat/gsap/playhead-crossings.d.ts +0 -47
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { p as _ } from "./shading-0lPgnXmD.js";
|
|
2
2
|
import { mat4 as h, vec3 as v } from "@algorisys/tinyfly";
|
|
3
|
-
const
|
|
3
|
+
const s = 8, p = { unlit: 0, flat: 1, lambert: 2, toon: 3 }, w = { ambient: 0, directional: 1, point: 2, spot: 3 }, A = `#version 300 es
|
|
4
4
|
in vec3 a_position;
|
|
5
5
|
in vec3 a_normal;
|
|
6
6
|
uniform mat4 u_model;
|
|
@@ -17,7 +17,7 @@ void main() {
|
|
|
17
17
|
}
|
|
18
18
|
`, b = `#version 300 es
|
|
19
19
|
precision highp float;
|
|
20
|
-
#define MAX_LIGHTS ${
|
|
20
|
+
#define MAX_LIGHTS ${s}
|
|
21
21
|
uniform int u_lightCount;
|
|
22
22
|
uniform int u_lightKind[MAX_LIGHTS];
|
|
23
23
|
uniform vec3 u_lightColor[MAX_LIGHTS];
|
|
@@ -120,15 +120,15 @@ void main() {
|
|
|
120
120
|
{ id: "default-key", light: "directional", color: "#ffffff", intensity: 0.8, position: [3, 5, 4], direction: v.normalize([-3, -5, -4]), angle: 30 }
|
|
121
121
|
];
|
|
122
122
|
function F(a) {
|
|
123
|
-
const t = (a.length > 0 ? a : R).slice(0,
|
|
123
|
+
const t = (a.length > 0 ? a : R).slice(0, s), i = {
|
|
124
124
|
count: t.length,
|
|
125
|
-
kind: new Int32Array(
|
|
126
|
-
color: new Float32Array(
|
|
127
|
-
intensity: new Float32Array(
|
|
128
|
-
position: new Float32Array(
|
|
129
|
-
direction: new Float32Array(
|
|
130
|
-
range: new Float32Array(
|
|
131
|
-
cone: new Float32Array(
|
|
125
|
+
kind: new Int32Array(s),
|
|
126
|
+
color: new Float32Array(s * 3),
|
|
127
|
+
intensity: new Float32Array(s),
|
|
128
|
+
position: new Float32Array(s * 3),
|
|
129
|
+
direction: new Float32Array(s * 3),
|
|
130
|
+
range: new Float32Array(s),
|
|
131
|
+
cone: new Float32Array(s * 2)
|
|
132
132
|
};
|
|
133
133
|
return t.forEach((o, n) => {
|
|
134
134
|
i.kind[n] = w[o.light], i.color.set(_(o.color), n * 3), i.intensity[n] = o.intensity, i.position.set(o.position, n * 3), i.direction.set(o.direction, n * 3), i.range[n] = o.range ?? 0, i.cone[n * 2] = Math.cos(o.angle * Math.PI / 180), i.cone[n * 2 + 1] = Math.cos(o.angle * 0.8 * Math.PI / 180);
|
|
@@ -143,7 +143,7 @@ function L(a, t, i) {
|
|
|
143
143
|
bands: a.bands ?? 3
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
|
-
function
|
|
146
|
+
function g(a) {
|
|
147
147
|
const t = h.transpose(h.invert(a) ?? h.identity());
|
|
148
148
|
return new Float32Array([t[0], t[1], t[2], t[4], t[5], t[6], t[8], t[9], t[10]]);
|
|
149
149
|
}
|
|
@@ -154,14 +154,14 @@ class C {
|
|
|
154
154
|
buffers = /* @__PURE__ */ new WeakMap();
|
|
155
155
|
overlay;
|
|
156
156
|
constructor(t, i = {}) {
|
|
157
|
-
this.gl = t, this.overlay = i.overlay, this.surface =
|
|
157
|
+
this.gl = t, this.overlay = i.overlay, this.surface = m(t, A, b), this.outline = m(t, E, y);
|
|
158
158
|
}
|
|
159
159
|
render(t) {
|
|
160
160
|
const i = this.gl, o = i.drawingBufferWidth, n = i.drawingBufferHeight;
|
|
161
161
|
i.viewport(0, 0, o, n);
|
|
162
|
-
const e = t.background && t.background !== "transparent" ? _(t.background) : null;
|
|
162
|
+
const e = t.background && t.background !== "transparent" ? _(typeof t.background == "string" ? t.background : t.background.bottom) : null;
|
|
163
163
|
i.clearColor(e?.[0] ?? 0, e?.[1] ?? 0, e?.[2] ?? 0, e ? 1 : 0), i.clearDepth(1), i.clear(i.COLOR_BUFFER_BIT | i.DEPTH_BUFFER_BIT), i.enable(i.DEPTH_TEST), i.depthFunc(i.LEQUAL), i.enable(i.CULL_FACE), i.frontFace(i.CCW);
|
|
164
|
-
const l = t.meshes.filter((r) => r.opacity >= 1),
|
|
164
|
+
const l = t.meshes.filter((r) => r.opacity >= 1), c = t.camera.position, u = (r) => Math.hypot(r.world[12] - c[0], r.world[13] - c[1], r.world[14] - c[2]), d = t.meshes.filter((r) => r.opacity < 1).sort((r, f) => u(f) - u(r) || r.objectIndex - f.objectIndex);
|
|
165
165
|
i.disable(i.BLEND), i.depthMask(!0);
|
|
166
166
|
for (const r of l) r.material.outline && this.drawOutline(t, r, o, n);
|
|
167
167
|
for (const r of l) this.drawSurface(t, r);
|
|
@@ -179,18 +179,18 @@ class C {
|
|
|
179
179
|
const o = this.gl, n = this.surface;
|
|
180
180
|
o.useProgram(n.program), i.material.doubleSided ? o.disable(o.CULL_FACE) : (o.enable(o.CULL_FACE), o.cullFace(o.BACK)), this.bindMesh(n, i.mesh);
|
|
181
181
|
const e = n.uniform;
|
|
182
|
-
o.uniformMatrix4fv(e("u_model"), !1, i.world), o.uniformMatrix4fv(e("u_view"), !1, t.camera.view), o.uniformMatrix4fv(e("u_projection"), !1, t.camera.projection), o.uniformMatrix3fv(e("u_normalMatrix"), !1,
|
|
182
|
+
o.uniformMatrix4fv(e("u_model"), !1, i.world), o.uniformMatrix4fv(e("u_view"), !1, t.camera.view), o.uniformMatrix4fv(e("u_projection"), !1, t.camera.projection), o.uniformMatrix3fv(e("u_normalMatrix"), !1, g(i.world));
|
|
183
183
|
const l = F(t.lights);
|
|
184
184
|
o.uniform1i(e("u_lightCount"), l.count), o.uniform1iv(e("u_lightKind"), l.kind), o.uniform3fv(e("u_lightColor"), l.color), o.uniform1fv(e("u_lightIntensity"), l.intensity), o.uniform3fv(e("u_lightPosition"), l.position), o.uniform3fv(e("u_lightDirection"), l.direction), o.uniform1fv(e("u_lightRange"), l.range), o.uniform2fv(e("u_lightCone"), l.cone);
|
|
185
|
-
const
|
|
186
|
-
o.uniform3fv(e("u_color"),
|
|
185
|
+
const c = L(i.material, i.color, i.opacity);
|
|
186
|
+
o.uniform3fv(e("u_color"), c.color), o.uniform3fv(e("u_emissive"), c.emissive), o.uniform1f(e("u_opacity"), c.opacity), o.uniform1i(e("u_shading"), c.shading), o.uniform1f(e("u_bands"), c.bands), o.uniform3fv(e("u_eye"), t.camera.position), o.uniform3fv(e("u_forward"), t.camera.forward), o.uniform1i(e("u_orthographic"), t.camera.orthographic ? 1 : 0), o.uniform1i(e("u_fog"), t.fog ? 1 : 0), t.fog && (o.uniform3fv(e("u_fogColor"), _(t.fog.color)), o.uniform2f(e("u_fogRange"), t.fog.near, t.fog.far)), o.drawElements(o.TRIANGLES, i.mesh.indices.length, o.UNSIGNED_INT, 0);
|
|
187
187
|
}
|
|
188
188
|
drawOutline(t, i, o, n) {
|
|
189
|
-
const e = this.gl, l = this.outline,
|
|
189
|
+
const e = this.gl, l = this.outline, c = i.material.outline;
|
|
190
190
|
e.useProgram(l.program), e.enable(e.CULL_FACE), e.cullFace(e.FRONT), this.bindMesh(l, i.mesh);
|
|
191
191
|
const u = l.uniform;
|
|
192
|
-
e.uniformMatrix4fv(u("u_model"), !1, i.world), e.uniformMatrix4fv(u("u_view"), !1, t.camera.view), e.uniformMatrix4fv(u("u_projection"), !1, t.camera.projection), e.uniformMatrix3fv(u("u_normalMatrix"), !1,
|
|
193
|
-
const [d, r, f] = _(
|
|
192
|
+
e.uniformMatrix4fv(u("u_model"), !1, i.world), e.uniformMatrix4fv(u("u_view"), !1, t.camera.view), e.uniformMatrix4fv(u("u_projection"), !1, t.camera.projection), e.uniformMatrix3fv(u("u_normalMatrix"), !1, g(i.world)), e.uniform2f(u("u_viewport"), o, n), e.uniform1f(u("u_width"), c.width * (o / t.width));
|
|
193
|
+
const [d, r, f] = _(c.color);
|
|
194
194
|
e.uniform4f(u("u_ink"), d, r, f, 1), e.drawElements(e.TRIANGLES, i.mesh.indices.length, e.UNSIGNED_INT, 0), e.cullFace(e.BACK);
|
|
195
195
|
}
|
|
196
196
|
/** Upload a mesh once; bind its buffers to the program's attributes. */
|
|
@@ -200,14 +200,14 @@ class C {
|
|
|
200
200
|
if (!n) {
|
|
201
201
|
const l = o.createBuffer();
|
|
202
202
|
o.bindBuffer(o.ARRAY_BUFFER, l), o.bufferData(o.ARRAY_BUFFER, new Float32Array(i.positions), o.STATIC_DRAW);
|
|
203
|
-
const
|
|
204
|
-
o.bindBuffer(o.ARRAY_BUFFER,
|
|
203
|
+
const c = o.createBuffer();
|
|
204
|
+
o.bindBuffer(o.ARRAY_BUFFER, c), o.bufferData(o.ARRAY_BUFFER, new Float32Array(i.normals), o.STATIC_DRAW);
|
|
205
205
|
const u = o.createBuffer();
|
|
206
|
-
o.bindBuffer(o.ELEMENT_ARRAY_BUFFER, u), o.bufferData(o.ELEMENT_ARRAY_BUFFER, new Uint32Array(i.indices), o.STATIC_DRAW), n = { position: l, normal:
|
|
206
|
+
o.bindBuffer(o.ELEMENT_ARRAY_BUFFER, u), o.bufferData(o.ELEMENT_ARRAY_BUFFER, new Uint32Array(i.indices), o.STATIC_DRAW), n = { position: l, normal: c, index: u }, this.buffers.set(i, n);
|
|
207
207
|
}
|
|
208
|
-
const e = (l,
|
|
208
|
+
const e = (l, c) => {
|
|
209
209
|
const u = o.getAttribLocation(t.program, l);
|
|
210
|
-
u < 0 || (o.bindBuffer(o.ARRAY_BUFFER,
|
|
210
|
+
u < 0 || (o.bindBuffer(o.ARRAY_BUFFER, c), o.enableVertexAttribArray(u), o.vertexAttribPointer(u, 3, o.FLOAT, !1, 0, 0));
|
|
211
211
|
};
|
|
212
212
|
e("a_position", n.position), e("a_normal", n.normal), o.bindBuffer(o.ELEMENT_ARRAY_BUFFER, n.index);
|
|
213
213
|
}
|
|
@@ -216,10 +216,10 @@ class C {
|
|
|
216
216
|
this.gl.deleteProgram(this.surface.program), this.gl.deleteProgram(this.outline.program);
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
|
-
function
|
|
220
|
-
const o = (l,
|
|
219
|
+
function m(a, t, i) {
|
|
220
|
+
const o = (l, c) => {
|
|
221
221
|
const u = a.createShader(l);
|
|
222
|
-
if (a.shaderSource(u,
|
|
222
|
+
if (a.shaderSource(u, c), a.compileShader(u), !a.getShaderParameter(u, a.COMPILE_STATUS)) throw new Error(`scene-3d webgl: shader failed to compile — ${a.getShaderInfoLog(u)}`);
|
|
223
223
|
return u;
|
|
224
224
|
}, n = a.createProgram();
|
|
225
225
|
if (a.attachShader(n, o(a.VERTEX_SHADER, t)), a.attachShader(n, o(a.FRAGMENT_SHADER, i)), a.linkProgram(n), !a.getProgramParameter(n, a.LINK_STATUS)) throw new Error(`scene-3d webgl: program failed to link — ${a.getProgramInfoLog(n)}`);
|
|
@@ -231,10 +231,10 @@ function g(a, t, i) {
|
|
|
231
231
|
}
|
|
232
232
|
export {
|
|
233
233
|
w as LIGHT_CODE,
|
|
234
|
-
|
|
234
|
+
s as MAX_LIGHTS,
|
|
235
235
|
p as SHADING_CODE,
|
|
236
236
|
C as WebGL2Renderer,
|
|
237
|
-
|
|
237
|
+
g as normalMatrix3,
|
|
238
238
|
F as packLights,
|
|
239
239
|
L as surfaceUniforms
|
|
240
240
|
};
|