illutions 0.31.0 → 0.32.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,33 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.32.0
4
+
5
+ ### Added
6
+
7
+ - Added `Scene.animTransformTo({ obj, pos?, rot?, scale?, duration?, ease? })` for local transformations with rotation in degrees; new calls replace the previous transformation of the same object.
8
+ - Added `Audio.pause({ name, fade?, ease? })` to pause a sound while preserving its playback position; `Audio.play()` resumes it, while `Audio.stop()` resets playing or paused sounds to the beginning.
9
+ - Added the exported `AudioEvent` with `Audio_Start`, `Audio_Complete`, and `Audio_Stop`, each carrying `soundName`; completion indicates a natural playback end, and stopping emits its event immediately or after fade-out finishes.
10
+ - Added the exported `SoundParamsPos` and optional per-sound distance attenuation and directional cone overrides in `SoundParams`; omitted settings inherit the shared audio defaults.
11
+ - Added `Audio.setSoundParams()` to update a loaded sound's volume and positional overrides; volume changes during a fade are stored for subsequent playback without interrupting the fade.
12
+
13
+ ### Renamed
14
+
15
+ - `cfg.audio.delayPlaySound` → `cfg.audio.delayLoadSound`
16
+ - `SoundParams.object` → `SoundParams.obj`
17
+ - `Audio.setListener({ object })` → `Audio.setListener({ obj })`
18
+
19
+ ### Changed
20
+
21
+ - Added `Anim_Cancel` to `AnimEvent` for transformations replaced by `Scene.animTransformTo()`.
22
+ - Merged `AudioLoadedEvent` into `AudioEvent`, which now also includes `Audio_Loaded`; removed the separate `AudioLoadedEvent` interface.
23
+ - Extended `SoundParams.obj` to accept a scene object name or an `Obj3D` instance; an empty string still selects global audio. Positional settings are rejected for global sounds during loading and ignored when updating them.
24
+ - Removed `fade` from `SoundParams` and `Audio.load()`; `Audio.loadAndPlay()`, `Audio.play()`, and `Audio.stop()` now accept per-call `fade` and GSAP `ease` options. Fades default to `0` (no fade), with linear easing (`'none'`), instead of a stored two-second fade.
25
+ - Changed `Audio.get()` to return `SoundParamsPos` and `Audio.set()` to accept `Partial<SoundParamsPos>`; loading delay is no longer exposed through these methods, and shared default updates preserve per-sound overrides.
26
+
27
+ ### Fixed
28
+
29
+ - Fixed `Audio.play()` and `Audio.resume()` to resume interrupted audio contexts in addition to suspended contexts.
30
+
3
31
  ## 0.31.0
4
32
 
5
33
  ### Added
@@ -33,8 +61,8 @@
33
61
  - `Obj3DInsts` → `SceneInsts`
34
62
  - `Comp.comps` → `Web.webs`
35
63
 
36
- ### Changed
37
-
64
+ ### Changed
65
+
38
66
  - Replaced the `objs3D` and `comps` registry groups with `comps.scene` and `comps.web`; initialized instances are now exposed through `app.comps.scene` and `app.comps.web`.
39
67
  - Changed `Raycast.setColliders()` and `Raycast.clearColliders()` to accept arrays of registered `Coll3D` instances and use or reset their persistent collider roles; removed the exported `Collider` interface.
40
68
  - Replaced the individual post-processing enable settings with typed `cfg.render.profile.webgl` and `cfg.render.profile.webgpu` settings for MSAA, AA, SSL, and SSR.
@@ -49,8 +77,8 @@
49
77
 
50
78
  ## 0.30.0
51
79
 
52
- ### Changed
53
-
80
+ ### Changed
81
+
54
82
  - Replaced `Mesh3D.setTexture()` and `TextureSlot` with `requestImageTexture()` and `getImageTexture()` to separate requesting unused GLTF images from accessing their initialized Three.js textures and assigning them directly to material slots.
55
83
  - Textures created from unused GLTF images now remain stable across progressive model levels while their image and mipmap data is updated.
56
84
 
