angular-three 4.0.0-next.11 → 4.0.0-next.12
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.
|
@@ -1733,9 +1733,9 @@ function createEvents(store) {
|
|
|
1733
1733
|
|
|
1734
1734
|
// This function prepares a set of changes to be applied to the instance
|
|
1735
1735
|
function diffProps(instance, props) {
|
|
1736
|
-
const propsEntries = Object.entries(props);
|
|
1737
1736
|
const changes = [];
|
|
1738
|
-
for (const
|
|
1737
|
+
for (const propKey in props) {
|
|
1738
|
+
const propValue = props[propKey];
|
|
1739
1739
|
let key = propKey;
|
|
1740
1740
|
if (is.colorSpaceExist(instance)) {
|
|
1741
1741
|
if (propKey === 'encoding') {
|
|
@@ -1771,6 +1771,19 @@ function getMemoizedPrototype(root) {
|
|
|
1771
1771
|
}
|
|
1772
1772
|
return ctor;
|
|
1773
1773
|
}
|
|
1774
|
+
function resolve(instance, key) {
|
|
1775
|
+
let targetProp = instance[key];
|
|
1776
|
+
if (!key.includes('.'))
|
|
1777
|
+
return { root: instance, targetKey: key, targetProp };
|
|
1778
|
+
// Resolve pierced target
|
|
1779
|
+
const chain = key.split('.');
|
|
1780
|
+
targetProp = chain.reduce((acc, part) => acc[part], instance);
|
|
1781
|
+
const targetKey = chain.pop();
|
|
1782
|
+
// Switch root if atomic
|
|
1783
|
+
if (!targetProp?.set)
|
|
1784
|
+
instance = chain.reduce((acc, part) => acc[part], instance);
|
|
1785
|
+
return { root: instance, targetKey, targetProp };
|
|
1786
|
+
}
|
|
1774
1787
|
// This function applies a set of changes to the instance
|
|
1775
1788
|
function applyProps(instance, props) {
|
|
1776
1789
|
// if props is empty
|
|
@@ -1800,8 +1813,11 @@ function applyProps(instance, props) {
|
|
|
1800
1813
|
// value = value === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace;
|
|
1801
1814
|
// }
|
|
1802
1815
|
// }
|
|
1803
|
-
const
|
|
1804
|
-
|
|
1816
|
+
const { root, targetKey, targetProp } = resolve(instance, key);
|
|
1817
|
+
// we have switched due to pierced props
|
|
1818
|
+
if (root !== instance) {
|
|
1819
|
+
return applyProps(root, { [targetKey]: value });
|
|
1820
|
+
}
|
|
1805
1821
|
// Copy if properties match signatures
|
|
1806
1822
|
if (targetProp?.copy &&
|
|
1807
1823
|
value?.constructor &&
|
|
@@ -1809,15 +1825,15 @@ function applyProps(instance, props) {
|
|
|
1809
1825
|
// If both are geometries, we should assign the value directly instead of copying
|
|
1810
1826
|
if (is.three(targetProp, 'isBufferGeometry') &&
|
|
1811
1827
|
is.three(value, 'isBufferGeometry')) {
|
|
1812
|
-
Object.assign(
|
|
1828
|
+
Object.assign(root, { [targetKey]: value });
|
|
1813
1829
|
}
|
|
1814
1830
|
else {
|
|
1815
1831
|
// fetch the default state of the target
|
|
1816
|
-
const ctor = getMemoizedPrototype(
|
|
1832
|
+
const ctor = getMemoizedPrototype(root);
|
|
1817
1833
|
// The target key was originally null or undefined, which indicates that the object which
|
|
1818
1834
|
// is now present was externally set by the user, we should therefore assign the value directly
|
|
1819
|
-
if (ctor !== undefined && ctor[
|
|
1820
|
-
Object.assign(
|
|
1835
|
+
if (ctor !== undefined && ctor[targetKey] == null)
|
|
1836
|
+
Object.assign(root, { [targetKey]: value });
|
|
1821
1837
|
// Otherwise copy is correct
|
|
1822
1838
|
else
|
|
1823
1839
|
targetProp.copy(value);
|
|
@@ -1846,22 +1862,22 @@ function applyProps(instance, props) {
|
|
|
1846
1862
|
}
|
|
1847
1863
|
// Else, just overwrite the value
|
|
1848
1864
|
else {
|
|
1849
|
-
Object.assign(
|
|
1865
|
+
Object.assign(root, { [targetKey]: value });
|
|
1850
1866
|
// Auto-convert sRGB texture parameters for built-in materials
|
|
1851
1867
|
// https://github.com/pmndrs/react-three-fiber/issues/344
|
|
1852
1868
|
// https://github.com/mrdoob/three.js/pull/25857
|
|
1853
1869
|
if (rootState &&
|
|
1854
1870
|
!rootState.linear &&
|
|
1855
|
-
colorMaps.includes(
|
|
1856
|
-
|
|
1871
|
+
colorMaps.includes(targetKey) &&
|
|
1872
|
+
root[targetKey]?.isTexture &&
|
|
1857
1873
|
// sRGB textures must be RGBA8 since r137 https://github.com/mrdoob/three.js/pull/23129
|
|
1858
|
-
|
|
1859
|
-
|
|
1874
|
+
root[targetKey].format === THREE.RGBAFormat &&
|
|
1875
|
+
root[targetKey].type === THREE.UnsignedByteType) {
|
|
1860
1876
|
// NOTE: this cannot be set from the renderer (e.g. sRGB source textures rendered to P3)
|
|
1861
|
-
|
|
1877
|
+
root[targetKey].colorSpace = THREE.SRGBColorSpace;
|
|
1862
1878
|
}
|
|
1863
1879
|
}
|
|
1864
|
-
checkUpdate(
|
|
1880
|
+
checkUpdate(root[targetKey]);
|
|
1865
1881
|
checkUpdate(targetProp);
|
|
1866
1882
|
invalidateInstance(instance);
|
|
1867
1883
|
}
|
|
@@ -2522,24 +2538,23 @@ class NgtRenderer2 {
|
|
|
2522
2538
|
if (instanceState)
|
|
2523
2539
|
instanceState.attach = paths;
|
|
2524
2540
|
}
|
|
2541
|
+
return;
|
|
2542
|
+
}
|
|
2543
|
+
// coercion for primitive values
|
|
2544
|
+
let maybeCoerced = value;
|
|
2545
|
+
if (maybeCoerced === '' || maybeCoerced === 'true' || maybeCoerced === 'false') {
|
|
2546
|
+
maybeCoerced = maybeCoerced === 'true' || maybeCoerced === '';
|
|
2525
2547
|
}
|
|
2526
2548
|
else {
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
}
|
|
2537
|
-
if (name === 'rawValue') {
|
|
2538
|
-
rS[2 /* NgtRendererClassId.rawValue */] = maybeCoerced;
|
|
2539
|
-
}
|
|
2540
|
-
else {
|
|
2541
|
-
applyProps(el, { [name]: maybeCoerced });
|
|
2542
|
-
}
|
|
2549
|
+
const maybeNumber = Number(maybeCoerced);
|
|
2550
|
+
if (!isNaN(maybeNumber))
|
|
2551
|
+
maybeCoerced = maybeNumber;
|
|
2552
|
+
}
|
|
2553
|
+
if (name === 'rawValue') {
|
|
2554
|
+
rS[2 /* NgtRendererClassId.rawValue */] = maybeCoerced;
|
|
2555
|
+
}
|
|
2556
|
+
else {
|
|
2557
|
+
applyProps(el, { [name]: maybeCoerced });
|
|
2543
2558
|
}
|
|
2544
2559
|
return;
|
|
2545
2560
|
}
|