@react-three/fiber 10.0.0-canary.ce4bd5f → 10.0.0-canary.d91831d
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 +43 -42
- package/dist/index.d.cts +249 -138
- package/dist/index.d.mts +249 -138
- package/dist/index.d.ts +249 -166
- package/dist/index.mjs +43 -42
- package/dist/legacy.cjs +42 -40
- package/dist/legacy.d.cts +253 -142
- package/dist/legacy.d.mts +253 -142
- package/dist/legacy.d.ts +253 -168
- package/dist/legacy.mjs +42 -40
- package/dist/webgpu/index.cjs +113 -112
- package/dist/webgpu/index.d.cts +309 -201
- package/dist/webgpu/index.d.mts +309 -201
- package/dist/webgpu/index.d.ts +309 -229
- package/dist/webgpu/index.mjs +113 -112
- 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;
|
|
@@ -631,11 +634,9 @@ function diffProps(instance, newProps) {
|
|
|
631
634
|
for (const prop in instance.props) {
|
|
632
635
|
if (RESERVED_PROPS.includes(prop) || newProps.hasOwnProperty(prop)) continue;
|
|
633
636
|
const { root, key } = resolve(instance.object, prop);
|
|
634
|
-
if (
|
|
637
|
+
if (typeof root?.constructor === "function") {
|
|
635
638
|
const ctor = getMemoizedPrototype(root);
|
|
636
639
|
if (!is.und(ctor)) changedProps[prop] = ctor[key];
|
|
637
|
-
} else {
|
|
638
|
-
changedProps[prop] = 0;
|
|
639
640
|
}
|
|
640
641
|
}
|
|
641
642
|
return changedProps;
|
|
@@ -1068,7 +1069,8 @@ const createStore = (invalidate, advance) => {
|
|
|
1068
1069
|
const resizeTarget = canvasTarget ?? actualRenderer;
|
|
1069
1070
|
if (viewport.dpr > 0) resizeTarget.setPixelRatio(viewport.dpr);
|
|
1070
1071
|
resizeTarget.setSize(size.width, size.height, false);
|
|
1071
|
-
|
|
1072
|
+
const activeTarget = actualRenderer.getCanvasTarget?.();
|
|
1073
|
+
if (!canvasTarget || activeTarget !== canvasTarget) internal.canvasTargetSizeDirty = true;
|
|
1072
1074
|
}
|
|
1073
1075
|
if (camera !== oldCamera) {
|
|
1074
1076
|
oldCamera = camera;
|
|
@@ -1357,12 +1359,24 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
1357
1359
|
webgpu.TextureLoader,
|
|
1358
1360
|
IsObject(stableInput) ? Object.values(stableInput) : stableInput
|
|
1359
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]);
|
|
1360
1374
|
React.useLayoutEffect(() => {
|
|
1361
1375
|
if (cachedResult) return;
|
|
1362
1376
|
if (onLoadCalledForRef.current === inputKey) return;
|
|
1363
1377
|
onLoadCalledForRef.current = inputKey;
|
|
1364
|
-
onLoadRef.current?.(
|
|
1365
|
-
}, [cachedResult,
|
|
1378
|
+
onLoadRef.current?.(mappedTextures);
|
|
1379
|
+
}, [cachedResult, mappedTextures, inputKey]);
|
|
1366
1380
|
React.useEffect(() => {
|
|
1367
1381
|
if (cachedResult) return;
|
|
1368
1382
|
if ("initTexture" in renderer) {
|
|
@@ -1381,18 +1395,6 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
1381
1395
|
});
|
|
1382
1396
|
}
|
|
1383
1397
|
}, [renderer, loadedTextures, cachedResult]);
|
|
1384
|
-
const mappedTextures = React.useMemo(() => {
|
|
1385
|
-
if (cachedResult) return cachedResult;
|
|
1386
|
-
if (IsObject(stableInput)) {
|
|
1387
|
-
const keyed = {};
|
|
1388
|
-
const textureArray = loadedTextures;
|
|
1389
|
-
let i = 0;
|
|
1390
|
-
for (const key in stableInput) keyed[key] = textureArray[i++];
|
|
1391
|
-
return keyed;
|
|
1392
|
-
} else {
|
|
1393
|
-
return loadedTextures;
|
|
1394
|
-
}
|
|
1395
|
-
}, [stableInput, loadedTextures, cachedResult]);
|
|
1396
1398
|
React.useEffect(() => {
|
|
1397
1399
|
if (!cache) return;
|
|
1398
1400
|
const urlTextureMap = [];
|
|
@@ -1596,7 +1598,7 @@ function useEnvironment({
|
|
|
1596
1598
|
texture = texture.renderTarget?.texture;
|
|
1597
1599
|
}
|
|
1598
1600
|
texture.mapping = isCubemap ? webgpu.CubeReflectionMapping : webgpu.EquirectangularReflectionMapping;
|
|
1599
|
-
texture.colorSpace = colorSpace ?? (isCubemap ? "srgb" : "srgb-linear");
|
|
1601
|
+
texture.colorSpace = colorSpace ?? (isCubemap && extension !== "hdr-cube" ? "srgb" : "srgb-linear");
|
|
1600
1602
|
return texture;
|
|
1601
1603
|
}
|
|
1602
1604
|
const preloadDefaultOptions = {
|
|
@@ -1649,11 +1651,12 @@ function getExtension(files) {
|
|
|
1649
1651
|
const isCubemap = isArray(files) && files.length === 6;
|
|
1650
1652
|
const isGainmap = isArray(files) && files.length === 3 && files.some((file) => file.endsWith("json"));
|
|
1651
1653
|
const firstEntry = isArray(files) ? files[0] : files;
|
|
1652
|
-
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;
|
|
1653
1656
|
return { extension, isCubemap, isGainmap };
|
|
1654
1657
|
}
|
|
1655
1658
|
function getLoader(extension) {
|
|
1656
|
-
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;
|
|
1657
1660
|
return loader;
|
|
1658
1661
|
}
|
|
1659
1662
|
|
|
@@ -1716,7 +1719,7 @@ function advance(timestamp, runGlobalEffects, state) {
|
|
|
1716
1719
|
else scheduler$1.step(timestamp);
|
|
1717
1720
|
}
|
|
1718
1721
|
|
|
1719
|
-
const version = "10.0.0-alpha.
|
|
1722
|
+
const version = "10.0.0-alpha.5";
|
|
1720
1723
|
const packageData = {
|
|
1721
1724
|
version: version};
|
|
1722
1725
|
|
|
@@ -13575,7 +13578,10 @@ function extend(objects) {
|
|
|
13575
13578
|
catalogue[Component] = objects;
|
|
13576
13579
|
return Component;
|
|
13577
13580
|
} else {
|
|
13578
|
-
|
|
13581
|
+
for (const name in objects) {
|
|
13582
|
+
const object = objects[name];
|
|
13583
|
+
if (isConstructor(object)) catalogue[name] = object;
|
|
13584
|
+
}
|
|
13579
13585
|
}
|
|
13580
13586
|
}
|
|
13581
13587
|
function validateInstance(type, props) {
|
|
@@ -13923,7 +13929,7 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13923
13929
|
getRootHostContext: () => NO_CONTEXT,
|
|
13924
13930
|
getChildHostContext: () => NO_CONTEXT,
|
|
13925
13931
|
commitUpdate(instance, type, oldProps, newProps, fiber) {
|
|
13926
|
-
validateInstance(type, newProps);
|
|
13932
|
+
validateInstance(instance.type, newProps);
|
|
13927
13933
|
let reconstruct = false;
|
|
13928
13934
|
if (instance.type === "primitive" && oldProps.object !== newProps.object) reconstruct = true;
|
|
13929
13935
|
else if (newProps.args?.length !== oldProps.args?.length) reconstruct = true;
|
|
@@ -13950,8 +13956,8 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13950
13956
|
for (const prop in instance.props) {
|
|
13951
13957
|
const value = instance.props[prop];
|
|
13952
13958
|
if (isFromRef(value)) {
|
|
13953
|
-
const ref = value
|
|
13954
|
-
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;
|
|
13955
13961
|
}
|
|
13956
13962
|
}
|
|
13957
13963
|
if (Object.keys(resolved).length) applyProps(instance.object, resolved);
|
|
@@ -14250,9 +14256,8 @@ function createRoot(canvas) {
|
|
|
14250
14256
|
if (!renderer.hasInitialized?.()) {
|
|
14251
14257
|
const size2 = computeInitialSize(canvas, propsSize);
|
|
14252
14258
|
if (size2.width > 0 && size2.height > 0) {
|
|
14253
|
-
|
|
14254
|
-
|
|
14255
|
-
canvas.height = size2.height * pixelRatio;
|
|
14259
|
+
renderer.setPixelRatio(calculateDpr(dpr));
|
|
14260
|
+
renderer.setSize(size2.width, size2.height, false);
|
|
14256
14261
|
}
|
|
14257
14262
|
await renderer.init();
|
|
14258
14263
|
}
|
|
@@ -14261,7 +14266,7 @@ function createRoot(canvas) {
|
|
|
14261
14266
|
state.internal.actualRenderer = renderer;
|
|
14262
14267
|
state.set({ webGPUSupported: isWebGPUBackend, renderer, primaryStore: store });
|
|
14263
14268
|
if (canvasId && !state.internal.isSecondary) {
|
|
14264
|
-
const canvasTarget =
|
|
14269
|
+
const canvasTarget = renderer.getCanvasTarget?.();
|
|
14265
14270
|
const unregisterPrimary = registerPrimary(canvasId, renderer, store);
|
|
14266
14271
|
state.set((prev) => ({
|
|
14267
14272
|
internal: {
|
|
@@ -14474,9 +14479,10 @@ function createRoot(canvas) {
|
|
|
14474
14479
|
const unregisterCanvasTarget = scheduler$1.register(
|
|
14475
14480
|
() => {
|
|
14476
14481
|
const state2 = store.getState();
|
|
14477
|
-
|
|
14482
|
+
const canvasTarget = state2.internal.canvasTarget;
|
|
14483
|
+
if (canvasTarget) {
|
|
14478
14484
|
const renderer2 = state2.internal.actualRenderer;
|
|
14479
|
-
renderer2.setCanvasTarget(
|
|
14485
|
+
if (renderer2.getCanvasTarget() !== canvasTarget) renderer2.setCanvasTarget(canvasTarget);
|
|
14480
14486
|
if (state2.internal.canvasTargetSizeDirty) {
|
|
14481
14487
|
state2.internal.canvasTargetSizeDirty = false;
|
|
14482
14488
|
renderer2.backend?.updateSize?.();
|
|
@@ -14640,7 +14646,7 @@ function unmountComponentAtNode(canvas, callback) {
|
|
|
14640
14646
|
const unregisterPrimary = state.internal.unregisterPrimary;
|
|
14641
14647
|
if (unregisterPrimary) unregisterPrimary();
|
|
14642
14648
|
const canvasTarget = state.internal.canvasTarget;
|
|
14643
|
-
if (canvasTarget?.dispose) canvasTarget.dispose();
|
|
14649
|
+
if (state.internal.isSecondary && canvasTarget?.dispose) canvasTarget.dispose();
|
|
14644
14650
|
state.events.disconnect?.();
|
|
14645
14651
|
cleanupHelperGroup(root.store);
|
|
14646
14652
|
if (state.isLegacy && renderer) {
|
|
@@ -14781,16 +14787,11 @@ function setEnvProps(background, scene, defaultScene, texture, sceneProps = {})
|
|
|
14781
14787
|
const oldbg = target.background;
|
|
14782
14788
|
const oldenv = target.environment;
|
|
14783
14789
|
const oldSceneProps = {
|
|
14784
|
-
// @ts-ignore
|
|
14785
14790
|
backgroundBlurriness: target.backgroundBlurriness,
|
|
14786
|
-
// @ts-ignore
|
|
14787
14791
|
backgroundIntensity: target.backgroundIntensity,
|
|
14788
|
-
|
|
14789
|
-
backgroundRotation: target.backgroundRotation?.clone?.() ?? [0, 0, 0],
|
|
14790
|
-
// @ts-ignore
|
|
14792
|
+
backgroundRotation: target.backgroundRotation.clone(),
|
|
14791
14793
|
environmentIntensity: target.environmentIntensity,
|
|
14792
|
-
|
|
14793
|
-
environmentRotation: target.environmentRotation?.clone?.() ?? [0, 0, 0]
|
|
14794
|
+
environmentRotation: target.environmentRotation.clone()
|
|
14794
14795
|
};
|
|
14795
14796
|
if (background !== "only") target.environment = texture;
|
|
14796
14797
|
if (background) target.background = texture;
|