@@ -82,8 +110,8 @@
82
110
  - Added the `Model_Ready` event after the final progressive model variant has been applied and rendered.
83
111
  - Added the exported `Collider` configuration and `Raycast.setColliders()` and `Raycast.clearColliders()` to configure named scene objects or `Obj3D` instances as occluders, pickables, or hidden colliders.
84
112
 
85
- ### Changed
86
-
113
+ ### Changed
114
+
87
115
  - Replaced `Raycast.setOccluders()`, `Raycast.resetOccluders()`, `Raycast.trackPickables()`, and `Raycast.untrackPickables()` with the unified collider API.
88
116
  - Renamed `Raycast.enable()` and `Raycast.disable()` to `Raycast.enablePickables()` and `Raycast.disablePickables()`.
89
117
  - Renamed `raycast.occlInterval` to `raycast.occludeeInterval` and `raycast.occlMoveFactor` to `raycast.occlusionMoveFactor`.
@@ -104,8 +132,8 @@
104
132
 
105
133
  - Added progressive model loading through ordered model levels in `ModelCfg.file`.
106
134
 
107
- ### Changed
108
-
135
+ ### Changed
136
+
109
137
  - Changed `ModelCfg.file` from `string | null` to `string[]`; use an empty array when no model should be loaded.
110
138
  - Added the one-based `level` parameter to `ModelLoadingEvent` to identify the model level currently loading.
111
139
  - Changed state names to `snake_case` and event names to `Pascal_Snake_Case`.
@@ -122,8 +150,8 @@
122
150
  - Added `Comp.trackOverlap()` and `Comp.untrackOverlap()` to manage component overlaps in screen space through the internal `CompCtrls`.
123
151
  - Added `cfg.light.rectArea` to lazily load and initialize renderer-specific LTC data for `RectAreaLight` support.
124
152
 
125
- ### Changed
126
-
153
+ ### Changed
154
+
127
155
  - Moved the shared SSR settings `maxDistance`, `thickness`, and `resolutionScale` from `cfg.post.webgl.ssr` and `cfg.post.webgpu.ssr` to `cfg.post.ssr`.
128
156
  - Renamed the public `Raycast.trackSelectables()` and `Raycast.untrackSelectable()` methods to `Raycast.trackPickables()` and `Raycast.untrackPickables()`.
129
157
 
@@ -149,8 +177,8 @@
149
177
 
150
178
  - Added the `ProgressBar_Hidden` event.
151
179
 
152
- ### Changed
153
-
180
+ ### Changed
181
+
154
182
  - Renamed the `aaCfg` interface to `AaCfg`.
155
183
 
156
184
  ### Fixed
@@ -166,8 +194,8 @@
166
194
  - Added `Audio.load()` to load audio without starting playback.
167
195
  - Added the `AudioLoadedEvent` (`Audio_Loaded`) event for handling completed audio loading.
168
196
 
169
- ### Changed
170
-
197
+ ### Changed
198
+
171
199
  - Replaced `pauseActions` with `stopMode` and `infinite` with `loop` in animation clip playback.
172
200
  - Renamed `Raycast.trackSelectable()` to `Raycast.trackSelectables()`.
173
201
  - Changed the `LightCfg` shadow defaults to match the corresponding Three.js defaults, while keeping `castShadow` enabled by default.
@@ -202,14 +230,14 @@
202
230
  - Added `render.api` output to the infobox.
203
231
  - Added `.blend` source files to the public example apps.
204
232
 
205
- ### Changed
206
-
233
+ ### Changed
234
+
207
235
  - Renamed `cfg.webgl` and `cfg.webgpu` parameter groups to `params`.
208
236
 
209
237
  ## 0.22.0
210
238
 
211
- ### Changed
212
-
239
+ ### Changed
240
+
213
241
  - Updated the framework to Three.js r185.
214
242
  - Changed the default renderer selection to `render.api = 'auto'`.
215
243
  - Added `envCtrls.dataType` to configure environment texture data handling.
@@ -222,12 +250,12 @@
222
250
 
223
251
  ## 0.21.9
