angular-three 1.6.10 → 1.7.0
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 +17 -2
- package/esm2020/lib/loader.mjs +5 -1
- package/esm2020/lib/renderer/renderer.mjs +71 -83
- package/esm2020/lib/renderer/state.mjs +52 -47
- package/fesm2015/angular-three.mjs +143 -132
- package/fesm2015/angular-three.mjs.map +1 -1
- package/fesm2020/angular-three.mjs +141 -130
- package/fesm2020/angular-three.mjs.map +1 -1
- package/lib/canvas.d.ts +7 -4
- package/lib/renderer/renderer.d.ts +6 -3
- package/package.json +1 -1
- package/plugin/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { ElementRef, Injectable,
|
|
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
4
|
import { isObservable, of, map, from, tap, retry, catchError, share, ReplaySubject, switchMap, forkJoin, take, BehaviorSubject, startWith, combineLatest, distinctUntilChanged, filter, takeUntil, merge } from 'rxjs';
|
|
5
5
|
import * as THREE from 'three';
|
|
@@ -53,6 +53,7 @@ function makeObjectGraph(object) {
|
|
|
53
53
|
const cached = new Map();
|
|
54
54
|
function injectLoader(loaderConstructorFactory, input, extensions, onProgress) {
|
|
55
55
|
const urls$ = isObservable(input) ? input : of(input);
|
|
56
|
+
const cdr = inject(ChangeDetectorRef);
|
|
56
57
|
return urls$.pipe(map((inputs) => {
|
|
57
58
|
const loaderConstructor = loaderConstructorFactory(inputs);
|
|
58
59
|
const loader = new loaderConstructor();
|
|
@@ -85,6 +86,8 @@ function injectLoader(loaderConstructorFactory, input, extensions, onProgress) {
|
|
|
85
86
|
result[key] = results[keys.indexOf(key)];
|
|
86
87
|
return result;
|
|
87
88
|
}, {});
|
|
89
|
+
}), tap(() => {
|
|
90
|
+
requestAnimationFrame(() => cdr.detectChanges());
|
|
88
91
|
}));
|
|
89
92
|
}));
|
|
90
93
|
}
|
|
@@ -1553,10 +1556,15 @@ class NgtRendererStore {
|
|
|
1553
1556
|
if (!rendererNode['ownerDocument']) {
|
|
1554
1557
|
rendererNode['ownerDocument'] = this.root.document;
|
|
1555
1558
|
}
|
|
1556
|
-
|
|
1559
|
+
// assign injectorFactory on non-three type since
|
|
1560
|
+
// rendererNode is an instance of DOM Node
|
|
1561
|
+
if (state[0 /* NgtRendererClassId.type */] !== 'three') {
|
|
1557
1562
|
state[13 /* NgtRendererClassId.injectorFactory */] = () => getDebugNode(rendererNode).injector;
|
|
1563
|
+
}
|
|
1564
|
+
if (state[0 /* NgtRendererClassId.type */] === 'comment') {
|
|
1558
1565
|
// we attach an arrow function to the Comment node
|
|
1559
1566
|
// In our directives, we can call this function to then start tracking the RendererNode
|
|
1567
|
+
// this is done to limit the amount of Nodes we need to process for getCreationState
|
|
1560
1568
|
rendererNode['__ngt_renderer_add_comment__'] = (portalNode) => {
|
|
1561
1569
|
if (portalNode && portalNode.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'portal') {
|
|
1562
1570
|
this.portals.push(portalNode);
|
|
@@ -1567,10 +1575,6 @@ class NgtRendererStore {
|
|
|
1567
1575
|
};
|
|
1568
1576
|
return rendererNode;
|
|
1569
1577
|
}
|
|
1570
|
-
if (state[0 /* NgtRendererClassId.type */] === 'portal') {
|
|
1571
|
-
state[13 /* NgtRendererClassId.injectorFactory */] = () => getDebugNode(rendererNode).injector;
|
|
1572
|
-
return rendererNode;
|
|
1573
|
-
}
|
|
1574
1578
|
if (state[0 /* NgtRendererClassId.type */] === 'compound') {
|
|
1575
1579
|
state[7 /* NgtRendererClassId.queueOps */] = new Set();
|
|
1576
1580
|
state[8 /* NgtRendererClassId.attributes */] = {};
|
|
@@ -1596,17 +1600,18 @@ class NgtRendererStore {
|
|
|
1596
1600
|
}
|
|
1597
1601
|
}
|
|
1598
1602
|
setCompound(compound, instance) {
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
const
|
|
1603
|
+
const rS = compound.__ngt_renderer__;
|
|
1604
|
+
rS[6 /* NgtRendererClassId.compounded */] = instance;
|
|
1605
|
+
const attributes = Object.keys(rS[8 /* NgtRendererClassId.attributes */]);
|
|
1606
|
+
const properties = Object.keys(rS[9 /* NgtRendererClassId.properties */]);
|
|
1602
1607
|
if (attributes.length) {
|
|
1603
1608
|
for (const key of attributes) {
|
|
1604
|
-
this.applyAttribute(instance, key,
|
|
1609
|
+
this.applyAttribute(instance, key, rS[8 /* NgtRendererClassId.attributes */][key]);
|
|
1605
1610
|
}
|
|
1606
1611
|
}
|
|
1607
1612
|
if (properties.length) {
|
|
1608
1613
|
for (const key of properties) {
|
|
1609
|
-
this.applyProperty(instance, key,
|
|
1614
|
+
this.applyProperty(instance, key, rS[9 /* NgtRendererClassId.properties */][key]);
|
|
1610
1615
|
}
|
|
1611
1616
|
}
|
|
1612
1617
|
this.executeOperation(compound);
|
|
@@ -1616,11 +1621,12 @@ class NgtRendererStore {
|
|
|
1616
1621
|
}
|
|
1617
1622
|
executeOperation(node, type = 'op') {
|
|
1618
1623
|
var _a;
|
|
1619
|
-
|
|
1620
|
-
|
|
1624
|
+
const rS = node.__ngt_renderer__;
|
|
1625
|
+
if ((_a = rS[7 /* NgtRendererClassId.queueOps */]) === null || _a === void 0 ? void 0 : _a.size) {
|
|
1626
|
+
rS[7 /* NgtRendererClassId.queueOps */].forEach((op) => {
|
|
1621
1627
|
if (op[0 /* NgtQueueOpClassId.type */] === type) {
|
|
1622
1628
|
op[1 /* NgtQueueOpClassId.op */]();
|
|
1623
|
-
|
|
1629
|
+
rS[7 /* NgtRendererClassId.queueOps */].delete(op);
|
|
1624
1630
|
}
|
|
1625
1631
|
});
|
|
1626
1632
|
}
|
|
@@ -1639,7 +1645,8 @@ class NgtRendererStore {
|
|
|
1639
1645
|
portal.__ngt_renderer__[12 /* NgtRendererClassId.portalContainer */] = this.createNode('three', portalContainer);
|
|
1640
1646
|
}
|
|
1641
1647
|
applyAttribute(node, name, value) {
|
|
1642
|
-
|
|
1648
|
+
const rS = node.__ngt_renderer__;
|
|
1649
|
+
if (rS[3 /* NgtRendererClassId.destroyed */])
|
|
1643
1650
|
return;
|
|
1644
1651
|
if (name === SPECIAL_PROPERTIES.RENDER_PRIORITY) {
|
|
1645
1652
|
// priority needs to be set as an attribute string so that they can be set as early as possible
|
|
@@ -1653,7 +1660,7 @@ class NgtRendererStore {
|
|
|
1653
1660
|
}
|
|
1654
1661
|
if (name === SPECIAL_PROPERTIES.COMPOUND) {
|
|
1655
1662
|
// we set the compound property on instance node now so we know that this instance is being compounded
|
|
1656
|
-
|
|
1663
|
+
rS[4 /* NgtRendererClassId.compound */] = [value === '' || value === 'first', {}];
|
|
1657
1664
|
return;
|
|
1658
1665
|
}
|
|
1659
1666
|
if (name === SPECIAL_PROPERTIES.ATTACH) {
|
|
@@ -1672,24 +1679,25 @@ class NgtRendererStore {
|
|
|
1672
1679
|
else if (!isNaN(Number(maybeCoerced))) {
|
|
1673
1680
|
maybeCoerced = Number(maybeCoerced);
|
|
1674
1681
|
}
|
|
1675
|
-
|
|
1682
|
+
rS[10 /* NgtRendererClassId.rawValue */] = maybeCoerced;
|
|
1676
1683
|
return;
|
|
1677
1684
|
}
|
|
1678
1685
|
applyProps(node, { [name]: value });
|
|
1679
1686
|
}
|
|
1680
1687
|
applyProperty(node, name, value) {
|
|
1681
|
-
|
|
1688
|
+
const rS = node.__ngt_renderer__;
|
|
1689
|
+
if (rS[3 /* NgtRendererClassId.destroyed */])
|
|
1682
1690
|
return;
|
|
1683
1691
|
// [ref]
|
|
1684
1692
|
if (name === SPECIAL_PROPERTIES.REF && is.ref(value)) {
|
|
1685
|
-
|
|
1693
|
+
rS[11 /* NgtRendererClassId.ref */] = value;
|
|
1686
1694
|
value.nativeElement = node;
|
|
1687
1695
|
return;
|
|
1688
1696
|
}
|
|
1689
|
-
const parent = getLocalState(node).parent ||
|
|
1697
|
+
const parent = getLocalState(node).parent || rS[1 /* NgtRendererClassId.parent */];
|
|
1690
1698
|
// [rawValue]
|
|
1691
1699
|
if (getLocalState(node).isRaw && name === SPECIAL_PROPERTIES.VALUE) {
|
|
1692
|
-
|
|
1700
|
+
rS[10 /* NgtRendererClassId.rawValue */] = value;
|
|
1693
1701
|
if (parent)
|
|
1694
1702
|
attachThreeChild(parent, node);
|
|
1695
1703
|
return;
|
|
@@ -1701,7 +1709,7 @@ class NgtRendererStore {
|
|
|
1701
1709
|
attachThreeChild(parent, node);
|
|
1702
1710
|
return;
|
|
1703
1711
|
}
|
|
1704
|
-
const compound =
|
|
1712
|
+
const compound = rS[4 /* NgtRendererClassId.compound */];
|
|
1705
1713
|
if ((compound === null || compound === void 0 ? void 0 : compound[1 /* NgtCompoundClassId.props */]) &&
|
|
1706
1714
|
name in compound[1 /* NgtCompoundClassId.props */] &&
|
|
1707
1715
|
!compound[0 /* NgtCompoundClassId.applyFirst */]) {
|
|
@@ -1713,9 +1721,9 @@ class NgtRendererStore {
|
|
|
1713
1721
|
return this.root.compoundPrefixes.some((prefix) => name.startsWith(prefix));
|
|
1714
1722
|
}
|
|
1715
1723
|
isDOM(node) {
|
|
1716
|
-
const
|
|
1717
|
-
return (!
|
|
1718
|
-
(
|
|
1724
|
+
const rS = node['__ngt_renderer__'];
|
|
1725
|
+
return (!rS ||
|
|
1726
|
+
(rS[0 /* NgtRendererClassId.type */] !== 'compound' &&
|
|
1719
1727
|
(node instanceof Element || node instanceof Document || node instanceof Window)));
|
|
1720
1728
|
}
|
|
1721
1729
|
get rootScene() {
|
|
@@ -1770,12 +1778,12 @@ class NgtRendererStore {
|
|
|
1770
1778
|
return { injectedArgs, store };
|
|
1771
1779
|
}
|
|
1772
1780
|
destroy(node, parent) {
|
|
1773
|
-
const
|
|
1774
|
-
if (
|
|
1781
|
+
const rS = node.__ngt_renderer__;
|
|
1782
|
+
if (rS[3 /* NgtRendererClassId.destroyed */])
|
|
1775
1783
|
return;
|
|
1776
|
-
if (
|
|
1777
|
-
|
|
1778
|
-
|
|
1784
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'three') {
|
|
1785
|
+
rS[4 /* NgtRendererClassId.compound */] = undefined;
|
|
1786
|
+
rS[5 /* NgtRendererClassId.compoundParent */] = undefined;
|
|
1779
1787
|
const localState = getLocalState(node);
|
|
1780
1788
|
if (localState.objects) {
|
|
1781
1789
|
localState.objects.value.forEach((obj) => this.destroy(obj, parent));
|
|
@@ -1801,44 +1809,44 @@ class NgtRendererStore {
|
|
|
1801
1809
|
delete node['__ngt__'];
|
|
1802
1810
|
}
|
|
1803
1811
|
}
|
|
1804
|
-
if (
|
|
1805
|
-
|
|
1812
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'comment') {
|
|
1813
|
+
rS[13 /* NgtRendererClassId.injectorFactory */] = null;
|
|
1806
1814
|
delete node['__ngt_renderer_add_comment__'];
|
|
1807
1815
|
const index = this.comments.findIndex((comment) => comment === node);
|
|
1808
1816
|
if (index > -1) {
|
|
1809
1817
|
this.comments.splice(index, 1);
|
|
1810
1818
|
}
|
|
1811
1819
|
}
|
|
1812
|
-
if (
|
|
1813
|
-
|
|
1820
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'portal') {
|
|
1821
|
+
rS[13 /* NgtRendererClassId.injectorFactory */] = null;
|
|
1814
1822
|
const index = this.portals.findIndex((portal) => portal === node);
|
|
1815
1823
|
if (index > -1) {
|
|
1816
1824
|
this.portals.splice(index, 1);
|
|
1817
1825
|
}
|
|
1818
1826
|
}
|
|
1819
|
-
if (
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1827
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'compound') {
|
|
1828
|
+
rS[6 /* NgtRendererClassId.compounded */] = undefined;
|
|
1829
|
+
rS[8 /* NgtRendererClassId.attributes */] = null;
|
|
1830
|
+
rS[9 /* NgtRendererClassId.properties */] = null;
|
|
1823
1831
|
this.executeOperation(node, 'cleanUp');
|
|
1824
|
-
|
|
1825
|
-
|
|
1832
|
+
rS[7 /* NgtRendererClassId.queueOps */].clear();
|
|
1833
|
+
rS[7 /* NgtRendererClassId.queueOps */] = null;
|
|
1826
1834
|
}
|
|
1827
|
-
if (
|
|
1835
|
+
if (rS[11 /* NgtRendererClassId.ref */]) {
|
|
1828
1836
|
// nullify ref
|
|
1829
|
-
|
|
1830
|
-
|
|
1837
|
+
rS[11 /* NgtRendererClassId.ref */].nativeElement = null;
|
|
1838
|
+
rS[11 /* NgtRendererClassId.ref */] = undefined;
|
|
1831
1839
|
}
|
|
1832
1840
|
// nullify parent
|
|
1833
|
-
|
|
1834
|
-
for (const renderChild of
|
|
1841
|
+
rS[1 /* NgtRendererClassId.parent */] = null;
|
|
1842
|
+
for (const renderChild of rS[2 /* NgtRendererClassId.children */] || []) {
|
|
1835
1843
|
if (renderChild.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three' && parent) {
|
|
1836
1844
|
removeThreeChild(parent, renderChild, true);
|
|
1837
1845
|
}
|
|
1838
1846
|
this.destroy(renderChild, parent);
|
|
1839
1847
|
}
|
|
1840
|
-
|
|
1841
|
-
|
|
1848
|
+
rS[2 /* NgtRendererClassId.children */] = [];
|
|
1849
|
+
rS[3 /* NgtRendererClassId.destroyed */] = true;
|
|
1842
1850
|
if (parent) {
|
|
1843
1851
|
this.removeChild(parent, node);
|
|
1844
1852
|
}
|
|
@@ -1920,7 +1928,7 @@ class NgtRendererFactory {
|
|
|
1920
1928
|
compoundPrefixes: this.compoundPrefixes,
|
|
1921
1929
|
document: this.document,
|
|
1922
1930
|
});
|
|
1923
|
-
renderer = new NgtRenderer(delegateRenderer, store, this.catalogue
|
|
1931
|
+
renderer = new NgtRenderer(delegateRenderer, store, this.catalogue);
|
|
1924
1932
|
this.rendererMap.set(type.id, renderer);
|
|
1925
1933
|
}
|
|
1926
1934
|
if (!renderer) {
|
|
@@ -1931,7 +1939,7 @@ class NgtRendererFactory {
|
|
|
1931
1939
|
compoundPrefixes: this.compoundPrefixes,
|
|
1932
1940
|
document: this.document,
|
|
1933
1941
|
});
|
|
1934
|
-
renderer = new NgtRenderer(delegateRenderer, store, this.catalogue);
|
|
1942
|
+
renderer = new NgtRenderer(delegateRenderer, store, this.catalogue, false);
|
|
1935
1943
|
this.rendererMap.set(type.id, renderer);
|
|
1936
1944
|
}
|
|
1937
1945
|
return renderer;
|
|
@@ -1942,8 +1950,11 @@ NgtRendererFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", v
|
|
|
1942
1950
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtRendererFactory, decorators: [{
|
|
1943
1951
|
type: Injectable
|
|
1944
1952
|
}] });
|
|
1953
|
+
/**
|
|
1954
|
+
* Anything abbreviated with rS/RS stands for RendererState
|
|
1955
|
+
*/
|
|
1945
1956
|
class NgtRenderer {
|
|
1946
|
-
constructor(delegate, store, catalogue, root =
|
|
1957
|
+
constructor(delegate, store, catalogue, root = true) {
|
|
1947
1958
|
this.delegate = delegate;
|
|
1948
1959
|
this.store = store;
|
|
1949
1960
|
this.catalogue = catalogue;
|
|
@@ -1972,9 +1983,7 @@ class NgtRenderer {
|
|
|
1972
1983
|
}
|
|
1973
1984
|
// handle compound
|
|
1974
1985
|
if (this.store.isCompound(name)) {
|
|
1975
|
-
|
|
1976
|
-
compound.__ngt_renderer__[13 /* NgtRendererClassId.injectorFactory */] = () => getDebugNode(element).injector;
|
|
1977
|
-
return compound;
|
|
1986
|
+
return this.store.createNode('compound', element);
|
|
1978
1987
|
}
|
|
1979
1988
|
// handle portal
|
|
1980
1989
|
if (name === SPECIAL_DOM_TAG.NGT_PORTAL) {
|
|
@@ -2015,50 +2024,48 @@ class NgtRenderer {
|
|
|
2015
2024
|
}
|
|
2016
2025
|
return node;
|
|
2017
2026
|
}
|
|
2018
|
-
|
|
2019
|
-
domNode.__ngt_renderer__[13 /* NgtRendererClassId.injectorFactory */] = () => getDebugNode(element).injector;
|
|
2020
|
-
return domNode;
|
|
2027
|
+
return this.store.createNode('dom', element);
|
|
2021
2028
|
}
|
|
2022
2029
|
createComment(value) {
|
|
2023
|
-
|
|
2024
|
-
return this.store.createNode('comment', comment);
|
|
2030
|
+
return this.store.createNode('comment', this.delegate.createComment(value));
|
|
2025
2031
|
}
|
|
2026
2032
|
appendChild(parent, newChild) {
|
|
2027
2033
|
// TODO: just ignore text node for now
|
|
2028
2034
|
if (newChild instanceof Text)
|
|
2029
2035
|
return;
|
|
2030
|
-
|
|
2036
|
+
const cRS = newChild.__ngt_renderer__;
|
|
2037
|
+
const pRS = parent.__ngt_renderer__;
|
|
2038
|
+
if (cRS[0 /* NgtRendererClassId.type */] === 'comment') {
|
|
2031
2039
|
this.store.setParent(newChild, parent);
|
|
2032
2040
|
return;
|
|
2033
2041
|
}
|
|
2034
2042
|
this.store.setParent(newChild, parent);
|
|
2035
2043
|
this.store.addChild(parent, newChild);
|
|
2036
2044
|
// if new child is a portal
|
|
2037
|
-
if (
|
|
2045
|
+
if (cRS[0 /* NgtRendererClassId.type */] === 'portal') {
|
|
2038
2046
|
this.store.processPortalContainer(newChild);
|
|
2039
|
-
if (
|
|
2040
|
-
this.appendChild(parent,
|
|
2047
|
+
if (cRS[12 /* NgtRendererClassId.portalContainer */]) {
|
|
2048
|
+
this.appendChild(parent, cRS[12 /* NgtRendererClassId.portalContainer */]);
|
|
2041
2049
|
}
|
|
2042
2050
|
return;
|
|
2043
2051
|
}
|
|
2044
2052
|
// if parent is a portal
|
|
2045
|
-
if (
|
|
2053
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'portal') {
|
|
2046
2054
|
this.store.processPortalContainer(parent);
|
|
2047
|
-
if (
|
|
2048
|
-
this.appendChild(
|
|
2055
|
+
if (pRS[12 /* NgtRendererClassId.portalContainer */]) {
|
|
2056
|
+
this.appendChild(pRS[12 /* NgtRendererClassId.portalContainer */], newChild);
|
|
2049
2057
|
}
|
|
2050
2058
|
return;
|
|
2051
2059
|
}
|
|
2052
2060
|
// if both are three instances, straightforward case
|
|
2053
|
-
if (
|
|
2054
|
-
newChild.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2061
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'three' && cRS[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2055
2062
|
// if child already attached to a parent, skip
|
|
2056
2063
|
if (getLocalState(newChild).parent)
|
|
2057
2064
|
return;
|
|
2058
2065
|
// attach THREE child
|
|
2059
2066
|
attachThreeChild(parent, newChild);
|
|
2060
2067
|
// here, we handle the special case of if the parent has a compoundParent, which means this child is part of a compound parent template
|
|
2061
|
-
if (!
|
|
2068
|
+
if (!cRS[4 /* NgtRendererClassId.compound */])
|
|
2062
2069
|
return;
|
|
2063
2070
|
const closestGrandparentWithCompound = this.store.getClosestParentWithCompound(parent);
|
|
2064
2071
|
if (!closestGrandparentWithCompound)
|
|
@@ -2067,53 +2074,43 @@ class NgtRenderer {
|
|
|
2067
2074
|
return;
|
|
2068
2075
|
}
|
|
2069
2076
|
// if only the parent is the THREE instance
|
|
2070
|
-
if (
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
this.appendChild(parent, renderChild);
|
|
2074
|
-
}
|
|
2077
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2078
|
+
for (const renderChild of cRS[2 /* NgtRendererClassId.children */]) {
|
|
2079
|
+
this.appendChild(parent, renderChild);
|
|
2075
2080
|
}
|
|
2076
2081
|
}
|
|
2077
2082
|
// if parent is a compound
|
|
2078
|
-
if (
|
|
2083
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'compound') {
|
|
2079
2084
|
// if compound doesn't have a THREE instance set yet
|
|
2080
|
-
if (!
|
|
2081
|
-
newChild.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2085
|
+
if (!pRS[6 /* NgtRendererClassId.compounded */] && cRS[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2082
2086
|
// if child is indeed an ngtCompound
|
|
2083
|
-
if (
|
|
2087
|
+
if (cRS[4 /* NgtRendererClassId.compound */])
|
|
2084
2088
|
this.store.setCompound(parent, newChild);
|
|
2085
|
-
|
|
2086
|
-
else
|
|
2087
|
-
|
|
2088
|
-
if (!newChild.__ngt_renderer__[5 /* NgtRendererClassId.compoundParent */]) {
|
|
2089
|
-
newChild.__ngt_renderer__[5 /* NgtRendererClassId.compoundParent */] = parent;
|
|
2090
|
-
}
|
|
2091
|
-
}
|
|
2089
|
+
// if not, we track the parent (that is supposedly the compound component) on this three instance
|
|
2090
|
+
else if (!cRS[5 /* NgtRendererClassId.compoundParent */])
|
|
2091
|
+
cRS[5 /* NgtRendererClassId.compoundParent */] = parent;
|
|
2092
2092
|
}
|
|
2093
2093
|
// reset the compound if it's changed
|
|
2094
|
-
if (
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2094
|
+
if (pRS[6 /* NgtRendererClassId.compounded */] &&
|
|
2095
|
+
cRS[0 /* NgtRendererClassId.type */] === 'three' &&
|
|
2096
|
+
cRS[4 /* NgtRendererClassId.compound */] &&
|
|
2097
|
+
pRS[6 /* NgtRendererClassId.compounded */] !== newChild) {
|
|
2098
2098
|
this.store.setCompound(parent, newChild);
|
|
2099
2099
|
}
|
|
2100
2100
|
}
|
|
2101
2101
|
const shouldFindGrandparentInstance =
|
|
2102
2102
|
// if child is three but haven't been attached to a parent yet
|
|
2103
|
-
(
|
|
2103
|
+
(cRS[0 /* NgtRendererClassId.type */] === 'three' && !getLocalState(newChild).parent) ||
|
|
2104
2104
|
// or both parent and child are DOM elements
|
|
2105
|
-
((
|
|
2106
|
-
(
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
(newChild.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'compound' &&
|
|
2110
|
-
!newChild.__ngt_renderer__[6 /* NgtRendererClassId.compounded */])));
|
|
2105
|
+
((pRS[0 /* NgtRendererClassId.type */] === 'dom' ||
|
|
2106
|
+
(pRS[0 /* NgtRendererClassId.type */] === 'compound' && !pRS[6 /* NgtRendererClassId.compounded */])) &&
|
|
2107
|
+
(cRS[0 /* NgtRendererClassId.type */] === 'dom' ||
|
|
2108
|
+
(cRS[0 /* NgtRendererClassId.type */] === 'compound' && !cRS[6 /* NgtRendererClassId.compounded */])));
|
|
2111
2109
|
if (shouldFindGrandparentInstance) {
|
|
2112
2110
|
// we'll try to get the grandparent instance here so that we can run appendChild with both instances
|
|
2113
2111
|
const closestGrandparentInstance = this.store.getClosestParentWithInstance(parent);
|
|
2114
|
-
if (closestGrandparentInstance)
|
|
2112
|
+
if (closestGrandparentInstance)
|
|
2115
2113
|
this.appendChild(closestGrandparentInstance, newChild);
|
|
2116
|
-
}
|
|
2117
2114
|
}
|
|
2118
2115
|
}
|
|
2119
2116
|
insertBefore(parent, newChild
|
|
@@ -2126,71 +2123,71 @@ class NgtRenderer {
|
|
|
2126
2123
|
this.appendChild(parent, newChild);
|
|
2127
2124
|
}
|
|
2128
2125
|
removeChild(parent, oldChild, isHostElement) {
|
|
2129
|
-
|
|
2130
|
-
|
|
2126
|
+
const pRS = parent.__ngt_renderer__;
|
|
2127
|
+
const cRS = oldChild.__ngt_renderer__;
|
|
2128
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'three' && cRS[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2131
2129
|
removeThreeChild(parent, oldChild, true);
|
|
2132
2130
|
this.store.destroy(oldChild, parent);
|
|
2133
2131
|
return;
|
|
2134
2132
|
}
|
|
2135
|
-
if (
|
|
2136
|
-
|
|
2137
|
-
this.removeChild(parent.__ngt_renderer__[1 /* NgtRendererClassId.parent */], oldChild, isHostElement);
|
|
2133
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'compound' && pRS[1 /* NgtRendererClassId.parent */]) {
|
|
2134
|
+
this.removeChild(pRS[1 /* NgtRendererClassId.parent */], oldChild, isHostElement);
|
|
2138
2135
|
return;
|
|
2139
2136
|
}
|
|
2140
|
-
if (
|
|
2137
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2141
2138
|
this.store.destroy(oldChild, parent);
|
|
2142
2139
|
return;
|
|
2143
2140
|
}
|
|
2144
2141
|
const closestGrandparentInstance = this.store.getClosestParentWithInstance(parent);
|
|
2145
|
-
if (closestGrandparentInstance)
|
|
2142
|
+
if (closestGrandparentInstance)
|
|
2146
2143
|
this.removeChild(closestGrandparentInstance, oldChild, isHostElement);
|
|
2147
|
-
}
|
|
2148
2144
|
this.store.destroy(oldChild, closestGrandparentInstance);
|
|
2149
2145
|
}
|
|
2150
2146
|
parentNode(node) {
|
|
2151
|
-
|
|
2152
|
-
if (
|
|
2153
|
-
return
|
|
2147
|
+
const rS = node.__ngt_renderer__;
|
|
2148
|
+
if (rS === null || rS === void 0 ? void 0 : rS[1 /* NgtRendererClassId.parent */])
|
|
2149
|
+
return rS[1 /* NgtRendererClassId.parent */];
|
|
2154
2150
|
return this.delegate.parentNode(node);
|
|
2155
2151
|
}
|
|
2156
2152
|
setAttribute(el, name, value, namespace) {
|
|
2157
|
-
|
|
2153
|
+
const rS = el.__ngt_renderer__;
|
|
2154
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'compound') {
|
|
2158
2155
|
// we don't have the compound instance yet
|
|
2159
|
-
|
|
2160
|
-
if (!
|
|
2156
|
+
rS[8 /* NgtRendererClassId.attributes */][name] = value;
|
|
2157
|
+
if (!rS[6 /* NgtRendererClassId.compounded */]) {
|
|
2161
2158
|
this.store.queueOperation(el, ['op', () => this.setAttribute(el, name, value, namespace)]);
|
|
2162
2159
|
return;
|
|
2163
2160
|
}
|
|
2164
|
-
this.setAttribute(
|
|
2161
|
+
this.setAttribute(rS[6 /* NgtRendererClassId.compounded */], name, value, namespace);
|
|
2165
2162
|
return;
|
|
2166
2163
|
}
|
|
2167
|
-
if (
|
|
2164
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'three')
|
|
2168
2165
|
this.store.applyAttribute(el, name, value);
|
|
2169
|
-
}
|
|
2170
2166
|
}
|
|
2171
2167
|
setProperty(el, name, value) {
|
|
2172
|
-
|
|
2168
|
+
const rS = el.__ngt_renderer__;
|
|
2169
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'compound') {
|
|
2173
2170
|
// we don't have the compound instance yet
|
|
2174
|
-
|
|
2175
|
-
if (!
|
|
2171
|
+
rS[9 /* NgtRendererClassId.properties */][name] = value;
|
|
2172
|
+
if (!rS[6 /* NgtRendererClassId.compounded */]) {
|
|
2176
2173
|
this.store.queueOperation(el, ['op', () => this.setProperty(el, name, value)]);
|
|
2177
2174
|
return;
|
|
2178
2175
|
}
|
|
2179
|
-
if (
|
|
2180
|
-
Object.assign(
|
|
2181
|
-
props: Object.assign(Object.assign({},
|
|
2176
|
+
if (rS[6 /* NgtRendererClassId.compounded */].__ngt_renderer__[4 /* NgtRendererClassId.compound */]) {
|
|
2177
|
+
Object.assign(rS[6 /* NgtRendererClassId.compounded */].__ngt_renderer__[4 /* NgtRendererClassId.compound */], {
|
|
2178
|
+
props: Object.assign(Object.assign({}, rS[6 /* NgtRendererClassId.compounded */].__ngt_renderer__[4 /* NgtRendererClassId.compound */]), { [name]: value }),
|
|
2182
2179
|
});
|
|
2183
2180
|
}
|
|
2184
|
-
this.setProperty(
|
|
2181
|
+
this.setProperty(rS[6 /* NgtRendererClassId.compounded */], name, value);
|
|
2185
2182
|
return;
|
|
2186
2183
|
}
|
|
2187
|
-
if (
|
|
2184
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'three')
|
|
2188
2185
|
this.store.applyProperty(el, name, value);
|
|
2189
|
-
}
|
|
2190
2186
|
}
|
|
2191
2187
|
listen(target, eventName, callback) {
|
|
2192
|
-
var _a
|
|
2193
|
-
const
|
|
2188
|
+
var _a;
|
|
2189
|
+
const rS = target.__ngt_renderer__;
|
|
2190
|
+
const targetCdr = (_a = rS === null || rS === void 0 ? void 0 : rS[13 /* NgtRendererClassId.injectorFactory */]) === null || _a === void 0 ? void 0 : _a.call(rS).get(ChangeDetectorRef, null);
|
|
2194
2191
|
// if target is DOM node, then we pass that to delegate Renderer
|
|
2195
2192
|
const callbackWithCdr = (event) => {
|
|
2196
2193
|
const value = callback(event);
|
|
@@ -2214,15 +2211,13 @@ class NgtRenderer {
|
|
|
2214
2211
|
: target['ownerDocument'];
|
|
2215
2212
|
return this.delegate.listen(eventTarget, event, callbackWithCdr);
|
|
2216
2213
|
}
|
|
2217
|
-
if (
|
|
2218
|
-
(
|
|
2219
|
-
|
|
2220
|
-
const instance = target.__ngt_renderer__[6 /* NgtRendererClassId.compounded */] || target;
|
|
2214
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'three' ||
|
|
2215
|
+
(rS[0 /* NgtRendererClassId.type */] === 'compound' && rS[6 /* NgtRendererClassId.compounded */])) {
|
|
2216
|
+
const instance = rS[6 /* NgtRendererClassId.compounded */] || target;
|
|
2221
2217
|
const priority = getLocalState(target).priority;
|
|
2222
2218
|
return processThreeEvent(instance, priority || 0, eventName, callback, this.store.rootCdr, targetCdr);
|
|
2223
2219
|
}
|
|
2224
|
-
if (
|
|
2225
|
-
!target.__ngt_renderer__[6 /* NgtRendererClassId.compounded */]) {
|
|
2220
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'compound' && !rS[6 /* NgtRendererClassId.compounded */]) {
|
|
2226
2221
|
this.store.queueOperation(target, [
|
|
2227
2222
|
'op',
|
|
2228
2223
|
() => this.store.queueOperation(target, ['cleanUp', this.listen(target, eventName, callback)]),
|
|
@@ -2327,6 +2322,7 @@ class NgtCanvas extends NgtRxStore {
|
|
|
2327
2322
|
this.host = inject(ElementRef);
|
|
2328
2323
|
this.store = inject(NgtStore);
|
|
2329
2324
|
this.hostClass = true;
|
|
2325
|
+
this.sceneGraphInputs = {};
|
|
2330
2326
|
this.compoundPrefixes = [];
|
|
2331
2327
|
this.created = new EventEmitter();
|
|
2332
2328
|
this.pointerMissed = new EventEmitter();
|
|
@@ -2391,6 +2387,11 @@ class NgtCanvas extends NgtRxStore {
|
|
|
2391
2387
|
set performance(performance) {
|
|
2392
2388
|
this.set({ performance });
|
|
2393
2389
|
}
|
|
2390
|
+
ngOnChanges(changes) {
|
|
2391
|
+
if (changes['sceneGraphInputs'] && this.glRef) {
|
|
2392
|
+
this.setSceneGraphInputs();
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2394
2395
|
ngOnInit() {
|
|
2395
2396
|
if (!this.get('eventSource')) {
|
|
2396
2397
|
// set default event source to the host element
|
|
@@ -2458,6 +2459,7 @@ class NgtCanvas extends NgtRxStore {
|
|
|
2458
2459
|
environmentInjector: this.glEnvInjector,
|
|
2459
2460
|
});
|
|
2460
2461
|
this.glRef.changeDetectorRef.detach();
|
|
2462
|
+
this.setSceneGraphInputs();
|
|
2461
2463
|
// here, we override the detectChanges to also call detectChanges on the ComponentRef
|
|
2462
2464
|
this.overrideDetectChanges();
|
|
2463
2465
|
this.cdr.detectChanges();
|
|
@@ -2479,9 +2481,16 @@ class NgtCanvas extends NgtRxStore {
|
|
|
2479
2481
|
(_a = this.glRef) === null || _a === void 0 ? void 0 : _a.changeDetectorRef.detectChanges();
|
|
2480
2482
|
};
|
|
2481
2483
|
}
|
|
2484
|
+
setSceneGraphInputs() {
|
|
2485
|
+
var _a;
|
|
2486
|
+
for (const key of Object.keys(this.sceneGraphInputs)) {
|
|
2487
|
+
(_a = this.glRef) === null || _a === void 0 ? void 0 : _a.setInput(key, this.sceneGraphInputs[key]);
|
|
2488
|
+
}
|
|
2489
|
+
this.cdr.detectChanges();
|
|
2490
|
+
}
|
|
2482
2491
|
}
|
|
2483
2492
|
NgtCanvas.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtCanvas, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
2484
|
-
NgtCanvas.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.3", type: NgtCanvas, isStandalone: true, selector: "ngt-canvas", inputs: { sceneGraph: "sceneGraph", compoundPrefixes: "compoundPrefixes", linear: "linear", legacy: "legacy", flat: "flat", orthographic: "orthographic", frameloop: "frameloop", dpr: "dpr", raycaster: "raycaster", shadows: "shadows", camera: "camera", gl: "gl", eventSource: "eventSource", eventPrefix: "eventPrefix", lookAt: "lookAt", performance: "performance" }, outputs: { created: "created", pointerMissed: "pointerMissed" }, host: { properties: { "class.ngt-canvas": "this.hostClass", "style.pointerEvents": "this.pointerEvents" } }, providers: [NgtStore, provideNgxResizeOptions({ emitInZone: false })], viewQueries: [{ propertyName: "glCanvas", first: true, predicate: ["glCanvas"], descendants: true, static: true }, { propertyName: "glAnchor", first: true, predicate: ["glCanvas"], descendants: true, read: ViewContainerRef, static: true }], usesInheritance: true, ngImport: i0, template: `
|
|
2493
|
+
NgtCanvas.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.3", type: NgtCanvas, isStandalone: true, selector: "ngt-canvas", inputs: { sceneGraph: "sceneGraph", sceneGraphInputs: "sceneGraphInputs", compoundPrefixes: "compoundPrefixes", linear: "linear", legacy: "legacy", flat: "flat", orthographic: "orthographic", frameloop: "frameloop", dpr: "dpr", raycaster: "raycaster", shadows: "shadows", camera: "camera", gl: "gl", eventSource: "eventSource", eventPrefix: "eventPrefix", lookAt: "lookAt", performance: "performance" }, outputs: { created: "created", pointerMissed: "pointerMissed" }, host: { properties: { "class.ngt-canvas": "this.hostClass", "style.pointerEvents": "this.pointerEvents" } }, providers: [NgtStore, provideNgxResizeOptions({ emitInZone: false })], viewQueries: [{ propertyName: "glCanvas", first: true, predicate: ["glCanvas"], descendants: true, static: true }, { propertyName: "glAnchor", first: true, predicate: ["glCanvas"], descendants: true, read: ViewContainerRef, static: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: `
|
|
2485
2494
|
<div (ngxResize)="onResize($event)" style="height: 100%; width: 100%;">
|
|
2486
2495
|
<canvas #glCanvas style="display: block;"></canvas>
|
|
2487
2496
|
</div>
|
|
@@ -2501,6 +2510,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImpor
|
|
|
2501
2510
|
args: ['style.pointerEvents']
|
|
2502
2511
|
}], sceneGraph: [{
|
|
2503
2512
|
type: Input
|
|
2513
|
+
}], sceneGraphInputs: [{
|
|
2514
|
+
type: Input
|
|
2504
2515
|
}], compoundPrefixes: [{
|
|
2505
2516
|
type: Input
|
|
2506
2517
|
}], linear: [{
|