@react-three/fiber 10.0.0-canary.5c62eb9 → 10.0.0-canary.60e7a38
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 +365 -135
- package/dist/index.d.cts +68 -31
- package/dist/index.d.mts +68 -31
- package/dist/index.d.ts +68 -31
- package/dist/index.mjs +368 -138
- package/dist/legacy.cjs +320 -90
- package/dist/legacy.d.cts +68 -30
- package/dist/legacy.d.mts +68 -30
- package/dist/legacy.d.ts +68 -30
- package/dist/legacy.mjs +322 -92
- package/dist/webgpu/index.cjs +652 -663
- package/dist/webgpu/index.d.cts +102 -35
- package/dist/webgpu/index.d.mts +102 -35
- package/dist/webgpu/index.d.ts +102 -35
- package/dist/webgpu/index.mjs +655 -666
- package/package.json +3 -3
- package/readme.md +0 -1
package/dist/legacy.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as three from 'three';
|
|
2
|
-
import { WebGLRenderTarget, CubeReflectionMapping, EquirectangularReflectionMapping, CubeTextureLoader, Scene,
|
|
2
|
+
import { WebGLCubeRenderTarget, WebGLRenderTarget, CubeReflectionMapping, EquirectangularReflectionMapping, CubeTextureLoader, Scene, HalfFloatType, Color, Frustum, Matrix4, Group, BoxGeometry, MeshBasicNodeMaterial, Mesh, Node, NodeUpdateType, Layers, ShaderMaterial, Uniform, SRGBColorSpace, RGBAFormat, UnsignedByteType, Vector3, Vector2, TextureLoader, Texture as Texture$1, Raycaster, OrthographicCamera, PerspectiveCamera, PCFShadowMap, VSMShadowMap, BasicShadowMap, ACESFilmicToneMapping, WebGLRenderer } from 'three';
|
|
3
3
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import React__default, { useLayoutEffect, useRef, useMemo, useEffect, useContext, useImperativeHandle, useCallback, useState } from 'react';
|
|
@@ -11,7 +11,7 @@ import { HDRLoader } from 'three/examples/jsm/loaders/HDRLoader.js';
|
|
|
11
11
|
import { EXRLoader } from 'three/examples/jsm/loaders/EXRLoader.js';
|
|
12
12
|
import { UltraHDRLoader } from 'three/examples/jsm/loaders/UltraHDRLoader.js';
|
|
13
13
|
import { GainMapLoader } from '@monogrid/gainmap-js';
|
|
14
|
-
import Tb, {
|
|
14
|
+
import Tb, { unstable_getCurrentPriorityLevel, unstable_IdlePriority, unstable_LowPriority, unstable_NormalPriority, unstable_UserBlockingPriority, unstable_ImmediatePriority, unstable_scheduleCallback } from 'scheduler';
|
|
15
15
|
import { createWithEqualityFn } from 'zustand/traditional';
|
|
16
16
|
import { getScheduler } from '@pmndrs/scheduler';
|
|
17
17
|
export { Scheduler, getScheduler } from '@pmndrs/scheduler';
|
|
@@ -42,9 +42,12 @@ const WebGPURenderer = class WebGPURenderer2 {
|
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
const RenderTarget = null;
|
|
45
|
+
const CubeRenderTarget = null;
|
|
45
46
|
|
|
46
47
|
const THREE = /*#__PURE__*/_mergeNamespaces({
|
|
47
48
|
__proto__: null,
|
|
49
|
+
CubeRenderTarget: CubeRenderTarget,
|
|
50
|
+
CubeRenderTargetCompat: WebGLCubeRenderTarget,
|
|
48
51
|
Inspector: Inspector,
|
|
49
52
|
R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
|
|
50
53
|
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
@@ -322,15 +325,16 @@ function EnvironmentPortal({
|
|
|
322
325
|
preset = void 0,
|
|
323
326
|
extensions
|
|
324
327
|
}) {
|
|
325
|
-
const
|
|
328
|
+
const renderer = useThree$1((state) => state.renderer);
|
|
329
|
+
const isLegacy = useThree$1((state) => state.isLegacy);
|
|
326
330
|
const defaultScene = useThree$1((state) => state.scene);
|
|
327
331
|
const camera = React.useRef(null);
|
|
328
332
|
const [virtualScene] = React.useState(() => new Scene());
|
|
329
333
|
const fbo = React.useMemo(() => {
|
|
330
|
-
const fbo2 = new WebGLCubeRenderTarget(resolution);
|
|
334
|
+
const fbo2 = isLegacy ? new WebGLCubeRenderTarget(resolution) : new CubeRenderTarget(resolution);
|
|
331
335
|
fbo2.texture.type = HalfFloatType;
|
|
332
336
|
return fbo2;
|
|
333
|
-
}, [resolution]);
|
|
337
|
+
}, [resolution, isLegacy]);
|
|
334
338
|
React.useEffect(() => {
|
|
335
339
|
return () => {
|
|
336
340
|
fbo.dispose();
|
|
@@ -338,10 +342,10 @@ function EnvironmentPortal({
|
|
|
338
342
|
}, [fbo]);
|
|
339
343
|
React.useLayoutEffect(() => {
|
|
340
344
|
if (frames === 1) {
|
|
341
|
-
const autoClear =
|
|
342
|
-
|
|
343
|
-
camera.current.update(
|
|
344
|
-
|
|
345
|
+
const autoClear = renderer.autoClear;
|
|
346
|
+
renderer.autoClear = true;
|
|
347
|
+
camera.current.update(renderer, virtualScene);
|
|
348
|
+
renderer.autoClear = autoClear;
|
|
345
349
|
}
|
|
346
350
|
return setEnvProps(background, scene, defaultScene, fbo.texture, {
|
|
347
351
|
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
@@ -358,7 +362,7 @@ function EnvironmentPortal({
|
|
|
358
362
|
defaultScene,
|
|
359
363
|
background,
|
|
360
364
|
frames,
|
|
361
|
-
|
|
365
|
+
renderer,
|
|
362
366
|
blur,
|
|
363
367
|
backgroundBlurriness,
|
|
364
368
|
backgroundIntensity,
|
|
@@ -369,10 +373,10 @@ function EnvironmentPortal({
|
|
|
369
373
|
let count = 1;
|
|
370
374
|
useFrame$1(() => {
|
|
371
375
|
if (frames === Infinity || count < frames) {
|
|
372
|
-
const autoClear =
|
|
373
|
-
|
|
374
|
-
camera.current.update(
|
|
375
|
-
|
|
376
|
+
const autoClear = renderer.autoClear;
|
|
377
|
+
renderer.autoClear = true;
|
|
378
|
+
camera.current.update(renderer, virtualScene);
|
|
379
|
+
renderer.autoClear = autoClear;
|
|
376
380
|
count++;
|
|
377
381
|
}
|
|
378
382
|
});
|
|
@@ -439,7 +443,6 @@ function Environment(props) {
|
|
|
439
443
|
var __defProp = Object.defineProperty;
|
|
440
444
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
441
445
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
442
|
-
const act = React["act"];
|
|
443
446
|
const useIsomorphicLayoutEffect = /* @__PURE__ */ (() => typeof window !== "undefined" && (window.document?.createElement || window.navigator?.product === "ReactNative"))() ? React.useLayoutEffect : React.useEffect;
|
|
444
447
|
function useMutableCallback(fn) {
|
|
445
448
|
const ref = React.useRef(fn);
|
|
@@ -615,8 +618,7 @@ function prepare(target, root, type, props) {
|
|
|
615
618
|
object,
|
|
616
619
|
eventCount: 0,
|
|
617
620
|
handlers: {},
|
|
618
|
-
isHidden: false
|
|
619
|
-
deferredRefs: []
|
|
621
|
+
isHidden: false
|
|
620
622
|
};
|
|
621
623
|
if (object) object.__r3f = instance;
|
|
622
624
|
}
|
|
@@ -773,6 +775,17 @@ function unregisterVisibility(store, object) {
|
|
|
773
775
|
internal.visibilityRegistry.delete(object.uuid);
|
|
774
776
|
internal.occlusionCache.delete(object);
|
|
775
777
|
}
|
|
778
|
+
function updateVisibilityHandlers(store, object, handlers) {
|
|
779
|
+
const { internal } = store.getState();
|
|
780
|
+
const entry = internal.visibilityRegistry.get(object.uuid);
|
|
781
|
+
if (!entry) return false;
|
|
782
|
+
entry.handlers = handlers;
|
|
783
|
+
if ((handlers.onOccluded || handlers.onVisible) && !internal.occlusionEnabled) {
|
|
784
|
+
object.occlusionTest = true;
|
|
785
|
+
enableOcclusion(store);
|
|
786
|
+
}
|
|
787
|
+
return true;
|
|
788
|
+
}
|
|
776
789
|
function checkVisibility(state) {
|
|
777
790
|
const { internal, camera } = state;
|
|
778
791
|
const registry = internal.visibilityRegistry;
|
|
@@ -933,9 +946,9 @@ function diffProps(instance, newProps) {
|
|
|
933
946
|
const { root, key } = resolve(instance.object, prop);
|
|
934
947
|
if (root.constructor && root.constructor.length === 0) {
|
|
935
948
|
const ctor = getMemoizedPrototype(root);
|
|
936
|
-
if (!is.und(ctor)) changedProps[
|
|
949
|
+
if (!is.und(ctor)) changedProps[prop] = ctor[key];
|
|
937
950
|
} else {
|
|
938
|
-
changedProps[
|
|
951
|
+
changedProps[prop] = 0;
|
|
939
952
|
}
|
|
940
953
|
}
|
|
941
954
|
return changedProps;
|
|
@@ -960,10 +973,7 @@ function applyProps(object, props) {
|
|
|
960
973
|
continue;
|
|
961
974
|
}
|
|
962
975
|
if (value === void 0) continue;
|
|
963
|
-
if (isFromRef(value))
|
|
964
|
-
instance?.deferredRefs?.push({ prop, ref: value[FROM_REF] });
|
|
965
|
-
continue;
|
|
966
|
-
}
|
|
976
|
+
if (isFromRef(value)) continue;
|
|
967
977
|
if (isOnce(value)) {
|
|
968
978
|
if (instance?.appliedOnce?.has(prop)) continue;
|
|
969
979
|
if (instance) {
|
|
@@ -999,6 +1009,19 @@ function applyProps(object, props) {
|
|
|
999
1009
|
} else if (isVectorLike(target) && is.num(value)) {
|
|
1000
1010
|
if ("setScalar" in target && typeof target.setScalar === "function") target.setScalar(value);
|
|
1001
1011
|
else target.set(value);
|
|
1012
|
+
} else if (root instanceof ShaderMaterial && key === "uniforms" && is.obj(value)) {
|
|
1013
|
+
if (!is.obj(root.uniforms)) root.uniforms = {};
|
|
1014
|
+
const uniforms = root.uniforms;
|
|
1015
|
+
const nextUniforms = value;
|
|
1016
|
+
for (const name in nextUniforms) {
|
|
1017
|
+
const uniform = nextUniforms[name];
|
|
1018
|
+
const targetUniform = uniforms[name];
|
|
1019
|
+
if (targetUniform) Object.assign(targetUniform, uniform);
|
|
1020
|
+
else {
|
|
1021
|
+
const nextUniform = uniform instanceof Uniform ? uniform.clone() : new Uniform(uniform.value);
|
|
1022
|
+
uniforms[name] = nextUniform;
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1002
1025
|
} else {
|
|
1003
1026
|
root[key] = value;
|
|
1004
1027
|
if (key.endsWith("Node") && root.isMaterial) {
|
|
@@ -1017,6 +1040,9 @@ function applyProps(object, props) {
|
|
|
1017
1040
|
if (instance.eventCount && object2.raycast !== null) {
|
|
1018
1041
|
rootState.internal.interaction.push(object2);
|
|
1019
1042
|
}
|
|
1043
|
+
}
|
|
1044
|
+
if (instance?.parent && rootState?.internal && instance.object?.isObject3D) {
|
|
1045
|
+
const object2 = instance.object;
|
|
1020
1046
|
const root = findInitialRoot(instance);
|
|
1021
1047
|
const visibilityHandlers = {
|
|
1022
1048
|
onFramed: instance.handlers.onFramed,
|
|
@@ -1024,7 +1050,9 @@ function applyProps(object, props) {
|
|
|
1024
1050
|
onVisible: instance.handlers.onVisible
|
|
1025
1051
|
};
|
|
1026
1052
|
if (hasVisibilityHandlers(visibilityHandlers)) {
|
|
1027
|
-
|
|
1053
|
+
if (!updateVisibilityHandlers(root, object2, visibilityHandlers)) {
|
|
1054
|
+
registerVisibility(root, object2, visibilityHandlers);
|
|
1055
|
+
}
|
|
1028
1056
|
} else {
|
|
1029
1057
|
unregisterVisibility(root, object2);
|
|
1030
1058
|
}
|
|
@@ -1067,6 +1095,41 @@ function releaseInternalPointerCapture(internal, obj, pointerId) {
|
|
|
1067
1095
|
captureData.target.releasePointerCapture(pointerId);
|
|
1068
1096
|
}
|
|
1069
1097
|
}
|
|
1098
|
+
function swapInteractivity(store, object, newObject) {
|
|
1099
|
+
const { internal } = store.getState();
|
|
1100
|
+
for (let i = 0; i < internal.interaction.length; i++) {
|
|
1101
|
+
if (internal.interaction[i] === object) internal.interaction[i] = newObject;
|
|
1102
|
+
}
|
|
1103
|
+
for (const pointerState of internal.pointerMap.values()) {
|
|
1104
|
+
for (let i = 0; i < pointerState.initialHits.length; i++) {
|
|
1105
|
+
if (pointerState.initialHits[i] === object) pointerState.initialHits[i] = newObject;
|
|
1106
|
+
}
|
|
1107
|
+
pointerState.hovered.forEach((value, key) => {
|
|
1108
|
+
if (value.eventObject === object || value.object === object) {
|
|
1109
|
+
pointerState.hovered.delete(key);
|
|
1110
|
+
const next = {
|
|
1111
|
+
...value,
|
|
1112
|
+
eventObject: value.eventObject === object ? newObject : value.eventObject,
|
|
1113
|
+
object: value.object === object ? newObject : value.object
|
|
1114
|
+
};
|
|
1115
|
+
pointerState.hovered.set(makeId(next), next);
|
|
1116
|
+
}
|
|
1117
|
+
});
|
|
1118
|
+
const captureData = pointerState.captured.get(object);
|
|
1119
|
+
if (captureData) {
|
|
1120
|
+
pointerState.captured.delete(object);
|
|
1121
|
+
pointerState.captured.set(newObject, {
|
|
1122
|
+
...captureData,
|
|
1123
|
+
intersection: {
|
|
1124
|
+
...captureData.intersection,
|
|
1125
|
+
object: captureData.intersection.object === object ? newObject : captureData.intersection.object,
|
|
1126
|
+
eventObject: captureData.intersection.eventObject === object ? newObject : captureData.intersection.eventObject
|
|
1127
|
+
}
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
unregisterVisibility(store, object);
|
|
1132
|
+
}
|
|
1070
1133
|
function removeInteractivity(store, object) {
|
|
1071
1134
|
const { internal } = store.getState();
|
|
1072
1135
|
internal.interaction = internal.interaction.filter((o) => o !== object);
|
|
@@ -1552,6 +1615,7 @@ function createPointerEvents(store) {
|
|
|
1552
1615
|
set((state) => ({ events: { ...state.events, connected: void 0 } }));
|
|
1553
1616
|
}
|
|
1554
1617
|
},
|
|
1618
|
+
// PREVIEW (A8): the XR pointer registration API may change before stable.
|
|
1555
1619
|
registerPointer: (config) => {
|
|
1556
1620
|
const pointerId = nextXRPointerId++;
|
|
1557
1621
|
xrPointers.set(pointerId, config);
|
|
@@ -1639,11 +1703,10 @@ function notifyAlpha({ message, link }) {
|
|
|
1639
1703
|
}
|
|
1640
1704
|
|
|
1641
1705
|
const INTERNAL_LIB_MARKERS = ["zustand", "setState", "Object.assign"];
|
|
1642
|
-
const INTERNAL_FIBER_MARKERS = ["packages/fiber/src", "packages/fiber/dist", "@react-three/fiber", "@react-three_fiber"];
|
|
1643
1706
|
function isInternalRendererAccess(stack, callerDepth = 2) {
|
|
1644
1707
|
if (!stack) return false;
|
|
1645
1708
|
const caller = stack.split("\n")[callerDepth] ?? "";
|
|
1646
|
-
return INTERNAL_LIB_MARKERS.some((m) => caller.includes(m))
|
|
1709
|
+
return INTERNAL_LIB_MARKERS.some((m) => caller.includes(m));
|
|
1647
1710
|
}
|
|
1648
1711
|
|
|
1649
1712
|
const R3F_CONTEXT = Symbol.for("@react-three/fiber.context");
|
|
@@ -1778,6 +1841,7 @@ const createStore = (invalidate, advance) => {
|
|
|
1778
1841
|
}),
|
|
1779
1842
|
setFrameloop: (frameloop = "always") => {
|
|
1780
1843
|
set(() => ({ frameloop }));
|
|
1844
|
+
getScheduler().frameloop = frameloop;
|
|
1781
1845
|
},
|
|
1782
1846
|
setError: (error) => set(() => ({ error })),
|
|
1783
1847
|
error: null,
|
|
@@ -1958,19 +2022,25 @@ function loadingFn(extensions, onProgress) {
|
|
|
1958
2022
|
);
|
|
1959
2023
|
};
|
|
1960
2024
|
}
|
|
1961
|
-
function useLoader(loader, input, extensions, onProgress) {
|
|
1962
|
-
const
|
|
2025
|
+
function useLoader(loader, input, extensions, onProgress, cacheKey) {
|
|
2026
|
+
const inputs = Array.isArray(input) ? input : [input];
|
|
2027
|
+
const cacheKeys = Array.isArray(cacheKey ?? input) ? cacheKey ?? input : [cacheKey ?? input];
|
|
1963
2028
|
const fn = loadingFn(extensions, onProgress);
|
|
1964
|
-
const results =
|
|
2029
|
+
const results = cacheKeys.map(
|
|
2030
|
+
(key, index) => suspend(() => fn(loader, inputs[index]), [loader, key], { equal: is.equ })
|
|
2031
|
+
);
|
|
1965
2032
|
return Array.isArray(input) ? results : results[0];
|
|
1966
2033
|
}
|
|
1967
|
-
useLoader.preload = function(loader, input, extensions, onProgress) {
|
|
1968
|
-
const
|
|
1969
|
-
|
|
2034
|
+
useLoader.preload = function(loader, input, extensions, onProgress, cacheKey) {
|
|
2035
|
+
const inputs = Array.isArray(input) ? input : [input];
|
|
2036
|
+
const cacheKeys = Array.isArray(cacheKey ?? input) ? cacheKey ?? input : [cacheKey ?? input];
|
|
2037
|
+
cacheKeys.forEach(
|
|
2038
|
+
(key, index) => preload(() => loadingFn(extensions, onProgress)(loader, inputs[index]), [loader, key])
|
|
2039
|
+
);
|
|
1970
2040
|
};
|
|
1971
|
-
useLoader.clear = function(loader, input) {
|
|
1972
|
-
const
|
|
1973
|
-
|
|
2041
|
+
useLoader.clear = function(loader, input, cacheKey) {
|
|
2042
|
+
const cacheKeys = Array.isArray(cacheKey ?? input) ? cacheKey ?? input : [cacheKey ?? input];
|
|
2043
|
+
cacheKeys.forEach((key) => clear([loader, key]));
|
|
1974
2044
|
};
|
|
1975
2045
|
useLoader.loader = getLoader;
|
|
1976
2046
|
|
|
@@ -2390,7 +2460,7 @@ function advance(timestamp) {
|
|
|
2390
2460
|
getScheduler().step(timestamp);
|
|
2391
2461
|
}
|
|
2392
2462
|
|
|
2393
|
-
const version = "10.0.0-alpha.
|
|
2463
|
+
const version = "10.0.0-alpha.3";
|
|
2394
2464
|
const packageData = {
|
|
2395
2465
|
version: version};
|
|
2396
2466
|
|
|
@@ -13646,7 +13716,7 @@ function n0() {
|
|
|
13646
13716
|
var t0 = n0();
|
|
13647
13717
|
const r0 = Xb(t0);
|
|
13648
13718
|
|
|
13649
|
-
const t = 1, o = 8, r = 32, e = 2;
|
|
13719
|
+
const t = 1, o = 8, r = 32, e = 2, i$1 = 268435456;
|
|
13650
13720
|
|
|
13651
13721
|
function createReconciler(config) {
|
|
13652
13722
|
const reconciler2 = r0(config);
|
|
@@ -13811,7 +13881,15 @@ function setFiberRef(fiber, publicInstance) {
|
|
|
13811
13881
|
}
|
|
13812
13882
|
}
|
|
13813
13883
|
const reconstructed = [];
|
|
13814
|
-
function
|
|
13884
|
+
function flushReconstructedInstances() {
|
|
13885
|
+
if (reconstructed.length === 0) return;
|
|
13886
|
+
try {
|
|
13887
|
+
swapReconstructedInstances();
|
|
13888
|
+
} finally {
|
|
13889
|
+
reconstructed.length = 0;
|
|
13890
|
+
}
|
|
13891
|
+
}
|
|
13892
|
+
function swapReconstructedInstances() {
|
|
13815
13893
|
for (const [instance] of reconstructed) {
|
|
13816
13894
|
const parent = instance.parent;
|
|
13817
13895
|
if (parent) {
|
|
@@ -13829,6 +13907,9 @@ function swapInstances() {
|
|
|
13829
13907
|
}
|
|
13830
13908
|
}
|
|
13831
13909
|
if (instance.isHidden) unhideInstance(instance);
|
|
13910
|
+
if (isObject3D(instance.object) && !instance.parent) {
|
|
13911
|
+
removeInteractivity(findInitialRoot(instance), instance.object);
|
|
13912
|
+
}
|
|
13832
13913
|
if (instance.object.__r3f) delete instance.object.__r3f;
|
|
13833
13914
|
if (instance.type !== "primitive") disposeOnIdle(instance.object);
|
|
13834
13915
|
}
|
|
@@ -13837,10 +13918,16 @@ function swapInstances() {
|
|
|
13837
13918
|
const parent = instance.parent;
|
|
13838
13919
|
if (parent) {
|
|
13839
13920
|
const target = catalogue[toPascalCase(instance.type)];
|
|
13921
|
+
const prevObject = instance.object;
|
|
13840
13922
|
instance.object = instance.props.object ?? new target(...instance.props.args ?? []);
|
|
13841
13923
|
instance.object.__r3f = instance;
|
|
13842
13924
|
setFiberRef(fiber, instance.object);
|
|
13925
|
+
if (isObject3D(prevObject) && isObject3D(instance.object)) {
|
|
13926
|
+
swapInteractivity(findInitialRoot(instance), prevObject, instance.object);
|
|
13927
|
+
}
|
|
13843
13928
|
delete instance.appliedOnce;
|
|
13929
|
+
instance.eventCount = 0;
|
|
13930
|
+
instance.handlers = {};
|
|
13844
13931
|
applyProps(instance.object, instance.props);
|
|
13845
13932
|
if (instance.props.attach) {
|
|
13846
13933
|
attach(parent, instance);
|
|
@@ -13857,14 +13944,114 @@ function swapInstances() {
|
|
|
13857
13944
|
invalidateInstance(instance);
|
|
13858
13945
|
}
|
|
13859
13946
|
}
|
|
13860
|
-
reconstructed.length = 0;
|
|
13861
13947
|
}
|
|
13862
13948
|
const handleTextInstance = () => {
|
|
13863
13949
|
};
|
|
13864
13950
|
const NO_CONTEXT = {};
|
|
13865
13951
|
let currentUpdatePriority = NoEventPriority;
|
|
13866
|
-
|
|
13867
|
-
|
|
13952
|
+
function getEventPriority(type) {
|
|
13953
|
+
switch (type) {
|
|
13954
|
+
case "beforetoggle":
|
|
13955
|
+
case "cancel":
|
|
13956
|
+
case "click":
|
|
13957
|
+
case "close":
|
|
13958
|
+
case "contextmenu":
|
|
13959
|
+
case "copy":
|
|
13960
|
+
case "cut":
|
|
13961
|
+
case "auxclick":
|
|
13962
|
+
case "dblclick":
|
|
13963
|
+
case "dragend":
|
|
13964
|
+
case "dragstart":
|
|
13965
|
+
case "drop":
|
|
13966
|
+
case "focusin":
|
|
13967
|
+
case "focusout":
|
|
13968
|
+
case "input":
|
|
13969
|
+
case "invalid":
|
|
13970
|
+
case "keydown":
|
|
13971
|
+
case "keypress":
|
|
13972
|
+
case "keyup":
|
|
13973
|
+
case "mousedown":
|
|
13974
|
+
case "mouseup":
|
|
13975
|
+
case "paste":
|
|
13976
|
+
case "pause":
|
|
13977
|
+
case "play":
|
|
13978
|
+
case "pointercancel":
|
|
13979
|
+
case "pointerdown":
|
|
13980
|
+
case "pointerup":
|
|
13981
|
+
case "ratechange":
|
|
13982
|
+
case "reset":
|
|
13983
|
+
case "resize":
|
|
13984
|
+
case "seeked":
|
|
13985
|
+
case "submit":
|
|
13986
|
+
case "touchcancel":
|
|
13987
|
+
case "touchend":
|
|
13988
|
+
case "touchstart":
|
|
13989
|
+
case "volumechange":
|
|
13990
|
+
case "change":
|
|
13991
|
+
case "selectionchange":
|
|
13992
|
+
case "compositionstart":
|
|
13993
|
+
case "compositionend":
|
|
13994
|
+
case "compositionupdate":
|
|
13995
|
+
case "beforeinput":
|
|
13996
|
+
case "blur":
|
|
13997
|
+
case "fullscreenchange":
|
|
13998
|
+
case "focus":
|
|
13999
|
+
case "hashchange":
|
|
14000
|
+
case "popstate":
|
|
14001
|
+
case "select":
|
|
14002
|
+
case "selectstart":
|
|
14003
|
+
return e;
|
|
14004
|
+
case "drag":
|
|
14005
|
+
case "dragenter":
|
|
14006
|
+
case "dragexit":
|
|
14007
|
+
case "dragleave":
|
|
14008
|
+
case "dragover":
|
|
14009
|
+
case "mousemove":
|
|
14010
|
+
case "mouseout":
|
|
14011
|
+
case "mouseover":
|
|
14012
|
+
case "pointermove":
|
|
14013
|
+
case "pointerout":
|
|
14014
|
+
case "pointerover":
|
|
14015
|
+
case "scroll":
|
|
14016
|
+
case "touchmove":
|
|
14017
|
+
case "wheel":
|
|
14018
|
+
case "mouseenter":
|
|
14019
|
+
case "mouseleave":
|
|
14020
|
+
case "pointerenter":
|
|
14021
|
+
case "pointerleave":
|
|
14022
|
+
return o;
|
|
14023
|
+
case "message": {
|
|
14024
|
+
switch (unstable_getCurrentPriorityLevel()) {
|
|
14025
|
+
case unstable_ImmediatePriority:
|
|
14026
|
+
return e;
|
|
14027
|
+
case unstable_UserBlockingPriority:
|
|
14028
|
+
return o;
|
|
14029
|
+
case unstable_NormalPriority:
|
|
14030
|
+
case unstable_LowPriority:
|
|
14031
|
+
return r;
|
|
14032
|
+
case unstable_IdlePriority:
|
|
14033
|
+
return i$1;
|
|
14034
|
+
default:
|
|
14035
|
+
return r;
|
|
14036
|
+
}
|
|
14037
|
+
}
|
|
14038
|
+
default:
|
|
14039
|
+
return r;
|
|
14040
|
+
}
|
|
14041
|
+
}
|
|
14042
|
+
function scheduleMicrotask(callback) {
|
|
14043
|
+
if (typeof queueMicrotask === "function") {
|
|
14044
|
+
queueMicrotask(callback);
|
|
14045
|
+
} else if (typeof Promise !== "undefined") {
|
|
14046
|
+
Promise.resolve().then(callback).catch((error) => {
|
|
14047
|
+
setTimeout(() => {
|
|
14048
|
+
throw error;
|
|
14049
|
+
});
|
|
14050
|
+
});
|
|
14051
|
+
} else {
|
|
14052
|
+
setTimeout(callback);
|
|
14053
|
+
}
|
|
14054
|
+
}
|
|
13868
14055
|
const reconciler = /* @__PURE__ */ createReconciler({
|
|
13869
14056
|
isPrimaryRenderer: false,
|
|
13870
14057
|
warnsIfNotActing: false,
|
|
@@ -13903,16 +14090,15 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13903
14090
|
else if (newProps.args?.length !== oldProps.args?.length) reconstruct = true;
|
|
13904
14091
|
else if (newProps.args?.some((value, index) => value !== oldProps.args?.[index])) reconstruct = true;
|
|
13905
14092
|
if (reconstruct) {
|
|
13906
|
-
reconstructed.push([instance,
|
|
14093
|
+
reconstructed.push([instance, getInstanceProps(newProps), fiber]);
|
|
13907
14094
|
} else {
|
|
13908
14095
|
const changedProps = diffProps(instance, newProps);
|
|
13909
|
-
|
|
13910
|
-
|
|
13911
|
-
|
|
13912
|
-
|
|
14096
|
+
const attach2 = instance.props.attach;
|
|
14097
|
+
instance.props = getInstanceProps(newProps);
|
|
14098
|
+
if (attach2 !== void 0) instance.props.attach = attach2;
|
|
14099
|
+
else delete instance.props.attach;
|
|
14100
|
+
if (Object.keys(changedProps).length) applyProps(instance.object, changedProps);
|
|
13913
14101
|
}
|
|
13914
|
-
const isTailSibling = fiber.sibling === null || (fiber.flags & Update) === NoFlags;
|
|
13915
|
-
if (isTailSibling) swapInstances();
|
|
13916
14102
|
},
|
|
13917
14103
|
finalizeInitialChildren: (instance) => {
|
|
13918
14104
|
for (const prop in instance.props) {
|
|
@@ -13937,8 +14123,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13937
14123
|
const target = container.getState().internal.container ?? container.getState().scene;
|
|
13938
14124
|
return prepare(target, container, "", {});
|
|
13939
14125
|
},
|
|
13940
|
-
|
|
13941
|
-
|
|
14126
|
+
// Reconstructed instances are swapped once all mutations are committed,
|
|
14127
|
+
// before layout effects run so refs point to the new objects
|
|
14128
|
+
resetAfterCommit: flushReconstructedInstances,
|
|
13942
14129
|
shouldSetTextContent: () => false,
|
|
13943
14130
|
clearContainer: () => false,
|
|
13944
14131
|
hideInstance,
|
|
@@ -13946,6 +14133,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13946
14133
|
createTextInstance: handleTextInstance,
|
|
13947
14134
|
hideTextInstance: handleTextInstance,
|
|
13948
14135
|
unhideTextInstance: handleTextInstance,
|
|
14136
|
+
// Mirrors react-dom, which flushes discrete work in microtasks
|
|
14137
|
+
supportsMicrotasks: true,
|
|
14138
|
+
scheduleMicrotask,
|
|
13949
14139
|
scheduleTimeout: typeof setTimeout === "function" ? setTimeout : void 0,
|
|
13950
14140
|
cancelTimeout: typeof clearTimeout === "function" ? clearTimeout : void 0,
|
|
13951
14141
|
noTimeout: -1,
|
|
@@ -13986,28 +14176,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13986
14176
|
},
|
|
13987
14177
|
resolveUpdatePriority() {
|
|
13988
14178
|
if (currentUpdatePriority !== NoEventPriority) return currentUpdatePriority;
|
|
13989
|
-
|
|
13990
|
-
|
|
13991
|
-
|
|
13992
|
-
case "dblclick":
|
|
13993
|
-
case "dragenter":
|
|
13994
|
-
case "dragleave":
|
|
13995
|
-
case "drop":
|
|
13996
|
-
case "pointercancel":
|
|
13997
|
-
case "pointerdown":
|
|
13998
|
-
case "pointerup":
|
|
13999
|
-
return e;
|
|
14000
|
-
case "dragover":
|
|
14001
|
-
case "pointermove":
|
|
14002
|
-
case "pointerout":
|
|
14003
|
-
case "pointerover":
|
|
14004
|
-
case "pointerenter":
|
|
14005
|
-
case "pointerleave":
|
|
14006
|
-
case "wheel":
|
|
14007
|
-
return o;
|
|
14008
|
-
default:
|
|
14009
|
-
return r;
|
|
14010
|
-
}
|
|
14179
|
+
const eventType = typeof window !== "undefined" ? window.event?.type : void 0;
|
|
14180
|
+
if (eventType === void 0) return r;
|
|
14181
|
+
return getEventPriority(eventType);
|
|
14011
14182
|
},
|
|
14012
14183
|
resetFormInstance() {
|
|
14013
14184
|
},
|
|
@@ -14056,11 +14227,15 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
14056
14227
|
cloneMutableTextInstance(textInstance) {
|
|
14057
14228
|
return textInstance;
|
|
14058
14229
|
},
|
|
14230
|
+
// React 19.2 added these for root-level view transitions. They only run for hosts that opt into
|
|
14231
|
+
// view transitions by returning a container from cloneRootViewTransitionContainer; R3F renders
|
|
14232
|
+
// into a WebGL/WebGPU canvas, where cloning the root has no meaning, so we never opt in and
|
|
14233
|
+
// React never calls them. They stay as no-ops rather than throws: the host config is shared by
|
|
14234
|
+
// every root, and a throw here would turn a React-internal probe into a hard crash for users.
|
|
14235
|
+
// Guarded by a test asserting a full render + unmount never reaches them.
|
|
14059
14236
|
cloneRootViewTransitionContainer(_rootContainer) {
|
|
14060
|
-
throw new Error("Not implemented.");
|
|
14061
14237
|
},
|
|
14062
14238
|
removeRootViewTransitionClone(_rootContainer, _clone) {
|
|
14063
|
-
throw new Error("Not implemented.");
|
|
14064
14239
|
},
|
|
14065
14240
|
// https://github.com/facebook/react/pull/32465
|
|
14066
14241
|
createFragmentInstance: (_fiber) => null,
|
|
@@ -14145,6 +14320,7 @@ function createRoot(canvas) {
|
|
|
14145
14320
|
const lastConfiguredProps = {};
|
|
14146
14321
|
let configured = false;
|
|
14147
14322
|
let pending = null;
|
|
14323
|
+
let rendererSetup = null;
|
|
14148
14324
|
return {
|
|
14149
14325
|
async configure(props = {}) {
|
|
14150
14326
|
let resolve;
|
|
@@ -14175,7 +14351,7 @@ function createRoot(canvas) {
|
|
|
14175
14351
|
forceEven
|
|
14176
14352
|
} = props;
|
|
14177
14353
|
const textureColorSpace = is.obj(glConfig) && !is.fun(glConfig) && !isRenderer(glConfig) && glConfig.textureColorSpace || is.obj(rendererConfig) && !is.fun(rendererConfig) && !isRenderer(rendererConfig) && rendererConfig.textureColorSpace || SRGBColorSpace;
|
|
14178
|
-
|
|
14354
|
+
let state = store.getState();
|
|
14179
14355
|
const defaultGLProps = {
|
|
14180
14356
|
canvas,
|
|
14181
14357
|
powerPreference: "high-performance",
|
|
@@ -14203,9 +14379,21 @@ function createRoot(canvas) {
|
|
|
14203
14379
|
);
|
|
14204
14380
|
}
|
|
14205
14381
|
if (!state.internal.actualRenderer) {
|
|
14206
|
-
|
|
14207
|
-
|
|
14208
|
-
|
|
14382
|
+
if (!rendererSetup) {
|
|
14383
|
+
rendererSetup = (async () => {
|
|
14384
|
+
{
|
|
14385
|
+
renderer = await resolveRenderer(glConfig, defaultGLProps, WebGLRenderer);
|
|
14386
|
+
state.internal.actualRenderer = renderer;
|
|
14387
|
+
state.set({ isLegacy: true, gl: renderer, renderer, primaryStore: store });
|
|
14388
|
+
}
|
|
14389
|
+
})().catch((err) => {
|
|
14390
|
+
rendererSetup = null;
|
|
14391
|
+
throw err;
|
|
14392
|
+
});
|
|
14393
|
+
}
|
|
14394
|
+
await rendererSetup;
|
|
14395
|
+
state = store.getState();
|
|
14396
|
+
renderer = state.internal.actualRenderer;
|
|
14209
14397
|
}
|
|
14210
14398
|
let raycaster = state.raycaster;
|
|
14211
14399
|
if (!raycaster) state.set({ raycaster: raycaster = new Raycaster() });
|
|
@@ -14555,7 +14743,8 @@ function unmountComponentAtNode(canvas, callback) {
|
|
|
14555
14743
|
dispose(state.scene);
|
|
14556
14744
|
_roots.delete(canvas);
|
|
14557
14745
|
if (callback) callback(canvas);
|
|
14558
|
-
} catch {
|
|
14746
|
+
} catch (error) {
|
|
14747
|
+
console.warn("[R3F] Error while unmounting root; teardown may be incomplete:", error);
|
|
14559
14748
|
}
|
|
14560
14749
|
}, 500);
|
|
14561
14750
|
}
|
|
@@ -14618,6 +14807,7 @@ function PortalInner({ state = {}, children, container }) {
|
|
|
14618
14807
|
viewport = rootState.viewport.getCurrentViewport(camera, new Vector3(), resolvedSize);
|
|
14619
14808
|
if (camera !== rootState.camera) updateCamera(camera, resolvedSize);
|
|
14620
14809
|
}
|
|
14810
|
+
const set = injectState.set;
|
|
14621
14811
|
return {
|
|
14622
14812
|
// The intersect consists of the previous root state
|
|
14623
14813
|
...rootState,
|
|
@@ -14636,7 +14826,7 @@ function PortalInner({ state = {}, children, container }) {
|
|
|
14636
14826
|
size: resolvedSize,
|
|
14637
14827
|
viewport: { ...rootState.viewport, ...viewport },
|
|
14638
14828
|
// Layers are allowed to override events
|
|
14639
|
-
setEvents: (events2) =>
|
|
14829
|
+
setEvents: (events2) => set((state2) => ({ ...state2, events: { ...state2.events, ...events2 } })),
|
|
14640
14830
|
// Container for child attachment - the portalScene (injected or container itself)
|
|
14641
14831
|
internal: { ...rootState.internal, ...injectState.internal, container: portalScene }
|
|
14642
14832
|
};
|
|
@@ -14708,14 +14898,36 @@ function parseRendererConfig(rendererProp) {
|
|
|
14708
14898
|
return { primaryCanvas: void 0, scheduler: void 0, renderer: rendererProp };
|
|
14709
14899
|
}
|
|
14710
14900
|
|
|
14901
|
+
const RESOURCE_KINDS = ["nodes", "uniforms", "buffers", "gpuStorage"];
|
|
14902
|
+
const registries = /* @__PURE__ */ new WeakMap();
|
|
14903
|
+
function getKindRegistry(store, kind) {
|
|
14904
|
+
let registry = registries.get(store);
|
|
14905
|
+
if (!registry) {
|
|
14906
|
+
registry = {
|
|
14907
|
+
nodes: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() },
|
|
14908
|
+
uniforms: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() },
|
|
14909
|
+
buffers: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() },
|
|
14910
|
+
gpuStorage: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() }
|
|
14911
|
+
};
|
|
14912
|
+
registries.set(store, registry);
|
|
14913
|
+
}
|
|
14914
|
+
return registry[kind];
|
|
14915
|
+
}
|
|
14916
|
+
function invalidateResource(store, kind, scopeKey) {
|
|
14917
|
+
const registry = getKindRegistry(store, kind);
|
|
14918
|
+
{
|
|
14919
|
+
registry.valid.clear();
|
|
14920
|
+
registry.staged.clear();
|
|
14921
|
+
}
|
|
14922
|
+
}
|
|
14923
|
+
function invalidateAllResources(store) {
|
|
14924
|
+
for (const kind of RESOURCE_KINDS) invalidateResource(store, kind);
|
|
14925
|
+
}
|
|
14926
|
+
|
|
14711
14927
|
function clearHmrCaches(store) {
|
|
14712
|
-
store.
|
|
14713
|
-
|
|
14714
|
-
|
|
14715
|
-
buffers: {},
|
|
14716
|
-
gpuStorage: {},
|
|
14717
|
-
_hmrVersion: state._hmrVersion + 1
|
|
14718
|
-
}));
|
|
14928
|
+
const primary = store.getState().primaryStore ?? store;
|
|
14929
|
+
invalidateAllResources(primary);
|
|
14930
|
+
primary.setState((state) => ({ _hmrVersion: state._hmrVersion + 1 }));
|
|
14719
14931
|
}
|
|
14720
14932
|
|
|
14721
14933
|
function CanvasImpl({
|
|
@@ -14796,6 +15008,7 @@ function CanvasImpl({
|
|
|
14796
15008
|
const handleDropMissed = useMutableCallback(onDropMissed);
|
|
14797
15009
|
const [block, setBlock] = React.useState(false);
|
|
14798
15010
|
const [error, setError] = React.useState(false);
|
|
15011
|
+
const [fallbackVisible, setFallbackVisible] = React.useState(false);
|
|
14799
15012
|
if (block) throw block;
|
|
14800
15013
|
if (error) throw error;
|
|
14801
15014
|
const root = React.useRef(null);
|
|
@@ -14803,6 +15016,7 @@ function CanvasImpl({
|
|
|
14803
15016
|
const unsubscribeErrorRef = React.useRef(null);
|
|
14804
15017
|
useIsomorphicLayoutEffect(() => {
|
|
14805
15018
|
effectActiveRef.current = true;
|
|
15019
|
+
if (fallbackVisible) return;
|
|
14806
15020
|
const canvas = canvasRef.current;
|
|
14807
15021
|
if (effectiveSize.width > 0 && effectiveSize.height > 0 && canvas) {
|
|
14808
15022
|
if (!root.current) {
|
|
@@ -14823,7 +15037,7 @@ function CanvasImpl({
|
|
|
14823
15037
|
}
|
|
14824
15038
|
async function run() {
|
|
14825
15039
|
if (!effectActiveRef.current || !root.current) return;
|
|
14826
|
-
await root.current.configure({
|
|
15040
|
+
const configured = await root.current.configure({
|
|
14827
15041
|
id,
|
|
14828
15042
|
primaryCanvas,
|
|
14829
15043
|
scheduler,
|
|
@@ -14864,8 +15078,20 @@ function CanvasImpl({
|
|
|
14864
15078
|
}
|
|
14865
15079
|
onCreated?.(state);
|
|
14866
15080
|
}
|
|
14867
|
-
})
|
|
14868
|
-
|
|
15081
|
+
}).then(
|
|
15082
|
+
() => true,
|
|
15083
|
+
// Renderer setup failed (e.g. no WebGL/WebGPU support). The `fallback` prop lives
|
|
15084
|
+
// inside <canvas>, which browsers don't display, so surface it as visible DOM
|
|
15085
|
+
// instead; with no fallback, rethrow to an external error boundary. (#3757)
|
|
15086
|
+
(setupError) => {
|
|
15087
|
+
if (effectActiveRef.current) {
|
|
15088
|
+
if (fallback != null) setFallbackVisible(true);
|
|
15089
|
+
else setError(setupError);
|
|
15090
|
+
}
|
|
15091
|
+
return false;
|
|
15092
|
+
}
|
|
15093
|
+
);
|
|
15094
|
+
if (!configured || !effectActiveRef.current || !root.current) return;
|
|
14869
15095
|
root.current.render(
|
|
14870
15096
|
/* @__PURE__ */ jsx(Bridge, { children: /* @__PURE__ */ jsx(ErrorBoundary, { set: setError, children: /* @__PURE__ */ jsxs(React.Suspense, { fallback: /* @__PURE__ */ jsx(Block, { set: setBlock }), children: [
|
|
14871
15097
|
backgroundProps && /* @__PURE__ */ jsx(Environment, { ...backgroundProps }),
|
|
@@ -14928,7 +15154,11 @@ function CanvasImpl({
|
|
|
14928
15154
|
...style
|
|
14929
15155
|
},
|
|
14930
15156
|
...props,
|
|
14931
|
-
children:
|
|
15157
|
+
children: fallbackVisible ? (
|
|
15158
|
+
// Renderer setup failed: render the fallback as visible DOM. Inside <canvas> (below)
|
|
15159
|
+
// it exists in the tree but browsers never paint it, which is the whole bug (#3757).
|
|
15160
|
+
fallback
|
|
15161
|
+
) : /* @__PURE__ */ jsx("div", { ref: containerRef, className: "r3f-canvas-container", style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ jsx(
|
|
14932
15162
|
"canvas",
|
|
14933
15163
|
{
|
|
14934
15164
|
ref: canvasRef,
|
|
@@ -14947,4 +15177,4 @@ function Canvas(props) {
|
|
|
14947
15177
|
|
|
14948
15178
|
extend(THREE);
|
|
14949
15179
|
|
|
14950
|
-
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,
|
|
15180
|
+
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, context, createEvents, createPointerEvents, createPortal, createRoot, createStore, 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, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, reconciler, registerPrimary, removeInteractivity, resolve, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useEnvironment, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useRenderTarget, useStore, useTexture, useTextures, useThree, waitForPrimary };
|