angular-three 1.6.10 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { ElementRef, Injectable, inject, InjectionToken, ViewContainerRef, TemplateRef, Directive, Input, EventEmitter, getDebugNode, RendererFactory2, ChangeDetectorRef, makeEnvironmentProviders, EnvironmentInjector, createEnvironmentInjector, Component, HostBinding, Output, ViewChild, Injector, Pipe, SkipSelf, ContentChild } from '@angular/core';
2
+ import { inject, ChangeDetectorRef, ElementRef, Injectable, InjectionToken, ViewContainerRef, TemplateRef, Directive, Input, EventEmitter, getDebugNode, RendererFactory2, makeEnvironmentProviders, EnvironmentInjector, createEnvironmentInjector, Component, HostBinding, Output, ViewChild, Injector, Pipe, SkipSelf, ContentChild } from '@angular/core';
3
3
  import { provideNgxResizeOptions, NgxResize } from 'ngx-resize';
4
4
  import { isObservable, of, map, from, tap, retry, catchError, share, ReplaySubject, switchMap, forkJoin, take, BehaviorSubject, startWith, combineLatest, distinctUntilChanged, filter, takeUntil, merge } from 'rxjs';
5
5
  import * as THREE from 'three';
@@ -59,6 +59,7 @@ function makeObjectGraph(object) {
59
59
  const cached = new Map();
60
60
  function injectLoader(loaderConstructorFactory, input, extensions, onProgress) {
61
61
  const urls$ = isObservable(input) ? input : of(input);
62
+ const cdr = inject(ChangeDetectorRef);
62
63
  return urls$.pipe(map((inputs) => {
63
64
  const loaderConstructor = loaderConstructorFactory(inputs);
64
65
  const loader = new loaderConstructor();
@@ -91,6 +92,8 @@ function injectLoader(loaderConstructorFactory, input, extensions, onProgress) {
91
92
  result[key] = results[keys.indexOf(key)];
92
93
  return result;
93
94
  }, {});
95
+ }), tap(() => {
96
+ requestAnimationFrame(() => cdr.detectChanges());
94
97
  }));
95
98
  }));
96
99
  }
