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
|
@@ -1556,10 +1556,15 @@ class NgtRendererStore {
|
|
|
1556
1556
|
if (!rendererNode['ownerDocument']) {
|
|
1557
1557
|
rendererNode['ownerDocument'] = this.root.document;
|
|
1558
1558
|
}
|
|
1559
|
-
|
|
1559
|
+
// assign injectorFactory on non-three type since
|
|
1560
|
+
// rendererNode is an instance of DOM Node
|
|
1561
|
+
if (state[0 /* NgtRendererClassId.type */] !== 'three') {
|
|
1560
1562
|
state[13 /* NgtRendererClassId.injectorFactory */] = () => getDebugNode(rendererNode).injector;
|
|
1563
|
+
}
|
|
1564
|
+
if (state[0 /* NgtRendererClassId.type */] === 'comment') {
|
|
1561
1565
|
// we attach an arrow function to the Comment node
|
|
1562
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
|
|
1563
1568
|
rendererNode['__ngt_renderer_add_comment__'] = (portalNode) => {
|
|
1564
1569
|
if (portalNode && portalNode.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'portal') {
|
|
1565
1570
|
this.portals.push(portalNode);
|
|
@@ -1570,10 +1575,6 @@ class NgtRendererStore {
|
|
|
1570
1575
|
};
|
|
1571
1576
|
return rendererNode;
|
|
1572
1577
|
}
|
|
1573
|
-
if (state[0 /* NgtRendererClassId.type */] === 'portal') {
|
|
1574
|
-
state[13 /* NgtRendererClassId.injectorFactory */] = () => getDebugNode(rendererNode).injector;
|
|
1575
|
-
return rendererNode;
|
|
1576
|
-
}
|
|
1577
1578
|
if (state[0 /* NgtRendererClassId.type */] === 'compound') {
|
|
1578
1579
|
state[7 /* NgtRendererClassId.queueOps */] = new Set();
|
|
1579
1580
|
state[8 /* NgtRendererClassId.attributes */] = {};
|
|
@@ -1599,17 +1600,18 @@ class NgtRendererStore {
|
|
|
1599
1600
|
}
|
|
1600
1601
|
}
|
|
1601
1602
|
setCompound(compound, instance) {
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
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 */]);
|
|
1605
1607
|
if (attributes.length) {
|
|
1606
1608
|
for (const key of attributes) {
|
|
1607
|
-
this.applyAttribute(instance, key,
|
|
1609
|
+
this.applyAttribute(instance, key, rS[8 /* NgtRendererClassId.attributes */][key]);
|
|
1608
1610
|
}
|
|
1609
1611
|
}
|
|
1610
1612
|
if (properties.length) {
|
|
1611
1613
|
for (const key of properties) {
|
|
1612
|
-
this.applyProperty(instance, key,
|
|
1614
|
+
this.applyProperty(instance, key, rS[9 /* NgtRendererClassId.properties */][key]);
|
|
1613
1615
|
}
|
|
1614
1616
|
}
|
|
1615
1617
|
this.executeOperation(compound);
|
|
@@ -1619,11 +1621,12 @@ class NgtRendererStore {
|
|
|
1619
1621
|
}
|
|
1620
1622
|
executeOperation(node, type = 'op') {
|
|
1621
1623
|
var _a;
|
|
1622
|
-
|
|
1623
|
-
|
|
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) => {
|
|
1624
1627
|
if (op[0 /* NgtQueueOpClassId.type */] === type) {
|
|
1625
1628
|
op[1 /* NgtQueueOpClassId.op */]();
|
|
1626
|
-
|
|
1629
|
+
rS[7 /* NgtRendererClassId.queueOps */].delete(op);
|
|
1627
1630
|
}
|
|
1628
1631
|
});
|
|
1629
1632
|
}
|
|
@@ -1642,7 +1645,8 @@ class NgtRendererStore {
|
|
|
1642
1645
|
portal.__ngt_renderer__[12 /* NgtRendererClassId.portalContainer */] = this.createNode('three', portalContainer);
|
|
1643
1646
|
}
|
|
1644
1647
|
applyAttribute(node, name, value) {
|
|
1645
|
-
|
|
1648
|
+
const rS = node.__ngt_renderer__;
|
|
1649
|
+
if (rS[3 /* NgtRendererClassId.destroyed */])
|
|
1646
1650
|
return;
|
|
1647
1651
|
if (name === SPECIAL_PROPERTIES.RENDER_PRIORITY) {
|
|
1648
1652
|
// priority needs to be set as an attribute string so that they can be set as early as possible
|
|
@@ -1656,7 +1660,7 @@ class NgtRendererStore {
|
|
|
1656
1660
|
}
|
|
1657
1661
|
if (name === SPECIAL_PROPERTIES.COMPOUND) {
|
|
1658
1662
|
// we set the compound property on instance node now so we know that this instance is being compounded
|
|
1659
|
-
|
|
1663
|
+
rS[4 /* NgtRendererClassId.compound */] = [value === '' || value === 'first', {}];
|
|
1660
1664
|
return;
|
|
1661
1665
|
}
|
|
1662
1666
|
if (name === SPECIAL_PROPERTIES.ATTACH) {
|
|
@@ -1675,24 +1679,25 @@ class NgtRendererStore {
|
|
|
1675
1679
|
else if (!isNaN(Number(maybeCoerced))) {
|
|
1676
1680
|
maybeCoerced = Number(maybeCoerced);
|
|
1677
1681
|
}
|
|
1678
|
-
|
|
1682
|
+
rS[10 /* NgtRendererClassId.rawValue */] = maybeCoerced;
|
|
1679
1683
|
return;
|
|
1680
1684
|
}
|
|
1681
1685
|
applyProps(node, { [name]: value });
|
|
1682
1686
|
}
|
|
1683
1687
|
applyProperty(node, name, value) {
|
|
1684
|
-
|
|
1688
|
+
const rS = node.__ngt_renderer__;
|
|
1689
|
+
if (rS[3 /* NgtRendererClassId.destroyed */])
|
|
1685
1690
|
return;
|
|
1686
1691
|
// [ref]
|
|
1687
1692
|
if (name === SPECIAL_PROPERTIES.REF && is.ref(value)) {
|
|
1688
|
-
|
|
1693
|
+
rS[11 /* NgtRendererClassId.ref */] = value;
|
|
1689
1694
|
value.nativeElement = node;
|
|
1690
1695
|
return;
|
|
1691
1696
|
}
|
|
1692
|
-
const parent = getLocalState(node).parent ||
|
|
1697
|
+
const parent = getLocalState(node).parent || rS[1 /* NgtRendererClassId.parent */];
|
|
1693
1698
|
// [rawValue]
|
|
1694
1699
|
if (getLocalState(node).isRaw && name === SPECIAL_PROPERTIES.VALUE) {
|
|
1695
|
-
|
|
1700
|
+
rS[10 /* NgtRendererClassId.rawValue */] = value;
|
|
1696
1701
|
if (parent)
|
|
1697
1702
|
attachThreeChild(parent, node);
|
|
1698
1703
|
return;
|
|
@@ -1704,7 +1709,7 @@ class NgtRendererStore {
|
|
|
1704
1709
|
attachThreeChild(parent, node);
|
|
1705
1710
|
return;
|
|
1706
1711
|
}
|
|
1707
|
-
const compound =
|
|
1712
|
+
const compound = rS[4 /* NgtRendererClassId.compound */];
|
|
1708
1713
|
if ((compound === null || compound === void 0 ? void 0 : compound[1 /* NgtCompoundClassId.props */]) &&
|
|
1709
1714
|
name in compound[1 /* NgtCompoundClassId.props */] &&
|
|
1710
1715
|
!compound[0 /* NgtCompoundClassId.applyFirst */]) {
|
|
@@ -1716,9 +1721,9 @@ class NgtRendererStore {
|
|
|
1716
1721
|
return this.root.compoundPrefixes.some((prefix) => name.startsWith(prefix));
|
|
1717
1722
|
}
|
|
1718
1723
|
isDOM(node) {
|
|
1719
|
-
const
|
|
1720
|
-
return (!
|
|
1721
|
-
(
|
|
1724
|
+
const rS = node['__ngt_renderer__'];
|
|
1725
|
+
return (!rS ||
|
|
1726
|
+
(rS[0 /* NgtRendererClassId.type */] !== 'compound' &&
|
|
1722
1727
|
(node instanceof Element || node instanceof Document || node instanceof Window)));
|
|
1723
1728
|
}
|
|
1724
1729
|
get rootScene() {
|
|
@@ -1773,12 +1778,12 @@ class NgtRendererStore {
|
|
|
1773
1778
|
return { injectedArgs, store };
|
|
1774
1779
|
}
|
|
1775
1780
|
destroy(node, parent) {
|
|
1776
|
-
const
|
|
1777
|
-
if (
|
|
1781
|
+
const rS = node.__ngt_renderer__;
|
|
1782
|
+
if (rS[3 /* NgtRendererClassId.destroyed */])
|
|
1778
1783
|
return;
|
|
1779
|
-
if (
|
|
1780
|
-
|
|
1781
|
-
|
|
1784
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'three') {
|
|
1785
|
+
rS[4 /* NgtRendererClassId.compound */] = undefined;
|
|
1786
|
+
rS[5 /* NgtRendererClassId.compoundParent */] = undefined;
|
|
1782
1787
|
const localState = getLocalState(node);
|
|
1783
1788
|
if (localState.objects) {
|
|
1784
1789
|
localState.objects.value.forEach((obj) => this.destroy(obj, parent));
|
|
@@ -1804,44 +1809,44 @@ class NgtRendererStore {
|
|
|
1804
1809
|
delete node['__ngt__'];
|
|
1805
1810
|
}
|
|
1806
1811
|
}
|
|
1807
|
-
if (
|
|
1808
|
-
|
|
1812
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'comment') {
|
|
1813
|
+
rS[13 /* NgtRendererClassId.injectorFactory */] = null;
|
|
1809
1814
|
delete node['__ngt_renderer_add_comment__'];
|
|
1810
1815
|
const index = this.comments.findIndex((comment) => comment === node);
|
|
1811
1816
|
if (index > -1) {
|
|
1812
1817
|
this.comments.splice(index, 1);
|
|
1813
1818
|
}
|
|
1814
1819
|
}
|
|
1815
|
-
if (
|
|
1816
|
-
|
|
1820
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'portal') {
|
|
1821
|
+
rS[13 /* NgtRendererClassId.injectorFactory */] = null;
|
|
1817
1822
|
const index = this.portals.findIndex((portal) => portal === node);
|
|
1818
1823
|
if (index > -1) {
|
|
1819
1824
|
this.portals.splice(index, 1);
|
|
1820
1825
|
}
|
|
1821
1826
|
}
|
|
1822
|
-
if (
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
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;
|
|
1826
1831
|
this.executeOperation(node, 'cleanUp');
|
|
1827
|
-
|
|
1828
|
-
|
|
1832
|
+
rS[7 /* NgtRendererClassId.queueOps */].clear();
|
|
1833
|
+
rS[7 /* NgtRendererClassId.queueOps */] = null;
|
|
1829
1834
|
}
|
|
1830
|
-
if (
|
|
1835
|
+
if (rS[11 /* NgtRendererClassId.ref */]) {
|
|
1831
1836
|
// nullify ref
|
|
1832
|
-
|
|
1833
|
-
|
|
1837
|
+
rS[11 /* NgtRendererClassId.ref */].nativeElement = null;
|
|
1838
|
+
rS[11 /* NgtRendererClassId.ref */] = undefined;
|
|
1834
1839
|
}
|
|
1835
1840
|
// nullify parent
|
|
1836
|
-
|
|
1837
|
-
for (const renderChild of
|
|
1841
|
+
rS[1 /* NgtRendererClassId.parent */] = null;
|
|
1842
|
+
for (const renderChild of rS[2 /* NgtRendererClassId.children */] || []) {
|
|
1838
1843
|
if (renderChild.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three' && parent) {
|
|
1839
1844
|
removeThreeChild(parent, renderChild, true);
|
|
1840
1845
|
}
|
|
1841
1846
|
this.destroy(renderChild, parent);
|
|
1842
1847
|
}
|
|
1843
|
-
|
|
1844
|
-
|
|
1848
|
+
rS[2 /* NgtRendererClassId.children */] = [];
|
|
1849
|
+
rS[3 /* NgtRendererClassId.destroyed */] = true;
|
|
1845
1850
|
if (parent) {
|
|
1846
1851
|
this.removeChild(parent, node);
|
|
1847
1852
|
}
|
|
@@ -1907,34 +1912,21 @@ class NgtRendererFactory {
|
|
|
1907
1912
|
this.document = inject(DOCUMENT);
|
|
1908
1913
|
this.rendererMap = new Map();
|
|
1909
1914
|
this.portals = [];
|
|
1915
|
+
this.rendererStore = new NgtRendererStore({
|
|
1916
|
+
store: this.store,
|
|
1917
|
+
cdr: this.cdr,
|
|
1918
|
+
portals: this.portals,
|
|
1919
|
+
compoundPrefixes: this.compoundPrefixes,
|
|
1920
|
+
document: this.document,
|
|
1921
|
+
});
|
|
1910
1922
|
}
|
|
1911
1923
|
createRenderer(hostElement, type) {
|
|
1912
1924
|
const delegateRenderer = this.delegateRendererFactory.createRenderer(hostElement, type);
|
|
1913
1925
|
if (!type)
|
|
1914
1926
|
return delegateRenderer;
|
|
1915
1927
|
let renderer = this.rendererMap.get(type.id);
|
|
1916
|
-
if (renderer)
|
|
1917
|
-
return renderer;
|
|
1918
|
-
if (!hostElement) {
|
|
1919
|
-
const store = new NgtRendererStore({
|
|
1920
|
-
store: this.store,
|
|
1921
|
-
cdr: this.cdr,
|
|
1922
|
-
portals: this.portals,
|
|
1923
|
-
compoundPrefixes: this.compoundPrefixes,
|
|
1924
|
-
document: this.document,
|
|
1925
|
-
});
|
|
1926
|
-
renderer = new NgtRenderer(delegateRenderer, store, this.catalogue, true);
|
|
1927
|
-
this.rendererMap.set(type.id, renderer);
|
|
1928
|
-
}
|
|
1929
1928
|
if (!renderer) {
|
|
1930
|
-
|
|
1931
|
-
store: this.store,
|
|
1932
|
-
cdr: this.cdr,
|
|
1933
|
-
portals: this.portals,
|
|
1934
|
-
compoundPrefixes: this.compoundPrefixes,
|
|
1935
|
-
document: this.document,
|
|
1936
|
-
});
|
|
1937
|
-
renderer = new NgtRenderer(delegateRenderer, store, this.catalogue);
|
|
1929
|
+
renderer = new NgtRenderer(delegateRenderer, this.rendererStore, this.catalogue, !hostElement);
|
|
1938
1930
|
this.rendererMap.set(type.id, renderer);
|
|
1939
1931
|
}
|
|
1940
1932
|
return renderer;
|
|
@@ -1945,13 +1937,15 @@ NgtRendererFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", v
|
|
|
1945
1937
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtRendererFactory, decorators: [{
|
|
1946
1938
|
type: Injectable
|
|
1947
1939
|
}] });
|
|
1940
|
+
/**
|
|
1941
|
+
* Anything abbreviated with rS/RS stands for RendererState
|
|
1942
|
+
*/
|
|
1948
1943
|
class NgtRenderer {
|
|
1949
|
-
constructor(delegate, store, catalogue, root =
|
|
1944
|
+
constructor(delegate, store, catalogue, root = true) {
|
|
1950
1945
|
this.delegate = delegate;
|
|
1951
1946
|
this.store = store;
|
|
1952
1947
|
this.catalogue = catalogue;
|
|
1953
1948
|
this.root = root;
|
|
1954
|
-
this.first = false;
|
|
1955
1949
|
this.createText = this.delegate.createText.bind(this.delegate);
|
|
1956
1950
|
this.destroy = this.delegate.destroy.bind(this.delegate);
|
|
1957
1951
|
this.destroyNode = null;
|
|
@@ -1967,17 +1961,15 @@ class NgtRenderer {
|
|
|
1967
1961
|
createElement(name, namespace) {
|
|
1968
1962
|
const element = this.delegate.createElement(name, namespace);
|
|
1969
1963
|
// on first pass, we return the Root Scene as the root node
|
|
1970
|
-
if (this.root
|
|
1971
|
-
this.
|
|
1964
|
+
if (this.root) {
|
|
1965
|
+
this.root = false;
|
|
1972
1966
|
const node = this.store.createNode('three', this.store.rootScene);
|
|
1973
1967
|
node.__ngt_renderer__[13 /* NgtRendererClassId.injectorFactory */] = () => getDebugNode(element).injector;
|
|
1974
1968
|
return node;
|
|
1975
1969
|
}
|
|
1976
1970
|
// handle compound
|
|
1977
1971
|
if (this.store.isCompound(name)) {
|
|
1978
|
-
|
|
1979
|
-
compound.__ngt_renderer__[13 /* NgtRendererClassId.injectorFactory */] = () => getDebugNode(element).injector;
|
|
1980
|
-
return compound;
|
|
1972
|
+
return this.store.createNode('compound', element);
|
|
1981
1973
|
}
|
|
1982
1974
|
// handle portal
|
|
1983
1975
|
if (name === SPECIAL_DOM_TAG.NGT_PORTAL) {
|
|
@@ -2018,50 +2010,48 @@ class NgtRenderer {
|
|
|
2018
2010
|
}
|
|
2019
2011
|
return node;
|
|
2020
2012
|
}
|
|
2021
|
-
|
|
2022
|
-
domNode.__ngt_renderer__[13 /* NgtRendererClassId.injectorFactory */] = () => getDebugNode(element).injector;
|
|
2023
|
-
return domNode;
|
|
2013
|
+
return this.store.createNode('dom', element);
|
|
2024
2014
|
}
|
|
2025
2015
|
createComment(value) {
|
|
2026
|
-
|
|
2027
|
-
return this.store.createNode('comment', comment);
|
|
2016
|
+
return this.store.createNode('comment', this.delegate.createComment(value));
|
|
2028
2017
|
}
|
|
2029
2018
|
appendChild(parent, newChild) {
|
|
2030
2019
|
// TODO: just ignore text node for now
|
|
2031
2020
|
if (newChild instanceof Text)
|
|
2032
2021
|
return;
|
|
2033
|
-
|
|
2022
|
+
const cRS = newChild.__ngt_renderer__;
|
|
2023
|
+
const pRS = parent.__ngt_renderer__;
|
|
2024
|
+
if (cRS[0 /* NgtRendererClassId.type */] === 'comment') {
|
|
2034
2025
|
this.store.setParent(newChild, parent);
|
|
2035
2026
|
return;
|
|
2036
2027
|
}
|
|
2037
2028
|
this.store.setParent(newChild, parent);
|
|
2038
2029
|
this.store.addChild(parent, newChild);
|
|
2039
2030
|
// if new child is a portal
|
|
2040
|
-
if (
|
|
2031
|
+
if (cRS[0 /* NgtRendererClassId.type */] === 'portal') {
|
|
2041
2032
|
this.store.processPortalContainer(newChild);
|
|
2042
|
-
if (
|
|
2043
|
-
this.appendChild(parent,
|
|
2033
|
+
if (cRS[12 /* NgtRendererClassId.portalContainer */]) {
|
|
2034
|
+
this.appendChild(parent, cRS[12 /* NgtRendererClassId.portalContainer */]);
|
|
2044
2035
|
}
|
|
2045
2036
|
return;
|
|
2046
2037
|
}
|
|
2047
2038
|
// if parent is a portal
|
|
2048
|
-
if (
|
|
2039
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'portal') {
|
|
2049
2040
|
this.store.processPortalContainer(parent);
|
|
2050
|
-
if (
|
|
2051
|
-
this.appendChild(
|
|
2041
|
+
if (pRS[12 /* NgtRendererClassId.portalContainer */]) {
|
|
2042
|
+
this.appendChild(pRS[12 /* NgtRendererClassId.portalContainer */], newChild);
|
|
2052
2043
|
}
|
|
2053
2044
|
return;
|
|
2054
2045
|
}
|
|
2055
2046
|
// if both are three instances, straightforward case
|
|
2056
|
-
if (
|
|
2057
|
-
newChild.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2047
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'three' && cRS[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2058
2048
|
// if child already attached to a parent, skip
|
|
2059
2049
|
if (getLocalState(newChild).parent)
|
|
2060
2050
|
return;
|
|
2061
2051
|
// attach THREE child
|
|
2062
2052
|
attachThreeChild(parent, newChild);
|
|
2063
2053
|
// here, we handle the special case of if the parent has a compoundParent, which means this child is part of a compound parent template
|
|
2064
|
-
if (!
|
|
2054
|
+
if (!cRS[4 /* NgtRendererClassId.compound */])
|
|
2065
2055
|
return;
|
|
2066
2056
|
const closestGrandparentWithCompound = this.store.getClosestParentWithCompound(parent);
|
|
2067
2057
|
if (!closestGrandparentWithCompound)
|
|
@@ -2070,53 +2060,43 @@ class NgtRenderer {
|
|
|
2070
2060
|
return;
|
|
2071
2061
|
}
|
|
2072
2062
|
// if only the parent is the THREE instance
|
|
2073
|
-
if (
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
this.appendChild(parent, renderChild);
|
|
2077
|
-
}
|
|
2063
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2064
|
+
for (const renderChild of cRS[2 /* NgtRendererClassId.children */]) {
|
|
2065
|
+
this.appendChild(parent, renderChild);
|
|
2078
2066
|
}
|
|
2079
2067
|
}
|
|
2080
2068
|
// if parent is a compound
|
|
2081
|
-
if (
|
|
2069
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'compound') {
|
|
2082
2070
|
// if compound doesn't have a THREE instance set yet
|
|
2083
|
-
if (!
|
|
2084
|
-
newChild.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2071
|
+
if (!pRS[6 /* NgtRendererClassId.compounded */] && cRS[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2085
2072
|
// if child is indeed an ngtCompound
|
|
2086
|
-
if (
|
|
2073
|
+
if (cRS[4 /* NgtRendererClassId.compound */])
|
|
2087
2074
|
this.store.setCompound(parent, newChild);
|
|
2088
|
-
|
|
2089
|
-
else
|
|
2090
|
-
|
|
2091
|
-
if (!newChild.__ngt_renderer__[5 /* NgtRendererClassId.compoundParent */]) {
|
|
2092
|
-
newChild.__ngt_renderer__[5 /* NgtRendererClassId.compoundParent */] = parent;
|
|
2093
|
-
}
|
|
2094
|
-
}
|
|
2075
|
+
// if not, we track the parent (that is supposedly the compound component) on this three instance
|
|
2076
|
+
else if (!cRS[5 /* NgtRendererClassId.compoundParent */])
|
|
2077
|
+
cRS[5 /* NgtRendererClassId.compoundParent */] = parent;
|
|
2095
2078
|
}
|
|
2096
2079
|
// reset the compound if it's changed
|
|
2097
|
-
if (
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2080
|
+
if (pRS[6 /* NgtRendererClassId.compounded */] &&
|
|
2081
|
+
cRS[0 /* NgtRendererClassId.type */] === 'three' &&
|
|
2082
|
+
cRS[4 /* NgtRendererClassId.compound */] &&
|
|
2083
|
+
pRS[6 /* NgtRendererClassId.compounded */] !== newChild) {
|
|
2101
2084
|
this.store.setCompound(parent, newChild);
|
|
2102
2085
|
}
|
|
2103
2086
|
}
|
|
2104
2087
|
const shouldFindGrandparentInstance =
|
|
2105
2088
|
// if child is three but haven't been attached to a parent yet
|
|
2106
|
-
(
|
|
2089
|
+
(cRS[0 /* NgtRendererClassId.type */] === 'three' && !getLocalState(newChild).parent) ||
|
|
2107
2090
|
// or both parent and child are DOM elements
|
|
2108
|
-
((
|
|
2109
|
-
(
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
(newChild.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'compound' &&
|
|
2113
|
-
!newChild.__ngt_renderer__[6 /* NgtRendererClassId.compounded */])));
|
|
2091
|
+
((pRS[0 /* NgtRendererClassId.type */] === 'dom' ||
|
|
2092
|
+
(pRS[0 /* NgtRendererClassId.type */] === 'compound' && !pRS[6 /* NgtRendererClassId.compounded */])) &&
|
|
2093
|
+
(cRS[0 /* NgtRendererClassId.type */] === 'dom' ||
|
|
2094
|
+
(cRS[0 /* NgtRendererClassId.type */] === 'compound' && !cRS[6 /* NgtRendererClassId.compounded */])));
|
|
2114
2095
|
if (shouldFindGrandparentInstance) {
|
|
2115
2096
|
// we'll try to get the grandparent instance here so that we can run appendChild with both instances
|
|
2116
2097
|
const closestGrandparentInstance = this.store.getClosestParentWithInstance(parent);
|
|
2117
|
-
if (closestGrandparentInstance)
|
|
2098
|
+
if (closestGrandparentInstance)
|
|
2118
2099
|
this.appendChild(closestGrandparentInstance, newChild);
|
|
2119
|
-
}
|
|
2120
2100
|
}
|
|
2121
2101
|
}
|
|
2122
2102
|
insertBefore(parent, newChild
|
|
@@ -2129,71 +2109,71 @@ class NgtRenderer {
|
|
|
2129
2109
|
this.appendChild(parent, newChild);
|
|
2130
2110
|
}
|
|
2131
2111
|
removeChild(parent, oldChild, isHostElement) {
|
|
2132
|
-
|
|
2133
|
-
|
|
2112
|
+
const pRS = parent.__ngt_renderer__;
|
|
2113
|
+
const cRS = oldChild.__ngt_renderer__;
|
|
2114
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'three' && cRS[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2134
2115
|
removeThreeChild(parent, oldChild, true);
|
|
2135
2116
|
this.store.destroy(oldChild, parent);
|
|
2136
2117
|
return;
|
|
2137
2118
|
}
|
|
2138
|
-
if (
|
|
2139
|
-
|
|
2140
|
-
this.removeChild(parent.__ngt_renderer__[1 /* NgtRendererClassId.parent */], oldChild, isHostElement);
|
|
2119
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'compound' && pRS[1 /* NgtRendererClassId.parent */]) {
|
|
2120
|
+
this.removeChild(pRS[1 /* NgtRendererClassId.parent */], oldChild, isHostElement);
|
|
2141
2121
|
return;
|
|
2142
2122
|
}
|
|
2143
|
-
if (
|
|
2123
|
+
if (pRS[0 /* NgtRendererClassId.type */] === 'three') {
|
|
2144
2124
|
this.store.destroy(oldChild, parent);
|
|
2145
2125
|
return;
|
|
2146
2126
|
}
|
|
2147
2127
|
const closestGrandparentInstance = this.store.getClosestParentWithInstance(parent);
|
|
2148
|
-
if (closestGrandparentInstance)
|
|
2128
|
+
if (closestGrandparentInstance)
|
|
2149
2129
|
this.removeChild(closestGrandparentInstance, oldChild, isHostElement);
|
|
2150
|
-
}
|
|
2151
2130
|
this.store.destroy(oldChild, closestGrandparentInstance);
|
|
2152
2131
|
}
|
|
2153
2132
|
parentNode(node) {
|
|
2154
|
-
|
|
2155
|
-
if (
|
|
2156
|
-
return
|
|
2133
|
+
const rS = node.__ngt_renderer__;
|
|
2134
|
+
if (rS === null || rS === void 0 ? void 0 : rS[1 /* NgtRendererClassId.parent */])
|
|
2135
|
+
return rS[1 /* NgtRendererClassId.parent */];
|
|
2157
2136
|
return this.delegate.parentNode(node);
|
|
2158
2137
|
}
|
|
2159
2138
|
setAttribute(el, name, value, namespace) {
|
|
2160
|
-
|
|
2139
|
+
const rS = el.__ngt_renderer__;
|
|
2140
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'compound') {
|
|
2161
2141
|
// we don't have the compound instance yet
|
|
2162
|
-
|
|
2163
|
-
if (!
|
|
2142
|
+
rS[8 /* NgtRendererClassId.attributes */][name] = value;
|
|
2143
|
+
if (!rS[6 /* NgtRendererClassId.compounded */]) {
|
|
2164
2144
|
this.store.queueOperation(el, ['op', () => this.setAttribute(el, name, value, namespace)]);
|
|
2165
2145
|
return;
|
|
2166
2146
|
}
|
|
2167
|
-
this.setAttribute(
|
|
2147
|
+
this.setAttribute(rS[6 /* NgtRendererClassId.compounded */], name, value, namespace);
|
|
2168
2148
|
return;
|
|
2169
2149
|
}
|
|
2170
|
-
if (
|
|
2150
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'three')
|
|
2171
2151
|
this.store.applyAttribute(el, name, value);
|
|
2172
|
-
}
|
|
2173
2152
|
}
|
|
2174
2153
|
setProperty(el, name, value) {
|
|
2175
|
-
|
|
2154
|
+
const rS = el.__ngt_renderer__;
|
|
2155
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'compound') {
|
|
2176
2156
|
// we don't have the compound instance yet
|
|
2177
|
-
|
|
2178
|
-
if (!
|
|
2157
|
+
rS[9 /* NgtRendererClassId.properties */][name] = value;
|
|
2158
|
+
if (!rS[6 /* NgtRendererClassId.compounded */]) {
|
|
2179
2159
|
this.store.queueOperation(el, ['op', () => this.setProperty(el, name, value)]);
|
|
2180
2160
|
return;
|
|
2181
2161
|
}
|
|
2182
|
-
if (
|
|
2183
|
-
Object.assign(
|
|
2184
|
-
props: Object.assign(Object.assign({},
|
|
2162
|
+
if (rS[6 /* NgtRendererClassId.compounded */].__ngt_renderer__[4 /* NgtRendererClassId.compound */]) {
|
|
2163
|
+
Object.assign(rS[6 /* NgtRendererClassId.compounded */].__ngt_renderer__[4 /* NgtRendererClassId.compound */], {
|
|
2164
|
+
props: Object.assign(Object.assign({}, rS[6 /* NgtRendererClassId.compounded */].__ngt_renderer__[4 /* NgtRendererClassId.compound */]), { [name]: value }),
|
|
2185
2165
|
});
|
|
2186
2166
|
}
|
|
2187
|
-
this.setProperty(
|
|
2167
|
+
this.setProperty(rS[6 /* NgtRendererClassId.compounded */], name, value);
|
|
2188
2168
|
return;
|
|
2189
2169
|
}
|
|
2190
|
-
if (
|
|
2170
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'three')
|
|
2191
2171
|
this.store.applyProperty(el, name, value);
|
|
2192
|
-
}
|
|
2193
2172
|
}
|
|
2194
2173
|
listen(target, eventName, callback) {
|
|
2195
|
-
var _a
|
|
2196
|
-
const
|
|
2174
|
+
var _a;
|
|
2175
|
+
const rS = target.__ngt_renderer__;
|
|
2176
|
+
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);
|
|
2197
2177
|
// if target is DOM node, then we pass that to delegate Renderer
|
|
2198
2178
|
const callbackWithCdr = (event) => {
|
|
2199
2179
|
const value = callback(event);
|
|
@@ -2217,15 +2197,13 @@ class NgtRenderer {
|
|
|
2217
2197
|
: target['ownerDocument'];
|
|
2218
2198
|
return this.delegate.listen(eventTarget, event, callbackWithCdr);
|
|
2219
2199
|
}
|
|
2220
|
-
if (
|
|
2221
|
-
(
|
|
2222
|
-
|
|
2223
|
-
const instance = target.__ngt_renderer__[6 /* NgtRendererClassId.compounded */] || target;
|
|
2200
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'three' ||
|
|
2201
|
+
(rS[0 /* NgtRendererClassId.type */] === 'compound' && rS[6 /* NgtRendererClassId.compounded */])) {
|
|
2202
|
+
const instance = rS[6 /* NgtRendererClassId.compounded */] || target;
|
|
2224
2203
|
const priority = getLocalState(target).priority;
|
|
2225
2204
|
return processThreeEvent(instance, priority || 0, eventName, callback, this.store.rootCdr, targetCdr);
|
|
2226
2205
|
}
|
|
2227
|
-
if (
|
|
2228
|
-
!target.__ngt_renderer__[6 /* NgtRendererClassId.compounded */]) {
|
|
2206
|
+
if (rS[0 /* NgtRendererClassId.type */] === 'compound' && !rS[6 /* NgtRendererClassId.compounded */]) {
|
|
2229
2207
|
this.store.queueOperation(target, [
|
|
2230
2208
|
'op',
|
|
2231
2209
|
() => this.store.queueOperation(target, ['cleanUp', this.listen(target, eventName, callback)]),
|
|
@@ -2330,6 +2308,7 @@ class NgtCanvas extends NgtRxStore {
|
|
|
2330
2308
|
this.host = inject(ElementRef);
|
|
2331
2309
|
this.store = inject(NgtStore);
|
|
2332
2310
|
this.hostClass = true;
|
|
2311
|
+
this.sceneGraphInputs = {};
|
|
2333
2312
|
this.compoundPrefixes = [];
|
|
2334
2313
|
this.created = new EventEmitter();
|
|
2335
2314
|
this.pointerMissed = new EventEmitter();
|
|
@@ -2394,6 +2373,11 @@ class NgtCanvas extends NgtRxStore {
|
|
|
2394
2373
|
set performance(performance) {
|
|
2395
2374
|
this.set({ performance });
|
|
2396
2375
|
}
|
|
2376
|
+
ngOnChanges(changes) {
|
|
2377
|
+
if (changes['sceneGraphInputs'] && this.glRef) {
|
|
2378
|
+
this.setSceneGraphInputs();
|
|
2379
|
+
}
|
|
2380
|
+
}
|
|
2397
2381
|
ngOnInit() {
|
|
2398
2382
|
if (!this.get('eventSource')) {
|
|
2399
2383
|
// set default event source to the host element
|
|
@@ -2461,6 +2445,7 @@ class NgtCanvas extends NgtRxStore {
|
|
|
2461
2445
|
environmentInjector: this.glEnvInjector,
|
|
2462
2446
|
});
|
|
2463
2447
|
this.glRef.changeDetectorRef.detach();
|
|
2448
|
+
this.setSceneGraphInputs();
|
|
2464
2449
|
// here, we override the detectChanges to also call detectChanges on the ComponentRef
|
|
2465
2450
|
this.overrideDetectChanges();
|
|
2466
2451
|
this.cdr.detectChanges();
|
|
@@ -2482,9 +2467,16 @@ class NgtCanvas extends NgtRxStore {
|
|
|
2482
2467
|
(_a = this.glRef) === null || _a === void 0 ? void 0 : _a.changeDetectorRef.detectChanges();
|
|
2483
2468
|
};
|
|
2484
2469
|
}
|
|
2470
|
+
setSceneGraphInputs() {
|
|
2471
|
+
var _a;
|
|
2472
|
+
for (const key of Object.keys(this.sceneGraphInputs)) {
|
|
2473
|
+
(_a = this.glRef) === null || _a === void 0 ? void 0 : _a.setInput(key, this.sceneGraphInputs[key]);
|
|
2474
|
+
}
|
|
2475
|
+
this.cdr.detectChanges();
|
|
2476
|
+
}
|
|
2485
2477
|
}
|
|
2486
2478
|
NgtCanvas.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtCanvas, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
2487
|
-
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: `
|
|
2479
|
+
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: `
|
|
2488
2480
|
<div (ngxResize)="onResize($event)" style="height: 100%; width: 100%;">
|
|
2489
2481
|
<canvas #glCanvas style="display: block;"></canvas>
|
|
2490
2482
|
</div>
|
|
@@ -2504,6 +2496,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImpor
|
|
|
2504
2496
|
args: ['style.pointerEvents']
|
|
2505
2497
|
}], sceneGraph: [{
|
|
2506
2498
|
type: Input
|
|
2499
|
+
}], sceneGraphInputs: [{
|
|
2500
|
+
type: Input
|
|
2507
2501
|
}], compoundPrefixes: [{
|
|
2508
2502
|
type: Input
|
|
2509
2503
|
}], linear: [{
|