@react-three/fiber 10.0.0-alpha.4 → 10.0.0-alpha.5

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.
@@ -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
- return { [FROM_REF]: ref };
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 (root.constructor && root.constructor.length === 0) {
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
- internal.canvasTargetSizeDirty = true;
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?.(loadedTextures);
1375
- }, [cachedResult, loadedTextures, inputKey]);
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 extension = isCubemap ? "cube" : isGainmap ? "webp" : firstEntry.startsWith("data:application/exr") ? "exr" : firstEntry.startsWith("data:application/hdr") ? "hdr" : firstEntry.startsWith("data:image/jpeg") ? "jpg" : firstEntry.split(".").pop()?.split("?")?.shift()?.toLowerCase();
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.4";
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
- Object.assign(catalogue, objects);
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[FROM_REF];
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
- const pixelRatio = calculateDpr(dpr);
14244
- canvas.width = size2.width * pixelRatio;
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 = new webgpu.CanvasTarget(canvas);
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
- if (state2.internal.isMultiCanvas && state2.internal.canvasTarget) {
14472
+ const canvasTarget = state2.internal.canvasTarget;
14473
+ if (canvasTarget) {
14468
14474
  const renderer2 = state2.internal.actualRenderer;
14469
- renderer2.setCanvasTarget(state2.internal.canvasTarget);
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
- // @ts-ignore
14779
- backgroundRotation: target.backgroundRotation?.clone?.() ?? [0, 0, 0],
14780
- // @ts-ignore
14782
+ backgroundRotation: target.backgroundRotation.clone(),
14781
14783
  environmentIntensity: target.environmentIntensity,
14782
- // @ts-ignore
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;
@@ -15171,9 +15172,9 @@ function CanvasImpl({
15171
15172
  React__namespace.useMemo(() => extend(THREE), []);
15172
15173
  const Bridge = useBridge();
15173
15174
  const backgroundProps = React__namespace.useMemo(() => parseBackground(background), [background]);
15174
- const hasInitialSizeRef = React__namespace.useRef(false);
15175
+ const [hasInitialSize, setHasInitialSize] = React__namespace.useState(false);
15175
15176
  const measureConfig = React__namespace.useMemo(() => {
15176
- if (!hasInitialSizeRef.current) {
15177
+ if (!hasInitialSize) {
15177
15178
  return {
15178
15179
  ...resize,
15179
15180
  scroll: resize?.scroll ?? true,
@@ -15185,7 +15186,7 @@ function CanvasImpl({
15185
15186
  debounce: { scroll: 50, resize: 0 },
15186
15187
  ...resize
15187
15188
  };
15188
- }, [resize, hasInitialSizeRef.current]);
15189
+ }, [hasInitialSize, resize]);
15189
15190
  const [containerRef, containerRect] = useMeasure__default(measureConfig);
15190
15191
  const effectiveSize = React__namespace.useMemo(() => {
15191
15192
  let w = width ?? containerRect.width;
@@ -15201,9 +15202,7 @@ function CanvasImpl({
15201
15202
  left: containerRect.left
15202
15203
  };
15203
15204
  }, [width, height, containerRect, forceEven]);
15204
- if (!hasInitialSizeRef.current && effectiveSize.width > 0 && effectiveSize.height > 0) {
15205
- hasInitialSizeRef.current = true;
15206
- }
15205
+ if (!hasInitialSize && effectiveSize.width > 0 && effectiveSize.height > 0) setHasInitialSize(true);
15207
15206
  const canvasRef = React__namespace.useRef(null);
15208
15207
  const divRef = React__namespace.useRef(null);
15209
15208
  React__namespace.useImperativeHandle(ref, () => canvasRef.current);
@@ -15376,20 +15375,36 @@ function CanvasImpl({
15376
15375
  }
15377
15376
  );
15378
15377
  }
15379
- function Canvas(props) {
15378
+ function Canvas$1(props) {
15380
15379
  return /* @__PURE__ */ jsxRuntime.jsx(itsFine.FiberProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(CanvasImpl, { ...props }) });
15381
15380
  }
15382
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
+
15383
15395
  var __defProp = Object.defineProperty;
15384
15396
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15385
15397
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
15386
- var _a;
15398
+ var _a, _b;
15387
15399
  const INTERNAL_DATA = Symbol("ScopedStore.data");
15388
- _a = INTERNAL_DATA;
15400
+ const INTERNAL_IS_LEAF = Symbol("ScopedStore.isLeaf");
15401
+ _b = INTERNAL_DATA, _a = INTERNAL_IS_LEAF;
15389
15402
  const _ScopedStore = class _ScopedStore {
15390
- constructor(data) {
15403
+ constructor(data, isLeaf) {
15404
+ __publicField(this, _b);
15391
15405
  __publicField(this, _a);
15392
15406
  this[INTERNAL_DATA] = data;
15407
+ this[INTERNAL_IS_LEAF] = isLeaf;
15393
15408
  return new Proxy(this, {
15394
15409
  get(target, prop, receiver) {
15395
15410
  if (typeof prop === "string") {
@@ -15423,10 +15438,10 @@ const _ScopedStore = class _ScopedStore {
15423
15438
  * If the key doesn't exist or isn't a scope object, returns an empty ScopedStore.
15424
15439
  */
15425
15440
  scope(key) {
15426
- const data = this[INTERNAL_DATA][key];
15427
- return new _ScopedStore(
15428
- data && typeof data === "object" ? data : {}
15429
- );
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);
15430
15445
  }
15431
15446
  /**
15432
15447
  * Check if a key exists in the store.
@@ -15442,8 +15457,8 @@ const _ScopedStore = class _ScopedStore {
15442
15457
  }
15443
15458
  };
15444
15459
  let ScopedStore = _ScopedStore;
15445
- function createScopedStore(data) {
15446
- return new ScopedStore(data);
15460
+ function createScopedStore(data, isLeaf) {
15461
+ return new ScopedStore(data, isLeaf);
15447
15462
  }
15448
15463
  function createLazyCreatorState(state, store) {
15449
15464
  let _uniforms = null;
@@ -15454,22 +15469,22 @@ function createLazyCreatorState(state, store) {
15454
15469
  return Object.create(state, {
15455
15470
  uniforms: {
15456
15471
  get() {
15457
- return _uniforms ?? (_uniforms = createScopedStore(view("uniforms")));
15472
+ return _uniforms ?? (_uniforms = createScopedStore(view("uniforms"), isUniformNode));
15458
15473
  }
15459
15474
  },
15460
15475
  nodes: {
15461
15476
  get() {
15462
- return _nodes ?? (_nodes = createScopedStore(view("nodes")));
15477
+ return _nodes ?? (_nodes = createScopedStore(view("nodes"), isTSLNode));
15463
15478
  }
15464
15479
  },
15465
15480
  buffers: {
15466
15481
  get() {
15467
- return _buffers ?? (_buffers = createScopedStore(view("buffers")));
15482
+ return _buffers ?? (_buffers = createScopedStore(view("buffers"), isBufferLike));
15468
15483
  }
15469
15484
  },
15470
15485
  gpuStorage: {
15471
15486
  get() {
15472
- return _gpuStorage ?? (_gpuStorage = createScopedStore(view("gpuStorage")));
15487
+ return _gpuStorage ?? (_gpuStorage = createScopedStore(view("gpuStorage"), isStorageLike));
15473
15488
  }
15474
15489
  }
15475
15490
  });
@@ -15570,7 +15585,7 @@ function vectorize(inObject) {
15570
15585
  return extractTSLValue(inObject);
15571
15586
  }
15572
15587
  if (obj.isVector2 || obj.isVector3 || obj.isVector4) return inObject;
15573
- if (obj.isMatrix3 || obj.isMatrix4) return inObject;
15588
+ if (obj.isMatrix2 || obj.isMatrix3 || obj.isMatrix4) return inObject;
15574
15589
  if (obj.isColor || obj.isEuler || obj.isQuaternion || obj.isSpherical) return inObject;
15575
15590
  if ("r" in obj && "g" in obj && "b" in obj && typeof obj.r === "number" && typeof obj.g === "number" && typeof obj.b === "number") {
15576
15591
  const scale = obj.r > 1 || obj.g > 1 || obj.b > 1 ? 1 / 255 : 1;
@@ -15628,22 +15643,21 @@ function useScopedResource(options) {
15628
15643
  return entries;
15629
15644
  }
15630
15645
 
15631
- const isUniformNode$1 = (value) => value !== null && typeof value === "object" && "value" in value && "uuid" in value;
15632
15646
  function useUniforms(creatorOrScope, scope) {
15633
15647
  const store = usePrimaryStore();
15634
15648
  const removeUniforms2 = React.useCallback(
15635
- (names, targetScope) => removeResourceEntries(store, "uniforms", Array.isArray(names) ? names : [names], targetScope, isUniformNode$1),
15649
+ (names, targetScope) => removeResourceEntries(store, "uniforms", Array.isArray(names) ? names : [names], targetScope, isUniformNode),
15636
15650
  [store]
15637
15651
  );
15638
15652
  const clearUniforms = React.useCallback(
15639
- (targetScope) => clearResourceEntries(store, "uniforms", targetScope, isUniformNode$1),
15653
+ (targetScope) => clearResourceEntries(store, "uniforms", targetScope, isUniformNode),
15640
15654
  [store]
15641
15655
  );
15642
15656
  const rebuildUniforms = React.useCallback(
15643
15657
  (targetScope) => rebuildResource(store, "uniforms", targetScope),
15644
15658
  [store]
15645
15659
  );
15646
- const inputForMemoization = React.useMemo(() => {
15660
+ const processedInput = React.useMemo(() => {
15647
15661
  let raw = creatorOrScope;
15648
15662
  if (is.fun(creatorOrScope)) {
15649
15663
  const wrappedState = createLazyCreatorState(store.getState(), store);
@@ -15654,23 +15668,24 @@ function useUniforms(creatorOrScope, scope) {
15654
15668
  for (const [key, value] of Object.entries(raw)) {
15655
15669
  normalized[key] = vectorize(value);
15656
15670
  }
15657
- return normalized;
15671
+ return { candidates: raw, normalized };
15658
15672
  }
15659
- return raw;
15673
+ return { candidates: raw, normalized: raw };
15660
15674
  }, [creatorOrScope, store]);
15661
- const memoizedInput = useCompareMemoize(inputForMemoization);
15675
+ const memoizedInput = useCompareMemoize(processedInput.normalized);
15662
15676
  const isReader = memoizedInput === void 0 || typeof memoizedInput === "string";
15663
15677
  const storeUniforms = usePrimaryThree((s) => s.uniforms);
15664
15678
  const created = useScopedResource({
15665
15679
  store,
15666
15680
  kind: "uniforms",
15667
15681
  scope: isReader ? void 0 : scope,
15668
- isLeaf: isUniformNode$1,
15682
+ isLeaf: isUniformNode,
15669
15683
  input: memoizedInput,
15670
15684
  create: () => {
15671
15685
  if (isReader) return {};
15672
- if (typeof memoizedInput !== "object" || memoizedInput === null) throw new Error("Invalid uniform input");
15673
- return memoizedInput;
15686
+ if (typeof processedInput.candidates !== "object" || processedInput.candidates === null)
15687
+ throw new Error("Invalid uniform input");
15688
+ return processedInput.candidates;
15674
15689
  },
15675
15690
  prepare: (name, candidate) => createUniform(name, candidate, scope),
15676
15691
  reconcile: (existing, candidate) => {
@@ -15692,7 +15707,7 @@ function useUniforms(creatorOrScope, scope) {
15692
15707
  uniforms = storeUniforms;
15693
15708
  } else if (typeof memoizedInput === "string") {
15694
15709
  const scopeData = storeUniforms[memoizedInput];
15695
- uniforms = scopeData && !isUniformNode$1(scopeData) ? scopeData : {};
15710
+ uniforms = scopeData && !isUniformNode(scopeData) ? scopeData : {};
15696
15711
  }
15697
15712
  return { ...uniforms, removeUniforms: removeUniforms2, clearUniforms, rebuildUniforms };
15698
15713
  }
@@ -15707,7 +15722,7 @@ function removeUniforms(set, names, scope) {
15707
15722
  return { uniforms: { ...state.uniforms, [scope]: currentScope } };
15708
15723
  }
15709
15724
  const uniforms = { ...state.uniforms };
15710
- for (const name of names) if (isUniformNode$1(uniforms[name])) delete uniforms[name];
15725
+ for (const name of names) if (isUniformNode(uniforms[name])) delete uniforms[name];
15711
15726
  return { uniforms };
15712
15727
  });
15713
15728
  }
@@ -15721,7 +15736,7 @@ function clearRootUniforms(set) {
15721
15736
  set((state) => {
15722
15737
  const uniforms = {};
15723
15738
  for (const [key, value] of Object.entries(state.uniforms)) {
15724
- if (!isUniformNode$1(value)) uniforms[key] = value;
15739
+ if (!isUniformNode(value)) uniforms[key] = value;
15725
15740
  }
15726
15741
  return { uniforms };
15727
15742
  });
@@ -15757,12 +15772,10 @@ function hasEqualsMethod(value) {
15757
15772
  function isSameThreeType(a, b) {
15758
15773
  const obj_a = a;
15759
15774
  const obj_b = b;
15760
- 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;
15761
15776
  }
15762
15777
 
15763
15778
  const uniformOf = tsl.uniform;
15764
- const isUniformNode = (value) => value !== null && typeof value === "object" && "value" in value && "uuid" in value;
15765
- const isTSLNode$1 = (value) => value !== null && typeof value === "object" && "uuid" in value && "nodeType" in value;
15766
15779
  function useUniform(name, value) {
15767
15780
  const store = useStore();
15768
15781
  const registered = useScopedResource({
@@ -15774,7 +15787,7 @@ function useUniform(name, value) {
15774
15787
  create: () => value === void 0 ? {} : { [name]: value },
15775
15788
  prepare: createNamedUniform,
15776
15789
  reconcile: (existing2) => {
15777
- if (value !== void 0 && !isTSLNode$1(value) && !isUniformNode(value)) {
15790
+ if (value !== void 0 && !isTSLNode(value) && !isUniformNode(value)) {
15778
15791
  existing2.value = typeof value === "string" ? new webgpu.Color(value) : value;
15779
15792
  }
15780
15793
  }
@@ -15790,7 +15803,7 @@ function createNamedUniform(name, value) {
15790
15803
  let node;
15791
15804
  if (isUniformNode(value)) {
15792
15805
  node = value;
15793
- } else if (isTSLNode$1(value)) {
15806
+ } else if (isTSLNode(value)) {
15794
15807
  node = uniformOf(value);
15795
15808
  } else if (typeof value === "string") {
15796
15809
  node = tsl.uniform(new webgpu.Color(value));
@@ -15803,7 +15816,6 @@ function createNamedUniform(name, value) {
15803
15816
  return node;
15804
15817
  }
15805
15818
 
15806
- const isTSLNode = (value) => value !== null && typeof value === "object" && ("uuid" in value || "nodeType" in value);
15807
15819
  function useNodes(creatorOrScope, scope) {
15808
15820
  const store = usePrimaryStore();
15809
15821
  const removeNodes2 = React.useCallback(
@@ -15830,7 +15842,8 @@ function useNodes(creatorOrScope, scope) {
15830
15842
  return creatorOrScope(createLazyCreatorState(store.getState(), store));
15831
15843
  },
15832
15844
  prepare: (name, node) => {
15833
- node.setName?.(scopedNodeName(scope, name));
15845
+ const setName = Reflect.get(node, "setName");
15846
+ if (typeof setName === "function") setName.call(node, scopedNodeName(scope, name));
15834
15847
  return node;
15835
15848
  }
15836
15849
  });
@@ -15885,13 +15898,6 @@ function useLocalNodes(creator) {
15885
15898
  }, [store, creator, uniforms, nodes, textures, hmrVersion]);
15886
15899
  }
15887
15900
 
15888
- const isBufferLike = (value) => {
15889
- if (value === null || typeof value !== "object") return false;
15890
- if (ArrayBuffer.isView(value)) return true;
15891
- if ("isBufferAttribute" in value) return true;
15892
- if ("uuid" in value || "nodeType" in value) return true;
15893
- return false;
15894
- };
15895
15901
  const disposeBuffer = (buffer) => {
15896
15902
  if (buffer === null || typeof buffer !== "object") return;
15897
15903
  if ("dispose" in buffer && typeof buffer.dispose === "function") {
@@ -15938,9 +15944,8 @@ function useBuffers(creatorOrScope, scope) {
15938
15944
  return creatorOrScope(createLazyCreatorState(store.getState(), store));
15939
15945
  },
15940
15946
  prepare: (name, buffer) => {
15941
- if ("setName" in buffer && typeof buffer.setName === "function") {
15942
- buffer.setName(scopedNodeName(scope, name));
15943
- }
15947
+ const setName = Reflect.get(buffer, "setName");
15948
+ if (typeof setName === "function") setName.call(buffer, scopedNodeName(scope, name));
15944
15949
  return buffer;
15945
15950
  }
15946
15951
  });
@@ -15957,13 +15962,6 @@ function rebuildAllBuffers(store, scope) {
15957
15962
  rebuildResource(store, "buffers", scope);
15958
15963
  }
15959
15964
 
15960
- const isStorageLike = (value) => {
15961
- if (value === null || typeof value !== "object") return false;
15962
- if ("isTexture" in value) return true;
15963
- if ("isData3DTexture" in value) return true;
15964
- if ("uuid" in value || "nodeType" in value) return true;
15965
- return false;
15966
- };
15967
15965
  const disposeStorage = (storage) => {
15968
15966
  if (storage === null || typeof storage !== "object") return;
15969
15967
  if ("dispose" in storage && typeof storage.dispose === "function") {
@@ -16011,9 +16009,8 @@ function useGPUStorage(creatorOrScope, scope) {
16011
16009
  },
16012
16010
  prepare: (name, storage) => {
16013
16011
  const label = scopedNodeName(scope, name);
16014
- if ("setName" in storage && typeof storage.setName === "function") {
16015
- storage.setName(label);
16016
- }
16012
+ const setName = Reflect.get(storage, "setName");
16013
+ if (typeof setName === "function") setName.call(storage, label);
16017
16014
  if ("name" in storage && typeof storage.name === "string") {
16018
16015
  storage.name = label;
16019
16016
  }
@@ -16062,7 +16059,7 @@ function useRenderPipeline(mainCB, setupCB) {
16062
16059
  renderPipeline: null,
16063
16060
  passes: {}
16064
16061
  });
16065
- scenePassCacheRef.current?.scenePass?.dispose?.();
16062
+ scenePassCacheRef.current?.scenePass.dispose();
16066
16063
  callbacksRanRef.current = false;
16067
16064
  scenePassCacheRef.current = null;
16068
16065
  forceScenePassRebuildRef.current = false;
@@ -16077,6 +16074,9 @@ function useRenderPipeline(mainCB, setupCB) {
16077
16074
  throw new Error("useRenderPipeline is only available with WebGPU renderer. Set renderer prop on Canvas.");
16078
16075
  }
16079
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
+ }
16080
16080
  const state = store.getState();
16081
16081
  const set = store.setState;
16082
16082
  try {
@@ -16110,7 +16110,9 @@ function useRenderPipeline(mainCB, setupCB) {
16110
16110
  if (setupCBRef.current) {
16111
16111
  const freshState = Object.assign({}, store.getState(), {
16112
16112
  renderPipeline: pipeline,
16113
- passes: currentPasses
16113
+ passes: { ...currentPasses, scenePass },
16114
+ renderer,
16115
+ isLegacy: false
16114
16116
  });
16115
16117
  const setupResult = setupCBRef.current(freshState);
16116
16118
  if (setupResult && typeof setupResult === "object") {
@@ -16121,7 +16123,9 @@ function useRenderPipeline(mainCB, setupCB) {
16121
16123
  if (mainCBRef.current) {
16122
16124
  const freshState = Object.assign({}, store.getState(), {
16123
16125
  renderPipeline: pipeline,
16124
- passes: currentPasses
16126
+ passes: { ...currentPasses, scenePass },
16127
+ renderer,
16128
+ isLegacy: false
16125
16129
  });
16126
16130
  const mainResult = mainCBRef.current(freshState);
16127
16131
  if (mainResult && typeof mainResult === "object") {
@@ -16133,27 +16137,22 @@ function useRenderPipeline(mainCB, setupCB) {
16133
16137
  callbacksRanRef.current = true;
16134
16138
  }
16135
16139
  if (outputNodeChanged) pipeline.needsUpdate = true;
16136
- if (outgoingScenePass && outgoingScenePass !== scenePass) outgoingScenePass.dispose?.();
16140
+ if (outgoingScenePass && outgoingScenePass !== scenePass) outgoingScenePass.dispose();
16137
16141
  } catch (error) {
16138
16142
  console.warn("[useRenderPipeline] Setup failed; the render pipeline was not configured:", error);
16139
16143
  }
16140
16144
  }, [store, renderer, scene, camera, isLegacy, rebuildVersion]);
16141
16145
  const passes = useThree$1((s) => s.passes);
16142
16146
  const renderPipeline = useThree$1((s) => s.renderPipeline);
16143
- return {
16144
- passes,
16145
- renderPipeline,
16146
- clearPasses,
16147
- reset,
16148
- rebuild,
16149
- // isReady indicates if RenderPipeline is configured and ready for rendering
16150
- isReady: renderPipeline !== null
16151
- };
16147
+ const actions = { passes, clearPasses, reset, rebuild };
16148
+ if (renderPipeline) return { ...actions, isReady: true, renderPipeline };
16149
+ return { ...actions, isReady: false, renderPipeline: null };
16152
16150
  }
16153
16151
 
16154
16152
  extend(THREE);
16155
16153
  const useThree = useThree$1;
16156
16154
  const useFrame = useFrame$1;
16155
+ const Canvas = Canvas$1;
16157
16156
 
16158
16157
  exports.Scheduler = scheduler.Scheduler;
16159
16158
  exports.getScheduler = scheduler.getScheduler;