@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/webgpu/index.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';
|
|
@@ -519,8 +520,10 @@ function hasVisibilityHandlers(handlers) {
|
|
|
519
520
|
}
|
|
520
521
|
|
|
521
522
|
const FROM_REF = Symbol.for("@react-three/fiber.fromRef");
|
|
522
|
-
function fromRef(ref) {
|
|
523
|
-
|
|
523
|
+
function fromRef(ref, transform) {
|
|
524
|
+
const marker = { [FROM_REF]: ref };
|
|
525
|
+
if (transform) marker.transform = transform;
|
|
526
|
+
return marker;
|
|
524
527
|
}
|
|
525
528
|
function isFromRef(value) {
|
|
526
529
|
return value !== null && typeof value === "object" && FROM_REF in value;
|
|
@@ -621,11 +624,9 @@ function diffProps(instance, newProps) {
|
|
|
621
624
|
for (const prop in instance.props) {
|
|
622
625
|
if (RESERVED_PROPS.includes(prop) || newProps.hasOwnProperty(prop)) continue;
|
|
623
626
|
const { root, key } = resolve(instance.object, prop);
|
|
624
|
-
if (
|
|
627
|
+
if (typeof root?.constructor === "function") {
|
|
625
628
|
const ctor = getMemoizedPrototype(root);
|
|
626
629
|
if (!is.und(ctor)) changedProps[prop] = ctor[key];
|
|
627
|
-
} else {
|
|
628
|
-
changedProps[prop] = 0;
|
|
629
630
|
}
|
|
630
631
|
}
|
|
631
632
|
return changedProps;
|
|
@@ -1058,7 +1059,8 @@ const createStore = (invalidate, advance) => {
|
|
|
1058
1059
|
const resizeTarget = canvasTarget ?? actualRenderer;
|
|
1059
1060
|
if (viewport.dpr > 0) resizeTarget.setPixelRatio(viewport.dpr);
|
|
1060
1061
|
resizeTarget.setSize(size.width, size.height, false);
|
|
1061
|
-
|
|
1062
|
+
const activeTarget = actualRenderer.getCanvasTarget?.();
|
|
1063
|
+
if (!canvasTarget || activeTarget !== canvasTarget) internal.canvasTargetSizeDirty = true;
|
|
1062
1064
|
}
|
|
1063
1065
|
if (camera !== oldCamera) {
|
|
1064
1066
|
oldCamera = camera;
|
|
@@ -1347,12 +1349,24 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
1347
1349
|
TextureLoader,
|
|
1348
1350
|
IsObject(stableInput) ? Object.values(stableInput) : stableInput
|
|
1349
1351
|
);
|
|
1352
|
+
const mappedTextures = useMemo(() => {
|
|
1353
|
+
if (cachedResult) return cachedResult;
|
|
1354
|
+
if (IsObject(stableInput)) {
|
|
1355
|
+
const keyed = {};
|
|
1356
|
+
const textureArray = loadedTextures;
|
|
1357
|
+
let i = 0;
|
|
1358
|
+
for (const key in stableInput) keyed[key] = textureArray[i++];
|
|
1359
|
+
return keyed;
|
|
1360
|
+
} else {
|
|
1361
|
+
return loadedTextures;
|
|
1362
|
+
}
|
|
1363
|
+
}, [stableInput, loadedTextures, cachedResult]);
|
|
1350
1364
|
useLayoutEffect(() => {
|
|
1351
1365
|
if (cachedResult) return;
|
|
1352
1366
|
if (onLoadCalledForRef.current === inputKey) return;
|
|
1353
1367
|
onLoadCalledForRef.current = inputKey;
|
|
1354
|
-
onLoadRef.current?.(
|
|
1355
|
-
}, [cachedResult,
|
|
1368
|
+
onLoadRef.current?.(mappedTextures);
|
|
1369
|
+
}, [cachedResult, mappedTextures, inputKey]);
|
|
1356
1370
|
useEffect(() => {
|
|
1357
1371
|
if (cachedResult) return;
|
|
1358
1372
|
if ("initTexture" in renderer) {
|
|
@@ -1371,18 +1385,6 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
1371
1385
|
});
|
|
1372
1386
|
}
|
|
1373
1387
|
}, [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
1388
|
useEffect(() => {
|
|
1387
1389
|
if (!cache) return;
|
|
1388
1390
|
const urlTextureMap = [];
|
|
@@ -1584,7 +1586,7 @@ function useEnvironment({
|
|
|
1584
1586
|
texture = texture.renderTarget?.texture;
|
|
1585
1587
|
}
|
|
1586
1588
|
texture.mapping = isCubemap ? CubeReflectionMapping : EquirectangularReflectionMapping;
|
|
1587
|
-
texture.colorSpace = colorSpace ?? (isCubemap ? "srgb" : "srgb-linear");
|
|
1589
|
+
texture.colorSpace = colorSpace ?? (isCubemap && extension !== "hdr-cube" ? "srgb" : "srgb-linear");
|
|
1588
1590
|
return texture;
|
|
1589
1591
|
}
|
|
1590
1592
|
const preloadDefaultOptions = {
|
|
@@ -1637,11 +1639,12 @@ function getExtension(files) {
|
|
|
1637
1639
|
const isCubemap = isArray(files) && files.length === 6;
|
|
1638
1640
|
const isGainmap = isArray(files) && files.length === 3 && files.some((file) => file.endsWith("json"));
|
|
1639
1641
|
const firstEntry = isArray(files) ? files[0] : files;
|
|
1640
|
-
const
|
|
1642
|
+
const firstExtension = firstEntry.split(".").pop()?.split("?")?.shift()?.toLowerCase();
|
|
1643
|
+
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
1644
|
return { extension, isCubemap, isGainmap };
|
|
1642
1645
|
}
|
|
1643
1646
|
function getLoader(extension) {
|
|
1644
|
-
const loader = extension === "cube" ? CubeTextureLoader : extension === "hdr" ? HDRLoader : extension === "exr" ? EXRLoader : extension === "jpg" || extension === "jpeg" ? UltraHDRLoader : extension === "webp" ? GainMapLoader : null;
|
|
1647
|
+
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
1648
|
return loader;
|
|
1646
1649
|
}
|
|
1647
1650
|
|
|
@@ -1704,16 +1707,16 @@ function advance(timestamp, runGlobalEffects, state) {
|
|
|
1704
1707
|
else scheduler.step(timestamp);
|
|
1705
1708
|
}
|
|
1706
1709
|
|
|
1707
|
-
const version = "10.0.0-alpha.
|
|
1710
|
+
const version = "10.0.0-alpha.5";
|
|
1708
1711
|
const packageData = {
|
|
1709
1712
|
version: version};
|
|
1710
1713
|
|
|
1711
1714
|
function Xb(Tt) {
|
|
1712
1715
|
return Tt && Tt.__esModule && Object.prototype.hasOwnProperty.call(Tt, "default") ? Tt.default : Tt;
|
|
1713
1716
|
}
|
|
1714
|
-
var Rm = { exports: {} }, Og = { exports: {} }, _b;
|
|
1717
|
+
var Rm = { exports: {} }, Og = { exports: {} }, _b$1;
|
|
1715
1718
|
function Kb() {
|
|
1716
|
-
return _b || (_b = 1, (function(Tt) {
|
|
1719
|
+
return _b$1 || (_b$1 = 1, (function(Tt) {
|
|
1717
1720
|
Tt.exports = function(m) {
|
|
1718
1721
|
function Yn(t, r, a, l) {
|
|
1719
1722
|
return new uc(t, r, a, l);
|
|
@@ -13563,7 +13566,10 @@ function extend(objects) {
|
|
|
13563
13566
|
catalogue[Component] = objects;
|
|
13564
13567
|
return Component;
|
|
13565
13568
|
} else {
|
|
13566
|
-
|
|
13569
|
+
for (const name in objects) {
|
|
13570
|
+
const object = objects[name];
|
|
13571
|
+
if (isConstructor(object)) catalogue[name] = object;
|
|
13572
|
+
}
|
|
13567
13573
|
}
|
|
13568
13574
|
}
|
|
13569
13575
|
function validateInstance(type, props) {
|
|
@@ -13911,7 +13917,7 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13911
13917
|
getRootHostContext: () => NO_CONTEXT,
|
|
13912
13918
|
getChildHostContext: () => NO_CONTEXT,
|
|
13913
13919
|
commitUpdate(instance, type, oldProps, newProps, fiber) {
|
|
13914
|
-
validateInstance(type, newProps);
|
|
13920
|
+
validateInstance(instance.type, newProps);
|
|
13915
13921
|
let reconstruct = false;
|
|
13916
13922
|
if (instance.type === "primitive" && oldProps.object !== newProps.object) reconstruct = true;
|
|
13917
13923
|
else if (newProps.args?.length !== oldProps.args?.length) reconstruct = true;
|
|
@@ -13938,8 +13944,8 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13938
13944
|
for (const prop in instance.props) {
|
|
13939
13945
|
const value = instance.props[prop];
|
|
13940
13946
|
if (isFromRef(value)) {
|
|
13941
|
-
const ref = value
|
|
13942
|
-
if (ref.current != null) resolved[prop] = ref.current;
|
|
13947
|
+
const { [FROM_REF]: ref, transform } = value;
|
|
13948
|
+
if (ref.current != null) resolved[prop] = transform ? transform(ref.current) : ref.current;
|
|
13943
13949
|
}
|
|
13944
13950
|
}
|
|
13945
13951
|
if (Object.keys(resolved).length) applyProps(instance.object, resolved);
|
|
@@ -14220,9 +14226,8 @@ function createRoot(canvas) {
|
|
|
14220
14226
|
if (!renderer.hasInitialized?.()) {
|
|
14221
14227
|
const size2 = computeInitialSize(canvas, propsSize);
|
|
14222
14228
|
if (size2.width > 0 && size2.height > 0) {
|
|
14223
|
-
|
|
14224
|
-
|
|
14225
|
-
canvas.height = size2.height * pixelRatio;
|
|
14229
|
+
renderer.setPixelRatio(calculateDpr(dpr));
|
|
14230
|
+
renderer.setSize(size2.width, size2.height, false);
|
|
14226
14231
|
}
|
|
14227
14232
|
await renderer.init();
|
|
14228
14233
|
}
|
|
@@ -14231,7 +14236,7 @@ function createRoot(canvas) {
|
|
|
14231
14236
|
state.internal.actualRenderer = renderer;
|
|
14232
14237
|
state.set({ webGPUSupported: isWebGPUBackend, renderer, primaryStore: store });
|
|
14233
14238
|
if (canvasId && !state.internal.isSecondary) {
|
|
14234
|
-
const canvasTarget =
|
|
14239
|
+
const canvasTarget = renderer.getCanvasTarget?.();
|
|
14235
14240
|
const unregisterPrimary = registerPrimary(canvasId, renderer, store);
|
|
14236
14241
|
state.set((prev) => ({
|
|
14237
14242
|
internal: {
|
|
@@ -14444,9 +14449,10 @@ function createRoot(canvas) {
|
|
|
14444
14449
|
const unregisterCanvasTarget = scheduler.register(
|
|
14445
14450
|
() => {
|
|
14446
14451
|
const state2 = store.getState();
|
|
14447
|
-
|
|
14452
|
+
const canvasTarget = state2.internal.canvasTarget;
|
|
14453
|
+
if (canvasTarget) {
|
|
14448
14454
|
const renderer2 = state2.internal.actualRenderer;
|
|
14449
|
-
renderer2.setCanvasTarget(
|
|
14455
|
+
if (renderer2.getCanvasTarget() !== canvasTarget) renderer2.setCanvasTarget(canvasTarget);
|
|
14450
14456
|
if (state2.internal.canvasTargetSizeDirty) {
|
|
14451
14457
|
state2.internal.canvasTargetSizeDirty = false;
|
|
14452
14458
|
renderer2.backend?.updateSize?.();
|
|
@@ -14610,7 +14616,7 @@ function unmountComponentAtNode(canvas, callback) {
|
|
|
14610
14616
|
const unregisterPrimary = state.internal.unregisterPrimary;
|
|
14611
14617
|
if (unregisterPrimary) unregisterPrimary();
|
|
14612
14618
|
const canvasTarget = state.internal.canvasTarget;
|
|
14613
|
-
if (canvasTarget?.dispose) canvasTarget.dispose();
|
|
14619
|
+
if (state.internal.isSecondary && canvasTarget?.dispose) canvasTarget.dispose();
|
|
14614
14620
|
state.events.disconnect?.();
|
|
14615
14621
|
cleanupHelperGroup(root.store);
|
|
14616
14622
|
if (state.isLegacy && renderer) {
|
|
@@ -14751,16 +14757,11 @@ function setEnvProps(background, scene, defaultScene, texture, sceneProps = {})
|
|
|
14751
14757
|
const oldbg = target.background;
|
|
14752
14758
|
const oldenv = target.environment;
|
|
14753
14759
|
const oldSceneProps = {
|
|
14754
|
-
// @ts-ignore
|
|
14755
14760
|
backgroundBlurriness: target.backgroundBlurriness,
|
|
14756
|
-
// @ts-ignore
|
|
14757
14761
|
backgroundIntensity: target.backgroundIntensity,
|
|
14758
|
-
|
|
14759
|
-
backgroundRotation: target.backgroundRotation?.clone?.() ?? [0, 0, 0],
|
|
14760
|
-
// @ts-ignore
|
|
14762
|
+
backgroundRotation: target.backgroundRotation.clone(),
|
|
14761
14763
|
environmentIntensity: target.environmentIntensity,
|
|
14762
|
-
|
|
14763
|
-
environmentRotation: target.environmentRotation?.clone?.() ?? [0, 0, 0]
|
|
14764
|
+
environmentRotation: target.environmentRotation.clone()
|
|
14764
14765
|
};
|
|
14765
14766
|
if (background !== "only") target.environment = texture;
|
|
14766
14767
|
if (background) target.background = texture;
|
|
@@ -15354,20 +15355,36 @@ function CanvasImpl({
|
|
|
15354
15355
|
}
|
|
15355
15356
|
);
|
|
15356
15357
|
}
|
|
15357
|
-
function Canvas(props) {
|
|
15358
|
+
function Canvas$1(props) {
|
|
15358
15359
|
return /* @__PURE__ */ jsx(FiberProvider, { children: /* @__PURE__ */ jsx(CanvasImpl, { ...props }) });
|
|
15359
15360
|
}
|
|
15360
15361
|
|
|
15362
|
+
const isObjectLike = (value) => value !== null && (typeof value === "object" || typeof value === "function");
|
|
15363
|
+
const hasValidLegacyNodeMarkers = (value) => {
|
|
15364
|
+
const hasUuid = "uuid" in value;
|
|
15365
|
+
const hasNodeType = "nodeType" in value;
|
|
15366
|
+
const uuid = Reflect.get(value, "uuid");
|
|
15367
|
+
const nodeType = Reflect.get(value, "nodeType");
|
|
15368
|
+
return (hasUuid || hasNodeType) && (!hasUuid || uuid === void 0 || typeof uuid === "string") && (!hasNodeType || nodeType === void 0 || nodeType === null || typeof nodeType === "string");
|
|
15369
|
+
};
|
|
15370
|
+
const isUniformNode = (value) => isObjectLike(value) && "isUniformNode" in value && value.isUniformNode === true;
|
|
15371
|
+
const isTSLNode = (value) => isObjectLike(value) && (Reflect.get(value, "isNode") === true || Reflect.get(value, "shaderNode") !== void 0 && typeof Reflect.get(value, "id") === "number" || hasValidLegacyNodeMarkers(value));
|
|
15372
|
+
const isBufferLike = (value) => ArrayBuffer.isView(value) && !(value instanceof DataView) || isObjectLike(value) && ("isBufferAttribute" in value || "isInterleavedBufferAttribute" in value || isTSLNode(value));
|
|
15373
|
+
const isStorageLike = (value) => isObjectLike(value) && ("isTexture" in value || "isData3DTexture" in value || isTSLNode(value));
|
|
15374
|
+
|
|
15361
15375
|
var __defProp = Object.defineProperty;
|
|
15362
15376
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
15363
15377
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
15364
|
-
var _a;
|
|
15378
|
+
var _a, _b;
|
|
15365
15379
|
const INTERNAL_DATA = Symbol("ScopedStore.data");
|
|
15366
|
-
|
|
15380
|
+
const INTERNAL_IS_LEAF = Symbol("ScopedStore.isLeaf");
|
|
15381
|
+
_b = INTERNAL_DATA, _a = INTERNAL_IS_LEAF;
|
|
15367
15382
|
const _ScopedStore = class _ScopedStore {
|
|
15368
|
-
constructor(data) {
|
|
15383
|
+
constructor(data, isLeaf) {
|
|
15384
|
+
__publicField(this, _b);
|
|
15369
15385
|
__publicField(this, _a);
|
|
15370
15386
|
this[INTERNAL_DATA] = data;
|
|
15387
|
+
this[INTERNAL_IS_LEAF] = isLeaf;
|
|
15371
15388
|
return new Proxy(this, {
|
|
15372
15389
|
get(target, prop, receiver) {
|
|
15373
15390
|
if (typeof prop === "string") {
|
|
@@ -15401,10 +15418,10 @@ const _ScopedStore = class _ScopedStore {
|
|
|
15401
15418
|
* If the key doesn't exist or isn't a scope object, returns an empty ScopedStore.
|
|
15402
15419
|
*/
|
|
15403
15420
|
scope(key) {
|
|
15404
|
-
const
|
|
15405
|
-
|
|
15406
|
-
|
|
15407
|
-
);
|
|
15421
|
+
const value = this[INTERNAL_DATA][key];
|
|
15422
|
+
const isLeaf = this[INTERNAL_IS_LEAF];
|
|
15423
|
+
const scope = value && typeof value === "object" && !isLeaf(value) ? value : {};
|
|
15424
|
+
return new _ScopedStore(scope, isLeaf);
|
|
15408
15425
|
}
|
|
15409
15426
|
/**
|
|
15410
15427
|
* Check if a key exists in the store.
|
|
@@ -15420,8 +15437,8 @@ const _ScopedStore = class _ScopedStore {
|
|
|
15420
15437
|
}
|
|
15421
15438
|
};
|
|
15422
15439
|
let ScopedStore = _ScopedStore;
|
|
15423
|
-
function createScopedStore(data) {
|
|
15424
|
-
return new ScopedStore(data);
|
|
15440
|
+
function createScopedStore(data, isLeaf) {
|
|
15441
|
+
return new ScopedStore(data, isLeaf);
|
|
15425
15442
|
}
|
|
15426
15443
|
function createLazyCreatorState(state, store) {
|
|
15427
15444
|
let _uniforms = null;
|
|
@@ -15432,22 +15449,22 @@ function createLazyCreatorState(state, store) {
|
|
|
15432
15449
|
return Object.create(state, {
|
|
15433
15450
|
uniforms: {
|
|
15434
15451
|
get() {
|
|
15435
|
-
return _uniforms ?? (_uniforms = createScopedStore(view("uniforms")));
|
|
15452
|
+
return _uniforms ?? (_uniforms = createScopedStore(view("uniforms"), isUniformNode));
|
|
15436
15453
|
}
|
|
15437
15454
|
},
|
|
15438
15455
|
nodes: {
|
|
15439
15456
|
get() {
|
|
15440
|
-
return _nodes ?? (_nodes = createScopedStore(view("nodes")));
|
|
15457
|
+
return _nodes ?? (_nodes = createScopedStore(view("nodes"), isTSLNode));
|
|
15441
15458
|
}
|
|
15442
15459
|
},
|
|
15443
15460
|
buffers: {
|
|
15444
15461
|
get() {
|
|
15445
|
-
return _buffers ?? (_buffers = createScopedStore(view("buffers")));
|
|
15462
|
+
return _buffers ?? (_buffers = createScopedStore(view("buffers"), isBufferLike));
|
|
15446
15463
|
}
|
|
15447
15464
|
},
|
|
15448
15465
|
gpuStorage: {
|
|
15449
15466
|
get() {
|
|
15450
|
-
return _gpuStorage ?? (_gpuStorage = createScopedStore(view("gpuStorage")));
|
|
15467
|
+
return _gpuStorage ?? (_gpuStorage = createScopedStore(view("gpuStorage"), isStorageLike));
|
|
15451
15468
|
}
|
|
15452
15469
|
}
|
|
15453
15470
|
});
|
|
@@ -15548,7 +15565,7 @@ function vectorize(inObject) {
|
|
|
15548
15565
|
return extractTSLValue(inObject);
|
|
15549
15566
|
}
|
|
15550
15567
|
if (obj.isVector2 || obj.isVector3 || obj.isVector4) return inObject;
|
|
15551
|
-
if (obj.isMatrix3 || obj.isMatrix4) return inObject;
|
|
15568
|
+
if (obj.isMatrix2 || obj.isMatrix3 || obj.isMatrix4) return inObject;
|
|
15552
15569
|
if (obj.isColor || obj.isEuler || obj.isQuaternion || obj.isSpherical) return inObject;
|
|
15553
15570
|
if ("r" in obj && "g" in obj && "b" in obj && typeof obj.r === "number" && typeof obj.g === "number" && typeof obj.b === "number") {
|
|
15554
15571
|
const scale = obj.r > 1 || obj.g > 1 || obj.b > 1 ? 1 / 255 : 1;
|
|
@@ -15606,22 +15623,21 @@ function useScopedResource(options) {
|
|
|
15606
15623
|
return entries;
|
|
15607
15624
|
}
|
|
15608
15625
|
|
|
15609
|
-
const isUniformNode$1 = (value) => value !== null && typeof value === "object" && "value" in value && "uuid" in value;
|
|
15610
15626
|
function useUniforms(creatorOrScope, scope) {
|
|
15611
15627
|
const store = usePrimaryStore();
|
|
15612
15628
|
const removeUniforms2 = useCallback(
|
|
15613
|
-
(names, targetScope) => removeResourceEntries(store, "uniforms", Array.isArray(names) ? names : [names], targetScope, isUniformNode
|
|
15629
|
+
(names, targetScope) => removeResourceEntries(store, "uniforms", Array.isArray(names) ? names : [names], targetScope, isUniformNode),
|
|
15614
15630
|
[store]
|
|
15615
15631
|
);
|
|
15616
15632
|
const clearUniforms = useCallback(
|
|
15617
|
-
(targetScope) => clearResourceEntries(store, "uniforms", targetScope, isUniformNode
|
|
15633
|
+
(targetScope) => clearResourceEntries(store, "uniforms", targetScope, isUniformNode),
|
|
15618
15634
|
[store]
|
|
15619
15635
|
);
|
|
15620
15636
|
const rebuildUniforms = useCallback(
|
|
15621
15637
|
(targetScope) => rebuildResource(store, "uniforms", targetScope),
|
|
15622
15638
|
[store]
|
|
15623
15639
|
);
|
|
15624
|
-
const
|
|
15640
|
+
const processedInput = useMemo(() => {
|
|
15625
15641
|
let raw = creatorOrScope;
|
|
15626
15642
|
if (is.fun(creatorOrScope)) {
|
|
15627
15643
|
const wrappedState = createLazyCreatorState(store.getState(), store);
|
|
@@ -15632,23 +15648,24 @@ function useUniforms(creatorOrScope, scope) {
|
|
|
15632
15648
|
for (const [key, value] of Object.entries(raw)) {
|
|
15633
15649
|
normalized[key] = vectorize(value);
|
|
15634
15650
|
}
|
|
15635
|
-
return normalized;
|
|
15651
|
+
return { candidates: raw, normalized };
|
|
15636
15652
|
}
|
|
15637
|
-
return raw;
|
|
15653
|
+
return { candidates: raw, normalized: raw };
|
|
15638
15654
|
}, [creatorOrScope, store]);
|
|
15639
|
-
const memoizedInput = useCompareMemoize(
|
|
15655
|
+
const memoizedInput = useCompareMemoize(processedInput.normalized);
|
|
15640
15656
|
const isReader = memoizedInput === void 0 || typeof memoizedInput === "string";
|
|
15641
15657
|
const storeUniforms = usePrimaryThree((s) => s.uniforms);
|
|
15642
15658
|
const created = useScopedResource({
|
|
15643
15659
|
store,
|
|
15644
15660
|
kind: "uniforms",
|
|
15645
15661
|
scope: isReader ? void 0 : scope,
|
|
15646
|
-
isLeaf: isUniformNode
|
|
15662
|
+
isLeaf: isUniformNode,
|
|
15647
15663
|
input: memoizedInput,
|
|
15648
15664
|
create: () => {
|
|
15649
15665
|
if (isReader) return {};
|
|
15650
|
-
if (typeof
|
|
15651
|
-
|
|
15666
|
+
if (typeof processedInput.candidates !== "object" || processedInput.candidates === null)
|
|
15667
|
+
throw new Error("Invalid uniform input");
|
|
15668
|
+
return processedInput.candidates;
|
|
15652
15669
|
},
|
|
15653
15670
|
prepare: (name, candidate) => createUniform(name, candidate, scope),
|
|
15654
15671
|
reconcile: (existing, candidate) => {
|
|
@@ -15670,7 +15687,7 @@ function useUniforms(creatorOrScope, scope) {
|
|
|
15670
15687
|
uniforms = storeUniforms;
|
|
15671
15688
|
} else if (typeof memoizedInput === "string") {
|
|
15672
15689
|
const scopeData = storeUniforms[memoizedInput];
|
|
15673
|
-
uniforms = scopeData && !isUniformNode
|
|
15690
|
+
uniforms = scopeData && !isUniformNode(scopeData) ? scopeData : {};
|
|
15674
15691
|
}
|
|
15675
15692
|
return { ...uniforms, removeUniforms: removeUniforms2, clearUniforms, rebuildUniforms };
|
|
15676
15693
|
}
|
|
@@ -15685,7 +15702,7 @@ function removeUniforms(set, names, scope) {
|
|
|
15685
15702
|
return { uniforms: { ...state.uniforms, [scope]: currentScope } };
|
|
15686
15703
|
}
|
|
15687
15704
|
const uniforms = { ...state.uniforms };
|
|
15688
|
-
for (const name of names) if (isUniformNode
|
|
15705
|
+
for (const name of names) if (isUniformNode(uniforms[name])) delete uniforms[name];
|
|
15689
15706
|
return { uniforms };
|
|
15690
15707
|
});
|
|
15691
15708
|
}
|
|
@@ -15699,7 +15716,7 @@ function clearRootUniforms(set) {
|
|
|
15699
15716
|
set((state) => {
|
|
15700
15717
|
const uniforms = {};
|
|
15701
15718
|
for (const [key, value] of Object.entries(state.uniforms)) {
|
|
15702
|
-
if (!isUniformNode
|
|
15719
|
+
if (!isUniformNode(value)) uniforms[key] = value;
|
|
15703
15720
|
}
|
|
15704
15721
|
return { uniforms };
|
|
15705
15722
|
});
|
|
@@ -15735,12 +15752,10 @@ function hasEqualsMethod(value) {
|
|
|
15735
15752
|
function isSameThreeType(a, b) {
|
|
15736
15753
|
const obj_a = a;
|
|
15737
15754
|
const obj_b = b;
|
|
15738
|
-
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;
|
|
15755
|
+
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;
|
|
15739
15756
|
}
|
|
15740
15757
|
|
|
15741
15758
|
const uniformOf = uniform;
|
|
15742
|
-
const isUniformNode = (value) => value !== null && typeof value === "object" && "value" in value && "uuid" in value;
|
|
15743
|
-
const isTSLNode$1 = (value) => value !== null && typeof value === "object" && "uuid" in value && "nodeType" in value;
|
|
15744
15759
|
function useUniform(name, value) {
|
|
15745
15760
|
const store = useStore();
|
|
15746
15761
|
const registered = useScopedResource({
|
|
@@ -15752,7 +15767,7 @@ function useUniform(name, value) {
|
|
|
15752
15767
|
create: () => value === void 0 ? {} : { [name]: value },
|
|
15753
15768
|
prepare: createNamedUniform,
|
|
15754
15769
|
reconcile: (existing2) => {
|
|
15755
|
-
if (value !== void 0 && !isTSLNode
|
|
15770
|
+
if (value !== void 0 && !isTSLNode(value) && !isUniformNode(value)) {
|
|
15756
15771
|
existing2.value = typeof value === "string" ? new Color(value) : value;
|
|
15757
15772
|
}
|
|
15758
15773
|
}
|
|
@@ -15768,7 +15783,7 @@ function createNamedUniform(name, value) {
|
|
|
15768
15783
|
let node;
|
|
15769
15784
|
if (isUniformNode(value)) {
|
|
15770
15785
|
node = value;
|
|
15771
|
-
} else if (isTSLNode
|
|
15786
|
+
} else if (isTSLNode(value)) {
|
|
15772
15787
|
node = uniformOf(value);
|
|
15773
15788
|
} else if (typeof value === "string") {
|
|
15774
15789
|
node = uniform(new Color(value));
|
|
@@ -15781,7 +15796,6 @@ function createNamedUniform(name, value) {
|
|
|
15781
15796
|
return node;
|
|
15782
15797
|
}
|
|
15783
15798
|
|
|
15784
|
-
const isTSLNode = (value) => value !== null && typeof value === "object" && ("uuid" in value || "nodeType" in value);
|
|
15785
15799
|
function useNodes(creatorOrScope, scope) {
|
|
15786
15800
|
const store = usePrimaryStore();
|
|
15787
15801
|
const removeNodes2 = useCallback(
|
|
@@ -15808,7 +15822,8 @@ function useNodes(creatorOrScope, scope) {
|
|
|
15808
15822
|
return creatorOrScope(createLazyCreatorState(store.getState(), store));
|
|
15809
15823
|
},
|
|
15810
15824
|
prepare: (name, node) => {
|
|
15811
|
-
|
|
15825
|
+
const setName = Reflect.get(node, "setName");
|
|
15826
|
+
if (typeof setName === "function") setName.call(node, scopedNodeName(scope, name));
|
|
15812
15827
|
return node;
|
|
15813
15828
|
}
|
|
15814
15829
|
});
|
|
@@ -15863,13 +15878,6 @@ function useLocalNodes(creator) {
|
|
|
15863
15878
|
}, [store, creator, uniforms, nodes, textures, hmrVersion]);
|
|
15864
15879
|
}
|
|
15865
15880
|
|
|
15866
|
-
const isBufferLike = (value) => {
|
|
15867
|
-
if (value === null || typeof value !== "object") return false;
|
|
15868
|
-
if (ArrayBuffer.isView(value)) return true;
|
|
15869
|
-
if ("isBufferAttribute" in value) return true;
|
|
15870
|
-
if ("uuid" in value || "nodeType" in value) return true;
|
|
15871
|
-
return false;
|
|
15872
|
-
};
|
|
15873
15881
|
const disposeBuffer = (buffer) => {
|
|
15874
15882
|
if (buffer === null || typeof buffer !== "object") return;
|
|
15875
15883
|
if ("dispose" in buffer && typeof buffer.dispose === "function") {
|
|
@@ -15916,9 +15924,8 @@ function useBuffers(creatorOrScope, scope) {
|
|
|
15916
15924
|
return creatorOrScope(createLazyCreatorState(store.getState(), store));
|
|
15917
15925
|
},
|
|
15918
15926
|
prepare: (name, buffer) => {
|
|
15919
|
-
|
|
15920
|
-
|
|
15921
|
-
}
|
|
15927
|
+
const setName = Reflect.get(buffer, "setName");
|
|
15928
|
+
if (typeof setName === "function") setName.call(buffer, scopedNodeName(scope, name));
|
|
15922
15929
|
return buffer;
|
|
15923
15930
|
}
|
|
15924
15931
|
});
|
|
@@ -15935,13 +15942,6 @@ function rebuildAllBuffers(store, scope) {
|
|
|
15935
15942
|
rebuildResource(store, "buffers", scope);
|
|
15936
15943
|
}
|
|
15937
15944
|
|
|
15938
|
-
const isStorageLike = (value) => {
|
|
15939
|
-
if (value === null || typeof value !== "object") return false;
|
|
15940
|
-
if ("isTexture" in value) return true;
|
|
15941
|
-
if ("isData3DTexture" in value) return true;
|
|
15942
|
-
if ("uuid" in value || "nodeType" in value) return true;
|
|
15943
|
-
return false;
|
|
15944
|
-
};
|
|
15945
15945
|
const disposeStorage = (storage) => {
|
|
15946
15946
|
if (storage === null || typeof storage !== "object") return;
|
|
15947
15947
|
if ("dispose" in storage && typeof storage.dispose === "function") {
|
|
@@ -15989,9 +15989,8 @@ function useGPUStorage(creatorOrScope, scope) {
|
|
|
15989
15989
|
},
|
|
15990
15990
|
prepare: (name, storage) => {
|
|
15991
15991
|
const label = scopedNodeName(scope, name);
|
|
15992
|
-
|
|
15993
|
-
|
|
15994
|
-
}
|
|
15992
|
+
const setName = Reflect.get(storage, "setName");
|
|
15993
|
+
if (typeof setName === "function") setName.call(storage, label);
|
|
15995
15994
|
if ("name" in storage && typeof storage.name === "string") {
|
|
15996
15995
|
storage.name = label;
|
|
15997
15996
|
}
|
|
@@ -16040,7 +16039,7 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
16040
16039
|
renderPipeline: null,
|
|
16041
16040
|
passes: {}
|
|
16042
16041
|
});
|
|
16043
|
-
scenePassCacheRef.current?.scenePass
|
|
16042
|
+
scenePassCacheRef.current?.scenePass.dispose();
|
|
16044
16043
|
callbacksRanRef.current = false;
|
|
16045
16044
|
scenePassCacheRef.current = null;
|
|
16046
16045
|
forceScenePassRebuildRef.current = false;
|
|
@@ -16055,6 +16054,9 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
16055
16054
|
throw new Error("useRenderPipeline is only available with WebGPU renderer. Set renderer prop on Canvas.");
|
|
16056
16055
|
}
|
|
16057
16056
|
if (!renderer || !scene || !camera) return;
|
|
16057
|
+
if (!("isWebGPURenderer" in renderer)) {
|
|
16058
|
+
throw new Error("useRenderPipeline: renderer is not a WebGPURenderer but isLegacy is false.");
|
|
16059
|
+
}
|
|
16058
16060
|
const state = store.getState();
|
|
16059
16061
|
const set = store.setState;
|
|
16060
16062
|
try {
|
|
@@ -16088,7 +16090,9 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
16088
16090
|
if (setupCBRef.current) {
|
|
16089
16091
|
const freshState = Object.assign({}, store.getState(), {
|
|
16090
16092
|
renderPipeline: pipeline,
|
|
16091
|
-
passes: currentPasses
|
|
16093
|
+
passes: { ...currentPasses, scenePass },
|
|
16094
|
+
renderer,
|
|
16095
|
+
isLegacy: false
|
|
16092
16096
|
});
|
|
16093
16097
|
const setupResult = setupCBRef.current(freshState);
|
|
16094
16098
|
if (setupResult && typeof setupResult === "object") {
|
|
@@ -16099,7 +16103,9 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
16099
16103
|
if (mainCBRef.current) {
|
|
16100
16104
|
const freshState = Object.assign({}, store.getState(), {
|
|
16101
16105
|
renderPipeline: pipeline,
|
|
16102
|
-
passes: currentPasses
|
|
16106
|
+
passes: { ...currentPasses, scenePass },
|
|
16107
|
+
renderer,
|
|
16108
|
+
isLegacy: false
|
|
16103
16109
|
});
|
|
16104
16110
|
const mainResult = mainCBRef.current(freshState);
|
|
16105
16111
|
if (mainResult && typeof mainResult === "object") {
|
|
@@ -16111,26 +16117,21 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
16111
16117
|
callbacksRanRef.current = true;
|
|
16112
16118
|
}
|
|
16113
16119
|
if (outputNodeChanged) pipeline.needsUpdate = true;
|
|
16114
|
-
if (outgoingScenePass && outgoingScenePass !== scenePass) outgoingScenePass.dispose
|
|
16120
|
+
if (outgoingScenePass && outgoingScenePass !== scenePass) outgoingScenePass.dispose();
|
|
16115
16121
|
} catch (error) {
|
|
16116
16122
|
console.warn("[useRenderPipeline] Setup failed; the render pipeline was not configured:", error);
|
|
16117
16123
|
}
|
|
16118
16124
|
}, [store, renderer, scene, camera, isLegacy, rebuildVersion]);
|
|
16119
16125
|
const passes = useThree$1((s) => s.passes);
|
|
16120
16126
|
const renderPipeline = useThree$1((s) => s.renderPipeline);
|
|
16121
|
-
|
|
16122
|
-
|
|
16123
|
-
|
|
16124
|
-
clearPasses,
|
|
16125
|
-
reset,
|
|
16126
|
-
rebuild,
|
|
16127
|
-
// isReady indicates if RenderPipeline is configured and ready for rendering
|
|
16128
|
-
isReady: renderPipeline !== null
|
|
16129
|
-
};
|
|
16127
|
+
const actions = { passes, clearPasses, reset, rebuild };
|
|
16128
|
+
if (renderPipeline) return { ...actions, isReady: true, renderPipeline };
|
|
16129
|
+
return { ...actions, isReady: false, renderPipeline: null };
|
|
16130
16130
|
}
|
|
16131
16131
|
|
|
16132
16132
|
extend(THREE);
|
|
16133
16133
|
const useThree = useThree$1;
|
|
16134
16134
|
const useFrame = useFrame$1;
|
|
16135
|
+
const Canvas = Canvas$1;
|
|
16135
16136
|
|
|
16136
16137
|
export { Block, Canvas, Environment, EnvironmentCube, EnvironmentMap, EnvironmentPortal, ErrorBoundary, FROM_REF, IsObject, ONCE, Portal, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, Texture, _roots, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, clearNodeScope, clearRootNodes, clearRootUniforms, clearScope, context, createEvents, createPointerEvents, createPortal, createRoot, createScopedStore, createStore, createTextureOperations, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, fromRef, getInstanceProps, getPrimary, getPrimaryIds, getRootState, getUuidPrefix, hasConstructor, hasPrimary, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isFromRef, isObject3D, isOnce, isOrthographicCamera, isRef$1 as isRef, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, rebuildAllBuffers, rebuildAllNodes, rebuildAllStorage, rebuildAllUniforms, reconciler, registerPrimary, removeInteractivity, removeNodes, removeUniforms, resolve, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useBuffers, useEnvironment, useFrame, useGPUStorage, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useLocalNodes, useMutableCallback, useNodes, useRenderPipeline, useRenderTarget, useStore, useTexture, useTextures, useThree, useUniform, useUniforms, waitForPrimary };
|