angular-three 1.6.11 → 1.7.1
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/renderer/renderer.mjs +79 -105
- package/esm2020/lib/renderer/state.mjs +52 -47
- package/fesm2015/angular-three.mjs +147 -153
- package/fesm2015/angular-three.mjs.map +1 -1
- package/fesm2020/angular-three.mjs +145 -151
- package/fesm2020/angular-three.mjs.map +1 -1
- package/lib/canvas.d.ts +7 -4
- package/lib/renderer/renderer.d.ts +8 -5
- package/package.json +1 -1
- package/plugin/package.json +1 -1
|
@@ -1579,10 +1579,15 @@ class NgtRendererStore {
|
|
|
1579
1579
|
if (!rendererNode['ownerDocument']) {
|
|
1580
1580
|
rendererNode['ownerDocument'] = this.root.document;
|
|
1581
1581
|
}
|
|
1582
|
-
|
|
1582
|
+
// assign injectorFactory on non-three type since
|
|
1583
|
+
// rendererNode is an instance of DOM Node
|
|
1584
|
+
if (state[0 /* NgtRendererClassId.type */] !== 'three') {
|
|
1583
1585
|
state[13 /* NgtRendererClassId.injectorFactory */] = () => getDebugNode(rendererNode).injector;
|
|
1586
|
+
}
|
|
1587
|
+
if (state[0 /* NgtRendererClassId.type */] === 'comment') {
|
|
1584
1588
|
// we attach an arrow function to the Comment node
|
|
1585
1589
|
// In our directives, we can call this function to then start tracking the RendererNode
|
|
1590
|
+
// this is done to limit the amount of Nodes we need to process for getCreationState
|
|
1586
1591
|
rendererNode['__ngt_renderer_add_comment__'] = (portalNode) => {
|
|
1587
1592
|
if (portalNode && portalNode.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'portal') {
|
|
1588
1593
|
this.portals.push(portalNode);
|
|
@@ -1593,10 +1598,6 @@ class NgtRendererStore {
|
|
|
1593
1598
|
};
|
|
1594
1599
|
return rendererNode;
|
|
1595
1600
|
}
|
|
1596
|
-
if (state[0 /* NgtRendererClassId.type */] === 'portal') {
|
|
1597
|
-
state[13 /* NgtRendererClassId.injectorFactory */] = () => getDebugNode(rendererNode).injector;
|
|
1598
|
-
return rendererNode;
|
|
1599
|
-
}
|
|
1600
1601
|
if (state[0 /* NgtRendererClassId.type */] === 'compound') {
|
|
1601
1602
|
state[7 /* NgtRendererClassId.queueOps */] = new Set();
|
|
1602
1603
|
state[8 /* NgtRendererClassId.attributes */] = {};
|
|
@@ -1622,17 +1623,18 @@ class NgtRendererStore {
|
|
|
1622
1623
|
}
|
|
1623
1624
|
}
|
|
1624
1625
|
setCompound(compound, instance) {
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
const
|
|
1626
|
+
const rS = compound.__ngt_renderer__;
|
|
1627
|
+
rS[6 /* NgtRendererClassId.compounded */] = instance;
|
|
1628
|
+
const attributes = Object.keys(rS[8 /* NgtRendererClassId.attributes */]);
|
|
1629
|
+
const properties = Object.keys(rS[9 /* NgtRendererClassId.properties */]);
|
|
1628
1630
|
if (attributes.length) {
|
|
1629
1631
|
for (const key of attributes) {
|
|
1630
|
-
this.applyAttribute(instance, key,
|
|
1632
|
+
this.applyAttribute(instance, key, rS[8 /* NgtRendererClassId.attributes */][key]);
|
|
1631
1633
|
}
|
|
1632
1634
|
}
|
|
1633
1635
|
if (properties.length) {
|
|
1634
1636
|
for (const key of properties) {
|
|
1635
|
-
this.applyProperty(instance, key,
|
|
1637
|
+
this.applyProperty(instance, key, rS[9 /* NgtRendererClassId.properties */][key]);
|
|
1636
1638
|
}
|
|
1637
1639
|
}
|
|
1638
1640
|
this.executeOperation(compound);
|
|
@@ -1641,11 +1643,12 @@ class NgtRendererStore {
|
|
|
1641
1643
|
node.__ngt_renderer__[7 /* NgtRendererClassId.queueOps */].add(op);
|
|
1642
1644
|
}
|
|
1643
1645
|
executeOperation(node, type = 'op') {
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
+
const rS = node.__ngt_renderer__;
|
|
1647
|
+
if (rS[7 /* NgtRendererClassId.queueOps */]?.size) {
|
|
1648
|
+
rS[7 /* NgtRendererClassId.queueOps */].forEach((op) => {
|
|
1646
1649
|
if (op[0 /* NgtQueueOpClassId.type */] === type) {
|
|
1647
1650
|
op[1 /* NgtQueueOpClassId.op */]();
|
|
1648
|
-
|
|
1651
|
+
rS[7 /* NgtRendererClassId.queueOps */].delete(op);
|
|
1649
1652
|
}
|
|
1650
1653
|
});
|
|
1651
1654
|
}
|
|
@@ -1664,7 +1667,8 @@ class NgtRendererStore {
|
|
|
1664
1667
|
portal.__ngt_renderer__[12 /* NgtRendererClassId.portalContainer */] = this.createNode('three', portalContainer);
|
|
1665
1668
|
}
|
|
1666
1669
|
applyAttribute(node, name, value) {
|
|
1667
|
-
|
|
1670
|
+
const rS = node.__ngt_renderer__;
|
|
1671
|
+
if (rS[3 /* NgtRendererClassId.destroyed */])
|
|
1668
1672
|
return;
|
|
1669
1673
|
if (name === SPECIAL_PROPERTIES.RENDER_PRIORITY) {
|
|
1670
1674
|
// priority needs to be set as an attribute string so that they can be set as early as possible
|
|
@@ -1678,7 +1682,7 @@ class NgtRendererStore {
|
|
|
1678
1682
|
}
|
|
1679
1683
|
if (name === SPECIAL_PROPERTIES.COMPOUND) {
|
|
1680
1684
|
// we set the compound property on instance node now so we know that this instance is being compounded
|
|
1681
|
-
|
|
1685
|
+
rS[4 /* NgtRendererClassId.compound */] = [value === '' || value === 'first', {}];
|
|
1682
1686
|
return;
|
|
1683
1687
|
}
|
|
1684
1688
|
if (name === SPECIAL_PROPERTIES.ATTACH) {
|
|
@@ -1697,24 +1701,25 @@ class NgtRendererStore {
|
|
|
1697
1701
|
else if (!isNaN(Number(maybeCoerced))) {
|
|
1698
1702
|
maybeCoerced = Number(maybeCoerced);
|
|
1699
1703
|
}
|
|
1700
|
-
|
|
1704
|
+
rS[10 /* NgtRendererClassId.rawValue */] = maybeCoerced;
|
|
1701
1705
|
return;
|
|
1702
1706
|
}
|
|
1703
1707
|
applyProps(node, { [name]: value });
|
|
1704
1708
|
}
|
|
1705
1709
|
applyProperty(node, name, value) {
|
|
1706
|
-
|
|
1710
|
+
const rS = node.__ngt_renderer__;
|
|
1711
|
+
if (rS[3 /* NgtRendererClassId.destroyed */])
|
|
1707
1712
|
return;
|
|
1708
1713
|
// [ref]
|
|
1709
1714
|
if (name === SPECIAL_PROPERTIES.REF && is.ref(value)) {
|
|
1710
|
-
|
|
1715
|
+
rS[11 /* NgtRendererClassId.ref */] = value;
|
|
1711
1716
|
value.nativeElement = node;
|
|
1712
1717
|
return;
|
|
1713
1718
|
}
|
|
1714
|
-
const parent = getLocalState(node).parent ||
|
|
1719
|
+
const parent = getLocalState(node).parent || rS[1 /* NgtRendererClassId.parent */];
|
|
1715
1720
|
// [rawValue]
|
|
1716
1721
|
if (getLocalState(node).isRaw && name === SPECIAL_PROPERTIES.VALUE) {
|
|
1717
|
-
|
|
1722
|
+
rS[10 /* NgtRendererClassId.rawValue */] = value;
|
|
1718
1723
|
if (parent)
|
|
1719
1724
|
attachThreeChild(parent, node);
|
|
1720
1725
|
return;
|
|
@@ -1726,7 +1731,7 @@ class NgtRendererStore {
|
|
|
1726
1731
|
attachThreeChild(parent, node);
|
|
1727
1732
|
return;
|
|
1728
1733
|
}
|
|
1729
|
-
const compound =
|
|
1734
|
+
const compound = rS[4 /* NgtRendererClassId.compound */];
|
|
1730
1735
|
if (compound?.[1 /* NgtCompoundClassId.props */] &&
|
|
1731
1736
|
name in compound[1 /* NgtCompoundClassId.props */] &&
|
|
1732
1737
|
!compound[0 /* NgtCompoundClassId.applyFirst */]) {
|
|
@@ -1738,9 +1743,9 @@ class NgtRendererStore {
|
|
|
1738
1743
|
return this.root.compoundPrefixes.some((prefix) => name.startsWith(prefix));
|
|
1739
1744
|
}
|
|
1740
1745
|
isDOM(node) {
|
|
1741
|
-
const
|
|
1742
|
-
return (!
|
|
1743
|
-
(
|
|
1746
|
+
const rS = node['__ngt_renderer__'];
|
|
1747
|
+
return (!rS ||
|
|
1748
|
+
(rS[0 /* NgtRendererClassId.type */] !== 'compound' &&
|
|
1744
1749
|
(node instanceof Element || node instanceof Document || node instanceof Window)));
|
|
1745
1750
|
}
|
|
1746
1751
|
get rootScene() {
|
|
@@ -1794,12 +1799,12 @@ class NgtRendererStore {
|
|
|
1794
1799
|
return { injectedArgs, store };
|
|
1795
1800
|
}
|
|
1796
1801
|
destroy(node, parent) {
|
|
1797
|
-
const
|
|
1798
|
-
if (
|
|
1802
|
+
const rS = node.__ngt_renderer__;
|
|
1803
|
+
if (rS[3 /* NgtRendererClassId.destroyed */])
|
|
1799
1804
|
return;
|
|
1800
|
-
if (
|
|
1801
|
-
|
|
1802
|
-
|
|
1805
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'three') {
|
|
1806
|
+
rS[4 /* NgtRendererClassId.compound */] = undefined;
|
|
1807
|
+
rS[5 /* NgtRendererClassId.compoundParent */] = undefined;
|
|
1803
1808
|
const localState = getLocalState(node);
|
|
1804
1809
|
if (localState.objects) {
|
|
1805
1810
|
localState.objects.value.forEach((obj) => this.destroy(obj, parent));
|
|
@@ -1825,44 +1830,44 @@ class NgtRendererStore {
|
|
|
1825
1830
|
delete node['__ngt__'];
|
|
1826
1831
|
}
|
|
1827
1832
|
}
|
|
1828
|
-
if (
|
|
1829
|
-
|
|
1833
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'comment') {
|
|
1834
|
+
rS[13 /* NgtRendererClassId.injectorFactory */] = null;
|
|
1830
1835
|
delete node['__ngt_renderer_add_comment__'];
|
|
1831
1836
|
const index = this.comments.findIndex((comment) => comment === node);
|
|
1832
1837
|
if (index > -1) {
|
|
1833
1838
|
this.comments.splice(index, 1);
|
|
1834
1839
|
}
|
|
1835
1840
|
}
|
|
1836
|
-
if (
|
|
1837
|
-
|
|
1841
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'portal') {
|
|
1842
|
+
rS[13 /* NgtRendererClassId.injectorFactory */] = null;
|
|
1838
1843
|
const index = this.portals.findIndex((portal) => portal === node);
|
|
1839
1844
|
if (index > -1) {
|
|
1840
1845
|
this.portals.splice(index, 1);
|
|
1841
1846
|
}
|
|
1842
1847
|
}
|
|
1843
|
-
if (
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1848
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'compound') {
|
|
1849
|
+
rS[6 /* NgtRendererClassId.compounded */] = undefined;
|
|
1850
|
+
rS[8 /* NgtRendererClassId.attributes */] = null;
|
|
1851
|
+
rS[9 /* NgtRendererClassId.properties */] = null;
|
|
1847
1852
|
this.executeOperation(node, 'cleanUp');
|
|
1848
|
-
|
|
1849
|
-
|
|
1853
|
+
rS[7 /* NgtRendererClassId.queueOps */].clear();
|
|
1854
|
+
rS[7 /* NgtRendererClassId.queueOps */] = null;
|
|
1850
1855
|
}
|
|
1851
|
-
if (
|
|
1856
|
+
if (rS[11 /* NgtRendererClassId.ref */]) {
|
|
1852
1857
|
// nullify ref
|
|
1853
|
-
|
|
1854
|
-
|
|
1858
|
+
rS[11 /* NgtRendererClassId.ref */].nativeElement = null;
|
|
1859
|
+
rS[11 /* NgtRendererClassId.ref */] = undefined;
|
|
1855
1860
|
}
|
|
1856
1861
|
// nullify parent
|
|
1857
|
-
|
|
1858
|
-
for (const renderChild of
|
|
1862
|
+
rS[1 /* NgtRendererClassId.parent */] = null;
|
|
1863
|
+
for (const renderChild of rS[2 /* NgtRendererClassId.children */] || []) {
|
|
1859
1864
|
if (renderChild.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three' && parent) {
|
|
1860
1865
|
removeThreeChild(parent, renderChild, true);
|
|
1861
1866
|
}
|
|
1862
1867
|
this.destroy(renderChild, parent);
|
|
1863
1868
|
}
|
|
1864
|
-
|
|
1865
|
-
|
|
1869
|
+
rS[2 /* NgtRendererClassId.children */] = [];
|
|
1870
|
+
rS[3 /* NgtRendererClassId.destroyed */] = true;
|
|
1866
1871
|
if (parent) {
|
|
1867
1872
|
this.removeChild(parent, node);
|
|
1868
1873
|
}
|
|
@@ -1928,34 +1933,21 @@ class NgtRendererFactory {
|
|
|
1928
1933
|
this.document = inject(DOCUMENT);
|
|
1929
1934
|
this.rendererMap = new Map();
|
|
1930
1935
|
this.portals = [];
|
|
1936
|
+
this.rendererStore = new NgtRendererStore({
|
|
1937
|
+
store: this.store,
|
|
1938
|
+
cdr: this.cdr,
|
|
1939
|
+
portals: this.portals,
|
|
1940
|
+
compoundPrefixes: this.compoundPrefixes,
|
|
1941
|
+
document: this.document,
|
|
1942
|
+
});
|
|
1931
1943
|
}
|
|
1932
1944
|
createRenderer(hostElement, type) {
|
|
1933
1945
|
const delegateRenderer = this.delegateRendererFactory.createRenderer(hostElement, type);
|
|
1934
1946
|
if (!type)
|
|
1935
1947
|
return delegateRenderer;
|
|
1936
1948
|
let renderer = this.rendererMap.get(type.id);
|
|
1937
|
-
if (renderer)
|
|
1938
|
-
return renderer;
|
|
1939
|
-
if (!hostElement) {
|
|
1940
|
-
const store = new NgtRendererStore({
|
|
1941
|
-
store: this.store,
|
|
1942
|
-
cdr: this.cdr,
|
|
1943
|
-
portals: this.portals,
|
|
1944
|
-
compoundPrefixes: this.compoundPrefixes,
|
|
1945
|
-
document: this.document,
|
|
1946
|
-
});
|
|
1947
|
-
renderer = new NgtRenderer(delegateRenderer, store, this.catalogue, true);
|
|
1948
|
-
this.rendererMap.set(type.id, renderer);
|
|
1949
|
-
}
|
|
1950
1949
|
if (!renderer) {
|
|
1951
|
-
|
|
1952
|
-
store: this.store,
|
|
1953
|
-
cdr: this.cdr,
|
|
1954
|
-
portals: this.portals,
|
|
1955
|
-
compoundPrefixes: this.compoundPrefixes,
|
|
1956
|
-
document: this.document,
|
|
1957
|
-
});
|
|
1958
|
-
renderer = new NgtRenderer(delegateRenderer, store, this.catalogue);
|
|
1950
|
+
renderer = new NgtRenderer(delegateRenderer, this.rendererStore, this.catalogue, !hostElement);
|
|
1959
1951
|
this.rendererMap.set(type.id, renderer);
|
|
1960
1952
|
}
|
|
1961
1953
|
return renderer;
|
|
@@ -1966,13 +1958,15 @@ NgtRendererFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", v
|
|
|
1966
1958
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtRendererFactory, decorators: [{
|
|
1967
1959
|
type: Injectable
|
|
1968
1960
|
}] });
|
|
1961
|
+
/**
|
|
1962
|
+
* Anything abbreviated with rS/RS stands for RendererState
|
|
1963
|
+
*/
|
|
1969
1964
|
class NgtRenderer {
|
|
1970
|
-
constructor(delegate, store, catalogue, root =
|
|
1965
|
+
constructor(delegate, store, catalogue, root = true) {
|
|
1971
1966
|
this.delegate = delegate;
|
|
1972
1967
|
this.store = store;
|
|
1973
1968
|
this.catalogue = catalogue;
|
|
1974
1969
|
this.root = root;
|
|
1975
|
-
this.first = false;
|
|
1976
1970
|
this.createText = this.delegate.createText.bind(this.delegate);
|
|
1977
1971
|
this.destroy = this.delegate.destroy.bind(this.delegate);
|
|
1978
1972
|
this.destroyNode = null;
|
|
@@ -1988,17 +1982,15 @@ class NgtRenderer {
|
|
|
1988
1982
|
createElement(name, namespace) {
|
|
1989
1983
|
const element = this.delegate.createElement(name, namespace);
|
|
1990
1984
|
// on first pass, we return the Root Scene as the root node
|
|
1991
|
-
if (this.root
|
|
1992
|
-
this.
|
|
1985
|
+
if (this.root) {
|
|
1986
|
+
this.root = false;
|
|
1993
1987
|
const node = this.store.createNode('three', this.store.rootScene);
|
|
1994
1988
|
node.__ngt_renderer__[13 /* NgtRendererClassId.injectorFactory */] = () => getDebugNode(element).injector;
|
|
1995
1989
|
return node;
|
|
1996
1990
|
}
|
|
1997
1991
|
// handle compound
|
|
1998
1992
|
if (this.store.isCompound(name)) {
|
|
1999
|
-
|
|
2000
|
-
compound.__ngt_renderer__[13 /* NgtRendererClassId.injectorFactory */] = () => getDebugNode(element).injector;
|
|
2001
|
-
return compound;
|
|
1993
|
+
return this.store.createNode('compound', element);
|
|
2002
1994
|
}
|
|
2003
1995
|
// handle portal
|
|
2004
1996
|
if (name === SPECIAL_DOM_TAG.NGT_PORTAL) {
|
|
@@ -2039,50 +2031,48 @@ class NgtRenderer {
|
|
|
2039
2031
|
}
|
|
2040
2032
|
return node;
|
|
2041
2033
|
}
|
|
2042
|
-
|
|
2043
|
-
domNode.__ngt_renderer__[13 /* NgtRendererClassId.injectorFactory */] = () => getDebugNode(element).injector;
|
|
2044
|
-
return domNode;
|
|
2034
|
+
return this.store.createNode('dom', element);
|
|
2045
2035
|
}
|
|
2046
2036
|
createComment(value) {
|
|
2047
|
-
|
|
2048
|
-
return this.store.createNode('comment', comment);
|
|
2037
|
+
return this.store.createNode('comment', this.delegate.createComment(value));
|
|
2049
2038
|
}
|
|
2050
2039
|
appendChild(parent, newChild) {
|
|
2051
2040
|
// TODO: just ignore text node for now
|
|
2052
2041
|
if (newChild instanceof Text)
|
|
2053
2042
|
return;
|
|
2054
|
-
|
|
2043
|
+
const cRS = newChild.__ngt_renderer__;
|
|
2044
|
+
const pRS = parent.__ngt_renderer__;
|
|
2045
|
+
if (cRS[0 /* NgtRendererClassId.type */] === 'comment') {
|
|
2055
2046
|
this.store.setParent(newChild, parent);
|
|
2056
2047
|
return;
|
|
2057
2048
|
}
|
|
2058
2049
|
this.store.setParent(newChild, parent);
|
|
2059
2050
|
this.store.addChild(parent, newChild);
|
|
2060
2051
|
// if new child is a portal
|
|
2061
|
-
if (
|
|
2052
|
+
if (cRS[0 /* NgtRendererClassId.type */] === 'portal') {
|
|
2062
2053
|
this.store.processPortalContainer(newChild);
|
|
2063
|
-
if (
|
|
2064
|
-
this.appendChild(parent,
|
|
2054
|
+
if (cRS[12 /* NgtRendererClassId.portalContainer */]) {
|
|
2055
|
+
this.appendChild(parent, cRS[12 /* NgtRendererClassId.portalContainer */]);
|
|
2065
2056
|
}
|
|
2066
2057
|
return;
|
|
2067
2058
|
}
|
|
2068
2059
|
// if parent is a portal
|
|
2069
|
-
if (
|
|
2060
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'portal') {
|
|
2070
2061
|
this.store.processPortalContainer(parent);
|
|
2071
|
-
if (
|
|
2072
|
-
this.appendChild(
|
|
2062
|
+
if (pRS[12 /* NgtRendererClassId.portalContainer */]) {
|
|
2063
|
+
this.appendChild(pRS[12 /* NgtRendererClassId.portalContainer */], newChild);
|
|
2073
2064
|
}
|
|
2074
2065
|
return;
|
|
2075
2066
|
}
|
|
2076
2067
|
// if both are three instances, straightforward case
|
|
2077
|
-
if (
|
|
2078
|
-
newChild.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2068
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'three' && cRS[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2079
2069
|
// if child already attached to a parent, skip
|
|
2080
2070
|
if (getLocalState(newChild).parent)
|
|
2081
2071
|
return;
|
|
2082
2072
|
// attach THREE child
|
|
2083
2073
|
attachThreeChild(parent, newChild);
|
|
2084
2074
|
// here, we handle the special case of if the parent has a compoundParent, which means this child is part of a compound parent template
|
|
2085
|
-
if (!
|
|
2075
|
+
if (!cRS[4 /* NgtRendererClassId.compound */])
|
|
2086
2076
|
return;
|
|
2087
2077
|
const closestGrandparentWithCompound = this.store.getClosestParentWithCompound(parent);
|
|
2088
2078
|
if (!closestGrandparentWithCompound)
|
|
@@ -2091,53 +2081,43 @@ class NgtRenderer {
|
|
|
2091
2081
|
return;
|
|
2092
2082
|
}
|
|
2093
2083
|
// if only the parent is the THREE instance
|
|
2094
|
-
if (
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
this.appendChild(parent, renderChild);
|
|
2098
|
-
}
|
|
2084
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2085
|
+
for (const renderChild of cRS[2 /* NgtRendererClassId.children */]) {
|
|
2086
|
+
this.appendChild(parent, renderChild);
|
|
2099
2087
|
}
|
|
2100
2088
|
}
|
|
2101
2089
|
// if parent is a compound
|
|
2102
|
-
if (
|
|
2090
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'compound') {
|
|
2103
2091
|
// if compound doesn't have a THREE instance set yet
|
|
2104
|
-
if (!
|
|
2105
|
-
newChild.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2092
|
+
if (!pRS[6 /* NgtRendererClassId.compounded */] && cRS[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2106
2093
|
// if child is indeed an ngtCompound
|
|
2107
|
-
if (
|
|
2094
|
+
if (cRS[4 /* NgtRendererClassId.compound */])
|
|
2108
2095
|
this.store.setCompound(parent, newChild);
|
|
2109
|
-
|
|
2110
|
-
else
|
|
2111
|
-
|
|
2112
|
-
if (!newChild.__ngt_renderer__[5 /* NgtRendererClassId.compoundParent */]) {
|
|
2113
|
-
newChild.__ngt_renderer__[5 /* NgtRendererClassId.compoundParent */] = parent;
|
|
2114
|
-
}
|
|
2115
|
-
}
|
|
2096
|
+
// if not, we track the parent (that is supposedly the compound component) on this three instance
|
|
2097
|
+
else if (!cRS[5 /* NgtRendererClassId.compoundParent */])
|
|
2098
|
+
cRS[5 /* NgtRendererClassId.compoundParent */] = parent;
|
|
2116
2099
|
}
|
|
2117
2100
|
// reset the compound if it's changed
|
|
2118
|
-
if (
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2101
|
+
if (pRS[6 /* NgtRendererClassId.compounded */] &&
|
|
2102
|
+
cRS[0 /* NgtRendererClassId.type */] === 'three' &&
|
|
2103
|
+
cRS[4 /* NgtRendererClassId.compound */] &&
|
|
2104
|
+
pRS[6 /* NgtRendererClassId.compounded */] !== newChild) {
|
|
2122
2105
|
this.store.setCompound(parent, newChild);
|
|
2123
2106
|
}
|
|
2124
2107
|
}
|
|
2125
2108
|
const shouldFindGrandparentInstance =
|
|
2126
2109
|
// if child is three but haven't been attached to a parent yet
|
|
2127
|
-
(
|
|
2110
|
+
(cRS[0 /* NgtRendererClassId.type */] === 'three' && !getLocalState(newChild).parent) ||
|
|
2128
2111
|
// or both parent and child are DOM elements
|
|
2129
|
-
((
|
|
2130
|
-
(
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
(newChild.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'compound' &&
|
|
2134
|
-
!newChild.__ngt_renderer__[6 /* NgtRendererClassId.compounded */])));
|
|
2112
|
+
((pRS[0 /* NgtRendererClassId.type */] === 'dom' ||
|
|
2113
|
+
(pRS[0 /* NgtRendererClassId.type */] === 'compound' && !pRS[6 /* NgtRendererClassId.compounded */])) &&
|
|
2114
|
+
(cRS[0 /* NgtRendererClassId.type */] === 'dom' ||
|
|
2115
|
+
(cRS[0 /* NgtRendererClassId.type */] === 'compound' && !cRS[6 /* NgtRendererClassId.compounded */])));
|
|
2135
2116
|
if (shouldFindGrandparentInstance) {
|
|
2136
2117
|
// we'll try to get the grandparent instance here so that we can run appendChild with both instances
|
|
2137
2118
|
const closestGrandparentInstance = this.store.getClosestParentWithInstance(parent);
|
|
2138
|
-
if (closestGrandparentInstance)
|
|
2119
|
+
if (closestGrandparentInstance)
|
|
2139
2120
|
this.appendChild(closestGrandparentInstance, newChild);
|
|
2140
|
-
}
|
|
2141
2121
|
}
|
|
2142
2122
|
}
|
|
2143
2123
|
insertBefore(parent, newChild
|
|
@@ -2150,72 +2130,73 @@ class NgtRenderer {
|
|
|
2150
2130
|
this.appendChild(parent, newChild);
|
|
2151
2131
|
}
|
|
2152
2132
|
removeChild(parent, oldChild, isHostElement) {
|
|
2153
|
-
|
|
2154
|
-
|
|
2133
|
+
const pRS = parent.__ngt_renderer__;
|
|
2134
|
+
const cRS = oldChild.__ngt_renderer__;
|
|
2135
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'three' && cRS[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2155
2136
|
removeThreeChild(parent, oldChild, true);
|
|
2156
2137
|
this.store.destroy(oldChild, parent);
|
|
2157
2138
|
return;
|
|
2158
2139
|
}
|
|
2159
|
-
if (
|
|
2160
|
-
|
|
2161
|
-
this.removeChild(parent.__ngt_renderer__[1 /* NgtRendererClassId.parent */], oldChild, isHostElement);
|
|
2140
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'compound' && pRS[1 /* NgtRendererClassId.parent */]) {
|
|
2141
|
+
this.removeChild(pRS[1 /* NgtRendererClassId.parent */], oldChild, isHostElement);
|
|
2162
2142
|
return;
|
|
2163
2143
|
}
|
|
2164
|
-
if (
|
|
2144
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2165
2145
|
this.store.destroy(oldChild, parent);
|
|
2166
2146
|
return;
|
|
2167
2147
|
}
|
|
2168
2148
|
const closestGrandparentInstance = this.store.getClosestParentWithInstance(parent);
|
|
2169
|
-
if (closestGrandparentInstance)
|
|
2149
|
+
if (closestGrandparentInstance)
|
|
2170
2150
|
this.removeChild(closestGrandparentInstance, oldChild, isHostElement);
|
|
2171
|
-
}
|
|
2172
2151
|
this.store.destroy(oldChild, closestGrandparentInstance);
|
|
2173
2152
|
}
|
|
2174
2153
|
parentNode(node) {
|
|
2175
|
-
|
|
2176
|
-
|
|
2154
|
+
const rS = node.__ngt_renderer__;
|
|
2155
|
+
if (rS?.[1 /* NgtRendererClassId.parent */])
|
|
2156
|
+
return rS[1 /* NgtRendererClassId.parent */];
|
|
2177
2157
|
return this.delegate.parentNode(node);
|
|
2178
2158
|
}
|
|
2179
2159
|
setAttribute(el, name, value, namespace) {
|
|
2180
|
-
|
|
2160
|
+
const rS = el.__ngt_renderer__;
|
|
2161
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'compound') {
|
|
2181
2162
|
// we don't have the compound instance yet
|
|
2182
|
-
|
|
2183
|
-
if (!
|
|
2163
|
+
rS[8 /* NgtRendererClassId.attributes */][name] = value;
|
|
2164
|
+
if (!rS[6 /* NgtRendererClassId.compounded */]) {
|
|
2184
2165
|
this.store.queueOperation(el, ['op', () => this.setAttribute(el, name, value, namespace)]);
|
|
2185
2166
|
return;
|
|
2186
2167
|
}
|
|
2187
|
-
this.setAttribute(
|
|
2168
|
+
this.setAttribute(rS[6 /* NgtRendererClassId.compounded */], name, value, namespace);
|
|
2188
2169
|
return;
|
|
2189
2170
|
}
|
|
2190
|
-
if (
|
|
2171
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'three')
|
|
2191
2172
|
this.store.applyAttribute(el, name, value);
|
|
2192
|
-
}
|
|
2193
2173
|
}
|
|
2194
2174
|
setProperty(el, name, value) {
|
|
2195
|
-
|
|
2175
|
+
const rS = el.__ngt_renderer__;
|
|
2176
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'compound') {
|
|
2196
2177
|
// we don't have the compound instance yet
|
|
2197
|
-
|
|
2198
|
-
if (!
|
|
2178
|
+
rS[9 /* NgtRendererClassId.properties */][name] = value;
|
|
2179
|
+
if (!rS[6 /* NgtRendererClassId.compounded */]) {
|
|
2199
2180
|
this.store.queueOperation(el, ['op', () => this.setProperty(el, name, value)]);
|
|
2200
2181
|
return;
|
|
2201
2182
|
}
|
|
2202
|
-
if (
|
|
2203
|
-
Object.assign(
|
|
2183
|
+
if (rS[6 /* NgtRendererClassId.compounded */].__ngt_renderer__[4 /* NgtRendererClassId.compound */]) {
|
|
2184
|
+
Object.assign(rS[6 /* NgtRendererClassId.compounded */].__ngt_renderer__[4 /* NgtRendererClassId.compound */], {
|
|
2204
2185
|
props: {
|
|
2205
|
-
...
|
|
2186
|
+
...rS[6 /* NgtRendererClassId.compounded */].__ngt_renderer__[4 /* NgtRendererClassId.compound */],
|
|
2206
2187
|
[name]: value,
|
|
2207
2188
|
},
|
|
2208
2189
|
});
|
|
2209
2190
|
}
|
|
2210
|
-
this.setProperty(
|
|
2191
|
+
this.setProperty(rS[6 /* NgtRendererClassId.compounded */], name, value);
|
|
2211
2192
|
return;
|
|
2212
2193
|
}
|
|
2213
|
-
if (
|
|
2194
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'three')
|
|
2214
2195
|
this.store.applyProperty(el, name, value);
|
|
2215
|
-
}
|
|
2216
2196
|
}
|
|
2217
2197
|
listen(target, eventName, callback) {
|
|
2218
|
-
const
|
|
2198
|
+
const rS = target.__ngt_renderer__;
|
|
2199
|
+
const targetCdr = rS?.[13 /* NgtRendererClassId.injectorFactory */]?.().get(ChangeDetectorRef, null);
|
|
2219
2200
|
// if target is DOM node, then we pass that to delegate Renderer
|
|
2220
2201
|
const callbackWithCdr = (event) => {
|
|
2221
2202
|
const value = callback(event);
|
|
@@ -2239,15 +2220,13 @@ class NgtRenderer {
|
|
|
2239
2220
|
: target['ownerDocument'];
|
|
2240
2221
|
return this.delegate.listen(eventTarget, event, callbackWithCdr);
|
|
2241
2222
|
}
|
|
2242
|
-
if (
|
|
2243
|
-
(
|
|
2244
|
-
|
|
2245
|
-
const instance = target.__ngt_renderer__[6 /* NgtRendererClassId.compounded */] || target;
|
|
2223
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'three' ||
|
|
2224
|
+
(rS[0 /* NgtRendererClassId.type */] === 'compound' && rS[6 /* NgtRendererClassId.compounded */])) {
|
|
2225
|
+
const instance = rS[6 /* NgtRendererClassId.compounded */] || target;
|
|
2246
2226
|
const priority = getLocalState(target).priority;
|
|
2247
2227
|
return processThreeEvent(instance, priority || 0, eventName, callback, this.store.rootCdr, targetCdr);
|
|
2248
2228
|
}
|
|
2249
|
-
if (
|
|
2250
|
-
!target.__ngt_renderer__[6 /* NgtRendererClassId.compounded */]) {
|
|
2229
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'compound' && !rS[6 /* NgtRendererClassId.compounded */]) {
|
|
2251
2230
|
this.store.queueOperation(target, [
|
|
2252
2231
|
'op',
|
|
2253
2232
|
() => this.store.queueOperation(target, ['cleanUp', this.listen(target, eventName, callback)]),
|
|
@@ -2350,6 +2329,7 @@ class NgtCanvas extends NgtRxStore {
|
|
|
2350
2329
|
this.host = inject(ElementRef);
|
|
2351
2330
|
this.store = inject(NgtStore);
|
|
2352
2331
|
this.hostClass = true;
|
|
2332
|
+
this.sceneGraphInputs = {};
|
|
2353
2333
|
this.compoundPrefixes = [];
|
|
2354
2334
|
this.created = new EventEmitter();
|
|
2355
2335
|
this.pointerMissed = new EventEmitter();
|
|
@@ -2414,6 +2394,11 @@ class NgtCanvas extends NgtRxStore {
|
|
|
2414
2394
|
set performance(performance) {
|
|
2415
2395
|
this.set({ performance });
|
|
2416
2396
|
}
|
|
2397
|
+
ngOnChanges(changes) {
|
|
2398
|
+
if (changes['sceneGraphInputs'] && this.glRef) {
|
|
2399
|
+
this.setSceneGraphInputs();
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2417
2402
|
ngOnInit() {
|
|
2418
2403
|
if (!this.get('eventSource')) {
|
|
2419
2404
|
// set default event source to the host element
|
|
@@ -2480,6 +2465,7 @@ class NgtCanvas extends NgtRxStore {
|
|
|
2480
2465
|
environmentInjector: this.glEnvInjector,
|
|
2481
2466
|
});
|
|
2482
2467
|
this.glRef.changeDetectorRef.detach();
|
|
2468
|
+
this.setSceneGraphInputs();
|
|
2483
2469
|
// here, we override the detectChanges to also call detectChanges on the ComponentRef
|
|
2484
2470
|
this.overrideDetectChanges();
|
|
2485
2471
|
this.cdr.detectChanges();
|
|
@@ -2500,9 +2486,15 @@ class NgtCanvas extends NgtRxStore {
|
|
|
2500
2486
|
this.glRef?.changeDetectorRef.detectChanges();
|
|
2501
2487
|
};
|
|
2502
2488
|
}
|
|
2489
|
+
setSceneGraphInputs() {
|
|
2490
|
+
for (const key of Object.keys(this.sceneGraphInputs)) {
|
|
2491
|
+
this.glRef?.setInput(key, this.sceneGraphInputs[key]);
|
|
2492
|
+
}
|
|
2493
|
+
this.cdr.detectChanges();
|
|
2494
|
+
}
|
|
2503
2495
|
}
|
|
2504
2496
|
NgtCanvas.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtCanvas, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
2505
|
-
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: `
|
|
2497
|
+
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: `
|
|
2506
2498
|
<div (ngxResize)="onResize($event)" style="height: 100%; width: 100%;">
|
|
2507
2499
|
<canvas #glCanvas style="display: block;"></canvas>
|
|
2508
2500
|
</div>
|
|
@@ -2522,6 +2514,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImpor
|
|
|
2522
2514
|
args: ['style.pointerEvents']
|
|
2523
2515
|
}], sceneGraph: [{
|
|
2524
2516
|
type: Input
|
|
2517
|
+
}], sceneGraphInputs: [{
|
|
2518
|
+
type: Input
|
|
2525
2519
|
}], compoundPrefixes: [{
|
|
2526
2520
|
type: Input
|
|
2527
2521
|
}], linear: [{
|