@needle-tools/engine 4.3.0-alpha → 4.3.0-alpha.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/CHANGELOG.md +3 -0
- package/dist/needle-engine.bundle.js +1467 -222
- package/dist/needle-engine.bundle.light.js +1467 -222
- package/dist/needle-engine.bundle.light.min.js +32 -32
- package/dist/needle-engine.bundle.light.umd.cjs +3 -3
- package/dist/needle-engine.bundle.min.js +3 -3
- package/dist/needle-engine.bundle.umd.cjs +3 -3
- package/dist/needle-engine.light.d.ts +9 -9
- package/lib/engine/engine_types.d.ts +162 -17
- package/lib/engine-components/Animator.d.ts +129 -21
- package/lib/engine-components/Animator.js +115 -21
- package/lib/engine-components/Animator.js.map +1 -1
- package/lib/engine-components/AnimatorController.d.ts +161 -32
- package/lib/engine-components/AnimatorController.js +176 -29
- package/lib/engine-components/AnimatorController.js.map +1 -1
- package/lib/engine-components/AudioListener.d.ts +16 -5
- package/lib/engine-components/AudioListener.js +16 -5
- package/lib/engine-components/AudioListener.js.map +1 -1
- package/lib/engine-components/AudioSource.d.ts +120 -28
- package/lib/engine-components/AudioSource.js +120 -37
- package/lib/engine-components/AudioSource.js.map +1 -1
- package/lib/engine-components/AvatarLoader.d.ts +61 -0
- package/lib/engine-components/AvatarLoader.js +61 -1
- package/lib/engine-components/AvatarLoader.js.map +1 -1
- package/lib/engine-components/AxesHelper.d.ts +19 -1
- package/lib/engine-components/AxesHelper.js +19 -1
- package/lib/engine-components/AxesHelper.js.map +1 -1
- package/lib/engine-components/BoxHelperComponent.d.ts +26 -0
- package/lib/engine-components/BoxHelperComponent.js +26 -0
- package/lib/engine-components/BoxHelperComponent.js.map +1 -1
- package/lib/engine-components/Camera.d.ts +126 -37
- package/lib/engine-components/Camera.js +139 -37
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/CameraUtils.js +20 -0
- package/lib/engine-components/CameraUtils.js.map +1 -1
- package/lib/engine-components/Collider.d.ts +95 -21
- package/lib/engine-components/Collider.js +100 -23
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/Component.d.ts +554 -106
- package/lib/engine-components/Component.js +352 -81
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/DragControls.d.ts +95 -21
- package/lib/engine-components/DragControls.js +126 -32
- package/lib/engine-components/DragControls.js.map +1 -1
- package/lib/engine-components/DropListener.d.ts +99 -16
- package/lib/engine-components/DropListener.js +119 -14
- package/lib/engine-components/DropListener.js.map +1 -1
- package/lib/engine-components/Light.d.ts +102 -5
- package/lib/engine-components/Light.js +102 -44
- package/lib/engine-components/Light.js.map +1 -1
- package/lib/engine-components/NeedleMenu.d.ts +28 -11
- package/lib/engine-components/NeedleMenu.js +28 -11
- package/lib/engine-components/NeedleMenu.js.map +1 -1
- package/lib/engine-components/Networking.d.ts +37 -5
- package/lib/engine-components/Networking.js +37 -5
- package/lib/engine-components/Networking.js.map +1 -1
- package/lib/engine-components/SceneSwitcher.js +44 -0
- package/lib/engine-components/SceneSwitcher.js.map +1 -1
- package/lib/engine-components/SpatialTrigger.d.ts +66 -1
- package/lib/engine-components/SpatialTrigger.js +74 -2
- package/lib/engine-components/SpatialTrigger.js.map +1 -1
- package/lib/engine-components/SpectatorCamera.d.ts +66 -4
- package/lib/engine-components/SpectatorCamera.js +132 -6
- package/lib/engine-components/SpectatorCamera.js.map +1 -1
- package/lib/engine-components/SyncedTransform.d.ts +45 -6
- package/lib/engine-components/SyncedTransform.js +45 -6
- package/lib/engine-components/SyncedTransform.js.map +1 -1
- package/lib/engine-components/TransformGizmo.d.ts +49 -3
- package/lib/engine-components/TransformGizmo.js +49 -3
- package/lib/engine-components/TransformGizmo.js.map +1 -1
- package/lib/engine-components/webxr/WebXR.d.ts +131 -22
- package/lib/engine-components/webxr/WebXR.js +132 -23
- package/lib/engine-components/webxr/WebXR.js.map +1 -1
- package/lib/engine-components-experimental/networking/PlayerSync.d.ts +82 -9
- package/lib/engine-components-experimental/networking/PlayerSync.js +76 -11
- package/lib/engine-components-experimental/networking/PlayerSync.js.map +1 -1
- package/package.json +1 -1
- package/src/engine/engine_types.ts +179 -18
- package/src/engine-components/Animator.ts +142 -22
- package/src/engine-components/AnimatorController.ts +184 -34
- package/src/engine-components/AudioListener.ts +16 -5
- package/src/engine-components/AudioSource.ts +126 -37
- package/src/engine-components/AvatarLoader.ts +61 -2
- package/src/engine-components/AxesHelper.ts +21 -1
- package/src/engine-components/BoxHelperComponent.ts +26 -0
- package/src/engine-components/Camera.ts +147 -41
- package/src/engine-components/CameraUtils.ts +20 -0
- package/src/engine-components/Collider.ts +102 -27
- package/src/engine-components/Component.ts +605 -129
- package/src/engine-components/DragControls.ts +134 -38
- package/src/engine-components/DropListener.ts +143 -23
- package/src/engine-components/Light.ts +105 -44
- package/src/engine-components/NeedleMenu.ts +29 -11
- package/src/engine-components/Networking.ts +37 -6
- package/src/engine-components/SceneSwitcher.ts +48 -1
- package/src/engine-components/SpatialTrigger.ts +80 -3
- package/src/engine-components/SpectatorCamera.ts +136 -18
- package/src/engine-components/SyncedTransform.ts +50 -7
- package/src/engine-components/TransformGizmo.ts +49 -4
- package/src/engine-components/webxr/WebXR.ts +144 -27
- package/src/engine-components-experimental/networking/PlayerSync.ts +85 -13
|
@@ -11,38 +11,73 @@ import { Behaviour } from "./Component.js";
|
|
|
11
11
|
|
|
12
12
|
const debug = getParam("debuganimator");
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Represents an event emitted by an animation mixer
|
|
16
|
+
* @category Animation and Sequencing
|
|
17
|
+
*/
|
|
15
18
|
export declare class MixerEvent {
|
|
19
|
+
/** The type of event that occurred */
|
|
16
20
|
type: string;
|
|
21
|
+
/** The animation action that triggered this event */
|
|
17
22
|
action: AnimationAction;
|
|
23
|
+
/** Number of loops completed in this cycle */
|
|
18
24
|
loopDelta: number;
|
|
25
|
+
/** The animation mixer that emitted this event */
|
|
19
26
|
target: AnimationMixer;
|
|
20
27
|
}
|
|
21
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Configuration options for playing animations
|
|
31
|
+
* @category Animation and Sequencing
|
|
32
|
+
*/
|
|
22
33
|
export declare class PlayOptions {
|
|
34
|
+
/** Whether the animation should loop, and if so, which loop style to use */
|
|
23
35
|
loop?: boolean | AnimationActionLoopStyles;
|
|
36
|
+
/** Whether the final animation state should be maintained after playback completes */
|
|
24
37
|
clampWhenFinished?: boolean;
|
|
25
38
|
}
|
|
26
39
|
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
40
|
+
/**
|
|
41
|
+
* The Animator component plays and manages animations on a GameObject.
|
|
42
|
+
* It works with an AnimatorController to handle state transitions and animation blending.
|
|
43
|
+
* A new AnimatorController can be created from code via `AnimatorController.createFromClips`.
|
|
29
44
|
* @category Animation and Sequencing
|
|
30
45
|
* @group Components
|
|
31
46
|
*/
|
|
32
47
|
export class Animator extends Behaviour implements IAnimationComponent {
|
|
33
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Identifies this component as an animation component in the engine
|
|
51
|
+
*/
|
|
34
52
|
get isAnimationComponent() {
|
|
35
53
|
return true;
|
|
36
54
|
}
|
|
37
55
|
|
|
56
|
+
/**
|
|
57
|
+
* When enabled, animation will affect the root transform position and rotation
|
|
58
|
+
*/
|
|
38
59
|
@serializable()
|
|
39
60
|
applyRootMotion: boolean = false;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Indicates whether this animator contains root motion data
|
|
64
|
+
*/
|
|
40
65
|
@serializable()
|
|
41
66
|
hasRootMotion: boolean = false;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* When enabled, the animator will maintain its state when the component is disabled
|
|
70
|
+
*/
|
|
42
71
|
@serializable()
|
|
43
72
|
keepAnimatorControllerStateOnDisable: boolean = false;
|
|
44
73
|
|
|
45
74
|
// set from needle animator extension
|
|
75
|
+
/**
|
|
76
|
+
* Sets or replaces the animator controller for this component.
|
|
77
|
+
* Handles binding the controller to this animator instance and ensures
|
|
78
|
+
* proper initialization when the controller changes.
|
|
79
|
+
* @param val The animator controller model or instance to use
|
|
80
|
+
*/
|
|
46
81
|
@serializable()
|
|
47
82
|
set runtimeAnimatorController(val: AnimatorControllerModel | AnimatorController | undefined | null) {
|
|
48
83
|
if (this._animatorController && this._animatorController.model === val) {
|
|
@@ -69,41 +104,53 @@ export class Animator extends Behaviour implements IAnimationComponent {
|
|
|
69
104
|
}
|
|
70
105
|
else this._animatorController = null;
|
|
71
106
|
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Gets the current animator controller instance
|
|
110
|
+
* @returns The current animator controller or null if none is assigned
|
|
111
|
+
*/
|
|
72
112
|
get runtimeAnimatorController(): AnimatorController | undefined | null {
|
|
73
113
|
return this._animatorController;
|
|
74
114
|
}
|
|
75
115
|
|
|
76
|
-
/**
|
|
77
|
-
*
|
|
78
|
-
* @returns
|
|
79
|
-
|
|
116
|
+
/**
|
|
117
|
+
* Retrieves information about the current animation state
|
|
118
|
+
* @returns The current state information, or undefined if no state is playing
|
|
119
|
+
*/
|
|
80
120
|
getCurrentStateInfo() {
|
|
81
121
|
return this.runtimeAnimatorController?.getCurrentStateInfo();
|
|
82
122
|
}
|
|
83
|
-
/**
|
|
84
|
-
*
|
|
85
|
-
|
|
123
|
+
/**
|
|
124
|
+
* The currently playing animation action that can be used to modify animation properties
|
|
125
|
+
* @returns The current animation action, or null if no animation is playing
|
|
126
|
+
*/
|
|
86
127
|
get currentAction() {
|
|
87
128
|
return this.runtimeAnimatorController?.currentAction || null;
|
|
88
129
|
}
|
|
89
130
|
|
|
90
|
-
/**
|
|
131
|
+
/**
|
|
132
|
+
* Indicates whether animation parameters have been modified since the last update
|
|
133
|
+
* @returns True if parameters have been changed
|
|
134
|
+
*/
|
|
91
135
|
get parametersAreDirty() { return this._parametersAreDirty; }
|
|
92
136
|
private _parametersAreDirty: boolean = false;
|
|
93
137
|
|
|
94
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* Indicates whether the animator state has changed since the last update
|
|
140
|
+
* @returns True if the animator has been changed
|
|
141
|
+
*/
|
|
95
142
|
get isDirty() { return this._isDirty; }
|
|
96
143
|
private _isDirty: boolean = false;
|
|
97
144
|
|
|
98
145
|
/**@deprecated use play() */
|
|
99
146
|
Play(name: string | number, layer: number = -1, normalizedTime: number = Number.NEGATIVE_INFINITY, transitionDurationInSec: number = 0) { this.play(name, layer, normalizedTime, transitionDurationInSec); }
|
|
100
|
-
/**
|
|
101
|
-
*
|
|
102
|
-
* @param
|
|
103
|
-
* @param
|
|
104
|
-
* @param
|
|
105
|
-
* @
|
|
106
|
-
|
|
147
|
+
/**
|
|
148
|
+
* Plays an animation on the animator
|
|
149
|
+
* @param name The name or hash of the animation to play
|
|
150
|
+
* @param layer The layer to play the animation on (-1 for default layer)
|
|
151
|
+
* @param normalizedTime The time position to start playing (0-1 range, NEGATIVE_INFINITY for current position)
|
|
152
|
+
* @param transitionDurationInSec The duration of the blend transition in seconds
|
|
153
|
+
*/
|
|
107
154
|
play(name: string | number, layer: number = -1, normalizedTime: number = Number.NEGATIVE_INFINITY, transitionDurationInSec: number = 0) {
|
|
108
155
|
this.runtimeAnimatorController?.play(name, layer, normalizedTime, transitionDurationInSec);
|
|
109
156
|
this._isDirty = true;
|
|
@@ -111,7 +158,9 @@ export class Animator extends Behaviour implements IAnimationComponent {
|
|
|
111
158
|
|
|
112
159
|
/**@deprecated use reset */
|
|
113
160
|
Reset() { this.reset(); }
|
|
114
|
-
/**
|
|
161
|
+
/**
|
|
162
|
+
* Resets the animator controller to its initial state
|
|
163
|
+
*/
|
|
115
164
|
reset() {
|
|
116
165
|
this._animatorController?.reset();
|
|
117
166
|
this._isDirty = true;
|
|
@@ -119,6 +168,12 @@ export class Animator extends Behaviour implements IAnimationComponent {
|
|
|
119
168
|
|
|
120
169
|
/**@deprecated use setBool */
|
|
121
170
|
SetBool(name: string | number, val: boolean) { this.setBool(name, val); }
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Sets a boolean parameter in the animator
|
|
174
|
+
* @param name The name or hash of the parameter
|
|
175
|
+
* @param value The boolean value to set
|
|
176
|
+
*/
|
|
122
177
|
setBool(name: string | number, value: boolean) {
|
|
123
178
|
if (debug) console.log("setBool", name, value);
|
|
124
179
|
if (this.runtimeAnimatorController?.getBool(name) !== value)
|
|
@@ -128,18 +183,34 @@ export class Animator extends Behaviour implements IAnimationComponent {
|
|
|
128
183
|
|
|
129
184
|
/**@deprecated use getBool */
|
|
130
185
|
GetBool(name: string | number) { return this.getBool(name); }
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Gets a boolean parameter from the animator
|
|
189
|
+
* @param name The name or hash of the parameter
|
|
190
|
+
* @returns The value of the boolean parameter, or false if not found
|
|
191
|
+
*/
|
|
131
192
|
getBool(name: string | number): boolean {
|
|
132
193
|
const res = this.runtimeAnimatorController?.getBool(name) ?? false;
|
|
133
194
|
if (debug) console.log("getBool", name, res);
|
|
134
195
|
return res;
|
|
135
196
|
}
|
|
136
197
|
|
|
198
|
+
/**
|
|
199
|
+
* Toggles a boolean parameter between true and false
|
|
200
|
+
* @param name The name or hash of the parameter
|
|
201
|
+
*/
|
|
137
202
|
toggleBool(name: string | number) {
|
|
138
203
|
this.setBool(name, !this.getBool(name));
|
|
139
204
|
}
|
|
140
205
|
|
|
141
206
|
/**@deprecated use setFloat */
|
|
142
207
|
SetFloat(name: string | number, val: number) { this.setFloat(name, val); }
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Sets a float parameter in the animator
|
|
211
|
+
* @param name The name or hash of the parameter
|
|
212
|
+
* @param val The float value to set
|
|
213
|
+
*/
|
|
143
214
|
setFloat(name: string | number, val: number) {
|
|
144
215
|
if (this.runtimeAnimatorController?.getFloat(name) !== val)
|
|
145
216
|
this._parametersAreDirty = true;
|
|
@@ -149,6 +220,12 @@ export class Animator extends Behaviour implements IAnimationComponent {
|
|
|
149
220
|
|
|
150
221
|
/**@deprecated use getFloat */
|
|
151
222
|
GetFloat(name: string | number) { return this.getFloat(name); }
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Gets a float parameter from the animator
|
|
226
|
+
* @param name The name or hash of the parameter
|
|
227
|
+
* @returns The value of the float parameter, or -1 if not found
|
|
228
|
+
*/
|
|
152
229
|
getFloat(name: string | number): number {
|
|
153
230
|
const res = this.runtimeAnimatorController?.getFloat(name) ?? -1;
|
|
154
231
|
if (debug) console.log("getFloat", name, res);
|
|
@@ -157,6 +234,12 @@ export class Animator extends Behaviour implements IAnimationComponent {
|
|
|
157
234
|
|
|
158
235
|
/**@deprecated use setInteger */
|
|
159
236
|
SetInteger(name: string | number, val: number) { this.setInteger(name, val); }
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Sets an integer parameter in the animator
|
|
240
|
+
* @param name The name or hash of the parameter
|
|
241
|
+
* @param val The integer value to set
|
|
242
|
+
*/
|
|
160
243
|
setInteger(name: string | number, val: number) {
|
|
161
244
|
if (this.runtimeAnimatorController?.getInteger(name) !== val)
|
|
162
245
|
this._parametersAreDirty = true;
|
|
@@ -166,6 +249,12 @@ export class Animator extends Behaviour implements IAnimationComponent {
|
|
|
166
249
|
|
|
167
250
|
/**@deprecated use getInteger */
|
|
168
251
|
GetInteger(name: string | number) { return this.getInteger(name); }
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Gets an integer parameter from the animator
|
|
255
|
+
* @param name The name or hash of the parameter
|
|
256
|
+
* @returns The value of the integer parameter, or -1 if not found
|
|
257
|
+
*/
|
|
169
258
|
getInteger(name: string | number): number {
|
|
170
259
|
const res = this.runtimeAnimatorController?.getInteger(name) ?? -1;
|
|
171
260
|
if (debug) console.log("getInteger", name, res);
|
|
@@ -174,6 +263,11 @@ export class Animator extends Behaviour implements IAnimationComponent {
|
|
|
174
263
|
|
|
175
264
|
/**@deprecated use setTrigger */
|
|
176
265
|
SetTrigger(name: string | number) { this.setTrigger(name); }
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Activates a trigger parameter in the animator
|
|
269
|
+
* @param name The name or hash of the trigger parameter
|
|
270
|
+
*/
|
|
177
271
|
setTrigger(name: string | number) {
|
|
178
272
|
this._parametersAreDirty = true;
|
|
179
273
|
if (debug) console.log("setTrigger", name);
|
|
@@ -182,6 +276,11 @@ export class Animator extends Behaviour implements IAnimationComponent {
|
|
|
182
276
|
|
|
183
277
|
/**@deprecated use resetTrigger */
|
|
184
278
|
ResetTrigger(name: string | number) { this.resetTrigger(name); }
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Resets a trigger parameter in the animator
|
|
282
|
+
* @param name The name or hash of the trigger parameter
|
|
283
|
+
*/
|
|
185
284
|
resetTrigger(name: string | number) {
|
|
186
285
|
this._parametersAreDirty = true;
|
|
187
286
|
if (debug) console.log("resetTrigger", name);
|
|
@@ -190,6 +289,12 @@ export class Animator extends Behaviour implements IAnimationComponent {
|
|
|
190
289
|
|
|
191
290
|
/**@deprecated use getTrigger */
|
|
192
291
|
GetTrigger(name: string | number) { this.getTrigger(name); }
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Gets the state of a trigger parameter from the animator
|
|
295
|
+
* @param name The name or hash of the trigger parameter
|
|
296
|
+
* @returns The state of the trigger parameter
|
|
297
|
+
*/
|
|
193
298
|
getTrigger(name: string | number) {
|
|
194
299
|
const res = this.runtimeAnimatorController?.getTrigger(name);
|
|
195
300
|
if (debug) console.log("getTrigger", name, res);
|
|
@@ -198,13 +303,21 @@ export class Animator extends Behaviour implements IAnimationComponent {
|
|
|
198
303
|
|
|
199
304
|
/**@deprecated use isInTransition */
|
|
200
305
|
IsInTransition() { return this.isInTransition(); }
|
|
201
|
-
/**
|
|
306
|
+
/**
|
|
307
|
+
* Checks if the animator is currently in a transition between states
|
|
308
|
+
* @returns True if the animator is currently blending between animations
|
|
309
|
+
*/
|
|
202
310
|
isInTransition(): boolean {
|
|
203
311
|
return this.runtimeAnimatorController?.isInTransition() ?? false;
|
|
204
312
|
}
|
|
205
313
|
|
|
206
314
|
/**@deprecated use setSpeed */
|
|
207
315
|
SetSpeed(speed: number) { return this.setSpeed(speed); }
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Sets the playback speed of the animator
|
|
319
|
+
* @param speed The new playback speed multiplier
|
|
320
|
+
*/
|
|
208
321
|
setSpeed(speed: number) {
|
|
209
322
|
if (speed === this._speed) return;
|
|
210
323
|
if (debug) console.log("setSpeed", speed);
|
|
@@ -213,13 +326,20 @@ export class Animator extends Behaviour implements IAnimationComponent {
|
|
|
213
326
|
this._animatorController.setSpeed(speed);
|
|
214
327
|
}
|
|
215
328
|
|
|
216
|
-
/**
|
|
329
|
+
/**
|
|
330
|
+
* Sets a random playback speed between the min and max values
|
|
331
|
+
* @param minMax Object with x (minimum) and y (maximum) speed values
|
|
332
|
+
*/
|
|
217
333
|
set minMaxSpeed(minMax: { x: number, y: number }) {
|
|
218
334
|
this._speed = Mathf.lerp(minMax.x, minMax.y, Math.random());
|
|
219
335
|
if (this._animatorController?.animator == this)
|
|
220
336
|
this._animatorController.setSpeed(this._speed);
|
|
221
337
|
}
|
|
222
338
|
|
|
339
|
+
/**
|
|
340
|
+
* Sets a random normalized time offset for animations between min (x) and max (y) values
|
|
341
|
+
* @param minMax Object with x (min) and y (max) values for the offset range
|
|
342
|
+
*/
|
|
223
343
|
set minMaxOffsetNormalized(minMax: { x: number, y: number }) {
|
|
224
344
|
this._normalizedStartOffset = Mathf.lerp(minMax.x, minMax.y, Math.random());
|
|
225
345
|
if (this.runtimeAnimatorController?.animator == this)
|