illutions 0.26.0 → 0.27.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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.27.0
4
+
5
+ ### Added
6
+
7
+ - Added progressive model loading through ordered model levels in `ModelCfg.file`.
8
+
9
+ ### Changed
10
+
11
+ - Changed `ModelCfg.file` from `string | null` to `string[]`; use an empty array when no model should be loaded.
12
+ - Added the one-based `level` parameter to `ModelLoadingEvent` to identify the model level currently loading.
13
+ - Changed state names to `snake_case` and event names to `Pascal_Snake_Case`.
14
+ - Updated debug console output to use `State:` and `Event:` labels and the new naming conventions.
15
+
3
16
  ## 0.26.0
4
17
 
5
18
  ### Added
@@ -24,19 +37,19 @@
24
37
 
25
38
  ### Added
26
39
 
27
- - Added `CanvasPointerLeave` handling to the `OBJ3D_POINTER_LEAVE` event.
40
+ - Added `CanvasPointerLeave` handling to the `Obj3D_Pointer_Leave` event.
28
41
  - Added `ActionCtrls` for centralized animation action lifecycle, layer grouping, and interruptible fades.
29
- - Extended `ClipEvent` with `CLIP_CANCEL`, `CLIP_FADE_START`, `CLIP_FADE_COMPLETE`, `CLIP_SPEED_START`, and `CLIP_SPEED_COMPLETE` events.
42
+ - Extended `ClipEvent` with `Clip_Cancel`, `Clip_Fade_Start`, `Clip_Fade_Complete`, `Clip_Speed_Start`, and `Clip_Speed_Complete` events.
30
43
 
31
44
  ### Fixed
32
45
 
33
- - 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.
46
+ - 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.
34
47
 
35
48
  ## 0.24.1
36
49
 
37
50
  ### Added
38
51
 
39
- - Added the `PROGRESSBAR_HIDDEN` event.
52
+ - Added the `ProgressBar_Hidden` event.
40
53
 
41
54
  ### Changed
42
55
 
@@ -53,7 +66,7 @@
53
66
  - Added animation modes `BlendMode`, `FinishMode`, `LoopMode`, `StopMode`
54
67
  - Added `fadeDuration` to `playClip()` and `playClipCam()`.
55
68
  - Added `Audio.load()` to load audio without starting playback.
56
- - Added the `AudioLoadedEvent` (`AUDIO_LOADED`) event for handling completed audio loading.
69
+ - Added the `AudioLoadedEvent` (`Audio_Loaded`) event for handling completed audio loading.
57
70
 
58
71
  ### Changed
59
72
 
package/README.md CHANGED
@@ -3,14 +3,22 @@
3
3
  illutions is a proprietary Web 3D engine for building interactive browser-based
4
4
  3D applications with Three.js, XState, GSAP, Tweakpane and more.
5
5
 
