pixi-effects 0.48.1 → 0.49.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/CHANGELOG.md +15 -0
- package/README.md +51 -7
- package/ai/chat-template.html +8 -4
- package/ai/tools/check.mjs +6 -6
- package/dist/3d.cjs +963 -0
- package/dist/3d.cjs.map +1 -0
- package/dist/3d.d.cts +303 -0
- package/dist/3d.d.ts +303 -0
- package/dist/3d.js +956 -0
- package/dist/3d.js.map +1 -0
- package/dist/Canvas-BfZkAFJm.d.cts +12 -0
- package/dist/Canvas-BfZkAFJm.d.ts +12 -0
- package/dist/Composition-464AWDV6.cjs +16 -0
- package/dist/{Composition-ZZEOEETS.cjs.map → Composition-464AWDV6.cjs.map} +1 -1
- package/dist/Composition-5U63LMPX.js +7 -0
- package/dist/{Composition-BOLWGT2R.js.map → Composition-5U63LMPX.js.map} +1 -1
- package/dist/Controller.d.cts +2 -2
- package/dist/Controller.d.ts +2 -2
- package/dist/{Movie--qSYKgAQ.d.ts → Movie-6EWOz6Yw.d.ts} +21 -5
- package/dist/{Movie-svZQF-9Z.d.cts → Movie-BxB7bauG.d.cts} +21 -5
- package/dist/{Spans-MWYFG7RI.cjs → Spans-DUR2W5EH.cjs} +11 -11
- package/dist/{Spans-MWYFG7RI.cjs.map → Spans-DUR2W5EH.cjs.map} +1 -1
- package/dist/{Spans-PGXRMD6J.js → Spans-W5VJRMGC.js} +6 -6
- package/dist/{Spans-PGXRMD6J.js.map → Spans-W5VJRMGC.js.map} +1 -1
- package/dist/{blendModes-V5XHC7U4.cjs → blendModes-NC76DNVX.cjs} +5 -5
- package/dist/{blendModes-V5XHC7U4.cjs.map → blendModes-NC76DNVX.cjs.map} +1 -1
- package/dist/{blendModes-535EMYGK.js → blendModes-ZOBLPSR3.js} +4 -4
- package/dist/{blendModes-535EMYGK.js.map → blendModes-ZOBLPSR3.js.map} +1 -1
- package/dist/{chunk-V3VBHSK6.cjs → chunk-33USHRV5.cjs} +94 -104
- package/dist/chunk-33USHRV5.cjs.map +1 -0
- package/dist/{chunk-WYR2AU4W.cjs → chunk-5YNME6AH.cjs} +5 -5
- package/dist/{chunk-WYR2AU4W.cjs.map → chunk-5YNME6AH.cjs.map} +1 -1
- package/dist/{chunk-NGJXVJB7.cjs → chunk-ABWRISRK.cjs} +3 -2
- package/dist/chunk-ABWRISRK.cjs.map +1 -0
- package/dist/{chunk-M2LFQY2E.cjs → chunk-BSFWVTSR.cjs} +93 -93
- package/dist/chunk-BSFWVTSR.cjs.map +1 -0
- package/dist/{chunk-L3MEZZAV.js → chunk-DOGY3EAW.js} +25 -17
- package/dist/chunk-DOGY3EAW.js.map +1 -0
- package/dist/{chunk-L3XC464G.cjs → chunk-GUDLIAIG.cjs} +89 -66
- package/dist/chunk-GUDLIAIG.cjs.map +1 -0
- package/dist/{chunk-BFRWSV3R.js → chunk-H363KMJR.js} +3 -3
- package/dist/chunk-H363KMJR.js.map +1 -0
- package/dist/{chunk-JBDBICS2.js → chunk-MXACRKAN.js} +4 -4
- package/dist/{chunk-JBDBICS2.js.map → chunk-MXACRKAN.js.map} +1 -1
- package/dist/{chunk-IY5YTIK3.js → chunk-PBMDZT2T.js} +47 -24
- package/dist/chunk-PBMDZT2T.js.map +1 -0
- package/dist/{chunk-AJWUCFGM.js → chunk-USUUAYTE.js} +6 -6
- package/dist/chunk-USUUAYTE.js.map +1 -0
- package/dist/index.cjs +35 -35
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -5
- package/dist/loader.css +1 -1
- package/dist/{music-P4JRT73P.js → music-ATX22VAT.js} +3 -3
- package/dist/{music-P4JRT73P.js.map → music-ATX22VAT.js.map} +1 -1
- package/dist/{music-XQEPBIDT.cjs → music-OFVM3PYH.cjs} +3 -3
- package/dist/{music-XQEPBIDT.cjs.map → music-OFVM3PYH.cjs.map} +1 -1
- package/dist/present.cjs +5 -5
- package/dist/present.d.cts +2 -2
- package/dist/present.d.ts +2 -2
- package/dist/present.js +5 -5
- package/dist/three.cjs +7 -8
- package/dist/three.cjs.map +1 -1
- package/dist/three.d.cts +2 -12
- package/dist/three.d.ts +2 -12
- package/dist/three.js +2 -3
- package/dist/three.js.map +1 -1
- package/dist/{types-CTSrPvY3.d.cts → types-kt7DQKfO.d.cts} +1 -1
- package/dist/{types-CTSrPvY3.d.ts → types-kt7DQKfO.d.ts} +1 -1
- package/docs/api.md +41 -1
- package/docs/dsl.md +81 -1
- package/llms-full.txt +218 -5
- package/package.json +19 -3
- package/skills/pixi-effects/SKILL.md +3 -2
- package/skills/pixi-effects/reference/cheatsheet.md +2 -0
- package/skills/pixi-effects/reference/pitfalls.md +14 -0
- package/skills/pixi-effects/reference/recipes.md +77 -1
- package/skills/pixi-effects/template.html +13 -8
- package/dist/Composition-BOLWGT2R.js +0 -7
- package/dist/Composition-ZZEOEETS.cjs +0 -16
- package/dist/chunk-AJWUCFGM.js.map +0 -1
- package/dist/chunk-BFRWSV3R.js.map +0 -1
- package/dist/chunk-IY5YTIK3.js.map +0 -1
- package/dist/chunk-L3MEZZAV.js.map +0 -1
- package/dist/chunk-L3XC464G.cjs.map +0 -1
- package/dist/chunk-M2LFQY2E.cjs.map +0 -1
- package/dist/chunk-NGJXVJB7.cjs.map +0 -1
- package/dist/chunk-V3VBHSK6.cjs.map +0 -1
package/dist/3d.d.ts
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { b as SpaceNow, c as SequenceCommon, d as PropValue, e as Sequence, f as PathRouters, S as SequenceSpec } from './types-kt7DQKfO.js';
|
|
2
|
+
import { Renderer, RenderTexture } from 'pixi.js';
|
|
3
|
+
import { View3D, Container3D, Camera3D, View3DOptions, FlatMaterial, Model3D } from '@pixi/3d';
|
|
4
|
+
import { C as CanvasCheck } from './Canvas-BfZkAFJm.js';
|
|
5
|
+
|
|
6
|
+
/** Handed to setup / update / dispose. One per scene3d layer. */
|
|
7
|
+
interface Scene3DContext {
|
|
8
|
+
/** The PixiJS 3D view the layer shows: a PixiJS display object that draws the scene inside PixiJS's own renderer. */
|
|
9
|
+
view: View3D;
|
|
10
|
+
/** `view.root`: add the meshes, models and lights here. */
|
|
11
|
+
root: Container3D;
|
|
12
|
+
/** `view.camera`: the view owns its camera (fov in degrees, `mode` perspective or orthographic); place it with `position.set` and `lookAt`. */
|
|
13
|
+
camera: Camera3D;
|
|
14
|
+
/** PixiJS's renderer (the same one that draws every layer). */
|
|
15
|
+
renderer: Renderer;
|
|
16
|
+
/** The layer's size in composition px. */
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
/** What setup returned in `objects`, plus `camera` and `view`: the names keyframes reach as `scene3d.<name>.<path>`. */
|
|
20
|
+
objects: Record<string, object>;
|
|
21
|
+
/** With `followCamera`: the composition's camera (and lights, fog) at this moment, as plain numbers, set before every `update`; undefined otherwise. */
|
|
22
|
+
space?: SpaceNow;
|
|
23
|
+
}
|
|
24
|
+
interface Scene3DSetupResult {
|
|
25
|
+
/** Objects addressable from keyframes as `scene3d.<name>.<path>` (`camera` and `view` are added unless you name your own). */
|
|
26
|
+
objects?: Record<string, object>;
|
|
27
|
+
}
|
|
28
|
+
interface Scene3DSequenceSpec extends SequenceCommon {
|
|
29
|
+
type: 'scene3d';
|
|
30
|
+
/** Layer size in composition px. Expressions allowed (e.g. 'W * 0.5'). Default: the parent composition's size. */
|
|
31
|
+
width?: PropValue;
|
|
32
|
+
height?: PropValue;
|
|
33
|
+
/**
|
|
34
|
+
* Options for the PixiJS 3D view (`environment`, `toneMapping`, `exposure`, `shadowQuality`, `passes`, `cull`, ...). `width`, `height` and `autoResize` belong to the layer.
|
|
35
|
+
* The layer draws with `cull: 'cpu'` unless you name one (the GPU cull of large batches is not the same from draw to draw on WebGPU).
|
|
36
|
+
*/
|
|
37
|
+
view?: Omit<View3DOptions, 'width' | 'height' | 'autoResize'>;
|
|
38
|
+
/**
|
|
39
|
+
* Live in the composition's space: before every frame the view's camera is put where the composition's `camera` layer is (position, look-at, vertical fov), so a
|
|
40
|
+
* `cameraPath()` flies through the flat layers and this scene together. The scene is in composition PIXELS with y flipped: a point the composition calls (x, y, z) is
|
|
41
|
+
* (x, -y, z) here. Give the layer the composition's size (the default).
|
|
42
|
+
*/
|
|
43
|
+
followCamera?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* The composition's `light` layers become PixiJS 3D lights in this scene (ambient, point, spot, parallel; same position, colour, intensity, cone, falloff), moved every
|
|
46
|
+
* frame. A parallel or spot light with `castsShadows` casts in the scene (meshes cast and receive by default in PixiJS 3D); a point light cannot cast in PixiJS 3D (it says so).
|
|
47
|
+
*/
|
|
48
|
+
followLights?: boolean;
|
|
49
|
+
/** The composition camera's fog (`fogNear` / `fogFar` / `fogColor`) becomes the view's linear fog, every frame (PixiJS 3D fades by smoothstep; no `fogAmount` below 1). */
|
|
50
|
+
followFog?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* A rebuild (`setVars`, `resize`, `rebuild`) keeps this layer's scene when the layer did not change (same `name`, same `setup` function, size and options): `setup` runs once,
|
|
53
|
+
* not at every rebuild, and a model is not loaded again. Default `true`; a layer with no `name` is always built again. `false`: `setup` runs again at every rebuild (when it
|
|
54
|
+
* reads something a variable changes). `update` is the new composition's own and runs on the kept scene.
|
|
55
|
+
*/
|
|
56
|
+
reuse?: boolean;
|
|
57
|
+
/** The view's resolution (1 draws at the layer's size; another value draws the scene at that scale and composites it). */
|
|
58
|
+
resolution?: number;
|
|
59
|
+
/** Build the scene: add objects to `ctx.root`, place `ctx.camera`. May be async (a model loads): Movie.init waits for it. */
|
|
60
|
+
setup: (ctx: Scene3DContext) => Promise<Scene3DSetupResult | void> | Scene3DSetupResult | void;
|
|
61
|
+
/**
|
|
62
|
+
* Per frame; `t` is the layer's own time in seconds. MUST set everything from `t` (no clock, no unseeded randomness, no state carried from the last call):
|
|
63
|
+
* playback, a seek and an export each draw a frame on its own. A model's clip: `model.player.getState(name).gotoAndStop(t)`.
|
|
64
|
+
*/
|
|
65
|
+
update?: (t: number, ctx: Scene3DContext) => void;
|
|
66
|
+
/** Cleanup for resources you made (the view and everything under its root are destroyed by the layer). */
|
|
67
|
+
dispose?: (ctx: Scene3DContext) => void;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* A `scene3d` layer: a PixiJS 3D scene (`View3D`) drawn inside PixiJS's own renderer, in the layer's place in the stack. The author builds the scene in `setup` and
|
|
72
|
+
* sets it from the time in `update`; `awaitFrameAt` (the per-frame hook `Movie` awaits for playback, seek and export alike) runs `update`, and PixiJS draws the view with the stage.
|
|
73
|
+
*/
|
|
74
|
+
declare class Scene3DSequence extends Sequence {
|
|
75
|
+
private _view;
|
|
76
|
+
private _ctx;
|
|
77
|
+
private _objects;
|
|
78
|
+
private _warned;
|
|
79
|
+
/** The animation players under the root (found after setup). */
|
|
80
|
+
private _players;
|
|
81
|
+
/** The layer's own last filter: what PixiJS 3D ignores on its view (alpha, its parents' alpha, a basic blend mode) applied to the view's picture. Only there while needed. */
|
|
82
|
+
private _look;
|
|
83
|
+
/** An advanced blend mode on a layer with no filter of its own: its blend filter, owned by the layer (the view's own blend mode would be shut inside the look filter's pass). */
|
|
84
|
+
private _blend;
|
|
85
|
+
/** The layer's time, what PixiJS 3D's shader time `uTime` reads once pinned (see `_pinShaderTime`). */
|
|
86
|
+
private _time;
|
|
87
|
+
/** Things to do before every frame of the scene is drawn (the 2D layers shown on meshes: `layerTexture`), and their handles. */
|
|
88
|
+
private _drawHooks;
|
|
89
|
+
private _shown;
|
|
90
|
+
/** Resources the 2D layers on meshes leave to this layer to free when it goes (shared, like `_shown`, with a layer that takes the scene over). */
|
|
91
|
+
private _owned;
|
|
92
|
+
/** What a rebuild matches this layer by (core/reuse.ts); null: never kept (`reuse: false`, no `name`, view options that are not plain data). */
|
|
93
|
+
private _key;
|
|
94
|
+
/** The layer of the tree being replaced whose scene this one takes over at the swap (`commitReuse`): until then it is not this layer's. */
|
|
95
|
+
private _borrowed;
|
|
96
|
+
/** True once another layer took this layer's scene: destroying this one must not let it go. */
|
|
97
|
+
private _donated;
|
|
98
|
+
private _pendingRebinds;
|
|
99
|
+
private _lightMirror;
|
|
100
|
+
private _fogMirror;
|
|
101
|
+
private _pinned;
|
|
102
|
+
/** The scene may have changed since the meshes were last made pickable (a frame ran `update`): the next pick walks it again, the picks after it do not. */
|
|
103
|
+
private _pickStale;
|
|
104
|
+
/** The PixiJS 3D view this layer shows (null before build and after destroy). */
|
|
105
|
+
get view(): View3D | null;
|
|
106
|
+
private get _spec();
|
|
107
|
+
private _say;
|
|
108
|
+
private _who;
|
|
109
|
+
protected pathRouters(): PathRouters;
|
|
110
|
+
build(): Promise<void>;
|
|
111
|
+
/** Reuse (core/reuse.ts): the key this layer is matched by, while it can still lend its scene. */
|
|
112
|
+
reuseKey(): string | null;
|
|
113
|
+
private _lendable;
|
|
114
|
+
/**
|
|
115
|
+
* Take over a layer of the tree being replaced. The view is a PixiJS display object with one parent, so the old view stays in the old tree (which goes on drawing while this tree is
|
|
116
|
+
* built); this layer has a view of its own, and at the swap (`commitReuse`) the old view's whole scene, its camera with it, moves into this one. The objects setup made (and every
|
|
117
|
+
* value an author kept from setup: the camera, the meshes) are the same objects.
|
|
118
|
+
*/
|
|
119
|
+
private _borrow;
|
|
120
|
+
/** The new tree is on stage: the scene of the layer this one borrowed from moves into this layer's view, for good. */
|
|
121
|
+
commitReuse(): void;
|
|
122
|
+
/** Unknown keys (with the likely one), and the keys only a three layer has. */
|
|
123
|
+
private _checkKeys;
|
|
124
|
+
/**
|
|
125
|
+
* PixiJS 3D (0.1.0) writes `performance.now()` into the shader time `uTime` of every view at every draw: a shader bit that reads it would follow the wall clock.
|
|
126
|
+
* The view's global uniforms exist once PixiJS has drawn it; from then on `uTime` reads the layer's time and the pipe's write is ignored. Tried before every frame
|
|
127
|
+
* until it holds (drawing the view on its own at build to make them sooner broke a stencil mask on it later). This reaches into the view's per-renderer data
|
|
128
|
+
* (`_gpuData[renderer.uid].globalUniformGroup.uniforms`); when that is there but has no `uTime` (another version), say so once.
|
|
129
|
+
*/
|
|
130
|
+
private _pinShaderTime;
|
|
131
|
+
/**
|
|
132
|
+
* `followCamera` (and, later, `followLights` / `followFog`): before each frame, ask the composition for its camera at this moment (the layer's time on the composition's
|
|
133
|
+
* clock) and put the view's camera there. `ctx.space` keeps the raw numbers for `update`, which runs after and may override.
|
|
134
|
+
*/
|
|
135
|
+
private _followSpace;
|
|
136
|
+
/** followCamera shows the whole composition through the layer's picture: a layer of another shape would show it squeezed or cut. Said once at build. */
|
|
137
|
+
private _checkFollowShape;
|
|
138
|
+
/** PixiJS 3D draws the view in its materials' colours: a tint does nothing. Said once, at build. */
|
|
139
|
+
private _checkTint;
|
|
140
|
+
/**
|
|
141
|
+
* Every frame, before the draw: PixiJS 3D ignores the view's alpha (and its parents') and a basic blend mode, so when the layer is not at full strength or blends,
|
|
142
|
+
* its picture goes through one AlphaFilter of the layer's own, last in its filter list, that applies them. A layer at alpha 1 with a normal blend has no such filter.
|
|
143
|
+
*/
|
|
144
|
+
syncFrame(): void;
|
|
145
|
+
/**
|
|
146
|
+
* Models, animation players and particle systems update themselves on PixiJS's shared ticker unless told otherwise: their picture would follow the browser's clock,
|
|
147
|
+
* not the video's time. Turn that off on everything under the root, and say once what was turned off (the author drives them from `update`).
|
|
148
|
+
*/
|
|
149
|
+
private _stopSelfUpdating;
|
|
150
|
+
/**
|
|
151
|
+
* Per-frame hook, duck-typed by `Movie._awaitVideoFrames` (as the video and three layers are): the single frame path of playback, seek and export.
|
|
152
|
+
* `update` sets the scene from the time; PixiJS draws the view with the rest of the stage.
|
|
153
|
+
*/
|
|
154
|
+
awaitFrameAt(local: number): Promise<void>;
|
|
155
|
+
/**
|
|
156
|
+
* A clip still playing after `update` (a model made with `autoPlay`, a `player.play(name)` in setup) is posed by nobody: it would move with the ticker, or not at all.
|
|
157
|
+
* The layer poses it from its own time (its speed and loop kept) and leaves it playing, so it plays in the video as it would in a page. A clip `update` poses itself
|
|
158
|
+
* (`gotoAndStop(t)` stops it) is left alone. Nothing is remembered from one frame to the next: the frame depends on this frame's `update` only.
|
|
159
|
+
*/
|
|
160
|
+
private _poseClips;
|
|
161
|
+
/**
|
|
162
|
+
* The determinism check (`check`, `movie.review()`): the scene set by `update` and drawn at a few moments in two orders, with one draw thrown away first, and the pictures
|
|
163
|
+
* compared, as the canvas and three layers are. A scene whose same frame is not the same picture (state kept from call to call, a clock, a player or particle system on its
|
|
164
|
+
* own clock, a motion blur that reads the last frame) is reported. It draws the view alone into a texture of its own size with PixiJS's renderer; the next real frame sets
|
|
165
|
+
* the scene again, so nothing is left behind.
|
|
166
|
+
*/
|
|
167
|
+
checkDeterminism(times: number[]): CanvasCheck;
|
|
168
|
+
/** What `layerTexture` asks of this layer: the layers listed before it, PixiJS's renderer, and a place to hook in before every frame. */
|
|
169
|
+
private _makeHost;
|
|
170
|
+
/** True when this layer shows 2D layers on its meshes (`layerTexture`): the movie runs its frame after the rest of the frame is ready (projections, filters fed), as for a three layer. */
|
|
171
|
+
get showsLayers(): boolean;
|
|
172
|
+
/** The 2D layer that a material shows (`layerTexture`), for a click on the mesh to reach it (movie.pick); null for any other material. */
|
|
173
|
+
screenOf(material: unknown): {
|
|
174
|
+
source: Sequence;
|
|
175
|
+
at(u: number, v: number): {
|
|
176
|
+
x: number;
|
|
177
|
+
y: number;
|
|
178
|
+
};
|
|
179
|
+
} | null;
|
|
180
|
+
/** The view's global point at (u, v) of its picture (0..1, v down). */
|
|
181
|
+
private _globalAt;
|
|
182
|
+
/**
|
|
183
|
+
* Make the scene's meshes hit by a ray, exactly: PixiJS 3D only hits nodes whose eventMode is not 'passive', and by default against the mesh's bounding box (a sphere's corners
|
|
184
|
+
* count, and the hit has no uv). A mesh the author left as it was gets eventMode 'static' and hitVolume 'geometry' (per triangle: the silhouette, the normal and the uv a 2D
|
|
185
|
+
* layer on the mesh needs); the author's own choice is kept.
|
|
186
|
+
*/
|
|
187
|
+
private _makePickable;
|
|
188
|
+
/**
|
|
189
|
+
* `movie.pick`: a ray through (u, v) of the layer's picture (0..1, v down) from the view's camera, and what it meets first: the object's name (its own label, or its nearest
|
|
190
|
+
* labelled ancestor's), where (scene units), how far from the camera, and the node. Uses the transforms of the last render, which is the frame on screen. null when it meets nothing.
|
|
191
|
+
*/
|
|
192
|
+
pickAt(u: number, v: number): {
|
|
193
|
+
object: string;
|
|
194
|
+
point: [number, number, number];
|
|
195
|
+
distance: number;
|
|
196
|
+
object3d: unknown;
|
|
197
|
+
uv?: {
|
|
198
|
+
u: number;
|
|
199
|
+
v: number;
|
|
200
|
+
};
|
|
201
|
+
material?: unknown;
|
|
202
|
+
} | null;
|
|
203
|
+
/**
|
|
204
|
+
* `hit.scene3d.grab(plane)`: a function of a point (u, v) of the layer's picture that gives where the pointer's ray meets a plane through the grabbed point, and how far that is
|
|
205
|
+
* from it (`delta`): move the object by it. `plane`: 'screen' (facing the camera: the default), 'floor' (horizontal: y up), 'wall' (z constant), or a normal [x, y, z].
|
|
206
|
+
* null where the ray never meets the plane.
|
|
207
|
+
*/
|
|
208
|
+
dragPlane(point: [number, number, number], plane?: 'screen' | 'floor' | 'wall' | [number, number, number]): (u: number, v: number) => {
|
|
209
|
+
point: [number, number, number];
|
|
210
|
+
delta: [number, number, number];
|
|
211
|
+
} | null;
|
|
212
|
+
private _resolvePath;
|
|
213
|
+
private _warnPath;
|
|
214
|
+
private _destroyView;
|
|
215
|
+
destroy(): void;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* `layerTexture(ctx, 'screen')`: a live 2D layer (a `composition`) as the picture on a mesh of a `scene3d` layer (a phone's screen, a television, a billboard, a label).
|
|
220
|
+
*
|
|
221
|
+
* The 2D layer stays a layer of the movie: the timeline drives it, its own `at` / `duration` / keyframes / filters apply. It is not drawn on the stage any more: before each
|
|
222
|
+
* frame of the scene3d layer (after the timeline has put every layer at that frame), PixiJS draws it into a RenderTexture, and the material shows that texture. PixiJS 3D takes
|
|
223
|
+
* a PixiJS texture as it is: no copy, no read-back, the same on WebGL and WebGPU.
|
|
224
|
+
*/
|
|
225
|
+
|
|
226
|
+
interface LayerTextureOptions {
|
|
227
|
+
/** Pixels of the texture per pixel of the 2D layer: 2 for a screen that is seen large. Default 1. */
|
|
228
|
+
resolution?: number;
|
|
229
|
+
/** The 2D layer's empty and half-transparent parts let what is behind the mesh show through (a sticker, a hologram). Default `false`: an opaque screen, empty parts black. */
|
|
230
|
+
transparent?: boolean;
|
|
231
|
+
}
|
|
232
|
+
interface LayerTexture {
|
|
233
|
+
/** An unlit material that shows the 2D layer: put it on a mesh. A screen shines by itself, so the scene's lights do not shade it. */
|
|
234
|
+
material: FlatMaterial;
|
|
235
|
+
/** The texture behind the material (a PixiJS RenderTexture, redrawn every frame). */
|
|
236
|
+
texture: RenderTexture;
|
|
237
|
+
/** The size of the texture in pixels. */
|
|
238
|
+
width: number;
|
|
239
|
+
height: number;
|
|
240
|
+
/** Stop showing the layer on the mesh (it is drawn on the stage again; the mesh keeps the last picture). The material and the texture are freed with the scene3d layer. */
|
|
241
|
+
dispose(): void;
|
|
242
|
+
}
|
|
243
|
+
declare function layerTexture(ctx: Scene3DContext, name: string, options?: LayerTextureOptions): Promise<LayerTexture>;
|
|
244
|
+
|
|
245
|
+
interface LoadModelOptions {
|
|
246
|
+
/** A clip name, a clip index, or `false` (no animation: the model's bind pose). Default: the first clip, if the file has one. */
|
|
247
|
+
animation?: string | number | false;
|
|
248
|
+
/** The clip time is `t x speed + offset` (the layer's seconds). Defaults 1 and 0. */
|
|
249
|
+
speed?: number;
|
|
250
|
+
offset?: number;
|
|
251
|
+
/** `true` (default): the clip repeats; `false`: it holds its last pose. */
|
|
252
|
+
loop?: boolean;
|
|
253
|
+
}
|
|
254
|
+
interface LoadedModel {
|
|
255
|
+
/** Add this to `ctx.root`. A group whose origin is the centre of the model's bounding box (bind pose): position, turn and `fit` it about its centre. */
|
|
256
|
+
object: Container3D;
|
|
257
|
+
/** The PixiJS 3D model inside `object` (its `player`, `materials`, `skeletons`). */
|
|
258
|
+
model: Model3D;
|
|
259
|
+
/** The names of the clips the file has. */
|
|
260
|
+
clips: string[];
|
|
261
|
+
/** The size of the model's bounding box now (with `fit`), in the scene's units. */
|
|
262
|
+
size(): {
|
|
263
|
+
x: number;
|
|
264
|
+
y: number;
|
|
265
|
+
z: number;
|
|
266
|
+
};
|
|
267
|
+
/** Scale `object` so the model's longest side is `n` (a model in metres in a scene in composition pixels: `fit(400)` under `followCamera`). */
|
|
268
|
+
fit(n: number): void;
|
|
269
|
+
/** Pose the model at the layer's time `t` (seconds): the clip at `t x speed + offset`, looped or held. A seek, an export and a repeat give the same pose. */
|
|
270
|
+
pose(t: number): void;
|
|
271
|
+
}
|
|
272
|
+
/** Load a glTF / GLB (a URL relative to the page) as a PixiJS 3D model, ready to pose from the time. Call it in a scene3d layer's `setup` (await it). */
|
|
273
|
+
declare function loadModel(url: string, options?: LoadModelOptions): Promise<LoadedModel>;
|
|
274
|
+
interface FitCameraOptions {
|
|
275
|
+
/** The direction the camera sits in from the centre of the object, any length. Default `[0.45, 0.3, 1]`: a three-quarter view, a little from the side and above. */
|
|
276
|
+
direction?: [number, number, number];
|
|
277
|
+
/** Free room around the object: 1.1 (the default) leaves 10 %. */
|
|
278
|
+
margin?: number;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Put the layer's camera where the whole of `object` (its bounding box now, with its scale and place) fits the picture, looking at its centre: the smallest distance at which
|
|
282
|
+
* the 8 corners of the box fit both the vertical and the horizontal field of view. Uses the camera's `fov` and the layer's shape; `near` and `far` follow the distance.
|
|
283
|
+
* The box is the pose of now: for a clip that travels far, place the camera yourself.
|
|
284
|
+
*/
|
|
285
|
+
declare function fitCamera(ctx: Scene3DContext, object: Container3D, options?: FitCameraOptions): void;
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* pixi-effects/3d — 3D scenes drawn by PixiJS 3D (`@pixi/3d`), the main 3D engine.
|
|
289
|
+
*
|
|
290
|
+
* Import this entry BEFORE `movie.init` and call `register3D()` once: PixiJS loads the 3D drawing code while its renderer starts, so a
|
|
291
|
+
* renderer that started before `@pixi/3d` was imported cannot draw a `scene3d` layer. The core `pixi-effects` entry never loads `@pixi/3d`.
|
|
292
|
+
*/
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Register the `scene3d` layer type. Explicit call so `sideEffects: false` bundlers cannot drop it; calling it again is fine.
|
|
296
|
+
* It also turns off the self-updating of models and animation players (they would move with the browser's clock, not the video's time):
|
|
297
|
+
* pose a clip from the time in `update` with `model.player.getState(name).gotoAndStop(t)`.
|
|
298
|
+
*/
|
|
299
|
+
declare function register3D(): void;
|
|
300
|
+
/** Typing helper: accepts a strongly-typed scene3d spec and returns it as a core SequenceSpec, keeping `@pixi/3d` types out of the core union. */
|
|
301
|
+
declare function scene3d(spec: Scene3DSequenceSpec): SequenceSpec;
|
|
302
|
+
|
|
303
|
+
export { type FitCameraOptions, type LayerTexture, type LayerTextureOptions, type LoadModelOptions, type LoadedModel, type Scene3DContext, Scene3DSequence, type Scene3DSequenceSpec, type Scene3DSetupResult, fitCamera, layerTexture, loadModel, register3D, scene3d };
|