angular-three 4.0.0-next.2 → 4.0.0-next.20

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 (42) hide show
  1. package/README.md +41 -41
  2. package/dom/lib/canvas.d.ts +4 -4
  3. package/fesm2022/angular-three-dom.mjs +14 -10
  4. package/fesm2022/angular-three-dom.mjs.map +1 -1
  5. package/fesm2022/angular-three-testing.mjs +3 -3
  6. package/fesm2022/angular-three.mjs +228 -130
  7. package/fesm2022/angular-three.mjs.map +1 -1
  8. package/lib/html.d.ts +1 -1
  9. package/lib/portal.d.ts +4 -4
  10. package/lib/renderer/renderer.d.ts +1 -1
  11. package/lib/three-types.d.ts +6 -1
  12. package/lib/types.d.ts +4 -1
  13. package/lib/utils/before-render.d.ts +10 -21
  14. package/lib/utils/make.d.ts +1 -1
  15. package/package.json +56 -79
  16. package/LICENSE +0 -21
  17. package/plugin/README.md +0 -11
  18. package/plugin/generators.json +0 -27
  19. package/plugin/src/generators/add-soba/compat.d.ts +0 -2
  20. package/plugin/src/generators/add-soba/compat.js +0 -6
  21. package/plugin/src/generators/add-soba/compat.js.map +0 -1
  22. package/plugin/src/generators/add-soba/generator.d.ts +0 -3
  23. package/plugin/src/generators/add-soba/generator.js +0 -77
  24. package/plugin/src/generators/add-soba/generator.js.map +0 -1
  25. package/plugin/src/generators/add-soba/schema.json +0 -4
  26. package/plugin/src/generators/init/compat.d.ts +0 -2
  27. package/plugin/src/generators/init/compat.js +0 -6
  28. package/plugin/src/generators/init/compat.js.map +0 -1
  29. package/plugin/src/generators/init/files/experience/experience.component.ts__tmpl__ +0 -28
  30. package/plugin/src/generators/init/generator.d.ts +0 -6
  31. package/plugin/src/generators/init/generator.js +0 -154
  32. package/plugin/src/generators/init/generator.js.map +0 -1
  33. package/plugin/src/generators/init/schema.json +0 -13
  34. package/plugin/src/generators/utils.d.ts +0 -2
  35. package/plugin/src/generators/utils.js +0 -35
  36. package/plugin/src/generators/utils.js.map +0 -1
  37. package/plugin/src/generators/version.d.ts +0 -17
  38. package/plugin/src/generators/version.js +0 -21
  39. package/plugin/src/generators/version.js.map +0 -1
  40. package/plugin/src/index.d.ts +0 -0
  41. package/plugin/src/index.js +0 -1
  42. package/plugin/src/index.js.map +0 -1
@@ -19,7 +19,7 @@ const NGT_GET_NODE_ATTRIBUTE_FLAG = '__ngt_get_node_attribute__';
19
19
  const NGT_DOM_PARENT_FLAG = '__ngt_dom_parent__';
20
20
  const NGT_DELEGATE_RENDERER_DESTROY_NODE_PATCHED_FLAG = '__ngt_delegate_renderer_destroy_node_patched__';
21
21
  const NGT_HTML_FLAG = '__ngt_html__';
22
- const THREE_NATIVE_EVENTS = ['added', 'removed', 'childadded', 'childremoved', 'disposed'];
22
+ const THREE_NATIVE_EVENTS = ['added', 'removed', 'childadded', 'childremoved', 'change', 'disposed'];
23
23
 
