@needle-tools/engine 5.1.0-alpha → 5.1.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 +9 -1
- package/SKILL.md +39 -21
- package/dist/{needle-engine.bundle-CwhCzjep.js → needle-engine.bundle-BGyKqxBH.js} +10494 -10174
- package/dist/{needle-engine.bundle-qDahLTqW.min.js → needle-engine.bundle-CiYtOO2O.min.js} +230 -154
- package/dist/{needle-engine.bundle-wM-BWPX9.umd.cjs → needle-engine.bundle-DzVx9Z8D.umd.cjs} +228 -152
- package/dist/needle-engine.d.ts +176 -4
- package/dist/needle-engine.js +571 -567
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/lib/engine/engine_components.js +5 -1
- package/lib/engine/engine_components.js.map +1 -1
- package/lib/engine/engine_init.js +2 -0
- package/lib/engine/engine_init.js.map +1 -1
- package/lib/engine/engine_physics_rapier.d.ts +3 -0
- package/lib/engine/engine_physics_rapier.js +13 -9
- package/lib/engine/engine_physics_rapier.js.map +1 -1
- package/lib/engine/engine_utils.js +2 -2
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/xr/NeedleXRSession.d.ts +1 -0
- package/lib/engine/xr/NeedleXRSession.js +4 -4
- package/lib/engine/xr/NeedleXRSession.js.map +1 -1
- package/lib/engine/xr/events.d.ts +30 -3
- package/lib/engine/xr/events.js +38 -0
- package/lib/engine/xr/events.js.map +1 -1
- package/lib/engine/xr/init.js +1 -7
- package/lib/engine/xr/init.js.map +1 -1
- package/lib/engine-components/AnimatorController.d.ts +135 -2
- package/lib/engine-components/AnimatorController.js +218 -2
- package/lib/engine-components/AnimatorController.js.map +1 -1
- package/lib/engine-components/GroundProjection.d.ts +1 -0
- package/lib/engine-components/GroundProjection.js +184 -48
- package/lib/engine-components/GroundProjection.js.map +1 -1
- package/lib/engine-components/api.d.ts +1 -0
- package/lib/engine-components/api.js +1 -0
- package/lib/engine-components/api.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +1 -0
- package/lib/engine-components/codegen/components.js +1 -0
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/package.json +1 -1
- package/plugins/common/logger.js +42 -19
- package/plugins/vite/logger.client.js +4 -3
- package/src/engine/engine_components.ts +7 -4
- package/src/engine/engine_init.ts +2 -0
- package/src/engine/engine_physics_rapier.ts +14 -9
- package/src/engine/engine_utils.ts +2 -2
- package/src/engine/xr/NeedleXRSession.ts +5 -5
- package/src/engine/xr/events.ts +44 -1
- package/src/engine/xr/init.ts +0 -7
- package/src/engine-components/AnimatorController.ts +286 -4
- package/src/engine-components/GroundProjection.ts +226 -52
- package/src/engine-components/api.ts +1 -0
- package/src/engine-components/codegen/components.ts +1 -0
package/dist/needle-engine.d.ts
CHANGED
|
@@ -918,8 +918,9 @@ export declare enum AnimatorConditionMode {
|
|
|
918
918
|
* and parameters that affect those transitions. It is used by the {@link Animator}
|
|
919
919
|
* component to control animation behavior on 3D models.
|
|
920
920
|
*
|
|
921
|
-
* Use
|
|
922
|
-
*
|
|
921
|
+
* Use {@link AnimatorController.build} to fluently create a controller with parameters,
|
|
922
|
+
* states, transitions, and conditions. For simple sequential playback,
|
|
923
|
+
* use {@link AnimatorController.createFromClips}.
|
|
923
924
|
*
|
|
924
925
|
* @category Animation and Sequencing
|
|
925
926
|
* @group Utilities
|
|
@@ -934,6 +935,27 @@ export declare class AnimatorController {
|
|
|
934
935
|
* @returns A new AnimatorController instance
|
|
935
936
|
*/
|
|
936
937
|
static createFromClips(clips: AnimationClip[], options?: CreateAnimatorControllerOptions): AnimatorController;
|
|
938
|
+
/**
|
|
939
|
+
* Creates a new {@link AnimatorControllerBuilder} for fluently constructing a controller with
|
|
940
|
+
* parameters, states, transitions, and conditions.
|
|
941
|
+
*
|
|
942
|
+
* @param name - Optional name for the controller
|
|
943
|
+
* @returns A new builder instance
|
|
944
|
+
*
|
|
945
|
+
* @example
|
|
946
|
+
* ```ts
|
|
947
|
+
* const ctrl = AnimatorController.build("MyController")
|
|
948
|
+
* .floatParameter("Speed")
|
|
949
|
+
* .state("Idle", { clip: idleClip, loop: true })
|
|
950
|
+
* .state("Walk", { clip: walkClip, loop: true })
|
|
951
|
+
* .transition("Idle", "Walk", { duration: 0.25 })
|
|
952
|
+
* .condition("Speed", "greater", 0.1)
|
|
953
|
+
* .transition("Walk", "Idle", { duration: 0.25 })
|
|
954
|
+
* .condition("Speed", "less", 0.1)
|
|
955
|
+
* .build();
|
|
956
|
+
* ```
|
|
957
|
+
*/
|
|
958
|
+
static build(name?: string): AnimatorControllerBuilder;
|
|
937
959
|
/**
|
|
938
960
|
* Plays an animation state by name or hash.
|
|
939
961
|
*
|
|
@@ -1125,6 +1147,84 @@ export declare class AnimatorController {
|
|
|
1125
1147
|
private rootMotionHandler?;
|
|
1126
1148
|
}
|
|
1127
1149
|
|
|
1150
|
+
/**
|
|
1151
|
+
* A fluent builder for creating {@link AnimatorController} instances from code.
|
|
1152
|
+
*
|
|
1153
|
+
* Use {@link AnimatorController.build} to create a new builder.
|
|
1154
|
+
*
|
|
1155
|
+
* @example
|
|
1156
|
+
* ```ts
|
|
1157
|
+
* const controller = AnimatorController.build("CharacterController")
|
|
1158
|
+
* .floatParameter("Speed", 0)
|
|
1159
|
+
* .triggerParameter("Jump")
|
|
1160
|
+
* .state("Idle", { clip: idleClip, loop: true })
|
|
1161
|
+
* .state("Walk", { clip: walkClip, loop: true })
|
|
1162
|
+
* .state("Jump", { clip: jumpClip })
|
|
1163
|
+
* .transition("Idle", "Walk", { duration: 0.25 })
|
|
1164
|
+
* .condition("Speed", "greater", 0.1)
|
|
1165
|
+
* .transition("Walk", "Idle", { duration: 0.25 })
|
|
1166
|
+
* .condition("Speed", "less", 0.1)
|
|
1167
|
+
* .transition("*", "Jump", { duration: 0.1 })
|
|
1168
|
+
* .condition("Jump", "if")
|
|
1169
|
+
* .transition("Jump", "Idle", { hasExitTime: true, exitTime: 0.9, duration: 0.25 })
|
|
1170
|
+
* .build();
|
|
1171
|
+
* ```
|
|
1172
|
+
*
|
|
1173
|
+
* @category Animation and Sequencing
|
|
1174
|
+
* @group Utilities
|
|
1175
|
+
*/
|
|
1176
|
+
export declare class AnimatorControllerBuilder {
|
|
1177
|
+
private _name;
|
|
1178
|
+
private _parameters;
|
|
1179
|
+
private _states;
|
|
1180
|
+
private _anyStateTransitions;
|
|
1181
|
+
private _defaultStateName;
|
|
1182
|
+
private _lastTransition;
|
|
1183
|
+
constructor(name?: string);
|
|
1184
|
+
/** Adds a float parameter */
|
|
1185
|
+
floatParameter(name: string, defaultValue?: number): this;
|
|
1186
|
+
/** Adds an integer parameter */
|
|
1187
|
+
intParameter(name: string, defaultValue?: number): this;
|
|
1188
|
+
/** Adds a boolean parameter */
|
|
1189
|
+
boolParameter(name: string, defaultValue?: boolean): this;
|
|
1190
|
+
/** Adds a trigger parameter */
|
|
1191
|
+
triggerParameter(name: string): this;
|
|
1192
|
+
/**
|
|
1193
|
+
* Adds a state to the controller. The first state added becomes the default state.
|
|
1194
|
+
* @param name - Unique name for the state
|
|
1195
|
+
* @param options - State configuration including clip, loop, speed
|
|
1196
|
+
*/
|
|
1197
|
+
state(name: string, options: StateOptions): this;
|
|
1198
|
+
/**
|
|
1199
|
+
* Adds a transition between two states.
|
|
1200
|
+
* Use `"*"` as the source to create a transition from any state.
|
|
1201
|
+
* Chain `.condition()` calls after this to add conditions.
|
|
1202
|
+
* @param from - Source state name, or `"*"` for any-state transition
|
|
1203
|
+
* @param to - Destination state name
|
|
1204
|
+
* @param options - Transition configuration
|
|
1205
|
+
*/
|
|
1206
|
+
transition(from: string, to: string, options?: TransitionOptions): this;
|
|
1207
|
+
/**
|
|
1208
|
+
* Adds a condition to the most recently added transition.
|
|
1209
|
+
* Multiple conditions on the same transition are AND-ed together.
|
|
1210
|
+
* @param parameter - Name of the parameter to evaluate
|
|
1211
|
+
* @param mode - Condition mode: `"if"`, `"ifNot"`, `"greater"`, `"less"`, `"equals"`, `"notEqual"`
|
|
1212
|
+
* @param threshold - Comparison threshold for numeric conditions (default: 0)
|
|
1213
|
+
*/
|
|
1214
|
+
condition(parameter: string, mode: ConditionMode, threshold?: number): this;
|
|
1215
|
+
/**
|
|
1216
|
+
* Sets which state is the default/entry state.
|
|
1217
|
+
* If not called, the first added state is used.
|
|
1218
|
+
* @param name - Name of the state
|
|
1219
|
+
*/
|
|
1220
|
+
defaultState(name: string): this;
|
|
1221
|
+
/**
|
|
1222
|
+
* Builds and returns the {@link AnimatorController}.
|
|
1223
|
+
* Resolves all state name references to indices.
|
|
1224
|
+
*/
|
|
1225
|
+
build(): AnimatorController;
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1128
1228
|
export declare type AnimatorControllerModel = {
|
|
1129
1229
|
name: string;
|
|
1130
1230
|
guid: string;
|
|
@@ -4006,6 +4106,9 @@ export declare type Condition = {
|
|
|
4006
4106
|
threshold: number;
|
|
4007
4107
|
};
|
|
4008
4108
|
|
|
4109
|
+
/** String condition modes for the builder, mapped to {@link AnimatorConditionMode} */
|
|
4110
|
+
export declare type ConditionMode = "if" | "ifNot" | "greater" | "less" | "equals" | "notEqual";
|
|
4111
|
+
|
|
4009
4112
|
/** Events regarding the websocket connection (e.g. when the connection opens) */
|
|
4010
4113
|
export declare enum ConnectionEvents {
|
|
4011
4114
|
ConnectionInfo = "connection-start-info"
|
|
@@ -7516,6 +7619,7 @@ export declare class GroundProjectedEnv extends Component {
|
|
|
7516
7619
|
updateProjection(): void;
|
|
7517
7620
|
private _blurrynessShader;
|
|
7518
7621
|
private _lastBlurriness;
|
|
7622
|
+
private updateProjectionMaterial;
|
|
7519
7623
|
private updateBlurriness;
|
|
7520
7624
|
}
|
|
7521
7625
|
|
|
@@ -8301,6 +8405,10 @@ export declare class InheritVelocityModule {
|
|
|
8301
8405
|
applyCurrent(vel: Vector3 | Vector3_2, t01: number, lerpFactor: number): void;
|
|
8302
8406
|
}
|
|
8303
8407
|
|
|
8408
|
+
/** Register the Rapier physics backend. Called from {@link initEngine}
|
|
8409
|
+
* to ensure it runs regardless of tree-shaking. */
|
|
8410
|
+
export declare function initPhysics(): void;
|
|
8411
|
+
|
|
8304
8412
|
/**
|
|
8305
8413
|
* Handles all input events including mouse, touch, keyboard, and XR controllers.
|
|
8306
8414
|
* Access via `this.context.input` from any component.
|
|
@@ -12900,6 +13008,12 @@ export declare class ObjectUtils {
|
|
|
12900
13008
|
private static applyDefaultObjectOptions;
|
|
12901
13009
|
}
|
|
12902
13010
|
|
|
13011
|
+
/**
|
|
13012
|
+
* Remove a listener for before an XR session is requested
|
|
13013
|
+
* @param fn The function to remove from the listeners
|
|
13014
|
+
*/
|
|
13015
|
+
export declare function offBeforeXRSession(fn: (args: XRSessionRequestEventArgs) => void): void;
|
|
13016
|
+
|
|
12903
13017
|
/* Excluded from this release type: OffscreenCanvasExt */
|
|
12904
13018
|
|
|
12905
13019
|
/**
|
|
@@ -13004,6 +13118,21 @@ export declare function onAfterRender(cb: LifecycleMethod, opts?: LifecycleMetho
|
|
|
13004
13118
|
* */
|
|
13005
13119
|
export declare function onBeforeRender(cb: LifecycleMethod, opts?: LifecycleMethodOptions): () => void;
|
|
13006
13120
|
|
|
13121
|
+
/**
|
|
13122
|
+
* Add a listener that fires before an XR session is requested.
|
|
13123
|
+
* Use this to modify the session init options, e.g. to add optional features like `camera-access`.
|
|
13124
|
+
* @param fn The function to call before the XR session is requested
|
|
13125
|
+
* @example
|
|
13126
|
+
* ```js
|
|
13127
|
+
* onBeforeXRSession((args) => {
|
|
13128
|
+
* args.init.optionalFeatures ??= [];
|
|
13129
|
+
* args.init.optionalFeatures.push("camera-access");
|
|
13130
|
+
* });
|
|
13131
|
+
* ```
|
|
13132
|
+
* @return A function to remove the listener
|
|
13133
|
+
*/
|
|
13134
|
+
export declare function onBeforeXRSession(fn: (args: XRSessionRequestEventArgs) => void): () => void;
|
|
13135
|
+
|
|
13007
13136
|
/**
|
|
13008
13137
|
* Register a callback before the engine context is cleared.
|
|
13009
13138
|
* This happens if e.g. `<needle-engine src>` changes
|
|
@@ -13225,8 +13354,9 @@ export declare function onUpdate(cb: LifecycleMethod, opts?: LifecycleMethodOpti
|
|
|
13225
13354
|
* console.log("XR session ended", evt);
|
|
13226
13355
|
* });
|
|
13227
13356
|
* ```
|
|
13357
|
+
* @returns A function to remove the listener
|
|
13228
13358
|
*/
|
|
13229
|
-
export declare function onXRSessionEnd(fn: (evt: XRSessionEventArgs) => void): void;
|
|
13359
|
+
export declare function onXRSessionEnd(fn: (evt: XRSessionEventArgs) => void): () => void;
|
|
13230
13360
|
|
|
13231
13361
|
/**
|
|
13232
13362
|
* Add a listener for when an XR session starts
|
|
@@ -13238,8 +13368,9 @@ export declare function onXRSessionEnd(fn: (evt: XRSessionEventArgs) => void): v
|
|
|
13238
13368
|
* console.log("XR session started", evt);
|
|
13239
13369
|
* });
|
|
13240
13370
|
* ```
|
|
13371
|
+
* @returns A function to remove the listener
|
|
13241
13372
|
*/
|
|
13242
|
-
export declare function onXRSessionStart(fn: (evt: XRSessionEventArgs) => void): void;
|
|
13373
|
+
export declare function onXRSessionStart(fn: (evt: XRSessionEventArgs) => void): () => void;
|
|
13243
13374
|
|
|
13244
13375
|
/**
|
|
13245
13376
|
* OpenURL behaviour opens a URL in a new tab or window when the object (or any if it's children) is clicked.
|
|
@@ -17977,6 +18108,7 @@ export declare class OrbitControls extends Component implements ICameraControlle
|
|
|
17977
18108
|
export declare type SessionRequestedEvent = (args: {
|
|
17978
18109
|
readonly mode: XRSessionMode;
|
|
17979
18110
|
readonly init: XRSessionInit;
|
|
18111
|
+
readonly context: Context;
|
|
17980
18112
|
}) => void;
|
|
17981
18113
|
|
|
17982
18114
|
export declare function setActive(go: Object3D, active: boolean | number): boolean;
|
|
@@ -19614,6 +19746,24 @@ export declare class OrbitControls extends Component implements ICameraControlle
|
|
|
19614
19746
|
instance?: StateMachineBehaviour;
|
|
19615
19747
|
};
|
|
19616
19748
|
|
|
19749
|
+
/**
|
|
19750
|
+
* Configuration for an animation state in the builder
|
|
19751
|
+
*/
|
|
19752
|
+
export declare type StateOptions = {
|
|
19753
|
+
/** The animation clip for this state */
|
|
19754
|
+
clip: AnimationClip;
|
|
19755
|
+
/** Whether the animation should loop (default: false) */
|
|
19756
|
+
loop?: boolean;
|
|
19757
|
+
/** Base speed multiplier (default: 1) */
|
|
19758
|
+
speed?: number;
|
|
19759
|
+
/** Name of a float parameter to multiply with speed */
|
|
19760
|
+
speedParameter?: string;
|
|
19761
|
+
/** Normalized cycle offset 0-1 (default: 0) */
|
|
19762
|
+
cycleOffset?: number;
|
|
19763
|
+
/** Name of a float parameter to use as cycle offset */
|
|
19764
|
+
cycleOffsetParameter?: string;
|
|
19765
|
+
};
|
|
19766
|
+
|
|
19617
19767
|
declare type StickName = "xr-standard-thumbstick" | "xr-standard-touchpad";
|
|
19618
19768
|
|
|
19619
19769
|
export declare class StreamEndedEvent {
|
|
@@ -20712,6 +20862,22 @@ export declare class OrbitControls extends Component implements ICameraControlle
|
|
|
20712
20862
|
Animation = 3
|
|
20713
20863
|
}
|
|
20714
20864
|
|
|
20865
|
+
/**
|
|
20866
|
+
* Configuration for a transition in the builder
|
|
20867
|
+
*/
|
|
20868
|
+
export declare type TransitionOptions = {
|
|
20869
|
+
/** Duration of the crossfade in seconds (default: 0) */
|
|
20870
|
+
duration?: number;
|
|
20871
|
+
/** Normalized exit time 0-1 (default: 1). Only used when hasExitTime is true */
|
|
20872
|
+
exitTime?: number;
|
|
20873
|
+
/** Whether the transition waits for exitTime before transitioning (default: false) */
|
|
20874
|
+
hasExitTime?: boolean;
|
|
20875
|
+
/** Normalized offset into the destination state's animation (default: 0) */
|
|
20876
|
+
offset?: number;
|
|
20877
|
+
/** Whether duration is in seconds (true) or normalized (false) (default: false) */
|
|
20878
|
+
hasFixedDuration?: boolean;
|
|
20879
|
+
};
|
|
20880
|
+
|
|
20715
20881
|
export declare class TriggerBuilder {
|
|
20716
20882
|
private static __sceneStartTrigger?;
|
|
20717
20883
|
static sceneStartTrigger(): TriggerModel;
|
|
@@ -23231,6 +23397,12 @@ export declare class OrbitControls extends Component implements ICameraControlle
|
|
|
23231
23397
|
session: NeedleXRSession;
|
|
23232
23398
|
};
|
|
23233
23399
|
|
|
23400
|
+
export declare type XRSessionRequestEventArgs = {
|
|
23401
|
+
readonly mode: XRSessionMode;
|
|
23402
|
+
readonly init: XRSessionInit;
|
|
23403
|
+
readonly context: Context;
|
|
23404
|
+
};
|
|
23405
|
+
|
|
23234
23406
|
export declare class XRState {
|
|
23235
23407
|
static Global: XRState;
|
|
23236
23408
|
Mask: XRStateFlag;
|