@react-three/fiber 10.0.0-canary.e881a4a → 10.0.0-canary.ea31ccd
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 +2050 -1856
- package/dist/index.d.cts +310 -155
- package/dist/index.d.mts +310 -155
- package/dist/index.d.ts +308 -181
- package/dist/index.mjs +2052 -1858
- package/dist/legacy.cjs +2617 -2427
- package/dist/legacy.d.cts +313 -162
- package/dist/legacy.d.mts +313 -162
- package/dist/legacy.d.ts +311 -186
- package/dist/legacy.mjs +2619 -2429
- package/dist/webgpu/index.cjs +2161 -1942
- package/dist/webgpu/index.d.cts +390 -266
- package/dist/webgpu/index.d.mts +390 -266
- package/dist/webgpu/index.d.ts +388 -292
- package/dist/webgpu/index.mjs +2001 -1782
- package/package.json +4 -4
- package/readme.md +1 -1
- package/react-reconciler/constants.d.ts +0 -7
- package/react-reconciler/constants.js +0 -1
- package/react-reconciler/index.d.ts +0 -1044
- package/react-reconciler/index.js +0 -208
package/dist/webgpu/index.mjs
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import * as webgpu from 'three/webgpu';
|
|
2
|
-
import { CubeRenderTarget, RenderTarget,
|
|
3
|
-
import { Inspector } from 'three/addons/inspector/Inspector.js';
|
|
2
|
+
import { CubeRenderTarget, RenderTarget, Frustum, Matrix4, Group, BoxGeometry, MeshBasicNodeMaterial, Mesh, Node, NodeUpdateType, Layers, ShaderMaterial, Uniform, SRGBColorSpace, RGBAFormat, UnsignedByteType, Vector3, Vector2, TextureLoader, Texture as Texture$1, CubeReflectionMapping, EquirectangularReflectionMapping, CubeTextureLoader, CanvasTarget, Raycaster, OrthographicCamera, PerspectiveCamera, Scene, PCFShadowMap, VSMShadowMap, BasicShadowMap, ACESFilmicToneMapping, WebGPURenderer, HalfFloatType, Color, Vector4, RenderPipeline } from 'three/webgpu';
|
|
4
3
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
5
4
|
import * as React from 'react';
|
|
6
|
-
import React__default, {
|
|
5
|
+
import React__default, { useRef, useMemo, useLayoutEffect, useEffect, useContext, useImperativeHandle, useCallback, useState } from 'react';
|
|
7
6
|
import useMeasure from 'react-use-measure';
|
|
8
7
|
import { useFiber, useContextBridge, traverseFiber, FiberProvider } from 'its-fine';
|
|
9
|
-
import {
|
|
8
|
+
import { createWithEqualityFn } from 'zustand/traditional';
|
|
9
|
+
import { getScheduler } from '@pmndrs/scheduler';
|
|
10
|
+
export { Scheduler, getScheduler } from '@pmndrs/scheduler';
|
|
11
|
+
import Tb, { unstable_getCurrentPriorityLevel, unstable_IdlePriority, unstable_LowPriority, unstable_NormalPriority, unstable_UserBlockingPriority, unstable_ImmediatePriority, unstable_scheduleCallback } from 'scheduler';
|
|
10
12
|
import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
|
|
11
13
|
import { HDRLoader } from 'three/examples/jsm/loaders/HDRLoader.js';
|
|
14
|
+
import { HDRCubeTextureLoader } from 'three/examples/jsm/loaders/HDRCubeTextureLoader.js';
|
|
12
15
|
import { EXRLoader } from 'three/examples/jsm/loaders/EXRLoader.js';
|
|
13
16
|
import { UltraHDRLoader } from 'three/examples/jsm/loaders/UltraHDRLoader.js';
|
|
14
17
|
import { GainMapLoader } from '@monogrid/gainmap-js';
|
|
15
|
-
import Tb, { unstable_scheduleCallback, unstable_IdlePriority } from 'scheduler';
|
|
16
|
-
import { createWithEqualityFn } from 'zustand/traditional';
|
|
17
|
-
import { getScheduler } from '@pmndrs/scheduler';
|
|
18
|
-
export { Scheduler, getScheduler } from '@pmndrs/scheduler';
|
|
19
18
|
import { suspend, preload, clear } from 'suspend-react';
|
|
20
19
|
import { dequal } from 'dequal/lite';
|
|
21
20
|
import 'zustand/shallow';
|
|
@@ -35,6 +34,10 @@ function _mergeNamespaces(n, m) {
|
|
|
35
34
|
|
|
36
35
|
const R3F_BUILD_LEGACY = false;
|
|
37
36
|
const R3F_BUILD_WEBGPU = true;
|
|
37
|
+
async function loadInspector() {
|
|
38
|
+
const { Inspector } = await import('three/addons/inspector/Inspector.js');
|
|
39
|
+
return Inspector;
|
|
40
|
+
}
|
|
38
41
|
const WebGLRenderer = class WebGLRenderer2 {
|
|
39
42
|
constructor() {
|
|
40
43
|
throw new Error(
|
|
@@ -48,13 +51,13 @@ const WebGLCubeRenderTarget = null;
|
|
|
48
51
|
const THREE = /*#__PURE__*/_mergeNamespaces({
|
|
49
52
|
__proto__: null,
|
|
50
53
|
CubeRenderTargetCompat: CubeRenderTarget,
|
|
51
|
-
Inspector: Inspector,
|
|
52
54
|
R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
|
|
53
55
|
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
54
56
|
RenderTargetCompat: RenderTarget,
|
|
55
57
|
WebGLCubeRenderTarget: WebGLCubeRenderTarget,
|
|
56
58
|
WebGLRenderTarget: WebGLRenderTarget,
|
|
57
|
-
WebGLRenderer: WebGLRenderer
|
|
59
|
+
WebGLRenderer: WebGLRenderer,
|
|
60
|
+
loadInspector: loadInspector
|
|
58
61
|
}, [webgpu]);
|
|
59
62
|
|
|
60
63
|
const primaryRegistry = /* @__PURE__ */ new Map();
|
|
@@ -115,556 +118,228 @@ function getPrimaryIds() {
|
|
|
115
118
|
return Array.from(primaryRegistry.keys());
|
|
116
119
|
}
|
|
117
120
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
121
|
+
var __defProp$1 = Object.defineProperty;
|
|
122
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
123
|
+
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
124
|
+
const useIsomorphicLayoutEffect = /* @__PURE__ */ (() => typeof window !== "undefined" && (window.document?.createElement || window.navigator?.product === "ReactNative"))() ? React.useLayoutEffect : React.useEffect;
|
|
125
|
+
function useMutableCallback(fn) {
|
|
126
|
+
const ref = React.useRef(fn);
|
|
127
|
+
useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
|
|
128
|
+
return ref;
|
|
129
|
+
}
|
|
130
|
+
function useBridge() {
|
|
131
|
+
const fiber = useFiber();
|
|
132
|
+
const ContextBridge = useContextBridge();
|
|
133
|
+
return React.useMemo(
|
|
134
|
+
() => ({ children }) => {
|
|
135
|
+
const strict = !!traverseFiber(fiber, true, (node) => node.type === React.StrictMode);
|
|
136
|
+
const Root = strict ? React.StrictMode : React.Fragment;
|
|
137
|
+
return /* @__PURE__ */ jsx(Root, { children: /* @__PURE__ */ jsx(ContextBridge, { children }) });
|
|
138
|
+
},
|
|
139
|
+
[fiber, ContextBridge]
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
function Block({ set }) {
|
|
143
|
+
useIsomorphicLayoutEffect(() => {
|
|
144
|
+
set(new Promise(() => null));
|
|
145
|
+
return () => set(false);
|
|
146
|
+
}, [set]);
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
const ErrorBoundary = /* @__PURE__ */ (() => {
|
|
150
|
+
var _a;
|
|
151
|
+
return _a = class extends React.Component {
|
|
152
|
+
constructor() {
|
|
153
|
+
super(...arguments);
|
|
154
|
+
__publicField$1(this, "state", { error: false });
|
|
155
|
+
}
|
|
156
|
+
componentDidCatch(err) {
|
|
157
|
+
this.props.set(err);
|
|
158
|
+
}
|
|
159
|
+
render() {
|
|
160
|
+
return this.state.error ? null : this.props.children;
|
|
161
|
+
}
|
|
162
|
+
}, __publicField$1(_a, "getDerivedStateFromError", () => ({ error: true })), _a;
|
|
163
|
+
})();
|
|
130
164
|
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
} = {}) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
useLoader$1.clear(loader, multiFile ? [files] : files);
|
|
165
|
+
const is = {
|
|
166
|
+
obj: (a) => a === Object(a) && !is.arr(a) && typeof a !== "function",
|
|
167
|
+
fun: (a) => typeof a === "function",
|
|
168
|
+
str: (a) => typeof a === "string",
|
|
169
|
+
num: (a) => typeof a === "number",
|
|
170
|
+
boo: (a) => typeof a === "boolean",
|
|
171
|
+
und: (a) => a === void 0,
|
|
172
|
+
nul: (a) => a === null,
|
|
173
|
+
arr: (a) => Array.isArray(a),
|
|
174
|
+
equ(a, b, { arrays = "shallow", objects = "reference", strict = true } = {}) {
|
|
175
|
+
if (typeof a !== typeof b || !!a !== !!b) return false;
|
|
176
|
+
if (is.str(a) || is.num(a) || is.boo(a)) return a === b;
|
|
177
|
+
const isObj = is.obj(a);
|
|
178
|
+
if (isObj && objects === "reference") return a === b;
|
|
179
|
+
const isArr = is.arr(a);
|
|
180
|
+
if (isArr && arrays === "reference") return a === b;
|
|
181
|
+
if ((isArr || isObj) && a === b) return true;
|
|
182
|
+
let i;
|
|
183
|
+
for (i in a) if (!(i in b)) return false;
|
|
184
|
+
if (isObj && arrays === "shallow" && objects === "shallow") {
|
|
185
|
+
for (i in strict ? b : a) if (!is.equ(a[i], b[i], { strict, objects: "reference" })) return false;
|
|
186
|
+
} else {
|
|
187
|
+
for (i in strict ? b : a) if (a[i] !== b[i]) return false;
|
|
155
188
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
multiFile ? [files] : files,
|
|
161
|
-
(loader2) => {
|
|
162
|
-
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
163
|
-
loader2.setRenderer?.(renderer);
|
|
164
|
-
}
|
|
165
|
-
loader2.setPath?.(path);
|
|
166
|
-
if (extensions) extensions(loader2);
|
|
189
|
+
if (is.und(i)) {
|
|
190
|
+
if (isArr && a.length === 0 && b.length === 0) return true;
|
|
191
|
+
if (isObj && Object.keys(a).length === 0 && Object.keys(b).length === 0) return true;
|
|
192
|
+
if (a !== b) return false;
|
|
167
193
|
}
|
|
168
|
-
|
|
169
|
-
let texture = multiFile ? (
|
|
170
|
-
// @ts-ignore
|
|
171
|
-
loaderResult[0]
|
|
172
|
-
) : loaderResult;
|
|
173
|
-
if (extension === "jpg" || extension === "jpeg" || extension === "webp") {
|
|
174
|
-
texture = texture.renderTarget?.texture;
|
|
175
|
-
}
|
|
176
|
-
texture.mapping = isCubemap ? CubeReflectionMapping : EquirectangularReflectionMapping;
|
|
177
|
-
texture.colorSpace = colorSpace ?? (isCubemap ? "srgb" : "srgb-linear");
|
|
178
|
-
return texture;
|
|
179
|
-
}
|
|
180
|
-
const preloadDefaultOptions = {
|
|
181
|
-
files: defaultFiles,
|
|
182
|
-
path: "",
|
|
183
|
-
preset: void 0,
|
|
184
|
-
extensions: void 0
|
|
185
|
-
};
|
|
186
|
-
useEnvironment.preload = (preloadOptions) => {
|
|
187
|
-
const options = { ...preloadDefaultOptions, ...preloadOptions };
|
|
188
|
-
let { files, path = "" } = options;
|
|
189
|
-
const { preset, extensions } = options;
|
|
190
|
-
if (preset) {
|
|
191
|
-
validatePreset(preset);
|
|
192
|
-
files = presetsObj[preset];
|
|
193
|
-
path = CUBEMAP_ROOT;
|
|
194
|
-
}
|
|
195
|
-
const { extension } = getExtension(files);
|
|
196
|
-
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
197
|
-
throw new Error("useEnvironment: Preloading gainmaps is not supported");
|
|
198
|
-
}
|
|
199
|
-
const loader = getLoader$1(extension);
|
|
200
|
-
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
201
|
-
useLoader$1.preload(loader, isArray(files) ? [files] : files, (loader2) => {
|
|
202
|
-
loader2.setPath?.(path);
|
|
203
|
-
if (extensions) extensions(loader2);
|
|
204
|
-
});
|
|
205
|
-
};
|
|
206
|
-
const clearDefaultOptins = {
|
|
207
|
-
files: defaultFiles,
|
|
208
|
-
preset: void 0
|
|
209
|
-
};
|
|
210
|
-
useEnvironment.clear = (clearOptions) => {
|
|
211
|
-
const options = { ...clearDefaultOptins, ...clearOptions };
|
|
212
|
-
let { files } = options;
|
|
213
|
-
const { preset } = options;
|
|
214
|
-
if (preset) {
|
|
215
|
-
validatePreset(preset);
|
|
216
|
-
files = presetsObj[preset];
|
|
194
|
+
return true;
|
|
217
195
|
}
|
|
218
|
-
const { extension } = getExtension(files);
|
|
219
|
-
const loader = getLoader$1(extension);
|
|
220
|
-
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
221
|
-
useLoader$1.clear(loader, isArray(files) ? [files] : files);
|
|
222
196
|
};
|
|
223
|
-
|
|
224
|
-
|
|
197
|
+
const isOrthographicCamera = (def) => def && def.isOrthographicCamera;
|
|
198
|
+
const isRef$1 = (obj) => obj !== null && typeof obj === "object" && obj.hasOwnProperty("current");
|
|
199
|
+
const isColorRepresentation = (value) => value != null && (typeof value === "string" || typeof value === "number" || value.isColor);
|
|
200
|
+
const isObject3D = (object) => object?.isObject3D;
|
|
201
|
+
const isTexture = (value) => !!value?.isTexture;
|
|
202
|
+
const isVectorLike = (object) => object !== null && typeof object === "object" && "set" in object && typeof object.set === "function";
|
|
203
|
+
const isCopyable = (object) => isVectorLike(object) && "copy" in object && typeof object.copy === "function";
|
|
204
|
+
const hasConstructor = (object) => !!object?.constructor;
|
|
205
|
+
|
|
206
|
+
function calculateDpr(dpr) {
|
|
207
|
+
const target = typeof window !== "undefined" ? window.devicePixelRatio ?? 2 : 1;
|
|
208
|
+
return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
|
|
225
209
|
}
|
|
226
|
-
function
|
|
227
|
-
|
|
228
|
-
const isGainmap = isArray(files) && files.length === 3 && files.some((file) => file.endsWith("json"));
|
|
229
|
-
const firstEntry = isArray(files) ? files[0] : files;
|
|
230
|
-
const extension = isCubemap ? "cube" : isGainmap ? "webp" : firstEntry.startsWith("data:application/exr") ? "exr" : firstEntry.startsWith("data:application/hdr") ? "hdr" : firstEntry.startsWith("data:image/jpeg") ? "jpg" : firstEntry.split(".").pop()?.split("?")?.shift()?.toLowerCase();
|
|
231
|
-
return { extension, isCubemap, isGainmap };
|
|
210
|
+
function getUuidPrefix(uuid) {
|
|
211
|
+
return uuid.split("-")[0];
|
|
232
212
|
}
|
|
233
|
-
function
|
|
234
|
-
|
|
235
|
-
|
|
213
|
+
function updateCamera(camera, size) {
|
|
214
|
+
if (camera.manual) return;
|
|
215
|
+
if (isOrthographicCamera(camera)) {
|
|
216
|
+
camera.left = size.width / -2;
|
|
217
|
+
camera.right = size.width / 2;
|
|
218
|
+
camera.top = size.height / 2;
|
|
219
|
+
camera.bottom = size.height / -2;
|
|
220
|
+
} else {
|
|
221
|
+
camera.aspect = size.width / size.height;
|
|
222
|
+
}
|
|
223
|
+
camera.updateProjectionMatrix();
|
|
236
224
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
backgroundIntensity: 1,
|
|
244
|
-
backgroundRotation: [0, 0, 0],
|
|
245
|
-
environmentIntensity: 1,
|
|
246
|
-
environmentRotation: [0, 0, 0],
|
|
247
|
-
...sceneProps
|
|
248
|
-
};
|
|
249
|
-
const target = resolveScene(scene || defaultScene);
|
|
250
|
-
const oldbg = target.background;
|
|
251
|
-
const oldenv = target.environment;
|
|
252
|
-
const oldSceneProps = {
|
|
253
|
-
// @ts-ignore
|
|
254
|
-
backgroundBlurriness: target.backgroundBlurriness,
|
|
255
|
-
// @ts-ignore
|
|
256
|
-
backgroundIntensity: target.backgroundIntensity,
|
|
257
|
-
// @ts-ignore
|
|
258
|
-
backgroundRotation: target.backgroundRotation?.clone?.() ?? [0, 0, 0],
|
|
259
|
-
// @ts-ignore
|
|
260
|
-
environmentIntensity: target.environmentIntensity,
|
|
261
|
-
// @ts-ignore
|
|
262
|
-
environmentRotation: target.environmentRotation?.clone?.() ?? [0, 0, 0]
|
|
263
|
-
};
|
|
264
|
-
if (background !== "only") target.environment = texture;
|
|
265
|
-
if (background) target.background = texture;
|
|
266
|
-
applyProps$1(target, sceneProps);
|
|
267
|
-
return () => {
|
|
268
|
-
if (background !== "only") target.environment = oldenv;
|
|
269
|
-
if (background) target.background = oldbg;
|
|
270
|
-
applyProps$1(target, oldSceneProps);
|
|
271
|
-
};
|
|
225
|
+
const frustumMatrix = new Matrix4();
|
|
226
|
+
function updateFrustum(camera, frustum) {
|
|
227
|
+
const target = frustum ?? new Frustum();
|
|
228
|
+
frustumMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
229
|
+
target.setFromProjectionMatrix(frustumMatrix);
|
|
230
|
+
return target;
|
|
272
231
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
return
|
|
232
|
+
|
|
233
|
+
const REACT_INTERNAL_PROPS = ["children", "key", "ref"];
|
|
234
|
+
function findInitialRoot(instance) {
|
|
235
|
+
let root = instance.root;
|
|
236
|
+
while (root.getState().previousRoot) root = root.getState().previousRoot;
|
|
237
|
+
return root;
|
|
279
238
|
}
|
|
280
|
-
function
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
...rest
|
|
290
|
-
}) {
|
|
291
|
-
const texture = useEnvironment(rest);
|
|
292
|
-
const defaultScene = useThree$1((state) => state.scene);
|
|
293
|
-
React.useLayoutEffect(() => {
|
|
294
|
-
return setEnvProps(background, scene, defaultScene, texture, {
|
|
295
|
-
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
296
|
-
backgroundIntensity,
|
|
297
|
-
backgroundRotation,
|
|
298
|
-
environmentIntensity,
|
|
299
|
-
environmentRotation
|
|
239
|
+
function getRootState(obj) {
|
|
240
|
+
let state = obj.__r3f?.root.getState();
|
|
241
|
+
if (!state) {
|
|
242
|
+
obj.traverseAncestors((ancestor) => {
|
|
243
|
+
const parentState = ancestor.__r3f?.root.getState();
|
|
244
|
+
if (parentState) {
|
|
245
|
+
state = parentState;
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
300
248
|
});
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
return () => {
|
|
304
|
-
texture.dispose();
|
|
305
|
-
};
|
|
306
|
-
}, [texture]);
|
|
307
|
-
return null;
|
|
249
|
+
}
|
|
250
|
+
return state;
|
|
308
251
|
}
|
|
309
|
-
function
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
path,
|
|
326
|
-
preset = void 0,
|
|
327
|
-
extensions
|
|
328
|
-
}) {
|
|
329
|
-
const renderer = useThree$1((state) => state.renderer);
|
|
330
|
-
const isLegacy = useThree$1((state) => state.isLegacy);
|
|
331
|
-
const defaultScene = useThree$1((state) => state.scene);
|
|
332
|
-
const camera = React.useRef(null);
|
|
333
|
-
const [virtualScene] = React.useState(() => new Scene());
|
|
334
|
-
const fbo = React.useMemo(() => {
|
|
335
|
-
const fbo2 = isLegacy ? new WebGLCubeRenderTarget(resolution) : new CubeRenderTarget(resolution);
|
|
336
|
-
fbo2.texture.type = HalfFloatType;
|
|
337
|
-
return fbo2;
|
|
338
|
-
}, [resolution, isLegacy]);
|
|
339
|
-
React.useEffect(() => {
|
|
340
|
-
return () => {
|
|
341
|
-
fbo.dispose();
|
|
342
|
-
};
|
|
343
|
-
}, [fbo]);
|
|
344
|
-
React.useLayoutEffect(() => {
|
|
345
|
-
if (frames === 1) {
|
|
346
|
-
const autoClear = renderer.autoClear;
|
|
347
|
-
renderer.autoClear = true;
|
|
348
|
-
camera.current.update(renderer, virtualScene);
|
|
349
|
-
renderer.autoClear = autoClear;
|
|
350
|
-
}
|
|
351
|
-
return setEnvProps(background, scene, defaultScene, fbo.texture, {
|
|
352
|
-
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
353
|
-
backgroundIntensity,
|
|
354
|
-
backgroundRotation,
|
|
355
|
-
environmentIntensity,
|
|
356
|
-
environmentRotation
|
|
252
|
+
function buildGraph(object) {
|
|
253
|
+
const data = { nodes: {}, materials: {}, meshes: {} };
|
|
254
|
+
if (object) {
|
|
255
|
+
object.traverse((obj) => {
|
|
256
|
+
if (obj.name) data.nodes[obj.name] = obj;
|
|
257
|
+
if (obj.material) {
|
|
258
|
+
const material = Array.isArray(obj.material) ? obj.material[0] : obj.material;
|
|
259
|
+
const nameAlreadyUsed = data.materials[material.name];
|
|
260
|
+
let materialName = material.name;
|
|
261
|
+
if (nameAlreadyUsed) {
|
|
262
|
+
materialName = materialName + `-${getUuidPrefix(material.uuid)}`;
|
|
263
|
+
material.userData.materialCacheName = materialName;
|
|
264
|
+
}
|
|
265
|
+
data.materials[materialName] = material;
|
|
266
|
+
}
|
|
267
|
+
if (obj.isMesh && !data.meshes[obj.name]) data.meshes[obj.name] = obj;
|
|
357
268
|
});
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
virtualScene,
|
|
361
|
-
fbo.texture,
|
|
362
|
-
scene,
|
|
363
|
-
defaultScene,
|
|
364
|
-
background,
|
|
365
|
-
frames,
|
|
366
|
-
renderer,
|
|
367
|
-
blur,
|
|
368
|
-
backgroundBlurriness,
|
|
369
|
-
backgroundIntensity,
|
|
370
|
-
backgroundRotation,
|
|
371
|
-
environmentIntensity,
|
|
372
|
-
environmentRotation
|
|
373
|
-
]);
|
|
374
|
-
let count = 1;
|
|
375
|
-
useFrame$1(() => {
|
|
376
|
-
if (frames === Infinity || count < frames) {
|
|
377
|
-
const autoClear = renderer.autoClear;
|
|
378
|
-
renderer.autoClear = true;
|
|
379
|
-
camera.current.update(renderer, virtualScene);
|
|
380
|
-
renderer.autoClear = autoClear;
|
|
381
|
-
count++;
|
|
382
|
-
}
|
|
383
|
-
});
|
|
384
|
-
return /* @__PURE__ */ jsx(Fragment, { children: createPortal$1(
|
|
385
|
-
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
386
|
-
children,
|
|
387
|
-
/* @__PURE__ */ jsx("cubeCamera", { ref: camera, args: [near, far, fbo] }),
|
|
388
|
-
files || preset ? /* @__PURE__ */ jsx(EnvironmentCube, { background: true, files, preset, path, extensions }) : map ? /* @__PURE__ */ jsx(EnvironmentMap, { background: true, map, extensions }) : null
|
|
389
|
-
] }),
|
|
390
|
-
virtualScene
|
|
391
|
-
) });
|
|
269
|
+
}
|
|
270
|
+
return data;
|
|
392
271
|
}
|
|
393
|
-
function
|
|
394
|
-
|
|
395
|
-
const
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
textureDefault.dispose();
|
|
400
|
-
};
|
|
401
|
-
}, [textureDefault]);
|
|
402
|
-
const height = props.ground?.height ?? 15;
|
|
403
|
-
const radius = props.ground?.radius ?? 60;
|
|
404
|
-
const scale = props.ground?.scale ?? 1e3;
|
|
405
|
-
const args = React.useMemo(
|
|
406
|
-
() => [texture, height, radius],
|
|
407
|
-
[texture, height, radius]
|
|
408
|
-
);
|
|
409
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
410
|
-
/* @__PURE__ */ jsx(EnvironmentMap, { ...props, map: texture }),
|
|
411
|
-
/* @__PURE__ */ jsx("groundProjectedEnvImpl", { args, scale })
|
|
412
|
-
] });
|
|
272
|
+
function dispose(obj) {
|
|
273
|
+
if (obj.type !== "Scene") obj.dispose?.();
|
|
274
|
+
for (const p in obj) {
|
|
275
|
+
const prop = obj[p];
|
|
276
|
+
if (prop?.type !== "Scene") prop?.dispose?.();
|
|
277
|
+
}
|
|
413
278
|
}
|
|
414
|
-
function
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
if (
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
279
|
+
function getInstanceProps(pendingProps) {
|
|
280
|
+
const props = {};
|
|
281
|
+
for (const key in pendingProps) {
|
|
282
|
+
if (!REACT_INTERNAL_PROPS.includes(key)) props[key] = pendingProps[key];
|
|
283
|
+
}
|
|
284
|
+
return props;
|
|
285
|
+
}
|
|
286
|
+
function prepare(target, root, type, props) {
|
|
287
|
+
const object = target;
|
|
288
|
+
let instance = object?.__r3f;
|
|
289
|
+
if (!instance) {
|
|
290
|
+
instance = {
|
|
291
|
+
root,
|
|
292
|
+
type,
|
|
293
|
+
parent: null,
|
|
294
|
+
children: [],
|
|
295
|
+
props: getInstanceProps(props),
|
|
296
|
+
object,
|
|
297
|
+
eventCount: 0,
|
|
298
|
+
handlers: {},
|
|
299
|
+
isHidden: false
|
|
423
300
|
};
|
|
424
|
-
|
|
425
|
-
|
|
301
|
+
if (object) object.__r3f = instance;
|
|
302
|
+
}
|
|
303
|
+
return instance;
|
|
426
304
|
}
|
|
427
|
-
function
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
/* @__PURE__ */ jsx(EnvironmentCube, { ...props, files: backgroundFiles, background: "only" })
|
|
432
|
-
] });
|
|
305
|
+
function invalidateInstance(instance) {
|
|
306
|
+
if (!instance.parent) return;
|
|
307
|
+
const state = instance.root?.getState?.();
|
|
308
|
+
if (state && state.internal.frames === 0) state.invalidate();
|
|
433
309
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
310
|
+
|
|
311
|
+
const tempFrustum = new Frustum();
|
|
312
|
+
let hasWarnedWebGL = false;
|
|
313
|
+
let tslModule = null;
|
|
314
|
+
async function loadTSL() {
|
|
315
|
+
if (tslModule) return tslModule;
|
|
316
|
+
try {
|
|
317
|
+
const tsl = await import('three/tsl');
|
|
318
|
+
tslModule = { uniform: tsl.uniform, nodeObject: tsl.nodeObject };
|
|
319
|
+
return tslModule;
|
|
320
|
+
} catch {
|
|
321
|
+
return null;
|
|
440
322
|
}
|
|
441
|
-
return props.ground ? /* @__PURE__ */ jsx(EnvironmentGround, { ...props }) : props.map ? /* @__PURE__ */ jsx(EnvironmentMap, { ...props }) : props.children ? /* @__PURE__ */ jsx(EnvironmentPortal, { ...props }) : /* @__PURE__ */ jsx(EnvironmentCube, { ...props });
|
|
442
323
|
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
const
|
|
448
|
-
const
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
},
|
|
463
|
-
[fiber, ContextBridge]
|
|
464
|
-
);
|
|
465
|
-
}
|
|
466
|
-
function Block({ set }) {
|
|
467
|
-
useIsomorphicLayoutEffect(() => {
|
|
468
|
-
set(new Promise(() => null));
|
|
469
|
-
return () => set(false);
|
|
470
|
-
}, [set]);
|
|
471
|
-
return null;
|
|
472
|
-
}
|
|
473
|
-
const ErrorBoundary = /* @__PURE__ */ (() => {
|
|
474
|
-
var _a;
|
|
475
|
-
return _a = class extends React.Component {
|
|
476
|
-
constructor() {
|
|
477
|
-
super(...arguments);
|
|
478
|
-
__publicField$1(this, "state", { error: false });
|
|
479
|
-
}
|
|
480
|
-
componentDidCatch(err) {
|
|
481
|
-
this.props.set(err);
|
|
482
|
-
}
|
|
483
|
-
render() {
|
|
484
|
-
return this.state.error ? null : this.props.children;
|
|
485
|
-
}
|
|
486
|
-
}, __publicField$1(_a, "getDerivedStateFromError", () => ({ error: true })), _a;
|
|
487
|
-
})();
|
|
488
|
-
|
|
489
|
-
const is = {
|
|
490
|
-
obj: (a) => a === Object(a) && !is.arr(a) && typeof a !== "function",
|
|
491
|
-
fun: (a) => typeof a === "function",
|
|
492
|
-
str: (a) => typeof a === "string",
|
|
493
|
-
num: (a) => typeof a === "number",
|
|
494
|
-
boo: (a) => typeof a === "boolean",
|
|
495
|
-
und: (a) => a === void 0,
|
|
496
|
-
nul: (a) => a === null,
|
|
497
|
-
arr: (a) => Array.isArray(a),
|
|
498
|
-
equ(a, b, { arrays = "shallow", objects = "reference", strict = true } = {}) {
|
|
499
|
-
if (typeof a !== typeof b || !!a !== !!b) return false;
|
|
500
|
-
if (is.str(a) || is.num(a) || is.boo(a)) return a === b;
|
|
501
|
-
const isObj = is.obj(a);
|
|
502
|
-
if (isObj && objects === "reference") return a === b;
|
|
503
|
-
const isArr = is.arr(a);
|
|
504
|
-
if (isArr && arrays === "reference") return a === b;
|
|
505
|
-
if ((isArr || isObj) && a === b) return true;
|
|
506
|
-
let i;
|
|
507
|
-
for (i in a) if (!(i in b)) return false;
|
|
508
|
-
if (isObj && arrays === "shallow" && objects === "shallow") {
|
|
509
|
-
for (i in strict ? b : a) if (!is.equ(a[i], b[i], { strict, objects: "reference" })) return false;
|
|
510
|
-
} else {
|
|
511
|
-
for (i in strict ? b : a) if (a[i] !== b[i]) return false;
|
|
512
|
-
}
|
|
513
|
-
if (is.und(i)) {
|
|
514
|
-
if (isArr && a.length === 0 && b.length === 0) return true;
|
|
515
|
-
if (isObj && Object.keys(a).length === 0 && Object.keys(b).length === 0) return true;
|
|
516
|
-
if (a !== b) return false;
|
|
517
|
-
}
|
|
518
|
-
return true;
|
|
519
|
-
}
|
|
520
|
-
};
|
|
521
|
-
const isOrthographicCamera = (def) => def && def.isOrthographicCamera;
|
|
522
|
-
const isRef = (obj) => obj !== null && typeof obj === "object" && obj.hasOwnProperty("current");
|
|
523
|
-
const isColorRepresentation = (value) => value != null && (typeof value === "string" || typeof value === "number" || value.isColor);
|
|
524
|
-
const isObject3D = (object) => object?.isObject3D;
|
|
525
|
-
const isTexture = (value) => !!value?.isTexture;
|
|
526
|
-
const isVectorLike = (object) => object !== null && typeof object === "object" && "set" in object && typeof object.set === "function";
|
|
527
|
-
const isCopyable = (object) => isVectorLike(object) && "copy" in object && typeof object.copy === "function";
|
|
528
|
-
const hasConstructor = (object) => !!object?.constructor;
|
|
529
|
-
|
|
530
|
-
function calculateDpr(dpr) {
|
|
531
|
-
const target = typeof window !== "undefined" ? window.devicePixelRatio ?? 2 : 1;
|
|
532
|
-
return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
|
|
533
|
-
}
|
|
534
|
-
function getUuidPrefix(uuid) {
|
|
535
|
-
return uuid.split("-")[0];
|
|
536
|
-
}
|
|
537
|
-
function updateCamera(camera, size) {
|
|
538
|
-
if (camera.manual) return;
|
|
539
|
-
if (isOrthographicCamera(camera)) {
|
|
540
|
-
camera.left = size.width / -2;
|
|
541
|
-
camera.right = size.width / 2;
|
|
542
|
-
camera.top = size.height / 2;
|
|
543
|
-
camera.bottom = size.height / -2;
|
|
544
|
-
} else {
|
|
545
|
-
camera.aspect = size.width / size.height;
|
|
546
|
-
}
|
|
547
|
-
camera.updateProjectionMatrix();
|
|
548
|
-
}
|
|
549
|
-
const frustumMatrix = new Matrix4();
|
|
550
|
-
function updateFrustum(camera, frustum) {
|
|
551
|
-
const target = frustum ?? new Frustum();
|
|
552
|
-
frustumMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
553
|
-
target.setFromProjectionMatrix(frustumMatrix);
|
|
554
|
-
return target;
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
const REACT_INTERNAL_PROPS = ["children", "key", "ref"];
|
|
558
|
-
function findInitialRoot(instance) {
|
|
559
|
-
let root = instance.root;
|
|
560
|
-
while (root.getState().previousRoot) root = root.getState().previousRoot;
|
|
561
|
-
return root;
|
|
562
|
-
}
|
|
563
|
-
function getRootState(obj) {
|
|
564
|
-
let state = obj.__r3f?.root.getState();
|
|
565
|
-
if (!state) {
|
|
566
|
-
obj.traverseAncestors((ancestor) => {
|
|
567
|
-
const parentState = ancestor.__r3f?.root.getState();
|
|
568
|
-
if (parentState) {
|
|
569
|
-
state = parentState;
|
|
570
|
-
return false;
|
|
571
|
-
}
|
|
572
|
-
});
|
|
573
|
-
}
|
|
574
|
-
return state;
|
|
575
|
-
}
|
|
576
|
-
function buildGraph(object) {
|
|
577
|
-
const data = { nodes: {}, materials: {}, meshes: {} };
|
|
578
|
-
if (object) {
|
|
579
|
-
object.traverse((obj) => {
|
|
580
|
-
if (obj.name) data.nodes[obj.name] = obj;
|
|
581
|
-
if (obj.material) {
|
|
582
|
-
const material = Array.isArray(obj.material) ? obj.material[0] : obj.material;
|
|
583
|
-
const nameAlreadyUsed = data.materials[material.name];
|
|
584
|
-
let materialName = material.name;
|
|
585
|
-
if (nameAlreadyUsed) {
|
|
586
|
-
materialName = materialName + `-${getUuidPrefix(material.uuid)}`;
|
|
587
|
-
material.userData.materialCacheName = materialName;
|
|
588
|
-
}
|
|
589
|
-
data.materials[materialName] = material;
|
|
590
|
-
}
|
|
591
|
-
if (obj.isMesh && !data.meshes[obj.name]) data.meshes[obj.name] = obj;
|
|
592
|
-
});
|
|
593
|
-
}
|
|
594
|
-
return data;
|
|
595
|
-
}
|
|
596
|
-
function dispose(obj) {
|
|
597
|
-
if (obj.type !== "Scene") obj.dispose?.();
|
|
598
|
-
for (const p in obj) {
|
|
599
|
-
const prop = obj[p];
|
|
600
|
-
if (prop?.type !== "Scene") prop?.dispose?.();
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
function getInstanceProps(pendingProps) {
|
|
604
|
-
const props = {};
|
|
605
|
-
for (const key in pendingProps) {
|
|
606
|
-
if (!REACT_INTERNAL_PROPS.includes(key)) props[key] = pendingProps[key];
|
|
607
|
-
}
|
|
608
|
-
return props;
|
|
609
|
-
}
|
|
610
|
-
function prepare(target, root, type, props) {
|
|
611
|
-
const object = target;
|
|
612
|
-
let instance = object?.__r3f;
|
|
613
|
-
if (!instance) {
|
|
614
|
-
instance = {
|
|
615
|
-
root,
|
|
616
|
-
type,
|
|
617
|
-
parent: null,
|
|
618
|
-
children: [],
|
|
619
|
-
props: getInstanceProps(props),
|
|
620
|
-
object,
|
|
621
|
-
eventCount: 0,
|
|
622
|
-
handlers: {},
|
|
623
|
-
isHidden: false
|
|
624
|
-
};
|
|
625
|
-
if (object) object.__r3f = instance;
|
|
626
|
-
}
|
|
627
|
-
return instance;
|
|
628
|
-
}
|
|
629
|
-
function invalidateInstance(instance) {
|
|
630
|
-
if (!instance.parent) return;
|
|
631
|
-
instance.props.onUpdate?.(instance.object);
|
|
632
|
-
const state = instance.root?.getState?.();
|
|
633
|
-
if (state && state.internal.frames === 0) state.invalidate();
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
const tempFrustum = new Frustum();
|
|
637
|
-
let hasWarnedWebGL = false;
|
|
638
|
-
let tslModule = null;
|
|
639
|
-
async function loadTSL() {
|
|
640
|
-
if (tslModule) return tslModule;
|
|
641
|
-
try {
|
|
642
|
-
const tsl = await import('three/tsl');
|
|
643
|
-
tslModule = { uniform: tsl.uniform, nodeObject: tsl.nodeObject };
|
|
644
|
-
return tslModule;
|
|
645
|
-
} catch {
|
|
646
|
-
return null;
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
function createOcclusionObserverNode(store, uniform) {
|
|
650
|
-
const node = new Node("float");
|
|
651
|
-
node.updateType = NodeUpdateType.OBJECT;
|
|
652
|
-
node.update = function(frame) {
|
|
653
|
-
const { internal } = store.getState();
|
|
654
|
-
const registry = internal.visibilityRegistry;
|
|
655
|
-
const cache = internal.occlusionCache;
|
|
656
|
-
for (const entry of registry.values()) {
|
|
657
|
-
const { object, handlers } = entry;
|
|
658
|
-
if (handlers.onOccluded || handlers.onVisible) {
|
|
659
|
-
const isOccluded = frame.renderer.isOccluded(object);
|
|
660
|
-
cache.set(object, isOccluded);
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
};
|
|
664
|
-
node.setup = function() {
|
|
665
|
-
return uniform(0);
|
|
666
|
-
};
|
|
667
|
-
return node;
|
|
324
|
+
function createOcclusionObserverNode(store, uniform) {
|
|
325
|
+
const node = new Node("float");
|
|
326
|
+
node.updateType = NodeUpdateType.OBJECT;
|
|
327
|
+
node.update = function(frame) {
|
|
328
|
+
const { internal } = store.getState();
|
|
329
|
+
const registry = internal.visibilityRegistry;
|
|
330
|
+
const cache = internal.occlusionCache;
|
|
331
|
+
for (const entry of registry.values()) {
|
|
332
|
+
const { object, handlers } = entry;
|
|
333
|
+
if (handlers.onOccluded || handlers.onVisible) {
|
|
334
|
+
const isOccluded = frame.renderer.isOccluded(object);
|
|
335
|
+
cache.set(object, isOccluded);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
node.setup = function() {
|
|
340
|
+
return uniform(0);
|
|
341
|
+
};
|
|
342
|
+
return node;
|
|
668
343
|
}
|
|
669
344
|
let occlusionSetupPromise = null;
|
|
670
345
|
function enableOcclusion(store) {
|
|
@@ -844,8 +519,10 @@ function hasVisibilityHandlers(handlers) {
|
|
|
844
519
|
}
|
|
845
520
|
|
|
846
521
|
const FROM_REF = Symbol.for("@react-three/fiber.fromRef");
|
|
847
|
-
function fromRef(ref) {
|
|
848
|
-
|
|
522
|
+
function fromRef(ref, transform) {
|
|
523
|
+
const marker = { [FROM_REF]: ref };
|
|
524
|
+
if (transform) marker.transform = transform;
|
|
525
|
+
return marker;
|
|
849
526
|
}
|
|
850
527
|
function isFromRef(value) {
|
|
851
528
|
return value !== null && typeof value === "object" && FROM_REF in value;
|
|
@@ -859,56 +536,112 @@ function isOnce(value) {
|
|
|
859
536
|
return value !== null && typeof value === "object" && ONCE in value;
|
|
860
537
|
}
|
|
861
538
|
|
|
862
|
-
const
|
|
863
|
-
|
|
864
|
-
"
|
|
865
|
-
|
|
866
|
-
// Instance props
|
|
867
|
-
"args",
|
|
868
|
-
"dispose",
|
|
869
|
-
"attach",
|
|
870
|
-
"object",
|
|
871
|
-
"onUpdate",
|
|
872
|
-
// Behavior flags
|
|
873
|
-
"dispose"
|
|
874
|
-
];
|
|
875
|
-
const EVENT_REGEX = /^on(Pointer|Drag|Drop|Click|DoubleClick|ContextMenu|Wheel)/;
|
|
876
|
-
const VISIBILITY_EVENT_REGEX = /^on(Framed|Occluded|Visible)$/;
|
|
877
|
-
const INDEX_REGEX = /-\d+$/;
|
|
878
|
-
const MEMOIZED_PROTOTYPES = /* @__PURE__ */ new Map();
|
|
879
|
-
const colorMaps = ["map", "emissiveMap", "sheenColorMap", "specularColorMap", "envMap"];
|
|
880
|
-
function resolve(root, key) {
|
|
881
|
-
if (!key.includes("-")) return { root, key, target: root[key] };
|
|
882
|
-
if (key in root) return { root, key, target: root[key] };
|
|
883
|
-
const originalKey = key;
|
|
884
|
-
let target = root;
|
|
885
|
-
const parts = key.split("-");
|
|
886
|
-
for (const part of parts) {
|
|
887
|
-
if (typeof target !== "object" || target === null) {
|
|
888
|
-
if (target !== void 0) {
|
|
889
|
-
const remaining = parts.slice(parts.indexOf(part)).join("-");
|
|
890
|
-
return { root: target, key: remaining, target: void 0 };
|
|
891
|
-
}
|
|
892
|
-
return { root, key: originalKey, target: void 0 };
|
|
893
|
-
}
|
|
894
|
-
key = part;
|
|
895
|
-
root = target;
|
|
896
|
-
target = target[key];
|
|
539
|
+
const shownNotices = /* @__PURE__ */ new Set();
|
|
540
|
+
function notifyDepreciated({ heading, body, link }) {
|
|
541
|
+
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_DEPRECATION_WARNINGS !== "true") {
|
|
542
|
+
return;
|
|
897
543
|
}
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
if (
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
544
|
+
if (shownNotices.has(heading)) return;
|
|
545
|
+
shownNotices.add(heading);
|
|
546
|
+
const caller = getCallerFrame();
|
|
547
|
+
if (caller) {
|
|
548
|
+
console.log();
|
|
549
|
+
}
|
|
550
|
+
const boxStyle = "background: #ff9800; color: #1a1a1a; padding: 8px 12px; border-radius: 4px; font-weight: 500;";
|
|
551
|
+
if (caller) {
|
|
552
|
+
console.log(`%c\u26A0\uFE0F ${heading}`, boxStyle);
|
|
553
|
+
}
|
|
554
|
+
if (body || link) {
|
|
555
|
+
let message = "";
|
|
556
|
+
if (body) message += body;
|
|
557
|
+
if (link) message += (body ? "\n\n" : "") + `More info: ${link}`;
|
|
558
|
+
console.warn(`%c${message}`, "font-weight: bold;");
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
function getCallerFrame(depth = 3) {
|
|
562
|
+
const stack = new Error().stack;
|
|
563
|
+
if (!stack) return null;
|
|
564
|
+
const lines = stack.split("\n");
|
|
565
|
+
const frame = lines[depth];
|
|
566
|
+
if (!frame) return null;
|
|
567
|
+
let match = frame.match(/^\s*at (?:(.+?) )?\(?(.+?):(\d+):(\d+)\)?$/);
|
|
568
|
+
if (!match) {
|
|
569
|
+
match = frame.match(/^(?:(.+?)@)?(.+?):(\d+):(\d+)$/);
|
|
570
|
+
}
|
|
571
|
+
if (!match) return null;
|
|
572
|
+
const [, fn, url, line] = match;
|
|
573
|
+
return {
|
|
574
|
+
functionName: fn ?? "<anonymous>",
|
|
575
|
+
location: formatLocation(url, Number(line))
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
function formatLocation(url, line) {
|
|
579
|
+
const clean = url.split("?")[0];
|
|
580
|
+
const file = clean.split("/").pop() ?? clean;
|
|
581
|
+
return `${file}:${line}`;
|
|
582
|
+
}
|
|
583
|
+
function notifyAlpha({ message, link }) {
|
|
584
|
+
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_ALPHA_WARNINGS !== "true") {
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
if (shownNotices.has(message)) return;
|
|
588
|
+
shownNotices.add(message);
|
|
589
|
+
const boxStyle = "background: #6366f1; color: #ffffff; padding: 6px 10px; border-radius: 4px; font-weight: 500;";
|
|
590
|
+
console.log(`%c\u{1F52C} ${message}`, boxStyle);
|
|
591
|
+
{
|
|
592
|
+
console.log(`%cMore info: ${link}`, "color: #6366f1; font-weight: normal;");
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
const RESERVED_PROPS = [
|
|
597
|
+
"children",
|
|
598
|
+
"key",
|
|
599
|
+
"ref",
|
|
600
|
+
// Instance props
|
|
601
|
+
"args",
|
|
602
|
+
"dispose",
|
|
603
|
+
"attach",
|
|
604
|
+
"object",
|
|
605
|
+
// Behavior flags
|
|
606
|
+
"dispose"
|
|
607
|
+
];
|
|
608
|
+
const EVENT_REGEX = /^on(Pointer|Drag|Drop|Click|DoubleClick|ContextMenu|Wheel)/;
|
|
609
|
+
const VISIBILITY_EVENT_REGEX = /^on(Framed|Occluded|Visible)$/;
|
|
610
|
+
const INDEX_REGEX = /-\d+$/;
|
|
611
|
+
const MEMOIZED_PROTOTYPES = /* @__PURE__ */ new Map();
|
|
612
|
+
const colorMaps = ["map", "emissiveMap", "sheenColorMap", "specularColorMap", "envMap"];
|
|
613
|
+
function resolve(root, key) {
|
|
614
|
+
if (!key.includes("-")) return { root, key, target: root[key] };
|
|
615
|
+
if (key in root) return { root, key, target: root[key] };
|
|
616
|
+
const originalKey = key;
|
|
617
|
+
let target = root;
|
|
618
|
+
const parts = key.split("-");
|
|
619
|
+
for (const part of parts) {
|
|
620
|
+
if (typeof target !== "object" || target === null) {
|
|
621
|
+
if (target !== void 0) {
|
|
622
|
+
const remaining = parts.slice(parts.indexOf(part)).join("-");
|
|
623
|
+
return { root: target, key: remaining, target: void 0 };
|
|
624
|
+
}
|
|
625
|
+
return { root, key: originalKey, target: void 0 };
|
|
626
|
+
}
|
|
627
|
+
key = part;
|
|
628
|
+
root = target;
|
|
629
|
+
target = target[key];
|
|
630
|
+
}
|
|
631
|
+
return { root, key, target };
|
|
632
|
+
}
|
|
633
|
+
function attach(parent, child) {
|
|
634
|
+
if (is.str(child.props.attach)) {
|
|
635
|
+
if (INDEX_REGEX.test(child.props.attach)) {
|
|
636
|
+
const index = child.props.attach.replace(INDEX_REGEX, "");
|
|
637
|
+
const { root: root2, key: key2 } = resolve(parent.object, index);
|
|
638
|
+
if (!Array.isArray(root2[key2])) root2[key2] = [];
|
|
639
|
+
}
|
|
640
|
+
const { root, key } = resolve(parent.object, child.props.attach);
|
|
641
|
+
child.previousAttach = root[key];
|
|
642
|
+
root[key] = child.object;
|
|
643
|
+
} else if (is.fun(child.props.attach)) {
|
|
644
|
+
child.previousAttach = child.props.attach(parent.object, child.object);
|
|
912
645
|
}
|
|
913
646
|
}
|
|
914
647
|
function detach(parent, child) {
|
|
@@ -946,11 +679,9 @@ function diffProps(instance, newProps) {
|
|
|
946
679
|
for (const prop in instance.props) {
|
|
947
680
|
if (RESERVED_PROPS.includes(prop) || newProps.hasOwnProperty(prop)) continue;
|
|
948
681
|
const { root, key } = resolve(instance.object, prop);
|
|
949
|
-
if (
|
|
682
|
+
if (typeof root?.constructor === "function") {
|
|
950
683
|
const ctor = getMemoizedPrototype(root);
|
|
951
|
-
if (!is.und(ctor)) changedProps[
|
|
952
|
-
} else {
|
|
953
|
-
changedProps[key] = 0;
|
|
684
|
+
if (!is.und(ctor)) changedProps[prop] = ctor[key];
|
|
954
685
|
}
|
|
955
686
|
}
|
|
956
687
|
return changedProps;
|
|
@@ -962,6 +693,13 @@ function applyProps(object, props) {
|
|
|
962
693
|
for (const prop in props) {
|
|
963
694
|
const value = props[prop];
|
|
964
695
|
if (RESERVED_PROPS.includes(prop)) continue;
|
|
696
|
+
if (prop === "onUpdate") {
|
|
697
|
+
notifyDepreciated({
|
|
698
|
+
heading: "onUpdate is no longer an R3F prop",
|
|
699
|
+
body: "v10 removed the onUpdate hook: R3F no longer calls it after prop updates. The value is assigned to the object by name. On a Texture that sets three's Texture.onUpdate, which the renderer calls after a GPU upload, not after prop changes. On a node it replaces the Node.onUpdate() method. On other objects it is never called.\n\nUse an effect keyed on the props that change, read the object in useFrame, or use a ref callback.",
|
|
700
|
+
link: "https://docs.pmnd.rs/react-three-fiber/migration/v10#onupdate-removed"
|
|
701
|
+
});
|
|
702
|
+
}
|
|
965
703
|
if (instance && EVENT_REGEX.test(prop)) {
|
|
966
704
|
if (typeof value === "function") instance.handlers[prop] = value;
|
|
967
705
|
else delete instance.handlers[prop];
|
|
@@ -1067,635 +805,33 @@ function applyProps(object, props) {
|
|
|
1067
805
|
return object;
|
|
1068
806
|
}
|
|
1069
807
|
|
|
1070
|
-
const
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
state = {
|
|
1076
|
-
hovered: /* @__PURE__ */ new Map(),
|
|
1077
|
-
captured: /* @__PURE__ */ new Map(),
|
|
1078
|
-
initialClick: [0, 0],
|
|
1079
|
-
initialHits: []
|
|
1080
|
-
};
|
|
1081
|
-
internal.pointerMap.set(pointerId, state);
|
|
1082
|
-
}
|
|
1083
|
-
return state;
|
|
1084
|
-
}
|
|
1085
|
-
function getPointerId(event) {
|
|
1086
|
-
return "pointerId" in event ? event.pointerId : DEFAULT_POINTER_ID;
|
|
1087
|
-
}
|
|
1088
|
-
function makeId(event) {
|
|
1089
|
-
return (event.eventObject || event.object).uuid + "/" + event.index + event.instanceId;
|
|
1090
|
-
}
|
|
1091
|
-
function releaseInternalPointerCapture(internal, obj, pointerId) {
|
|
1092
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1093
|
-
if (!pointerState) return;
|
|
1094
|
-
const captureData = pointerState.captured.get(obj);
|
|
1095
|
-
if (captureData) {
|
|
1096
|
-
pointerState.captured.delete(obj);
|
|
1097
|
-
captureData.target.releasePointerCapture(pointerId);
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
function removeInteractivity(store, object) {
|
|
1101
|
-
const { internal } = store.getState();
|
|
1102
|
-
internal.interaction = internal.interaction.filter((o) => o !== object);
|
|
1103
|
-
for (const [pointerId, pointerState] of internal.pointerMap) {
|
|
1104
|
-
pointerState.initialHits = pointerState.initialHits.filter((o) => o !== object);
|
|
1105
|
-
pointerState.hovered.forEach((value, key) => {
|
|
1106
|
-
if (value.eventObject === object || value.object === object) {
|
|
1107
|
-
pointerState.hovered.delete(key);
|
|
1108
|
-
}
|
|
1109
|
-
});
|
|
1110
|
-
if (pointerState.captured.has(object)) {
|
|
1111
|
-
releaseInternalPointerCapture(internal, object, pointerId);
|
|
1112
|
-
}
|
|
1113
|
-
}
|
|
1114
|
-
unregisterVisibility(store, object);
|
|
808
|
+
const INTERNAL_LIB_MARKERS = ["zustand", "setState", "Object.assign"];
|
|
809
|
+
function isInternalRendererAccess(stack, callerDepth = 2) {
|
|
810
|
+
if (!stack) return false;
|
|
811
|
+
const caller = stack.split("\n")[callerDepth] ?? "";
|
|
812
|
+
return INTERNAL_LIB_MARKERS.some((m) => caller.includes(m));
|
|
1115
813
|
}
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
const
|
|
1122
|
-
const
|
|
1123
|
-
const
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
)
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
const duplicates = /* @__PURE__ */ new Set();
|
|
1138
|
-
const intersections = [];
|
|
1139
|
-
const eventsObjects = filter ? filter(state.internal.interaction) : state.internal.interaction;
|
|
1140
|
-
for (let i = 0; i < eventsObjects.length; i++) {
|
|
1141
|
-
const state2 = getRootState(eventsObjects[i]);
|
|
1142
|
-
if (state2) {
|
|
1143
|
-
state2.raycaster.camera = void 0;
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1146
|
-
if (!state.previousRoot) {
|
|
1147
|
-
state.events.compute?.(event, state);
|
|
1148
|
-
}
|
|
1149
|
-
function handleRaycast(obj) {
|
|
1150
|
-
const state2 = getRootState(obj);
|
|
1151
|
-
if (!state2 || !state2.events.enabled || state2.raycaster.camera === null) return [];
|
|
1152
|
-
if (state2.raycaster.camera === void 0) {
|
|
1153
|
-
state2.events.compute?.(event, state2, state2.previousRoot?.getState());
|
|
1154
|
-
if (state2.raycaster.camera === void 0) state2.raycaster.camera = null;
|
|
1155
|
-
}
|
|
1156
|
-
return state2.raycaster.camera ? state2.raycaster.intersectObject(obj, true) : [];
|
|
1157
|
-
}
|
|
1158
|
-
let hits = eventsObjects.flatMap(handleRaycast).sort((a, b) => {
|
|
1159
|
-
const aInteractivePriority = a.object.userData?.interactivePriority;
|
|
1160
|
-
const bInteractivePriority = b.object.userData?.interactivePriority;
|
|
1161
|
-
if (aInteractivePriority !== void 0 || bInteractivePriority !== void 0) {
|
|
1162
|
-
if (aInteractivePriority !== void 0 && bInteractivePriority === void 0) return -1;
|
|
1163
|
-
if (bInteractivePriority !== void 0 && aInteractivePriority === void 0) return 1;
|
|
1164
|
-
if (aInteractivePriority !== bInteractivePriority) {
|
|
1165
|
-
return (bInteractivePriority ?? 0) - (aInteractivePriority ?? 0);
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
const aState = getRootState(a.object);
|
|
1169
|
-
const bState = getRootState(b.object);
|
|
1170
|
-
const aPriority = aState?.events?.priority ?? 1;
|
|
1171
|
-
const bPriority = bState?.events?.priority ?? 1;
|
|
1172
|
-
return bPriority - aPriority || a.distance - b.distance;
|
|
1173
|
-
}).filter((item) => {
|
|
1174
|
-
const id = makeId(item);
|
|
1175
|
-
if (duplicates.has(id)) return false;
|
|
1176
|
-
duplicates.add(id);
|
|
1177
|
-
return true;
|
|
1178
|
-
});
|
|
1179
|
-
if (state.events.filter) hits = state.events.filter(hits, state);
|
|
1180
|
-
for (const hit of hits) {
|
|
1181
|
-
let eventObject = hit.object;
|
|
1182
|
-
while (eventObject) {
|
|
1183
|
-
if (eventObject.__r3f?.eventCount) {
|
|
1184
|
-
intersections.push({ ...hit, eventObject });
|
|
1185
|
-
}
|
|
1186
|
-
eventObject = eventObject.parent;
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
1189
|
-
if ("pointerId" in event) {
|
|
1190
|
-
const pointerId = event.pointerId;
|
|
1191
|
-
const pointerState = state.internal.pointerMap.get(pointerId);
|
|
1192
|
-
if (pointerState?.captured.size) {
|
|
1193
|
-
for (const captureData of pointerState.captured.values()) {
|
|
1194
|
-
if (!duplicates.has(makeId(captureData.intersection))) intersections.push(captureData.intersection);
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
return intersections;
|
|
1199
|
-
}
|
|
1200
|
-
function handleIntersects(intersections, event, delta, callback) {
|
|
1201
|
-
if (intersections.length) {
|
|
1202
|
-
const localState = { stopped: false };
|
|
1203
|
-
for (const hit of intersections) {
|
|
1204
|
-
const state = getRootState(hit.object);
|
|
1205
|
-
if (state) {
|
|
1206
|
-
const { raycaster, pointer, camera, internal } = state;
|
|
1207
|
-
const unprojectedPoint = new Vector3(pointer.x, pointer.y, 0).unproject(camera);
|
|
1208
|
-
const hasPointerCapture = (id) => {
|
|
1209
|
-
const pointerState = internal.pointerMap.get(id);
|
|
1210
|
-
return pointerState?.captured.has(hit.eventObject) ?? false;
|
|
1211
|
-
};
|
|
1212
|
-
const setPointerCapture = (id) => {
|
|
1213
|
-
const captureData = { intersection: hit, target: event.target };
|
|
1214
|
-
const pointerState = getPointerState(internal, id);
|
|
1215
|
-
pointerState.captured.set(hit.eventObject, captureData);
|
|
1216
|
-
event.target.setPointerCapture(id);
|
|
1217
|
-
};
|
|
1218
|
-
const releasePointerCapture = (id) => {
|
|
1219
|
-
releaseInternalPointerCapture(internal, hit.eventObject, id);
|
|
1220
|
-
};
|
|
1221
|
-
const extractEventProps = {};
|
|
1222
|
-
for (const prop in event) {
|
|
1223
|
-
const property = event[prop];
|
|
1224
|
-
if (typeof property !== "function") extractEventProps[prop] = property;
|
|
1225
|
-
}
|
|
1226
|
-
const eventPointerId = "pointerId" in event ? event.pointerId : void 0;
|
|
1227
|
-
const raycastEvent = {
|
|
1228
|
-
...hit,
|
|
1229
|
-
...extractEventProps,
|
|
1230
|
-
pointer,
|
|
1231
|
-
intersections,
|
|
1232
|
-
stopped: localState.stopped,
|
|
1233
|
-
delta,
|
|
1234
|
-
unprojectedPoint,
|
|
1235
|
-
ray: raycaster.ray,
|
|
1236
|
-
camera,
|
|
1237
|
-
pointerId: eventPointerId,
|
|
1238
|
-
// Hijack stopPropagation, which just sets a flag
|
|
1239
|
-
stopPropagation() {
|
|
1240
|
-
const pointerState = eventPointerId !== void 0 ? internal.pointerMap.get(eventPointerId) : void 0;
|
|
1241
|
-
if (
|
|
1242
|
-
// ...if this pointer hasn't been captured
|
|
1243
|
-
!pointerState?.captured.size || // ... or if the hit object is capturing the pointer
|
|
1244
|
-
pointerState.captured.has(hit.eventObject)
|
|
1245
|
-
) {
|
|
1246
|
-
raycastEvent.stopped = localState.stopped = true;
|
|
1247
|
-
if (pointerState?.hovered.size && Array.from(pointerState.hovered.values()).find((i) => i.eventObject === hit.eventObject)) {
|
|
1248
|
-
const higher = intersections.slice(0, intersections.indexOf(hit));
|
|
1249
|
-
cancelPointer([...higher, hit], eventPointerId);
|
|
1250
|
-
}
|
|
1251
|
-
}
|
|
1252
|
-
},
|
|
1253
|
-
// there should be a distinction between target and currentTarget
|
|
1254
|
-
target: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
1255
|
-
currentTarget: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
1256
|
-
nativeEvent: event
|
|
1257
|
-
};
|
|
1258
|
-
callback(raycastEvent);
|
|
1259
|
-
if (localState.stopped === true) break;
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
return intersections;
|
|
1264
|
-
}
|
|
1265
|
-
function cancelPointer(intersections, pointerId) {
|
|
1266
|
-
const { internal } = store.getState();
|
|
1267
|
-
const pid = pointerId ?? DEFAULT_POINTER_ID;
|
|
1268
|
-
const pointerState = internal.pointerMap.get(pid);
|
|
1269
|
-
if (!pointerState) return;
|
|
1270
|
-
for (const [hoveredId, hoveredObj] of pointerState.hovered) {
|
|
1271
|
-
if (!intersections.length || !intersections.find(
|
|
1272
|
-
(hit) => hit.object === hoveredObj.object && hit.index === hoveredObj.index && hit.instanceId === hoveredObj.instanceId
|
|
1273
|
-
)) {
|
|
1274
|
-
const eventObject = hoveredObj.eventObject;
|
|
1275
|
-
const instance = eventObject.__r3f;
|
|
1276
|
-
pointerState.hovered.delete(hoveredId);
|
|
1277
|
-
if (instance?.eventCount) {
|
|
1278
|
-
const handlers = instance.handlers;
|
|
1279
|
-
const data = { ...hoveredObj, intersections };
|
|
1280
|
-
handlers.onPointerOut?.(data);
|
|
1281
|
-
handlers.onPointerLeave?.(data);
|
|
1282
|
-
handlers.onDragOverLeave?.(data);
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1287
|
-
function pointerMissed(event, objects) {
|
|
1288
|
-
for (let i = 0; i < objects.length; i++) {
|
|
1289
|
-
const instance = objects[i].__r3f;
|
|
1290
|
-
instance?.handlers.onPointerMissed?.(event);
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
function dragOverMissed(event, objects) {
|
|
1294
|
-
for (let i = 0; i < objects.length; i++) {
|
|
1295
|
-
const instance = objects[i].__r3f;
|
|
1296
|
-
instance?.handlers.onDragOverMissed?.(event);
|
|
1297
|
-
}
|
|
1298
|
-
}
|
|
1299
|
-
function dropMissed(event, objects) {
|
|
1300
|
-
for (let i = 0; i < objects.length; i++) {
|
|
1301
|
-
const instance = objects[i].__r3f;
|
|
1302
|
-
instance?.handlers.onDropMissed?.(event);
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1305
|
-
function cleanupPointer(pointerId) {
|
|
1306
|
-
const { internal } = store.getState();
|
|
1307
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1308
|
-
if (pointerState) {
|
|
1309
|
-
for (const [, hoveredObj] of pointerState.hovered) {
|
|
1310
|
-
const eventObject = hoveredObj.eventObject;
|
|
1311
|
-
const instance = eventObject.__r3f;
|
|
1312
|
-
if (instance?.eventCount) {
|
|
1313
|
-
const handlers = instance.handlers;
|
|
1314
|
-
const data = { ...hoveredObj, intersections: [] };
|
|
1315
|
-
handlers.onPointerOut?.(data);
|
|
1316
|
-
handlers.onPointerLeave?.(data);
|
|
1317
|
-
}
|
|
1318
|
-
}
|
|
1319
|
-
internal.pointerMap.delete(pointerId);
|
|
1320
|
-
}
|
|
1321
|
-
internal.pointerDirty.delete(pointerId);
|
|
1322
|
-
}
|
|
1323
|
-
function processDeferredPointer(event, pointerId) {
|
|
1324
|
-
const state = store.getState();
|
|
1325
|
-
const { internal } = state;
|
|
1326
|
-
if (!state.events.enabled) return;
|
|
1327
|
-
const filter = filterPointerEvents;
|
|
1328
|
-
const hits = intersect(event, filter);
|
|
1329
|
-
cancelPointer(hits, pointerId);
|
|
1330
|
-
function onIntersect(data) {
|
|
1331
|
-
const eventObject = data.eventObject;
|
|
1332
|
-
const instance = eventObject.__r3f;
|
|
1333
|
-
if (!instance?.eventCount) return;
|
|
1334
|
-
const handlers = instance.handlers;
|
|
1335
|
-
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
1336
|
-
const id = makeId(data);
|
|
1337
|
-
const pointerState = getPointerState(internal, pointerId);
|
|
1338
|
-
const hoveredItem = pointerState.hovered.get(id);
|
|
1339
|
-
if (!hoveredItem) {
|
|
1340
|
-
pointerState.hovered.set(id, data);
|
|
1341
|
-
handlers.onPointerOver?.(data);
|
|
1342
|
-
handlers.onPointerEnter?.(data);
|
|
1343
|
-
} else if (hoveredItem.stopped) {
|
|
1344
|
-
data.stopPropagation();
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
|
-
handlers.onPointerMove?.(data);
|
|
1348
|
-
}
|
|
1349
|
-
handleIntersects(hits, event, 0, onIntersect);
|
|
1350
|
-
}
|
|
1351
|
-
function handlePointer(name) {
|
|
1352
|
-
switch (name) {
|
|
1353
|
-
case "onPointerLeave":
|
|
1354
|
-
case "onDragLeave":
|
|
1355
|
-
return () => cancelPointer([]);
|
|
1356
|
-
// Global cancel of these events
|
|
1357
|
-
case "onPointerCancel":
|
|
1358
|
-
return (event) => {
|
|
1359
|
-
const pointerId = getPointerId(event);
|
|
1360
|
-
cleanupPointer(pointerId);
|
|
1361
|
-
};
|
|
1362
|
-
case "onLostPointerCapture":
|
|
1363
|
-
return (event) => {
|
|
1364
|
-
const { internal } = store.getState();
|
|
1365
|
-
const pointerId = getPointerId(event);
|
|
1366
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1367
|
-
if (pointerState?.captured.size) {
|
|
1368
|
-
requestAnimationFrame(() => {
|
|
1369
|
-
const pointerState2 = internal.pointerMap.get(pointerId);
|
|
1370
|
-
if (pointerState2?.captured.size) {
|
|
1371
|
-
pointerState2.captured.clear();
|
|
1372
|
-
}
|
|
1373
|
-
cancelPointer([], pointerId);
|
|
1374
|
-
});
|
|
1375
|
-
}
|
|
1376
|
-
};
|
|
1377
|
-
}
|
|
1378
|
-
return function handleEvent(event) {
|
|
1379
|
-
const state = store.getState();
|
|
1380
|
-
const { onPointerMissed, onDragOverMissed, onDropMissed, internal, events } = state;
|
|
1381
|
-
const pointerId = getPointerId(event);
|
|
1382
|
-
internal.lastEvent.current = event;
|
|
1383
|
-
if (!events.enabled) return;
|
|
1384
|
-
const isPointerMove = name === "onPointerMove";
|
|
1385
|
-
const isDragOver = name === "onDragOver";
|
|
1386
|
-
const isDrop = name === "onDrop";
|
|
1387
|
-
const isClickEvent = name === "onClick" || name === "onContextMenu" || name === "onDoubleClick";
|
|
1388
|
-
const isPointerDown = name === "onPointerDown";
|
|
1389
|
-
const isPointerUp = name === "onPointerUp";
|
|
1390
|
-
const isWheel = name === "onWheel";
|
|
1391
|
-
const canDeferRaycasts = events.frameTimedRaycasts && state.frameloop === "always";
|
|
1392
|
-
if (isPointerMove && canDeferRaycasts) {
|
|
1393
|
-
events.compute?.(event, state);
|
|
1394
|
-
internal.pointerDirty.set(pointerId, event);
|
|
1395
|
-
return;
|
|
1396
|
-
}
|
|
1397
|
-
if (isWheel && canDeferRaycasts && !events.alwaysFireOnScroll) {
|
|
1398
|
-
events.compute?.(event, state);
|
|
1399
|
-
internal.pointerDirty.set(pointerId, event);
|
|
1400
|
-
return;
|
|
1401
|
-
}
|
|
1402
|
-
if ((isClickEvent || isPointerDown || isPointerUp) && internal.pointerDirty.has(pointerId)) {
|
|
1403
|
-
const deferredEvent = internal.pointerDirty.get(pointerId);
|
|
1404
|
-
internal.pointerDirty.delete(pointerId);
|
|
1405
|
-
processDeferredPointer(deferredEvent, pointerId);
|
|
1406
|
-
}
|
|
1407
|
-
const filter = isPointerMove || isDragOver || isDrop ? filterPointerEvents : void 0;
|
|
1408
|
-
const hits = intersect(event, filter);
|
|
1409
|
-
const delta = isClickEvent ? calculateDistance(event, pointerId) : 0;
|
|
1410
|
-
if (isPointerDown) {
|
|
1411
|
-
const pointerState2 = getPointerState(internal, pointerId);
|
|
1412
|
-
pointerState2.initialClick = [event.offsetX, event.offsetY];
|
|
1413
|
-
pointerState2.initialHits = hits.map((hit) => hit.eventObject);
|
|
1414
|
-
}
|
|
1415
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1416
|
-
const initialHits = pointerState?.initialHits ?? [];
|
|
1417
|
-
if (isClickEvent && !hits.length) {
|
|
1418
|
-
if (delta <= 2) {
|
|
1419
|
-
pointerMissed(event, internal.interaction);
|
|
1420
|
-
if (onPointerMissed) onPointerMissed(event);
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
|
-
if (isDragOver && !hits.length) {
|
|
1424
|
-
dragOverMissed(event, internal.interaction);
|
|
1425
|
-
if (onDragOverMissed) onDragOverMissed(event);
|
|
1426
|
-
}
|
|
1427
|
-
if (isDrop && !hits.length) {
|
|
1428
|
-
dropMissed(event, internal.interaction);
|
|
1429
|
-
if (onDropMissed) onDropMissed(event);
|
|
1430
|
-
}
|
|
1431
|
-
if (isPointerMove || isDragOver) {
|
|
1432
|
-
cancelPointer(hits, pointerId);
|
|
1433
|
-
}
|
|
1434
|
-
function onIntersect(data) {
|
|
1435
|
-
const eventObject = data.eventObject;
|
|
1436
|
-
const instance = eventObject.__r3f;
|
|
1437
|
-
if (!instance?.eventCount) return;
|
|
1438
|
-
const handlers = instance.handlers;
|
|
1439
|
-
if (isPointerMove) {
|
|
1440
|
-
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
1441
|
-
const id = makeId(data);
|
|
1442
|
-
const pointerState2 = getPointerState(internal, pointerId);
|
|
1443
|
-
const hoveredItem = pointerState2.hovered.get(id);
|
|
1444
|
-
if (!hoveredItem) {
|
|
1445
|
-
pointerState2.hovered.set(id, data);
|
|
1446
|
-
handlers.onPointerOver?.(data);
|
|
1447
|
-
handlers.onPointerEnter?.(data);
|
|
1448
|
-
} else if (hoveredItem.stopped) {
|
|
1449
|
-
data.stopPropagation();
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
handlers.onPointerMove?.(data);
|
|
1453
|
-
} else if (isDragOver) {
|
|
1454
|
-
const id = makeId(data);
|
|
1455
|
-
const pointerState2 = getPointerState(internal, pointerId);
|
|
1456
|
-
const hoveredItem = pointerState2.hovered.get(id);
|
|
1457
|
-
if (!hoveredItem) {
|
|
1458
|
-
pointerState2.hovered.set(id, data);
|
|
1459
|
-
handlers.onDragOverEnter?.(data);
|
|
1460
|
-
} else if (hoveredItem.stopped) {
|
|
1461
|
-
data.stopPropagation();
|
|
1462
|
-
}
|
|
1463
|
-
handlers.onDragOver?.(data);
|
|
1464
|
-
} else if (isDrop) {
|
|
1465
|
-
handlers.onDrop?.(data);
|
|
1466
|
-
} else {
|
|
1467
|
-
const handler = handlers[name];
|
|
1468
|
-
if (handler) {
|
|
1469
|
-
if (!isClickEvent || initialHits.includes(eventObject)) {
|
|
1470
|
-
pointerMissed(
|
|
1471
|
-
event,
|
|
1472
|
-
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
1473
|
-
);
|
|
1474
|
-
handler(data);
|
|
1475
|
-
}
|
|
1476
|
-
} else {
|
|
1477
|
-
if (isClickEvent && initialHits.includes(eventObject)) {
|
|
1478
|
-
pointerMissed(
|
|
1479
|
-
event,
|
|
1480
|
-
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
1481
|
-
);
|
|
1482
|
-
}
|
|
1483
|
-
}
|
|
1484
|
-
}
|
|
1485
|
-
}
|
|
1486
|
-
handleIntersects(hits, event, delta, onIntersect);
|
|
1487
|
-
};
|
|
1488
|
-
}
|
|
1489
|
-
function flushDeferredPointers() {
|
|
1490
|
-
const { internal, events } = store.getState();
|
|
1491
|
-
if (!events.frameTimedRaycasts) return;
|
|
1492
|
-
for (const [pointerId, event] of internal.pointerDirty) {
|
|
1493
|
-
processDeferredPointer(event, pointerId);
|
|
1494
|
-
}
|
|
1495
|
-
internal.pointerDirty.clear();
|
|
1496
|
-
}
|
|
1497
|
-
return { handlePointer, flushDeferredPointers, processDeferredPointer };
|
|
1498
|
-
}
|
|
1499
|
-
const DOM_EVENTS = {
|
|
1500
|
-
onClick: ["click", false],
|
|
1501
|
-
onContextMenu: ["contextmenu", false],
|
|
1502
|
-
onDoubleClick: ["dblclick", false],
|
|
1503
|
-
onDragEnter: ["dragenter", false],
|
|
1504
|
-
onDragLeave: ["dragleave", false],
|
|
1505
|
-
onDragOver: ["dragover", false],
|
|
1506
|
-
onDrop: ["drop", false],
|
|
1507
|
-
onWheel: ["wheel", true],
|
|
1508
|
-
onPointerDown: ["pointerdown", true],
|
|
1509
|
-
onPointerUp: ["pointerup", true],
|
|
1510
|
-
onPointerLeave: ["pointerleave", true],
|
|
1511
|
-
onPointerMove: ["pointermove", true],
|
|
1512
|
-
onPointerCancel: ["pointercancel", true],
|
|
1513
|
-
onLostPointerCapture: ["lostpointercapture", true]
|
|
1514
|
-
};
|
|
1515
|
-
function createPointerEvents(store) {
|
|
1516
|
-
const { handlePointer, flushDeferredPointers, processDeferredPointer } = createEvents(store);
|
|
1517
|
-
let nextXRPointerId = XR_POINTER_ID_START;
|
|
1518
|
-
const xrPointers = /* @__PURE__ */ new Map();
|
|
1519
|
-
return {
|
|
1520
|
-
priority: 1,
|
|
1521
|
-
enabled: true,
|
|
1522
|
-
frameTimedRaycasts: true,
|
|
1523
|
-
alwaysFireOnScroll: true,
|
|
1524
|
-
updateOnFrame: false,
|
|
1525
|
-
compute(event, state) {
|
|
1526
|
-
state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
|
|
1527
|
-
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
1528
|
-
},
|
|
1529
|
-
connected: void 0,
|
|
1530
|
-
handlers: Object.keys(DOM_EVENTS).reduce(
|
|
1531
|
-
(acc, key) => ({ ...acc, [key]: handlePointer(key) }),
|
|
1532
|
-
{}
|
|
1533
|
-
),
|
|
1534
|
-
update: (pointerId) => {
|
|
1535
|
-
const { events, internal } = store.getState();
|
|
1536
|
-
if (!events.handlers) return;
|
|
1537
|
-
if (pointerId !== void 0) {
|
|
1538
|
-
const event = internal.pointerDirty.get(pointerId);
|
|
1539
|
-
if (event) {
|
|
1540
|
-
internal.pointerDirty.delete(pointerId);
|
|
1541
|
-
processDeferredPointer(event, pointerId);
|
|
1542
|
-
} else if (internal.lastEvent?.current) {
|
|
1543
|
-
processDeferredPointer(internal.lastEvent.current, pointerId);
|
|
1544
|
-
}
|
|
1545
|
-
} else {
|
|
1546
|
-
flushDeferredPointers();
|
|
1547
|
-
if (internal.lastEvent?.current) {
|
|
1548
|
-
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
1549
|
-
}
|
|
1550
|
-
}
|
|
1551
|
-
},
|
|
1552
|
-
flush: () => {
|
|
1553
|
-
const { events, internal } = store.getState();
|
|
1554
|
-
flushDeferredPointers();
|
|
1555
|
-
if (events.updateOnFrame && internal.lastEvent?.current && events.handlers) {
|
|
1556
|
-
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
1557
|
-
}
|
|
1558
|
-
},
|
|
1559
|
-
connect: (target) => {
|
|
1560
|
-
if (!target) return;
|
|
1561
|
-
const { set, events } = store.getState();
|
|
1562
|
-
events.disconnect?.();
|
|
1563
|
-
set((state) => ({ events: { ...state.events, connected: target } }));
|
|
1564
|
-
if (events.handlers) {
|
|
1565
|
-
for (const name in events.handlers) {
|
|
1566
|
-
const event = events.handlers[name];
|
|
1567
|
-
const [eventName, passive] = DOM_EVENTS[name];
|
|
1568
|
-
target.addEventListener(eventName, event, { passive });
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1571
|
-
},
|
|
1572
|
-
disconnect: () => {
|
|
1573
|
-
const { set, events } = store.getState();
|
|
1574
|
-
if (events.connected) {
|
|
1575
|
-
if (events.handlers) {
|
|
1576
|
-
for (const name in events.handlers) {
|
|
1577
|
-
const event = events.handlers[name];
|
|
1578
|
-
const [eventName] = DOM_EVENTS[name];
|
|
1579
|
-
events.connected.removeEventListener(eventName, event);
|
|
1580
|
-
}
|
|
1581
|
-
}
|
|
1582
|
-
set((state) => ({ events: { ...state.events, connected: void 0 } }));
|
|
1583
|
-
}
|
|
1584
|
-
},
|
|
1585
|
-
// PREVIEW (A8): the XR pointer registration API may change before stable.
|
|
1586
|
-
registerPointer: (config) => {
|
|
1587
|
-
const pointerId = nextXRPointerId++;
|
|
1588
|
-
xrPointers.set(pointerId, config);
|
|
1589
|
-
const { internal } = store.getState();
|
|
1590
|
-
getPointerState(internal, pointerId);
|
|
1591
|
-
return pointerId;
|
|
1592
|
-
},
|
|
1593
|
-
unregisterPointer: (pointerId) => {
|
|
1594
|
-
xrPointers.delete(pointerId);
|
|
1595
|
-
const { internal } = store.getState();
|
|
1596
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1597
|
-
if (pointerState) {
|
|
1598
|
-
for (const [, hoveredObj] of pointerState.hovered) {
|
|
1599
|
-
const eventObject = hoveredObj.eventObject;
|
|
1600
|
-
const instance = eventObject.__r3f;
|
|
1601
|
-
if (instance?.eventCount) {
|
|
1602
|
-
const handlers = instance.handlers;
|
|
1603
|
-
const data = { ...hoveredObj, intersections: [] };
|
|
1604
|
-
handlers.onPointerOut?.(data);
|
|
1605
|
-
handlers.onPointerLeave?.(data);
|
|
1606
|
-
}
|
|
1607
|
-
}
|
|
1608
|
-
internal.pointerMap.delete(pointerId);
|
|
1609
|
-
}
|
|
1610
|
-
internal.pointerDirty.delete(pointerId);
|
|
1611
|
-
}
|
|
1612
|
-
};
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
|
-
const shownNotices = /* @__PURE__ */ new Set();
|
|
1616
|
-
function notifyDepreciated({ heading, body, link }) {
|
|
1617
|
-
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_DEPRECATION_WARNINGS !== "true") {
|
|
1618
|
-
return;
|
|
1619
|
-
}
|
|
1620
|
-
if (shownNotices.has(heading)) return;
|
|
1621
|
-
shownNotices.add(heading);
|
|
1622
|
-
const caller = getCallerFrame();
|
|
1623
|
-
if (caller) {
|
|
1624
|
-
console.log();
|
|
1625
|
-
}
|
|
1626
|
-
const boxStyle = "background: #ff9800; color: #1a1a1a; padding: 8px 12px; border-radius: 4px; font-weight: 500;";
|
|
1627
|
-
if (caller) {
|
|
1628
|
-
console.log(`%c\u26A0\uFE0F ${heading}`, boxStyle);
|
|
1629
|
-
}
|
|
1630
|
-
if (body || link) {
|
|
1631
|
-
let message = "";
|
|
1632
|
-
if (body) message += body;
|
|
1633
|
-
if (link) message += (body ? "\n\n" : "") + `More info: ${link}`;
|
|
1634
|
-
console.warn(`%c${message}`, "font-weight: bold;");
|
|
1635
|
-
}
|
|
1636
|
-
}
|
|
1637
|
-
function getCallerFrame(depth = 3) {
|
|
1638
|
-
const stack = new Error().stack;
|
|
1639
|
-
if (!stack) return null;
|
|
1640
|
-
const lines = stack.split("\n");
|
|
1641
|
-
const frame = lines[depth];
|
|
1642
|
-
if (!frame) return null;
|
|
1643
|
-
let match = frame.match(/^\s*at (?:(.+?) )?\(?(.+?):(\d+):(\d+)\)?$/);
|
|
1644
|
-
if (!match) {
|
|
1645
|
-
match = frame.match(/^(?:(.+?)@)?(.+?):(\d+):(\d+)$/);
|
|
1646
|
-
}
|
|
1647
|
-
if (!match) return null;
|
|
1648
|
-
const [, fn, url, line] = match;
|
|
1649
|
-
return {
|
|
1650
|
-
functionName: fn ?? "<anonymous>",
|
|
1651
|
-
location: formatLocation(url, Number(line))
|
|
1652
|
-
};
|
|
1653
|
-
}
|
|
1654
|
-
function formatLocation(url, line) {
|
|
1655
|
-
const clean = url.split("?")[0];
|
|
1656
|
-
const file = clean.split("/").pop() ?? clean;
|
|
1657
|
-
return `${file}:${line}`;
|
|
1658
|
-
}
|
|
1659
|
-
function notifyAlpha({ message, link }) {
|
|
1660
|
-
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_ALPHA_WARNINGS !== "true") {
|
|
1661
|
-
return;
|
|
1662
|
-
}
|
|
1663
|
-
if (shownNotices.has(message)) return;
|
|
1664
|
-
shownNotices.add(message);
|
|
1665
|
-
const boxStyle = "background: #6366f1; color: #ffffff; padding: 6px 10px; border-radius: 4px; font-weight: 500;";
|
|
1666
|
-
console.log(`%c\u{1F52C} ${message}`, boxStyle);
|
|
1667
|
-
{
|
|
1668
|
-
console.log(`%cMore info: ${link}`, "color: #6366f1; font-weight: normal;");
|
|
1669
|
-
}
|
|
1670
|
-
}
|
|
1671
|
-
|
|
1672
|
-
const INTERNAL_LIB_MARKERS = ["zustand", "setState", "Object.assign"];
|
|
1673
|
-
function isInternalRendererAccess(stack, callerDepth = 2) {
|
|
1674
|
-
if (!stack) return false;
|
|
1675
|
-
const caller = stack.split("\n")[callerDepth] ?? "";
|
|
1676
|
-
return INTERNAL_LIB_MARKERS.some((m) => caller.includes(m));
|
|
1677
|
-
}
|
|
1678
|
-
|
|
1679
|
-
const R3F_CONTEXT = Symbol.for("@react-three/fiber.context");
|
|
1680
|
-
const context = globalThis[R3F_CONTEXT] ?? (globalThis[R3F_CONTEXT] = React.createContext(null));
|
|
1681
|
-
const createStore = (invalidate, advance) => {
|
|
1682
|
-
const rootStore = createWithEqualityFn((set, get) => {
|
|
1683
|
-
const position = new Vector3();
|
|
1684
|
-
const defaultTarget = new Vector3();
|
|
1685
|
-
const tempTarget = new Vector3();
|
|
1686
|
-
function getCurrentViewport(camera = get().camera, target = defaultTarget, size = get().size) {
|
|
1687
|
-
const { width, height, top, left } = size;
|
|
1688
|
-
const aspect = width / height;
|
|
1689
|
-
if (target.isVector3) tempTarget.copy(target);
|
|
1690
|
-
else tempTarget.set(...target);
|
|
1691
|
-
const distance = camera.getWorldPosition(position).distanceTo(tempTarget);
|
|
1692
|
-
if (isOrthographicCamera(camera)) {
|
|
1693
|
-
return { width: width / camera.zoom, height: height / camera.zoom, top, left, factor: 1, distance, aspect };
|
|
1694
|
-
} else {
|
|
1695
|
-
const fov = camera.fov * Math.PI / 180;
|
|
1696
|
-
const h = 2 * Math.tan(fov / 2) * distance;
|
|
1697
|
-
const w = h * (width / height);
|
|
1698
|
-
return { width: w, height: h, top, left, factor: width / w, distance, aspect };
|
|
814
|
+
|
|
815
|
+
const R3F_CONTEXT = Symbol.for("@react-three/fiber.context");
|
|
816
|
+
const context = globalThis[R3F_CONTEXT] ?? (globalThis[R3F_CONTEXT] = React.createContext(null));
|
|
817
|
+
const createStore = (invalidate, advance) => {
|
|
818
|
+
const rootStore = createWithEqualityFn((set, get) => {
|
|
819
|
+
const position = new Vector3();
|
|
820
|
+
const defaultTarget = new Vector3();
|
|
821
|
+
const tempTarget = new Vector3();
|
|
822
|
+
function getCurrentViewport(camera = get().camera, target = defaultTarget, size = get().size) {
|
|
823
|
+
const { width, height, top, left } = size;
|
|
824
|
+
const aspect = width / height;
|
|
825
|
+
if (target.isVector3) tempTarget.copy(target);
|
|
826
|
+
else tempTarget.set(...target);
|
|
827
|
+
const distance = camera.getWorldPosition(position).distanceTo(tempTarget);
|
|
828
|
+
if (isOrthographicCamera(camera)) {
|
|
829
|
+
return { width: width / camera.zoom, height: height / camera.zoom, top, left, factor: 1, distance, aspect };
|
|
830
|
+
} else {
|
|
831
|
+
const fov = camera.fov * Math.PI / 180;
|
|
832
|
+
const h = 2 * Math.tan(fov / 2) * distance;
|
|
833
|
+
const w = h * (width / height);
|
|
834
|
+
return { width: w, height: h, top, left, factor: width / w, distance, aspect };
|
|
1699
835
|
}
|
|
1700
836
|
}
|
|
1701
837
|
let performanceTimeout = void 0;
|
|
@@ -1785,7 +921,7 @@ const createStore = (invalidate, advance) => {
|
|
|
1785
921
|
size: newSize,
|
|
1786
922
|
viewport: { ...s.viewport, ...getCurrentViewport(state2.camera, defaultTarget, newSize) }
|
|
1787
923
|
}));
|
|
1788
|
-
|
|
924
|
+
get().invalidate();
|
|
1789
925
|
}
|
|
1790
926
|
}
|
|
1791
927
|
return;
|
|
@@ -1800,15 +936,16 @@ const createStore = (invalidate, advance) => {
|
|
|
1800
936
|
viewport: { ...s.viewport, ...getCurrentViewport(state2.camera, defaultTarget, size) },
|
|
1801
937
|
_sizeImperative: true
|
|
1802
938
|
}));
|
|
1803
|
-
|
|
939
|
+
get().invalidate();
|
|
1804
940
|
},
|
|
1805
941
|
setDpr: (dpr) => set((state2) => {
|
|
1806
942
|
const resolved = calculateDpr(dpr);
|
|
1807
943
|
return { viewport: { ...state2.viewport, dpr: resolved, initialDpr: state2.viewport.initialDpr || resolved } };
|
|
1808
944
|
}),
|
|
1809
945
|
setFrameloop: (frameloop = "always") => {
|
|
946
|
+
const rootId = get().internal.rootId;
|
|
947
|
+
if (rootId) getScheduler().setRootFrameloop(rootId, frameloop);
|
|
1810
948
|
set(() => ({ frameloop }));
|
|
1811
|
-
getScheduler().frameloop = frameloop;
|
|
1812
949
|
},
|
|
1813
950
|
setError: (error) => set(() => ({ error })),
|
|
1814
951
|
error: null,
|
|
@@ -1924,17 +1061,11 @@ const createStore = (invalidate, advance) => {
|
|
|
1924
1061
|
oldSize = size;
|
|
1925
1062
|
oldDpr = viewport.dpr;
|
|
1926
1063
|
updateCamera(camera, size);
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
actualRenderer.setSize(size.width, size.height, false);
|
|
1933
|
-
if (canvasTarget) {
|
|
1934
|
-
if (viewport.dpr > 0) canvasTarget.setPixelRatio(viewport.dpr);
|
|
1935
|
-
canvasTarget.setSize(size.width, size.height, false);
|
|
1936
|
-
}
|
|
1937
|
-
}
|
|
1064
|
+
const resizeTarget = canvasTarget ?? actualRenderer;
|
|
1065
|
+
if (viewport.dpr > 0) resizeTarget.setPixelRatio(viewport.dpr);
|
|
1066
|
+
resizeTarget.setSize(size.width, size.height, false);
|
|
1067
|
+
const activeTarget = actualRenderer.getCanvasTarget?.();
|
|
1068
|
+
if (!canvasTarget || activeTarget !== canvasTarget) internal.canvasTargetSizeDirty = true;
|
|
1938
1069
|
}
|
|
1939
1070
|
if (camera !== oldCamera) {
|
|
1940
1071
|
oldCamera = camera;
|
|
@@ -1955,7 +1086,7 @@ const createStore = (invalidate, advance) => {
|
|
|
1955
1086
|
|
|
1956
1087
|
const memoizedLoaders = /* @__PURE__ */ new WeakMap();
|
|
1957
1088
|
const isConstructor$1 = (value) => typeof value === "function" && value?.prototype?.constructor === value;
|
|
1958
|
-
function getLoader(Proto) {
|
|
1089
|
+
function getLoader$1(Proto) {
|
|
1959
1090
|
if (isConstructor$1(Proto)) {
|
|
1960
1091
|
let loader = memoizedLoaders.get(Proto);
|
|
1961
1092
|
if (!loader) {
|
|
@@ -1968,7 +1099,7 @@ function getLoader(Proto) {
|
|
|
1968
1099
|
}
|
|
1969
1100
|
function loadingFn(extensions, onProgress) {
|
|
1970
1101
|
return function(Proto, input) {
|
|
1971
|
-
const loader = getLoader(Proto);
|
|
1102
|
+
const loader = getLoader$1(Proto);
|
|
1972
1103
|
if (extensions) extensions(loader);
|
|
1973
1104
|
if ("loadAsync" in loader && typeof loader.loadAsync === "function") {
|
|
1974
1105
|
return loader.loadAsync(input, onProgress).then((data) => {
|
|
@@ -1996,7 +1127,11 @@ function useLoader(loader, input, extensions, onProgress, cacheKey) {
|
|
|
1996
1127
|
const results = cacheKeys.map(
|
|
1997
1128
|
(key, index) => suspend(() => fn(loader, inputs[index]), [loader, key], { equal: is.equ })
|
|
1998
1129
|
);
|
|
1999
|
-
|
|
1130
|
+
const stableRef = useRef(null);
|
|
1131
|
+
const previous = stableRef.current;
|
|
1132
|
+
const stable = previous !== null && previous.length === results.length && previous.every((value, i) => value === results[i]) ? previous : results;
|
|
1133
|
+
stableRef.current = stable;
|
|
1134
|
+
return Array.isArray(input) ? stable : stable[0];
|
|
2000
1135
|
}
|
|
2001
1136
|
useLoader.preload = function(loader, input, extensions, onProgress, cacheKey) {
|
|
2002
1137
|
const inputs = Array.isArray(input) ? input : [input];
|
|
@@ -2009,9 +1144,9 @@ useLoader.clear = function(loader, input, cacheKey) {
|
|
|
2009
1144
|
const cacheKeys = Array.isArray(cacheKey ?? input) ? cacheKey ?? input : [cacheKey ?? input];
|
|
2010
1145
|
cacheKeys.forEach((key) => clear([loader, key]));
|
|
2011
1146
|
};
|
|
2012
|
-
useLoader.loader = getLoader;
|
|
1147
|
+
useLoader.loader = getLoader$1;
|
|
2013
1148
|
|
|
2014
|
-
function useFrame(callback, priorityOrOptions) {
|
|
1149
|
+
function useFrame$1(callback, priorityOrOptions) {
|
|
2015
1150
|
const store = React.useContext(context);
|
|
2016
1151
|
const isInsideCanvas = store !== null;
|
|
2017
1152
|
const scheduler = getScheduler();
|
|
@@ -2116,6 +1251,13 @@ function useFrame(callback, priorityOrOptions) {
|
|
|
2116
1251
|
* Use for controlling the entire frame loop, adding phases, etc.
|
|
2117
1252
|
*/
|
|
2118
1253
|
scheduler: scheduler2,
|
|
1254
|
+
/**
|
|
1255
|
+
* The root that currently owns this job. Resolve on access because ambient
|
|
1256
|
+
* jobs can be adopted by a Canvas after the controls object is created.
|
|
1257
|
+
*/
|
|
1258
|
+
get rootId() {
|
|
1259
|
+
return getScheduler().getJobRootId(id);
|
|
1260
|
+
},
|
|
2119
1261
|
/**
|
|
2120
1262
|
* Manually step this job only.
|
|
2121
1263
|
* Bypasses FPS limiting - always runs.
|
|
@@ -2132,6 +1274,14 @@ function useFrame(callback, priorityOrOptions) {
|
|
|
2132
1274
|
stepAll: (timestamp) => {
|
|
2133
1275
|
getScheduler().step(timestamp);
|
|
2134
1276
|
},
|
|
1277
|
+
/**
|
|
1278
|
+
* Request frames for this job's owning root without waking sibling roots.
|
|
1279
|
+
*/
|
|
1280
|
+
invalidate: (frames, stackFrames) => {
|
|
1281
|
+
const scheduler3 = getScheduler();
|
|
1282
|
+
const rootId = scheduler3.getJobRootId(id);
|
|
1283
|
+
if (rootId) scheduler3.invalidateRoot(rootId, frames, stackFrames);
|
|
1284
|
+
},
|
|
2135
1285
|
/**
|
|
2136
1286
|
* Pause this job (set enabled=false).
|
|
2137
1287
|
* Job remains registered but won't run.
|
|
@@ -2161,6 +1311,11 @@ function getUrls(input) {
|
|
|
2161
1311
|
if (Array.isArray(input)) return input;
|
|
2162
1312
|
return Object.values(input);
|
|
2163
1313
|
}
|
|
1314
|
+
function inputSignature(input) {
|
|
1315
|
+
if (typeof input === "string") return input;
|
|
1316
|
+
if (Array.isArray(input)) return input.join("\0");
|
|
1317
|
+
return Object.keys(input).sort().map((key) => `${key}\0${input[key]}`).join("");
|
|
1318
|
+
}
|
|
2164
1319
|
function allUrlsCached(urls, textureCache) {
|
|
2165
1320
|
return urls.every((url) => textureCache.has(url));
|
|
2166
1321
|
}
|
|
@@ -2179,31 +1334,44 @@ function buildFromCache(input, textureCache) {
|
|
|
2179
1334
|
}
|
|
2180
1335
|
}
|
|
2181
1336
|
function useTexture(input, optionsOrOnLoad) {
|
|
2182
|
-
const renderer = useThree((state) => state.internal.actualRenderer);
|
|
1337
|
+
const renderer = useThree$1((state) => state.internal.actualRenderer);
|
|
2183
1338
|
const store = useStore();
|
|
2184
1339
|
const options = typeof optionsOrOnLoad === "function" ? { onLoad: optionsOrOnLoad } : optionsOrOnLoad ?? {};
|
|
2185
1340
|
const { onLoad, cache = true } = options;
|
|
2186
1341
|
const onLoadRef = useRef(onLoad);
|
|
2187
1342
|
onLoadRef.current = onLoad;
|
|
2188
1343
|
const onLoadCalledForRef = useRef(null);
|
|
2189
|
-
const
|
|
1344
|
+
const inputKey = useMemo(() => inputSignature(input), [input]);
|
|
1345
|
+
const stableInput = useMemo(() => input, [inputKey]);
|
|
1346
|
+
const urls = useMemo(() => getUrls(stableInput), [stableInput]);
|
|
2190
1347
|
const cachedResult = useMemo(() => {
|
|
2191
1348
|
if (!cache) return null;
|
|
2192
1349
|
const textures = store.getState().textures;
|
|
2193
1350
|
if (!allUrlsCached(urls, textures)) return null;
|
|
2194
|
-
return buildFromCache(
|
|
2195
|
-
}, [cache, urls,
|
|
1351
|
+
return buildFromCache(stableInput, textures);
|
|
1352
|
+
}, [cache, urls, stableInput, store]);
|
|
2196
1353
|
const loadedTextures = useLoader(
|
|
2197
1354
|
TextureLoader,
|
|
2198
|
-
IsObject(
|
|
1355
|
+
IsObject(stableInput) ? Object.values(stableInput) : stableInput
|
|
2199
1356
|
);
|
|
2200
|
-
const
|
|
1357
|
+
const mappedTextures = useMemo(() => {
|
|
1358
|
+
if (cachedResult) return cachedResult;
|
|
1359
|
+
if (IsObject(stableInput)) {
|
|
1360
|
+
const keyed = {};
|
|
1361
|
+
const textureArray = loadedTextures;
|
|
1362
|
+
let i = 0;
|
|
1363
|
+
for (const key in stableInput) keyed[key] = textureArray[i++];
|
|
1364
|
+
return keyed;
|
|
1365
|
+
} else {
|
|
1366
|
+
return loadedTextures;
|
|
1367
|
+
}
|
|
1368
|
+
}, [stableInput, loadedTextures, cachedResult]);
|
|
2201
1369
|
useLayoutEffect(() => {
|
|
2202
1370
|
if (cachedResult) return;
|
|
2203
1371
|
if (onLoadCalledForRef.current === inputKey) return;
|
|
2204
1372
|
onLoadCalledForRef.current = inputKey;
|
|
2205
|
-
onLoadRef.current?.(
|
|
2206
|
-
}, [cachedResult,
|
|
1373
|
+
onLoadRef.current?.(mappedTextures);
|
|
1374
|
+
}, [cachedResult, mappedTextures, inputKey]);
|
|
2207
1375
|
useEffect(() => {
|
|
2208
1376
|
if (cachedResult) return;
|
|
2209
1377
|
if ("initTexture" in renderer) {
|
|
@@ -2222,30 +1390,18 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
2222
1390
|
});
|
|
2223
1391
|
}
|
|
2224
1392
|
}, [renderer, loadedTextures, cachedResult]);
|
|
2225
|
-
const mappedTextures = useMemo(() => {
|
|
2226
|
-
if (cachedResult) return cachedResult;
|
|
2227
|
-
if (IsObject(input)) {
|
|
2228
|
-
const keyed = {};
|
|
2229
|
-
const textureArray = loadedTextures;
|
|
2230
|
-
let i = 0;
|
|
2231
|
-
for (const key in input) keyed[key] = textureArray[i++];
|
|
2232
|
-
return keyed;
|
|
2233
|
-
} else {
|
|
2234
|
-
return loadedTextures;
|
|
2235
|
-
}
|
|
2236
|
-
}, [input, loadedTextures, cachedResult]);
|
|
2237
1393
|
useEffect(() => {
|
|
2238
1394
|
if (!cache) return;
|
|
2239
1395
|
const urlTextureMap = [];
|
|
2240
|
-
if (typeof
|
|
2241
|
-
urlTextureMap.push([
|
|
2242
|
-
} else if (Array.isArray(
|
|
1396
|
+
if (typeof stableInput === "string") {
|
|
1397
|
+
urlTextureMap.push([stableInput, mappedTextures]);
|
|
1398
|
+
} else if (Array.isArray(stableInput)) {
|
|
2243
1399
|
const textureArray = mappedTextures;
|
|
2244
|
-
|
|
2245
|
-
} else if (IsObject(
|
|
1400
|
+
stableInput.forEach((url, i) => urlTextureMap.push([url, textureArray[i]]));
|
|
1401
|
+
} else if (IsObject(stableInput)) {
|
|
2246
1402
|
const textureRecord = mappedTextures;
|
|
2247
|
-
for (const key in
|
|
2248
|
-
const url =
|
|
1403
|
+
for (const key in stableInput) {
|
|
1404
|
+
const url = stableInput[key];
|
|
2249
1405
|
urlTextureMap.push([url, textureRecord[key]]);
|
|
2250
1406
|
}
|
|
2251
1407
|
}
|
|
@@ -2274,7 +1430,7 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
2274
1430
|
}
|
|
2275
1431
|
return { _textureRefs: refs };
|
|
2276
1432
|
});
|
|
2277
|
-
}, [cache,
|
|
1433
|
+
}, [cache, stableInput, mappedTextures, store]);
|
|
2278
1434
|
return mappedTextures;
|
|
2279
1435
|
}
|
|
2280
1436
|
useTexture.preload = (url) => useLoader.preload(TextureLoader, url);
|
|
@@ -2345,13 +1501,13 @@ function useTextures(selector) {
|
|
|
2345
1501
|
};
|
|
2346
1502
|
}, [store]);
|
|
2347
1503
|
const subscribe = selector ? () => selector(registry) : (state) => state.textures;
|
|
2348
|
-
const selected = useThree(subscribe);
|
|
1504
|
+
const selected = useThree$1(subscribe);
|
|
2349
1505
|
return selector ? selected : registry;
|
|
2350
1506
|
}
|
|
2351
1507
|
|
|
2352
1508
|
function useRenderTarget(widthOrOptions, heightOrOptions, options) {
|
|
2353
|
-
const isLegacy = useThree((s) => s.isLegacy);
|
|
2354
|
-
const size = useThree((s) => s.size);
|
|
1509
|
+
const isLegacy = useThree$1((s) => s.isLegacy);
|
|
1510
|
+
const size = useThree$1((s) => s.size);
|
|
2355
1511
|
let width;
|
|
2356
1512
|
let height;
|
|
2357
1513
|
let opts;
|
|
@@ -2376,12 +1532,133 @@ function useRenderTarget(widthOrOptions, heightOrOptions, options) {
|
|
|
2376
1532
|
}, [width, height, size.width, size.height, opts, isLegacy]);
|
|
2377
1533
|
}
|
|
2378
1534
|
|
|
1535
|
+
const presetsObj = {
|
|
1536
|
+
apartment: "lebombo_1k.hdr",
|
|
1537
|
+
city: "potsdamer_platz_1k.hdr",
|
|
1538
|
+
dawn: "kiara_1_dawn_1k.hdr",
|
|
1539
|
+
forest: "forest_slope_1k.hdr",
|
|
1540
|
+
lobby: "st_fagans_interior_1k.hdr",
|
|
1541
|
+
night: "dikhololo_night_1k.hdr",
|
|
1542
|
+
park: "rooitou_park_1k.hdr",
|
|
1543
|
+
studio: "studio_small_03_1k.hdr",
|
|
1544
|
+
sunset: "venice_sunset_1k.hdr",
|
|
1545
|
+
warehouse: "empty_warehouse_01_1k.hdr"
|
|
1546
|
+
};
|
|
1547
|
+
|
|
1548
|
+
const CUBEMAP_ROOT = "https://raw.githack.com/pmndrs/drei-assets/456060a26bbeb8fdf79326f224b6d99b8bcce736/hdri/";
|
|
1549
|
+
const isArray = (arr) => Array.isArray(arr);
|
|
1550
|
+
const defaultFiles = ["/px.png", "/nx.png", "/py.png", "/ny.png", "/pz.png", "/nz.png"];
|
|
1551
|
+
function useEnvironment({
|
|
1552
|
+
files = defaultFiles,
|
|
1553
|
+
path = "",
|
|
1554
|
+
preset = void 0,
|
|
1555
|
+
colorSpace = void 0,
|
|
1556
|
+
extensions
|
|
1557
|
+
} = {}) {
|
|
1558
|
+
if (preset) {
|
|
1559
|
+
validatePreset(preset);
|
|
1560
|
+
files = presetsObj[preset];
|
|
1561
|
+
path = CUBEMAP_ROOT;
|
|
1562
|
+
}
|
|
1563
|
+
const multiFile = isArray(files);
|
|
1564
|
+
const { extension, isCubemap } = getExtension(files);
|
|
1565
|
+
const loader = getLoader(extension);
|
|
1566
|
+
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1567
|
+
const renderer = useThree$1((state) => state.renderer);
|
|
1568
|
+
useLayoutEffect(() => {
|
|
1569
|
+
if (extension !== "webp" && extension !== "jpg" && extension !== "jpeg") return;
|
|
1570
|
+
function clearGainmapTexture() {
|
|
1571
|
+
useLoader.clear(loader, multiFile ? [files] : files);
|
|
1572
|
+
}
|
|
1573
|
+
renderer.domElement.addEventListener("webglcontextlost", clearGainmapTexture, { once: true });
|
|
1574
|
+
}, [extension, files, loader, multiFile, renderer.domElement]);
|
|
1575
|
+
const loaderResult = useLoader(
|
|
1576
|
+
loader,
|
|
1577
|
+
multiFile ? [files] : files,
|
|
1578
|
+
(loader2) => {
|
|
1579
|
+
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
1580
|
+
loader2.setRenderer?.(renderer);
|
|
1581
|
+
}
|
|
1582
|
+
loader2.setPath?.(path);
|
|
1583
|
+
if (extensions) extensions(loader2);
|
|
1584
|
+
}
|
|
1585
|
+
);
|
|
1586
|
+
let texture = multiFile ? (
|
|
1587
|
+
// @ts-ignore
|
|
1588
|
+
loaderResult[0]
|
|
1589
|
+
) : loaderResult;
|
|
1590
|
+
if (extension === "jpg" || extension === "jpeg" || extension === "webp") {
|
|
1591
|
+
texture = texture.renderTarget?.texture;
|
|
1592
|
+
}
|
|
1593
|
+
texture.mapping = isCubemap ? CubeReflectionMapping : EquirectangularReflectionMapping;
|
|
1594
|
+
texture.colorSpace = colorSpace ?? (isCubemap && extension !== "hdr-cube" ? "srgb" : "srgb-linear");
|
|
1595
|
+
return texture;
|
|
1596
|
+
}
|
|
1597
|
+
const preloadDefaultOptions = {
|
|
1598
|
+
files: defaultFiles,
|
|
1599
|
+
path: "",
|
|
1600
|
+
preset: void 0,
|
|
1601
|
+
extensions: void 0
|
|
1602
|
+
};
|
|
1603
|
+
useEnvironment.preload = (preloadOptions) => {
|
|
1604
|
+
const options = { ...preloadDefaultOptions, ...preloadOptions };
|
|
1605
|
+
let { files, path = "" } = options;
|
|
1606
|
+
const { preset, extensions } = options;
|
|
1607
|
+
if (preset) {
|
|
1608
|
+
validatePreset(preset);
|
|
1609
|
+
files = presetsObj[preset];
|
|
1610
|
+
path = CUBEMAP_ROOT;
|
|
1611
|
+
}
|
|
1612
|
+
const { extension } = getExtension(files);
|
|
1613
|
+
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
1614
|
+
throw new Error("useEnvironment: Preloading gainmaps is not supported");
|
|
1615
|
+
}
|
|
1616
|
+
const loader = getLoader(extension);
|
|
1617
|
+
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1618
|
+
useLoader.preload(loader, isArray(files) ? [files] : files, (loader2) => {
|
|
1619
|
+
loader2.setPath?.(path);
|
|
1620
|
+
if (extensions) extensions(loader2);
|
|
1621
|
+
});
|
|
1622
|
+
};
|
|
1623
|
+
const clearDefaultOptins = {
|
|
1624
|
+
files: defaultFiles,
|
|
1625
|
+
preset: void 0
|
|
1626
|
+
};
|
|
1627
|
+
useEnvironment.clear = (clearOptions) => {
|
|
1628
|
+
const options = { ...clearDefaultOptins, ...clearOptions };
|
|
1629
|
+
let { files } = options;
|
|
1630
|
+
const { preset } = options;
|
|
1631
|
+
if (preset) {
|
|
1632
|
+
validatePreset(preset);
|
|
1633
|
+
files = presetsObj[preset];
|
|
1634
|
+
}
|
|
1635
|
+
const { extension } = getExtension(files);
|
|
1636
|
+
const loader = getLoader(extension);
|
|
1637
|
+
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1638
|
+
useLoader.clear(loader, isArray(files) ? [files] : files);
|
|
1639
|
+
};
|
|
1640
|
+
function validatePreset(preset) {
|
|
1641
|
+
if (!(preset in presetsObj)) throw new Error("Preset must be one of: " + Object.keys(presetsObj).join(", "));
|
|
1642
|
+
}
|
|
1643
|
+
function getExtension(files) {
|
|
1644
|
+
const isCubemap = isArray(files) && files.length === 6;
|
|
1645
|
+
const isGainmap = isArray(files) && files.length === 3 && files.some((file) => file.endsWith("json"));
|
|
1646
|
+
const firstEntry = isArray(files) ? files[0] : files;
|
|
1647
|
+
const firstExtension = firstEntry.split(".").pop()?.split("?")?.shift()?.toLowerCase();
|
|
1648
|
+
const extension = isCubemap ? firstExtension === "hdr" ? "hdr-cube" : "cube" : isGainmap ? "webp" : firstEntry.startsWith("data:application/exr") ? "exr" : firstEntry.startsWith("data:application/hdr") ? "hdr" : firstEntry.startsWith("data:image/jpeg") ? "jpg" : firstExtension;
|
|
1649
|
+
return { extension, isCubemap, isGainmap };
|
|
1650
|
+
}
|
|
1651
|
+
function getLoader(extension) {
|
|
1652
|
+
const loader = extension === "cube" ? CubeTextureLoader : extension === "hdr-cube" ? HDRCubeTextureLoader : extension === "hdr" ? HDRLoader : extension === "exr" ? EXRLoader : extension === "jpg" || extension === "jpeg" ? UltraHDRLoader : extension === "webp" ? GainMapLoader : null;
|
|
1653
|
+
return loader;
|
|
1654
|
+
}
|
|
1655
|
+
|
|
2379
1656
|
function useStore() {
|
|
2380
1657
|
const store = useContext(context);
|
|
2381
1658
|
if (!store) throw new Error("R3F: Hooks can only be used within the Canvas component!");
|
|
2382
1659
|
return store;
|
|
2383
1660
|
}
|
|
2384
|
-
function useThree(selector = (state) => state, equalityFn) {
|
|
1661
|
+
function useThree$1(selector = (state) => state, equalityFn) {
|
|
2385
1662
|
return useStore()(selector, equalityFn);
|
|
2386
1663
|
}
|
|
2387
1664
|
function useInstanceHandle(ref) {
|
|
@@ -2393,6 +1670,8 @@ function useGraph(object) {
|
|
|
2393
1670
|
return useMemo(() => buildGraph(object), [object]);
|
|
2394
1671
|
}
|
|
2395
1672
|
|
|
1673
|
+
const t = 1, o = 8, r = 32, e = 2, i$1 = 268435456;
|
|
1674
|
+
|
|
2396
1675
|
let effectId = 0;
|
|
2397
1676
|
function addEffect(callback) {
|
|
2398
1677
|
notifyDepreciated({
|
|
@@ -2421,22 +1700,28 @@ function addTail(callback) {
|
|
|
2421
1700
|
return getScheduler().onIdle(callback);
|
|
2422
1701
|
}
|
|
2423
1702
|
function invalidate(state, frames = 1, stackFrames = false) {
|
|
2424
|
-
|
|
1703
|
+
const rootId = state?.internal?.rootId;
|
|
1704
|
+
const scheduler = getScheduler();
|
|
1705
|
+
if (rootId) scheduler.invalidateRoot(rootId, frames, stackFrames);
|
|
1706
|
+
else scheduler.invalidate(frames, stackFrames);
|
|
2425
1707
|
}
|
|
2426
|
-
function advance(timestamp) {
|
|
2427
|
-
|
|
1708
|
+
function advance(timestamp, runGlobalEffects, state) {
|
|
1709
|
+
const rootId = state?.internal?.rootId;
|
|
1710
|
+
const scheduler = getScheduler();
|
|
1711
|
+
if (rootId) scheduler.stepRoot(rootId, timestamp);
|
|
1712
|
+
else scheduler.step(timestamp);
|
|
2428
1713
|
}
|
|
2429
1714
|
|
|
2430
|
-
const version = "10.0.0-alpha.
|
|
1715
|
+
const version = "10.0.0-alpha.5";
|
|
2431
1716
|
const packageData = {
|
|
2432
1717
|
version: version};
|
|
2433
1718
|
|
|
2434
1719
|
function Xb(Tt) {
|
|
2435
1720
|
return Tt && Tt.__esModule && Object.prototype.hasOwnProperty.call(Tt, "default") ? Tt.default : Tt;
|
|
2436
1721
|
}
|
|
2437
|
-
var Rm = { exports: {} }, Og = { exports: {} }, _b;
|
|
1722
|
+
var Rm = { exports: {} }, Og = { exports: {} }, _b$1;
|
|
2438
1723
|
function Kb() {
|
|
2439
|
-
return _b || (_b = 1, (function(Tt) {
|
|
1724
|
+
return _b$1 || (_b$1 = 1, (function(Tt) {
|
|
2440
1725
|
Tt.exports = function(m) {
|
|
2441
1726
|
function Yn(t, r, a, l) {
|
|
2442
1727
|
return new uc(t, r, a, l);
|
|
@@ -13291,399 +12576,982 @@ Check the top-level render call using <` + i + ">.");
|
|
|
13291
12576
|
var o = x.H;
|
|
13292
12577
|
x.H = $o;
|
|
13293
12578
|
try {
|
|
13294
|
-
return Vi(e, n);
|
|
12579
|
+
return Vi(e, n);
|
|
12580
|
+
} finally {
|
|
12581
|
+
x.H = o;
|
|
12582
|
+
}
|
|
12583
|
+
}, useReducer: function(e, n, o) {
|
|
12584
|
+
z = "useReducer", D(), N();
|
|
12585
|
+
var i = x.H;
|
|
12586
|
+
x.H = $o;
|
|
12587
|
+
try {
|
|
12588
|
+
return Br(e, n, o);
|
|
12589
|
+
} finally {
|
|
12590
|
+
x.H = i;
|
|
12591
|
+
}
|
|
12592
|
+
}, useRef: function() {
|
|
12593
|
+
return z = "useRef", D(), N(), xe().memoizedState;
|
|
12594
|
+
}, useState: function() {
|
|
12595
|
+
z = "useState", D(), N();
|
|
12596
|
+
var e = x.H;
|
|
12597
|
+
x.H = $o;
|
|
12598
|
+
try {
|
|
12599
|
+
return Br(gr);
|
|
12600
|
+
} finally {
|
|
12601
|
+
x.H = e;
|
|
12602
|
+
}
|
|
12603
|
+
}, useDebugValue: function() {
|
|
12604
|
+
z = "useDebugValue", D(), N();
|
|
12605
|
+
}, useDeferredValue: function(e, n) {
|
|
12606
|
+
return z = "useDeferredValue", D(), N(), nc(e, n);
|
|
12607
|
+
}, useTransition: function() {
|
|
12608
|
+
return z = "useTransition", D(), N(), Qp();
|
|
12609
|
+
}, useSyncExternalStore: function(e, n, o) {
|
|
12610
|
+
return z = "useSyncExternalStore", D(), N(), ta(e, n, o);
|
|
12611
|
+
}, useId: function() {
|
|
12612
|
+
return z = "useId", D(), N(), xe().memoizedState;
|
|
12613
|
+
}, useFormState: function(e) {
|
|
12614
|
+
return z = "useFormState", D(), N(), hs(e);
|
|
12615
|
+
}, useActionState: function(e) {
|
|
12616
|
+
return z = "useActionState", D(), N(), hs(e);
|
|
12617
|
+
}, useOptimistic: function(e, n) {
|
|
12618
|
+
return z = "useOptimistic", D(), N(), rf(e, n);
|
|
12619
|
+
}, useMemoCache: function(e) {
|
|
12620
|
+
return D(), Oa(e);
|
|
12621
|
+
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
12622
|
+
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
12623
|
+
}, useEffectEvent: function(e) {
|
|
12624
|
+
return z = "useEffectEvent", D(), N(), oa(e);
|
|
12625
|
+
} }, dm = { readContext: function(e) {
|
|
12626
|
+
return Ce(), Ee(e);
|
|
12627
|
+
}, use: function(e) {
|
|
12628
|
+
return D(), we(e);
|
|
12629
|
+
}, useCallback: function(e, n) {
|
|
12630
|
+
return z = "useCallback", D(), N(), Ma(e, n);
|
|
12631
|
+
}, useContext: function(e) {
|
|
12632
|
+
return z = "useContext", D(), N(), Ee(e);
|
|
12633
|
+
}, useEffect: function(e, n) {
|
|
12634
|
+
z = "useEffect", D(), N(), Qn(2048, Ut, e, n);
|
|
12635
|
+
}, useImperativeHandle: function(e, n, o) {
|
|
12636
|
+
return z = "useImperativeHandle", D(), N(), aa(e, n, o);
|
|
12637
|
+
}, useInsertionEffect: function(e, n) {
|
|
12638
|
+
return z = "useInsertionEffect", D(), N(), Qn(4, Wt, e, n);
|
|
12639
|
+
}, useLayoutEffect: function(e, n) {
|
|
12640
|
+
return z = "useLayoutEffect", D(), N(), Qn(4, Rr, e, n);
|
|
12641
|
+
}, useMemo: function(e, n) {
|
|
12642
|
+
z = "useMemo", D(), N();
|
|
12643
|
+
var o = x.H;
|
|
12644
|
+
x.H = $o;
|
|
12645
|
+
try {
|
|
12646
|
+
return Vi(e, n);
|
|
12647
|
+
} finally {
|
|
12648
|
+
x.H = o;
|
|
12649
|
+
}
|
|
12650
|
+
}, useReducer: function(e, n, o) {
|
|
12651
|
+
z = "useReducer", D(), N();
|
|
12652
|
+
var i = x.H;
|
|
12653
|
+
x.H = $o;
|
|
12654
|
+
try {
|
|
12655
|
+
return Qi(e, n, o);
|
|
12656
|
+
} finally {
|
|
12657
|
+
x.H = i;
|
|
12658
|
+
}
|
|
12659
|
+
}, useRef: function() {
|
|
12660
|
+
return z = "useRef", D(), N(), xe().memoizedState;
|
|
12661
|
+
}, useState: function() {
|
|
12662
|
+
z = "useState", D(), N();
|
|
12663
|
+
var e = x.H;
|
|
12664
|
+
x.H = $o;
|
|
12665
|
+
try {
|
|
12666
|
+
return Qi(gr);
|
|
12667
|
+
} finally {
|
|
12668
|
+
x.H = e;
|
|
12669
|
+
}
|
|
12670
|
+
}, useDebugValue: function() {
|
|
12671
|
+
z = "useDebugValue", D(), N();
|
|
12672
|
+
}, useDeferredValue: function(e, n) {
|
|
12673
|
+
return z = "useDeferredValue", D(), N(), sf(e, n);
|
|
12674
|
+
}, useTransition: function() {
|
|
12675
|
+
return z = "useTransition", D(), N(), Ro();
|
|
12676
|
+
}, useSyncExternalStore: function(e, n, o) {
|
|
12677
|
+
return z = "useSyncExternalStore", D(), N(), ta(e, n, o);
|
|
12678
|
+
}, useId: function() {
|
|
12679
|
+
return z = "useId", D(), N(), xe().memoizedState;
|
|
12680
|
+
}, useFormState: function(e) {
|
|
12681
|
+
return z = "useFormState", D(), N(), $t(e);
|
|
12682
|
+
}, useActionState: function(e) {
|
|
12683
|
+
return z = "useActionState", D(), N(), $t(e);
|
|
12684
|
+
}, useOptimistic: function(e, n) {
|
|
12685
|
+
return z = "useOptimistic", D(), N(), of(e, n);
|
|
12686
|
+
}, useMemoCache: function(e) {
|
|
12687
|
+
return D(), Oa(e);
|
|
12688
|
+
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
12689
|
+
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
12690
|
+
}, useEffectEvent: function(e) {
|
|
12691
|
+
return z = "useEffectEvent", D(), N(), oa(e);
|
|
12692
|
+
} };
|
|
12693
|
+
var Fy = {}, Hy = /* @__PURE__ */ new Set(), Ay = /* @__PURE__ */ new Set(), jy = /* @__PURE__ */ new Set(), Dy = /* @__PURE__ */ new Set(), Wy = /* @__PURE__ */ new Set(), Uy = /* @__PURE__ */ new Set(), By = /* @__PURE__ */ new Set(), Oy = /* @__PURE__ */ new Set(), My = /* @__PURE__ */ new Set(), Qy = /* @__PURE__ */ new Set();
|
|
12694
|
+
Object.freeze(Fy);
|
|
12695
|
+
var zg = { enqueueSetState: function(e, n, o) {
|
|
12696
|
+
e = e._reactInternals;
|
|
12697
|
+
var i = Nt(e), s = zo(i);
|
|
12698
|
+
s.payload = n, o != null && (df(o), s.callback = o), n = Mt(e, s, i), n !== null && (ur(i, "this.setState()", e), We(n, e, i), Bi(n, e, i));
|
|
12699
|
+
}, enqueueReplaceState: function(e, n, o) {
|
|
12700
|
+
e = e._reactInternals;
|
|
12701
|
+
var i = Nt(e), s = zo(i);
|
|
12702
|
+
s.tag = Cy, s.payload = n, o != null && (df(o), s.callback = o), n = Mt(e, s, i), n !== null && (ur(i, "this.replaceState()", e), We(n, e, i), Bi(n, e, i));
|
|
12703
|
+
}, enqueueForceUpdate: function(e, n) {
|
|
12704
|
+
e = e._reactInternals;
|
|
12705
|
+
var o = Nt(e), i = zo(o);
|
|
12706
|
+
i.tag = Ty, n != null && (df(n), i.callback = n), n = Mt(e, i, o), n !== null && (ur(o, "this.forceUpdate()", e), We(n, e, o), Bi(n, e, o));
|
|
12707
|
+
} }, bd = null, Cg = null, Tg = Error("This is not a real error. It's an implementation detail of React's selective hydration feature. If this leaks into userspace, it's a bug in React. Please file an issue."), Cn = false, $y = {}, Vy = {}, qy = {}, Gy = {}, vd = false, Jy = {}, fm = {}, _g = { dehydrated: null, treeContext: null, retryLane: 0, hydrationErrors: null }, Zy = false, Yy = null;
|
|
12708
|
+
Yy = /* @__PURE__ */ new Set();
|
|
12709
|
+
var Si = false, Tn = false, Rg = false, Xy = typeof WeakSet == "function" ? WeakSet : Set, Gn = null, Sd = null, kd = null, _n = null, nr = false, Vo = null, Wn = false, wd = 8192, Vb = { getCacheForType: function(e) {
|
|
12710
|
+
var n = Ee(un), o = n.data.get(e);
|
|
12711
|
+
return o === void 0 && (o = e(), n.data.set(e, o)), o;
|
|
12712
|
+
}, cacheSignal: function() {
|
|
12713
|
+
return Ee(un).controller.signal;
|
|
12714
|
+
}, getOwner: function() {
|
|
12715
|
+
return di;
|
|
12716
|
+
} }, pm = 0, hm = 1, mm = 2, gm = 3, ym = 4;
|
|
12717
|
+
if (typeof Symbol == "function" && Symbol.for) {
|
|
12718
|
+
var bp = Symbol.for;
|
|
12719
|
+
pm = bp("selector.component"), hm = bp("selector.has_pseudo_class"), mm = bp("selector.role"), gm = bp("selector.test_id"), ym = bp("selector.text");
|
|
12720
|
+
}
|
|
12721
|
+
var bm = [], qb = typeof WeakMap == "function" ? WeakMap : Map, Jn = 0, Zn = 2, uo = 4, ki = 0, vp = 1, iu = 2, vm = 3, Tl = 4, Sm = 6, Ky = 5, ye = Jn, je = null, se = null, ae = 0, tr = 0, km = 1, lu = 2, Sp = 3, eb = 4, Eg = 5, kp = 6, wm = 7, Ig = 8, su = 9, Le = tr, Er = null, _l = false, Pd = false, Lg = false, Ta = 0, nn = ki, Rl = 0, El = 0, Ng = 0, rr = 0, uu = 0, wp = null, Bt = null, Pm = false, xm = 0, nb = 0, tb = 300, Pp = 1 / 0, Fg = 500, xp = null, gn = null, Il = null, zm = 0, Hg = 1, Ag = 2, rb = 3, Ll = 0, ob = 1, ab = 2, ib = 3, lb = 4, Cm = 5, Rn = 0, Nl = null, xd = null, qo = 0, jg = 0, Dg = -0, Wg = null, sb = null, ub = null, Go = zm, cb = null, Gb = 50, zp = 0, Ug = null, Bg = false, Tm = false, Jb = 50, cu = 0, Cp = null, zd = false, _m = null, db = false, fb = /* @__PURE__ */ new Set(), Zb = {}, co = null, Cd = null, pb = false;
|
|
12722
|
+
try {
|
|
12723
|
+
var o0 = Object.preventExtensions({});
|
|
12724
|
+
} catch {
|
|
12725
|
+
pb = true;
|
|
12726
|
+
}
|
|
12727
|
+
var hb = false, mb = {}, gb = null, yb = null, bb = null, vb = null, Sb = null, kb = null, wb = null, Pb = null, xb = null, zb = null;
|
|
12728
|
+
return gb = function(e, n, o, i) {
|
|
12729
|
+
n = Yn(e, n), n !== null && (o = _d(n.memoizedState, o, 0, i), n.memoizedState = o, n.baseState = o, e.memoizedProps = ze({}, e.memoizedProps), o = On(e, 2), o !== null && We(o, e, 2));
|
|
12730
|
+
}, yb = function(e, n, o) {
|
|
12731
|
+
n = Yn(e, n), n !== null && (o = du(n.memoizedState, o, 0), n.memoizedState = o, n.baseState = o, e.memoizedProps = ze({}, e.memoizedProps), o = On(e, 2), o !== null && We(o, e, 2));
|
|
12732
|
+
}, bb = function(e, n, o, i) {
|
|
12733
|
+
n = Yn(e, n), n !== null && (o = F(n.memoizedState, o, i), n.memoizedState = o, n.baseState = o, e.memoizedProps = ze({}, e.memoizedProps), o = On(e, 2), o !== null && We(o, e, 2));
|
|
12734
|
+
}, vb = function(e, n, o) {
|
|
12735
|
+
e.pendingProps = _d(e.memoizedProps, n, 0, o), e.alternate && (e.alternate.pendingProps = e.pendingProps), n = On(e, 2), n !== null && We(n, e, 2);
|
|
12736
|
+
}, Sb = function(e, n) {
|
|
12737
|
+
e.pendingProps = du(e.memoizedProps, n, 0), e.alternate && (e.alternate.pendingProps = e.pendingProps), n = On(e, 2), n !== null && We(n, e, 2);
|
|
12738
|
+
}, kb = function(e, n, o) {
|
|
12739
|
+
e.pendingProps = F(e.memoizedProps, n, o), e.alternate && (e.alternate.pendingProps = e.pendingProps), n = On(e, 2), n !== null && We(n, e, 2);
|
|
12740
|
+
}, wb = function(e) {
|
|
12741
|
+
var n = On(e, 2);
|
|
12742
|
+
n !== null && We(n, e, 2);
|
|
12743
|
+
}, Pb = function(e) {
|
|
12744
|
+
var n = ut(), o = On(e, n);
|
|
12745
|
+
o !== null && We(o, e, n);
|
|
12746
|
+
}, xb = function(e) {
|
|
12747
|
+
pu = e;
|
|
12748
|
+
}, zb = function(e) {
|
|
12749
|
+
fu = e;
|
|
12750
|
+
}, le.attemptContinuousHydration = function(e) {
|
|
12751
|
+
if (e.tag === 13 || e.tag === 31) {
|
|
12752
|
+
var n = On(e, 67108864);
|
|
12753
|
+
n !== null && We(n, e, 67108864), rl(e, 67108864);
|
|
12754
|
+
}
|
|
12755
|
+
}, le.attemptHydrationAtCurrentPriority = function(e) {
|
|
12756
|
+
if (e.tag === 13 || e.tag === 31) {
|
|
12757
|
+
var n = Nt(e);
|
|
12758
|
+
n = Xo(n);
|
|
12759
|
+
var o = On(e, n);
|
|
12760
|
+
o !== null && We(o, e, n), rl(e, n);
|
|
12761
|
+
}
|
|
12762
|
+
}, le.attemptSynchronousHydration = function(e) {
|
|
12763
|
+
switch (e.tag) {
|
|
12764
|
+
case 3:
|
|
12765
|
+
if (e = e.stateNode, e.current.memoizedState.isDehydrated) {
|
|
12766
|
+
var n = _t(e.pendingLanes);
|
|
12767
|
+
if (n !== 0) {
|
|
12768
|
+
for (e.pendingLanes |= 2, e.entangledLanes |= 2; n; ) {
|
|
12769
|
+
var o = 1 << 31 - vn(n);
|
|
12770
|
+
e.entanglements[1] |= o, n &= ~o;
|
|
12771
|
+
}
|
|
12772
|
+
Kn(e), (ye & (Zn | uo)) === Jn && (Pp = me() + Fg, Wa(0));
|
|
12773
|
+
}
|
|
12774
|
+
}
|
|
12775
|
+
break;
|
|
12776
|
+
case 31:
|
|
12777
|
+
case 13:
|
|
12778
|
+
n = On(e, 2), n !== null && We(n, e, 2), Ls(), rl(e, 2);
|
|
12779
|
+
}
|
|
12780
|
+
}, le.batchedUpdates = function(e, n) {
|
|
12781
|
+
return e(n);
|
|
12782
|
+
}, le.createComponentSelector = function(e) {
|
|
12783
|
+
return { $$typeof: pm, value: e };
|
|
12784
|
+
}, le.createContainer = function(e, n, o, i, s, u, f, p, g, S) {
|
|
12785
|
+
return Ka(e, n, false, null, o, i, u, null, f, p, g, S);
|
|
12786
|
+
}, le.createHasPseudoClassSelector = function(e) {
|
|
12787
|
+
return { $$typeof: hm, value: e };
|
|
12788
|
+
}, le.createHydrationContainer = function(e, n, o, i, s, u, f, p, g, S, T, _, I, O) {
|
|
12789
|
+
return e = Ka(o, i, true, e, s, u, p, O, g, S, T, _), e.context = Dh(null), o = e.current, i = Nt(o), i = Xo(i), s = zo(i), s.callback = n ?? null, Mt(o, s, i), ur(i, "hydrateRoot()", null), n = i, e.current.lanes = n, Ci(e, n), Kn(e), e;
|
|
12790
|
+
}, le.createPortal = function(e, n, o) {
|
|
12791
|
+
var i = 3 < arguments.length && arguments[3] !== void 0 ? arguments[3] : null;
|
|
12792
|
+
try {
|
|
12793
|
+
vt(i);
|
|
12794
|
+
var s = false;
|
|
12795
|
+
} catch {
|
|
12796
|
+
s = true;
|
|
12797
|
+
}
|
|
12798
|
+
return s && (console.error("The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", typeof Symbol == "function" && Symbol.toStringTag && i[Symbol.toStringTag] || i.constructor.name || "Object"), vt(i)), { $$typeof: Ao, key: i == null ? null : "" + i, children: e, containerInfo: n, implementation: o };
|
|
12799
|
+
}, le.createRoleSelector = function(e) {
|
|
12800
|
+
return { $$typeof: mm, value: e };
|
|
12801
|
+
}, le.createTestNameSelector = function(e) {
|
|
12802
|
+
return { $$typeof: gm, value: e };
|
|
12803
|
+
}, le.createTextSelector = function(e) {
|
|
12804
|
+
return { $$typeof: ym, value: e };
|
|
12805
|
+
}, le.defaultOnCaughtError = function(e) {
|
|
12806
|
+
var n = bd ? "The above error occurred in the <" + bd + "> component." : "The above error occurred in one of your React components.", o = "React will try to recreate this component tree from scratch using the error boundary you provided, " + ((Cg || "Anonymous") + ".");
|
|
12807
|
+
typeof e == "object" && e !== null && typeof e.environmentName == "string" ? ri("error", [`%o
|
|
12808
|
+
|
|
12809
|
+
%s
|
|
12810
|
+
|
|
12811
|
+
%s
|
|
12812
|
+
`, e, n, o], e.environmentName)() : console.error(`%o
|
|
12813
|
+
|
|
12814
|
+
%s
|
|
12815
|
+
|
|
12816
|
+
%s
|
|
12817
|
+
`, e, n, o);
|
|
12818
|
+
}, le.defaultOnRecoverableError = function(e) {
|
|
12819
|
+
qg(e);
|
|
12820
|
+
}, le.defaultOnUncaughtError = function(e) {
|
|
12821
|
+
qg(e), console.warn(`%s
|
|
12822
|
+
|
|
12823
|
+
%s
|
|
12824
|
+
`, bd ? "An error occurred in the <" + bd + "> component." : "An error occurred in one of your React components.", `Consider adding an error boundary to your tree to customize error handling behavior.
|
|
12825
|
+
Visit https://react.dev/link/error-boundaries to learn more about error boundaries.`);
|
|
12826
|
+
}, le.deferredUpdates = function(e) {
|
|
12827
|
+
var n = x.T, o = wt();
|
|
12828
|
+
try {
|
|
12829
|
+
return an(32), x.T = null, e();
|
|
13295
12830
|
} finally {
|
|
13296
|
-
x.
|
|
12831
|
+
an(o), x.T = n;
|
|
13297
12832
|
}
|
|
13298
|
-
},
|
|
13299
|
-
|
|
13300
|
-
var i = x.H;
|
|
13301
|
-
x.H = $o;
|
|
12833
|
+
}, le.discreteUpdates = function(e, n, o, i, s) {
|
|
12834
|
+
var u = x.T, f = wt();
|
|
13302
12835
|
try {
|
|
13303
|
-
return
|
|
12836
|
+
return an(2), x.T = null, e(n, o, i, s);
|
|
13304
12837
|
} finally {
|
|
13305
|
-
x.
|
|
12838
|
+
an(f), x.T = u, ye === Jn && (Pp = me() + Fg);
|
|
13306
12839
|
}
|
|
13307
|
-
},
|
|
13308
|
-
|
|
13309
|
-
|
|
13310
|
-
|
|
13311
|
-
|
|
13312
|
-
|
|
13313
|
-
|
|
13314
|
-
|
|
13315
|
-
|
|
13316
|
-
|
|
12840
|
+
}, le.findAllNodes = kc, le.findBoundingRects = function(e, n) {
|
|
12841
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12842
|
+
n = kc(e, n), e = [];
|
|
12843
|
+
for (var o = 0; o < n.length; o++) e.push(ma(n[o]));
|
|
12844
|
+
for (n = e.length - 1; 0 < n; n--) {
|
|
12845
|
+
o = e[n];
|
|
12846
|
+
for (var i = o.x, s = i + o.width, u = o.y, f = u + o.height, p = n - 1; 0 <= p; p--) if (n !== p) {
|
|
12847
|
+
var g = e[p], S = g.x, T = S + g.width, _ = g.y, I = _ + g.height;
|
|
12848
|
+
if (i >= S && u >= _ && s <= T && f <= I) {
|
|
12849
|
+
e.splice(n, 1);
|
|
12850
|
+
break;
|
|
12851
|
+
} else if (i !== S || o.width !== g.width || I < u || _ > f) {
|
|
12852
|
+
if (!(u !== _ || o.height !== g.height || T < i || S > s)) {
|
|
12853
|
+
S > i && (g.width += S - i, g.x = i), T < s && (g.width = s - S), e.splice(n, 1);
|
|
12854
|
+
break;
|
|
12855
|
+
}
|
|
12856
|
+
} else {
|
|
12857
|
+
_ > u && (g.height += _ - u, g.y = u), I < f && (g.height = f - _), e.splice(n, 1);
|
|
12858
|
+
break;
|
|
12859
|
+
}
|
|
12860
|
+
}
|
|
13317
12861
|
}
|
|
13318
|
-
|
|
13319
|
-
|
|
13320
|
-
|
|
13321
|
-
|
|
13322
|
-
|
|
13323
|
-
|
|
13324
|
-
|
|
13325
|
-
|
|
13326
|
-
|
|
13327
|
-
|
|
13328
|
-
|
|
13329
|
-
|
|
13330
|
-
|
|
13331
|
-
|
|
13332
|
-
|
|
13333
|
-
|
|
13334
|
-
}, useMemoCache: function(e) {
|
|
13335
|
-
return D(), Oa(e);
|
|
13336
|
-
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
13337
|
-
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
13338
|
-
}, useEffectEvent: function(e) {
|
|
13339
|
-
return z = "useEffectEvent", D(), N(), oa(e);
|
|
13340
|
-
} }, dm = { readContext: function(e) {
|
|
13341
|
-
return Ce(), Ee(e);
|
|
13342
|
-
}, use: function(e) {
|
|
13343
|
-
return D(), we(e);
|
|
13344
|
-
}, useCallback: function(e, n) {
|
|
13345
|
-
return z = "useCallback", D(), N(), Ma(e, n);
|
|
13346
|
-
}, useContext: function(e) {
|
|
13347
|
-
return z = "useContext", D(), N(), Ee(e);
|
|
13348
|
-
}, useEffect: function(e, n) {
|
|
13349
|
-
z = "useEffect", D(), N(), Qn(2048, Ut, e, n);
|
|
13350
|
-
}, useImperativeHandle: function(e, n, o) {
|
|
13351
|
-
return z = "useImperativeHandle", D(), N(), aa(e, n, o);
|
|
13352
|
-
}, useInsertionEffect: function(e, n) {
|
|
13353
|
-
return z = "useInsertionEffect", D(), N(), Qn(4, Wt, e, n);
|
|
13354
|
-
}, useLayoutEffect: function(e, n) {
|
|
13355
|
-
return z = "useLayoutEffect", D(), N(), Qn(4, Rr, e, n);
|
|
13356
|
-
}, useMemo: function(e, n) {
|
|
13357
|
-
z = "useMemo", D(), N();
|
|
13358
|
-
var o = x.H;
|
|
13359
|
-
x.H = $o;
|
|
13360
|
-
try {
|
|
13361
|
-
return Vi(e, n);
|
|
13362
|
-
} finally {
|
|
13363
|
-
x.H = o;
|
|
12862
|
+
return e;
|
|
12863
|
+
}, le.findHostInstance = function(e) {
|
|
12864
|
+
var n = e._reactInternals;
|
|
12865
|
+
if (n === void 0) throw typeof e.render == "function" ? Error("Unable to find node on an unmounted component.") : (e = Object.keys(e).join(","), Error("Argument appears to not be a ReactComponent. Keys: " + e));
|
|
12866
|
+
return e = mu(n), e === null ? null : ot(e.stateNode);
|
|
12867
|
+
}, le.findHostInstanceWithNoPortals = function(e) {
|
|
12868
|
+
return e = Ed(e), e = e !== null ? _p(e) : null, e === null ? null : ot(e.stateNode);
|
|
12869
|
+
}, le.findHostInstanceWithWarning = function(e, n) {
|
|
12870
|
+
var o = e._reactInternals;
|
|
12871
|
+
if (o === void 0) throw typeof e.render == "function" ? Error("Unable to find node on an unmounted component.") : (e = Object.keys(e).join(","), Error("Argument appears to not be a ReactComponent. Keys: " + e));
|
|
12872
|
+
if (e = mu(o), e === null) return null;
|
|
12873
|
+
if (e.mode & 8) {
|
|
12874
|
+
var i = G(o) || "Component";
|
|
12875
|
+
mb[i] || (mb[i] = true, B(e, function() {
|
|
12876
|
+
o.mode & 8 ? console.error("%s is deprecated in StrictMode. %s was passed an instance of %s which is inside StrictMode. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://react.dev/link/strict-mode-find-node", n, n, i) : console.error("%s is deprecated in StrictMode. %s was passed an instance of %s which renders StrictMode children. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://react.dev/link/strict-mode-find-node", n, n, i);
|
|
12877
|
+
}));
|
|
13364
12878
|
}
|
|
13365
|
-
|
|
13366
|
-
|
|
13367
|
-
var
|
|
13368
|
-
|
|
12879
|
+
return ot(e.stateNode);
|
|
12880
|
+
}, le.flushPassiveEffects = el, le.flushSyncFromReconciler = function(e) {
|
|
12881
|
+
var n = ye;
|
|
12882
|
+
ye |= 1;
|
|
12883
|
+
var o = x.T, i = wt();
|
|
13369
12884
|
try {
|
|
13370
|
-
|
|
12885
|
+
if (an(2), x.T = null, e) return e();
|
|
13371
12886
|
} finally {
|
|
13372
|
-
x.
|
|
12887
|
+
an(i), x.T = o, ye = n, (ye & (Zn | uo)) === Jn && Wa(0);
|
|
13373
12888
|
}
|
|
13374
|
-
},
|
|
13375
|
-
|
|
13376
|
-
|
|
13377
|
-
|
|
13378
|
-
|
|
13379
|
-
|
|
13380
|
-
|
|
13381
|
-
|
|
13382
|
-
}
|
|
13383
|
-
|
|
12889
|
+
}, le.flushSyncWork = Ls, le.focusWithin = function(e, n) {
|
|
12890
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12891
|
+
for (e = Ef(e), n = hh(e, n), n = Array.from(n), e = 0; e < n.length; ) {
|
|
12892
|
+
var o = n[e++], i = o.tag;
|
|
12893
|
+
if (!Kr(o)) {
|
|
12894
|
+
if ((i === 5 || i === 26 || i === 27) && Ft(o.stateNode)) return true;
|
|
12895
|
+
for (o = o.child; o !== null; ) n.push(o), o = o.sibling;
|
|
12896
|
+
}
|
|
12897
|
+
}
|
|
12898
|
+
return false;
|
|
12899
|
+
}, le.getFindAllNodesFailureDescription = function(e, n) {
|
|
12900
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12901
|
+
var o = 0, i = [];
|
|
12902
|
+
e = [Ef(e), 0];
|
|
12903
|
+
for (var s = 0; s < e.length; ) {
|
|
12904
|
+
var u = e[s++], f = u.tag, p = e[s++], g = n[p];
|
|
12905
|
+
if ((f !== 5 && f !== 26 && f !== 27 || !Kr(u)) && (If(u, g) && (i.push(Sc(g)), p++, p > o && (o = p)), p < n.length)) for (u = u.child; u !== null; ) e.push(u, p), u = u.sibling;
|
|
12906
|
+
}
|
|
12907
|
+
if (o < n.length) {
|
|
12908
|
+
for (e = []; o < n.length; o++) e.push(Sc(n[o]));
|
|
12909
|
+
return `findAllNodes was able to match part of the selector:
|
|
12910
|
+
` + (i.join(" > ") + `
|
|
12911
|
+
|
|
12912
|
+
No matching component was found for:
|
|
12913
|
+
`) + e.join(" > ");
|
|
12914
|
+
}
|
|
12915
|
+
return null;
|
|
12916
|
+
}, le.getPublicRootInstance = function(e) {
|
|
12917
|
+
if (e = e.current, !e.child) return null;
|
|
12918
|
+
switch (e.child.tag) {
|
|
12919
|
+
case 27:
|
|
12920
|
+
case 5:
|
|
12921
|
+
return ot(e.child.stateNode);
|
|
12922
|
+
default:
|
|
12923
|
+
return e.child.stateNode;
|
|
12924
|
+
}
|
|
12925
|
+
}, le.injectIntoDevTools = function() {
|
|
12926
|
+
var e = { bundleType: 1, version: Jt, rendererPackageName: Zt, currentDispatcherRef: x, reconcilerVersion: "19.2.0" };
|
|
12927
|
+
return jo !== null && (e.rendererConfig = jo), e.overrideHookState = gb, e.overrideHookStateDeletePath = yb, e.overrideHookStateRenamePath = bb, e.overrideProps = vb, e.overridePropsDeletePath = Sb, e.overridePropsRenamePath = kb, e.scheduleUpdate = wb, e.scheduleRetry = Pb, e.setErrorHandler = xb, e.setSuspenseHandler = zb, e.scheduleRefresh = hu, e.scheduleRoot = Fl, e.setRefreshHandler = Ir, e.getCurrentFiber = Ic, Ep(e);
|
|
12928
|
+
}, le.isAlreadyRendering = Ns, le.observeVisibleRects = function(e, n, o, i) {
|
|
12929
|
+
function s() {
|
|
12930
|
+
var S = kc(e, n);
|
|
12931
|
+
u.forEach(function(T) {
|
|
12932
|
+
0 > S.indexOf(T) && g(T);
|
|
12933
|
+
}), S.forEach(function(T) {
|
|
12934
|
+
0 > u.indexOf(T) && p(T);
|
|
12935
|
+
});
|
|
12936
|
+
}
|
|
12937
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12938
|
+
var u = kc(e, n);
|
|
12939
|
+
o = zr(u, o, i);
|
|
12940
|
+
var f = o.disconnect, p = o.observe, g = o.unobserve;
|
|
12941
|
+
return bm.push(s), { disconnect: function() {
|
|
12942
|
+
var S = bm.indexOf(s);
|
|
12943
|
+
0 <= S && bm.splice(S, 1), f();
|
|
12944
|
+
} };
|
|
12945
|
+
}, le.shouldError = function(e) {
|
|
12946
|
+
return pu(e);
|
|
12947
|
+
}, le.shouldSuspend = function(e) {
|
|
12948
|
+
return fu(e);
|
|
12949
|
+
}, le.startHostTransition = function(e, n, o, i) {
|
|
12950
|
+
if (e.tag !== 5) throw Error("Expected the form instance to be a HostComponent. This is a bug in React.");
|
|
12951
|
+
var s = uf(e).queue;
|
|
12952
|
+
Hp(e), nt(e, s, n, Xt, o === null ? Em : function() {
|
|
12953
|
+
x.T === null && console.error("requestFormReset was called outside a transition or action. To fix, move to an action, or wrap with startTransition.");
|
|
12954
|
+
var u = uf(e);
|
|
12955
|
+
return u.next === null && (u = e.alternate.memoizedState), qi(e, u.next.queue, {}, Nt(e)), o(i);
|
|
12956
|
+
});
|
|
12957
|
+
}, le.updateContainer = function(e, n, o, i) {
|
|
12958
|
+
var s = n.current, u = Nt(s);
|
|
12959
|
+
return As(s, u, e, n, o, i), u;
|
|
12960
|
+
}, le.updateContainerSync = Wh, le;
|
|
12961
|
+
}, Tt.exports.default = Tt.exports, Object.defineProperty(Tt.exports, "__esModule", { value: true }));
|
|
12962
|
+
})(Mg)), Mg.exports;
|
|
12963
|
+
}
|
|
12964
|
+
var Eb;
|
|
12965
|
+
function n0() {
|
|
12966
|
+
return Eb || (Eb = 1, process.env.NODE_ENV === "production" ? Rm.exports = Kb() : Rm.exports = e0()), Rm.exports;
|
|
12967
|
+
}
|
|
12968
|
+
var t0 = n0();
|
|
12969
|
+
const r0 = Xb(t0);
|
|
12970
|
+
|
|
12971
|
+
const DEFAULT_POINTER_ID = 0;
|
|
12972
|
+
const XR_POINTER_ID_START = 1e3;
|
|
12973
|
+
function getPointerState(internal, pointerId) {
|
|
12974
|
+
let state = internal.pointerMap.get(pointerId);
|
|
12975
|
+
if (!state) {
|
|
12976
|
+
state = {
|
|
12977
|
+
hovered: /* @__PURE__ */ new Map(),
|
|
12978
|
+
captured: /* @__PURE__ */ new Map(),
|
|
12979
|
+
initialClick: [0, 0],
|
|
12980
|
+
initialHits: []
|
|
12981
|
+
};
|
|
12982
|
+
internal.pointerMap.set(pointerId, state);
|
|
12983
|
+
}
|
|
12984
|
+
return state;
|
|
12985
|
+
}
|
|
12986
|
+
function getPointerId(event) {
|
|
12987
|
+
return "pointerId" in event ? event.pointerId : DEFAULT_POINTER_ID;
|
|
12988
|
+
}
|
|
12989
|
+
function makeId(event) {
|
|
12990
|
+
return (event.eventObject || event.object).uuid + "/" + event.index + event.instanceId;
|
|
12991
|
+
}
|
|
12992
|
+
function releaseInternalPointerCapture(internal, obj, pointerId) {
|
|
12993
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
12994
|
+
if (!pointerState) return;
|
|
12995
|
+
const captureData = pointerState.captured.get(obj);
|
|
12996
|
+
if (captureData) {
|
|
12997
|
+
pointerState.captured.delete(obj);
|
|
12998
|
+
try {
|
|
12999
|
+
captureData.target.releasePointerCapture?.(pointerId);
|
|
13000
|
+
} catch {
|
|
13001
|
+
}
|
|
13002
|
+
}
|
|
13003
|
+
}
|
|
13004
|
+
function swapInteractivity(store, object, newObject) {
|
|
13005
|
+
const { internal } = store.getState();
|
|
13006
|
+
for (let i = 0; i < internal.interaction.length; i++) {
|
|
13007
|
+
if (internal.interaction[i] === object) internal.interaction[i] = newObject;
|
|
13008
|
+
}
|
|
13009
|
+
for (const pointerState of internal.pointerMap.values()) {
|
|
13010
|
+
for (let i = 0; i < pointerState.initialHits.length; i++) {
|
|
13011
|
+
if (pointerState.initialHits[i] === object) pointerState.initialHits[i] = newObject;
|
|
13012
|
+
}
|
|
13013
|
+
pointerState.hovered.forEach((value, key) => {
|
|
13014
|
+
if (value.eventObject === object || value.object === object) {
|
|
13015
|
+
pointerState.hovered.delete(key);
|
|
13016
|
+
const next = {
|
|
13017
|
+
...value,
|
|
13018
|
+
eventObject: value.eventObject === object ? newObject : value.eventObject,
|
|
13019
|
+
object: value.object === object ? newObject : value.object
|
|
13020
|
+
};
|
|
13021
|
+
pointerState.hovered.set(makeId(next), next);
|
|
13022
|
+
}
|
|
13023
|
+
});
|
|
13024
|
+
const captureData = pointerState.captured.get(object);
|
|
13025
|
+
if (captureData) {
|
|
13026
|
+
pointerState.captured.delete(object);
|
|
13027
|
+
pointerState.captured.set(newObject, {
|
|
13028
|
+
...captureData,
|
|
13029
|
+
intersection: {
|
|
13030
|
+
...captureData.intersection,
|
|
13031
|
+
object: captureData.intersection.object === object ? newObject : captureData.intersection.object,
|
|
13032
|
+
eventObject: captureData.intersection.eventObject === object ? newObject : captureData.intersection.eventObject
|
|
13384
13033
|
}
|
|
13385
|
-
}
|
|
13386
|
-
|
|
13387
|
-
|
|
13388
|
-
|
|
13389
|
-
|
|
13390
|
-
|
|
13391
|
-
|
|
13392
|
-
|
|
13393
|
-
|
|
13394
|
-
|
|
13395
|
-
|
|
13396
|
-
|
|
13397
|
-
|
|
13398
|
-
return z = "useActionState", D(), N(), $t(e);
|
|
13399
|
-
}, useOptimistic: function(e, n) {
|
|
13400
|
-
return z = "useOptimistic", D(), N(), of(e, n);
|
|
13401
|
-
}, useMemoCache: function(e) {
|
|
13402
|
-
return D(), Oa(e);
|
|
13403
|
-
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
13404
|
-
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
13405
|
-
}, useEffectEvent: function(e) {
|
|
13406
|
-
return z = "useEffectEvent", D(), N(), oa(e);
|
|
13407
|
-
} };
|
|
13408
|
-
var Fy = {}, Hy = /* @__PURE__ */ new Set(), Ay = /* @__PURE__ */ new Set(), jy = /* @__PURE__ */ new Set(), Dy = /* @__PURE__ */ new Set(), Wy = /* @__PURE__ */ new Set(), Uy = /* @__PURE__ */ new Set(), By = /* @__PURE__ */ new Set(), Oy = /* @__PURE__ */ new Set(), My = /* @__PURE__ */ new Set(), Qy = /* @__PURE__ */ new Set();
|
|
13409
|
-
Object.freeze(Fy);
|
|
13410
|
-
var zg = { enqueueSetState: function(e, n, o) {
|
|
13411
|
-
e = e._reactInternals;
|
|
13412
|
-
var i = Nt(e), s = zo(i);
|
|
13413
|
-
s.payload = n, o != null && (df(o), s.callback = o), n = Mt(e, s, i), n !== null && (ur(i, "this.setState()", e), We(n, e, i), Bi(n, e, i));
|
|
13414
|
-
}, enqueueReplaceState: function(e, n, o) {
|
|
13415
|
-
e = e._reactInternals;
|
|
13416
|
-
var i = Nt(e), s = zo(i);
|
|
13417
|
-
s.tag = Cy, s.payload = n, o != null && (df(o), s.callback = o), n = Mt(e, s, i), n !== null && (ur(i, "this.replaceState()", e), We(n, e, i), Bi(n, e, i));
|
|
13418
|
-
}, enqueueForceUpdate: function(e, n) {
|
|
13419
|
-
e = e._reactInternals;
|
|
13420
|
-
var o = Nt(e), i = zo(o);
|
|
13421
|
-
i.tag = Ty, n != null && (df(n), i.callback = n), n = Mt(e, i, o), n !== null && (ur(o, "this.forceUpdate()", e), We(n, e, o), Bi(n, e, o));
|
|
13422
|
-
} }, bd = null, Cg = null, Tg = Error("This is not a real error. It's an implementation detail of React's selective hydration feature. If this leaks into userspace, it's a bug in React. Please file an issue."), Cn = false, $y = {}, Vy = {}, qy = {}, Gy = {}, vd = false, Jy = {}, fm = {}, _g = { dehydrated: null, treeContext: null, retryLane: 0, hydrationErrors: null }, Zy = false, Yy = null;
|
|
13423
|
-
Yy = /* @__PURE__ */ new Set();
|
|
13424
|
-
var Si = false, Tn = false, Rg = false, Xy = typeof WeakSet == "function" ? WeakSet : Set, Gn = null, Sd = null, kd = null, _n = null, nr = false, Vo = null, Wn = false, wd = 8192, Vb = { getCacheForType: function(e) {
|
|
13425
|
-
var n = Ee(un), o = n.data.get(e);
|
|
13426
|
-
return o === void 0 && (o = e(), n.data.set(e, o)), o;
|
|
13427
|
-
}, cacheSignal: function() {
|
|
13428
|
-
return Ee(un).controller.signal;
|
|
13429
|
-
}, getOwner: function() {
|
|
13430
|
-
return di;
|
|
13431
|
-
} }, pm = 0, hm = 1, mm = 2, gm = 3, ym = 4;
|
|
13432
|
-
if (typeof Symbol == "function" && Symbol.for) {
|
|
13433
|
-
var bp = Symbol.for;
|
|
13434
|
-
pm = bp("selector.component"), hm = bp("selector.has_pseudo_class"), mm = bp("selector.role"), gm = bp("selector.test_id"), ym = bp("selector.text");
|
|
13034
|
+
});
|
|
13035
|
+
}
|
|
13036
|
+
}
|
|
13037
|
+
unregisterVisibility(store, object);
|
|
13038
|
+
}
|
|
13039
|
+
function removeInteractivity(store, object) {
|
|
13040
|
+
const { internal } = store.getState();
|
|
13041
|
+
internal.interaction = internal.interaction.filter((o) => o !== object);
|
|
13042
|
+
for (const [pointerId, pointerState] of internal.pointerMap) {
|
|
13043
|
+
pointerState.initialHits = pointerState.initialHits.filter((o) => o !== object);
|
|
13044
|
+
pointerState.hovered.forEach((value, key) => {
|
|
13045
|
+
if (value.eventObject === object || value.object === object) {
|
|
13046
|
+
pointerState.hovered.delete(key);
|
|
13435
13047
|
}
|
|
13436
|
-
|
|
13437
|
-
|
|
13438
|
-
|
|
13439
|
-
|
|
13440
|
-
|
|
13048
|
+
});
|
|
13049
|
+
if (pointerState.captured.has(object)) {
|
|
13050
|
+
releaseInternalPointerCapture(internal, object, pointerId);
|
|
13051
|
+
}
|
|
13052
|
+
}
|
|
13053
|
+
unregisterVisibility(store, object);
|
|
13054
|
+
}
|
|
13055
|
+
function createEvents(store) {
|
|
13056
|
+
function calculateDistance(event, pointerId) {
|
|
13057
|
+
const { internal } = store.getState();
|
|
13058
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13059
|
+
if (!pointerState) return 0;
|
|
13060
|
+
const [initialX, initialY] = pointerState.initialClick;
|
|
13061
|
+
const dx = event.offsetX - initialX;
|
|
13062
|
+
const dy = event.offsetY - initialY;
|
|
13063
|
+
return Math.round(Math.sqrt(dx * dx + dy * dy));
|
|
13064
|
+
}
|
|
13065
|
+
function filterPointerEvents(objects) {
|
|
13066
|
+
return objects.filter(
|
|
13067
|
+
(obj) => ["Move", "Over", "Enter", "Out", "Leave"].some(
|
|
13068
|
+
(name) => obj.__r3f?.handlers["onPointer" + name]
|
|
13069
|
+
) || ["OverEnter", "OverLeave", "Over"].some(
|
|
13070
|
+
(name) => obj.__r3f?.handlers["onDrag" + name]
|
|
13071
|
+
) || obj.__r3f?.handlers.onDrop
|
|
13072
|
+
);
|
|
13073
|
+
}
|
|
13074
|
+
function intersect(event, filter) {
|
|
13075
|
+
const state = store.getState();
|
|
13076
|
+
const duplicates = /* @__PURE__ */ new Set();
|
|
13077
|
+
const intersections = [];
|
|
13078
|
+
const eventsObjects = filter ? filter(state.internal.interaction) : state.internal.interaction;
|
|
13079
|
+
for (let i = 0; i < eventsObjects.length; i++) {
|
|
13080
|
+
const state2 = getRootState(eventsObjects[i]);
|
|
13081
|
+
if (state2) {
|
|
13082
|
+
state2.raycaster.camera = void 0;
|
|
13441
13083
|
}
|
|
13442
|
-
|
|
13443
|
-
|
|
13444
|
-
|
|
13445
|
-
|
|
13446
|
-
|
|
13447
|
-
|
|
13448
|
-
|
|
13449
|
-
|
|
13450
|
-
|
|
13451
|
-
|
|
13452
|
-
|
|
13453
|
-
|
|
13454
|
-
|
|
13455
|
-
|
|
13456
|
-
|
|
13457
|
-
|
|
13458
|
-
|
|
13459
|
-
|
|
13460
|
-
|
|
13461
|
-
|
|
13462
|
-
|
|
13463
|
-
|
|
13464
|
-
|
|
13465
|
-
}, le.attemptContinuousHydration = function(e) {
|
|
13466
|
-
if (e.tag === 13 || e.tag === 31) {
|
|
13467
|
-
var n = On(e, 67108864);
|
|
13468
|
-
n !== null && We(n, e, 67108864), rl(e, 67108864);
|
|
13084
|
+
}
|
|
13085
|
+
if (!state.previousRoot) {
|
|
13086
|
+
state.events.compute?.(event, state);
|
|
13087
|
+
}
|
|
13088
|
+
function handleRaycast(obj) {
|
|
13089
|
+
const state2 = getRootState(obj);
|
|
13090
|
+
if (!state2 || !state2.events.enabled || state2.raycaster.camera === null) return [];
|
|
13091
|
+
if (state2.raycaster.camera === void 0) {
|
|
13092
|
+
state2.events.compute?.(event, state2, state2.previousRoot?.getState());
|
|
13093
|
+
if (state2.raycaster.camera === void 0) state2.raycaster.camera = null;
|
|
13094
|
+
}
|
|
13095
|
+
if (!state2.raycaster.camera) return [];
|
|
13096
|
+
obj.updateWorldMatrix(true, true);
|
|
13097
|
+
return state2.raycaster.intersectObject(obj, true);
|
|
13098
|
+
}
|
|
13099
|
+
let hits = eventsObjects.flatMap(handleRaycast).sort((a, b) => {
|
|
13100
|
+
const aInteractivePriority = a.object.userData?.interactivePriority;
|
|
13101
|
+
const bInteractivePriority = b.object.userData?.interactivePriority;
|
|
13102
|
+
if (aInteractivePriority !== void 0 || bInteractivePriority !== void 0) {
|
|
13103
|
+
if (aInteractivePriority !== void 0 && bInteractivePriority === void 0) return -1;
|
|
13104
|
+
if (bInteractivePriority !== void 0 && aInteractivePriority === void 0) return 1;
|
|
13105
|
+
if (aInteractivePriority !== bInteractivePriority) {
|
|
13106
|
+
return (bInteractivePriority ?? 0) - (aInteractivePriority ?? 0);
|
|
13469
13107
|
}
|
|
13470
|
-
}
|
|
13471
|
-
|
|
13472
|
-
|
|
13473
|
-
|
|
13474
|
-
|
|
13475
|
-
|
|
13108
|
+
}
|
|
13109
|
+
const aState = getRootState(a.object);
|
|
13110
|
+
const bState = getRootState(b.object);
|
|
13111
|
+
const aPriority = aState?.events?.priority ?? 1;
|
|
13112
|
+
const bPriority = bState?.events?.priority ?? 1;
|
|
13113
|
+
return bPriority - aPriority || a.distance - b.distance;
|
|
13114
|
+
}).filter((item) => {
|
|
13115
|
+
const id = makeId(item);
|
|
13116
|
+
if (duplicates.has(id)) return false;
|
|
13117
|
+
duplicates.add(id);
|
|
13118
|
+
return true;
|
|
13119
|
+
});
|
|
13120
|
+
if (state.events.filter) hits = state.events.filter(hits, state);
|
|
13121
|
+
for (const hit of hits) {
|
|
13122
|
+
let eventObject = hit.object;
|
|
13123
|
+
while (eventObject) {
|
|
13124
|
+
if (eventObject.__r3f?.eventCount) {
|
|
13125
|
+
intersections.push({ ...hit, eventObject });
|
|
13476
13126
|
}
|
|
13477
|
-
|
|
13478
|
-
|
|
13479
|
-
|
|
13480
|
-
|
|
13481
|
-
|
|
13482
|
-
|
|
13483
|
-
|
|
13484
|
-
|
|
13485
|
-
|
|
13127
|
+
eventObject = eventObject.parent;
|
|
13128
|
+
}
|
|
13129
|
+
}
|
|
13130
|
+
if ("pointerId" in event) {
|
|
13131
|
+
const pointerId = event.pointerId;
|
|
13132
|
+
const pointerState = state.internal.pointerMap.get(pointerId);
|
|
13133
|
+
if (pointerState?.captured.size) {
|
|
13134
|
+
for (const captureData of pointerState.captured.values()) {
|
|
13135
|
+
if (!duplicates.has(makeId(captureData.intersection))) intersections.push(captureData.intersection);
|
|
13136
|
+
}
|
|
13137
|
+
}
|
|
13138
|
+
}
|
|
13139
|
+
return intersections;
|
|
13140
|
+
}
|
|
13141
|
+
function handleIntersects(intersections, event, delta, callback) {
|
|
13142
|
+
if (intersections.length) {
|
|
13143
|
+
const localState = { stopped: false };
|
|
13144
|
+
for (const hit of intersections) {
|
|
13145
|
+
const state = getRootState(hit.object);
|
|
13146
|
+
if (state) {
|
|
13147
|
+
const { raycaster, pointer, camera, internal } = state;
|
|
13148
|
+
const unprojectedPoint = new Vector3(pointer.x, pointer.y, 0).unproject(camera);
|
|
13149
|
+
const hasPointerCapture = (id) => {
|
|
13150
|
+
const pointerState = internal.pointerMap.get(id);
|
|
13151
|
+
return pointerState?.captured.has(hit.eventObject) ?? false;
|
|
13152
|
+
};
|
|
13153
|
+
const setPointerCapture = (id) => {
|
|
13154
|
+
const captureData = { intersection: hit, target: event.target };
|
|
13155
|
+
const pointerState = getPointerState(internal, id);
|
|
13156
|
+
pointerState.captured.set(hit.eventObject, captureData);
|
|
13157
|
+
event.target.setPointerCapture(id);
|
|
13158
|
+
};
|
|
13159
|
+
const releasePointerCapture = (id) => {
|
|
13160
|
+
releaseInternalPointerCapture(internal, hit.eventObject, id);
|
|
13161
|
+
};
|
|
13162
|
+
const extractEventProps = {};
|
|
13163
|
+
for (const prop in event) {
|
|
13164
|
+
const property = event[prop];
|
|
13165
|
+
if (typeof property !== "function") extractEventProps[prop] = property;
|
|
13166
|
+
}
|
|
13167
|
+
const eventPointerId = "pointerId" in event ? event.pointerId : void 0;
|
|
13168
|
+
const raycastEvent = {
|
|
13169
|
+
...hit,
|
|
13170
|
+
...extractEventProps,
|
|
13171
|
+
pointer,
|
|
13172
|
+
intersections,
|
|
13173
|
+
stopped: localState.stopped,
|
|
13174
|
+
delta,
|
|
13175
|
+
unprojectedPoint,
|
|
13176
|
+
ray: raycaster.ray,
|
|
13177
|
+
camera,
|
|
13178
|
+
pointerId: eventPointerId,
|
|
13179
|
+
// Hijack stopPropagation, which just sets a flag
|
|
13180
|
+
stopPropagation() {
|
|
13181
|
+
const pointerState = eventPointerId !== void 0 ? internal.pointerMap.get(eventPointerId) : void 0;
|
|
13182
|
+
if (
|
|
13183
|
+
// ...if this pointer hasn't been captured
|
|
13184
|
+
!pointerState?.captured.size || // ... or if the hit object is capturing the pointer
|
|
13185
|
+
pointerState.captured.has(hit.eventObject)
|
|
13186
|
+
) {
|
|
13187
|
+
raycastEvent.stopped = localState.stopped = true;
|
|
13188
|
+
if (pointerState?.hovered.size && Array.from(pointerState.hovered.values()).find((i) => i.eventObject === hit.eventObject)) {
|
|
13189
|
+
const higher = intersections.slice(0, intersections.indexOf(hit));
|
|
13190
|
+
cancelPointer([...higher, hit], eventPointerId);
|
|
13486
13191
|
}
|
|
13487
|
-
Kn(e), (ye & (Zn | uo)) === Jn && (Pp = me() + Fg, Wa(0));
|
|
13488
13192
|
}
|
|
13489
|
-
}
|
|
13490
|
-
|
|
13491
|
-
|
|
13492
|
-
|
|
13493
|
-
|
|
13193
|
+
},
|
|
13194
|
+
// there should be a distinction between target and currentTarget
|
|
13195
|
+
target: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
13196
|
+
currentTarget: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
13197
|
+
nativeEvent: event
|
|
13198
|
+
};
|
|
13199
|
+
callback(raycastEvent);
|
|
13200
|
+
if (localState.stopped === true) break;
|
|
13494
13201
|
}
|
|
13495
|
-
}
|
|
13496
|
-
|
|
13497
|
-
|
|
13498
|
-
|
|
13499
|
-
|
|
13500
|
-
|
|
13501
|
-
|
|
13502
|
-
|
|
13503
|
-
|
|
13504
|
-
|
|
13505
|
-
|
|
13506
|
-
|
|
13507
|
-
|
|
13508
|
-
|
|
13509
|
-
|
|
13510
|
-
|
|
13511
|
-
|
|
13202
|
+
}
|
|
13203
|
+
}
|
|
13204
|
+
return intersections;
|
|
13205
|
+
}
|
|
13206
|
+
function cancelPointer(intersections, pointerId) {
|
|
13207
|
+
const { internal } = store.getState();
|
|
13208
|
+
const pid = pointerId ?? DEFAULT_POINTER_ID;
|
|
13209
|
+
const pointerState = internal.pointerMap.get(pid);
|
|
13210
|
+
if (!pointerState) return;
|
|
13211
|
+
for (const [hoveredId, hoveredObj] of pointerState.hovered) {
|
|
13212
|
+
if (!intersections.length || !intersections.find(
|
|
13213
|
+
(hit) => hit.object === hoveredObj.object && hit.index === hoveredObj.index && hit.instanceId === hoveredObj.instanceId
|
|
13214
|
+
)) {
|
|
13215
|
+
const eventObject = hoveredObj.eventObject;
|
|
13216
|
+
const instance = eventObject.__r3f;
|
|
13217
|
+
pointerState.hovered.delete(hoveredId);
|
|
13218
|
+
if (instance?.eventCount) {
|
|
13219
|
+
const handlers = instance.handlers;
|
|
13220
|
+
const data = { ...hoveredObj, intersections };
|
|
13221
|
+
handlers.onPointerOut?.(data);
|
|
13222
|
+
handlers.onPointerLeave?.(data);
|
|
13223
|
+
handlers.onDragOverLeave?.(data);
|
|
13512
13224
|
}
|
|
13513
|
-
|
|
13514
|
-
|
|
13515
|
-
|
|
13516
|
-
|
|
13517
|
-
|
|
13518
|
-
|
|
13519
|
-
|
|
13520
|
-
|
|
13521
|
-
|
|
13522
|
-
|
|
13523
|
-
|
|
13524
|
-
|
|
13525
|
-
|
|
13526
|
-
|
|
13527
|
-
|
|
13528
|
-
|
|
13529
|
-
|
|
13530
|
-
|
|
13531
|
-
|
|
13532
|
-
|
|
13533
|
-
|
|
13534
|
-
|
|
13535
|
-
|
|
13536
|
-
|
|
13537
|
-
|
|
13538
|
-
|
|
13539
|
-
|
|
13540
|
-
|
|
13541
|
-
|
|
13542
|
-
|
|
13543
|
-
|
|
13544
|
-
|
|
13545
|
-
|
|
13546
|
-
an(o), x.T = n;
|
|
13225
|
+
}
|
|
13226
|
+
}
|
|
13227
|
+
}
|
|
13228
|
+
function pointerMissed(event, objects) {
|
|
13229
|
+
for (let i = 0; i < objects.length; i++) {
|
|
13230
|
+
const instance = objects[i].__r3f;
|
|
13231
|
+
instance?.handlers.onPointerMissed?.(event);
|
|
13232
|
+
}
|
|
13233
|
+
}
|
|
13234
|
+
function dragOverMissed(event, objects) {
|
|
13235
|
+
for (let i = 0; i < objects.length; i++) {
|
|
13236
|
+
const instance = objects[i].__r3f;
|
|
13237
|
+
instance?.handlers.onDragOverMissed?.(event);
|
|
13238
|
+
}
|
|
13239
|
+
}
|
|
13240
|
+
function dropMissed(event, objects) {
|
|
13241
|
+
for (let i = 0; i < objects.length; i++) {
|
|
13242
|
+
const instance = objects[i].__r3f;
|
|
13243
|
+
instance?.handlers.onDropMissed?.(event);
|
|
13244
|
+
}
|
|
13245
|
+
}
|
|
13246
|
+
function cleanupPointer(pointerId) {
|
|
13247
|
+
const { internal } = store.getState();
|
|
13248
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13249
|
+
if (pointerState) {
|
|
13250
|
+
for (const [, hoveredObj] of pointerState.hovered) {
|
|
13251
|
+
const eventObject = hoveredObj.eventObject;
|
|
13252
|
+
const instance = eventObject.__r3f;
|
|
13253
|
+
if (instance?.eventCount) {
|
|
13254
|
+
const handlers = instance.handlers;
|
|
13255
|
+
const data = { ...hoveredObj, intersections: [] };
|
|
13256
|
+
handlers.onPointerOut?.(data);
|
|
13257
|
+
handlers.onPointerLeave?.(data);
|
|
13547
13258
|
}
|
|
13548
|
-
}
|
|
13549
|
-
|
|
13550
|
-
|
|
13551
|
-
|
|
13552
|
-
|
|
13553
|
-
|
|
13259
|
+
}
|
|
13260
|
+
internal.pointerMap.delete(pointerId);
|
|
13261
|
+
}
|
|
13262
|
+
internal.pointerDirty.delete(pointerId);
|
|
13263
|
+
}
|
|
13264
|
+
function processDeferredPointer(event, pointerId) {
|
|
13265
|
+
const state = store.getState();
|
|
13266
|
+
const { internal } = state;
|
|
13267
|
+
if (!state.events.enabled) return;
|
|
13268
|
+
const filter = filterPointerEvents;
|
|
13269
|
+
const hits = intersect(event, filter);
|
|
13270
|
+
cancelPointer(hits, pointerId);
|
|
13271
|
+
function onIntersect(data) {
|
|
13272
|
+
const eventObject = data.eventObject;
|
|
13273
|
+
const instance = eventObject.__r3f;
|
|
13274
|
+
if (!instance?.eventCount) return;
|
|
13275
|
+
const handlers = instance.handlers;
|
|
13276
|
+
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
13277
|
+
const id = makeId(data);
|
|
13278
|
+
const pointerState = getPointerState(internal, pointerId);
|
|
13279
|
+
const hoveredItem = pointerState.hovered.get(id);
|
|
13280
|
+
if (!hoveredItem) {
|
|
13281
|
+
pointerState.hovered.set(id, data);
|
|
13282
|
+
handlers.onPointerOver?.(data);
|
|
13283
|
+
handlers.onPointerEnter?.(data);
|
|
13284
|
+
} else if (hoveredItem.stopped) {
|
|
13285
|
+
data.stopPropagation();
|
|
13554
13286
|
}
|
|
13555
|
-
}
|
|
13556
|
-
|
|
13557
|
-
|
|
13558
|
-
|
|
13559
|
-
|
|
13560
|
-
|
|
13561
|
-
|
|
13562
|
-
|
|
13563
|
-
|
|
13564
|
-
|
|
13565
|
-
|
|
13566
|
-
|
|
13567
|
-
|
|
13568
|
-
|
|
13569
|
-
|
|
13287
|
+
}
|
|
13288
|
+
handlers.onPointerMove?.(data);
|
|
13289
|
+
}
|
|
13290
|
+
handleIntersects(hits, event, 0, onIntersect);
|
|
13291
|
+
}
|
|
13292
|
+
function handlePointer(name) {
|
|
13293
|
+
switch (name) {
|
|
13294
|
+
case "onPointerLeave":
|
|
13295
|
+
case "onDragLeave":
|
|
13296
|
+
return () => cancelPointer([]);
|
|
13297
|
+
// Global cancel of these events
|
|
13298
|
+
case "onPointerCancel":
|
|
13299
|
+
return (event) => {
|
|
13300
|
+
const pointerId = getPointerId(event);
|
|
13301
|
+
cleanupPointer(pointerId);
|
|
13302
|
+
};
|
|
13303
|
+
case "onLostPointerCapture":
|
|
13304
|
+
return (event) => {
|
|
13305
|
+
const { internal } = store.getState();
|
|
13306
|
+
const pointerId = getPointerId(event);
|
|
13307
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13308
|
+
if (pointerState?.captured.size) {
|
|
13309
|
+
requestAnimationFrame(() => {
|
|
13310
|
+
const pointerState2 = internal.pointerMap.get(pointerId);
|
|
13311
|
+
if (pointerState2?.captured.size) {
|
|
13312
|
+
pointerState2.captured.clear();
|
|
13570
13313
|
}
|
|
13571
|
-
|
|
13572
|
-
|
|
13573
|
-
|
|
13314
|
+
cancelPointer([], pointerId);
|
|
13315
|
+
});
|
|
13316
|
+
}
|
|
13317
|
+
};
|
|
13318
|
+
}
|
|
13319
|
+
return function handleEvent(event) {
|
|
13320
|
+
const state = store.getState();
|
|
13321
|
+
const { onPointerMissed, onDragOverMissed, onDropMissed, internal, events } = state;
|
|
13322
|
+
const pointerId = getPointerId(event);
|
|
13323
|
+
internal.lastEvent.current = event;
|
|
13324
|
+
if (!events.enabled) return;
|
|
13325
|
+
const isPointerMove = name === "onPointerMove";
|
|
13326
|
+
const isDragOver = name === "onDragOver";
|
|
13327
|
+
const isDrop = name === "onDrop";
|
|
13328
|
+
const isClickEvent = name === "onClick" || name === "onContextMenu" || name === "onDoubleClick";
|
|
13329
|
+
const isPointerDown = name === "onPointerDown";
|
|
13330
|
+
const isPointerUp = name === "onPointerUp";
|
|
13331
|
+
const isWheel = name === "onWheel";
|
|
13332
|
+
const canDeferRaycasts = events.frameTimedRaycasts && state.frameloop === "always";
|
|
13333
|
+
if (isPointerMove && canDeferRaycasts) {
|
|
13334
|
+
events.compute?.(event, state);
|
|
13335
|
+
internal.pointerDirty.set(pointerId, event);
|
|
13336
|
+
return;
|
|
13337
|
+
}
|
|
13338
|
+
if (isWheel && canDeferRaycasts && !events.alwaysFireOnScroll) {
|
|
13339
|
+
events.compute?.(event, state);
|
|
13340
|
+
internal.pointerDirty.set(pointerId, event);
|
|
13341
|
+
return;
|
|
13342
|
+
}
|
|
13343
|
+
if ((isClickEvent || isPointerDown || isPointerUp) && internal.pointerDirty.has(pointerId)) {
|
|
13344
|
+
const deferredEvent = internal.pointerDirty.get(pointerId);
|
|
13345
|
+
internal.pointerDirty.delete(pointerId);
|
|
13346
|
+
processDeferredPointer(deferredEvent, pointerId);
|
|
13347
|
+
}
|
|
13348
|
+
const filter = isPointerMove || isDragOver || isDrop ? filterPointerEvents : void 0;
|
|
13349
|
+
const hits = intersect(event, filter);
|
|
13350
|
+
const delta = isClickEvent ? calculateDistance(event, pointerId) : 0;
|
|
13351
|
+
if (isPointerDown) {
|
|
13352
|
+
const pointerState2 = getPointerState(internal, pointerId);
|
|
13353
|
+
pointerState2.initialClick = [event.offsetX, event.offsetY];
|
|
13354
|
+
pointerState2.initialHits = hits.map((hit) => hit.eventObject);
|
|
13355
|
+
}
|
|
13356
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13357
|
+
const initialHits = pointerState?.initialHits ?? [];
|
|
13358
|
+
if (isClickEvent && !hits.length) {
|
|
13359
|
+
if (delta <= 2) {
|
|
13360
|
+
pointerMissed(event, internal.interaction);
|
|
13361
|
+
if (onPointerMissed) onPointerMissed(event);
|
|
13362
|
+
}
|
|
13363
|
+
}
|
|
13364
|
+
if (isDragOver && !hits.length) {
|
|
13365
|
+
dragOverMissed(event, internal.interaction);
|
|
13366
|
+
if (onDragOverMissed) onDragOverMissed(event);
|
|
13367
|
+
}
|
|
13368
|
+
if (isDrop && !hits.length) {
|
|
13369
|
+
dropMissed(event, internal.interaction);
|
|
13370
|
+
if (onDropMissed) onDropMissed(event);
|
|
13371
|
+
}
|
|
13372
|
+
if (isPointerMove || isDragOver) {
|
|
13373
|
+
cancelPointer(hits, pointerId);
|
|
13374
|
+
}
|
|
13375
|
+
function onIntersect(data) {
|
|
13376
|
+
const eventObject = data.eventObject;
|
|
13377
|
+
const instance = eventObject.__r3f;
|
|
13378
|
+
if (!instance?.eventCount) return;
|
|
13379
|
+
const handlers = instance.handlers;
|
|
13380
|
+
if (isPointerMove) {
|
|
13381
|
+
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
13382
|
+
const id = makeId(data);
|
|
13383
|
+
const pointerState2 = getPointerState(internal, pointerId);
|
|
13384
|
+
const hoveredItem = pointerState2.hovered.get(id);
|
|
13385
|
+
if (!hoveredItem) {
|
|
13386
|
+
pointerState2.hovered.set(id, data);
|
|
13387
|
+
handlers.onPointerOver?.(data);
|
|
13388
|
+
handlers.onPointerEnter?.(data);
|
|
13389
|
+
} else if (hoveredItem.stopped) {
|
|
13390
|
+
data.stopPropagation();
|
|
13574
13391
|
}
|
|
13575
13392
|
}
|
|
13576
|
-
|
|
13577
|
-
|
|
13578
|
-
|
|
13579
|
-
|
|
13580
|
-
|
|
13581
|
-
|
|
13582
|
-
|
|
13583
|
-
|
|
13584
|
-
|
|
13585
|
-
|
|
13586
|
-
|
|
13587
|
-
|
|
13588
|
-
if (
|
|
13589
|
-
|
|
13590
|
-
|
|
13591
|
-
|
|
13592
|
-
|
|
13593
|
-
|
|
13594
|
-
|
|
13595
|
-
|
|
13596
|
-
|
|
13597
|
-
|
|
13598
|
-
|
|
13599
|
-
|
|
13600
|
-
|
|
13601
|
-
|
|
13602
|
-
|
|
13603
|
-
|
|
13604
|
-
|
|
13605
|
-
|
|
13606
|
-
|
|
13607
|
-
var o = n[e++], i = o.tag;
|
|
13608
|
-
if (!Kr(o)) {
|
|
13609
|
-
if ((i === 5 || i === 26 || i === 27) && Ft(o.stateNode)) return true;
|
|
13610
|
-
for (o = o.child; o !== null; ) n.push(o), o = o.sibling;
|
|
13393
|
+
handlers.onPointerMove?.(data);
|
|
13394
|
+
} else if (isDragOver) {
|
|
13395
|
+
const id = makeId(data);
|
|
13396
|
+
const pointerState2 = getPointerState(internal, pointerId);
|
|
13397
|
+
const hoveredItem = pointerState2.hovered.get(id);
|
|
13398
|
+
if (!hoveredItem) {
|
|
13399
|
+
pointerState2.hovered.set(id, data);
|
|
13400
|
+
handlers.onDragOverEnter?.(data);
|
|
13401
|
+
} else if (hoveredItem.stopped) {
|
|
13402
|
+
data.stopPropagation();
|
|
13403
|
+
}
|
|
13404
|
+
handlers.onDragOver?.(data);
|
|
13405
|
+
} else if (isDrop) {
|
|
13406
|
+
handlers.onDrop?.(data);
|
|
13407
|
+
} else {
|
|
13408
|
+
const handler = handlers[name];
|
|
13409
|
+
if (handler) {
|
|
13410
|
+
if (!isClickEvent || initialHits.includes(eventObject)) {
|
|
13411
|
+
pointerMissed(
|
|
13412
|
+
event,
|
|
13413
|
+
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
13414
|
+
);
|
|
13415
|
+
handler(data);
|
|
13416
|
+
}
|
|
13417
|
+
} else {
|
|
13418
|
+
if (isClickEvent && initialHits.includes(eventObject)) {
|
|
13419
|
+
pointerMissed(
|
|
13420
|
+
event,
|
|
13421
|
+
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
13422
|
+
);
|
|
13423
|
+
}
|
|
13611
13424
|
}
|
|
13612
13425
|
}
|
|
13613
|
-
|
|
13614
|
-
|
|
13615
|
-
|
|
13616
|
-
|
|
13617
|
-
|
|
13618
|
-
|
|
13619
|
-
|
|
13620
|
-
|
|
13426
|
+
}
|
|
13427
|
+
handleIntersects(hits, event, delta, onIntersect);
|
|
13428
|
+
};
|
|
13429
|
+
}
|
|
13430
|
+
function flushDeferredPointers() {
|
|
13431
|
+
const { internal, events } = store.getState();
|
|
13432
|
+
if (!events.frameTimedRaycasts) return;
|
|
13433
|
+
for (const [pointerId, event] of internal.pointerDirty) {
|
|
13434
|
+
processDeferredPointer(event, pointerId);
|
|
13435
|
+
}
|
|
13436
|
+
internal.pointerDirty.clear();
|
|
13437
|
+
}
|
|
13438
|
+
return { handlePointer, flushDeferredPointers, processDeferredPointer };
|
|
13439
|
+
}
|
|
13440
|
+
const DOM_EVENTS = {
|
|
13441
|
+
onClick: ["click", false],
|
|
13442
|
+
onContextMenu: ["contextmenu", false],
|
|
13443
|
+
onDoubleClick: ["dblclick", false],
|
|
13444
|
+
onDragEnter: ["dragenter", false],
|
|
13445
|
+
onDragLeave: ["dragleave", false],
|
|
13446
|
+
onDragOver: ["dragover", false],
|
|
13447
|
+
onDrop: ["drop", false],
|
|
13448
|
+
onWheel: ["wheel", true],
|
|
13449
|
+
onPointerDown: ["pointerdown", true],
|
|
13450
|
+
onPointerUp: ["pointerup", true],
|
|
13451
|
+
onPointerLeave: ["pointerleave", true],
|
|
13452
|
+
onPointerMove: ["pointermove", true],
|
|
13453
|
+
onPointerCancel: ["pointercancel", true],
|
|
13454
|
+
onLostPointerCapture: ["lostpointercapture", true]
|
|
13455
|
+
};
|
|
13456
|
+
function createPointerEvents(store) {
|
|
13457
|
+
const { handlePointer, flushDeferredPointers, processDeferredPointer } = createEvents(store);
|
|
13458
|
+
let nextXRPointerId = XR_POINTER_ID_START;
|
|
13459
|
+
const xrPointers = /* @__PURE__ */ new Map();
|
|
13460
|
+
return {
|
|
13461
|
+
priority: 1,
|
|
13462
|
+
enabled: true,
|
|
13463
|
+
frameTimedRaycasts: true,
|
|
13464
|
+
alwaysFireOnScroll: true,
|
|
13465
|
+
updateOnFrame: false,
|
|
13466
|
+
compute(event, state) {
|
|
13467
|
+
state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
|
|
13468
|
+
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
13469
|
+
},
|
|
13470
|
+
connected: void 0,
|
|
13471
|
+
handlers: Object.keys(DOM_EVENTS).reduce(
|
|
13472
|
+
(acc, key) => ({ ...acc, [key]: handlePointer(key) }),
|
|
13473
|
+
{}
|
|
13474
|
+
),
|
|
13475
|
+
update: (pointerId) => {
|
|
13476
|
+
const { events, internal } = store.getState();
|
|
13477
|
+
if (!events.handlers) return;
|
|
13478
|
+
if (pointerId !== void 0) {
|
|
13479
|
+
const event = internal.pointerDirty.get(pointerId);
|
|
13480
|
+
if (event) {
|
|
13481
|
+
internal.pointerDirty.delete(pointerId);
|
|
13482
|
+
processDeferredPointer(event, pointerId);
|
|
13483
|
+
} else if (internal.lastEvent?.current) {
|
|
13484
|
+
processDeferredPointer(internal.lastEvent.current, pointerId);
|
|
13621
13485
|
}
|
|
13622
|
-
|
|
13623
|
-
|
|
13624
|
-
|
|
13625
|
-
|
|
13626
|
-
|
|
13627
|
-
No matching component was found for:
|
|
13628
|
-
`) + e.join(" > ");
|
|
13486
|
+
} else {
|
|
13487
|
+
flushDeferredPointers();
|
|
13488
|
+
if (internal.lastEvent?.current) {
|
|
13489
|
+
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
13629
13490
|
}
|
|
13630
|
-
|
|
13631
|
-
|
|
13632
|
-
|
|
13633
|
-
|
|
13634
|
-
|
|
13635
|
-
|
|
13636
|
-
|
|
13637
|
-
|
|
13638
|
-
|
|
13491
|
+
}
|
|
13492
|
+
},
|
|
13493
|
+
flush: () => {
|
|
13494
|
+
const { events, internal } = store.getState();
|
|
13495
|
+
flushDeferredPointers();
|
|
13496
|
+
if (events.updateOnFrame && internal.lastEvent?.current && events.handlers) {
|
|
13497
|
+
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
13498
|
+
}
|
|
13499
|
+
},
|
|
13500
|
+
connect: (target) => {
|
|
13501
|
+
if (!target) return;
|
|
13502
|
+
const { set, events } = store.getState();
|
|
13503
|
+
events.disconnect?.();
|
|
13504
|
+
set((state) => ({ events: { ...state.events, connected: target } }));
|
|
13505
|
+
if (events.handlers) {
|
|
13506
|
+
for (const name in events.handlers) {
|
|
13507
|
+
const event = events.handlers[name];
|
|
13508
|
+
const [eventName, passive] = DOM_EVENTS[name];
|
|
13509
|
+
target.addEventListener(eventName, event, { passive });
|
|
13639
13510
|
}
|
|
13640
|
-
}
|
|
13641
|
-
|
|
13642
|
-
|
|
13643
|
-
|
|
13644
|
-
|
|
13645
|
-
|
|
13646
|
-
|
|
13647
|
-
|
|
13648
|
-
|
|
13649
|
-
|
|
13650
|
-
}
|
|
13511
|
+
}
|
|
13512
|
+
},
|
|
13513
|
+
disconnect: () => {
|
|
13514
|
+
const { set, events } = store.getState();
|
|
13515
|
+
if (events.connected) {
|
|
13516
|
+
if (events.handlers) {
|
|
13517
|
+
for (const name in events.handlers) {
|
|
13518
|
+
const event = events.handlers[name];
|
|
13519
|
+
const [eventName] = DOM_EVENTS[name];
|
|
13520
|
+
events.connected.removeEventListener(eventName, event);
|
|
13521
|
+
}
|
|
13651
13522
|
}
|
|
13652
|
-
|
|
13653
|
-
|
|
13654
|
-
|
|
13655
|
-
|
|
13656
|
-
|
|
13657
|
-
|
|
13658
|
-
|
|
13659
|
-
|
|
13660
|
-
|
|
13661
|
-
|
|
13662
|
-
|
|
13663
|
-
|
|
13664
|
-
|
|
13665
|
-
|
|
13666
|
-
|
|
13667
|
-
|
|
13668
|
-
|
|
13669
|
-
|
|
13670
|
-
|
|
13671
|
-
|
|
13672
|
-
|
|
13673
|
-
|
|
13674
|
-
|
|
13675
|
-
|
|
13676
|
-
|
|
13677
|
-
|
|
13678
|
-
|
|
13679
|
-
|
|
13680
|
-
|
|
13681
|
-
|
|
13523
|
+
set((state) => ({ events: { ...state.events, connected: void 0 } }));
|
|
13524
|
+
}
|
|
13525
|
+
},
|
|
13526
|
+
// PREVIEW (A8): the XR pointer registration API may change before stable.
|
|
13527
|
+
registerPointer: (config) => {
|
|
13528
|
+
const pointerId = nextXRPointerId++;
|
|
13529
|
+
xrPointers.set(pointerId, config);
|
|
13530
|
+
const { internal } = store.getState();
|
|
13531
|
+
getPointerState(internal, pointerId);
|
|
13532
|
+
return pointerId;
|
|
13533
|
+
},
|
|
13534
|
+
unregisterPointer: (pointerId) => {
|
|
13535
|
+
xrPointers.delete(pointerId);
|
|
13536
|
+
const { internal } = store.getState();
|
|
13537
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13538
|
+
if (pointerState) {
|
|
13539
|
+
for (const [, hoveredObj] of pointerState.hovered) {
|
|
13540
|
+
const eventObject = hoveredObj.eventObject;
|
|
13541
|
+
const instance = eventObject.__r3f;
|
|
13542
|
+
if (instance?.eventCount) {
|
|
13543
|
+
const handlers = instance.handlers;
|
|
13544
|
+
const data = { ...hoveredObj, intersections: [] };
|
|
13545
|
+
handlers.onPointerOut?.(data);
|
|
13546
|
+
handlers.onPointerLeave?.(data);
|
|
13547
|
+
}
|
|
13548
|
+
}
|
|
13549
|
+
internal.pointerMap.delete(pointerId);
|
|
13550
|
+
}
|
|
13551
|
+
internal.pointerDirty.delete(pointerId);
|
|
13552
|
+
}
|
|
13553
|
+
};
|
|
13682
13554
|
}
|
|
13683
|
-
var t0 = n0();
|
|
13684
|
-
const r0 = Xb(t0);
|
|
13685
|
-
|
|
13686
|
-
const t = 1, o = 8, r = 32, e = 2;
|
|
13687
13555
|
|
|
13688
13556
|
function createReconciler(config) {
|
|
13689
13557
|
const reconciler2 = r0(config);
|
|
@@ -13703,7 +13571,10 @@ function extend(objects) {
|
|
|
13703
13571
|
catalogue[Component] = objects;
|
|
13704
13572
|
return Component;
|
|
13705
13573
|
} else {
|
|
13706
|
-
|
|
13574
|
+
for (const name in objects) {
|
|
13575
|
+
const object = objects[name];
|
|
13576
|
+
if (isConstructor(object)) catalogue[name] = object;
|
|
13577
|
+
}
|
|
13707
13578
|
}
|
|
13708
13579
|
}
|
|
13709
13580
|
function validateInstance(type, props) {
|
|
@@ -13848,7 +13719,15 @@ function setFiberRef(fiber, publicInstance) {
|
|
|
13848
13719
|
}
|
|
13849
13720
|
}
|
|
13850
13721
|
const reconstructed = [];
|
|
13851
|
-
function
|
|
13722
|
+
function flushReconstructedInstances() {
|
|
13723
|
+
if (reconstructed.length === 0) return;
|
|
13724
|
+
try {
|
|
13725
|
+
swapReconstructedInstances();
|
|
13726
|
+
} finally {
|
|
13727
|
+
reconstructed.length = 0;
|
|
13728
|
+
}
|
|
13729
|
+
}
|
|
13730
|
+
function swapReconstructedInstances() {
|
|
13852
13731
|
for (const [instance] of reconstructed) {
|
|
13853
13732
|
const parent = instance.parent;
|
|
13854
13733
|
if (parent) {
|
|
@@ -13866,7 +13745,9 @@ function swapInstances() {
|
|
|
13866
13745
|
}
|
|
13867
13746
|
}
|
|
13868
13747
|
if (instance.isHidden) unhideInstance(instance);
|
|
13869
|
-
if (isObject3D(instance.object)
|
|
13748
|
+
if (isObject3D(instance.object) && !instance.parent) {
|
|
13749
|
+
removeInteractivity(findInitialRoot(instance), instance.object);
|
|
13750
|
+
}
|
|
13870
13751
|
if (instance.object.__r3f) delete instance.object.__r3f;
|
|
13871
13752
|
if (instance.type !== "primitive") disposeOnIdle(instance.object);
|
|
13872
13753
|
}
|
|
@@ -13875,9 +13756,13 @@ function swapInstances() {
|
|
|
13875
13756
|
const parent = instance.parent;
|
|
13876
13757
|
if (parent) {
|
|
13877
13758
|
const target = catalogue[toPascalCase(instance.type)];
|
|
13759
|
+
const prevObject = instance.object;
|
|
13878
13760
|
instance.object = instance.props.object ?? new target(...instance.props.args ?? []);
|
|
13879
13761
|
instance.object.__r3f = instance;
|
|
13880
13762
|
setFiberRef(fiber, instance.object);
|
|
13763
|
+
if (isObject3D(prevObject) && isObject3D(instance.object)) {
|
|
13764
|
+
swapInteractivity(findInitialRoot(instance), prevObject, instance.object);
|
|
13765
|
+
}
|
|
13881
13766
|
delete instance.appliedOnce;
|
|
13882
13767
|
instance.eventCount = 0;
|
|
13883
13768
|
instance.handlers = {};
|
|
@@ -13897,14 +13782,114 @@ function swapInstances() {
|
|
|
13897
13782
|
invalidateInstance(instance);
|
|
13898
13783
|
}
|
|
13899
13784
|
}
|
|
13900
|
-
reconstructed.length = 0;
|
|
13901
13785
|
}
|
|
13902
13786
|
const handleTextInstance = () => {
|
|
13903
13787
|
};
|
|
13904
13788
|
const NO_CONTEXT = {};
|
|
13905
13789
|
let currentUpdatePriority = NoEventPriority;
|
|
13906
|
-
|
|
13907
|
-
|
|
13790
|
+
function getEventPriority(type) {
|
|
13791
|
+
switch (type) {
|
|
13792
|
+
case "beforetoggle":
|
|
13793
|
+
case "cancel":
|
|
13794
|
+
case "click":
|
|
13795
|
+
case "close":
|
|
13796
|
+
case "contextmenu":
|
|
13797
|
+
case "copy":
|
|
13798
|
+
case "cut":
|
|
13799
|
+
case "auxclick":
|
|
13800
|
+
case "dblclick":
|
|
13801
|
+
case "dragend":
|
|
13802
|
+
case "dragstart":
|
|
13803
|
+
case "drop":
|
|
13804
|
+
case "focusin":
|
|
13805
|
+
case "focusout":
|
|
13806
|
+
case "input":
|
|
13807
|
+
case "invalid":
|
|
13808
|
+
case "keydown":
|
|
13809
|
+
case "keypress":
|
|
13810
|
+
case "keyup":
|
|
13811
|
+
case "mousedown":
|
|
13812
|
+
case "mouseup":
|
|
13813
|
+
case "paste":
|
|
13814
|
+
case "pause":
|
|
13815
|
+
case "play":
|
|
13816
|
+
case "pointercancel":
|
|
13817
|
+
case "pointerdown":
|
|
13818
|
+
case "pointerup":
|
|
13819
|
+
case "ratechange":
|
|
13820
|
+
case "reset":
|
|
13821
|
+
case "resize":
|
|
13822
|
+
case "seeked":
|
|
13823
|
+
case "submit":
|
|
13824
|
+
case "touchcancel":
|
|
13825
|
+
case "touchend":
|
|
13826
|
+
case "touchstart":
|
|
13827
|
+
case "volumechange":
|
|
13828
|
+
case "change":
|
|
13829
|
+
case "selectionchange":
|
|
13830
|
+
case "compositionstart":
|
|
13831
|
+
case "compositionend":
|
|
13832
|
+
case "compositionupdate":
|
|
13833
|
+
case "beforeinput":
|
|
13834
|
+
case "blur":
|
|
13835
|
+
case "fullscreenchange":
|
|
13836
|
+
case "focus":
|
|
13837
|
+
case "hashchange":
|
|
13838
|
+
case "popstate":
|
|
13839
|
+
case "select":
|
|
13840
|
+
case "selectstart":
|
|
13841
|
+
return e;
|
|
13842
|
+
case "drag":
|
|
13843
|
+
case "dragenter":
|
|
13844
|
+
case "dragexit":
|
|
13845
|
+
case "dragleave":
|
|
13846
|
+
case "dragover":
|
|
13847
|
+
case "mousemove":
|
|
13848
|
+
case "mouseout":
|
|
13849
|
+
case "mouseover":
|
|
13850
|
+
case "pointermove":
|
|
13851
|
+
case "pointerout":
|
|
13852
|
+
case "pointerover":
|
|
13853
|
+
case "scroll":
|
|
13854
|
+
case "touchmove":
|
|
13855
|
+
case "wheel":
|
|
13856
|
+
case "mouseenter":
|
|
13857
|
+
case "mouseleave":
|
|
13858
|
+
case "pointerenter":
|
|
13859
|
+
case "pointerleave":
|
|
13860
|
+
return o;
|
|
13861
|
+
case "message": {
|
|
13862
|
+
switch (unstable_getCurrentPriorityLevel()) {
|
|
13863
|
+
case unstable_ImmediatePriority:
|
|
13864
|
+
return e;
|
|
13865
|
+
case unstable_UserBlockingPriority:
|
|
13866
|
+
return o;
|
|
13867
|
+
case unstable_NormalPriority:
|
|
13868
|
+
case unstable_LowPriority:
|
|
13869
|
+
return r;
|
|
13870
|
+
case unstable_IdlePriority:
|
|
13871
|
+
return i$1;
|
|
13872
|
+
default:
|
|
13873
|
+
return r;
|
|
13874
|
+
}
|
|
13875
|
+
}
|
|
13876
|
+
default:
|
|
13877
|
+
return r;
|
|
13878
|
+
}
|
|
13879
|
+
}
|
|
13880
|
+
function scheduleMicrotask(callback) {
|
|
13881
|
+
if (typeof queueMicrotask === "function") {
|
|
13882
|
+
queueMicrotask(callback);
|
|
13883
|
+
} else if (typeof Promise !== "undefined") {
|
|
13884
|
+
Promise.resolve().then(callback).catch((error) => {
|
|
13885
|
+
setTimeout(() => {
|
|
13886
|
+
throw error;
|
|
13887
|
+
});
|
|
13888
|
+
});
|
|
13889
|
+
} else {
|
|
13890
|
+
setTimeout(callback);
|
|
13891
|
+
}
|
|
13892
|
+
}
|
|
13908
13893
|
const reconciler = /* @__PURE__ */ createReconciler({
|
|
13909
13894
|
isPrimaryRenderer: false,
|
|
13910
13895
|
warnsIfNotActing: false,
|
|
@@ -13937,22 +13922,21 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13937
13922
|
getRootHostContext: () => NO_CONTEXT,
|
|
13938
13923
|
getChildHostContext: () => NO_CONTEXT,
|
|
13939
13924
|
commitUpdate(instance, type, oldProps, newProps, fiber) {
|
|
13940
|
-
validateInstance(type, newProps);
|
|
13925
|
+
validateInstance(instance.type, newProps);
|
|
13941
13926
|
let reconstruct = false;
|
|
13942
13927
|
if (instance.type === "primitive" && oldProps.object !== newProps.object) reconstruct = true;
|
|
13943
13928
|
else if (newProps.args?.length !== oldProps.args?.length) reconstruct = true;
|
|
13944
13929
|
else if (newProps.args?.some((value, index) => value !== oldProps.args?.[index])) reconstruct = true;
|
|
13945
13930
|
if (reconstruct) {
|
|
13946
|
-
reconstructed.push([instance,
|
|
13931
|
+
reconstructed.push([instance, getInstanceProps(newProps), fiber]);
|
|
13947
13932
|
} else {
|
|
13948
13933
|
const changedProps = diffProps(instance, newProps);
|
|
13949
|
-
|
|
13950
|
-
|
|
13951
|
-
|
|
13952
|
-
|
|
13934
|
+
const attach2 = instance.props.attach;
|
|
13935
|
+
instance.props = getInstanceProps(newProps);
|
|
13936
|
+
if (attach2 !== void 0) instance.props.attach = attach2;
|
|
13937
|
+
else delete instance.props.attach;
|
|
13938
|
+
if (Object.keys(changedProps).length) applyProps(instance.object, changedProps);
|
|
13953
13939
|
}
|
|
13954
|
-
const isTailSibling = fiber.sibling === null || (fiber.flags & Update) === NoFlags;
|
|
13955
|
-
if (isTailSibling) swapInstances();
|
|
13956
13940
|
},
|
|
13957
13941
|
finalizeInitialChildren: (instance) => {
|
|
13958
13942
|
for (const prop in instance.props) {
|
|
@@ -13965,8 +13949,8 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13965
13949
|
for (const prop in instance.props) {
|
|
13966
13950
|
const value = instance.props[prop];
|
|
13967
13951
|
if (isFromRef(value)) {
|
|
13968
|
-
const ref = value
|
|
13969
|
-
if (ref.current != null) resolved[prop] = ref.current;
|
|
13952
|
+
const { [FROM_REF]: ref, transform } = value;
|
|
13953
|
+
if (ref.current != null) resolved[prop] = transform ? transform(ref.current) : ref.current;
|
|
13970
13954
|
}
|
|
13971
13955
|
}
|
|
13972
13956
|
if (Object.keys(resolved).length) applyProps(instance.object, resolved);
|
|
@@ -13977,8 +13961,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13977
13961
|
const target = container.getState().internal.container ?? container.getState().scene;
|
|
13978
13962
|
return prepare(target, container, "", {});
|
|
13979
13963
|
},
|
|
13980
|
-
|
|
13981
|
-
|
|
13964
|
+
// Reconstructed instances are swapped once all mutations are committed,
|
|
13965
|
+
// before layout effects run so refs point to the new objects
|
|
13966
|
+
resetAfterCommit: flushReconstructedInstances,
|
|
13982
13967
|
shouldSetTextContent: () => false,
|
|
13983
13968
|
clearContainer: () => false,
|
|
13984
13969
|
hideInstance,
|
|
@@ -13986,6 +13971,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13986
13971
|
createTextInstance: handleTextInstance,
|
|
13987
13972
|
hideTextInstance: handleTextInstance,
|
|
13988
13973
|
unhideTextInstance: handleTextInstance,
|
|
13974
|
+
// Mirrors react-dom, which flushes discrete work in microtasks
|
|
13975
|
+
supportsMicrotasks: true,
|
|
13976
|
+
scheduleMicrotask,
|
|
13989
13977
|
scheduleTimeout: typeof setTimeout === "function" ? setTimeout : void 0,
|
|
13990
13978
|
cancelTimeout: typeof clearTimeout === "function" ? clearTimeout : void 0,
|
|
13991
13979
|
noTimeout: -1,
|
|
@@ -14026,28 +14014,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
14026
14014
|
},
|
|
14027
14015
|
resolveUpdatePriority() {
|
|
14028
14016
|
if (currentUpdatePriority !== NoEventPriority) return currentUpdatePriority;
|
|
14029
|
-
|
|
14030
|
-
|
|
14031
|
-
|
|
14032
|
-
case "dblclick":
|
|
14033
|
-
case "dragenter":
|
|
14034
|
-
case "dragleave":
|
|
14035
|
-
case "drop":
|
|
14036
|
-
case "pointercancel":
|
|
14037
|
-
case "pointerdown":
|
|
14038
|
-
case "pointerup":
|
|
14039
|
-
return e;
|
|
14040
|
-
case "dragover":
|
|
14041
|
-
case "pointermove":
|
|
14042
|
-
case "pointerout":
|
|
14043
|
-
case "pointerover":
|
|
14044
|
-
case "pointerenter":
|
|
14045
|
-
case "pointerleave":
|
|
14046
|
-
case "wheel":
|
|
14047
|
-
return o;
|
|
14048
|
-
default:
|
|
14049
|
-
return r;
|
|
14050
|
-
}
|
|
14017
|
+
const eventType = typeof window !== "undefined" ? window.event?.type : void 0;
|
|
14018
|
+
if (eventType === void 0) return r;
|
|
14019
|
+
return getEventPriority(eventType);
|
|
14051
14020
|
},
|
|
14052
14021
|
resetFormInstance() {
|
|
14053
14022
|
},
|
|
@@ -14262,9 +14231,8 @@ function createRoot(canvas) {
|
|
|
14262
14231
|
if (!renderer.hasInitialized?.()) {
|
|
14263
14232
|
const size2 = computeInitialSize(canvas, propsSize);
|
|
14264
14233
|
if (size2.width > 0 && size2.height > 0) {
|
|
14265
|
-
|
|
14266
|
-
|
|
14267
|
-
canvas.height = size2.height * pixelRatio;
|
|
14234
|
+
renderer.setPixelRatio(calculateDpr(dpr));
|
|
14235
|
+
renderer.setSize(size2.width, size2.height, false);
|
|
14268
14236
|
}
|
|
14269
14237
|
await renderer.init();
|
|
14270
14238
|
}
|
|
@@ -14273,7 +14241,7 @@ function createRoot(canvas) {
|
|
|
14273
14241
|
state.internal.actualRenderer = renderer;
|
|
14274
14242
|
state.set({ webGPUSupported: isWebGPUBackend, renderer, primaryStore: store });
|
|
14275
14243
|
if (canvasId && !state.internal.isSecondary) {
|
|
14276
|
-
const canvasTarget =
|
|
14244
|
+
const canvasTarget = renderer.getCanvasTarget?.();
|
|
14277
14245
|
const unregisterPrimary = registerPrimary(canvasId, renderer, store);
|
|
14278
14246
|
state.set((prev) => ({
|
|
14279
14247
|
internal: {
|
|
@@ -14387,7 +14355,7 @@ function createRoot(canvas) {
|
|
|
14387
14355
|
const handleXRFrame = (timestamp, _frame) => {
|
|
14388
14356
|
const state2 = store.getState();
|
|
14389
14357
|
if (state2.frameloop === "never") return;
|
|
14390
|
-
advance(timestamp);
|
|
14358
|
+
advance(timestamp, true, state2);
|
|
14391
14359
|
};
|
|
14392
14360
|
const actualRenderer = state.internal.actualRenderer;
|
|
14393
14361
|
const handleSessionChange = () => {
|
|
@@ -14395,7 +14363,7 @@ function createRoot(canvas) {
|
|
|
14395
14363
|
const renderer2 = state2.internal.actualRenderer;
|
|
14396
14364
|
actualRenderer.xr.enabled = actualRenderer.xr.isPresenting;
|
|
14397
14365
|
renderer2.xr.setAnimationLoop(renderer2.xr.isPresenting ? handleXRFrame : null);
|
|
14398
|
-
if (!renderer2.xr.isPresenting) invalidate();
|
|
14366
|
+
if (!renderer2.xr.isPresenting) invalidate(state2);
|
|
14399
14367
|
};
|
|
14400
14368
|
const xr = {
|
|
14401
14369
|
connect() {
|
|
@@ -14477,14 +14445,23 @@ function createRoot(canvas) {
|
|
|
14477
14445
|
const newRootId = canvasId || scheduler.generateRootId();
|
|
14478
14446
|
const unregisterRoot = scheduler.registerRoot(newRootId, {
|
|
14479
14447
|
getState: () => store.getState(),
|
|
14480
|
-
onError: (err) => store.getState().setError(err)
|
|
14448
|
+
onError: (err) => store.getState().setError(err),
|
|
14449
|
+
frameloop: store.getState().frameloop,
|
|
14450
|
+
before: schedulerConfig?.before,
|
|
14451
|
+
after: schedulerConfig?.after,
|
|
14452
|
+
order: schedulerConfig?.order
|
|
14481
14453
|
});
|
|
14482
14454
|
const unregisterCanvasTarget = scheduler.register(
|
|
14483
14455
|
() => {
|
|
14484
14456
|
const state2 = store.getState();
|
|
14485
|
-
|
|
14457
|
+
const canvasTarget = state2.internal.canvasTarget;
|
|
14458
|
+
if (canvasTarget) {
|
|
14486
14459
|
const renderer2 = state2.internal.actualRenderer;
|
|
14487
|
-
renderer2.setCanvasTarget(
|
|
14460
|
+
if (renderer2.getCanvasTarget() !== canvasTarget) renderer2.setCanvasTarget(canvasTarget);
|
|
14461
|
+
if (state2.internal.canvasTargetSizeDirty) {
|
|
14462
|
+
state2.internal.canvasTargetSizeDirty = false;
|
|
14463
|
+
renderer2.backend?.updateSize?.();
|
|
14464
|
+
}
|
|
14488
14465
|
}
|
|
14489
14466
|
},
|
|
14490
14467
|
{
|
|
@@ -14553,8 +14530,7 @@ function createRoot(canvas) {
|
|
|
14553
14530
|
phase: "render",
|
|
14554
14531
|
system: true,
|
|
14555
14532
|
// Internal flag: this is a system job, not user-controlled
|
|
14556
|
-
//
|
|
14557
|
-
...schedulerConfig?.after && { after: schedulerConfig.after },
|
|
14533
|
+
// FPS throttles only the default render job; Canvas ordering belongs to the root.
|
|
14558
14534
|
...schedulerConfig?.fps && { fps: schedulerConfig.fps }
|
|
14559
14535
|
}
|
|
14560
14536
|
);
|
|
@@ -14573,8 +14549,21 @@ function createRoot(canvas) {
|
|
|
14573
14549
|
scheduler
|
|
14574
14550
|
}
|
|
14575
14551
|
}));
|
|
14552
|
+
} else {
|
|
14553
|
+
const constraintsChanged = !is.equ(schedulerConfig?.before, lastConfiguredProps.schedulerBefore, shallowLoose) || !is.equ(schedulerConfig?.after, lastConfiguredProps.schedulerAfter, shallowLoose);
|
|
14554
|
+
if (constraintsChanged) {
|
|
14555
|
+
scheduler.setRootConstraints(rootId, {
|
|
14556
|
+
before: schedulerConfig?.before,
|
|
14557
|
+
after: schedulerConfig?.after
|
|
14558
|
+
});
|
|
14559
|
+
}
|
|
14560
|
+
if (schedulerConfig?.order !== lastConfiguredProps.schedulerOrder) {
|
|
14561
|
+
scheduler.setRootOrder(rootId, schedulerConfig?.order ?? 0);
|
|
14562
|
+
}
|
|
14576
14563
|
}
|
|
14577
|
-
|
|
14564
|
+
lastConfiguredProps.schedulerBefore = schedulerConfig?.before;
|
|
14565
|
+
lastConfiguredProps.schedulerAfter = schedulerConfig?.after;
|
|
14566
|
+
lastConfiguredProps.schedulerOrder = schedulerConfig?.order;
|
|
14578
14567
|
onCreated = onCreatedCallback;
|
|
14579
14568
|
configured = true;
|
|
14580
14569
|
resolve();
|
|
@@ -14616,18 +14605,23 @@ function unmountComponentAtNode(canvas, callback) {
|
|
|
14616
14605
|
const fiber = root?.fiber;
|
|
14617
14606
|
if (fiber) {
|
|
14618
14607
|
const state = root?.store.getState();
|
|
14619
|
-
if (state)
|
|
14608
|
+
if (state) {
|
|
14609
|
+
state.internal.active = false;
|
|
14610
|
+
const unregisterRoot = state.internal.unregisterRoot;
|
|
14611
|
+
if (unregisterRoot) {
|
|
14612
|
+
unregisterRoot();
|
|
14613
|
+
state.internal.unregisterRoot = void 0;
|
|
14614
|
+
}
|
|
14615
|
+
}
|
|
14620
14616
|
reconciler.updateContainer(null, fiber, null, () => {
|
|
14621
14617
|
if (state) {
|
|
14622
14618
|
setTimeout(() => {
|
|
14623
14619
|
try {
|
|
14624
14620
|
const renderer = state.internal.actualRenderer;
|
|
14625
|
-
const unregisterRoot = state.internal.unregisterRoot;
|
|
14626
|
-
if (unregisterRoot) unregisterRoot();
|
|
14627
14621
|
const unregisterPrimary = state.internal.unregisterPrimary;
|
|
14628
14622
|
if (unregisterPrimary) unregisterPrimary();
|
|
14629
14623
|
const canvasTarget = state.internal.canvasTarget;
|
|
14630
|
-
if (canvasTarget?.dispose) canvasTarget.dispose();
|
|
14624
|
+
if (state.internal.isSecondary && canvasTarget?.dispose) canvasTarget.dispose();
|
|
14631
14625
|
state.events.disconnect?.();
|
|
14632
14626
|
cleanupHelperGroup(root.store);
|
|
14633
14627
|
if (state.isLegacy && renderer) {
|
|
@@ -14753,6 +14747,207 @@ function flushSync(fn) {
|
|
|
14753
14747
|
return reconciler.flushSyncFromReconciler(fn);
|
|
14754
14748
|
}
|
|
14755
14749
|
|
|
14750
|
+
const isRef = (obj) => obj.current && obj.current.isScene;
|
|
14751
|
+
const resolveScene = (scene) => isRef(scene) ? scene.current : scene;
|
|
14752
|
+
function setEnvProps(background, scene, defaultScene, texture, sceneProps = {}) {
|
|
14753
|
+
sceneProps = {
|
|
14754
|
+
backgroundBlurriness: 0,
|
|
14755
|
+
backgroundIntensity: 1,
|
|
14756
|
+
backgroundRotation: [0, 0, 0],
|
|
14757
|
+
environmentIntensity: 1,
|
|
14758
|
+
environmentRotation: [0, 0, 0],
|
|
14759
|
+
...sceneProps
|
|
14760
|
+
};
|
|
14761
|
+
const target = resolveScene(scene || defaultScene);
|
|
14762
|
+
const oldbg = target.background;
|
|
14763
|
+
const oldenv = target.environment;
|
|
14764
|
+
const oldSceneProps = {
|
|
14765
|
+
backgroundBlurriness: target.backgroundBlurriness,
|
|
14766
|
+
backgroundIntensity: target.backgroundIntensity,
|
|
14767
|
+
backgroundRotation: target.backgroundRotation.clone(),
|
|
14768
|
+
environmentIntensity: target.environmentIntensity,
|
|
14769
|
+
environmentRotation: target.environmentRotation.clone()
|
|
14770
|
+
};
|
|
14771
|
+
if (background !== "only") target.environment = texture;
|
|
14772
|
+
if (background) target.background = texture;
|
|
14773
|
+
applyProps(target, sceneProps);
|
|
14774
|
+
return () => {
|
|
14775
|
+
if (background !== "only") target.environment = oldenv;
|
|
14776
|
+
if (background) target.background = oldbg;
|
|
14777
|
+
applyProps(target, oldSceneProps);
|
|
14778
|
+
};
|
|
14779
|
+
}
|
|
14780
|
+
function EnvironmentMap({ scene, background = false, map, ...config }) {
|
|
14781
|
+
const defaultScene = useThree$1((state) => state.scene);
|
|
14782
|
+
React.useLayoutEffect(() => {
|
|
14783
|
+
if (map) return setEnvProps(background, scene, defaultScene, map, config);
|
|
14784
|
+
});
|
|
14785
|
+
return null;
|
|
14786
|
+
}
|
|
14787
|
+
function EnvironmentCube({
|
|
14788
|
+
background = false,
|
|
14789
|
+
scene,
|
|
14790
|
+
blur,
|
|
14791
|
+
backgroundBlurriness,
|
|
14792
|
+
backgroundIntensity,
|
|
14793
|
+
backgroundRotation,
|
|
14794
|
+
environmentIntensity,
|
|
14795
|
+
environmentRotation,
|
|
14796
|
+
...rest
|
|
14797
|
+
}) {
|
|
14798
|
+
const texture = useEnvironment(rest);
|
|
14799
|
+
const defaultScene = useThree$1((state) => state.scene);
|
|
14800
|
+
React.useLayoutEffect(() => {
|
|
14801
|
+
return setEnvProps(background, scene, defaultScene, texture, {
|
|
14802
|
+
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
14803
|
+
backgroundIntensity,
|
|
14804
|
+
backgroundRotation,
|
|
14805
|
+
environmentIntensity,
|
|
14806
|
+
environmentRotation
|
|
14807
|
+
});
|
|
14808
|
+
});
|
|
14809
|
+
React.useEffect(() => {
|
|
14810
|
+
return () => {
|
|
14811
|
+
texture.dispose();
|
|
14812
|
+
};
|
|
14813
|
+
}, [texture]);
|
|
14814
|
+
return null;
|
|
14815
|
+
}
|
|
14816
|
+
function EnvironmentPortal({
|
|
14817
|
+
children,
|
|
14818
|
+
near = 0.1,
|
|
14819
|
+
far = 1e3,
|
|
14820
|
+
resolution = 256,
|
|
14821
|
+
frames = 1,
|
|
14822
|
+
map,
|
|
14823
|
+
background = false,
|
|
14824
|
+
blur,
|
|
14825
|
+
backgroundBlurriness,
|
|
14826
|
+
backgroundIntensity,
|
|
14827
|
+
backgroundRotation,
|
|
14828
|
+
environmentIntensity,
|
|
14829
|
+
environmentRotation,
|
|
14830
|
+
scene,
|
|
14831
|
+
files,
|
|
14832
|
+
path,
|
|
14833
|
+
preset = void 0,
|
|
14834
|
+
extensions
|
|
14835
|
+
}) {
|
|
14836
|
+
const renderer = useThree$1((state) => state.renderer);
|
|
14837
|
+
const isLegacy = useThree$1((state) => state.isLegacy);
|
|
14838
|
+
const defaultScene = useThree$1((state) => state.scene);
|
|
14839
|
+
const camera = React.useRef(null);
|
|
14840
|
+
const [virtualScene] = React.useState(() => new Scene());
|
|
14841
|
+
const fbo = React.useMemo(() => {
|
|
14842
|
+
const fbo2 = isLegacy ? new WebGLCubeRenderTarget(resolution) : new CubeRenderTarget(resolution);
|
|
14843
|
+
fbo2.texture.type = HalfFloatType;
|
|
14844
|
+
return fbo2;
|
|
14845
|
+
}, [resolution, isLegacy]);
|
|
14846
|
+
React.useEffect(() => {
|
|
14847
|
+
return () => {
|
|
14848
|
+
fbo.dispose();
|
|
14849
|
+
};
|
|
14850
|
+
}, [fbo]);
|
|
14851
|
+
React.useLayoutEffect(() => {
|
|
14852
|
+
if (frames === 1) {
|
|
14853
|
+
const autoClear = renderer.autoClear;
|
|
14854
|
+
renderer.autoClear = true;
|
|
14855
|
+
camera.current.update(renderer, virtualScene);
|
|
14856
|
+
renderer.autoClear = autoClear;
|
|
14857
|
+
}
|
|
14858
|
+
return setEnvProps(background, scene, defaultScene, fbo.texture, {
|
|
14859
|
+
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
14860
|
+
backgroundIntensity,
|
|
14861
|
+
backgroundRotation,
|
|
14862
|
+
environmentIntensity,
|
|
14863
|
+
environmentRotation
|
|
14864
|
+
});
|
|
14865
|
+
}, [
|
|
14866
|
+
children,
|
|
14867
|
+
virtualScene,
|
|
14868
|
+
fbo.texture,
|
|
14869
|
+
scene,
|
|
14870
|
+
defaultScene,
|
|
14871
|
+
background,
|
|
14872
|
+
frames,
|
|
14873
|
+
renderer,
|
|
14874
|
+
blur,
|
|
14875
|
+
backgroundBlurriness,
|
|
14876
|
+
backgroundIntensity,
|
|
14877
|
+
backgroundRotation,
|
|
14878
|
+
environmentIntensity,
|
|
14879
|
+
environmentRotation
|
|
14880
|
+
]);
|
|
14881
|
+
let count = 1;
|
|
14882
|
+
useFrame$1(() => {
|
|
14883
|
+
if (frames === Infinity || count < frames) {
|
|
14884
|
+
const autoClear = renderer.autoClear;
|
|
14885
|
+
renderer.autoClear = true;
|
|
14886
|
+
camera.current.update(renderer, virtualScene);
|
|
14887
|
+
renderer.autoClear = autoClear;
|
|
14888
|
+
count++;
|
|
14889
|
+
}
|
|
14890
|
+
});
|
|
14891
|
+
return /* @__PURE__ */ jsx(Fragment, { children: createPortal(
|
|
14892
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
14893
|
+
children,
|
|
14894
|
+
/* @__PURE__ */ jsx("cubeCamera", { ref: camera, args: [near, far, fbo] }),
|
|
14895
|
+
files || preset ? /* @__PURE__ */ jsx(EnvironmentCube, { background: true, files, preset, path, extensions }) : map ? /* @__PURE__ */ jsx(EnvironmentMap, { background: true, map, extensions }) : null
|
|
14896
|
+
] }),
|
|
14897
|
+
virtualScene
|
|
14898
|
+
) });
|
|
14899
|
+
}
|
|
14900
|
+
function EnvironmentGround(props) {
|
|
14901
|
+
const textureDefault = useEnvironment(props);
|
|
14902
|
+
const texture = props.map || textureDefault;
|
|
14903
|
+
React.useMemo(() => extend({ GroundProjectedEnvImpl: GroundedSkybox }), []);
|
|
14904
|
+
React.useEffect(() => {
|
|
14905
|
+
return () => {
|
|
14906
|
+
textureDefault.dispose();
|
|
14907
|
+
};
|
|
14908
|
+
}, [textureDefault]);
|
|
14909
|
+
const height = props.ground?.height ?? 15;
|
|
14910
|
+
const radius = props.ground?.radius ?? 60;
|
|
14911
|
+
const scale = props.ground?.scale ?? 1e3;
|
|
14912
|
+
const args = React.useMemo(
|
|
14913
|
+
() => [texture, height, radius],
|
|
14914
|
+
[texture, height, radius]
|
|
14915
|
+
);
|
|
14916
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
14917
|
+
/* @__PURE__ */ jsx(EnvironmentMap, { ...props, map: texture }),
|
|
14918
|
+
/* @__PURE__ */ jsx("groundProjectedEnvImpl", { args, scale })
|
|
14919
|
+
] });
|
|
14920
|
+
}
|
|
14921
|
+
function EnvironmentColor({ color, scene }) {
|
|
14922
|
+
const defaultScene = useThree$1((state) => state.scene);
|
|
14923
|
+
React.useLayoutEffect(() => {
|
|
14924
|
+
if (color === void 0) return;
|
|
14925
|
+
const target = resolveScene(scene || defaultScene);
|
|
14926
|
+
const oldBg = target.background;
|
|
14927
|
+
target.background = new Color(color);
|
|
14928
|
+
return () => {
|
|
14929
|
+
target.background = oldBg;
|
|
14930
|
+
};
|
|
14931
|
+
});
|
|
14932
|
+
return null;
|
|
14933
|
+
}
|
|
14934
|
+
function EnvironmentDualSource(props) {
|
|
14935
|
+
const { backgroundFiles, ...envProps } = props;
|
|
14936
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
14937
|
+
/* @__PURE__ */ jsx(EnvironmentCube, { ...envProps, background: false }),
|
|
14938
|
+
/* @__PURE__ */ jsx(EnvironmentCube, { ...props, files: backgroundFiles, background: "only" })
|
|
14939
|
+
] });
|
|
14940
|
+
}
|
|
14941
|
+
function Environment(props) {
|
|
14942
|
+
if (props.color && !props.files && !props.preset && !props.map) {
|
|
14943
|
+
return /* @__PURE__ */ jsx(EnvironmentColor, { ...props });
|
|
14944
|
+
}
|
|
14945
|
+
if (props.backgroundFiles && props.backgroundFiles !== props.files) {
|
|
14946
|
+
return /* @__PURE__ */ jsx(EnvironmentDualSource, { ...props });
|
|
14947
|
+
}
|
|
14948
|
+
return props.ground ? /* @__PURE__ */ jsx(EnvironmentGround, { ...props }) : props.map ? /* @__PURE__ */ jsx(EnvironmentMap, { ...props }) : props.children ? /* @__PURE__ */ jsx(EnvironmentPortal, { ...props }) : /* @__PURE__ */ jsx(EnvironmentCube, { ...props });
|
|
14949
|
+
}
|
|
14950
|
+
|
|
14756
14951
|
function parseBackground(background) {
|
|
14757
14952
|
if (!background) return null;
|
|
14758
14953
|
if (typeof background === "object" && !background.isColor) {
|
|
@@ -14962,9 +15157,9 @@ function CanvasImpl({
|
|
|
14962
15157
|
React.useMemo(() => extend(THREE), []);
|
|
14963
15158
|
const Bridge = useBridge();
|
|
14964
15159
|
const backgroundProps = React.useMemo(() => parseBackground(background), [background]);
|
|
14965
|
-
const
|
|
15160
|
+
const [hasInitialSize, setHasInitialSize] = React.useState(false);
|
|
14966
15161
|
const measureConfig = React.useMemo(() => {
|
|
14967
|
-
if (!
|
|
15162
|
+
if (!hasInitialSize) {
|
|
14968
15163
|
return {
|
|
14969
15164
|
...resize,
|
|
14970
15165
|
scroll: resize?.scroll ?? true,
|
|
@@ -14976,7 +15171,7 @@ function CanvasImpl({
|
|
|
14976
15171
|
debounce: { scroll: 50, resize: 0 },
|
|
14977
15172
|
...resize
|
|
14978
15173
|
};
|
|
14979
|
-
}, [
|
|
15174
|
+
}, [hasInitialSize, resize]);
|
|
14980
15175
|
const [containerRef, containerRect] = useMeasure(measureConfig);
|
|
14981
15176
|
const effectiveSize = React.useMemo(() => {
|
|
14982
15177
|
let w = width ?? containerRect.width;
|
|
@@ -14992,9 +15187,7 @@ function CanvasImpl({
|
|
|
14992
15187
|
left: containerRect.left
|
|
14993
15188
|
};
|
|
14994
15189
|
}, [width, height, containerRect, forceEven]);
|
|
14995
|
-
if (!
|
|
14996
|
-
hasInitialSizeRef.current = true;
|
|
14997
|
-
}
|
|
15190
|
+
if (!hasInitialSize && effectiveSize.width > 0 && effectiveSize.height > 0) setHasInitialSize(true);
|
|
14998
15191
|
const canvasRef = React.useRef(null);
|
|
14999
15192
|
const divRef = React.useRef(null);
|
|
15000
15193
|
React.useImperativeHandle(ref, () => canvasRef.current);
|
|
@@ -15059,7 +15252,7 @@ function CanvasImpl({
|
|
|
15059
15252
|
onDropMissed: (...args) => handleDropMissed.current?.(...args),
|
|
15060
15253
|
onCreated: (state) => {
|
|
15061
15254
|
state.events.connect?.(
|
|
15062
|
-
eventSource ? isRef(eventSource) ? eventSource.current : eventSource : divRef.current
|
|
15255
|
+
eventSource ? isRef$1(eventSource) ? eventSource.current : eventSource : divRef.current
|
|
15063
15256
|
);
|
|
15064
15257
|
if (eventPrefix) {
|
|
15065
15258
|
state.setEvents({
|
|
@@ -15108,6 +15301,7 @@ function CanvasImpl({
|
|
|
15108
15301
|
const canvas = canvasRef.current;
|
|
15109
15302
|
if (canvas) {
|
|
15110
15303
|
return () => {
|
|
15304
|
+
if (canvas.isConnected) return;
|
|
15111
15305
|
unmountComponentAtNode(canvas);
|
|
15112
15306
|
root.current = null;
|
|
15113
15307
|
};
|
|
@@ -15166,20 +15360,36 @@ function CanvasImpl({
|
|
|
15166
15360
|
}
|
|
15167
15361
|
);
|
|
15168
15362
|
}
|
|
15169
|
-
function Canvas(props) {
|
|
15363
|
+
function Canvas$1(props) {
|
|
15170
15364
|
return /* @__PURE__ */ jsx(FiberProvider, { children: /* @__PURE__ */ jsx(CanvasImpl, { ...props }) });
|
|
15171
15365
|
}
|
|
15172
15366
|
|
|
15367
|
+
const isObjectLike = (value) => value !== null && (typeof value === "object" || typeof value === "function");
|
|
15368
|
+
const hasValidLegacyNodeMarkers = (value) => {
|
|
15369
|
+
const hasUuid = "uuid" in value;
|
|
15370
|
+
const hasNodeType = "nodeType" in value;
|
|
15371
|
+
const uuid = Reflect.get(value, "uuid");
|
|
15372
|
+
const nodeType = Reflect.get(value, "nodeType");
|
|
15373
|
+
return (hasUuid || hasNodeType) && (!hasUuid || uuid === void 0 || typeof uuid === "string") && (!hasNodeType || nodeType === void 0 || nodeType === null || typeof nodeType === "string");
|
|
15374
|
+
};
|
|
15375
|
+
const isUniformNode = (value) => isObjectLike(value) && "isUniformNode" in value && value.isUniformNode === true;
|
|
15376
|
+
const isTSLNode = (value) => isObjectLike(value) && (Reflect.get(value, "isNode") === true || Reflect.get(value, "shaderNode") !== void 0 && typeof Reflect.get(value, "id") === "number" || hasValidLegacyNodeMarkers(value));
|
|
15377
|
+
const isBufferLike = (value) => ArrayBuffer.isView(value) && !(value instanceof DataView) || isObjectLike(value) && ("isBufferAttribute" in value || "isInterleavedBufferAttribute" in value || isTSLNode(value));
|
|
15378
|
+
const isStorageLike = (value) => isObjectLike(value) && ("isTexture" in value || "isData3DTexture" in value || isTSLNode(value));
|
|
15379
|
+
|
|
15173
15380
|
var __defProp = Object.defineProperty;
|
|
15174
15381
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
15175
15382
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
15176
|
-
var _a;
|
|
15383
|
+
var _a, _b;
|
|
15177
15384
|
const INTERNAL_DATA = Symbol("ScopedStore.data");
|
|
15178
|
-
|
|
15385
|
+
const INTERNAL_IS_LEAF = Symbol("ScopedStore.isLeaf");
|
|
15386
|
+
_b = INTERNAL_DATA, _a = INTERNAL_IS_LEAF;
|
|
15179
15387
|
const _ScopedStore = class _ScopedStore {
|
|
15180
|
-
constructor(data) {
|
|
15388
|
+
constructor(data, isLeaf) {
|
|
15389
|
+
__publicField(this, _b);
|
|
15181
15390
|
__publicField(this, _a);
|
|
15182
15391
|
this[INTERNAL_DATA] = data;
|
|
15392
|
+
this[INTERNAL_IS_LEAF] = isLeaf;
|
|
15183
15393
|
return new Proxy(this, {
|
|
15184
15394
|
get(target, prop, receiver) {
|
|
15185
15395
|
if (typeof prop === "string") {
|
|
@@ -15213,10 +15423,10 @@ const _ScopedStore = class _ScopedStore {
|
|
|
15213
15423
|
* If the key doesn't exist or isn't a scope object, returns an empty ScopedStore.
|
|
15214
15424
|
*/
|
|
15215
15425
|
scope(key) {
|
|
15216
|
-
const
|
|
15217
|
-
|
|
15218
|
-
|
|
15219
|
-
);
|
|
15426
|
+
const value = this[INTERNAL_DATA][key];
|
|
15427
|
+
const isLeaf = this[INTERNAL_IS_LEAF];
|
|
15428
|
+
const scope = value && typeof value === "object" && !isLeaf(value) ? value : {};
|
|
15429
|
+
return new _ScopedStore(scope, isLeaf);
|
|
15220
15430
|
}
|
|
15221
15431
|
/**
|
|
15222
15432
|
* Check if a key exists in the store.
|
|
@@ -15232,8 +15442,8 @@ const _ScopedStore = class _ScopedStore {
|
|
|
15232
15442
|
}
|
|
15233
15443
|
};
|
|
15234
15444
|
let ScopedStore = _ScopedStore;
|
|
15235
|
-
function createScopedStore(data) {
|
|
15236
|
-
return new ScopedStore(data);
|
|
15445
|
+
function createScopedStore(data, isLeaf) {
|
|
15446
|
+
return new ScopedStore(data, isLeaf);
|
|
15237
15447
|
}
|
|
15238
15448
|
function createLazyCreatorState(state, store) {
|
|
15239
15449
|
let _uniforms = null;
|
|
@@ -15244,22 +15454,22 @@ function createLazyCreatorState(state, store) {
|
|
|
15244
15454
|
return Object.create(state, {
|
|
15245
15455
|
uniforms: {
|
|
15246
15456
|
get() {
|
|
15247
|
-
return _uniforms ?? (_uniforms = createScopedStore(view("uniforms")));
|
|
15457
|
+
return _uniforms ?? (_uniforms = createScopedStore(view("uniforms"), isUniformNode));
|
|
15248
15458
|
}
|
|
15249
15459
|
},
|
|
15250
15460
|
nodes: {
|
|
15251
15461
|
get() {
|
|
15252
|
-
return _nodes ?? (_nodes = createScopedStore(view("nodes")));
|
|
15462
|
+
return _nodes ?? (_nodes = createScopedStore(view("nodes"), isTSLNode));
|
|
15253
15463
|
}
|
|
15254
15464
|
},
|
|
15255
15465
|
buffers: {
|
|
15256
15466
|
get() {
|
|
15257
|
-
return _buffers ?? (_buffers = createScopedStore(view("buffers")));
|
|
15467
|
+
return _buffers ?? (_buffers = createScopedStore(view("buffers"), isBufferLike));
|
|
15258
15468
|
}
|
|
15259
15469
|
},
|
|
15260
15470
|
gpuStorage: {
|
|
15261
15471
|
get() {
|
|
15262
|
-
return _gpuStorage ?? (_gpuStorage = createScopedStore(view("gpuStorage")));
|
|
15472
|
+
return _gpuStorage ?? (_gpuStorage = createScopedStore(view("gpuStorage"), isStorageLike));
|
|
15263
15473
|
}
|
|
15264
15474
|
}
|
|
15265
15475
|
});
|
|
@@ -15318,6 +15528,11 @@ function createTextureOperations(set) {
|
|
|
15318
15528
|
removeMultiple: (keys) => removeTextures(set, keys)
|
|
15319
15529
|
};
|
|
15320
15530
|
}
|
|
15531
|
+
function scopedNodeName(scope, name) {
|
|
15532
|
+
const raw = scope ? `${scope}_${name}` : name;
|
|
15533
|
+
const safe = raw.replace(/[^A-Za-z0-9_]/g, "_");
|
|
15534
|
+
return /^[A-Za-z_]/.test(safe) ? safe : `_${safe}`;
|
|
15535
|
+
}
|
|
15321
15536
|
function extractTSLValue(value) {
|
|
15322
15537
|
if (value === null || value === void 0) return value;
|
|
15323
15538
|
if (typeof value !== "object") return value;
|
|
@@ -15355,7 +15570,7 @@ function vectorize(inObject) {
|
|
|
15355
15570
|
return extractTSLValue(inObject);
|
|
15356
15571
|
}
|
|
15357
15572
|
if (obj.isVector2 || obj.isVector3 || obj.isVector4) return inObject;
|
|
15358
|
-
if (obj.isMatrix3 || obj.isMatrix4) return inObject;
|
|
15573
|
+
if (obj.isMatrix2 || obj.isMatrix3 || obj.isMatrix4) return inObject;
|
|
15359
15574
|
if (obj.isColor || obj.isEuler || obj.isQuaternion || obj.isSpherical) return inObject;
|
|
15360
15575
|
if ("r" in obj && "g" in obj && "b" in obj && typeof obj.r === "number" && typeof obj.g === "number" && typeof obj.b === "number") {
|
|
15361
15576
|
const scale = obj.r > 1 || obj.g > 1 || obj.b > 1 ? 1 / 255 : 1;
|
|
@@ -15413,22 +15628,21 @@ function useScopedResource(options) {
|
|
|
15413
15628
|
return entries;
|
|
15414
15629
|
}
|
|
15415
15630
|
|
|
15416
|
-
const isUniformNode$1 = (value) => value !== null && typeof value === "object" && "value" in value && "uuid" in value;
|
|
15417
15631
|
function useUniforms(creatorOrScope, scope) {
|
|
15418
15632
|
const store = usePrimaryStore();
|
|
15419
15633
|
const removeUniforms2 = useCallback(
|
|
15420
|
-
(names, targetScope) => removeResourceEntries(store, "uniforms", Array.isArray(names) ? names : [names], targetScope, isUniformNode
|
|
15634
|
+
(names, targetScope) => removeResourceEntries(store, "uniforms", Array.isArray(names) ? names : [names], targetScope, isUniformNode),
|
|
15421
15635
|
[store]
|
|
15422
15636
|
);
|
|
15423
15637
|
const clearUniforms = useCallback(
|
|
15424
|
-
(targetScope) => clearResourceEntries(store, "uniforms", targetScope, isUniformNode
|
|
15638
|
+
(targetScope) => clearResourceEntries(store, "uniforms", targetScope, isUniformNode),
|
|
15425
15639
|
[store]
|
|
15426
15640
|
);
|
|
15427
15641
|
const rebuildUniforms = useCallback(
|
|
15428
15642
|
(targetScope) => rebuildResource(store, "uniforms", targetScope),
|
|
15429
15643
|
[store]
|
|
15430
15644
|
);
|
|
15431
|
-
const
|
|
15645
|
+
const processedInput = useMemo(() => {
|
|
15432
15646
|
let raw = creatorOrScope;
|
|
15433
15647
|
if (is.fun(creatorOrScope)) {
|
|
15434
15648
|
const wrappedState = createLazyCreatorState(store.getState(), store);
|
|
@@ -15439,23 +15653,24 @@ function useUniforms(creatorOrScope, scope) {
|
|
|
15439
15653
|
for (const [key, value] of Object.entries(raw)) {
|
|
15440
15654
|
normalized[key] = vectorize(value);
|
|
15441
15655
|
}
|
|
15442
|
-
return normalized;
|
|
15656
|
+
return { candidates: raw, normalized };
|
|
15443
15657
|
}
|
|
15444
|
-
return raw;
|
|
15658
|
+
return { candidates: raw, normalized: raw };
|
|
15445
15659
|
}, [creatorOrScope, store]);
|
|
15446
|
-
const memoizedInput = useCompareMemoize(
|
|
15660
|
+
const memoizedInput = useCompareMemoize(processedInput.normalized);
|
|
15447
15661
|
const isReader = memoizedInput === void 0 || typeof memoizedInput === "string";
|
|
15448
15662
|
const storeUniforms = usePrimaryThree((s) => s.uniforms);
|
|
15449
15663
|
const created = useScopedResource({
|
|
15450
15664
|
store,
|
|
15451
15665
|
kind: "uniforms",
|
|
15452
15666
|
scope: isReader ? void 0 : scope,
|
|
15453
|
-
isLeaf: isUniformNode
|
|
15667
|
+
isLeaf: isUniformNode,
|
|
15454
15668
|
input: memoizedInput,
|
|
15455
15669
|
create: () => {
|
|
15456
15670
|
if (isReader) return {};
|
|
15457
|
-
if (typeof
|
|
15458
|
-
|
|
15671
|
+
if (typeof processedInput.candidates !== "object" || processedInput.candidates === null)
|
|
15672
|
+
throw new Error("Invalid uniform input");
|
|
15673
|
+
return processedInput.candidates;
|
|
15459
15674
|
},
|
|
15460
15675
|
prepare: (name, candidate) => createUniform(name, candidate, scope),
|
|
15461
15676
|
reconcile: (existing, candidate) => {
|
|
@@ -15477,7 +15692,7 @@ function useUniforms(creatorOrScope, scope) {
|
|
|
15477
15692
|
uniforms = storeUniforms;
|
|
15478
15693
|
} else if (typeof memoizedInput === "string") {
|
|
15479
15694
|
const scopeData = storeUniforms[memoizedInput];
|
|
15480
|
-
uniforms = scopeData && !isUniformNode
|
|
15695
|
+
uniforms = scopeData && !isUniformNode(scopeData) ? scopeData : {};
|
|
15481
15696
|
}
|
|
15482
15697
|
return { ...uniforms, removeUniforms: removeUniforms2, clearUniforms, rebuildUniforms };
|
|
15483
15698
|
}
|
|
@@ -15492,7 +15707,7 @@ function removeUniforms(set, names, scope) {
|
|
|
15492
15707
|
return { uniforms: { ...state.uniforms, [scope]: currentScope } };
|
|
15493
15708
|
}
|
|
15494
15709
|
const uniforms = { ...state.uniforms };
|
|
15495
|
-
for (const name of names) if (isUniformNode
|
|
15710
|
+
for (const name of names) if (isUniformNode(uniforms[name])) delete uniforms[name];
|
|
15496
15711
|
return { uniforms };
|
|
15497
15712
|
});
|
|
15498
15713
|
}
|
|
@@ -15506,7 +15721,7 @@ function clearRootUniforms(set) {
|
|
|
15506
15721
|
set((state) => {
|
|
15507
15722
|
const uniforms = {};
|
|
15508
15723
|
for (const [key, value] of Object.entries(state.uniforms)) {
|
|
15509
|
-
if (!isUniformNode
|
|
15724
|
+
if (!isUniformNode(value)) uniforms[key] = value;
|
|
15510
15725
|
}
|
|
15511
15726
|
return { uniforms };
|
|
15512
15727
|
});
|
|
@@ -15516,8 +15731,7 @@ function createUniform(inName, node, scope) {
|
|
|
15516
15731
|
const inValue = vectorize(node);
|
|
15517
15732
|
const newUniform = uniform(inValue);
|
|
15518
15733
|
if (typeof newUniform.setName === "function") {
|
|
15519
|
-
|
|
15520
|
-
newUniform.setName(name);
|
|
15734
|
+
newUniform.setName(scopedNodeName(scope, inName));
|
|
15521
15735
|
}
|
|
15522
15736
|
return newUniform;
|
|
15523
15737
|
}
|
|
@@ -15543,12 +15757,10 @@ function hasEqualsMethod(value) {
|
|
|
15543
15757
|
function isSameThreeType(a, b) {
|
|
15544
15758
|
const obj_a = a;
|
|
15545
15759
|
const obj_b = b;
|
|
15546
|
-
return obj_a.isColor && obj_b.isColor || obj_a.isMatrix3 && obj_b.isMatrix3 || obj_a.isMatrix4 && obj_b.isMatrix4 || obj_a.isEuler && obj_b.isEuler || obj_a.isQuaternion && obj_b.isQuaternion;
|
|
15760
|
+
return obj_a.isColor && obj_b.isColor || obj_a.isMatrix2 && obj_b.isMatrix2 || obj_a.isMatrix3 && obj_b.isMatrix3 || obj_a.isMatrix4 && obj_b.isMatrix4 || obj_a.isEuler && obj_b.isEuler || obj_a.isQuaternion && obj_b.isQuaternion;
|
|
15547
15761
|
}
|
|
15548
15762
|
|
|
15549
15763
|
const uniformOf = uniform;
|
|
15550
|
-
const isUniformNode = (value) => value !== null && typeof value === "object" && "value" in value && "uuid" in value;
|
|
15551
|
-
const isTSLNode$1 = (value) => value !== null && typeof value === "object" && "uuid" in value && "nodeType" in value;
|
|
15552
15764
|
function useUniform(name, value) {
|
|
15553
15765
|
const store = useStore();
|
|
15554
15766
|
const registered = useScopedResource({
|
|
@@ -15560,7 +15772,7 @@ function useUniform(name, value) {
|
|
|
15560
15772
|
create: () => value === void 0 ? {} : { [name]: value },
|
|
15561
15773
|
prepare: createNamedUniform,
|
|
15562
15774
|
reconcile: (existing2) => {
|
|
15563
|
-
if (value !== void 0 && !isTSLNode
|
|
15775
|
+
if (value !== void 0 && !isTSLNode(value) && !isUniformNode(value)) {
|
|
15564
15776
|
existing2.value = typeof value === "string" ? new Color(value) : value;
|
|
15565
15777
|
}
|
|
15566
15778
|
}
|
|
@@ -15576,7 +15788,7 @@ function createNamedUniform(name, value) {
|
|
|
15576
15788
|
let node;
|
|
15577
15789
|
if (isUniformNode(value)) {
|
|
15578
15790
|
node = value;
|
|
15579
|
-
} else if (isTSLNode
|
|
15791
|
+
} else if (isTSLNode(value)) {
|
|
15580
15792
|
node = uniformOf(value);
|
|
15581
15793
|
} else if (typeof value === "string") {
|
|
15582
15794
|
node = uniform(new Color(value));
|
|
@@ -15589,7 +15801,6 @@ function createNamedUniform(name, value) {
|
|
|
15589
15801
|
return node;
|
|
15590
15802
|
}
|
|
15591
15803
|
|
|
15592
|
-
const isTSLNode = (value) => value !== null && typeof value === "object" && ("uuid" in value || "nodeType" in value);
|
|
15593
15804
|
function useNodes(creatorOrScope, scope) {
|
|
15594
15805
|
const store = usePrimaryStore();
|
|
15595
15806
|
const removeNodes2 = useCallback(
|
|
@@ -15616,7 +15827,8 @@ function useNodes(creatorOrScope, scope) {
|
|
|
15616
15827
|
return creatorOrScope(createLazyCreatorState(store.getState(), store));
|
|
15617
15828
|
},
|
|
15618
15829
|
prepare: (name, node) => {
|
|
15619
|
-
|
|
15830
|
+
const setName = Reflect.get(node, "setName");
|
|
15831
|
+
if (typeof setName === "function") setName.call(node, scopedNodeName(scope, name));
|
|
15620
15832
|
return node;
|
|
15621
15833
|
}
|
|
15622
15834
|
});
|
|
@@ -15671,13 +15883,6 @@ function useLocalNodes(creator) {
|
|
|
15671
15883
|
}, [store, creator, uniforms, nodes, textures, hmrVersion]);
|
|
15672
15884
|
}
|
|
15673
15885
|
|
|
15674
|
-
const isBufferLike = (value) => {
|
|
15675
|
-
if (value === null || typeof value !== "object") return false;
|
|
15676
|
-
if (ArrayBuffer.isView(value)) return true;
|
|
15677
|
-
if ("isBufferAttribute" in value) return true;
|
|
15678
|
-
if ("uuid" in value || "nodeType" in value) return true;
|
|
15679
|
-
return false;
|
|
15680
|
-
};
|
|
15681
15886
|
const disposeBuffer = (buffer) => {
|
|
15682
15887
|
if (buffer === null || typeof buffer !== "object") return;
|
|
15683
15888
|
if ("dispose" in buffer && typeof buffer.dispose === "function") {
|
|
@@ -15724,9 +15929,8 @@ function useBuffers(creatorOrScope, scope) {
|
|
|
15724
15929
|
return creatorOrScope(createLazyCreatorState(store.getState(), store));
|
|
15725
15930
|
},
|
|
15726
15931
|
prepare: (name, buffer) => {
|
|
15727
|
-
|
|
15728
|
-
|
|
15729
|
-
}
|
|
15932
|
+
const setName = Reflect.get(buffer, "setName");
|
|
15933
|
+
if (typeof setName === "function") setName.call(buffer, scopedNodeName(scope, name));
|
|
15730
15934
|
return buffer;
|
|
15731
15935
|
}
|
|
15732
15936
|
});
|
|
@@ -15743,13 +15947,6 @@ function rebuildAllBuffers(store, scope) {
|
|
|
15743
15947
|
rebuildResource(store, "buffers", scope);
|
|
15744
15948
|
}
|
|
15745
15949
|
|
|
15746
|
-
const isStorageLike = (value) => {
|
|
15747
|
-
if (value === null || typeof value !== "object") return false;
|
|
15748
|
-
if ("isTexture" in value) return true;
|
|
15749
|
-
if ("isData3DTexture" in value) return true;
|
|
15750
|
-
if ("uuid" in value || "nodeType" in value) return true;
|
|
15751
|
-
return false;
|
|
15752
|
-
};
|
|
15753
15950
|
const disposeStorage = (storage) => {
|
|
15754
15951
|
if (storage === null || typeof storage !== "object") return;
|
|
15755
15952
|
if ("dispose" in storage && typeof storage.dispose === "function") {
|
|
@@ -15796,10 +15993,9 @@ function useGPUStorage(creatorOrScope, scope) {
|
|
|
15796
15993
|
return creatorOrScope(createLazyCreatorState(store.getState(), store));
|
|
15797
15994
|
},
|
|
15798
15995
|
prepare: (name, storage) => {
|
|
15799
|
-
const label = scope
|
|
15800
|
-
|
|
15801
|
-
|
|
15802
|
-
}
|
|
15996
|
+
const label = scopedNodeName(scope, name);
|
|
15997
|
+
const setName = Reflect.get(storage, "setName");
|
|
15998
|
+
if (typeof setName === "function") setName.call(storage, label);
|
|
15803
15999
|
if ("name" in storage && typeof storage.name === "string") {
|
|
15804
16000
|
storage.name = label;
|
|
15805
16001
|
}
|
|
@@ -15827,9 +16023,10 @@ function rebuildAllStorage(store, scope) {
|
|
|
15827
16023
|
|
|
15828
16024
|
function useRenderPipeline(mainCB, setupCB) {
|
|
15829
16025
|
const store = useStore();
|
|
15830
|
-
const { scene, camera, renderer, isLegacy } = useThree();
|
|
16026
|
+
const { scene, camera, renderer, isLegacy } = useThree$1();
|
|
15831
16027
|
const callbacksRanRef = useRef(false);
|
|
15832
16028
|
const scenePassCacheRef = useRef(null);
|
|
16029
|
+
const forceScenePassRebuildRef = useRef(false);
|
|
15833
16030
|
const mainCBRef = useRef(mainCB);
|
|
15834
16031
|
const setupCBRef = useRef(setupCB);
|
|
15835
16032
|
mainCBRef.current = mainCB;
|
|
@@ -15837,7 +16034,7 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
15837
16034
|
const [rebuildVersion, setRebuildVersion] = useState(0);
|
|
15838
16035
|
useEffect(() => {
|
|
15839
16036
|
callbacksRanRef.current = false;
|
|
15840
|
-
|
|
16037
|
+
forceScenePassRebuildRef.current = true;
|
|
15841
16038
|
}, []);
|
|
15842
16039
|
const clearPasses = useCallback(() => {
|
|
15843
16040
|
store.setState({ passes: {} });
|
|
@@ -15847,12 +16044,14 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
15847
16044
|
renderPipeline: null,
|
|
15848
16045
|
passes: {}
|
|
15849
16046
|
});
|
|
16047
|
+
scenePassCacheRef.current?.scenePass.dispose();
|
|
15850
16048
|
callbacksRanRef.current = false;
|
|
15851
16049
|
scenePassCacheRef.current = null;
|
|
16050
|
+
forceScenePassRebuildRef.current = false;
|
|
15852
16051
|
}, [store]);
|
|
15853
16052
|
const rebuild = useCallback(() => {
|
|
15854
16053
|
callbacksRanRef.current = false;
|
|
15855
|
-
|
|
16054
|
+
forceScenePassRebuildRef.current = true;
|
|
15856
16055
|
setRebuildVersion((v) => v + 1);
|
|
15857
16056
|
}, []);
|
|
15858
16057
|
useLayoutEffect(() => {
|
|
@@ -15860,6 +16059,9 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
15860
16059
|
throw new Error("useRenderPipeline is only available with WebGPU renderer. Set renderer prop on Canvas.");
|
|
15861
16060
|
}
|
|
15862
16061
|
if (!renderer || !scene || !camera) return;
|
|
16062
|
+
if (!("isWebGPURenderer" in renderer)) {
|
|
16063
|
+
throw new Error("useRenderPipeline: renderer is not a WebGPURenderer but isLegacy is false.");
|
|
16064
|
+
}
|
|
15863
16065
|
const state = store.getState();
|
|
15864
16066
|
const set = store.setState;
|
|
15865
16067
|
try {
|
|
@@ -15870,21 +16072,33 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
15870
16072
|
pipeline = new RenderPipeline(renderer);
|
|
15871
16073
|
justCreatedPipeline = true;
|
|
15872
16074
|
}
|
|
15873
|
-
const cacheValid = scenePassCacheRef.current && scenePassCacheRef.current.sceneUuid === scene.uuid && scenePassCacheRef.current.cameraUuid === camera.uuid;
|
|
16075
|
+
const cacheValid = !forceScenePassRebuildRef.current && scenePassCacheRef.current && scenePassCacheRef.current.sceneUuid === scene.uuid && scenePassCacheRef.current.cameraUuid === camera.uuid;
|
|
16076
|
+
let outgoingScenePass = null;
|
|
15874
16077
|
let scenePass;
|
|
15875
16078
|
if (cacheValid) {
|
|
15876
16079
|
scenePass = scenePassCacheRef.current.scenePass;
|
|
15877
16080
|
} else {
|
|
16081
|
+
outgoingScenePass = scenePassCacheRef.current?.scenePass ?? null;
|
|
15878
16082
|
scenePass = pass(scene, camera);
|
|
15879
16083
|
scenePassCacheRef.current = { sceneUuid: scene.uuid, cameraUuid: camera.uuid, scenePass };
|
|
16084
|
+
forceScenePassRebuildRef.current = false;
|
|
15880
16085
|
}
|
|
15881
16086
|
currentPasses.scenePass = scenePass;
|
|
15882
|
-
|
|
16087
|
+
let outputNodeChanged = false;
|
|
16088
|
+
if (!pipeline.outputNode || justCreatedPipeline || pipeline.outputNode === outgoingScenePass) {
|
|
16089
|
+
pipeline.outputNode = scenePass;
|
|
16090
|
+
outputNodeChanged = true;
|
|
16091
|
+
}
|
|
15883
16092
|
set({ renderPipeline: pipeline, passes: currentPasses });
|
|
15884
16093
|
const shouldRunCallbacks = justCreatedPipeline || !callbacksRanRef.current || !cacheValid;
|
|
15885
16094
|
if (shouldRunCallbacks) {
|
|
15886
16095
|
if (setupCBRef.current) {
|
|
15887
|
-
const freshState = store.getState()
|
|
16096
|
+
const freshState = Object.assign({}, store.getState(), {
|
|
16097
|
+
renderPipeline: pipeline,
|
|
16098
|
+
passes: { ...currentPasses, scenePass },
|
|
16099
|
+
renderer,
|
|
16100
|
+
isLegacy: false
|
|
16101
|
+
});
|
|
15888
16102
|
const setupResult = setupCBRef.current(freshState);
|
|
15889
16103
|
if (setupResult && typeof setupResult === "object") {
|
|
15890
16104
|
currentPasses = { ...currentPasses, ...setupResult };
|
|
@@ -15892,32 +16106,37 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
15892
16106
|
}
|
|
15893
16107
|
}
|
|
15894
16108
|
if (mainCBRef.current) {
|
|
15895
|
-
const freshState = store.getState()
|
|
16109
|
+
const freshState = Object.assign({}, store.getState(), {
|
|
16110
|
+
renderPipeline: pipeline,
|
|
16111
|
+
passes: { ...currentPasses, scenePass },
|
|
16112
|
+
renderer,
|
|
16113
|
+
isLegacy: false
|
|
16114
|
+
});
|
|
15896
16115
|
const mainResult = mainCBRef.current(freshState);
|
|
15897
16116
|
if (mainResult && typeof mainResult === "object") {
|
|
15898
16117
|
currentPasses = { ...currentPasses, ...mainResult };
|
|
15899
16118
|
set({ passes: currentPasses });
|
|
15900
16119
|
}
|
|
15901
16120
|
}
|
|
16121
|
+
outputNodeChanged = true;
|
|
15902
16122
|
callbacksRanRef.current = true;
|
|
15903
16123
|
}
|
|
16124
|
+
if (outputNodeChanged) pipeline.needsUpdate = true;
|
|
16125
|
+
if (outgoingScenePass && outgoingScenePass !== scenePass) outgoingScenePass.dispose();
|
|
15904
16126
|
} catch (error) {
|
|
15905
16127
|
console.warn("[useRenderPipeline] Setup failed; the render pipeline was not configured:", error);
|
|
15906
16128
|
}
|
|
15907
16129
|
}, [store, renderer, scene, camera, isLegacy, rebuildVersion]);
|
|
15908
|
-
const passes = useThree((s) => s.passes);
|
|
15909
|
-
const renderPipeline = useThree((s) => s.renderPipeline);
|
|
15910
|
-
|
|
15911
|
-
|
|
15912
|
-
|
|
15913
|
-
clearPasses,
|
|
15914
|
-
reset,
|
|
15915
|
-
rebuild,
|
|
15916
|
-
// isReady indicates if RenderPipeline is configured and ready for rendering
|
|
15917
|
-
isReady: renderPipeline !== null
|
|
15918
|
-
};
|
|
16130
|
+
const passes = useThree$1((s) => s.passes);
|
|
16131
|
+
const renderPipeline = useThree$1((s) => s.renderPipeline);
|
|
16132
|
+
const actions = { passes, clearPasses, reset, rebuild };
|
|
16133
|
+
if (renderPipeline) return { ...actions, isReady: true, renderPipeline };
|
|
16134
|
+
return { ...actions, isReady: false, renderPipeline: null };
|
|
15919
16135
|
}
|
|
15920
16136
|
|
|
15921
16137
|
extend(THREE);
|
|
16138
|
+
const useThree = useThree$1;
|
|
16139
|
+
const useFrame = useFrame$1;
|
|
16140
|
+
const Canvas = Canvas$1;
|
|
15922
16141
|
|
|
15923
|
-
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,
|
|
16142
|
+
export { Block, Canvas, Environment, EnvironmentCube, EnvironmentMap, EnvironmentPortal, ErrorBoundary, FROM_REF, IsObject, ONCE, Portal, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, Texture, _roots, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, clearNodeScope, clearRootNodes, clearRootUniforms, clearScope, context, createEvents, createPointerEvents, createPortal, createRoot, createScopedStore, createStore, createTextureOperations, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, fromRef, getInstanceProps, getPrimary, getPrimaryIds, getRootState, getUuidPrefix, hasConstructor, hasPrimary, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isFromRef, isObject3D, isOnce, isOrthographicCamera, isRef$1 as isRef, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, rebuildAllBuffers, rebuildAllNodes, rebuildAllStorage, rebuildAllUniforms, reconciler, registerPrimary, removeInteractivity, removeNodes, removeUniforms, resolve, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useBuffers, useEnvironment, useFrame, useGPUStorage, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useLocalNodes, useMutableCallback, useNodes, useRenderPipeline, useRenderTarget, useStore, useTexture, useTextures, useThree, useUniform, useUniforms, waitForPrimary };
|