@react-three/fiber 10.0.0-canary.4f316e6 → 10.0.0-canary.4f9f64c
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/dist/index.cjs +35 -40
- package/dist/index.d.cts +155 -164
- package/dist/index.d.mts +155 -164
- package/dist/index.d.ts +155 -192
- package/dist/index.mjs +35 -40
- package/dist/legacy.cjs +37 -42
- package/dist/legacy.d.cts +159 -168
- package/dist/legacy.d.mts +159 -168
- package/dist/legacy.d.ts +159 -194
- package/dist/legacy.mjs +37 -42
- package/dist/webgpu/index.cjs +91 -97
- package/dist/webgpu/index.d.cts +214 -214
- package/dist/webgpu/index.d.mts +214 -214
- package/dist/webgpu/index.d.ts +214 -242
- package/dist/webgpu/index.mjs +91 -97
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -11,6 +11,7 @@ const scheduler = require('@pmndrs/scheduler');
|
|
|
11
11
|
const Tb = require('scheduler');
|
|
12
12
|
const GroundedSkybox_js = require('three/examples/jsm/objects/GroundedSkybox.js');
|
|
13
13
|
const HDRLoader_js = require('three/examples/jsm/loaders/HDRLoader.js');
|
|
14
|
+
const HDRCubeTextureLoader_js = require('three/examples/jsm/loaders/HDRCubeTextureLoader.js');
|
|
14
15
|
const EXRLoader_js = require('three/examples/jsm/loaders/EXRLoader.js');
|
|
15
16
|
const UltraHDRLoader_js = require('three/examples/jsm/loaders/UltraHDRLoader.js');
|
|
16
17
|
const gainmapJs = require('@monogrid/gainmap-js');
|
|
@@ -529,8 +530,10 @@ function hasVisibilityHandlers(handlers) {
|
|
|
529
530
|
}
|
|
530
531
|
|
|
531
532
|
const FROM_REF = Symbol.for("@react-three/fiber.fromRef");
|
|
532
|
-
function fromRef(ref) {
|
|
533
|
-
|
|
533
|
+
function fromRef(ref, transform) {
|
|
534
|
+
const marker = { [FROM_REF]: ref };
|
|
535
|
+
if (transform) marker.transform = transform;
|
|
536
|
+
return marker;
|
|
534
537
|
}
|
|
535
538
|
function isFromRef(value) {
|
|
536
539
|
return value !== null && typeof value === "object" && FROM_REF in value;
|
|
@@ -622,12 +625,7 @@ function diffProps(instance, newProps) {
|
|
|
622
625
|
const changedProps = {};
|
|
623
626
|
for (const prop in newProps) {
|
|
624
627
|
if (RESERVED_PROPS.includes(prop)) continue;
|
|
625
|
-
if (is.equ(newProps[prop], instance.props[prop]))
|
|
626
|
-
const value = newProps[prop];
|
|
627
|
-
if (!isCopyable(value)) continue;
|
|
628
|
-
const { target } = resolve(instance.object, prop);
|
|
629
|
-
if (!isCopyable(target) || target.constructor !== value.constructor) continue;
|
|
630
|
-
}
|
|
628
|
+
if (is.equ(newProps[prop], instance.props[prop])) continue;
|
|
631
629
|
changedProps[prop] = newProps[prop];
|
|
632
630
|
for (const other in newProps) {
|
|
633
631
|
if (other.startsWith(`${prop}-`)) changedProps[other] = newProps[other];
|
|
@@ -636,11 +634,9 @@ function diffProps(instance, newProps) {
|
|
|
636
634
|
for (const prop in instance.props) {
|
|
637
635
|
if (RESERVED_PROPS.includes(prop) || newProps.hasOwnProperty(prop)) continue;
|
|
638
636
|
const { root, key } = resolve(instance.object, prop);
|
|
639
|
-
if (
|
|
637
|
+
if (typeof root?.constructor === "function") {
|
|
640
638
|
const ctor = getMemoizedPrototype(root);
|
|
641
639
|
if (!is.und(ctor)) changedProps[prop] = ctor[key];
|
|
642
|
-
} else {
|
|
643
|
-
changedProps[prop] = 0;
|
|
644
640
|
}
|
|
645
641
|
}
|
|
646
642
|
return changedProps;
|
|
@@ -1363,12 +1359,24 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
1363
1359
|
webgpu.TextureLoader,
|
|
1364
1360
|
IsObject(stableInput) ? Object.values(stableInput) : stableInput
|
|
1365
1361
|
);
|
|
1362
|
+
const mappedTextures = React.useMemo(() => {
|
|
1363
|
+
if (cachedResult) return cachedResult;
|
|
1364
|
+
if (IsObject(stableInput)) {
|
|
1365
|
+
const keyed = {};
|
|
1366
|
+
const textureArray = loadedTextures;
|
|
1367
|
+
let i = 0;
|
|
1368
|
+
for (const key in stableInput) keyed[key] = textureArray[i++];
|
|
1369
|
+
return keyed;
|
|
1370
|
+
} else {
|
|
1371
|
+
return loadedTextures;
|
|
1372
|
+
}
|
|
1373
|
+
}, [stableInput, loadedTextures, cachedResult]);
|
|
1366
1374
|
React.useLayoutEffect(() => {
|
|
1367
1375
|
if (cachedResult) return;
|
|
1368
1376
|
if (onLoadCalledForRef.current === inputKey) return;
|
|
1369
1377
|
onLoadCalledForRef.current = inputKey;
|
|
1370
|
-
onLoadRef.current?.(
|
|
1371
|
-
}, [cachedResult,
|
|
1378
|
+
onLoadRef.current?.(mappedTextures);
|
|
1379
|
+
}, [cachedResult, mappedTextures, inputKey]);
|
|
1372
1380
|
React.useEffect(() => {
|
|
1373
1381
|
if (cachedResult) return;
|
|
1374
1382
|
if ("initTexture" in renderer) {
|
|
@@ -1387,18 +1395,6 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
1387
1395
|
});
|
|
1388
1396
|
}
|
|
1389
1397
|
}, [renderer, loadedTextures, cachedResult]);
|
|
1390
|
-
const mappedTextures = React.useMemo(() => {
|
|
1391
|
-
if (cachedResult) return cachedResult;
|
|
1392
|
-
if (IsObject(stableInput)) {
|
|
1393
|
-
const keyed = {};
|
|
1394
|
-
const textureArray = loadedTextures;
|
|
1395
|
-
let i = 0;
|
|
1396
|
-
for (const key in stableInput) keyed[key] = textureArray[i++];
|
|
1397
|
-
return keyed;
|
|
1398
|
-
} else {
|
|
1399
|
-
return loadedTextures;
|
|
1400
|
-
}
|
|
1401
|
-
}, [stableInput, loadedTextures, cachedResult]);
|
|
1402
1398
|
React.useEffect(() => {
|
|
1403
1399
|
if (!cache) return;
|
|
1404
1400
|
const urlTextureMap = [];
|
|
@@ -1602,7 +1598,7 @@ function useEnvironment({
|
|
|
1602
1598
|
texture = texture.renderTarget?.texture;
|
|
1603
1599
|
}
|
|
1604
1600
|
texture.mapping = isCubemap ? webgpu.CubeReflectionMapping : webgpu.EquirectangularReflectionMapping;
|
|
1605
|
-
texture.colorSpace = colorSpace ?? (isCubemap ? "srgb" : "srgb-linear");
|
|
1601
|
+
texture.colorSpace = colorSpace ?? (isCubemap && extension !== "hdr-cube" ? "srgb" : "srgb-linear");
|
|
1606
1602
|
return texture;
|
|
1607
1603
|
}
|
|
1608
1604
|
const preloadDefaultOptions = {
|
|
@@ -1655,11 +1651,12 @@ function getExtension(files) {
|
|
|
1655
1651
|
const isCubemap = isArray(files) && files.length === 6;
|
|
1656
1652
|
const isGainmap = isArray(files) && files.length === 3 && files.some((file) => file.endsWith("json"));
|
|
1657
1653
|
const firstEntry = isArray(files) ? files[0] : files;
|
|
1658
|
-
const
|
|
1654
|
+
const firstExtension = firstEntry.split(".").pop()?.split("?")?.shift()?.toLowerCase();
|
|
1655
|
+
const extension = isCubemap ? firstExtension === "hdr" ? "hdr-cube" : "cube" : isGainmap ? "webp" : firstEntry.startsWith("data:application/exr") ? "exr" : firstEntry.startsWith("data:application/hdr") ? "hdr" : firstEntry.startsWith("data:image/jpeg") ? "jpg" : firstExtension;
|
|
1659
1656
|
return { extension, isCubemap, isGainmap };
|
|
1660
1657
|
}
|
|
1661
1658
|
function getLoader(extension) {
|
|
1662
|
-
const loader = extension === "cube" ? webgpu.CubeTextureLoader : extension === "hdr" ? HDRLoader_js.HDRLoader : extension === "exr" ? EXRLoader_js.EXRLoader : extension === "jpg" || extension === "jpeg" ? UltraHDRLoader_js.UltraHDRLoader : extension === "webp" ? gainmapJs.GainMapLoader : null;
|
|
1659
|
+
const loader = extension === "cube" ? webgpu.CubeTextureLoader : extension === "hdr-cube" ? HDRCubeTextureLoader_js.HDRCubeTextureLoader : extension === "hdr" ? HDRLoader_js.HDRLoader : extension === "exr" ? EXRLoader_js.EXRLoader : extension === "jpg" || extension === "jpeg" ? UltraHDRLoader_js.UltraHDRLoader : extension === "webp" ? gainmapJs.GainMapLoader : null;
|
|
1663
1660
|
return loader;
|
|
1664
1661
|
}
|
|
1665
1662
|
|
|
@@ -1722,7 +1719,7 @@ function advance(timestamp, runGlobalEffects, state) {
|
|
|
1722
1719
|
else scheduler$1.step(timestamp);
|
|
1723
1720
|
}
|
|
1724
1721
|
|
|
1725
|
-
const version = "10.0.0-alpha.
|
|
1722
|
+
const version = "10.0.0-alpha.5";
|
|
1726
1723
|
const packageData = {
|
|
1727
1724
|
version: version};
|
|
1728
1725
|
|
|
@@ -13581,7 +13578,10 @@ function extend(objects) {
|
|
|
13581
13578
|
catalogue[Component] = objects;
|
|
13582
13579
|
return Component;
|
|
13583
13580
|
} else {
|
|
13584
|
-
|
|
13581
|
+
for (const name in objects) {
|
|
13582
|
+
const object = objects[name];
|
|
13583
|
+
if (isConstructor(object)) catalogue[name] = object;
|
|
13584
|
+
}
|
|
13585
13585
|
}
|
|
13586
13586
|
}
|
|
13587
13587
|
function validateInstance(type, props) {
|
|
@@ -13929,7 +13929,7 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13929
13929
|
getRootHostContext: () => NO_CONTEXT,
|
|
13930
13930
|
getChildHostContext: () => NO_CONTEXT,
|
|
13931
13931
|
commitUpdate(instance, type, oldProps, newProps, fiber) {
|
|
13932
|
-
validateInstance(type, newProps);
|
|
13932
|
+
validateInstance(instance.type, newProps);
|
|
13933
13933
|
let reconstruct = false;
|
|
13934
13934
|
if (instance.type === "primitive" && oldProps.object !== newProps.object) reconstruct = true;
|
|
13935
13935
|
else if (newProps.args?.length !== oldProps.args?.length) reconstruct = true;
|
|
@@ -13956,8 +13956,8 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13956
13956
|
for (const prop in instance.props) {
|
|
13957
13957
|
const value = instance.props[prop];
|
|
13958
13958
|
if (isFromRef(value)) {
|
|
13959
|
-
const ref = value
|
|
13960
|
-
if (ref.current != null) resolved[prop] = ref.current;
|
|
13959
|
+
const { [FROM_REF]: ref, transform } = value;
|
|
13960
|
+
if (ref.current != null) resolved[prop] = transform ? transform(ref.current) : ref.current;
|
|
13961
13961
|
}
|
|
13962
13962
|
}
|
|
13963
13963
|
if (Object.keys(resolved).length) applyProps(instance.object, resolved);
|
|
@@ -14787,16 +14787,11 @@ function setEnvProps(background, scene, defaultScene, texture, sceneProps = {})
|
|
|
14787
14787
|
const oldbg = target.background;
|
|
14788
14788
|
const oldenv = target.environment;
|
|
14789
14789
|
const oldSceneProps = {
|
|
14790
|
-
// @ts-ignore
|
|
14791
14790
|
backgroundBlurriness: target.backgroundBlurriness,
|
|
14792
|
-
// @ts-ignore
|
|
14793
14791
|
backgroundIntensity: target.backgroundIntensity,
|
|
14794
|
-
|
|
14795
|
-
backgroundRotation: target.backgroundRotation?.clone?.() ?? [0, 0, 0],
|
|
14796
|
-
// @ts-ignore
|
|
14792
|
+
backgroundRotation: target.backgroundRotation.clone(),
|
|
14797
14793
|
environmentIntensity: target.environmentIntensity,
|
|
14798
|
-
|
|
14799
|
-
environmentRotation: target.environmentRotation?.clone?.() ?? [0, 0, 0]
|
|
14794
|
+
environmentRotation: target.environmentRotation.clone()
|
|
14800
14795
|
};
|
|
14801
14796
|
if (background !== "only") target.environment = texture;
|
|
14802
14797
|
if (background) target.background = texture;
|