angular-three 1.9.11 → 1.9.12

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.
@@ -1,11 +1,10 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { inject, ChangeDetectorRef, ElementRef, Injectable, InjectionToken, ViewContainerRef, TemplateRef, Directive, Input, EventEmitter, getDebugNode, RendererFactory2, makeEnvironmentProviders, EnvironmentInjector, createEnvironmentInjector, Component, HostBinding, Output, ViewChild, Injector, Pipe, SkipSelf, ContentChild } from '@angular/core';
3
3
  import { provideNgxResizeOptions, NgxResize } from 'ngx-resize';
4
- import { isObservable, of, map, from, tap, retry, catchError, share, ReplaySubject, switchMap, forkJoin, take, BehaviorSubject, startWith, combineLatest, distinctUntilChanged, filter, takeUntil, merge } from 'rxjs';
4
+ import { isObservable, of, map, from, tap, retry, catchError, share, ReplaySubject, switchMap, forkJoin, take, BehaviorSubject, startWith, combineLatest, filter, distinctUntilChanged, takeUntil, merge } from 'rxjs';
5
5
  import * as THREE from 'three';
6
6
  import { DOCUMENT, NgForOf, NgIf } from '@angular/common';
7
- import { RxState, selectSlice } from '@rx-angular/state';
8
- import { __classPrivateFieldGet } from 'tslib';
7
+ import { RxState } from '@rx-angular/state';
9
8
  import * as i1 from '@angular/router';
10
9
  import { ActivationEnd, RouterOutlet } from '@angular/router';
11
10
 
@@ -58,10 +57,24 @@ function makeObjectGraph(object) {
58
57
  return data;
59
58
  }
60
59
 
60
+ function safeDetectChanges(cdr) {
61
+ if (!cdr)
62
+ return;
63
+ try {
64
+ // dynamic created component with ViewContainerRef#createComponent does not have Context
65
+ // but it has _attachedToViewContainer
66
+ if (cdr['context'] || cdr['_attachedToViewContainer']) {
67
+ cdr.detectChanges();
68
+ }
69
+ }
70
+ catch (e) {
71
+ cdr.markForCheck();
72
+ }
73
+ }
74
+
61
75
  const cached = new Map();
62
- function injectLoader(loaderConstructorFactory, input, extensions, onProgress) {
76
+ function load(loaderConstructorFactory, input, extensions, onProgress) {
63
77
  const urls$ = isObservable(input) ? input : of(input);
64
- const cdr = inject(ChangeDetectorRef);
65
78
  return urls$.pipe(map((inputs) => {
66
79
  const loaderConstructor = loaderConstructorFactory(inputs);
67
80
  const loader = new loaderConstructor();
@@ -83,7 +96,11 @@ function injectLoader(loaderConstructorFactory, input, extensions, onProgress) {
83
96
  }),
84
97
  inputs,
85
98
  ];
86
- }), switchMap(([observables$, inputs]) => {
99
+ }));
100
+ }
101
+ function injectLoader(loaderConstructorFactory, input, extensions, onProgress) {
102
+ const cdr = inject(ChangeDetectorRef);
103
+ return load(loaderConstructorFactory, input, extensions, onProgress).pipe(switchMap(([observables$, inputs]) => {
87
104
  return forkJoin(observables$).pipe(map((results) => {
88
105
  if (Array.isArray(inputs))
89
106
  return results;
@@ -95,7 +112,7 @@ function injectLoader(loaderConstructorFactory, input, extensions, onProgress) {
95
112
  return result;
96
113
  }, {});
97
114
  }), tap(() => {
98
- requestAnimationFrame(() => cdr.detectChanges());
115
+ requestAnimationFrame(() => void safeDetectChanges(cdr));
99
116
  }));
100
117
  }));
101
118
  }
@@ -103,7 +120,7 @@ injectLoader.destroy = () => {
103
120
  cached.clear();
104
121
  };
105
122
  injectLoader.preLoad = (loaderConstructorFactory, inputs, extensions) => {
106
- injectLoader(loaderConstructorFactory, inputs, extensions).pipe(take(1)).subscribe();
123
+ load(loaderConstructorFactory, inputs, extensions).pipe(take(1)).subscribe();
107
124
  };
108
125
  const injectNgtLoader = injectLoader;
109
126
 
