angular-three-theatre 4.0.0-next.99 → 4.0.1

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 CHANGED
@@ -1 +1,190 @@
1
1
  # `angular-three-theatre`
2
+
3
+ This library provides [Theatre.js](https://www.theatrejs.com/) integration for Angular Three, enabling powerful animation and motion design capabilities for your 3D scenes.
4
+
5
+ ## Documentation
6
+
7
+ All public APIs are documented with JSDoc comments. Your IDE will provide inline documentation, parameter hints, and examples as you code.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install angular-three-theatre @theatre/core @theatre/studio
13
+ # yarn add angular-three-theatre @theatre/core @theatre/studio
14
+ # pnpm add angular-three-theatre @theatre/core @theatre/studio
15
+ ```
16
+
17
+ > Make sure to already have `angular-three` installed
18
+
19
+ ## Usage
20
+
21
+ ### Basic Setup
22
+
23
+ ```typescript
24
+ import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
25
+ import { TheatreProject, TheatreSheet, TheatreSheetObject } from 'angular-three-theatre';
26
+
27
+ @Component({
28
+ template: `
29
+ <theatre-project name="My Project">
30
+ <ng-container sheet="Scene">
31
+ <ng-template sheetObject="Box" [sheetObjectProps]="{ x: 0, y: 0, z: 0 }" let-values="values">
32
+ <ngt-mesh [position]="[values().x, values().y, values().z]">
33
+ <ngt-box-geometry />
34
+ <ngt-mesh-standard-material />
35
+ </ngt-mesh>
36
+ </ng-template>
37
+ </ng-container>
38
+ </theatre-project>
39
+ `,
40
+ imports: [TheatreProject, TheatreSheet, TheatreSheetObject],
41
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
42
+ })
43
+ export class SceneGraph {}
44
+ ```
45
+
46
+ ### Enable Studio (Development)
47
+
48
+ The `studio` directive is applied to `theatre-project`:
49
+
50
+ ```typescript
51
+ import { TheatreProject, TheatreStudio } from 'angular-three-theatre';
52
+
53
+ @Component({
54
+ template: `
55
+ <theatre-project name="My Project" [studio]="isDevelopment">
56
+ <ng-container sheet="Scene">
57
+ <!-- sheet objects here -->
58
+ </ng-container>
59
+ </theatre-project>
60
+ `,
61
+ imports: [TheatreProject, TheatreStudio],
62
+ })
63
+ export class SceneGraph {
64
+ isDevelopment = !environment.production;
65
+ }
66
+ ```
67
+
68
+ ### Sequence Playback
69
+
70
+ The `sequence` directive must be used together with the `sheet` directive:
71
+
72
+ ```typescript
73
+ import { TheatreProject, TheatreSheet } from 'angular-three-theatre';
74
+
75
+ @Component({
76
+ template: `
77
+ <theatre-project name="My Project">
78
+ <ng-container sheet="Scene" [sequence]="{ autoplay: true, rate: 1 }" #seq="sequence">
79
+ <p>Position: {{ seq.position() }}</p>
80
+ <button (click)="seq.play()">Play</button>
81
+ <button (click)="seq.pause()">Pause</button>
82
+
83
+ <!-- sheet objects here -->
84
+ </ng-container>
85
+ </theatre-project>
86
+ `,
87
+ imports: [TheatreProject, TheatreSheet],
88
+ })
89
+ export class SceneGraph {}
90
+ ```
91
+
92
+ ### Sync Three.js Properties
93
+
94
+ Use the `sync` directive to synchronize Three.js object properties with Theatre.js:
95
+
96
+ ```typescript
97
+ import { TheatreSheetObject } from 'angular-three-theatre';
98
+
99
+ @Component({
100
+ template: `
101
+ <ng-template sheetObject="myMaterial">
102
+ <ngt-mesh-standard-material
103
+ [sync]="material"
104
+ [syncProps]="['opacity', 'roughness', 'metalness']"
105
+ #material
106
+ />
107
+ </ng-template>
108
+ `,
109
+ imports: [TheatreSheetObject],
110
+ })
111
+ export class AnimatedMaterial {}
112
+ ```
113
+
114
+ ### Transform Controls
115
+
116
+ Use `theatre-transform` component for position, rotation, and scale animation:
117
+
118
+ ```typescript
119
+ import { TheatreSheetObject } from 'angular-three-theatre';
120
+
121
+ @Component({
122
+ template: `
123
+ <ng-template sheetObject="myCube">
124
+ <theatre-transform>
125
+ <ngt-mesh>
126
+ <ngt-box-geometry />
127
+ <ngt-mesh-standard-material />
128
+ </ngt-mesh>
129
+ </theatre-transform>
130
+ </ng-template>
131
+ `,
132
+ imports: [TheatreSheetObject],
133
+ })
134
+ export class TransformableObject {}
135
+ ```
136
+
137
+ ## Directives and Components
138
+
139
+ | Export | Selector | Description |
140
+ | ----------------------------- | -------------------------- | ---------------------------------------------- |
141
+ | `TheatreProject` | `theatre-project` | Root container for Theatre.js project |
142
+ | `TheatreSheet` | `[sheet]` | Creates an animation sheet (includes Sequence) |
143
+ | `TheatreSequence` | `[sheet][sequence]` | Controls sequence playback |
144
+ | `TheatreStudio` | `theatre-project[studio]` | Enables Theatre.js Studio UI |
145
+ | `TheatreSheetObject` | `ng-template[sheetObject]` | Creates animatable properties |
146
+ | `TheatreSheetObjectSync` | `[sync]` | Syncs Three.js object properties |
147
+ | `TheatreSheetObjectTransform` | `theatre-transform` | Adds transform controls |
148
+
149
+ ### Convenience Exports
150
+
151
+ For easier importing, the library provides combined exports:
152
+
153
+ ```typescript
154
+ // TheatreSheet includes both TheatreSheetImpl and TheatreSequence
155
+ import { TheatreSheet } from 'angular-three-theatre';
156
+
157
+ // TheatreSheetObject includes TheatreSheetObjectImpl, TheatreSheetObjectSync, and TheatreSheetObjectTransform
158
+ import { TheatreSheetObject } from 'angular-three-theatre';
159
+ ```
160
+
161
+ ## Sheet Object Template Context
162
+
163
+ The `sheetObject` directive provides the following template context:
164
+
165
+ ```html
166
+ <ng-template
167
+ sheetObject="myObject"
168
+ [sheetObjectProps]="{ opacity: 1 }"
169
+ let-values="values"
170
+ let-sheetObject="sheetObject"
171
+ let-select="select"
172
+ let-deselect="deselect"
173
+ >
174
+ <!-- values() returns the current animated values -->
175
+ <!-- sheetObject() returns the Theatre.js sheet object instance -->
176
+ <!-- select() selects this object in Studio -->
177
+ <!-- deselect() deselects this object in Studio -->
178
+ </ng-template>
179
+ ```
180
+
181
+ ## Transformers
182
+
183
+ Built-in property transformers for Theatre.js props:
184
+
185
+ - `color` - RGBA color picker
186
+ - `degrees` - Radian to degrees conversion
187
+ - `euler` - Euler rotation controls
188
+ - `normalized` - 0-1 range slider
189
+ - `side` - Material side property
190
+ - `generic` - Fallback for common types