angular-three 1.9.11 → 1.9.13
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.
- package/esm2020/lib/canvas.mjs +18 -22
- package/esm2020/lib/di/before-render.mjs +2 -2
- package/esm2020/lib/di/ref.mjs +9 -11
- package/esm2020/lib/di/run-in-context.mjs +6 -1
- package/esm2020/lib/directives/args.mjs +5 -7
- package/esm2020/lib/directives/common.mjs +6 -5
- package/esm2020/lib/directives/parent.mjs +3 -3
- package/esm2020/lib/directives/repeat.mjs +3 -3
- package/esm2020/lib/loader.mjs +10 -6
- package/esm2020/lib/pipes/push.mjs +16 -21
- package/esm2020/lib/portal.mjs +46 -50
- package/esm2020/lib/renderer/provider.mjs +3 -5
- package/esm2020/lib/renderer/renderer.mjs +9 -8
- package/esm2020/lib/renderer/store.mjs +376 -0
- package/esm2020/lib/renderer/utils.mjs +16 -27
- package/esm2020/lib/routed-scene.mjs +6 -5
- package/esm2020/lib/stores/rx-store.mjs +17 -40
- package/esm2020/lib/stores/store.mjs +15 -21
- package/esm2020/lib/utils/instance.mjs +3 -1
- package/esm2020/lib/utils/safe-detect-changes.mjs +4 -2
- package/fesm2015/angular-three.mjs +183 -238
- package/fesm2015/angular-three.mjs.map +1 -1
- package/fesm2020/angular-three.mjs +190 -246
- package/fesm2020/angular-three.mjs.map +1 -1
- package/lib/canvas.d.ts +2 -2
- package/lib/di/run-in-context.d.ts +5 -0
- package/lib/pipes/push.d.ts +1 -0
- package/lib/portal.d.ts +2 -2
- package/lib/renderer/renderer.d.ts +4 -4
- package/lib/renderer/{state.d.ts → store.d.ts} +2 -2
- package/lib/stores/rx-store.d.ts +2 -8
- package/lib/utils/safe-detect-changes.d.ts +1 -1
- package/package.json +5 -5
- package/plugin/package.json +2 -2
- package/esm2020/lib/renderer/state.mjs +0 -381
|
@@ -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,
|
|
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
|
|
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
|
|
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
|
-
})
|
|
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
|
|
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
|
-
|
|
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(
|
|
@@ -495,26 +513,20 @@ function tapEffect(effectFn) {
|
|
|
495
513
|
let cleanupFn = () => { };
|
|
496
514
|
let firstRun = false;
|
|
497
515
|
let prev = undefined;
|
|
498
|
-
const teardown = (error) => {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
cleanupFn({ prev, complete: true, error });
|
|
502
|
-
}
|
|
503
|
-
};
|
|
516
|
+
const teardown = (error) => () => {
|
|
517
|
+
if (cleanupFn)
|
|
518
|
+
cleanupFn({ prev, complete: true, error });
|
|
504
519
|
};
|
|
505
520
|
return tap({
|
|
506
521
|
next: (value) => {
|
|
507
|
-
if (cleanupFn && firstRun)
|
|
522
|
+
if (cleanupFn && firstRun)
|
|
508
523
|
cleanupFn({ prev, complete: false, error: false });
|
|
509
|
-
}
|
|
510
524
|
const cleanUpOrVoid = effectFn(value);
|
|
511
|
-
if (cleanUpOrVoid)
|
|
525
|
+
if (cleanUpOrVoid)
|
|
512
526
|
cleanupFn = cleanUpOrVoid;
|
|
513
|
-
}
|
|
514
527
|
prev = value;
|
|
515
|
-
if (!firstRun)
|
|
528
|
+
if (!firstRun)
|
|
516
529
|
firstRun = true;
|
|
517
|
-
}
|
|
518
530
|
},
|
|
519
531
|
complete: teardown(false),
|
|
520
532
|
unsubscribe: teardown(false),
|
|
@@ -524,7 +536,6 @@ function tapEffect(effectFn) {
|
|
|
524
536
|
class NgtRxStore extends RxState {
|
|
525
537
|
constructor() {
|
|
526
538
|
super();
|
|
527
|
-
this.cache = {};
|
|
528
539
|
// set a dummy property so that initial this.get() won't return undefined
|
|
529
540
|
this.set({ __ngt_dummy__: '__ngt_dummy__' });
|
|
530
541
|
// override set so our consumers don't have to handle undefined for state that already have default values
|
|
@@ -547,13 +558,10 @@ class NgtRxStore extends RxState {
|
|
|
547
558
|
// override get to return {} if get() returns undefined
|
|
548
559
|
const originalGet = this.get.bind(this);
|
|
549
560
|
Object.defineProperty(this, 'get', {
|
|
550
|
-
get: () => {
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
}
|
|
555
|
-
return originalGet(...args);
|
|
556
|
-
};
|
|
561
|
+
get: () => (...args) => {
|
|
562
|
+
if (args.length === 0)
|
|
563
|
+
return originalGet() ?? {};
|
|
564
|
+
return originalGet(...args);
|
|
557
565
|
},
|
|
558
566
|
});
|
|
559
567
|
// call initialize that might be setup by derived Stores
|
|
@@ -570,25 +578,12 @@ class NgtRxStore extends RxState {
|
|
|
570
578
|
if (keys.length) {
|
|
571
579
|
$ = combineLatest(keys.map((key) => this.select(key).pipe(startWith(this.get(key) ?? undefined))));
|
|
572
580
|
}
|
|
573
|
-
this.hold($, () =>
|
|
574
|
-
requestAnimationFrame(() => void cdr.detectChanges());
|
|
575
|
-
});
|
|
576
|
-
}
|
|
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();
|
|
581
|
+
this.hold($, () => void requestAnimationFrame(() => void safeDetectChanges(cdr)));
|
|
587
582
|
}
|
|
588
583
|
}
|
|
589
|
-
NgtRxStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.
|
|
590
|
-
NgtRxStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.
|
|
591
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.
|
|
584
|
+
NgtRxStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtRxStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
585
|
+
NgtRxStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtRxStore });
|
|
586
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtRxStore, decorators: [{
|
|
592
587
|
type: Injectable
|
|
593
588
|
}], ctorParameters: function () { return []; } });
|
|
594
589
|
|
|
@@ -631,7 +626,6 @@ class NgtStore extends NgtRxStore {
|
|
|
631
626
|
const w = h * aspect;
|
|
632
627
|
return { width: w, height: h, top, left, factor: width / w, distance, aspect };
|
|
633
628
|
};
|
|
634
|
-
const pointer = new THREE.Vector2();
|
|
635
629
|
let performanceTimeout;
|
|
636
630
|
const setPerformanceCurrent = (current) => {
|
|
637
631
|
this.set((state) => ({ performance: { ...state.performance, current } }));
|
|
@@ -650,7 +644,7 @@ class NgtStore extends NgtRxStore {
|
|
|
650
644
|
flat: false,
|
|
651
645
|
controls: null,
|
|
652
646
|
clock: new THREE.Clock(),
|
|
653
|
-
pointer,
|
|
647
|
+
pointer: new THREE.Vector2(),
|
|
654
648
|
frameloop: 'always',
|
|
655
649
|
performance: {
|
|
656
650
|
current: 1,
|
|
@@ -772,14 +766,12 @@ class NgtStore extends NgtRxStore {
|
|
|
772
766
|
const stateToUpdate = {};
|
|
773
767
|
// setup renderer
|
|
774
768
|
let gl = state.gl;
|
|
775
|
-
if (!state.gl)
|
|
769
|
+
if (!state.gl)
|
|
776
770
|
stateToUpdate.gl = gl = makeDefaultRenderer(glOptions, canvasElement);
|
|
777
|
-
}
|
|
778
771
|
// setup raycaster
|
|
779
772
|
let raycaster = state.raycaster;
|
|
780
|
-
if (!raycaster)
|
|
773
|
+
if (!raycaster)
|
|
781
774
|
stateToUpdate.raycaster = raycaster = new THREE.Raycaster();
|
|
782
|
-
}
|
|
783
775
|
// set raycaster options
|
|
784
776
|
const { params, ...options } = raycasterOptions || {};
|
|
785
777
|
if (!is.equ(options, raycaster, shallowLoose))
|
|
@@ -915,9 +907,7 @@ class NgtStore extends NgtRxStore {
|
|
|
915
907
|
this.invalidate();
|
|
916
908
|
}
|
|
917
909
|
destroy(canvas) {
|
|
918
|
-
this.set((state) => ({
|
|
919
|
-
internal: { ...state.internal, active: false },
|
|
920
|
-
}));
|
|
910
|
+
this.set((state) => ({ internal: { ...state.internal, active: false } }));
|
|
921
911
|
setTimeout(() => {
|
|
922
912
|
const { gl, xr, events } = this.get();
|
|
923
913
|
if (gl) {
|
|
@@ -940,8 +930,7 @@ class NgtStore extends NgtRxStore {
|
|
|
940
930
|
let oldSize = state.size;
|
|
941
931
|
let oldDpr = state.viewport.dpr;
|
|
942
932
|
let oldCamera = state.camera;
|
|
943
|
-
this.hold(this.select(
|
|
944
|
-
const { camera, size, viewport, gl, set } = this.get();
|
|
933
|
+
this.hold(combineLatest([this.select('camera'), this.select('size'), this.select('viewport'), this.select('gl')]), ([camera, size, viewport, gl]) => {
|
|
945
934
|
// resize camera and renderer on changes to size and dpr
|
|
946
935
|
if (size !== oldSize || viewport.dpr !== oldDpr) {
|
|
947
936
|
oldSize = size;
|
|
@@ -955,7 +944,9 @@ class NgtStore extends NgtRxStore {
|
|
|
955
944
|
if (camera !== oldCamera) {
|
|
956
945
|
updateCamera(camera, size);
|
|
957
946
|
oldCamera = camera;
|
|
958
|
-
set((state) => ({
|
|
947
|
+
this.set((state) => ({
|
|
948
|
+
viewport: { ...state.viewport, ...state.viewport.getCurrentViewport(camera) },
|
|
949
|
+
}));
|
|
959
950
|
}
|
|
960
951
|
});
|
|
961
952
|
}
|
|
@@ -963,18 +954,16 @@ class NgtStore extends NgtRxStore {
|
|
|
963
954
|
this.hold(this.select(), () => invalidate(this));
|
|
964
955
|
}
|
|
965
956
|
}
|
|
966
|
-
NgtStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.
|
|
967
|
-
NgtStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.
|
|
968
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.
|
|
957
|
+
NgtStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtStore, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
958
|
+
NgtStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtStore });
|
|
959
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtStore, decorators: [{
|
|
969
960
|
type: Injectable
|
|
970
961
|
}] });
|
|
971
962
|
function computeInitialSize(canvas, defaultSize) {
|
|
972
|
-
if (defaultSize)
|
|
963
|
+
if (defaultSize)
|
|
973
964
|
return defaultSize;
|
|
974
|
-
}
|
|
975
965
|
if (canvas instanceof HTMLCanvasElement && canvas.parentElement) {
|
|
976
|
-
|
|
977
|
-
return { width, height, top, left };
|
|
966
|
+
return canvas.parentElement.getBoundingClientRect();
|
|
978
967
|
}
|
|
979
968
|
return { width: 0, height: 0, top: 0, left: 0 };
|
|
980
969
|
}
|
|
@@ -1014,13 +1003,13 @@ class NgtCommonDirective {
|
|
|
1014
1003
|
this.view.destroy();
|
|
1015
1004
|
}
|
|
1016
1005
|
this.view = this.vcr.createEmbeddedView(this.template);
|
|
1017
|
-
this.view
|
|
1006
|
+
safeDetectChanges(this.view);
|
|
1018
1007
|
}
|
|
1019
1008
|
}
|
|
1020
1009
|
}
|
|
1021
|
-
NgtCommonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.
|
|
1022
|
-
NgtCommonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.
|
|
1023
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.
|
|
1010
|
+
NgtCommonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtCommonDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1011
|
+
NgtCommonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: NgtCommonDirective, ngImport: i0 });
|
|
1012
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtCommonDirective, decorators: [{
|
|
1024
1013
|
type: Directive
|
|
1025
1014
|
}], ctorParameters: function () { return []; } });
|
|
1026
1015
|
|
|
@@ -1030,9 +1019,7 @@ class NgtArgs extends NgtCommonDirective {
|
|
|
1030
1019
|
this.injectedArgs = [];
|
|
1031
1020
|
}
|
|
1032
1021
|
set args(args) {
|
|
1033
|
-
if (args == null || !Array.isArray(args))
|
|
1034
|
-
return;
|
|
1035
|
-
if (args.length === 1 && args[0] === null)
|
|
1022
|
+
if (args == null || !Array.isArray(args) || (args.length === 1 && args[0] === null))
|
|
1036
1023
|
return;
|
|
1037
1024
|
this.injected = false;
|
|
1038
1025
|
this.injectedArgs = args;
|
|
@@ -1049,9 +1036,9 @@ class NgtArgs extends NgtCommonDirective {
|
|
|
1049
1036
|
return !this.injected && !!this.injectedArgs.length;
|
|
1050
1037
|
}
|
|
1051
1038
|
}
|
|
1052
|
-
NgtArgs.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.
|
|
1053
|
-
NgtArgs.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.
|
|
1054
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.
|
|
1039
|
+
NgtArgs.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtArgs, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
1040
|
+
NgtArgs.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: NgtArgs, isStandalone: true, selector: "[args]", inputs: { args: "args" }, usesInheritance: true, ngImport: i0 });
|
|
1041
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtArgs, decorators: [{
|
|
1055
1042
|
type: Directive,
|
|
1056
1043
|
args: [{ selector: '[args]', standalone: true }]
|
|
1057
1044
|
}], propDecorators: { args: [{
|
|
@@ -1081,9 +1068,9 @@ class NgtParent extends NgtCommonDirective {
|
|
|
1081
1068
|
return !this.injected && !!this.injectedParent;
|
|
1082
1069
|
}
|
|
1083
1070
|
}
|
|
1084
|
-
NgtParent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.
|
|
1085
|
-
NgtParent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.
|
|
1086
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.
|
|
1071
|
+
NgtParent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtParent, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
1072
|
+
NgtParent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: NgtParent, isStandalone: true, selector: "[parent]", inputs: { parent: "parent" }, usesInheritance: true, ngImport: i0 });
|
|
1073
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtParent, decorators: [{
|
|
1087
1074
|
type: Directive,
|
|
1088
1075
|
args: [{ selector: '[parent]', standalone: true }]
|
|
1089
1076
|
}], propDecorators: { parent: [{
|
|
@@ -1531,9 +1518,8 @@ function attachThreeChild(parent, child) {
|
|
|
1531
1518
|
}
|
|
1532
1519
|
pLS.add(child, added ? 'objects' : 'nonObjects');
|
|
1533
1520
|
cLS.parent = parent;
|
|
1534
|
-
if (cLS.afterAttach)
|
|
1521
|
+
if (cLS.afterAttach)
|
|
1535
1522
|
cLS.afterAttach.emit({ parent, node: child });
|
|
1536
|
-
}
|
|
1537
1523
|
invalidateInstance(child);
|
|
1538
1524
|
invalidateInstance(parent);
|
|
1539
1525
|
}
|
|
@@ -1543,12 +1529,10 @@ function removeThreeChild(parent, child, dispose) {
|
|
|
1543
1529
|
// clear parent ref
|
|
1544
1530
|
cLS.parent = null;
|
|
1545
1531
|
// remove child from parent
|
|
1546
|
-
if (pLS.objects)
|
|
1532
|
+
if (pLS.objects)
|
|
1547
1533
|
pLS.remove(child, 'objects');
|
|
1548
|
-
|
|
1549
|
-
if (pLS.nonObjects) {
|
|
1534
|
+
if (pLS.nonObjects)
|
|
1550
1535
|
pLS.remove(child, 'nonObjects');
|
|
1551
|
-
}
|
|
1552
1536
|
if (cLS.attach) {
|
|
1553
1537
|
detach(parent, child, cLS.attach);
|
|
1554
1538
|
}
|
|
@@ -1579,15 +1563,14 @@ function processThreeEvent(instance, priority, eventName, callback, cdr, targetC
|
|
|
1579
1563
|
.subscribe((state) => callback({ state, object: instance }), priority || lS.priority || 0);
|
|
1580
1564
|
}
|
|
1581
1565
|
if (eventName === SPECIAL_EVENTS.AFTER_UPDATE || eventName === SPECIAL_EVENTS.AFTER_ATTACH) {
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
const sub =
|
|
1566
|
+
let emitter = lS[eventName];
|
|
1567
|
+
if (!emitter)
|
|
1568
|
+
emitter = new EventEmitter();
|
|
1569
|
+
const sub = emitter.subscribe(callback);
|
|
1586
1570
|
return sub.unsubscribe.bind(sub);
|
|
1587
1571
|
}
|
|
1588
|
-
if (!lS.handlers)
|
|
1572
|
+
if (!lS.handlers)
|
|
1589
1573
|
lS.handlers = {};
|
|
1590
|
-
}
|
|
1591
1574
|
// try to get the previous handler. compound might have one, the THREE object might also have one with the same name
|
|
1592
1575
|
const previousHandler = lS.handlers[eventName];
|
|
1593
1576
|
// readjust the callback
|
|
@@ -1596,40 +1579,32 @@ function processThreeEvent(instance, priority, eventName, callback, cdr, targetC
|
|
|
1596
1579
|
previousHandler(event);
|
|
1597
1580
|
callback(event);
|
|
1598
1581
|
};
|
|
1599
|
-
lS.handlers
|
|
1600
|
-
...lS.handlers,
|
|
1601
|
-
[eventName]: eventToHandler(updatedCallback, cdr, targetCdr),
|
|
1602
|
-
};
|
|
1582
|
+
Object.assign(lS.handlers, { [eventName]: eventToHandler(updatedCallback, cdr, targetCdr) });
|
|
1603
1583
|
// increment the count everytime
|
|
1604
1584
|
lS.eventCount += 1;
|
|
1605
1585
|
// but only add the instance (target) to the interaction array (so that it is handled by the EventManager with Raycast)
|
|
1606
1586
|
// the first time eventCount is incremented
|
|
1607
|
-
if (lS.eventCount === 1 && instance['raycast'])
|
|
1587
|
+
if (lS.eventCount === 1 && instance['raycast'])
|
|
1608
1588
|
lS.store.get('addInteraction')(instance);
|
|
1609
|
-
}
|
|
1610
1589
|
// clean up the event listener by removing the target from the interaction array
|
|
1611
1590
|
return () => {
|
|
1612
1591
|
const localState = getLocalState(instance);
|
|
1613
|
-
if (localState && localState.eventCount)
|
|
1592
|
+
if (localState && localState.eventCount)
|
|
1614
1593
|
localState.store.get('removeInteraction')(instance['uuid']);
|
|
1615
|
-
}
|
|
1616
1594
|
};
|
|
1617
1595
|
}
|
|
1618
1596
|
function eventToHandler(callback, cdr, targetCdr) {
|
|
1619
1597
|
return (event) => {
|
|
1620
1598
|
callback(event);
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
cdr.detectChanges();
|
|
1599
|
+
safeDetectChanges(targetCdr);
|
|
1600
|
+
safeDetectChanges(cdr);
|
|
1624
1601
|
};
|
|
1625
1602
|
}
|
|
1626
1603
|
function kebabToPascal(str) {
|
|
1627
1604
|
// split the string at each hyphen
|
|
1628
1605
|
const parts = str.split('-');
|
|
1629
1606
|
// map over the parts, capitalizing the first letter of each part
|
|
1630
|
-
const pascalParts = parts.map((part) =>
|
|
1631
|
-
return part.charAt(0).toUpperCase() + part.slice(1);
|
|
1632
|
-
});
|
|
1607
|
+
const pascalParts = parts.map((part) => part.charAt(0).toUpperCase() + part.slice(1));
|
|
1633
1608
|
// join the parts together to create the final PascalCase string
|
|
1634
1609
|
return pascalParts.join('');
|
|
1635
1610
|
}
|
|
@@ -1659,9 +1634,8 @@ class NgtRendererStore {
|
|
|
1659
1634
|
];
|
|
1660
1635
|
const rendererNode = Object.assign(node, { __ngt_renderer__: state });
|
|
1661
1636
|
// assign ownerDocument to node so we can use HostListener in Component
|
|
1662
|
-
if (!rendererNode['ownerDocument'])
|
|
1637
|
+
if (!rendererNode['ownerDocument'])
|
|
1663
1638
|
rendererNode['ownerDocument'] = this.root.document;
|
|
1664
|
-
}
|
|
1665
1639
|
// assign injectorFactory on non-three type since
|
|
1666
1640
|
// rendererNode is an instance of DOM Node
|
|
1667
1641
|
if (state[0 /* NgtRendererClassId.type */] !== 'three') {
|
|
@@ -1671,9 +1645,9 @@ class NgtRendererStore {
|
|
|
1671
1645
|
// we attach an arrow function to the Comment node
|
|
1672
1646
|
// In our directives, we can call this function to then start tracking the RendererNode
|
|
1673
1647
|
// this is done to limit the amount of Nodes we need to process for getCreationState
|
|
1674
|
-
rendererNode['__ngt_renderer_add_comment__'] = (
|
|
1675
|
-
if (
|
|
1676
|
-
this.portals.push(
|
|
1648
|
+
rendererNode['__ngt_renderer_add_comment__'] = (node) => {
|
|
1649
|
+
if (node && node.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'portal') {
|
|
1650
|
+
this.portals.push(node);
|
|
1677
1651
|
}
|
|
1678
1652
|
else {
|
|
1679
1653
|
this.comments.push(rendererNode);
|
|
@@ -1710,15 +1684,11 @@ class NgtRendererStore {
|
|
|
1710
1684
|
rS[7 /* NgtRendererClassId.compounded */] = instance;
|
|
1711
1685
|
const attributes = Object.keys(rS[9 /* NgtRendererClassId.attributes */]);
|
|
1712
1686
|
const properties = Object.keys(rS[10 /* NgtRendererClassId.properties */]);
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
this.applyAttribute(instance, key, rS[9 /* NgtRendererClassId.attributes */][key]);
|
|
1716
|
-
}
|
|
1687
|
+
for (const key of attributes) {
|
|
1688
|
+
this.applyAttribute(instance, key, rS[9 /* NgtRendererClassId.attributes */][key]);
|
|
1717
1689
|
}
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
this.applyProperty(instance, key, rS[10 /* NgtRendererClassId.properties */][key]);
|
|
1721
|
-
}
|
|
1690
|
+
for (const key of properties) {
|
|
1691
|
+
this.applyProperty(instance, key, rS[10 /* NgtRendererClassId.properties */][key]);
|
|
1722
1692
|
}
|
|
1723
1693
|
this.executeOperation(compound);
|
|
1724
1694
|
}
|
|
@@ -2013,6 +1983,7 @@ class NgtRendererFactory {
|
|
|
2013
1983
|
this.catalogue = inject(NGT_CATALOGUE);
|
|
2014
1984
|
this.rendererMap = new Map();
|
|
2015
1985
|
this.routedSet = new Set();
|
|
1986
|
+
// all Renderer instances share the same Store
|
|
2016
1987
|
this.rendererStore = new NgtRendererStore({
|
|
2017
1988
|
store: inject(NgtStore),
|
|
2018
1989
|
cdr: inject(ChangeDetectorRef),
|
|
@@ -2038,9 +2009,9 @@ class NgtRendererFactory {
|
|
|
2038
2009
|
return renderer;
|
|
2039
2010
|
}
|
|
2040
2011
|
}
|
|
2041
|
-
NgtRendererFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.
|
|
2042
|
-
NgtRendererFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.
|
|
2043
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.
|
|
2012
|
+
NgtRendererFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtRendererFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2013
|
+
NgtRendererFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtRendererFactory });
|
|
2014
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtRendererFactory, decorators: [{
|
|
2044
2015
|
type: Injectable
|
|
2045
2016
|
}] });
|
|
2046
2017
|
/**
|
|
@@ -2312,9 +2283,8 @@ class NgtRenderer {
|
|
|
2312
2283
|
// if target is DOM node, then we pass that to delegate Renderer
|
|
2313
2284
|
const callbackWithCdr = (event) => {
|
|
2314
2285
|
const value = callback(event);
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
this.store.rootCdr.detectChanges();
|
|
2286
|
+
safeDetectChanges(targetCdr);
|
|
2287
|
+
safeDetectChanges(this.store.rootCdr);
|
|
2318
2288
|
return value;
|
|
2319
2289
|
};
|
|
2320
2290
|
if (this.store.isDOM(target)) {
|
|
@@ -2352,12 +2322,10 @@ class NgtRenderer {
|
|
|
2352
2322
|
}
|
|
2353
2323
|
|
|
2354
2324
|
function provideNgtRenderer({ store, changeDetectorRef, compoundPrefixes = [] }) {
|
|
2355
|
-
if (!compoundPrefixes.includes('ngts'))
|
|
2325
|
+
if (!compoundPrefixes.includes('ngts'))
|
|
2356
2326
|
compoundPrefixes.push('ngts');
|
|
2357
|
-
|
|
2358
|
-
if (!compoundPrefixes.includes('ngtp')) {
|
|
2327
|
+
if (!compoundPrefixes.includes('ngtp'))
|
|
2359
2328
|
compoundPrefixes.push('ngtp');
|
|
2360
|
-
}
|
|
2361
2329
|
return makeEnvironmentProviders([
|
|
2362
2330
|
{ provide: RendererFactory2, useClass: NgtRendererFactory },
|
|
2363
2331
|
{ provide: NgtStore, useValue: store },
|
|
@@ -2440,7 +2408,7 @@ class NgtCanvas extends NgtRxStore {
|
|
|
2440
2408
|
this.envInjector = inject(EnvironmentInjector);
|
|
2441
2409
|
this.host = inject(ElementRef);
|
|
2442
2410
|
this.store = inject(NgtStore);
|
|
2443
|
-
this.
|
|
2411
|
+
this.hbClass = true;
|
|
2444
2412
|
this.sceneGraphInputs = {};
|
|
2445
2413
|
this.compoundPrefixes = [];
|
|
2446
2414
|
this.created = new EventEmitter();
|
|
@@ -2459,7 +2427,7 @@ class NgtCanvas extends NgtRxStore {
|
|
|
2459
2427
|
events: createPointerEvents,
|
|
2460
2428
|
});
|
|
2461
2429
|
}
|
|
2462
|
-
get
|
|
2430
|
+
get hbPointerEvents() {
|
|
2463
2431
|
return this.get('eventSource') !== this.host.nativeElement ? 'none' : 'auto';
|
|
2464
2432
|
}
|
|
2465
2433
|
set linear(linear) {
|
|
@@ -2520,7 +2488,7 @@ class NgtCanvas extends NgtRxStore {
|
|
|
2520
2488
|
this.store.set({
|
|
2521
2489
|
onPointerMissed: (event) => {
|
|
2522
2490
|
this.pointerMissed.emit(event);
|
|
2523
|
-
this.cdr
|
|
2491
|
+
safeDetectChanges(this.cdr);
|
|
2524
2492
|
},
|
|
2525
2493
|
});
|
|
2526
2494
|
}
|
|
@@ -2558,22 +2526,17 @@ class NgtCanvas extends NgtRxStore {
|
|
|
2558
2526
|
});
|
|
2559
2527
|
}
|
|
2560
2528
|
// emit created event if observed
|
|
2561
|
-
if (this.created.observed)
|
|
2529
|
+
if (this.created.observed)
|
|
2562
2530
|
this.created.emit(this.store.get());
|
|
2563
|
-
this.cdr.detectChanges();
|
|
2564
|
-
}
|
|
2565
2531
|
// render
|
|
2566
2532
|
if (this.glRef)
|
|
2567
2533
|
this.glRef.destroy();
|
|
2568
2534
|
requestAnimationFrame(() => {
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
store: this.store,
|
|
2572
|
-
changeDetectorRef: this.cdr,
|
|
2573
|
-
compoundPrefixes: this.compoundPrefixes,
|
|
2574
|
-
}),
|
|
2575
|
-
], this.envInjector);
|
|
2535
|
+
const { store, cdr: changeDetectorRef, compoundPrefixes } = this;
|
|
2536
|
+
this.glEnvInjector = createEnvironmentInjector([provideNgtRenderer({ store, changeDetectorRef, compoundPrefixes })], this.envInjector);
|
|
2576
2537
|
this.glRef = this.glAnchor.createComponent(this.sceneGraph, { environmentInjector: this.glEnvInjector });
|
|
2538
|
+
// detach the Scene graph from Change Detection mechanism
|
|
2539
|
+
// everything from this point forward will trigger CD manually with detectChanges
|
|
2577
2540
|
this.glRef.changeDetectorRef.detach();
|
|
2578
2541
|
this.setSceneGraphInputs();
|
|
2579
2542
|
// here, we override the detectChanges to also call detectChanges on the ComponentRef
|
|
@@ -2594,33 +2557,33 @@ class NgtCanvas extends NgtRxStore {
|
|
|
2594
2557
|
const originalDetectChanges = this.cdr.detectChanges.bind(this.cdr);
|
|
2595
2558
|
this.cdr.detectChanges = () => {
|
|
2596
2559
|
originalDetectChanges();
|
|
2597
|
-
this.glRef?.changeDetectorRef
|
|
2560
|
+
safeDetectChanges(this.glRef?.changeDetectorRef);
|
|
2598
2561
|
};
|
|
2599
2562
|
}
|
|
2600
2563
|
setSceneGraphInputs() {
|
|
2601
2564
|
for (const key of Object.keys(this.sceneGraphInputs)) {
|
|
2602
|
-
this.glRef
|
|
2565
|
+
this.glRef.setInput(key, this.sceneGraphInputs[key]);
|
|
2603
2566
|
}
|
|
2604
|
-
this.cdr
|
|
2567
|
+
safeDetectChanges(this.cdr);
|
|
2605
2568
|
}
|
|
2606
2569
|
}
|
|
2607
|
-
NgtCanvas.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.
|
|
2608
|
-
NgtCanvas.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.
|
|
2570
|
+
NgtCanvas.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtCanvas, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
2571
|
+
NgtCanvas.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", 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.hbClass", "style.pointerEvents": "this.hbPointerEvents" } }, 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
2572
|
<div (ngxResize)="onResize($event)" style="height: 100%; width: 100%;">
|
|
2610
2573
|
<canvas #glCanvas style="display: block;"></canvas>
|
|
2611
2574
|
</div>
|
|
2612
2575
|
`, 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.
|
|
2576
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtCanvas, decorators: [{
|
|
2614
2577
|
type: Component,
|
|
2615
2578
|
args: [{ selector: 'ngt-canvas', standalone: true, template: `
|
|
2616
2579
|
<div (ngxResize)="onResize($event)" style="height: 100%; width: 100%;">
|
|
2617
2580
|
<canvas #glCanvas style="display: block;"></canvas>
|
|
2618
2581
|
</div>
|
|
2619
2582
|
`, imports: [NgxResize], providers: [NgtStore, provideNgxResizeOptions({ emitInZone: false })], styles: [":host{display:block;position:relative;width:100%;height:100%;overflow:hidden}\n"] }]
|
|
2620
|
-
}], propDecorators: {
|
|
2583
|
+
}], propDecorators: { hbClass: [{
|
|
2621
2584
|
type: HostBinding,
|
|
2622
2585
|
args: ['class.ngt-canvas']
|
|
2623
|
-
}],
|
|
2586
|
+
}], hbPointerEvents: [{
|
|
2624
2587
|
type: HostBinding,
|
|
2625
2588
|
args: ['style.pointerEvents']
|
|
2626
2589
|
}], sceneGraph: [{
|
|
@@ -2693,7 +2656,7 @@ function injectNgtDestroy(cb) {
|
|
|
2693
2656
|
function injectBeforeRender(cb, priority = 0) {
|
|
2694
2657
|
try {
|
|
2695
2658
|
const store = inject(NgtStore);
|
|
2696
|
-
const sub = store.get('internal').subscribe(
|
|
2659
|
+
const sub = store.get('internal').subscribe(cb, priority, store);
|
|
2697
2660
|
injectNgtDestroy(() => void sub());
|
|
2698
2661
|
return sub;
|
|
2699
2662
|
}
|
|
@@ -2702,35 +2665,19 @@ function injectBeforeRender(cb, priority = 0) {
|
|
|
2702
2665
|
}
|
|
2703
2666
|
}
|
|
2704
2667
|
|
|
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
2668
|
function injectNgtRef(initialValue = null) {
|
|
2719
2669
|
const ref = is.ref(initialValue) ? initialValue : new ElementRef(initialValue);
|
|
2720
2670
|
let lastValue = ref.nativeElement;
|
|
2721
2671
|
const cdRefs = [];
|
|
2722
2672
|
const ref$ = new BehaviorSubject(lastValue);
|
|
2723
|
-
const { destroy$, cdr } = injectNgtDestroy(() =>
|
|
2724
|
-
ref$.complete();
|
|
2725
|
-
});
|
|
2673
|
+
const { destroy$, cdr } = injectNgtDestroy(() => void ref$.complete());
|
|
2726
2674
|
cdRefs.push(cdr);
|
|
2727
2675
|
const obs$ = ref$.asObservable().pipe(distinctUntilChanged(), takeUntil(destroy$));
|
|
2728
|
-
const subscribe = (callback) => {
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
};
|
|
2676
|
+
const subscribe = (callback) => obs$.subscribe((current) => {
|
|
2677
|
+
callback(current, lastValue);
|
|
2678
|
+
lastValue = current;
|
|
2679
|
+
});
|
|
2680
|
+
const useCDR = (cdr) => void cdRefs.push(cdr);
|
|
2734
2681
|
const $ = obs$.pipe(filter((value, index) => index > 0 || value != null), takeUntil(destroy$));
|
|
2735
2682
|
const children$ = (type = 'objects') => $.pipe(switchMap((instance) => {
|
|
2736
2683
|
const localState = getLocalState(instance);
|
|
@@ -2749,6 +2696,7 @@ function injectNgtRef(initialValue = null) {
|
|
|
2749
2696
|
}
|
|
2750
2697
|
return of([]);
|
|
2751
2698
|
}), filter((children, index) => index > 0 || children.length > 0), takeUntil(destroy$));
|
|
2699
|
+
// here, we override nativeElement to add more functionalities to nativeElement
|
|
2752
2700
|
Object.defineProperty(ref, 'nativeElement', {
|
|
2753
2701
|
set: (newVal) => {
|
|
2754
2702
|
if (ref.nativeElement !== newVal) {
|
|
@@ -2773,9 +2721,14 @@ function injectNgtRef(initialValue = null) {
|
|
|
2773
2721
|
},
|
|
2774
2722
|
get: () => ref$.value,
|
|
2775
2723
|
});
|
|
2776
|
-
return Object.assign(ref, { subscribe, $, children$, useCDR
|
|
2724
|
+
return Object.assign(ref, { subscribe, $, children$, useCDR });
|
|
2777
2725
|
}
|
|
2778
2726
|
|
|
2727
|
+
/**
|
|
2728
|
+
* Please use this sparringly and know what you're doing.
|
|
2729
|
+
*
|
|
2730
|
+
* Create a runInContext function that has access to the NodeInjector as well
|
|
2731
|
+
*/
|
|
2779
2732
|
function createRunInContext() {
|
|
2780
2733
|
const nodeInjector = inject(Injector);
|
|
2781
2734
|
const envInjector = inject(EnvironmentInjector);
|
|
@@ -2815,9 +2768,9 @@ class NgtRepeat extends NgForOf {
|
|
|
2815
2768
|
this.ngForOf = Number.isInteger(count) ? Array.from({ length: count }, (_, i) => i) : [];
|
|
2816
2769
|
}
|
|
2817
2770
|
}
|
|
2818
|
-
NgtRepeat.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.
|
|
2819
|
-
NgtRepeat.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.
|
|
2820
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.
|
|
2771
|
+
NgtRepeat.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtRepeat, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
2772
|
+
NgtRepeat.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: NgtRepeat, isStandalone: true, selector: "[ngFor][ngForRepeat]", inputs: { ngForRepeat: "ngForRepeat" }, usesInheritance: true, ngImport: i0 });
|
|
2773
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtRepeat, decorators: [{
|
|
2821
2774
|
type: Directive,
|
|
2822
2775
|
args: [{ selector: '[ngFor][ngForRepeat]', standalone: true }]
|
|
2823
2776
|
}], propDecorators: { ngForRepeat: [{
|
|
@@ -2832,50 +2785,43 @@ class NgtPush {
|
|
|
2832
2785
|
constructor() {
|
|
2833
2786
|
this.cdr = inject(ChangeDetectorRef);
|
|
2834
2787
|
this.parentCdr = inject(ChangeDetectorRef, { skipSelf: true, optional: true });
|
|
2788
|
+
this.envCdr = inject(EnvironmentInjector).get(ChangeDetectorRef, null);
|
|
2835
2789
|
}
|
|
2836
2790
|
transform(value, defaultValue = null) {
|
|
2837
|
-
if (this.obj === value)
|
|
2791
|
+
if (this.obj === value)
|
|
2838
2792
|
return this.latestValue;
|
|
2839
|
-
}
|
|
2840
2793
|
this.obj = value;
|
|
2841
2794
|
this.latestValue = defaultValue;
|
|
2842
|
-
if (this.sub)
|
|
2795
|
+
if (this.sub)
|
|
2843
2796
|
this.sub.unsubscribe();
|
|
2844
|
-
|
|
2845
|
-
if (isObservable(this.obj)) {
|
|
2797
|
+
if (isObservable(this.obj))
|
|
2846
2798
|
this.sub = this.obj.subscribe(this.updateValue.bind(this));
|
|
2847
|
-
|
|
2848
|
-
else if (isPromise(this.obj)) {
|
|
2799
|
+
else if (isPromise(this.obj))
|
|
2849
2800
|
this.obj.then(this.updateValue.bind(this));
|
|
2850
|
-
|
|
2851
|
-
else {
|
|
2801
|
+
else
|
|
2852
2802
|
throw new Error(`[NGT] Invalid value passed to ngtPush pipe`);
|
|
2853
|
-
}
|
|
2854
2803
|
return this.latestValue;
|
|
2855
2804
|
}
|
|
2856
2805
|
updateValue(val) {
|
|
2857
2806
|
this.latestValue = val;
|
|
2858
|
-
this.cdr
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
}
|
|
2807
|
+
safeDetectChanges(this.cdr);
|
|
2808
|
+
safeDetectChanges(this.parentCdr);
|
|
2809
|
+
safeDetectChanges(this.envCdr);
|
|
2862
2810
|
}
|
|
2863
2811
|
ngOnDestroy() {
|
|
2864
|
-
if (this.sub)
|
|
2812
|
+
if (this.sub)
|
|
2865
2813
|
this.sub.unsubscribe();
|
|
2866
|
-
}
|
|
2867
2814
|
this.latestValue = undefined;
|
|
2868
2815
|
this.obj = undefined;
|
|
2869
2816
|
}
|
|
2870
2817
|
}
|
|
2871
|
-
NgtPush.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.
|
|
2872
|
-
NgtPush.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.
|
|
2873
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.
|
|
2818
|
+
NgtPush.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtPush, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
2819
|
+
NgtPush.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.5", ngImport: i0, type: NgtPush, isStandalone: true, name: "ngtPush", pure: false });
|
|
2820
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtPush, decorators: [{
|
|
2874
2821
|
type: Pipe,
|
|
2875
2822
|
args: [{ name: 'ngtPush', pure: false, standalone: true }]
|
|
2876
2823
|
}] });
|
|
2877
2824
|
|
|
2878
|
-
var _NgtPortal_instances, _NgtPortal_inject;
|
|
2879
2825
|
const privateKeys = [
|
|
2880
2826
|
'get',
|
|
2881
2827
|
'set',
|
|
@@ -2920,14 +2866,11 @@ class NgtPortalBeforeRender {
|
|
|
2920
2866
|
this.subscription?.();
|
|
2921
2867
|
}
|
|
2922
2868
|
}
|
|
2923
|
-
NgtPortalBeforeRender.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.
|
|
2924
|
-
NgtPortalBeforeRender.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.
|
|
2925
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.
|
|
2869
|
+
NgtPortalBeforeRender.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtPortalBeforeRender, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2870
|
+
NgtPortalBeforeRender.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: NgtPortalBeforeRender, isStandalone: true, selector: "[ngtPortalBeforeRender]", inputs: { renderPriority: "renderPriority", parentScene: "parentScene", parentCamera: "parentCamera" }, outputs: { beforeRender: "beforeRender" }, ngImport: i0 });
|
|
2871
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtPortalBeforeRender, decorators: [{
|
|
2926
2872
|
type: Directive,
|
|
2927
|
-
args: [{
|
|
2928
|
-
selector: 'ngt-portal-before-render',
|
|
2929
|
-
standalone: true,
|
|
2930
|
-
}]
|
|
2873
|
+
args: [{ selector: '[ngtPortalBeforeRender]', standalone: true }]
|
|
2931
2874
|
}], propDecorators: { renderPriority: [{
|
|
2932
2875
|
type: Input
|
|
2933
2876
|
}], parentScene: [{
|
|
@@ -2946,9 +2889,9 @@ class NgtPortalContent {
|
|
|
2946
2889
|
}
|
|
2947
2890
|
}
|
|
2948
2891
|
}
|
|
2949
|
-
NgtPortalContent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.
|
|
2950
|
-
NgtPortalContent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.
|
|
2951
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.
|
|
2892
|
+
NgtPortalContent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtPortalContent, deps: [{ token: i0.ViewContainerRef }, { token: i0.ViewContainerRef, skipSelf: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
2893
|
+
NgtPortalContent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: NgtPortalContent, isStandalone: true, selector: "ng-template[ngtPortalContent]", ngImport: i0 });
|
|
2894
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtPortalContent, decorators: [{
|
|
2952
2895
|
type: Directive,
|
|
2953
2896
|
args: [{ selector: 'ng-template[ngtPortalContent]', standalone: true }]
|
|
2954
2897
|
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.ViewContainerRef, decorators: [{
|
|
@@ -2957,7 +2900,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImpor
|
|
|
2957
2900
|
class NgtPortal extends NgtRxStore {
|
|
2958
2901
|
constructor() {
|
|
2959
2902
|
super(...arguments);
|
|
2960
|
-
_NgtPortal_instances.add(this);
|
|
2961
2903
|
this.autoRender = true;
|
|
2962
2904
|
this.autoRenderPriority = 1;
|
|
2963
2905
|
this.beforeRender = new EventEmitter();
|
|
@@ -3006,9 +2948,9 @@ class NgtPortal extends NgtRxStore {
|
|
|
3006
2948
|
select: this.portalStore.select.bind(this.portalStore),
|
|
3007
2949
|
setEvents: (events) => this.portalStore.set((state) => ({ ...state, events: { ...state.events, ...events } })),
|
|
3008
2950
|
});
|
|
3009
|
-
this.hold(this.parentStore.select(), (previous) => this.portalStore.set((state) =>
|
|
2951
|
+
this.hold(this.parentStore.select(), (previous) => this.portalStore.set((state) => this.inject(previous, state)));
|
|
3010
2952
|
requestAnimationFrame(() => {
|
|
3011
|
-
this.portalStore.set((injectState) =>
|
|
2953
|
+
this.portalStore.set((injectState) => this.inject(this.parentStore.get(), injectState));
|
|
3012
2954
|
});
|
|
3013
2955
|
this.portalContentView = this.portalContentAnchor.createEmbeddedView(this.portalContentTemplate);
|
|
3014
2956
|
this.portalContentView.detectChanges();
|
|
@@ -3026,57 +2968,59 @@ class NgtPortal extends NgtRxStore {
|
|
|
3026
2968
|
}
|
|
3027
2969
|
super.ngOnDestroy();
|
|
3028
2970
|
}
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
2971
|
+
inject(rootState, injectState) {
|
|
2972
|
+
const intersect = { ...rootState };
|
|
2973
|
+
Object.keys(intersect).forEach((key) => {
|
|
2974
|
+
if (privateKeys.includes(key) ||
|
|
2975
|
+
rootState[key] !== injectState[key]) {
|
|
2976
|
+
delete intersect[key];
|
|
2977
|
+
}
|
|
2978
|
+
});
|
|
2979
|
+
const inputs = this.get();
|
|
2980
|
+
const { size, events, ...restInputsState } = inputs.state || {};
|
|
2981
|
+
let viewport = undefined;
|
|
2982
|
+
if (injectState && size) {
|
|
2983
|
+
const camera = injectState.camera;
|
|
2984
|
+
viewport = rootState.viewport.getCurrentViewport(camera, new THREE.Vector3(), size);
|
|
2985
|
+
if (camera !== rootState.camera)
|
|
2986
|
+
updateCamera(camera, size);
|
|
3036
2987
|
}
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
2988
|
+
return {
|
|
2989
|
+
...intersect,
|
|
2990
|
+
scene: is.ref(inputs.container) ? inputs.container.nativeElement : inputs.container,
|
|
2991
|
+
raycaster: this.raycaster,
|
|
2992
|
+
pointer: this.pointer,
|
|
2993
|
+
previousStore: this.parentStore,
|
|
2994
|
+
events: { ...rootState.events, ...(injectState?.events || {}), ...events },
|
|
2995
|
+
size: { ...rootState.size, ...size },
|
|
2996
|
+
viewport: { ...rootState.viewport, ...(viewport || {}) },
|
|
2997
|
+
...restInputsState,
|
|
2998
|
+
};
|
|
3046
2999
|
}
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
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: `
|
|
3000
|
+
}
|
|
3001
|
+
NgtPortal.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtPortal, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
3002
|
+
NgtPortal.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", 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
3003
|
<ng-container #portalContentAnchor>
|
|
3062
|
-
<
|
|
3004
|
+
<ng-container
|
|
3063
3005
|
*ngIf="autoRender && portalContentRendered"
|
|
3006
|
+
ngtPortalBeforeRender
|
|
3064
3007
|
[renderPriority]="autoRenderPriority"
|
|
3065
3008
|
[parentScene]="parentScene"
|
|
3066
3009
|
[parentCamera]="parentCamera"
|
|
3067
3010
|
(beforeRender)="onBeforeRender($event)"
|
|
3068
3011
|
/>
|
|
3069
3012
|
</ng-container>
|
|
3070
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgtPortalBeforeRender, selector: "
|
|
3071
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.
|
|
3013
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgtPortalBeforeRender, selector: "[ngtPortalBeforeRender]", inputs: ["renderPriority", "parentScene", "parentCamera"], outputs: ["beforeRender"] }] });
|
|
3014
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtPortal, decorators: [{
|
|
3072
3015
|
type: Component,
|
|
3073
3016
|
args: [{
|
|
3074
3017
|
selector: 'ngt-portal',
|
|
3075
3018
|
standalone: true,
|
|
3076
3019
|
template: `
|
|
3077
3020
|
<ng-container #portalContentAnchor>
|
|
3078
|
-
<
|
|
3021
|
+
<ng-container
|
|
3079
3022
|
*ngIf="autoRender && portalContentRendered"
|
|
3023
|
+
ngtPortalBeforeRender
|
|
3080
3024
|
[renderPriority]="autoRenderPriority"
|
|
3081
3025
|
[parentScene]="parentScene"
|
|
3082
3026
|
[parentCamera]="parentCamera"
|
|
@@ -3110,13 +3054,13 @@ class NgtRoutedScene {
|
|
|
3110
3054
|
const { destroy$, cdr } = injectNgtDestroy();
|
|
3111
3055
|
router.events
|
|
3112
3056
|
.pipe(filter((event) => event instanceof ActivationEnd), takeUntil(destroy$))
|
|
3113
|
-
.subscribe(
|
|
3057
|
+
.subscribe(() => safeDetectChanges(cdr));
|
|
3114
3058
|
}
|
|
3115
3059
|
}
|
|
3116
3060
|
NgtRoutedScene.isRoutedScene = true;
|
|
3117
|
-
NgtRoutedScene.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.
|
|
3118
|
-
NgtRoutedScene.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.
|
|
3119
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.
|
|
3061
|
+
NgtRoutedScene.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtRoutedScene, deps: [{ token: i1.Router }], target: i0.ɵɵFactoryTarget.Component });
|
|
3062
|
+
NgtRoutedScene.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", 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"] }] });
|
|
3063
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgtRoutedScene, decorators: [{
|
|
3120
3064
|
type: Component,
|
|
3121
3065
|
args: [{
|
|
3122
3066
|
standalone: true,
|