@needle-tools/engine 4.11.1 → 4.11.3-next.2d2dff8

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.
Files changed (100) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/{needle-engine.bundle-6yF8G5KJ.js → needle-engine.bundle-Buwrv7Cc.js} +980 -956
  3. package/dist/{needle-engine.bundle-BSk8yk3v.min.js → needle-engine.bundle-CMdUN8y6.min.js} +93 -93
  4. package/dist/{needle-engine.bundle-DPVYipMl.umd.cjs → needle-engine.bundle-GysGCdkn.umd.cjs} +82 -82
  5. package/dist/needle-engine.js +2 -2
  6. package/dist/needle-engine.min.js +1 -1
  7. package/dist/needle-engine.umd.cjs +1 -1
  8. package/dist/rapier-BqdcSmKY.umd.cjs +1 -0
  9. package/dist/rapier-Cg3w3nFI.min.js +1 -0
  10. package/dist/rapier-sU12SWAs.js +5217 -0
  11. package/dist/{vendor-DWGd3dEf.min.js → vendor-BahM12Xj.min.js} +1 -1
  12. package/dist/{vendor-DJBpoQcM.js → vendor-Becub4o1.js} +1 -1
  13. package/dist/{vendor-CAWj5cBK.umd.cjs → vendor-H-9KkM5B.umd.cjs} +1 -1
  14. package/lib/engine-components/Animation.d.ts +2 -2
  15. package/lib/engine-components/Animation.js +3 -3
  16. package/lib/engine-components/Animation.js.map +1 -1
  17. package/lib/engine-components/AnimationCurve.d.ts +3 -0
  18. package/lib/engine-components/AnimationCurve.js +3 -0
  19. package/lib/engine-components/AnimationCurve.js.map +1 -1
  20. package/lib/engine-components/Animator.d.ts +2 -1
  21. package/lib/engine-components/Animator.js +2 -1
  22. package/lib/engine-components/Animator.js.map +1 -1
  23. package/lib/engine-components/AnimatorController.d.ts +3 -0
  24. package/lib/engine-components/AnimatorController.js +3 -0
  25. package/lib/engine-components/AnimatorController.js.map +1 -1
  26. package/lib/engine-components/LookAtConstraint.d.ts +4 -0
  27. package/lib/engine-components/LookAtConstraint.js +4 -0
  28. package/lib/engine-components/LookAtConstraint.js.map +1 -1
  29. package/lib/engine-components/NeedleMenu.d.ts +1 -0
  30. package/lib/engine-components/NeedleMenu.js +1 -0
  31. package/lib/engine-components/NeedleMenu.js.map +1 -1
  32. package/lib/engine-components/NestedGltf.d.ts +3 -0
  33. package/lib/engine-components/NestedGltf.js +3 -0
  34. package/lib/engine-components/NestedGltf.js.map +1 -1
  35. package/lib/engine-components/ReflectionProbe.d.ts +4 -0
  36. package/lib/engine-components/ReflectionProbe.js +4 -0
  37. package/lib/engine-components/ReflectionProbe.js.map +1 -1
  38. package/lib/engine-components/RendererLightmap.d.ts +6 -0
  39. package/lib/engine-components/RendererLightmap.js +6 -3
  40. package/lib/engine-components/RendererLightmap.js.map +1 -1
  41. package/lib/engine-components/SeeThrough.d.ts +3 -0
  42. package/lib/engine-components/SeeThrough.js +8 -1
  43. package/lib/engine-components/SeeThrough.js.map +1 -1
  44. package/lib/engine-components/Skybox.d.ts +3 -0
  45. package/lib/engine-components/Skybox.js +3 -0
  46. package/lib/engine-components/Skybox.js.map +1 -1
  47. package/lib/engine-components/SpriteRenderer.d.ts +14 -1
  48. package/lib/engine-components/SpriteRenderer.js +17 -1
  49. package/lib/engine-components/SpriteRenderer.js.map +1 -1
  50. package/lib/engine-components/export/usdz/ThreeUSDZExporter.d.ts +5 -5
  51. package/lib/engine-components/export/usdz/ThreeUSDZExporter.js +16 -13
  52. package/lib/engine-components/export/usdz/ThreeUSDZExporter.js.map +1 -1
  53. package/lib/engine-components/export/usdz/USDZExporter.js +0 -1
  54. package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
  55. package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.d.ts +8 -0
  56. package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js +24 -0
  57. package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js.map +1 -1
  58. package/lib/engine-components/splines/Spline.d.ts +3 -0
  59. package/lib/engine-components/splines/Spline.js +3 -0
  60. package/lib/engine-components/splines/Spline.js.map +1 -1
  61. package/lib/engine-components/splines/SplineUtils.d.ts +3 -0
  62. package/lib/engine-components/splines/SplineUtils.js +3 -0
  63. package/lib/engine-components/splines/SplineUtils.js.map +1 -1
  64. package/lib/engine-components/splines/SplineWalker.d.ts +3 -0
  65. package/lib/engine-components/splines/SplineWalker.js +6 -2
  66. package/lib/engine-components/splines/SplineWalker.js.map +1 -1
  67. package/lib/engine-components/timeline/SignalAsset.d.ts +11 -1
  68. package/lib/engine-components/timeline/SignalAsset.js +11 -1
  69. package/lib/engine-components/timeline/SignalAsset.js.map +1 -1
  70. package/lib/engine-components/ui/Raycaster.d.ts +18 -0
  71. package/lib/engine-components/ui/Raycaster.js +18 -0
  72. package/lib/engine-components/ui/Raycaster.js.map +1 -1
  73. package/lib/engine-components/web/Clickthrough.js.map +1 -1
  74. package/package.json +3 -3
  75. package/plugins/types/userconfig.d.ts +7 -0
  76. package/plugins/vite/build-pipeline.js +15 -7
  77. package/src/engine-components/Animation.ts +4 -3
  78. package/src/engine-components/AnimationCurve.ts +4 -1
  79. package/src/engine-components/Animator.ts +3 -2
  80. package/src/engine-components/AnimatorController.ts +3 -0
  81. package/src/engine-components/LookAtConstraint.ts +6 -1
  82. package/src/engine-components/NeedleMenu.ts +1 -0
  83. package/src/engine-components/NestedGltf.ts +3 -0
  84. package/src/engine-components/ReflectionProbe.ts +4 -0
  85. package/src/engine-components/RendererLightmap.ts +7 -3
  86. package/src/engine-components/SeeThrough.ts +8 -1
  87. package/src/engine-components/Skybox.ts +3 -0
  88. package/src/engine-components/SpriteRenderer.ts +18 -2
  89. package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +27 -15
  90. package/src/engine-components/export/usdz/USDZExporter.ts +0 -1
  91. package/src/engine-components/export/usdz/extensions/behavior/BehaviourComponents.ts +28 -0
  92. package/src/engine-components/splines/Spline.ts +3 -0
  93. package/src/engine-components/splines/SplineUtils.ts +3 -1
  94. package/src/engine-components/splines/SplineWalker.ts +6 -2
  95. package/src/engine-components/timeline/SignalAsset.ts +13 -2
  96. package/src/engine-components/ui/Raycaster.ts +19 -0
  97. package/src/engine-components/web/Clickthrough.ts +1 -0
  98. package/dist/rapier-BIeDFw5K.umd.cjs +0 -1
  99. package/dist/rapier-DQM98oaj.min.js +0 -1
  100. package/dist/rapier-DpcIWXum.js +0 -5217