24
24
  const is = {
25
25
  obj: (a) => a === Object(a) && !Array.isArray(a) && typeof a !== 'function',
@@ -82,9 +82,9 @@ class NgtCommonDirective {
82
82
  this.injected = false;
83
83
  this.injectedValue = null;
84
84
  effect(() => {
85
- const value = this.linkedValue();
86
85
  if (this.shouldSkipRender())
87
86
  return;
87
+ const value = this.linkedValue();
88
88
  if (is.equ(value, this.injectedValue)) {
89
89
  // we have the same value as before, no need to update
90
90
  return;
@@ -114,10 +114,10 @@ class NgtCommonDirective {
114
114
  this.view = this.vcr.createEmbeddedView(this.template);
115
115
  this.view.detectChanges();
116
116
  }
117
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtCommonDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
118
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.6", type: NgtCommonDirective, isStandalone: true, ngImport: i0 }); }
117
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtCommonDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
118
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.5", type: NgtCommonDirective, isStandalone: true, ngImport: i0 }); }
119
119
  }
120
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtCommonDirective, decorators: [{
120
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtCommonDirective, decorators: [{
121
121
  type: Directive
122
122
  }], ctorParameters: () => [] });
123
123
 
@@ -141,10 +141,10 @@ class NgtArgs extends NgtCommonDirective {
141
141
  validate() {
142
142
  return !this.injected && !!this.injectedValue?.length;
143
143
  }
144
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtArgs, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
145
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.6", type: NgtArgs, isStandalone: true, selector: "ng-template[args]", inputs: { args: { classPropertyName: "args", publicName: "args", isSignal: true, isRequired: true, transformFunction: null } }, usesInheritance: true, ngImport: i0 }); }
144
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtArgs, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
145
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.5", type: NgtArgs, isStandalone: true, selector: "ng-template[args]", inputs: { args: { classPropertyName: "args", publicName: "args", isSignal: true, isRequired: true, transformFunction: null } }, usesInheritance: true, ngImport: i0 }); }
146
146
  }
147
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtArgs, decorators: [{
147
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtArgs, decorators: [{
148
148
  type: Directive,
149
149
  args: [{ selector: 'ng-template[args]' }]
150
150
  }], ctorParameters: () => [] });
@@ -314,16 +314,16 @@ function makeDpr(dpr, window) {
314
314
  return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
315
315
  }
316
316
  function makeRendererInstance(glOptions, canvas) {
317
- const customRenderer = (typeof glOptions === 'function' ? glOptions(canvas) : glOptions);
318
- if (is.renderer(customRenderer))
319
- return customRenderer;
320
- return new THREE.WebGLRenderer({
317
+ const defaultOptions = {
321
318
  powerPreference: 'high-performance',
322
319
  canvas,
323
320
  antialias: true,
324
321
  alpha: true,
325
- ...glOptions,
326
- });
322
+ };
323
+ const customRenderer = (typeof glOptions === 'function' ? glOptions(defaultOptions) : glOptions);
324
+ if (is.renderer(customRenderer))
325
+ return customRenderer;
326
+ return new THREE.WebGLRenderer({ ...defaultOptions, ...glOptions });
327
327
  }
328
328
  function makeCameraInstance(isOrthographic, size) {
329
329
  if (isOrthographic)
@@ -483,7 +483,9 @@ function storeFactory() {
483
483
  clearTimeout(performanceTimeout);
484
484
  // Set lower bound performance
485
485
  if (state.performance.current !== state.performance.min)
486
- store.update((state) => ({ performance: { ...state.performance, current: state.performance.min } }));
486
+ store.update((state) => ({
487
+ performance: { ...state.performance, current: state.performance.min },
488
+ }));
487
489
  // Go back to upper bound performance after a while unless something regresses meanwhile
488
490
  performanceTimeout = setTimeout(() => store.update((state) => ({
489
491
  performance: { ...state.performance, current: store.snapshot.performance.max },
@@ -510,7 +512,15 @@ function storeFactory() {
510
512
  tempTarget.set(...target);
511
513
  const distance = camera.getWorldPosition(position).distanceTo(tempTarget);
512
514
  if (is.three(camera, 'isOrthographicCamera')) {
513
- return { width: width / camera.zoom, height: height / camera.zoom, top, left, factor: 1, distance, aspect };
515
+ return {
516
+ width: width / camera.zoom,
517
+ height: height / camera.zoom,
518
+ top,
519
+ left,
520
+ factor: 1,
521
+ distance,
522
+ aspect,
523
+ };
514
524
  }
515
525
  const fov = (camera.fov * Math.PI) / 180; // convert vertical fov to radians
516
526
  const h = 2 * Math.tan(fov / 2) * distance; // visible height
@@ -604,7 +614,9 @@ function storeFactory() {
604
614
  oldCamera = newCamera;
605
615
  updateCamera(newCamera, newSize);
606
616
  // Update viewport
607
- store.update((state) => ({ viewport: { ...state.viewport, ...state.viewport.getCurrentViewport(newCamera) } }));
617
+ store.update((state) => ({
618
+ viewport: { ...state.viewport, ...state.viewport.getCurrentViewport(newCamera) },
619
+ }));
608
620
  }
609
621
  });
610
622
  return store;
@@ -614,6 +626,13 @@ function injectStore(options) {
614
626
  return inject(NGT_STORE, options);
615
627
  }
616
628
 
629
+ function resolveRef(ref) {
630
+ if (is.ref(ref)) {
631
+ return ref.nativeElement;
632
+ }
633
+ return ref;
634
+ }
635
+
617
636
  class NgtParent extends NgtCommonDirective {
618
637
  constructor() {
619
638
  super();
@@ -628,10 +647,7 @@ class NgtParent extends NgtCommonDirective {
628
647
  if (typeof rawParent === 'string') {
629
648
  return scene.getObjectByName(rawParent);
630
649
  }
631
- if ('nativeElement' in rawParent) {
632
- return rawParent.nativeElement;
633
- }
634
- return rawParent;
650
+ return resolveRef(rawParent);
635
651
  });
636
652
  this.linkedValue = linkedSignal(this._parent);
637
653
  this.shouldSkipRender = computed(() => !this._parent());
@@ -652,10 +668,10 @@ class NgtParent extends NgtCommonDirective {
652
668
  commentNode[NGT_INTERNAL_SET_PARENT_COMMENT_FLAG](this.injectedValue);
653
669
  }
654
670
  }
655
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtParent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
656
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.6", type: NgtParent, isStandalone: true, selector: "ng-template[parent]", inputs: { parent: { classPropertyName: "parent", publicName: "parent", isSignal: true, isRequired: true, transformFunction: null } }, usesInheritance: true, ngImport: i0 }); }
671
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtParent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
672
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.5", type: NgtParent, isStandalone: true, selector: "ng-template[parent]", inputs: { parent: { classPropertyName: "parent", publicName: "parent", isSignal: true, isRequired: true, transformFunction: null } }, usesInheritance: true, ngImport: i0 }); }
657
673
  }
658
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtParent, decorators: [{
674
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtParent, decorators: [{
659
675
  type: Directive,
660
676
  args: [{ selector: 'ng-template[parent]' }]
661
677
  }], ctorParameters: () => [] });
@@ -721,7 +737,9 @@ function prepare(object, type, instanceState) {
721
737
  notifyAncestors(instance.__ngt__.hierarchyStore.snapshot.parent, type);
722
738
  },
723
739
  remove(object, type) {
724
- instance.__ngt__.hierarchyStore.update((prev) => ({ [type]: prev[type].filter((node) => node !== object) }));
740
+ instance.__ngt__.hierarchyStore.update((prev) => ({
741
+ [type]: prev[type].filter((node) => node !== object),
742
+ }));
725
743
  notifyAncestors(instance.__ngt__.hierarchyStore.snapshot.parent, type);
726
744
  },
727
745
  setParent(parent) {
@@ -826,10 +844,10 @@ class NgtSelection {
826
844
  return;
827
845
  this.source.update(...args);
828
846
  }
829
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtSelection, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
830
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.6", type: NgtSelection, isStandalone: true, selector: "[ngtSelection]", inputs: { enabled: { classPropertyName: "enabled", publicName: "ngtSelection", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
847
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtSelection, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
848
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.5", type: NgtSelection, isStandalone: true, selector: "[ngtSelection]", inputs: { enabled: { classPropertyName: "enabled", publicName: "ngtSelection", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
831
849
  }
832
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtSelection, decorators: [{
850
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtSelection, decorators: [{
833
851
  type: Directive,
834
852
  args: [{ selector: '[ngtSelection]' }]
835
853
  }] });
@@ -873,10 +891,10 @@ class NgtSelect {
873
891
  });
874
892
  });
875
893
  }
876
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtSelect, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
877
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.6", type: NgtSelect, isStandalone: true, selector: "ngt-group[ngtSelect], ngt-mesh[ngtSelect]", inputs: { enabled: { classPropertyName: "enabled", publicName: "ngtSelect", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
894
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtSelect, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
895
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.5", type: NgtSelect, isStandalone: true, selector: "ngt-group[ngtSelect], ngt-mesh[ngtSelect]", inputs: { enabled: { classPropertyName: "enabled", publicName: "ngtSelect", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
878
896
  }
879
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtSelect, decorators: [{
897
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtSelect, decorators: [{
880
898
  type: Directive,
881
899
  args: [{ selector: 'ngt-group[ngtSelect], ngt-mesh[ngtSelect]' }]
882
900
  }], ctorParameters: () => [] });
@@ -913,10 +931,10 @@ class NgtHTML {
913
931
  delete host.nativeElement[NGT_DOM_PARENT_FLAG];
914
932
  });
915
933
  }
916
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtHTML, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
917
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.6", type: NgtHTML, isStandalone: true, ngImport: i0 }); }
934
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtHTML, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
935
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.5", type: NgtHTML, isStandalone: true, ngImport: i0 }); }
918
936
  }
