angular-three 4.0.0-next.9 → 4.0.0-next.90
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/README.md +38 -183
- package/dom/lib/canvas.d.ts +6 -4
- package/dom/lib/renderer.d.ts +2 -1
- package/fesm2022/angular-three-dom.mjs +21 -12
- package/fesm2022/angular-three-dom.mjs.map +1 -1
- package/fesm2022/angular-three-testing.mjs +3 -3
- package/fesm2022/angular-three.mjs +275 -194
- package/fesm2022/angular-three.mjs.map +1 -1
- package/lib/directives/common.d.ts +1 -1
- package/lib/directives/selection.d.ts +5 -4
- package/lib/html.d.ts +1 -1
- package/lib/portal.d.ts +4 -4
- package/lib/renderer/renderer.d.ts +9 -3
- package/lib/three-types.d.ts +130 -418
- package/lib/types.d.ts +5 -1
- package/lib/utils/before-render.d.ts +10 -21
- package/lib/utils/is.d.ts +1 -0
- package/lib/utils/make.d.ts +2 -1
- package/metadata.json +37469 -0
- package/package.json +3 -26
- package/testing/lib/utils/web-gl-rendering-context.d.ts +1 -1
- package/web-types.json +37475 -0
- package/plugin/README.md +0 -11
- package/plugin/generators.json +0 -27
- package/plugin/src/generators/add-soba/compat.d.ts +0 -2
- package/plugin/src/generators/add-soba/compat.js +0 -6
- package/plugin/src/generators/add-soba/compat.js.map +0 -1
- package/plugin/src/generators/add-soba/generator.d.ts +0 -3
- package/plugin/src/generators/add-soba/generator.js +0 -77
- package/plugin/src/generators/add-soba/generator.js.map +0 -1
- package/plugin/src/generators/add-soba/schema.json +0 -4
- package/plugin/src/generators/init/compat.d.ts +0 -2
- package/plugin/src/generators/init/compat.js +0 -6
- package/plugin/src/generators/init/compat.js.map +0 -1
- package/plugin/src/generators/init/files/experience/experience.component.ts__tmpl__ +0 -28
- package/plugin/src/generators/init/generator.d.ts +0 -6
- package/plugin/src/generators/init/generator.js +0 -154
- package/plugin/src/generators/init/generator.js.map +0 -1
- package/plugin/src/generators/init/schema.json +0 -13
- package/plugin/src/generators/utils.d.ts +0 -2
- package/plugin/src/generators/utils.js +0 -35
- package/plugin/src/generators/utils.js.map +0 -1
- package/plugin/src/generators/version.d.ts +0 -17
- package/plugin/src/generators/version.js +0 -21
- package/plugin/src/generators/version.js.map +0 -1
- package/plugin/src/index.d.ts +0 -0
- package/plugin/src/index.js +0 -1
- package/plugin/src/index.js.map +0 -1
|
@@ -19,7 +19,7 @@ const NGT_GET_NODE_ATTRIBUTE_FLAG = '__ngt_get_node_attribute__';
|
|
|
19
19
|
const NGT_DOM_PARENT_FLAG = '__ngt_dom_parent__';
|
|
20
20
|
const NGT_DELEGATE_RENDERER_DESTROY_NODE_PATCHED_FLAG = '__ngt_delegate_renderer_destroy_node_patched__';
|
|
21
21
|
const NGT_HTML_FLAG = '__ngt_html__';
|
|
22
|
-
const THREE_NATIVE_EVENTS = ['added', 'removed', 'childadded', 'childremoved', 'disposed'];
|
|
22
|
+
const THREE_NATIVE_EVENTS = ['added', 'removed', 'childadded', 'childremoved', 'change', 'disposed'];
|
|
23
23
|
|
|
24
24
|
const is = {
|
|
25
25
|
obj: (a) => a === Object(a) && !Array.isArray(a) && typeof a !== 'function',
|
|
@@ -34,6 +34,7 @@ const is = {
|
|
|
34
34
|
instance: (a) => !!a && !!a['__ngt__'],
|
|
35
35
|
object3D: (a) => !!a && a.isObject3D,
|
|
36
36
|
three: (a, isKey) => !!a && a[isKey],
|
|
37
|
+
colorRepresentation: (a) => a != null && (typeof a === 'string' || typeof a === 'number' || is.three(a, 'isColor')),
|
|
37
38
|
colorSpaceExist: (object) => 'colorSpace' in object || 'outputColorSpace' in object,
|
|
38
39
|
equ(a, b, { arrays = 'shallow', objects = 'reference', strict = true } = {}) {
|
|
39
40
|
// Wrong type or one of the two undefined, doesn't match
|
|
@@ -82,9 +83,9 @@ class NgtCommonDirective {
|
|
|
82
83
|
this.injected = false;
|
|
83
84
|
this.injectedValue = null;
|
|
84
85
|
effect(() => {
|
|
85
|
-
const value = this.linkedValue();
|
|
86
86
|
if (this.shouldSkipRender())
|
|
87
87
|
return;
|
|
88
|
+
const value = this.linkedValue();
|
|
88
89
|
if (is.equ(value, this.injectedValue)) {
|
|
89
90
|
// we have the same value as before, no need to update
|
|
90
91
|
return;
|
|
@@ -114,10 +115,10 @@ class NgtCommonDirective {
|
|
|
114
115
|
this.view = this.vcr.createEmbeddedView(this.template);
|
|
115
116
|
this.view.detectChanges();
|
|
116
117
|
}
|
|
117
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.
|
|
118
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.
|
|
118
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtCommonDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
119
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.6", type: NgtCommonDirective, isStandalone: true, ngImport: i0 }); }
|
|
119
120
|
}
|
|
120
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.
|
|
121
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtCommonDirective, decorators: [{
|
|
121
122
|
type: Directive
|
|
122
123
|
}], ctorParameters: () => [] });
|
|
123
124
|
|
|
@@ -141,10 +142,10 @@ class NgtArgs extends NgtCommonDirective {
|
|
|
141
142
|
validate() {
|
|
142
143
|
return !this.injected && !!this.injectedValue?.length;
|
|
143
144
|
}
|
|
144
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.
|
|
145
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.
|
|
145
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtArgs, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
146
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.6", type: NgtArgs, isStandalone: true, selector: "ng-template[args]", inputs: { args: { classPropertyName: "args", publicName: "args", isSignal: true, isRequired: true, transformFunction: null } }, usesInheritance: true, ngImport: i0 }); }
|
|
146
147
|
}
|
|
147
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.
|
|
148
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtArgs, decorators: [{
|
|
148
149
|
type: Directive,
|
|
149
150
|
args: [{ selector: 'ng-template[args]' }]
|
|
150
151
|
}], ctorParameters: () => [] });
|
|
@@ -314,16 +315,16 @@ function makeDpr(dpr, window) {
|
|
|
314
315
|
return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
|
|
315
316
|
}
|
|
316
317
|
function makeRendererInstance(glOptions, canvas) {
|
|
317
|
-
const
|
|
318
|
-
if (is.renderer(customRenderer))
|
|
319
|
-
return customRenderer;
|
|
320
|
-
return new THREE.WebGLRenderer({
|
|
318
|
+
const defaultOptions = {
|
|
321
319
|
powerPreference: 'high-performance',
|
|
322
320
|
canvas,
|
|
323
321
|
antialias: true,
|
|
324
322
|
alpha: true,
|
|
325
|
-
|
|
326
|
-
|
|
323
|
+
};
|
|
324
|
+
const customRenderer = (typeof glOptions === 'function' ? glOptions(defaultOptions) : glOptions);
|
|
325
|
+
if (is.renderer(customRenderer))
|
|
326
|
+
return customRenderer;
|
|
327
|
+
return new THREE.WebGLRenderer({ ...defaultOptions, ...glOptions });
|
|
327
328
|
}
|
|
328
329
|
function makeCameraInstance(isOrthographic, size) {
|
|
329
330
|
if (isOrthographic)
|
|
@@ -331,7 +332,7 @@ function makeCameraInstance(isOrthographic, size) {
|
|
|
331
332
|
return new THREE.PerspectiveCamera(75, size.width / size.height, 0.1, 1000);
|
|
332
333
|
}
|
|
333
334
|
function makeObjectGraph(object) {
|
|
334
|
-
const data = { nodes: {}, materials: {} };
|
|
335
|
+
const data = { nodes: {}, materials: {}, meshes: {} };
|
|
335
336
|
if (object) {
|
|
336
337
|
object.traverse((child) => {
|
|
337
338
|
if (child.name)
|
|
@@ -340,6 +341,8 @@ function makeObjectGraph(object) {
|
|
|
340
341
|
data.materials[child.material.name] = child
|
|
341
342
|
.material;
|
|
342
343
|
}
|
|
344
|
+
if (is.three(child, 'isMesh') && !data.meshes[child.name])
|
|
345
|
+
data.meshes[child.name] = child;
|
|
343
346
|
});
|
|
344
347
|
}
|
|
345
348
|
return data;
|
|
@@ -483,7 +486,9 @@ function storeFactory() {
|
|
|
483
486
|
clearTimeout(performanceTimeout);
|
|
484
487
|
// Set lower bound performance
|
|
485
488
|
if (state.performance.current !== state.performance.min)
|
|
486
|
-
store.update((state) => ({
|
|
489
|
+
store.update((state) => ({
|
|
490
|
+
performance: { ...state.performance, current: state.performance.min },
|
|
491
|
+
}));
|
|
487
492
|
// Go back to upper bound performance after a while unless something regresses meanwhile
|
|
488
493
|
performanceTimeout = setTimeout(() => store.update((state) => ({
|
|
489
494
|
performance: { ...state.performance, current: store.snapshot.performance.max },
|
|
@@ -510,7 +515,15 @@ function storeFactory() {
|
|
|
510
515
|
tempTarget.set(...target);
|
|
511
516
|
const distance = camera.getWorldPosition(position).distanceTo(tempTarget);
|
|
512
517
|
if (is.three(camera, 'isOrthographicCamera')) {
|
|
513
|
-
return {
|
|
518
|
+
return {
|
|
519
|
+
width: width / camera.zoom,
|
|
520
|
+
height: height / camera.zoom,
|
|
521
|
+
top,
|
|
522
|
+
left,
|
|
523
|
+
factor: 1,
|
|
524
|
+
distance,
|
|
525
|
+
aspect,
|
|
526
|
+
};
|
|
514
527
|
}
|
|
515
528
|
const fov = (camera.fov * Math.PI) / 180; // convert vertical fov to radians
|
|
516
529
|
const h = 2 * Math.tan(fov / 2) * distance; // visible height
|
|
@@ -604,7 +617,9 @@ function storeFactory() {
|
|
|
604
617
|
oldCamera = newCamera;
|
|
605
618
|
updateCamera(newCamera, newSize);
|
|
606
619
|
// Update viewport
|
|
607
|
-
store.update((state) => ({
|
|
620
|
+
store.update((state) => ({
|
|
621
|
+
viewport: { ...state.viewport, ...state.viewport.getCurrentViewport(newCamera) },
|
|
622
|
+
}));
|
|
608
623
|
}
|
|
609
624
|
});
|
|
610
625
|
return store;
|
|
@@ -614,6 +629,13 @@ function injectStore(options) {
|
|
|
614
629
|
return inject(NGT_STORE, options);
|
|
615
630
|
}
|
|
616
631
|
|
|
632
|
+
function resolveRef(ref) {
|
|
633
|
+
if (is.ref(ref)) {
|
|
634
|
+
return ref.nativeElement;
|
|
635
|
+
}
|
|
636
|
+
return ref;
|
|
637
|
+
}
|
|
638
|
+
|
|
617
639
|
class NgtParent extends NgtCommonDirective {
|
|
618
640
|
constructor() {
|
|
619
641
|
super();
|
|
@@ -628,10 +650,7 @@ class NgtParent extends NgtCommonDirective {
|
|
|
628
650
|
if (typeof rawParent === 'string') {
|
|
629
651
|
return scene.getObjectByName(rawParent);
|
|
630
652
|
}
|
|
631
|
-
|
|
632
|
-
return rawParent.nativeElement;
|
|
633
|
-
}
|
|
634
|
-
return rawParent;
|
|
653
|
+
return resolveRef(rawParent);
|
|
635
654
|
});
|
|
636
655
|
this.linkedValue = linkedSignal(this._parent);
|
|
637
656
|
this.shouldSkipRender = computed(() => !this._parent());
|
|
@@ -652,10 +671,10 @@ class NgtParent extends NgtCommonDirective {
|
|
|
652
671
|
commentNode[NGT_INTERNAL_SET_PARENT_COMMENT_FLAG](this.injectedValue);
|
|
653
672
|
}
|
|
654
673
|
}
|
|
655
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.
|
|
656
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.
|
|
674
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtParent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
675
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.6", type: NgtParent, isStandalone: true, selector: "ng-template[parent]", inputs: { parent: { classPropertyName: "parent", publicName: "parent", isSignal: true, isRequired: true, transformFunction: null } }, usesInheritance: true, ngImport: i0 }); }
|
|
657
676
|
}
|
|
658
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.
|
|
677
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtParent, decorators: [{
|
|
659
678
|
type: Directive,
|
|
660
679
|
args: [{ selector: 'ng-template[parent]' }]
|
|
661
680
|
}], ctorParameters: () => [] });
|
|
@@ -721,7 +740,9 @@ function prepare(object, type, instanceState) {
|
|
|
721
740
|
notifyAncestors(instance.__ngt__.hierarchyStore.snapshot.parent, type);
|
|
722
741
|
},
|
|
723
742
|
remove(object, type) {
|
|
724
|
-
instance.__ngt__.hierarchyStore.update((prev) => ({
|
|
743
|
+
instance.__ngt__.hierarchyStore.update((prev) => ({
|
|
744
|
+
[type]: prev[type].filter((node) => node !== object),
|
|
745
|
+
}));
|
|
725
746
|
notifyAncestors(instance.__ngt__.hierarchyStore.snapshot.parent, type);
|
|
726
747
|
},
|
|
727
748
|
setParent(parent) {
|
|
@@ -754,7 +775,7 @@ function prepare(object, type, instanceState) {
|
|
|
754
775
|
return () => {
|
|
755
776
|
const iS = getInstanceState(instance);
|
|
756
777
|
if (iS) {
|
|
757
|
-
delete iS.handlers[eventName];
|
|
778
|
+
iS.handlers && delete iS.handlers[eventName];
|
|
758
779
|
iS.eventCount -= 1;
|
|
759
780
|
}
|
|
760
781
|
};
|
|
@@ -815,9 +836,9 @@ function notifyAncestors(instance, type) {
|
|
|
815
836
|
notifyAncestors(parent, type);
|
|
816
837
|
}
|
|
817
838
|
|
|
818
|
-
class
|
|
839
|
+
class NgtSelectionApi {
|
|
819
840
|
constructor() {
|
|
820
|
-
this.enabled = input(true, { alias: '
|
|
841
|
+
this.enabled = input(true, { alias: 'selection', transform: booleanAttribute });
|
|
821
842
|
this.source = signal([]);
|
|
822
843
|
this.selected = this.source.asReadonly();
|
|
823
844
|
}
|
|
@@ -826,20 +847,20 @@ class NgtSelection {
|
|
|
826
847
|
return;
|
|
827
848
|
this.source.update(...args);
|
|
828
849
|
}
|
|
829
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.
|
|
830
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.
|
|
850
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtSelectionApi, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
851
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.6", type: NgtSelectionApi, isStandalone: true, selector: "[selection]", inputs: { enabled: { classPropertyName: "enabled", publicName: "selection", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
|
|
831
852
|
}
|
|
832
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.
|
|
853
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtSelectionApi, decorators: [{
|
|
833
854
|
type: Directive,
|
|
834
|
-
args: [{ selector: '[
|
|
855
|
+
args: [{ selector: '[selection]' }]
|
|
835
856
|
}] });
|
|
836
857
|
class NgtSelect {
|
|
837
858
|
constructor() {
|
|
838
|
-
this.enabled = input(false, { transform: booleanAttribute, alias: '
|
|
859
|
+
this.enabled = input(false, { transform: booleanAttribute, alias: 'select' });
|
|
839
860
|
const elementRef = inject(ElementRef);
|
|
840
|
-
const
|
|
861
|
+
const selectionApi = inject(NgtSelectionApi);
|
|
841
862
|
effect((onCleanup) => {
|
|
842
|
-
const selectionEnabled =
|
|
863
|
+
const selectionEnabled = selectionApi.enabled();
|
|
843
864
|
if (!selectionEnabled)
|
|
844
865
|
return;
|
|
845
866
|
const enabled = this.enabled();
|
|
@@ -851,13 +872,13 @@ class NgtSelect {
|
|
|
851
872
|
const localState = getInstanceState(host);
|
|
852
873
|
if (!localState)
|
|
853
874
|
return;
|
|
854
|
-
// ngt-mesh[
|
|
875
|
+
// ngt-mesh[select]
|
|
855
876
|
if (host.type === 'Mesh') {
|
|
856
|
-
|
|
857
|
-
onCleanup(() =>
|
|
877
|
+
selectionApi.update((prev) => [...prev, host]);
|
|
878
|
+
onCleanup(() => selectionApi.update((prev) => prev.filter((el) => el !== host)));
|
|
858
879
|
return;
|
|
859
880
|
}
|
|
860
|
-
const [collection] = [untracked(
|
|
881
|
+
const [collection] = [untracked(selectionApi.selected), localState.objects()];
|
|
861
882
|
let changed = false;
|
|
862
883
|
const current = [];
|
|
863
884
|
host.traverse((child) => {
|
|
@@ -867,19 +888,20 @@ class NgtSelect {
|
|
|
867
888
|
});
|
|
868
889
|
if (!changed)
|
|
869
890
|
return;
|
|
870
|
-
|
|
891
|
+
selectionApi.update((prev) => [...prev, ...current]);
|
|
871
892
|
onCleanup(() => {
|
|
872
|
-
|
|
893
|
+
selectionApi.update((prev) => prev.filter((el) => !current.includes(el)));
|
|
873
894
|
});
|
|
874
895
|
});
|
|
875
896
|
}
|
|
876
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.
|
|
877
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.
|
|
897
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtSelect, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
898
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.6", type: NgtSelect, isStandalone: true, selector: "ngt-group[select], ngt-mesh[select]", inputs: { enabled: { classPropertyName: "enabled", publicName: "select", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
|
|
878
899
|
}
|
|
879
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.
|
|
900
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtSelect, decorators: [{
|
|
880
901
|
type: Directive,
|
|
881
|
-
args: [{ selector: 'ngt-group[
|
|
902
|
+
args: [{ selector: 'ngt-group[select], ngt-mesh[select]' }]
|
|
882
903
|
}], ctorParameters: () => [] });
|
|
904
|
+
const NgtSelection = [NgtSelectionApi, NgtSelect];
|
|
883
905
|
|
|
884
906
|
var _a;
|
|
885
907
|
//
|
|
@@ -913,10 +935,10 @@ class NgtHTML {
|
|
|
913
935
|
delete host.nativeElement[NGT_DOM_PARENT_FLAG];
|
|
914
936
|
});
|
|
915
937
|
}
|
|
916
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.
|
|
917
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.
|
|
938
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtHTML, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
939
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.6", type: NgtHTML, isStandalone: true, ngImport: i0 }); }
|
|
918
940
|
}
|
|
919
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.
|
|
941
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtHTML, decorators: [{
|
|
920
942
|
type: Directive
|
|
921
943
|
}], ctorParameters: () => [] });
|
|
922
944
|
|
|
@@ -1085,10 +1107,10 @@ class NgtHexify {
|
|
|
1085
1107
|
const hex = component.toString(16);
|
|
1086
1108
|
return hex.length === 1 ? '0' + hex : hex;
|
|
1087
1109
|
}
|
|
1088
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.
|
|
1089
|
-
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.1.
|
|
1110
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtHexify, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1111
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.1.6", ngImport: i0, type: NgtHexify, isStandalone: true, name: "hexify" }); }
|
|
1090
1112
|
}
|
|
1091
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.
|
|
1113
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtHexify, decorators: [{
|
|
1092
1114
|
type: Pipe,
|
|
1093
1115
|
args: [{ name: 'hexify', pure: true }]
|
|
1094
1116
|
}] });
|
|
@@ -1181,7 +1203,7 @@ class NgtPortalAutoRender {
|
|
|
1181
1203
|
constructor() {
|
|
1182
1204
|
this.portalStore = injectStore({ host: true });
|
|
1183
1205
|
this.parentStore = injectStore({ skipSelf: true });
|
|
1184
|
-
this.portal = inject(
|
|
1206
|
+
this.portal = inject(NgtPortalImpl, { host: true });
|
|
1185
1207
|
this.renderPriority = input(1, { alias: 'autoRender', transform: (value) => numberAttribute(value, 1) });
|
|
1186
1208
|
effect(() => {
|
|
1187
1209
|
// this.portalStore.update((state) => ({ events: { ...state.events, priority: this.renderPriority() + 1 } }));
|
|
@@ -1194,7 +1216,10 @@ class NgtPortalAutoRender {
|
|
|
1194
1216
|
const [renderPriority, { internal }] = [this.renderPriority(), this.portalStore()];
|
|
1195
1217
|
let oldClean;
|
|
1196
1218
|
const cleanup = internal.subscribe(({ gl, scene, camera }) => {
|
|
1197
|
-
const [parentScene, parentCamera] = [
|
|
1219
|
+
const [parentScene, parentCamera] = [
|
|
1220
|
+
this.parentStore.snapshot.scene,
|
|
1221
|
+
this.parentStore.snapshot.camera,
|
|
1222
|
+
];
|
|
1198
1223
|
oldClean = gl.autoClear;
|
|
1199
1224
|
if (renderPriority === 1) {
|
|
1200
1225
|
// clear scene and render with default
|
|
@@ -1211,10 +1236,10 @@ class NgtPortalAutoRender {
|
|
|
1211
1236
|
onCleanup(() => cleanup());
|
|
1212
1237
|
});
|
|
1213
1238
|
}
|
|
1214
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.
|
|
1215
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.
|
|
1239
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtPortalAutoRender, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1240
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.6", type: NgtPortalAutoRender, isStandalone: true, selector: "ngt-portal[autoRender]", inputs: { renderPriority: { classPropertyName: "renderPriority", publicName: "autoRender", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
|
|
1216
1241
|
}
|
|
1217
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.
|
|
1242
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtPortalAutoRender, decorators: [{
|
|
1218
1243
|
type: Directive,
|
|
1219
1244
|
args: [{ selector: 'ngt-portal[autoRender]' }]
|
|
1220
1245
|
}], ctorParameters: () => [] });
|
|
@@ -1236,10 +1261,10 @@ class NgtPortalContent {
|
|
|
1236
1261
|
delete commentNode[NGT_INTERNAL_ADD_COMMENT_FLAG];
|
|
1237
1262
|
}
|
|
1238
1263
|
}
|
|
1239
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.
|
|
1240
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.
|
|
1264
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtPortalContent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1265
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.6", type: NgtPortalContent, isStandalone: true, selector: "ng-template[portalContent]", ngImport: i0 }); }
|
|
1241
1266
|
}
|
|
1242
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.
|
|
1267
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtPortalContent, decorators: [{
|
|
1243
1268
|
type: Directive,
|
|
1244
1269
|
args: [{ selector: 'ng-template[portalContent]' }]
|
|
1245
1270
|
}], ctorParameters: () => [] });
|
|
@@ -1273,7 +1298,7 @@ function mergeState(previousRoot, store, container, pointer, raycaster, events,
|
|
|
1273
1298
|
setEvents: (events) => store.update((state) => ({ ...state, events: { ...state.events, ...events } })),
|
|
1274
1299
|
};
|
|
1275
1300
|
}
|
|
1276
|
-
class
|
|
1301
|
+
class NgtPortalImpl {
|
|
1277
1302
|
constructor() {
|
|
1278
1303
|
this.container = input.required();
|
|
1279
1304
|
this.state = input({});
|
|
@@ -1289,7 +1314,12 @@ class NgtPortal {
|
|
|
1289
1314
|
this.portalRendered = this.portalContentRendered.asReadonly();
|
|
1290
1315
|
extend({ Group });
|
|
1291
1316
|
effect(() => {
|
|
1292
|
-
let [container, anchor, content] = [
|
|
1317
|
+
let [container, anchor, content] = [
|
|
1318
|
+
this.container(),
|
|
1319
|
+
this.anchorRef(),
|
|
1320
|
+
this.contentRef(),
|
|
1321
|
+
this.previousStore(),
|
|
1322
|
+
];
|
|
1293
1323
|
const [size, events, restState] = [untracked(this.size), untracked(this.events), untracked(this.restState)];
|
|
1294
1324
|
if (!is.instance(container)) {
|
|
1295
1325
|
container = prepare(container, 'ngt-portal', { store: this.portalStore });
|
|
@@ -1308,8 +1338,8 @@ class NgtPortal {
|
|
|
1308
1338
|
this.portalContentRendered.set(true);
|
|
1309
1339
|
});
|
|
1310
1340
|
}
|
|
1311
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.
|
|
1312
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.1.
|
|
1341
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtPortalImpl, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1342
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.1.6", type: NgtPortalImpl, isStandalone: true, selector: "ngt-portal", inputs: { container: { classPropertyName: "container", publicName: "container", isSignal: true, isRequired: true, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
|
|
1313
1343
|
{
|
|
1314
1344
|
provide: NGT_STORE,
|
|
1315
1345
|
useFactory: (previousStore) => {
|
|
@@ -1336,7 +1366,7 @@ class NgtPortal {
|
|
|
1336
1366
|
}
|
|
1337
1367
|
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
1338
1368
|
}
|
|
1339
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.
|
|
1369
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtPortalImpl, decorators: [{
|
|
1340
1370
|
type: Component,
|
|
1341
1371
|
args: [{
|
|
1342
1372
|
selector: 'ngt-portal',
|
|
@@ -1371,7 +1401,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
|
|
|
1371
1401
|
],
|
|
1372
1402
|
}]
|
|
1373
1403
|
}], ctorParameters: () => [] });
|
|
1374
|
-
const
|
|
1404
|
+
const NgtPortal = [NgtPortalImpl, NgtPortalContent];
|
|
1375
1405
|
|
|
1376
1406
|
/**
|
|
1377
1407
|
* Release pointer captures.
|
|
@@ -1501,7 +1531,20 @@ function createEvents(store) {
|
|
|
1501
1531
|
if (intersections.length) {
|
|
1502
1532
|
const localState = { stopped: false };
|
|
1503
1533
|
for (const hit of intersections) {
|
|
1504
|
-
|
|
1534
|
+
let instanceState = getInstanceState(hit.object);
|
|
1535
|
+
// If the object is not managed by NGT, it might be parented to an element which is.
|
|
1536
|
+
// Traverse upwards until we find a managed parent and use its state instead.
|
|
1537
|
+
if (!instanceState) {
|
|
1538
|
+
hit.object.traverseAncestors((ancestor) => {
|
|
1539
|
+
const parentInstanceState = getInstanceState(ancestor);
|
|
1540
|
+
if (parentInstanceState) {
|
|
1541
|
+
instanceState = parentInstanceState;
|
|
1542
|
+
return false;
|
|
1543
|
+
}
|
|
1544
|
+
return;
|
|
1545
|
+
});
|
|
1546
|
+
}
|
|
1547
|
+
const { raycaster, pointer, camera, internal } = instanceState?.store?.snapshot || rootState;
|
|
1505
1548
|
const unprojectedPoint = new THREE.Vector3(pointer.x, pointer.y, 0).unproject(camera);
|
|
1506
1549
|
const hasPointerCapture = (id) => internal.capturedMap.get(id)?.has(hit.eventObject) ?? false;
|
|
1507
1550
|
const setPointerCapture = (id) => {
|
|
@@ -1686,7 +1729,10 @@ function createEvents(store) {
|
|
|
1686
1729
|
}*/
|
|
1687
1730
|
if (isPointerMove) {
|
|
1688
1731
|
// Move event ...
|
|
1689
|
-
if (handlers?.pointerover ||
|
|
1732
|
+
if (handlers?.pointerover ||
|
|
1733
|
+
handlers?.pointerenter ||
|
|
1734
|
+
handlers?.pointerout ||
|
|
1735
|
+
handlers?.pointerleave) {
|
|
1690
1736
|
// When enter or out is present take care of hover-state
|
|
1691
1737
|
const id = makeId(data);
|
|
1692
1738
|
const hoveredItem = internal.hovered.get(id);
|
|
@@ -1733,9 +1779,9 @@ function createEvents(store) {
|
|
|
1733
1779
|
|
|
1734
1780
|
// This function prepares a set of changes to be applied to the instance
|
|
1735
1781
|
function diffProps(instance, props) {
|
|
1736
|
-
const propsEntries = Object.entries(props);
|
|
1737
1782
|
const changes = [];
|
|
1738
|
-
for (const
|
|
1783
|
+
for (const propKey in props) {
|
|
1784
|
+
const propValue = props[propKey];
|
|
1739
1785
|
let key = propKey;
|
|
1740
1786
|
if (is.colorSpaceExist(instance)) {
|
|
1741
1787
|
if (propKey === 'encoding') {
|
|
@@ -1771,6 +1817,19 @@ function getMemoizedPrototype(root) {
|
|
|
1771
1817
|
}
|
|
1772
1818
|
return ctor;
|
|
1773
1819
|
}
|
|
1820
|
+
function resolve(instance, key) {
|
|
1821
|
+
let targetProp = instance[key];
|
|
1822
|
+
if (!key.includes('.'))
|
|
1823
|
+
return { root: instance, targetKey: key, targetProp };
|
|
1824
|
+
// Resolve pierced target
|
|
1825
|
+
const chain = key.split('.');
|
|
1826
|
+
targetProp = chain.reduce((acc, part) => acc[part], instance);
|
|
1827
|
+
const targetKey = chain.pop();
|
|
1828
|
+
// Switch root if atomic
|
|
1829
|
+
if (!targetProp?.set)
|
|
1830
|
+
instance = chain.reduce((acc, part) => acc[part], instance);
|
|
1831
|
+
return { root: instance, targetKey, targetProp };
|
|
1832
|
+
}
|
|
1774
1833
|
// This function applies a set of changes to the instance
|
|
1775
1834
|
function applyProps(instance, props) {
|
|
1776
1835
|
// if props is empty
|
|
@@ -1800,45 +1859,45 @@ function applyProps(instance, props) {
|
|
|
1800
1859
|
// value = value === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace;
|
|
1801
1860
|
// }
|
|
1802
1861
|
// }
|
|
1803
|
-
const
|
|
1804
|
-
|
|
1862
|
+
const { root, targetKey, targetProp } = resolve(instance, key);
|
|
1863
|
+
// we have switched due to pierced props
|
|
1864
|
+
if (root !== instance) {
|
|
1865
|
+
return applyProps(root, { [targetKey]: value });
|
|
1866
|
+
}
|
|
1867
|
+
// Layers have no copy function, we must therefore copy the mask property
|
|
1868
|
+
if (targetProp instanceof THREE.Layers && value instanceof THREE.Layers) {
|
|
1869
|
+
targetProp.mask = value.mask;
|
|
1870
|
+
}
|
|
1871
|
+
else if (is.three(targetProp, 'isColor') && is.colorRepresentation(value)) {
|
|
1872
|
+
targetProp.set(value);
|
|
1873
|
+
}
|
|
1805
1874
|
// Copy if properties match signatures
|
|
1806
|
-
if (targetProp
|
|
1875
|
+
else if (targetProp &&
|
|
1876
|
+
typeof targetProp.set === 'function' &&
|
|
1877
|
+
typeof targetProp.copy === 'function' &&
|
|
1807
1878
|
value?.constructor &&
|
|
1808
1879
|
targetProp.constructor === value.constructor) {
|
|
1809
1880
|
// If both are geometries, we should assign the value directly instead of copying
|
|
1810
1881
|
if (is.three(targetProp, 'isBufferGeometry') &&
|
|
1811
1882
|
is.three(value, 'isBufferGeometry')) {
|
|
1812
|
-
Object.assign(
|
|
1883
|
+
Object.assign(root, { [targetKey]: value });
|
|
1813
1884
|
}
|
|
1814
1885
|
else {
|
|
1815
|
-
|
|
1816
|
-
const ctor = getMemoizedPrototype(currentInstance);
|
|
1817
|
-
// The target key was originally null or undefined, which indicates that the object which
|
|
1818
|
-
// is now present was externally set by the user, we should therefore assign the value directly
|
|
1819
|
-
if (ctor !== undefined && ctor[key] == null)
|
|
1820
|
-
Object.assign(currentInstance, { [key]: value });
|
|
1821
|
-
// Otherwise copy is correct
|
|
1822
|
-
else
|
|
1823
|
-
targetProp.copy(value);
|
|
1886
|
+
targetProp.copy(value);
|
|
1824
1887
|
}
|
|
1825
1888
|
}
|
|
1826
|
-
// Layers have no copy function, we must therefore copy the mask property
|
|
1827
|
-
else if (targetProp instanceof THREE.Layers && value instanceof THREE.Layers) {
|
|
1828
|
-
targetProp.mask = value.mask;
|
|
1829
|
-
}
|
|
1830
1889
|
// Set array types
|
|
1831
|
-
else if (targetProp
|
|
1832
|
-
if (targetProp.fromArray)
|
|
1890
|
+
else if (targetProp && typeof targetProp.set === 'function' && Array.isArray(value)) {
|
|
1891
|
+
if (typeof targetProp.fromArray === 'function')
|
|
1833
1892
|
targetProp.fromArray(value);
|
|
1834
1893
|
else
|
|
1835
1894
|
targetProp.set(...value);
|
|
1836
1895
|
}
|
|
1837
1896
|
// Set literal types
|
|
1838
|
-
else if (targetProp
|
|
1839
|
-
const isColor = targetProp
|
|
1897
|
+
else if (targetProp && typeof targetProp.set === 'function' && typeof value !== 'object') {
|
|
1898
|
+
const isColor = is.three(targetProp, 'isColor');
|
|
1840
1899
|
// Allow setting array scalars
|
|
1841
|
-
if (!isColor && targetProp.setScalar && typeof value === 'number')
|
|
1900
|
+
if (!isColor && typeof targetProp.setScalar === 'function' && typeof value === 'number')
|
|
1842
1901
|
targetProp.setScalar(value);
|
|
1843
1902
|
// Otherwise just set single value
|
|
1844
1903
|
else
|
|
@@ -1846,22 +1905,22 @@ function applyProps(instance, props) {
|
|
|
1846
1905
|
}
|
|
1847
1906
|
// Else, just overwrite the value
|
|
1848
1907
|
else {
|
|
1849
|
-
Object.assign(
|
|
1908
|
+
Object.assign(root, { [targetKey]: value });
|
|
1850
1909
|
// Auto-convert sRGB texture parameters for built-in materials
|
|
1851
1910
|
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
1852
1911
|
// https://github.com/mrdoob/three.js/pull/25857
|
|
1853
1912
|
if (rootState &&
|
|
1854
1913
|
!rootState.linear &&
|
|
1855
|
-
colorMaps.includes(
|
|
1856
|
-
|
|
1914
|
+
colorMaps.includes(targetKey) &&
|
|
1915
|
+
root[targetKey]?.isTexture &&
|
|
1857
1916
|
// sRGB textures must be RGBA8 since r137 https://github.com/mrdoob/three.js/pull/23129
|
|
1858
|
-
|
|
1859
|
-
|
|
1917
|
+
root[targetKey].format === THREE.RGBAFormat &&
|
|
1918
|
+
root[targetKey].type === THREE.UnsignedByteType) {
|
|
1860
1919
|
// NOTE: this cannot be set from the renderer (e.g. sRGB source textures rendered to P3)
|
|
1861
|
-
|
|
1920
|
+
root[targetKey].colorSpace = THREE.SRGBColorSpace;
|
|
1862
1921
|
}
|
|
1863
1922
|
}
|
|
1864
|
-
checkUpdate(
|
|
1923
|
+
checkUpdate(root[targetKey]);
|
|
1865
1924
|
checkUpdate(targetProp);
|
|
1866
1925
|
invalidateInstance(instance);
|
|
1867
1926
|
}
|
|
@@ -1987,7 +2046,10 @@ function propagateStoreRecursively(node, parentNode) {
|
|
|
1987
2046
|
// Call addInteraction if it exists
|
|
1988
2047
|
iS.addInteraction?.(pIS.store);
|
|
1989
2048
|
// Collect all children (objects and nonObjects)
|
|
1990
|
-
const children = [
|
|
2049
|
+
const children = [
|
|
2050
|
+
...(iS.objects ? untracked(iS.objects) : []),
|
|
2051
|
+
...(iS.nonObjects ? untracked(iS.nonObjects) : []),
|
|
2052
|
+
];
|
|
1991
2053
|
// Recursively reassign the store for each child
|
|
1992
2054
|
for (const child of children) {
|
|
1993
2055
|
propagateStoreRecursively(child, node);
|
|
@@ -2155,6 +2217,7 @@ function internalDestroyNode(node, removeChild) {
|
|
|
2155
2217
|
rS[1 /* NgtRendererClassId.destroyed */] = true;
|
|
2156
2218
|
}
|
|
2157
2219
|
|
|
2220
|
+
const NGT_RENDERER_OPTIONS = new InjectionToken('NGT_RENDERER_OPTIONS');
|
|
2158
2221
|
class NgtRendererFactory2 {
|
|
2159
2222
|
/**
|
|
2160
2223
|
* NOTE: We use `useFactory` to instantiate `NgtRendererFactory2`
|
|
@@ -2163,6 +2226,7 @@ class NgtRendererFactory2 {
|
|
|
2163
2226
|
this.delegateRendererFactory = delegateRendererFactory;
|
|
2164
2227
|
this.catalogue = injectCatalogue();
|
|
2165
2228
|
this.document = inject(DOCUMENT);
|
|
2229
|
+
this.options = inject(NGT_RENDERER_OPTIONS, { optional: true }) || {};
|
|
2166
2230
|
this.rendererMap = new Map();
|
|
2167
2231
|
}
|
|
2168
2232
|
createRenderer(hostElement, type) {
|
|
@@ -2194,24 +2258,27 @@ class NgtRendererFactory2 {
|
|
|
2194
2258
|
return;
|
|
2195
2259
|
internalDestroyNode(node, null);
|
|
2196
2260
|
};
|
|
2197
|
-
Object.assign(delegateRenderer.destroyNode, {
|
|
2261
|
+
Object.assign(delegateRenderer.destroyNode, {
|
|
2262
|
+
[NGT_DELEGATE_RENDERER_DESTROY_NODE_PATCHED_FLAG]: true,
|
|
2263
|
+
});
|
|
2198
2264
|
}
|
|
2199
2265
|
return delegateRenderer;
|
|
2200
2266
|
}
|
|
2201
|
-
this.rendererMap.set(type.id, (renderer = new NgtRenderer2(delegateRenderer, this.catalogue, this.document)));
|
|
2267
|
+
this.rendererMap.set(type.id, (renderer = new NgtRenderer2(delegateRenderer, this.catalogue, this.document, this.options)));
|
|
2202
2268
|
return renderer;
|
|
2203
2269
|
}
|
|
2204
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.
|
|
2205
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.
|
|
2270
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtRendererFactory2, deps: [{ token: i0.RendererFactory2 }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2271
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtRendererFactory2 }); }
|
|
2206
2272
|
}
|
|
2207
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.
|
|
2273
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtRendererFactory2, decorators: [{
|
|
2208
2274
|
type: Injectable
|
|
2209
2275
|
}], ctorParameters: () => [{ type: i0.RendererFactory2 }] });
|
|
2210
2276
|
class NgtRenderer2 {
|
|
2211
|
-
constructor(delegateRenderer, catalogue, document, count = 1) {
|
|
2277
|
+
constructor(delegateRenderer, catalogue, document, options, count = 1) {
|
|
2212
2278
|
this.delegateRenderer = delegateRenderer;
|
|
2213
2279
|
this.catalogue = catalogue;
|
|
2214
2280
|
this.document = document;
|
|
2281
|
+
this.options = options;
|
|
2215
2282
|
this.count = count;
|
|
2216
2283
|
this.argsInjectors = [];
|
|
2217
2284
|
this.parentInjectors = [];
|
|
@@ -2226,6 +2293,9 @@ class NgtRenderer2 {
|
|
|
2226
2293
|
this.selectRootElement = this.delegateRenderer.selectRootElement.bind(this.delegateRenderer);
|
|
2227
2294
|
this.nextSibling = this.delegateRenderer.nextSibling.bind(this.delegateRenderer);
|
|
2228
2295
|
this.setValue = this.delegateRenderer.setValue.bind(this.delegateRenderer);
|
|
2296
|
+
if (!this.options.verbose) {
|
|
2297
|
+
this.options.verbose = false;
|
|
2298
|
+
}
|
|
2229
2299
|
}
|
|
2230
2300
|
get data() {
|
|
2231
2301
|
return { ...this.delegateRenderer.data, __ngt_renderer__: true };
|
|
@@ -2258,10 +2328,9 @@ class NgtRenderer2 {
|
|
|
2258
2328
|
throw new Error(`[NGT] ngt-primitive without args is invalid`);
|
|
2259
2329
|
const object = injectedArgs[0];
|
|
2260
2330
|
let instanceState = getInstanceState(object);
|
|
2261
|
-
if (!instanceState || instanceState.type
|
|
2331
|
+
if (!instanceState || instanceState.type !== 'ngt-primitive') {
|
|
2262
2332
|
// if an object isn't already "prepared", we'll prepare it
|
|
2263
2333
|
prepare(object, 'ngt-primitive', instanceState);
|
|
2264
|
-
instanceState = getInstanceState(object);
|
|
2265
2334
|
}
|
|
2266
2335
|
const primitiveRendererNode = createRendererNode('three', object, this.document);
|
|
2267
2336
|
if (injectedParent) {
|
|
@@ -2330,11 +2399,12 @@ class NgtRenderer2 {
|
|
|
2330
2399
|
const pRS = parent.__ngt_renderer__;
|
|
2331
2400
|
const cRS = newChild.__ngt_renderer__;
|
|
2332
2401
|
if (!pRS || !cRS) {
|
|
2333
|
-
|
|
2402
|
+
this.options.verbose &&
|
|
2403
|
+
console.warn('[NGT dev mode] One of parent or child is not a renderer node.', { parent, newChild });
|
|
2334
2404
|
return delegatedFn();
|
|
2335
2405
|
}
|
|
2336
2406
|
if (cRS[0 /* NgtRendererClassId.type */] === 'comment') {
|
|
2337
|
-
// if
|
|
2407
|
+
// if child is a comment, we'll set the parent then bail.
|
|
2338
2408
|
// comment usually means it's part of a templateRef ViewContainerRef or structural directive
|
|
2339
2409
|
setRendererParentNode(newChild, parent);
|
|
2340
2410
|
// if parent is not three, we'll delegate to the renderer
|
|
@@ -2358,6 +2428,8 @@ class NgtRenderer2 {
|
|
|
2358
2428
|
if (pRS[0 /* NgtRendererClassId.type */] === 'platform' && cRS[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2359
2429
|
// if platform has parent, delegate to that parent
|
|
2360
2430
|
if (pRS[5 /* NgtRendererClassId.parent */]) {
|
|
2431
|
+
// but track the child for this parent as well
|
|
2432
|
+
addRendererChildNode(parent, newChild);
|
|
2361
2433
|
return this.appendChild(pRS[5 /* NgtRendererClassId.parent */], newChild);
|
|
2362
2434
|
}
|
|
2363
2435
|
// platform can also have normal parentNode
|
|
@@ -2399,7 +2471,10 @@ class NgtRenderer2 {
|
|
|
2399
2471
|
// if both are comments and the reference child is NgtCanvasContent, we'll assign the same flag to the newChild
|
|
2400
2472
|
// this means that the NgtCanvas component is embedding. This flag allows the Renderer to get the root scene
|
|
2401
2473
|
// when it tries to attach the template under `ng-template[canvasContent]`
|
|
2402
|
-
if (refChild &&
|
|
2474
|
+
if (refChild &&
|
|
2475
|
+
refChild[NGT_CANVAS_CONTENT_FLAG] &&
|
|
2476
|
+
refChild instanceof Comment &&
|
|
2477
|
+
newChild instanceof Comment) {
|
|
2403
2478
|
Object.assign(newChild, { [NGT_CANVAS_CONTENT_FLAG]: refChild[NGT_CANVAS_CONTENT_FLAG] });
|
|
2404
2479
|
}
|
|
2405
2480
|
// if there is no parent, we delegate
|
|
@@ -2429,7 +2504,8 @@ class NgtRenderer2 {
|
|
|
2429
2504
|
// if the child is already destroyed, just skip
|
|
2430
2505
|
return;
|
|
2431
2506
|
}
|
|
2432
|
-
|
|
2507
|
+
this.options.verbose &&
|
|
2508
|
+
console.warn('[NGT dev mode] parent is not found when remove child', { parent, oldChild });
|
|
2433
2509
|
return;
|
|
2434
2510
|
}
|
|
2435
2511
|
const pRS = parent.__ngt_renderer__;
|
|
@@ -2482,7 +2558,9 @@ class NgtRenderer2 {
|
|
|
2482
2558
|
// set parent to the comment too
|
|
2483
2559
|
setRendererParentNode(node, sceneRendererNode);
|
|
2484
2560
|
}
|
|
2485
|
-
if (node[NGT_PORTAL_CONTENT_FLAG] &&
|
|
2561
|
+
if (node[NGT_PORTAL_CONTENT_FLAG] &&
|
|
2562
|
+
node[NGT_DOM_PARENT_FLAG] &&
|
|
2563
|
+
isRendererNode(node[NGT_DOM_PARENT_FLAG])) {
|
|
2486
2564
|
const portalContentParent = node[NGT_DOM_PARENT_FLAG];
|
|
2487
2565
|
const portalContentParentRS = portalContentParent.__ngt_renderer__;
|
|
2488
2566
|
if (!portalContentParentRS[3 /* NgtRendererClassId.portalContainer */]) {
|
|
@@ -2495,7 +2573,6 @@ class NgtRenderer2 {
|
|
|
2495
2573
|
// returns the renderer parent node if it exists, otherwise returns the delegateRenderer parentNode
|
|
2496
2574
|
return rendererParentNode ?? this.delegateRenderer.parentNode(node);
|
|
2497
2575
|
}
|
|
2498
|
-
// removeAttribute = this.delegateRenderer.removeAttribute.bind(this.delegateRenderer);
|
|
2499
2576
|
removeAttribute(el, name, namespace) {
|
|
2500
2577
|
const rS = el.__ngt_renderer__;
|
|
2501
2578
|
if (!rS || rS[1 /* NgtRendererClassId.destroyed */])
|
|
@@ -2510,7 +2587,7 @@ class NgtRenderer2 {
|
|
|
2510
2587
|
if (!rS)
|
|
2511
2588
|
return this.delegateRenderer.setAttribute(el, name, value, namespace);
|
|
2512
2589
|
if (rS[1 /* NgtRendererClassId.destroyed */]) {
|
|
2513
|
-
|
|
2590
|
+
this.options.verbose &&
|
|
2514
2591
|
console.warn(`[NGT dev mode] setAttribute is invoked on destroyed renderer node.`, { el, name, value });
|
|
2515
2592
|
return;
|
|
2516
2593
|
}
|
|
@@ -2522,24 +2599,23 @@ class NgtRenderer2 {
|
|
|
2522
2599
|
if (instanceState)
|
|
2523
2600
|
instanceState.attach = paths;
|
|
2524
2601
|
}
|
|
2602
|
+
return;
|
|
2603
|
+
}
|
|
2604
|
+
// coercion for primitive values
|
|
2605
|
+
let maybeCoerced = value;
|
|
2606
|
+
if (maybeCoerced === '' || maybeCoerced === 'true' || maybeCoerced === 'false') {
|
|
2607
|
+
maybeCoerced = maybeCoerced === 'true' || maybeCoerced === '';
|
|
2525
2608
|
}
|
|
2526
2609
|
else {
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
}
|
|
2537
|
-
if (name === 'rawValue') {
|
|
2538
|
-
rS[2 /* NgtRendererClassId.rawValue */] = maybeCoerced;
|
|
2539
|
-
}
|
|
2540
|
-
else {
|
|
2541
|
-
applyProps(el, { [name]: maybeCoerced });
|
|
2542
|
-
}
|
|
2610
|
+
const maybeNumber = Number(maybeCoerced);
|
|
2611
|
+
if (!isNaN(maybeNumber))
|
|
2612
|
+
maybeCoerced = maybeNumber;
|
|
2613
|
+
}
|
|
2614
|
+
if (name === 'rawValue') {
|
|
2615
|
+
rS[2 /* NgtRendererClassId.rawValue */] = maybeCoerced;
|
|
2616
|
+
}
|
|
2617
|
+
else {
|
|
2618
|
+
applyProps(el, { [name]: maybeCoerced });
|
|
2543
2619
|
}
|
|
2544
2620
|
return;
|
|
2545
2621
|
}
|
|
@@ -2550,7 +2626,7 @@ class NgtRenderer2 {
|
|
|
2550
2626
|
// attaching potentially updates signals which is not allowed
|
|
2551
2627
|
const rS = el.__ngt_renderer__;
|
|
2552
2628
|
if (!rS || rS[1 /* NgtRendererClassId.destroyed */]) {
|
|
2553
|
-
|
|
2629
|
+
this.options.verbose &&
|
|
2554
2630
|
console.warn('[NGT dev mode] setProperty is invoked on destroyed renderer node.', { el, name, value });
|
|
2555
2631
|
return;
|
|
2556
2632
|
}
|
|
@@ -2562,7 +2638,7 @@ class NgtRenderer2 {
|
|
|
2562
2638
|
value['raycast'] = () => null;
|
|
2563
2639
|
}
|
|
2564
2640
|
applyProps(el, value);
|
|
2565
|
-
if ('geometry' in value && value['geometry']
|
|
2641
|
+
if ('geometry' in value && is.three(value['geometry'], 'isBufferGeometry')) {
|
|
2566
2642
|
untracked(() => {
|
|
2567
2643
|
instanceState?.updateGeometryStamp();
|
|
2568
2644
|
});
|
|
@@ -2574,8 +2650,6 @@ class NgtRenderer2 {
|
|
|
2574
2650
|
if (instanceState?.type === 'ngt-value' && name === 'rawValue') {
|
|
2575
2651
|
rS[2 /* NgtRendererClassId.rawValue */] = value;
|
|
2576
2652
|
if (parent) {
|
|
2577
|
-
// untrack this attach because this is during setProperty which is a reactive context
|
|
2578
|
-
// attaching potentially updates signals which is not allowed
|
|
2579
2653
|
untracked(() => attachThreeNodes(parent, el));
|
|
2580
2654
|
}
|
|
2581
2655
|
return;
|
|
@@ -2600,7 +2674,7 @@ class NgtRenderer2 {
|
|
|
2600
2674
|
value = () => null;
|
|
2601
2675
|
}
|
|
2602
2676
|
applyProps(el, { [name]: value });
|
|
2603
|
-
if (instanceState && name === 'geometry' && value
|
|
2677
|
+
if (instanceState && name === 'geometry' && is.three(value, 'isBufferGeometry')) {
|
|
2604
2678
|
untracked(() => {
|
|
2605
2679
|
instanceState.updateGeometryStamp();
|
|
2606
2680
|
});
|
|
@@ -2625,6 +2699,10 @@ class NgtRenderer2 {
|
|
|
2625
2699
|
console.warn('[NGT] instance which has not been prepared cannot have events. Call `prepare()` manually if needed.');
|
|
2626
2700
|
return () => { };
|
|
2627
2701
|
}
|
|
2702
|
+
if (eventName === 'created') {
|
|
2703
|
+
callback(target);
|
|
2704
|
+
return () => { };
|
|
2705
|
+
}
|
|
2628
2706
|
if (eventName === 'attached') {
|
|
2629
2707
|
iS.onAttach = callback;
|
|
2630
2708
|
const parent = iS.parent && untracked(iS.parent);
|
|
@@ -2645,7 +2723,8 @@ class NgtRenderer2 {
|
|
|
2645
2723
|
if (eventName === 'disposed') {
|
|
2646
2724
|
eventName = 'dispose';
|
|
2647
2725
|
}
|
|
2648
|
-
if (target.parent &&
|
|
2726
|
+
if (target.parent &&
|
|
2727
|
+
(eventName === 'added' || eventName === 'removed')) {
|
|
2649
2728
|
callback({ type: eventName, target });
|
|
2650
2729
|
}
|
|
2651
2730
|
target.addEventListener(eventName, callback);
|
|
@@ -2654,7 +2733,7 @@ class NgtRenderer2 {
|
|
|
2654
2733
|
};
|
|
2655
2734
|
}
|
|
2656
2735
|
const cleanup = iS.setPointerEvent?.(eventName, callback) || (() => { });
|
|
2657
|
-
// this means the object has already been
|
|
2736
|
+
// this means the object has already been attached to the parent and has its store propagated
|
|
2658
2737
|
if (iS.store) {
|
|
2659
2738
|
iS.addInteraction?.(iS.store);
|
|
2660
2739
|
}
|
|
@@ -2663,16 +2742,19 @@ class NgtRenderer2 {
|
|
|
2663
2742
|
return this.delegateRenderer.listen(target, eventName, callback);
|
|
2664
2743
|
}
|
|
2665
2744
|
appendThreeRendererNodes(parent, child) {
|
|
2666
|
-
// if parent and
|
|
2745
|
+
// if parent and child are the same, skip
|
|
2667
2746
|
if (parent === child) {
|
|
2668
|
-
|
|
2669
|
-
console.warn('[NGT dev mode] appending THREE.js parent and child but they are the same', {
|
|
2747
|
+
this.options.verbose &&
|
|
2748
|
+
console.warn('[NGT dev mode] appending THREE.js parent and child but they are the same', {
|
|
2749
|
+
parent,
|
|
2750
|
+
child,
|
|
2751
|
+
});
|
|
2670
2752
|
return;
|
|
2671
2753
|
}
|
|
2672
2754
|
const cIS = getInstanceState(child);
|
|
2673
2755
|
// if child is already attached to a parent, skip
|
|
2674
2756
|
if (cIS?.hierarchyStore.snapshot.parent) {
|
|
2675
|
-
|
|
2757
|
+
this.options.verbose &&
|
|
2676
2758
|
console.warn('[NGT dev mode] appending THREE.js parent and child but child is already attached', {
|
|
2677
2759
|
parent,
|
|
2678
2760
|
child,
|
|
@@ -2736,6 +2818,7 @@ function injectCanvasRootInitializer(injector) {
|
|
|
2736
2818
|
const state = root.snapshot;
|
|
2737
2819
|
state.events.disconnect?.();
|
|
2738
2820
|
state.gl?.renderLists?.dispose?.();
|
|
2821
|
+
state.gl?.dispose?.();
|
|
2739
2822
|
state.gl?.forceContextLoss?.();
|
|
2740
2823
|
if (state.gl?.xr)
|
|
2741
2824
|
state.xr.disconnect();
|
|
@@ -2768,10 +2851,13 @@ function injectCanvasRootInitializer(injector) {
|
|
|
2768
2851
|
applyProps(raycaster, { params: { ...raycaster.params, ...(params || {}) } });
|
|
2769
2852
|
}
|
|
2770
2853
|
// Create default camera, don't overwrite any user-set state
|
|
2771
|
-
if (!state.camera ||
|
|
2854
|
+
if (!state.camera ||
|
|
2855
|
+
(state.camera === lastCamera && !is.equ(lastCamera, cameraOptions, shallowLoose))) {
|
|
2772
2856
|
lastCamera = cameraOptions;
|
|
2773
2857
|
const isCamera = is.three(cameraOptions, 'isCamera');
|
|
2774
|
-
let camera = isCamera
|
|
2858
|
+
let camera = isCamera
|
|
2859
|
+
? cameraOptions
|
|
2860
|
+
: makeCameraInstance(orthographic, sizeOptions ?? state.size);
|
|
2775
2861
|
if (!isCamera) {
|
|
2776
2862
|
camera.position.z = 5;
|
|
2777
2863
|
if (cameraOptions) {
|
|
@@ -2973,12 +3059,12 @@ class NgtRoutedScene {
|
|
|
2973
3059
|
onCleanup(() => sub.unsubscribe());
|
|
2974
3060
|
});
|
|
2975
3061
|
}
|
|
2976
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.
|
|
2977
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.
|
|
3062
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtRoutedScene, deps: [{ token: i1.Router }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
3063
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.6", type: NgtRoutedScene, isStandalone: true, selector: "ngt-routed-scene", ngImport: i0, template: `
|
|
2978
3064
|
<router-outlet />
|
|
2979
3065
|
`, isInline: true, dependencies: [{ kind: "directive", type: RouterOutlet, selector: "router-outlet", inputs: ["name", "routerOutletData"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }] }); }
|
|
2980
3066
|
}
|
|
2981
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.
|
|
3067
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtRoutedScene, decorators: [{
|
|
2982
3068
|
type: Component,
|
|
2983
3069
|
args: [{
|
|
2984
3070
|
selector: 'ngt-routed-scene',
|
|
@@ -2993,32 +3079,34 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
|
|
|
2993
3079
|
* `injectBeforeRender` invokes its callback on every frame. Hence, the notion of tracking
|
|
2994
3080
|
* changes (i.e: signals) does not really matter since we're getting latest values of the things we need on every frame anyway.
|
|
2995
3081
|
*
|
|
2996
|
-
* If `priority` is
|
|
2997
|
-
* an `effect` and track `priority` changes. Make use of `onCleanup` to clean up
|
|
2998
|
-
* previous before render subscription
|
|
3082
|
+
* If `priority` is a Signal, `injectBeforeRender` will set up an Effect internally and returns the `EffectRef#destroy` instead.
|
|
2999
3083
|
*
|
|
3000
3084
|
* @example
|
|
3001
3085
|
* ```ts
|
|
3002
|
-
* const
|
|
3003
|
-
*
|
|
3004
|
-
*
|
|
3005
|
-
*
|
|
3006
|
-
*
|
|
3007
|
-
*
|
|
3008
|
-
*
|
|
3009
|
-
*
|
|
3010
|
-
* },
|
|
3011
|
-
* {
|
|
3012
|
-
* priority,
|
|
3013
|
-
* injector, // injector is needed since injectBeforeRender is invoked in effect body
|
|
3014
|
-
* }
|
|
3015
|
-
* });
|
|
3016
|
-
*
|
|
3017
|
-
* onCleanup(() => sub());
|
|
3018
|
-
* });
|
|
3086
|
+
* const destroy = injectBeforeRender(
|
|
3087
|
+
* ({ gl, camera }) => {
|
|
3088
|
+
* // before render logic
|
|
3089
|
+
* },
|
|
3090
|
+
* {
|
|
3091
|
+
* priority: this.priority, // this.priority is a Signal<number>
|
|
3092
|
+
* }
|
|
3093
|
+
* )
|
|
3019
3094
|
* ```
|
|
3020
3095
|
*/
|
|
3021
3096
|
function injectBeforeRender(cb, { priority = 0, injector } = {}) {
|
|
3097
|
+
if (typeof priority === 'function') {
|
|
3098
|
+
const effectRef = assertInjector(injectBeforeRender, injector, () => {
|
|
3099
|
+
const store = injectStore();
|
|
3100
|
+
const ref = effect((onCleanup) => {
|
|
3101
|
+
const p = priority();
|
|
3102
|
+
const sub = store.snapshot.internal.subscribe(cb, p, store);
|
|
3103
|
+
onCleanup(() => sub());
|
|
3104
|
+
});
|
|
3105
|
+
inject(DestroyRef).onDestroy(() => void ref.destroy());
|
|
3106
|
+
return ref;
|
|
3107
|
+
});
|
|
3108
|
+
return effectRef.destroy.bind(effectRef);
|
|
3109
|
+
}
|
|
3022
3110
|
return assertInjector(injectBeforeRender, injector, () => {
|
|
3023
3111
|
const store = injectStore();
|
|
3024
3112
|
const sub = store.snapshot.internal.subscribe(cb, priority, store);
|
|
@@ -3027,29 +3115,22 @@ function injectBeforeRender(cb, { priority = 0, injector } = {}) {
|
|
|
3027
3115
|
});
|
|
3028
3116
|
}
|
|
3029
3117
|
|
|
3030
|
-
function resolveRef(ref) {
|
|
3031
|
-
if (is.ref(ref)) {
|
|
3032
|
-
return ref.nativeElement;
|
|
3033
|
-
}
|
|
3034
|
-
return ref;
|
|
3035
|
-
}
|
|
3036
|
-
|
|
3037
3118
|
/**
|
|
3038
3119
|
* As host directive:
|
|
3039
3120
|
* - outputs: [
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3121
|
+
'click',
|
|
3122
|
+
'dblclick',
|
|
3123
|
+
'contextmenu',
|
|
3124
|
+
'pointerup',
|
|
3125
|
+
'pointerdown',
|
|
3126
|
+
'pointerover',
|
|
3127
|
+
'pointerout',
|
|
3128
|
+
'pointerenter',
|
|
3129
|
+
'pointerleave',
|
|
3130
|
+
'pointermove',
|
|
3131
|
+
'pointermissed',
|
|
3132
|
+
'pointercancel',
|
|
3133
|
+
'wheel',
|
|
3053
3134
|
* ]
|
|
3054
3135
|
* - inputs: [
|
|
3055
3136
|
* 'ngtObjectEvents'
|
|
@@ -3097,10 +3178,10 @@ class NgtObjectEvents {
|
|
|
3097
3178
|
emitEvent(eventName) {
|
|
3098
3179
|
return this[eventName].emit.bind(this[eventName]);
|
|
3099
3180
|
}
|
|
3100
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.
|
|
3101
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.
|
|
3181
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtObjectEvents, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
3182
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.6", type: NgtObjectEvents, isStandalone: true, selector: "[ngtObjectEvents]", inputs: { ngtObjectEvents: { classPropertyName: "ngtObjectEvents", publicName: "ngtObjectEvents", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { click: "click", dblclick: "dblclick", contextmenu: "contextmenu", pointerup: "pointerup", pointerdown: "pointerdown", pointerover: "pointerover", pointerout: "pointerout", pointerenter: "pointerenter", pointerleave: "pointerleave", pointermove: "pointermove", pointermissed: "pointermissed", pointercancel: "pointercancel", wheel: "wheel", ngtObjectEvents: "ngtObjectEventsChange" }, ngImport: i0 }); }
|
|
3102
3183
|
}
|
|
3103
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.
|
|
3184
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.6", ngImport: i0, type: NgtObjectEvents, decorators: [{
|
|
3104
3185
|
type: Directive,
|
|
3105
3186
|
args: [{ selector: '[ngtObjectEvents]' }]
|
|
3106
3187
|
}], ctorParameters: () => [] });
|
|
@@ -3109,11 +3190,11 @@ function injectObjectEvents(target, events, { injector } = {}) {
|
|
|
3109
3190
|
const renderer = inject(Renderer2);
|
|
3110
3191
|
const cleanUps = [];
|
|
3111
3192
|
effect((onCleanup) => {
|
|
3112
|
-
const
|
|
3113
|
-
if (!
|
|
3193
|
+
const targetObj = resolveRef(target());
|
|
3194
|
+
if (!targetObj || !is.instance(targetObj))
|
|
3114
3195
|
return;
|
|
3115
3196
|
Object.entries(events).forEach(([eventName, eventHandler]) => {
|
|
3116
|
-
cleanUps.push(renderer.listen(
|
|
3197
|
+
cleanUps.push(renderer.listen(targetObj, eventName, eventHandler));
|
|
3117
3198
|
});
|
|
3118
3199
|
onCleanup(() => {
|
|
3119
3200
|
cleanUps.forEach((cleanUp) => cleanUp());
|
|
@@ -3139,5 +3220,5 @@ function hasListener(...emitterRefs) {
|
|
|
3139
3220
|
* Generated bundle index. Do not edit.
|
|
3140
3221
|
*/
|
|
3141
3222
|
|
|
3142
|
-
export { NGT_APPLY_PROPS, NGT_ARGS_FLAG, NGT_CANVAS_CONTENT_FLAG, NGT_CATALOGUE, NGT_DELEGATE_RENDERER_DESTROY_NODE_PATCHED_FLAG, NGT_DOM_PARENT_FLAG, NGT_GET_NODE_ATTRIBUTE_FLAG, NGT_HTML_FLAG, NGT_INTERNAL_ADD_COMMENT_FLAG, NGT_INTERNAL_SET_PARENT_COMMENT_FLAG, NGT_LOOP, NGT_PARENT_FLAG, NGT_PORTAL_CONTENT_FLAG, NGT_RENDERER_NODE_FLAG, NGT_STORE, NgtArgs, NgtHTML, NgtHexify, NgtObjectEvents, NgtParent, NgtPortal, NgtPortalAutoRender, NgtPortalContent,
|
|
3223
|
+
export { NGT_APPLY_PROPS, NGT_ARGS_FLAG, NGT_CANVAS_CONTENT_FLAG, NGT_CATALOGUE, NGT_DELEGATE_RENDERER_DESTROY_NODE_PATCHED_FLAG, NGT_DOM_PARENT_FLAG, NGT_GET_NODE_ATTRIBUTE_FLAG, NGT_HTML_FLAG, NGT_INTERNAL_ADD_COMMENT_FLAG, NGT_INTERNAL_SET_PARENT_COMMENT_FLAG, NGT_LOOP, NGT_PARENT_FLAG, NGT_PORTAL_CONTENT_FLAG, NGT_RENDERER_NODE_FLAG, NGT_RENDERER_OPTIONS, NGT_STORE, NgtArgs, NgtHTML, NgtHexify, NgtObjectEvents, NgtParent, NgtPortal, NgtPortalAutoRender, NgtPortalContent, NgtPortalImpl, NgtRenderer2, NgtRendererFactory2, NgtRoutedScene, NgtSelect, NgtSelection, NgtSelectionApi, THREE_NATIVE_EVENTS, addAfterEffect, addEffect, addTail, applyProps, attach, checkNeedsUpdate, checkUpdate, createAttachFunction, createEvents, detach, dispose, extend, flushGlobalEffects, getEmitter, getInstanceState, getLocalState, hasListener, injectBeforeRender, injectCanvasRootInitializer, injectCatalogue, injectLoader, injectLoop, injectObjectEvents, injectStore, invalidateInstance, is, makeCameraInstance, makeDpr, makeId, makeObjectGraph, makeRendererInstance, merge, omit, pick, prepare, provideHTMLDomElement, removeInteractivity, resolveRef, roots, signalState, storeFactory, updateCamera, vector2, vector3, vector4 };
|
|
3143
3224
|
//# sourceMappingURL=angular-three.mjs.map
|