illutions 0.24.0 → 0.25.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 CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.25.0
4
+
5
+ ### Added
6
+
7
+ - Added `CanvasPointerLeave` handling to the `OBJ3D_POINTER_LEAVE` event.
8
+ - Added `ActionCtrls` for centralized animation action lifecycle, layer grouping, and interruptible fades.
9
+ - Extended `ClipEvent` with `CLIP_CANCEL`, `CLIP_FADE_START`, `CLIP_FADE_COMPLETE`, `CLIP_SPEED_START`, and `CLIP_SPEED_COMPLETE` events.
10
+
11
+ ### Fixed
12
+
13
+ - Fixed `OBJ3D_POINTER_LEAVE` being emitted during pointer movement with a pressed mouse button and ensured touch pointers emit it after `OBJ3D_POINTER_UP` when contact ends.
14
+
15
+ ## 0.24.1
16
+
17
+ ### Added
18
+
19
+ - Added the `PROGRESSBAR_HIDDEN` event.
20
+
21
+ ### Changed
22
+
23
+ - Renamed the `aaCfg` interface to `AaCfg`.
24
+
25
+ ### Fixed
26
+
27
+ - Fixed an incorrect `objTarget.position` when enabling orbit or FPV controls after setting it in `Cam3D.onReady()`.
28
+
3
29
  ## 0.24.0
4
30
 
5
31
  ### Added
package/dist/main.d.ts CHANGED
@@ -35,7 +35,7 @@ import { TierResult } from 'detect-gpu';
35
35
  * Defines the shared anti-aliasing settings.
36
36
  * @category Cfg
37
37
  */
