@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.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;
|
|
@@ -641,11 +644,9 @@ function diffProps(instance, newProps) {
|
|
|
641
644
|
for (const prop in instance.props) {
|
|
642
645
|
if (RESERVED_PROPS.includes(prop) || newProps.hasOwnProperty(prop)) continue;
|
|
643
646
|
const { root, key } = resolve(instance.object, prop);
|
|
644
|
-
if (
|
|
647
|
+
if (typeof root?.constructor === "function") {
|
|
645
648
|
const ctor = getMemoizedPrototype(root);
|
|
646
649
|
if (!is.und(ctor)) changedProps[prop] = ctor[key];
|
|
647
|
-
} else {
|
|
648
|
-
changedProps[prop] = 0;
|
|
649
650
|
}
|
|
650
651
|
}
|
|
651
652
|
return changedProps;
|
|
@@ -1078,7 +1079,8 @@ const createStore = (invalidate, advance) => {
|
|
|
1078
1079
|
const resizeTarget = canvasTarget ?? actualRenderer;
|
|
1079
1080
|
if (viewport.dpr > 0) resizeTarget.setPixelRatio(viewport.dpr);
|
|
1080
1081
|
resizeTarget.setSize(size.width, size.height, false);
|
|
1081
|
-
|
|
1082
|
+
const activeTarget = actualRenderer.getCanvasTarget?.();
|
|
1083
|
+
if (!canvasTarget || activeTarget !== canvasTarget) internal.canvasTargetSizeDirty = true;
|
|
1082
1084
|
}
|
|
1083
1085
|
if (camera !== oldCamera) {
|
|
1084
1086
|
oldCamera = camera;
|
|
@@ -1367,12 +1369,24 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
1367
1369
|
webgpu.TextureLoader,
|
|
1368
1370
|
IsObject(stableInput) ? Object.values(stableInput) : stableInput
|
|
1369
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]);
|
|
1370
1384
|
React.useLayoutEffect(() => {
|
|
1371
1385
|
if (cachedResult) return;
|
|
1372
1386
|
if (onLoadCalledForRef.current === inputKey) return;
|
|
1373
1387
|
onLoadCalledForRef.current = inputKey;
|
|
1374
|
-
onLoadRef.current?.(
|
|
1375
|
-
}, [cachedResult,
|
|
1388
|
+
onLoadRef.current?.(mappedTextures);
|
|
1389
|
+
}, [cachedResult, mappedTextures, inputKey]);
|
|
1376
1390
|
React.useEffect(() => {
|
|
1377
1391
|
if (cachedResult) return;
|
|
1378
1392
|
if ("initTexture" in renderer) {
|
|
@@ -1391,18 +1405,6 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
1391
1405
|
});
|
|
1392
1406
|
}
|
|
1393
1407
|
}, [renderer, loadedTextures, cachedResult]);
|
|
1394
|
-
const mappedTextures = React.useMemo(() => {
|
|
1395
|
-
if (cachedResult) return cachedResult;
|
|
1396
|
-
if (IsObject(stableInput)) {
|
|
1397
|
-
const keyed = {};
|
|
1398
|
-
const textureArray = loadedTextures;
|
|
1399
|
-
let i = 0;
|
|
1400
|
-
for (const key in stableInput) keyed[key] = textureArray[i++];
|
|
1401
|
-
return keyed;
|
|
1402
|
-
} else {
|
|
1403
|
-
return loadedTextures;
|
|
1404
|
-
}
|
|
1405
|
-
}, [stableInput, loadedTextures, cachedResult]);
|
|
1406
1408
|
React.useEffect(() => {
|
|
1407
1409
|
if (!cache) return;
|
|
1408
1410
|
const urlTextureMap = [];
|
|
@@ -1604,7 +1606,7 @@ function useEnvironment({
|
|
|
1604
1606
|
texture = texture.renderTarget?.texture;
|
|
1605
1607
|
}
|
|
1606
1608
|
texture.mapping = isCubemap ? webgpu.CubeReflectionMapping : webgpu.EquirectangularReflectionMapping;
|
|
1607
|
-
texture.colorSpace = colorSpace ?? (isCubemap ? "srgb" : "srgb-linear");
|
|
1609
|
+
texture.colorSpace = colorSpace ?? (isCubemap && extension !== "hdr-cube" ? "srgb" : "srgb-linear");
|
|
1608
1610
|
return texture;
|
|
1609
1611
|
}
|
|
1610
1612
|
const preloadDefaultOptions = {
|
|
@@ -1657,11 +1659,12 @@ function getExtension(files) {
|
|
|
1657
1659
|
const isCubemap = isArray(files) && files.length === 6;
|
|
1658
1660
|
const isGainmap = isArray(files) && files.length === 3 && files.some((file) => file.endsWith("json"));
|
|
1659
1661
|
const firstEntry = isArray(files) ? files[0] : files;
|
|
1660
|
-
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;
|
|
1661
1664
|
return { extension, isCubemap, isGainmap };
|
|
1662
1665
|
}
|
|
1663
1666
|
function getLoader(extension) {
|
|
1664
|
-
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;
|
|
1665
1668
|
return loader;
|
|
1666
1669
|
}
|
|
1667
1670
|
|
|
@@ -1724,16 +1727,16 @@ function advance(timestamp, runGlobalEffects, state) {
|
|
|
1724
1727
|
else scheduler$1.step(timestamp);
|
|
1725
1728
|
}
|
|
1726
1729
|
|
|
1727
|
-
const version = "10.0.0-alpha.
|
|
1730
|
+
const version = "10.0.0-alpha.5";
|
|
1728
1731
|
const packageData = {
|
|
1729
1732
|
version: version};
|
|
1730
1733
|
|
|
1731
1734
|
function Xb(Tt) {
|
|
1732
1735
|
return Tt && Tt.__esModule && Object.prototype.hasOwnProperty.call(Tt, "default") ? Tt.default : Tt;
|
|
1733
1736
|
}
|
|
1734
|
-
var Rm = { exports: {} }, Og = { exports: {} }, _b;
|
|
1737
|
+
var Rm = { exports: {} }, Og = { exports: {} }, _b$1;
|
|
1735
1738
|
function Kb() {
|
|
1736
|
-
return _b || (_b = 1, (function(Tt) {
|
|
1739
|
+
return _b$1 || (_b$1 = 1, (function(Tt) {
|
|
1737
1740
|
Tt.exports = function(m) {
|
|
1738
1741
|
function Yn(t, r, a, l) {
|
|
1739
1742
|
return new uc(t, r, a, l);
|
|
@@ -13583,7 +13586,10 @@ function extend(objects) {
|
|
|
13583
13586
|
catalogue[Component] = objects;
|
|
13584
13587
|
return Component;
|
|
13585
13588
|
} else {
|
|
13586
|
-
|
|
13589
|
+
for (const name in objects) {
|
|
13590
|
+
const object = objects[name];
|
|
13591
|
+
if (isConstructor(object)) catalogue[name] = object;
|
|
13592
|
+
}
|
|
13587
13593
|
}
|
|
13588
13594
|
}
|
|
13589
13595
|
function validateInstance(type, props) {
|
|
@@ -13931,7 +13937,7 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13931
13937
|
getRootHostContext: () => NO_CONTEXT,
|
|
13932
13938
|
getChildHostContext: () => NO_CONTEXT,
|
|
13933
13939
|
commitUpdate(instance, type, oldProps, newProps, fiber) {
|
|
13934
|
-
validateInstance(type, newProps);
|
|
13940
|
+
validateInstance(instance.type, newProps);
|
|
13935
13941
|
let reconstruct = false;
|
|
13936
13942
|
if (instance.type === "primitive" && oldProps.object !== newProps.object) reconstruct = true;
|
|
13937
13943
|
else if (newProps.args?.length !== oldProps.args?.length) reconstruct = true;
|
|
@@ -13958,8 +13964,8 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13958
13964
|
for (const prop in instance.props) {
|
|
13959
13965
|
const value = instance.props[prop];
|
|
13960
13966
|
if (isFromRef(value)) {
|
|
13961
|
-
const ref = value
|
|
13962
|
-
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;
|
|
13963
13969
|
}
|
|
13964
13970
|
}
|
|
13965
13971
|
if (Object.keys(resolved).length) applyProps(instance.object, resolved);
|
|
@@ -14240,9 +14246,8 @@ function createRoot(canvas) {
|
|
|
14240
14246
|
if (!renderer.hasInitialized?.()) {
|
|
14241
14247
|
const size2 = computeInitialSize(canvas, propsSize);
|
|
14242
14248
|
if (size2.width > 0 && size2.height > 0) {
|
|
14243
|
-
|
|
14244
|
-
|
|
14245
|
-
canvas.height = size2.height * pixelRatio;
|
|
14249
|
+
renderer.setPixelRatio(calculateDpr(dpr));
|
|
14250
|
+
renderer.setSize(size2.width, size2.height, false);
|
|
14246
14251
|
}
|
|
14247
14252
|
await renderer.init();
|
|
14248
14253
|
}
|
|
@@ -14251,7 +14256,7 @@ function createRoot(canvas) {
|
|
|
14251
14256
|
state.internal.actualRenderer = renderer;
|
|
14252
14257
|
state.set({ webGPUSupported: isWebGPUBackend, renderer, primaryStore: store });
|
|
14253
14258
|
if (canvasId && !state.internal.isSecondary) {
|
|
14254
|
-
const canvasTarget =
|
|
14259
|
+
const canvasTarget = renderer.getCanvasTarget?.();
|
|
14255
14260
|
const unregisterPrimary = registerPrimary(canvasId, renderer, store);
|
|
14256
14261
|
state.set((prev) => ({
|
|
14257
14262
|
internal: {
|
|
@@ -14464,9 +14469,10 @@ function createRoot(canvas) {
|
|
|
14464
14469
|
const unregisterCanvasTarget = scheduler$1.register(
|
|
14465
14470
|
() => {
|
|
14466
14471
|
const state2 = store.getState();
|
|
14467
|
-
|
|
14472
|
+
const canvasTarget = state2.internal.canvasTarget;
|
|
14473
|
+
if (canvasTarget) {
|
|
14468
14474
|
const renderer2 = state2.internal.actualRenderer;
|
|
14469
|
-
renderer2.setCanvasTarget(
|
|
14475
|
+
if (renderer2.getCanvasTarget() !== canvasTarget) renderer2.setCanvasTarget(canvasTarget);
|
|
14470
14476
|
if (state2.internal.canvasTargetSizeDirty) {
|
|
14471
14477
|
state2.internal.canvasTargetSizeDirty = false;
|
|
14472
14478
|
renderer2.backend?.updateSize?.();
|
|
@@ -14630,7 +14636,7 @@ function unmountComponentAtNode(canvas, callback) {
|
|
|
14630
14636
|
const unregisterPrimary = state.internal.unregisterPrimary;
|
|
14631
14637
|
if (unregisterPrimary) unregisterPrimary();
|
|
14632
14638
|
const canvasTarget = state.internal.canvasTarget;
|
|
14633
|
-
if (canvasTarget?.dispose) canvasTarget.dispose();
|
|
14639
|
+
if (state.internal.isSecondary && canvasTarget?.dispose) canvasTarget.dispose();
|
|
14634
14640
|
state.events.disconnect?.();
|
|
14635
14641
|
cleanupHelperGroup(root.store);
|
|
14636
14642
|
if (state.isLegacy && renderer) {
|
|
@@ -14771,16 +14777,11 @@ function setEnvProps(background, scene, defaultScene, texture, sceneProps = {})
|
|
|
14771
14777
|
const oldbg = target.background;
|
|
14772
14778
|
const oldenv = target.environment;
|
|
14773
14779
|
const oldSceneProps = {
|
|
14774
|
-
// @ts-ignore
|
|
14775
14780
|
backgroundBlurriness: target.backgroundBlurriness,
|
|
14776
|
-
// @ts-ignore
|
|
14777
14781
|
backgroundIntensity: target.backgroundIntensity,
|
|
14778
|
-
|
|
14779
|
-
backgroundRotation: target.backgroundRotation?.clone?.() ?? [0, 0, 0],
|
|
14780
|
-
// @ts-ignore
|
|
14782
|
+
backgroundRotation: target.backgroundRotation.clone(),
|
|
14781
14783
|
environmentIntensity: target.environmentIntensity,
|
|
14782
|
-
|
|
14783
|
-
environmentRotation: target.environmentRotation?.clone?.() ?? [0, 0, 0]
|
|
14784
|
+
environmentRotation: target.environmentRotation.clone()
|
|
14784
14785
|
};
|
|
14785
14786
|
if (background !== "only") target.environment = texture;
|
|
14786
14787
|
if (background) target.background = texture;
|
|
@@ -15374,20 +15375,36 @@ function CanvasImpl({
|
|
|
15374
15375
|
}
|
|
15375
15376
|
);
|
|
15376
15377
|
}
|
|
15377
|
-
function Canvas(props) {
|
|
15378
|
+
function Canvas$1(props) {
|
|
15378
15379
|
return /* @__PURE__ */ jsxRuntime.jsx(itsFine.FiberProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(CanvasImpl, { ...props }) });
|
|
15379
15380
|
}
|
|
15380
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
|
+
|
|
15381
15395
|
var __defProp = Object.defineProperty;
|
|
15382
15396
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
15383
15397
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
15384
|
-
var _a;
|
|
15398
|
+
var _a, _b;
|
|
15385
15399
|
const INTERNAL_DATA = Symbol("ScopedStore.data");
|
|
15386
|
-
|
|
15400
|
+
const INTERNAL_IS_LEAF = Symbol("ScopedStore.isLeaf");
|
|
15401
|
+
_b = INTERNAL_DATA, _a = INTERNAL_IS_LEAF;
|
|
15387
15402
|
const _ScopedStore = class _ScopedStore {
|
|
15388
|
-
constructor(data) {
|
|
15403
|
+
constructor(data, isLeaf) {
|
|
15404
|
+
__publicField(this, _b);
|
|
15389
15405
|
__publicField(this, _a);
|
|
15390
15406
|
this[INTERNAL_DATA] = data;
|
|
15407
|
+
this[INTERNAL_IS_LEAF] = isLeaf;
|
|
15391
15408
|
return new Proxy(this, {
|
|
15392
15409
|
get(target, prop, receiver) {
|
|
15393
15410
|
if (typeof prop === "string") {
|
|
@@ -15421,10 +15438,10 @@ const _ScopedStore = class _ScopedStore {
|
|
|
15421
15438
|
* If the key doesn't exist or isn't a scope object, returns an empty ScopedStore.
|
|
15422
15439
|
*/
|
|
15423
15440
|
scope(key) {
|
|
15424
|
-
const
|
|
15425
|
-
|
|
15426
|
-
|
|
15427
|
-
);
|
|
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);
|
|
15428
15445
|
}
|
|
15429
15446
|
/**
|
|
15430
15447
|
* Check if a key exists in the store.
|
|
@@ -15440,8 +15457,8 @@ const _ScopedStore = class _ScopedStore {
|
|
|
15440
15457
|
}
|
|
15441
15458
|
};
|
|
15442
15459
|
let ScopedStore = _ScopedStore;
|
|
15443
|
-
function createScopedStore(data) {
|
|
15444
|
-
return new ScopedStore(data);
|
|
15460
|
+
function createScopedStore(data, isLeaf) {
|
|
15461
|
+
return new ScopedStore(data, isLeaf);
|
|
15445
15462
|
}
|
|
15446
15463
|
function createLazyCreatorState(state, store) {
|
|
15447
15464
|
let _uniforms = null;
|
|
@@ -15452,22 +15469,22 @@ function createLazyCreatorState(state, store) {
|
|
|
15452
15469
|
return Object.create(state, {
|
|
15453
15470
|
uniforms: {
|
|
15454
15471
|
get() {
|
|
15455
|
-
return _uniforms ?? (_uniforms = createScopedStore(view("uniforms")));
|
|
15472
|
+
return _uniforms ?? (_uniforms = createScopedStore(view("uniforms"), isUniformNode));
|
|
15456
15473
|
}
|
|
15457
15474
|
},
|
|
15458
15475
|
nodes: {
|
|
15459
15476
|
get() {
|
|
15460
|
-
return _nodes ?? (_nodes = createScopedStore(view("nodes")));
|
|
15477
|
+
return _nodes ?? (_nodes = createScopedStore(view("nodes"), isTSLNode));
|
|
15461
15478
|
}
|
|
15462
15479
|
},
|
|
15463
15480
|
buffers: {
|
|
15464
15481
|
get() {
|
|
15465
|
-
return _buffers ?? (_buffers = createScopedStore(view("buffers")));
|
|
15482
|
+
return _buffers ?? (_buffers = createScopedStore(view("buffers"), isBufferLike));
|
|
15466
15483
|
}
|
|
15467
15484
|
},
|
|
15468
15485
|
gpuStorage: {
|
|
15469
15486
|
get() {
|
|
15470
|
-
return _gpuStorage ?? (_gpuStorage = createScopedStore(view("gpuStorage")));
|
|
15487
|
+
return _gpuStorage ?? (_gpuStorage = createScopedStore(view("gpuStorage"), isStorageLike));
|
|
15471
15488
|
}
|
|
15472
15489
|
}
|
|
15473
15490
|
});
|
|
@@ -15568,7 +15585,7 @@ function vectorize(inObject) {
|
|
|
15568
15585
|
return extractTSLValue(inObject);
|
|
15569
15586
|
}
|
|
15570
15587
|
if (obj.isVector2 || obj.isVector3 || obj.isVector4) return inObject;
|
|
15571
|
-
if (obj.isMatrix3 || obj.isMatrix4) return inObject;
|
|
15588
|
+
if (obj.isMatrix2 || obj.isMatrix3 || obj.isMatrix4) return inObject;
|
|
15572
15589
|
if (obj.isColor || obj.isEuler || obj.isQuaternion || obj.isSpherical) return inObject;
|
|
15573
15590
|
if ("r" in obj && "g" in obj && "b" in obj && typeof obj.r === "number" && typeof obj.g === "number" && typeof obj.b === "number") {
|
|
15574
15591
|
const scale = obj.r > 1 || obj.g > 1 || obj.b > 1 ? 1 / 255 : 1;
|
|
@@ -15626,22 +15643,21 @@ function useScopedResource(options) {
|
|
|
15626
15643
|
return entries;
|
|
15627
15644
|
}
|
|
15628
15645
|
|
|
15629
|
-
const isUniformNode$1 = (value) => value !== null && typeof value === "object" && "value" in value && "uuid" in value;
|
|
15630
15646
|
function useUniforms(creatorOrScope, scope) {
|
|
15631
15647
|
const store = usePrimaryStore();
|
|
15632
15648
|
const removeUniforms2 = React.useCallback(
|
|
15633
|
-
(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),
|
|
15634
15650
|
[store]
|
|
15635
15651
|
);
|
|
15636
15652
|
const clearUniforms = React.useCallback(
|
|
15637
|
-
(targetScope) => clearResourceEntries(store, "uniforms", targetScope, isUniformNode
|
|
15653
|
+
(targetScope) => clearResourceEntries(store, "uniforms", targetScope, isUniformNode),
|
|
15638
15654
|
[store]
|
|
15639
15655
|
);
|
|
15640
15656
|
const rebuildUniforms = React.useCallback(
|
|
15641
15657
|
(targetScope) => rebuildResource(store, "uniforms", targetScope),
|
|
15642
15658
|
[store]
|
|
15643
15659
|
);
|
|
15644
|
-
const
|
|
15660
|
+
const processedInput = React.useMemo(() => {
|
|
15645
15661
|
let raw = creatorOrScope;
|
|
15646
15662
|
if (is.fun(creatorOrScope)) {
|
|
15647
15663
|
const wrappedState = createLazyCreatorState(store.getState(), store);
|
|
@@ -15652,23 +15668,24 @@ function useUniforms(creatorOrScope, scope) {
|
|
|
15652
15668
|
for (const [key, value] of Object.entries(raw)) {
|
|
15653
15669
|
normalized[key] = vectorize(value);
|
|
15654
15670
|
}
|
|
15655
|
-
return normalized;
|
|
15671
|
+
return { candidates: raw, normalized };
|
|
15656
15672
|
}
|
|
15657
|
-
return raw;
|
|
15673
|
+
return { candidates: raw, normalized: raw };
|
|
15658
15674
|
}, [creatorOrScope, store]);
|
|
15659
|
-
const memoizedInput = useCompareMemoize(
|
|
15675
|
+
const memoizedInput = useCompareMemoize(processedInput.normalized);
|
|
15660
15676
|
const isReader = memoizedInput === void 0 || typeof memoizedInput === "string";
|
|
15661
15677
|
const storeUniforms = usePrimaryThree((s) => s.uniforms);
|
|
15662
15678
|
const created = useScopedResource({
|
|
15663
15679
|
store,
|
|
15664
15680
|
kind: "uniforms",
|
|
15665
15681
|
scope: isReader ? void 0 : scope,
|
|
15666
|
-
isLeaf: isUniformNode
|
|
15682
|
+
isLeaf: isUniformNode,
|
|
15667
15683
|
input: memoizedInput,
|
|
15668
15684
|
create: () => {
|
|
15669
15685
|
if (isReader) return {};
|
|
15670
|
-
if (typeof
|
|
15671
|
-
|
|
15686
|
+
if (typeof processedInput.candidates !== "object" || processedInput.candidates === null)
|
|
15687
|
+
throw new Error("Invalid uniform input");
|
|
15688
|
+
return processedInput.candidates;
|
|
15672
15689
|
},
|
|
15673
15690
|
prepare: (name, candidate) => createUniform(name, candidate, scope),
|
|
15674
15691
|
reconcile: (existing, candidate) => {
|
|
@@ -15690,7 +15707,7 @@ function useUniforms(creatorOrScope, scope) {
|
|
|
15690
15707
|
uniforms = storeUniforms;
|
|
15691
15708
|
} else if (typeof memoizedInput === "string") {
|
|
15692
15709
|
const scopeData = storeUniforms[memoizedInput];
|
|
15693
|
-
uniforms = scopeData && !isUniformNode
|
|
15710
|
+
uniforms = scopeData && !isUniformNode(scopeData) ? scopeData : {};
|
|
15694
15711
|
}
|
|
15695
15712
|
return { ...uniforms, removeUniforms: removeUniforms2, clearUniforms, rebuildUniforms };
|
|
15696
15713
|
}
|
|
@@ -15705,7 +15722,7 @@ function removeUniforms(set, names, scope) {
|
|
|
15705
15722
|
return { uniforms: { ...state.uniforms, [scope]: currentScope } };
|
|
15706
15723
|
}
|
|
15707
15724
|
const uniforms = { ...state.uniforms };
|
|
15708
|
-
for (const name of names) if (isUniformNode
|
|
15725
|
+
for (const name of names) if (isUniformNode(uniforms[name])) delete uniforms[name];
|
|
15709
15726
|
return { uniforms };
|
|
15710
15727
|
});
|
|
15711
15728
|
}
|
|
@@ -15719,7 +15736,7 @@ function clearRootUniforms(set) {
|
|
|
15719
15736
|
set((state) => {
|
|
15720
15737
|
const uniforms = {};
|
|
15721
15738
|
for (const [key, value] of Object.entries(state.uniforms)) {
|
|
15722
|
-
if (!isUniformNode
|
|
15739
|
+
if (!isUniformNode(value)) uniforms[key] = value;
|
|
15723
15740
|
}
|
|
15724
15741
|
return { uniforms };
|
|
15725
15742
|
});
|
|
@@ -15755,12 +15772,10 @@ function hasEqualsMethod(value) {
|
|
|
15755
15772
|
function isSameThreeType(a, b) {
|
|
15756
15773
|
const obj_a = a;
|
|
15757
15774
|
const obj_b = b;
|
|
15758
|
-
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;
|
|
15759
15776
|
}
|
|
15760
15777
|
|
|
15761
15778
|
const uniformOf = tsl.uniform;
|
|
15762
|
-
const isUniformNode = (value) => value !== null && typeof value === "object" && "value" in value && "uuid" in value;
|
|
15763
|
-
const isTSLNode$1 = (value) => value !== null && typeof value === "object" && "uuid" in value && "nodeType" in value;
|
|
15764
15779
|
function useUniform(name, value) {
|
|
15765
15780
|
const store = useStore();
|
|
15766
15781
|
const registered = useScopedResource({
|
|
@@ -15772,7 +15787,7 @@ function useUniform(name, value) {
|
|
|
15772
15787
|
create: () => value === void 0 ? {} : { [name]: value },
|
|
15773
15788
|
prepare: createNamedUniform,
|
|
15774
15789
|
reconcile: (existing2) => {
|
|
15775
|
-
if (value !== void 0 && !isTSLNode
|
|
15790
|
+
if (value !== void 0 && !isTSLNode(value) && !isUniformNode(value)) {
|
|
15776
15791
|
existing2.value = typeof value === "string" ? new webgpu.Color(value) : value;
|
|
15777
15792
|
}
|
|
15778
15793
|
}
|
|
@@ -15788,7 +15803,7 @@ function createNamedUniform(name, value) {
|
|
|
15788
15803
|
let node;
|
|
15789
15804
|
if (isUniformNode(value)) {
|
|
15790
15805
|
node = value;
|
|
15791
|
-
} else if (isTSLNode
|
|
15806
|
+
} else if (isTSLNode(value)) {
|
|
15792
15807
|
node = uniformOf(value);
|
|
15793
15808
|
} else if (typeof value === "string") {
|
|
15794
15809
|
node = tsl.uniform(new webgpu.Color(value));
|
|
@@ -15801,7 +15816,6 @@ function createNamedUniform(name, value) {
|
|
|
15801
15816
|
return node;
|
|
15802
15817
|
}
|
|
15803
15818
|
|
|
15804
|
-
const isTSLNode = (value) => value !== null && typeof value === "object" && ("uuid" in value || "nodeType" in value);
|
|
15805
15819
|
function useNodes(creatorOrScope, scope) {
|
|
15806
15820
|
const store = usePrimaryStore();
|
|
15807
15821
|
const removeNodes2 = React.useCallback(
|
|
@@ -15828,7 +15842,8 @@ function useNodes(creatorOrScope, scope) {
|
|
|
15828
15842
|
return creatorOrScope(createLazyCreatorState(store.getState(), store));
|
|
15829
15843
|
},
|
|
15830
15844
|
prepare: (name, node) => {
|
|
15831
|
-
|
|
15845
|
+
const setName = Reflect.get(node, "setName");
|
|
15846
|
+
if (typeof setName === "function") setName.call(node, scopedNodeName(scope, name));
|
|
15832
15847
|
return node;
|
|
15833
15848
|
}
|
|
15834
15849
|
});
|
|
@@ -15883,13 +15898,6 @@ function useLocalNodes(creator) {
|
|
|
15883
15898
|
}, [store, creator, uniforms, nodes, textures, hmrVersion]);
|
|
15884
15899
|
}
|
|
15885
15900
|
|
|
15886
|
-
const isBufferLike = (value) => {
|
|
15887
|
-
if (value === null || typeof value !== "object") return false;
|
|
15888
|
-
if (ArrayBuffer.isView(value)) return true;
|
|
15889
|
-
if ("isBufferAttribute" in value) return true;
|
|
15890
|
-
if ("uuid" in value || "nodeType" in value) return true;
|
|
15891
|
-
return false;
|
|
15892
|
-
};
|
|
15893
15901
|
const disposeBuffer = (buffer) => {
|
|
15894
15902
|
if (buffer === null || typeof buffer !== "object") return;
|
|
15895
15903
|
if ("dispose" in buffer && typeof buffer.dispose === "function") {
|
|
@@ -15936,9 +15944,8 @@ function useBuffers(creatorOrScope, scope) {
|
|
|
15936
15944
|
return creatorOrScope(createLazyCreatorState(store.getState(), store));
|
|
15937
15945
|
},
|
|
15938
15946
|
prepare: (name, buffer) => {
|
|
15939
|
-
|
|
15940
|
-
|
|
15941
|
-
}
|
|
15947
|
+
const setName = Reflect.get(buffer, "setName");
|
|
15948
|
+
if (typeof setName === "function") setName.call(buffer, scopedNodeName(scope, name));
|
|
15942
15949
|
return buffer;
|
|
15943
15950
|
}
|
|
15944
15951
|
});
|
|
@@ -15955,13 +15962,6 @@ function rebuildAllBuffers(store, scope) {
|
|
|
15955
15962
|
rebuildResource(store, "buffers", scope);
|
|
15956
15963
|
}
|
|
15957
15964
|
|
|
15958
|
-
const isStorageLike = (value) => {
|
|
15959
|
-
if (value === null || typeof value !== "object") return false;
|
|
15960
|
-
if ("isTexture" in value) return true;
|
|
15961
|
-
if ("isData3DTexture" in value) return true;
|
|
15962
|
-
if ("uuid" in value || "nodeType" in value) return true;
|
|
15963
|
-
return false;
|
|
15964
|
-
};
|
|
15965
15965
|
const disposeStorage = (storage) => {
|
|
15966
15966
|
if (storage === null || typeof storage !== "object") return;
|
|
15967
15967
|
if ("dispose" in storage && typeof storage.dispose === "function") {
|
|
@@ -16009,9 +16009,8 @@ function useGPUStorage(creatorOrScope, scope) {
|
|
|
16009
16009
|
},
|
|
16010
16010
|
prepare: (name, storage) => {
|
|
16011
16011
|
const label = scopedNodeName(scope, name);
|
|
16012
|
-
|
|
16013
|
-
|
|
16014
|
-
}
|
|
16012
|
+
const setName = Reflect.get(storage, "setName");
|
|
16013
|
+
if (typeof setName === "function") setName.call(storage, label);
|
|
16015
16014
|
if ("name" in storage && typeof storage.name === "string") {
|
|
16016
16015
|
storage.name = label;
|
|
16017
16016
|
}
|
|
@@ -16060,7 +16059,7 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
16060
16059
|
renderPipeline: null,
|
|
16061
16060
|
passes: {}
|
|
16062
16061
|
});
|
|
16063
|
-
scenePassCacheRef.current?.scenePass
|
|
16062
|
+
scenePassCacheRef.current?.scenePass.dispose();
|
|
16064
16063
|
callbacksRanRef.current = false;
|
|
16065
16064
|
scenePassCacheRef.current = null;
|
|
16066
16065
|
forceScenePassRebuildRef.current = false;
|
|
@@ -16075,6 +16074,9 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
16075
16074
|
throw new Error("useRenderPipeline is only available with WebGPU renderer. Set renderer prop on Canvas.");
|
|
16076
16075
|
}
|
|
16077
16076
|
if (!renderer || !scene || !camera) return;
|
|
16077
|
+
if (!("isWebGPURenderer" in renderer)) {
|
|
16078
|
+
throw new Error("useRenderPipeline: renderer is not a WebGPURenderer but isLegacy is false.");
|
|
16079
|
+
}
|
|
16078
16080
|
const state = store.getState();
|
|
16079
16081
|
const set = store.setState;
|
|
16080
16082
|
try {
|
|
@@ -16108,7 +16110,9 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
16108
16110
|
if (setupCBRef.current) {
|
|
16109
16111
|
const freshState = Object.assign({}, store.getState(), {
|
|
16110
16112
|
renderPipeline: pipeline,
|
|
16111
|
-
passes: currentPasses
|
|
16113
|
+
passes: { ...currentPasses, scenePass },
|
|
16114
|
+
renderer,
|
|
16115
|
+
isLegacy: false
|
|
16112
16116
|
});
|
|
16113
16117
|
const setupResult = setupCBRef.current(freshState);
|
|
16114
16118
|
if (setupResult && typeof setupResult === "object") {
|
|
@@ -16119,7 +16123,9 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
16119
16123
|
if (mainCBRef.current) {
|
|
16120
16124
|
const freshState = Object.assign({}, store.getState(), {
|
|
16121
16125
|
renderPipeline: pipeline,
|
|
16122
|
-
passes: currentPasses
|
|
16126
|
+
passes: { ...currentPasses, scenePass },
|
|
16127
|
+
renderer,
|
|
16128
|
+
isLegacy: false
|
|
16123
16129
|
});
|
|
16124
16130
|
const mainResult = mainCBRef.current(freshState);
|
|
16125
16131
|
if (mainResult && typeof mainResult === "object") {
|
|
@@ -16131,27 +16137,22 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
16131
16137
|
callbacksRanRef.current = true;
|
|
16132
16138
|
}
|
|
16133
16139
|
if (outputNodeChanged) pipeline.needsUpdate = true;
|
|
16134
|
-
if (outgoingScenePass && outgoingScenePass !== scenePass) outgoingScenePass.dispose
|
|
16140
|
+
if (outgoingScenePass && outgoingScenePass !== scenePass) outgoingScenePass.dispose();
|
|
16135
16141
|
} catch (error) {
|
|
16136
16142
|
console.warn("[useRenderPipeline] Setup failed; the render pipeline was not configured:", error);
|
|
16137
16143
|
}
|
|
16138
16144
|
}, [store, renderer, scene, camera, isLegacy, rebuildVersion]);
|
|
16139
16145
|
const passes = useThree$1((s) => s.passes);
|
|
16140
16146
|
const renderPipeline = useThree$1((s) => s.renderPipeline);
|
|
16141
|
-
|
|
16142
|
-
|
|
16143
|
-
|
|
16144
|
-
clearPasses,
|
|
16145
|
-
reset,
|
|
16146
|
-
rebuild,
|
|
16147
|
-
// isReady indicates if RenderPipeline is configured and ready for rendering
|
|
16148
|
-
isReady: renderPipeline !== null
|
|
16149
|
-
};
|
|
16147
|
+
const actions = { passes, clearPasses, reset, rebuild };
|
|
16148
|
+
if (renderPipeline) return { ...actions, isReady: true, renderPipeline };
|
|
16149
|
+
return { ...actions, isReady: false, renderPipeline: null };
|
|
16150
16150
|
}
|
|
16151
16151
|
|
|
16152
16152
|
extend(THREE);
|
|
16153
16153
|
const useThree = useThree$1;
|
|
16154
16154
|
const useFrame = useFrame$1;
|
|
16155
|
+
const Canvas = Canvas$1;
|
|
16155
16156
|
|
|
16156
16157
|
exports.Scheduler = scheduler.Scheduler;
|
|
16157
16158
|
exports.getScheduler = scheduler.getScheduler;
|