angular-three 1.0.0-beta.1 → 1.0.0-beta.10

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,12 +1,114 @@
1
1
  import * as i0 from '@angular/core';
2
- import { ElementRef, Injectable, inject, InjectionToken, ViewContainerRef, TemplateRef, Directive, Input, EventEmitter, getDebugNode, ChangeDetectorRef, RendererFactory2, Component, Output, EnvironmentInjector, createEnvironmentInjector, HostBinding, ViewChild } from '@angular/core';
3
- import { injectNgxResize, provideNgxResizeOptions } from 'ngx-resize';
4
- import { BehaviorSubject, startWith, tap, isObservable, of, map, from, retry, catchError, share, ReplaySubject, switchMap, forkJoin, take, filter } from 'rxjs';
2
+ import { ElementRef, Injectable, inject, InjectionToken, ViewContainerRef, TemplateRef, Directive, Input, EventEmitter, getDebugNode, ChangeDetectorRef, RendererFactory2, EnvironmentInjector, createEnvironmentInjector, Component, HostBinding, Output, ViewChild, Pipe } from '@angular/core';
3
+ import { provideNgxResizeOptions, NgxResize } from 'ngx-resize';
4
+ import { isObservable, of, map, from, tap, retry, catchError, share, ReplaySubject, switchMap, forkJoin, take, BehaviorSubject, startWith, filter, distinctUntilChanged, takeUntil, merge } from 'rxjs';
5
+ import * as THREE from 'three';
5
6
  import { DOCUMENT, NgForOf } from '@angular/common';
6
7
  import { RxState, selectSlice } from '@rx-angular/state';
7
- import * as THREE from 'three';
8
8
  import { ɵDomRendererFactory2 } from '@angular/platform-browser';
9
9
 