@@ -352,6 +369,8 @@ function prepare(object, localState) {
352
369
  const current = instance.__ngt__[type].value;
353
370
  const foundIndex = current.indexOf((obj) => obj === object);
354
371
  if (foundIndex > -1) {
372
+ // if we add an object with the same reference, then we switch it out
373
+ // and update the BehaviorSubject
355
374
  current.splice(foundIndex, 1, object);
356
375
  instance.__ngt__[type].next(current);
357
376
  }
@@ -474,7 +493,6 @@ const startWithUndefined = () => startWith(undefined);
474
493
  * - can optionally return a `cleanUp` function that
475
494
  * invokes from the 2nd `next` notification onward and on `unsubscribe` (destroyed)
476
495
  *
477
- *
478
496
  * @example
479
497
  * ```typescript
480
498
  * source$.pipe(
@@ -504,17 +522,14 @@ function tapEffect(effectFn) {
504
522
  };
505
523
  return tap({
506
524
  next: (value) => {
507
- if (cleanupFn && firstRun) {
525
+ if (cleanupFn && firstRun)
508
526
  cleanupFn({ prev, complete: false, error: false });
509
- }
510
527
  const cleanUpOrVoid = effectFn(value);
511
- if (cleanUpOrVoid) {
528
+ if (cleanUpOrVoid)
512
529
  cleanupFn = cleanUpOrVoid;
513
- }
514
530
  prev = value;
515
- if (!firstRun) {
531
+ if (!firstRun)
516
532
  firstRun = true;
517
- }
518
533
  },
519
534
  complete: teardown(false),
520
535
  unsubscribe: teardown(false),
@@ -524,7 +539,6 @@ function tapEffect(effectFn) {
524
539
  class NgtRxStore extends RxState {
525
540
  constructor() {
526
541
  super();
527
- this.cache = {};
528
542
  // set a dummy property so that initial this.get() won't return undefined
529
543
  this.set({ __ngt_dummy__: '__ngt_dummy__' });
530
544
  // override set so our consumers don't have to handle undefined for state that already have default values
@@ -571,24 +585,13 @@ class NgtRxStore extends RxState {
571
585
  $ = combineLatest(keys.map((key) => this.select(key).pipe(startWith(this.get(key) ?? undefined))));
572
586
  }
573
587
  this.hold($, () => {
574
- requestAnimationFrame(() => void cdr.detectChanges());
588
+ requestAnimationFrame(() => void safeDetectChanges(cdr));
575
589
  });
576
590
  }
577
- key$(...keys) {
578
- const key = keys.join('.');
579
- if (!this.cache[key]) {
580
- this.cache[key] = this.select(...keys).pipe(startWith(this.get(...keys) ?? undefined), distinctUntilChanged());
581
- }
582
- return this.cache[key];
583
- }
584
- ngOnDestroy() {
585
- this.cache = {};
586
- super.ngOnDestroy();
587
- }
588
591
  }
589
- NgtRxStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtRxStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
590
- NgtRxStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtRxStore });
591
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtRxStore, decorators: [{
592
+ NgtRxStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtRxStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
593
+ NgtRxStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtRxStore });
594
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtRxStore, decorators: [{
592
595
  type: Injectable
593
596
  }], ctorParameters: function () { return []; } });
594
597
 
@@ -631,7 +634,6 @@ class NgtStore extends NgtRxStore {
631
634
  const w = h * aspect;
632
635
  return { width: w, height: h, top, left, factor: width / w, distance, aspect };
633
636
  };
634
- const pointer = new THREE.Vector2();
635
637
  let performanceTimeout;
636
638
  const setPerformanceCurrent = (current) => {
637
639
  this.set((state) => ({ performance: { ...state.performance, current } }));
@@ -650,7 +652,7 @@ class NgtStore extends NgtRxStore {
650
652
  flat: false,
651
653
  controls: null,
652
654
  clock: new THREE.Clock(),
653
- pointer,
655
+ pointer: new THREE.Vector2(),
654
656
  frameloop: 'always',
655
657
  performance: {
656
658
  current: 1,
@@ -940,8 +942,7 @@ class NgtStore extends NgtRxStore {
940
942
  let oldSize = state.size;
941
943
  let oldDpr = state.viewport.dpr;
942
944
  let oldCamera = state.camera;
943
- this.hold(this.select(selectSlice(['camera', 'size', 'viewport', 'gl'])), () => {
944
- const { camera, size, viewport, gl, set } = this.get();
945
+ this.hold(combineLatest([this.select('camera'), this.select('size'), this.select('viewport'), this.select('gl')]), ([camera, size, viewport, gl]) => {
945
946
  // resize camera and renderer on changes to size and dpr
946
947
  if (size !== oldSize || viewport.dpr !== oldDpr) {
947
948
  oldSize = size;
@@ -955,7 +956,9 @@ class NgtStore extends NgtRxStore {
955
956
  if (camera !== oldCamera) {
956
957
  updateCamera(camera, size);
957
958
  oldCamera = camera;
958
- set((state) => ({ viewport: { ...state.viewport, ...state.viewport.getCurrentViewport(camera) } }));
959
+ this.set((state) => ({
960
+ viewport: { ...state.viewport, ...state.viewport.getCurrentViewport(camera) },
961
+ }));
959
962
  }
960
963
  });
961
964
  }
@@ -963,9 +966,9 @@ class NgtStore extends NgtRxStore {
963
966
  this.hold(this.select(), () => invalidate(this));
964
967
  }
965
968
  }
966
- NgtStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtStore, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
967
- NgtStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtStore });
968
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtStore, decorators: [{
969
+ NgtStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtStore, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
970
+ NgtStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtStore });
971
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtStore, decorators: [{
969
972
  type: Injectable
970
973
  }] });
971
974
  function computeInitialSize(canvas, defaultSize) {
@@ -973,8 +976,7 @@ function computeInitialSize(canvas, defaultSize) {
973
976
  return defaultSize;
974
977
  }
975
978
  if (canvas instanceof HTMLCanvasElement && canvas.parentElement) {
976
- const { width, height, top, left } = canvas.parentElement.getBoundingClientRect();
977
- return { width, height, top, left };
979
+ return canvas.parentElement.getBoundingClientRect();
978
980
  }
979
981
  return { width: 0, height: 0, top: 0, left: 0 };
980
982
  }
@@ -1014,13 +1016,13 @@ class NgtCommonDirective {
1014
1016
  this.view.destroy();
1015
1017
  }
1016
1018
  this.view = this.vcr.createEmbeddedView(this.template);
1017
- this.view.detectChanges();
1019
+ safeDetectChanges(this.view);
1018
1020
  }
1019
1021
  }
1020
1022
  }
1021
- NgtCommonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtCommonDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1022
- NgtCommonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.0", type: NgtCommonDirective, ngImport: i0 });
1023
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtCommonDirective, decorators: [{
1023
+ NgtCommonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtCommonDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1024
+ NgtCommonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.1", type: NgtCommonDirective, ngImport: i0 });
1025
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtCommonDirective, decorators: [{
1024
1026
  type: Directive
1025
1027
  }], ctorParameters: function () { return []; } });
1026
1028
 
@@ -1049,9 +1051,9 @@ class NgtArgs extends NgtCommonDirective {
1049
1051
  return !this.injected && !!this.injectedArgs.length;
1050
1052
  }
1051
1053
  }
1052
- NgtArgs.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtArgs, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1053
- NgtArgs.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.0", type: NgtArgs, isStandalone: true, selector: "[args]", inputs: { args: "args" }, usesInheritance: true, ngImport: i0 });
1054
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtArgs, decorators: [{
1054
+ NgtArgs.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtArgs, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1055
+ NgtArgs.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.1", type: NgtArgs, isStandalone: true, selector: "[args]", inputs: { args: "args" }, usesInheritance: true, ngImport: i0 });
1056
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtArgs, decorators: [{
1055
1057
  type: Directive,
1056
1058
  args: [{ selector: '[args]', standalone: true }]
1057
1059
  }], propDecorators: { args: [{
@@ -1081,9 +1083,9 @@ class NgtParent extends NgtCommonDirective {
1081
1083
  return !this.injected && !!this.injectedParent;
1082
1084
  }
1083
1085
  }
1084
- NgtParent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtParent, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1085
- NgtParent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.0", type: NgtParent, isStandalone: true, selector: "[parent]", inputs: { parent: "parent" }, usesInheritance: true, ngImport: i0 });
1086
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtParent, decorators: [{
1086
+ NgtParent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtParent, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1087
+ NgtParent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.1", type: NgtParent, isStandalone: true, selector: "[parent]", inputs: { parent: "parent" }, usesInheritance: true, ngImport: i0 });
1088
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtParent, decorators: [{
1087
1089
  type: Directive,
1088
1090
  args: [{ selector: '[parent]', standalone: true }]
1089
1091
  }], propDecorators: { parent: [{
@@ -1618,9 +1620,8 @@ function processThreeEvent(instance, priority, eventName, callback, cdr, targetC
1618
1620
  function eventToHandler(callback, cdr, targetCdr) {
1619
1621
  return (event) => {
1620
1622
  callback(event);
1621
- if (targetCdr)
1622
- targetCdr.detectChanges();
1623
- cdr.detectChanges();
1623
+ safeDetectChanges(targetCdr);
1624
+ safeDetectChanges(cdr);
1624
1625
  };
1625
1626
  }
1626
1627
  function kebabToPascal(str) {
@@ -2038,9 +2039,9 @@ class NgtRendererFactory {
2038
2039
  return renderer;
2039
2040
  }
2040
2041
  }
2041
- NgtRendererFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtRendererFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2042
- NgtRendererFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtRendererFactory });
2043
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtRendererFactory, decorators: [{
2042
+ NgtRendererFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtRendererFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2043
+ NgtRendererFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtRendererFactory });
2044
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtRendererFactory, decorators: [{
2044
2045
  type: Injectable
2045
2046
  }] });
2046
2047
  /**
@@ -2312,9 +2313,8 @@ class NgtRenderer {
2312
2313
  // if target is DOM node, then we pass that to delegate Renderer
2313
2314
  const callbackWithCdr = (event) => {
2314
2315
  const value = callback(event);
2315
- if (targetCdr)
2316
- targetCdr.detectChanges();
2317
- this.store.rootCdr.detectChanges();
2316
+ safeDetectChanges(targetCdr);
2317
+ safeDetectChanges(this.store.rootCdr);
2318
2318
  return value;
2319
2319
  };
2320
2320
  if (this.store.isDOM(target)) {
@@ -2520,7 +2520,7 @@ class NgtCanvas extends NgtRxStore {
2520
2520
  this.store.set({
2521
2521
  onPointerMissed: (event) => {
2522
2522
  this.pointerMissed.emit(event);
2523
- this.cdr.detectChanges();
2523
+ safeDetectChanges(this.cdr);
2524
2524
  },
2525
2525
  });
2526
2526
  }
@@ -2560,20 +2560,16 @@ class NgtCanvas extends NgtRxStore {
2560
2560
  // emit created event if observed
2561
2561
  if (this.created.observed) {
2562
2562
  this.created.emit(this.store.get());
2563
- this.cdr.detectChanges();
2564
2563
  }
2565
2564
  // render
2566
2565
  if (this.glRef)
2567
2566
  this.glRef.destroy();
2568
2567
  requestAnimationFrame(() => {
2569
- this.glEnvInjector = createEnvironmentInjector([
2570
- provideNgtRenderer({
2571
- store: this.store,
2572
- changeDetectorRef: this.cdr,
2573
- compoundPrefixes: this.compoundPrefixes,
2574
- }),
2575
- ], this.envInjector);
2568
+ const { store, cdr: changeDetectorRef, compoundPrefixes } = this;
2569
+ this.glEnvInjector = createEnvironmentInjector([provideNgtRenderer({ store, changeDetectorRef, compoundPrefixes })], this.envInjector);
2576
2570
  this.glRef = this.glAnchor.createComponent(this.sceneGraph, { environmentInjector: this.glEnvInjector });
2571
+ // detach the Scene graph from Change Detection mechanism
2572
+ // everything from this point forward will trigger CD manually with detectChanges
2577
2573
  this.glRef.changeDetectorRef.detach();
2578
2574
  this.setSceneGraphInputs();
2579
2575
  // here, we override the detectChanges to also call detectChanges on the ComponentRef
@@ -2594,23 +2590,23 @@ class NgtCanvas extends NgtRxStore {
2594
2590
  const originalDetectChanges = this.cdr.detectChanges.bind(this.cdr);
2595
2591
  this.cdr.detectChanges = () => {
2596
2592
  originalDetectChanges();
2597
- this.glRef?.changeDetectorRef.detectChanges();
2593
+ safeDetectChanges(this.glRef?.changeDetectorRef);
2598
2594
  };
2599
2595
  }
2600
2596
  setSceneGraphInputs() {
2601
2597
  for (const key of Object.keys(this.sceneGraphInputs)) {
2602
- this.glRef?.setInput(key, this.sceneGraphInputs[key]);
2598
+ this.glRef.setInput(key, this.sceneGraphInputs[key]);
2603
2599
  }
2604
- this.cdr.detectChanges();
2600
+ safeDetectChanges(this.cdr);
2605
2601
  }
2606
2602
  }
2607
- NgtCanvas.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtCanvas, deps: null, target: i0.ɵɵFactoryTarget.Component });
2608
- NgtCanvas.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.0", type: NgtCanvas, isStandalone: true, selector: "ngt-canvas", inputs: { sceneGraph: "sceneGraph", sceneGraphInputs: "sceneGraphInputs", compoundPrefixes: "compoundPrefixes", linear: "linear", legacy: "legacy", flat: "flat", orthographic: "orthographic", frameloop: "frameloop", dpr: "dpr", raycaster: "raycaster", shadows: "shadows", camera: "camera", gl: "gl", eventSource: "eventSource", eventPrefix: "eventPrefix", lookAt: "lookAt", performance: "performance" }, outputs: { created: "created", pointerMissed: "pointerMissed" }, host: { properties: { "class.ngt-canvas": "this.hostClass", "style.pointerEvents": "this.pointerEvents" } }, providers: [NgtStore, provideNgxResizeOptions({ emitInZone: false })], viewQueries: [{ propertyName: "glCanvas", first: true, predicate: ["glCanvas"], descendants: true, static: true }, { propertyName: "glAnchor", first: true, predicate: ["glCanvas"], descendants: true, read: ViewContainerRef, static: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: `
2603
+ NgtCanvas.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtCanvas, deps: null, target: i0.ɵɵFactoryTarget.Component });
2604
+ NgtCanvas.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.1", type: NgtCanvas, isStandalone: true, selector: "ngt-canvas", inputs: { sceneGraph: "sceneGraph", sceneGraphInputs: "sceneGraphInputs", compoundPrefixes: "compoundPrefixes", linear: "linear", legacy: "legacy", flat: "flat", orthographic: "orthographic", frameloop: "frameloop", dpr: "dpr", raycaster: "raycaster", shadows: "shadows", camera: "camera", gl: "gl", eventSource: "eventSource", eventPrefix: "eventPrefix", lookAt: "lookAt", performance: "performance" }, outputs: { created: "created", pointerMissed: "pointerMissed" }, host: { properties: { "class.ngt-canvas": "this.hostClass", "style.pointerEvents": "this.pointerEvents" } }, providers: [NgtStore, provideNgxResizeOptions({ emitInZone: false })], viewQueries: [{ propertyName: "glCanvas", first: true, predicate: ["glCanvas"], descendants: true, static: true }, { propertyName: "glAnchor", first: true, predicate: ["glCanvas"], descendants: true, read: ViewContainerRef, static: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: `
2609
2605
  <div (ngxResize)="onResize($event)" style="height: 100%; width: 100%;">
