@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.cjs
CHANGED
|
@@ -62,9 +62,12 @@ const WebGPURenderer = class WebGPURenderer2 {
|
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
const RenderTarget = null;
|
|
65
|
+
const CubeRenderTarget = null;
|
|
65
66
|
|
|
66
67
|
const THREE = /*#__PURE__*/_mergeNamespaces({
|
|
67
68
|
__proto__: null,
|
|
69
|
+
CubeRenderTarget: CubeRenderTarget,
|
|
70
|
+
CubeRenderTargetCompat: three.WebGLCubeRenderTarget,
|
|
68
71
|
Inspector: Inspector,
|
|
69
72
|
R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
|
|
70
73
|
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
@@ -342,15 +345,16 @@ function EnvironmentPortal({
|
|
|
342
345
|
preset = void 0,
|
|
343
346
|
extensions
|
|
344
347
|
}) {
|
|
345
|
-
const
|
|
348
|
+
const renderer = fiber.useThree((state) => state.renderer);
|
|
349
|
+
const isLegacy = fiber.useThree((state) => state.isLegacy);
|
|
346
350
|
const defaultScene = fiber.useThree((state) => state.scene);
|
|
347
351
|
const camera = React__namespace.useRef(null);
|
|
348
352
|
const [virtualScene] = React__namespace.useState(() => new three.Scene());
|
|
349
353
|
const fbo = React__namespace.useMemo(() => {
|
|
350
|
-
const fbo2 = new three.WebGLCubeRenderTarget(resolution);
|
|
354
|
+
const fbo2 = isLegacy ? new three.WebGLCubeRenderTarget(resolution) : new CubeRenderTarget(resolution);
|
|
351
355
|
fbo2.texture.type = three.HalfFloatType;
|
|
352
356
|
return fbo2;
|
|
353
|
-
}, [resolution]);
|
|
357
|
+
}, [resolution, isLegacy]);
|
|
354
358
|
React__namespace.useEffect(() => {
|
|
355
359
|
return () => {
|
|
356
360
|
fbo.dispose();
|
|
@@ -358,10 +362,10 @@ function EnvironmentPortal({
|
|
|
358
362
|
}, [fbo]);
|
|
359
363
|
React__namespace.useLayoutEffect(() => {
|
|
360
364
|
if (frames === 1) {
|
|
361
|
-
const autoClear =
|
|
362
|
-
|
|
363
|
-
camera.current.update(
|
|
364
|
-
|
|
365
|
+
const autoClear = renderer.autoClear;
|
|
366
|
+
renderer.autoClear = true;
|
|
367
|
+
camera.current.update(renderer, virtualScene);
|
|
368
|
+
renderer.autoClear = autoClear;
|
|
365
369
|
}
|
|
366
370
|
return setEnvProps(background, scene, defaultScene, fbo.texture, {
|
|
367
371
|
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
@@ -378,7 +382,7 @@ function EnvironmentPortal({
|
|
|
378
382
|
defaultScene,
|
|
379
383
|
background,
|
|
380
384
|
frames,
|
|
381
|
-
|
|
385
|
+
renderer,
|
|
382
386
|
blur,
|
|
383
387
|
backgroundBlurriness,
|
|
384
388
|
backgroundIntensity,
|
|
@@ -389,10 +393,10 @@ function EnvironmentPortal({
|
|
|
389
393
|
let count = 1;
|
|
390
394
|
fiber.useFrame(() => {
|
|
391
395
|
if (frames === Infinity || count < frames) {
|
|
392
|
-
const autoClear =
|
|
393
|
-
|
|
394
|
-
camera.current.update(
|
|
395
|
-
|
|
396
|
+
const autoClear = renderer.autoClear;
|
|
397
|
+
renderer.autoClear = true;
|
|
398
|
+
camera.current.update(renderer, virtualScene);
|
|
399
|
+
renderer.autoClear = autoClear;
|
|
396
400
|
count++;
|
|
397
401
|
}
|
|
398
402
|
});
|
|
@@ -459,7 +463,6 @@ function Environment(props) {
|
|
|
459
463
|
var __defProp = Object.defineProperty;
|
|
460
464
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
461
465
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
462
|
-
const act = React__namespace["act"];
|
|
463
466
|
const useIsomorphicLayoutEffect = /* @__PURE__ */ (() => typeof window !== "undefined" && (window.document?.createElement || window.navigator?.product === "ReactNative"))() ? React__namespace.useLayoutEffect : React__namespace.useEffect;
|
|
464
467
|
function useMutableCallback(fn) {
|
|
465
468
|
const ref = React__namespace.useRef(fn);
|
|
@@ -635,8 +638,7 @@ function prepare(target, root, type, props) {
|
|
|
635
638
|
object,
|
|
636
639
|
eventCount: 0,
|
|
637
640
|
handlers: {},
|
|
638
|
-
isHidden: false
|
|
639
|
-
deferredRefs: []
|
|
641
|
+
isHidden: false
|
|
640
642
|
};
|
|
641
643
|
if (object) object.__r3f = instance;
|
|
642
644
|
}
|
|
@@ -793,6 +795,17 @@ function unregisterVisibility(store, object) {
|
|
|
793
795
|
internal.visibilityRegistry.delete(object.uuid);
|
|
794
796
|
internal.occlusionCache.delete(object);
|
|
795
797
|
}
|
|
798
|
+
function updateVisibilityHandlers(store, object, handlers) {
|
|
799
|
+
const { internal } = store.getState();
|
|
800
|
+
const entry = internal.visibilityRegistry.get(object.uuid);
|
|
801
|
+
if (!entry) return false;
|
|
802
|
+
entry.handlers = handlers;
|
|
803
|
+
if ((handlers.onOccluded || handlers.onVisible) && !internal.occlusionEnabled) {
|
|
804
|
+
object.occlusionTest = true;
|
|
805
|
+
enableOcclusion(store);
|
|
806
|
+
}
|
|
807
|
+
return true;
|
|
808
|
+
}
|
|
796
809
|
function checkVisibility(state) {
|
|
797
810
|
const { internal, camera } = state;
|
|
798
811
|
const registry = internal.visibilityRegistry;
|
|
@@ -953,9 +966,9 @@ function diffProps(instance, newProps) {
|
|
|
953
966
|
const { root, key } = resolve(instance.object, prop);
|
|
954
967
|
if (root.constructor && root.constructor.length === 0) {
|
|
955
968
|
const ctor = getMemoizedPrototype(root);
|
|
956
|
-
if (!is.und(ctor)) changedProps[
|
|
969
|
+
if (!is.und(ctor)) changedProps[prop] = ctor[key];
|
|
957
970
|
} else {
|
|
958
|
-
changedProps[
|
|
971
|
+
changedProps[prop] = 0;
|
|
959
972
|
}
|
|
960
973
|
}
|
|
961
974
|
return changedProps;
|
|
@@ -980,10 +993,7 @@ function applyProps(object, props) {
|
|
|
980
993
|
continue;
|
|
981
994
|
}
|
|
982
995
|
if (value === void 0) continue;
|
|
983
|
-
if (isFromRef(value))
|
|
984
|
-
instance?.deferredRefs?.push({ prop, ref: value[FROM_REF] });
|
|
985
|
-
continue;
|
|
986
|
-
}
|
|
996
|
+
if (isFromRef(value)) continue;
|
|
987
997
|
if (isOnce(value)) {
|
|
988
998
|
if (instance?.appliedOnce?.has(prop)) continue;
|
|
989
999
|
if (instance) {
|
|
@@ -1019,6 +1029,19 @@ function applyProps(object, props) {
|
|
|
1019
1029
|
} else if (isVectorLike(target) && is.num(value)) {
|
|
1020
1030
|
if ("setScalar" in target && typeof target.setScalar === "function") target.setScalar(value);
|
|
1021
1031
|
else target.set(value);
|
|
1032
|
+
} else if (root instanceof three.ShaderMaterial && key === "uniforms" && is.obj(value)) {
|
|
1033
|
+
if (!is.obj(root.uniforms)) root.uniforms = {};
|
|
1034
|
+
const uniforms = root.uniforms;
|
|
1035
|
+
const nextUniforms = value;
|
|
1036
|
+
for (const name in nextUniforms) {
|
|
1037
|
+
const uniform = nextUniforms[name];
|
|
1038
|
+
const targetUniform = uniforms[name];
|
|
1039
|
+
if (targetUniform) Object.assign(targetUniform, uniform);
|
|
1040
|
+
else {
|
|
1041
|
+
const nextUniform = uniform instanceof three.Uniform ? uniform.clone() : new three.Uniform(uniform.value);
|
|
1042
|
+
uniforms[name] = nextUniform;
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1022
1045
|
} else {
|
|
1023
1046
|
root[key] = value;
|
|
1024
1047
|
if (key.endsWith("Node") && root.isMaterial) {
|
|
@@ -1037,6 +1060,9 @@ function applyProps(object, props) {
|
|
|
1037
1060
|
if (instance.eventCount && object2.raycast !== null) {
|
|
1038
1061
|
rootState.internal.interaction.push(object2);
|
|
1039
1062
|
}
|
|
1063
|
+
}
|
|
1064
|
+
if (instance?.parent && rootState?.internal && instance.object?.isObject3D) {
|
|
1065
|
+
const object2 = instance.object;
|
|
1040
1066
|
const root = findInitialRoot(instance);
|
|
1041
1067
|
const visibilityHandlers = {
|
|
1042
1068
|
onFramed: instance.handlers.onFramed,
|
|
@@ -1044,7 +1070,9 @@ function applyProps(object, props) {
|
|
|
1044
1070
|
onVisible: instance.handlers.onVisible
|
|
1045
1071
|
};
|
|
1046
1072
|
if (hasVisibilityHandlers(visibilityHandlers)) {
|
|
1047
|
-
|
|
1073
|
+
if (!updateVisibilityHandlers(root, object2, visibilityHandlers)) {
|
|
1074
|
+
registerVisibility(root, object2, visibilityHandlers);
|
|
1075
|
+
}
|
|
1048
1076
|
} else {
|
|
1049
1077
|
unregisterVisibility(root, object2);
|
|
1050
1078
|
}
|
|
@@ -1087,6 +1115,41 @@ function releaseInternalPointerCapture(internal, obj, pointerId) {
|
|
|
1087
1115
|
captureData.target.releasePointerCapture(pointerId);
|
|
1088
1116
|
}
|
|
1089
1117
|
}
|
|
1118
|
+
function swapInteractivity(store, object, newObject) {
|
|
1119
|
+
const { internal } = store.getState();
|
|
1120
|
+
for (let i = 0; i < internal.interaction.length; i++) {
|
|
1121
|
+
if (internal.interaction[i] === object) internal.interaction[i] = newObject;
|
|
1122
|
+
}
|
|
1123
|
+
for (const pointerState of internal.pointerMap.values()) {
|
|
1124
|
+
for (let i = 0; i < pointerState.initialHits.length; i++) {
|
|
1125
|
+
if (pointerState.initialHits[i] === object) pointerState.initialHits[i] = newObject;
|
|
1126
|
+
}
|
|
1127
|
+
pointerState.hovered.forEach((value, key) => {
|
|
1128
|
+
if (value.eventObject === object || value.object === object) {
|
|
1129
|
+
pointerState.hovered.delete(key);
|
|
1130
|
+
const next = {
|
|
1131
|
+
...value,
|
|
1132
|
+
eventObject: value.eventObject === object ? newObject : value.eventObject,
|
|
1133
|
+
object: value.object === object ? newObject : value.object
|
|
1134
|
+
};
|
|
1135
|
+
pointerState.hovered.set(makeId(next), next);
|
|
1136
|
+
}
|
|
1137
|
+
});
|
|
1138
|
+
const captureData = pointerState.captured.get(object);
|
|
1139
|
+
if (captureData) {
|
|
1140
|
+
pointerState.captured.delete(object);
|
|
1141
|
+
pointerState.captured.set(newObject, {
|
|
1142
|
+
...captureData,
|
|
1143
|
+
intersection: {
|
|
1144
|
+
...captureData.intersection,
|
|
1145
|
+
object: captureData.intersection.object === object ? newObject : captureData.intersection.object,
|
|
1146
|
+
eventObject: captureData.intersection.eventObject === object ? newObject : captureData.intersection.eventObject
|
|
1147
|
+
}
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
unregisterVisibility(store, object);
|
|
1152
|
+
}
|
|
1090
1153
|
function removeInteractivity(store, object) {
|
|
1091
1154
|
const { internal } = store.getState();
|
|
1092
1155
|
internal.interaction = internal.interaction.filter((o) => o !== object);
|
|
@@ -1572,6 +1635,7 @@ function createPointerEvents(store) {
|
|
|
1572
1635
|
set((state) => ({ events: { ...state.events, connected: void 0 } }));
|
|
1573
1636
|
}
|
|
1574
1637
|
},
|
|
1638
|
+
// PREVIEW (A8): the XR pointer registration API may change before stable.
|
|
1575
1639
|
registerPointer: (config) => {
|
|
1576
1640
|
const pointerId = nextXRPointerId++;
|
|
1577
1641
|
xrPointers.set(pointerId, config);
|
|
@@ -1659,11 +1723,10 @@ function notifyAlpha({ message, link }) {
|
|
|
1659
1723
|
}
|
|
1660
1724
|
|
|
1661
1725
|
const INTERNAL_LIB_MARKERS = ["zustand", "setState", "Object.assign"];
|
|
1662
|
-
const INTERNAL_FIBER_MARKERS = ["packages/fiber/src", "packages/fiber/dist", "@react-three/fiber", "@react-three_fiber"];
|
|
1663
1726
|
function isInternalRendererAccess(stack, callerDepth = 2) {
|
|
1664
1727
|
if (!stack) return false;
|
|
1665
1728
|
const caller = stack.split("\n")[callerDepth] ?? "";
|
|
1666
|
-
return INTERNAL_LIB_MARKERS.some((m) => caller.includes(m))
|
|
1729
|
+
return INTERNAL_LIB_MARKERS.some((m) => caller.includes(m));
|
|
1667
1730
|
}
|
|
1668
1731
|
|
|
1669
1732
|
const R3F_CONTEXT = Symbol.for("@react-three/fiber.context");
|
|
@@ -1798,6 +1861,7 @@ const createStore = (invalidate, advance) => {
|
|
|
1798
1861
|
}),
|
|
1799
1862
|
setFrameloop: (frameloop = "always") => {
|
|
1800
1863
|
set(() => ({ frameloop }));
|
|
1864
|
+
scheduler.getScheduler().frameloop = frameloop;
|
|
1801
1865
|
},
|
|
1802
1866
|
setError: (error) => set(() => ({ error })),
|
|
1803
1867
|
error: null,
|
|
@@ -1978,19 +2042,25 @@ function loadingFn(extensions, onProgress) {
|
|
|
1978
2042
|
);
|
|
1979
2043
|
};
|
|
1980
2044
|
}
|
|
1981
|
-
function useLoader(loader, input, extensions, onProgress) {
|
|
1982
|
-
const
|
|
2045
|
+
function useLoader(loader, input, extensions, onProgress, cacheKey) {
|
|
2046
|
+
const inputs = Array.isArray(input) ? input : [input];
|
|
2047
|
+
const cacheKeys = Array.isArray(cacheKey ?? input) ? cacheKey ?? input : [cacheKey ?? input];
|
|
1983
2048
|
const fn = loadingFn(extensions, onProgress);
|
|
1984
|
-
const results =
|
|
2049
|
+
const results = cacheKeys.map(
|
|
2050
|
+
(key, index) => suspendReact.suspend(() => fn(loader, inputs[index]), [loader, key], { equal: is.equ })
|
|
2051
|
+
);
|
|
1985
2052
|
return Array.isArray(input) ? results : results[0];
|
|
1986
2053
|
}
|
|
1987
|
-
useLoader.preload = function(loader, input, extensions, onProgress) {
|
|
1988
|
-
const
|
|
1989
|
-
|
|
2054
|
+
useLoader.preload = function(loader, input, extensions, onProgress, cacheKey) {
|
|
2055
|
+
const inputs = Array.isArray(input) ? input : [input];
|
|
2056
|
+
const cacheKeys = Array.isArray(cacheKey ?? input) ? cacheKey ?? input : [cacheKey ?? input];
|
|
2057
|
+
cacheKeys.forEach(
|
|
2058
|
+
(key, index) => suspendReact.preload(() => loadingFn(extensions, onProgress)(loader, inputs[index]), [loader, key])
|
|
2059
|
+
);
|
|
1990
2060
|
};
|
|
1991
|
-
useLoader.clear = function(loader, input) {
|
|
1992
|
-
const
|
|
1993
|
-
|
|
2061
|
+
useLoader.clear = function(loader, input, cacheKey) {
|
|
2062
|
+
const cacheKeys = Array.isArray(cacheKey ?? input) ? cacheKey ?? input : [cacheKey ?? input];
|
|
2063
|
+
cacheKeys.forEach((key) => suspendReact.clear([loader, key]));
|
|
1994
2064
|
};
|
|
1995
2065
|
useLoader.loader = getLoader;
|
|
1996
2066
|
|
|
@@ -2410,7 +2480,7 @@ function advance(timestamp) {
|
|
|
2410
2480
|
scheduler.getScheduler().step(timestamp);
|
|
2411
2481
|
}
|
|
2412
2482
|
|
|
2413
|
-
const version = "10.0.0-alpha.
|
|
2483
|
+
const version = "10.0.0-alpha.3";
|
|
2414
2484
|
const packageData = {
|
|
2415
2485
|
version: version};
|
|
2416
2486
|
|
|
@@ -13666,7 +13736,7 @@ function n0() {
|
|
|
13666
13736
|
var t0 = n0();
|
|
13667
13737
|
const r0 = Xb(t0);
|
|
13668
13738
|
|
|
13669
|
-
const t = 1, o = 8, r = 32, e = 2;
|
|
13739
|
+
const t = 1, o = 8, r = 32, e = 2, i$1 = 268435456;
|
|
13670
13740
|
|
|
13671
13741
|
function createReconciler(config) {
|
|
13672
13742
|
const reconciler2 = r0(config);
|
|
@@ -13831,7 +13901,15 @@ function setFiberRef(fiber, publicInstance) {
|
|
|
13831
13901
|
}
|
|
13832
13902
|
}
|
|
13833
13903
|
const reconstructed = [];
|
|
13834
|
-
function
|
|
13904
|
+
function flushReconstructedInstances() {
|
|
13905
|
+
if (reconstructed.length === 0) return;
|
|
13906
|
+
try {
|
|
13907
|
+
swapReconstructedInstances();
|
|
13908
|
+
} finally {
|
|
13909
|
+
reconstructed.length = 0;
|
|
13910
|
+
}
|
|
13911
|
+
}
|
|
13912
|
+
function swapReconstructedInstances() {
|
|
13835
13913
|
for (const [instance] of reconstructed) {
|
|
13836
13914
|
const parent = instance.parent;
|
|
13837
13915
|
if (parent) {
|
|
@@ -13849,6 +13927,9 @@ function swapInstances() {
|
|
|
13849
13927
|
}
|
|
13850
13928
|
}
|
|
13851
13929
|
if (instance.isHidden) unhideInstance(instance);
|
|
13930
|
+
if (isObject3D(instance.object) && !instance.parent) {
|
|
13931
|
+
removeInteractivity(findInitialRoot(instance), instance.object);
|
|
13932
|
+
}
|
|
13852
13933
|
if (instance.object.__r3f) delete instance.object.__r3f;
|
|
13853
13934
|
if (instance.type !== "primitive") disposeOnIdle(instance.object);
|
|
13854
13935
|
}
|
|
@@ -13857,10 +13938,16 @@ function swapInstances() {
|
|
|
13857
13938
|
const parent = instance.parent;
|
|
13858
13939
|
if (parent) {
|
|
13859
13940
|
const target = catalogue[toPascalCase(instance.type)];
|
|
13941
|
+
const prevObject = instance.object;
|
|
13860
13942
|
instance.object = instance.props.object ?? new target(...instance.props.args ?? []);
|
|
13861
13943
|
instance.object.__r3f = instance;
|
|
13862
13944
|
setFiberRef(fiber, instance.object);
|
|
13945
|
+
if (isObject3D(prevObject) && isObject3D(instance.object)) {
|
|
13946
|
+
swapInteractivity(findInitialRoot(instance), prevObject, instance.object);
|
|
13947
|
+
}
|
|
13863
13948
|
delete instance.appliedOnce;
|
|
13949
|
+
instance.eventCount = 0;
|
|
13950
|
+
instance.handlers = {};
|
|
13864
13951
|
applyProps(instance.object, instance.props);
|
|
13865
13952
|
if (instance.props.attach) {
|
|
13866
13953
|
attach(parent, instance);
|
|
@@ -13877,14 +13964,114 @@ function swapInstances() {
|
|
|
13877
13964
|
invalidateInstance(instance);
|
|
13878
13965
|
}
|
|
13879
13966
|
}
|
|
13880
|
-
reconstructed.length = 0;
|
|
13881
13967
|
}
|
|
13882
13968
|
const handleTextInstance = () => {
|
|
13883
13969
|
};
|
|
13884
13970
|
const NO_CONTEXT = {};
|
|
13885
13971
|
let currentUpdatePriority = NoEventPriority;
|
|
13886
|
-
|
|
13887
|
-
|
|
13972
|
+
function getEventPriority(type) {
|
|
13973
|
+
switch (type) {
|
|
13974
|
+
case "beforetoggle":
|
|
13975
|
+
case "cancel":
|
|
13976
|
+
case "click":
|
|
13977
|
+
case "close":
|
|
13978
|
+
case "contextmenu":
|
|
13979
|
+
case "copy":
|
|
13980
|
+
case "cut":
|
|
13981
|
+
case "auxclick":
|
|
13982
|
+
case "dblclick":
|
|
13983
|
+
case "dragend":
|
|
13984
|
+
case "dragstart":
|
|
13985
|
+
case "drop":
|
|
13986
|
+
case "focusin":
|
|
13987
|
+
case "focusout":
|
|
13988
|
+
case "input":
|
|
13989
|
+
case "invalid":
|
|
13990
|
+
case "keydown":
|
|
13991
|
+
case "keypress":
|
|
13992
|
+
case "keyup":
|
|
13993
|
+
case "mousedown":
|
|
13994
|
+
case "mouseup":
|
|
13995
|
+
case "paste":
|
|
13996
|
+
case "pause":
|
|
13997
|
+
case "play":
|
|
13998
|
+
case "pointercancel":
|
|
13999
|
+
case "pointerdown":
|
|
14000
|
+
case "pointerup":
|
|
14001
|
+
case "ratechange":
|
|
14002
|
+
case "reset":
|
|
14003
|
+
case "resize":
|
|
14004
|
+
case "seeked":
|
|
14005
|
+
case "submit":
|
|
14006
|
+
case "touchcancel":
|
|
14007
|
+
case "touchend":
|
|
14008
|
+
case "touchstart":
|
|
14009
|
+
case "volumechange":
|
|
14010
|
+
case "change":
|
|
14011
|
+
case "selectionchange":
|
|
14012
|
+
case "compositionstart":
|
|
14013
|
+
case "compositionend":
|
|
14014
|
+
case "compositionupdate":
|
|
14015
|
+
case "beforeinput":
|
|
14016
|
+
case "blur":
|
|
14017
|
+
case "fullscreenchange":
|
|
14018
|
+
case "focus":
|
|
14019
|
+
case "hashchange":
|
|
14020
|
+
case "popstate":
|
|
14021
|
+
case "select":
|
|
14022
|
+
case "selectstart":
|
|
14023
|
+
return e;
|
|
14024
|
+
case "drag":
|
|
14025
|
+
case "dragenter":
|
|
14026
|
+
case "dragexit":
|
|
14027
|
+
case "dragleave":
|
|
14028
|
+
case "dragover":
|
|
14029
|
+
case "mousemove":
|
|
14030
|
+
case "mouseout":
|
|
14031
|
+
case "mouseover":
|
|
14032
|
+
case "pointermove":
|
|
14033
|
+
case "pointerout":
|
|
14034
|
+
case "pointerover":
|
|
14035
|
+
case "scroll":
|
|
14036
|
+
case "touchmove":
|
|
14037
|
+
case "wheel":
|
|
14038
|
+
case "mouseenter":
|
|
14039
|
+
case "mouseleave":
|
|
14040
|
+
case "pointerenter":
|
|
14041
|
+
case "pointerleave":
|
|
14042
|
+
return o;
|
|
14043
|
+
case "message": {
|
|
14044
|
+
switch (Tb.unstable_getCurrentPriorityLevel()) {
|
|
14045
|
+
case Tb.unstable_ImmediatePriority:
|
|
14046
|
+
return e;
|
|
14047
|
+
case Tb.unstable_UserBlockingPriority:
|
|
14048
|
+
return o;
|
|
14049
|
+
case Tb.unstable_NormalPriority:
|
|
14050
|
+
case Tb.unstable_LowPriority:
|
|
14051
|
+
return r;
|
|
14052
|
+
case Tb.unstable_IdlePriority:
|
|
14053
|
+
return i$1;
|
|
14054
|
+
default:
|
|
14055
|
+
return r;
|
|
14056
|
+
}
|
|
14057
|
+
}
|
|
14058
|
+
default:
|
|
14059
|
+
return r;
|
|
14060
|
+
}
|
|
14061
|
+
}
|
|
14062
|
+
function scheduleMicrotask(callback) {
|
|
14063
|
+
if (typeof queueMicrotask === "function") {
|
|
14064
|
+
queueMicrotask(callback);
|
|
14065
|
+
} else if (typeof Promise !== "undefined") {
|
|
14066
|
+
Promise.resolve().then(callback).catch((error) => {
|
|
14067
|
+
setTimeout(() => {
|
|
14068
|
+
throw error;
|
|
14069
|
+
});
|
|
14070
|
+
});
|
|
14071
|
+
} else {
|
|
14072
|
+
setTimeout(callback);
|
|
14073
|
+
}
|
|
14074
|
+
}
|
|
13888
14075
|
const reconciler = /* @__PURE__ */ createReconciler({
|
|
13889
14076
|
isPrimaryRenderer: false,
|
|
13890
14077
|
warnsIfNotActing: false,
|
|
@@ -13923,16 +14110,15 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13923
14110
|
else if (newProps.args?.length !== oldProps.args?.length) reconstruct = true;
|
|
13924
14111
|
else if (newProps.args?.some((value, index) => value !== oldProps.args?.[index])) reconstruct = true;
|
|
13925
14112
|
if (reconstruct) {
|
|
13926
|
-
reconstructed.push([instance,
|
|
14113
|
+
reconstructed.push([instance, getInstanceProps(newProps), fiber]);
|
|
13927
14114
|
} else {
|
|
13928
14115
|
const changedProps = diffProps(instance, newProps);
|
|
13929
|
-
|
|
13930
|
-
|
|
13931
|
-
|
|
13932
|
-
|
|
14116
|
+
const attach2 = instance.props.attach;
|
|
14117
|
+
instance.props = getInstanceProps(newProps);
|
|
14118
|
+
if (attach2 !== void 0) instance.props.attach = attach2;
|
|
14119
|
+
else delete instance.props.attach;
|
|
14120
|
+
if (Object.keys(changedProps).length) applyProps(instance.object, changedProps);
|
|
13933
14121
|
}
|
|
13934
|
-
const isTailSibling = fiber.sibling === null || (fiber.flags & Update) === NoFlags;
|
|
13935
|
-
if (isTailSibling) swapInstances();
|
|
13936
14122
|
},
|
|
13937
14123
|
finalizeInitialChildren: (instance) => {
|
|
13938
14124
|
for (const prop in instance.props) {
|
|
@@ -13957,8 +14143,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13957
14143
|
const target = container.getState().internal.container ?? container.getState().scene;
|
|
13958
14144
|
return prepare(target, container, "", {});
|
|
13959
14145
|
},
|
|
13960
|
-
|
|
13961
|
-
|
|
14146
|
+
// Reconstructed instances are swapped once all mutations are committed,
|
|
14147
|
+
// before layout effects run so refs point to the new objects
|
|
14148
|
+
resetAfterCommit: flushReconstructedInstances,
|
|
13962
14149
|
shouldSetTextContent: () => false,
|
|
13963
14150
|
clearContainer: () => false,
|
|
13964
14151
|
hideInstance,
|
|
@@ -13966,6 +14153,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13966
14153
|
createTextInstance: handleTextInstance,
|
|
13967
14154
|
hideTextInstance: handleTextInstance,
|
|
13968
14155
|
unhideTextInstance: handleTextInstance,
|
|
14156
|
+
// Mirrors react-dom, which flushes discrete work in microtasks
|
|
14157
|
+
supportsMicrotasks: true,
|
|
14158
|
+
scheduleMicrotask,
|
|
13969
14159
|
scheduleTimeout: typeof setTimeout === "function" ? setTimeout : void 0,
|
|
13970
14160
|
cancelTimeout: typeof clearTimeout === "function" ? clearTimeout : void 0,
|
|
13971
14161
|
noTimeout: -1,
|
|
@@ -14006,28 +14196,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
14006
14196
|
},
|
|
14007
14197
|
resolveUpdatePriority() {
|
|
14008
14198
|
if (currentUpdatePriority !== NoEventPriority) return currentUpdatePriority;
|
|
14009
|
-
|
|
14010
|
-
|
|
14011
|
-
|
|
14012
|
-
case "dblclick":
|
|
14013
|
-
case "dragenter":
|
|
14014
|
-
case "dragleave":
|
|
14015
|
-
case "drop":
|
|
14016
|
-
case "pointercancel":
|
|
14017
|
-
case "pointerdown":
|
|
14018
|
-
case "pointerup":
|
|
14019
|
-
return e;
|
|
14020
|
-
case "dragover":
|
|
14021
|
-
case "pointermove":
|
|
14022
|
-
case "pointerout":
|
|
14023
|
-
case "pointerover":
|
|
14024
|
-
case "pointerenter":
|
|
14025
|
-
case "pointerleave":
|
|
14026
|
-
case "wheel":
|
|
14027
|
-
return o;
|
|
14028
|
-
default:
|
|
14029
|
-
return r;
|
|
14030
|
-
}
|
|
14199
|
+
const eventType = typeof window !== "undefined" ? window.event?.type : void 0;
|
|
14200
|
+
if (eventType === void 0) return r;
|
|
14201
|
+
return getEventPriority(eventType);
|
|
14031
14202
|
},
|
|
14032
14203
|
resetFormInstance() {
|
|
14033
14204
|
},
|
|
@@ -14076,11 +14247,15 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
14076
14247
|
cloneMutableTextInstance(textInstance) {
|
|
14077
14248
|
return textInstance;
|
|
14078
14249
|
},
|
|
14250
|
+
// React 19.2 added these for root-level view transitions. They only run for hosts that opt into
|
|
14251
|
+
// view transitions by returning a container from cloneRootViewTransitionContainer; R3F renders
|
|
14252
|
+
// into a WebGL/WebGPU canvas, where cloning the root has no meaning, so we never opt in and
|
|
14253
|
+
// React never calls them. They stay as no-ops rather than throws: the host config is shared by
|
|
14254
|
+
// every root, and a throw here would turn a React-internal probe into a hard crash for users.
|
|
14255
|
+
// Guarded by a test asserting a full render + unmount never reaches them.
|
|
14079
14256
|
cloneRootViewTransitionContainer(_rootContainer) {
|
|
14080
|
-
throw new Error("Not implemented.");
|
|
14081
14257
|
},
|
|
14082
14258
|
removeRootViewTransitionClone(_rootContainer, _clone) {
|
|
14083
|
-
throw new Error("Not implemented.");
|
|
14084
14259
|
},
|
|
14085
14260
|
// https://github.com/facebook/react/pull/32465
|
|
14086
14261
|
createFragmentInstance: (_fiber) => null,
|
|
@@ -14165,6 +14340,7 @@ function createRoot(canvas) {
|
|
|
14165
14340
|
const lastConfiguredProps = {};
|
|
14166
14341
|
let configured = false;
|
|
14167
14342
|
let pending = null;
|
|
14343
|
+
let rendererSetup = null;
|
|
14168
14344
|
return {
|
|
14169
14345
|
async configure(props = {}) {
|
|
14170
14346
|
let resolve;
|
|
@@ -14195,7 +14371,7 @@ function createRoot(canvas) {
|
|
|
14195
14371
|
forceEven
|
|
14196
14372
|
} = props;
|
|
14197
14373
|
const textureColorSpace = is.obj(glConfig) && !is.fun(glConfig) && !isRenderer(glConfig) && glConfig.textureColorSpace || is.obj(rendererConfig) && !is.fun(rendererConfig) && !isRenderer(rendererConfig) && rendererConfig.textureColorSpace || three.SRGBColorSpace;
|
|
14198
|
-
|
|
14374
|
+
let state = store.getState();
|
|
14199
14375
|
const defaultGLProps = {
|
|
14200
14376
|
canvas,
|
|
14201
14377
|
powerPreference: "high-performance",
|
|
@@ -14223,9 +14399,21 @@ function createRoot(canvas) {
|
|
|
14223
14399
|
);
|
|
14224
14400
|
}
|
|
14225
14401
|
if (!state.internal.actualRenderer) {
|
|
14226
|
-
|
|
14227
|
-
|
|
14228
|
-
|
|
14402
|
+
if (!rendererSetup) {
|
|
14403
|
+
rendererSetup = (async () => {
|
|
14404
|
+
{
|
|
14405
|
+
renderer = await resolveRenderer(glConfig, defaultGLProps, three.WebGLRenderer);
|
|
14406
|
+
state.internal.actualRenderer = renderer;
|
|
14407
|
+
state.set({ isLegacy: true, gl: renderer, renderer, primaryStore: store });
|
|
14408
|
+
}
|
|
14409
|
+
})().catch((err) => {
|
|
14410
|
+
rendererSetup = null;
|
|
14411
|
+
throw err;
|
|
14412
|
+
});
|
|
14413
|
+
}
|
|
14414
|
+
await rendererSetup;
|
|
14415
|
+
state = store.getState();
|
|
14416
|
+
renderer = state.internal.actualRenderer;
|
|
14229
14417
|
}
|
|
14230
14418
|
let raycaster = state.raycaster;
|
|
14231
14419
|
if (!raycaster) state.set({ raycaster: raycaster = new three.Raycaster() });
|
|
@@ -14575,7 +14763,8 @@ function unmountComponentAtNode(canvas, callback) {
|
|
|
14575
14763
|
dispose(state.scene);
|
|
14576
14764
|
_roots.delete(canvas);
|
|
14577
14765
|
if (callback) callback(canvas);
|
|
14578
|
-
} catch {
|
|
14766
|
+
} catch (error) {
|
|
14767
|
+
console.warn("[R3F] Error while unmounting root; teardown may be incomplete:", error);
|
|
14579
14768
|
}
|
|
14580
14769
|
}, 500);
|
|
14581
14770
|
}
|
|
@@ -14638,6 +14827,7 @@ function PortalInner({ state = {}, children, container }) {
|
|
|
14638
14827
|
viewport = rootState.viewport.getCurrentViewport(camera, new three.Vector3(), resolvedSize);
|
|
14639
14828
|
if (camera !== rootState.camera) updateCamera(camera, resolvedSize);
|
|
14640
14829
|
}
|
|
14830
|
+
const set = injectState.set;
|
|
14641
14831
|
return {
|
|
14642
14832
|
// The intersect consists of the previous root state
|
|
14643
14833
|
...rootState,
|
|
@@ -14656,7 +14846,7 @@ function PortalInner({ state = {}, children, container }) {
|
|
|
14656
14846
|
size: resolvedSize,
|
|
14657
14847
|
viewport: { ...rootState.viewport, ...viewport },
|
|
14658
14848
|
// Layers are allowed to override events
|
|
14659
|
-
setEvents: (events2) =>
|
|
14849
|
+
setEvents: (events2) => set((state2) => ({ ...state2, events: { ...state2.events, ...events2 } })),
|
|
14660
14850
|
// Container for child attachment - the portalScene (injected or container itself)
|
|
14661
14851
|
internal: { ...rootState.internal, ...injectState.internal, container: portalScene }
|
|
14662
14852
|
};
|
|
@@ -14728,14 +14918,36 @@ function parseRendererConfig(rendererProp) {
|
|
|
14728
14918
|
return { primaryCanvas: void 0, scheduler: void 0, renderer: rendererProp };
|
|
14729
14919
|
}
|
|
14730
14920
|
|
|
14921
|
+
const RESOURCE_KINDS = ["nodes", "uniforms", "buffers", "gpuStorage"];
|
|
14922
|
+
const registries = /* @__PURE__ */ new WeakMap();
|
|
14923
|
+
function getKindRegistry(store, kind) {
|
|
14924
|
+
let registry = registries.get(store);
|
|
14925
|
+
if (!registry) {
|
|
14926
|
+
registry = {
|
|
14927
|
+
nodes: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() },
|
|
14928
|
+
uniforms: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() },
|
|
14929
|
+
buffers: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() },
|
|
14930
|
+
gpuStorage: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() }
|
|
14931
|
+
};
|
|
14932
|
+
registries.set(store, registry);
|
|
14933
|
+
}
|
|
14934
|
+
return registry[kind];
|
|
14935
|
+
}
|
|
14936
|
+
function invalidateResource(store, kind, scopeKey) {
|
|
14937
|
+
const registry = getKindRegistry(store, kind);
|
|
14938
|
+
{
|
|
14939
|
+
registry.valid.clear();
|
|
14940
|
+
registry.staged.clear();
|
|
14941
|
+
}
|
|
14942
|
+
}
|
|
14943
|
+
function invalidateAllResources(store) {
|
|
14944
|
+
for (const kind of RESOURCE_KINDS) invalidateResource(store, kind);
|
|
14945
|
+
}
|
|
14946
|
+
|
|
14731
14947
|
function clearHmrCaches(store) {
|
|
14732
|
-
store.
|
|
14733
|
-
|
|
14734
|
-
|
|
14735
|
-
buffers: {},
|
|
14736
|
-
gpuStorage: {},
|
|
14737
|
-
_hmrVersion: state._hmrVersion + 1
|
|
14738
|
-
}));
|
|
14948
|
+
const primary = store.getState().primaryStore ?? store;
|
|
14949
|
+
invalidateAllResources(primary);
|
|
14950
|
+
primary.setState((state) => ({ _hmrVersion: state._hmrVersion + 1 }));
|
|
14739
14951
|
}
|
|
14740
14952
|
|
|
14741
14953
|
function CanvasImpl({
|
|
@@ -14816,6 +15028,7 @@ function CanvasImpl({
|
|
|
14816
15028
|
const handleDropMissed = useMutableCallback(onDropMissed);
|
|
14817
15029
|
const [block, setBlock] = React__namespace.useState(false);
|
|
14818
15030
|
const [error, setError] = React__namespace.useState(false);
|
|
15031
|
+
const [fallbackVisible, setFallbackVisible] = React__namespace.useState(false);
|
|
14819
15032
|
if (block) throw block;
|
|
14820
15033
|
if (error) throw error;
|
|
14821
15034
|
const root = React__namespace.useRef(null);
|
|
@@ -14823,6 +15036,7 @@ function CanvasImpl({
|
|
|
14823
15036
|
const unsubscribeErrorRef = React__namespace.useRef(null);
|
|
14824
15037
|
useIsomorphicLayoutEffect(() => {
|
|
14825
15038
|
effectActiveRef.current = true;
|
|
15039
|
+
if (fallbackVisible) return;
|
|
14826
15040
|
const canvas = canvasRef.current;
|
|
14827
15041
|
if (effectiveSize.width > 0 && effectiveSize.height > 0 && canvas) {
|
|
14828
15042
|
if (!root.current) {
|
|
@@ -14843,7 +15057,7 @@ function CanvasImpl({
|
|
|
14843
15057
|
}
|
|
14844
15058
|
async function run() {
|
|
14845
15059
|
if (!effectActiveRef.current || !root.current) return;
|
|
14846
|
-
await root.current.configure({
|
|
15060
|
+
const configured = await root.current.configure({
|
|
14847
15061
|
id,
|
|
14848
15062
|
primaryCanvas,
|
|
14849
15063
|
scheduler,
|
|
@@ -14884,8 +15098,20 @@ function CanvasImpl({
|
|
|
14884
15098
|
}
|
|
14885
15099
|
onCreated?.(state);
|
|
14886
15100
|
}
|
|
14887
|
-
})
|
|
14888
|
-
|
|
15101
|
+
}).then(
|
|
15102
|
+
() => true,
|
|
15103
|
+
// Renderer setup failed (e.g. no WebGL/WebGPU support). The `fallback` prop lives
|
|
15104
|
+
// inside <canvas>, which browsers don't display, so surface it as visible DOM
|
|
15105
|
+
// instead; with no fallback, rethrow to an external error boundary. (#3757)
|
|
15106
|
+
(setupError) => {
|
|
15107
|
+
if (effectActiveRef.current) {
|
|
15108
|
+
if (fallback != null) setFallbackVisible(true);
|
|
15109
|
+
else setError(setupError);
|
|
15110
|
+
}
|
|
15111
|
+
return false;
|
|
15112
|
+
}
|
|
15113
|
+
);
|
|
15114
|
+
if (!configured || !effectActiveRef.current || !root.current) return;
|
|
14889
15115
|
root.current.render(
|
|
14890
15116
|
/* @__PURE__ */ jsxRuntime.jsx(Bridge, { children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { set: setError, children: /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx(Block, { set: setBlock }), children: [
|
|
14891
15117
|
backgroundProps && /* @__PURE__ */ jsxRuntime.jsx(Environment, { ...backgroundProps }),
|
|
@@ -14948,7 +15174,11 @@ function CanvasImpl({
|
|
|
14948
15174
|
...style
|
|
14949
15175
|
},
|
|
14950
15176
|
...props,
|
|
14951
|
-
children:
|
|
15177
|
+
children: fallbackVisible ? (
|
|
15178
|
+
// Renderer setup failed: render the fallback as visible DOM. Inside <canvas> (below)
|
|
15179
|
+
// it exists in the tree but browsers never paint it, which is the whole bug (#3757).
|
|
15180
|
+
fallback
|
|
15181
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, className: "r3f-canvas-container", style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
14952
15182
|
"canvas",
|
|
14953
15183
|
{
|
|
14954
15184
|
ref: canvasRef,
|
|
@@ -14986,7 +15216,6 @@ exports.REACT_INTERNAL_PROPS = REACT_INTERNAL_PROPS;
|
|
|
14986
15216
|
exports.RESERVED_PROPS = RESERVED_PROPS;
|
|
14987
15217
|
exports.Texture = Texture;
|
|
14988
15218
|
exports._roots = _roots;
|
|
14989
|
-
exports.act = act;
|
|
14990
15219
|
exports.addAfterEffect = addAfterEffect;
|
|
14991
15220
|
exports.addEffect = addEffect;
|
|
14992
15221
|
exports.addTail = addTail;
|
|
@@ -15036,6 +15265,7 @@ exports.reconciler = reconciler;
|
|
|
15036
15265
|
exports.registerPrimary = registerPrimary;
|
|
15037
15266
|
exports.removeInteractivity = removeInteractivity;
|
|
15038
15267
|
exports.resolve = resolve;
|
|
15268
|
+
exports.swapInteractivity = swapInteractivity;
|
|
15039
15269
|
exports.unmountComponentAtNode = unmountComponentAtNode;
|
|
15040
15270
|
exports.unregisterPrimary = unregisterPrimary;
|
|
15041
15271
|
exports.updateCamera = updateCamera;
|