@algorisys/tinyfly 0.86.2 → 0.88.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 (38) hide show
  1. package/README.md +7 -4
  2. package/bin/tinyfly.mjs +44 -6
  3. package/lib/addons/adapters.js +389 -281
  4. package/lib/addons/characters.js +3 -3
  5. package/lib/addons/load-scene-CQvcFWGJ.js +331 -0
  6. package/lib/addons/maps.js +1 -1
  7. package/lib/addons/scene-3d-webgl.js +52 -49
  8. package/lib/addons/scene-3d.js +299 -215
  9. package/lib/addons/shading-o5T_v9DT.js +89 -0
  10. package/lib/addons/{sketch-CA8ZXhxI.js → sketch-CYPUbk3Q.js} +2 -2
  11. package/lib/browser/tinyfly-scene-3d-webgl.iife.js +4 -2
  12. package/lib/browser/tinyfly-scene-3d.iife.js +2 -2
  13. package/lib/browser/tinyfly.iife.js +4 -4
  14. package/lib/browser/tinyfly.js +2204 -2043
  15. package/lib/browser/tinyfly.umd.js +4 -4
  16. package/lib/engine/tinyfly-engine.js +149 -106
  17. package/lib/engine/tinyfly-engine.umd.cjs +2 -2
  18. package/lib/headless/headless.js +165 -18
  19. package/lib/types/adapters/canvas/bloom.d.ts +33 -0
  20. package/lib/types/adapters/canvas/index.d.ts +3 -0
  21. package/lib/types/adapters/canvas/offscreen.d.ts +13 -0
  22. package/lib/types/adapters/canvas/trail.d.ts +57 -0
  23. package/lib/types/browser/index.d.ts +4 -0
  24. package/lib/types/engine/path/index.d.ts +2 -0
  25. package/lib/types/engine/path/trail.d.ts +79 -0
  26. package/lib/types/headless/index.d.ts +1 -0
  27. package/lib/types/headless/loop-check.d.ts +41 -0
  28. package/lib/types/headless/node-video.d.ts +8 -0
  29. package/lib/types/headless/video-scene.d.ts +9 -1
  30. package/lib/types/scene-3d/resolve-scene.d.ts +6 -0
  31. package/lib/types/scene-3d/scene-3d-adapter.d.ts +9 -1
  32. package/lib/types/scene-3d/scene-types.d.ts +42 -2
  33. package/lib/types/scene-3d/strokes.d.ts +30 -0
  34. package/lib/types/scene-3d/webgl/gl-data.d.ts +1 -0
  35. package/lib/types/scene-3d/webgl/shaders.d.ts +1 -1
  36. package/package.json +1 -1
  37. package/lib/addons/load-scene-vp14_Jj-.js +0 -324
  38. package/lib/addons/shading-ByG9UXd0.js +0 -85
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Trails: where something has been, as plain data.
3
+ *
4
+ * A trail is not a history of frames. It is the moving thing's position at
5
+ * earlier times, asked of a function of time (usually the timeline's state),
6
+ * so the same time always gives the same trail: seeking, scrubbing, frames
7
+ * rendered in any order and loops all draw it identically.
8
+ *
9
+ * The ribbon helper turns sampled points into a tapered band's two edges,
10
+ * for any renderer that fills polygons.
11
+ */
12
+ export interface TrailOptions {
13
+ /** How far back the trail reaches, ms */
14
+ length: number;
15
+ /** Points along it, head included (default 32; at least 2) */
16
+ samples?: number;
17
+ /**
18
+ * Motion that repeats every `period` ms: earlier times wrap into
19
+ * [0, period), so at the start of a loop the trail already shows the end
20
+ * of the previous lap.
21
+ */
22
+ period?: number;
23
+ /** Nothing before this time, ms (default: no limit). The trail is shorter until it has had time to grow. */
24
+ since?: number;
25
+ }
26
+ export interface TrailSample<P> {
27
+ /** Where it was */
28
+ at: P;
29
+ /** When, ms */
30
+ time: number;
31
+ /** 0 at the head (now) to 1 at the tail (`length` ago) */
32
+ age: number;
33
+ }
34
+ /**
35
+ * Sample a trail ending at `time`: oldest first, the head last.
36
+ *
37
+ * ```ts
38
+ * const trail = trailSamples((t) => pointOnOrbit(t), now, { length: 400 })
39
+ * ```
40
+ */
41
+ export declare function trailSamples<P>(positionAt: (time: number) => P, time: number, options: TrailOptions): TrailSample<P>[];
42
+ export interface RibbonPoint {
43
+ x: number;
44
+ y: number;
45
+ /** Full width here, in the points' units */
46
+ width: number;
47
+ }
48
+ export interface Ribbon {
49
+ /** One edge, a point per input point */
50
+ left: Array<{
51
+ x: number;
52
+ y: number;
53
+ }>;
54
+ /** The other edge, a point per input point */
55
+ right: Array<{
56
+ x: number;
57
+ y: number;
58
+ }>;
59
+ }
60
+ /**
61
+ * The two edges of a band along `points`, each point `width` wide. Joints
62
+ * are mitred, so neighbouring segments share their corners exactly (quads
63
+ * `left[i], left[i+1], right[i+1], right[i]` meet with no gap or overlap).
64
+ * Repeated points are skipped over when finding directions.
65
+ */
66
+ export declare function ribbon(points: RibbonPoint[]): Ribbon;
67
+ /**
68
+ * A round end for a band's last point: a half circle, `width / 2` across,
69
+ * bulging the way the band travels. Drawn as part of the last segment, it
70
+ * covers nothing the segment covers. Null when the band has no direction.
71
+ * Angles are canvas angles (radians, y down): the arc runs from `start`
72
+ * through the travel direction, decreasing, to `start - π`.
73
+ */
74
+ export declare function ribbonHeadCap(points: RibbonPoint[]): {
75
+ x: number;
76
+ y: number;
77
+ radius: number;
78
+ start: number;
79
+ } | null;
@@ -9,4 +9,5 @@ export * from './scene-captions';
9
9
  export * from './node-video';
10
10
  export * from './narration-audio';
11
11
  export * from './node-audio';
12
+ export * from './loop-check';
12
13
  export { toSRT, toWebVTT, captionCuesFromTimeline, type CaptionCue } from '../engine/export/captions';
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Does a video loop? Pure measurements on rendered frames (RGBA bytes), so a
3
+ * loop can be checked without encoding anything.
4
+ *
5
+ * A loop closes when the frame at time = duration is the frame at time 0:
6
+ * every motion repeats over the duration. Then the step from the last frame
7
+ * back to the first is a step like any other. A loop with a cut, or one that
8
+ * drifts, shows a seam that differs much more than its ordinary steps.
9
+ */
10
+ /** Peak signal-to-noise ratio of two RGBA images (RGB only), dB; Infinity when identical. Higher is more alike. */
11
+ export declare function psnr(a: ArrayLike<number>, b: ArrayLike<number>): number;
12
+ export interface LoopFrames {
13
+ /** The frame at time 0 */
14
+ first: ArrayLike<number>;
15
+ /** The frame after it */
16
+ second: ArrayLike<number>;
17
+ /** The frame before the last */
18
+ beforeLast: ArrayLike<number>;
19
+ /** The last frame */
20
+ last: ArrayLike<number>;
21
+ /** The frame at time = duration: one frame past the end, where the loop comes back round */
22
+ wrapped: ArrayLike<number>;
23
+ }
24
+ export interface LoopReport {
25
+ /** The frame at time = duration against the first: Infinity (or very high) when every motion repeats */
26
+ closure: number;
27
+ /** The last frame → the first: the step a looping player shows */
28
+ seam: number;
29
+ /** Ordinary steps for comparison: first → second, before-last → last */
30
+ steps: [number, number];
31
+ /** True when the loop closes, or its seam differs no more than an ordinary step does */
32
+ loops: boolean;
33
+ /** Why, in a sentence */
34
+ verdict: string;
35
+ }
36
+ /** Above this the frames at 0 and at the duration count as the same picture. */
37
+ export declare const CLOSED_DB = 40;
38
+ /** A seam this much worse than the worse ordinary step stands out. */
39
+ export declare const SEAM_SLACK_DB = 3;
40
+ /** Judge a loop from its frames: does it close, and does its seam look like any other step? */
41
+ export declare function loopReport(frames: LoopFrames): LoopReport;
@@ -1,4 +1,5 @@
1
1
  import type { VideoScene } from './video-scene';
2
+ import { type LoopReport } from './loop-check';
2
3
  /** Options shared by video and stills rendering. */
3
4
  export interface HeadlessOptions {
4
5
  /** Directory that relative `audio` and font paths resolve against (default: cwd) */
@@ -46,3 +47,10 @@ export interface RenderStillsOptions extends HeadlessOptions {
46
47
  * encoding a video. Returns the written file paths.
47
48
  */
48
49
  export declare function renderStills(scene: VideoScene, options: RenderStillsOptions): Promise<string[]>;
50
+ /**
51
+ * Check that a scene loops, rendering only five frames: the first two, the
52
+ * last two, and the one at time = duration. See {@link loopReport}.
53
+ */
54
+ export declare function checkLoop(scene: VideoScene, options?: HeadlessOptions & {
55
+ fps?: number;
56
+ }): Promise<LoopReport>;
@@ -1,6 +1,6 @@
1
1
  import type { AnimationState, TimelineDefinition } from '../engine/types';
2
2
  import type { CaptionCue } from '../engine/export/captions';
3
- import type { CanvasTarget } from '../adapters/canvas';
3
+ import type { BloomOptions, CanvasTarget } from '../adapters/canvas';
4
4
  /**
5
5
  * A video scene: everything needed to render an animation to frames without a
6
6
  * browser.
@@ -33,6 +33,12 @@ export interface VideoScene {
33
33
  background?: string | DrawFunction;
34
34
  /** Immediate-mode drawing, called every frame after the targets */
35
35
  draw?: DrawFunction;
36
+ /**
37
+ * Glow around what is bright, added over each finished frame: `true` for
38
+ * the defaults, or options (threshold, strength, radius in scene px…).
39
+ * See `applyBloom`.
40
+ */
41
+ bloom?: boolean | BloomOptions;
36
42
  /** Soundtrack to mux into the video, relative to the scene file */
37
43
  audio?: string;
38
44
  /** Font files to register before drawing, by family, relative to the scene file */
@@ -50,6 +56,8 @@ export interface FrameInfo {
50
56
  time: number;
51
57
  /** Timeline state at `time`, when the scene has a timeline */
52
58
  state?: AnimationState;
59
+ /** Timeline state at any other time (trails ask where things were), when the scene has a timeline */
60
+ stateAt?: (time: number) => AnimationState;
53
61
  /** Scene size in pixels (the logical size, before `scale`) */
54
62
  width: number;
55
63
  height: number;
@@ -14,6 +14,7 @@ import type { Drawable } from './object-kind';
14
14
  * `rotateZ` (degrees, YXZ) or `quaternion` (a slerp track); `scale` or
15
15
  * `scaleX` / `scaleY` / `scaleZ`; `visible` (0 or 1); `opacity`;
16
16
  * - meshes and lights: `color`; lights: `intensity`, `target`;
17
+ * - lines and trails: `color`, `width`, `opacity`; trails: `length`;
17
18
  * - cameras: `fov` (perspective), `height` (orthographic), `lookAt`;
18
19
  * - the scene itself, `<sceneId>`: `activeCamera` (a camera's id: a cut is one keyframe).
19
20
  */
@@ -117,6 +118,11 @@ export interface ResolveOptions {
117
118
  height: number;
118
119
  /** ms: the moment drawn, for looks that move with time (default 0) */
119
120
  time?: number;
121
+ /**
122
+ * The animated values at another moment (an `AnimationState`'s `values`):
123
+ * trails ask where what they follow was. Without it, trails draw nothing.
124
+ */
125
+ valuesAt?: (time: number) => SceneValues;
120
126
  }
121
127
  /** The frame at these animated values (an `AnimationState`'s `values`, or none for the scene as authored). */
122
128
  export declare function resolveScene3D(loaded: LoadedScene3D, values: SceneValues | undefined, options: ResolveOptions): ResolvedScene3D;
@@ -20,9 +20,12 @@ export declare class Scene3DAdapter {
20
20
  private height;
21
21
  private readonly scenes;
22
22
  private values;
23
+ private readonly valuesAt?;
24
+ /** `valuesAt`: the values at another time (`(t) => timeline.getStateAtTime(t).values`), for trails */
23
25
  constructor(renderer: Renderer3D, options: {
24
26
  width: number;
25
27
  height: number;
28
+ valuesAt?: (time: number) => SceneValues;
26
29
  });
27
30
  /** Add a scene; its tracks address `<scene.id>/<objectId>`. */
28
31
  registerScene(scene: LoadedScene3D): void;
@@ -37,10 +40,15 @@ export declare class Scene3DAdapter {
37
40
  /**
38
41
  * Draw a scene at these animated values in one call: for a headless video
39
42
  * scene's `draw(ctx, frame)` (`drawScene3D(ctx, scene, frame.state?.values, frame)`)
40
- * or a canvas target's custom draw.
43
+ * or a canvas target's custom draw. A video frame carries `stateAt`, so
44
+ * trails find where things were; elsewhere pass `valuesAt`.
41
45
  */
42
46
  export declare function drawScene3D(ctx: CanvasRenderingContext2D, scene: LoadedScene3D, values: SceneValues | undefined, size: {
43
47
  width: number;
44
48
  height: number;
45
49
  time?: number;
50
+ valuesAt?: (time: number) => SceneValues;
51
+ stateAt?: (time: number) => {
52
+ values: SceneValues;
53
+ };
46
54
  }): void;
@@ -134,7 +134,46 @@ export interface CharacterObject3D extends ObjectBase {
134
134
  } | false;
135
135
  };
136
136
  }
137
- export type Object3D = GroupObject | MeshObject | CameraObject | LightObject | CharacterObject3D;
137
+ /** How a line or trail looks: a flat band facing the camera, drawn among the meshes by depth. */
138
+ export interface StrokeStyle3D {
139
+ color: string;
140
+ /** Width, metres (default 0.05): it narrows with distance, like everything else */
141
+ width?: number;
142
+ /** How much it narrows toward its start (a line's first point, a trail's tail), 0..1 */
143
+ taper?: number;
144
+ /** How much it fades toward its start, 0..1 */
145
+ fade?: number;
146
+ /** 0..1, default 1 */
147
+ opacity?: number;
148
+ /** `normal` (default) paints over what is behind; `add` adds its light: glowing beams that feed bloom */
149
+ blend?: 'normal' | 'add';
150
+ }
151
+ /** A polyline through `points` (in its own space, so it moves with its transform and parent). */
152
+ export interface LineObject3D extends ObjectBase, StrokeStyle3D {
153
+ kind: 'line';
154
+ points: Vec3Tuple[];
155
+ /** Join the last point back to the first */
156
+ closed?: boolean;
157
+ }
158
+ /**
159
+ * Where another object has been: a band through its positions over the last
160
+ * `length` ms, narrowing and fading toward the tail (taper and fade default
161
+ * to 1). It needs the earlier moments, so the renderer is given a way to ask
162
+ * for them (`valuesAt` / `stateAt`); without one it draws nothing. Its own
163
+ * transform is not used.
164
+ */
165
+ export interface TrailObject3D extends ObjectBase, StrokeStyle3D {
166
+ kind: 'trail';
167
+ /** Id of the object it follows */
168
+ follow: string;
169
+ /** How far back it reaches, ms */
170
+ length: number;
171
+ /** Points along it (default 32) */
172
+ samples?: number;
173
+ /** Motion that repeats every `period` ms: the trail wraps, so a loop's first frame shows the last lap */
174
+ period?: number;
175
+ }
176
+ export type Object3D = GroupObject | MeshObject | CameraObject | LightObject | CharacterObject3D | LineObject3D | TrailObject3D;
138
177
  export type Geometry3D = {
139
178
  type: 'box';
140
179
  size: Vec3Tuple;
@@ -185,7 +224,8 @@ export interface Material3D {
185
224
  width: number;
186
225
  color: string;
187
226
  };
227
+ /** Light the surface gives off itself, added after lighting (both modes): neon, screens, lamps; feeds bloom */
228
+ emissive?: string;
188
229
  roughness?: number;
189
230
  metalness?: number;
190
- emissive?: string;
191
231
  }
@@ -0,0 +1,30 @@
1
+ import { type Vec3 } from '../engine/math';
2
+ import type { Drawable } from './object-kind';
3
+ import type { ResolvedCamera, ResolvedScene3D, ScreenPoint } from './resolve-scene';
4
+ /**
5
+ * Lines and trails in a 3D scene: a band through world points, facing the
6
+ * camera, as many drawables as it has segments, so each sits at its own
7
+ * depth among the meshes' triangles (a trail can pass behind one shape and in
8
+ * front of another).
9
+ */
10
+ export interface StrokeLook {
11
+ color: string;
12
+ /** Metres */
13
+ width: number;
14
+ taper: number;
15
+ fade: number;
16
+ opacity: number;
17
+ additive: boolean;
18
+ }
19
+ export interface StrokeView {
20
+ camera: ResolvedCamera;
21
+ /** Canvas height, px */
22
+ height: number;
23
+ fog?: ResolvedScene3D['fog'];
24
+ toScreen(view: Vec3): ScreenPoint;
25
+ }
26
+ /**
27
+ * The band through `points` (world space), each with its age: 0 at the head,
28
+ * 1 at the tail, where taper and fade apply in full.
29
+ */
30
+ export declare function strokeDrawables(points: Vec3[], ages: number[], look: StrokeLook, view: StrokeView): Drawable[];
@@ -20,6 +20,7 @@ export declare function packLights(lights: ResolvedLight[]): LightUniforms;
20
20
  /** A material's numbers for the surface shader, with an object's own colour and opacity over it. */
21
21
  export declare function surfaceUniforms(material: Material3D, color: string | undefined, opacity: number): {
22
22
  color: import("../shading").Rgb;
23
+ emissive: [number, number, number];
23
24
  opacity: number;
24
25
  shading: 0 | 2 | 1 | 3;
25
26
  bands: number;
@@ -19,7 +19,7 @@ export declare const LIGHT_CODE: {
19
19
  readonly spot: 3;
20
20
  };
21
21
  export declare const SURFACE_VERTEX = "#version 300 es\nin vec3 a_position;\nin vec3 a_normal;\nuniform mat4 u_model;\nuniform mat4 u_view;\nuniform mat4 u_projection;\nuniform mat3 u_normalMatrix;\nout vec3 v_world;\nout vec3 v_normal;\nvoid main() {\n vec4 world = u_model * vec4(a_position, 1.0);\n v_world = world.xyz;\n v_normal = u_normalMatrix * a_normal;\n gl_Position = u_projection * u_view * world;\n}\n";
22
- export declare const SURFACE_FRAGMENT = "#version 300 es\nprecision highp float;\n#define MAX_LIGHTS 8\nuniform int u_lightCount;\nuniform int u_lightKind[MAX_LIGHTS];\nuniform vec3 u_lightColor[MAX_LIGHTS];\nuniform float u_lightIntensity[MAX_LIGHTS];\nuniform vec3 u_lightPosition[MAX_LIGHTS];\nuniform vec3 u_lightDirection[MAX_LIGHTS];\nuniform float u_lightRange[MAX_LIGHTS];\nuniform vec2 u_lightCone[MAX_LIGHTS];\nuniform vec3 u_color;\nuniform float u_opacity;\nuniform int u_shading;\nuniform float u_bands;\nuniform vec3 u_eye;\nuniform vec3 u_forward;\nuniform bool u_orthographic;\nuniform bool u_fog;\nuniform vec3 u_fogColor;\nuniform vec2 u_fogRange;\nin vec3 v_world;\nin vec3 v_normal;\nout vec4 outColor;\n\nvec3 lightAt(vec3 p, vec3 n) {\n vec3 total = vec3(0.0);\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= u_lightCount) break;\n float amount;\n int kind = u_lightKind[i];\n if (kind == 0) {\n amount = u_lightIntensity[i];\n } else if (kind == 1) {\n amount = u_lightIntensity[i] * max(0.0, -dot(n, u_lightDirection[i]));\n } else {\n vec3 toLight = u_lightPosition[i] - p;\n float distance = length(toLight);\n vec3 l = distance > 0.0 ? toLight / distance : n;\n float fade = u_lightRange[i] > 0.0 ? pow(max(0.0, 1.0 - distance / u_lightRange[i]), 2.0) : 1.0;\n amount = u_lightIntensity[i] * max(0.0, dot(n, l)) * fade;\n if (kind == 3) amount *= smoothstep(u_lightCone[i].x, u_lightCone[i].y, -dot(l, u_lightDirection[i]));\n }\n total += u_lightColor[i] * amount;\n }\n return total;\n}\n\nvoid main() {\n vec3 rgb = u_color;\n if (u_shading != 0) {\n // Flat: the face's own normal, from the surface's slope; otherwise the smooth one.\n vec3 n = u_shading == 1 ? normalize(cross(dFdx(v_world), dFdy(v_world))) : normalize(v_normal);\n vec3 toEye = u_orthographic ? -u_forward : normalize(u_eye - v_world);\n if (dot(n, toEye) < 0.0) n = -n;\n vec3 light = lightAt(v_world, n);\n if (u_shading == 3) {\n // Band the brightness, not each channel, so coloured lights keep their hue.\n float level = max(light.r, max(light.g, light.b));\n float steps = max(2.0, floor(u_bands + 0.5));\n float banded = min(1.2, ceil(min(1.0, level) * steps - 1e-6) / steps);\n light = level > 0.0 ? light * (banded / level) : vec3(0.0);\n }\n rgb *= light;\n }\n if (u_fog) {\n float amount = clamp((distance(v_world, u_eye) - u_fogRange.x) / (u_fogRange.y - u_fogRange.x), 0.0, 1.0);\n rgb = mix(rgb, u_fogColor, amount);\n }\n outColor = vec4(clamp(rgb, 0.0, 1.0), u_opacity);\n}\n";
22
+ export declare const SURFACE_FRAGMENT = "#version 300 es\nprecision highp float;\n#define MAX_LIGHTS 8\nuniform int u_lightCount;\nuniform int u_lightKind[MAX_LIGHTS];\nuniform vec3 u_lightColor[MAX_LIGHTS];\nuniform float u_lightIntensity[MAX_LIGHTS];\nuniform vec3 u_lightPosition[MAX_LIGHTS];\nuniform vec3 u_lightDirection[MAX_LIGHTS];\nuniform float u_lightRange[MAX_LIGHTS];\nuniform vec2 u_lightCone[MAX_LIGHTS];\nuniform vec3 u_color;\nuniform vec3 u_emissive;\nuniform float u_opacity;\nuniform int u_shading;\nuniform float u_bands;\nuniform vec3 u_eye;\nuniform vec3 u_forward;\nuniform bool u_orthographic;\nuniform bool u_fog;\nuniform vec3 u_fogColor;\nuniform vec2 u_fogRange;\nin vec3 v_world;\nin vec3 v_normal;\nout vec4 outColor;\n\nvec3 lightAt(vec3 p, vec3 n) {\n vec3 total = vec3(0.0);\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= u_lightCount) break;\n float amount;\n int kind = u_lightKind[i];\n if (kind == 0) {\n amount = u_lightIntensity[i];\n } else if (kind == 1) {\n amount = u_lightIntensity[i] * max(0.0, -dot(n, u_lightDirection[i]));\n } else {\n vec3 toLight = u_lightPosition[i] - p;\n float distance = length(toLight);\n vec3 l = distance > 0.0 ? toLight / distance : n;\n float fade = u_lightRange[i] > 0.0 ? pow(max(0.0, 1.0 - distance / u_lightRange[i]), 2.0) : 1.0;\n amount = u_lightIntensity[i] * max(0.0, dot(n, l)) * fade;\n if (kind == 3) amount *= smoothstep(u_lightCone[i].x, u_lightCone[i].y, -dot(l, u_lightDirection[i]));\n }\n total += u_lightColor[i] * amount;\n }\n return total;\n}\n\nvoid main() {\n vec3 rgb = u_color;\n if (u_shading != 0) {\n // Flat: the face's own normal, from the surface's slope; otherwise the smooth one.\n vec3 n = u_shading == 1 ? normalize(cross(dFdx(v_world), dFdy(v_world))) : normalize(v_normal);\n vec3 toEye = u_orthographic ? -u_forward : normalize(u_eye - v_world);\n if (dot(n, toEye) < 0.0) n = -n;\n vec3 light = lightAt(v_world, n);\n if (u_shading == 3) {\n // Band the brightness, not each channel, so coloured lights keep their hue.\n float level = max(light.r, max(light.g, light.b));\n float steps = max(2.0, floor(u_bands + 0.5));\n float banded = min(1.2, ceil(min(1.0, level) * steps - 1e-6) / steps);\n light = level > 0.0 ? light * (banded / level) : vec3(0.0);\n }\n rgb *= light;\n }\n rgb += u_emissive;\n if (u_fog) {\n float amount = clamp((distance(v_world, u_eye) - u_fogRange.x) / (u_fogRange.y - u_fogRange.x), 0.0, 1.0);\n rgb = mix(rgb, u_fogColor, amount);\n }\n outColor = vec4(clamp(rgb, 0.0, 1.0), u_opacity);\n}\n";
23
23
  /**
24
24
  * Ink outlines by the inverted hull: each mesh again, its back faces only,
25
25
  * pushed out along their normals by the outline's width in pixels, in the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@algorisys/tinyfly",
3
- "version": "0.86.2",
3
+ "version": "0.88.0",
4
4
  "type": "module",
5
5
  "description": "Lightweight, API-driven animation engine and editor. The engine is framework-agnostic and runs in browsers, Web Workers, and Node.",
6
6
  "license": "MIT",