2610
2606
  <canvas #glCanvas style="display: block;"></canvas>
2611
2607
  </div>
2612
2608
  `, isInline: true, styles: [":host{display:block;position:relative;width:100%;height:100%;overflow:hidden}\n"], dependencies: [{ kind: "directive", type: NgxResize, selector: "[ngxResize]", inputs: ["ngxResizeOptions"], outputs: ["ngxResize"] }] });
2613
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtCanvas, decorators: [{
2609
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtCanvas, decorators: [{
2614
2610
  type: Component,
2615
2611
  args: [{ selector: 'ngt-canvas', standalone: true, template: `
2616
2612
  <div (ngxResize)="onResize($event)" style="height: 100%; width: 100%;">
@@ -2702,19 +2698,6 @@ function injectBeforeRender(cb, priority = 0) {
2702
2698
  }
2703
2699
  }
2704
2700
 
2705
- function safeDetectChanges(cdr) {
2706
- if (!cdr)
2707
- return;
2708
- try {
2709
- if (cdr['context']) {
2710
- cdr.detectChanges();
2711
- }
2712
- }
2713
- catch (e) {
2714
- cdr.markForCheck();
2715
- }
2716
- }
2717
-
2718
2701
  function injectNgtRef(initialValue = null) {
2719
2702
  const ref = is.ref(initialValue) ? initialValue : new ElementRef(initialValue);
2720
2703
  let lastValue = ref.nativeElement;
@@ -2731,6 +2714,7 @@ function injectNgtRef(initialValue = null) {
2731
2714
  lastValue = current;
2732
2715
  });
