@needle-tools/engine 3.19.2 → 3.19.4

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 (44) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/needle-engine.js +8937 -8894
  3. package/dist/needle-engine.light.js +8639 -8596
  4. package/dist/needle-engine.light.min.js +183 -183
  5. package/dist/needle-engine.light.umd.cjs +188 -188
  6. package/dist/needle-engine.min.js +184 -184
  7. package/dist/needle-engine.umd.cjs +189 -189
  8. package/lib/engine/extensions/NEEDLE_progressive.js +14 -12
  9. package/lib/engine/extensions/NEEDLE_progressive.js.map +1 -1
  10. package/lib/engine-components/Animation.js +6 -6
  11. package/lib/engine-components/Animation.js.map +1 -1
  12. package/lib/engine-components/Collider.d.ts +2 -0
  13. package/lib/engine-components/Collider.js +4 -0
  14. package/lib/engine-components/Collider.js.map +1 -1
  15. package/lib/engine-components/Interactable.js +0 -1
  16. package/lib/engine-components/Interactable.js.map +1 -1
  17. package/lib/engine-components/OrbitControls.d.ts +11 -1
  18. package/lib/engine-components/OrbitControls.js +53 -3
  19. package/lib/engine-components/OrbitControls.js.map +1 -1
  20. package/lib/engine-components/Renderer.js +4 -1
  21. package/lib/engine-components/Renderer.js.map +1 -1
  22. package/lib/engine-components/VideoPlayer.d.ts +1 -2
  23. package/lib/engine-components/VideoPlayer.js +9 -7
  24. package/lib/engine-components/VideoPlayer.js.map +1 -1
  25. package/lib/engine-components/timeline/PlayableDirector.js +50 -36
  26. package/lib/engine-components/timeline/PlayableDirector.js.map +1 -1
  27. package/lib/engine-components/timeline/TimelineModels.d.ts +2 -2
  28. package/lib/engine-components/webxr/WebARSessionRoot.js +2 -2
  29. package/lib/engine-components/webxr/WebARSessionRoot.js.map +1 -1
  30. package/lib/engine-components/webxr/WebXRController.d.ts +0 -1
  31. package/lib/engine-components/webxr/WebXRController.js +0 -14
  32. package/lib/engine-components/webxr/WebXRController.js.map +1 -1
  33. package/package.json +1 -1
  34. package/src/engine/extensions/NEEDLE_progressive.ts +14 -12
  35. package/src/engine-components/Animation.ts +5 -4
  36. package/src/engine-components/Collider.ts +5 -0
  37. package/src/engine-components/Interactable.ts +1 -10
  38. package/src/engine-components/OrbitControls.ts +29 -3
  39. package/src/engine-components/Renderer.ts +4 -1
  40. package/src/engine-components/VideoPlayer.ts +7 -5
  41. package/src/engine-components/timeline/PlayableDirector.ts +48 -34
  42. package/src/engine-components/timeline/TimelineModels.ts +2 -2
  43. package/src/engine-components/webxr/WebARSessionRoot.ts +2 -2
  44. package/src/engine-components/webxr/WebXRController.ts +1141 -1156
