angular-three-theatre 4.0.0-next.115 → 4.0.0-next.118
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 +134 -0
- package/fesm2022/angular-three-theatre.mjs +665 -54
- package/fesm2022/angular-three-theatre.mjs.map +1 -1
- package/package.json +4 -4
- package/types/angular-three-theatre.d.ts +734 -0
- package/index.d.ts +0 -203
|
@@ -0,0 +1,734 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { ElementRef } from '@angular/core';
|
|
3
|
+
import * as _theatre_core from '@theatre/core';
|
|
4
|
+
import { IProjectConfig, ISheet, UnknownShorthandCompoundProps, types, ISequence } from '@theatre/core';
|
|
5
|
+
import { NgtsTransformControlsOptions } from 'angular-three-soba/gizmos';
|
|
6
|
+
import * as THREE from 'three';
|
|
7
|
+
import { IStudio } from '@theatre/studio';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Component that creates and manages a Theatre.js project.
|
|
11
|
+
*
|
|
12
|
+
* A Theatre.js project is the top-level container for all animation data.
|
|
13
|
+
* It contains sheets, which in turn contain sheet objects that hold animatable properties.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```html
|
|
17
|
+
* <theatre-project name="my-animation" [config]="{ state: savedState }">
|
|
18
|
+
* <ng-container sheet="scene1">
|
|
19
|
+
* <!-- sheet objects here -->
|
|
20
|
+
* </ng-container>
|
|
21
|
+
* </theatre-project>
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
declare class TheatreProject {
|
|
25
|
+
/**
|
|
26
|
+
* The name of the Theatre.js project.
|
|
27
|
+
* This name is used to identify the project and must be unique.
|
|
28
|
+
*
|
|
29
|
+
* @default 'default-theatre-project'
|
|
30
|
+
*/
|
|
31
|
+
name: _angular_core.InputSignal<string>;
|
|
32
|
+
/**
|
|
33
|
+
* Configuration options for the Theatre.js project.
|
|
34
|
+
* Can include saved state data for restoring animations.
|
|
35
|
+
*
|
|
36
|
+
* @default {}
|
|
37
|
+
*/
|
|
38
|
+
config: _angular_core.InputSignal<IProjectConfig>;
|
|
39
|
+
/**
|
|
40
|
+
* Computed signal containing the Theatre.js project instance.
|
|
41
|
+
*/
|
|
42
|
+
project: _angular_core.Signal<_theatre_core.IProject>;
|
|
43
|
+
/**
|
|
44
|
+
* Internal registry of sheets created within this project.
|
|
45
|
+
* Tracks sheet instances and their reference counts for cleanup.
|
|
46
|
+
*/
|
|
47
|
+
sheets: Record<string, [sheet: ISheet, count: number]>;
|
|
48
|
+
constructor();
|
|
49
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<TheatreProject, never>;
|
|
50
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<TheatreProject, "theatre-project", never, { "name": { "alias": "name"; "required": false; "isSignal": true; }; "config": { "alias": "config"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Directive that creates a Theatre.js sheet object for animating properties.
|
|
55
|
+
*
|
|
56
|
+
* A sheet object is a container for animatable properties within a sheet.
|
|
57
|
+
* This directive must be applied to an `ng-template` element and provides
|
|
58
|
+
* a structural context with access to the sheet object and its values.
|
|
59
|
+
*
|
|
60
|
+
* The template context includes:
|
|
61
|
+
* - `sheetObject`: The Theatre.js sheet object instance (read-only signal)
|
|
62
|
+
* - `values`: Current values of all animated properties (read-only signal)
|
|
63
|
+
* - `select()`: Method to select this object in Theatre.js Studio
|
|
64
|
+
* - `deselect()`: Method to deselect this object in Theatre.js Studio
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```html
|
|
68
|
+
* <ng-template sheetObject="cube" [sheetObjectProps]="{ opacity: 1 }" let-values="values">
|
|
69
|
+
* <ngt-mesh>
|
|
70
|
+
* <ngt-mesh-standard-material [opacity]="values().opacity" />
|
|
71
|
+
* </ngt-mesh>
|
|
72
|
+
* </ng-template>
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```html
|
|
77
|
+
* <!-- With selection support -->
|
|
78
|
+
* <ng-template
|
|
79
|
+
* sheetObject="cube"
|
|
80
|
+
* [(sheetObjectSelected)]="isSelected"
|
|
81
|
+
* let-select="select"
|
|
82
|
+
* let-deselect="deselect"
|
|
83
|
+
* >
|
|
84
|
+
* <ngt-mesh (click)="select()" />
|
|
85
|
+
* </ng-template>
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
declare class TheatreSheetObject$1 {
|
|
89
|
+
/**
|
|
90
|
+
* Unique key identifying this sheet object within its parent sheet.
|
|
91
|
+
* This key is used by Theatre.js to track and persist animation data.
|
|
92
|
+
*/
|
|
93
|
+
key: _angular_core.InputSignal<string>;
|
|
94
|
+
/**
|
|
95
|
+
* Initial properties and their default values for this sheet object.
|
|
96
|
+
* These properties will be animatable in Theatre.js Studio.
|
|
97
|
+
*
|
|
98
|
+
* @default {}
|
|
99
|
+
*/
|
|
100
|
+
props: _angular_core.InputSignal<UnknownShorthandCompoundProps>;
|
|
101
|
+
/**
|
|
102
|
+
* Whether to detach (remove) the sheet object when this directive is destroyed.
|
|
103
|
+
* When true, the animation data for this object will be removed from the sheet.
|
|
104
|
+
*
|
|
105
|
+
* @default false
|
|
106
|
+
*/
|
|
107
|
+
detach: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
|
108
|
+
/**
|
|
109
|
+
* Two-way bindable signal indicating whether this object is selected in Theatre.js Studio.
|
|
110
|
+
*
|
|
111
|
+
* @default false
|
|
112
|
+
*/
|
|
113
|
+
selected: _angular_core.ModelSignal<boolean>;
|
|
114
|
+
private templateRef;
|
|
115
|
+
private vcr;
|
|
116
|
+
private sheet;
|
|
117
|
+
private studio;
|
|
118
|
+
private store;
|
|
119
|
+
private originalSheetObject;
|
|
120
|
+
/**
|
|
121
|
+
* Signal containing the Theatre.js sheet object instance.
|
|
122
|
+
* This is a linked signal that updates when the sheet or key changes.
|
|
123
|
+
*/
|
|
124
|
+
sheetObject: _angular_core.WritableSignal<_theatre_core.ISheetObject<UnknownShorthandCompoundProps>>;
|
|
125
|
+
/**
|
|
126
|
+
* Signal containing the current values of all animated properties.
|
|
127
|
+
* Updates automatically when Theatre.js values change.
|
|
128
|
+
*/
|
|
129
|
+
values: _angular_core.WritableSignal<{
|
|
130
|
+
[x: string]: any;
|
|
131
|
+
}>;
|
|
132
|
+
private detached;
|
|
133
|
+
private aggregatedProps;
|
|
134
|
+
constructor();
|
|
135
|
+
/**
|
|
136
|
+
* Updates the sheet object with the current aggregated props.
|
|
137
|
+
* Detaches the existing object and creates a new one with reconfigured properties.
|
|
138
|
+
*/
|
|
139
|
+
update(): void;
|
|
140
|
+
/**
|
|
141
|
+
* Adds new properties to the sheet object.
|
|
142
|
+
* The properties are merged with existing properties and the object is reconfigured.
|
|
143
|
+
*
|
|
144
|
+
* @param props - Properties to add to the sheet object
|
|
145
|
+
*/
|
|
146
|
+
addProps(props: UnknownShorthandCompoundProps): void;
|
|
147
|
+
/**
|
|
148
|
+
* Removes properties from the sheet object.
|
|
149
|
+
* If all properties are removed and `detach` is true, the object is detached from the sheet.
|
|
150
|
+
*
|
|
151
|
+
* @param props - Array of property names to remove
|
|
152
|
+
*/
|
|
153
|
+
removeProps(props: string[]): void;
|
|
154
|
+
/**
|
|
155
|
+
* Selects this sheet object in Theatre.js Studio.
|
|
156
|
+
* Only works when the studio is available.
|
|
157
|
+
*/
|
|
158
|
+
select(): void;
|
|
159
|
+
/**
|
|
160
|
+
* Deselects this sheet object in Theatre.js Studio.
|
|
161
|
+
* Only deselects if this object is currently selected.
|
|
162
|
+
*/
|
|
163
|
+
deselect(): void;
|
|
164
|
+
/**
|
|
165
|
+
* Type guard for the template context.
|
|
166
|
+
* Provides type safety for the template variables exposed by this directive.
|
|
167
|
+
*
|
|
168
|
+
* @param _ - The directive instance
|
|
169
|
+
* @param ctx - The template context
|
|
170
|
+
* @returns Type predicate for the template context
|
|
171
|
+
*/
|
|
172
|
+
static ngTemplateContextGuard(_: TheatreSheetObject$1, ctx: unknown): ctx is {
|
|
173
|
+
select: TheatreSheetObject$1['select'];
|
|
174
|
+
deselect: TheatreSheetObject$1['deselect'];
|
|
175
|
+
sheetObject: ReturnType<TheatreSheetObject$1['sheetObject']['asReadonly']>;
|
|
176
|
+
values: ReturnType<TheatreSheetObject$1['values']['asReadonly']>;
|
|
177
|
+
};
|
|
178
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<TheatreSheetObject$1, never>;
|
|
179
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<TheatreSheetObject$1, "ng-template[sheetObject]", ["sheetObject"], { "key": { "alias": "sheetObject"; "required": true; "isSignal": true; }; "props": { "alias": "sheetObjectProps"; "required": false; "isSignal": true; }; "detach": { "alias": "sheetObjectDetach"; "required": false; "isSignal": true; }; "selected": { "alias": "sheetObjectSelected"; "required": false; "isSignal": true; }; }, { "selected": "sheetObjectSelectedChange"; }, never, never, true, never>;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Type definition for a Theatre.js property transformer.
|
|
184
|
+
*
|
|
185
|
+
* Transformers are used to convert between Three.js property values and
|
|
186
|
+
* Theatre.js animation values. This allows for proper representation
|
|
187
|
+
* in the Theatre.js Studio UI (e.g., showing degrees instead of radians).
|
|
188
|
+
*
|
|
189
|
+
* Based on https://github.com/threlte/threlte/blob/main/packages/theatre/src/lib/sheetObject/transfomers/types.ts
|
|
190
|
+
*
|
|
191
|
+
* @typeParam Value - The type of the original Three.js property value
|
|
192
|
+
* @typeParam TransformedValue - The type of the value used in Theatre.js
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* const myTransformer: TheatreTransformer<number, number> = {
|
|
197
|
+
* transform: (value) => types.number(value * 100),
|
|
198
|
+
* apply: (target, property, value) => { target[property] = value / 100; }
|
|
199
|
+
* };
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
type TheatreTransformer<Value = any, TransformedValue = any> = {
|
|
203
|
+
/**
|
|
204
|
+
* The `transform` function is used to transform the value of a certain
|
|
205
|
+
* Three.js objects proerty to a property that Theatre.js can use in an
|
|
206
|
+
* `ISheetObject`. To ensure compatibility with the rest of the package, the
|
|
207
|
+
* return value must be any one of the functions available at Theatre.js'
|
|
208
|
+
* `types`.
|
|
209
|
+
*/
|
|
210
|
+
transform: (value: Value) => ReturnType<(typeof types)[keyof typeof types]>;
|
|
211
|
+
/**
|
|
212
|
+
* The `apply` function is used to apply the value to the target. `target` is
|
|
213
|
+
* the parent object of the property (usually a Three.js object), `path` is
|
|
214
|
+
* the name of the property and `value` is the value to apply.
|
|
215
|
+
*/
|
|
216
|
+
apply: (target: any, property: string, value: TransformedValue) => void;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Directive that synchronizes Three.js object properties with Theatre.js animations.
|
|
221
|
+
*
|
|
222
|
+
* This directive allows you to expose specific properties of a Three.js object
|
|
223
|
+
* to Theatre.js for animation. It automatically handles property transformation
|
|
224
|
+
* (e.g., converting Euler angles to degrees for the UI).
|
|
225
|
+
*
|
|
226
|
+
* Must be used within a `TheatreSheetObject` context.
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```html
|
|
230
|
+
* <ng-template sheetObject="myMaterial">
|
|
231
|
+
* <ngt-mesh-standard-material
|
|
232
|
+
* [sync]="material"
|
|
233
|
+
* [syncProps]="['opacity', 'roughness', 'metalness']"
|
|
234
|
+
* #material
|
|
235
|
+
* />
|
|
236
|
+
* </ng-template>
|
|
237
|
+
* ```
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```html
|
|
241
|
+
* <!-- With custom property mapping -->
|
|
242
|
+
* <ng-template sheetObject="myLight">
|
|
243
|
+
* <ngt-point-light
|
|
244
|
+
* [sync]="light"
|
|
245
|
+
* [syncProps]="[
|
|
246
|
+
* ['intensity', { label: 'Light Intensity', key: 'lightIntensity' }],
|
|
247
|
+
* 'color'
|
|
248
|
+
* ]"
|
|
249
|
+
* #light
|
|
250
|
+
* />
|
|
251
|
+
* </ng-template>
|
|
252
|
+
* ```
|
|
253
|
+
*
|
|
254
|
+
* @typeParam TObject - The type of the Three.js object being synchronized
|
|
255
|
+
*/
|
|
256
|
+
declare class TheatreSheetObjectSync<TObject extends object> {
|
|
257
|
+
/**
|
|
258
|
+
* The Three.js object to synchronize with Theatre.js.
|
|
259
|
+
* Can be an object reference, ElementRef, or a function returning either.
|
|
260
|
+
*/
|
|
261
|
+
parent: _angular_core.InputSignal<TObject | ElementRef<TObject> | (() => TObject | ElementRef<TObject> | undefined | null)>;
|
|
262
|
+
/**
|
|
263
|
+
* Array of property paths to synchronize with Theatre.js.
|
|
264
|
+
*
|
|
265
|
+
* Each item can be:
|
|
266
|
+
* - A string property path (e.g., 'opacity', 'position.x')
|
|
267
|
+
* - A tuple of [propertyPath, keyOrOptions] where options can include:
|
|
268
|
+
* - `label`: Display label in Theatre.js Studio
|
|
269
|
+
* - `key`: Unique key for the property in Theatre.js
|
|
270
|
+
* - `transformer`: Custom transformer for the property value
|
|
271
|
+
*
|
|
272
|
+
* @default []
|
|
273
|
+
*/
|
|
274
|
+
props: _angular_core.InputSignal<(string | [string, string | {
|
|
275
|
+
label?: string;
|
|
276
|
+
key?: string;
|
|
277
|
+
transformer?: TheatreTransformer;
|
|
278
|
+
}])[]>;
|
|
279
|
+
private theatreSheetObject;
|
|
280
|
+
/**
|
|
281
|
+
* Computed signal containing the Theatre.js sheet object instance.
|
|
282
|
+
*/
|
|
283
|
+
sheetObject: _angular_core.Signal<_theatre_core.ISheetObject<_theatre_core.UnknownShorthandCompoundProps>>;
|
|
284
|
+
private studio;
|
|
285
|
+
private parentRef;
|
|
286
|
+
private resolvedProps;
|
|
287
|
+
private propsToAdd;
|
|
288
|
+
private propsMapping;
|
|
289
|
+
constructor();
|
|
290
|
+
/**
|
|
291
|
+
* Captures the current values of all synchronized properties from the Three.js object
|
|
292
|
+
* and commits them to Theatre.js.
|
|
293
|
+
*
|
|
294
|
+
* This is useful for "baking" the current state of the Three.js object into the
|
|
295
|
+
* Theatre.js animation. Requires Theatre.js Studio to be available.
|
|
296
|
+
*/
|
|
297
|
+
capture(): void;
|
|
298
|
+
/**
|
|
299
|
+
* Converts a property path (e.g., 'position.x') to a safe alphanumeric key.
|
|
300
|
+
*
|
|
301
|
+
* @param propPath - The property path to convert
|
|
302
|
+
* @returns A safe alphanumeric key string
|
|
303
|
+
*/
|
|
304
|
+
private resolvePropertyPath;
|
|
305
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<TheatreSheetObjectSync<any>, never>;
|
|
306
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<TheatreSheetObjectSync<any>, "[sync]", ["sync"], { "parent": { "alias": "sync"; "required": true; "isSignal": true; }; "props": { "alias": "syncProps"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Component that provides transform controls for animating position, rotation, and scale
|
|
311
|
+
* of child Three.js objects via Theatre.js.
|
|
312
|
+
*
|
|
313
|
+
* When the sheet object is selected in Theatre.js Studio, transform controls appear
|
|
314
|
+
* allowing direct manipulation of the object's transform. Changes are captured and
|
|
315
|
+
* committed to Theatre.js.
|
|
316
|
+
*
|
|
317
|
+
* Must be used within a `TheatreSheetObject` context.
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* ```html
|
|
321
|
+
* <ng-template sheetObject="myCube">
|
|
322
|
+
* <theatre-transform>
|
|
323
|
+
* <ngt-mesh>
|
|
324
|
+
* <ngt-box-geometry />
|
|
325
|
+
* <ngt-mesh-standard-material />
|
|
326
|
+
* </ngt-mesh>
|
|
327
|
+
* </theatre-transform>
|
|
328
|
+
* </ng-template>
|
|
329
|
+
* ```
|
|
330
|
+
*
|
|
331
|
+
* @example
|
|
332
|
+
* ```html
|
|
333
|
+
* <!-- With custom key and options -->
|
|
334
|
+
* <ng-template sheetObject="scene">
|
|
335
|
+
* <theatre-transform key="cubeTransform" label="Cube" [options]="{ mode: 'rotate' }">
|
|
336
|
+
* <ngt-mesh />
|
|
337
|
+
* </theatre-transform>
|
|
338
|
+
* </ng-template>
|
|
339
|
+
* ```
|
|
340
|
+
*
|
|
341
|
+
* @typeParam TLabel - The type of the label string
|
|
342
|
+
*/
|
|
343
|
+
declare class TheatreSheetObjectTransform<TLabel extends string | undefined> {
|
|
344
|
+
/**
|
|
345
|
+
* Display label for the transform properties in Theatre.js Studio.
|
|
346
|
+
*/
|
|
347
|
+
label: _angular_core.InputSignal<TLabel | undefined>;
|
|
348
|
+
/**
|
|
349
|
+
* Unique key for grouping the transform properties in Theatre.js.
|
|
350
|
+
* If provided, position/rotation/scale will be nested under this key.
|
|
351
|
+
*/
|
|
352
|
+
key: _angular_core.InputSignal<string | undefined>;
|
|
353
|
+
/**
|
|
354
|
+
* Options for the transform controls gizmo.
|
|
355
|
+
* Allows configuring the transform mode, snap values, and coordinate space.
|
|
356
|
+
*
|
|
357
|
+
* @default {}
|
|
358
|
+
*/
|
|
359
|
+
options: _angular_core.InputSignal<Pick<NgtsTransformControlsOptions, "mode" | "translationSnap" | "scaleSnap" | "rotationSnap" | "space">>;
|
|
360
|
+
/**
|
|
361
|
+
* Reference to the Three.js Group element that wraps the transformed content.
|
|
362
|
+
*/
|
|
363
|
+
groupRef: _angular_core.Signal<ElementRef<THREE.Group<THREE.Object3DEventMap>>>;
|
|
364
|
+
private controlsRef;
|
|
365
|
+
private theatreSheetObject;
|
|
366
|
+
/**
|
|
367
|
+
* Computed signal containing the Theatre.js sheet object instance.
|
|
368
|
+
*/
|
|
369
|
+
sheetObject: _angular_core.Signal<_theatre_core.ISheetObject<_theatre_core.UnknownShorthandCompoundProps>>;
|
|
370
|
+
private studio;
|
|
371
|
+
protected selected: _angular_core.Signal<boolean>;
|
|
372
|
+
private scrub?;
|
|
373
|
+
private positionTransformer;
|
|
374
|
+
private rotationTransformer;
|
|
375
|
+
private scaleTransformer;
|
|
376
|
+
protected onMouseDown(): void;
|
|
377
|
+
protected onMouseUp(): void;
|
|
378
|
+
protected onChange(): void;
|
|
379
|
+
constructor();
|
|
380
|
+
private init;
|
|
381
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<TheatreSheetObjectTransform<any>, never>;
|
|
382
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<TheatreSheetObjectTransform<any>, "theatre-transform", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "key": { "alias": "key"; "required": false; "isSignal": true; }; "options": { "alias": "options"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Combined array of sheet object directives for convenient importing.
|
|
387
|
+
*
|
|
388
|
+
* Includes:
|
|
389
|
+
* - `TheatreSheetObject` - Base directive for creating sheet objects
|
|
390
|
+
* - `TheatreSheetObjectTransform` - Component for animating transform properties
|
|
391
|
+
* - `TheatreSheetObjectSync` - Directive for syncing arbitrary object properties
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* ```typescript
|
|
395
|
+
* import { TheatreSheetObject } from 'angular-three-theatre';
|
|
396
|
+
*
|
|
397
|
+
* @Component({
|
|
398
|
+
* imports: [TheatreSheetObject],
|
|
399
|
+
* template: `
|
|
400
|
+
* <ng-template sheetObject="myObject">
|
|
401
|
+
* <theatre-transform>
|
|
402
|
+
* <ngt-mesh />
|
|
403
|
+
* </theatre-transform>
|
|
404
|
+
* </ng-template>
|
|
405
|
+
* `
|
|
406
|
+
* })
|
|
407
|
+
* export class MyComponent {}
|
|
408
|
+
* ```
|
|
409
|
+
*/
|
|
410
|
+
declare const TheatreSheetObject: (typeof TheatreSheetObject$1 | typeof TheatreSheetObjectTransform | typeof TheatreSheetObjectSync)[];
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Directive that initializes and manages the Theatre.js Studio.
|
|
414
|
+
*
|
|
415
|
+
* Theatre.js Studio is a visual editor that allows you to create and edit
|
|
416
|
+
* animations directly in the browser. The studio UI is dynamically imported
|
|
417
|
+
* to avoid including it in production builds.
|
|
418
|
+
*
|
|
419
|
+
* This directive must be applied to a `theatre-project` element and provides
|
|
420
|
+
* the studio instance via the `THEATRE_STUDIO` injection token.
|
|
421
|
+
*
|
|
422
|
+
* @example
|
|
423
|
+
* ```html
|
|
424
|
+
* <!-- Enable studio (default) -->
|
|
425
|
+
* <theatre-project studio>
|
|
426
|
+
* <ng-container sheet="scene">...</ng-container>
|
|
427
|
+
* </theatre-project>
|
|
428
|
+
*
|
|
429
|
+
* <!-- Conditionally enable/disable studio -->
|
|
430
|
+
* <theatre-project [studio]="isDevelopment">
|
|
431
|
+
* <ng-container sheet="scene">...</ng-container>
|
|
432
|
+
* </theatre-project>
|
|
433
|
+
*
|
|
434
|
+
* <!-- Disable studio -->
|
|
435
|
+
* <theatre-project [studio]="false">
|
|
436
|
+
* <ng-container sheet="scene">...</ng-container>
|
|
437
|
+
* </theatre-project>
|
|
438
|
+
* ```
|
|
439
|
+
*/
|
|
440
|
+
declare class TheatreStudio {
|
|
441
|
+
/**
|
|
442
|
+
* Whether the studio UI should be visible.
|
|
443
|
+
* When false, the studio UI is hidden but the studio instance remains active.
|
|
444
|
+
*
|
|
445
|
+
* @default true
|
|
446
|
+
*/
|
|
447
|
+
enabled: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
|
448
|
+
private Studio;
|
|
449
|
+
/**
|
|
450
|
+
* Read-only signal containing the Theatre.js Studio instance.
|
|
451
|
+
* May be null while the studio is being loaded.
|
|
452
|
+
*/
|
|
453
|
+
studio: _angular_core.Signal<IStudio | null>;
|
|
454
|
+
constructor();
|
|
455
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<TheatreStudio, never>;
|
|
456
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<TheatreStudio, "theatre-project[studio]", ["studio"], { "enabled": { "alias": "studio"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Options for attaching audio to a Theatre.js sequence.
|
|
461
|
+
*
|
|
462
|
+
* When audio is attached, the sequence playback will be synchronized
|
|
463
|
+
* with the audio playback.
|
|
464
|
+
*/
|
|
465
|
+
interface AttachAudioOptions {
|
|
466
|
+
/**
|
|
467
|
+
* Either a URL to the audio file (eg "http://localhost:3000/audio.mp3") or an instance of AudioBuffer
|
|
468
|
+
*/
|
|
469
|
+
source: string | AudioBuffer;
|
|
470
|
+
/**
|
|
471
|
+
* An optional AudioContext. If not provided, one will be created.
|
|
472
|
+
*/
|
|
473
|
+
audioContext?: AudioContext;
|
|
474
|
+
/**
|
|
475
|
+
* An AudioNode to feed the audio into. Will use audioContext.destination if not provided.
|
|
476
|
+
*/
|
|
477
|
+
destinationNode?: AudioNode;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Configuration options for the TheatreSequence directive.
|
|
481
|
+
*
|
|
482
|
+
* Extends Theatre.js sequence play options with additional Angular-specific options
|
|
483
|
+
* for automatic playback control.
|
|
484
|
+
*/
|
|
485
|
+
type TheatreSequenceOptions = Parameters<ISequence['play']>[0] & {
|
|
486
|
+
/**
|
|
487
|
+
* Whether to automatically start playback when the sequence is initialized.
|
|
488
|
+
* @default false
|
|
489
|
+
*/
|
|
490
|
+
autoplay: boolean;
|
|
491
|
+
/**
|
|
492
|
+
* Whether to automatically pause playback when the directive is destroyed.
|
|
493
|
+
* @default false
|
|
494
|
+
*/
|
|
495
|
+
autopause: boolean;
|
|
496
|
+
/**
|
|
497
|
+
* Delay in milliseconds before autoplay starts.
|
|
498
|
+
* @default 0
|
|
499
|
+
*/
|
|
500
|
+
delay: number;
|
|
501
|
+
/**
|
|
502
|
+
* When to reset the sequence position to 0.
|
|
503
|
+
* - 'init': Reset when the directive is initialized
|
|
504
|
+
* - 'destroy': Reset when the directive is destroyed
|
|
505
|
+
* - 'always': Reset on both init and destroy
|
|
506
|
+
*/
|
|
507
|
+
autoreset?: 'init' | 'destroy' | 'always';
|
|
508
|
+
};
|
|
509
|
+
/**
|
|
510
|
+
* Directive that provides control over a Theatre.js sequence.
|
|
511
|
+
*
|
|
512
|
+
* A sequence controls the playback of animations within a sheet. This directive
|
|
513
|
+
* provides methods to play, pause, and reset the sequence, as well as reactive
|
|
514
|
+
* signals for the current position, playing state, and length.
|
|
515
|
+
*
|
|
516
|
+
* Must be used on an element that also has the `sheet` directive.
|
|
517
|
+
*
|
|
518
|
+
* @example
|
|
519
|
+
* ```html
|
|
520
|
+
* <ng-container sheet="scene" [sequence]="{ autoplay: true, rate: 1 }" #seq="sequence">
|
|
521
|
+
* <p>Position: {{ seq.position() }}</p>
|
|
522
|
+
* <button (click)="seq.play()">Play</button>
|
|
523
|
+
* <button (click)="seq.pause()">Pause</button>
|
|
524
|
+
* </ng-container>
|
|
525
|
+
* ```
|
|
526
|
+
*
|
|
527
|
+
* @example
|
|
528
|
+
* ```html
|
|
529
|
+
* <!-- With audio synchronization -->
|
|
530
|
+
* <ng-container
|
|
531
|
+
* sheet="scene"
|
|
532
|
+
* [sequence]="{ autoplay: true }"
|
|
533
|
+
* [sequenceAudio]="{ source: '/audio/soundtrack.mp3' }"
|
|
534
|
+
* />
|
|
535
|
+
* ```
|
|
536
|
+
*/
|
|
537
|
+
declare class TheatreSequence {
|
|
538
|
+
/**
|
|
539
|
+
* Sequence configuration options.
|
|
540
|
+
* Merged with default options using ngxtension's mergeInputs.
|
|
541
|
+
*
|
|
542
|
+
* @default { rate: 1, autoplay: false, autopause: false, delay: 0 }
|
|
543
|
+
*/
|
|
544
|
+
options: _angular_core.InputSignalWithTransform<{
|
|
545
|
+
iterationCount?: number;
|
|
546
|
+
range?: [from: number, to: number];
|
|
547
|
+
rate?: number;
|
|
548
|
+
direction?: "normal" | "reverse" | "alternate" | "alternateReverse";
|
|
549
|
+
rafDriver?: _theatre_core.IRafDriver;
|
|
550
|
+
} & {
|
|
551
|
+
/**
|
|
552
|
+
* Whether to automatically start playback when the sequence is initialized.
|
|
553
|
+
* @default false
|
|
554
|
+
*/
|
|
555
|
+
autoplay: boolean;
|
|
556
|
+
/**
|
|
557
|
+
* Whether to automatically pause playback when the directive is destroyed.
|
|
558
|
+
* @default false
|
|
559
|
+
*/
|
|
560
|
+
autopause: boolean;
|
|
561
|
+
/**
|
|
562
|
+
* Delay in milliseconds before autoplay starts.
|
|
563
|
+
* @default 0
|
|
564
|
+
*/
|
|
565
|
+
delay: number;
|
|
566
|
+
/**
|
|
567
|
+
* When to reset the sequence position to 0.
|
|
568
|
+
* - 'init': Reset when the directive is initialized
|
|
569
|
+
* - 'destroy': Reset when the directive is destroyed
|
|
570
|
+
* - 'always': Reset on both init and destroy
|
|
571
|
+
*/
|
|
572
|
+
autoreset?: "init" | "destroy" | "always";
|
|
573
|
+
}, "" | Partial<{
|
|
574
|
+
iterationCount?: number;
|
|
575
|
+
range?: [from: number, to: number];
|
|
576
|
+
rate?: number;
|
|
577
|
+
direction?: "normal" | "reverse" | "alternate" | "alternateReverse";
|
|
578
|
+
rafDriver?: _theatre_core.IRafDriver;
|
|
579
|
+
} & {
|
|
580
|
+
/**
|
|
581
|
+
* Whether to automatically start playback when the sequence is initialized.
|
|
582
|
+
* @default false
|
|
583
|
+
*/
|
|
584
|
+
autoplay: boolean;
|
|
585
|
+
/**
|
|
586
|
+
* Whether to automatically pause playback when the directive is destroyed.
|
|
587
|
+
* @default false
|
|
588
|
+
*/
|
|
589
|
+
autopause: boolean;
|
|
590
|
+
/**
|
|
591
|
+
* Delay in milliseconds before autoplay starts.
|
|
592
|
+
* @default 0
|
|
593
|
+
*/
|
|
594
|
+
delay: number;
|
|
595
|
+
/**
|
|
596
|
+
* When to reset the sequence position to 0.
|
|
597
|
+
* - 'init': Reset when the directive is initialized
|
|
598
|
+
* - 'destroy': Reset when the directive is destroyed
|
|
599
|
+
* - 'always': Reset on both init and destroy
|
|
600
|
+
*/
|
|
601
|
+
autoreset?: "init" | "destroy" | "always";
|
|
602
|
+
}>>;
|
|
603
|
+
/**
|
|
604
|
+
* Audio options for synchronizing playback with an audio file.
|
|
605
|
+
* When provided, the sequence will be synchronized with the audio.
|
|
606
|
+
*/
|
|
607
|
+
audioOptions: _angular_core.InputSignal<AttachAudioOptions | undefined>;
|
|
608
|
+
/**
|
|
609
|
+
* Two-way bindable signal for the current playback position in seconds.
|
|
610
|
+
*
|
|
611
|
+
* @default 0
|
|
612
|
+
*/
|
|
613
|
+
position: _angular_core.ModelSignal<number>;
|
|
614
|
+
/**
|
|
615
|
+
* Two-way bindable signal indicating whether the sequence is currently playing.
|
|
616
|
+
*
|
|
617
|
+
* @default false
|
|
618
|
+
*/
|
|
619
|
+
playing: _angular_core.ModelSignal<boolean>;
|
|
620
|
+
/**
|
|
621
|
+
* Two-way bindable signal for the total length of the sequence in seconds.
|
|
622
|
+
*
|
|
623
|
+
* @default 0
|
|
624
|
+
*/
|
|
625
|
+
length: _angular_core.ModelSignal<number>;
|
|
626
|
+
private playOptions;
|
|
627
|
+
private autoplay;
|
|
628
|
+
private autopause;
|
|
629
|
+
private autoreset;
|
|
630
|
+
private delay;
|
|
631
|
+
private project;
|
|
632
|
+
private sheet;
|
|
633
|
+
/**
|
|
634
|
+
* Computed signal containing the Theatre.js sequence instance.
|
|
635
|
+
*/
|
|
636
|
+
sequence: _angular_core.Signal<ISequence>;
|
|
637
|
+
constructor();
|
|
638
|
+
/**
|
|
639
|
+
* Pauses the sequence playback at the current position.
|
|
640
|
+
*/
|
|
641
|
+
pause(): void;
|
|
642
|
+
/**
|
|
643
|
+
* Starts or resumes sequence playback.
|
|
644
|
+
*
|
|
645
|
+
* Waits for the project to be ready before starting playback.
|
|
646
|
+
* Options are merged with the configured play options.
|
|
647
|
+
*
|
|
648
|
+
* @param options - Optional play options that override the configured options
|
|
649
|
+
*/
|
|
650
|
+
play(options?: Parameters<ISequence['play']>[0]): void;
|
|
651
|
+
/**
|
|
652
|
+
* Resets the sequence position to 0.
|
|
653
|
+
*
|
|
654
|
+
* If the sequence was playing before reset, it will continue playing
|
|
655
|
+
* from the beginning.
|
|
656
|
+
*/
|
|
657
|
+
reset(): void;
|
|
658
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<TheatreSequence, never>;
|
|
659
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<TheatreSequence, "[sheet][sequence]", ["sequence"], { "options": { "alias": "sequence"; "required": false; "isSignal": true; }; "audioOptions": { "alias": "sequenceAudio"; "required": false; "isSignal": true; }; "position": { "alias": "position"; "required": false; "isSignal": true; }; "playing": { "alias": "playing"; "required": false; "isSignal": true; }; "length": { "alias": "length"; "required": false; "isSignal": true; }; }, { "position": "positionChange"; "playing": "playingChange"; "length": "lengthChange"; }, never, never, true, never>;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* Directive that creates and manages a Theatre.js sheet within a project.
|
|
664
|
+
*
|
|
665
|
+
* A sheet is a container for sheet objects and their animations. Multiple sheets
|
|
666
|
+
* can exist within a project, allowing you to organize animations into logical groups.
|
|
667
|
+
*
|
|
668
|
+
* The directive automatically handles reference counting and cleanup when the
|
|
669
|
+
* directive is destroyed.
|
|
670
|
+
*
|
|
671
|
+
* @example
|
|
672
|
+
* ```html
|
|
673
|
+
* <theatre-project>
|
|
674
|
+
* <ng-container sheet="mainScene">
|
|
675
|
+
* <!-- sheet objects here -->
|
|
676
|
+
* </ng-container>
|
|
677
|
+
* </theatre-project>
|
|
678
|
+
* ```
|
|
679
|
+
*
|
|
680
|
+
* @example
|
|
681
|
+
* ```html
|
|
682
|
+
* <!-- Using with template reference -->
|
|
683
|
+
* <ng-container sheet="mySheet" #sheetRef="sheet">
|
|
684
|
+
* {{ sheetRef.sheet().sequence.position }}
|
|
685
|
+
* </ng-container>
|
|
686
|
+
* ```
|
|
687
|
+
*/
|
|
688
|
+
declare class TheatreSheet$1 {
|
|
689
|
+
/**
|
|
690
|
+
* The name of the sheet within the project.
|
|
691
|
+
* This name must be unique within the parent project.
|
|
692
|
+
*
|
|
693
|
+
* @default 'default-theatre-sheet'
|
|
694
|
+
*/
|
|
695
|
+
name: _angular_core.InputSignalWithTransform<string, string>;
|
|
696
|
+
private project;
|
|
697
|
+
/**
|
|
698
|
+
* Computed signal containing the Theatre.js sheet instance.
|
|
699
|
+
* Returns an existing sheet if one with the same name already exists,
|
|
700
|
+
* otherwise creates a new sheet.
|
|
701
|
+
*/
|
|
702
|
+
sheet: _angular_core.Signal<_theatre_core.ISheet>;
|
|
703
|
+
constructor();
|
|
704
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<TheatreSheet$1, never>;
|
|
705
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<TheatreSheet$1, "[sheet]", ["sheet"], { "name": { "alias": "sheet"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* Angular Three Theatre.js integration library
|
|
710
|
+
*
|
|
711
|
+
* This library provides Angular components and directives for integrating
|
|
712
|
+
* Theatre.js animation toolkit with Angular Three applications.
|
|
713
|
+
*
|
|
714
|
+
* @packageDocumentation
|
|
715
|
+
*/
|
|
716
|
+
|
|
717
|
+
/**
|
|
718
|
+
* Combined array of TheatreSheet and TheatreSequence directives for convenient importing.
|
|
719
|
+
*
|
|
720
|
+
* @example
|
|
721
|
+
* ```typescript
|
|
722
|
+
* import { TheatreSheet } from 'angular-three-theatre';
|
|
723
|
+
*
|
|
724
|
+
* @Component({
|
|
725
|
+
* imports: [TheatreSheet],
|
|
726
|
+
* template: `<ng-container sheet="mySheet" sequence />`
|
|
727
|
+
* })
|
|
728
|
+
* export class MyComponent {}
|
|
729
|
+
* ```
|
|
730
|
+
*/
|
|
731
|
+
declare const TheatreSheet: readonly [typeof TheatreSheet$1, typeof TheatreSequence];
|
|
732
|
+
|
|
733
|
+
export { TheatreProject, TheatreSequence, TheatreSheet, TheatreSheet$1 as TheatreSheetImpl, TheatreSheetObject, TheatreSheetObject$1 as TheatreSheetObjectImpl, TheatreSheetObjectSync, TheatreSheetObjectTransform, TheatreStudio };
|
|
734
|
+
export type { AttachAudioOptions, TheatreSequenceOptions };
|