6
+ ## Gallery
7
+
8
+ Explore all illutions examples in the GitHub Gallery:
9
+ [https://github.com/illutions](https://github.com/illutions)
10
+
6
11
  ## Highlights
7
12
 
8
13
  **Advanced post-processing**
9
- Add SSAO, SSR, FXAA and SMAA through configurable pipelines for WebGL and WebGPU.
14
+ Add configurable SSAO, SSR, FXAA and SMAA pipelines for WebGL and WebGPU, plus TRAA for WebGPU.
10
15
 
11
16
  **Advanced animation control**
12
17
  Coordinate GLTF animation clips, GSAP transitions, camera paths and custom dolly-rig camera workflows.
13
18
 
19
+ **Progressive model and HDRI loading**
20
+ Load ordered model levels and environment maps progressively for faster initial presentation and seamless quality upgrades.
21
+
14
22
  **XState-powered application logic**
15
23
  Model complex application flows as predictable and inspectable state machines with integrated XState 5 usage.
16
24
 
@@ -32,6 +40,9 @@ Use pointer-based raycasting and distance-aware spatial audio.
32
40
  **Flexible environments**
33
41
  Load HDR, EXR and texture environments with configurable rotation, intensity and background controls.
34
42
 
43
+ **Intelligent web markers**
44
+ Keep screen-space markers responsive with optimized occlusion checks, configurable occluders and movement-aware updates.
45
+
35
46
  **Runtime insights and debugging**
36
47
  Inspect runtime properties, FPS, CPU and renderer statistics with detailed state, event and console reporting.
37
48
 
package/dist/main.d.ts CHANGED
@@ -78,7 +78,7 @@ export declare interface AmbientlightCfg {
78
78
  /** @event Fired when an object animation starts or finishes and triggers the corresponding XState event. */
79
79
  export declare interface AnimEvent {
80
80
  /** Identifies this event type. */
81
- type: 'ANIM_COMPLETE' | 'ANIM_START';
81
+ type: 'Anim_Complete' | 'Anim_Start';
82
82
  /** The name of the `THREE.Object3D` whose animation changed state. */
83
83
  objName: string;
84
84
  /** The name of the calling method. */
@@ -88,7 +88,7 @@ export declare interface AnimEvent {
88
88
  /** @event Fired when a material fade animation starts or finishes and triggers the corresponding XState event. */
89
89
  export declare interface AnimFadeEvent {
90
90
  /** Identifies this event type. */
91
- type: 'ANIM_FADE_COMPLETE' | 'ANIM_FADE_START';
91
+ type: 'Anim_Fade_Complete' | 'Anim_Fade_Start';
92
92
  /** The name of the `THREE.Mesh` whose material fade changed state. */
93
93
  objName: string;
94
94
  /** The name of the calling method. */
@@ -176,19 +176,19 @@ declare class Audio_2 {
176
176
  }): boolean;
177
177
  private loadSound;
178
178
  /**
179
- * Loads an audio file without playing it and sends an `AUDIO_LOADED` event when the sound is ready.
179
+ * Loads an audio file without playing it and sends an `Audio_Loaded` event when the sound is ready.
180
180
  * @param params - The sound options.
181
181
  */
182
182
  load({ name, url, object, volume, fade, loop }: SoundParams): void;
183
183
  /**
184
184
  * Loads an audio file and plays it automatically when loading is complete.
185
- * Use this method when no separate `AUDIO_LOADED` handling is required.
185
+ * Use this method when no separate `Audio_Loaded` handling is required.
186
186
  * @param params - The sound options.
187
187
  */
188
188
  loadAndPlay({ name, url, object, volume, fade, loop }: SoundParams): void;
189
189
  /**
190
190
  * Plays an audio that has finished loading, with a smooth fade-in.
191
- * When using {@link load}, call this method after receiving the matching `AUDIO_LOADED` event.
191
+ * When using {@link load}, call this method after receiving the matching `Audio_Loaded` event.
192
192
  * This method does not wait for an audio file that is still loading.
193
193
  * @param params - Parameter object.
194
194
  * @param params.name - The name of the loaded audio to play.
@@ -295,7 +295,7 @@ export declare interface AudioCfg {
295
295
  /** @event Fired when an audio file has finished loading and is ready for playback. */
296
296
  export declare interface AudioLoadedEvent {
297
297
  /** Identifies this event type. */
298
- type: 'AUDIO_LOADED';
298
+ type: 'Audio_Loaded';
299
299
  /** The unique name assigned to the loaded sound. */
300
300
  soundName: string;
301
301
  }
@@ -441,7 +441,7 @@ export declare interface CamPerspectiveCfg extends CamBaseCfg {
441
441
  /** @event Fired when the user uses keys while the canvas has focus and triggers the corresponding XState event. */
442
442
  export declare interface CanvasKeyEvent {
443
443
  /** Identifies this event type. */
444
- type: 'CANVAS_KEY_DOWN' | 'CANVAS_KEY_UP';
444
+ type: 'Canvas_Key_Down' | 'Canvas_Key_Up';
445
445
  /** Native keyboard event from the canvas interaction. */
446
446
  event: KeyboardEvent;
447
447
  }
@@ -449,7 +449,7 @@ export declare interface CanvasKeyEvent {
449
449
  /** @event Fired when the user uses the pointer on the canvas and triggers the corresponding XState event. */
450
450
  export declare interface CanvasPointerEvent {
451
451
  /** Identifies this event type. */
452
- type: 'CANVAS_CLICK' | 'CANVAS_POINTER_DOWN' | 'CANVAS_POINTER_MOVE' | 'CANVAS_POINTER_UP';
452
+ type: 'Canvas_Click' | 'Canvas_Pointer_Down' | 'Canvas_Pointer_Move' | 'Canvas_Pointer_Up';
453
453
  /** Native pointer event from the canvas interaction. */
454
454
  event: PointerEvent;
455
455
  }
@@ -513,7 +513,7 @@ export declare type Classes<TObj3DClasses extends Record<string, Obj3DClass> = {
513
513
  /** @event Fired when a clip starts, completes, is canceled, fades its weight, or changes its playback speed. */
514
514
  export declare interface ClipEvent {
515
515
  /** Identifies this event type. */
516
- type: 'CLIP_START' | 'CLIP_COMPLETE' | 'CLIP_CANCEL' | 'CLIP_FADE_START' | 'CLIP_FADE_COMPLETE' | 'CLIP_SPEED_START' | 'CLIP_SPEED_COMPLETE';
516
+ type: 'Clip_Start' | 'Clip_Complete' | 'Clip_Cancel' | 'Clip_Fade_Start' | 'Clip_Fade_Complete' | 'Clip_Speed_Start' | 'Clip_Speed_Complete';
517
517
  /** The name of the affected `THREE.AnimationClip`. */
518
518
  clipName: string;
519
519
  /** The name of the calling method. */
@@ -609,7 +609,7 @@ export declare type CompInsts<T extends Record<string, CompClass>> = {
609
609
  /** @event Fired when the overlap state of a web component changes and triggers the corresponding XState event. */
610
610
  export declare interface CompOverlapEvent {
611
611
  /** Identifies this event type. */
612
- type: 'COMP_OVERLAP_CHANGED';
612
+ type: 'Comp_Overlap_Changed';
613
613
  /** The affected web component. */
614
614
  comp: Comp;
615
615
  /** Whether the component is overlapped by a nearer component. */
@@ -640,7 +640,7 @@ export declare interface CompsOverlapCfg {
640
640
  /** @event Fired when the combined 3D-object and overlap visibility of a web component changes and triggers the corresponding XState event. */
641
641
  export declare interface CompVisibleEvent {
642
642
  /** Identifies this event type. */
643
- type: 'COMP_VISIBLE_CHANGED';
643
+ type: 'Comp_Visible_Changed';
644
644
  /** The affected web component. */
645
645
  comp: Comp;
646
646
  /** Whether the component is visible after combining all visibility conditions. */
@@ -677,10 +677,12 @@ export declare class Engine {
677
677
  private readonly objs3D;
678
678
  private readonly cfg;
679
679
  private readonly infoBox;
680
+ private readonly model;
680
681
  private actionCtrls;
681
682
  private gltf;
682
683
  private mixer;
683
684
  private callbacks;
685
+ private resolveWaitForRender;
684
686
  private canvas;
685
687
  private composer;
686
688
  /* Excluded from this release type: renderer */
@@ -714,6 +716,7 @@ export declare class Engine {
714
716
  private resizeDelay;
715
717
  /* Excluded from this release type: __constructor */
716
718
  /* Excluded from this release type: init */
719
+ private initFirstScene;
717
720
  private initWebGpuRenderer;
718
721
  /**
719
722
  * Registers a callback that is executed on every requestAnimationFrame update.
@@ -836,7 +839,6 @@ export declare class Engine {
836
839
  private isPostCfg;
837
840
  /* Excluded from this release type: isPostEnabled */
838
841
  private isPostGpu;
839
- private loadScene;
840
842
  /**
841
843
  * Finds a Three.js animation clip by name and plays it through the `THREE.AnimationMixer`.
842
844
  *
@@ -1009,7 +1011,7 @@ export declare class Engine {
1009
1011
  * @param params.ease - The easing function name for the fade-out transition. Default: **'power1.inOut'**
1010
1012
  *
1011
1013
  * @remarks
1012
- * 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`.
1014
+ * 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`.
1013
1015
  * If no speed transition is specified, the clip is canceled immediately.
1014
1016
  *
1015
1017
  * **Events**
@@ -1169,6 +1171,22 @@ export declare interface EnvCtrlsCfg {
1169
1171
  type: 'hdr' | 'exr' | 'texture';
1170
1172
  }
1171
1173
 
1174
+ declare type EventByType<TEvent extends {
1175
+ type: string;
1176
+ }, TType extends EventType<TEvent>> = Extract<TEvent, {
1177
+ type: TType;
1178
+ }>;
1179
+
1180
+ declare class EventDispatcher<TEvent extends {
1181
+ type: string;
1182
+ }> {
1183
+ private readonly listeners;
1184
+ addEventListener<TType extends EventType<TEvent>>(type: TType, listener: Listener<EventByType<TEvent, TType>>): Unsubscribe;
1185
+ removeEventListener<TType extends EventType<TEvent>>(type: TType, listener: Listener<EventByType<TEvent, TType>>): void;
1186
+ emit(event: TEvent): void;
1187
+ listenerCount<TType extends EventType<TEvent>>(type: TType): number;
1188
+ }
1189
+
1172
1190
  /**
1173
1191
  * Internal event dispatcher for the engine.
1174
1192
  * @category Core
@@ -1179,7 +1197,7 @@ export declare class Events {
1179
1197
  private eventQueue;
1180
1198
  private isProcessingEvents;
1181
1199
  /* Excluded from this release type: __constructor */
1182
- /** Queues callbacks and processes them sequentially to prevent re-entrant or simultaneous access to send(). */
1200
+ /** A nested snapshot.can() is only evaluated after the current event callback has completed. */
1183
1201
  private enqueue;
1184
1202
  /* Excluded from this release type: anim */
1185
1203
  /* Excluded from this release type: animFade */
@@ -1196,6 +1214,10 @@ export declare class Events {
1196
1214
  /* Excluded from this release type: windowResize */
1197
1215
  }
1198
1216
 
1217
+ declare type EventType<TEvent extends {
1218
+ type: string;
1219
+ }> = TEvent['type'];
1220
+
1199
1221
  /**
1200
1222
  * Defines how an animation action behaves after its final loop.
1201
1223
  * - 'hold': Keeps the action enabled and holds its final pose.
@@ -1370,7 +1392,7 @@ export declare interface FpvCtrlsCfg {
1370
1392
  /** @event Fired when an `FpvCtrls` event occurs and triggers the corresponding XState event. */
1371
1393
  export declare interface FpvCtrlsEvent {
1372
1394
  /** Identifies this event type. */
1373
- type: 'FPVCTRLS_DISABLED' | 'FPVCTRLS_ENABLED' | 'FPVCTRLS_LOCK' | 'FPVCTRLS_UNLOCK';
1395
+ type: 'FpvCtrls_Disabled' | 'FpvCtrls_Enabled' | 'FpvCtrls_Lock' | 'FpvCtrls_Unlock';
1374
1396
  }
1375
1397
 
1376
1398
  /**
@@ -1572,6 +1594,8 @@ export declare interface LightCfg {
1572
1594
  far: number;
1573
1595
  }
1574
1596
 
1597
+ declare type Listener<TEvent> = (event: TEvent) => void;
1598
+
1575
1599
  /**
1576
1600
  * Defines how often an animation action is played.
1577
1601
  * - number: Plays the action the specified positive number of times.
@@ -1669,10 +1693,10 @@ export declare interface ModelCfg {
1669
1693
  texture: 'none' | 'webp' | 'ktx2';
1670
1694
  };
1671
1695
  /**
1672
- * The file path of your GLTF/GLB scene model. Set to `null` if no model should be loaded.
1673
- * @default null
1696
+ * An ordered list of non-empty, progressively higher-quality GLTF/GLB scene paths. The first file initializes the scene, subsequent files replace matching mesh geometries and textured materials in order.
1697
+ * @default []
1674
1698
  */
1675
- file: string | null;
1699
+ file: string[];
1676
1700
  /**
1677
1701
  * Public path to the Draco decoder files.
1678
1702
  * @default 'draco/'
@@ -1688,7 +1712,7 @@ export declare interface ModelCfg {
1688
1712
  /** @event Fired when an error occurs while loading model assets and triggers the corresponding XState event. */
1689
1713
  export declare interface ModelErrorEvent {
1690
1714
  /** Identifies this event type. */
1691
- type: 'MODEL_ERROR';
1715
+ type: 'Model_Error';
1692
1716
  /** The caught error object. */
1693
1717
  error: Error;
1694
1718
  }
@@ -1696,9 +1720,11 @@ export declare interface ModelErrorEvent {
1696
1720
  /** @event Fired while model assets are loading and triggers the corresponding XState event. */
1697
1721
  export declare interface ModelLoadingEvent {
1698
1722
  /** Identifies this event type. */
1699
- type: 'MODEL_LOADING';
1723
+ type: 'Model_Loading';
1700
1724
  /** Loading progress in percent (0-100). */
1701
1725
  loading: number;
1726
+ /** One-based index of the model level currently loading. */
1727
+ level: number;
1702
1728
  }
1703
1729
 
1704
1730
  declare class Modules {
@@ -1800,7 +1826,7 @@ export declare class Obj3D {
1800
1826
  * @public
1801
1827
  */
1802
1828
  protected scene: Readonly<THREE_TYPE.Scene>;
1803
- private readonly eventDispatcher;
1829
+ /* Excluded from this release type: eventDispatcher */
1804
1830
  private posNdc;
1805
1831
  private posScreen;
1806
1832
  private posScreenLast;
@@ -1890,7 +1916,7 @@ export declare type Obj3DEvent = Obj3DPosWorldEvent | Obj3DPosScreenEvent | Obj3
1890
1916
  /** @event Fired when the frustum visibility of a 3D object changes. */
1891
1917
  export declare interface Obj3DFrustumEvent {
1892
1918
  /** Identifies this event type. */
1893
- type: 'OBJ3D_FRUSTUM_CHANGED';
1919
+ type: 'Obj3D_Frustum_Changed';
1894
1920
  /** Whether the object's world position is inside the camera frustum. */
1895
1921
  visibleFrustum: boolean;
1896
1922
  }
@@ -1907,7 +1933,7 @@ export declare type Obj3DInsts<T extends Record<string, Obj3DClass>> = {
1907
1933
  /** @event Fired when the user uses the pointer on an active object and triggers the corresponding XState event. */
1908
1934
  export declare interface Obj3DPointerEvent {
1909
1935
  /** Identifies this event type. */
1910
- type: 'OBJ3D_CLICK' | 'OBJ3D_POINTER_ENTER' | 'OBJ3D_POINTER_DOWN' | 'OBJ3D_POINTER_LEAVE' | 'OBJ3D_POINTER_MOVE' | 'OBJ3D_POINTER_UP';
1936
+ type: 'Obj3D_Click' | 'Obj3D_Pointer_Enter' | 'Obj3D_Pointer_Down' | 'Obj3D_Pointer_Leave' | 'Obj3D_Pointer_Move' | 'Obj3D_Pointer_Up';
1911
1937
  /** Native pointer event from the active object interaction. */
1912
1938
  event: PointerEvent;
1913
1939
  /** The name of the object receiving the pointer event. */
@@ -1919,7 +1945,7 @@ export declare interface Obj3DPointerEvent {
1919
1945
  */
1920
1946
  export declare interface Obj3DPosScreenEvent {
1921
1947
  /** Identifies this event type. */
1922
- type: 'OBJ3D_POS_SCREEN_CHANGED';
1948
+ type: 'Obj3D_Pos_Screen_Changed';
1923
1949
  /** The object's position projected into screen space. */
1924
1950
  posScreen: THREE_TYPE.Vector2;
1925
1951
  }
@@ -1929,7 +1955,7 @@ export declare interface Obj3DPosScreenEvent {
1929
1955
  */
1930
1956
  export declare interface Obj3DPosWorldEvent {
1931
1957
  /** Identifies this event type. */
1932
- type: 'OBJ3D_POS_WORLD_CHANGED';
1958
+ type: 'Obj3D_Pos_World_Changed';
1933
1959
  /** The object's position in world coordinates. */
1934
1960
  posWorld: THREE_TYPE.Vector3;
1935
1961
  }
@@ -1939,7 +1965,7 @@ export declare interface Obj3DPosWorldEvent {
1939
1965
  */
1940
1966
  export declare interface Obj3DRotWorldEvent {
1941
1967
  /** Identifies this event type. */
1942
- type: 'OBJ3D_ROT_WORLD_CHANGED';
1968
+ type: 'Obj3D_Rot_World_Changed';
1943
1969
  /** The object's rotation in world coordinates. */
1944
1970
  rotWorld: THREE_TYPE.Euler;
1945
1971
  }
@@ -1947,7 +1973,7 @@ export declare interface Obj3DRotWorldEvent {
1947
1973
  /** @event Fired when the combined frustum and occlusion visibility of a 3D object changes and triggers the corresponding XState event. */
1948
1974
  export declare interface Obj3DVisibleEvent {
1949
1975
  /** Identifies this event type. */
1950
- type: 'OBJ3D_VISIBLE_CHANGED';
1976
+ type: 'Obj3D_Visible_Changed';
1951
1977
  /** Whether the object is inside the camera frustum and not occluded. */
1952
1978
  visible: boolean;
1953
1979
  }
@@ -2095,7 +2121,7 @@ export declare interface OrbitCtrlsCfg {
2095
2121
  /** @event Fired when an OrbitControls event occurs and triggers the corresponding XState event. */
2096
2122
  export declare interface OrbitCtrlsEvent {
2097
2123
  /** Identifies this event type. */
2098
- type: 'ORBITCTRLS_CHANGED' | 'ORBITCTRLS_DISABLED' | 'ORBITCTRLS_ENABLED' | 'ORBITCTRLS_END' | 'ORBITCTRLS_START' | 'ORBITCTRLS_DISPOSED';
2124
+ type: 'OrbitCtrls_Changed' | 'OrbitCtrls_Disabled' | 'OrbitCtrls_Enabled' | 'OrbitCtrls_End' | 'OrbitCtrls_Start' | 'OrbitCtrls_Disposed';
2099
2125
  }
2100
2126
 
2101
2127
  /**
@@ -2138,7 +2164,7 @@ export declare interface PostCfg {
2138
2164
  /** @event Fired after the progress bar has finished hiding and triggers the corresponding XState event. */
2139
2165
  export declare interface ProgressBarHiddenEvent {
2140
2166
  /** Identifies this event type. */
2141
- type: 'PROGRESSBAR_HIDDEN';
2167
+ type: 'ProgressBar_Hidden';
2142
2168
  }
2143
2169
 
2144
2170
  /**
@@ -2407,13 +2433,13 @@ export declare interface SceneCfg {
2407
2433
  /** @event Fired when the scene is set up and ready and triggers the corresponding XState event. */
2408
2434
  export declare interface SceneReadyEvent {
2409
2435
  /** Identifies this event type. */
2410
- type: 'SCENE_READY';
2436
+ type: 'Scene_Ready';
2411
2437
  }
2412
2438
 
2413
2439
  /** @event Fired after the scene has been rendered for the first time and triggers the corresponding XState event. */
2414
2440
  export declare interface SceneRenderedEvent {
2415
2441
  /** Identifies this event type. */
2416
- type: 'SCENE_RENDERED';
2442
+ type: 'Scene_Rendered';
2417
2443
  }
2418
2444
 
2419
2445
  /**
@@ -2694,7 +2720,7 @@ export declare type WebGpuRendererParams = NonNullable<ConstructorParameters<typ
2694
2720
  /** @event Fired when the window size changes and triggers the corresponding XState event. */
2695
2721
  export declare interface WindowResizeEvent {
2696
2722
  /** Identifies this event type. */
2697
- type: 'WINDOW_RESIZE';
2723
+ type: 'Window_Resize';
2698
2724
  }
2699
2725
 
2700
2726
  export { }