angular-three 2.0.0-beta.311 → 2.0.0-beta.312
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/esm2022/lib/canvas.mjs +6 -8
- package/esm2022/lib/renderer/index.mjs +14 -38
- package/esm2022/lib/renderer/state.mjs +9 -4
- package/esm2022/lib/renderer/utils.mjs +1 -1
- package/esm2022/lib/store.mjs +1 -8
- package/esm2022/lib/utils/make.mjs +2 -2
- package/esm2022/nativescript/angular-three-nativescript.mjs +5 -0
- package/esm2022/nativescript/index.mjs +2 -0
- package/esm2022/nativescript/lib/canvas.mjs +132 -0
- package/fesm2022/angular-three-nativescript.mjs +139 -0
- package/fesm2022/angular-three-nativescript.mjs.map +1 -0
- package/fesm2022/angular-three.mjs +26 -53
- package/fesm2022/angular-three.mjs.map +1 -1
- package/lib/renderer/index.d.ts +0 -1
- package/lib/renderer/state.d.ts +3 -2
- package/lib/renderer/utils.d.ts +2 -1
- package/nativescript/README.md +5 -0
- package/nativescript/index.d.ts +1 -0
- package/nativescript/lib/canvas.d.ts +369 -0
- package/nativescript/package.json +3 -0
- package/package.json +24 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { untracked, computed, signal, ElementRef, input, inject, ViewContainerRef, NgZone, TemplateRef, afterNextRender, DestroyRef, Directive, effect, InjectionToken,
|
|
2
|
+
import { untracked, computed, signal, ElementRef, input, inject, ViewContainerRef, NgZone, TemplateRef, afterNextRender, DestroyRef, Directive, effect, InjectionToken, DebugNode, RendererFactory2, Injectable, makeEnvironmentProviders, Component, EnvironmentInjector, Injector, booleanAttribute, output, viewChild, createEnvironmentInjector, ChangeDetectionStrategy, Pipe, CUSTOM_ELEMENTS_SCHEMA, contentChild, model, Renderer2 } from '@angular/core';
|
|
3
3
|
import { takeUntilDestroyed, outputFromObservable, toObservable } from '@angular/core/rxjs-interop';
|
|
4
4
|
import { injectAutoEffect } from 'ngxtension/auto-effect';
|
|
5
5
|
import { provideResizeOptions, NgxResize } from 'ngxtension/resize';
|
|
@@ -282,7 +282,7 @@ function makeRendererInstance(glOptions, canvas) {
|
|
|
282
282
|
return customRenderer;
|
|
283
283
|
return new WebGLRenderer({
|
|
284
284
|
powerPreference: 'high-performance',
|
|
285
|
-
canvas
|
|
285
|
+
canvas,
|
|
286
286
|
antialias: true,
|
|
287
287
|
alpha: true,
|
|
288
288
|
...glOptions,
|
|
@@ -955,12 +955,6 @@ function createLoop(roots) {
|
|
|
955
955
|
const [injectLoop] = createInjectionToken(() => createLoop(roots));
|
|
956
956
|
|
|
957
957
|
function storeFactory(previousStore) {
|
|
958
|
-
const document = inject(DOCUMENT);
|
|
959
|
-
const window = document.defaultView;
|
|
960
|
-
if (!window) {
|
|
961
|
-
// TODO: revisit this when we need to support multiple platforms
|
|
962
|
-
throw new Error(`[NGT] Window is not available.`);
|
|
963
|
-
}
|
|
964
958
|
const loop = injectLoop();
|
|
965
959
|
// NOTE: using Subject because we do not care about late-subscribers
|
|
966
960
|
const pointerMissed$ = new Subject();
|
|
@@ -1254,7 +1248,7 @@ function extend(objects) {
|
|
|
1254
1248
|
const [injectCatalogue] = createInjectionToken(() => catalogue);
|
|
1255
1249
|
|
|
1256
1250
|
function createNode(type, node, document) {
|
|
1257
|
-
const state = [type, null, [], false, undefined, undefined, undefined];
|
|
1251
|
+
const state = [type, null, [], false, undefined, undefined, undefined, undefined];
|
|
1258
1252
|
const rendererNode = Object.assign(node, { __ngt_renderer__: state });
|
|
1259
1253
|
// NOTE: assign ownerDocument to node so we can use HostListener in Component
|
|
1260
1254
|
if (!rendererNode['ownerDocument'])
|
|
@@ -1262,7 +1256,12 @@ function createNode(type, node, document) {
|
|
|
1262
1256
|
// NOTE: assign injectorFactory on non-three type since
|
|
1263
1257
|
// rendererNode is an instance of DOM Node
|
|
1264
1258
|
if (state[0 /* NgtRendererClassId.type */] !== 'three') {
|
|
1265
|
-
state[
|
|
1259
|
+
state[7 /* NgtRendererClassId.debugNodeFactory */] = () => {
|
|
1260
|
+
if (!state[6 /* NgtRendererClassId.debugNode */]) {
|
|
1261
|
+
state[6 /* NgtRendererClassId.debugNode */] = new DebugNode(rendererNode);
|
|
1262
|
+
}
|
|
1263
|
+
return state[6 /* NgtRendererClassId.debugNode */];
|
|
1264
|
+
};
|
|
1266
1265
|
}
|
|
1267
1266
|
return rendererNode;
|
|
1268
1267
|
}
|
|
@@ -1603,7 +1602,12 @@ class NgtRenderer {
|
|
|
1603
1602
|
if (this.isRoot) {
|
|
1604
1603
|
this.isRoot = false;
|
|
1605
1604
|
const node = createNode('three', this.rootStore.snapshot.scene, this.document);
|
|
1606
|
-
node.__ngt_renderer__[
|
|
1605
|
+
node.__ngt_renderer__[7 /* NgtRendererClassId.debugNodeFactory */] = () => {
|
|
1606
|
+
if (!node.__ngt_renderer__[6 /* NgtRendererClassId.debugNode */]) {
|
|
1607
|
+
node.__ngt_renderer__[6 /* NgtRendererClassId.debugNode */] = new DebugNode(element);
|
|
1608
|
+
}
|
|
1609
|
+
return node.__ngt_renderer__[6 /* NgtRendererClassId.debugNode */];
|
|
1610
|
+
};
|
|
1607
1611
|
return node;
|
|
1608
1612
|
}
|
|
1609
1613
|
if (name === SPECIAL_DOM_TAG.NGT_PORTAL) {
|
|
@@ -1959,12 +1963,14 @@ class NgtRenderer {
|
|
|
1959
1963
|
}
|
|
1960
1964
|
}
|
|
1961
1965
|
if (rS[0 /* NgtRendererClassId.type */] === 'comment') {
|
|
1962
|
-
rS[6 /* NgtRendererClassId.
|
|
1966
|
+
rS[6 /* NgtRendererClassId.debugNode */] = null;
|
|
1967
|
+
rS[7 /* NgtRendererClassId.debugNodeFactory */] = null;
|
|
1963
1968
|
delete node[SPECIAL_INTERNAL_ADD_COMMENT];
|
|
1964
1969
|
this.removeCommentNode(node, this.argsCommentNodes);
|
|
1965
1970
|
}
|
|
1966
1971
|
if (rS[0 /* NgtRendererClassId.type */] === 'portal') {
|
|
1967
|
-
rS[6 /* NgtRendererClassId.
|
|
1972
|
+
rS[6 /* NgtRendererClassId.debugNode */] = null;
|
|
1973
|
+
rS[7 /* NgtRendererClassId.debugNodeFactory */] = null;
|
|
1968
1974
|
this.removeCommentNode(node, this.portalCommentsNodes);
|
|
1969
1975
|
}
|
|
1970
1976
|
// nullify parent
|
|
@@ -1995,7 +2001,7 @@ class NgtRenderer {
|
|
|
1995
2001
|
}
|
|
1996
2002
|
}
|
|
1997
2003
|
processPortalContainer(portal) {
|
|
1998
|
-
const injector = portal.__ngt_renderer__[
|
|
2004
|
+
const injector = portal.__ngt_renderer__[7 /* NgtRendererClassId.debugNodeFactory */]?.()?.injector;
|
|
1999
2005
|
if (!injector)
|
|
2000
2006
|
return;
|
|
2001
2007
|
const portalStore = injector.get(NGT_STORE, null);
|
|
@@ -2033,7 +2039,7 @@ class NgtRenderer {
|
|
|
2033
2039
|
i--;
|
|
2034
2040
|
continue;
|
|
2035
2041
|
}
|
|
2036
|
-
const injector = comment.__ngt_renderer__[
|
|
2042
|
+
const injector = comment.__ngt_renderer__[7 /* NgtRendererClassId.debugNodeFactory */]?.()?.injector;
|
|
2037
2043
|
if (!injector) {
|
|
2038
2044
|
i--;
|
|
2039
2045
|
continue;
|
|
@@ -2050,37 +2056,6 @@ class NgtRenderer {
|
|
|
2050
2056
|
});
|
|
2051
2057
|
return directive;
|
|
2052
2058
|
}
|
|
2053
|
-
tryGetPortalStore() {
|
|
2054
|
-
let store;
|
|
2055
|
-
const destroyed = [];
|
|
2056
|
-
// we only care about the portal states because NgtStore only differs per Portal
|
|
2057
|
-
let i = this.portalCommentsNodes.length - 1;
|
|
2058
|
-
while (i >= 0) {
|
|
2059
|
-
// loop through the portal state backwards to find the closest NgtStore
|
|
2060
|
-
const portal = this.portalCommentsNodes[i];
|
|
2061
|
-
if (portal.__ngt_renderer__[3 /* NgtRendererClassId.destroyed */]) {
|
|
2062
|
-
destroyed.push(i);
|
|
2063
|
-
i--;
|
|
2064
|
-
continue;
|
|
2065
|
-
}
|
|
2066
|
-
const injector = portal.__ngt_renderer__[6 /* NgtRendererClassId.injectorFactory */]();
|
|
2067
|
-
if (!injector) {
|
|
2068
|
-
i--;
|
|
2069
|
-
continue;
|
|
2070
|
-
}
|
|
2071
|
-
const instance = injector.get(NGT_STORE, null);
|
|
2072
|
-
// only the instance with previousRoot should pass
|
|
2073
|
-
if (instance && instance.get('previousRoot')) {
|
|
2074
|
-
store = instance;
|
|
2075
|
-
break;
|
|
2076
|
-
}
|
|
2077
|
-
i--;
|
|
2078
|
-
}
|
|
2079
|
-
destroyed.forEach((index) => {
|
|
2080
|
-
this.portalCommentsNodes.splice(index, 1);
|
|
2081
|
-
});
|
|
2082
|
-
return store || this.rootStore;
|
|
2083
|
-
}
|
|
2084
2059
|
get data() {
|
|
2085
2060
|
return this.delegate.data;
|
|
2086
2061
|
}
|
|
@@ -2508,14 +2483,12 @@ class NgtCanvas {
|
|
|
2508
2483
|
if (!this.store.get('events', 'connected')) {
|
|
2509
2484
|
this.store.get('events').connect?.(untracked(this.glCanvas).nativeElement);
|
|
2510
2485
|
}
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
injector: this.injector,
|
|
2516
|
-
});
|
|
2517
|
-
this.glRef.changeDetectorRef.detectChanges();
|
|
2486
|
+
this.glEnvironmentInjector = createEnvironmentInjector([provideNgtRenderer(this.store)], this.environmentInjector);
|
|
2487
|
+
this.glRef = untracked(this.glCanvasViewContainerRef).createComponent(untracked(this.sceneGraph), {
|
|
2488
|
+
environmentInjector: this.glEnvironmentInjector,
|
|
2489
|
+
injector: this.injector,
|
|
2518
2490
|
});
|
|
2491
|
+
this.glRef.changeDetectorRef.detectChanges();
|
|
2519
2492
|
}
|
|
2520
2493
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: NgtCanvas, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2521
2494
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "18.2.0", type: NgtCanvas, isStandalone: true, selector: "ngt-canvas", inputs: { sceneGraph: { classPropertyName: "sceneGraph", publicName: "sceneGraph", isSignal: true, isRequired: true, transformFunction: null }, gl: { classPropertyName: "gl", publicName: "gl", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, shadows: { classPropertyName: "shadows", publicName: "shadows", isSignal: true, isRequired: false, transformFunction: null }, legacy: { classPropertyName: "legacy", publicName: "legacy", isSignal: true, isRequired: false, transformFunction: null }, linear: { classPropertyName: "linear", publicName: "linear", isSignal: true, isRequired: false, transformFunction: null }, flat: { classPropertyName: "flat", publicName: "flat", isSignal: true, isRequired: false, transformFunction: null }, orthographic: { classPropertyName: "orthographic", publicName: "orthographic", isSignal: true, isRequired: false, transformFunction: null }, frameloop: { classPropertyName: "frameloop", publicName: "frameloop", isSignal: true, isRequired: false, transformFunction: null }, performance: { classPropertyName: "performance", publicName: "performance", isSignal: true, isRequired: false, transformFunction: null }, dpr: { classPropertyName: "dpr", publicName: "dpr", isSignal: true, isRequired: false, transformFunction: null }, raycaster: { classPropertyName: "raycaster", publicName: "raycaster", isSignal: true, isRequired: false, transformFunction: null }, scene: { classPropertyName: "scene", publicName: "scene", isSignal: true, isRequired: false, transformFunction: null }, camera: { classPropertyName: "camera", publicName: "camera", isSignal: true, isRequired: false, transformFunction: null }, events: { classPropertyName: "events", publicName: "events", isSignal: true, isRequired: false, transformFunction: null }, eventSource: { classPropertyName: "eventSource", publicName: "eventSource", isSignal: true, isRequired: false, transformFunction: null }, eventPrefix: { classPropertyName: "eventPrefix", publicName: "eventPrefix", isSignal: true, isRequired: false, transformFunction: null }, lookAt: { classPropertyName: "lookAt", publicName: "lookAt", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { created: "created", pointerMissed: "pointerMissed" }, host: { properties: { "style.pointerEvents": "hbPointerEvents()" }, styleAttribute: "display: block;position: relative;width: 100%;height: 100%;overflow: hidden;" }, providers: [
|