@@ -325,9 +325,11 @@ export class PlayableDirector extends Behaviour {
325
325
  const binding = track.outputs[i];
326
326
  if (typeof binding === "object") {
327
327
  let isActive: boolean = false;
328
- for (const clip of track.clips) {
329
- if (clip.start <= time && time <= clip.end) {
330
- isActive = true;
328
+ if (track.clips) {
329
+ for (const clip of track.clips) {
330
+ if (clip.start <= time && time <= clip.end) {
331
+ isActive = true;
332
+ }
331
333
  }
332
334
  }
333
335
  const obj = binding as THREE.Object3D;
@@ -411,20 +413,22 @@ export class PlayableDirector extends Behaviour {
411
413
  }
412
414
  }
413
415
  if (track.type === Models.TrackType.Control) {
414
- for (let i = 0; i < track.clips.length; i++) {
415
- const clip = track.clips[i];
416
- let binding = clip.asset.sourceObject;
417
- if (typeof binding === "string") {
418
- if (this._guidsMap && this._guidsMap[binding])
419
- binding = this._guidsMap[binding];
420
- const obj = GameObject.findByGuid(binding, root);
421
- if (obj === null || typeof obj !== "object") {
422
- console.warn("Failed to resolve sourceObject binding", binding, track.name, clip);
423
- }
424
- else {
425
- if (debug)
426
- console.log("Resolved binding", binding, "to", obj);
427
- clip.asset.sourceObject = obj;
416
+ if (track.clips) {
417
+ for (let i = 0; i < track.clips.length; i++) {
418
+ const clip = track.clips[i];
419
+ let binding = clip.asset.sourceObject;
420
+ if (typeof binding === "string") {
421
+ if (this._guidsMap && this._guidsMap[binding])
422
+ binding = this._guidsMap[binding];
423
+ const obj = GameObject.findByGuid(binding, root);
424
+ if (obj === null || typeof obj !== "object") {
425
+ console.warn("Failed to resolve sourceObject binding", binding, track.name, clip);
426
+ }
427
+ else {
428
+ if (debug)
429
+ console.log("Resolved binding", binding, "to", obj);
430
+ clip.asset.sourceObject = obj;
431
+ }
428
432
  }
429
433
  }
430
434
  }
@@ -443,11 +447,15 @@ export class PlayableDirector extends Behaviour {
443
447
  if (!this.playableAsset || !this.playableAsset.tracks) return;
444
448
  for (const track of this.playableAsset.tracks) {
445
449
  if (track.muted === true) continue;
446
- for (const clip of track.clips) {
447
- if (clip.end > this._duration) this._duration = clip.end;
450
+ if (track.clips) {
451
+ for (const clip of track.clips) {
452
+ if (clip.end > this._duration) this._duration = clip.end;
453
+ }
448
454
  }
449
- for (const marker of track.markers) {
450
- if (marker.time > this._duration) this._duration = marker.time + .001;
455
+ if (track.markers) {
456
+ for (const marker of track.markers) {
457
+ if (marker.time > this._duration) this._duration = marker.time + .001;
458
+ }
451
459
  }
452
460
  }
453
461
  // console.log("timeline duration", this._duration, this.playableAsset);
@@ -474,7 +482,7 @@ export class PlayableDirector extends Behaviour {
474
482
  }
475
483
  // only handle animation tracks
476
484
  if (track.type === Models.TrackType.Animation) {
477
- if (track.clips.length <= 0) {
485
+ if (!track.clips || track.clips.length <= 0) {
478
486
  if (debug) console.warn("Animation track has no clips", track);
479
487
  continue;
480
488
  }
@@ -533,7 +541,7 @@ export class PlayableDirector extends Behaviour {
533
541
  }
534
542
  }
535
543
  else if (track.type === Models.TrackType.Audio) {
536
- if (track.clips.length <= 0) continue;
544
+ if (!track.clips || track.clips.length <= 0) continue;
537
545
  const audio = new Tracks.AudioTrackHandler();
538
546
  audio.director = this;
539
547
  audio.track = track;
@@ -549,12 +557,14 @@ export class PlayableDirector extends Behaviour {
549
557
  const signalHandler: Tracks.SignalTrackHandler = new Tracks.SignalTrackHandler();
550
558
  signalHandler.director = this;
551
559
  signalHandler.track = track;
552
- for (const marker of track.markers) {
553
- switch (marker.type) {
554
- case Models.MarkerType.Signal:
555
- signalHandler.models.push(marker as Models.SignalMarkerModel);
556
- signalHandler.didTrigger.push(false);
557
- break;
560
+ if (track.markers) {
561
+ for (const marker of track.markers) {
562
+ switch (marker.type) {
563
+ case Models.MarkerType.Signal:
564
+ signalHandler.models.push(marker as Models.SignalMarkerModel);
565
+ signalHandler.didTrigger.push(false);
566
+ break;
567
+ }
558
568
  }
559
569
  }
560
570
  if (signalHandler !== null && signalHandler.models.length > 0) {
@@ -569,9 +579,11 @@ export class PlayableDirector extends Behaviour {
569
579
  const handler = new Tracks.SignalTrackHandler();
570
580
  handler.director = this;
571
581
  handler.track = track;
572
- for (const marker of track.markers) {
573
- handler.models.push(marker as Models.SignalMarkerModel);
574
- handler.didTrigger.push(false);
582
+ if (track.markers) {
583
+ for (const marker of track.markers) {
584
+ handler.models.push(marker as Models.SignalMarkerModel);
585
+ handler.didTrigger.push(false);
586
+ }
575
587
  }
576
588
  for (const bound of track.outputs) {
577
589
  handler.receivers.push(bound as SignalReceiver);
@@ -582,8 +594,10 @@ export class PlayableDirector extends Behaviour {
582
594
  const handler = new Tracks.ControlTrackHandler();
583
595
  handler.director = this;
584
596
  handler.track = track;
585
- for (const clip of track.clips) {
586
- handler.models.push(clip);
597
+ if (track.clips) {
598
+ for (const clip of track.clips) {
599
+ handler.models.push(clip);
600
+ }
587
601
  }
588
602
  handler.resolveSourceObjects(this.context);
589
603
  this._controlTracks.push(handler);
@@ -28,8 +28,8 @@ export declare type TrackModel = {
28
28
  type: TrackType;
29
29
  muted: boolean;
30
30
  outputs: Array<null | string | object>;
31
- clips: Array<ClipModel>;
32
- markers: Array<MarkerModel>;
31
+ clips?: Array<ClipModel>;
32
+ markers?: Array<MarkerModel>;
33
33
  trackOffset?: TrackOffset;
34
34
  }
35
35
 
@@ -109,9 +109,9 @@ export class WebARSessionRoot extends Behaviour {
109
109
  // }
110
110
  }
111
111
 
112
- private async onCreatePlacementAnchor(hit: XRHitTestResult, pose: XRPose) {
112
+ private onCreatePlacementAnchor(hit: XRHitTestResult, pose: XRPose) {
113
113
  this._anchor = null;
114
- hit.createAnchor?.call(hit, pose.transform)?.then(anchor => {
114
+ hit?.createAnchor?.call(hit, pose.transform)?.then(anchor => {
115
115
  if (this.context.isInAR)
116
116
  this._anchor = anchor;
117
117
  });