angular-three 1.6.11 → 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/renderer/renderer.mjs +71 -83
- package/esm2020/lib/renderer/state.mjs +52 -47
- package/fesm2015/angular-three.mjs +139 -131
- package/fesm2015/angular-three.mjs.map +1 -1
- package/fesm2020/angular-three.mjs +137 -129
- 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
|
@@ -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
|
}
|
|
@@ -1944,7 +1949,7 @@ class NgtRendererFactory {
|
|
|
1944
1949
|
compoundPrefixes: this.compoundPrefixes,
|
|
1945
1950
|
document: this.document,
|
|
1946
1951
|
});
|
|
1947
|
-
renderer = new NgtRenderer(delegateRenderer, store, this.catalogue
|
|
1952
|
+
renderer = new NgtRenderer(delegateRenderer, store, this.catalogue);
|
|
1948
1953
|
this.rendererMap.set(type.id, renderer);
|
|
1949
1954
|
}
|
|
1950
1955
|
if (!renderer) {
|
|
@@ -1955,7 +1960,7 @@ class NgtRendererFactory {
|
|
|
1955
1960
|
compoundPrefixes: this.compoundPrefixes,
|
|
1956
1961
|
document: this.document,
|
|
1957
1962
|
});
|
|
1958
|
-
renderer = new NgtRenderer(delegateRenderer, store, this.catalogue);
|
|
1963
|
+
renderer = new NgtRenderer(delegateRenderer, store, this.catalogue, false);
|
|
1959
1964
|
this.rendererMap.set(type.id, renderer);
|
|
1960
1965
|
}
|
|
1961
1966
|
return renderer;
|
|
@@ -1966,8 +1971,11 @@ NgtRendererFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", v
|
|
|
1966
1971
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtRendererFactory, decorators: [{
|
|
1967
1972
|
type: Injectable
|
|
1968
1973
|
}] });
|
|
1974
|
+
/**
|
|
1975
|
+
* Anything abbreviated with rS/RS stands for RendererState
|
|
1976
|
+
*/
|
|
1969
1977
|
class NgtRenderer {
|
|
1970
|
-
constructor(delegate, store, catalogue, root =
|
|
1978
|
+
constructor(delegate, store, catalogue, root = true) {
|
|
1971
1979
|
this.delegate = delegate;
|
|
1972
1980
|
this.store = store;
|
|
1973
1981
|
this.catalogue = catalogue;
|
|
@@ -1996,9 +2004,7 @@ class NgtRenderer {
|
|
|
1996
2004
|
}
|
|
1997
2005
|
// handle compound
|
|
1998
2006
|
if (this.store.isCompound(name)) {
|
|
1999
|
-
|
|
2000
|
-
compound.__ngt_renderer__[13 /* NgtRendererClassId.injectorFactory */] = () => getDebugNode(element).injector;
|
|
2001
|
-
return compound;
|
|
2007
|
+
return this.store.createNode('compound', element);
|
|
2002
2008
|
}
|
|
2003
2009
|
// handle portal
|
|
2004
2010
|
if (name === SPECIAL_DOM_TAG.NGT_PORTAL) {
|
|
@@ -2039,50 +2045,48 @@ class NgtRenderer {
|
|
|
2039
2045
|
}
|
|
2040
2046
|
return node;
|
|
2041
2047
|
}
|
|
2042
|
-
|
|
2043
|
-
domNode.__ngt_renderer__[13 /* NgtRendererClassId.injectorFactory */] = () => getDebugNode(element).injector;
|
|
2044
|
-
return domNode;
|
|
2048
|
+
return this.store.createNode('dom', element);
|
|
2045
2049
|
}
|
|
2046
2050
|
createComment(value) {
|
|
2047
|
-
|
|
2048
|
-
return this.store.createNode('comment', comment);
|
|
2051
|
+
return this.store.createNode('comment', this.delegate.createComment(value));
|
|
2049
2052
|
}
|
|
2050
2053
|
appendChild(parent, newChild) {
|
|
2051
2054
|
// TODO: just ignore text node for now
|
|
2052
2055
|
if (newChild instanceof Text)
|
|
2053
2056
|
return;
|
|
2054
|
-
|
|
2057
|
+
const cRS = newChild.__ngt_renderer__;
|
|
2058
|
+
const pRS = parent.__ngt_renderer__;
|
|
2059
|
+
if (cRS[0 /* NgtRendererClassId.type */] === 'comment') {
|
|
2055
2060
|
this.store.setParent(newChild, parent);
|
|
2056
2061
|
return;
|
|
2057
2062
|
}
|
|
2058
2063
|
this.store.setParent(newChild, parent);
|
|
2059
2064
|
this.store.addChild(parent, newChild);
|
|
2060
2065
|
// if new child is a portal
|
|
2061
|
-
if (
|
|
2066
|
+
if (cRS[0 /* NgtRendererClassId.type */] === 'portal') {
|
|
2062
2067
|
this.store.processPortalContainer(newChild);
|
|
2063
|
-
if (
|
|
2064
|
-
this.appendChild(parent,
|
|
2068
|
+
if (cRS[12 /* NgtRendererClassId.portalContainer */]) {
|
|
2069
|
+
this.appendChild(parent, cRS[12 /* NgtRendererClassId.portalContainer */]);
|
|
2065
2070
|
}
|
|
2066
2071
|
return;
|
|
2067
2072
|
}
|
|
2068
2073
|
// if parent is a portal
|
|
2069
|
-
if (
|
|
2074
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'portal') {
|
|
2070
2075
|
this.store.processPortalContainer(parent);
|
|
2071
|
-
if (
|
|
2072
|
-
this.appendChild(
|
|
2076
|
+
if (pRS[12 /* NgtRendererClassId.portalContainer */]) {
|
|
2077
|
+
this.appendChild(pRS[12 /* NgtRendererClassId.portalContainer */], newChild);
|
|
2073
2078
|
}
|
|
2074
2079
|
return;
|
|
2075
2080
|
}
|
|
2076
2081
|
// if both are three instances, straightforward case
|
|
2077
|
-
if (
|
|
2078
|
-
newChild.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2082
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'three' && cRS[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2079
2083
|
// if child already attached to a parent, skip
|
|
2080
2084
|
if (getLocalState(newChild).parent)
|
|
2081
2085
|
return;
|
|
2082
2086
|
// attach THREE child
|
|
2083
2087
|
attachThreeChild(parent, newChild);
|
|
2084
2088
|
// 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 (!
|
|
2089
|
+
if (!cRS[4 /* NgtRendererClassId.compound */])
|
|
2086
2090
|
return;
|
|
2087
2091
|
const closestGrandparentWithCompound = this.store.getClosestParentWithCompound(parent);
|
|
2088
2092
|
if (!closestGrandparentWithCompound)
|
|
@@ -2091,53 +2095,43 @@ class NgtRenderer {
|
|
|
2091
2095
|
return;
|
|
2092
2096
|
}
|
|
2093
2097
|
// if only the parent is the THREE instance
|
|
2094
|
-
if (
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
this.appendChild(parent, renderChild);
|
|
2098
|
-
}
|
|
2098
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2099
|
+
for (const renderChild of cRS[2 /* NgtRendererClassId.children */]) {
|
|
2100
|
+
this.appendChild(parent, renderChild);
|
|
2099
2101
|
}
|
|
2100
2102
|
}
|
|
2101
2103
|
// if parent is a compound
|
|
2102
|
-
if (
|
|
2104
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'compound') {
|
|
2103
2105
|
// if compound doesn't have a THREE instance set yet
|
|
2104
|
-
if (!
|
|
2105
|
-
newChild.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2106
|
+
if (!pRS[6 /* NgtRendererClassId.compounded */] && cRS[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2106
2107
|
// if child is indeed an ngtCompound
|
|
2107
|
-
if (
|
|
2108
|
+
if (cRS[4 /* NgtRendererClassId.compound */])
|
|
2108
2109
|
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
|
-
}
|
|
2110
|
+
// if not, we track the parent (that is supposedly the compound component) on this three instance
|
|
2111
|
+
else if (!cRS[5 /* NgtRendererClassId.compoundParent */])
|
|
2112
|
+
cRS[5 /* NgtRendererClassId.compoundParent */] = parent;
|
|
2116
2113
|
}
|
|
2117
2114
|
// reset the compound if it's changed
|
|
2118
|
-
if (
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2115
|
+
if (pRS[6 /* NgtRendererClassId.compounded */] &&
|
|
2116
|
+
cRS[0 /* NgtRendererClassId.type */] === 'three' &&
|
|
2117
|
+
cRS[4 /* NgtRendererClassId.compound */] &&
|
|
2118
|
+
pRS[6 /* NgtRendererClassId.compounded */] !== newChild) {
|
|
2122
2119
|
this.store.setCompound(parent, newChild);
|
|
2123
2120
|
}
|
|
2124
2121
|
}
|
|
2125
2122
|
const shouldFindGrandparentInstance =
|
|
2126
2123
|
// if child is three but haven't been attached to a parent yet
|
|
2127
|
-
(
|
|
2124
|
+
(cRS[0 /* NgtRendererClassId.type */] === 'three' && !getLocalState(newChild).parent) ||
|
|
2128
2125
|
// 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 */])));
|
|
2126
|
+
((pRS[0 /* NgtRendererClassId.type */] === 'dom' ||
|
|
2127
|
+
(pRS[0 /* NgtRendererClassId.type */] === 'compound' && !pRS[6 /* NgtRendererClassId.compounded */])) &&
|
|
2128
|
+
(cRS[0 /* NgtRendererClassId.type */] === 'dom' ||
|
|
2129
|
+
(cRS[0 /* NgtRendererClassId.type */] === 'compound' && !cRS[6 /* NgtRendererClassId.compounded */])));
|
|
2135
2130
|
if (shouldFindGrandparentInstance) {
|
|
2136
2131
|
// we'll try to get the grandparent instance here so that we can run appendChild with both instances
|
|
2137
2132
|
const closestGrandparentInstance = this.store.getClosestParentWithInstance(parent);
|
|
2138
|
-
if (closestGrandparentInstance)
|
|
2133
|
+
if (closestGrandparentInstance)
|
|
2139
2134
|
this.appendChild(closestGrandparentInstance, newChild);
|
|
2140
|
-
}
|
|
2141
2135
|
}
|
|
2142
2136
|
}
|
|
2143
2137
|
insertBefore(parent, newChild
|
|
@@ -2150,72 +2144,73 @@ class NgtRenderer {
|
|
|
2150
2144
|
this.appendChild(parent, newChild);
|
|
2151
2145
|
}
|
|
2152
2146
|
removeChild(parent, oldChild, isHostElement) {
|
|
2153
|
-
|
|
2154
|
-
|
|
2147
|
+
const pRS = parent.__ngt_renderer__;
|
|
2148
|
+
const cRS = oldChild.__ngt_renderer__;
|
|
2149
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'three' && cRS[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2155
2150
|
removeThreeChild(parent, oldChild, true);
|
|
2156
2151
|
this.store.destroy(oldChild, parent);
|
|
2157
2152
|
return;
|
|
2158
2153
|
}
|
|
2159
|
-
if (
|
|
2160
|
-
|
|
2161
|
-
this.removeChild(parent.__ngt_renderer__[1 /* NgtRendererClassId.parent */], oldChild, isHostElement);
|
|
2154
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'compound' && pRS[1 /* NgtRendererClassId.parent */]) {
|
|
2155
|
+
this.removeChild(pRS[1 /* NgtRendererClassId.parent */], oldChild, isHostElement);
|
|
2162
2156
|
return;
|
|
2163
2157
|
}
|
|
2164
|
-
if (
|
|
2158
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2165
2159
|
this.store.destroy(oldChild, parent);
|
|
2166
2160
|
return;
|
|
2167
2161
|
}
|
|
2168
2162
|
const closestGrandparentInstance = this.store.getClosestParentWithInstance(parent);
|
|
2169
|
-
if (closestGrandparentInstance)
|
|
2163
|
+
if (closestGrandparentInstance)
|
|
2170
2164
|
this.removeChild(closestGrandparentInstance, oldChild, isHostElement);
|
|
2171
|
-
}
|
|
2172
2165
|
this.store.destroy(oldChild, closestGrandparentInstance);
|
|
2173
2166
|
}
|
|
2174
2167
|
parentNode(node) {
|
|
2175
|
-
|
|
2176
|
-
|
|
2168
|
+
const rS = node.__ngt_renderer__;
|
|
2169
|
+
if (rS?.[1 /* NgtRendererClassId.parent */])
|
|
2170
|
+
return rS[1 /* NgtRendererClassId.parent */];
|
|
2177
2171
|
return this.delegate.parentNode(node);
|
|
2178
2172
|
}
|
|
2179
2173
|
setAttribute(el, name, value, namespace) {
|
|
2180
|
-
|
|
2174
|
+
const rS = el.__ngt_renderer__;
|
|
2175
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'compound') {
|
|
2181
2176
|
// we don't have the compound instance yet
|
|
2182
|
-
|
|
2183
|
-
if (!
|
|
2177
|
+
rS[8 /* NgtRendererClassId.attributes */][name] = value;
|
|
2178
|
+
if (!rS[6 /* NgtRendererClassId.compounded */]) {
|
|
2184
2179
|
this.store.queueOperation(el, ['op', () => this.setAttribute(el, name, value, namespace)]);
|
|
2185
2180
|
return;
|
|
2186
2181
|
}
|
|
2187
|
-
this.setAttribute(
|
|
2182
|
+
this.setAttribute(rS[6 /* NgtRendererClassId.compounded */], name, value, namespace);
|
|
2188
2183
|
return;
|
|
2189
2184
|
}
|
|
2190
|
-
if (
|
|
2185
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'three')
|
|
2191
2186
|
this.store.applyAttribute(el, name, value);
|
|
2192
|
-
}
|
|
2193
2187
|
}
|
|
2194
2188
|
setProperty(el, name, value) {
|
|
2195
|
-
|
|
2189
|
+
const rS = el.__ngt_renderer__;
|
|
2190
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'compound') {
|
|
2196
2191
|
// we don't have the compound instance yet
|
|
2197
|
-
|
|
2198
|
-
if (!
|
|
2192
|
+
rS[9 /* NgtRendererClassId.properties */][name] = value;
|
|
2193
|
+
if (!rS[6 /* NgtRendererClassId.compounded */]) {
|
|
2199
2194
|
this.store.queueOperation(el, ['op', () => this.setProperty(el, name, value)]);
|
|
2200
2195
|
return;
|
|
2201
2196
|
}
|
|
2202
|
-
if (
|
|
2203
|
-
Object.assign(
|
|
2197
|
+
if (rS[6 /* NgtRendererClassId.compounded */].__ngt_renderer__[4 /* NgtRendererClassId.compound */]) {
|
|
2198
|
+
Object.assign(rS[6 /* NgtRendererClassId.compounded */].__ngt_renderer__[4 /* NgtRendererClassId.compound */], {
|
|
2204
2199
|
props: {
|
|
2205
|
-
...
|
|
2200
|
+
...rS[6 /* NgtRendererClassId.compounded */].__ngt_renderer__[4 /* NgtRendererClassId.compound */],
|
|
2206
2201
|
[name]: value,
|
|
2207
2202
|
},
|
|
2208
2203
|
});
|
|
2209
2204
|
}
|
|
2210
|
-
this.setProperty(
|
|
2205
|
+
this.setProperty(rS[6 /* NgtRendererClassId.compounded */], name, value);
|
|
2211
2206
|
return;
|
|
2212
2207
|
}
|
|
2213
|
-
if (
|
|
2208
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'three')
|
|
2214
2209
|
this.store.applyProperty(el, name, value);
|
|
2215
|
-
}
|
|
2216
2210
|
}
|
|
2217
2211
|
listen(target, eventName, callback) {
|
|
2218
|
-
const
|
|
2212
|
+
const rS = target.__ngt_renderer__;
|
|
2213
|
+
const targetCdr = rS?.[13 /* NgtRendererClassId.injectorFactory */]?.().get(ChangeDetectorRef, null);
|
|
2219
2214
|
// if target is DOM node, then we pass that to delegate Renderer
|
|
2220
2215
|
const callbackWithCdr = (event) => {
|
|
2221
2216
|
const value = callback(event);
|
|
@@ -2239,15 +2234,13 @@ class NgtRenderer {
|
|
|
2239
2234
|
: target['ownerDocument'];
|
|
2240
2235
|
return this.delegate.listen(eventTarget, event, callbackWithCdr);
|
|
2241
2236
|
}
|
|
2242
|
-
if (
|
|
2243
|
-
(
|
|
2244
|
-
|
|
2245
|
-
const instance = target.__ngt_renderer__[6 /* NgtRendererClassId.compounded */] || target;
|
|
2237
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'three' ||
|
|
2238
|
+
(rS[0 /* NgtRendererClassId.type */] === 'compound' && rS[6 /* NgtRendererClassId.compounded */])) {
|
|
2239
|
+
const instance = rS[6 /* NgtRendererClassId.compounded */] || target;
|
|
2246
2240
|
const priority = getLocalState(target).priority;
|
|
2247
2241
|
return processThreeEvent(instance, priority || 0, eventName, callback, this.store.rootCdr, targetCdr);
|
|
2248
2242
|
}
|
|
2249
|
-
if (
|
|
2250
|
-
!target.__ngt_renderer__[6 /* NgtRendererClassId.compounded */]) {
|
|
2243
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'compound' && !rS[6 /* NgtRendererClassId.compounded */]) {
|
|
2251
2244
|
this.store.queueOperation(target, [
|
|
2252
2245
|
'op',
|
|
2253
2246
|
() => this.store.queueOperation(target, ['cleanUp', this.listen(target, eventName, callback)]),
|
|
@@ -2350,6 +2343,7 @@ class NgtCanvas extends NgtRxStore {
|
|
|
2350
2343
|
this.host = inject(ElementRef);
|
|
2351
2344
|
this.store = inject(NgtStore);
|
|
2352
2345
|
this.hostClass = true;
|
|
2346
|
+
this.sceneGraphInputs = {};
|
|
2353
2347
|
this.compoundPrefixes = [];
|
|
2354
2348
|
this.created = new EventEmitter();
|
|
2355
2349
|
this.pointerMissed = new EventEmitter();
|
|
@@ -2414,6 +2408,11 @@ class NgtCanvas extends NgtRxStore {
|
|
|
2414
2408
|
set performance(performance) {
|
|
2415
2409
|
this.set({ performance });
|
|
2416
2410
|
}
|
|
2411
|
+
ngOnChanges(changes) {
|
|
2412
|
+
if (changes['sceneGraphInputs'] && this.glRef) {
|
|
2413
|
+
this.setSceneGraphInputs();
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2417
2416
|
ngOnInit() {
|
|
2418
2417
|
if (!this.get('eventSource')) {
|
|
2419
2418
|
// set default event source to the host element
|
|
@@ -2480,6 +2479,7 @@ class NgtCanvas extends NgtRxStore {
|
|
|
2480
2479
|
environmentInjector: this.glEnvInjector,
|
|
2481
2480
|
});
|
|
2482
2481
|
this.glRef.changeDetectorRef.detach();
|
|
2482
|
+
this.setSceneGraphInputs();
|
|
2483
2483
|
// here, we override the detectChanges to also call detectChanges on the ComponentRef
|
|
2484
2484
|
this.overrideDetectChanges();
|
|
2485
2485
|
this.cdr.detectChanges();
|
|
@@ -2500,9 +2500,15 @@ class NgtCanvas extends NgtRxStore {
|
|
|
2500
2500
|
this.glRef?.changeDetectorRef.detectChanges();
|
|
2501
2501
|
};
|
|
2502
2502
|
}
|
|
2503
|
+
setSceneGraphInputs() {
|
|
2504
|
+
for (const key of Object.keys(this.sceneGraphInputs)) {
|
|
2505
|
+
this.glRef?.setInput(key, this.sceneGraphInputs[key]);
|
|
2506
|
+
}
|
|
2507
|
+
this.cdr.detectChanges();
|
|
2508
|
+
}
|
|
2503
2509
|
}
|
|
2504
2510
|
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: `
|
|
2511
|
+
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
2512
|
<div (ngxResize)="onResize($event)" style="height: 100%; width: 100%;">
|
|
2507
2513
|
<canvas #glCanvas style="display: block;"></canvas>
|
|
2508
2514
|
</div>
|
|
@@ -2522,6 +2528,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImpor
|
|
|
2522
2528
|
args: ['style.pointerEvents']
|
|
2523
2529
|
}], sceneGraph: [{
|
|
2524
2530
|
type: Input
|
|
2531
|
+
}], sceneGraphInputs: [{
|
|
2532
|
+
type: Input
|
|
2525
2533
|
}], compoundPrefixes: [{
|
|
2526
2534
|
type: Input
|
|
2527
2535
|
}], linear: [{
|