@@ -58,7 +58,7 @@ declare type AnimationIdentifier = AnimationClip | number | string | undefined;
58
58
  class Vec2 { x!: number; y!: number }
59
59
 
60
60
  /**
61
- * Animation component to play animations on a GameObject
61
+ * Animation component to play animations on a GameObject.
62
62
  * @category Animation and Sequencing
63
63
  * @group Components
64
64
  */
@@ -78,10 +78,10 @@ export class Animation extends Behaviour implements IAnimationComponent {
78
78
 
79
79
  /**
80
80
  * If true, the animation will start at a random time. This is used when the animation component is enabled
81
- * @default true
81
+ * @default false
82
82
  */
83
83
  @serializable()
84
- randomStartTime: boolean = true;
84
+ randomStartTime: boolean = false;
85
85
 
86
86
  /**
87
87
  * The animation min-max speed range
@@ -449,6 +449,7 @@ export class Animation extends Behaviour implements IAnimationComponent {
449
449
  action.time = 0;
450
450
  }
451
451
 
452
+
452
453
  // Apply speed
453
454
  if (options?.minMaxSpeed) {
454
455
  action.timeScale = Mathf.lerp(options.minMaxSpeed.x, options.minMaxSpeed.y, Math.random());
@@ -27,7 +27,10 @@ export class Keyframe {
27
27
  }
28
28
 
29
29
  /**
30
- * AnimationCurve is a representation of a curve that can be used to animate values over time.
30
+ * AnimationCurve is a representation of a curve that can be used to animate values over time.
31
+ *
32
+ * @category Animation
33
+ * @group Utilities
31
34
  */
32
35
  export class AnimationCurve {
33
36
 
@@ -39,8 +39,9 @@ export declare class PlayOptions {
39
39
 
40
40
  /**
41
41
  * The Animator component plays and manages animations on a GameObject.
42
- * It works with an AnimatorController to handle state transitions and animation blending.
43
- * A new AnimatorController can be created from code via `AnimatorController.createFromClips`.
42
+ * It works with an {@link AnimatorController} to handle state transitions and animation blending.
43
+ * A new AnimatorController can be created from code via `AnimatorController.createFromClips`.
44
+ *
44
45
  * @category Animation and Sequencing
45
46
  * @group Components
46
47
  */
@@ -51,6 +51,9 @@ declare type CreateAnimatorControllerOptions = {
51
51
  *
52
52
  * Use the static method {@link AnimatorController.createFromClips} to create
53
53
  * an animator controller from a set of animation clips.
54
+ *
55
+ * @category Animation and Sequencing
56
+ * @group Utilities
54
57
  */
55
58
  export class AnimatorController {
56
59
 
@@ -2,9 +2,14 @@ import { Object3D, Vector3 } from "three";
2
2
 
3
3
  import { serializable } from "../engine/engine_serialization_decorator.js";
4
4
  import { Behaviour } from "./Component.js";
5
+ import type { OrbitControls } from "./OrbitControls.js";
5
6
 
6
7
  /**
7
- * A LookAtConstraint is used by OrbitControls to make the camera look at a target.
8
+ * A LookAtConstraint is used by OrbitControls to make the camera look at a target.
9
+ * This component is used by {@link OrbitControls} internally.
10
+ *
11
+ * @category Camera Controls
12
+ * @group Components
8
13
  */
9
14
  export class LookAtConstraint extends Behaviour {
10
15
 
@@ -9,6 +9,7 @@ import { Behaviour } from './Component.js';
9
9
  *
10
10
  * Controls display options, button visibility, and menu positioning.
11
11
  * From code, you can access the menu via {@link Context.menu}.
12
+ *
12
13
  * @category User Interface
13
14
  * @group Components
14
15
  **/
@@ -10,6 +10,9 @@ const debug = getParam("debugnestedgltf");
10
10
 
11
11
  /** The nested gltf is a component that is used to load a gltf file when the component becomes active (start)
12
12
  * It will load the gltf file and instantiate it as a child of the parent of the GameObject that has this component
13
+ *
14
+ * @category Asset Management
15
+ * @group Components
13
16
  */
14
17
  export class NestedGltf extends Behaviour {
15
18
 
@@ -15,6 +15,10 @@ const $reflectionProbeKey = Symbol("reflectionProbeKey");
15
15
  const $originalMaterial = Symbol("original material");
16
16
 
17
17
  /**
18
+ * A ReflectionProbe provides reflection data to materials within its defined area.
19
+ *
20
+ * - Sample: http://samples.needle.tools/reflection-probes
21
+ *
18
22
  * @category Rendering
19
23
  * @group Components
20
24
  */
@@ -9,9 +9,13 @@ const debug = getParam("debuglightmaps");
9
9
 
10
10
  declare type MaterialWithLightmap = Material & { lightMap?: Texture | null };
11
11
 
12
- // this component is automatically added by the Renderer if the object has lightmap uvs AND we have a lightmap
13
- // for multimaterial objects GLTF exports a "Group" with the renderer component
14
- // and every child mesh is a material from unity
12
+
13
+ /**
14
+ * This component is automatically added by the {@link Renderer} component if the object has lightmap uvs AND we have a lightmap.
15
+ *
16
+ * @category Rendering
17
+ * @group Components
18
+ */
15
19
  export class RendererLightmap {
16
20
 
17
21
  get lightmap(): Texture | null {
@@ -39,6 +39,9 @@ let i = 0;
39
39
  * Requires a Renderer component on the same object or a child object.
40
40
  *
41
41
  * - Example https://see-through-walls-z23hmxbz1kjfjn.needle.run/
42
+ *
43
+ * @category Rendering
44
+ * @group Components
42
45
  */
43
46
  export class SeeThrough extends Behaviour {
44
47
 
@@ -241,6 +244,7 @@ export class SeeThrough extends Behaviour {
241
244
 
242
245
  const wasTransparent = mat.transparent;
243
246
  const wasAlphaHash = mat.alphaHash;
247
+ const previousOpacity = mat.opacity;
244
248
 
245
249
  mat.alphaHash = this.useAlphaHash;
246
250
 
@@ -253,7 +257,10 @@ export class SeeThrough extends Behaviour {
253
257
  mat.transparent = mat.opacity >= 1 ? false : !this.useAlphaHash;
254
258
  }
255
259
 
256
- if (wasTransparent != mat.transparent || wasAlphaHash != mat.alphaHash) {
260
+ if (wasTransparent !== mat.transparent
261
+ || wasAlphaHash !== mat.alphaHash
262
+ || mat.opacity !== previousOpacity // MeshPhysicsMaterial needs that and maybe other materials too...
263
+ ) {
257
264
  mat.needsUpdate = true;
258
265
  }
259
266
  }
@@ -120,6 +120,9 @@ ContextRegistry.registerCallback(ContextEvent.ContextCreationStart, () => {
120
120
  * ```ts
121
121
  * skybox.setSkybox("https://example.com/skybox.hdr");
122
122
  * ```
123
+ *
124
+ * @category Rendering
125
+ * @group Components
123
126
  */
124
127
  export class RemoteSkybox extends Behaviour {
125
128
 
@@ -9,6 +9,9 @@ import { Behaviour } from "./Component.js";
9
9
  const debug = getParam("debugspriterenderer");
10
10
  const showWireframe = getParam("wireframe");
11
11
 
12
+ /**
13
+ * @internal
14
+ */
12
15
  class SpriteUtils {
13
16
 
14
17
  static cache: { [key: string]: BufferGeometry } = {};
@@ -82,7 +85,7 @@ function updateTextureIfNecessary(tex: Texture) {
82
85
  }
83
86
 
84
87
  /**
85
- * A sprite is a mesh that represents a 2D image
88
+ * A sprite is a mesh that represents a 2D image. Used by the {@link SpriteRenderer} to render 2D images in the scene.
86
89
  * @category Rendering
87
90
  * @group Components
88
91
  */
@@ -152,6 +155,9 @@ export class Sprite {
152
155
 
153
156
  const $spriteTexOwner = Symbol("spriteOwner");
154
157
 
158
+ /**
159
+ * @category Sprites
160
+ */
155
161
  export class SpriteSheet {
156
162
 
157
163
  @serializable(Sprite)
@@ -162,6 +168,11 @@ export class SpriteSheet {
162
168
  }
163
169
  }
164
170
 
171
+ /**
172
+ * Used by the {@link SpriteRenderer} to hold the sprite sheet and the currently active sprite index.
173
+ *
174
+ * @category Sprites
175
+ */
165
176
  export class SpriteData {
166
177
 
167
178
  static create() {
@@ -246,7 +257,12 @@ export class SpriteData {
246
257
  }
247
258
 
248
259
  /**
249
- * The sprite renderer renders a sprite on a GameObject using an assigned spritesheet ({@link SpriteData}).
260
+ * The sprite renderer renders a sprite on a GameObject using an assigned spritesheet ({@link SpriteData}).
261
+ *
262
+ * - Example: https://engine.needle.tools/samples/spritesheet-animation
263
+ *
264
+ * @category Sprites
265
+ * @group Components
250
266
  */
251
267
  export class SpriteRenderer extends Behaviour {
252
268
 
@@ -39,9 +39,10 @@ import * as fflate from 'three/examples/jsm/libs/fflate.module.js';
39
39
  import { VERSION } from "../../../engine/engine_constants.js";
40
40
  import type { OffscreenCanvasExt } from '../../../engine/engine_shims.js';
41
41
  import { Progress } from '../../../engine/engine_time_utils.js';
42
- import { BehaviorExtension } from '../../api.js';
42
+ // import { BehaviorExtension } from '../../api.js';
43
43
  import type { IUSDExporterExtension } from './Extension.js';
44
44
  import type { AnimationExtension } from './extensions/Animation.js';
45
+ import { BehaviorExtension } from './extensions/behavior/Behaviour.js';
45
46
  import type { PhysicsExtension } from './extensions/behavior/PhysicsExtension.js';
46
47
  import {buildNodeMaterial} from './extensions/NodeMaterialConverter.js';
47
48
 
@@ -622,13 +623,13 @@ class USDZExporterContext {
622
623
  output: string;
623
624
  animations: AnimationClip[];
624
625
 
625
- constructor( root: Object3D | undefined, exporter: USDZExporter, options: {
626
+ constructor( root: Object3D | null | undefined, exporter: USDZExporter, options: {
626
627
  extensions?: Array<IUSDExporterExtension>,
627
628
  quickLookCompatible: boolean,
628
629
  exportInvisible: boolean,
629
630
  } ) {
630
631
 
631
- this.root = root;
632
+ this.root = root || undefined;
632
633
  this.exporter = exporter;
633
634
  this.quickLookCompatible = options.quickLookCompatible;
634
635
  this.exportInvisible = options.exportInvisible;
@@ -656,18 +657,28 @@ export type Anchoring = "plane" | "image" | "face" | "none"
656
657
  /**[documentation](https://developer.apple.com/documentation/arkit/usdz_schemas_for_ar/preliminary_anchoringapi/preliminary_planeanchoring_alignment) */
657
658
  export type Alignment = "horizontal" | "vertical" | "any";
658
659
 
659
- class USDZExporterOptions {
660
+ type USDZExporterOptions = {
660
661
  ar: {
661
662
  anchoring: { type: Anchoring },
662
663
  planeAnchoring: { alignment: Alignment },
663
- } = {
664
- anchoring: { type: 'plane' },
665
- planeAnchoring: { alignment: 'horizontal' }
666
- };
667
- quickLookCompatible: boolean = false;
668
- extensions: any[] = [];
669
- maxTextureSize: number = 4096;
670
- exportInvisible: boolean = false;
664
+ }
665
+ quickLookCompatible: boolean;
666
+ extensions: Array<IUSDExporterExtension>;
667
+ maxTextureSize: number;
668
+ exportInvisible: boolean;
669
+ }
670
+
671
+ const getDefaultExporterOptions : () => USDZExporterOptions = () => {
672
+ return {
673
+ ar: {
674
+ anchoring: { type: 'plane' },
675
+ planeAnchoring: { alignment: 'horizontal' }
676
+ },
677
+ quickLookCompatible: false,
678
+ extensions: [],
679
+ maxTextureSize: 4096,
680
+ exportInvisible: false
681
+ }
671
682
  }
672
683
 
673
684
  // #region USDZExporter
@@ -675,7 +686,7 @@ class USDZExporterOptions {
675
686
  class USDZExporter {
676
687
  debug: boolean;
677
688
  pruneUnusedNodes: boolean;
678
- sceneAnchoringOptions: USDZExporterOptions = new USDZExporterOptions();
689
+ sceneAnchoringOptions: USDZExporterOptions = getDefaultExporterOptions();
679
690
  extensions: Array<IUSDExporterExtension> = [];
680
691
  keepObject?: (object: Object3D) => boolean;
681
692
  beforeWritingDocument?: () => void;
@@ -687,9 +698,10 @@ class USDZExporter {
687
698
 
688
699
  }
689
700
 
690
- async parse(scene: Object3D | undefined, options: USDZExporterOptions = new USDZExporterOptions()) {
701
+ async parse(scene: Object3D | null | undefined, options: USDZExporterOptions = getDefaultExporterOptions()) {
691
702
 
692
- options = Object.assign( new USDZExporterOptions(), options );
703
+ // clone options to avoid modifying the original object
704
+ options = Object.assign({}, options );
693
705
 
694
706
  this.sceneAnchoringOptions = options;
695
707
  const context = new USDZExporterContext( scene, this, options );
@@ -483,7 +483,6 @@ export class USDZExporter extends Behaviour {
483
483
 
484
484
  Progress.report("export-usdz", "Invoking exporter.parse");
485
485
 
486
- //@ts-ignore
487
486
  const arraybuffer = await exporter.parse(this.objectToExport, {
488
487
  ar: {
489
488
  anchoring: {
@@ -58,6 +58,13 @@ export class ChangeTransformOnClick extends Behaviour implements IPointerClickHa
58
58
  ensureRaycaster(this.gameObject);
59
59
  }
60
60
 
61
+ onPointerEnter() {
62
+ this.context.input.setCursor("pointer");
63
+ }
64
+ onPointerExit() {
65
+ this.context.input.unsetCursor("pointer");
66
+ }
67
+
61
68
  onPointerClick(args: PointerEventData) {
62
69
  args.use();
63
70
  if (this.coroutine) this.stopCoroutine(this.coroutine);
@@ -380,6 +387,13 @@ export class SetActiveOnClick extends Behaviour implements IPointerClickHandler,
380
387
  ensureRaycaster(this.gameObject);
381
388
  }
382
389
 
390
+ onPointerEnter() {
391
+ this.context.input.setCursor("pointer");
392
+ }
393
+ onPointerExit() {
394
+ this.context.input.unsetCursor("pointer");
395
+ }
396
+
383
397
  onPointerClick(args: PointerEventData) {
384
398
  args.use();
385
399
 
@@ -703,6 +717,13 @@ export class PlayAudioOnClick extends Behaviour implements IPointerClickHandler,
703
717
  }
704
718
  }
705
719
 
720
+
721
+ onPointerEnter() {
722
+ this.context.input.setCursor("pointer");
723
+ }
724
+ onPointerExit() {
725
+ this.context.input.unsetCursor("pointer");
726
+ }
706
727
  onPointerClick(args: PointerEventData) {
707
728
  args.use();
708
729
 
@@ -810,6 +831,13 @@ export class PlayAnimationOnClick extends Behaviour implements IPointerClickHand
810
831
  ensureRaycaster(this.gameObject);
811
832
  }
812
833
 
834
+
835
+ onPointerEnter() {
836
+ this.context.input.setCursor("pointer");
837
+ }
838
+ onPointerExit() {
839
+ this.context.input.unsetCursor("pointer");
840
+ }
813
841
  onPointerClick(args: PointerEventData) {
814
842
  args.use();
815
843
  if (!this.target) return;
@@ -36,6 +36,9 @@ export class SplineData {
36
36
  * The spline is defined by an array of knots (SplineData) which define position, rotation and tangents.
37
37
  *
38
38
  * You can create a SplineContainer from an array of points using the static method 'createFromPoints'.
39
+ *
40
+ * @category Splines
41
+ * @group Components
39
42
  */
40
43
  export class SplineContainer extends Behaviour {
41
44
 
@@ -3,7 +3,9 @@ import { Vector3 } from "three";
3
3
  import { Mathf } from "../../engine/engine_math.js";
4
4
  import { SplineContainer, SplineData } from "./Spline.js";
5
5
 
6
-
6
+ /**
7
+ * @category Splines
8
+ */
7
9
  export namespace SplineUtils {
8
10
 
9
11
  /**
@@ -11,6 +11,9 @@ import { SplineContainer } from "./Spline.js";
11
11
  * Use this with a SplineContainer component.
12
12
  *
13
13
  * - Example http://samples.needle.tools/splines
14
+ *
15
+ * @category Splines
16
+ * @group Components
14
17
  */
15
18
  export class SplineWalker extends Behaviour {
16
19
 
@@ -114,12 +117,13 @@ export class SplineWalker extends Behaviour {
114
117
  /** @internal */
115
118
  onEnable(): void {
116
119
  window.addEventListener("pointerdown", this.onUserInput, { passive: true });
117
- window.addEventListener("wheel", this.onUserInput, { passive: true });
120
+ // TODO: wheel event is also triggered for touch and it interrupts spline pull if it's an actual site scroll
121
+ this.context.domElement.addEventListener("wheel", this.onUserInput, { passive: true });
118
122
  }
119
123
  /** @internal */
120
124
  onDisable(): void {
121
125
  window.removeEventListener("pointerdown", this.onUserInput);
122
- window.removeEventListener("wheel", this.onUserInput);
126
+ this.context.domElement.removeEventListener("wheel", this.onUserInput);
123
127
  }
124
128
  private onUserInput = () => {
125
129
  if (this.object?.contains(this.context.mainCamera)) {
@@ -2,15 +2,23 @@ import { serializable } from "../../engine/engine_serialization_decorator.js";
2
2
  import { getParam } from "../../engine/engine_utils.js";
3
3
  import { Behaviour } from "../Component.js";
4
4
  import { EventList } from "../EventList.js";
5
+ import type { PlayableDirector } from "./PlayableDirector.js";
5
6
 
6
7
  const debug = getParam("debugsignals")
7
8
 
8
9
 
10
+ /**
11
+ * Used to reference a signal asset in a SignalReceiver. This is internally used by the {@link SignalReceiverEvent}.
12
+ */
9
13
  export class SignalAsset {
10
14
  @serializable()
11
15
  guid!: string;
12
16
  }
13
17
 
18
+ /**
19
+ * An event that links a signal to a reaction.
20
+ * Used internally by {@link SignalReceiver}.
21
+ */
14
22
  export class SignalReceiverEvent {
15
23
  @serializable(SignalAsset)
16
24
  signal!: SignalAsset;
@@ -19,7 +27,10 @@ export class SignalReceiverEvent {
19
27
  }
20
28
 
21
29
  /** SignalReceiver is a component that listens for signals and invokes a reaction when a signal is received.
22
- * Signals can be added to a signal track on a timeline
30
+ * Signals can be added to a signal track on a {@link PlayableDirector}
31
+ *
32
+ * @category Sequencing and Timelines
33
+ * @group Components
23
34
  */
24
35
  export class SignalReceiver extends Behaviour {
25
36
 
@@ -41,7 +52,7 @@ export class SignalReceiver extends Behaviour {
41
52
 
42
53
  /** @internal */
43
54
  awake(): void {
44
- if(debug) console.log("SignalReceiver awake", this);
55
+ if (debug) console.log("SignalReceiver awake", this);
45
56
  }
46
57
 
47
58
  /** @internal */
@@ -28,6 +28,12 @@ export abstract class Raycaster extends Behaviour {
28
28
  }
29
29
 
30
30
 
31
+ /**
32
+ * A Raycaster that performs raycasting against its own GameObject.
33
+ *
34
+ * @category Interaction
35
+ * @group Components
36
+ */
31
37
  export class ObjectRaycaster extends Raycaster {
32
38
  private targets: Object3D[] | null = null;
33
39
  private raycastHits: Intersection[] = [];
@@ -65,6 +71,13 @@ export class ObjectRaycaster extends Raycaster {
65
71
  }
66
72
  }
67
73
 
74
+
75
+ /**
76
+ * A Raycaster that performs raycasting against UI elements (objects with a CanvasRenderer component).
77
+ *
78
+ * @category UI
79
+ * @group Components
80
+ */
68
81
  export class GraphicRaycaster extends ObjectRaycaster {
69
82
  // eventCamera: Camera | null = null;
70
83
  // ignoreReversedGraphics: boolean = false;
@@ -76,6 +89,12 @@ export class GraphicRaycaster extends ObjectRaycaster {
76
89
  }
77
90
  }
78
91
 
92
+ /**
93
+ * A Raycaster that performs sphere overlap raycasting for spatial grab interactions in XR.
94
+ *
95
+ * @category XR
96
+ * @group Components
97
+ */
79
98
  export class SpatialGrabRaycaster extends Raycaster {
80
99
 
81
100
  /**
@@ -1,4 +1,5 @@
1
1
  import { Vector2 } from "three";
2
+
2
3
  import { NEPointerEvent } from "../../engine/engine_input.js";
3
4
  import { onStart } from "../../engine/engine_lifecycle_api.js";
4
5
  import { addAttributeChangeCallback } from "../../engine/engine_utils.js";