10
+ const idCache = {};
11
+ function makeId(event) {
12
+ if (event) {
13
+ return (event.eventObject || event.object).uuid + '/' + event.index + event.instanceId;
14
+ }
15
+ const newId = THREE.MathUtils.generateUUID();
16
+ // ensure not already used
17
+ if (!idCache[newId]) {
18
+ idCache[newId] = true;
19
+ return newId;
20
+ }
21
+ return makeId();
22
+ }
23
+ function makeDpr(dpr, window) {
24
+ const target = window?.devicePixelRatio || 1;
25
+ return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
26
+ }
27
+ function makeDefaultCamera(isOrthographic, size) {
28
+ if (isOrthographic)
29
+ return new THREE.OrthographicCamera(0, 0, 0, 0, 0.1, 1000);
30
+ return new THREE.PerspectiveCamera(75, size.width / size.height, 0.1, 1000);
31
+ }
32
+ function makeDefaultRenderer(glOptions, canvasElement) {
33
+ const customRenderer = (typeof glOptions === 'function' ? glOptions(canvasElement) : glOptions);
34
+ if (customRenderer?.render != null)
35
+ return customRenderer;
36
+ return new THREE.WebGLRenderer({
37
+ powerPreference: 'high-performance',
38
+ canvas: canvasElement,
39
+ antialias: true,
40
+ alpha: true,
41
+ ...(glOptions || {}),
42
+ });
43
+ }
44
+ function makeObjectGraph(object) {
45
+ const data = { nodes: {}, materials: {} };
46
+ if (object) {
47
+ object.traverse((child) => {
48
+ if (child.name)
49
+ data.nodes[child.name] = child;
50
+ if ('material' in child && !data.materials[child.material.name]) {
51
+ data.materials[child.material.name] = child
52
+ .material;
53
+ }
54
+ });
55
+ }
56
+ return data;
57
+ }
58
+
59
+ const cached = new Map();
60
+ function injectLoader(loaderConstructorFactory, input, extensions, onProgress) {
61
+ const urls$ = isObservable(input) ? input : of(input);
62
+ return urls$.pipe(map((inputs) => {
63
+ const loaderConstructor = loaderConstructorFactory(inputs);
64
+ const loader = new loaderConstructor();
65
+ if (extensions) {
66
+ extensions(loader);
67
+ }
68
+ const urls = Array.isArray(inputs) ? inputs : typeof inputs === 'string' ? [inputs] : Object.values(inputs);
69
+ return [
70
+ urls.map((url) => {
71
+ if (!cached.has(url)) {
72
+ cached.set(url, from(loader.loadAsync(url, onProgress)).pipe(tap((data) => {
73
+ if (data.scene) {
74
+ Object.assign(data, makeObjectGraph(data.scene));
75
+ }
76
+ }), retry(2), catchError((err) => {
77
+ console.error(`[NGT] Error loading ${url}: ${err.message}`);
78
+ return of([]);
79
+ }), share({
80
+ connector: () => new ReplaySubject(1),
81
+ resetOnComplete: true,
82
+ resetOnError: true,
83
+ resetOnRefCountZero: true,
84
+ })));
85
+ }
86
+ return cached.get(url);
87
+ }),
88
+ inputs,
89
+ ];
90
+ }), switchMap(([observables$, inputs]) => {
91
+ return forkJoin(observables$).pipe(map((results) => {
92
+ if (Array.isArray(inputs))
93
+ return results;
94
+ if (typeof inputs === 'string')
95
+ return results[0];
96
+ const keys = Object.keys(inputs);
97
+ return keys.reduce((result, key) => {
98
+ result[key] = results[keys.indexOf(key)];
99
+ return result;
100
+ }, {});
101
+ }));
102
+ }));
103
+ }
104
+ injectLoader.destroy = () => {
105
+ cached.clear();
106
+ };
107
+ injectLoader.preLoad = (loaderConstructorFactory, inputs, extensions) => {
108
+ injectLoader(loaderConstructorFactory, inputs, extensions).pipe(take(1)).subscribe();
109
+ };
110
+ const injectNgtLoader = injectLoader;
111
+
10
112
  function createSubs(callback, subs) {
11
113
  const sub = { callback };
12
114
  subs.add(sub);
@@ -364,55 +466,6 @@ function applyProps(instance, props) {
364
466
  return instance;
365
467
  }
366
468
 
367
- const idCache = {};
368
- function makeId(event) {
369
- if (event) {
370
- return (event.eventObject || event.object).uuid + '/' + event.index + event.instanceId;
371
- }
372
- const newId = THREE.MathUtils.generateUUID();
373
- // ensure not already used
374
- if (!idCache[newId]) {
375
- idCache[newId] = true;
376
- return newId;
377
- }
378
- return makeId();
379
- }
380
- function makeDpr(dpr, window) {
381
- const target = window?.devicePixelRatio || 1;
382
- return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
383
- }
384
- function makeDefaultCamera(isOrthographic, size) {
385
- if (isOrthographic)
386
- return new THREE.OrthographicCamera(0, 0, 0, 0, 0.1, 1000);
387
- return new THREE.PerspectiveCamera(75, size.width / size.height, 0.1, 1000);
388
- }
389
- function makeDefaultRenderer(glOptions, canvasElement) {
390
- const customRenderer = (typeof glOptions === 'function' ? glOptions(canvasElement) : glOptions);
391
- if (customRenderer?.render != null)
392
- return customRenderer;
393
- return new THREE.WebGLRenderer({
394
- powerPreference: 'high-performance',
395
- canvas: canvasElement,
396
- antialias: true,
397
- alpha: true,
398
- ...(glOptions || {}),
399
- });
400
- }
401
- function makeObjectGraph(object) {
402
- const data = { nodes: {}, materials: {} };
403
- if (object) {
404
- object.traverse((child) => {
405
- if (child.name)
406
- data.nodes[child.name] = child;
407
- if ('material' in child && !data.materials[child.material.name]) {
408
- data.materials[child.material.name] = child
409
- .material;
410
- }
411
- });
412
- }
413
- return data;
414
- }
415
-
416
469
  const startWithUndefined = () => startWith(undefined);
417
470
  /**
418
471
  * An extended `tap` operator that accepts an `effectFn` which:
@@ -787,7 +840,7 @@ class NgtStore extends NgtRxStore {
787
840
  // Safely set color management if available.
788
841
  // Avoid accessing THREE.ColorManagement to play nice with older versions
789
842
  if (THREE.ColorManagement)
790
- THREE.ColorManagement.legacyMode = state.legacy;
843
+ THREE.ColorManagement.legacyMode = legacy ?? true;
791
844
  const outputEncoding = linear ? THREE.LinearEncoding : THREE.sRGBEncoding;
792
845
  const toneMapping = flat ? THREE.NoToneMapping : THREE.ACESFilmicToneMapping;
793
846
  if (gl.outputEncoding !== outputEncoding)
@@ -2181,72 +2234,6 @@ function createPointerEvents(store) {
2181
2234
  };
2182
2235
  }
2183
2236
 
2184
- const cached = new Map();
2185
- function injectLoader(loaderConstructorFactory, input, extensions, onProgress) {
2186
- const urls$ = isObservable(input) ? input : of(input);
2187
- return urls$.pipe(map((inputs) => {
2188
- const loaderConstructor = loaderConstructorFactory(inputs);
2189
- const loader = new loaderConstructor();
2190
- if (extensions) {
2191
- extensions(loader);
2192
- }
2193
- const urls = Array.isArray(inputs) ? inputs : typeof inputs === 'string' ? [inputs] : Object.values(inputs);
2194
- return [
2195
- urls.map((url) => {
2196
- if (!cached.has(url)) {
2197
- cached.set(url, from(loader.loadAsync(url, onProgress)).pipe(tap((data) => {
2198
- if (data.scene) {
2199
- Object.assign(data, makeObjectGraph(data.scene));
2200
- }
2201
- }), retry(2), catchError((err) => {
2202
- console.error(`[NGT] Error loading ${url}: ${err.message}`);
2203
- return of([]);
2204
- }), share({
2205
- connector: () => new ReplaySubject(1),
2206
- resetOnComplete: true,
2207
- resetOnError: true,
2208
- resetOnRefCountZero: true,
2209
- })));
2210
- }
2211
- return cached.get(url);
2212
- }),
2213
- inputs,
2214
- ];
2215
- }), switchMap(([observables$, inputs]) => {
2216
- return forkJoin(observables$).pipe(map((results) => {
2217
- if (Array.isArray(inputs))
2218
- return results;
2219
- if (typeof inputs === 'string')
2220
- return results[0];
2221
- const keys = Object.keys(inputs);
2222
- return keys.reduce((result, key) => {
2223
- result[key] = results[keys.indexOf(key)];
2224
- return result;
2225
- }, {});
2226
- }));
2227
- }));
2228
- }
2229
- injectLoader.destroy = () => {
2230
- cached.clear();
2231
- };
2232
- injectLoader.preLoad = (loaderConstructorFactory, inputs, extensions) => {
2233
- injectLoader(loaderConstructorFactory, inputs, extensions).pipe(take(1)).subscribe();
2234
- };
2235
- const injectNgtLoader = injectLoader;
2236
-
2237
- class NgtCanvasContainer {
2238
- constructor() {
2239
- this.canvasResize = injectNgxResize();
2240
- }
2241
- }
2242
- NgtCanvasContainer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: NgtCanvasContainer, deps: [], target: i0.ɵɵFactoryTarget.Component });
2243
- NgtCanvasContainer.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.1", type: NgtCanvasContainer, isStandalone: true, selector: "ngt-canvas-container", outputs: { canvasResize: "canvasResize" }, providers: [provideNgxResizeOptions({ emitInZone: false })], ngImport: i0, template: '<ng-content />', isInline: true, styles: [":host{display:block;width:100%;height:100%}\n"] });
2244
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: NgtCanvasContainer, decorators: [{
2245
- type: Component,
2246
- args: [{ selector: 'ngt-canvas-container', standalone: true, template: '<ng-content />', providers: [provideNgxResizeOptions({ emitInZone: false })], styles: [":host{display:block;width:100%;height:100%}\n"] }]
2247
- }], propDecorators: { canvasResize: [{
2248
- type: Output
2249
- }] } });
2250
2237
  class NgtCanvas extends NgtRxStore {
2251
2238
  constructor() {
2252
2239
  super(...arguments);
@@ -2384,9 +2371,12 @@ class NgtCanvas extends NgtRxStore {
2384
2371
  compoundPrefixes: this.compoundPrefixes,
2385
2372
  }),
2386
2373
  ], this.envInjector);
2387
- this.glRef = this.glAnchor.createComponent(this.scene, { environmentInjector: this.glEnvInjector });
2388
- this.glRef.changeDetectorRef.detectChanges();
2374
+ this.glRef = this.glAnchor.createComponent(this.sceneGraph, {
2375
+ environmentInjector: this.glEnvInjector,
2376
+ });
2389
2377
  this.glRef.changeDetectorRef.detach();
2378
+ // here, we override the detectChanges to also call detectChanges on the ComponentRef
2379
+ this.overrideDetectChanges();
2390
2380
  this.cdr.detectChanges();
2391
2381
  });
2392
2382
  }
@@ -2400,29 +2390,34 @@ class NgtCanvas extends NgtRxStore {
2400
2390
  injectNgtLoader.destroy();
2401
2391
  super.ngOnDestroy();
2402
2392
  }
2393
+ overrideDetectChanges() {
2394
+ const originalDetectChanges = this.cdr.detectChanges.bind(this.cdr);
2395
+ this.cdr.detectChanges = () => {
2396
+ originalDetectChanges();
2397
+ this.glRef?.changeDetectorRef.detectChanges();
2398
+ };
2399
+ }
2403
2400
  }
2404
2401
  NgtCanvas.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: NgtCanvas, deps: null, target: i0.ɵɵFactoryTarget.Component });
2405
- NgtCanvas.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.1", type: NgtCanvas, isStandalone: true, selector: "ngt-canvas", inputs: { scene: "scene", 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], viewQueries: [{ propertyName: "glCanvas", first: true, predicate: ["glCanvas"], descendants: true, static: true }, { propertyName: "glAnchor", first: true, predicate: ["glAnchor"], descendants: true, read: ViewContainerRef, static: true }], usesInheritance: true, ngImport: i0, template: `
2406
- <ngt-canvas-container (canvasResize)="onResize($event)">
2402
+ NgtCanvas.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.1", type: NgtCanvas, isStandalone: true, selector: "ngt-canvas", inputs: { sceneGraph: "sceneGraph", 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, ngImport: i0, template: `
2403
+ <div (ngxResize)="onResize($event)" style="height: 100%; width: 100%;">
2407
2404
  <canvas #glCanvas style="display: block;"></canvas>
2408
- <ng-container #glAnchor />
2409
- </ngt-canvas-container>
2410
- `, isInline: true, styles: [":host{display:block;position:relative;width:100%;height:100%;overflow:hidden}\n"], dependencies: [{ kind: "component", type: NgtCanvasContainer, selector: "ngt-canvas-container", outputs: ["canvasResize"] }] });
2405
+ </div>
2406
+ `, 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"] }] });
2411
2407
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: NgtCanvas, decorators: [{
2412
2408
  type: Component,
2413
2409
  args: [{ selector: 'ngt-canvas', standalone: true, template: `
2414
- <ngt-canvas-container (canvasResize)="onResize($event)">
2410
+ <div (ngxResize)="onResize($event)" style="height: 100%; width: 100%;">
2415
2411
  <canvas #glCanvas style="display: block;"></canvas>
2416
- <ng-container #glAnchor />
2417
- </ngt-canvas-container>
2418
- `, imports: [NgtCanvasContainer], providers: [NgtStore], styles: [":host{display:block;position:relative;width:100%;height:100%;overflow:hidden}\n"] }]
2412
+ </div>
2413
+ `, imports: [NgxResize], providers: [NgtStore, provideNgxResizeOptions({ emitInZone: false })], styles: [":host{display:block;position:relative;width:100%;height:100%;overflow:hidden}\n"] }]
2419
2414
  }], propDecorators: { hostClass: [{
2420
2415
  type: HostBinding,
2421
2416
  args: ['class.ngt-canvas']
2422
2417
  }], pointerEvents: [{
2423
2418
  type: HostBinding,
2424
2419
  args: ['style.pointerEvents']
2425
- }], scene: [{
2420
+ }], sceneGraph: [{
2426
2421
  type: Input
2427
2422
  }], compoundPrefixes: [{
2428
2423
  type: Input
@@ -2463,9 +2458,109 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImpor
2463
2458
  args: ['glCanvas', { static: true }]
2464
2459
  }], glAnchor: [{
2465
2460
  type: ViewChild,
2466
- args: ['glAnchor', { static: true, read: ViewContainerRef }]
2461
+ args: ['glCanvas', { static: true, read: ViewContainerRef }]
2467
2462
  }] } });
2468
2463
 
2464
+ /**
2465
+ * A utility injection fn that can be used in other injection fn to provide the destroy capability.
2466
+ */
2467
+ function injectNgtDestroy(cb) {
2468
+ try {
2469
+ const cdr = inject(ChangeDetectorRef);
2470
+ const destroy$ = new ReplaySubject();
2471
+ queueMicrotask(() => {
2472
+ cdr.onDestroy(() => {
2473
+ destroy$.next();
2474
+ destroy$.complete();
2475
+ cb?.();
2476
+ });
2477
+ });
2478
+ return { destroy$, cdr };
2479
+ }
2480
+ catch (e) {
2481
+ console.warn(`[NGT] injectNgtDestroy is being called outside of Constructor Context`);
2482
+ return {};
2483
+ }
2484
+ }
2485
+
2486
+ function injectBeforeRender(cb, priority = 0) {
2487
+ try {
2488
+ const store = inject(NgtStore);
2489
+ const sub = store.get('internal').subscribe((state) => cb(state), priority, store);
2490
+ injectNgtDestroy(() => void sub());
2491
+ return sub;
2492
+ }
2493
+ catch (e) {
2494
+ throw new Error(`[NGT] "injectBeforeRender" is invoked outside of Constructor Context`);
2495
+ }
2496
+ }
2497
+
2498
+ function injectNgtRef(initialValue = null) {
2499
+ let ref = new ElementRef(initialValue);
2500
+ if (is.ref(initialValue)) {
2501
+ ref = initialValue;
2502
+ }
2503
+ let lastValue = ref.nativeElement;
2504
+ const cdRefs = [];
2505
+ const ref$ = new BehaviorSubject(lastValue);
2506
+ const { destroy$, cdr } = injectNgtDestroy(() => {
2507
+ ref$.complete();
2508
+ });
2509
+ cdRefs.push(cdr);
2510
+ const obs$ = ref$.asObservable().pipe(distinctUntilChanged(), takeUntil(destroy$));
2511
+ const subscribe = (callback) => {
2512
+ return obs$.subscribe((current) => {
2513
+ callback(current, lastValue);
2514
+ lastValue = current;
2515
+ });
2516
+ };
2517
+ const $ = obs$.pipe(filter((value, index) => index > 0 || value != null), takeUntil(destroy$));
2518
+ const children$ = (type = 'objects') => $.pipe(switchMap((instance) => {
2519
+ const localState = getLocalState(instance);
2520
+ if (localState.objects && localState.nonObjects) {
2521
+ return merge(localState.objects, localState.nonObjects).pipe(map(() => {
2522
+ try {
2523
+ return type === 'both'
2524
+ ? [...localState.objects.value, ...localState.nonObjects.value]
2525
+ : localState[type].value;
2526
+ }
2527
+ catch (e) {
2528
+ console.error(`[NGT] Exception in accessing children of ${instance}`);
2529
+ return [];
2530
+ }
2531
+ }));
2532
+ }
2533
+ return of([]);
2534
+ }), filter((children, index) => index > 0 || children.length > 0), takeUntil(destroy$));
2535
+ Object.defineProperty(ref, 'nativeElement', {
2536
+ set: (newVal) => {
2537
+ if (ref.nativeElement !== newVal) {
2538
+ ref$.next(newVal);
2539
+ lastValue = ref.nativeElement;
2540
+ ref.nativeElement = newVal;
2541
+ // clone the cdRefs so we can mutate cdRefs in the loop
2542
+ const cds = [...cdRefs];
2543
+ for (let i = 0; i < cds.length; i++) {
2544
+ const cd = cds[i];
2545
+ // if a ChangeDetectorRef is destroyed, we stop tracking it and go to the next one
2546
+ if (cd.destroyed) {
2547
+ cdRefs.splice(i, 1);
2548
+ continue;
2549
+ }
2550
+ // during creation phase, 'context' on ViewRef will be null
2551
+ // we check the "context" to avoid running detectChanges during this phase.
2552
+ // becuase there's nothing to check
2553
+ if (cd['context']) {
2554
+ cd.detectChanges();
2555
+ }
2556
+ }
2557
+ }
2558
+ },
2559
+ get: () => ref$.value,
2560
+ });
2561
+ return Object.assign(ref, { subscribe, $, children$, useCDR: (cdr) => void cdRefs.push(cdr) });
2562
+ }
2563
+
2469
2564
  class NgtRepeat extends NgForOf {
2470
2565
  set ngForRepeat(count) {
2471
2566
  this.ngForOf = Number.isInteger(count) ? Array.from({ length: count }, (_, i) => i) : [];
@@ -2480,9 +2575,60 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImpor
2480
2575
  type: Input
2481
2576
  }] } });
