@react-three/fiber 10.0.0-canary.6eb9584 → 10.0.0-canary.7a50545
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 +94 -43
- package/dist/index.d.cts +40 -11
- package/dist/index.d.mts +40 -11
- package/dist/index.d.ts +40 -11
- package/dist/index.mjs +94 -43
- package/dist/legacy.cjs +94 -43
- package/dist/legacy.d.cts +40 -11
- package/dist/legacy.d.mts +40 -11
- package/dist/legacy.d.ts +40 -11
- package/dist/legacy.mjs +94 -43
- package/dist/webgpu/index.cjs +119 -49
- package/dist/webgpu/index.d.cts +43 -10
- package/dist/webgpu/index.d.mts +43 -10
- package/dist/webgpu/index.d.ts +43 -10
- package/dist/webgpu/index.mjs +119 -49
- package/package.json +2 -2
package/dist/webgpu/index.d.ts
CHANGED
|
@@ -503,6 +503,18 @@ interface InternalState {
|
|
|
503
503
|
* @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
|
|
504
504
|
*/
|
|
505
505
|
canvasTarget?: CanvasTarget
|
|
506
|
+
/**
|
|
507
|
+
* Set when this root's canvas target has been resized and the backend's cached render pass
|
|
508
|
+
* descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
|
|
509
|
+
*
|
|
510
|
+
* Flushed by the canvas-target job in the `start` phase, which is the only place this root's
|
|
511
|
+
* target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
|
|
512
|
+
* whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
|
|
513
|
+
* invalidate some other canvas's descriptor instead.
|
|
514
|
+
*
|
|
515
|
+
* @see https://github.com/pmndrs/react-three-fiber/issues/3847
|
|
516
|
+
*/
|
|
517
|
+
canvasTargetSizeDirty?: boolean
|
|
506
518
|
/**
|
|
507
519
|
* Whether multi-canvas rendering is active.
|
|
508
520
|
* True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
|
|
@@ -712,12 +724,19 @@ type DefaultRendererProps = {
|
|
|
712
724
|
*/
|
|
713
725
|
interface CanvasSchedulerConfig {
|
|
714
726
|
/**
|
|
715
|
-
*
|
|
716
|
-
|
|
727
|
+
* Run this Canvas root before the referenced Canvas root id(s).
|
|
728
|
+
*/
|
|
729
|
+
before?: string | string[]
|
|
730
|
+
/**
|
|
731
|
+
* Run this Canvas root after the referenced Canvas root id(s).
|
|
717
732
|
*/
|
|
718
|
-
after?: string
|
|
733
|
+
after?: string | string[]
|
|
719
734
|
/**
|
|
720
|
-
*
|
|
735
|
+
* Numeric root order. Lower values run first.
|
|
736
|
+
*/
|
|
737
|
+
order?: number
|
|
738
|
+
/**
|
|
739
|
+
* Limit this Canvas's default render job (frames per second).
|
|
721
740
|
*/
|
|
722
741
|
fps?: number
|
|
723
742
|
}
|
|
@@ -1321,11 +1340,16 @@ declare global {
|
|
|
1321
1340
|
/** Pass record - stores TSL pass nodes for render pipeline */
|
|
1322
1341
|
type PassRecord = Record<string, any>
|
|
1323
1342
|
|
|
1343
|
+
/** State passed to pipeline callbacks after the active pipeline has been created */
|
|
1344
|
+
type RenderPipelineCallbackState = RootState & {
|
|
1345
|
+
renderPipeline: ThreeRenderPipeline
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1324
1348
|
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1325
|
-
type RenderPipelineSetupCallback = (state:
|
|
1349
|
+
type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => PassRecord | void
|
|
1326
1350
|
|
|
1327
1351
|
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1328
|
-
type RenderPipelineMainCallback = (state:
|
|
1352
|
+
type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => PassRecord | void
|
|
1329
1353
|
|
|
1330
1354
|
/** Return type for useRenderPipeline hook */
|
|
1331
1355
|
interface UseRenderPipelineReturn {
|
|
@@ -2132,7 +2156,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
|
|
|
2132
2156
|
* Invalidates the view, requesting a frame to be rendered.
|
|
2133
2157
|
* In demand mode, this triggers the scheduler to run frames.
|
|
2134
2158
|
*
|
|
2135
|
-
*
|
|
2159
|
+
* With a state argument, only that root's jobs run on the requested frames; other
|
|
2160
|
+
* roots on 'demand' stay idle. Without one, every registered root is invalidated.
|
|
2161
|
+
*
|
|
2162
|
+
* @param state - Optional root state; targets the invalidation at that root
|
|
2136
2163
|
* @param frames - Number of frames to request (default: 1)
|
|
2137
2164
|
* @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
|
|
2138
2165
|
*
|
|
@@ -2143,14 +2170,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
|
|
|
2143
2170
|
* Advances the frameloop and runs render effects.
|
|
2144
2171
|
* Useful for when manually rendering via `frameloop="never"`.
|
|
2145
2172
|
*
|
|
2173
|
+
* With a state argument, only that root is stepped. Without one, every
|
|
2174
|
+
* registered root is stepped for backwards compatibility.
|
|
2175
|
+
*
|
|
2146
2176
|
* @param timestamp - The timestamp to use for this frame
|
|
2147
2177
|
* @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
|
|
2148
|
-
* @param state -
|
|
2149
|
-
* @param frame - Ignored (kept for backwards compat)
|
|
2178
|
+
* @param state - Optional root state; targets the manual step at that root
|
|
2150
2179
|
*
|
|
2151
2180
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
2152
2181
|
*/
|
|
2153
|
-
declare function advance(timestamp: number): void;
|
|
2182
|
+
declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
|
|
2154
2183
|
|
|
2155
2184
|
/* eslint-disable @definitelytyped/no-unnecessary-generics */
|
|
2156
2185
|
declare function ReactReconciler<
|
|
@@ -4041,6 +4070,10 @@ declare function createTextureOperations(set: StoreApi<RootState>['setState']):
|
|
|
4041
4070
|
* - Callbacks receive full RootState for flexibility
|
|
4042
4071
|
* - No auto-cleanup on unmount - use reset() for explicit cleanup
|
|
4043
4072
|
* - Scene/camera changes trigger scenePass recreation
|
|
4073
|
+
* - A replaced scenePass is disposed once the new graph is installed, so rebuild() does not
|
|
4074
|
+
* strand its render target (and MRT attachments) on the GPU
|
|
4075
|
+
* - Any run that changes the output node sets RenderPipeline.needsUpdate, so rebuild() actually
|
|
4076
|
+
* recompiles instead of silently keeping the first compiled graph
|
|
4044
4077
|
*
|
|
4045
4078
|
* @param mainCB - Main callback to configure outputNode and create effect passes
|
|
4046
4079
|
* @param setupCB - Optional setup callback to configure MRT on scenePass
|
package/dist/webgpu/index.mjs
CHANGED
|
@@ -915,7 +915,7 @@ const createStore = (invalidate, advance) => {
|
|
|
915
915
|
size: newSize,
|
|
916
916
|
viewport: { ...s.viewport, ...getCurrentViewport(state2.camera, defaultTarget, newSize) }
|
|
917
917
|
}));
|
|
918
|
-
|
|
918
|
+
get().invalidate();
|
|
919
919
|
}
|
|
920
920
|
}
|
|
921
921
|
return;
|
|
@@ -930,15 +930,16 @@ const createStore = (invalidate, advance) => {
|
|
|
930
930
|
viewport: { ...s.viewport, ...getCurrentViewport(state2.camera, defaultTarget, size) },
|
|
931
931
|
_sizeImperative: true
|
|
932
932
|
}));
|
|
933
|
-
|
|
933
|
+
get().invalidate();
|
|
934
934
|
},
|
|
935
935
|
setDpr: (dpr) => set((state2) => {
|
|
936
936
|
const resolved = calculateDpr(dpr);
|
|
937
937
|
return { viewport: { ...state2.viewport, dpr: resolved, initialDpr: state2.viewport.initialDpr || resolved } };
|
|
938
938
|
}),
|
|
939
939
|
setFrameloop: (frameloop = "always") => {
|
|
940
|
+
const rootId = get().internal.rootId;
|
|
941
|
+
if (rootId) getScheduler().setRootFrameloop(rootId, frameloop);
|
|
940
942
|
set(() => ({ frameloop }));
|
|
941
|
-
getScheduler().frameloop = frameloop;
|
|
942
943
|
},
|
|
943
944
|
setError: (error) => set(() => ({ error })),
|
|
944
945
|
error: null,
|
|
@@ -1054,17 +1055,10 @@ const createStore = (invalidate, advance) => {
|
|
|
1054
1055
|
oldSize = size;
|
|
1055
1056
|
oldDpr = viewport.dpr;
|
|
1056
1057
|
updateCamera(camera, size);
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
if (viewport.dpr > 0) actualRenderer.setPixelRatio(viewport.dpr);
|
|
1062
|
-
actualRenderer.setSize(size.width, size.height, false);
|
|
1063
|
-
if (canvasTarget) {
|
|
1064
|
-
if (viewport.dpr > 0) canvasTarget.setPixelRatio(viewport.dpr);
|
|
1065
|
-
canvasTarget.setSize(size.width, size.height, false);
|
|
1066
|
-
}
|
|
1067
|
-
}
|
|
1058
|
+
const resizeTarget = canvasTarget ?? actualRenderer;
|
|
1059
|
+
if (viewport.dpr > 0) resizeTarget.setPixelRatio(viewport.dpr);
|
|
1060
|
+
resizeTarget.setSize(size.width, size.height, false);
|
|
1061
|
+
internal.canvasTargetSizeDirty = true;
|
|
1068
1062
|
}
|
|
1069
1063
|
if (camera !== oldCamera) {
|
|
1070
1064
|
oldCamera = camera;
|
|
@@ -1126,7 +1120,11 @@ function useLoader(loader, input, extensions, onProgress, cacheKey) {
|
|
|
1126
1120
|
const results = cacheKeys.map(
|
|
1127
1121
|
(key, index) => suspend(() => fn(loader, inputs[index]), [loader, key], { equal: is.equ })
|
|
1128
1122
|
);
|
|
1129
|
-
|
|
1123
|
+
const stableRef = useRef(null);
|
|
1124
|
+
const previous = stableRef.current;
|
|
1125
|
+
const stable = previous !== null && previous.length === results.length && previous.every((value, i) => value === results[i]) ? previous : results;
|
|
1126
|
+
stableRef.current = stable;
|
|
1127
|
+
return Array.isArray(input) ? stable : stable[0];
|
|
1130
1128
|
}
|
|
1131
1129
|
useLoader.preload = function(loader, input, extensions, onProgress, cacheKey) {
|
|
1132
1130
|
const inputs = Array.isArray(input) ? input : [input];
|
|
@@ -1246,6 +1244,13 @@ function useFrame$1(callback, priorityOrOptions) {
|
|
|
1246
1244
|
* Use for controlling the entire frame loop, adding phases, etc.
|
|
1247
1245
|
*/
|
|
1248
1246
|
scheduler: scheduler2,
|
|
1247
|
+
/**
|
|
1248
|
+
* The root that currently owns this job. Resolve on access because ambient
|
|
1249
|
+
* jobs can be adopted by a Canvas after the controls object is created.
|
|
1250
|
+
*/
|
|
1251
|
+
get rootId() {
|
|
1252
|
+
return getScheduler().getJobRootId(id);
|
|
1253
|
+
},
|
|
1249
1254
|
/**
|
|
1250
1255
|
* Manually step this job only.
|
|
1251
1256
|
* Bypasses FPS limiting - always runs.
|
|
@@ -1262,6 +1267,14 @@ function useFrame$1(callback, priorityOrOptions) {
|
|
|
1262
1267
|
stepAll: (timestamp) => {
|
|
1263
1268
|
getScheduler().step(timestamp);
|
|
1264
1269
|
},
|
|
1270
|
+
/**
|
|
1271
|
+
* Request frames for this job's owning root without waking sibling roots.
|
|
1272
|
+
*/
|
|
1273
|
+
invalidate: (frames, stackFrames) => {
|
|
1274
|
+
const scheduler3 = getScheduler();
|
|
1275
|
+
const rootId = scheduler3.getJobRootId(id);
|
|
1276
|
+
if (rootId) scheduler3.invalidateRoot(rootId, frames, stackFrames);
|
|
1277
|
+
},
|
|
1265
1278
|
/**
|
|
1266
1279
|
* Pause this job (set enabled=false).
|
|
1267
1280
|
* Job remains registered but won't run.
|
|
@@ -1291,6 +1304,11 @@ function getUrls(input) {
|
|
|
1291
1304
|
if (Array.isArray(input)) return input;
|
|
1292
1305
|
return Object.values(input);
|
|
1293
1306
|
}
|
|
1307
|
+
function inputSignature(input) {
|
|
1308
|
+
if (typeof input === "string") return input;
|
|
1309
|
+
if (Array.isArray(input)) return input.join("\0");
|
|
1310
|
+
return Object.keys(input).sort().map((key) => `${key}\0${input[key]}`).join("");
|
|
1311
|
+
}
|
|
1294
1312
|
function allUrlsCached(urls, textureCache) {
|
|
1295
1313
|
return urls.every((url) => textureCache.has(url));
|
|
1296
1314
|
}
|
|
@@ -1316,18 +1334,19 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
1316
1334
|
const onLoadRef = useRef(onLoad);
|
|
1317
1335
|
onLoadRef.current = onLoad;
|
|
1318
1336
|
const onLoadCalledForRef = useRef(null);
|
|
1319
|
-
const
|
|
1337
|
+
const inputKey = useMemo(() => inputSignature(input), [input]);
|
|
1338
|
+
const stableInput = useMemo(() => input, [inputKey]);
|
|
1339
|
+
const urls = useMemo(() => getUrls(stableInput), [stableInput]);
|
|
1320
1340
|
const cachedResult = useMemo(() => {
|
|
1321
1341
|
if (!cache) return null;
|
|
1322
1342
|
const textures = store.getState().textures;
|
|
1323
1343
|
if (!allUrlsCached(urls, textures)) return null;
|
|
1324
|
-
return buildFromCache(
|
|
1325
|
-
}, [cache, urls,
|
|
1344
|
+
return buildFromCache(stableInput, textures);
|
|
1345
|
+
}, [cache, urls, stableInput, store]);
|
|
1326
1346
|
const loadedTextures = useLoader(
|
|
1327
1347
|
TextureLoader,
|
|
1328
|
-
IsObject(
|
|
1348
|
+
IsObject(stableInput) ? Object.values(stableInput) : stableInput
|
|
1329
1349
|
);
|
|
1330
|
-
const inputKey = urls.join("\0");
|
|
1331
1350
|
useLayoutEffect(() => {
|
|
1332
1351
|
if (cachedResult) return;
|
|
1333
1352
|
if (onLoadCalledForRef.current === inputKey) return;
|
|
@@ -1354,28 +1373,28 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
1354
1373
|
}, [renderer, loadedTextures, cachedResult]);
|
|
1355
1374
|
const mappedTextures = useMemo(() => {
|
|
1356
1375
|
if (cachedResult) return cachedResult;
|
|
1357
|
-
if (IsObject(
|
|
1376
|
+
if (IsObject(stableInput)) {
|
|
1358
1377
|
const keyed = {};
|
|
1359
1378
|
const textureArray = loadedTextures;
|
|
1360
1379
|
let i = 0;
|
|
1361
|
-
for (const key in
|
|
1380
|
+
for (const key in stableInput) keyed[key] = textureArray[i++];
|
|
1362
1381
|
return keyed;
|
|
1363
1382
|
} else {
|
|
1364
1383
|
return loadedTextures;
|
|
1365
1384
|
}
|
|
1366
|
-
}, [
|
|
1385
|
+
}, [stableInput, loadedTextures, cachedResult]);
|
|
1367
1386
|
useEffect(() => {
|
|
1368
1387
|
if (!cache) return;
|
|
1369
1388
|
const urlTextureMap = [];
|
|
1370
|
-
if (typeof
|
|
1371
|
-
urlTextureMap.push([
|
|
1372
|
-
} else if (Array.isArray(
|
|
1389
|
+
if (typeof stableInput === "string") {
|
|
1390
|
+
urlTextureMap.push([stableInput, mappedTextures]);
|
|
1391
|
+
} else if (Array.isArray(stableInput)) {
|
|
1373
1392
|
const textureArray = mappedTextures;
|
|
1374
|
-
|
|
1375
|
-
} else if (IsObject(
|
|
1393
|
+
stableInput.forEach((url, i) => urlTextureMap.push([url, textureArray[i]]));
|
|
1394
|
+
} else if (IsObject(stableInput)) {
|
|
1376
1395
|
const textureRecord = mappedTextures;
|
|
1377
|
-
for (const key in
|
|
1378
|
-
const url =
|
|
1396
|
+
for (const key in stableInput) {
|
|
1397
|
+
const url = stableInput[key];
|
|
1379
1398
|
urlTextureMap.push([url, textureRecord[key]]);
|
|
1380
1399
|
}
|
|
1381
1400
|
}
|
|
@@ -1404,7 +1423,7 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
1404
1423
|
}
|
|
1405
1424
|
return { _textureRefs: refs };
|
|
1406
1425
|
});
|
|
1407
|
-
}, [cache,
|
|
1426
|
+
}, [cache, stableInput, mappedTextures, store]);
|
|
1408
1427
|
return mappedTextures;
|
|
1409
1428
|
}
|
|
1410
1429
|
useTexture.preload = (url) => useLoader.preload(TextureLoader, url);
|
|
@@ -1673,10 +1692,16 @@ function addTail(callback) {
|
|
|
1673
1692
|
return getScheduler().onIdle(callback);
|
|
1674
1693
|
}
|
|
1675
1694
|
function invalidate(state, frames = 1, stackFrames = false) {
|
|
1676
|
-
|
|
1695
|
+
const rootId = state?.internal?.rootId;
|
|
1696
|
+
const scheduler = getScheduler();
|
|
1697
|
+
if (rootId) scheduler.invalidateRoot(rootId, frames, stackFrames);
|
|
1698
|
+
else scheduler.invalidate(frames, stackFrames);
|
|
1677
1699
|
}
|
|
1678
|
-
function advance(timestamp) {
|
|
1679
|
-
|
|
1700
|
+
function advance(timestamp, runGlobalEffects, state) {
|
|
1701
|
+
const rootId = state?.internal?.rootId;
|
|
1702
|
+
const scheduler = getScheduler();
|
|
1703
|
+
if (rootId) scheduler.stepRoot(rootId, timestamp);
|
|
1704
|
+
else scheduler.step(timestamp);
|
|
1680
1705
|
}
|
|
1681
1706
|
|
|
1682
1707
|
const version = "10.0.0-alpha.3";
|
|
@@ -14320,7 +14345,7 @@ function createRoot(canvas) {
|
|
|
14320
14345
|
const handleXRFrame = (timestamp, _frame) => {
|
|
14321
14346
|
const state2 = store.getState();
|
|
14322
14347
|
if (state2.frameloop === "never") return;
|
|
14323
|
-
advance(timestamp);
|
|
14348
|
+
advance(timestamp, true, state2);
|
|
14324
14349
|
};
|
|
14325
14350
|
const actualRenderer = state.internal.actualRenderer;
|
|
14326
14351
|
const handleSessionChange = () => {
|
|
@@ -14328,7 +14353,7 @@ function createRoot(canvas) {
|
|
|
14328
14353
|
const renderer2 = state2.internal.actualRenderer;
|
|
14329
14354
|
actualRenderer.xr.enabled = actualRenderer.xr.isPresenting;
|
|
14330
14355
|
renderer2.xr.setAnimationLoop(renderer2.xr.isPresenting ? handleXRFrame : null);
|
|
14331
|
-
if (!renderer2.xr.isPresenting) invalidate();
|
|
14356
|
+
if (!renderer2.xr.isPresenting) invalidate(state2);
|
|
14332
14357
|
};
|
|
14333
14358
|
const xr = {
|
|
14334
14359
|
connect() {
|
|
@@ -14410,7 +14435,11 @@ function createRoot(canvas) {
|
|
|
14410
14435
|
const newRootId = canvasId || scheduler.generateRootId();
|
|
14411
14436
|
const unregisterRoot = scheduler.registerRoot(newRootId, {
|
|
14412
14437
|
getState: () => store.getState(),
|
|
14413
|
-
onError: (err) => store.getState().setError(err)
|
|
14438
|
+
onError: (err) => store.getState().setError(err),
|
|
14439
|
+
frameloop: store.getState().frameloop,
|
|
14440
|
+
before: schedulerConfig?.before,
|
|
14441
|
+
after: schedulerConfig?.after,
|
|
14442
|
+
order: schedulerConfig?.order
|
|
14414
14443
|
});
|
|
14415
14444
|
const unregisterCanvasTarget = scheduler.register(
|
|
14416
14445
|
() => {
|
|
@@ -14418,6 +14447,10 @@ function createRoot(canvas) {
|
|
|
14418
14447
|
if (state2.internal.isMultiCanvas && state2.internal.canvasTarget) {
|
|
14419
14448
|
const renderer2 = state2.internal.actualRenderer;
|
|
14420
14449
|
renderer2.setCanvasTarget(state2.internal.canvasTarget);
|
|
14450
|
+
if (state2.internal.canvasTargetSizeDirty) {
|
|
14451
|
+
state2.internal.canvasTargetSizeDirty = false;
|
|
14452
|
+
renderer2.backend?.updateSize?.();
|
|
14453
|
+
}
|
|
14421
14454
|
}
|
|
14422
14455
|
},
|
|
14423
14456
|
{
|
|
@@ -14486,8 +14519,7 @@ function createRoot(canvas) {
|
|
|
14486
14519
|
phase: "render",
|
|
14487
14520
|
system: true,
|
|
14488
14521
|
// Internal flag: this is a system job, not user-controlled
|
|
14489
|
-
//
|
|
14490
|
-
...schedulerConfig?.after && { after: schedulerConfig.after },
|
|
14522
|
+
// FPS throttles only the default render job; Canvas ordering belongs to the root.
|
|
14491
14523
|
...schedulerConfig?.fps && { fps: schedulerConfig.fps }
|
|
14492
14524
|
}
|
|
14493
14525
|
);
|
|
@@ -14506,8 +14538,21 @@ function createRoot(canvas) {
|
|
|
14506
14538
|
scheduler
|
|
14507
14539
|
}
|
|
14508
14540
|
}));
|
|
14541
|
+
} else {
|
|
14542
|
+
const constraintsChanged = !is.equ(schedulerConfig?.before, lastConfiguredProps.schedulerBefore, shallowLoose) || !is.equ(schedulerConfig?.after, lastConfiguredProps.schedulerAfter, shallowLoose);
|
|
14543
|
+
if (constraintsChanged) {
|
|
14544
|
+
scheduler.setRootConstraints(rootId, {
|
|
14545
|
+
before: schedulerConfig?.before,
|
|
14546
|
+
after: schedulerConfig?.after
|
|
14547
|
+
});
|
|
14548
|
+
}
|
|
14549
|
+
if (schedulerConfig?.order !== lastConfiguredProps.schedulerOrder) {
|
|
14550
|
+
scheduler.setRootOrder(rootId, schedulerConfig?.order ?? 0);
|
|
14551
|
+
}
|
|
14509
14552
|
}
|
|
14510
|
-
|
|
14553
|
+
lastConfiguredProps.schedulerBefore = schedulerConfig?.before;
|
|
14554
|
+
lastConfiguredProps.schedulerAfter = schedulerConfig?.after;
|
|
14555
|
+
lastConfiguredProps.schedulerOrder = schedulerConfig?.order;
|
|
14511
14556
|
onCreated = onCreatedCallback;
|
|
14512
14557
|
configured = true;
|
|
14513
14558
|
resolve();
|
|
@@ -14549,14 +14594,19 @@ function unmountComponentAtNode(canvas, callback) {
|
|
|
14549
14594
|
const fiber = root?.fiber;
|
|
14550
14595
|
if (fiber) {
|
|
14551
14596
|
const state = root?.store.getState();
|
|
14552
|
-
if (state)
|
|
14597
|
+
if (state) {
|
|
14598
|
+
state.internal.active = false;
|
|
14599
|
+
const unregisterRoot = state.internal.unregisterRoot;
|
|
14600
|
+
if (unregisterRoot) {
|
|
14601
|
+
unregisterRoot();
|
|
14602
|
+
state.internal.unregisterRoot = void 0;
|
|
14603
|
+
}
|
|
14604
|
+
}
|
|
14553
14605
|
reconciler.updateContainer(null, fiber, null, () => {
|
|
14554
14606
|
if (state) {
|
|
14555
14607
|
setTimeout(() => {
|
|
14556
14608
|
try {
|
|
14557
14609
|
const renderer = state.internal.actualRenderer;
|
|
14558
|
-
const unregisterRoot = state.internal.unregisterRoot;
|
|
14559
|
-
if (unregisterRoot) unregisterRoot();
|
|
14560
14610
|
const unregisterPrimary = state.internal.unregisterPrimary;
|
|
14561
14611
|
if (unregisterPrimary) unregisterPrimary();
|
|
14562
14612
|
const canvasTarget = state.internal.canvasTarget;
|
|
@@ -15247,6 +15297,7 @@ function CanvasImpl({
|
|
|
15247
15297
|
const canvas = canvasRef.current;
|
|
15248
15298
|
if (canvas) {
|
|
15249
15299
|
return () => {
|
|
15300
|
+
if (canvas.isConnected) return;
|
|
15250
15301
|
unmountComponentAtNode(canvas);
|
|
15251
15302
|
root.current = null;
|
|
15252
15303
|
};
|
|
@@ -15973,6 +16024,7 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
15973
16024
|
const { scene, camera, renderer, isLegacy } = useThree$1();
|
|
15974
16025
|
const callbacksRanRef = useRef(false);
|
|
15975
16026
|
const scenePassCacheRef = useRef(null);
|
|
16027
|
+
const forceScenePassRebuildRef = useRef(false);
|
|
15976
16028
|
const mainCBRef = useRef(mainCB);
|
|
15977
16029
|
const setupCBRef = useRef(setupCB);
|
|
15978
16030
|
mainCBRef.current = mainCB;
|
|
@@ -15980,7 +16032,7 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
15980
16032
|
const [rebuildVersion, setRebuildVersion] = useState(0);
|
|
15981
16033
|
useEffect(() => {
|
|
15982
16034
|
callbacksRanRef.current = false;
|
|
15983
|
-
|
|
16035
|
+
forceScenePassRebuildRef.current = true;
|
|
15984
16036
|
}, []);
|
|
15985
16037
|
const clearPasses = useCallback(() => {
|
|
15986
16038
|
store.setState({ passes: {} });
|
|
@@ -15990,12 +16042,14 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
15990
16042
|
renderPipeline: null,
|
|
15991
16043
|
passes: {}
|
|
15992
16044
|
});
|
|
16045
|
+
scenePassCacheRef.current?.scenePass?.dispose?.();
|
|
15993
16046
|
callbacksRanRef.current = false;
|
|
15994
16047
|
scenePassCacheRef.current = null;
|
|
16048
|
+
forceScenePassRebuildRef.current = false;
|
|
15995
16049
|
}, [store]);
|
|
15996
16050
|
const rebuild = useCallback(() => {
|
|
15997
16051
|
callbacksRanRef.current = false;
|
|
15998
|
-
|
|
16052
|
+
forceScenePassRebuildRef.current = true;
|
|
15999
16053
|
setRebuildVersion((v) => v + 1);
|
|
16000
16054
|
}, []);
|
|
16001
16055
|
useLayoutEffect(() => {
|
|
@@ -16013,21 +16067,31 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
16013
16067
|
pipeline = new RenderPipeline(renderer);
|
|
16014
16068
|
justCreatedPipeline = true;
|
|
16015
16069
|
}
|
|
16016
|
-
const cacheValid = scenePassCacheRef.current && scenePassCacheRef.current.sceneUuid === scene.uuid && scenePassCacheRef.current.cameraUuid === camera.uuid;
|
|
16070
|
+
const cacheValid = !forceScenePassRebuildRef.current && scenePassCacheRef.current && scenePassCacheRef.current.sceneUuid === scene.uuid && scenePassCacheRef.current.cameraUuid === camera.uuid;
|
|
16071
|
+
let outgoingScenePass = null;
|
|
16017
16072
|
let scenePass;
|
|
16018
16073
|
if (cacheValid) {
|
|
16019
16074
|
scenePass = scenePassCacheRef.current.scenePass;
|
|
16020
16075
|
} else {
|
|
16076
|
+
outgoingScenePass = scenePassCacheRef.current?.scenePass ?? null;
|
|
16021
16077
|
scenePass = pass(scene, camera);
|
|
16022
16078
|
scenePassCacheRef.current = { sceneUuid: scene.uuid, cameraUuid: camera.uuid, scenePass };
|
|
16079
|
+
forceScenePassRebuildRef.current = false;
|
|
16023
16080
|
}
|
|
16024
16081
|
currentPasses.scenePass = scenePass;
|
|
16025
|
-
|
|
16082
|
+
let outputNodeChanged = false;
|
|
16083
|
+
if (!pipeline.outputNode || justCreatedPipeline || pipeline.outputNode === outgoingScenePass) {
|
|
16084
|
+
pipeline.outputNode = scenePass;
|
|
16085
|
+
outputNodeChanged = true;
|
|
16086
|
+
}
|
|
16026
16087
|
set({ renderPipeline: pipeline, passes: currentPasses });
|
|
16027
16088
|
const shouldRunCallbacks = justCreatedPipeline || !callbacksRanRef.current || !cacheValid;
|
|
16028
16089
|
if (shouldRunCallbacks) {
|
|
16029
16090
|
if (setupCBRef.current) {
|
|
16030
|
-
const freshState = store.getState()
|
|
16091
|
+
const freshState = Object.assign({}, store.getState(), {
|
|
16092
|
+
renderPipeline: pipeline,
|
|
16093
|
+
passes: currentPasses
|
|
16094
|
+
});
|
|
16031
16095
|
const setupResult = setupCBRef.current(freshState);
|
|
16032
16096
|
if (setupResult && typeof setupResult === "object") {
|
|
16033
16097
|
currentPasses = { ...currentPasses, ...setupResult };
|
|
@@ -16035,15 +16099,21 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
16035
16099
|
}
|
|
16036
16100
|
}
|
|
16037
16101
|
if (mainCBRef.current) {
|
|
16038
|
-
const freshState = store.getState()
|
|
16102
|
+
const freshState = Object.assign({}, store.getState(), {
|
|
16103
|
+
renderPipeline: pipeline,
|
|
16104
|
+
passes: currentPasses
|
|
16105
|
+
});
|
|
16039
16106
|
const mainResult = mainCBRef.current(freshState);
|
|
16040
16107
|
if (mainResult && typeof mainResult === "object") {
|
|
16041
16108
|
currentPasses = { ...currentPasses, ...mainResult };
|
|
16042
16109
|
set({ passes: currentPasses });
|
|
16043
16110
|
}
|
|
16044
16111
|
}
|
|
16112
|
+
outputNodeChanged = true;
|
|
16045
16113
|
callbacksRanRef.current = true;
|
|
16046
16114
|
}
|
|
16115
|
+
if (outputNodeChanged) pipeline.needsUpdate = true;
|
|
16116
|
+
if (outgoingScenePass && outgoingScenePass !== scenePass) outgoingScenePass.dispose?.();
|
|
16047
16117
|
} catch (error) {
|
|
16048
16118
|
console.warn("[useRenderPipeline] Setup failed; the render pipeline was not configured:", error);
|
|
16049
16119
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-three/fiber",
|
|
3
|
-
"version": "10.0.0-canary.
|
|
3
|
+
"version": "10.0.0-canary.7a50545",
|
|
4
4
|
"description": "A React renderer for Threejs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@babel/runtime": "^7.28.6",
|
|
60
60
|
"@monogrid/gainmap-js": "^3.4.0",
|
|
61
|
-
"@pmndrs/scheduler": "^0.
|
|
61
|
+
"@pmndrs/scheduler": "^0.2.0",
|
|
62
62
|
"dequal": "^2.0.3",
|
|
63
63
|
"its-fine": "^2.0.0",
|
|
64
64
|
"react-use-measure": "^2.1.7",
|