@react-three/fiber 10.0.0-canary.c6846c3 → 10.0.0-canary.ce4bd5f
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 +105 -53
- package/dist/index.d.cts +46 -12
- package/dist/index.d.mts +46 -12
- package/dist/index.d.ts +46 -12
- package/dist/index.mjs +105 -53
- package/dist/legacy.cjs +104 -57
- package/dist/legacy.d.cts +45 -15
- package/dist/legacy.d.mts +45 -15
- package/dist/legacy.d.ts +45 -15
- package/dist/legacy.mjs +104 -57
- package/dist/webgpu/index.cjs +158 -81
- package/dist/webgpu/index.d.cts +67 -61
- package/dist/webgpu/index.d.mts +67 -61
- package/dist/webgpu/index.d.ts +67 -61
- package/dist/webgpu/index.mjs +158 -81
- package/package.json +2 -2
package/dist/legacy.cjs
CHANGED
|
@@ -50,11 +50,9 @@ const Tb__default = /*#__PURE__*/_interopDefaultCompat(Tb);
|
|
|
50
50
|
|
|
51
51
|
const R3F_BUILD_LEGACY = true;
|
|
52
52
|
const R3F_BUILD_WEBGPU = false;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
};
|
|
53
|
+
async function loadInspector() {
|
|
54
|
+
throw new Error("Inspector is not available in legacy builds. Use @react-three/fiber/webgpu instead.");
|
|
55
|
+
}
|
|
58
56
|
const WebGPURenderer = class WebGPURenderer2 {
|
|
59
57
|
constructor() {
|
|
60
58
|
throw new Error("WebGPURenderer is not available in legacy builds. Use @react-three/fiber/webgpu instead.");
|
|
@@ -67,12 +65,12 @@ const THREE = /*#__PURE__*/_mergeNamespaces({
|
|
|
67
65
|
__proto__: null,
|
|
68
66
|
CubeRenderTarget: CubeRenderTarget,
|
|
69
67
|
CubeRenderTargetCompat: three.WebGLCubeRenderTarget,
|
|
70
|
-
Inspector: Inspector,
|
|
71
68
|
R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
|
|
72
69
|
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
73
70
|
RenderTarget: RenderTarget,
|
|
74
71
|
RenderTargetCompat: three.WebGLRenderTarget,
|
|
75
|
-
WebGPURenderer: WebGPURenderer
|
|
72
|
+
WebGPURenderer: WebGPURenderer,
|
|
73
|
+
loadInspector: loadInspector
|
|
76
74
|
}, [three__namespace]);
|
|
77
75
|
|
|
78
76
|
const primaryRegistry = /* @__PURE__ */ new Map();
|
|
@@ -931,7 +929,7 @@ const createStore = (invalidate, advance) => {
|
|
|
931
929
|
size: newSize,
|
|
932
930
|
viewport: { ...s.viewport, ...getCurrentViewport(state2.camera, defaultTarget, newSize) }
|
|
933
931
|
}));
|
|
934
|
-
|
|
932
|
+
get().invalidate();
|
|
935
933
|
}
|
|
936
934
|
}
|
|
937
935
|
return;
|
|
@@ -946,15 +944,16 @@ const createStore = (invalidate, advance) => {
|
|
|
946
944
|
viewport: { ...s.viewport, ...getCurrentViewport(state2.camera, defaultTarget, size) },
|
|
947
945
|
_sizeImperative: true
|
|
948
946
|
}));
|
|
949
|
-
|
|
947
|
+
get().invalidate();
|
|
950
948
|
},
|
|
951
949
|
setDpr: (dpr) => set((state2) => {
|
|
952
950
|
const resolved = calculateDpr(dpr);
|
|
953
951
|
return { viewport: { ...state2.viewport, dpr: resolved, initialDpr: state2.viewport.initialDpr || resolved } };
|
|
954
952
|
}),
|
|
955
953
|
setFrameloop: (frameloop = "always") => {
|
|
954
|
+
const rootId = get().internal.rootId;
|
|
955
|
+
if (rootId) scheduler.getScheduler().setRootFrameloop(rootId, frameloop);
|
|
956
956
|
set(() => ({ frameloop }));
|
|
957
|
-
scheduler.getScheduler().frameloop = frameloop;
|
|
958
957
|
},
|
|
959
958
|
setError: (error) => set(() => ({ error })),
|
|
960
959
|
error: null,
|
|
@@ -1070,17 +1069,10 @@ const createStore = (invalidate, advance) => {
|
|
|
1070
1069
|
oldSize = size;
|
|
1071
1070
|
oldDpr = viewport.dpr;
|
|
1072
1071
|
updateCamera(camera, size);
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
if (viewport.dpr > 0) actualRenderer.setPixelRatio(viewport.dpr);
|
|
1078
|
-
actualRenderer.setSize(size.width, size.height, false);
|
|
1079
|
-
if (canvasTarget) {
|
|
1080
|
-
if (viewport.dpr > 0) canvasTarget.setPixelRatio(viewport.dpr);
|
|
1081
|
-
canvasTarget.setSize(size.width, size.height, false);
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1072
|
+
const resizeTarget = canvasTarget ?? actualRenderer;
|
|
1073
|
+
if (viewport.dpr > 0) resizeTarget.setPixelRatio(viewport.dpr);
|
|
1074
|
+
resizeTarget.setSize(size.width, size.height, false);
|
|
1075
|
+
internal.canvasTargetSizeDirty = true;
|
|
1084
1076
|
}
|
|
1085
1077
|
if (camera !== oldCamera) {
|
|
1086
1078
|
oldCamera = camera;
|
|
@@ -1142,7 +1134,11 @@ function useLoader(loader, input, extensions, onProgress, cacheKey) {
|
|
|
1142
1134
|
const results = cacheKeys.map(
|
|
1143
1135
|
(key, index) => suspendReact.suspend(() => fn(loader, inputs[index]), [loader, key], { equal: is.equ })
|
|
1144
1136
|
);
|
|
1145
|
-
|
|
1137
|
+
const stableRef = React.useRef(null);
|
|
1138
|
+
const previous = stableRef.current;
|
|
1139
|
+
const stable = previous !== null && previous.length === results.length && previous.every((value, i) => value === results[i]) ? previous : results;
|
|
1140
|
+
stableRef.current = stable;
|
|
1141
|
+
return Array.isArray(input) ? stable : stable[0];
|
|
1146
1142
|
}
|
|
1147
1143
|
useLoader.preload = function(loader, input, extensions, onProgress, cacheKey) {
|
|
1148
1144
|
const inputs = Array.isArray(input) ? input : [input];
|
|
@@ -1262,6 +1258,13 @@ function useFrame(callback, priorityOrOptions) {
|
|
|
1262
1258
|
* Use for controlling the entire frame loop, adding phases, etc.
|
|
1263
1259
|
*/
|
|
1264
1260
|
scheduler: scheduler2,
|
|
1261
|
+
/**
|
|
1262
|
+
* The root that currently owns this job. Resolve on access because ambient
|
|
1263
|
+
* jobs can be adopted by a Canvas after the controls object is created.
|
|
1264
|
+
*/
|
|
1265
|
+
get rootId() {
|
|
1266
|
+
return scheduler.getScheduler().getJobRootId(id);
|
|
1267
|
+
},
|
|
1265
1268
|
/**
|
|
1266
1269
|
* Manually step this job only.
|
|
1267
1270
|
* Bypasses FPS limiting - always runs.
|
|
@@ -1278,6 +1281,14 @@ function useFrame(callback, priorityOrOptions) {
|
|
|
1278
1281
|
stepAll: (timestamp) => {
|
|
1279
1282
|
scheduler.getScheduler().step(timestamp);
|
|
1280
1283
|
},
|
|
1284
|
+
/**
|
|
1285
|
+
* Request frames for this job's owning root without waking sibling roots.
|
|
1286
|
+
*/
|
|
1287
|
+
invalidate: (frames, stackFrames) => {
|
|
1288
|
+
const scheduler3 = scheduler.getScheduler();
|
|
1289
|
+
const rootId = scheduler3.getJobRootId(id);
|
|
1290
|
+
if (rootId) scheduler3.invalidateRoot(rootId, frames, stackFrames);
|
|
1291
|
+
},
|
|
1281
1292
|
/**
|
|
1282
1293
|
* Pause this job (set enabled=false).
|
|
1283
1294
|
* Job remains registered but won't run.
|
|
@@ -1307,6 +1318,11 @@ function getUrls(input) {
|
|
|
1307
1318
|
if (Array.isArray(input)) return input;
|
|
1308
1319
|
return Object.values(input);
|
|
1309
1320
|
}
|
|
1321
|
+
function inputSignature(input) {
|
|
1322
|
+
if (typeof input === "string") return input;
|
|
1323
|
+
if (Array.isArray(input)) return input.join("\0");
|
|
1324
|
+
return Object.keys(input).sort().map((key) => `${key}\0${input[key]}`).join("");
|
|
1325
|
+
}
|
|
1310
1326
|
function allUrlsCached(urls, textureCache) {
|
|
1311
1327
|
return urls.every((url) => textureCache.has(url));
|
|
1312
1328
|
}
|
|
@@ -1332,18 +1348,19 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
1332
1348
|
const onLoadRef = React.useRef(onLoad);
|
|
1333
1349
|
onLoadRef.current = onLoad;
|
|
1334
1350
|
const onLoadCalledForRef = React.useRef(null);
|
|
1335
|
-
const
|
|
1351
|
+
const inputKey = React.useMemo(() => inputSignature(input), [input]);
|
|
1352
|
+
const stableInput = React.useMemo(() => input, [inputKey]);
|
|
1353
|
+
const urls = React.useMemo(() => getUrls(stableInput), [stableInput]);
|
|
1336
1354
|
const cachedResult = React.useMemo(() => {
|
|
1337
1355
|
if (!cache) return null;
|
|
1338
1356
|
const textures = store.getState().textures;
|
|
1339
1357
|
if (!allUrlsCached(urls, textures)) return null;
|
|
1340
|
-
return buildFromCache(
|
|
1341
|
-
}, [cache, urls,
|
|
1358
|
+
return buildFromCache(stableInput, textures);
|
|
1359
|
+
}, [cache, urls, stableInput, store]);
|
|
1342
1360
|
const loadedTextures = useLoader(
|
|
1343
1361
|
three.TextureLoader,
|
|
1344
|
-
IsObject(
|
|
1362
|
+
IsObject(stableInput) ? Object.values(stableInput) : stableInput
|
|
1345
1363
|
);
|
|
1346
|
-
const inputKey = urls.join("\0");
|
|
1347
1364
|
React.useLayoutEffect(() => {
|
|
1348
1365
|
if (cachedResult) return;
|
|
1349
1366
|
if (onLoadCalledForRef.current === inputKey) return;
|
|
@@ -1370,28 +1387,28 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
1370
1387
|
}, [renderer, loadedTextures, cachedResult]);
|
|
1371
1388
|
const mappedTextures = React.useMemo(() => {
|
|
1372
1389
|
if (cachedResult) return cachedResult;
|
|
1373
|
-
if (IsObject(
|
|
1390
|
+
if (IsObject(stableInput)) {
|
|
1374
1391
|
const keyed = {};
|
|
1375
1392
|
const textureArray = loadedTextures;
|
|
1376
1393
|
let i = 0;
|
|
1377
|
-
for (const key in
|
|
1394
|
+
for (const key in stableInput) keyed[key] = textureArray[i++];
|
|
1378
1395
|
return keyed;
|
|
1379
1396
|
} else {
|
|
1380
1397
|
return loadedTextures;
|
|
1381
1398
|
}
|
|
1382
|
-
}, [
|
|
1399
|
+
}, [stableInput, loadedTextures, cachedResult]);
|
|
1383
1400
|
React.useEffect(() => {
|
|
1384
1401
|
if (!cache) return;
|
|
1385
1402
|
const urlTextureMap = [];
|
|
1386
|
-
if (typeof
|
|
1387
|
-
urlTextureMap.push([
|
|
1388
|
-
} else if (Array.isArray(
|
|
1403
|
+
if (typeof stableInput === "string") {
|
|
1404
|
+
urlTextureMap.push([stableInput, mappedTextures]);
|
|
1405
|
+
} else if (Array.isArray(stableInput)) {
|
|
1389
1406
|
const textureArray = mappedTextures;
|
|
1390
|
-
|
|
1391
|
-
} else if (IsObject(
|
|
1407
|
+
stableInput.forEach((url, i) => urlTextureMap.push([url, textureArray[i]]));
|
|
1408
|
+
} else if (IsObject(stableInput)) {
|
|
1392
1409
|
const textureRecord = mappedTextures;
|
|
1393
|
-
for (const key in
|
|
1394
|
-
const url =
|
|
1410
|
+
for (const key in stableInput) {
|
|
1411
|
+
const url = stableInput[key];
|
|
1395
1412
|
urlTextureMap.push([url, textureRecord[key]]);
|
|
1396
1413
|
}
|
|
1397
1414
|
}
|
|
@@ -1420,7 +1437,7 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
1420
1437
|
}
|
|
1421
1438
|
return { _textureRefs: refs };
|
|
1422
1439
|
});
|
|
1423
|
-
}, [cache,
|
|
1440
|
+
}, [cache, stableInput, mappedTextures, store]);
|
|
1424
1441
|
return mappedTextures;
|
|
1425
1442
|
}
|
|
1426
1443
|
useTexture.preload = (url) => useLoader.preload(three.TextureLoader, url);
|
|
@@ -1689,13 +1706,19 @@ function addTail(callback) {
|
|
|
1689
1706
|
return scheduler.getScheduler().onIdle(callback);
|
|
1690
1707
|
}
|
|
1691
1708
|
function invalidate(state, frames = 1, stackFrames = false) {
|
|
1692
|
-
|
|
1709
|
+
const rootId = state?.internal?.rootId;
|
|
1710
|
+
const scheduler$1 = scheduler.getScheduler();
|
|
1711
|
+
if (rootId) scheduler$1.invalidateRoot(rootId, frames, stackFrames);
|
|
1712
|
+
else scheduler$1.invalidate(frames, stackFrames);
|
|
1693
1713
|
}
|
|
1694
|
-
function advance(timestamp) {
|
|
1695
|
-
|
|
1714
|
+
function advance(timestamp, runGlobalEffects, state) {
|
|
1715
|
+
const rootId = state?.internal?.rootId;
|
|
1716
|
+
const scheduler$1 = scheduler.getScheduler();
|
|
1717
|
+
if (rootId) scheduler$1.stepRoot(rootId, timestamp);
|
|
1718
|
+
else scheduler$1.step(timestamp);
|
|
1696
1719
|
}
|
|
1697
1720
|
|
|
1698
|
-
const version = "10.0.0-alpha.
|
|
1721
|
+
const version = "10.0.0-alpha.4";
|
|
1699
1722
|
const packageData = {
|
|
1700
1723
|
version: version};
|
|
1701
1724
|
|
|
@@ -14307,7 +14330,7 @@ function createRoot(canvas) {
|
|
|
14307
14330
|
const handleXRFrame = (timestamp, _frame) => {
|
|
14308
14331
|
const state2 = store.getState();
|
|
14309
14332
|
if (state2.frameloop === "never") return;
|
|
14310
|
-
advance(timestamp);
|
|
14333
|
+
advance(timestamp, true, state2);
|
|
14311
14334
|
};
|
|
14312
14335
|
const actualRenderer = state.internal.actualRenderer;
|
|
14313
14336
|
const handleSessionChange = () => {
|
|
@@ -14315,7 +14338,7 @@ function createRoot(canvas) {
|
|
|
14315
14338
|
const renderer2 = state2.internal.actualRenderer;
|
|
14316
14339
|
actualRenderer.xr.enabled = actualRenderer.xr.isPresenting;
|
|
14317
14340
|
renderer2.xr.setAnimationLoop(renderer2.xr.isPresenting ? handleXRFrame : null);
|
|
14318
|
-
if (!renderer2.xr.isPresenting) invalidate();
|
|
14341
|
+
if (!renderer2.xr.isPresenting) invalidate(state2);
|
|
14319
14342
|
};
|
|
14320
14343
|
const xr = {
|
|
14321
14344
|
connect() {
|
|
@@ -14397,7 +14420,11 @@ function createRoot(canvas) {
|
|
|
14397
14420
|
const newRootId = canvasId || scheduler$1.generateRootId();
|
|
14398
14421
|
const unregisterRoot = scheduler$1.registerRoot(newRootId, {
|
|
14399
14422
|
getState: () => store.getState(),
|
|
14400
|
-
onError: (err) => store.getState().setError(err)
|
|
14423
|
+
onError: (err) => store.getState().setError(err),
|
|
14424
|
+
frameloop: store.getState().frameloop,
|
|
14425
|
+
before: schedulerConfig?.before,
|
|
14426
|
+
after: schedulerConfig?.after,
|
|
14427
|
+
order: schedulerConfig?.order
|
|
14401
14428
|
});
|
|
14402
14429
|
const unregisterCanvasTarget = scheduler$1.register(
|
|
14403
14430
|
() => {
|
|
@@ -14405,6 +14432,10 @@ function createRoot(canvas) {
|
|
|
14405
14432
|
if (state2.internal.isMultiCanvas && state2.internal.canvasTarget) {
|
|
14406
14433
|
const renderer2 = state2.internal.actualRenderer;
|
|
14407
14434
|
renderer2.setCanvasTarget(state2.internal.canvasTarget);
|
|
14435
|
+
if (state2.internal.canvasTargetSizeDirty) {
|
|
14436
|
+
state2.internal.canvasTargetSizeDirty = false;
|
|
14437
|
+
renderer2.backend?.updateSize?.();
|
|
14438
|
+
}
|
|
14408
14439
|
}
|
|
14409
14440
|
},
|
|
14410
14441
|
{
|
|
@@ -14473,8 +14504,7 @@ function createRoot(canvas) {
|
|
|
14473
14504
|
phase: "render",
|
|
14474
14505
|
system: true,
|
|
14475
14506
|
// Internal flag: this is a system job, not user-controlled
|
|
14476
|
-
//
|
|
14477
|
-
...schedulerConfig?.after && { after: schedulerConfig.after },
|
|
14507
|
+
// FPS throttles only the default render job; Canvas ordering belongs to the root.
|
|
14478
14508
|
...schedulerConfig?.fps && { fps: schedulerConfig.fps }
|
|
14479
14509
|
}
|
|
14480
14510
|
);
|
|
@@ -14493,8 +14523,21 @@ function createRoot(canvas) {
|
|
|
14493
14523
|
scheduler: scheduler$1
|
|
14494
14524
|
}
|
|
14495
14525
|
}));
|
|
14526
|
+
} else {
|
|
14527
|
+
const constraintsChanged = !is.equ(schedulerConfig?.before, lastConfiguredProps.schedulerBefore, shallowLoose) || !is.equ(schedulerConfig?.after, lastConfiguredProps.schedulerAfter, shallowLoose);
|
|
14528
|
+
if (constraintsChanged) {
|
|
14529
|
+
scheduler$1.setRootConstraints(rootId, {
|
|
14530
|
+
before: schedulerConfig?.before,
|
|
14531
|
+
after: schedulerConfig?.after
|
|
14532
|
+
});
|
|
14533
|
+
}
|
|
14534
|
+
if (schedulerConfig?.order !== lastConfiguredProps.schedulerOrder) {
|
|
14535
|
+
scheduler$1.setRootOrder(rootId, schedulerConfig?.order ?? 0);
|
|
14536
|
+
}
|
|
14496
14537
|
}
|
|
14497
|
-
|
|
14538
|
+
lastConfiguredProps.schedulerBefore = schedulerConfig?.before;
|
|
14539
|
+
lastConfiguredProps.schedulerAfter = schedulerConfig?.after;
|
|
14540
|
+
lastConfiguredProps.schedulerOrder = schedulerConfig?.order;
|
|
14498
14541
|
onCreated = onCreatedCallback;
|
|
14499
14542
|
configured = true;
|
|
14500
14543
|
resolve();
|
|
@@ -14536,14 +14579,19 @@ function unmountComponentAtNode(canvas, callback) {
|
|
|
14536
14579
|
const fiber = root?.fiber;
|
|
14537
14580
|
if (fiber) {
|
|
14538
14581
|
const state = root?.store.getState();
|
|
14539
|
-
if (state)
|
|
14582
|
+
if (state) {
|
|
14583
|
+
state.internal.active = false;
|
|
14584
|
+
const unregisterRoot = state.internal.unregisterRoot;
|
|
14585
|
+
if (unregisterRoot) {
|
|
14586
|
+
unregisterRoot();
|
|
14587
|
+
state.internal.unregisterRoot = void 0;
|
|
14588
|
+
}
|
|
14589
|
+
}
|
|
14540
14590
|
reconciler.updateContainer(null, fiber, null, () => {
|
|
14541
14591
|
if (state) {
|
|
14542
14592
|
setTimeout(() => {
|
|
14543
14593
|
try {
|
|
14544
14594
|
const renderer = state.internal.actualRenderer;
|
|
14545
|
-
const unregisterRoot = state.internal.unregisterRoot;
|
|
14546
|
-
if (unregisterRoot) unregisterRoot();
|
|
14547
14595
|
const unregisterPrimary = state.internal.unregisterPrimary;
|
|
14548
14596
|
if (unregisterPrimary) unregisterPrimary();
|
|
14549
14597
|
const canvasTarget = state.internal.canvasTarget;
|
|
@@ -14991,9 +15039,9 @@ function CanvasImpl({
|
|
|
14991
15039
|
React__namespace.useMemo(() => extend(THREE), []);
|
|
14992
15040
|
const Bridge = useBridge();
|
|
14993
15041
|
const backgroundProps = React__namespace.useMemo(() => parseBackground(background), [background]);
|
|
14994
|
-
const
|
|
15042
|
+
const [hasInitialSize, setHasInitialSize] = React__namespace.useState(false);
|
|
14995
15043
|
const measureConfig = React__namespace.useMemo(() => {
|
|
14996
|
-
if (!
|
|
15044
|
+
if (!hasInitialSize) {
|
|
14997
15045
|
return {
|
|
14998
15046
|
...resize,
|
|
14999
15047
|
scroll: resize?.scroll ?? true,
|
|
@@ -15005,7 +15053,7 @@ function CanvasImpl({
|
|
|
15005
15053
|
debounce: { scroll: 50, resize: 0 },
|
|
15006
15054
|
...resize
|
|
15007
15055
|
};
|
|
15008
|
-
}, [
|
|
15056
|
+
}, [hasInitialSize, resize]);
|
|
15009
15057
|
const [containerRef, containerRect] = useMeasure__default(measureConfig);
|
|
15010
15058
|
const effectiveSize = React__namespace.useMemo(() => {
|
|
15011
15059
|
let w = width ?? containerRect.width;
|
|
@@ -15021,9 +15069,7 @@ function CanvasImpl({
|
|
|
15021
15069
|
left: containerRect.left
|
|
15022
15070
|
};
|
|
15023
15071
|
}, [width, height, containerRect, forceEven]);
|
|
15024
|
-
if (!
|
|
15025
|
-
hasInitialSizeRef.current = true;
|
|
15026
|
-
}
|
|
15072
|
+
if (!hasInitialSize && effectiveSize.width > 0 && effectiveSize.height > 0) setHasInitialSize(true);
|
|
15027
15073
|
const canvasRef = React__namespace.useRef(null);
|
|
15028
15074
|
const divRef = React__namespace.useRef(null);
|
|
15029
15075
|
React__namespace.useImperativeHandle(ref, () => canvasRef.current);
|
|
@@ -15137,6 +15183,7 @@ function CanvasImpl({
|
|
|
15137
15183
|
const canvas = canvasRef.current;
|
|
15138
15184
|
if (canvas) {
|
|
15139
15185
|
return () => {
|
|
15186
|
+
if (canvas.isConnected) return;
|
|
15140
15187
|
unmountComponentAtNode(canvas);
|
|
15141
15188
|
root.current = null;
|
|
15142
15189
|
};
|
package/dist/legacy.d.cts
CHANGED
|
@@ -38,9 +38,9 @@ function _mergeNamespaces(n, m) {
|
|
|
38
38
|
declare const R3F_BUILD_LEGACY = true;
|
|
39
39
|
declare const R3F_BUILD_WEBGPU = false;
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
type Inspector = never;
|
|
42
|
+
/** Not available on the legacy (WebGL-only) entry. */
|
|
43
|
+
declare function loadInspector(): Promise<never>;
|
|
44
44
|
declare const WebGPURenderer: {
|
|
45
45
|
new (): {};
|
|
46
46
|
};
|
|
@@ -58,7 +58,8 @@ var THREE = /*#__PURE__*/_mergeNamespaces({
|
|
|
58
58
|
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
59
59
|
RenderTarget: RenderTarget,
|
|
60
60
|
RenderTargetCompat: WebGLRenderTarget,
|
|
61
|
-
WebGPURenderer: WebGPURenderer
|
|
61
|
+
WebGPURenderer: WebGPURenderer,
|
|
62
|
+
loadInspector: loadInspector
|
|
62
63
|
}, [THREE$1]);
|
|
63
64
|
|
|
64
65
|
//* Utility Types ==============================
|
|
@@ -496,6 +497,18 @@ interface InternalState {
|
|
|
496
497
|
* @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
|
|
497
498
|
*/
|
|
498
499
|
canvasTarget?: CanvasTarget
|
|
500
|
+
/**
|
|
501
|
+
* Set when this root's canvas target has been resized and the backend's cached render pass
|
|
502
|
+
* descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
|
|
503
|
+
*
|
|
504
|
+
* Flushed by the canvas-target job in the `start` phase, which is the only place this root's
|
|
505
|
+
* target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
|
|
506
|
+
* whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
|
|
507
|
+
* invalidate some other canvas's descriptor instead.
|
|
508
|
+
*
|
|
509
|
+
* @see https://github.com/pmndrs/react-three-fiber/issues/3847
|
|
510
|
+
*/
|
|
511
|
+
canvasTargetSizeDirty?: boolean
|
|
499
512
|
/**
|
|
500
513
|
* Whether multi-canvas rendering is active.
|
|
501
514
|
* True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
|
|
@@ -705,12 +718,19 @@ type DefaultRendererProps = {
|
|
|
705
718
|
*/
|
|
706
719
|
interface CanvasSchedulerConfig {
|
|
707
720
|
/**
|
|
708
|
-
*
|
|
709
|
-
|
|
721
|
+
* Run this Canvas root before the referenced Canvas root id(s).
|
|
722
|
+
*/
|
|
723
|
+
before?: string | string[]
|
|
724
|
+
/**
|
|
725
|
+
* Run this Canvas root after the referenced Canvas root id(s).
|
|
726
|
+
*/
|
|
727
|
+
after?: string | string[]
|
|
728
|
+
/**
|
|
729
|
+
* Numeric root order. Lower values run first.
|
|
710
730
|
*/
|
|
711
|
-
|
|
731
|
+
order?: number
|
|
712
732
|
/**
|
|
713
|
-
* Limit this
|
|
733
|
+
* Limit this Canvas's default render job (frames per second).
|
|
714
734
|
*/
|
|
715
735
|
fps?: number
|
|
716
736
|
}
|
|
@@ -1314,11 +1334,16 @@ declare global {
|
|
|
1314
1334
|
/** Pass record - stores TSL pass nodes for render pipeline */
|
|
1315
1335
|
type PassRecord = Record<string, any>
|
|
1316
1336
|
|
|
1337
|
+
/** State passed to pipeline callbacks after the active pipeline has been created */
|
|
1338
|
+
type RenderPipelineCallbackState = RootState & {
|
|
1339
|
+
renderPipeline: ThreeRenderPipeline
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1317
1342
|
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1318
|
-
type RenderPipelineSetupCallback = (state:
|
|
1343
|
+
type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => PassRecord | void
|
|
1319
1344
|
|
|
1320
1345
|
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1321
|
-
type RenderPipelineMainCallback = (state:
|
|
1346
|
+
type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => PassRecord | void
|
|
1322
1347
|
|
|
1323
1348
|
/** Return type for useRenderPipeline hook */
|
|
1324
1349
|
interface UseRenderPipelineReturn {
|
|
@@ -1878,7 +1903,7 @@ declare namespace useLoader {
|
|
|
1878
1903
|
*
|
|
1879
1904
|
* @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
|
|
1880
1905
|
* @param priorityOrOptions - Either a priority number (backwards compat) or options object
|
|
1881
|
-
* @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
|
|
1906
|
+
* @returns Controls object with step(), stepAll(), invalidate(), pause(), resume(), isPaused, id, rootId, scheduler
|
|
1882
1907
|
*
|
|
1883
1908
|
* @example
|
|
1884
1909
|
* // Simple priority (backwards compat)
|
|
@@ -2174,7 +2199,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
|
|
|
2174
2199
|
* Invalidates the view, requesting a frame to be rendered.
|
|
2175
2200
|
* In demand mode, this triggers the scheduler to run frames.
|
|
2176
2201
|
*
|
|
2177
|
-
*
|
|
2202
|
+
* With a state argument, only that root's jobs run on the requested frames; other
|
|
2203
|
+
* roots on 'demand' stay idle. Without one, every registered root is invalidated.
|
|
2204
|
+
*
|
|
2205
|
+
* @param state - Optional root state; targets the invalidation at that root
|
|
2178
2206
|
* @param frames - Number of frames to request (default: 1)
|
|
2179
2207
|
* @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
|
|
2180
2208
|
*
|
|
@@ -2185,14 +2213,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
|
|
|
2185
2213
|
* Advances the frameloop and runs render effects.
|
|
2186
2214
|
* Useful for when manually rendering via `frameloop="never"`.
|
|
2187
2215
|
*
|
|
2216
|
+
* With a state argument, only that root is stepped. Without one, every
|
|
2217
|
+
* registered root is stepped for backwards compatibility.
|
|
2218
|
+
*
|
|
2188
2219
|
* @param timestamp - The timestamp to use for this frame
|
|
2189
2220
|
* @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
|
|
2190
|
-
* @param state -
|
|
2191
|
-
* @param frame - Ignored (kept for backwards compat)
|
|
2221
|
+
* @param state - Optional root state; targets the manual step at that root
|
|
2192
2222
|
*
|
|
2193
2223
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
2194
2224
|
*/
|
|
2195
|
-
declare function advance(timestamp: number): void;
|
|
2225
|
+
declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
|
|
2196
2226
|
|
|
2197
2227
|
/* eslint-disable @definitelytyped/no-unnecessary-generics */
|
|
2198
2228
|
declare function ReactReconciler<
|
package/dist/legacy.d.mts
CHANGED
|
@@ -38,9 +38,9 @@ function _mergeNamespaces(n, m) {
|
|
|
38
38
|
declare const R3F_BUILD_LEGACY = true;
|
|
39
39
|
declare const R3F_BUILD_WEBGPU = false;
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
type Inspector = never;
|
|
42
|
+
/** Not available on the legacy (WebGL-only) entry. */
|
|
43
|
+
declare function loadInspector(): Promise<never>;
|
|
44
44
|
declare const WebGPURenderer: {
|
|
45
45
|
new (): {};
|
|
46
46
|
};
|
|
@@ -58,7 +58,8 @@ var THREE = /*#__PURE__*/_mergeNamespaces({
|
|
|
58
58
|
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
59
59
|
RenderTarget: RenderTarget,
|
|
60
60
|
RenderTargetCompat: WebGLRenderTarget,
|
|
61
|
-
WebGPURenderer: WebGPURenderer
|
|
61
|
+
WebGPURenderer: WebGPURenderer,
|
|
62
|
+
loadInspector: loadInspector
|
|
62
63
|
}, [THREE$1]);
|
|
63
64
|
|
|
64
65
|
//* Utility Types ==============================
|
|
@@ -496,6 +497,18 @@ interface InternalState {
|
|
|
496
497
|
* @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
|
|
497
498
|
*/
|
|
498
499
|
canvasTarget?: CanvasTarget
|
|
500
|
+
/**
|
|
501
|
+
* Set when this root's canvas target has been resized and the backend's cached render pass
|
|
502
|
+
* descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
|
|
503
|
+
*
|
|
504
|
+
* Flushed by the canvas-target job in the `start` phase, which is the only place this root's
|
|
505
|
+
* target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
|
|
506
|
+
* whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
|
|
507
|
+
* invalidate some other canvas's descriptor instead.
|
|
508
|
+
*
|
|
509
|
+
* @see https://github.com/pmndrs/react-three-fiber/issues/3847
|
|
510
|
+
*/
|
|
511
|
+
canvasTargetSizeDirty?: boolean
|
|
499
512
|
/**
|
|
500
513
|
* Whether multi-canvas rendering is active.
|
|
501
514
|
* True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
|
|
@@ -705,12 +718,19 @@ type DefaultRendererProps = {
|
|
|
705
718
|
*/
|
|
706
719
|
interface CanvasSchedulerConfig {
|
|
707
720
|
/**
|
|
708
|
-
*
|
|
709
|
-
|
|
721
|
+
* Run this Canvas root before the referenced Canvas root id(s).
|
|
722
|
+
*/
|
|
723
|
+
before?: string | string[]
|
|
724
|
+
/**
|
|
725
|
+
* Run this Canvas root after the referenced Canvas root id(s).
|
|
726
|
+
*/
|
|
727
|
+
after?: string | string[]
|
|
728
|
+
/**
|
|
729
|
+
* Numeric root order. Lower values run first.
|
|
710
730
|
*/
|
|
711
|
-
|
|
731
|
+
order?: number
|
|
712
732
|
/**
|
|
713
|
-
* Limit this
|
|
733
|
+
* Limit this Canvas's default render job (frames per second).
|
|
714
734
|
*/
|
|
715
735
|
fps?: number
|
|
716
736
|
}
|
|
@@ -1314,11 +1334,16 @@ declare global {
|
|
|
1314
1334
|
/** Pass record - stores TSL pass nodes for render pipeline */
|
|
1315
1335
|
type PassRecord = Record<string, any>
|
|
1316
1336
|
|
|
1337
|
+
/** State passed to pipeline callbacks after the active pipeline has been created */
|
|
1338
|
+
type RenderPipelineCallbackState = RootState & {
|
|
1339
|
+
renderPipeline: ThreeRenderPipeline
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1317
1342
|
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1318
|
-
type RenderPipelineSetupCallback = (state:
|
|
1343
|
+
type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => PassRecord | void
|
|
1319
1344
|
|
|
1320
1345
|
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1321
|
-
type RenderPipelineMainCallback = (state:
|
|
1346
|
+
type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => PassRecord | void
|
|
1322
1347
|
|
|
1323
1348
|
/** Return type for useRenderPipeline hook */
|
|
1324
1349
|
interface UseRenderPipelineReturn {
|
|
@@ -1878,7 +1903,7 @@ declare namespace useLoader {
|
|
|
1878
1903
|
*
|
|
1879
1904
|
* @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
|
|
1880
1905
|
* @param priorityOrOptions - Either a priority number (backwards compat) or options object
|
|
1881
|
-
* @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
|
|
1906
|
+
* @returns Controls object with step(), stepAll(), invalidate(), pause(), resume(), isPaused, id, rootId, scheduler
|
|
1882
1907
|
*
|
|
1883
1908
|
* @example
|
|
1884
1909
|
* // Simple priority (backwards compat)
|
|
@@ -2174,7 +2199,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
|
|
|
2174
2199
|
* Invalidates the view, requesting a frame to be rendered.
|
|
2175
2200
|
* In demand mode, this triggers the scheduler to run frames.
|
|
2176
2201
|
*
|
|
2177
|
-
*
|
|
2202
|
+
* With a state argument, only that root's jobs run on the requested frames; other
|
|
2203
|
+
* roots on 'demand' stay idle. Without one, every registered root is invalidated.
|
|
2204
|
+
*
|
|
2205
|
+
* @param state - Optional root state; targets the invalidation at that root
|
|
2178
2206
|
* @param frames - Number of frames to request (default: 1)
|
|
2179
2207
|
* @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
|
|
2180
2208
|
*
|
|
@@ -2185,14 +2213,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
|
|
|
2185
2213
|
* Advances the frameloop and runs render effects.
|
|
2186
2214
|
* Useful for when manually rendering via `frameloop="never"`.
|
|
2187
2215
|
*
|
|
2216
|
+
* With a state argument, only that root is stepped. Without one, every
|
|
2217
|
+
* registered root is stepped for backwards compatibility.
|
|
2218
|
+
*
|
|
2188
2219
|
* @param timestamp - The timestamp to use for this frame
|
|
2189
2220
|
* @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
|
|
2190
|
-
* @param state -
|
|
2191
|
-
* @param frame - Ignored (kept for backwards compat)
|
|
2221
|
+
* @param state - Optional root state; targets the manual step at that root
|
|
2192
2222
|
*
|
|
2193
2223
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
2194
2224
|
*/
|
|
2195
|
-
declare function advance(timestamp: number): void;
|
|
2225
|
+
declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
|
|
2196
2226
|
|
|
2197
2227
|
/* eslint-disable @definitelytyped/no-unnecessary-generics */
|
|
2198
2228
|
declare function ReactReconciler<
|