2482
2577
 
2578
+ function isPromise(value) {
2579
+ return ((value instanceof Promise || Object.prototype.toString.call(value) === '[object Promise]') &&
2580
+ typeof value['then'] === 'function');
2581
+ }
2582
+ class NgtPush {
2583
+ constructor() {
2584
+ this.cdr = inject(ChangeDetectorRef);
2585
+ this.parentCdr = inject(ChangeDetectorRef, { skipSelf: true, optional: true });
2586
+ }
2587
+ transform(value, defaultValue = null) {
2588
+ if (this.obj === value) {
2589
+ return this.latestValue;
2590
+ }
2591
+ this.obj = value;
2592
+ this.latestValue = defaultValue;
2593
+ if (this.sub) {
2594
+ this.sub.unsubscribe();
2595
+ }
2596
+ if (isObservable(this.obj)) {
2597
+ this.sub = this.obj.subscribe(this.updateValue.bind(this));
2598
+ }
2599
+ else if (isPromise(this.obj)) {
2600
+ this.obj.then(this.updateValue.bind(this));
2601
+ }
2602
+ else {
2603
+ throw new Error(`[NGT] Invalid value passed to ngtPush pipe`);
2604
+ }
2605
+ return this.latestValue;
2606
+ }
2607
+ updateValue(val) {
2608
+ this.latestValue = val;
2609
+ this.cdr.detectChanges();
2610
+ if (this.parentCdr) {
2611
+ this.parentCdr.detectChanges();
2612
+ }
2613
+ }
2614
+ ngOnDestroy() {
2615
+ if (this.sub) {
2616
+ this.sub.unsubscribe();
2617
+ }
2618
+ this.latestValue = undefined;
2619
+ this.obj = undefined;
2620
+ }
2621
+ }
2622
+ NgtPush.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: NgtPush, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2623
+ NgtPush.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.1.1", ngImport: i0, type: NgtPush, isStandalone: true, name: "ngtPush", pure: false });
2624
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: NgtPush, decorators: [{
2625
+ type: Pipe,
2626
+ args: [{ name: 'ngtPush', pure: false, standalone: true }]
2627
+ }] });
2628
+
2483
2629
  /**
2484
2630
  * Generated bundle index. Do not edit.
2485
2631
  */
2486
2632
 
2487
- export { NGT_CATALOGUE, NgtArgs, NgtCanvas, NgtCanvasContainer, NgtRepeat, extend };
2633
+ export { NGT_CATALOGUE, NgtArgs, NgtCanvas, NgtPush, NgtRepeat, NgtRxStore, NgtStore, checkNeedsUpdate, checkUpdate, extend, getLocalState, injectBeforeRender, injectNgtDestroy, injectNgtLoader, injectNgtRef, invalidateInstance, is, prepare, rootStateMap, startWithUndefined, updateCamera };
2488
2634
  //# sourceMappingURL=angular-three.mjs.map