illutions 0.33.0 → 0.34.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,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.34.0
4
+
5
+ ### Added
6
+
7
+ - Added object-bound `Obj3D.animRotTo()`, `Obj3D.animScaleTo()`, and `Obj3D.animTranslTo()` counterparts to the Scene transformation methods.
8
+ - Added `Obj3D.animVelRotTo()`, `Obj3D.animVelScaleTo()`, and `Obj3D.animVelTranslTo()` with optional `vx`, `vy`, and `vz` targets; omitted axes retain their velocities. Angular velocity uses radians per second and defaults to local space; translation uses coordinate units per second and defaults to parent space; scale velocity is additive in local scale units per second. Defaults are `time: 0` (immediate) and `ease: 'none'` (linear), with `ease` typed as `string`. World-space angular velocity requires uniformly scaled parents. Velocity is applied before `onUpdate()`; `Cam3D.animVelRotTo()` automatically lets angular velocity control camera orientation. Callers coordinate simultaneous transformation and velocity animations affecting the same values.
9
+ - Velocity animations emit `Anim_Start`, `Anim_Complete`, and `Anim_Cancel` when replaced, with the component name in `objName` and the method in `fct`. Completion means the target velocity is reached; motion continues unless the target is zero. Immediate changes emit start and completion synchronously. A new call replaces only the previous animation of the same velocity channel.
10
+ - Exported `CoordinateSpace` with `'parent'`, `'local'`, and `'world'`, plus `degToRad()` and `radToDeg()` through `illutions`.
11
+
12
+ ### Changed
13
+
14
+ - Replaced `Scene.animTransformTo()` with `Scene.animTranslTo()`, `Scene.animRotTo()`, and `Scene.animScaleTo()`. Each accepts optional `x`, `y`, and `z` targets and has independent duration, easing, and cancellation; a new call cancels only the previous animation of the same transform channel. Defaults are `time: 1` and `ease: 'power2.inOut'`. Rotation uses radians, `path: 'euler'` or `'quat'` (default `'euler'`), and `order: 'XYZ'` by default. Euler interpolation supports full turns; quaternion interpolation follows the shortest orientation path. Rotation and translation support parent/world targets through `space` (default `'parent'`); scale uses local values.
15
+ - Environment rotation and rotation speed now use radians and radians per second in `cfg.envCtrls`, `EnvCtrls.set()`, and `EnvCtrls.get()`. Orbit azimuth and polar limits now use radians in `cfg.orbitCtrls`, `OrbitCtrls.set()`, and `OrbitCtrls.get()`; the default `maxPolarAngle` is `Math.PI` instead of `180`. Convert existing degree values with `degToRad()`. First-Person limits already use radians; camera field of view and audio cone angles remain in degrees, and control speed factors are unchanged.
16
+ - The Inspector displays Orbit and First-Person angle limits and environment rotation in degrees while converting edits to radians. It also provides an environment rotation speed field in degrees per second.
17
+
3
18
  ## 0.33.0
4
19
 
5
20
  ### Added
package/dist/main.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { AnyEventObject } from 'xstate';
2
2
  import { AnyStateMachine } from 'xstate';
3
+ import { degToRad } from 'three/src/math/MathUtils.js';
3
4
  import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
5
+ import { radToDeg } from 'three/src/math/MathUtils.js';
4
6
  import { ReflectorForSSRPass } from 'three/addons/objects/ReflectorForSSRPass.js';
5
7
  import type * as THREE_TYPE from 'three';
6
8
  import type * as THREE_WEBGPU_TYPE from 'three/webgpu';
