@react-three/fiber 10.0.0-canary.0d86c23 → 10.0.0-canary.0f7fc9b
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 +41 -31
- package/dist/index.d.cts +18 -1
- package/dist/index.d.mts +18 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.mjs +41 -31
- package/dist/legacy.cjs +40 -35
- package/dist/legacy.d.cts +17 -4
- package/dist/legacy.d.mts +17 -4
- package/dist/legacy.d.ts +17 -4
- package/dist/legacy.mjs +40 -35
- package/dist/webgpu/index.cjs +86 -57
- package/dist/webgpu/index.d.cts +40 -51
- package/dist/webgpu/index.d.mts +40 -51
- package/dist/webgpu/index.d.ts +40 -51
- package/dist/webgpu/index.mjs +86 -57
- package/package.json +1 -1
- package/readme.md +1 -1
package/dist/webgpu/index.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as webgpu from 'three/webgpu';
|
|
2
2
|
import { CubeRenderTarget, RenderTarget, Frustum, Matrix4, Group, BoxGeometry, MeshBasicNodeMaterial, Mesh, Node, NodeUpdateType, Layers, ShaderMaterial, Uniform, SRGBColorSpace, RGBAFormat, UnsignedByteType, Vector3, Vector2, TextureLoader, Texture as Texture$1, CubeReflectionMapping, EquirectangularReflectionMapping, CubeTextureLoader, CanvasTarget, Raycaster, OrthographicCamera, PerspectiveCamera, Scene, PCFShadowMap, VSMShadowMap, BasicShadowMap, ACESFilmicToneMapping, WebGPURenderer, HalfFloatType, Color, Vector4, RenderPipeline } from 'three/webgpu';
|
|
3
|
-
import { Inspector } from 'three/addons/inspector/Inspector.js';
|
|
4
3
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
5
4
|
import * as React from 'react';
|
|
6
5
|
import React__default, { useRef, useMemo, useLayoutEffect, useEffect, useContext, useImperativeHandle, useCallback, useState } from 'react';
|
|
@@ -34,6 +33,10 @@ function _mergeNamespaces(n, m) {
|
|
|
34
33
|
|
|
35
34
|
const R3F_BUILD_LEGACY = false;
|
|
36
35
|
const R3F_BUILD_WEBGPU = true;
|
|
36
|
+
async function loadInspector() {
|
|
37
|
+
const { Inspector } = await import('three/addons/inspector/Inspector.js');
|
|
38
|
+
return Inspector;
|
|
39
|
+
}
|
|
37
40
|
const WebGLRenderer = class WebGLRenderer2 {
|
|
38
41
|
constructor() {
|
|
39
42
|
throw new Error(
|
|
@@ -47,13 +50,13 @@ const WebGLCubeRenderTarget = null;
|
|
|
47
50
|
const THREE = /*#__PURE__*/_mergeNamespaces({
|
|
48
51
|
__proto__: null,
|
|
49
52
|
CubeRenderTargetCompat: CubeRenderTarget,
|
|
50
|
-
Inspector: Inspector,
|
|
51
53
|
R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
|
|
52
54
|
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
53
55
|
RenderTargetCompat: RenderTarget,
|
|
54
56
|
WebGLCubeRenderTarget: WebGLCubeRenderTarget,
|
|
55
57
|
WebGLRenderTarget: WebGLRenderTarget,
|
|
56
|
-
WebGLRenderer: WebGLRenderer
|
|
58
|
+
WebGLRenderer: WebGLRenderer,
|
|
59
|
+
loadInspector: loadInspector
|
|
57
60
|
}, [webgpu]);
|
|
58
61
|
|
|
59
62
|
const primaryRegistry = /* @__PURE__ */ new Map();
|
|
@@ -1051,17 +1054,10 @@ const createStore = (invalidate, advance) => {
|
|
|
1051
1054
|
oldSize = size;
|
|
1052
1055
|
oldDpr = viewport.dpr;
|
|
1053
1056
|
updateCamera(camera, size);
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
if (viewport.dpr > 0) actualRenderer.setPixelRatio(viewport.dpr);
|
|
1059
|
-
actualRenderer.setSize(size.width, size.height, false);
|
|
1060
|
-
if (canvasTarget) {
|
|
1061
|
-
if (viewport.dpr > 0) canvasTarget.setPixelRatio(viewport.dpr);
|
|
1062
|
-
canvasTarget.setSize(size.width, size.height, false);
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1057
|
+
const resizeTarget = canvasTarget ?? actualRenderer;
|
|
1058
|
+
if (viewport.dpr > 0) resizeTarget.setPixelRatio(viewport.dpr);
|
|
1059
|
+
resizeTarget.setSize(size.width, size.height, false);
|
|
1060
|
+
internal.canvasTargetSizeDirty = true;
|
|
1065
1061
|
}
|
|
1066
1062
|
if (camera !== oldCamera) {
|
|
1067
1063
|
oldCamera = camera;
|
|
@@ -1123,7 +1119,11 @@ function useLoader(loader, input, extensions, onProgress, cacheKey) {
|
|
|
1123
1119
|
const results = cacheKeys.map(
|
|
1124
1120
|
(key, index) => suspend(() => fn(loader, inputs[index]), [loader, key], { equal: is.equ })
|
|
1125
1121
|
);
|
|
1126
|
-
|
|
1122
|
+
const stableRef = useRef(null);
|
|
1123
|
+
const previous = stableRef.current;
|
|
1124
|
+
const stable = previous !== null && previous.length === results.length && previous.every((value, i) => value === results[i]) ? previous : results;
|
|
1125
|
+
stableRef.current = stable;
|
|
1126
|
+
return Array.isArray(input) ? stable : stable[0];
|
|
1127
1127
|
}
|
|
1128
1128
|
useLoader.preload = function(loader, input, extensions, onProgress, cacheKey) {
|
|
1129
1129
|
const inputs = Array.isArray(input) ? input : [input];
|
|
@@ -1138,7 +1138,7 @@ useLoader.clear = function(loader, input, cacheKey) {
|
|
|
1138
1138
|
};
|
|
1139
1139
|
useLoader.loader = getLoader$1;
|
|
1140
1140
|
|
|
1141
|
-
function useFrame(callback, priorityOrOptions) {
|
|
1141
|
+
function useFrame$1(callback, priorityOrOptions) {
|
|
1142
1142
|
const store = React.useContext(context);
|
|
1143
1143
|
const isInsideCanvas = store !== null;
|
|
1144
1144
|
const scheduler = getScheduler();
|
|
@@ -1288,6 +1288,11 @@ function getUrls(input) {
|
|
|
1288
1288
|
if (Array.isArray(input)) return input;
|
|
1289
1289
|
return Object.values(input);
|
|
1290
1290
|
}
|
|
1291
|
+
function inputSignature(input) {
|
|
1292
|
+
if (typeof input === "string") return input;
|
|
1293
|
+
if (Array.isArray(input)) return input.join("\0");
|
|
1294
|
+
return Object.keys(input).sort().map((key) => `${key}\0${input[key]}`).join("");
|
|
1295
|
+
}
|
|
1291
1296
|
function allUrlsCached(urls, textureCache) {
|
|
1292
1297
|
return urls.every((url) => textureCache.has(url));
|
|
1293
1298
|
}
|
|
@@ -1306,25 +1311,26 @@ function buildFromCache(input, textureCache) {
|
|
|
1306
1311
|
}
|
|
1307
1312
|
}
|
|
1308
1313
|
function useTexture(input, optionsOrOnLoad) {
|
|
1309
|
-
const renderer = useThree((state) => state.internal.actualRenderer);
|
|
1314
|
+
const renderer = useThree$1((state) => state.internal.actualRenderer);
|
|
1310
1315
|
const store = useStore();
|
|
1311
1316
|
const options = typeof optionsOrOnLoad === "function" ? { onLoad: optionsOrOnLoad } : optionsOrOnLoad ?? {};
|
|
1312
1317
|
const { onLoad, cache = true } = options;
|
|
1313
1318
|
const onLoadRef = useRef(onLoad);
|
|
1314
1319
|
onLoadRef.current = onLoad;
|
|
1315
1320
|
const onLoadCalledForRef = useRef(null);
|
|
1316
|
-
const
|
|
1321
|
+
const inputKey = useMemo(() => inputSignature(input), [input]);
|
|
1322
|
+
const stableInput = useMemo(() => input, [inputKey]);
|
|
1323
|
+
const urls = useMemo(() => getUrls(stableInput), [stableInput]);
|
|
1317
1324
|
const cachedResult = useMemo(() => {
|
|
1318
1325
|
if (!cache) return null;
|
|
1319
1326
|
const textures = store.getState().textures;
|
|
1320
1327
|
if (!allUrlsCached(urls, textures)) return null;
|
|
1321
|
-
return buildFromCache(
|
|
1322
|
-
}, [cache, urls,
|
|
1328
|
+
return buildFromCache(stableInput, textures);
|
|
1329
|
+
}, [cache, urls, stableInput, store]);
|
|
1323
1330
|
const loadedTextures = useLoader(
|
|
1324
1331
|
TextureLoader,
|
|
1325
|
-
IsObject(
|
|
1332
|
+
IsObject(stableInput) ? Object.values(stableInput) : stableInput
|
|
1326
1333
|
);
|
|
1327
|
-
const inputKey = urls.join("\0");
|
|
1328
1334
|
useLayoutEffect(() => {
|
|
1329
1335
|
if (cachedResult) return;
|
|
1330
1336
|
if (onLoadCalledForRef.current === inputKey) return;
|
|
@@ -1351,28 +1357,28 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
1351
1357
|
}, [renderer, loadedTextures, cachedResult]);
|
|
1352
1358
|
const mappedTextures = useMemo(() => {
|
|
1353
1359
|
if (cachedResult) return cachedResult;
|
|
1354
|
-
if (IsObject(
|
|
1360
|
+
if (IsObject(stableInput)) {
|
|
1355
1361
|
const keyed = {};
|
|
1356
1362
|
const textureArray = loadedTextures;
|
|
1357
1363
|
let i = 0;
|
|
1358
|
-
for (const key in
|
|
1364
|
+
for (const key in stableInput) keyed[key] = textureArray[i++];
|
|
1359
1365
|
return keyed;
|
|
1360
1366
|
} else {
|
|
1361
1367
|
return loadedTextures;
|
|
1362
1368
|
}
|
|
1363
|
-
}, [
|
|
1369
|
+
}, [stableInput, loadedTextures, cachedResult]);
|
|
1364
1370
|
useEffect(() => {
|
|
1365
1371
|
if (!cache) return;
|
|
1366
1372
|
const urlTextureMap = [];
|
|
1367
|
-
if (typeof
|
|
1368
|
-
urlTextureMap.push([
|
|
1369
|
-
} else if (Array.isArray(
|
|
1373
|
+
if (typeof stableInput === "string") {
|
|
1374
|
+
urlTextureMap.push([stableInput, mappedTextures]);
|
|
1375
|
+
} else if (Array.isArray(stableInput)) {
|
|
1370
1376
|
const textureArray = mappedTextures;
|
|
1371
|
-
|
|
1372
|
-
} else if (IsObject(
|
|
1377
|
+
stableInput.forEach((url, i) => urlTextureMap.push([url, textureArray[i]]));
|
|
1378
|
+
} else if (IsObject(stableInput)) {
|
|
1373
1379
|
const textureRecord = mappedTextures;
|
|
1374
|
-
for (const key in
|
|
1375
|
-
const url =
|
|
1380
|
+
for (const key in stableInput) {
|
|
1381
|
+
const url = stableInput[key];
|
|
1376
1382
|
urlTextureMap.push([url, textureRecord[key]]);
|
|
1377
1383
|
}
|
|
1378
1384
|
}
|
|
@@ -1401,7 +1407,7 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
1401
1407
|
}
|
|
1402
1408
|
return { _textureRefs: refs };
|
|
1403
1409
|
});
|
|
1404
|
-
}, [cache,
|
|
1410
|
+
}, [cache, stableInput, mappedTextures, store]);
|
|
1405
1411
|
return mappedTextures;
|
|
1406
1412
|
}
|
|
1407
1413
|
useTexture.preload = (url) => useLoader.preload(TextureLoader, url);
|
|
@@ -1472,13 +1478,13 @@ function useTextures(selector) {
|
|
|
1472
1478
|
};
|
|
1473
1479
|
}, [store]);
|
|
1474
1480
|
const subscribe = selector ? () => selector(registry) : (state) => state.textures;
|
|
1475
|
-
const selected = useThree(subscribe);
|
|
1481
|
+
const selected = useThree$1(subscribe);
|
|
1476
1482
|
return selector ? selected : registry;
|
|
1477
1483
|
}
|
|
1478
1484
|
|
|
1479
1485
|
function useRenderTarget(widthOrOptions, heightOrOptions, options) {
|
|
1480
|
-
const isLegacy = useThree((s) => s.isLegacy);
|
|
1481
|
-
const size = useThree((s) => s.size);
|
|
1486
|
+
const isLegacy = useThree$1((s) => s.isLegacy);
|
|
1487
|
+
const size = useThree$1((s) => s.size);
|
|
1482
1488
|
let width;
|
|
1483
1489
|
let height;
|
|
1484
1490
|
let opts;
|
|
@@ -1535,7 +1541,7 @@ function useEnvironment({
|
|
|
1535
1541
|
const { extension, isCubemap } = getExtension(files);
|
|
1536
1542
|
const loader = getLoader(extension);
|
|
1537
1543
|
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1538
|
-
const renderer = useThree((state) => state.renderer);
|
|
1544
|
+
const renderer = useThree$1((state) => state.renderer);
|
|
1539
1545
|
useLayoutEffect(() => {
|
|
1540
1546
|
if (extension !== "webp" && extension !== "jpg" && extension !== "jpeg") return;
|
|
1541
1547
|
function clearGainmapTexture() {
|
|
@@ -1628,7 +1634,7 @@ function useStore() {
|
|
|
1628
1634
|
if (!store) throw new Error("R3F: Hooks can only be used within the Canvas component!");
|
|
1629
1635
|
return store;
|
|
1630
1636
|
}
|
|
1631
|
-
function useThree(selector = (state) => state, equalityFn) {
|
|
1637
|
+
function useThree$1(selector = (state) => state, equalityFn) {
|
|
1632
1638
|
return useStore()(selector, equalityFn);
|
|
1633
1639
|
}
|
|
1634
1640
|
function useInstanceHandle(ref) {
|
|
@@ -14415,6 +14421,10 @@ function createRoot(canvas) {
|
|
|
14415
14421
|
if (state2.internal.isMultiCanvas && state2.internal.canvasTarget) {
|
|
14416
14422
|
const renderer2 = state2.internal.actualRenderer;
|
|
14417
14423
|
renderer2.setCanvasTarget(state2.internal.canvasTarget);
|
|
14424
|
+
if (state2.internal.canvasTargetSizeDirty) {
|
|
14425
|
+
state2.internal.canvasTargetSizeDirty = false;
|
|
14426
|
+
renderer2.backend?.updateSize?.();
|
|
14427
|
+
}
|
|
14418
14428
|
}
|
|
14419
14429
|
},
|
|
14420
14430
|
{
|
|
@@ -14719,7 +14729,7 @@ function setEnvProps(background, scene, defaultScene, texture, sceneProps = {})
|
|
|
14719
14729
|
};
|
|
14720
14730
|
}
|
|
14721
14731
|
function EnvironmentMap({ scene, background = false, map, ...config }) {
|
|
14722
|
-
const defaultScene = useThree((state) => state.scene);
|
|
14732
|
+
const defaultScene = useThree$1((state) => state.scene);
|
|
14723
14733
|
React.useLayoutEffect(() => {
|
|
14724
14734
|
if (map) return setEnvProps(background, scene, defaultScene, map, config);
|
|
14725
14735
|
});
|
|
@@ -14737,7 +14747,7 @@ function EnvironmentCube({
|
|
|
14737
14747
|
...rest
|
|
14738
14748
|
}) {
|
|
14739
14749
|
const texture = useEnvironment(rest);
|
|
14740
|
-
const defaultScene = useThree((state) => state.scene);
|
|
14750
|
+
const defaultScene = useThree$1((state) => state.scene);
|
|
14741
14751
|
React.useLayoutEffect(() => {
|
|
14742
14752
|
return setEnvProps(background, scene, defaultScene, texture, {
|
|
14743
14753
|
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
@@ -14774,9 +14784,9 @@ function EnvironmentPortal({
|
|
|
14774
14784
|
preset = void 0,
|
|
14775
14785
|
extensions
|
|
14776
14786
|
}) {
|
|
14777
|
-
const renderer = useThree((state) => state.renderer);
|
|
14778
|
-
const isLegacy = useThree((state) => state.isLegacy);
|
|
14779
|
-
const defaultScene = useThree((state) => state.scene);
|
|
14787
|
+
const renderer = useThree$1((state) => state.renderer);
|
|
14788
|
+
const isLegacy = useThree$1((state) => state.isLegacy);
|
|
14789
|
+
const defaultScene = useThree$1((state) => state.scene);
|
|
14780
14790
|
const camera = React.useRef(null);
|
|
14781
14791
|
const [virtualScene] = React.useState(() => new Scene());
|
|
14782
14792
|
const fbo = React.useMemo(() => {
|
|
@@ -14820,7 +14830,7 @@ function EnvironmentPortal({
|
|
|
14820
14830
|
environmentRotation
|
|
14821
14831
|
]);
|
|
14822
14832
|
let count = 1;
|
|
14823
|
-
useFrame(() => {
|
|
14833
|
+
useFrame$1(() => {
|
|
14824
14834
|
if (frames === Infinity || count < frames) {
|
|
14825
14835
|
const autoClear = renderer.autoClear;
|
|
14826
14836
|
renderer.autoClear = true;
|
|
@@ -14860,7 +14870,7 @@ function EnvironmentGround(props) {
|
|
|
14860
14870
|
] });
|
|
14861
14871
|
}
|
|
14862
14872
|
function EnvironmentColor({ color, scene }) {
|
|
14863
|
-
const defaultScene = useThree((state) => state.scene);
|
|
14873
|
+
const defaultScene = useThree$1((state) => state.scene);
|
|
14864
14874
|
React.useLayoutEffect(() => {
|
|
14865
14875
|
if (color === void 0) return;
|
|
14866
14876
|
const target = resolveScene(scene || defaultScene);
|
|
@@ -15454,6 +15464,11 @@ function createTextureOperations(set) {
|
|
|
15454
15464
|
removeMultiple: (keys) => removeTextures(set, keys)
|
|
15455
15465
|
};
|
|
15456
15466
|
}
|
|
15467
|
+
function scopedNodeName(scope, name) {
|
|
15468
|
+
const raw = scope ? `${scope}_${name}` : name;
|
|
15469
|
+
const safe = raw.replace(/[^A-Za-z0-9_]/g, "_");
|
|
15470
|
+
return /^[A-Za-z_]/.test(safe) ? safe : `_${safe}`;
|
|
15471
|
+
}
|
|
15457
15472
|
function extractTSLValue(value) {
|
|
15458
15473
|
if (value === null || value === void 0) return value;
|
|
15459
15474
|
if (typeof value !== "object") return value;
|
|
@@ -15652,8 +15667,7 @@ function createUniform(inName, node, scope) {
|
|
|
15652
15667
|
const inValue = vectorize(node);
|
|
15653
15668
|
const newUniform = uniform(inValue);
|
|
15654
15669
|
if (typeof newUniform.setName === "function") {
|
|
15655
|
-
|
|
15656
|
-
newUniform.setName(name);
|
|
15670
|
+
newUniform.setName(scopedNodeName(scope, inName));
|
|
15657
15671
|
}
|
|
15658
15672
|
return newUniform;
|
|
15659
15673
|
}
|
|
@@ -15752,7 +15766,7 @@ function useNodes(creatorOrScope, scope) {
|
|
|
15752
15766
|
return creatorOrScope(createLazyCreatorState(store.getState(), store));
|
|
15753
15767
|
},
|
|
15754
15768
|
prepare: (name, node) => {
|
|
15755
|
-
node.setName?.(scope
|
|
15769
|
+
node.setName?.(scopedNodeName(scope, name));
|
|
15756
15770
|
return node;
|
|
15757
15771
|
}
|
|
15758
15772
|
});
|
|
@@ -15861,7 +15875,7 @@ function useBuffers(creatorOrScope, scope) {
|
|
|
15861
15875
|
},
|
|
15862
15876
|
prepare: (name, buffer) => {
|
|
15863
15877
|
if ("setName" in buffer && typeof buffer.setName === "function") {
|
|
15864
|
-
buffer.setName(scope
|
|
15878
|
+
buffer.setName(scopedNodeName(scope, name));
|
|
15865
15879
|
}
|
|
15866
15880
|
return buffer;
|
|
15867
15881
|
}
|
|
@@ -15932,7 +15946,7 @@ function useGPUStorage(creatorOrScope, scope) {
|
|
|
15932
15946
|
return creatorOrScope(createLazyCreatorState(store.getState(), store));
|
|
15933
15947
|
},
|
|
15934
15948
|
prepare: (name, storage) => {
|
|
15935
|
-
const label = scope
|
|
15949
|
+
const label = scopedNodeName(scope, name);
|
|
15936
15950
|
if ("setName" in storage && typeof storage.setName === "function") {
|
|
15937
15951
|
storage.setName(label);
|
|
15938
15952
|
}
|
|
@@ -15963,9 +15977,10 @@ function rebuildAllStorage(store, scope) {
|
|
|
15963
15977
|
|
|
15964
15978
|
function useRenderPipeline(mainCB, setupCB) {
|
|
15965
15979
|
const store = useStore();
|
|
15966
|
-
const { scene, camera, renderer, isLegacy } = useThree();
|
|
15980
|
+
const { scene, camera, renderer, isLegacy } = useThree$1();
|
|
15967
15981
|
const callbacksRanRef = useRef(false);
|
|
15968
15982
|
const scenePassCacheRef = useRef(null);
|
|
15983
|
+
const forceScenePassRebuildRef = useRef(false);
|
|
15969
15984
|
const mainCBRef = useRef(mainCB);
|
|
15970
15985
|
const setupCBRef = useRef(setupCB);
|
|
15971
15986
|
mainCBRef.current = mainCB;
|
|
@@ -15973,7 +15988,7 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
15973
15988
|
const [rebuildVersion, setRebuildVersion] = useState(0);
|
|
15974
15989
|
useEffect(() => {
|
|
15975
15990
|
callbacksRanRef.current = false;
|
|
15976
|
-
|
|
15991
|
+
forceScenePassRebuildRef.current = true;
|
|
15977
15992
|
}, []);
|
|
15978
15993
|
const clearPasses = useCallback(() => {
|
|
15979
15994
|
store.setState({ passes: {} });
|
|
@@ -15983,12 +15998,14 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
15983
15998
|
renderPipeline: null,
|
|
15984
15999
|
passes: {}
|
|
15985
16000
|
});
|
|
16001
|
+
scenePassCacheRef.current?.scenePass?.dispose?.();
|
|
15986
16002
|
callbacksRanRef.current = false;
|
|
15987
16003
|
scenePassCacheRef.current = null;
|
|
16004
|
+
forceScenePassRebuildRef.current = false;
|
|
15988
16005
|
}, [store]);
|
|
15989
16006
|
const rebuild = useCallback(() => {
|
|
15990
16007
|
callbacksRanRef.current = false;
|
|
15991
|
-
|
|
16008
|
+
forceScenePassRebuildRef.current = true;
|
|
15992
16009
|
setRebuildVersion((v) => v + 1);
|
|
15993
16010
|
}, []);
|
|
15994
16011
|
useLayoutEffect(() => {
|
|
@@ -16006,16 +16023,23 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
16006
16023
|
pipeline = new RenderPipeline(renderer);
|
|
16007
16024
|
justCreatedPipeline = true;
|
|
16008
16025
|
}
|
|
16009
|
-
const cacheValid = scenePassCacheRef.current && scenePassCacheRef.current.sceneUuid === scene.uuid && scenePassCacheRef.current.cameraUuid === camera.uuid;
|
|
16026
|
+
const cacheValid = !forceScenePassRebuildRef.current && scenePassCacheRef.current && scenePassCacheRef.current.sceneUuid === scene.uuid && scenePassCacheRef.current.cameraUuid === camera.uuid;
|
|
16027
|
+
let outgoingScenePass = null;
|
|
16010
16028
|
let scenePass;
|
|
16011
16029
|
if (cacheValid) {
|
|
16012
16030
|
scenePass = scenePassCacheRef.current.scenePass;
|
|
16013
16031
|
} else {
|
|
16032
|
+
outgoingScenePass = scenePassCacheRef.current?.scenePass ?? null;
|
|
16014
16033
|
scenePass = pass(scene, camera);
|
|
16015
16034
|
scenePassCacheRef.current = { sceneUuid: scene.uuid, cameraUuid: camera.uuid, scenePass };
|
|
16035
|
+
forceScenePassRebuildRef.current = false;
|
|
16016
16036
|
}
|
|
16017
16037
|
currentPasses.scenePass = scenePass;
|
|
16018
|
-
|
|
16038
|
+
let outputNodeChanged = false;
|
|
16039
|
+
if (!pipeline.outputNode || justCreatedPipeline || pipeline.outputNode === outgoingScenePass) {
|
|
16040
|
+
pipeline.outputNode = scenePass;
|
|
16041
|
+
outputNodeChanged = true;
|
|
16042
|
+
}
|
|
16019
16043
|
set({ renderPipeline: pipeline, passes: currentPasses });
|
|
16020
16044
|
const shouldRunCallbacks = justCreatedPipeline || !callbacksRanRef.current || !cacheValid;
|
|
16021
16045
|
if (shouldRunCallbacks) {
|
|
@@ -16035,14 +16059,17 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
16035
16059
|
set({ passes: currentPasses });
|
|
16036
16060
|
}
|
|
16037
16061
|
}
|
|
16062
|
+
outputNodeChanged = true;
|
|
16038
16063
|
callbacksRanRef.current = true;
|
|
16039
16064
|
}
|
|
16065
|
+
if (outputNodeChanged) pipeline.needsUpdate = true;
|
|
16066
|
+
if (outgoingScenePass && outgoingScenePass !== scenePass) outgoingScenePass.dispose?.();
|
|
16040
16067
|
} catch (error) {
|
|
16041
16068
|
console.warn("[useRenderPipeline] Setup failed; the render pipeline was not configured:", error);
|
|
16042
16069
|
}
|
|
16043
16070
|
}, [store, renderer, scene, camera, isLegacy, rebuildVersion]);
|
|
16044
|
-
const passes = useThree((s) => s.passes);
|
|
16045
|
-
const renderPipeline = useThree((s) => s.renderPipeline);
|
|
16071
|
+
const passes = useThree$1((s) => s.passes);
|
|
16072
|
+
const renderPipeline = useThree$1((s) => s.renderPipeline);
|
|
16046
16073
|
return {
|
|
16047
16074
|
passes,
|
|
16048
16075
|
renderPipeline,
|
|
@@ -16055,5 +16082,7 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
16055
16082
|
}
|
|
16056
16083
|
|
|
16057
16084
|
extend(THREE);
|
|
16085
|
+
const useThree = useThree$1;
|
|
16086
|
+
const useFrame = useFrame$1;
|
|
16058
16087
|
|
|
16059
16088
|
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 };
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -143,7 +143,7 @@ Live demo: https://codesandbox.io/s/icy-tree-brnsm?file=/src/App.tsx
|
|
|
143
143
|
<details>
|
|
144
144
|
<summary>Show React Native example</summary>
|
|
145
145
|
|
|
146
|
-
This example
|
|
146
|
+
This example uses `expo-cli`, but you can create a bare project with their template or with the `react-native` CLI.
|
|
147
147
|
|
|
148
148
|
```bash
|
|
149
149
|
# Install expo-cli, this will create our app
|