38
- export declare interface aaCfg {
38
+ export declare interface AaCfg {
39
39
  /**
40
40
  * Whether the GUI anti-aliasing dropdown is open.
41
41
  * @default false
@@ -48,6 +48,8 @@ export declare interface aaCfg {
48
48
  mode: 'none' | 'fxaa' | 'smaa';
49
49
  }
50
50
 
51
+ export declare type ActionFadeMode = 'in' | 'out';
52
+
51
53
  /**
52
54
  * Defines the ambient light settings controlling global scene illumination.
53
55
  * @category Cfg
@@ -112,6 +114,8 @@ export declare class App<TClasses extends Classes = {}> {
112
114
  private readonly inspector;
113
115
  readonly comps: CompInsts<NonNullable<TClasses['comps']>>;
114
116
  readonly objs3D: Obj3DInsts<NonNullable<TClasses['objs3D']>>;
117
+ private compsMap;
118
+ private objs3DMap;
115
119
  /* Excluded from this release type: __constructor */
116
120
  init(cfg: Cfg): Promise<void>;
117
121
  /**
@@ -294,8 +298,8 @@ export declare interface AudioLoadedEvent {
294
298
 
295
299
  /**
296
300
  * Defines how an animation action is blended with other active actions.
297
- * - `'normal'`: Blends the action's values with other normal actions according to their weights.
298
- * - `'additive'`: Adds the action's values to the current animation result according to its weight.
301
+ * - 'normal': Blends the action's values with other normal actions according to their weights.
302
+ * - 'additive': Adds the action's values to the current animation result according to its weight.
299
303
  */
300
304
  export declare type BlendMode = 'normal' | 'additive';
301
305
 
@@ -500,28 +504,18 @@ export declare type Classes<TObj3DClasses extends Record<string, Obj3DClass> = {
500
504
  comps?: TCompClasses;
501
505
  };
502
506
 
503
- /** @event Fired when a clip starts or finishes playing and triggers the corresponding XState event. */
507
+ /** @event Fired when a clip starts, completes, is canceled, fades its weight, or changes its playback speed. */
504
508
  export declare interface ClipEvent {
505
509
  /** Identifies this event type. */
506
- type: 'CLIP_START' | 'CLIP_COMPLETE';
507
- /** The name of the `THREE.AnimationClip` that changed state. */
508
- clipName: string;
509
- /** The name of the calling method. */
510
- fct: string;
511
- /** The associated animation action, when available. */
512
- action?: THREE_TYPE.AnimationAction;
513
- }
514
-
515
- /** @event Fired when a clip fade starts, completes, or fade-out starts/completes and triggers the corresponding XState event. */
516
- export declare interface ClipFadeEvent {
517
- /** Identifies this event type. */
518
- type: 'CLIP_FADE_START' | 'CLIP_FADE_COMPLETE' | 'CLIP_FADEOUT_COMPLETE' | 'CLIP_FADEOUT_START';
519
- /** The name of the `THREE.AnimationClip` whose fade changed state. */
510
+ type: 'CLIP_START' | 'CLIP_COMPLETE' | 'CLIP_CANCEL' | 'CLIP_FADE_START' | 'CLIP_FADE_COMPLETE' | 'CLIP_SPEED_START' | 'CLIP_SPEED_COMPLETE';
511
+ /** The name of the affected `THREE.AnimationClip`. */
520
512
  clipName: string;
521
513
  /** The name of the calling method. */
522
514
  fct: string;
523
515
  /** The associated animation action, when available. */
524
516
  action?: THREE_TYPE.AnimationAction;
517
+ /** Whether the clip weight is fading in or out. */
518
+ fadeMode?: ActionFadeMode;
525
519
  }
526
520
 
527
521
  declare type ColorNode = THREE_WEBGPU_TYPE.Node<'vec4'>;
@@ -608,12 +602,10 @@ export declare class Engine {
608
602
  private readonly cam3D;
609
603
  private readonly events;
610
604
  private readonly modules;
611
- private readonly comps;
612
605
  private readonly objs3D;
613
606
  private readonly cfg;
614
607
  private readonly infoBox;
615
- private actionObserver;
616
- private readonly objActions;
608
+ private actionCtrls;
617
609
  private gltf;
618
610
  private mixer;
619
611
  private callbacks;
@@ -650,7 +642,6 @@ export declare class Engine {
650
642
  /* Excluded from this release type: __constructor */
651
643
  /* Excluded from this release type: init */
652
644
  private initWebGpuRenderer;
653
- private addActionToObj;
654
645
  /**
655
646
  * Registers a callback that is executed on every requestAnimationFrame update.
656
647
  * @param {(deltaTime: number) => void} cb - Callback executed once per frame with `deltaTime`.
@@ -754,8 +745,6 @@ export declare class Engine {
754
745
  [key: string]: any;
755
746
  }): void;
756
747
  private calcEaseArea;
757
- private stopObjActions;
758
- private finishAction;
759
748
  /**
760
749
  * Selects the active anti-aliasing mode. The modes `'fxaa'` and `'smaa'` lazy-load their required modules.
761
750
  * @param aaMode - The anti-aliasing mode to use.
@@ -779,35 +768,37 @@ export declare class Engine {
779
768
  * Finds a Three.js animation clip by name and plays it through the `THREE.AnimationMixer`.
780
769
  *
781
770
  * @param params - Parameters for controlling the animation playback.
782
- * @param params.obj - The name of the object whose animation clip should be played.
771
+ * @param params.layer - The freely named layer used to group animation actions.
783
772
  * @param params.clip - The name of the animation clip to play.
784
773
  * @param params.blendMode - How the action is blended with other active actions. Default: **'normal'**
785
774
  * @param params.finishMode - Whether the final pose is held or faded out after the final loop. Default: **'hold'**
786
- * @param params.loop - Number of plays or `'infinite'` for endless looping. Default: **1**
787
- * @param params.stopMode - Which previous actions of the same object are stopped before playback. Default: **'all'**
775
+ * @param params.loopMode - Number of plays or `'infinite'` for endless looping. Default: **1**
776
+ * @param params.stopMode - Which previous actions of the same layer are stopped before playback. Default: **'all'**
788
777
  * @param params.fadeDuration - Duration in seconds for fading affected previous actions out and the new action in. Default: **0**
789
778
  * @param params.fadeDurationFinish - Duration in seconds for `finishMode: 'fadeOut'`. Default: **0**
790
779
  * @param params.reverse - If `true`, plays the clip in reverse. Default: **false**
791
- * @param params.reset - If `true`, resets the clip before playback. Default: **false**
780
+ * @param params.reset - If `true`, resets the clip before a new playback. Default: **false**
792
781
  * @param params.startSpeed - Initial playback speed for speed interpolation. Default: **0**
793
782
  * @param params.endSpeed - Target playback speed. Default: **1**
794
783
  * @param params.duration - Duration in seconds for speed interpolation. Default: **0**
795
784
  * @param params.ease - GSAP easing function name. Default: **'power1.inOut'**
796
785
  *
797
786
  * @remarks
798
- * `finishMode` and `fadeDurationFinish` have no effect when `loop` is `'infinite'`.
787
+ * Calling a running or fading-in action again is ignored. A finished or stopped action starts again, while an unfinished fading-out action continues at its current time and fades back in from its current weight.
788
+ *
789
+ * `finishMode` and `fadeDurationFinish` have no effect when `loopMode` is `'infinite'`.
799
790
  *
800
791
  * **Events**
801
792
  *
802
793
  * {@link ClipEvent}
803
794
  */
804
- playClip({ obj, clip: clipName, blendMode, finishMode, loop, stopMode, fadeDuration, fadeDurationFinish, reverse, reset, startSpeed, endSpeed, duration, ease }: {
805
- obj: string;
795
+ playClip({ layer, clip: clipName, blendMode, finishMode, loopMode, stopMode, fadeDuration, fadeDurationFinish, reverse, reset, startSpeed, endSpeed, duration, ease }: {
796
+ layer: string;
806
797
  clip: string;
807
798
  singleAction?: boolean;
808
799
  blendMode?: BlendMode;
809
800
  finishMode?: FinishMode;
810
- loop?: LoopMode;
801
+ loopMode?: LoopMode;
811
802
  stopMode?: StopMode;
812
803
  fadeDuration?: number;
813
804
  fadeDurationFinish?: number;
@@ -822,30 +813,31 @@ export declare class Engine {
822
813
  * Finds a camera animation clip by name and plays it through the `THREE.AnimationMixer`.
823
814
  *
824
815
  * @param params - Parameters for controlling the camera animation playback.
825
- * @param params.obj - The name of the camera object whose animation clip should be played.
816
+ * @param params.layer - The freely named layer used to group camera animation actions.
826
817
  * @param params.clip - The name of the camera animation clip to play.
827
818
  * @param params.blendMode - How the action is blended with other active actions. Default: **'normal'**
828
- * @param params.loop - Number of plays or `'infinite'` for endless looping. Default: **1**
829
- * @param params.stopMode - Which previous actions of the same object are stopped before playback. Default: **'all'**
819
+ * @param params.loopMode - Number of plays or `'infinite'` for endless looping. Default: **1**
820
+ * @param params.stopMode - Which previous actions of the same layer are stopped before playback. Default: **'all'**
830
821
  * @param params.fadeDuration - Duration in seconds for fading affected previous actions out and the new action in. Default: **0**
831
-
832
822
  * @param params.reverse - If `true`, plays the clip in reverse. Default: **false**
833
- * @param params.reset - If `true`, resets the clip before playback. Default: **false**
823
+ * @param params.reset - If `true`, resets the clip before a new playback. Default: **false**
834
824
  * @param params.startSpeed - Initial playback speed for speed interpolation. Default: **0**
835
825
  * @param params.endSpeed - Target playback speed. Default: **1**
836
826
  * @param params.duration - Duration in seconds for speed interpolation. Default: **0**
837
827
  * @param params.ease - GSAP easing function name. Default: **'power1.inOut'**
838
828
  *
839
-
829
+ * @remarks
830
+ * Calling a running or fading-in action again is ignored. A finished or stopped action starts again, while an unfinished fading-out action continues at its current time and fades back in from its current weight.
831
+ *
840
832
  * **Events**
841
833
  *
842
834
  * {@link ClipEvent}
843
835
  */
844
- playClipCam({ obj, clip: clipName, blendMode, loop, stopMode, fadeDuration, reverse, reset, startSpeed, endSpeed, duration, ease }: {
845
- obj: string;
836
+ playClipCam({ layer, clip: clipName, blendMode, loopMode, stopMode, fadeDuration, reverse, reset, startSpeed, endSpeed, duration, ease }: {
837
+ layer: string;
846
838
  clip: string;
847
839
  blendMode?: BlendMode;
848
- loop?: LoopMode;
840
+ loopMode?: LoopMode;
849
841
  stopMode?: StopMode;
850
842
  fadeDuration?: number;
851
843
  reverse?: boolean;
@@ -944,12 +936,12 @@ export declare class Engine {
944
936
  * @param params.ease - The easing function name for the fade-out transition. Default: **'power1.inOut'**
945
937
  *
946
938
  * @remarks
947
- * The method gradually reduces the clip's playback speed to zero when `fadeOut` is greater than zero, allowing a visually smooth stop. Once completed, a `ClipFade` event with type `CLIP_FADEOUT_COMPLETE`
948
- * is emitted. If no fade-out is specified, the clip stops immediately.
939
+ * The method gradually reduces the clip's playback speed to zero when `fadeOut` is greater than zero. It emits `CLIP_SPEED_START`, `CLIP_SPEED_COMPLETE`, and finally `CLIP_CANCEL`.
940
+ * If no speed transition is specified, the clip is canceled immediately.
949
941
  *
950
942
  * **Events**
951
943
  *
952
- * {@link ClipFadeEvent}
944
+ * {@link ClipEvent}
953
945
  */
954
946
  stopAnimClip({ clipName, fadeOut, ease }: {
955
947
  clipName: string;
@@ -1120,7 +1112,6 @@ export declare class Events {
1120
1112
  /* Excluded from this release type: animFade */
1121
1113
  /* Excluded from this release type: audioLoaded */
1122
1114
  /* Excluded from this release type: clip */
1123
- /* Excluded from this release type: clipFade */
1124
1115
  /* Excluded from this release type: modelError */
1125
1116
  /* Excluded from this release type: modelLoading */
1126
1117
  /**
@@ -1134,8 +1125,8 @@ export declare class Events {
1134
1125
 
1135
1126
  /**
1136
1127
  * Defines how an animation action behaves after its final loop.
1137
- * - `'hold'`: Keeps the action enabled and holds its final pose.
1138
- * - `'fadeOut'`: Fades the action out using `fadeDurationFinish`, or disables it immediately when the duration is `0`.
1128
+ * - 'hold': Keeps the action enabled and holds its final pose.
1129
+ * - 'fadeOut': Fades the action out using fadeDurationFinish, or disables it immediately when the duration is 0.
1139
1130
  */
1140
1131
  export declare type FinishMode = 'hold' | 'fadeOut';
1141
1132
 
@@ -1505,8 +1496,8 @@ export declare interface LightCfg {
1505
1496
 
1506
1497
  /**
1507
1498
  * Defines how often an animation action is played.
1508
- * - `number`: Plays the action the specified positive number of times.
1509
- * - `'infinite'`: Repeats the action indefinitely.
1499
+ * - number: Plays the action the specified positive number of times.
1500
+ * - 'infinite': Repeats the action indefinitely.
1510
1501
  */
1511
1502
  export declare type LoopMode = number | 'infinite';
1512
1503
 
@@ -2011,7 +2002,7 @@ export declare interface PostCfg {
2011
2002
  */
2012
2003
  guiOpened: boolean;
2013
2004
  /** Anti-aliasing settings. */
2014
- aa: aaCfg;
2005
+ aa: AaCfg;
2015
2006
  /** Shared SSAO settings. */
2016
2007
  ssao: SsaoCfg;
2017
2008
  /** Shared SSR settings. */
@@ -2037,6 +2028,12 @@ export declare interface PostCfg {
2037
2028
  };
2038
2029
  }
2039
2030
 
2031
+ /** @event Fired after the progress bar has finished hiding and triggers the corresponding XState event. */
2032
+ export declare interface ProgressBarHiddenEvent {
2033
+ /** Identifies this event type. */
2034
+ type: 'PROGRESSBAR_HIDDEN';
2035
+ }
2036
+
2040
2037
  /**
2041
2038
  * The Raycast class manages pointer-based raycasting in a `THREE.Scene`. It tracks specified objects, detects cursor intersections with them, and triggers intersection and non-intersection events via
2042
2039
  * the application state. The class dynamically enables or disables pointer listeners depending on the number of tracked objects. It also handles pointer events (click, down, up, move, enter, leave) for the
@@ -2057,12 +2054,14 @@ export declare class Raycast {
2057
2054
  private objCandidate;
2058
2055
  private closestObjCounter;
2059
2056
  private isEnabled;
2060
- private callbackSelect;
2057
+ private callback;
2061
2058
  private listenerClick;
2059
+ private listenerCancel;
2062
2060
  private listenerDown;
2061
+ private listenerLeave;
2063
2062
  private listenerMove;
2064
2063
  private listenerUp;
2065
- private pointerEvent;
2064
+ private eventPointerMove;
2066
2065
  private posPrevPointerX;
2067
2066
  private posPrevPointerY;
2068
2067
  private posWorldObj;
@@ -2073,6 +2072,7 @@ export declare class Raycast {
2073
2072
  enable(): void;
2074
2073
  /** Disables pointer-based raycasting and removes all pointer event listeners and the frame update callback. */
2075
2074
  disable(): void;
2075
+ private getObjectAtPointer;
2076
2076
  /**
2077
2077
  * Checks whether an object's world position is visible from the active camera without being occluded.
2078
2078
  *
@@ -2080,15 +2080,19 @@ export declare class Raycast {
2080
2080
  * @returns `true` if no other object blocks the line of sight to the object's world position, otherwise `false`.
2081
2081
  */
2082
2082
  isVisibleOcclusion(obj: THREE_TYPE.Object3D): boolean;
2083
- private onClick;
2084
- private onPointerDown;
2083
+ private onCanvasClick;
2084
+ private onCanvasPointerLeave;
2085
+ private onCanvasPointerMove;
2086
+ private onCanvasPointerCancel;
2087
+ private onCanvasPointerDown;
2088
+ private onCanvasPointerExit;
2089
+ private onCanvasPointerUp;
2085
2090
  private onPointerEnter;
2086
2091
  private onPointerLeave;
2087
2092
  private onPointerMove;
2088
- private onPointerUp;
2089
2093
  /**
2090
2094
  * Begins tracking a list of scene objects for pointer intersection detection. If the raycaster is not yet listening for pointer movements, this method automatically attaches pointer event listeners
2091
- * (`pointermove`, `click`, `pointerdown`, `pointerup`).
2095
+ * (`pointermove`, `click`, `pointercancel`, `pointerdown`, `pointerleave`, `pointerup`).
2092
2096
  *
2093
2097
  * @param params - Parameter object.
2094
2098
  * @param params.objs3D - The `Obj3D` instances to track.
@@ -2111,8 +2115,8 @@ export declare class Raycast {
2111
2115
  untrackSelectable({ objs3D }: {
2112
2116
  objs3D: Obj3D[];
2113
2117
  }): void;
2114
- /* Excluded from this release type: updateSelect */
2115
- private updatePointer;
2118
+ /* Excluded from this release type: updatePointerHover */
2119
+ private updatePointerPosition;
2116
2120
  }
2117
2121
 
2118
2122
  /**
@@ -2568,10 +2572,10 @@ export declare interface StateMachineCfg {
2568
2572
  }
2569
2573
 
2570
2574
  /**
2571
- * Defines which previous active animation actions of the same object are stopped before a new action is played.
2572
- * - `'all'`: Stops all previous active actions.
2573
- * - `'last'`: Stops only the most recently played previous active action.
2574
- * - `'none'`: Keeps all previous active actions running.
2575
+ * Defines which previous active animation actions of the same layer are stopped before a new action is played.
2576
+ * - 'all': Stops all previous active actions.
2577
+ * - 'last': Stops only the most recently played previous active action.
2578
+ * - 'none': Keeps all previous active actions running.
2575
2579
  */
2576
2580
  export declare type StopMode = 'all' | 'last' | 'none';
2577
2581