2733
2716
  };
2717
+ const useCDR = (cdr) => void cdRefs.push(cdr);
2734
2718
  const $ = obs$.pipe(filter((value, index) => index > 0 || value != null), takeUntil(destroy$));
2735
2719
  const children$ = (type = 'objects') => $.pipe(switchMap((instance) => {
2736
2720
  const localState = getLocalState(instance);
@@ -2749,6 +2733,7 @@ function injectNgtRef(initialValue = null) {
2749
2733
  }
2750
2734
  return of([]);
2751
2735
  }), filter((children, index) => index > 0 || children.length > 0), takeUntil(destroy$));
2736
+ // here, we override nativeElement to add more functionalities to nativeElement
2752
2737
  Object.defineProperty(ref, 'nativeElement', {
2753
2738
  set: (newVal) => {
2754
2739
  if (ref.nativeElement !== newVal) {
@@ -2773,9 +2758,14 @@ function injectNgtRef(initialValue = null) {
2773
2758
  },
2774
2759
  get: () => ref$.value,
2775
2760
  });
2776
- return Object.assign(ref, { subscribe, $, children$, useCDR: (cdr) => void cdRefs.push(cdr) });
2761
+ return Object.assign(ref, { subscribe, $, children$, useCDR });
2777
2762
  }
2778
2763
 
2764
+ /**
2765
+ * Please use this sparringly and know what you're doing.
2766
+ *
2767
+ * Create a runInContext function that has access to the NodeInjector as well
2768
+ */
2779
2769
  function createRunInContext() {
2780
2770
  const nodeInjector = inject(Injector);
2781
2771
  const envInjector = inject(EnvironmentInjector);
@@ -2815,9 +2805,9 @@ class NgtRepeat extends NgForOf {
2815
2805
  this.ngForOf = Number.isInteger(count) ? Array.from({ length: count }, (_, i) => i) : [];
2816
2806
  }
2817
2807
  }
2818
- NgtRepeat.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtRepeat, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2819
- NgtRepeat.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.0", type: NgtRepeat, isStandalone: true, selector: "[ngFor][ngForRepeat]", inputs: { ngForRepeat: "ngForRepeat" }, usesInheritance: true, ngImport: i0 });
2820
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtRepeat, decorators: [{
2808
+ NgtRepeat.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtRepeat, deps: null, target: i0.ɵɵFactoryTarget.Directive });
2809
+ NgtRepeat.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.1", type: NgtRepeat, isStandalone: true, selector: "[ngFor][ngForRepeat]", inputs: { ngForRepeat: "ngForRepeat" }, usesInheritance: true, ngImport: i0 });
2810
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtRepeat, decorators: [{
2821
2811
  type: Directive,
2822
2812
  args: [{ selector: '[ngFor][ngForRepeat]', standalone: true }]
2823
2813
  }], propDecorators: { ngForRepeat: [{
@@ -2832,50 +2822,43 @@ class NgtPush {
2832
2822
  constructor() {
2833
2823
  this.cdr = inject(ChangeDetectorRef);
2834
2824
  this.parentCdr = inject(ChangeDetectorRef, { skipSelf: true, optional: true });
2825
+ this.envCdr = inject(EnvironmentInjector).get(ChangeDetectorRef, null);
2835
2826
  }
2836
2827
  transform(value, defaultValue = null) {
2837
- if (this.obj === value) {
2828
+ if (this.obj === value)
2838
2829
  return this.latestValue;
2839
- }
2840
2830
  this.obj = value;
2841
2831
  this.latestValue = defaultValue;
2842
- if (this.sub) {
2832
+ if (this.sub)
2843
2833
  this.sub.unsubscribe();
2844
- }
2845
- if (isObservable(this.obj)) {
2834
+ if (isObservable(this.obj))
2846
2835
  this.sub = this.obj.subscribe(this.updateValue.bind(this));
2847
- }
2848
- else if (isPromise(this.obj)) {
2836
+ else if (isPromise(this.obj))
2849
2837
  this.obj.then(this.updateValue.bind(this));
2850
- }
2851
- else {
2838
+ else
2852
2839
  throw new Error(`[NGT] Invalid value passed to ngtPush pipe`);
2853
- }
2854
2840
  return this.latestValue;
2855
2841
  }
2856
2842
  updateValue(val) {
2857
2843
  this.latestValue = val;
2858
- this.cdr.detectChanges();
2859
- if (this.parentCdr) {
2860
- this.parentCdr.detectChanges();
2861
- }
2844
+ safeDetectChanges(this.cdr);
2845
+ safeDetectChanges(this.parentCdr);
2846
+ safeDetectChanges(this.envCdr);
2862
2847
  }
2863
2848
  ngOnDestroy() {
2864
- if (this.sub) {
2849
+ if (this.sub)
2865
2850
  this.sub.unsubscribe();
2866
- }
2867
2851
  this.latestValue = undefined;
2868
2852
  this.obj = undefined;
2869
2853
  }
2870
2854
  }
2871
- NgtPush.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtPush, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2872
- NgtPush.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.0", ngImport: i0, type: NgtPush, isStandalone: true, name: "ngtPush", pure: false });
2873
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtPush, decorators: [{
2855
+ NgtPush.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtPush, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2856
+ NgtPush.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.1", ngImport: i0, type: NgtPush, isStandalone: true, name: "ngtPush", pure: false });
2857
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtPush, decorators: [{
2874
2858
  type: Pipe,
2875
2859
  args: [{ name: 'ngtPush', pure: false, standalone: true }]
2876
2860
  }] });
2877
2861
 
2878
- var _NgtPortal_instances, _NgtPortal_inject;
2879
2862
  const privateKeys = [
2880
2863
  'get',
2881
2864
  'set',
@@ -2920,9 +2903,9 @@ class NgtPortalBeforeRender {
2920
2903
  this.subscription?.();
2921
2904
  }
2922
2905
  }
2923
- NgtPortalBeforeRender.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtPortalBeforeRender, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2924
- NgtPortalBeforeRender.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.0", type: NgtPortalBeforeRender, isStandalone: true, selector: "ngt-portal-before-render", inputs: { renderPriority: "renderPriority", parentScene: "parentScene", parentCamera: "parentCamera" }, outputs: { beforeRender: "beforeRender" }, ngImport: i0 });
2925
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtPortalBeforeRender, decorators: [{
2906
+ NgtPortalBeforeRender.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtPortalBeforeRender, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2907
+ NgtPortalBeforeRender.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.1", type: NgtPortalBeforeRender, isStandalone: true, selector: "ngt-portal-before-render", inputs: { renderPriority: "renderPriority", parentScene: "parentScene", parentCamera: "parentCamera" }, outputs: { beforeRender: "beforeRender" }, ngImport: i0 });
2908
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtPortalBeforeRender, decorators: [{
2926
2909
  type: Directive,
2927
2910
  args: [{
2928
2911
  selector: 'ngt-portal-before-render',
@@ -2946,9 +2929,9 @@ class NgtPortalContent {
2946
2929
  }
2947
2930
  }
2948
2931
  }
2949
- NgtPortalContent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtPortalContent, deps: [{ token: i0.ViewContainerRef }, { token: i0.ViewContainerRef, skipSelf: true }], target: i0.ɵɵFactoryTarget.Directive });
2950
- NgtPortalContent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.0", type: NgtPortalContent, isStandalone: true, selector: "ng-template[ngtPortalContent]", ngImport: i0 });
2951
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtPortalContent, decorators: [{
2932
+ NgtPortalContent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtPortalContent, deps: [{ token: i0.ViewContainerRef }, { token: i0.ViewContainerRef, skipSelf: true }], target: i0.ɵɵFactoryTarget.Directive });
2933
+ NgtPortalContent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.1", type: NgtPortalContent, isStandalone: true, selector: "ng-template[ngtPortalContent]", ngImport: i0 });
2934
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtPortalContent, decorators: [{
2952
2935
  type: Directive,
2953
2936
  args: [{ selector: 'ng-template[ngtPortalContent]', standalone: true }]
2954
2937
  }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.ViewContainerRef, decorators: [{
@@ -2957,7 +2940,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImpor
2957
2940
  class NgtPortal extends NgtRxStore {
2958
2941
  constructor() {
2959
2942
  super(...arguments);
2960
- _NgtPortal_instances.add(this);
2961
2943
  this.autoRender = true;
2962
2944
  this.autoRenderPriority = 1;
2963
2945
  this.beforeRender = new EventEmitter();
@@ -3006,9 +2988,9 @@ class NgtPortal extends NgtRxStore {
3006
2988
  select: this.portalStore.select.bind(this.portalStore),
3007
2989
  setEvents: (events) => this.portalStore.set((state) => ({ ...state, events: { ...state.events, ...events } })),
3008
2990
  });
3009
- this.hold(this.parentStore.select(), (previous) => this.portalStore.set((state) => __classPrivateFieldGet(this, _NgtPortal_instances, "m", _NgtPortal_inject).call(this, previous, state)));
2991
+ this.hold(this.parentStore.select(), (previous) => this.portalStore.set((state) => this.inject(previous, state)));
3010
2992
  requestAnimationFrame(() => {
3011
- this.portalStore.set((injectState) => __classPrivateFieldGet(this, _NgtPortal_instances, "m", _NgtPortal_inject).call(this, this.parentStore.get(), injectState));
2993
+ this.portalStore.set((injectState) => this.inject(this.parentStore.get(), injectState));
3012
2994
  });
3013
2995
  this.portalContentView = this.portalContentAnchor.createEmbeddedView(this.portalContentTemplate);
3014
2996
  this.portalContentView.detectChanges();
@@ -3026,38 +3008,38 @@ class NgtPortal extends NgtRxStore {
3026
3008
  }
3027
3009
  super.ngOnDestroy();
3028
3010
  }
3029
- }
3030
- _NgtPortal_instances = new WeakSet(), _NgtPortal_inject = function _NgtPortal_inject(rootState, injectState) {
3031
- const intersect = { ...rootState };
3032
- Object.keys(intersect).forEach((key) => {
3033
- if (privateKeys.includes(key) ||
3034
- rootState[key] !== injectState[key]) {
3035
- delete intersect[key];
3011
+ inject(rootState, injectState) {
3012
+ const intersect = { ...rootState };
3013
+ Object.keys(intersect).forEach((key) => {
3014
+ if (privateKeys.includes(key) ||
3015
+ rootState[key] !== injectState[key]) {
3016
+ delete intersect[key];
3017
+ }
3018
+ });
3019
+ const inputs = this.get();
3020
+ const { size, events, ...restInputsState } = inputs.state || {};
3021
+ let viewport = undefined;
3022
+ if (injectState && size) {
3023
+ const camera = injectState.camera;
3024
+ viewport = rootState.viewport.getCurrentViewport(camera, new THREE.Vector3(), size);
3025
+ if (camera !== rootState.camera)
3026
+ updateCamera(camera, size);
3036
3027
  }
3037
- });
3038
- const inputs = this.get();
3039
- const { size, events, ...restInputsState } = inputs.state || {};
3040
- let viewport = undefined;
3041
- if (injectState && size) {
3042
- const camera = injectState.camera;
3043
- viewport = rootState.viewport.getCurrentViewport(camera, new THREE.Vector3(), size);
3044
- if (camera !== rootState.camera)
3045
- updateCamera(camera, size);
3028
+ return {
3029
+ ...intersect,
3030
+ scene: is.ref(inputs.container) ? inputs.container.nativeElement : inputs.container,
3031
+ raycaster: this.raycaster,
3032
+ pointer: this.pointer,
3033
+ previousStore: this.parentStore,
3034
+ events: { ...rootState.events, ...(injectState?.events || {}), ...events },
3035
+ size: { ...rootState.size, ...size },
3036
+ viewport: { ...rootState.viewport, ...(viewport || {}) },
3037
+ ...restInputsState,
3038
+ };
3046
3039
  }
3047
- return {
3048
- ...intersect,
3049
- scene: is.ref(inputs.container) ? inputs.container.nativeElement : inputs.container,
3050
- raycaster: this.raycaster,
3051
- pointer: this.pointer,
3052
- previousStore: this.parentStore,
3053
- events: { ...rootState.events, ...(injectState?.events || {}), ...events },
3054
- size: { ...rootState.size, ...size },
3055
- viewport: { ...rootState.viewport, ...(viewport || {}) },
3056
- ...restInputsState,
3057
- };
3058
- };
3059
- NgtPortal.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtPortal, deps: null, target: i0.ɵɵFactoryTarget.Component });
3060
- NgtPortal.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.0", type: NgtPortal, isStandalone: true, selector: "ngt-portal", inputs: { container: "container", state: "state", autoRender: "autoRender", autoRenderPriority: "autoRenderPriority" }, outputs: { beforeRender: "beforeRender" }, providers: [NgtStore], queries: [{ propertyName: "portalContentTemplate", first: true, predicate: NgtPortalContent, descendants: true, read: TemplateRef, static: true }], viewQueries: [{ propertyName: "portalContentAnchor", first: true, predicate: ["portalContentAnchor"], descendants: true, read: ViewContainerRef, static: true }], usesInheritance: true, ngImport: i0, template: `
3040
+ }
3041
+ NgtPortal.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtPortal, deps: null, target: i0.ɵɵFactoryTarget.Component });
3042
+ NgtPortal.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.1", type: NgtPortal, isStandalone: true, selector: "ngt-portal", inputs: { container: "container", state: "state", autoRender: "autoRender", autoRenderPriority: "autoRenderPriority" }, outputs: { beforeRender: "beforeRender" }, providers: [NgtStore], queries: [{ propertyName: "portalContentTemplate", first: true, predicate: NgtPortalContent, descendants: true, read: TemplateRef, static: true }], viewQueries: [{ propertyName: "portalContentAnchor", first: true, predicate: ["portalContentAnchor"], descendants: true, read: ViewContainerRef, static: true }], usesInheritance: true, ngImport: i0, template: `
3061
3043
  <ng-container #portalContentAnchor>
3062
3044
  <ngt-portal-before-render
3063
3045
  *ngIf="autoRender && portalContentRendered"
@@ -3068,7 +3050,7 @@ NgtPortal.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15
3068
3050
  />
3069
3051
  </ng-container>
3070
3052
  `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgtPortalBeforeRender, selector: "ngt-portal-before-render", inputs: ["renderPriority", "parentScene", "parentCamera"], outputs: ["beforeRender"] }] });
3071
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtPortal, decorators: [{
3053
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtPortal, decorators: [{
3072
3054
  type: Component,
3073
3055
  args: [{
3074
3056
  selector: 'ngt-portal',
@@ -3110,13 +3092,13 @@ class NgtRoutedScene {
3110
3092
  const { destroy$, cdr } = injectNgtDestroy();
3111
3093
  router.events
3112
3094
  .pipe(filter((event) => event instanceof ActivationEnd), takeUntil(destroy$))
3113
- .subscribe(cdr.detectChanges.bind(cdr));
3095
+ .subscribe(() => safeDetectChanges(cdr));
3114
3096
  }
3115
3097
  }
3116
3098
  NgtRoutedScene.isRoutedScene = true;
3117
- NgtRoutedScene.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtRoutedScene, deps: [{ token: i1.Router }], target: i0.ɵɵFactoryTarget.Component });
3118
- NgtRoutedScene.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.0", type: NgtRoutedScene, isStandalone: true, selector: "ngt-routed-scene", ngImport: i0, template: `<router-outlet />`, isInline: true, dependencies: [{ kind: "directive", type: RouterOutlet, selector: "router-outlet", inputs: ["name"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }] });
3119
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: NgtRoutedScene, decorators: [{
3099
+ NgtRoutedScene.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtRoutedScene, deps: [{ token: i1.Router }], target: i0.ɵɵFactoryTarget.Component });
3100
+ NgtRoutedScene.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.1", type: NgtRoutedScene, isStandalone: true, selector: "ngt-routed-scene", ngImport: i0, template: `<router-outlet />`, isInline: true, dependencies: [{ kind: "directive", type: RouterOutlet, selector: "router-outlet", inputs: ["name"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }] });
3101
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.1", ngImport: i0, type: NgtRoutedScene, decorators: [{
3120
3102
  type: Component,
3121
3103
  args: [{
3122
3104
  standalone: true,