@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/legacy.mjs
CHANGED
|
@@ -11,6 +11,7 @@ export { Scheduler, getScheduler } from '@pmndrs/scheduler';
|
|
|
11
11
|
import Tb, { unstable_getCurrentPriorityLevel, unstable_IdlePriority, unstable_LowPriority, unstable_NormalPriority, unstable_UserBlockingPriority, unstable_ImmediatePriority, unstable_scheduleCallback } from 'scheduler';
|
|
12
12
|
import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
|
|
13
13
|
import { HDRLoader } from 'three/examples/jsm/loaders/HDRLoader.js';
|
|
14
|
+
import { HDRCubeTextureLoader } from 'three/examples/jsm/loaders/HDRCubeTextureLoader.js';
|
|
14
15
|
import { EXRLoader } from 'three/examples/jsm/loaders/EXRLoader.js';
|
|
15
16
|
import { UltraHDRLoader } from 'three/examples/jsm/loaders/UltraHDRLoader.js';
|
|
16
17
|
import { GainMapLoader } from '@monogrid/gainmap-js';
|
|
@@ -33,11 +34,11 @@ const R3F_BUILD_WEBGPU = false;
|
|
|
33
34
|
async function loadInspector() {
|
|
34
35
|
throw new Error("Inspector is not available in legacy builds. Use @react-three/fiber/webgpu instead.");
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
+
class WebGPURenderer {
|
|
37
38
|
constructor() {
|
|
38
39
|
throw new Error("WebGPURenderer is not available in legacy builds. Use @react-three/fiber/webgpu instead.");
|
|
39
40
|
}
|
|
40
|
-
}
|
|
41
|
+
}
|
|
41
42
|
const RenderTarget = null;
|
|
42
43
|
const CubeRenderTarget = null;
|
|
43
44
|
|
|
@@ -513,8 +514,10 @@ function hasVisibilityHandlers(handlers) {
|
|
|
513
514
|
}
|
|
514
515
|
|
|
515
516
|
const FROM_REF = Symbol.for("@react-three/fiber.fromRef");
|
|
516
|
-
function fromRef(ref) {
|
|
517
|
-
|
|
517
|
+
function fromRef(ref, transform) {
|
|
518
|
+
const marker = { [FROM_REF]: ref };
|
|
519
|
+
if (transform) marker.transform = transform;
|
|
520
|
+
return marker;
|
|
518
521
|
}
|
|
519
522
|
function isFromRef(value) {
|
|
520
523
|
return value !== null && typeof value === "object" && FROM_REF in value;
|
|
@@ -606,12 +609,7 @@ function diffProps(instance, newProps) {
|
|
|
606
609
|
const changedProps = {};
|
|
607
610
|
for (const prop in newProps) {
|
|
608
611
|
if (RESERVED_PROPS.includes(prop)) continue;
|
|
609
|
-
if (is.equ(newProps[prop], instance.props[prop]))
|
|
610
|
-
const value = newProps[prop];
|
|
611
|
-
if (!isCopyable(value)) continue;
|
|
612
|
-
const { target } = resolve(instance.object, prop);
|
|
613
|
-
if (!isCopyable(target) || target.constructor !== value.constructor) continue;
|
|
614
|
-
}
|
|
612
|
+
if (is.equ(newProps[prop], instance.props[prop])) continue;
|
|
615
613
|
changedProps[prop] = newProps[prop];
|
|
616
614
|
for (const other in newProps) {
|
|
617
615
|
if (other.startsWith(`${prop}-`)) changedProps[other] = newProps[other];
|
|
@@ -620,11 +618,9 @@ function diffProps(instance, newProps) {
|
|
|
620
618
|
for (const prop in instance.props) {
|
|
621
619
|
if (RESERVED_PROPS.includes(prop) || newProps.hasOwnProperty(prop)) continue;
|
|
622
620
|
const { root, key } = resolve(instance.object, prop);
|
|
623
|
-
if (
|
|
621
|
+
if (typeof root?.constructor === "function") {
|
|
624
622
|
const ctor = getMemoizedPrototype(root);
|
|
625
623
|
if (!is.und(ctor)) changedProps[prop] = ctor[key];
|
|
626
|
-
} else {
|
|
627
|
-
changedProps[prop] = 0;
|
|
628
624
|
}
|
|
629
625
|
}
|
|
630
626
|
return changedProps;
|
|
@@ -1347,12 +1343,24 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
1347
1343
|
TextureLoader,
|
|
1348
1344
|
IsObject(stableInput) ? Object.values(stableInput) : stableInput
|
|
1349
1345
|
);
|
|
1346
|
+
const mappedTextures = useMemo(() => {
|
|
1347
|
+
if (cachedResult) return cachedResult;
|
|
1348
|
+
if (IsObject(stableInput)) {
|
|
1349
|
+
const keyed = {};
|
|
1350
|
+
const textureArray = loadedTextures;
|
|
1351
|
+
let i = 0;
|
|
1352
|
+
for (const key in stableInput) keyed[key] = textureArray[i++];
|
|
1353
|
+
return keyed;
|
|
1354
|
+
} else {
|
|
1355
|
+
return loadedTextures;
|
|
1356
|
+
}
|
|
1357
|
+
}, [stableInput, loadedTextures, cachedResult]);
|
|
1350
1358
|
useLayoutEffect(() => {
|
|
1351
1359
|
if (cachedResult) return;
|
|
1352
1360
|
if (onLoadCalledForRef.current === inputKey) return;
|
|
1353
1361
|
onLoadCalledForRef.current = inputKey;
|
|
1354
|
-
onLoadRef.current?.(
|
|
1355
|
-
}, [cachedResult,
|
|
1362
|
+
onLoadRef.current?.(mappedTextures);
|
|
1363
|
+
}, [cachedResult, mappedTextures, inputKey]);
|
|
1356
1364
|
useEffect(() => {
|
|
1357
1365
|
if (cachedResult) return;
|
|
1358
1366
|
if ("initTexture" in renderer) {
|
|
@@ -1371,18 +1379,6 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
1371
1379
|
});
|
|
1372
1380
|
}
|
|
1373
1381
|
}, [renderer, loadedTextures, cachedResult]);
|
|
1374
|
-
const mappedTextures = useMemo(() => {
|
|
1375
|
-
if (cachedResult) return cachedResult;
|
|
1376
|
-
if (IsObject(stableInput)) {
|
|
1377
|
-
const keyed = {};
|
|
1378
|
-
const textureArray = loadedTextures;
|
|
1379
|
-
let i = 0;
|
|
1380
|
-
for (const key in stableInput) keyed[key] = textureArray[i++];
|
|
1381
|
-
return keyed;
|
|
1382
|
-
} else {
|
|
1383
|
-
return loadedTextures;
|
|
1384
|
-
}
|
|
1385
|
-
}, [stableInput, loadedTextures, cachedResult]);
|
|
1386
1382
|
useEffect(() => {
|
|
1387
1383
|
if (!cache) return;
|
|
1388
1384
|
const urlTextureMap = [];
|
|
@@ -1584,7 +1580,7 @@ function useEnvironment({
|
|
|
1584
1580
|
texture = texture.renderTarget?.texture;
|
|
1585
1581
|
}
|
|
1586
1582
|
texture.mapping = isCubemap ? CubeReflectionMapping : EquirectangularReflectionMapping;
|
|
1587
|
-
texture.colorSpace = colorSpace ?? (isCubemap ? "srgb" : "srgb-linear");
|
|
1583
|
+
texture.colorSpace = colorSpace ?? (isCubemap && extension !== "hdr-cube" ? "srgb" : "srgb-linear");
|
|
1588
1584
|
return texture;
|
|
1589
1585
|
}
|
|
1590
1586
|
const preloadDefaultOptions = {
|
|
@@ -1637,11 +1633,12 @@ function getExtension(files) {
|
|
|
1637
1633
|
const isCubemap = isArray(files) && files.length === 6;
|
|
1638
1634
|
const isGainmap = isArray(files) && files.length === 3 && files.some((file) => file.endsWith("json"));
|
|
1639
1635
|
const firstEntry = isArray(files) ? files[0] : files;
|
|
1640
|
-
const
|
|
1636
|
+
const firstExtension = firstEntry.split(".").pop()?.split("?")?.shift()?.toLowerCase();
|
|
1637
|
+
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;
|
|
1641
1638
|
return { extension, isCubemap, isGainmap };
|
|
1642
1639
|
}
|
|
1643
1640
|
function getLoader(extension) {
|
|
1644
|
-
const loader = extension === "cube" ? CubeTextureLoader : extension === "hdr" ? HDRLoader : extension === "exr" ? EXRLoader : extension === "jpg" || extension === "jpeg" ? UltraHDRLoader : extension === "webp" ? GainMapLoader : null;
|
|
1641
|
+
const loader = extension === "cube" ? CubeTextureLoader : extension === "hdr-cube" ? HDRCubeTextureLoader : extension === "hdr" ? HDRLoader : extension === "exr" ? EXRLoader : extension === "jpg" || extension === "jpeg" ? UltraHDRLoader : extension === "webp" ? GainMapLoader : null;
|
|
1645
1642
|
return loader;
|
|
1646
1643
|
}
|
|
1647
1644
|
|
|
@@ -1704,7 +1701,7 @@ function advance(timestamp, runGlobalEffects, state) {
|
|
|
1704
1701
|
else scheduler.step(timestamp);
|
|
1705
1702
|
}
|
|
1706
1703
|
|
|
1707
|
-
const version = "10.0.0-alpha.
|
|
1704
|
+
const version = "10.0.0-alpha.5";
|
|
1708
1705
|
const packageData = {
|
|
1709
1706
|
version: version};
|
|
1710
1707
|
|
|
@@ -13563,7 +13560,10 @@ function extend(objects) {
|
|
|
13563
13560
|
catalogue[Component] = objects;
|
|
13564
13561
|
return Component;
|
|
13565
13562
|
} else {
|
|
13566
|
-
|
|
13563
|
+
for (const name in objects) {
|
|
13564
|
+
const object = objects[name];
|
|
13565
|
+
if (isConstructor(object)) catalogue[name] = object;
|
|
13566
|
+
}
|
|
13567
13567
|
}
|
|
13568
13568
|
}
|
|
13569
13569
|
function validateInstance(type, props) {
|
|
@@ -13911,7 +13911,7 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13911
13911
|
getRootHostContext: () => NO_CONTEXT,
|
|
13912
13912
|
getChildHostContext: () => NO_CONTEXT,
|
|
13913
13913
|
commitUpdate(instance, type, oldProps, newProps, fiber) {
|
|
13914
|
-
validateInstance(type, newProps);
|
|
13914
|
+
validateInstance(instance.type, newProps);
|
|
13915
13915
|
let reconstruct = false;
|
|
13916
13916
|
if (instance.type === "primitive" && oldProps.object !== newProps.object) reconstruct = true;
|
|
13917
13917
|
else if (newProps.args?.length !== oldProps.args?.length) reconstruct = true;
|
|
@@ -13938,8 +13938,8 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13938
13938
|
for (const prop in instance.props) {
|
|
13939
13939
|
const value = instance.props[prop];
|
|
13940
13940
|
if (isFromRef(value)) {
|
|
13941
|
-
const ref = value
|
|
13942
|
-
if (ref.current != null) resolved[prop] = ref.current;
|
|
13941
|
+
const { [FROM_REF]: ref, transform } = value;
|
|
13942
|
+
if (ref.current != null) resolved[prop] = transform ? transform(ref.current) : ref.current;
|
|
13943
13943
|
}
|
|
13944
13944
|
}
|
|
13945
13945
|
if (Object.keys(resolved).length) applyProps(instance.object, resolved);
|
|
@@ -14723,16 +14723,11 @@ function setEnvProps(background, scene, defaultScene, texture, sceneProps = {})
|
|
|
14723
14723
|
const oldbg = target.background;
|
|
14724
14724
|
const oldenv = target.environment;
|
|
14725
14725
|
const oldSceneProps = {
|
|
14726
|
-
// @ts-ignore
|
|
14727
14726
|
backgroundBlurriness: target.backgroundBlurriness,
|
|
14728
|
-
// @ts-ignore
|
|
14729
14727
|
backgroundIntensity: target.backgroundIntensity,
|
|
14730
|
-
|
|
14731
|
-
backgroundRotation: target.backgroundRotation?.clone?.() ?? [0, 0, 0],
|
|
14732
|
-
// @ts-ignore
|
|
14728
|
+
backgroundRotation: target.backgroundRotation.clone(),
|
|
14733
14729
|
environmentIntensity: target.environmentIntensity,
|
|
14734
|
-
|
|
14735
|
-
environmentRotation: target.environmentRotation?.clone?.() ?? [0, 0, 0]
|
|
14730
|
+
environmentRotation: target.environmentRotation.clone()
|
|
14736
14731
|
};
|
|
14737
14732
|
if (background !== "only") target.environment = texture;
|
|
14738
14733
|
if (background) target.background = texture;
|
package/dist/webgpu/index.cjs
CHANGED
|
@@ -10,6 +10,7 @@ const scheduler = require('@pmndrs/scheduler');
|
|
|
10
10
|
const Tb = require('scheduler');
|
|
11
11
|
const GroundedSkybox_js = require('three/examples/jsm/objects/GroundedSkybox.js');
|
|
12
12
|
const HDRLoader_js = require('three/examples/jsm/loaders/HDRLoader.js');
|
|
13
|
+
const HDRCubeTextureLoader_js = require('three/examples/jsm/loaders/HDRCubeTextureLoader.js');
|
|
13
14
|
const EXRLoader_js = require('three/examples/jsm/loaders/EXRLoader.js');
|
|
14
15
|
const UltraHDRLoader_js = require('three/examples/jsm/loaders/UltraHDRLoader.js');
|
|
15
16
|
const gainmapJs = require('@monogrid/gainmap-js');
|
|
@@ -539,8 +540,10 @@ function hasVisibilityHandlers(handlers) {
|
|
|
539
540
|
}
|
|
540
541
|
|
|
541
542
|
const FROM_REF = Symbol.for("@react-three/fiber.fromRef");
|
|
542
|
-
function fromRef(ref) {
|
|
543
|
-
|
|
543
|
+
function fromRef(ref, transform) {
|
|
544
|
+
const marker = { [FROM_REF]: ref };
|
|
545
|
+
if (transform) marker.transform = transform;
|
|
546
|
+
return marker;
|
|
544
547
|
}
|
|
545
548
|
function isFromRef(value) {
|
|
546
549
|
return value !== null && typeof value === "object" && FROM_REF in value;
|
|
@@ -632,12 +635,7 @@ function diffProps(instance, newProps) {
|
|
|
632
635
|
const changedProps = {};
|
|
633
636
|
for (const prop in newProps) {
|
|
634
637
|
if (RESERVED_PROPS.includes(prop)) continue;
|
|
635
|
-
if (is.equ(newProps[prop], instance.props[prop]))
|
|
636
|
-
const value = newProps[prop];
|
|
637
|
-
if (!isCopyable(value)) continue;
|
|
638
|
-
const { target } = resolve(instance.object, prop);
|
|
639
|
-
if (!isCopyable(target) || target.constructor !== value.constructor) continue;
|
|
640
|
-
}
|
|
638
|
+
if (is.equ(newProps[prop], instance.props[prop])) continue;
|
|
641
639
|
changedProps[prop] = newProps[prop];
|
|
642
640
|
for (const other in newProps) {
|
|
643
641
|
if (other.startsWith(`${prop}-`)) changedProps[other] = newProps[other];
|
|
@@ -646,11 +644,9 @@ function diffProps(instance, newProps) {
|
|
|
646
644
|
for (const prop in instance.props) {
|
|
647
645
|
if (RESERVED_PROPS.includes(prop) || newProps.hasOwnProperty(prop)) continue;
|
|
648
646
|
const { root, key } = resolve(instance.object, prop);
|
|
649
|
-
if (
|
|
647
|
+
if (typeof root?.constructor === "function") {
|
|
650
648
|
const ctor = getMemoizedPrototype(root);
|
|
651
649
|
if (!is.und(ctor)) changedProps[prop] = ctor[key];
|
|
652
|
-
} else {
|
|
653
|
-
changedProps[prop] = 0;
|
|
654
650
|
}
|
|
655
651
|
}
|
|
656
652
|
return changedProps;
|
|
@@ -1373,12 +1369,24 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
1373
1369
|
webgpu.TextureLoader,
|
|
1374
1370
|
IsObject(stableInput) ? Object.values(stableInput) : stableInput
|
|
1375
1371
|
);
|
|
1372
|
+
const mappedTextures = React.useMemo(() => {
|
|
1373
|
+
if (cachedResult) return cachedResult;
|
|
1374
|
+
if (IsObject(stableInput)) {
|
|
1375
|
+
const keyed = {};
|
|
1376
|
+
const textureArray = loadedTextures;
|
|
1377
|
+
let i = 0;
|
|
1378
|
+
for (const key in stableInput) keyed[key] = textureArray[i++];
|
|
1379
|
+
return keyed;
|
|
1380
|
+
} else {
|
|
1381
|
+
return loadedTextures;
|
|
1382
|
+
}
|
|
1383
|
+
}, [stableInput, loadedTextures, cachedResult]);
|
|
1376
1384
|
React.useLayoutEffect(() => {
|
|
1377
1385
|
if (cachedResult) return;
|
|
1378
1386
|
if (onLoadCalledForRef.current === inputKey) return;
|
|
1379
1387
|
onLoadCalledForRef.current = inputKey;
|
|
1380
|
-
onLoadRef.current?.(
|
|
1381
|
-
}, [cachedResult,
|
|
1388
|
+
onLoadRef.current?.(mappedTextures);
|
|
1389
|
+
}, [cachedResult, mappedTextures, inputKey]);
|
|
1382
1390
|
React.useEffect(() => {
|
|
1383
1391
|
if (cachedResult) return;
|
|
1384
1392
|
if ("initTexture" in renderer) {
|
|
@@ -1397,18 +1405,6 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
1397
1405
|
});
|
|
1398
1406
|
}
|
|
1399
1407
|
}, [renderer, loadedTextures, cachedResult]);
|
|
1400
|
-
const mappedTextures = React.useMemo(() => {
|
|
1401
|
-
if (cachedResult) return cachedResult;
|
|
1402
|
-
if (IsObject(stableInput)) {
|
|
1403
|
-
const keyed = {};
|
|
1404
|
-
const textureArray = loadedTextures;
|
|
1405
|
-
let i = 0;
|
|
1406
|
-
for (const key in stableInput) keyed[key] = textureArray[i++];
|
|
1407
|
-
return keyed;
|
|
1408
|
-
} else {
|
|
1409
|
-
return loadedTextures;
|
|
1410
|
-
}
|
|
1411
|
-
}, [stableInput, loadedTextures, cachedResult]);
|
|
1412
1408
|
React.useEffect(() => {
|
|
1413
1409
|
if (!cache) return;
|
|
1414
1410
|
const urlTextureMap = [];
|
|
@@ -1610,7 +1606,7 @@ function useEnvironment({
|
|
|
1610
1606
|
texture = texture.renderTarget?.texture;
|
|
1611
1607
|
}
|
|
1612
1608
|
texture.mapping = isCubemap ? webgpu.CubeReflectionMapping : webgpu.EquirectangularReflectionMapping;
|
|
1613
|
-
texture.colorSpace = colorSpace ?? (isCubemap ? "srgb" : "srgb-linear");
|
|
1609
|
+
texture.colorSpace = colorSpace ?? (isCubemap && extension !== "hdr-cube" ? "srgb" : "srgb-linear");
|
|
1614
1610
|
return texture;
|
|
1615
1611
|
}
|
|
1616
1612
|
const preloadDefaultOptions = {
|
|
@@ -1663,11 +1659,12 @@ function getExtension(files) {
|
|
|
1663
1659
|
const isCubemap = isArray(files) && files.length === 6;
|
|
1664
1660
|
const isGainmap = isArray(files) && files.length === 3 && files.some((file) => file.endsWith("json"));
|
|
1665
1661
|
const firstEntry = isArray(files) ? files[0] : files;
|
|
1666
|
-
const
|
|
1662
|
+
const firstExtension = firstEntry.split(".").pop()?.split("?")?.shift()?.toLowerCase();
|
|
1663
|
+
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;
|
|
1667
1664
|
return { extension, isCubemap, isGainmap };
|
|
1668
1665
|
}
|
|
1669
1666
|
function getLoader(extension) {
|
|
1670
|
-
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;
|
|
1667
|
+
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;
|
|
1671
1668
|
return loader;
|
|
1672
1669
|
}
|
|
1673
1670
|
|
|
@@ -1730,16 +1727,16 @@ function advance(timestamp, runGlobalEffects, state) {
|
|
|
1730
1727
|
else scheduler$1.step(timestamp);
|
|
1731
1728
|
}
|
|
1732
1729
|
|
|
1733
|
-
const version = "10.0.0-alpha.
|
|
1730
|
+
const version = "10.0.0-alpha.5";
|
|
1734
1731
|
const packageData = {
|
|
1735
1732
|
version: version};
|
|
1736
1733
|
|
|
1737
1734
|
function Xb(Tt) {
|
|
1738
1735
|
return Tt && Tt.__esModule && Object.prototype.hasOwnProperty.call(Tt, "default") ? Tt.default : Tt;
|
|
1739
1736
|
}
|
|
1740
|
-
var Rm = { exports: {} }, Og = { exports: {} }, _b;
|
|
1737
|
+
var Rm = { exports: {} }, Og = { exports: {} }, _b$1;
|
|
1741
1738
|
function Kb() {
|
|
1742
|
-
return _b || (_b = 1, (function(Tt) {
|
|
1739
|
+
return _b$1 || (_b$1 = 1, (function(Tt) {
|
|
1743
1740
|
Tt.exports = function(m) {
|
|
1744
1741
|
function Yn(t, r, a, l) {
|
|
1745
1742
|
return new uc(t, r, a, l);
|
|
@@ -13589,7 +13586,10 @@ function extend(objects) {
|
|
|
13589
13586
|
catalogue[Component] = objects;
|
|
13590
13587
|
return Component;
|
|
13591
13588
|
} else {
|
|
13592
|
-
|
|
13589
|
+
for (const name in objects) {
|
|
13590
|
+
const object = objects[name];
|
|
13591
|
+
if (isConstructor(object)) catalogue[name] = object;
|
|
13592
|
+
}
|
|
13593
13593
|
}
|
|
13594
13594
|
}
|
|
13595
13595
|
function validateInstance(type, props) {
|
|
@@ -13937,7 +13937,7 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13937
13937
|
getRootHostContext: () => NO_CONTEXT,
|
|
13938
13938
|
getChildHostContext: () => NO_CONTEXT,
|
|
13939
13939
|
commitUpdate(instance, type, oldProps, newProps, fiber) {
|
|
13940
|
-
validateInstance(type, newProps);
|
|
13940
|
+
validateInstance(instance.type, newProps);
|
|
13941
13941
|
let reconstruct = false;
|
|
13942
13942
|
if (instance.type === "primitive" && oldProps.object !== newProps.object) reconstruct = true;
|
|
13943
13943
|
else if (newProps.args?.length !== oldProps.args?.length) reconstruct = true;
|
|
@@ -13964,8 +13964,8 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13964
13964
|
for (const prop in instance.props) {
|
|
13965
13965
|
const value = instance.props[prop];
|
|
13966
13966
|
if (isFromRef(value)) {
|
|
13967
|
-
const ref = value
|
|
13968
|
-
if (ref.current != null) resolved[prop] = ref.current;
|
|
13967
|
+
const { [FROM_REF]: ref, transform } = value;
|
|
13968
|
+
if (ref.current != null) resolved[prop] = transform ? transform(ref.current) : ref.current;
|
|
13969
13969
|
}
|
|
13970
13970
|
}
|
|
13971
13971
|
if (Object.keys(resolved).length) applyProps(instance.object, resolved);
|
|
@@ -14777,16 +14777,11 @@ function setEnvProps(background, scene, defaultScene, texture, sceneProps = {})
|
|
|
14777
14777
|
const oldbg = target.background;
|
|
14778
14778
|
const oldenv = target.environment;
|
|
14779
14779
|
const oldSceneProps = {
|
|
14780
|
-
// @ts-ignore
|
|
14781
14780
|
backgroundBlurriness: target.backgroundBlurriness,
|
|
14782
|
-
// @ts-ignore
|
|
14783
14781
|
backgroundIntensity: target.backgroundIntensity,
|
|
14784
|
-
|
|
14785
|
-
backgroundRotation: target.backgroundRotation?.clone?.() ?? [0, 0, 0],
|
|
14786
|
-
// @ts-ignore
|
|
14782
|
+
backgroundRotation: target.backgroundRotation.clone(),
|
|
14787
14783
|
environmentIntensity: target.environmentIntensity,
|
|
14788
|
-
|
|
14789
|
-
environmentRotation: target.environmentRotation?.clone?.() ?? [0, 0, 0]
|
|
14784
|
+
environmentRotation: target.environmentRotation.clone()
|
|
14790
14785
|
};
|
|
14791
14786
|
if (background !== "only") target.environment = texture;
|
|
14792
14787
|
if (background) target.background = texture;
|
|
@@ -15380,20 +15375,36 @@ function CanvasImpl({
|
|
|
15380
15375
|
}
|
|
15381
15376
|
);
|
|
15382
15377
|
}
|
|
15383
|
-
function Canvas(props) {
|
|
15378
|
+
function Canvas$1(props) {
|
|
15384
15379
|
return /* @__PURE__ */ jsxRuntime.jsx(itsFine.FiberProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(CanvasImpl, { ...props }) });
|
|
15385
15380
|
}
|
|
15386
15381
|
|
|
15382
|
+
const isObjectLike = (value) => value !== null && (typeof value === "object" || typeof value === "function");
|
|
15383
|
+
const hasValidLegacyNodeMarkers = (value) => {
|
|
15384
|
+
const hasUuid = "uuid" in value;
|
|
15385
|
+
const hasNodeType = "nodeType" in value;
|
|
15386
|
+
const uuid = Reflect.get(value, "uuid");
|
|
15387
|
+
const nodeType = Reflect.get(value, "nodeType");
|
|
15388
|
+
return (hasUuid || hasNodeType) && (!hasUuid || uuid === void 0 || typeof uuid === "string") && (!hasNodeType || nodeType === void 0 || nodeType === null || typeof nodeType === "string");
|
|
15389
|
+
};
|
|
15390
|
+
const isUniformNode = (value) => isObjectLike(value) && "isUniformNode" in value && value.isUniformNode === true;
|
|
15391
|
+
const isTSLNode = (value) => isObjectLike(value) && (Reflect.get(value, "isNode") === true || Reflect.get(value, "shaderNode") !== void 0 && typeof Reflect.get(value, "id") === "number" || hasValidLegacyNodeMarkers(value));
|
|
15392
|
+
const isBufferLike = (value) => ArrayBuffer.isView(value) && !(value instanceof DataView) || isObjectLike(value) && ("isBufferAttribute" in value || "isInterleavedBufferAttribute" in value || isTSLNode(value));
|
|
15393
|
+
const isStorageLike = (value) => isObjectLike(value) && ("isTexture" in value || "isData3DTexture" in value || isTSLNode(value));
|
|
15394
|
+
|
|
15387
15395
|
var __defProp = Object.defineProperty;
|
|
15388
15396
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
15389
15397
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
15390
|
-
var _a;
|
|
15398
|
+
var _a, _b;
|
|
15391
15399
|
const INTERNAL_DATA = Symbol("ScopedStore.data");
|
|
15392
|
-
|
|
15400
|
+
const INTERNAL_IS_LEAF = Symbol("ScopedStore.isLeaf");
|
|
15401
|
+
_b = INTERNAL_DATA, _a = INTERNAL_IS_LEAF;
|
|
15393
15402
|
const _ScopedStore = class _ScopedStore {
|
|
15394
|
-
constructor(data) {
|
|
15403
|
+
constructor(data, isLeaf) {
|
|
15404
|
+
__publicField(this, _b);
|
|
15395
15405
|
__publicField(this, _a);
|
|
15396
15406
|
this[INTERNAL_DATA] = data;
|
|
15407
|
+
this[INTERNAL_IS_LEAF] = isLeaf;
|
|
15397
15408
|
return new Proxy(this, {
|
|
15398
15409
|
get(target, prop, receiver) {
|
|
15399
15410
|
if (typeof prop === "string") {
|
|
@@ -15427,10 +15438,10 @@ const _ScopedStore = class _ScopedStore {
|
|
|
15427
15438
|
* If the key doesn't exist or isn't a scope object, returns an empty ScopedStore.
|
|
15428
15439
|
*/
|
|
15429
15440
|
scope(key) {
|
|
15430
|
-
const
|
|
15431
|
-
|
|
15432
|
-
|
|
15433
|
-
);
|
|
15441
|
+
const value = this[INTERNAL_DATA][key];
|
|
15442
|
+
const isLeaf = this[INTERNAL_IS_LEAF];
|
|
15443
|
+
const scope = value && typeof value === "object" && !isLeaf(value) ? value : {};
|
|
15444
|
+
return new _ScopedStore(scope, isLeaf);
|
|
15434
15445
|
}
|
|
15435
15446
|
/**
|
|
15436
15447
|
* Check if a key exists in the store.
|
|
@@ -15446,8 +15457,8 @@ const _ScopedStore = class _ScopedStore {
|
|
|
15446
15457
|
}
|
|
15447
15458
|
};
|
|
15448
15459
|
let ScopedStore = _ScopedStore;
|
|
15449
|
-
function createScopedStore(data) {
|
|
15450
|
-
return new ScopedStore(data);
|
|
15460
|
+
function createScopedStore(data, isLeaf) {
|
|
15461
|
+
return new ScopedStore(data, isLeaf);
|
|
15451
15462
|
}
|
|
15452
15463
|
function createLazyCreatorState(state, store) {
|
|
15453
15464
|
let _uniforms = null;
|
|
@@ -15458,22 +15469,22 @@ function createLazyCreatorState(state, store) {
|
|
|
15458
15469
|
return Object.create(state, {
|
|
15459
15470
|
uniforms: {
|
|
15460
15471
|
get() {
|
|
15461
|
-
return _uniforms ?? (_uniforms = createScopedStore(view("uniforms")));
|
|
15472
|
+
return _uniforms ?? (_uniforms = createScopedStore(view("uniforms"), isUniformNode));
|
|
15462
15473
|
}
|
|
15463
15474
|
},
|
|
15464
15475
|
nodes: {
|
|
15465
15476
|
get() {
|
|
15466
|
-
return _nodes ?? (_nodes = createScopedStore(view("nodes")));
|
|
15477
|
+
return _nodes ?? (_nodes = createScopedStore(view("nodes"), isTSLNode));
|
|
15467
15478
|
}
|
|
15468
15479
|
},
|
|
15469
15480
|
buffers: {
|
|
15470
15481
|
get() {
|
|
15471
|
-
return _buffers ?? (_buffers = createScopedStore(view("buffers")));
|
|
15482
|
+
return _buffers ?? (_buffers = createScopedStore(view("buffers"), isBufferLike));
|
|
15472
15483
|
}
|
|
15473
15484
|
},
|
|
15474
15485
|
gpuStorage: {
|
|
15475
15486
|
get() {
|
|
15476
|
-
return _gpuStorage ?? (_gpuStorage = createScopedStore(view("gpuStorage")));
|
|
15487
|
+
return _gpuStorage ?? (_gpuStorage = createScopedStore(view("gpuStorage"), isStorageLike));
|
|
15477
15488
|
}
|
|
15478
15489
|
}
|
|
15479
15490
|
});
|
|
@@ -15574,7 +15585,7 @@ function vectorize(inObject) {
|
|
|
15574
15585
|
return extractTSLValue(inObject);
|
|
15575
15586
|
}
|
|
15576
15587
|
if (obj.isVector2 || obj.isVector3 || obj.isVector4) return inObject;
|
|
15577
|
-
if (obj.isMatrix3 || obj.isMatrix4) return inObject;
|
|
15588
|
+
if (obj.isMatrix2 || obj.isMatrix3 || obj.isMatrix4) return inObject;
|
|
15578
15589
|
if (obj.isColor || obj.isEuler || obj.isQuaternion || obj.isSpherical) return inObject;
|
|
15579
15590
|
if ("r" in obj && "g" in obj && "b" in obj && typeof obj.r === "number" && typeof obj.g === "number" && typeof obj.b === "number") {
|
|
15580
15591
|
const scale = obj.r > 1 || obj.g > 1 || obj.b > 1 ? 1 / 255 : 1;
|
|
@@ -15632,22 +15643,21 @@ function useScopedResource(options) {
|
|
|
15632
15643
|
return entries;
|
|
15633
15644
|
}
|
|
15634
15645
|
|
|
15635
|
-
const isUniformNode$1 = (value) => value !== null && typeof value === "object" && "value" in value && "uuid" in value;
|
|
15636
15646
|
function useUniforms(creatorOrScope, scope) {
|
|
15637
15647
|
const store = usePrimaryStore();
|
|
15638
15648
|
const removeUniforms2 = React.useCallback(
|
|
15639
|
-
(names, targetScope) => removeResourceEntries(store, "uniforms", Array.isArray(names) ? names : [names], targetScope, isUniformNode
|
|
15649
|
+
(names, targetScope) => removeResourceEntries(store, "uniforms", Array.isArray(names) ? names : [names], targetScope, isUniformNode),
|
|
15640
15650
|
[store]
|
|
15641
15651
|
);
|
|
15642
15652
|
const clearUniforms = React.useCallback(
|
|
15643
|
-
(targetScope) => clearResourceEntries(store, "uniforms", targetScope, isUniformNode
|
|
15653
|
+
(targetScope) => clearResourceEntries(store, "uniforms", targetScope, isUniformNode),
|
|
15644
15654
|
[store]
|
|
15645
15655
|
);
|
|
15646
15656
|
const rebuildUniforms = React.useCallback(
|
|
15647
15657
|
(targetScope) => rebuildResource(store, "uniforms", targetScope),
|
|
15648
15658
|
[store]
|
|
15649
15659
|
);
|
|
15650
|
-
const
|
|
15660
|
+
const processedInput = React.useMemo(() => {
|
|
15651
15661
|
let raw = creatorOrScope;
|
|
15652
15662
|
if (is.fun(creatorOrScope)) {
|
|
15653
15663
|
const wrappedState = createLazyCreatorState(store.getState(), store);
|
|
@@ -15658,23 +15668,24 @@ function useUniforms(creatorOrScope, scope) {
|
|
|
15658
15668
|
for (const [key, value] of Object.entries(raw)) {
|
|
15659
15669
|
normalized[key] = vectorize(value);
|
|
15660
15670
|
}
|
|
15661
|
-
return normalized;
|
|
15671
|
+
return { candidates: raw, normalized };
|
|
15662
15672
|
}
|
|
15663
|
-
return raw;
|
|
15673
|
+
return { candidates: raw, normalized: raw };
|
|
15664
15674
|
}, [creatorOrScope, store]);
|
|
15665
|
-
const memoizedInput = useCompareMemoize(
|
|
15675
|
+
const memoizedInput = useCompareMemoize(processedInput.normalized);
|
|
15666
15676
|
const isReader = memoizedInput === void 0 || typeof memoizedInput === "string";
|
|
15667
15677
|
const storeUniforms = usePrimaryThree((s) => s.uniforms);
|
|
15668
15678
|
const created = useScopedResource({
|
|
15669
15679
|
store,
|
|
15670
15680
|
kind: "uniforms",
|
|
15671
15681
|
scope: isReader ? void 0 : scope,
|
|
15672
|
-
isLeaf: isUniformNode
|
|
15682
|
+
isLeaf: isUniformNode,
|
|
15673
15683
|
input: memoizedInput,
|
|
15674
15684
|
create: () => {
|
|
15675
15685
|
if (isReader) return {};
|
|
15676
|
-
if (typeof
|
|
15677
|
-
|
|
15686
|
+
if (typeof processedInput.candidates !== "object" || processedInput.candidates === null)
|
|
15687
|
+
throw new Error("Invalid uniform input");
|
|
15688
|
+
return processedInput.candidates;
|
|
15678
15689
|
},
|
|
15679
15690
|
prepare: (name, candidate) => createUniform(name, candidate, scope),
|
|
15680
15691
|
reconcile: (existing, candidate) => {
|
|
@@ -15696,7 +15707,7 @@ function useUniforms(creatorOrScope, scope) {
|
|
|
15696
15707
|
uniforms = storeUniforms;
|
|
15697
15708
|
} else if (typeof memoizedInput === "string") {
|
|
15698
15709
|
const scopeData = storeUniforms[memoizedInput];
|
|
15699
|
-
uniforms = scopeData && !isUniformNode
|
|
15710
|
+
uniforms = scopeData && !isUniformNode(scopeData) ? scopeData : {};
|
|
15700
15711
|
}
|
|
15701
15712
|
return { ...uniforms, removeUniforms: removeUniforms2, clearUniforms, rebuildUniforms };
|
|
15702
15713
|
}
|
|
@@ -15711,7 +15722,7 @@ function removeUniforms(set, names, scope) {
|
|
|
15711
15722
|
return { uniforms: { ...state.uniforms, [scope]: currentScope } };
|
|
15712
15723
|
}
|
|
15713
15724
|
const uniforms = { ...state.uniforms };
|
|
15714
|
-
for (const name of names) if (isUniformNode
|
|
15725
|
+
for (const name of names) if (isUniformNode(uniforms[name])) delete uniforms[name];
|
|
15715
15726
|
return { uniforms };
|
|
15716
15727
|
});
|
|
15717
15728
|
}
|
|
@@ -15725,7 +15736,7 @@ function clearRootUniforms(set) {
|
|
|
15725
15736
|
set((state) => {
|
|
15726
15737
|
const uniforms = {};
|
|
15727
15738
|
for (const [key, value] of Object.entries(state.uniforms)) {
|
|
15728
|
-
if (!isUniformNode
|
|
15739
|
+
if (!isUniformNode(value)) uniforms[key] = value;
|
|
15729
15740
|
}
|
|
15730
15741
|
return { uniforms };
|
|
15731
15742
|
});
|
|
@@ -15761,12 +15772,10 @@ function hasEqualsMethod(value) {
|
|
|
15761
15772
|
function isSameThreeType(a, b) {
|
|
15762
15773
|
const obj_a = a;
|
|
15763
15774
|
const obj_b = b;
|
|
15764
|
-
return obj_a.isColor && obj_b.isColor || obj_a.isMatrix3 && obj_b.isMatrix3 || obj_a.isMatrix4 && obj_b.isMatrix4 || obj_a.isEuler && obj_b.isEuler || obj_a.isQuaternion && obj_b.isQuaternion;
|
|
15775
|
+
return obj_a.isColor && obj_b.isColor || obj_a.isMatrix2 && obj_b.isMatrix2 || obj_a.isMatrix3 && obj_b.isMatrix3 || obj_a.isMatrix4 && obj_b.isMatrix4 || obj_a.isEuler && obj_b.isEuler || obj_a.isQuaternion && obj_b.isQuaternion;
|
|
15765
15776
|
}
|
|
15766
15777
|
|
|
15767
15778
|
const uniformOf = tsl.uniform;
|
|
15768
|
-
const isUniformNode = (value) => value !== null && typeof value === "object" && "value" in value && "uuid" in value;
|
|
15769
|
-
const isTSLNode$1 = (value) => value !== null && typeof value === "object" && "uuid" in value && "nodeType" in value;
|
|
15770
15779
|
function useUniform(name, value) {
|
|
15771
15780
|
const store = useStore();
|
|
15772
15781
|
const registered = useScopedResource({
|
|
@@ -15778,7 +15787,7 @@ function useUniform(name, value) {
|
|
|
15778
15787
|
create: () => value === void 0 ? {} : { [name]: value },
|
|
15779
15788
|
prepare: createNamedUniform,
|
|
15780
15789
|
reconcile: (existing2) => {
|
|
15781
|
-
if (value !== void 0 && !isTSLNode
|
|
15790
|
+
if (value !== void 0 && !isTSLNode(value) && !isUniformNode(value)) {
|
|
15782
15791
|
existing2.value = typeof value === "string" ? new webgpu.Color(value) : value;
|
|
15783
15792
|
}
|
|
15784
15793
|
}
|
|
@@ -15794,7 +15803,7 @@ function createNamedUniform(name, value) {
|
|
|
15794
15803
|
let node;
|
|
15795
15804
|
if (isUniformNode(value)) {
|
|
15796
15805
|
node = value;
|
|
15797
|
-
} else if (isTSLNode
|
|
15806
|
+
} else if (isTSLNode(value)) {
|
|
15798
15807
|
node = uniformOf(value);
|
|
15799
15808
|
} else if (typeof value === "string") {
|
|
15800
15809
|
node = tsl.uniform(new webgpu.Color(value));
|
|
@@ -15807,7 +15816,6 @@ function createNamedUniform(name, value) {
|
|
|
15807
15816
|
return node;
|
|
15808
15817
|
}
|
|
15809
15818
|
|
|
15810
|
-
const isTSLNode = (value) => value !== null && typeof value === "object" && ("uuid" in value || "nodeType" in value);
|
|
15811
15819
|
function useNodes(creatorOrScope, scope) {
|
|
15812
15820
|
const store = usePrimaryStore();
|
|
15813
15821
|
const removeNodes2 = React.useCallback(
|
|
@@ -15834,7 +15842,8 @@ function useNodes(creatorOrScope, scope) {
|
|
|
15834
15842
|
return creatorOrScope(createLazyCreatorState(store.getState(), store));
|
|
15835
15843
|
},
|
|
15836
15844
|
prepare: (name, node) => {
|
|
15837
|
-
|
|
15845
|
+
const setName = Reflect.get(node, "setName");
|
|
15846
|
+
if (typeof setName === "function") setName.call(node, scopedNodeName(scope, name));
|
|
15838
15847
|
return node;
|
|
15839
15848
|
}
|
|
15840
15849
|
});
|
|
@@ -15889,13 +15898,6 @@ function useLocalNodes(creator) {
|
|
|
15889
15898
|
}, [store, creator, uniforms, nodes, textures, hmrVersion]);
|
|
15890
15899
|
}
|
|
15891
15900
|
|
|
15892
|
-
const isBufferLike = (value) => {
|
|
15893
|
-
if (value === null || typeof value !== "object") return false;
|
|
15894
|
-
if (ArrayBuffer.isView(value)) return true;
|
|
15895
|
-
if ("isBufferAttribute" in value) return true;
|
|
15896
|
-
if ("uuid" in value || "nodeType" in value) return true;
|
|
15897
|
-
return false;
|
|
15898
|
-
};
|
|
15899
15901
|
const disposeBuffer = (buffer) => {
|
|
15900
15902
|
if (buffer === null || typeof buffer !== "object") return;
|
|
15901
15903
|
if ("dispose" in buffer && typeof buffer.dispose === "function") {
|
|
@@ -15942,9 +15944,8 @@ function useBuffers(creatorOrScope, scope) {
|
|
|
15942
15944
|
return creatorOrScope(createLazyCreatorState(store.getState(), store));
|
|
15943
15945
|
},
|
|
15944
15946
|
prepare: (name, buffer) => {
|
|
15945
|
-
|
|
15946
|
-
|
|
15947
|
-
}
|
|
15947
|
+
const setName = Reflect.get(buffer, "setName");
|
|
15948
|
+
if (typeof setName === "function") setName.call(buffer, scopedNodeName(scope, name));
|
|
15948
15949
|
return buffer;
|
|
15949
15950
|
}
|
|
15950
15951
|
});
|
|
@@ -15961,13 +15962,6 @@ function rebuildAllBuffers(store, scope) {
|
|
|
15961
15962
|
rebuildResource(store, "buffers", scope);
|
|
15962
15963
|
}
|
|
15963
15964
|
|
|
15964
|
-
const isStorageLike = (value) => {
|
|
15965
|
-
if (value === null || typeof value !== "object") return false;
|
|
15966
|
-
if ("isTexture" in value) return true;
|
|
15967
|
-
if ("isData3DTexture" in value) return true;
|
|
15968
|
-
if ("uuid" in value || "nodeType" in value) return true;
|
|
15969
|
-
return false;
|
|
15970
|
-
};
|
|
15971
15965
|
const disposeStorage = (storage) => {
|
|
15972
15966
|
if (storage === null || typeof storage !== "object") return;
|
|
15973
15967
|
if ("dispose" in storage && typeof storage.dispose === "function") {
|
|
@@ -16015,9 +16009,8 @@ function useGPUStorage(creatorOrScope, scope) {
|
|
|
16015
16009
|
},
|
|
16016
16010
|
prepare: (name, storage) => {
|
|
16017
16011
|
const label = scopedNodeName(scope, name);
|
|
16018
|
-
|
|
16019
|
-
|
|
16020
|
-
}
|
|
16012
|
+
const setName = Reflect.get(storage, "setName");
|
|
16013
|
+
if (typeof setName === "function") setName.call(storage, label);
|
|
16021
16014
|
if ("name" in storage && typeof storage.name === "string") {
|
|
16022
16015
|
storage.name = label;
|
|
16023
16016
|
}
|
|
@@ -16159,6 +16152,7 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
16159
16152
|
extend(THREE);
|
|
16160
16153
|
const useThree = useThree$1;
|
|
16161
16154
|
const useFrame = useFrame$1;
|
|
16155
|
+
const Canvas = Canvas$1;
|
|
16162
16156
|
|
|
16163
16157
|
exports.Scheduler = scheduler.Scheduler;
|
|
16164
16158
|
exports.getScheduler = scheduler.getScheduler;
|