224
252
 
225
- ### Changed
226
-
253
+ ### Changed
254
+
227
255
  - Removed the `CfgCtrl` class and the related `app.cfgCtrl` access point. Runtime parameters are now updated through the responsible feature APIs, such as `app.audio.set(...)`.
228
256
 
229
257
  ## 0.21.8
230
258
 
231
- ### Changed
232
-
259
+ ### Changed
260
+
233
261
  - Added `cfg.audio.enable` to the configuration.
package/dist/main.d.ts CHANGED
@@ -50,9 +50,9 @@ export declare interface AmbientlightCfg {
50
50
  intensity: number;
51
51
  }
52
52
 
53
- /** @event Fired when an object or material color animation starts or completes. */
53
+ /** @event Fired when an object or material color animation starts, completes, or is canceled. */
54
54
  export declare interface AnimEvent {
55
- type: 'Anim_Complete' | 'Anim_Start';
55
+ type: 'Anim_Complete' | 'Anim_Start' | 'Anim_Cancel';
56
56
  /** The name of the `THREE.Object3D` whose animation changed state. */
57
57
  objName: string;
58
58
  /** The name of the calling method. */
@@ -90,7 +90,6 @@ export declare class App<TComps extends Comps = {}> {
90
90
  readonly stateMachine: StateMachine;
91
91
  private readonly webCtrls;
92
92
  private cam3D;
93
- private readonly inspector;
94
93
  readonly comps: CompsInsts<TComps>;
95
94
  private objs3DMap;
96
95
  private websMap;
@@ -114,17 +113,18 @@ export declare class App<TComps extends Comps = {}> {
114
113
  */
115
114
  declare class Audio_2 {
116
115
  private readonly ctx;
116
+ private listener;
117
117
  private readonly loader;
118
- private readonly scene;
119
118
  private readonly events;
120
- private readonly loadedSounds;
121
119
  private readonly params;
122
- private listener;
120
+ private readonly scene;
121
+ private readonly sounds;
123
122
  private attachSoundTo;
123
+ private fadeSound;
124
124
  /**
125
- * Returns a snapshot of playback timing and positional audio settings.
125
+ * Returns the shared positional sound defaults.
126
126
  */
127
- get(): Partial<AudioCfg>;
127
+ get(): SoundParamsPos;
128
128
  /**
129
129
  * Checks whether a named sound is loaded.
130
130
  * @param params - Sound selection.
@@ -146,52 +146,84 @@ declare class Audio_2 {
146
146
  * Loads an audio file without playing it and sends an `Audio_Loaded` event when the sound is ready.
147
147
  * @param params - The sound options.
148
148
  */
149
- load({ name, url, object, volume, fade, loop }: SoundParams): void;
149
+ load(params: SoundParams): void;
150
150
  /**
151
151
  * Loads an audio file and plays it automatically when loading is complete.
152
152
  * Use this method when no separate `Audio_Loaded` handling is required.
153
153
  * @param params - The sound options.
154
+ * @param params.fade - Fade-in duration for this start in seconds. Defaults to 0 (no fade).
155
+ * @param params.ease - GSAP easing for the fade-in. Defaults to linear ('none').
154
156
  */
155
- loadAndPlay({ name, url, object, volume, fade, loop }: SoundParams): void;
157
+ loadAndPlay({ fade, ease, ...params }: {
158
+ fade?: number;
159
+ ease?: string;
160
+ } & SoundParams): void;
156
161
  /**
157
- * Plays a loaded sound with a volume fade-in.
162
+ * Plays or resumes a loaded sound, optionally fading in from zero.
158
163
  * When using {@link load}, call this method after receiving the matching `Audio_Loaded` event.
159
164
  * This method does not wait for an audio file that is still loading.
160
165
  * @param params - Sound selection.
161
166
  * @param params.name - Loaded sound name.
167
+ * @param params.fade - Fade-in duration in seconds. Defaults to 0 (no fade).
168
+ * @param params.ease - GSAP easing for the fade-in. Defaults to linear ('none').
169
+ */
170
+ play({ name, fade, ease }: {
171
+ name: string;
172
+ fade?: number;
173
+ ease?: string;
174
+ }): void;
175
+ /**
176
+ * Pauses a playing sound and keeps its position for the next play().
177
+ * @param params - Sound selection and optional fade-out settings.
178
+ * @param params.name - Sound name.
179
+ * @param params.fade - Fade-out duration in seconds. Defaults to 0 (no fade).
180
+ * @param params.ease - GSAP easing for the fade-out. Defaults to linear ('none').
162
181
  */
163
- play({ name }: {
182
+ pause({ name, fade, ease }: {
164
183
  name: string;
184
+ fade?: number;
185
+ ease?: string;
165
186
  }): void;
166
187
  /**
167
188
  * Resumes the Web Audio context after a user gesture.
168
189
  */
169
190
  resume(): void;
170
- private setAttribute;
191
+ /**
192
+ * Updates shared positional defaults without replacing individual sound overrides.
193
+ * @param params - Positional defaults to update; omitted values remain unchanged.
194
+ */
195
+ set(params: Partial<SoundParamsPos>): void;
171
196
  private setAudioContext;
172
197
  /**
173
198
  * Attaches an audio listener to a scene object or camera. Set a listener before loading sounds.
174
199
  *
175
200
  * @param params - Listener target.
176
- * @param params.object - Scene object name or camera to attach the listener to.
201
+ * @param params.obj - Scene object name or camera to attach the listener to.
177
202
  */
178
- setListener({ object }: {
179
- object: string | Cam3D;
203
+ setListener({ obj }: {
204
+ obj: string | Cam3D;
180
205
  }): void;
181
- private setAllPositionalSoundsCfg;
182
- private setPositionalSoundCfg;
183
206
  /**
184
- * Updates one or more audio parameters at runtime.
185
- * @param params - Audio parameters to update.
207
+ * Updates the volume and positional overrides of a loaded sound immediately.
208
+ * Volume is stored during a fade without interrupting it.
209
+ * @param params - Sound name and settings to change; omitted settings remain unchanged.
186
210
  */
187
- set(params: Partial<AudioCfg>): void;
211
+ setSoundParams({ name, volume, ...positional }: {
212
+ name: string;
213
+ volume?: number;
214
+ } & Partial<SoundParamsPos>): void;
215
+ private setSoundParamsPos;
188
216
  /**
189
- * Fades out a playing sound and stops it.
217
+ * Stops a playing or paused sound and resets its position, optionally fading out.
190
218
  * @param params - Sound selection.
191
219
  * @param params.name - Sound name.
220
+ * @param params.fade - Fade-out duration in seconds. Defaults to 0 (no fade).
221
+ * @param params.ease - GSAP easing for the fade-out. Defaults to linear ('none').
192
222
  */
193
- stop({ name }: {
223
+ stop({ name, fade, ease }: {
194
224
  name: string;
225
+ fade?: number;
226
+ ease?: string;
195
227
  }): void;
196
228
  /**
197
229
  * Runs an extension callback immediately with access to the public API.
@@ -205,7 +237,7 @@ export { Audio_2 as Audio }
205
237
  * Controls playback timing and how positional sound fades with distance.
206
238
  * @category Cfg
207
239
  */
208
- export declare interface AudioCfg {
240
+ export declare interface AudioCfg extends SoundParamsPos {
209
241
  /**
210
242
  * Whether audio support is initialized when the application starts.
211
243
  * @default false
@@ -220,48 +252,13 @@ export declare interface AudioCfg {
220
252
  * Delay in milliseconds before loading audio for automatic playback.
221
253
  * @default 200
222
254
  */
223
- delayPlaySound: number;
224
- /**
225
- * The reference distance after which the attenuation begins.
226
- * @default 1
227
- */
228
- refDistance: number;
229
- /**
230
- * Determines how quickly the volume falls off with distance.
231
- * @default 1
232
- */
233
- rolloffFactor: number;
234
- /**
235
- * Distance beyond which linear attenuation stops reducing volume.
236
- * @default 1000
237
- */
238
- maxDistance: number;
239
- /**
240
- * The distance attenuation model used.
241
- * @default 'inverse'
242
- */
243
- distanceModel: 'linear' | 'inverse' | 'exponential';
244
- /**
245
- * Inner cone angle in degrees, within which sound is not attenuated.
246
- * @default 360
247
- */
248
- coneInnerAngle: number;
249
- /**
250
- * Outer cone angle in degrees, beyond which `coneOuterGain` applies.
251
- * @default 360
252
- */
253
- coneOuterAngle: number;
254
- /**
255
- * The gain factor outside the cone.
256
- * @default 0
257
- */
258
- coneOuterGain: number;
255
+ delayLoadSound: number;
259
256
  }
260
257
 
261
- /** @event Fired when an audio file has finished loading and is ready for playback. */
262
- export declare interface AudioLoadedEvent {
263
- type: 'Audio_Loaded';
264
- /** The unique name assigned to the loaded sound. */
258
+ /** @event Fired when a sound finishes loading, starts playback, completes naturally, or is stopped. */
259
+ export declare interface AudioEvent {
260
+ type: 'Audio_Loaded' | 'Audio_Start' | 'Audio_Complete' | 'Audio_Stop';
261
+ /** The unique name assigned to the sound. */
265
262
  soundName: string;
266
263
  }
267
264
 
@@ -580,9 +577,8 @@ export declare class Engine {
580
577
  private rttNode;
581
578
  private traaWarmupContext;
582
579
  private ecoButtonActive;
583
- private gfxChanging;
584
- private gfxIndex;
585
- private gfxLevels;
580
+ private gfxLevelChanges;
581
+ private gfxLevel;
586
582
  private gfxMode;
587
583
  private readonly gfxPostProfiles;
588
584
  private gfxState;
@@ -1565,7 +1561,6 @@ export declare type Objs3D = Cam3D | Light3D | Mesh3D | Obj3D;
1565
1561
  */
1566
1562
  export declare class OrbitCtrls {
1567
1563
  private readonly cam3D;
1568
- private readonly canvas;
1569
1564
  private readonly engine;
1570
1565
  private readonly events;
1571
1566
  private readonly modules;
@@ -2070,8 +2065,12 @@ export declare class Scene {
2070
2065
  private readonly cam3D;
2071
2066
  private readonly events;
2072
2067
  private readonly objs3D;
2068
+ private readonly tweens;
2073
2069
  private ambientLight;
2074
2070
  private hemisphereLight;
2071
+ /**
2072
+ * The underlying Three.js scene.
2073
+ */
2075
2074
  readonly obj: THREE_TYPE.Scene;
2076
2075
  /**
2077
2076
  * Moves the camera along a curved path, optionally turning it toward a new target.
@@ -2148,7 +2147,44 @@ export declare class Scene {
2148
2147
  needsUpdate?: boolean;
2149
2148
  [key: string]: any;
2150
2149
  }): void;
2151
- private calcEaseArea;
2150
+ /**
2151
+ * Animates selected local position, rotation, and scale components from their current values.
2152
+ * @param params - Target object and transformation settings.
2153
+ * @param params.obj - Scene object name or component, including cameras.
2154
+ * @param params.pos - Target local position; omitted axes remain unchanged.
2155
+ * @param params.rot - Target local Euler angles in degrees, using the object's Euler order.
2156
+ * @param params.scale - Target local scale; omitted axes remain unchanged.
2157
+ * @param params.duration - Duration in seconds. Default: **1**. A value of 0 applies the values immediately.
2158
+ * @param params.ease - GSAP easing function. Default: **'power2.inOut'**
2159
+ *
2160
+ * @remarks
2161
+ * Rotation uses quaternion interpolation along the shortest path and does not support full turns.
2162
+ * Omitted rotation axes keep their current target angles, but may change during interpolation.
2163
+ * Cameras switch to free look mode. The caller coordinates other animations and controls.
2164
+ * A new call cancels the entire previous transformation of the same object.
2165
+ * Emits {@link AnimEvent}: `Anim_Start`, `Anim_Complete`, or `Anim_Cancel` when replaced.
2166
+ */
2167
+ animTransformTo({ obj, pos, rot, scale, duration, ease }: {
2168
+ obj: string | Obj3D;
2169
+ pos?: {
2170
+ x?: number;
2171
+ y?: number;
2172
+ z?: number;
2173
+ };
2174
+ rot?: {
2175
+ x?: number;
2176
+ y?: number;
2177
+ z?: number;
2178
+ };
2179
+ scale?: {
2180
+ x?: number;
2181
+ y?: number;
2182
+ z?: number;
2183
+ };
2184
+ duration?: number;
2185
+ ease?: string;
2186
+ }): void;
2187
+ private getObjectName;
2152
2188
  /**
2153
2189
  * Plays a named animation clip with blending, looping, and speed control.
2154
2190
  *
@@ -2392,21 +2428,76 @@ export declare interface SmaaCfg {
2392
2428
  guiOpened: boolean;
2393
2429
  }
2394
2430
 
2395
- /** Parameters used to load a global or positional audio source. */
2396
- export declare type SoundParams = {
2397
- /** Unique name used to identify the audio source. */
2431
+ /**
2432
+ * Parameters used to load a global or positional audio source.
2433
+ * @category Cfg
2434
+ */
2435
+ export declare interface SoundParams extends Partial<SoundParamsPos> {
2436
+ /**
2437
+ * Whether playback should loop.
2438
+ * @default true
2439
+ */
2440
+ loop?: boolean;
2441
+ /**
2442
+ * Unique name used to identify the audio source.
2443
+ */
2398
2444
  name: string;
2399
- /** Path or URL to the audio file. */
2445
+ /**
2446
+ * Scene object name or Obj3D component for positional audio. Use an empty string for global audio.
2447
+ */
2448
+ obj: string | Obj3D;
2449
+ /**
2450
+ * Path or URL to the audio file.
2451
+ */
2400
2452
  url: string;
2401
- /** Name of the scene object for positional audio. Use an empty string for global audio. */
2402
- object: string;
2403
- /** Target playback volume. Default: `0`. */
2453
+ /**
2454
+ * Target playback volume.
2455
+ * @default 0
2456
+ */
2404
2457
  volume?: number;
2405
- /** Fade-in duration in seconds. Default: `2`. */
2406
- fade?: number;
2407
- /** Whether playback should loop. Default: `true`. */
2408
- loop?: boolean;
2409
- };
2458
+ }
2459
+
2460
+ /**
2461
+ * Controls distance attenuation and directional cones for positional sounds.
2462
+ * @category Cfg
2463
+ */
2464
+ export declare interface SoundParamsPos {
2465
+ /**
2466
+ * The reference distance after which the attenuation begins.
2467
+ * @default 1
2468
+ */
2469
+ refDistance: number;
2470
+ /**
2471
+ * Determines how quickly the volume falls off with distance.
2472
+ * @default 1
2473
+ */
2474
+ rolloffFactor: number;
2475
+ /**
2476
+ * Distance beyond which linear attenuation stops reducing volume.
2477
+ * @default 1000
2478
+ */
2479
+ maxDistance: number;
2480
+ /**
2481
+ * The distance attenuation model used.
2482
+ * @default 'inverse'
2483
+ */
2484
+ distanceModel: 'linear' | 'inverse' | 'exponential';
2485
+ /**
2486
+ * Inner cone angle in degrees, within which sound is not attenuated.
2487
+ * @default 360
2488
+ */
2489
+ coneInnerAngle: number;
2490
+ /**
2491
+ * Outer cone angle in degrees, beyond which `coneOuterGain` applies.
2492
+ * @default 360
2493
+ */
2494
+ coneOuterAngle: number;
2495
+ /**
2496
+ * The gain factor outside the cone.
2497
+ * @default 0
2498
+ */
2499
+ coneOuterGain: number;
2500
+ }
2410
2501
 
2411
2502
  /**
2412
2503
  * Controls contact shading with WebGL SSAO.