919
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtHTML, decorators: [{
937
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtHTML, decorators: [{
920
938
  type: Directive
921
939
  }], ctorParameters: () => [] });
922
940
 
@@ -1085,10 +1103,10 @@ class NgtHexify {
1085
1103
  const hex = component.toString(16);
1086
1104
  return hex.length === 1 ? '0' + hex : hex;
1087
1105
  }
1088
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtHexify, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
1089
- static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.0.6", ngImport: i0, type: NgtHexify, isStandalone: true, name: "hexify" }); }
1106
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtHexify, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
1107
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.1.5", ngImport: i0, type: NgtHexify, isStandalone: true, name: "hexify" }); }
1090
1108
  }
1091
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtHexify, decorators: [{
1109
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtHexify, decorators: [{
1092
1110
  type: Pipe,
1093
1111
  args: [{ name: 'hexify', pure: true }]
1094
1112
  }] });
@@ -1181,7 +1199,7 @@ class NgtPortalAutoRender {
1181
1199
  constructor() {
1182
1200
  this.portalStore = injectStore({ host: true });
1183
1201
  this.parentStore = injectStore({ skipSelf: true });
1184
- this.portal = inject(NgtPortal, { host: true });
1202
+ this.portal = inject(NgtPortalImpl, { host: true });
1185
1203
  this.renderPriority = input(1, { alias: 'autoRender', transform: (value) => numberAttribute(value, 1) });
1186
1204
  effect(() => {
1187
1205
  // this.portalStore.update((state) => ({ events: { ...state.events, priority: this.renderPriority() + 1 } }));
@@ -1194,7 +1212,10 @@ class NgtPortalAutoRender {
1194
1212
  const [renderPriority, { internal }] = [this.renderPriority(), this.portalStore()];
1195
1213
  let oldClean;
1196
1214
  const cleanup = internal.subscribe(({ gl, scene, camera }) => {
1197
- const [parentScene, parentCamera] = [this.parentStore.snapshot.scene, this.parentStore.snapshot.camera];
1215
+ const [parentScene, parentCamera] = [
1216
+ this.parentStore.snapshot.scene,
1217
+ this.parentStore.snapshot.camera,
1218
+ ];
1198
1219
  oldClean = gl.autoClear;
1199
1220
  if (renderPriority === 1) {
1200
1221
  // clear scene and render with default
@@ -1211,10 +1232,10 @@ class NgtPortalAutoRender {
1211
1232
  onCleanup(() => cleanup());
1212
1233
  });
1213
1234
  }
1214
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtPortalAutoRender, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
1215
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.6", type: NgtPortalAutoRender, isStandalone: true, selector: "ngt-portal[autoRender]", inputs: { renderPriority: { classPropertyName: "renderPriority", publicName: "autoRender", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
1235
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtPortalAutoRender, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
1236
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.5", type: NgtPortalAutoRender, isStandalone: true, selector: "ngt-portal[autoRender]", inputs: { renderPriority: { classPropertyName: "renderPriority", publicName: "autoRender", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
1216
1237
  }
1217
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtPortalAutoRender, decorators: [{
1238
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtPortalAutoRender, decorators: [{
1218
1239
  type: Directive,
1219
1240
  args: [{ selector: 'ngt-portal[autoRender]' }]
1220
1241
  }], ctorParameters: () => [] });
@@ -1236,10 +1257,10 @@ class NgtPortalContent {
1236
1257
  delete commentNode[NGT_INTERNAL_ADD_COMMENT_FLAG];
1237
1258
  }
1238
1259
  }
1239
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtPortalContent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
1240
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.6", type: NgtPortalContent, isStandalone: true, selector: "ng-template[portalContent]", ngImport: i0 }); }
1260
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtPortalContent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
1261
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.5", type: NgtPortalContent, isStandalone: true, selector: "ng-template[portalContent]", ngImport: i0 }); }
1241
1262
  }
1242
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtPortalContent, decorators: [{
1263
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtPortalContent, decorators: [{
1243
1264
  type: Directive,
1244
1265
  args: [{ selector: 'ng-template[portalContent]' }]
1245
1266
  }], ctorParameters: () => [] });
@@ -1273,7 +1294,7 @@ function mergeState(previousRoot, store, container, pointer, raycaster, events,
1273
1294
  setEvents: (events) => store.update((state) => ({ ...state, events: { ...state.events, ...events } })),
1274
1295
  };
1275
1296
  }
1276
- class NgtPortal {
1297
+ class NgtPortalImpl {
1277
1298
  constructor() {
1278
1299
  this.container = input.required();
1279
1300
  this.state = input({});
@@ -1289,7 +1310,12 @@ class NgtPortal {
1289
1310
  this.portalRendered = this.portalContentRendered.asReadonly();
1290
1311
  extend({ Group });
1291
1312
  effect(() => {
1292
- let [container, anchor, content] = [this.container(), this.anchorRef(), this.contentRef(), this.previousStore()];
1313
+ let [container, anchor, content] = [
1314
+ this.container(),
1315
+ this.anchorRef(),
1316
+ this.contentRef(),
1317
+ this.previousStore(),
1318
+ ];
1293
1319
  const [size, events, restState] = [untracked(this.size), untracked(this.events), untracked(this.restState)];
1294
1320
  if (!is.instance(container)) {
1295
1321
  container = prepare(container, 'ngt-portal', { store: this.portalStore });
@@ -1308,8 +1334,8 @@ class NgtPortal {
1308
1334
  this.portalContentRendered.set(true);
1309
1335
  });
1310
1336
  }
1311
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtPortal, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1312
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.6", type: NgtPortal, isStandalone: true, selector: "ngt-portal", inputs: { container: { classPropertyName: "container", publicName: "container", isSignal: true, isRequired: true, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
1337
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtPortalImpl, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1338
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.1.5", type: NgtPortalImpl, isStandalone: true, selector: "ngt-portal", inputs: { container: { classPropertyName: "container", publicName: "container", isSignal: true, isRequired: true, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
1313
1339
  {
1314
1340
  provide: NGT_STORE,
1315
1341
  useFactory: (previousStore) => {
@@ -1336,7 +1362,7 @@ class NgtPortal {
1336
1362
  }
1337
1363
  `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1338
1364
  }
1339
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtPortal, decorators: [{
1365
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtPortalImpl, decorators: [{
1340
1366
  type: Component,
1341
1367
  args: [{
1342
1368
  selector: 'ngt-portal',
@@ -1371,7 +1397,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImpor
1371
1397
  ],
1372
1398
  }]
1373
1399
  }], ctorParameters: () => [] });
1374
- const NgtPortalDeclarations = [NgtPortal, NgtPortalContent];
1400
+ const NgtPortal = [NgtPortalImpl, NgtPortalContent];
1375
1401
 
1376
1402
  /**
1377
1403
  * Release pointer captures.
@@ -1501,7 +1527,20 @@ function createEvents(store) {
1501
1527
  if (intersections.length) {
1502
1528
  const localState = { stopped: false };
1503
1529
  for (const hit of intersections) {
1504
- const { raycaster, pointer, camera, internal } = getInstanceState(hit.object)?.store?.snapshot || rootState;
1530
+ let instanceState = getInstanceState(hit.object);
1531
+ // If the object is not managed by NGT, it might be parented to an element which is.
1532
+ // Traverse upwards until we find a managed parent and use its state instead.
1533
+ if (!instanceState) {
1534
+ hit.object.traverseAncestors((ancestor) => {
1535
+ const parentInstanceState = getInstanceState(ancestor);
1536
+ if (parentInstanceState) {
1537
+ instanceState = parentInstanceState;
1538
+ return false;
1539
+ }
1540
+ return;
1541
+ });
1542
+ }
1543
+ const { raycaster, pointer, camera, internal } = instanceState?.store?.snapshot || rootState;
1505
1544
  const unprojectedPoint = new THREE.Vector3(pointer.x, pointer.y, 0).unproject(camera);
1506
1545
  const hasPointerCapture = (id) => internal.capturedMap.get(id)?.has(hit.eventObject) ?? false;
1507
1546
  const setPointerCapture = (id) => {
@@ -1686,7 +1725,10 @@ function createEvents(store) {
1686
1725
  }*/
1687
1726
  if (isPointerMove) {
1688
1727
  // Move event ...
1689
- if (handlers?.pointerover || handlers?.pointerenter || handlers?.pointerout || handlers?.pointerleave) {
1728
+ if (handlers?.pointerover ||
1729
+ handlers?.pointerenter ||
1730
+ handlers?.pointerout ||
1731
+ handlers?.pointerleave) {
1690
1732
  // When enter or out is present take care of hover-state
1691
1733
  const id = makeId(data);
1692
1734
  const hoveredItem = internal.hovered.get(id);
@@ -1733,9 +1775,9 @@ function createEvents(store) {
1733
1775
 
1734
1776
  // This function prepares a set of changes to be applied to the instance
1735
1777
  function diffProps(instance, props) {
1736
- const propsEntries = Object.entries(props);
1737
1778
  const changes = [];
1738
- for (const [propKey, propValue] of propsEntries) {
1779
+ for (const propKey in props) {
1780
+ const propValue = props[propKey];
1739
1781
  let key = propKey;
1740
1782
  if (is.colorSpaceExist(instance)) {
1741
1783
  if (propKey === 'encoding') {
@@ -1757,6 +1799,33 @@ const NGT_APPLY_PROPS = '__ngt_apply_props__';
1757
1799
  // https://github.com/mrdoob/three.js/pull/27042
1758
1800
  // https://github.com/mrdoob/three.js/pull/22748
1759
1801
  const colorMaps = ['map', 'emissiveMap', 'sheenColorMap', 'specularColorMap', 'envMap'];
1802
+ const MEMOIZED_PROTOTYPES = new Map();
1803
+ function getMemoizedPrototype(root) {
1804
+ let ctor = MEMOIZED_PROTOTYPES.get(root.constructor);
1805
+ try {
1806
+ if (!ctor) {
1807
+ ctor = new root.constructor();
1808
+ MEMOIZED_PROTOTYPES.set(root.constructor, ctor);
1809
+ }
1810
+ }
1811
+ catch (e) {
1812
+ // ...
1813
+ }
1814
+ return ctor;
1815
+ }
1816
+ function resolve(instance, key) {
1817
+ let targetProp = instance[key];
1818
+ if (!key.includes('.'))
1819
+ return { root: instance, targetKey: key, targetProp };
1820
+ // Resolve pierced target
1821
+ const chain = key.split('.');
1822
+ targetProp = chain.reduce((acc, part) => acc[part], instance);
1823
+ const targetKey = chain.pop();
1824
+ // Switch root if atomic
1825
+ if (!targetProp?.set)
1826
+ instance = chain.reduce((acc, part) => acc[part], instance);
1827
+ return { root: instance, targetKey, targetProp };
1828
+ }
1760
1829
  // This function applies a set of changes to the instance
1761
1830
  function applyProps(instance, props) {
1762
1831
  // if props is empty
@@ -1786,13 +1855,31 @@ function applyProps(instance, props) {
1786
1855
  // value = value === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace;
1787
1856
  // }
1788
1857
  // }
1789
- const currentInstance = instance;
1790
- const targetProp = currentInstance[key];
1858
+ const { root, targetKey, targetProp } = resolve(instance, key);
1859
+ // we have switched due to pierced props
1860
+ if (root !== instance) {
1861
+ return applyProps(root, { [targetKey]: value });
1862
+ }
1791
1863
  // Copy if properties match signatures
1792
1864
  if (targetProp?.copy &&
1793
1865
  value?.constructor &&
1794
1866
  targetProp.constructor === value.constructor) {
1795
- targetProp.copy(value);
1867
+ // If both are geometries, we should assign the value directly instead of copying
1868
+ if (is.three(targetProp, 'isBufferGeometry') &&
1869
+ is.three(value, 'isBufferGeometry')) {
1870
+ Object.assign(root, { [targetKey]: value });
1871
+ }
1872
+ else {
1873
+ // fetch the default state of the target
1874
+ const ctor = getMemoizedPrototype(root);
1875
+ // The target key was originally null or undefined, which indicates that the object which
1876
+ // is now present was externally set by the user, we should therefore assign the value directly
1877
+ if (ctor !== undefined && ctor[targetKey] == null)
1878
+ Object.assign(root, { [targetKey]: value });
1879
+ // Otherwise copy is correct
1880
+ else
1881
+ targetProp.copy(value);
1882
+ }
1796
1883
  }
1797
1884
  // Layers have no copy function, we must therefore copy the mask property
1798
1885
  else if (targetProp instanceof THREE.Layers && value instanceof THREE.Layers) {
@@ -1817,22 +1904,22 @@ function applyProps(instance, props) {
1817
1904
  }
1818
1905
  // Else, just overwrite the value
1819
1906
  else {
1820
- Object.assign(currentInstance, { [key]: value });
1907
+ Object.assign(root, { [targetKey]: value });
1821
1908
  // Auto-convert sRGB texture parameters for built-in materials
1822
1909
  // https://github.com/pmndrs/react-three-fiber/issues/344
1823
1910
  // https://github.com/mrdoob/three.js/pull/25857
1824
1911
  if (rootState &&
1825
1912
  !rootState.linear &&
1826
- colorMaps.includes(key) &&
1827
- currentInstance[key]?.isTexture &&
1913
+ colorMaps.includes(targetKey) &&
1914
+ root[targetKey]?.isTexture &&
1828
1915
  // sRGB textures must be RGBA8 since r137 https://github.com/mrdoob/three.js/pull/23129
1829
- currentInstance[key].format === THREE.RGBAFormat &&
1830
- currentInstance[key].type === THREE.UnsignedByteType) {
1916
+ root[targetKey].format === THREE.RGBAFormat &&
1917
+ root[targetKey].type === THREE.UnsignedByteType) {
1831
1918
  // NOTE: this cannot be set from the renderer (e.g. sRGB source textures rendered to P3)
1832
- currentInstance[key].colorSpace = THREE.SRGBColorSpace;
1919
+ root[targetKey].colorSpace = THREE.SRGBColorSpace;
1833
1920
  }
1834
1921
  }
1835
- checkUpdate(currentInstance[key]);
1922
+ checkUpdate(root[targetKey]);
1836
1923
  checkUpdate(targetProp);
1837
1924
  invalidateInstance(instance);
1838
1925
  }
@@ -1958,7 +2045,10 @@ function propagateStoreRecursively(node, parentNode) {
1958
2045
  // Call addInteraction if it exists
1959
2046
  iS.addInteraction?.(pIS.store);
1960
2047
  // Collect all children (objects and nonObjects)
1961
- const children = [...(iS.objects ? untracked(iS.objects) : []), ...(iS.nonObjects ? untracked(iS.nonObjects) : [])];
2048
+ const children = [
2049
+ ...(iS.objects ? untracked(iS.objects) : []),
2050
+ ...(iS.nonObjects ? untracked(iS.nonObjects) : []),
2051
+ ];
1962
2052
  // Recursively reassign the store for each child
1963
2053
  for (const child of children) {
1964
2054
  propagateStoreRecursively(child, node);
@@ -2165,17 +2255,19 @@ class NgtRendererFactory2 {
2165
2255
  return;
2166
2256
  internalDestroyNode(node, null);
2167
2257
  };
2168
- Object.assign(delegateRenderer.destroyNode, { [NGT_DELEGATE_RENDERER_DESTROY_NODE_PATCHED_FLAG]: true });
2258
+ Object.assign(delegateRenderer.destroyNode, {
2259
+ [NGT_DELEGATE_RENDERER_DESTROY_NODE_PATCHED_FLAG]: true,
2260
+ });
2169
2261
  }
2170
2262
  return delegateRenderer;
2171
2263
  }
2172
2264
  this.rendererMap.set(type.id, (renderer = new NgtRenderer2(delegateRenderer, this.catalogue, this.document)));
2173
2265
  return renderer;
2174
2266
  }
2175
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtRendererFactory2, deps: [{ token: i0.RendererFactory2 }], target: i0.ɵɵFactoryTarget.Injectable }); }
2176
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtRendererFactory2 }); }
2267
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtRendererFactory2, deps: [{ token: i0.RendererFactory2 }], target: i0.ɵɵFactoryTarget.Injectable }); }
2268
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtRendererFactory2 }); }
2177
2269
  }
2178
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtRendererFactory2, decorators: [{
2270
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtRendererFactory2, decorators: [{
2179
2271
  type: Injectable
2180
2272
  }], ctorParameters: () => [{ type: i0.RendererFactory2 }] });
2181
2273
  class NgtRenderer2 {
@@ -2243,7 +2335,6 @@ class NgtRenderer2 {
2243
2335
  }
2244
2336
  const threeName = kebabToPascal(name.startsWith('ngt-') ? name.slice(4) : name);
2245
2337
  const threeTarget = this.catalogue[threeName];
2246
- //
2247
2338
  if (threeTarget) {
2248
2339
  const threeInstance = prepare(new threeTarget(...injectedArgs), name);
2249
2340
  const rendererNode = createRendererNode('three', threeInstance, this.document);
@@ -2251,7 +2342,7 @@ class NgtRenderer2 {
2251
2342
  const instanceState = getInstanceState(threeInstance);
2252
2343
  // auto-attach for geometry and material
2253
2344
  if (is.three(threeInstance, 'isBufferGeometry')) {
2254
- Object.assign(instanceState, { attach: ['geometry'] });
2345
+ instanceState.attach = ['geometry'];
2255
2346
  }
2256
2347
  else if (is.three(threeInstance, 'isMaterial')) {
2257
2348
  instanceState.attach = ['material'];
@@ -2302,7 +2393,8 @@ class NgtRenderer2 {
2302
2393
  const pRS = parent.__ngt_renderer__;
2303
2394
  const cRS = newChild.__ngt_renderer__;
2304
2395
  if (!pRS || !cRS) {
2305
- ngDevMode && console.warn('[NGT dev mode] One of parent or child is not a renderer node.', { parent, newChild });
2396
+ ngDevMode &&
2397
+ console.warn('[NGT dev mode] One of parent or child is not a renderer node.', { parent, newChild });
2306
2398
  return delegatedFn();
2307
2399
  }
2308
2400
  if (cRS[0 /* NgtRendererClassId.type */] === 'comment') {
@@ -2371,7 +2463,10 @@ class NgtRenderer2 {
2371
2463
  // if both are comments and the reference child is NgtCanvasContent, we'll assign the same flag to the newChild
2372
2464
  // this means that the NgtCanvas component is embedding. This flag allows the Renderer to get the root scene
2373
2465
  // when it tries to attach the template under `ng-template[canvasContent]`
2374
- if (refChild && refChild[NGT_CANVAS_CONTENT_FLAG] && refChild instanceof Comment && newChild instanceof Comment) {
2466
+ if (refChild &&
2467
+ refChild[NGT_CANVAS_CONTENT_FLAG] &&
2468
+ refChild instanceof Comment &&
2469
+ newChild instanceof Comment) {
2375
2470
  Object.assign(newChild, { [NGT_CANVAS_CONTENT_FLAG]: refChild[NGT_CANVAS_CONTENT_FLAG] });
2376
2471
  }
2377
2472
  // if there is no parent, we delegate
@@ -2454,7 +2549,9 @@ class NgtRenderer2 {
2454
2549
  // set parent to the comment too
2455
2550
  setRendererParentNode(node, sceneRendererNode);
2456
2551
  }
2457
- if (node[NGT_PORTAL_CONTENT_FLAG] && node[NGT_DOM_PARENT_FLAG] && isRendererNode(node[NGT_DOM_PARENT_FLAG])) {
2552
+ if (node[NGT_PORTAL_CONTENT_FLAG] &&
2553
+ node[NGT_DOM_PARENT_FLAG] &&
2554
+ isRendererNode(node[NGT_DOM_PARENT_FLAG])) {
2458
2555
  const portalContentParent = node[NGT_DOM_PARENT_FLAG];
2459
2556
  const portalContentParentRS = portalContentParent.__ngt_renderer__;
2460
2557
  if (!portalContentParentRS[3 /* NgtRendererClassId.portalContainer */]) {
@@ -2494,24 +2591,23 @@ class NgtRenderer2 {
2494
2591
  if (instanceState)
2495
2592
  instanceState.attach = paths;
2496
2593
  }
2594
+ return;
2595
+ }
2596
+ // coercion for primitive values
2597
+ let maybeCoerced = value;
2598
+ if (maybeCoerced === '' || maybeCoerced === 'true' || maybeCoerced === 'false') {
2599
+ maybeCoerced = maybeCoerced === 'true' || maybeCoerced === '';
2497
2600
  }
2498
2601
  else {
2499
- // coercion for primitive values
2500
- let maybeCoerced = value;
2501
- if (maybeCoerced === '' || maybeCoerced === 'true' || maybeCoerced === 'false') {
2502
- maybeCoerced = maybeCoerced === 'true' || maybeCoerced === '';
2503
- }
2504
- else {
2505
- const maybeNumber = Number(maybeCoerced);
2506
- if (!isNaN(maybeNumber))
2507
- maybeCoerced = maybeNumber;
2508
- }
2509
- if (name === 'rawValue') {
2510
- rS[2 /* NgtRendererClassId.rawValue */] = maybeCoerced;
2511
- }
2512
- else {
2513
- applyProps(el, { [name]: maybeCoerced });
2514
- }
2602
+ const maybeNumber = Number(maybeCoerced);
2603
+ if (!isNaN(maybeNumber))
2604
+ maybeCoerced = maybeNumber;
2605
+ }
2606
+ if (name === 'rawValue') {
2607
+ rS[2 /* NgtRendererClassId.rawValue */] = maybeCoerced;
2608
+ }
2609
+ else {
2610
+ applyProps(el, { [name]: maybeCoerced });
2515
2611
  }
2516
2612
  return;
2517
2613
  }
@@ -2617,7 +2713,8 @@ class NgtRenderer2 {
2617
2713
  if (eventName === 'disposed') {
2618
2714
  eventName = 'dispose';
2619
2715
  }
2620
- if (target.parent && (eventName === 'added' || eventName === 'removed')) {
2716
+ if (target.parent &&
2717
+ (eventName === 'added' || eventName === 'removed')) {
2621
2718
  callback({ type: eventName, target });
2622
2719
  }
2623
2720
  target.addEventListener(eventName, callback);
@@ -2638,7 +2735,10 @@ class NgtRenderer2 {
2638
2735
  // if parent and chlid are the same, skip
2639
2736
  if (parent === child) {
2640
2737
  ngDevMode &&
2641
- console.warn('[NGT dev mode] appending THREE.js parent and child but they are the same', { parent, child });
2738
+ console.warn('[NGT dev mode] appending THREE.js parent and child but they are the same', {
2739
+ parent,
2740
+ child,
2741
+ });
2642
2742
  return;
2643
2743
  }
2644
2744
  const cIS = getInstanceState(child);
@@ -2740,10 +2840,13 @@ function injectCanvasRootInitializer(injector) {
2740
2840
  applyProps(raycaster, { params: { ...raycaster.params, ...(params || {}) } });
2741
2841
  }
2742
2842
  // Create default camera, don't overwrite any user-set state
2743
- if (!state.camera || (state.camera === lastCamera && !is.equ(lastCamera, cameraOptions, shallowLoose))) {
2843
+ if (!state.camera ||
2844
+ (state.camera === lastCamera && !is.equ(lastCamera, cameraOptions, shallowLoose))) {
2744
2845
  lastCamera = cameraOptions;
2745
2846
  const isCamera = is.three(cameraOptions, 'isCamera');
2746
- let camera = isCamera ? cameraOptions : makeCameraInstance(orthographic, sizeOptions ?? state.size);
2847
+ let camera = isCamera
2848
+ ? cameraOptions
2849
+ : makeCameraInstance(orthographic, sizeOptions ?? state.size);
2747
2850
  if (!isCamera) {
2748
2851
  camera.position.z = 5;
2749
2852
  if (cameraOptions) {
@@ -2945,12 +3048,12 @@ class NgtRoutedScene {
2945
3048
  onCleanup(() => sub.unsubscribe());
2946
3049
  });
2947
3050
  }
2948
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtRoutedScene, deps: [{ token: i1.Router }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
2949
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.6", type: NgtRoutedScene, isStandalone: true, selector: "ngt-routed-scene", ngImport: i0, template: `
3051
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtRoutedScene, deps: [{ token: i1.Router }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
3052
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.5", type: NgtRoutedScene, isStandalone: true, selector: "ngt-routed-scene", ngImport: i0, template: `
2950
3053
  <router-outlet />
2951
3054
  `, isInline: true, dependencies: [{ kind: "directive", type: RouterOutlet, selector: "router-outlet", inputs: ["name", "routerOutletData"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }] }); }
2952
3055
  }
2953
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtRoutedScene, decorators: [{
3056
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtRoutedScene, decorators: [{
2954
3057
  type: Component,
2955
3058
  args: [{
2956
3059
  selector: 'ngt-routed-scene',
@@ -2965,32 +3068,34 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImpor
2965
3068
  * `injectBeforeRender` invokes its callback on every frame. Hence, the notion of tracking
2966
3069
  * changes (i.e: signals) does not really matter since we're getting latest values of the things we need on every frame anyway.
2967
3070
  *
2968
- * If `priority` is dynamic, consumers should set up `injectBeforeRender` in
2969
- * an `effect` and track `priority` changes. Make use of `onCleanup` to clean up
2970
- * previous before render subscription
3071
+ * If `priority` is a Signal, `injectBeforeRender` will set up an Effect internally and returns the `EffectRef#destroy` instead.
2971
3072
  *
2972
3073
  * @example
2973
3074
  * ```ts
2974
- * const injector = inject(Injector);
2975
- *
2976
- * effect((onCleanup) => {
2977
- * const priority = this.priority(); // track priority
2978
- *
2979
- * const sub = injectBeforeRender(
2980
- * ({ gl, camera }) => {
2981
- * // before render logic
2982
- * },
2983
- * {
2984
- * priority,
2985
- * injector, // injector is needed since injectBeforeRender is invoked in effect body
2986
- * }
2987
- * });
2988
- *
2989
- * onCleanup(() => sub());
2990
- * });
3075
+ * const destroy = injectBeforeRender(
3076
+ * ({ gl, camera }) => {
3077
+ * // before render logic
3078
+ * },
3079
+ * {
3080
+ * priority: this.priority, // this.priority is a Signal<number>
3081
+ * }
3082
+ * )
2991
3083
  * ```
2992
3084
  */
2993
3085
  function injectBeforeRender(cb, { priority = 0, injector } = {}) {
3086
+ if (typeof priority === 'function') {
3087
+ const effectRef = assertInjector(injectBeforeRender, injector, () => {
3088
+ const store = injectStore();
3089
+ const ref = effect((onCleanup) => {
3090
+ const p = priority();
3091
+ const sub = store.snapshot.internal.subscribe(cb, p, store);
3092
+ onCleanup(() => sub());
3093
+ });
3094
+ inject(DestroyRef).onDestroy(() => void ref.destroy());
3095
+ return ref;
3096
+ });
3097
+ return effectRef.destroy.bind(effectRef);
3098
+ }
2994
3099
  return assertInjector(injectBeforeRender, injector, () => {
2995
3100
  const store = injectStore();
2996
3101
  const sub = store.snapshot.internal.subscribe(cb, priority, store);
@@ -2999,13 +3104,6 @@ function injectBeforeRender(cb, { priority = 0, injector } = {}) {
2999
3104
  });
3000
3105
  }
3001
3106
 
3002
- function resolveRef(ref) {
3003
- if (is.ref(ref)) {
3004
- return ref.nativeElement;
3005
- }
3006
- return ref;
3007
- }
3008
-
3009
3107
  /**
3010
3108
  * As host directive:
3011
3109
  * - outputs: [
@@ -3069,10 +3167,10 @@ class NgtObjectEvents {
3069
3167
  emitEvent(eventName) {
3070
3168
  return this[eventName].emit.bind(this[eventName]);
3071
3169
  }
3072
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtObjectEvents, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
3073
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.6", type: NgtObjectEvents, isStandalone: true, selector: "[ngtObjectEvents]", inputs: { ngtObjectEvents: { classPropertyName: "ngtObjectEvents", publicName: "ngtObjectEvents", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { click: "click", dblclick: "dblclick", contextmenu: "contextmenu", pointerup: "pointerup", pointerdown: "pointerdown", pointerover: "pointerover", pointerout: "pointerout", pointerenter: "pointerenter", pointerleave: "pointerleave", pointermove: "pointermove", pointermissed: "pointermissed", pointercancel: "pointercancel", wheel: "wheel", ngtObjectEvents: "ngtObjectEventsChange" }, ngImport: i0 }); }
3170
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtObjectEvents, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
3171
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.5", type: NgtObjectEvents, isStandalone: true, selector: "[ngtObjectEvents]", inputs: { ngtObjectEvents: { classPropertyName: "ngtObjectEvents", publicName: "ngtObjectEvents", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { click: "click", dblclick: "dblclick", contextmenu: "contextmenu", pointerup: "pointerup", pointerdown: "pointerdown", pointerover: "pointerover", pointerout: "pointerout", pointerenter: "pointerenter", pointerleave: "pointerleave", pointermove: "pointermove", pointermissed: "pointermissed", pointercancel: "pointercancel", wheel: "wheel", ngtObjectEvents: "ngtObjectEventsChange" }, ngImport: i0 }); }
3074
3172
  }
3075
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: NgtObjectEvents, decorators: [{
3173
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: NgtObjectEvents, decorators: [{
3076
3174
  type: Directive,
3077
3175
  args: [{ selector: '[ngtObjectEvents]' }]
3078
3176
  }], ctorParameters: () => [] });
@@ -3082,7 +3180,7 @@ function injectObjectEvents(target, events, { injector } = {}) {
3082
3180
  const cleanUps = [];
3083
3181
  effect((onCleanup) => {
3084
3182
  const targetRef = resolveRef(target());
3085
- if (!targetRef)
3183
+ if (!targetRef || !is.instance(targetRef))
3086
3184
  return;
3087
3185
  Object.entries(events).forEach(([eventName, eventHandler]) => {
3088
3186
  cleanUps.push(renderer.listen(targetRef, eventName, eventHandler));
@@ -3111,5 +3209,5 @@ function hasListener(...emitterRefs) {
3111
3209
  * Generated bundle index. Do not edit.
3112
3210
  */
3113
3211
 
3114
- export { NGT_APPLY_PROPS, NGT_ARGS_FLAG, NGT_CANVAS_CONTENT_FLAG, NGT_CATALOGUE, NGT_DELEGATE_RENDERER_DESTROY_NODE_PATCHED_FLAG, NGT_DOM_PARENT_FLAG, NGT_GET_NODE_ATTRIBUTE_FLAG, NGT_HTML_FLAG, NGT_INTERNAL_ADD_COMMENT_FLAG, NGT_INTERNAL_SET_PARENT_COMMENT_FLAG, NGT_LOOP, NGT_PARENT_FLAG, NGT_PORTAL_CONTENT_FLAG, NGT_RENDERER_NODE_FLAG, NGT_STORE, NgtArgs, NgtHTML, NgtHexify, NgtObjectEvents, NgtParent, NgtPortal, NgtPortalAutoRender, NgtPortalContent, NgtPortalDeclarations, NgtRenderer2, NgtRendererFactory2, NgtRoutedScene, NgtSelect, NgtSelection, THREE_NATIVE_EVENTS, addAfterEffect, addEffect, addTail, applyProps, attach, checkNeedsUpdate, checkUpdate, createAttachFunction, createEvents, detach, dispose, extend, flushGlobalEffects, getEmitter, getInstanceState, getLocalState, hasListener, injectBeforeRender, injectCanvasRootInitializer, injectCatalogue, injectLoader, injectLoop, injectObjectEvents, injectStore, invalidateInstance, is, makeCameraInstance, makeDpr, makeId, makeObjectGraph, makeRendererInstance, merge, omit, pick, prepare, provideHTMLDomElement, removeInteractivity, resolveRef, roots, signalState, storeFactory, updateCamera, vector2, vector3, vector4 };
3212
+ export { NGT_APPLY_PROPS, NGT_ARGS_FLAG, NGT_CANVAS_CONTENT_FLAG, NGT_CATALOGUE, NGT_DELEGATE_RENDERER_DESTROY_NODE_PATCHED_FLAG, NGT_DOM_PARENT_FLAG, NGT_GET_NODE_ATTRIBUTE_FLAG, NGT_HTML_FLAG, NGT_INTERNAL_ADD_COMMENT_FLAG, NGT_INTERNAL_SET_PARENT_COMMENT_FLAG, NGT_LOOP, NGT_PARENT_FLAG, NGT_PORTAL_CONTENT_FLAG, NGT_RENDERER_NODE_FLAG, NGT_STORE, NgtArgs, NgtHTML, NgtHexify, NgtObjectEvents, NgtParent, NgtPortal, NgtPortalAutoRender, NgtPortalContent, NgtPortalImpl, NgtRenderer2, NgtRendererFactory2, NgtRoutedScene, NgtSelect, NgtSelection, THREE_NATIVE_EVENTS, addAfterEffect, addEffect, addTail, applyProps, attach, checkNeedsUpdate, checkUpdate, createAttachFunction, createEvents, detach, dispose, extend, flushGlobalEffects, getEmitter, getInstanceState, getLocalState, hasListener, injectBeforeRender, injectCanvasRootInitializer, injectCatalogue, injectLoader, injectLoop, injectObjectEvents, injectStore, invalidateInstance, is, makeCameraInstance, makeDpr, makeId, makeObjectGraph, makeRendererInstance, merge, omit, pick, prepare, provideHTMLDomElement, removeInteractivity, resolveRef, roots, signalState, storeFactory, updateCamera, vector2, vector3, vector4 };
3115
3213
  //# sourceMappingURL=angular-three.mjs.map