@@ -1576,10 +1579,15 @@ class NgtRendererStore {
1576
1579
  if (!rendererNode['ownerDocument']) {
1577
1580
  rendererNode['ownerDocument'] = this.root.document;
1578
1581
  }
1579
- if (state[0 /* NgtRendererClassId.type */] === 'comment') {
1582
+ // assign injectorFactory on non-three type since
1583
+ // rendererNode is an instance of DOM Node
1584
+ if (state[0 /* NgtRendererClassId.type */] !== 'three') {
1580
1585
  state[13 /* NgtRendererClassId.injectorFactory */] = () => getDebugNode(rendererNode).injector;
1586
+ }
1587
+ if (state[0 /* NgtRendererClassId.type */] === 'comment') {
1581
1588
  // we attach an arrow function to the Comment node
1582
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
1583
1591
  rendererNode['__ngt_renderer_add_comment__'] = (portalNode) => {
1584
1592
  if (portalNode && portalNode.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'portal') {
1585
1593
  this.portals.push(portalNode);
@@ -1590,10 +1598,6 @@ class NgtRendererStore {
1590
1598
  };
1591
1599
  return rendererNode;
1592
1600
  }
1593
- if (state[0 /* NgtRendererClassId.type */] === 'portal') {
1594
- state[13 /* NgtRendererClassId.injectorFactory */] = () => getDebugNode(rendererNode).injector;
1595
- return rendererNode;
1596
- }
1597
1601
  if (state[0 /* NgtRendererClassId.type */] === 'compound') {
1598
1602
  state[7 /* NgtRendererClassId.queueOps */] = new Set();
1599
1603
  state[8 /* NgtRendererClassId.attributes */] = {};
@@ -1619,17 +1623,18 @@ class NgtRendererStore {
1619
1623
  }
1620
1624
  }
1621
1625
  setCompound(compound, instance) {
1622
- compound.__ngt_renderer__[6 /* NgtRendererClassId.compounded */] = instance;
1623
- const attributes = Object.keys(compound.__ngt_renderer__[8 /* NgtRendererClassId.attributes */]);
1624
- const properties = Object.keys(compound.__ngt_renderer__[9 /* NgtRendererClassId.properties */]);
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 */]);
1625
1630
  if (attributes.length) {
1626
1631
  for (const key of attributes) {
1627
- this.applyAttribute(instance, key, compound.__ngt_renderer__[8 /* NgtRendererClassId.attributes */][key]);
1632
+ this.applyAttribute(instance, key, rS[8 /* NgtRendererClassId.attributes */][key]);
1628
1633
  }
1629
1634
  }
1630
1635
  if (properties.length) {
1631
1636
  for (const key of properties) {
1632
- this.applyProperty(instance, key, compound.__ngt_renderer__[9 /* NgtRendererClassId.properties */][key]);
1637
+ this.applyProperty(instance, key, rS[9 /* NgtRendererClassId.properties */][key]);
1633
1638
  }
1634
1639
  }
1635
1640
  this.executeOperation(compound);
@@ -1638,11 +1643,12 @@ class NgtRendererStore {
1638
1643
  node.__ngt_renderer__[7 /* NgtRendererClassId.queueOps */].add(op);
1639
1644
  }
1640
1645
  executeOperation(node, type = 'op') {
1641
- if (node.__ngt_renderer__[7 /* NgtRendererClassId.queueOps */]?.size) {
1642
- node.__ngt_renderer__[7 /* NgtRendererClassId.queueOps */].forEach((op) => {
1646
+ const rS = node.__ngt_renderer__;
1647
+ if (rS[7 /* NgtRendererClassId.queueOps */]?.size) {
1648
+ rS[7 /* NgtRendererClassId.queueOps */].forEach((op) => {
1643
1649
  if (op[0 /* NgtQueueOpClassId.type */] === type) {
1644
1650
  op[1 /* NgtQueueOpClassId.op */]();
1645
- node.__ngt_renderer__[7 /* NgtRendererClassId.queueOps */].delete(op);
1651
+ rS[7 /* NgtRendererClassId.queueOps */].delete(op);
1646
1652
  }
1647
1653
  });
1648
1654
  }
@@ -1661,7 +1667,8 @@ class NgtRendererStore {
1661
1667
  portal.__ngt_renderer__[12 /* NgtRendererClassId.portalContainer */] = this.createNode('three', portalContainer);
1662
1668
  }
1663
1669
  applyAttribute(node, name, value) {
1664
- if (node.__ngt_renderer__[3 /* NgtRendererClassId.destroyed */])
1670
+ const rS = node.__ngt_renderer__;
1671
+ if (rS[3 /* NgtRendererClassId.destroyed */])
1665
1672
  return;
1666
1673
  if (name === SPECIAL_PROPERTIES.RENDER_PRIORITY) {
1667
1674
  // priority needs to be set as an attribute string so that they can be set as early as possible
@@ -1675,7 +1682,7 @@ class NgtRendererStore {
1675
1682
  }
1676
1683
  if (name === SPECIAL_PROPERTIES.COMPOUND) {
1677
1684
  // we set the compound property on instance node now so we know that this instance is being compounded
1678
- node.__ngt_renderer__[4 /* NgtRendererClassId.compound */] = [value === '' || value === 'first', {}];
1685
+ rS[4 /* NgtRendererClassId.compound */] = [value === '' || value === 'first', {}];
1679
1686
  return;
1680
1687
  }
1681
1688
  if (name === SPECIAL_PROPERTIES.ATTACH) {
@@ -1694,24 +1701,25 @@ class NgtRendererStore {
1694
1701
  else if (!isNaN(Number(maybeCoerced))) {
1695
1702
  maybeCoerced = Number(maybeCoerced);
1696
1703
  }
1697
- node.__ngt_renderer__[10 /* NgtRendererClassId.rawValue */] = maybeCoerced;
1704
+ rS[10 /* NgtRendererClassId.rawValue */] = maybeCoerced;
1698
1705
  return;
1699
1706
  }
1700
1707
  applyProps(node, { [name]: value });
1701
1708
  }
1702
1709
  applyProperty(node, name, value) {
1703
- if (node.__ngt_renderer__[3 /* NgtRendererClassId.destroyed */])
1710
+ const rS = node.__ngt_renderer__;
1711
+ if (rS[3 /* NgtRendererClassId.destroyed */])
1704
1712
  return;
1705
1713
  // [ref]
1706
1714
  if (name === SPECIAL_PROPERTIES.REF && is.ref(value)) {
1707
- node.__ngt_renderer__[11 /* NgtRendererClassId.ref */] = value;
1715
+ rS[11 /* NgtRendererClassId.ref */] = value;
1708
1716
  value.nativeElement = node;
1709
1717
  return;
1710
1718
  }
1711
- const parent = getLocalState(node).parent || node.__ngt_renderer__[1 /* NgtRendererClassId.parent */];
1719
+ const parent = getLocalState(node).parent || rS[1 /* NgtRendererClassId.parent */];
1712
1720
  // [rawValue]
1713
1721
  if (getLocalState(node).isRaw && name === SPECIAL_PROPERTIES.VALUE) {
1714
- node.__ngt_renderer__[10 /* NgtRendererClassId.rawValue */] = value;
1722
+ rS[10 /* NgtRendererClassId.rawValue */] = value;
1715
1723
  if (parent)
1716
1724
  attachThreeChild(parent, node);
1717
1725
  return;
@@ -1723,7 +1731,7 @@ class NgtRendererStore {
1723
1731
  attachThreeChild(parent, node);
1724
1732
  return;
1725
1733
  }
1726
- const compound = node.__ngt_renderer__[4 /* NgtRendererClassId.compound */];
1734
+ const compound = rS[4 /* NgtRendererClassId.compound */];
1727
1735
  if (compound?.[1 /* NgtCompoundClassId.props */] &&
1728
1736
  name in compound[1 /* NgtCompoundClassId.props */] &&
1729
1737
  !compound[0 /* NgtCompoundClassId.applyFirst */]) {
@@ -1735,9 +1743,9 @@ class NgtRendererStore {
1735
1743
  return this.root.compoundPrefixes.some((prefix) => name.startsWith(prefix));
1736
1744
  }
1737
1745
  isDOM(node) {
1738
- const rendererNode = node['__ngt_renderer__'];
1739
- return (!rendererNode ||
1740
- (rendererNode[0 /* NgtRendererClassId.type */] !== 'compound' &&
1746
+ const rS = node['__ngt_renderer__'];
1747
+ return (!rS ||
1748
+ (rS[0 /* NgtRendererClassId.type */] !== 'compound' &&
1741
1749
  (node instanceof Element || node instanceof Document || node instanceof Window)));
1742
1750
  }
1743
1751
  get rootScene() {
@@ -1791,12 +1799,12 @@ class NgtRendererStore {
1791
1799
  return { injectedArgs, store };
1792
1800
  }
1793
1801
  destroy(node, parent) {
1794
- const state = node.__ngt_renderer__;
1795
- if (state[3 /* NgtRendererClassId.destroyed */])
1802
+ const rS = node.__ngt_renderer__;
1803
+ if (rS[3 /* NgtRendererClassId.destroyed */])
1796
1804
  return;
1797
- if (state[0 /* NgtRendererClassId.type */] === 'three') {
1798
- state[4 /* NgtRendererClassId.compound */] = undefined;
1799
- state[5 /* NgtRendererClassId.compoundParent */] = undefined;
1805
+ if (rS[0 /* NgtRendererClassId.type */] === 'three') {
1806
+ rS[4 /* NgtRendererClassId.compound */] = undefined;
1807
+ rS[5 /* NgtRendererClassId.compoundParent */] = undefined;
1800
1808
  const localState = getLocalState(node);
1801
1809
  if (localState.objects) {
1802
1810
  localState.objects.value.forEach((obj) => this.destroy(obj, parent));
@@ -1822,44 +1830,44 @@ class NgtRendererStore {
1822
1830
  delete node['__ngt__'];
1823
1831
  }
1824
1832
  }
1825
- if (state[0 /* NgtRendererClassId.type */] === 'comment') {
1826
- state[13 /* NgtRendererClassId.injectorFactory */] = null;
1833
+ if (rS[0 /* NgtRendererClassId.type */] === 'comment') {
1834
+ rS[13 /* NgtRendererClassId.injectorFactory */] = null;
1827
1835
  delete node['__ngt_renderer_add_comment__'];
1828
1836
  const index = this.comments.findIndex((comment) => comment === node);
1829
1837
  if (index > -1) {
1830
1838
  this.comments.splice(index, 1);
1831
1839
  }
1832
1840
  }
1833
- if (state[0 /* NgtRendererClassId.type */] === 'portal') {
1834
- state[13 /* NgtRendererClassId.injectorFactory */] = null;
1841
+ if (rS[0 /* NgtRendererClassId.type */] === 'portal') {
1842
+ rS[13 /* NgtRendererClassId.injectorFactory */] = null;
1835
1843
  const index = this.portals.findIndex((portal) => portal === node);
1836
1844
  if (index > -1) {
1837
1845
  this.portals.splice(index, 1);
1838
1846
  }
1839
1847
  }
1840
- if (state[0 /* NgtRendererClassId.type */] === 'compound') {
1841
- state[6 /* NgtRendererClassId.compounded */] = undefined;
1842
- state[8 /* NgtRendererClassId.attributes */] = null;
1843
- state[9 /* NgtRendererClassId.properties */] = null;
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;
1844
1852
  this.executeOperation(node, 'cleanUp');
1845
- state[7 /* NgtRendererClassId.queueOps */].clear();
1846
- state[7 /* NgtRendererClassId.queueOps */] = null;
1853
+ rS[7 /* NgtRendererClassId.queueOps */].clear();
1854
+ rS[7 /* NgtRendererClassId.queueOps */] = null;
1847
1855
  }
1848
- if (state[11 /* NgtRendererClassId.ref */]) {
1856
+ if (rS[11 /* NgtRendererClassId.ref */]) {
1849
1857
  // nullify ref
1850
- state[11 /* NgtRendererClassId.ref */].nativeElement = null;
1851
- state[11 /* NgtRendererClassId.ref */] = undefined;
1858
+ rS[11 /* NgtRendererClassId.ref */].nativeElement = null;
1859
+ rS[11 /* NgtRendererClassId.ref */] = undefined;
1852
1860
  }
1853
1861
  // nullify parent
1854
- state[1 /* NgtRendererClassId.parent */] = null;
1855
- for (const renderChild of state[2 /* NgtRendererClassId.children */] || []) {
1862
+ rS[1 /* NgtRendererClassId.parent */] = null;
1863
+ for (const renderChild of rS[2 /* NgtRendererClassId.children */] || []) {
1856
1864
  if (renderChild.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three' && parent) {
1857
1865
  removeThreeChild(parent, renderChild, true);
1858
1866
  }
1859
1867
  this.destroy(renderChild, parent);
1860
1868
  }
1861
- state[2 /* NgtRendererClassId.children */] = [];
1862
- state[3 /* NgtRendererClassId.destroyed */] = true;
1869
+ rS[2 /* NgtRendererClassId.children */] = [];
1870
+ rS[3 /* NgtRendererClassId.destroyed */] = true;
1863
1871
  if (parent) {
1864
1872
  this.removeChild(parent, node);
1865
1873
  }
@@ -1941,7 +1949,7 @@ class NgtRendererFactory {
1941
1949
  compoundPrefixes: this.compoundPrefixes,
1942
1950
  document: this.document,
1943
1951
  });
1944
- renderer = new NgtRenderer(delegateRenderer, store, this.catalogue, true);
1952
+ renderer = new NgtRenderer(delegateRenderer, store, this.catalogue);
1945
1953
  this.rendererMap.set(type.id, renderer);
1946
1954
  }
1947
1955
  if (!renderer) {
@@ -1952,7 +1960,7 @@ class NgtRendererFactory {
1952
1960
  compoundPrefixes: this.compoundPrefixes,
1953
1961
  document: this.document,
1954
1962
  });
1955
- renderer = new NgtRenderer(delegateRenderer, store, this.catalogue);
1963
+ renderer = new NgtRenderer(delegateRenderer, store, this.catalogue, false);
1956
1964
  this.rendererMap.set(type.id, renderer);
1957
1965
  }
1958
1966
  return renderer;
@@ -1963,8 +1971,11 @@ NgtRendererFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", v
1963
1971
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtRendererFactory, decorators: [{
1964
1972
  type: Injectable
1965
1973
  }] });
1974
+ /**
1975
+ * Anything abbreviated with rS/RS stands for RendererState
1976
+ */
1966
1977
  class NgtRenderer {
1967
- constructor(delegate, store, catalogue, root = false) {
1978
+ constructor(delegate, store, catalogue, root = true) {
1968
1979
  this.delegate = delegate;
1969
1980
  this.store = store;
1970
1981
  this.catalogue = catalogue;
@@ -1993,9 +2004,7 @@ class NgtRenderer {
1993
2004
  }
1994
2005
  // handle compound
1995
2006
  if (this.store.isCompound(name)) {
1996
- const compound = this.store.createNode('compound', element);
1997
- compound.__ngt_renderer__[13 /* NgtRendererClassId.injectorFactory */] = () => getDebugNode(element).injector;
1998
- return compound;
2007
+ return this.store.createNode('compound', element);
1999
2008
  }
2000
2009
  // handle portal
2001
2010
  if (name === SPECIAL_DOM_TAG.NGT_PORTAL) {
@@ -2036,50 +2045,48 @@ class NgtRenderer {
2036
2045
  }
2037
2046
  return node;
2038
2047
  }
2039
- const domNode = this.store.createNode('dom', element);
2040
- domNode.__ngt_renderer__[13 /* NgtRendererClassId.injectorFactory */] = () => getDebugNode(element).injector;
2041
- return domNode;
2048
+ return this.store.createNode('dom', element);
2042
2049
  }
2043
2050
  createComment(value) {
2044
- const comment = this.delegate.createComment(value);
2045
- return this.store.createNode('comment', comment);
2051
+ return this.store.createNode('comment', this.delegate.createComment(value));
2046
2052
  }
2047
2053
  appendChild(parent, newChild) {
2048
2054
  // TODO: just ignore text node for now
2049
2055
  if (newChild instanceof Text)
2050
2056
  return;
2051
- if (newChild.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'comment') {
2057
+ const cRS = newChild.__ngt_renderer__;
2058
+ const pRS = parent.__ngt_renderer__;
2059
+ if (cRS[0 /* NgtRendererClassId.type */] === 'comment') {
2052
2060
  this.store.setParent(newChild, parent);
2053
2061
  return;
2054
2062
  }
2055
2063
  this.store.setParent(newChild, parent);
2056
2064
  this.store.addChild(parent, newChild);
2057
2065
  // if new child is a portal
2058
- if (newChild.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'portal') {
2066
+ if (cRS[0 /* NgtRendererClassId.type */] === 'portal') {
2059
2067
  this.store.processPortalContainer(newChild);
2060
- if (newChild.__ngt_renderer__[12 /* NgtRendererClassId.portalContainer */]) {
2061
- this.appendChild(parent, newChild.__ngt_renderer__[12 /* NgtRendererClassId.portalContainer */]);
2068
+ if (cRS[12 /* NgtRendererClassId.portalContainer */]) {
2069
+ this.appendChild(parent, cRS[12 /* NgtRendererClassId.portalContainer */]);
2062
2070
  }
2063
2071
  return;
2064
2072
  }
2065
2073
  // if parent is a portal
2066
- if (parent.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'portal') {
2074
+ if (pRS[0 /* NgtRendererClassId.type */] === 'portal') {
2067
2075
  this.store.processPortalContainer(parent);
2068
- if (parent.__ngt_renderer__[12 /* NgtRendererClassId.portalContainer */]) {
2069
- this.appendChild(parent.__ngt_renderer__[12 /* NgtRendererClassId.portalContainer */], newChild);
2076
+ if (pRS[12 /* NgtRendererClassId.portalContainer */]) {
2077
+ this.appendChild(pRS[12 /* NgtRendererClassId.portalContainer */], newChild);
2070
2078
  }
2071
2079
  return;
2072
2080
  }
2073
2081
  // if both are three instances, straightforward case
2074
- if (parent.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three' &&
2075
- newChild.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three') {
2082
+ if (pRS[0 /* NgtRendererClassId.type */] === 'three' && cRS[0 /* NgtRendererClassId.type */] === 'three') {
2076
2083
  // if child already attached to a parent, skip
2077
2084
  if (getLocalState(newChild).parent)
2078
2085
  return;
2079
2086
  // attach THREE child
2080
2087
  attachThreeChild(parent, newChild);
2081
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
2082
- if (!newChild.__ngt_renderer__[4 /* NgtRendererClassId.compound */])
2089
+ if (!cRS[4 /* NgtRendererClassId.compound */])
2083
2090
  return;
2084
2091
  const closestGrandparentWithCompound = this.store.getClosestParentWithCompound(parent);
2085
2092
  if (!closestGrandparentWithCompound)
@@ -2088,53 +2095,43 @@ class NgtRenderer {
2088
2095
  return;
2089
2096
  }
2090
2097
  // if only the parent is the THREE instance
2091
- if (parent.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three') {
2092
- if (newChild.__ngt_renderer__[2 /* NgtRendererClassId.children */].length) {
2093
- for (const renderChild of newChild.__ngt_renderer__[2 /* NgtRendererClassId.children */]) {
2094
- this.appendChild(parent, renderChild);
2095
- }
2098
+ if (pRS[0 /* NgtRendererClassId.type */] === 'three') {
2099
+ for (const renderChild of cRS[2 /* NgtRendererClassId.children */]) {
2100
+ this.appendChild(parent, renderChild);
2096
2101
  }
2097
2102
  }
2098
2103
  // if parent is a compound
2099
- if (parent.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'compound') {
2104
+ if (pRS[0 /* NgtRendererClassId.type */] === 'compound') {
2100
2105
  // if compound doesn't have a THREE instance set yet
2101
- if (!parent.__ngt_renderer__[6 /* NgtRendererClassId.compounded */] &&
2102
- newChild.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three') {
2106
+ if (!pRS[6 /* NgtRendererClassId.compounded */] && cRS[0 /* NgtRendererClassId.type */] === 'three') {
2103
2107
  // if child is indeed an ngtCompound
2104
- if (newChild.__ngt_renderer__[4 /* NgtRendererClassId.compound */]) {
2108
+ if (cRS[4 /* NgtRendererClassId.compound */])
2105
2109
  this.store.setCompound(parent, newChild);
2106
- }
2107
- else {
2108
- // if not, we track the parent (that is supposedly the compound component) on this three instance
2109
- if (!newChild.__ngt_renderer__[5 /* NgtRendererClassId.compoundParent */]) {
2110
- newChild.__ngt_renderer__[5 /* NgtRendererClassId.compoundParent */] = parent;
2111
- }
2112
- }
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;
2113
2113
  }
2114
2114
  // reset the compound if it's changed
2115
- if (parent.__ngt_renderer__[6 /* NgtRendererClassId.compounded */] &&
2116
- newChild.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three' &&
2117
- newChild.__ngt_renderer__[4 /* NgtRendererClassId.compound */] &&
2118
- parent.__ngt_renderer__[6 /* NgtRendererClassId.compounded */] !== newChild) {
2115
+ if (pRS[6 /* NgtRendererClassId.compounded */] &&
2116
+ cRS[0 /* NgtRendererClassId.type */] === 'three' &&
2117
+ cRS[4 /* NgtRendererClassId.compound */] &&
2118
+ pRS[6 /* NgtRendererClassId.compounded */] !== newChild) {
2119
2119
  this.store.setCompound(parent, newChild);
2120
2120
  }
2121
2121
  }
2122
2122
  const shouldFindGrandparentInstance =
2123
2123
  // if child is three but haven't been attached to a parent yet
2124
- (newChild.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three' && !getLocalState(newChild).parent) ||
2124
+ (cRS[0 /* NgtRendererClassId.type */] === 'three' && !getLocalState(newChild).parent) ||
2125
2125
  // or both parent and child are DOM elements
2126
- ((parent.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'dom' ||
2127
- (parent.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'compound' &&
2128
- !parent.__ngt_renderer__[6 /* NgtRendererClassId.compounded */])) &&
2129
- (newChild.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'dom' ||
2130
- (newChild.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'compound' &&
2131
- !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 */])));
2132
2130
  if (shouldFindGrandparentInstance) {
2133
2131
  // we'll try to get the grandparent instance here so that we can run appendChild with both instances
2134
2132
  const closestGrandparentInstance = this.store.getClosestParentWithInstance(parent);
2135
- if (closestGrandparentInstance) {
2133
+ if (closestGrandparentInstance)
2136
2134
  this.appendChild(closestGrandparentInstance, newChild);
2137
- }
2138
2135
  }
2139
2136
  }
2140
2137
  insertBefore(parent, newChild
@@ -2147,72 +2144,73 @@ class NgtRenderer {
2147
2144
  this.appendChild(parent, newChild);
2148
2145
  }
2149
2146
  removeChild(parent, oldChild, isHostElement) {
2150
- if (parent.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three' &&
2151
- oldChild.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three') {
2147
+ const pRS = parent.__ngt_renderer__;
2148
+ const cRS = oldChild.__ngt_renderer__;
2149
+ if (pRS[0 /* NgtRendererClassId.type */] === 'three' && cRS[0 /* NgtRendererClassId.type */] === 'three') {
2152
2150
  removeThreeChild(parent, oldChild, true);
2153
2151
  this.store.destroy(oldChild, parent);
2154
2152
  return;
2155
2153
  }
2156
- if (parent.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'compound' &&
2157
- parent.__ngt_renderer__[1 /* NgtRendererClassId.parent */]) {
2158
- 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);
2159
2156
  return;
2160
2157
  }
2161
- if (parent.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three') {
2158
+ if (pRS[0 /* NgtRendererClassId.type */] === 'three') {
2162
2159
  this.store.destroy(oldChild, parent);
2163
2160
  return;
2164
2161
  }
2165
2162
  const closestGrandparentInstance = this.store.getClosestParentWithInstance(parent);
2166
- if (closestGrandparentInstance) {
2163
+ if (closestGrandparentInstance)
2167
2164
  this.removeChild(closestGrandparentInstance, oldChild, isHostElement);
2168
- }
2169
2165
  this.store.destroy(oldChild, closestGrandparentInstance);
2170
2166
  }
2171
2167
  parentNode(node) {
2172
- if (node.__ngt_renderer__?.[1 /* NgtRendererClassId.parent */])
2173
- return node.__ngt_renderer__[1 /* NgtRendererClassId.parent */];
2168
+ const rS = node.__ngt_renderer__;
2169
+ if (rS?.[1 /* NgtRendererClassId.parent */])
2170
+ return rS[1 /* NgtRendererClassId.parent */];
2174
2171
  return this.delegate.parentNode(node);
2175
2172
  }
2176
2173
  setAttribute(el, name, value, namespace) {
2177
- if (el.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'compound') {
2174
+ const rS = el.__ngt_renderer__;
2175
+ if (rS[0 /* NgtRendererClassId.type */] === 'compound') {
2178
2176
  // we don't have the compound instance yet
2179
- el.__ngt_renderer__[8 /* NgtRendererClassId.attributes */][name] = value;
2180
- if (!el.__ngt_renderer__[6 /* NgtRendererClassId.compounded */]) {
2177
+ rS[8 /* NgtRendererClassId.attributes */][name] = value;
2178
+ if (!rS[6 /* NgtRendererClassId.compounded */]) {
2181
2179
  this.store.queueOperation(el, ['op', () => this.setAttribute(el, name, value, namespace)]);
2182
2180
  return;
2183
2181
  }
2184
- this.setAttribute(el.__ngt_renderer__[6 /* NgtRendererClassId.compounded */], name, value, namespace);
2182
+ this.setAttribute(rS[6 /* NgtRendererClassId.compounded */], name, value, namespace);
2185
2183
  return;
2186
2184
  }
2187
- if (el.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three') {
2185
+ if (rS[0 /* NgtRendererClassId.type */] === 'three')
2188
2186
  this.store.applyAttribute(el, name, value);
2189
- }
2190
2187
  }
2191
2188
  setProperty(el, name, value) {
2192
- if (el.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'compound') {
2189
+ const rS = el.__ngt_renderer__;
2190
+ if (rS[0 /* NgtRendererClassId.type */] === 'compound') {
2193
2191
  // we don't have the compound instance yet
2194
- el.__ngt_renderer__[9 /* NgtRendererClassId.properties */][name] = value;
2195
- if (!el.__ngt_renderer__[6 /* NgtRendererClassId.compounded */]) {
2192
+ rS[9 /* NgtRendererClassId.properties */][name] = value;
2193
+ if (!rS[6 /* NgtRendererClassId.compounded */]) {
2196
2194
  this.store.queueOperation(el, ['op', () => this.setProperty(el, name, value)]);
2197
2195
  return;
2198
2196
  }
2199
- if (el.__ngt_renderer__[6 /* NgtRendererClassId.compounded */].__ngt_renderer__[4 /* NgtRendererClassId.compound */]) {
2200
- Object.assign(el.__ngt_renderer__[6 /* NgtRendererClassId.compounded */].__ngt_renderer__[4 /* NgtRendererClassId.compound */], {
2197
+ if (rS[6 /* NgtRendererClassId.compounded */].__ngt_renderer__[4 /* NgtRendererClassId.compound */]) {
2198
+ Object.assign(rS[6 /* NgtRendererClassId.compounded */].__ngt_renderer__[4 /* NgtRendererClassId.compound */], {
2201
2199
  props: {
2202
- ...el.__ngt_renderer__[6 /* NgtRendererClassId.compounded */].__ngt_renderer__[4 /* NgtRendererClassId.compound */],
2200
+ ...rS[6 /* NgtRendererClassId.compounded */].__ngt_renderer__[4 /* NgtRendererClassId.compound */],
2203
2201
  [name]: value,
2204
2202
  },
2205
2203
  });
2206
2204
  }
2207
- this.setProperty(el.__ngt_renderer__[6 /* NgtRendererClassId.compounded */], name, value);
2205
+ this.setProperty(rS[6 /* NgtRendererClassId.compounded */], name, value);
2208
2206
  return;
2209
2207
  }
2210
- if (el.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three') {
2208
+ if (rS[0 /* NgtRendererClassId.type */] === 'three')
2211
2209
  this.store.applyProperty(el, name, value);
2212
- }
2213
2210
  }
2214
2211
  listen(target, eventName, callback) {
2215
- const targetCdr = target.__ngt_renderer__?.[13 /* NgtRendererClassId.injectorFactory */]?.().get(ChangeDetectorRef, null);
2212
+ const rS = target.__ngt_renderer__;
2213
+ const targetCdr = rS?.[13 /* NgtRendererClassId.injectorFactory */]?.().get(ChangeDetectorRef, null);
2216
2214
  // if target is DOM node, then we pass that to delegate Renderer
2217
2215
  const callbackWithCdr = (event) => {
2218
2216
  const value = callback(event);
@@ -2236,15 +2234,13 @@ class NgtRenderer {
2236
2234
  : target['ownerDocument'];
2237
2235
  return this.delegate.listen(eventTarget, event, callbackWithCdr);
2238
2236
  }
2239
- if (target.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three' ||
2240
- (target.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'compound' &&
2241
- target.__ngt_renderer__[6 /* NgtRendererClassId.compounded */])) {
2242
- 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;
2243
2240
  const priority = getLocalState(target).priority;
2244
2241
  return processThreeEvent(instance, priority || 0, eventName, callback, this.store.rootCdr, targetCdr);
2245
2242
  }
2246
- if (target.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'compound' &&
2247
- !target.__ngt_renderer__[6 /* NgtRendererClassId.compounded */]) {
2243
+ if (rS[0 /* NgtRendererClassId.type */] === 'compound' && !rS[6 /* NgtRendererClassId.compounded */]) {
2248
2244
  this.store.queueOperation(target, [
2249
2245
  'op',
2250
2246
  () => this.store.queueOperation(target, ['cleanUp', this.listen(target, eventName, callback)]),
@@ -2347,6 +2343,7 @@ class NgtCanvas extends NgtRxStore {
2347
2343
  this.host = inject(ElementRef);
2348
2344
  this.store = inject(NgtStore);
2349
2345
  this.hostClass = true;
2346
+ this.sceneGraphInputs = {};
2350
2347
  this.compoundPrefixes = [];
2351
2348
  this.created = new EventEmitter();
2352
2349
  this.pointerMissed = new EventEmitter();
@@ -2411,6 +2408,11 @@ class NgtCanvas extends NgtRxStore {
2411
2408
  set performance(performance) {
2412
2409
  this.set({ performance });
2413
2410
  }
2411
+ ngOnChanges(changes) {
2412
+ if (changes['sceneGraphInputs'] && this.glRef) {
2413
+ this.setSceneGraphInputs();
2414
+ }
2415
+ }
2414
2416
  ngOnInit() {
2415
2417
  if (!this.get('eventSource')) {
2416
2418
  // set default event source to the host element
@@ -2477,6 +2479,7 @@ class NgtCanvas extends NgtRxStore {
2477
2479
  environmentInjector: this.glEnvInjector,
2478
2480
  });
2479
2481
  this.glRef.changeDetectorRef.detach();
2482
+ this.setSceneGraphInputs();
2480
2483
  // here, we override the detectChanges to also call detectChanges on the ComponentRef
2481
2484
  this.overrideDetectChanges();
2482
2485
  this.cdr.detectChanges();
@@ -2497,9 +2500,15 @@ class NgtCanvas extends NgtRxStore {
2497
2500
  this.glRef?.changeDetectorRef.detectChanges();
2498
2501
  };
2499
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
+ }
2500
2509
  }
2501
2510
  NgtCanvas.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtCanvas, deps: null, target: i0.ɵɵFactoryTarget.Component });
2502
- 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: `
2503
2512
  <div (ngxResize)="onResize($event)" style="height: 100%; width: 100%;">
2504
2513
  <canvas #glCanvas style="display: block;"></canvas>
2505
2514
  </div>
@@ -2519,6 +2528,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImpor
2519
2528
  args: ['style.pointerEvents']
2520
2529
  }], sceneGraph: [{
2521
2530
  type: Input
2531
+ }], sceneGraphInputs: [{
2532
+ type: Input
2522
2533
  }], compoundPrefixes: [{
2523
2534
  type: Input
2524
2535
  }], linear: [{