@@ -284,6 +286,7 @@ export declare class Cam3D extends Obj3D {
284
286
  /** Reference to the original target `THREE.Object3D` loaded from the GLTF scene. */
285
287
  targetGltf: THREE_TYPE.Object3D | null;
286
288
  private readonly tmpVec;
289
+ animVelRotTo(params: Parameters<Obj3D['animVelRotTo']>[0]): void;
287
290
  /**
288
291
  * Called when a matching GLTF camera is found. Adopts its projection and world transform when the camera types match.
289
292
  * @param objGltf - The GLTF `THREE.Camera` object.
@@ -524,6 +527,9 @@ export declare interface CompsOverlapCfg {
524
527
  padding: number;
525
528
  }
526
529
 
530
+ /** Coordinate space used for transformations. */
531
+ export declare type CoordinateSpace = 'parent' | 'local' | 'world';
532
+
527
533
  /**
528
534
  * Controls diagnostic console output.
529
535
  * @category Cfg
@@ -547,6 +553,8 @@ declare type DeepPartial<T> = T extends readonly unknown[] ? T : T extends objec
547
553
  [P in keyof T]?: DeepPartial<T[P]>;
548
554
  } : T;
549
555
 
556
+ export { degToRad }
557
+
550
558
  /**
551
559
  * Renders the scene and controls post-processing and adaptive performance.
552
560
  * @category Core
@@ -674,7 +682,7 @@ export declare class EnvCtrls {
674
682
  /** Removes environment lighting and background maps, cancels pending updates, and stops rotation. */
675
683
  disable(): void;
676
684
  /**
677
- * Returns a snapshot of environment rotation, intensity, and background blurriness.
685
+ * Returns a snapshot of environment rotation in radians, rotation speed in radians per second, intensity, and background blurriness.
678
686
  */
679
687
  get(): Partial<EnvCtrlsCfg>;
680
688
  /**
@@ -685,7 +693,7 @@ export declare class EnvCtrls {
685
693
  private loadText;
686
694
  /**
687
695
  * Updates supported environment control values at runtime.
688
- * @param params - Runtime values to update: rotation speed, intensities, background blurriness or rotation.
696
+ * @param params - Runtime values to update: rotation speed in radians per second, intensities, background blurriness or rotation in radians.
689
697
  */
690
698
  set(params: Partial<EnvCtrlsCfg>): void;
691
699
  private setEnv;
@@ -739,7 +747,7 @@ export declare interface EnvCtrlsCfg {
739
747
  */
740
748
  map: string[];
741
749
  /**
742
- * Environment and background rotation values in degrees.
750
+ * Environment and background rotation values in radians.
743
751
  * @default { x: 0, y: 0, z: 0 }
744
752
  */
745
753
  rotation: {
@@ -748,7 +756,7 @@ export declare interface EnvCtrlsCfg {
748
756
  z: number;
749
757
  };
750
758
  /**
751
- * Environment and background rotation speed in degrees per second.
759
+ * Environment and background rotation speed in radians per second.
752
760
  * @default 0
753
761
  */
754
762
  rotationSpeed: number;
@@ -1409,23 +1417,31 @@ export declare class Obj3D {
1409
1417
  * @public
1410
1418
  */
1411
1419
  scene: Scene;
1412
- private posNdc;
1413
- private posScreen;
1420
+ private coordTransl;
1421
+ private coordRot;
1422
+ private readonly tweensVel;
1423
+ private readonly posNdc;
1424
+ private readonly posScreen;
1414
1425
  private posScreenLast;
1415
- private posWorld;
1426
+ private readonly posWorld;
1416
1427
  private posWorldLast;
1417
- private posCamWorld;
1428
+ private readonly posCamWorld;
1418
1429
  private posWorldOccl;
1419
1430
  private posCamWorldOccl;
1420
- private quatWorld;
1421
- private quatWorldLast;
1422
- private rotWorld;
1423
- private visible;
1431
+ private readonly orientWorld;
1432
+ private orientWorldLast;
1433
+ private readonly orientAnglesWorld;
1434
+ private readonly velQuat;
1435
+ private readonly velRotAxis;
1436
+ private readonly velRotWorldToParent;
1437
+ private readonly velTranslFrame;
1438
+ private readonly velTranslWorldToParent;
1424
1439
  private inFrustum;
1425
1440
  private inFrustumLast;
1426
- private visibleLast;
1427
1441
  private occluded;
1428
1442
  private objHidden;
1443
+ private visible;
1444
+ private visibleLast;
1429
1445
  private visibleBeforeHidden;
1430
1446
  /**
1431
1447
  * Subscribes to an object event.
@@ -1436,11 +1452,90 @@ export declare class Obj3D {
1436
1452
  addEventListener<TType extends Obj3DEvent['type']>(type: TType, listener: (event: Extract<Obj3DEvent, {
1437
1453
  type: TType;
1438
1454
  }>) => void): Unsubscribe;
1439
- private calcFrustumVisibility;
1440
- private calcPosScreen;
1441
- private calcPosOccl;
1442
- private calcRotWorld;
1443
- private calcVisibility;
1455
+ /**
1456
+ * Animates this object's orientation in radians through {@link Scene.animRotTo}.
1457
+ * @param params - Target orientation and animation settings, without an object parameter.
1458
+ */
1459
+ animRotTo(params: Omit<Parameters<Scene['animRotTo']>[0], 'obj'>): void;
1460
+ /**
1461
+ * Animates this object's scale through {@link Scene.animScaleTo}.
1462
+ * @param params - Target scale and animation settings, without an object parameter.
1463
+ */
1464
+ animScaleTo(params: Omit<Parameters<Scene['animScaleTo']>[0], 'obj'>): void;
1465
+ /**
1466
+ * Animates this object's position through {@link Scene.animTranslTo}.
1467
+ * @param params - Target position and animation settings, without an object parameter.
1468
+ */
1469
+ animTranslTo(params: Omit<Parameters<Scene['animTranslTo']>[0], 'obj'>): void;
1470
+ /**
1471
+ * Animates angular velocity in radians per second. World rotation requires uniformly scaled parents.
1472
+ * @param params - Target angular velocity and animation settings.
1473
+ * @param params.vx - Target velocity around X; omitted axes remain unchanged.
1474
+ * @param params.vy - Target velocity around Y.
1475
+ * @param params.vz - Target velocity around Z.
1476
+ * @param params.space - Coordinate space. Default: **'local'**
1477
+ * @param params.time - Duration in seconds. Default: **0** (immediate).
1478
+ * @param params.ease - GSAP easing. Default: **'none'** (linear).
1479
+ * @remarks
1480
+ * Emits {@link AnimEvent}: `Anim_Start`, `Anim_Complete`, or `Anim_Cancel` when replaced.
1481
+ * Completion means the target velocity is reached; motion continues unless the target is zero.
1482
+ * With `time: 0`, start and completion are emitted immediately.
1483
+ */
1484
+ animVelRotTo({ vx, vy, vz, space, time, ease }: {
1485
+ vx?: number;
1486
+ vy?: number;
1487
+ vz?: number;
1488
+ space?: CoordinateSpace;
1489
+ time?: number;
1490
+ ease?: string;
1491
+ }): void;
1492
+ /**
1493
+ * Animates additive local scale velocity in scale units per second.
1494
+ * @param params - Target scale velocity and animation settings.
1495
+ * @param params.vx - Target velocity along X; omitted axes remain unchanged.
1496
+ * @param params.vy - Target velocity along Y.
1497
+ * @param params.vz - Target velocity along Z.
1498
+ * @param params.time - Duration in seconds. Default: **0** (immediate).
1499
+ * @param params.ease - GSAP easing. Default: **'none'** (linear).
1500
+ * @remarks
1501
+ * Emits {@link AnimEvent}: `Anim_Start`, `Anim_Complete`, or `Anim_Cancel` when replaced.
1502
+ * Completion means the target velocity is reached; motion continues unless the target is zero.
1503
+ * With `time: 0`, start and completion are emitted immediately.
1504
+ */
1505
+ animVelScaleTo({ vx, vy, vz, time, ease }: {
1506
+ vx?: number;
1507
+ vy?: number;
1508
+ vz?: number;
1509
+ time?: number;
1510
+ ease?: string;
1511
+ }): void;
1512
+ private animVelTo;
1513
+ /**
1514
+ * Animates translation velocity in coordinate units per second. Parent scaling affects parent and local movement.
1515
+ * @param params - Target translation velocity and animation settings.
1516
+ * @param params.vx - Target velocity along X; omitted axes remain unchanged.
1517
+ * @param params.vy - Target velocity along Y.
1518
+ * @param params.vz - Target velocity along Z.
1519
+ * @param params.space - Coordinate space. Default: **'parent'**
1520
+ * @param params.time - Duration in seconds. Default: **0** (immediate).
1521
+ * @param params.ease - GSAP easing. Default: **'none'** (linear).
1522
+ * @remarks
1523
+ * Emits {@link AnimEvent}: `Anim_Start`, `Anim_Complete`, or `Anim_Cancel` when replaced.
1524
+ * Completion means the target velocity is reached; motion continues unless the target is zero.
1525
+ * With `time: 0`, start and completion are emitted immediately.
1526
+ */
1527
+ animVelTranslTo({ vx, vy, vz, space, time, ease }: {
1528
+ vx?: number;
1529
+ vy?: number;
1530
+ vz?: number;
1531
+ space?: CoordinateSpace;
1532
+ time?: number;
1533
+ ease?: string;
1534
+ }): void;
1535
+ private checkFrustumVisible;
1536
+ private checkPosOccl;
1537
+ private checkPosScreen;
1538
+ private checkRotWorld;
1444
1539
  /**
1445
1540
  * Returns the object's screen position in canvas coordinates.
1446
1541
  * @param cam3D - Camera used for projection to canvas coordinates.
@@ -1481,6 +1576,7 @@ export declare class Obj3D {
1481
1576
  type: TType;
1482
1577
  }>) => void): void;
1483
1578
  private resetEventState;
1579
+ private updVisible;
1484
1580
  }
1485
1581
 
1486
1582
  /** Object events available to registered listeners. */
@@ -1648,7 +1744,7 @@ export declare interface OrbitCtrlsCfg {
1648
1744
  */
1649
1745
  load: boolean;
1650
1746
  /**
1651
- * Maximum allowed horizontal orbit angle in degrees.
1747
+ * Maximum allowed horizontal orbit angle in radians.
1652
1748
  * @default Infinity
1653
1749
  */
1654
1750
  maxAzimuthAngle: number;
@@ -1658,12 +1754,12 @@ export declare interface OrbitCtrlsCfg {
1658
1754
  */
1659
1755
  maxDistance: number;
1660
1756
  /**
1661
- * Maximum allowed vertical orbit angle in degrees.
1662
- * @default 180
1757
+ * Maximum allowed vertical orbit angle in radians.
1758
+ * @default Math.PI
1663
1759
  */
1664
1760
  maxPolarAngle: number;
1665
1761
  /**
1666
- * Minimum allowed horizontal orbit angle in degrees.
1762
+ * Minimum allowed horizontal orbit angle in radians.
1667
1763
  * @default -Infinity
1668
1764
  */
1669
1765
  minAzimuthAngle: number;
@@ -1673,7 +1769,7 @@ export declare interface OrbitCtrlsCfg {
1673
1769
  */
1674
1770
  minDistance: number;
1675
1771
  /**
1676
- * Minimum allowed vertical orbit angle in degrees.
1772
+ * Minimum allowed vertical orbit angle in radians.
1677
1773
  * @default 0
1678
1774
  */
1679
1775
  minPolarAngle: number;
@@ -1743,6 +1839,8 @@ export declare interface ProgressBarHiddenEvent {
1743
1839
  type: 'ProgressBar_Hidden';
1744
1840
  }
1745
1841
 
1842
+ export { radToDeg }
1843
+
1746
1844
  /**
1747
1845
  * Manages collider-based occlusion and pointer picking in a `THREE.Scene`. Collider roles determine which objects block rays, emit pointer events, or remain hidden while participating in raycasting.
1748
1846
  * @category Core
@@ -2144,44 +2242,83 @@ export declare class Scene {
2144
2242
  [key: string]: any;
2145
2243
  }): void;
2146
2244
  /**
2147
- * Animates selected local position, rotation, and scale components from their current values.
2148
- * @param params - Target object and transformation settings.
2245
+ * Animates orientation from its current value using Euler angles in radians.
2246
+ * @param params - Target object, orientation, and animation settings.
2149
2247
  * @param params.obj - Scene object name or component, including cameras.
2150
- * @param params.pos - Target local position; omitted axes remain unchanged.
2151
- * @param params.rot - Target local Euler angles in degrees, using the object's Euler order.
2152
- * @param params.scale - Target local scale; omitted axes remain unchanged.
2248
+ * @param params.x - Target X angle in radians; omitted axes keep their starting target angles.
2249
+ * @param params.y - Target Y angle in radians.
2250
+ * @param params.z - Target Z angle in radians.
2251
+ * @param params.path - Rotation interpolation. Default: **'euler'**; **'quat'** takes the shortest orientation path.
2252
+ * @param params.order - Euler order for interpreting angles in both paths. Default: **'XYZ'**
2253
+ * @param params.space - Orientation space. Default: **'parent'**
2153
2254
  * @param params.time - Duration in seconds. Default: **1**. A value of 0 applies the values immediately.
2154
2255
  * @param params.ease - GSAP easing function. Default: **'power2.inOut'**
2155
- *
2156
2256
  * @remarks
2157
- * Rotation uses quaternion interpolation along the shortest path and does not support full turns.
2158
- * Omitted rotation axes keep their current target angles, but may change during interpolation.
2257
+ * Euler interpolation supports full turns. Each call starts from the current orientation without retaining previous turns.
2258
+ * Quaternion interpolation takes the shortest path; omitted Euler axes may change during interpolation.
2259
+ * World targets account for moving parents. The caller is responsible for non-uniform parent scaling.
2159
2260
  * Cameras switch to free look mode. The caller coordinates other animations and controls.
2160
- * A new call cancels the entire previous transformation of the same object.
2261
+ * A new call cancels only the previous orientation animation of the same object.
2161
2262
  * Emits {@link AnimEvent}: `Anim_Start`, `Anim_Complete`, or `Anim_Cancel` when replaced.
2162
2263
  */
2163
- animTransformTo({ obj, pos, rot, scale, time, ease }: {
2264
+ animRotTo({ obj, x, y, z, path, order, space, time, ease }: {
2164
2265
  obj: string | Obj3D;
2165
- pos?: {
2166
- x?: number;
2167
- y?: number;
2168
- z?: number;
2169
- };
2170
- rot?: {
2171
- x?: number;
2172
- y?: number;
2173
- z?: number;
2174
- };
2175
- scale?: {
2176
- x?: number;
2177
- y?: number;
2178
- z?: number;
2179
- };
2266
+ x?: number;
2267
+ y?: number;
2268
+ z?: number;
2269
+ path?: 'euler' | 'quat';
2270
+ order?: THREE_TYPE.EulerOrder;
2271
+ space?: 'parent' | 'world';
2272
+ time?: number;
2273
+ ease?: string;
2274
+ }): void;
2275
+ /**
2276
+ * Animates selected local scale axes from their current values.
2277
+ * @param params - Target object, scale, and animation settings.
2278
+ * @param params.obj - Scene object name or component, including cameras.
2279
+ * @param params.x - Target X scale; omitted axes remain unchanged.
2280
+ * @param params.y - Target Y scale.
2281
+ * @param params.z - Target Z scale.
2282
+ * @param params.time - Duration in seconds. Default: **1**. A value of 0 applies the values immediately.
2283
+ * @param params.ease - GSAP easing function. Default: **'power2.inOut'**
2284
+ * @remarks
2285
+ * A new call cancels only the previous scale animation of the same object.
2286
+ * Emits {@link AnimEvent}: `Anim_Start`, `Anim_Complete`, or `Anim_Cancel` when replaced.
2287
+ */
2288
+ animScaleTo({ obj, x, y, z, time, ease }: {
2289
+ obj: string | Obj3D;
2290
+ x?: number;
2291
+ y?: number;
2292
+ z?: number;
2293
+ time?: number;
2294
+ ease?: string;
2295
+ }): void;
2296
+ /**
2297
+ * Animates selected position axes from their current values in parent or world space.
2298
+ * @param params - Target object, position, and animation settings.
2299
+ * @param params.obj - Scene object name or component, including cameras.
2300
+ * @param params.x - Target X position; omitted axes keep their starting values.
2301
+ * @param params.y - Target Y position.
2302
+ * @param params.z - Target Z position.
2303
+ * @param params.space - Position space. Default: **'parent'**
2304
+ * @param params.time - Duration in seconds. Default: **1**. A value of 0 applies the values immediately.
2305
+ * @param params.ease - GSAP easing function. Default: **'power2.inOut'**
2306
+ * @remarks
2307
+ * World targets account for moving parents. Cameras switch to free look mode.
2308
+ * A new call cancels only the previous position animation of the same object.
2309
+ * Emits {@link AnimEvent}: `Anim_Start`, `Anim_Complete`, or `Anim_Cancel` when replaced.
2310
+ */
2311
+ animTranslTo({ obj, x, y, z, space, time, ease }: {
2312
+ obj: string | Obj3D;
2313
+ x?: number;
2314
+ y?: number;
2315
+ z?: number;
2316
+ space?: 'parent' | 'world';
2180
2317
  time?: number;
2181
2318
  ease?: string;
2182
2319
  }): void;
2183
2320
  private getMtrls;
2184
- private getObjectName;
2321
+ private getObj;
2185
2322
  /**
2186
2323
  * Plays a named animation clip with blending, looping, and speed control.
2187
2324
  *