@react-three/fiber 10.0.0-canary.c49d4cb → 10.0.0-canary.c6846c3
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 +1734 -1576
- package/dist/index.d.cts +22 -10
- package/dist/index.d.mts +22 -10
- package/dist/index.d.ts +22 -10
- package/dist/index.mjs +1736 -1578
- package/dist/legacy.cjs +1732 -1574
- package/dist/legacy.d.cts +22 -10
- package/dist/legacy.d.mts +22 -10
- package/dist/legacy.d.ts +22 -10
- package/dist/legacy.mjs +1734 -1576
- package/dist/webgpu/index.cjs +2012 -2096
- package/dist/webgpu/index.d.cts +38 -14
- package/dist/webgpu/index.d.mts +38 -14
- package/dist/webgpu/index.d.ts +38 -14
- package/dist/webgpu/index.mjs +2014 -2098
- package/package.json +3 -3
- 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,
|
|
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';
|
|
3
3
|
import { Inspector } from 'three/addons/inspector/Inspector.js';
|
|
4
4
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
5
5
|
import * as React from 'react';
|
|
6
|
-
import React__default, {
|
|
6
|
+
import React__default, { useRef, useMemo, useLayoutEffect, useEffect, useContext, useImperativeHandle, useCallback, useState } from 'react';
|
|
7
7
|
import useMeasure from 'react-use-measure';
|
|
8
8
|
import { useFiber, useContextBridge, traverseFiber, FiberProvider } from 'its-fine';
|
|
9
|
-
import {
|
|
9
|
+
import { createWithEqualityFn } from 'zustand/traditional';
|
|
10
|
+
import { getScheduler } from '@pmndrs/scheduler';
|
|
11
|
+
export { Scheduler, getScheduler } from '@pmndrs/scheduler';
|
|
12
|
+
import Tb, { unstable_getCurrentPriorityLevel, unstable_IdlePriority, unstable_LowPriority, unstable_NormalPriority, unstable_UserBlockingPriority, unstable_ImmediatePriority, unstable_scheduleCallback } from 'scheduler';
|
|
10
13
|
import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
|
|
11
14
|
import { HDRLoader } from 'three/examples/jsm/loaders/HDRLoader.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';
|
|
@@ -115,556 +114,229 @@ function getPrimaryIds() {
|
|
|
115
114
|
return Array.from(primaryRegistry.keys());
|
|
116
115
|
}
|
|
117
116
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
117
|
+
var __defProp$1 = Object.defineProperty;
|
|
118
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
119
|
+
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
120
|
+
const useIsomorphicLayoutEffect = /* @__PURE__ */ (() => typeof window !== "undefined" && (window.document?.createElement || window.navigator?.product === "ReactNative"))() ? React.useLayoutEffect : React.useEffect;
|
|
121
|
+
function useMutableCallback(fn) {
|
|
122
|
+
const ref = React.useRef(fn);
|
|
123
|
+
useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
|
|
124
|
+
return ref;
|
|
125
|
+
}
|
|
126
|
+
function useBridge() {
|
|
127
|
+
const fiber = useFiber();
|
|
128
|
+
const ContextBridge = useContextBridge();
|
|
129
|
+
return React.useMemo(
|
|
130
|
+
() => ({ children }) => {
|
|
131
|
+
const strict = !!traverseFiber(fiber, true, (node) => node.type === React.StrictMode);
|
|
132
|
+
const Root = strict ? React.StrictMode : React.Fragment;
|
|
133
|
+
return /* @__PURE__ */ jsx(Root, { children: /* @__PURE__ */ jsx(ContextBridge, { children }) });
|
|
134
|
+
},
|
|
135
|
+
[fiber, ContextBridge]
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
function Block({ set }) {
|
|
139
|
+
useIsomorphicLayoutEffect(() => {
|
|
140
|
+
set(new Promise(() => null));
|
|
141
|
+
return () => set(false);
|
|
142
|
+
}, [set]);
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
const ErrorBoundary = /* @__PURE__ */ (() => {
|
|
146
|
+
var _a;
|
|
147
|
+
return _a = class extends React.Component {
|
|
148
|
+
constructor() {
|
|
149
|
+
super(...arguments);
|
|
150
|
+
__publicField$1(this, "state", { error: false });
|
|
151
|
+
}
|
|
152
|
+
componentDidCatch(err) {
|
|
153
|
+
this.props.set(err);
|
|
154
|
+
}
|
|
155
|
+
render() {
|
|
156
|
+
return this.state.error ? null : this.props.children;
|
|
157
|
+
}
|
|
158
|
+
}, __publicField$1(_a, "getDerivedStateFromError", () => ({ error: true })), _a;
|
|
159
|
+
})();
|
|
130
160
|
|
|
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);
|
|
161
|
+
const is = {
|
|
162
|
+
obj: (a) => a === Object(a) && !is.arr(a) && typeof a !== "function",
|
|
163
|
+
fun: (a) => typeof a === "function",
|
|
164
|
+
str: (a) => typeof a === "string",
|
|
165
|
+
num: (a) => typeof a === "number",
|
|
166
|
+
boo: (a) => typeof a === "boolean",
|
|
167
|
+
und: (a) => a === void 0,
|
|
168
|
+
nul: (a) => a === null,
|
|
169
|
+
arr: (a) => Array.isArray(a),
|
|
170
|
+
equ(a, b, { arrays = "shallow", objects = "reference", strict = true } = {}) {
|
|
171
|
+
if (typeof a !== typeof b || !!a !== !!b) return false;
|
|
172
|
+
if (is.str(a) || is.num(a) || is.boo(a)) return a === b;
|
|
173
|
+
const isObj = is.obj(a);
|
|
174
|
+
if (isObj && objects === "reference") return a === b;
|
|
175
|
+
const isArr = is.arr(a);
|
|
176
|
+
if (isArr && arrays === "reference") return a === b;
|
|
177
|
+
if ((isArr || isObj) && a === b) return true;
|
|
178
|
+
let i;
|
|
179
|
+
for (i in a) if (!(i in b)) return false;
|
|
180
|
+
if (isObj && arrays === "shallow" && objects === "shallow") {
|
|
181
|
+
for (i in strict ? b : a) if (!is.equ(a[i], b[i], { strict, objects: "reference" })) return false;
|
|
182
|
+
} else {
|
|
183
|
+
for (i in strict ? b : a) if (a[i] !== b[i]) return false;
|
|
155
184
|
}
|
|
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);
|
|
185
|
+
if (is.und(i)) {
|
|
186
|
+
if (isArr && a.length === 0 && b.length === 0) return true;
|
|
187
|
+
if (isObj && Object.keys(a).length === 0 && Object.keys(b).length === 0) return true;
|
|
188
|
+
if (a !== b) return false;
|
|
167
189
|
}
|
|
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];
|
|
190
|
+
return true;
|
|
217
191
|
}
|
|
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
192
|
};
|
|
223
|
-
|
|
224
|
-
|
|
193
|
+
const isOrthographicCamera = (def) => def && def.isOrthographicCamera;
|
|
194
|
+
const isRef$1 = (obj) => obj !== null && typeof obj === "object" && obj.hasOwnProperty("current");
|
|
195
|
+
const isColorRepresentation = (value) => value != null && (typeof value === "string" || typeof value === "number" || value.isColor);
|
|
196
|
+
const isObject3D = (object) => object?.isObject3D;
|
|
197
|
+
const isTexture = (value) => !!value?.isTexture;
|
|
198
|
+
const isVectorLike = (object) => object !== null && typeof object === "object" && "set" in object && typeof object.set === "function";
|
|
199
|
+
const isCopyable = (object) => isVectorLike(object) && "copy" in object && typeof object.copy === "function";
|
|
200
|
+
const hasConstructor = (object) => !!object?.constructor;
|
|
201
|
+
|
|
202
|
+
function calculateDpr(dpr) {
|
|
203
|
+
const target = typeof window !== "undefined" ? window.devicePixelRatio ?? 2 : 1;
|
|
204
|
+
return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
|
|
225
205
|
}
|
|
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 };
|
|
206
|
+
function getUuidPrefix(uuid) {
|
|
207
|
+
return uuid.split("-")[0];
|
|
232
208
|
}
|
|
233
|
-
function
|
|
234
|
-
|
|
235
|
-
|
|
209
|
+
function updateCamera(camera, size) {
|
|
210
|
+
if (camera.manual) return;
|
|
211
|
+
if (isOrthographicCamera(camera)) {
|
|
212
|
+
camera.left = size.width / -2;
|
|
213
|
+
camera.right = size.width / 2;
|
|
214
|
+
camera.top = size.height / 2;
|
|
215
|
+
camera.bottom = size.height / -2;
|
|
216
|
+
} else {
|
|
217
|
+
camera.aspect = size.width / size.height;
|
|
218
|
+
}
|
|
219
|
+
camera.updateProjectionMatrix();
|
|
236
220
|
}
|
|
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
|
-
};
|
|
221
|
+
const frustumMatrix = new Matrix4();
|
|
222
|
+
function updateFrustum(camera, frustum) {
|
|
223
|
+
const target = frustum ?? new Frustum();
|
|
224
|
+
frustumMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
225
|
+
target.setFromProjectionMatrix(frustumMatrix);
|
|
226
|
+
return target;
|
|
272
227
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
return
|
|
228
|
+
|
|
229
|
+
const REACT_INTERNAL_PROPS = ["children", "key", "ref"];
|
|
230
|
+
function findInitialRoot(instance) {
|
|
231
|
+
let root = instance.root;
|
|
232
|
+
while (root.getState().previousRoot) root = root.getState().previousRoot;
|
|
233
|
+
return root;
|
|
279
234
|
}
|
|
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
|
|
235
|
+
function getRootState(obj) {
|
|
236
|
+
let state = obj.__r3f?.root.getState();
|
|
237
|
+
if (!state) {
|
|
238
|
+
obj.traverseAncestors((ancestor) => {
|
|
239
|
+
const parentState = ancestor.__r3f?.root.getState();
|
|
240
|
+
if (parentState) {
|
|
241
|
+
state = parentState;
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
300
244
|
});
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
return () => {
|
|
304
|
-
texture.dispose();
|
|
305
|
-
};
|
|
306
|
-
}, [texture]);
|
|
307
|
-
return null;
|
|
245
|
+
}
|
|
246
|
+
return state;
|
|
308
247
|
}
|
|
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
|
|
248
|
+
function buildGraph(object) {
|
|
249
|
+
const data = { nodes: {}, materials: {}, meshes: {} };
|
|
250
|
+
if (object) {
|
|
251
|
+
object.traverse((obj) => {
|
|
252
|
+
if (obj.name) data.nodes[obj.name] = obj;
|
|
253
|
+
if (obj.material) {
|
|
254
|
+
const material = Array.isArray(obj.material) ? obj.material[0] : obj.material;
|
|
255
|
+
const nameAlreadyUsed = data.materials[material.name];
|
|
256
|
+
let materialName = material.name;
|
|
257
|
+
if (nameAlreadyUsed) {
|
|
258
|
+
materialName = materialName + `-${getUuidPrefix(material.uuid)}`;
|
|
259
|
+
material.userData.materialCacheName = materialName;
|
|
260
|
+
}
|
|
261
|
+
data.materials[materialName] = material;
|
|
262
|
+
}
|
|
263
|
+
if (obj.isMesh && !data.meshes[obj.name]) data.meshes[obj.name] = obj;
|
|
357
264
|
});
|
|
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
|
-
) });
|
|
392
|
-
}
|
|
393
|
-
function EnvironmentGround(props) {
|
|
394
|
-
const textureDefault = useEnvironment(props);
|
|
395
|
-
const texture = props.map || textureDefault;
|
|
396
|
-
React.useMemo(() => extend$1({ GroundProjectedEnvImpl: GroundedSkybox }), []);
|
|
397
|
-
React.useEffect(() => {
|
|
398
|
-
return () => {
|
|
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
|
-
] });
|
|
413
|
-
}
|
|
414
|
-
function EnvironmentColor({ color, scene }) {
|
|
415
|
-
const defaultScene = useThree$1((state) => state.scene);
|
|
416
|
-
React.useLayoutEffect(() => {
|
|
417
|
-
if (color === void 0) return;
|
|
418
|
-
const target = resolveScene(scene || defaultScene);
|
|
419
|
-
const oldBg = target.background;
|
|
420
|
-
target.background = new Color(color);
|
|
421
|
-
return () => {
|
|
422
|
-
target.background = oldBg;
|
|
423
|
-
};
|
|
424
|
-
});
|
|
425
|
-
return null;
|
|
265
|
+
}
|
|
266
|
+
return data;
|
|
426
267
|
}
|
|
427
|
-
function
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
268
|
+
function dispose(obj) {
|
|
269
|
+
if (obj.type !== "Scene") obj.dispose?.();
|
|
270
|
+
for (const p in obj) {
|
|
271
|
+
const prop = obj[p];
|
|
272
|
+
if (prop?.type !== "Scene") prop?.dispose?.();
|
|
273
|
+
}
|
|
433
274
|
}
|
|
434
|
-
function
|
|
435
|
-
|
|
436
|
-
|
|
275
|
+
function getInstanceProps(pendingProps) {
|
|
276
|
+
const props = {};
|
|
277
|
+
for (const key in pendingProps) {
|
|
278
|
+
if (!REACT_INTERNAL_PROPS.includes(key)) props[key] = pendingProps[key];
|
|
437
279
|
}
|
|
438
|
-
|
|
439
|
-
|
|
280
|
+
return props;
|
|
281
|
+
}
|
|
282
|
+
function prepare(target, root, type, props) {
|
|
283
|
+
const object = target;
|
|
284
|
+
let instance = object?.__r3f;
|
|
285
|
+
if (!instance) {
|
|
286
|
+
instance = {
|
|
287
|
+
root,
|
|
288
|
+
type,
|
|
289
|
+
parent: null,
|
|
290
|
+
children: [],
|
|
291
|
+
props: getInstanceProps(props),
|
|
292
|
+
object,
|
|
293
|
+
eventCount: 0,
|
|
294
|
+
handlers: {},
|
|
295
|
+
isHidden: false
|
|
296
|
+
};
|
|
297
|
+
if (object) object.__r3f = instance;
|
|
440
298
|
}
|
|
441
|
-
return
|
|
299
|
+
return instance;
|
|
300
|
+
}
|
|
301
|
+
function invalidateInstance(instance) {
|
|
302
|
+
if (!instance.parent) return;
|
|
303
|
+
instance.props.onUpdate?.(instance.object);
|
|
304
|
+
const state = instance.root?.getState?.();
|
|
305
|
+
if (state && state.internal.frames === 0) state.invalidate();
|
|
442
306
|
}
|
|
443
307
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
308
|
+
const tempFrustum = new Frustum();
|
|
309
|
+
let hasWarnedWebGL = false;
|
|
310
|
+
let tslModule = null;
|
|
311
|
+
async function loadTSL() {
|
|
312
|
+
if (tslModule) return tslModule;
|
|
313
|
+
try {
|
|
314
|
+
const tsl = await import('three/tsl');
|
|
315
|
+
tslModule = { uniform: tsl.uniform, nodeObject: tsl.nodeObject };
|
|
316
|
+
return tslModule;
|
|
317
|
+
} catch {
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
453
320
|
}
|
|
454
|
-
function
|
|
455
|
-
const
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
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;
|
|
321
|
+
function createOcclusionObserverNode(store, uniform) {
|
|
322
|
+
const node = new Node("float");
|
|
323
|
+
node.updateType = NodeUpdateType.OBJECT;
|
|
324
|
+
node.update = function(frame) {
|
|
325
|
+
const { internal } = store.getState();
|
|
326
|
+
const registry = internal.visibilityRegistry;
|
|
327
|
+
const cache = internal.occlusionCache;
|
|
328
|
+
for (const entry of registry.values()) {
|
|
329
|
+
const { object, handlers } = entry;
|
|
330
|
+
if (handlers.onOccluded || handlers.onVisible) {
|
|
331
|
+
const isOccluded = frame.renderer.isOccluded(object);
|
|
332
|
+
cache.set(object, isOccluded);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
node.setup = function() {
|
|
337
|
+
return uniform(0);
|
|
338
|
+
};
|
|
339
|
+
return node;
|
|
668
340
|
}
|
|
669
341
|
let occlusionSetupPromise = null;
|
|
670
342
|
function enableOcclusion(store) {
|
|
@@ -948,9 +620,9 @@ function diffProps(instance, newProps) {
|
|
|
948
620
|
const { root, key } = resolve(instance.object, prop);
|
|
949
621
|
if (root.constructor && root.constructor.length === 0) {
|
|
950
622
|
const ctor = getMemoizedPrototype(root);
|
|
951
|
-
if (!is.und(ctor)) changedProps[
|
|
623
|
+
if (!is.und(ctor)) changedProps[prop] = ctor[key];
|
|
952
624
|
} else {
|
|
953
|
-
changedProps[
|
|
625
|
+
changedProps[prop] = 0;
|
|
954
626
|
}
|
|
955
627
|
}
|
|
956
628
|
return changedProps;
|
|
@@ -1067,635 +739,90 @@ function applyProps(object, props) {
|
|
|
1067
739
|
return object;
|
|
1068
740
|
}
|
|
1069
741
|
|
|
1070
|
-
const
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
if (!state) {
|
|
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);
|
|
742
|
+
const shownNotices = /* @__PURE__ */ new Set();
|
|
743
|
+
function notifyDepreciated({ heading, body, link }) {
|
|
744
|
+
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_DEPRECATION_WARNINGS !== "true") {
|
|
745
|
+
return;
|
|
1082
746
|
}
|
|
1083
|
-
return
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
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);
|
|
747
|
+
if (shownNotices.has(heading)) return;
|
|
748
|
+
shownNotices.add(heading);
|
|
749
|
+
const caller = getCallerFrame();
|
|
750
|
+
if (caller) {
|
|
751
|
+
console.log();
|
|
1098
752
|
}
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
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
|
-
}
|
|
753
|
+
const boxStyle = "background: #ff9800; color: #1a1a1a; padding: 8px 12px; border-radius: 4px; font-weight: 500;";
|
|
754
|
+
if (caller) {
|
|
755
|
+
console.log(`%c\u26A0\uFE0F ${heading}`, boxStyle);
|
|
1113
756
|
}
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1120
|
-
if (!pointerState) return 0;
|
|
1121
|
-
const [initialX, initialY] = pointerState.initialClick;
|
|
1122
|
-
const dx = event.offsetX - initialX;
|
|
1123
|
-
const dy = event.offsetY - initialY;
|
|
1124
|
-
return Math.round(Math.sqrt(dx * dx + dy * dy));
|
|
757
|
+
if (body || link) {
|
|
758
|
+
let message = "";
|
|
759
|
+
if (body) message += body;
|
|
760
|
+
if (link) message += (body ? "\n\n" : "") + `More info: ${link}`;
|
|
761
|
+
console.warn(`%c${message}`, "font-weight: bold;");
|
|
1125
762
|
}
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
763
|
+
}
|
|
764
|
+
function getCallerFrame(depth = 3) {
|
|
765
|
+
const stack = new Error().stack;
|
|
766
|
+
if (!stack) return null;
|
|
767
|
+
const lines = stack.split("\n");
|
|
768
|
+
const frame = lines[depth];
|
|
769
|
+
if (!frame) return null;
|
|
770
|
+
let match = frame.match(/^\s*at (?:(.+?) )?\(?(.+?):(\d+):(\d+)\)?$/);
|
|
771
|
+
if (!match) {
|
|
772
|
+
match = frame.match(/^(?:(.+?)@)?(.+?):(\d+):(\d+)$/);
|
|
1134
773
|
}
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
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;
|
|
774
|
+
if (!match) return null;
|
|
775
|
+
const [, fn, url, line] = match;
|
|
776
|
+
return {
|
|
777
|
+
functionName: fn ?? "<anonymous>",
|
|
778
|
+
location: formatLocation(url, Number(line))
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
function formatLocation(url, line) {
|
|
782
|
+
const clean = url.split("?")[0];
|
|
783
|
+
const file = clean.split("/").pop() ?? clean;
|
|
784
|
+
return `${file}:${line}`;
|
|
785
|
+
}
|
|
786
|
+
function notifyAlpha({ message, link }) {
|
|
787
|
+
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_ALPHA_WARNINGS !== "true") {
|
|
788
|
+
return;
|
|
1199
789
|
}
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
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;
|
|
790
|
+
if (shownNotices.has(message)) return;
|
|
791
|
+
shownNotices.add(message);
|
|
792
|
+
const boxStyle = "background: #6366f1; color: #ffffff; padding: 6px 10px; border-radius: 4px; font-weight: 500;";
|
|
793
|
+
console.log(`%c\u{1F52C} ${message}`, boxStyle);
|
|
794
|
+
{
|
|
795
|
+
console.log(`%cMore info: ${link}`, "color: #6366f1; font-weight: normal;");
|
|
1264
796
|
}
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
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 };
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
const INTERNAL_LIB_MARKERS = ["zustand", "setState", "Object.assign"];
|
|
800
|
+
function isInternalRendererAccess(stack, callerDepth = 2) {
|
|
801
|
+
if (!stack) return false;
|
|
802
|
+
const caller = stack.split("\n")[callerDepth] ?? "";
|
|
803
|
+
return INTERNAL_LIB_MARKERS.some((m) => caller.includes(m));
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
const R3F_CONTEXT = Symbol.for("@react-three/fiber.context");
|
|
807
|
+
const context = globalThis[R3F_CONTEXT] ?? (globalThis[R3F_CONTEXT] = React.createContext(null));
|
|
808
|
+
const createStore = (invalidate, advance) => {
|
|
809
|
+
const rootStore = createWithEqualityFn((set, get) => {
|
|
810
|
+
const position = new Vector3();
|
|
811
|
+
const defaultTarget = new Vector3();
|
|
812
|
+
const tempTarget = new Vector3();
|
|
813
|
+
function getCurrentViewport(camera = get().camera, target = defaultTarget, size = get().size) {
|
|
814
|
+
const { width, height, top, left } = size;
|
|
815
|
+
const aspect = width / height;
|
|
816
|
+
if (target.isVector3) tempTarget.copy(target);
|
|
817
|
+
else tempTarget.set(...target);
|
|
818
|
+
const distance = camera.getWorldPosition(position).distanceTo(tempTarget);
|
|
819
|
+
if (isOrthographicCamera(camera)) {
|
|
820
|
+
return { width: width / camera.zoom, height: height / camera.zoom, top, left, factor: 1, distance, aspect };
|
|
821
|
+
} else {
|
|
822
|
+
const fov = camera.fov * Math.PI / 180;
|
|
823
|
+
const h = 2 * Math.tan(fov / 2) * distance;
|
|
824
|
+
const w = h * (width / height);
|
|
825
|
+
return { width: w, height: h, top, left, factor: width / w, distance, aspect };
|
|
1699
826
|
}
|
|
1700
827
|
}
|
|
1701
828
|
let performanceTimeout = void 0;
|
|
@@ -1955,7 +1082,7 @@ const createStore = (invalidate, advance) => {
|
|
|
1955
1082
|
|
|
1956
1083
|
const memoizedLoaders = /* @__PURE__ */ new WeakMap();
|
|
1957
1084
|
const isConstructor$1 = (value) => typeof value === "function" && value?.prototype?.constructor === value;
|
|
1958
|
-
function getLoader(Proto) {
|
|
1085
|
+
function getLoader$1(Proto) {
|
|
1959
1086
|
if (isConstructor$1(Proto)) {
|
|
1960
1087
|
let loader = memoizedLoaders.get(Proto);
|
|
1961
1088
|
if (!loader) {
|
|
@@ -1968,7 +1095,7 @@ function getLoader(Proto) {
|
|
|
1968
1095
|
}
|
|
1969
1096
|
function loadingFn(extensions, onProgress) {
|
|
1970
1097
|
return function(Proto, input) {
|
|
1971
|
-
const loader = getLoader(Proto);
|
|
1098
|
+
const loader = getLoader$1(Proto);
|
|
1972
1099
|
if (extensions) extensions(loader);
|
|
1973
1100
|
if ("loadAsync" in loader && typeof loader.loadAsync === "function") {
|
|
1974
1101
|
return loader.loadAsync(input, onProgress).then((data) => {
|
|
@@ -2009,7 +1136,7 @@ useLoader.clear = function(loader, input, cacheKey) {
|
|
|
2009
1136
|
const cacheKeys = Array.isArray(cacheKey ?? input) ? cacheKey ?? input : [cacheKey ?? input];
|
|
2010
1137
|
cacheKeys.forEach((key) => clear([loader, key]));
|
|
2011
1138
|
};
|
|
2012
|
-
useLoader.loader = getLoader;
|
|
1139
|
+
useLoader.loader = getLoader$1;
|
|
2013
1140
|
|
|
2014
1141
|
function useFrame(callback, priorityOrOptions) {
|
|
2015
1142
|
const store = React.useContext(context);
|
|
@@ -2369,11 +1496,131 @@ function useRenderTarget(widthOrOptions, heightOrOptions, options) {
|
|
|
2369
1496
|
height = widthOrOptions;
|
|
2370
1497
|
}
|
|
2371
1498
|
}
|
|
2372
|
-
return useMemo(() => {
|
|
2373
|
-
const w = width ?? size.width;
|
|
2374
|
-
const h = height ?? size.height;
|
|
2375
|
-
return new RenderTarget(w, h, opts);
|
|
2376
|
-
}, [width, height, size.width, size.height, opts, isLegacy]);
|
|
1499
|
+
return useMemo(() => {
|
|
1500
|
+
const w = width ?? size.width;
|
|
1501
|
+
const h = height ?? size.height;
|
|
1502
|
+
return new RenderTarget(w, h, opts);
|
|
1503
|
+
}, [width, height, size.width, size.height, opts, isLegacy]);
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
const presetsObj = {
|
|
1507
|
+
apartment: "lebombo_1k.hdr",
|
|
1508
|
+
city: "potsdamer_platz_1k.hdr",
|
|
1509
|
+
dawn: "kiara_1_dawn_1k.hdr",
|
|
1510
|
+
forest: "forest_slope_1k.hdr",
|
|
1511
|
+
lobby: "st_fagans_interior_1k.hdr",
|
|
1512
|
+
night: "dikhololo_night_1k.hdr",
|
|
1513
|
+
park: "rooitou_park_1k.hdr",
|
|
1514
|
+
studio: "studio_small_03_1k.hdr",
|
|
1515
|
+
sunset: "venice_sunset_1k.hdr",
|
|
1516
|
+
warehouse: "empty_warehouse_01_1k.hdr"
|
|
1517
|
+
};
|
|
1518
|
+
|
|
1519
|
+
const CUBEMAP_ROOT = "https://raw.githack.com/pmndrs/drei-assets/456060a26bbeb8fdf79326f224b6d99b8bcce736/hdri/";
|
|
1520
|
+
const isArray = (arr) => Array.isArray(arr);
|
|
1521
|
+
const defaultFiles = ["/px.png", "/nx.png", "/py.png", "/ny.png", "/pz.png", "/nz.png"];
|
|
1522
|
+
function useEnvironment({
|
|
1523
|
+
files = defaultFiles,
|
|
1524
|
+
path = "",
|
|
1525
|
+
preset = void 0,
|
|
1526
|
+
colorSpace = void 0,
|
|
1527
|
+
extensions
|
|
1528
|
+
} = {}) {
|
|
1529
|
+
if (preset) {
|
|
1530
|
+
validatePreset(preset);
|
|
1531
|
+
files = presetsObj[preset];
|
|
1532
|
+
path = CUBEMAP_ROOT;
|
|
1533
|
+
}
|
|
1534
|
+
const multiFile = isArray(files);
|
|
1535
|
+
const { extension, isCubemap } = getExtension(files);
|
|
1536
|
+
const loader = getLoader(extension);
|
|
1537
|
+
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1538
|
+
const renderer = useThree((state) => state.renderer);
|
|
1539
|
+
useLayoutEffect(() => {
|
|
1540
|
+
if (extension !== "webp" && extension !== "jpg" && extension !== "jpeg") return;
|
|
1541
|
+
function clearGainmapTexture() {
|
|
1542
|
+
useLoader.clear(loader, multiFile ? [files] : files);
|
|
1543
|
+
}
|
|
1544
|
+
renderer.domElement.addEventListener("webglcontextlost", clearGainmapTexture, { once: true });
|
|
1545
|
+
}, [extension, files, loader, multiFile, renderer.domElement]);
|
|
1546
|
+
const loaderResult = useLoader(
|
|
1547
|
+
loader,
|
|
1548
|
+
multiFile ? [files] : files,
|
|
1549
|
+
(loader2) => {
|
|
1550
|
+
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
1551
|
+
loader2.setRenderer?.(renderer);
|
|
1552
|
+
}
|
|
1553
|
+
loader2.setPath?.(path);
|
|
1554
|
+
if (extensions) extensions(loader2);
|
|
1555
|
+
}
|
|
1556
|
+
);
|
|
1557
|
+
let texture = multiFile ? (
|
|
1558
|
+
// @ts-ignore
|
|
1559
|
+
loaderResult[0]
|
|
1560
|
+
) : loaderResult;
|
|
1561
|
+
if (extension === "jpg" || extension === "jpeg" || extension === "webp") {
|
|
1562
|
+
texture = texture.renderTarget?.texture;
|
|
1563
|
+
}
|
|
1564
|
+
texture.mapping = isCubemap ? CubeReflectionMapping : EquirectangularReflectionMapping;
|
|
1565
|
+
texture.colorSpace = colorSpace ?? (isCubemap ? "srgb" : "srgb-linear");
|
|
1566
|
+
return texture;
|
|
1567
|
+
}
|
|
1568
|
+
const preloadDefaultOptions = {
|
|
1569
|
+
files: defaultFiles,
|
|
1570
|
+
path: "",
|
|
1571
|
+
preset: void 0,
|
|
1572
|
+
extensions: void 0
|
|
1573
|
+
};
|
|
1574
|
+
useEnvironment.preload = (preloadOptions) => {
|
|
1575
|
+
const options = { ...preloadDefaultOptions, ...preloadOptions };
|
|
1576
|
+
let { files, path = "" } = options;
|
|
1577
|
+
const { preset, extensions } = options;
|
|
1578
|
+
if (preset) {
|
|
1579
|
+
validatePreset(preset);
|
|
1580
|
+
files = presetsObj[preset];
|
|
1581
|
+
path = CUBEMAP_ROOT;
|
|
1582
|
+
}
|
|
1583
|
+
const { extension } = getExtension(files);
|
|
1584
|
+
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
1585
|
+
throw new Error("useEnvironment: Preloading gainmaps is not supported");
|
|
1586
|
+
}
|
|
1587
|
+
const loader = getLoader(extension);
|
|
1588
|
+
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1589
|
+
useLoader.preload(loader, isArray(files) ? [files] : files, (loader2) => {
|
|
1590
|
+
loader2.setPath?.(path);
|
|
1591
|
+
if (extensions) extensions(loader2);
|
|
1592
|
+
});
|
|
1593
|
+
};
|
|
1594
|
+
const clearDefaultOptins = {
|
|
1595
|
+
files: defaultFiles,
|
|
1596
|
+
preset: void 0
|
|
1597
|
+
};
|
|
1598
|
+
useEnvironment.clear = (clearOptions) => {
|
|
1599
|
+
const options = { ...clearDefaultOptins, ...clearOptions };
|
|
1600
|
+
let { files } = options;
|
|
1601
|
+
const { preset } = options;
|
|
1602
|
+
if (preset) {
|
|
1603
|
+
validatePreset(preset);
|
|
1604
|
+
files = presetsObj[preset];
|
|
1605
|
+
}
|
|
1606
|
+
const { extension } = getExtension(files);
|
|
1607
|
+
const loader = getLoader(extension);
|
|
1608
|
+
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1609
|
+
useLoader.clear(loader, isArray(files) ? [files] : files);
|
|
1610
|
+
};
|
|
1611
|
+
function validatePreset(preset) {
|
|
1612
|
+
if (!(preset in presetsObj)) throw new Error("Preset must be one of: " + Object.keys(presetsObj).join(", "));
|
|
1613
|
+
}
|
|
1614
|
+
function getExtension(files) {
|
|
1615
|
+
const isCubemap = isArray(files) && files.length === 6;
|
|
1616
|
+
const isGainmap = isArray(files) && files.length === 3 && files.some((file) => file.endsWith("json"));
|
|
1617
|
+
const firstEntry = isArray(files) ? files[0] : files;
|
|
1618
|
+
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();
|
|
1619
|
+
return { extension, isCubemap, isGainmap };
|
|
1620
|
+
}
|
|
1621
|
+
function getLoader(extension) {
|
|
1622
|
+
const loader = extension === "cube" ? CubeTextureLoader : extension === "hdr" ? HDRLoader : extension === "exr" ? EXRLoader : extension === "jpg" || extension === "jpeg" ? UltraHDRLoader : extension === "webp" ? GainMapLoader : null;
|
|
1623
|
+
return loader;
|
|
2377
1624
|
}
|
|
2378
1625
|
|
|
2379
1626
|
function useStore() {
|
|
@@ -2393,6 +1640,8 @@ function useGraph(object) {
|
|
|
2393
1640
|
return useMemo(() => buildGraph(object), [object]);
|
|
2394
1641
|
}
|
|
2395
1642
|
|
|
1643
|
+
const t = 1, o = 8, r = 32, e = 2, i$1 = 268435456;
|
|
1644
|
+
|
|
2396
1645
|
let effectId = 0;
|
|
2397
1646
|
function addEffect(callback) {
|
|
2398
1647
|
notifyDepreciated({
|
|
@@ -13295,395 +12544,978 @@ Check the top-level render call using <` + i + ">.");
|
|
|
13295
12544
|
} finally {
|
|
13296
12545
|
x.H = o;
|
|
13297
12546
|
}
|
|
13298
|
-
}, useReducer: function(e, n, o) {
|
|
13299
|
-
z = "useReducer", D(), N();
|
|
13300
|
-
var i = x.H;
|
|
13301
|
-
x.H = $o;
|
|
12547
|
+
}, useReducer: function(e, n, o) {
|
|
12548
|
+
z = "useReducer", D(), N();
|
|
12549
|
+
var i = x.H;
|
|
12550
|
+
x.H = $o;
|
|
12551
|
+
try {
|
|
12552
|
+
return Br(e, n, o);
|
|
12553
|
+
} finally {
|
|
12554
|
+
x.H = i;
|
|
12555
|
+
}
|
|
12556
|
+
}, useRef: function() {
|
|
12557
|
+
return z = "useRef", D(), N(), xe().memoizedState;
|
|
12558
|
+
}, useState: function() {
|
|
12559
|
+
z = "useState", D(), N();
|
|
12560
|
+
var e = x.H;
|
|
12561
|
+
x.H = $o;
|
|
12562
|
+
try {
|
|
12563
|
+
return Br(gr);
|
|
12564
|
+
} finally {
|
|
12565
|
+
x.H = e;
|
|
12566
|
+
}
|
|
12567
|
+
}, useDebugValue: function() {
|
|
12568
|
+
z = "useDebugValue", D(), N();
|
|
12569
|
+
}, useDeferredValue: function(e, n) {
|
|
12570
|
+
return z = "useDeferredValue", D(), N(), nc(e, n);
|
|
12571
|
+
}, useTransition: function() {
|
|
12572
|
+
return z = "useTransition", D(), N(), Qp();
|
|
12573
|
+
}, useSyncExternalStore: function(e, n, o) {
|
|
12574
|
+
return z = "useSyncExternalStore", D(), N(), ta(e, n, o);
|
|
12575
|
+
}, useId: function() {
|
|
12576
|
+
return z = "useId", D(), N(), xe().memoizedState;
|
|
12577
|
+
}, useFormState: function(e) {
|
|
12578
|
+
return z = "useFormState", D(), N(), hs(e);
|
|
12579
|
+
}, useActionState: function(e) {
|
|
12580
|
+
return z = "useActionState", D(), N(), hs(e);
|
|
12581
|
+
}, useOptimistic: function(e, n) {
|
|
12582
|
+
return z = "useOptimistic", D(), N(), rf(e, n);
|
|
12583
|
+
}, useMemoCache: function(e) {
|
|
12584
|
+
return D(), Oa(e);
|
|
12585
|
+
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
12586
|
+
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
12587
|
+
}, useEffectEvent: function(e) {
|
|
12588
|
+
return z = "useEffectEvent", D(), N(), oa(e);
|
|
12589
|
+
} }, dm = { readContext: function(e) {
|
|
12590
|
+
return Ce(), Ee(e);
|
|
12591
|
+
}, use: function(e) {
|
|
12592
|
+
return D(), we(e);
|
|
12593
|
+
}, useCallback: function(e, n) {
|
|
12594
|
+
return z = "useCallback", D(), N(), Ma(e, n);
|
|
12595
|
+
}, useContext: function(e) {
|
|
12596
|
+
return z = "useContext", D(), N(), Ee(e);
|
|
12597
|
+
}, useEffect: function(e, n) {
|
|
12598
|
+
z = "useEffect", D(), N(), Qn(2048, Ut, e, n);
|
|
12599
|
+
}, useImperativeHandle: function(e, n, o) {
|
|
12600
|
+
return z = "useImperativeHandle", D(), N(), aa(e, n, o);
|
|
12601
|
+
}, useInsertionEffect: function(e, n) {
|
|
12602
|
+
return z = "useInsertionEffect", D(), N(), Qn(4, Wt, e, n);
|
|
12603
|
+
}, useLayoutEffect: function(e, n) {
|
|
12604
|
+
return z = "useLayoutEffect", D(), N(), Qn(4, Rr, e, n);
|
|
12605
|
+
}, useMemo: function(e, n) {
|
|
12606
|
+
z = "useMemo", D(), N();
|
|
12607
|
+
var o = x.H;
|
|
12608
|
+
x.H = $o;
|
|
12609
|
+
try {
|
|
12610
|
+
return Vi(e, n);
|
|
12611
|
+
} finally {
|
|
12612
|
+
x.H = o;
|
|
12613
|
+
}
|
|
12614
|
+
}, useReducer: function(e, n, o) {
|
|
12615
|
+
z = "useReducer", D(), N();
|
|
12616
|
+
var i = x.H;
|
|
12617
|
+
x.H = $o;
|
|
12618
|
+
try {
|
|
12619
|
+
return Qi(e, n, o);
|
|
12620
|
+
} finally {
|
|
12621
|
+
x.H = i;
|
|
12622
|
+
}
|
|
12623
|
+
}, useRef: function() {
|
|
12624
|
+
return z = "useRef", D(), N(), xe().memoizedState;
|
|
12625
|
+
}, useState: function() {
|
|
12626
|
+
z = "useState", D(), N();
|
|
12627
|
+
var e = x.H;
|
|
12628
|
+
x.H = $o;
|
|
12629
|
+
try {
|
|
12630
|
+
return Qi(gr);
|
|
12631
|
+
} finally {
|
|
12632
|
+
x.H = e;
|
|
12633
|
+
}
|
|
12634
|
+
}, useDebugValue: function() {
|
|
12635
|
+
z = "useDebugValue", D(), N();
|
|
12636
|
+
}, useDeferredValue: function(e, n) {
|
|
12637
|
+
return z = "useDeferredValue", D(), N(), sf(e, n);
|
|
12638
|
+
}, useTransition: function() {
|
|
12639
|
+
return z = "useTransition", D(), N(), Ro();
|
|
12640
|
+
}, useSyncExternalStore: function(e, n, o) {
|
|
12641
|
+
return z = "useSyncExternalStore", D(), N(), ta(e, n, o);
|
|
12642
|
+
}, useId: function() {
|
|
12643
|
+
return z = "useId", D(), N(), xe().memoizedState;
|
|
12644
|
+
}, useFormState: function(e) {
|
|
12645
|
+
return z = "useFormState", D(), N(), $t(e);
|
|
12646
|
+
}, useActionState: function(e) {
|
|
12647
|
+
return z = "useActionState", D(), N(), $t(e);
|
|
12648
|
+
}, useOptimistic: function(e, n) {
|
|
12649
|
+
return z = "useOptimistic", D(), N(), of(e, n);
|
|
12650
|
+
}, useMemoCache: function(e) {
|
|
12651
|
+
return D(), Oa(e);
|
|
12652
|
+
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
12653
|
+
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
12654
|
+
}, useEffectEvent: function(e) {
|
|
12655
|
+
return z = "useEffectEvent", D(), N(), oa(e);
|
|
12656
|
+
} };
|
|
12657
|
+
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();
|
|
12658
|
+
Object.freeze(Fy);
|
|
12659
|
+
var zg = { enqueueSetState: function(e, n, o) {
|
|
12660
|
+
e = e._reactInternals;
|
|
12661
|
+
var i = Nt(e), s = zo(i);
|
|
12662
|
+
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));
|
|
12663
|
+
}, enqueueReplaceState: function(e, n, o) {
|
|
12664
|
+
e = e._reactInternals;
|
|
12665
|
+
var i = Nt(e), s = zo(i);
|
|
12666
|
+
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));
|
|
12667
|
+
}, enqueueForceUpdate: function(e, n) {
|
|
12668
|
+
e = e._reactInternals;
|
|
12669
|
+
var o = Nt(e), i = zo(o);
|
|
12670
|
+
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));
|
|
12671
|
+
} }, 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;
|
|
12672
|
+
Yy = /* @__PURE__ */ new Set();
|
|
12673
|
+
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) {
|
|
12674
|
+
var n = Ee(un), o = n.data.get(e);
|
|
12675
|
+
return o === void 0 && (o = e(), n.data.set(e, o)), o;
|
|
12676
|
+
}, cacheSignal: function() {
|
|
12677
|
+
return Ee(un).controller.signal;
|
|
12678
|
+
}, getOwner: function() {
|
|
12679
|
+
return di;
|
|
12680
|
+
} }, pm = 0, hm = 1, mm = 2, gm = 3, ym = 4;
|
|
12681
|
+
if (typeof Symbol == "function" && Symbol.for) {
|
|
12682
|
+
var bp = Symbol.for;
|
|
12683
|
+
pm = bp("selector.component"), hm = bp("selector.has_pseudo_class"), mm = bp("selector.role"), gm = bp("selector.test_id"), ym = bp("selector.text");
|
|
12684
|
+
}
|
|
12685
|
+
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;
|
|
12686
|
+
try {
|
|
12687
|
+
var o0 = Object.preventExtensions({});
|
|
12688
|
+
} catch {
|
|
12689
|
+
pb = true;
|
|
12690
|
+
}
|
|
12691
|
+
var hb = false, mb = {}, gb = null, yb = null, bb = null, vb = null, Sb = null, kb = null, wb = null, Pb = null, xb = null, zb = null;
|
|
12692
|
+
return gb = function(e, n, o, i) {
|
|
12693
|
+
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));
|
|
12694
|
+
}, yb = function(e, n, o) {
|
|
12695
|
+
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));
|
|
12696
|
+
}, bb = function(e, n, o, i) {
|
|
12697
|
+
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));
|
|
12698
|
+
}, vb = function(e, n, o) {
|
|
12699
|
+
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);
|
|
12700
|
+
}, Sb = function(e, n) {
|
|
12701
|
+
e.pendingProps = du(e.memoizedProps, n, 0), e.alternate && (e.alternate.pendingProps = e.pendingProps), n = On(e, 2), n !== null && We(n, e, 2);
|
|
12702
|
+
}, kb = function(e, n, o) {
|
|
12703
|
+
e.pendingProps = F(e.memoizedProps, n, o), e.alternate && (e.alternate.pendingProps = e.pendingProps), n = On(e, 2), n !== null && We(n, e, 2);
|
|
12704
|
+
}, wb = function(e) {
|
|
12705
|
+
var n = On(e, 2);
|
|
12706
|
+
n !== null && We(n, e, 2);
|
|
12707
|
+
}, Pb = function(e) {
|
|
12708
|
+
var n = ut(), o = On(e, n);
|
|
12709
|
+
o !== null && We(o, e, n);
|
|
12710
|
+
}, xb = function(e) {
|
|
12711
|
+
pu = e;
|
|
12712
|
+
}, zb = function(e) {
|
|
12713
|
+
fu = e;
|
|
12714
|
+
}, le.attemptContinuousHydration = function(e) {
|
|
12715
|
+
if (e.tag === 13 || e.tag === 31) {
|
|
12716
|
+
var n = On(e, 67108864);
|
|
12717
|
+
n !== null && We(n, e, 67108864), rl(e, 67108864);
|
|
12718
|
+
}
|
|
12719
|
+
}, le.attemptHydrationAtCurrentPriority = function(e) {
|
|
12720
|
+
if (e.tag === 13 || e.tag === 31) {
|
|
12721
|
+
var n = Nt(e);
|
|
12722
|
+
n = Xo(n);
|
|
12723
|
+
var o = On(e, n);
|
|
12724
|
+
o !== null && We(o, e, n), rl(e, n);
|
|
12725
|
+
}
|
|
12726
|
+
}, le.attemptSynchronousHydration = function(e) {
|
|
12727
|
+
switch (e.tag) {
|
|
12728
|
+
case 3:
|
|
12729
|
+
if (e = e.stateNode, e.current.memoizedState.isDehydrated) {
|
|
12730
|
+
var n = _t(e.pendingLanes);
|
|
12731
|
+
if (n !== 0) {
|
|
12732
|
+
for (e.pendingLanes |= 2, e.entangledLanes |= 2; n; ) {
|
|
12733
|
+
var o = 1 << 31 - vn(n);
|
|
12734
|
+
e.entanglements[1] |= o, n &= ~o;
|
|
12735
|
+
}
|
|
12736
|
+
Kn(e), (ye & (Zn | uo)) === Jn && (Pp = me() + Fg, Wa(0));
|
|
12737
|
+
}
|
|
12738
|
+
}
|
|
12739
|
+
break;
|
|
12740
|
+
case 31:
|
|
12741
|
+
case 13:
|
|
12742
|
+
n = On(e, 2), n !== null && We(n, e, 2), Ls(), rl(e, 2);
|
|
12743
|
+
}
|
|
12744
|
+
}, le.batchedUpdates = function(e, n) {
|
|
12745
|
+
return e(n);
|
|
12746
|
+
}, le.createComponentSelector = function(e) {
|
|
12747
|
+
return { $$typeof: pm, value: e };
|
|
12748
|
+
}, le.createContainer = function(e, n, o, i, s, u, f, p, g, S) {
|
|
12749
|
+
return Ka(e, n, false, null, o, i, u, null, f, p, g, S);
|
|
12750
|
+
}, le.createHasPseudoClassSelector = function(e) {
|
|
12751
|
+
return { $$typeof: hm, value: e };
|
|
12752
|
+
}, le.createHydrationContainer = function(e, n, o, i, s, u, f, p, g, S, T, _, I, O) {
|
|
12753
|
+
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;
|
|
12754
|
+
}, le.createPortal = function(e, n, o) {
|
|
12755
|
+
var i = 3 < arguments.length && arguments[3] !== void 0 ? arguments[3] : null;
|
|
13302
12756
|
try {
|
|
13303
|
-
|
|
13304
|
-
|
|
13305
|
-
|
|
12757
|
+
vt(i);
|
|
12758
|
+
var s = false;
|
|
12759
|
+
} catch {
|
|
12760
|
+
s = true;
|
|
13306
12761
|
}
|
|
13307
|
-
|
|
13308
|
-
|
|
13309
|
-
|
|
13310
|
-
|
|
13311
|
-
|
|
13312
|
-
|
|
12762
|
+
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 };
|
|
12763
|
+
}, le.createRoleSelector = function(e) {
|
|
12764
|
+
return { $$typeof: mm, value: e };
|
|
12765
|
+
}, le.createTestNameSelector = function(e) {
|
|
12766
|
+
return { $$typeof: gm, value: e };
|
|
12767
|
+
}, le.createTextSelector = function(e) {
|
|
12768
|
+
return { $$typeof: ym, value: e };
|
|
12769
|
+
}, le.defaultOnCaughtError = function(e) {
|
|
12770
|
+
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") + ".");
|
|
12771
|
+
typeof e == "object" && e !== null && typeof e.environmentName == "string" ? ri("error", [`%o
|
|
12772
|
+
|
|
12773
|
+
%s
|
|
12774
|
+
|
|
12775
|
+
%s
|
|
12776
|
+
`, e, n, o], e.environmentName)() : console.error(`%o
|
|
12777
|
+
|
|
12778
|
+
%s
|
|
12779
|
+
|
|
12780
|
+
%s
|
|
12781
|
+
`, e, n, o);
|
|
12782
|
+
}, le.defaultOnRecoverableError = function(e) {
|
|
12783
|
+
qg(e);
|
|
12784
|
+
}, le.defaultOnUncaughtError = function(e) {
|
|
12785
|
+
qg(e), console.warn(`%s
|
|
12786
|
+
|
|
12787
|
+
%s
|
|
12788
|
+
`, 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.
|
|
12789
|
+
Visit https://react.dev/link/error-boundaries to learn more about error boundaries.`);
|
|
12790
|
+
}, le.deferredUpdates = function(e) {
|
|
12791
|
+
var n = x.T, o = wt();
|
|
13313
12792
|
try {
|
|
13314
|
-
return
|
|
12793
|
+
return an(32), x.T = null, e();
|
|
13315
12794
|
} finally {
|
|
13316
|
-
x.
|
|
12795
|
+
an(o), x.T = n;
|
|
13317
12796
|
}
|
|
13318
|
-
},
|
|
13319
|
-
|
|
13320
|
-
}, useDeferredValue: function(e, n) {
|
|
13321
|
-
return z = "useDeferredValue", D(), N(), nc(e, n);
|
|
13322
|
-
}, useTransition: function() {
|
|
13323
|
-
return z = "useTransition", D(), N(), Qp();
|
|
13324
|
-
}, useSyncExternalStore: function(e, n, o) {
|
|
13325
|
-
return z = "useSyncExternalStore", D(), N(), ta(e, n, o);
|
|
13326
|
-
}, useId: function() {
|
|
13327
|
-
return z = "useId", D(), N(), xe().memoizedState;
|
|
13328
|
-
}, useFormState: function(e) {
|
|
13329
|
-
return z = "useFormState", D(), N(), hs(e);
|
|
13330
|
-
}, useActionState: function(e) {
|
|
13331
|
-
return z = "useActionState", D(), N(), hs(e);
|
|
13332
|
-
}, useOptimistic: function(e, n) {
|
|
13333
|
-
return z = "useOptimistic", D(), N(), rf(e, n);
|
|
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;
|
|
12797
|
+
}, le.discreteUpdates = function(e, n, o, i, s) {
|
|
12798
|
+
var u = x.T, f = wt();
|
|
13360
12799
|
try {
|
|
13361
|
-
return
|
|
12800
|
+
return an(2), x.T = null, e(n, o, i, s);
|
|
13362
12801
|
} finally {
|
|
13363
|
-
x.
|
|
12802
|
+
an(f), x.T = u, ye === Jn && (Pp = me() + Fg);
|
|
13364
12803
|
}
|
|
13365
|
-
},
|
|
13366
|
-
|
|
13367
|
-
|
|
13368
|
-
|
|
13369
|
-
|
|
13370
|
-
|
|
13371
|
-
|
|
13372
|
-
|
|
12804
|
+
}, le.findAllNodes = kc, le.findBoundingRects = function(e, n) {
|
|
12805
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12806
|
+
n = kc(e, n), e = [];
|
|
12807
|
+
for (var o = 0; o < n.length; o++) e.push(ma(n[o]));
|
|
12808
|
+
for (n = e.length - 1; 0 < n; n--) {
|
|
12809
|
+
o = e[n];
|
|
12810
|
+
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) {
|
|
12811
|
+
var g = e[p], S = g.x, T = S + g.width, _ = g.y, I = _ + g.height;
|
|
12812
|
+
if (i >= S && u >= _ && s <= T && f <= I) {
|
|
12813
|
+
e.splice(n, 1);
|
|
12814
|
+
break;
|
|
12815
|
+
} else if (i !== S || o.width !== g.width || I < u || _ > f) {
|
|
12816
|
+
if (!(u !== _ || o.height !== g.height || T < i || S > s)) {
|
|
12817
|
+
S > i && (g.width += S - i, g.x = i), T < s && (g.width = s - S), e.splice(n, 1);
|
|
12818
|
+
break;
|
|
12819
|
+
}
|
|
12820
|
+
} else {
|
|
12821
|
+
_ > u && (g.height += _ - u, g.y = u), I < f && (g.height = f - _), e.splice(n, 1);
|
|
12822
|
+
break;
|
|
12823
|
+
}
|
|
12824
|
+
}
|
|
13373
12825
|
}
|
|
13374
|
-
|
|
13375
|
-
|
|
13376
|
-
|
|
13377
|
-
|
|
13378
|
-
|
|
13379
|
-
|
|
12826
|
+
return e;
|
|
12827
|
+
}, le.findHostInstance = function(e) {
|
|
12828
|
+
var n = e._reactInternals;
|
|
12829
|
+
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));
|
|
12830
|
+
return e = mu(n), e === null ? null : ot(e.stateNode);
|
|
12831
|
+
}, le.findHostInstanceWithNoPortals = function(e) {
|
|
12832
|
+
return e = Ed(e), e = e !== null ? _p(e) : null, e === null ? null : ot(e.stateNode);
|
|
12833
|
+
}, le.findHostInstanceWithWarning = function(e, n) {
|
|
12834
|
+
var o = e._reactInternals;
|
|
12835
|
+
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));
|
|
12836
|
+
if (e = mu(o), e === null) return null;
|
|
12837
|
+
if (e.mode & 8) {
|
|
12838
|
+
var i = G(o) || "Component";
|
|
12839
|
+
mb[i] || (mb[i] = true, B(e, function() {
|
|
12840
|
+
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);
|
|
12841
|
+
}));
|
|
12842
|
+
}
|
|
12843
|
+
return ot(e.stateNode);
|
|
12844
|
+
}, le.flushPassiveEffects = el, le.flushSyncFromReconciler = function(e) {
|
|
12845
|
+
var n = ye;
|
|
12846
|
+
ye |= 1;
|
|
12847
|
+
var o = x.T, i = wt();
|
|
13380
12848
|
try {
|
|
13381
|
-
return
|
|
12849
|
+
if (an(2), x.T = null, e) return e();
|
|
13382
12850
|
} finally {
|
|
13383
|
-
x.
|
|
12851
|
+
an(i), x.T = o, ye = n, (ye & (Zn | uo)) === Jn && Wa(0);
|
|
12852
|
+
}
|
|
12853
|
+
}, le.flushSyncWork = Ls, le.focusWithin = function(e, n) {
|
|
12854
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12855
|
+
for (e = Ef(e), n = hh(e, n), n = Array.from(n), e = 0; e < n.length; ) {
|
|
12856
|
+
var o = n[e++], i = o.tag;
|
|
12857
|
+
if (!Kr(o)) {
|
|
12858
|
+
if ((i === 5 || i === 26 || i === 27) && Ft(o.stateNode)) return true;
|
|
12859
|
+
for (o = o.child; o !== null; ) n.push(o), o = o.sibling;
|
|
12860
|
+
}
|
|
12861
|
+
}
|
|
12862
|
+
return false;
|
|
12863
|
+
}, le.getFindAllNodesFailureDescription = function(e, n) {
|
|
12864
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12865
|
+
var o = 0, i = [];
|
|
12866
|
+
e = [Ef(e), 0];
|
|
12867
|
+
for (var s = 0; s < e.length; ) {
|
|
12868
|
+
var u = e[s++], f = u.tag, p = e[s++], g = n[p];
|
|
12869
|
+
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;
|
|
12870
|
+
}
|
|
12871
|
+
if (o < n.length) {
|
|
12872
|
+
for (e = []; o < n.length; o++) e.push(Sc(n[o]));
|
|
12873
|
+
return `findAllNodes was able to match part of the selector:
|
|
12874
|
+
` + (i.join(" > ") + `
|
|
12875
|
+
|
|
12876
|
+
No matching component was found for:
|
|
12877
|
+
`) + e.join(" > ");
|
|
12878
|
+
}
|
|
12879
|
+
return null;
|
|
12880
|
+
}, le.getPublicRootInstance = function(e) {
|
|
12881
|
+
if (e = e.current, !e.child) return null;
|
|
12882
|
+
switch (e.child.tag) {
|
|
12883
|
+
case 27:
|
|
12884
|
+
case 5:
|
|
12885
|
+
return ot(e.child.stateNode);
|
|
12886
|
+
default:
|
|
12887
|
+
return e.child.stateNode;
|
|
12888
|
+
}
|
|
12889
|
+
}, le.injectIntoDevTools = function() {
|
|
12890
|
+
var e = { bundleType: 1, version: Jt, rendererPackageName: Zt, currentDispatcherRef: x, reconcilerVersion: "19.2.0" };
|
|
12891
|
+
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);
|
|
12892
|
+
}, le.isAlreadyRendering = Ns, le.observeVisibleRects = function(e, n, o, i) {
|
|
12893
|
+
function s() {
|
|
12894
|
+
var S = kc(e, n);
|
|
12895
|
+
u.forEach(function(T) {
|
|
12896
|
+
0 > S.indexOf(T) && g(T);
|
|
12897
|
+
}), S.forEach(function(T) {
|
|
12898
|
+
0 > u.indexOf(T) && p(T);
|
|
12899
|
+
});
|
|
12900
|
+
}
|
|
12901
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12902
|
+
var u = kc(e, n);
|
|
12903
|
+
o = zr(u, o, i);
|
|
12904
|
+
var f = o.disconnect, p = o.observe, g = o.unobserve;
|
|
12905
|
+
return bm.push(s), { disconnect: function() {
|
|
12906
|
+
var S = bm.indexOf(s);
|
|
12907
|
+
0 <= S && bm.splice(S, 1), f();
|
|
12908
|
+
} };
|
|
12909
|
+
}, le.shouldError = function(e) {
|
|
12910
|
+
return pu(e);
|
|
12911
|
+
}, le.shouldSuspend = function(e) {
|
|
12912
|
+
return fu(e);
|
|
12913
|
+
}, le.startHostTransition = function(e, n, o, i) {
|
|
12914
|
+
if (e.tag !== 5) throw Error("Expected the form instance to be a HostComponent. This is a bug in React.");
|
|
12915
|
+
var s = uf(e).queue;
|
|
12916
|
+
Hp(e), nt(e, s, n, Xt, o === null ? Em : function() {
|
|
12917
|
+
x.T === null && console.error("requestFormReset was called outside a transition or action. To fix, move to an action, or wrap with startTransition.");
|
|
12918
|
+
var u = uf(e);
|
|
12919
|
+
return u.next === null && (u = e.alternate.memoizedState), qi(e, u.next.queue, {}, Nt(e)), o(i);
|
|
12920
|
+
});
|
|
12921
|
+
}, le.updateContainer = function(e, n, o, i) {
|
|
12922
|
+
var s = n.current, u = Nt(s);
|
|
12923
|
+
return As(s, u, e, n, o, i), u;
|
|
12924
|
+
}, le.updateContainerSync = Wh, le;
|
|
12925
|
+
}, Tt.exports.default = Tt.exports, Object.defineProperty(Tt.exports, "__esModule", { value: true }));
|
|
12926
|
+
})(Mg)), Mg.exports;
|
|
12927
|
+
}
|
|
12928
|
+
var Eb;
|
|
12929
|
+
function n0() {
|
|
12930
|
+
return Eb || (Eb = 1, process.env.NODE_ENV === "production" ? Rm.exports = Kb() : Rm.exports = e0()), Rm.exports;
|
|
12931
|
+
}
|
|
12932
|
+
var t0 = n0();
|
|
12933
|
+
const r0 = Xb(t0);
|
|
12934
|
+
|
|
12935
|
+
const DEFAULT_POINTER_ID = 0;
|
|
12936
|
+
const XR_POINTER_ID_START = 1e3;
|
|
12937
|
+
function getPointerState(internal, pointerId) {
|
|
12938
|
+
let state = internal.pointerMap.get(pointerId);
|
|
12939
|
+
if (!state) {
|
|
12940
|
+
state = {
|
|
12941
|
+
hovered: /* @__PURE__ */ new Map(),
|
|
12942
|
+
captured: /* @__PURE__ */ new Map(),
|
|
12943
|
+
initialClick: [0, 0],
|
|
12944
|
+
initialHits: []
|
|
12945
|
+
};
|
|
12946
|
+
internal.pointerMap.set(pointerId, state);
|
|
12947
|
+
}
|
|
12948
|
+
return state;
|
|
12949
|
+
}
|
|
12950
|
+
function getPointerId(event) {
|
|
12951
|
+
return "pointerId" in event ? event.pointerId : DEFAULT_POINTER_ID;
|
|
12952
|
+
}
|
|
12953
|
+
function makeId(event) {
|
|
12954
|
+
return (event.eventObject || event.object).uuid + "/" + event.index + event.instanceId;
|
|
12955
|
+
}
|
|
12956
|
+
function releaseInternalPointerCapture(internal, obj, pointerId) {
|
|
12957
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
12958
|
+
if (!pointerState) return;
|
|
12959
|
+
const captureData = pointerState.captured.get(obj);
|
|
12960
|
+
if (captureData) {
|
|
12961
|
+
pointerState.captured.delete(obj);
|
|
12962
|
+
try {
|
|
12963
|
+
captureData.target.releasePointerCapture?.(pointerId);
|
|
12964
|
+
} catch {
|
|
12965
|
+
}
|
|
12966
|
+
}
|
|
12967
|
+
}
|
|
12968
|
+
function swapInteractivity(store, object, newObject) {
|
|
12969
|
+
const { internal } = store.getState();
|
|
12970
|
+
for (let i = 0; i < internal.interaction.length; i++) {
|
|
12971
|
+
if (internal.interaction[i] === object) internal.interaction[i] = newObject;
|
|
12972
|
+
}
|
|
12973
|
+
for (const pointerState of internal.pointerMap.values()) {
|
|
12974
|
+
for (let i = 0; i < pointerState.initialHits.length; i++) {
|
|
12975
|
+
if (pointerState.initialHits[i] === object) pointerState.initialHits[i] = newObject;
|
|
12976
|
+
}
|
|
12977
|
+
pointerState.hovered.forEach((value, key) => {
|
|
12978
|
+
if (value.eventObject === object || value.object === object) {
|
|
12979
|
+
pointerState.hovered.delete(key);
|
|
12980
|
+
const next = {
|
|
12981
|
+
...value,
|
|
12982
|
+
eventObject: value.eventObject === object ? newObject : value.eventObject,
|
|
12983
|
+
object: value.object === object ? newObject : value.object
|
|
12984
|
+
};
|
|
12985
|
+
pointerState.hovered.set(makeId(next), next);
|
|
12986
|
+
}
|
|
12987
|
+
});
|
|
12988
|
+
const captureData = pointerState.captured.get(object);
|
|
12989
|
+
if (captureData) {
|
|
12990
|
+
pointerState.captured.delete(object);
|
|
12991
|
+
pointerState.captured.set(newObject, {
|
|
12992
|
+
...captureData,
|
|
12993
|
+
intersection: {
|
|
12994
|
+
...captureData.intersection,
|
|
12995
|
+
object: captureData.intersection.object === object ? newObject : captureData.intersection.object,
|
|
12996
|
+
eventObject: captureData.intersection.eventObject === object ? newObject : captureData.intersection.eventObject
|
|
13384
12997
|
}
|
|
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");
|
|
12998
|
+
});
|
|
12999
|
+
}
|
|
13000
|
+
}
|
|
13001
|
+
unregisterVisibility(store, object);
|
|
13002
|
+
}
|
|
13003
|
+
function removeInteractivity(store, object) {
|
|
13004
|
+
const { internal } = store.getState();
|
|
13005
|
+
internal.interaction = internal.interaction.filter((o) => o !== object);
|
|
13006
|
+
for (const [pointerId, pointerState] of internal.pointerMap) {
|
|
13007
|
+
pointerState.initialHits = pointerState.initialHits.filter((o) => o !== object);
|
|
13008
|
+
pointerState.hovered.forEach((value, key) => {
|
|
13009
|
+
if (value.eventObject === object || value.object === object) {
|
|
13010
|
+
pointerState.hovered.delete(key);
|
|
13435
13011
|
}
|
|
13436
|
-
|
|
13437
|
-
|
|
13438
|
-
|
|
13439
|
-
|
|
13440
|
-
|
|
13012
|
+
});
|
|
13013
|
+
if (pointerState.captured.has(object)) {
|
|
13014
|
+
releaseInternalPointerCapture(internal, object, pointerId);
|
|
13015
|
+
}
|
|
13016
|
+
}
|
|
13017
|
+
unregisterVisibility(store, object);
|
|
13018
|
+
}
|
|
13019
|
+
function createEvents(store) {
|
|
13020
|
+
function calculateDistance(event, pointerId) {
|
|
13021
|
+
const { internal } = store.getState();
|
|
13022
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13023
|
+
if (!pointerState) return 0;
|
|
13024
|
+
const [initialX, initialY] = pointerState.initialClick;
|
|
13025
|
+
const dx = event.offsetX - initialX;
|
|
13026
|
+
const dy = event.offsetY - initialY;
|
|
13027
|
+
return Math.round(Math.sqrt(dx * dx + dy * dy));
|
|
13028
|
+
}
|
|
13029
|
+
function filterPointerEvents(objects) {
|
|
13030
|
+
return objects.filter(
|
|
13031
|
+
(obj) => ["Move", "Over", "Enter", "Out", "Leave"].some(
|
|
13032
|
+
(name) => obj.__r3f?.handlers["onPointer" + name]
|
|
13033
|
+
) || ["OverEnter", "OverLeave", "Over"].some(
|
|
13034
|
+
(name) => obj.__r3f?.handlers["onDrag" + name]
|
|
13035
|
+
) || obj.__r3f?.handlers.onDrop
|
|
13036
|
+
);
|
|
13037
|
+
}
|
|
13038
|
+
function intersect(event, filter) {
|
|
13039
|
+
const state = store.getState();
|
|
13040
|
+
const duplicates = /* @__PURE__ */ new Set();
|
|
13041
|
+
const intersections = [];
|
|
13042
|
+
const eventsObjects = filter ? filter(state.internal.interaction) : state.internal.interaction;
|
|
13043
|
+
for (let i = 0; i < eventsObjects.length; i++) {
|
|
13044
|
+
const state2 = getRootState(eventsObjects[i]);
|
|
13045
|
+
if (state2) {
|
|
13046
|
+
state2.raycaster.camera = void 0;
|
|
13441
13047
|
}
|
|
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);
|
|
13048
|
+
}
|
|
13049
|
+
if (!state.previousRoot) {
|
|
13050
|
+
state.events.compute?.(event, state);
|
|
13051
|
+
}
|
|
13052
|
+
function handleRaycast(obj) {
|
|
13053
|
+
const state2 = getRootState(obj);
|
|
13054
|
+
if (!state2 || !state2.events.enabled || state2.raycaster.camera === null) return [];
|
|
13055
|
+
if (state2.raycaster.camera === void 0) {
|
|
13056
|
+
state2.events.compute?.(event, state2, state2.previousRoot?.getState());
|
|
13057
|
+
if (state2.raycaster.camera === void 0) state2.raycaster.camera = null;
|
|
13058
|
+
}
|
|
13059
|
+
if (!state2.raycaster.camera) return [];
|
|
13060
|
+
obj.updateWorldMatrix(true, true);
|
|
13061
|
+
return state2.raycaster.intersectObject(obj, true);
|
|
13062
|
+
}
|
|
13063
|
+
let hits = eventsObjects.flatMap(handleRaycast).sort((a, b) => {
|
|
13064
|
+
const aInteractivePriority = a.object.userData?.interactivePriority;
|
|
13065
|
+
const bInteractivePriority = b.object.userData?.interactivePriority;
|
|
13066
|
+
if (aInteractivePriority !== void 0 || bInteractivePriority !== void 0) {
|
|
13067
|
+
if (aInteractivePriority !== void 0 && bInteractivePriority === void 0) return -1;
|
|
13068
|
+
if (bInteractivePriority !== void 0 && aInteractivePriority === void 0) return 1;
|
|
13069
|
+
if (aInteractivePriority !== bInteractivePriority) {
|
|
13070
|
+
return (bInteractivePriority ?? 0) - (aInteractivePriority ?? 0);
|
|
13469
13071
|
}
|
|
13470
|
-
}
|
|
13471
|
-
|
|
13472
|
-
|
|
13473
|
-
|
|
13474
|
-
|
|
13475
|
-
|
|
13072
|
+
}
|
|
13073
|
+
const aState = getRootState(a.object);
|
|
13074
|
+
const bState = getRootState(b.object);
|
|
13075
|
+
const aPriority = aState?.events?.priority ?? 1;
|
|
13076
|
+
const bPriority = bState?.events?.priority ?? 1;
|
|
13077
|
+
return bPriority - aPriority || a.distance - b.distance;
|
|
13078
|
+
}).filter((item) => {
|
|
13079
|
+
const id = makeId(item);
|
|
13080
|
+
if (duplicates.has(id)) return false;
|
|
13081
|
+
duplicates.add(id);
|
|
13082
|
+
return true;
|
|
13083
|
+
});
|
|
13084
|
+
if (state.events.filter) hits = state.events.filter(hits, state);
|
|
13085
|
+
for (const hit of hits) {
|
|
13086
|
+
let eventObject = hit.object;
|
|
13087
|
+
while (eventObject) {
|
|
13088
|
+
if (eventObject.__r3f?.eventCount) {
|
|
13089
|
+
intersections.push({ ...hit, eventObject });
|
|
13476
13090
|
}
|
|
13477
|
-
|
|
13478
|
-
|
|
13479
|
-
|
|
13480
|
-
|
|
13481
|
-
|
|
13482
|
-
|
|
13483
|
-
|
|
13484
|
-
|
|
13485
|
-
|
|
13091
|
+
eventObject = eventObject.parent;
|
|
13092
|
+
}
|
|
13093
|
+
}
|
|
13094
|
+
if ("pointerId" in event) {
|
|
13095
|
+
const pointerId = event.pointerId;
|
|
13096
|
+
const pointerState = state.internal.pointerMap.get(pointerId);
|
|
13097
|
+
if (pointerState?.captured.size) {
|
|
13098
|
+
for (const captureData of pointerState.captured.values()) {
|
|
13099
|
+
if (!duplicates.has(makeId(captureData.intersection))) intersections.push(captureData.intersection);
|
|
13100
|
+
}
|
|
13101
|
+
}
|
|
13102
|
+
}
|
|
13103
|
+
return intersections;
|
|
13104
|
+
}
|
|
13105
|
+
function handleIntersects(intersections, event, delta, callback) {
|
|
13106
|
+
if (intersections.length) {
|
|
13107
|
+
const localState = { stopped: false };
|
|
13108
|
+
for (const hit of intersections) {
|
|
13109
|
+
const state = getRootState(hit.object);
|
|
13110
|
+
if (state) {
|
|
13111
|
+
const { raycaster, pointer, camera, internal } = state;
|
|
13112
|
+
const unprojectedPoint = new Vector3(pointer.x, pointer.y, 0).unproject(camera);
|
|
13113
|
+
const hasPointerCapture = (id) => {
|
|
13114
|
+
const pointerState = internal.pointerMap.get(id);
|
|
13115
|
+
return pointerState?.captured.has(hit.eventObject) ?? false;
|
|
13116
|
+
};
|
|
13117
|
+
const setPointerCapture = (id) => {
|
|
13118
|
+
const captureData = { intersection: hit, target: event.target };
|
|
13119
|
+
const pointerState = getPointerState(internal, id);
|
|
13120
|
+
pointerState.captured.set(hit.eventObject, captureData);
|
|
13121
|
+
event.target.setPointerCapture(id);
|
|
13122
|
+
};
|
|
13123
|
+
const releasePointerCapture = (id) => {
|
|
13124
|
+
releaseInternalPointerCapture(internal, hit.eventObject, id);
|
|
13125
|
+
};
|
|
13126
|
+
const extractEventProps = {};
|
|
13127
|
+
for (const prop in event) {
|
|
13128
|
+
const property = event[prop];
|
|
13129
|
+
if (typeof property !== "function") extractEventProps[prop] = property;
|
|
13130
|
+
}
|
|
13131
|
+
const eventPointerId = "pointerId" in event ? event.pointerId : void 0;
|
|
13132
|
+
const raycastEvent = {
|
|
13133
|
+
...hit,
|
|
13134
|
+
...extractEventProps,
|
|
13135
|
+
pointer,
|
|
13136
|
+
intersections,
|
|
13137
|
+
stopped: localState.stopped,
|
|
13138
|
+
delta,
|
|
13139
|
+
unprojectedPoint,
|
|
13140
|
+
ray: raycaster.ray,
|
|
13141
|
+
camera,
|
|
13142
|
+
pointerId: eventPointerId,
|
|
13143
|
+
// Hijack stopPropagation, which just sets a flag
|
|
13144
|
+
stopPropagation() {
|
|
13145
|
+
const pointerState = eventPointerId !== void 0 ? internal.pointerMap.get(eventPointerId) : void 0;
|
|
13146
|
+
if (
|
|
13147
|
+
// ...if this pointer hasn't been captured
|
|
13148
|
+
!pointerState?.captured.size || // ... or if the hit object is capturing the pointer
|
|
13149
|
+
pointerState.captured.has(hit.eventObject)
|
|
13150
|
+
) {
|
|
13151
|
+
raycastEvent.stopped = localState.stopped = true;
|
|
13152
|
+
if (pointerState?.hovered.size && Array.from(pointerState.hovered.values()).find((i) => i.eventObject === hit.eventObject)) {
|
|
13153
|
+
const higher = intersections.slice(0, intersections.indexOf(hit));
|
|
13154
|
+
cancelPointer([...higher, hit], eventPointerId);
|
|
13486
13155
|
}
|
|
13487
|
-
Kn(e), (ye & (Zn | uo)) === Jn && (Pp = me() + Fg, Wa(0));
|
|
13488
13156
|
}
|
|
13489
|
-
}
|
|
13490
|
-
|
|
13491
|
-
|
|
13492
|
-
|
|
13493
|
-
|
|
13157
|
+
},
|
|
13158
|
+
// there should be a distinction between target and currentTarget
|
|
13159
|
+
target: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
13160
|
+
currentTarget: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
13161
|
+
nativeEvent: event
|
|
13162
|
+
};
|
|
13163
|
+
callback(raycastEvent);
|
|
13164
|
+
if (localState.stopped === true) break;
|
|
13494
13165
|
}
|
|
13495
|
-
}
|
|
13496
|
-
|
|
13497
|
-
|
|
13498
|
-
|
|
13499
|
-
|
|
13500
|
-
|
|
13501
|
-
|
|
13502
|
-
|
|
13503
|
-
|
|
13504
|
-
|
|
13505
|
-
|
|
13506
|
-
|
|
13507
|
-
|
|
13508
|
-
|
|
13509
|
-
|
|
13510
|
-
|
|
13511
|
-
|
|
13166
|
+
}
|
|
13167
|
+
}
|
|
13168
|
+
return intersections;
|
|
13169
|
+
}
|
|
13170
|
+
function cancelPointer(intersections, pointerId) {
|
|
13171
|
+
const { internal } = store.getState();
|
|
13172
|
+
const pid = pointerId ?? DEFAULT_POINTER_ID;
|
|
13173
|
+
const pointerState = internal.pointerMap.get(pid);
|
|
13174
|
+
if (!pointerState) return;
|
|
13175
|
+
for (const [hoveredId, hoveredObj] of pointerState.hovered) {
|
|
13176
|
+
if (!intersections.length || !intersections.find(
|
|
13177
|
+
(hit) => hit.object === hoveredObj.object && hit.index === hoveredObj.index && hit.instanceId === hoveredObj.instanceId
|
|
13178
|
+
)) {
|
|
13179
|
+
const eventObject = hoveredObj.eventObject;
|
|
13180
|
+
const instance = eventObject.__r3f;
|
|
13181
|
+
pointerState.hovered.delete(hoveredId);
|
|
13182
|
+
if (instance?.eventCount) {
|
|
13183
|
+
const handlers = instance.handlers;
|
|
13184
|
+
const data = { ...hoveredObj, intersections };
|
|
13185
|
+
handlers.onPointerOut?.(data);
|
|
13186
|
+
handlers.onPointerLeave?.(data);
|
|
13187
|
+
handlers.onDragOverLeave?.(data);
|
|
13512
13188
|
}
|
|
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;
|
|
13189
|
+
}
|
|
13190
|
+
}
|
|
13191
|
+
}
|
|
13192
|
+
function pointerMissed(event, objects) {
|
|
13193
|
+
for (let i = 0; i < objects.length; i++) {
|
|
13194
|
+
const instance = objects[i].__r3f;
|
|
13195
|
+
instance?.handlers.onPointerMissed?.(event);
|
|
13196
|
+
}
|
|
13197
|
+
}
|
|
13198
|
+
function dragOverMissed(event, objects) {
|
|
13199
|
+
for (let i = 0; i < objects.length; i++) {
|
|
13200
|
+
const instance = objects[i].__r3f;
|
|
13201
|
+
instance?.handlers.onDragOverMissed?.(event);
|
|
13202
|
+
}
|
|
13203
|
+
}
|
|
13204
|
+
function dropMissed(event, objects) {
|
|
13205
|
+
for (let i = 0; i < objects.length; i++) {
|
|
13206
|
+
const instance = objects[i].__r3f;
|
|
13207
|
+
instance?.handlers.onDropMissed?.(event);
|
|
13208
|
+
}
|
|
13209
|
+
}
|
|
13210
|
+
function cleanupPointer(pointerId) {
|
|
13211
|
+
const { internal } = store.getState();
|
|
13212
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13213
|
+
if (pointerState) {
|
|
13214
|
+
for (const [, hoveredObj] of pointerState.hovered) {
|
|
13215
|
+
const eventObject = hoveredObj.eventObject;
|
|
13216
|
+
const instance = eventObject.__r3f;
|
|
13217
|
+
if (instance?.eventCount) {
|
|
13218
|
+
const handlers = instance.handlers;
|
|
13219
|
+
const data = { ...hoveredObj, intersections: [] };
|
|
13220
|
+
handlers.onPointerOut?.(data);
|
|
13221
|
+
handlers.onPointerLeave?.(data);
|
|
13547
13222
|
}
|
|
13548
|
-
}
|
|
13549
|
-
|
|
13550
|
-
|
|
13551
|
-
|
|
13552
|
-
|
|
13553
|
-
|
|
13223
|
+
}
|
|
13224
|
+
internal.pointerMap.delete(pointerId);
|
|
13225
|
+
}
|
|
13226
|
+
internal.pointerDirty.delete(pointerId);
|
|
13227
|
+
}
|
|
13228
|
+
function processDeferredPointer(event, pointerId) {
|
|
13229
|
+
const state = store.getState();
|
|
13230
|
+
const { internal } = state;
|
|
13231
|
+
if (!state.events.enabled) return;
|
|
13232
|
+
const filter = filterPointerEvents;
|
|
13233
|
+
const hits = intersect(event, filter);
|
|
13234
|
+
cancelPointer(hits, pointerId);
|
|
13235
|
+
function onIntersect(data) {
|
|
13236
|
+
const eventObject = data.eventObject;
|
|
13237
|
+
const instance = eventObject.__r3f;
|
|
13238
|
+
if (!instance?.eventCount) return;
|
|
13239
|
+
const handlers = instance.handlers;
|
|
13240
|
+
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
13241
|
+
const id = makeId(data);
|
|
13242
|
+
const pointerState = getPointerState(internal, pointerId);
|
|
13243
|
+
const hoveredItem = pointerState.hovered.get(id);
|
|
13244
|
+
if (!hoveredItem) {
|
|
13245
|
+
pointerState.hovered.set(id, data);
|
|
13246
|
+
handlers.onPointerOver?.(data);
|
|
13247
|
+
handlers.onPointerEnter?.(data);
|
|
13248
|
+
} else if (hoveredItem.stopped) {
|
|
13249
|
+
data.stopPropagation();
|
|
13250
|
+
}
|
|
13251
|
+
}
|
|
13252
|
+
handlers.onPointerMove?.(data);
|
|
13253
|
+
}
|
|
13254
|
+
handleIntersects(hits, event, 0, onIntersect);
|
|
13255
|
+
}
|
|
13256
|
+
function handlePointer(name) {
|
|
13257
|
+
switch (name) {
|
|
13258
|
+
case "onPointerLeave":
|
|
13259
|
+
case "onDragLeave":
|
|
13260
|
+
return () => cancelPointer([]);
|
|
13261
|
+
// Global cancel of these events
|
|
13262
|
+
case "onPointerCancel":
|
|
13263
|
+
return (event) => {
|
|
13264
|
+
const pointerId = getPointerId(event);
|
|
13265
|
+
cleanupPointer(pointerId);
|
|
13266
|
+
};
|
|
13267
|
+
case "onLostPointerCapture":
|
|
13268
|
+
return (event) => {
|
|
13269
|
+
const { internal } = store.getState();
|
|
13270
|
+
const pointerId = getPointerId(event);
|
|
13271
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13272
|
+
if (pointerState?.captured.size) {
|
|
13273
|
+
requestAnimationFrame(() => {
|
|
13274
|
+
const pointerState2 = internal.pointerMap.get(pointerId);
|
|
13275
|
+
if (pointerState2?.captured.size) {
|
|
13276
|
+
pointerState2.captured.clear();
|
|
13277
|
+
}
|
|
13278
|
+
cancelPointer([], pointerId);
|
|
13279
|
+
});
|
|
13280
|
+
}
|
|
13281
|
+
};
|
|
13282
|
+
}
|
|
13283
|
+
return function handleEvent(event) {
|
|
13284
|
+
const state = store.getState();
|
|
13285
|
+
const { onPointerMissed, onDragOverMissed, onDropMissed, internal, events } = state;
|
|
13286
|
+
const pointerId = getPointerId(event);
|
|
13287
|
+
internal.lastEvent.current = event;
|
|
13288
|
+
if (!events.enabled) return;
|
|
13289
|
+
const isPointerMove = name === "onPointerMove";
|
|
13290
|
+
const isDragOver = name === "onDragOver";
|
|
13291
|
+
const isDrop = name === "onDrop";
|
|
13292
|
+
const isClickEvent = name === "onClick" || name === "onContextMenu" || name === "onDoubleClick";
|
|
13293
|
+
const isPointerDown = name === "onPointerDown";
|
|
13294
|
+
const isPointerUp = name === "onPointerUp";
|
|
13295
|
+
const isWheel = name === "onWheel";
|
|
13296
|
+
const canDeferRaycasts = events.frameTimedRaycasts && state.frameloop === "always";
|
|
13297
|
+
if (isPointerMove && canDeferRaycasts) {
|
|
13298
|
+
events.compute?.(event, state);
|
|
13299
|
+
internal.pointerDirty.set(pointerId, event);
|
|
13300
|
+
return;
|
|
13301
|
+
}
|
|
13302
|
+
if (isWheel && canDeferRaycasts && !events.alwaysFireOnScroll) {
|
|
13303
|
+
events.compute?.(event, state);
|
|
13304
|
+
internal.pointerDirty.set(pointerId, event);
|
|
13305
|
+
return;
|
|
13306
|
+
}
|
|
13307
|
+
if ((isClickEvent || isPointerDown || isPointerUp) && internal.pointerDirty.has(pointerId)) {
|
|
13308
|
+
const deferredEvent = internal.pointerDirty.get(pointerId);
|
|
13309
|
+
internal.pointerDirty.delete(pointerId);
|
|
13310
|
+
processDeferredPointer(deferredEvent, pointerId);
|
|
13311
|
+
}
|
|
13312
|
+
const filter = isPointerMove || isDragOver || isDrop ? filterPointerEvents : void 0;
|
|
13313
|
+
const hits = intersect(event, filter);
|
|
13314
|
+
const delta = isClickEvent ? calculateDistance(event, pointerId) : 0;
|
|
13315
|
+
if (isPointerDown) {
|
|
13316
|
+
const pointerState2 = getPointerState(internal, pointerId);
|
|
13317
|
+
pointerState2.initialClick = [event.offsetX, event.offsetY];
|
|
13318
|
+
pointerState2.initialHits = hits.map((hit) => hit.eventObject);
|
|
13319
|
+
}
|
|
13320
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13321
|
+
const initialHits = pointerState?.initialHits ?? [];
|
|
13322
|
+
if (isClickEvent && !hits.length) {
|
|
13323
|
+
if (delta <= 2) {
|
|
13324
|
+
pointerMissed(event, internal.interaction);
|
|
13325
|
+
if (onPointerMissed) onPointerMissed(event);
|
|
13554
13326
|
}
|
|
13555
|
-
}
|
|
13556
|
-
|
|
13557
|
-
|
|
13558
|
-
|
|
13559
|
-
|
|
13560
|
-
|
|
13561
|
-
|
|
13562
|
-
|
|
13563
|
-
|
|
13564
|
-
|
|
13565
|
-
|
|
13566
|
-
|
|
13567
|
-
|
|
13568
|
-
|
|
13569
|
-
|
|
13570
|
-
|
|
13571
|
-
|
|
13572
|
-
|
|
13573
|
-
|
|
13327
|
+
}
|
|
13328
|
+
if (isDragOver && !hits.length) {
|
|
13329
|
+
dragOverMissed(event, internal.interaction);
|
|
13330
|
+
if (onDragOverMissed) onDragOverMissed(event);
|
|
13331
|
+
}
|
|
13332
|
+
if (isDrop && !hits.length) {
|
|
13333
|
+
dropMissed(event, internal.interaction);
|
|
13334
|
+
if (onDropMissed) onDropMissed(event);
|
|
13335
|
+
}
|
|
13336
|
+
if (isPointerMove || isDragOver) {
|
|
13337
|
+
cancelPointer(hits, pointerId);
|
|
13338
|
+
}
|
|
13339
|
+
function onIntersect(data) {
|
|
13340
|
+
const eventObject = data.eventObject;
|
|
13341
|
+
const instance = eventObject.__r3f;
|
|
13342
|
+
if (!instance?.eventCount) return;
|
|
13343
|
+
const handlers = instance.handlers;
|
|
13344
|
+
if (isPointerMove) {
|
|
13345
|
+
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
13346
|
+
const id = makeId(data);
|
|
13347
|
+
const pointerState2 = getPointerState(internal, pointerId);
|
|
13348
|
+
const hoveredItem = pointerState2.hovered.get(id);
|
|
13349
|
+
if (!hoveredItem) {
|
|
13350
|
+
pointerState2.hovered.set(id, data);
|
|
13351
|
+
handlers.onPointerOver?.(data);
|
|
13352
|
+
handlers.onPointerEnter?.(data);
|
|
13353
|
+
} else if (hoveredItem.stopped) {
|
|
13354
|
+
data.stopPropagation();
|
|
13574
13355
|
}
|
|
13575
13356
|
}
|
|
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;
|
|
13357
|
+
handlers.onPointerMove?.(data);
|
|
13358
|
+
} else if (isDragOver) {
|
|
13359
|
+
const id = makeId(data);
|
|
13360
|
+
const pointerState2 = getPointerState(internal, pointerId);
|
|
13361
|
+
const hoveredItem = pointerState2.hovered.get(id);
|
|
13362
|
+
if (!hoveredItem) {
|
|
13363
|
+
pointerState2.hovered.set(id, data);
|
|
13364
|
+
handlers.onDragOverEnter?.(data);
|
|
13365
|
+
} else if (hoveredItem.stopped) {
|
|
13366
|
+
data.stopPropagation();
|
|
13367
|
+
}
|
|
13368
|
+
handlers.onDragOver?.(data);
|
|
13369
|
+
} else if (isDrop) {
|
|
13370
|
+
handlers.onDrop?.(data);
|
|
13371
|
+
} else {
|
|
13372
|
+
const handler = handlers[name];
|
|
13373
|
+
if (handler) {
|
|
13374
|
+
if (!isClickEvent || initialHits.includes(eventObject)) {
|
|
13375
|
+
pointerMissed(
|
|
13376
|
+
event,
|
|
13377
|
+
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
13378
|
+
);
|
|
13379
|
+
handler(data);
|
|
13380
|
+
}
|
|
13381
|
+
} else {
|
|
13382
|
+
if (isClickEvent && initialHits.includes(eventObject)) {
|
|
13383
|
+
pointerMissed(
|
|
13384
|
+
event,
|
|
13385
|
+
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
13386
|
+
);
|
|
13387
|
+
}
|
|
13611
13388
|
}
|
|
13612
13389
|
}
|
|
13613
|
-
|
|
13614
|
-
|
|
13615
|
-
|
|
13616
|
-
|
|
13617
|
-
|
|
13618
|
-
|
|
13619
|
-
|
|
13620
|
-
|
|
13390
|
+
}
|
|
13391
|
+
handleIntersects(hits, event, delta, onIntersect);
|
|
13392
|
+
};
|
|
13393
|
+
}
|
|
13394
|
+
function flushDeferredPointers() {
|
|
13395
|
+
const { internal, events } = store.getState();
|
|
13396
|
+
if (!events.frameTimedRaycasts) return;
|
|
13397
|
+
for (const [pointerId, event] of internal.pointerDirty) {
|
|
13398
|
+
processDeferredPointer(event, pointerId);
|
|
13399
|
+
}
|
|
13400
|
+
internal.pointerDirty.clear();
|
|
13401
|
+
}
|
|
13402
|
+
return { handlePointer, flushDeferredPointers, processDeferredPointer };
|
|
13403
|
+
}
|
|
13404
|
+
const DOM_EVENTS = {
|
|
13405
|
+
onClick: ["click", false],
|
|
13406
|
+
onContextMenu: ["contextmenu", false],
|
|
13407
|
+
onDoubleClick: ["dblclick", false],
|
|
13408
|
+
onDragEnter: ["dragenter", false],
|
|
13409
|
+
onDragLeave: ["dragleave", false],
|
|
13410
|
+
onDragOver: ["dragover", false],
|
|
13411
|
+
onDrop: ["drop", false],
|
|
13412
|
+
onWheel: ["wheel", true],
|
|
13413
|
+
onPointerDown: ["pointerdown", true],
|
|
13414
|
+
onPointerUp: ["pointerup", true],
|
|
13415
|
+
onPointerLeave: ["pointerleave", true],
|
|
13416
|
+
onPointerMove: ["pointermove", true],
|
|
13417
|
+
onPointerCancel: ["pointercancel", true],
|
|
13418
|
+
onLostPointerCapture: ["lostpointercapture", true]
|
|
13419
|
+
};
|
|
13420
|
+
function createPointerEvents(store) {
|
|
13421
|
+
const { handlePointer, flushDeferredPointers, processDeferredPointer } = createEvents(store);
|
|
13422
|
+
let nextXRPointerId = XR_POINTER_ID_START;
|
|
13423
|
+
const xrPointers = /* @__PURE__ */ new Map();
|
|
13424
|
+
return {
|
|
13425
|
+
priority: 1,
|
|
13426
|
+
enabled: true,
|
|
13427
|
+
frameTimedRaycasts: true,
|
|
13428
|
+
alwaysFireOnScroll: true,
|
|
13429
|
+
updateOnFrame: false,
|
|
13430
|
+
compute(event, state) {
|
|
13431
|
+
state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
|
|
13432
|
+
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
13433
|
+
},
|
|
13434
|
+
connected: void 0,
|
|
13435
|
+
handlers: Object.keys(DOM_EVENTS).reduce(
|
|
13436
|
+
(acc, key) => ({ ...acc, [key]: handlePointer(key) }),
|
|
13437
|
+
{}
|
|
13438
|
+
),
|
|
13439
|
+
update: (pointerId) => {
|
|
13440
|
+
const { events, internal } = store.getState();
|
|
13441
|
+
if (!events.handlers) return;
|
|
13442
|
+
if (pointerId !== void 0) {
|
|
13443
|
+
const event = internal.pointerDirty.get(pointerId);
|
|
13444
|
+
if (event) {
|
|
13445
|
+
internal.pointerDirty.delete(pointerId);
|
|
13446
|
+
processDeferredPointer(event, pointerId);
|
|
13447
|
+
} else if (internal.lastEvent?.current) {
|
|
13448
|
+
processDeferredPointer(internal.lastEvent.current, pointerId);
|
|
13621
13449
|
}
|
|
13622
|
-
|
|
13623
|
-
|
|
13624
|
-
|
|
13625
|
-
|
|
13626
|
-
|
|
13627
|
-
No matching component was found for:
|
|
13628
|
-
`) + e.join(" > ");
|
|
13450
|
+
} else {
|
|
13451
|
+
flushDeferredPointers();
|
|
13452
|
+
if (internal.lastEvent?.current) {
|
|
13453
|
+
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
13629
13454
|
}
|
|
13630
|
-
|
|
13631
|
-
|
|
13632
|
-
|
|
13633
|
-
|
|
13634
|
-
|
|
13635
|
-
|
|
13636
|
-
|
|
13637
|
-
|
|
13638
|
-
|
|
13455
|
+
}
|
|
13456
|
+
},
|
|
13457
|
+
flush: () => {
|
|
13458
|
+
const { events, internal } = store.getState();
|
|
13459
|
+
flushDeferredPointers();
|
|
13460
|
+
if (events.updateOnFrame && internal.lastEvent?.current && events.handlers) {
|
|
13461
|
+
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
13462
|
+
}
|
|
13463
|
+
},
|
|
13464
|
+
connect: (target) => {
|
|
13465
|
+
if (!target) return;
|
|
13466
|
+
const { set, events } = store.getState();
|
|
13467
|
+
events.disconnect?.();
|
|
13468
|
+
set((state) => ({ events: { ...state.events, connected: target } }));
|
|
13469
|
+
if (events.handlers) {
|
|
13470
|
+
for (const name in events.handlers) {
|
|
13471
|
+
const event = events.handlers[name];
|
|
13472
|
+
const [eventName, passive] = DOM_EVENTS[name];
|
|
13473
|
+
target.addEventListener(eventName, event, { passive });
|
|
13639
13474
|
}
|
|
13640
|
-
}
|
|
13641
|
-
|
|
13642
|
-
|
|
13643
|
-
|
|
13644
|
-
|
|
13645
|
-
|
|
13646
|
-
|
|
13647
|
-
|
|
13648
|
-
|
|
13649
|
-
|
|
13650
|
-
}
|
|
13475
|
+
}
|
|
13476
|
+
},
|
|
13477
|
+
disconnect: () => {
|
|
13478
|
+
const { set, events } = store.getState();
|
|
13479
|
+
if (events.connected) {
|
|
13480
|
+
if (events.handlers) {
|
|
13481
|
+
for (const name in events.handlers) {
|
|
13482
|
+
const event = events.handlers[name];
|
|
13483
|
+
const [eventName] = DOM_EVENTS[name];
|
|
13484
|
+
events.connected.removeEventListener(eventName, event);
|
|
13485
|
+
}
|
|
13486
|
+
}
|
|
13487
|
+
set((state) => ({ events: { ...state.events, connected: void 0 } }));
|
|
13488
|
+
}
|
|
13489
|
+
},
|
|
13490
|
+
// PREVIEW (A8): the XR pointer registration API may change before stable.
|
|
13491
|
+
registerPointer: (config) => {
|
|
13492
|
+
const pointerId = nextXRPointerId++;
|
|
13493
|
+
xrPointers.set(pointerId, config);
|
|
13494
|
+
const { internal } = store.getState();
|
|
13495
|
+
getPointerState(internal, pointerId);
|
|
13496
|
+
return pointerId;
|
|
13497
|
+
},
|
|
13498
|
+
unregisterPointer: (pointerId) => {
|
|
13499
|
+
xrPointers.delete(pointerId);
|
|
13500
|
+
const { internal } = store.getState();
|
|
13501
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13502
|
+
if (pointerState) {
|
|
13503
|
+
for (const [, hoveredObj] of pointerState.hovered) {
|
|
13504
|
+
const eventObject = hoveredObj.eventObject;
|
|
13505
|
+
const instance = eventObject.__r3f;
|
|
13506
|
+
if (instance?.eventCount) {
|
|
13507
|
+
const handlers = instance.handlers;
|
|
13508
|
+
const data = { ...hoveredObj, intersections: [] };
|
|
13509
|
+
handlers.onPointerOut?.(data);
|
|
13510
|
+
handlers.onPointerLeave?.(data);
|
|
13511
|
+
}
|
|
13651
13512
|
}
|
|
13652
|
-
|
|
13653
|
-
|
|
13654
|
-
|
|
13655
|
-
|
|
13656
|
-
|
|
13657
|
-
var S = bm.indexOf(s);
|
|
13658
|
-
0 <= S && bm.splice(S, 1), f();
|
|
13659
|
-
} };
|
|
13660
|
-
}, le.shouldError = function(e) {
|
|
13661
|
-
return pu(e);
|
|
13662
|
-
}, le.shouldSuspend = function(e) {
|
|
13663
|
-
return fu(e);
|
|
13664
|
-
}, le.startHostTransition = function(e, n, o, i) {
|
|
13665
|
-
if (e.tag !== 5) throw Error("Expected the form instance to be a HostComponent. This is a bug in React.");
|
|
13666
|
-
var s = uf(e).queue;
|
|
13667
|
-
Hp(e), nt(e, s, n, Xt, o === null ? Em : function() {
|
|
13668
|
-
x.T === null && console.error("requestFormReset was called outside a transition or action. To fix, move to an action, or wrap with startTransition.");
|
|
13669
|
-
var u = uf(e);
|
|
13670
|
-
return u.next === null && (u = e.alternate.memoizedState), qi(e, u.next.queue, {}, Nt(e)), o(i);
|
|
13671
|
-
});
|
|
13672
|
-
}, le.updateContainer = function(e, n, o, i) {
|
|
13673
|
-
var s = n.current, u = Nt(s);
|
|
13674
|
-
return As(s, u, e, n, o, i), u;
|
|
13675
|
-
}, le.updateContainerSync = Wh, le;
|
|
13676
|
-
}, Tt.exports.default = Tt.exports, Object.defineProperty(Tt.exports, "__esModule", { value: true }));
|
|
13677
|
-
})(Mg)), Mg.exports;
|
|
13678
|
-
}
|
|
13679
|
-
var Eb;
|
|
13680
|
-
function n0() {
|
|
13681
|
-
return Eb || (Eb = 1, process.env.NODE_ENV === "production" ? Rm.exports = Kb() : Rm.exports = e0()), Rm.exports;
|
|
13513
|
+
internal.pointerMap.delete(pointerId);
|
|
13514
|
+
}
|
|
13515
|
+
internal.pointerDirty.delete(pointerId);
|
|
13516
|
+
}
|
|
13517
|
+
};
|
|
13682
13518
|
}
|
|
13683
|
-
var t0 = n0();
|
|
13684
|
-
const r0 = Xb(t0);
|
|
13685
|
-
|
|
13686
|
-
const t = 1, o = 8, r = 32, e = 2;
|
|
13687
13519
|
|
|
13688
13520
|
function createReconciler(config) {
|
|
13689
13521
|
const reconciler2 = r0(config);
|
|
@@ -13848,7 +13680,15 @@ function setFiberRef(fiber, publicInstance) {
|
|
|
13848
13680
|
}
|
|
13849
13681
|
}
|
|
13850
13682
|
const reconstructed = [];
|
|
13851
|
-
function
|
|
13683
|
+
function flushReconstructedInstances() {
|
|
13684
|
+
if (reconstructed.length === 0) return;
|
|
13685
|
+
try {
|
|
13686
|
+
swapReconstructedInstances();
|
|
13687
|
+
} finally {
|
|
13688
|
+
reconstructed.length = 0;
|
|
13689
|
+
}
|
|
13690
|
+
}
|
|
13691
|
+
function swapReconstructedInstances() {
|
|
13852
13692
|
for (const [instance] of reconstructed) {
|
|
13853
13693
|
const parent = instance.parent;
|
|
13854
13694
|
if (parent) {
|
|
@@ -13866,7 +13706,9 @@ function swapInstances() {
|
|
|
13866
13706
|
}
|
|
13867
13707
|
}
|
|
13868
13708
|
if (instance.isHidden) unhideInstance(instance);
|
|
13869
|
-
if (isObject3D(instance.object)
|
|
13709
|
+
if (isObject3D(instance.object) && !instance.parent) {
|
|
13710
|
+
removeInteractivity(findInitialRoot(instance), instance.object);
|
|
13711
|
+
}
|
|
13870
13712
|
if (instance.object.__r3f) delete instance.object.__r3f;
|
|
13871
13713
|
if (instance.type !== "primitive") disposeOnIdle(instance.object);
|
|
13872
13714
|
}
|
|
@@ -13875,9 +13717,13 @@ function swapInstances() {
|
|
|
13875
13717
|
const parent = instance.parent;
|
|
13876
13718
|
if (parent) {
|
|
13877
13719
|
const target = catalogue[toPascalCase(instance.type)];
|
|
13720
|
+
const prevObject = instance.object;
|
|
13878
13721
|
instance.object = instance.props.object ?? new target(...instance.props.args ?? []);
|
|
13879
13722
|
instance.object.__r3f = instance;
|
|
13880
13723
|
setFiberRef(fiber, instance.object);
|
|
13724
|
+
if (isObject3D(prevObject) && isObject3D(instance.object)) {
|
|
13725
|
+
swapInteractivity(findInitialRoot(instance), prevObject, instance.object);
|
|
13726
|
+
}
|
|
13881
13727
|
delete instance.appliedOnce;
|
|
13882
13728
|
instance.eventCount = 0;
|
|
13883
13729
|
instance.handlers = {};
|
|
@@ -13897,14 +13743,114 @@ function swapInstances() {
|
|
|
13897
13743
|
invalidateInstance(instance);
|
|
13898
13744
|
}
|
|
13899
13745
|
}
|
|
13900
|
-
reconstructed.length = 0;
|
|
13901
13746
|
}
|
|
13902
13747
|
const handleTextInstance = () => {
|
|
13903
13748
|
};
|
|
13904
13749
|
const NO_CONTEXT = {};
|
|
13905
13750
|
let currentUpdatePriority = NoEventPriority;
|
|
13906
|
-
|
|
13907
|
-
|
|
13751
|
+
function getEventPriority(type) {
|
|
13752
|
+
switch (type) {
|
|
13753
|
+
case "beforetoggle":
|
|
13754
|
+
case "cancel":
|
|
13755
|
+
case "click":
|
|
13756
|
+
case "close":
|
|
13757
|
+
case "contextmenu":
|
|
13758
|
+
case "copy":
|
|
13759
|
+
case "cut":
|
|
13760
|
+
case "auxclick":
|
|
13761
|
+
case "dblclick":
|
|
13762
|
+
case "dragend":
|
|
13763
|
+
case "dragstart":
|
|
13764
|
+
case "drop":
|
|
13765
|
+
case "focusin":
|
|
13766
|
+
case "focusout":
|
|
13767
|
+
case "input":
|
|
13768
|
+
case "invalid":
|
|
13769
|
+
case "keydown":
|
|
13770
|
+
case "keypress":
|
|
13771
|
+
case "keyup":
|
|
13772
|
+
case "mousedown":
|
|
13773
|
+
case "mouseup":
|
|
13774
|
+
case "paste":
|
|
13775
|
+
case "pause":
|
|
13776
|
+
case "play":
|
|
13777
|
+
case "pointercancel":
|
|
13778
|
+
case "pointerdown":
|
|
13779
|
+
case "pointerup":
|
|
13780
|
+
case "ratechange":
|
|
13781
|
+
case "reset":
|
|
13782
|
+
case "resize":
|
|
13783
|
+
case "seeked":
|
|
13784
|
+
case "submit":
|
|
13785
|
+
case "touchcancel":
|
|
13786
|
+
case "touchend":
|
|
13787
|
+
case "touchstart":
|
|
13788
|
+
case "volumechange":
|
|
13789
|
+
case "change":
|
|
13790
|
+
case "selectionchange":
|
|
13791
|
+
case "compositionstart":
|
|
13792
|
+
case "compositionend":
|
|
13793
|
+
case "compositionupdate":
|
|
13794
|
+
case "beforeinput":
|
|
13795
|
+
case "blur":
|
|
13796
|
+
case "fullscreenchange":
|
|
13797
|
+
case "focus":
|
|
13798
|
+
case "hashchange":
|
|
13799
|
+
case "popstate":
|
|
13800
|
+
case "select":
|
|
13801
|
+
case "selectstart":
|
|
13802
|
+
return e;
|
|
13803
|
+
case "drag":
|
|
13804
|
+
case "dragenter":
|
|
13805
|
+
case "dragexit":
|
|
13806
|
+
case "dragleave":
|
|
13807
|
+
case "dragover":
|
|
13808
|
+
case "mousemove":
|
|
13809
|
+
case "mouseout":
|
|
13810
|
+
case "mouseover":
|
|
13811
|
+
case "pointermove":
|
|
13812
|
+
case "pointerout":
|
|
13813
|
+
case "pointerover":
|
|
13814
|
+
case "scroll":
|
|
13815
|
+
case "touchmove":
|
|
13816
|
+
case "wheel":
|
|
13817
|
+
case "mouseenter":
|
|
13818
|
+
case "mouseleave":
|
|
13819
|
+
case "pointerenter":
|
|
13820
|
+
case "pointerleave":
|
|
13821
|
+
return o;
|
|
13822
|
+
case "message": {
|
|
13823
|
+
switch (unstable_getCurrentPriorityLevel()) {
|
|
13824
|
+
case unstable_ImmediatePriority:
|
|
13825
|
+
return e;
|
|
13826
|
+
case unstable_UserBlockingPriority:
|
|
13827
|
+
return o;
|
|
13828
|
+
case unstable_NormalPriority:
|
|
13829
|
+
case unstable_LowPriority:
|
|
13830
|
+
return r;
|
|
13831
|
+
case unstable_IdlePriority:
|
|
13832
|
+
return i$1;
|
|
13833
|
+
default:
|
|
13834
|
+
return r;
|
|
13835
|
+
}
|
|
13836
|
+
}
|
|
13837
|
+
default:
|
|
13838
|
+
return r;
|
|
13839
|
+
}
|
|
13840
|
+
}
|
|
13841
|
+
function scheduleMicrotask(callback) {
|
|
13842
|
+
if (typeof queueMicrotask === "function") {
|
|
13843
|
+
queueMicrotask(callback);
|
|
13844
|
+
} else if (typeof Promise !== "undefined") {
|
|
13845
|
+
Promise.resolve().then(callback).catch((error) => {
|
|
13846
|
+
setTimeout(() => {
|
|
13847
|
+
throw error;
|
|
13848
|
+
});
|
|
13849
|
+
});
|
|
13850
|
+
} else {
|
|
13851
|
+
setTimeout(callback);
|
|
13852
|
+
}
|
|
13853
|
+
}
|
|
13908
13854
|
const reconciler = /* @__PURE__ */ createReconciler({
|
|
13909
13855
|
isPrimaryRenderer: false,
|
|
13910
13856
|
warnsIfNotActing: false,
|
|
@@ -13943,16 +13889,15 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13943
13889
|
else if (newProps.args?.length !== oldProps.args?.length) reconstruct = true;
|
|
13944
13890
|
else if (newProps.args?.some((value, index) => value !== oldProps.args?.[index])) reconstruct = true;
|
|
13945
13891
|
if (reconstruct) {
|
|
13946
|
-
reconstructed.push([instance,
|
|
13892
|
+
reconstructed.push([instance, getInstanceProps(newProps), fiber]);
|
|
13947
13893
|
} else {
|
|
13948
13894
|
const changedProps = diffProps(instance, newProps);
|
|
13949
|
-
|
|
13950
|
-
|
|
13951
|
-
|
|
13952
|
-
|
|
13895
|
+
const attach2 = instance.props.attach;
|
|
13896
|
+
instance.props = getInstanceProps(newProps);
|
|
13897
|
+
if (attach2 !== void 0) instance.props.attach = attach2;
|
|
13898
|
+
else delete instance.props.attach;
|
|
13899
|
+
if (Object.keys(changedProps).length) applyProps(instance.object, changedProps);
|
|
13953
13900
|
}
|
|
13954
|
-
const isTailSibling = fiber.sibling === null || (fiber.flags & Update) === NoFlags;
|
|
13955
|
-
if (isTailSibling) swapInstances();
|
|
13956
13901
|
},
|
|
13957
13902
|
finalizeInitialChildren: (instance) => {
|
|
13958
13903
|
for (const prop in instance.props) {
|
|
@@ -13977,8 +13922,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13977
13922
|
const target = container.getState().internal.container ?? container.getState().scene;
|
|
13978
13923
|
return prepare(target, container, "", {});
|
|
13979
13924
|
},
|
|
13980
|
-
|
|
13981
|
-
|
|
13925
|
+
// Reconstructed instances are swapped once all mutations are committed,
|
|
13926
|
+
// before layout effects run so refs point to the new objects
|
|
13927
|
+
resetAfterCommit: flushReconstructedInstances,
|
|
13982
13928
|
shouldSetTextContent: () => false,
|
|
13983
13929
|
clearContainer: () => false,
|
|
13984
13930
|
hideInstance,
|
|
@@ -13986,6 +13932,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13986
13932
|
createTextInstance: handleTextInstance,
|
|
13987
13933
|
hideTextInstance: handleTextInstance,
|
|
13988
13934
|
unhideTextInstance: handleTextInstance,
|
|
13935
|
+
// Mirrors react-dom, which flushes discrete work in microtasks
|
|
13936
|
+
supportsMicrotasks: true,
|
|
13937
|
+
scheduleMicrotask,
|
|
13989
13938
|
scheduleTimeout: typeof setTimeout === "function" ? setTimeout : void 0,
|
|
13990
13939
|
cancelTimeout: typeof clearTimeout === "function" ? clearTimeout : void 0,
|
|
13991
13940
|
noTimeout: -1,
|
|
@@ -14026,28 +13975,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
14026
13975
|
},
|
|
14027
13976
|
resolveUpdatePriority() {
|
|
14028
13977
|
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
|
-
}
|
|
13978
|
+
const eventType = typeof window !== "undefined" ? window.event?.type : void 0;
|
|
13979
|
+
if (eventType === void 0) return r;
|
|
13980
|
+
return getEventPriority(eventType);
|
|
14051
13981
|
},
|
|
14052
13982
|
resetFormInstance() {
|
|
14053
13983
|
},
|
|
@@ -14749,8 +14679,214 @@ function PortalInner({ state = {}, children, container }) {
|
|
|
14749
14679
|
) })
|
|
14750
14680
|
);
|
|
14751
14681
|
}
|
|
14752
|
-
function flushSync(fn) {
|
|
14753
|
-
return reconciler.flushSyncFromReconciler(fn);
|
|
14682
|
+
function flushSync(fn) {
|
|
14683
|
+
return reconciler.flushSyncFromReconciler(fn);
|
|
14684
|
+
}
|
|
14685
|
+
|
|
14686
|
+
const isRef = (obj) => obj.current && obj.current.isScene;
|
|
14687
|
+
const resolveScene = (scene) => isRef(scene) ? scene.current : scene;
|
|
14688
|
+
function setEnvProps(background, scene, defaultScene, texture, sceneProps = {}) {
|
|
14689
|
+
sceneProps = {
|
|
14690
|
+
backgroundBlurriness: 0,
|
|
14691
|
+
backgroundIntensity: 1,
|
|
14692
|
+
backgroundRotation: [0, 0, 0],
|
|
14693
|
+
environmentIntensity: 1,
|
|
14694
|
+
environmentRotation: [0, 0, 0],
|
|
14695
|
+
...sceneProps
|
|
14696
|
+
};
|
|
14697
|
+
const target = resolveScene(scene || defaultScene);
|
|
14698
|
+
const oldbg = target.background;
|
|
14699
|
+
const oldenv = target.environment;
|
|
14700
|
+
const oldSceneProps = {
|
|
14701
|
+
// @ts-ignore
|
|
14702
|
+
backgroundBlurriness: target.backgroundBlurriness,
|
|
14703
|
+
// @ts-ignore
|
|
14704
|
+
backgroundIntensity: target.backgroundIntensity,
|
|
14705
|
+
// @ts-ignore
|
|
14706
|
+
backgroundRotation: target.backgroundRotation?.clone?.() ?? [0, 0, 0],
|
|
14707
|
+
// @ts-ignore
|
|
14708
|
+
environmentIntensity: target.environmentIntensity,
|
|
14709
|
+
// @ts-ignore
|
|
14710
|
+
environmentRotation: target.environmentRotation?.clone?.() ?? [0, 0, 0]
|
|
14711
|
+
};
|
|
14712
|
+
if (background !== "only") target.environment = texture;
|
|
14713
|
+
if (background) target.background = texture;
|
|
14714
|
+
applyProps(target, sceneProps);
|
|
14715
|
+
return () => {
|
|
14716
|
+
if (background !== "only") target.environment = oldenv;
|
|
14717
|
+
if (background) target.background = oldbg;
|
|
14718
|
+
applyProps(target, oldSceneProps);
|
|
14719
|
+
};
|
|
14720
|
+
}
|
|
14721
|
+
function EnvironmentMap({ scene, background = false, map, ...config }) {
|
|
14722
|
+
const defaultScene = useThree((state) => state.scene);
|
|
14723
|
+
React.useLayoutEffect(() => {
|
|
14724
|
+
if (map) return setEnvProps(background, scene, defaultScene, map, config);
|
|
14725
|
+
});
|
|
14726
|
+
return null;
|
|
14727
|
+
}
|
|
14728
|
+
function EnvironmentCube({
|
|
14729
|
+
background = false,
|
|
14730
|
+
scene,
|
|
14731
|
+
blur,
|
|
14732
|
+
backgroundBlurriness,
|
|
14733
|
+
backgroundIntensity,
|
|
14734
|
+
backgroundRotation,
|
|
14735
|
+
environmentIntensity,
|
|
14736
|
+
environmentRotation,
|
|
14737
|
+
...rest
|
|
14738
|
+
}) {
|
|
14739
|
+
const texture = useEnvironment(rest);
|
|
14740
|
+
const defaultScene = useThree((state) => state.scene);
|
|
14741
|
+
React.useLayoutEffect(() => {
|
|
14742
|
+
return setEnvProps(background, scene, defaultScene, texture, {
|
|
14743
|
+
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
14744
|
+
backgroundIntensity,
|
|
14745
|
+
backgroundRotation,
|
|
14746
|
+
environmentIntensity,
|
|
14747
|
+
environmentRotation
|
|
14748
|
+
});
|
|
14749
|
+
});
|
|
14750
|
+
React.useEffect(() => {
|
|
14751
|
+
return () => {
|
|
14752
|
+
texture.dispose();
|
|
14753
|
+
};
|
|
14754
|
+
}, [texture]);
|
|
14755
|
+
return null;
|
|
14756
|
+
}
|
|
14757
|
+
function EnvironmentPortal({
|
|
14758
|
+
children,
|
|
14759
|
+
near = 0.1,
|
|
14760
|
+
far = 1e3,
|
|
14761
|
+
resolution = 256,
|
|
14762
|
+
frames = 1,
|
|
14763
|
+
map,
|
|
14764
|
+
background = false,
|
|
14765
|
+
blur,
|
|
14766
|
+
backgroundBlurriness,
|
|
14767
|
+
backgroundIntensity,
|
|
14768
|
+
backgroundRotation,
|
|
14769
|
+
environmentIntensity,
|
|
14770
|
+
environmentRotation,
|
|
14771
|
+
scene,
|
|
14772
|
+
files,
|
|
14773
|
+
path,
|
|
14774
|
+
preset = void 0,
|
|
14775
|
+
extensions
|
|
14776
|
+
}) {
|
|
14777
|
+
const renderer = useThree((state) => state.renderer);
|
|
14778
|
+
const isLegacy = useThree((state) => state.isLegacy);
|
|
14779
|
+
const defaultScene = useThree((state) => state.scene);
|
|
14780
|
+
const camera = React.useRef(null);
|
|
14781
|
+
const [virtualScene] = React.useState(() => new Scene());
|
|
14782
|
+
const fbo = React.useMemo(() => {
|
|
14783
|
+
const fbo2 = isLegacy ? new WebGLCubeRenderTarget(resolution) : new CubeRenderTarget(resolution);
|
|
14784
|
+
fbo2.texture.type = HalfFloatType;
|
|
14785
|
+
return fbo2;
|
|
14786
|
+
}, [resolution, isLegacy]);
|
|
14787
|
+
React.useEffect(() => {
|
|
14788
|
+
return () => {
|
|
14789
|
+
fbo.dispose();
|
|
14790
|
+
};
|
|
14791
|
+
}, [fbo]);
|
|
14792
|
+
React.useLayoutEffect(() => {
|
|
14793
|
+
if (frames === 1) {
|
|
14794
|
+
const autoClear = renderer.autoClear;
|
|
14795
|
+
renderer.autoClear = true;
|
|
14796
|
+
camera.current.update(renderer, virtualScene);
|
|
14797
|
+
renderer.autoClear = autoClear;
|
|
14798
|
+
}
|
|
14799
|
+
return setEnvProps(background, scene, defaultScene, fbo.texture, {
|
|
14800
|
+
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
14801
|
+
backgroundIntensity,
|
|
14802
|
+
backgroundRotation,
|
|
14803
|
+
environmentIntensity,
|
|
14804
|
+
environmentRotation
|
|
14805
|
+
});
|
|
14806
|
+
}, [
|
|
14807
|
+
children,
|
|
14808
|
+
virtualScene,
|
|
14809
|
+
fbo.texture,
|
|
14810
|
+
scene,
|
|
14811
|
+
defaultScene,
|
|
14812
|
+
background,
|
|
14813
|
+
frames,
|
|
14814
|
+
renderer,
|
|
14815
|
+
blur,
|
|
14816
|
+
backgroundBlurriness,
|
|
14817
|
+
backgroundIntensity,
|
|
14818
|
+
backgroundRotation,
|
|
14819
|
+
environmentIntensity,
|
|
14820
|
+
environmentRotation
|
|
14821
|
+
]);
|
|
14822
|
+
let count = 1;
|
|
14823
|
+
useFrame(() => {
|
|
14824
|
+
if (frames === Infinity || count < frames) {
|
|
14825
|
+
const autoClear = renderer.autoClear;
|
|
14826
|
+
renderer.autoClear = true;
|
|
14827
|
+
camera.current.update(renderer, virtualScene);
|
|
14828
|
+
renderer.autoClear = autoClear;
|
|
14829
|
+
count++;
|
|
14830
|
+
}
|
|
14831
|
+
});
|
|
14832
|
+
return /* @__PURE__ */ jsx(Fragment, { children: createPortal(
|
|
14833
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
14834
|
+
children,
|
|
14835
|
+
/* @__PURE__ */ jsx("cubeCamera", { ref: camera, args: [near, far, fbo] }),
|
|
14836
|
+
files || preset ? /* @__PURE__ */ jsx(EnvironmentCube, { background: true, files, preset, path, extensions }) : map ? /* @__PURE__ */ jsx(EnvironmentMap, { background: true, map, extensions }) : null
|
|
14837
|
+
] }),
|
|
14838
|
+
virtualScene
|
|
14839
|
+
) });
|
|
14840
|
+
}
|
|
14841
|
+
function EnvironmentGround(props) {
|
|
14842
|
+
const textureDefault = useEnvironment(props);
|
|
14843
|
+
const texture = props.map || textureDefault;
|
|
14844
|
+
React.useMemo(() => extend({ GroundProjectedEnvImpl: GroundedSkybox }), []);
|
|
14845
|
+
React.useEffect(() => {
|
|
14846
|
+
return () => {
|
|
14847
|
+
textureDefault.dispose();
|
|
14848
|
+
};
|
|
14849
|
+
}, [textureDefault]);
|
|
14850
|
+
const height = props.ground?.height ?? 15;
|
|
14851
|
+
const radius = props.ground?.radius ?? 60;
|
|
14852
|
+
const scale = props.ground?.scale ?? 1e3;
|
|
14853
|
+
const args = React.useMemo(
|
|
14854
|
+
() => [texture, height, radius],
|
|
14855
|
+
[texture, height, radius]
|
|
14856
|
+
);
|
|
14857
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
14858
|
+
/* @__PURE__ */ jsx(EnvironmentMap, { ...props, map: texture }),
|
|
14859
|
+
/* @__PURE__ */ jsx("groundProjectedEnvImpl", { args, scale })
|
|
14860
|
+
] });
|
|
14861
|
+
}
|
|
14862
|
+
function EnvironmentColor({ color, scene }) {
|
|
14863
|
+
const defaultScene = useThree((state) => state.scene);
|
|
14864
|
+
React.useLayoutEffect(() => {
|
|
14865
|
+
if (color === void 0) return;
|
|
14866
|
+
const target = resolveScene(scene || defaultScene);
|
|
14867
|
+
const oldBg = target.background;
|
|
14868
|
+
target.background = new Color(color);
|
|
14869
|
+
return () => {
|
|
14870
|
+
target.background = oldBg;
|
|
14871
|
+
};
|
|
14872
|
+
});
|
|
14873
|
+
return null;
|
|
14874
|
+
}
|
|
14875
|
+
function EnvironmentDualSource(props) {
|
|
14876
|
+
const { backgroundFiles, ...envProps } = props;
|
|
14877
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
14878
|
+
/* @__PURE__ */ jsx(EnvironmentCube, { ...envProps, background: false }),
|
|
14879
|
+
/* @__PURE__ */ jsx(EnvironmentCube, { ...props, files: backgroundFiles, background: "only" })
|
|
14880
|
+
] });
|
|
14881
|
+
}
|
|
14882
|
+
function Environment(props) {
|
|
14883
|
+
if (props.color && !props.files && !props.preset && !props.map) {
|
|
14884
|
+
return /* @__PURE__ */ jsx(EnvironmentColor, { ...props });
|
|
14885
|
+
}
|
|
14886
|
+
if (props.backgroundFiles && props.backgroundFiles !== props.files) {
|
|
14887
|
+
return /* @__PURE__ */ jsx(EnvironmentDualSource, { ...props });
|
|
14888
|
+
}
|
|
14889
|
+
return props.ground ? /* @__PURE__ */ jsx(EnvironmentGround, { ...props }) : props.map ? /* @__PURE__ */ jsx(EnvironmentMap, { ...props }) : props.children ? /* @__PURE__ */ jsx(EnvironmentPortal, { ...props }) : /* @__PURE__ */ jsx(EnvironmentCube, { ...props });
|
|
14754
14890
|
}
|
|
14755
14891
|
|
|
14756
14892
|
function parseBackground(background) {
|
|
@@ -14796,14 +14932,133 @@ function parseRendererConfig(rendererProp) {
|
|
|
14796
14932
|
return { primaryCanvas: void 0, scheduler: void 0, renderer: rendererProp };
|
|
14797
14933
|
}
|
|
14798
14934
|
|
|
14935
|
+
const RESOURCE_KINDS = ["nodes", "uniforms", "buffers", "gpuStorage"];
|
|
14936
|
+
const ROOT_SCOPE = "";
|
|
14937
|
+
const registries = /* @__PURE__ */ new WeakMap();
|
|
14938
|
+
function getKindRegistry(store, kind) {
|
|
14939
|
+
let registry = registries.get(store);
|
|
14940
|
+
if (!registry) {
|
|
14941
|
+
registry = {
|
|
14942
|
+
nodes: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() },
|
|
14943
|
+
uniforms: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() },
|
|
14944
|
+
buffers: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() },
|
|
14945
|
+
gpuStorage: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() }
|
|
14946
|
+
};
|
|
14947
|
+
registries.set(store, registry);
|
|
14948
|
+
}
|
|
14949
|
+
return registry[kind];
|
|
14950
|
+
}
|
|
14951
|
+
function resolvePrimary$1(store) {
|
|
14952
|
+
return store.getState().primaryStore ?? store;
|
|
14953
|
+
}
|
|
14954
|
+
function isScopeValid(store, kind, scopeKey) {
|
|
14955
|
+
return getKindRegistry(store, kind).valid.has(scopeKey);
|
|
14956
|
+
}
|
|
14957
|
+
function peekStaged(store, kind, scopeKey) {
|
|
14958
|
+
return getKindRegistry(store, kind).staged.get(scopeKey);
|
|
14959
|
+
}
|
|
14960
|
+
function stageEntries(store, kind, scopeKey, entries) {
|
|
14961
|
+
const { staged } = getKindRegistry(store, kind);
|
|
14962
|
+
const current = staged.get(scopeKey);
|
|
14963
|
+
if (current) Object.assign(current, entries);
|
|
14964
|
+
else staged.set(scopeKey, { ...entries });
|
|
14965
|
+
}
|
|
14966
|
+
function readCommittedScope(map, scopeKey, isLeaf) {
|
|
14967
|
+
if (scopeKey === ROOT_SCOPE) {
|
|
14968
|
+
const leaves = {};
|
|
14969
|
+
for (const [key, value] of Object.entries(map)) if (isLeaf(value)) leaves[key] = value;
|
|
14970
|
+
return leaves;
|
|
14971
|
+
}
|
|
14972
|
+
const scopeData = map[scopeKey];
|
|
14973
|
+
if (scopeData && typeof scopeData === "object" && !isLeaf(scopeData)) return scopeData;
|
|
14974
|
+
return {};
|
|
14975
|
+
}
|
|
14976
|
+
function withStagedOverlay(store, kind, committed) {
|
|
14977
|
+
const { staged } = getKindRegistry(store, kind);
|
|
14978
|
+
if (staged.size === 0) return committed;
|
|
14979
|
+
const view = { ...committed };
|
|
14980
|
+
for (const [scopeKey, entries] of staged) {
|
|
14981
|
+
if (scopeKey === ROOT_SCOPE) Object.assign(view, entries);
|
|
14982
|
+
else view[scopeKey] = { ...view[scopeKey], ...entries };
|
|
14983
|
+
}
|
|
14984
|
+
return view;
|
|
14985
|
+
}
|
|
14986
|
+
function flushStagedScope(store, kind, scopeKey, isLeaf) {
|
|
14987
|
+
const registry = getKindRegistry(store, kind);
|
|
14988
|
+
const staged = registry.staged.get(scopeKey);
|
|
14989
|
+
if (!staged) return;
|
|
14990
|
+
registry.staged.delete(scopeKey);
|
|
14991
|
+
const replace = !registry.valid.has(scopeKey);
|
|
14992
|
+
store.setState((state) => {
|
|
14993
|
+
const map = state[kind];
|
|
14994
|
+
if (scopeKey === ROOT_SCOPE) {
|
|
14995
|
+
if (!replace) return { [kind]: { ...map, ...staged } };
|
|
14996
|
+
const next = {};
|
|
14997
|
+
for (const [key, value] of Object.entries(map)) if (!isLeaf(value)) next[key] = value;
|
|
14998
|
+
return { [kind]: { ...next, ...staged } };
|
|
14999
|
+
}
|
|
15000
|
+
const current = replace ? {} : map[scopeKey] ?? {};
|
|
15001
|
+
return { [kind]: { ...map, [scopeKey]: { ...current, ...staged } } };
|
|
15002
|
+
});
|
|
15003
|
+
registry.valid.add(scopeKey);
|
|
15004
|
+
}
|
|
15005
|
+
function invalidateResource(store, kind, scopeKey) {
|
|
15006
|
+
const registry = getKindRegistry(store, kind);
|
|
15007
|
+
if (scopeKey === void 0) {
|
|
15008
|
+
registry.valid.clear();
|
|
15009
|
+
registry.staged.clear();
|
|
15010
|
+
} else {
|
|
15011
|
+
registry.valid.delete(scopeKey);
|
|
15012
|
+
registry.staged.delete(scopeKey);
|
|
15013
|
+
}
|
|
15014
|
+
}
|
|
15015
|
+
function rebuildResource(store, kind, userScope) {
|
|
15016
|
+
const primary = resolvePrimary$1(store);
|
|
15017
|
+
invalidateResource(primary, kind, userScope === "root" ? ROOT_SCOPE : userScope);
|
|
15018
|
+
primary.setState((state) => ({ _hmrVersion: state._hmrVersion + 1 }));
|
|
15019
|
+
}
|
|
15020
|
+
function invalidateAllResources(store) {
|
|
15021
|
+
for (const kind of RESOURCE_KINDS) invalidateResource(store, kind);
|
|
15022
|
+
}
|
|
15023
|
+
function removeResourceEntries(store, kind, names, scope, isLeaf) {
|
|
15024
|
+
const staged = peekStaged(store, kind, scope ?? ROOT_SCOPE);
|
|
15025
|
+
if (staged) for (const name of names) delete staged[name];
|
|
15026
|
+
store.setState((state) => {
|
|
15027
|
+
const map = state[kind];
|
|
15028
|
+
if (scope) {
|
|
15029
|
+
const currentScope = { ...map[scope] };
|
|
15030
|
+
for (const name of names) delete currentScope[name];
|
|
15031
|
+
return { [kind]: { ...map, [scope]: currentScope } };
|
|
15032
|
+
}
|
|
15033
|
+
const next = { ...map };
|
|
15034
|
+
for (const name of names) if (isLeaf(next[name])) delete next[name];
|
|
15035
|
+
return { [kind]: next };
|
|
15036
|
+
});
|
|
15037
|
+
}
|
|
15038
|
+
function clearResourceEntries(store, kind, scope, isLeaf) {
|
|
15039
|
+
const registry = getKindRegistry(store, kind);
|
|
15040
|
+
if (scope && scope !== "root") registry.staged.delete(scope);
|
|
15041
|
+
else if (scope === "root") registry.staged.delete(ROOT_SCOPE);
|
|
15042
|
+
else registry.staged.clear();
|
|
15043
|
+
store.setState((state) => {
|
|
15044
|
+
const map = state[kind];
|
|
15045
|
+
if (scope && scope !== "root") {
|
|
15046
|
+
const { [scope]: _, ...rest } = map;
|
|
15047
|
+
return { [kind]: rest };
|
|
15048
|
+
}
|
|
15049
|
+
if (scope === "root") {
|
|
15050
|
+
const next = {};
|
|
15051
|
+
for (const [key, value] of Object.entries(map)) if (!isLeaf(value)) next[key] = value;
|
|
15052
|
+
return { [kind]: next };
|
|
15053
|
+
}
|
|
15054
|
+
return { [kind]: {} };
|
|
15055
|
+
});
|
|
15056
|
+
}
|
|
15057
|
+
|
|
14799
15058
|
function clearHmrCaches(store) {
|
|
14800
|
-
store.
|
|
14801
|
-
|
|
14802
|
-
|
|
14803
|
-
buffers: {},
|
|
14804
|
-
gpuStorage: {},
|
|
14805
|
-
_hmrVersion: state._hmrVersion + 1
|
|
14806
|
-
}));
|
|
15059
|
+
const primary = store.getState().primaryStore ?? store;
|
|
15060
|
+
invalidateAllResources(primary);
|
|
15061
|
+
primary.setState((state) => ({ _hmrVersion: state._hmrVersion + 1 }));
|
|
14807
15062
|
}
|
|
14808
15063
|
|
|
14809
15064
|
function CanvasImpl({
|
|
@@ -14940,7 +15195,7 @@ function CanvasImpl({
|
|
|
14940
15195
|
onDropMissed: (...args) => handleDropMissed.current?.(...args),
|
|
14941
15196
|
onCreated: (state) => {
|
|
14942
15197
|
state.events.connect?.(
|
|
14943
|
-
eventSource ? isRef(eventSource) ? eventSource.current : eventSource : divRef.current
|
|
15198
|
+
eventSource ? isRef$1(eventSource) ? eventSource.current : eventSource : divRef.current
|
|
14944
15199
|
);
|
|
14945
15200
|
if (eventPrefix) {
|
|
14946
15201
|
state.setEvents({
|
|
@@ -15116,30 +15371,31 @@ let ScopedStore = _ScopedStore;
|
|
|
15116
15371
|
function createScopedStore(data) {
|
|
15117
15372
|
return new ScopedStore(data);
|
|
15118
15373
|
}
|
|
15119
|
-
function createLazyCreatorState(state) {
|
|
15374
|
+
function createLazyCreatorState(state, store) {
|
|
15120
15375
|
let _uniforms = null;
|
|
15121
15376
|
let _nodes = null;
|
|
15122
15377
|
let _buffers = null;
|
|
15123
15378
|
let _gpuStorage = null;
|
|
15379
|
+
const view = (kind) => store ? withStagedOverlay(store, kind, state[kind]) : state[kind];
|
|
15124
15380
|
return Object.create(state, {
|
|
15125
15381
|
uniforms: {
|
|
15126
15382
|
get() {
|
|
15127
|
-
return _uniforms ?? (_uniforms = createScopedStore(
|
|
15383
|
+
return _uniforms ?? (_uniforms = createScopedStore(view("uniforms")));
|
|
15128
15384
|
}
|
|
15129
15385
|
},
|
|
15130
15386
|
nodes: {
|
|
15131
15387
|
get() {
|
|
15132
|
-
return _nodes ?? (_nodes = createScopedStore(
|
|
15388
|
+
return _nodes ?? (_nodes = createScopedStore(view("nodes")));
|
|
15133
15389
|
}
|
|
15134
15390
|
},
|
|
15135
15391
|
buffers: {
|
|
15136
15392
|
get() {
|
|
15137
|
-
return _buffers ?? (_buffers = createScopedStore(
|
|
15393
|
+
return _buffers ?? (_buffers = createScopedStore(view("buffers")));
|
|
15138
15394
|
}
|
|
15139
15395
|
},
|
|
15140
15396
|
gpuStorage: {
|
|
15141
15397
|
get() {
|
|
15142
|
-
return _gpuStorage ?? (_gpuStorage = createScopedStore(
|
|
15398
|
+
return _gpuStorage ?? (_gpuStorage = createScopedStore(view("gpuStorage")));
|
|
15143
15399
|
}
|
|
15144
15400
|
}
|
|
15145
15401
|
});
|
|
@@ -15262,65 +15518,56 @@ function useCompareMemoize(value, deep) {
|
|
|
15262
15518
|
return ref.current;
|
|
15263
15519
|
}
|
|
15264
15520
|
|
|
15521
|
+
function useScopedResource(options) {
|
|
15522
|
+
const { store, kind, scope, isLeaf, create, prepare, reconcile, input } = options;
|
|
15523
|
+
const scopeKey = scope ?? ROOT_SCOPE;
|
|
15524
|
+
const version = store((s) => s._hmrVersion);
|
|
15525
|
+
const entries = useMemo(() => {
|
|
15526
|
+
const staged = peekStaged(store, kind, scopeKey);
|
|
15527
|
+
const reusable = isScopeValid(store, kind, scopeKey);
|
|
15528
|
+
const map = store.getState()[kind];
|
|
15529
|
+
const committed = reusable ? readCommittedScope(map, scopeKey, isLeaf) : void 0;
|
|
15530
|
+
const result = {};
|
|
15531
|
+
let fresh = null;
|
|
15532
|
+
for (const [name, candidate] of Object.entries(create())) {
|
|
15533
|
+
const existing = staged?.[name] ?? committed?.[name];
|
|
15534
|
+
if (existing !== void 0) {
|
|
15535
|
+
result[name] = existing;
|
|
15536
|
+
reconcile?.(existing, candidate);
|
|
15537
|
+
} else {
|
|
15538
|
+
const value = prepare ? prepare(name, candidate) : candidate;
|
|
15539
|
+
result[name] = value;
|
|
15540
|
+
(fresh ?? (fresh = {}))[name] = value;
|
|
15541
|
+
}
|
|
15542
|
+
}
|
|
15543
|
+
if (fresh) stageEntries(store, kind, scopeKey, fresh);
|
|
15544
|
+
return result;
|
|
15545
|
+
}, [store, kind, scopeKey, version, input]);
|
|
15546
|
+
useIsomorphicLayoutEffect(() => {
|
|
15547
|
+
flushStagedScope(store, kind, scopeKey, isLeaf);
|
|
15548
|
+
});
|
|
15549
|
+
return entries;
|
|
15550
|
+
}
|
|
15551
|
+
|
|
15265
15552
|
const isUniformNode$1 = (value) => value !== null && typeof value === "object" && "value" in value && "uuid" in value;
|
|
15266
15553
|
function useUniforms(creatorOrScope, scope) {
|
|
15267
15554
|
const store = usePrimaryStore();
|
|
15268
15555
|
const removeUniforms2 = useCallback(
|
|
15269
|
-
(names, targetScope) =>
|
|
15270
|
-
const nameArray = Array.isArray(names) ? names : [names];
|
|
15271
|
-
store.setState((state) => {
|
|
15272
|
-
if (targetScope) {
|
|
15273
|
-
const currentScope = { ...state.uniforms[targetScope] };
|
|
15274
|
-
for (const name of nameArray) delete currentScope[name];
|
|
15275
|
-
return { uniforms: { ...state.uniforms, [targetScope]: currentScope } };
|
|
15276
|
-
}
|
|
15277
|
-
const uniforms2 = { ...state.uniforms };
|
|
15278
|
-
for (const name of nameArray) if (isUniformNode$1(uniforms2[name])) delete uniforms2[name];
|
|
15279
|
-
return { uniforms: uniforms2 };
|
|
15280
|
-
});
|
|
15281
|
-
},
|
|
15556
|
+
(names, targetScope) => removeResourceEntries(store, "uniforms", Array.isArray(names) ? names : [names], targetScope, isUniformNode$1),
|
|
15282
15557
|
[store]
|
|
15283
15558
|
);
|
|
15284
15559
|
const clearUniforms = useCallback(
|
|
15285
|
-
(targetScope) =>
|
|
15286
|
-
store.setState((state) => {
|
|
15287
|
-
if (targetScope && targetScope !== "root") {
|
|
15288
|
-
const { [targetScope]: _, ...rest } = state.uniforms;
|
|
15289
|
-
return { uniforms: rest };
|
|
15290
|
-
}
|
|
15291
|
-
if (targetScope === "root") {
|
|
15292
|
-
const uniforms2 = {};
|
|
15293
|
-
for (const [key, value] of Object.entries(state.uniforms)) {
|
|
15294
|
-
if (!isUniformNode$1(value)) uniforms2[key] = value;
|
|
15295
|
-
}
|
|
15296
|
-
return { uniforms: uniforms2 };
|
|
15297
|
-
}
|
|
15298
|
-
return { uniforms: {} };
|
|
15299
|
-
});
|
|
15300
|
-
},
|
|
15560
|
+
(targetScope) => clearResourceEntries(store, "uniforms", targetScope, isUniformNode$1),
|
|
15301
15561
|
[store]
|
|
15302
15562
|
);
|
|
15303
15563
|
const rebuildUniforms = useCallback(
|
|
15304
|
-
(targetScope) =>
|
|
15305
|
-
store.setState((state) => {
|
|
15306
|
-
let newUniforms = {};
|
|
15307
|
-
if (targetScope && targetScope !== "root") {
|
|
15308
|
-
const { [targetScope]: _, ...rest } = state.uniforms;
|
|
15309
|
-
newUniforms = rest;
|
|
15310
|
-
} else if (targetScope === "root") {
|
|
15311
|
-
for (const [key, value] of Object.entries(state.uniforms)) {
|
|
15312
|
-
if (!isUniformNode$1(value)) newUniforms[key] = value;
|
|
15313
|
-
}
|
|
15314
|
-
}
|
|
15315
|
-
return { uniforms: newUniforms, _hmrVersion: state._hmrVersion + 1 };
|
|
15316
|
-
});
|
|
15317
|
-
},
|
|
15564
|
+
(targetScope) => rebuildResource(store, "uniforms", targetScope),
|
|
15318
15565
|
[store]
|
|
15319
15566
|
);
|
|
15320
15567
|
const inputForMemoization = useMemo(() => {
|
|
15321
15568
|
let raw = creatorOrScope;
|
|
15322
15569
|
if (is.fun(creatorOrScope)) {
|
|
15323
|
-
const wrappedState = createLazyCreatorState(store.getState());
|
|
15570
|
+
const wrappedState = createLazyCreatorState(store.getState(), store);
|
|
15324
15571
|
raw = creatorOrScope(wrappedState);
|
|
15325
15572
|
}
|
|
15326
15573
|
if (raw && typeof raw === "object" && !Array.isArray(raw)) {
|
|
@@ -15335,80 +15582,43 @@ function useUniforms(creatorOrScope, scope) {
|
|
|
15335
15582
|
const memoizedInput = useCompareMemoize(inputForMemoization);
|
|
15336
15583
|
const isReader = memoizedInput === void 0 || typeof memoizedInput === "string";
|
|
15337
15584
|
const storeUniforms = usePrimaryThree((s) => s.uniforms);
|
|
15338
|
-
const
|
|
15339
|
-
|
|
15340
|
-
|
|
15341
|
-
|
|
15342
|
-
|
|
15343
|
-
|
|
15344
|
-
|
|
15345
|
-
|
|
15346
|
-
|
|
15347
|
-
|
|
15348
|
-
|
|
15349
|
-
|
|
15350
|
-
|
|
15351
|
-
|
|
15352
|
-
|
|
15353
|
-
|
|
15354
|
-
|
|
15355
|
-
|
|
15356
|
-
|
|
15357
|
-
|
|
15358
|
-
|
|
15359
|
-
|
|
15360
|
-
|
|
15361
|
-
|
|
15362
|
-
}
|
|
15363
|
-
for (const [name, node] of Object.entries(created)) {
|
|
15364
|
-
if (targetRecord[name]) {
|
|
15365
|
-
result[name] = targetRecord[name];
|
|
15366
|
-
const existingVal = result[name].value;
|
|
15367
|
-
const newVal = vectorize(node);
|
|
15368
|
-
let equals = newVal === existingVal;
|
|
15369
|
-
if (!equals && hasEqualsMethod(existingVal) && hasEqualsMethod(newVal)) {
|
|
15370
|
-
if (isThreeVector(existingVal) && isThreeVector(newVal)) {
|
|
15371
|
-
equals = vectorEquals(existingVal, newVal);
|
|
15372
|
-
} else if (isSameThreeType(existingVal, newVal)) {
|
|
15373
|
-
equals = existingVal.equals(newVal);
|
|
15374
|
-
}
|
|
15375
|
-
}
|
|
15376
|
-
if (!equals) result[name].value = newVal;
|
|
15377
|
-
} else {
|
|
15378
|
-
result[name] = createUniform(name, node, scope);
|
|
15379
|
-
hasNewUniforms = true;
|
|
15380
|
-
}
|
|
15381
|
-
}
|
|
15382
|
-
if (hasNewUniforms) {
|
|
15383
|
-
if (scope) {
|
|
15384
|
-
set((s) => ({
|
|
15385
|
-
uniforms: {
|
|
15386
|
-
...s.uniforms,
|
|
15387
|
-
[scope]: { ...s.uniforms[scope], ...result }
|
|
15388
|
-
}
|
|
15389
|
-
}));
|
|
15390
|
-
} else {
|
|
15391
|
-
set((s) => ({ uniforms: { ...s.uniforms, ...result } }));
|
|
15392
|
-
}
|
|
15585
|
+
const created = useScopedResource({
|
|
15586
|
+
store,
|
|
15587
|
+
kind: "uniforms",
|
|
15588
|
+
scope: isReader ? void 0 : scope,
|
|
15589
|
+
isLeaf: isUniformNode$1,
|
|
15590
|
+
input: memoizedInput,
|
|
15591
|
+
create: () => {
|
|
15592
|
+
if (isReader) return {};
|
|
15593
|
+
if (typeof memoizedInput !== "object" || memoizedInput === null) throw new Error("Invalid uniform input");
|
|
15594
|
+
return memoizedInput;
|
|
15595
|
+
},
|
|
15596
|
+
prepare: (name, candidate) => createUniform(name, candidate, scope),
|
|
15597
|
+
reconcile: (existing, candidate) => {
|
|
15598
|
+
const existingVal = existing.value;
|
|
15599
|
+
const newVal = vectorize(candidate);
|
|
15600
|
+
let equals = newVal === existingVal;
|
|
15601
|
+
if (!equals && hasEqualsMethod(existingVal) && hasEqualsMethod(newVal)) {
|
|
15602
|
+
if (isThreeVector(existingVal) && isThreeVector(newVal)) {
|
|
15603
|
+
equals = vectorEquals(existingVal, newVal);
|
|
15604
|
+
} else if (isSameThreeType(existingVal, newVal)) {
|
|
15605
|
+
equals = existingVal.equals(newVal);
|
|
15606
|
+
}
|
|
15607
|
+
}
|
|
15608
|
+
if (!equals) existing.value = newVal;
|
|
15393
15609
|
}
|
|
15394
|
-
|
|
15395
|
-
|
|
15610
|
+
});
|
|
15611
|
+
let uniforms = created;
|
|
15612
|
+
if (memoizedInput === void 0) {
|
|
15613
|
+
uniforms = storeUniforms;
|
|
15614
|
+
} else if (typeof memoizedInput === "string") {
|
|
15615
|
+
const scopeData = storeUniforms[memoizedInput];
|
|
15616
|
+
uniforms = scopeData && !isUniformNode$1(scopeData) ? scopeData : {};
|
|
15617
|
+
}
|
|
15396
15618
|
return { ...uniforms, removeUniforms: removeUniforms2, clearUniforms, rebuildUniforms };
|
|
15397
15619
|
}
|
|
15398
15620
|
function rebuildAllUniforms(store, scope) {
|
|
15399
|
-
store
|
|
15400
|
-
store.setState((state) => {
|
|
15401
|
-
let newUniforms = {};
|
|
15402
|
-
if (scope && scope !== "root") {
|
|
15403
|
-
const { [scope]: _, ...rest } = state.uniforms;
|
|
15404
|
-
newUniforms = rest;
|
|
15405
|
-
} else if (scope === "root") {
|
|
15406
|
-
for (const [key, value] of Object.entries(state.uniforms)) {
|
|
15407
|
-
if (!isUniformNode$1(value)) newUniforms[key] = value;
|
|
15408
|
-
}
|
|
15409
|
-
}
|
|
15410
|
-
return { uniforms: newUniforms, _hmrVersion: state._hmrVersion + 1 };
|
|
15411
|
-
});
|
|
15621
|
+
rebuildResource(store, "uniforms", scope);
|
|
15412
15622
|
}
|
|
15413
15623
|
function removeUniforms(set, names, scope) {
|
|
15414
15624
|
set((state) => {
|
|
@@ -15477,188 +15687,86 @@ const isUniformNode = (value) => value !== null && typeof value === "object" &&
|
|
|
15477
15687
|
const isTSLNode$1 = (value) => value !== null && typeof value === "object" && "uuid" in value && "nodeType" in value;
|
|
15478
15688
|
function useUniform(name, value) {
|
|
15479
15689
|
const store = useStore();
|
|
15480
|
-
const
|
|
15481
|
-
|
|
15482
|
-
|
|
15483
|
-
|
|
15484
|
-
|
|
15485
|
-
|
|
15690
|
+
const registered = useScopedResource({
|
|
15691
|
+
store,
|
|
15692
|
+
kind: "uniforms",
|
|
15693
|
+
scope: void 0,
|
|
15694
|
+
isLeaf: isUniformNode,
|
|
15695
|
+
input: name,
|
|
15696
|
+
create: () => value === void 0 ? {} : { [name]: value },
|
|
15697
|
+
prepare: createNamedUniform,
|
|
15698
|
+
reconcile: (existing2) => {
|
|
15486
15699
|
if (value !== void 0 && !isTSLNode$1(value) && !isUniformNode(value)) {
|
|
15487
|
-
|
|
15700
|
+
existing2.value = typeof value === "string" ? new Color(value) : value;
|
|
15488
15701
|
}
|
|
15489
|
-
return existing;
|
|
15490
|
-
}
|
|
15491
|
-
if (value === void 0) {
|
|
15492
|
-
throw new Error(
|
|
15493
|
-
`[useUniform] Uniform "${name}" not found. Create it first with: useUniform('${name}', initialValue)`
|
|
15494
|
-
);
|
|
15495
|
-
}
|
|
15496
|
-
if (isUniformNode(value)) {
|
|
15497
|
-
const node2 = value;
|
|
15498
|
-
if (typeof node2.setName === "function") {
|
|
15499
|
-
node2.setName(name);
|
|
15500
|
-
}
|
|
15501
|
-
set((s) => ({
|
|
15502
|
-
uniforms: { ...s.uniforms, [name]: node2 }
|
|
15503
|
-
}));
|
|
15504
|
-
return node2;
|
|
15505
|
-
}
|
|
15506
|
-
let node;
|
|
15507
|
-
if (isTSLNode$1(value)) {
|
|
15508
|
-
node = uniformOf(value);
|
|
15509
|
-
} else if (typeof value === "string") {
|
|
15510
|
-
node = uniform(new Color(value));
|
|
15511
|
-
} else {
|
|
15512
|
-
node = uniformOf(value);
|
|
15513
|
-
}
|
|
15514
|
-
if (typeof node.setName === "function") {
|
|
15515
|
-
node.setName(name);
|
|
15516
15702
|
}
|
|
15517
|
-
|
|
15518
|
-
|
|
15519
|
-
|
|
15520
|
-
|
|
15521
|
-
|
|
15522
|
-
})
|
|
15523
|
-
|
|
15524
|
-
|
|
15703
|
+
});
|
|
15704
|
+
if (registered[name]) return registered[name];
|
|
15705
|
+
const existing = peekStaged(store, "uniforms", ROOT_SCOPE)?.[name] ?? store.getState().uniforms[name];
|
|
15706
|
+
if (existing && isUniformNode(existing)) return existing;
|
|
15707
|
+
throw new Error(
|
|
15708
|
+
`[useUniform] Uniform "${name}" not found. Create it first with: useUniform('${name}', initialValue)`
|
|
15709
|
+
);
|
|
15710
|
+
}
|
|
15711
|
+
function createNamedUniform(name, value) {
|
|
15712
|
+
let node;
|
|
15713
|
+
if (isUniformNode(value)) {
|
|
15714
|
+
node = value;
|
|
15715
|
+
} else if (isTSLNode$1(value)) {
|
|
15716
|
+
node = uniformOf(value);
|
|
15717
|
+
} else if (typeof value === "string") {
|
|
15718
|
+
node = uniform(new Color(value));
|
|
15719
|
+
} else {
|
|
15720
|
+
node = uniformOf(value);
|
|
15721
|
+
}
|
|
15722
|
+
if (typeof node.setName === "function") {
|
|
15723
|
+
node.setName(name);
|
|
15724
|
+
}
|
|
15725
|
+
return node;
|
|
15525
15726
|
}
|
|
15526
15727
|
|
|
15527
15728
|
const isTSLNode = (value) => value !== null && typeof value === "object" && ("uuid" in value || "nodeType" in value);
|
|
15528
15729
|
function useNodes(creatorOrScope, scope) {
|
|
15529
15730
|
const store = usePrimaryStore();
|
|
15530
15731
|
const removeNodes2 = useCallback(
|
|
15531
|
-
(names, targetScope) =>
|
|
15532
|
-
const nameArray = Array.isArray(names) ? names : [names];
|
|
15533
|
-
store.setState((state) => {
|
|
15534
|
-
if (targetScope) {
|
|
15535
|
-
const currentScope = { ...state.nodes[targetScope] };
|
|
15536
|
-
for (const name of nameArray) delete currentScope[name];
|
|
15537
|
-
return { nodes: { ...state.nodes, [targetScope]: currentScope } };
|
|
15538
|
-
}
|
|
15539
|
-
const nodes2 = { ...state.nodes };
|
|
15540
|
-
for (const name of nameArray) if (isTSLNode(nodes2[name])) delete nodes2[name];
|
|
15541
|
-
return { nodes: nodes2 };
|
|
15542
|
-
});
|
|
15543
|
-
},
|
|
15732
|
+
(names, targetScope) => removeResourceEntries(store, "nodes", Array.isArray(names) ? names : [names], targetScope, isTSLNode),
|
|
15544
15733
|
[store]
|
|
15545
15734
|
);
|
|
15546
15735
|
const clearNodes = useCallback(
|
|
15547
|
-
(targetScope) =>
|
|
15548
|
-
store.setState((state) => {
|
|
15549
|
-
if (targetScope && targetScope !== "root") {
|
|
15550
|
-
const { [targetScope]: _, ...rest } = state.nodes;
|
|
15551
|
-
return { nodes: rest };
|
|
15552
|
-
}
|
|
15553
|
-
if (targetScope === "root") {
|
|
15554
|
-
const nodes2 = {};
|
|
15555
|
-
for (const [key, value] of Object.entries(state.nodes)) {
|
|
15556
|
-
if (!isTSLNode(value)) nodes2[key] = value;
|
|
15557
|
-
}
|
|
15558
|
-
return { nodes: nodes2 };
|
|
15559
|
-
}
|
|
15560
|
-
return { nodes: {} };
|
|
15561
|
-
});
|
|
15562
|
-
},
|
|
15736
|
+
(targetScope) => clearResourceEntries(store, "nodes", targetScope, isTSLNode),
|
|
15563
15737
|
[store]
|
|
15564
15738
|
);
|
|
15565
15739
|
const rebuildNodes = useCallback(
|
|
15566
|
-
(targetScope) =>
|
|
15567
|
-
store.setState((state) => {
|
|
15568
|
-
let newNodes = state.nodes;
|
|
15569
|
-
if (targetScope && targetScope !== "root") {
|
|
15570
|
-
const { [targetScope]: _, ...rest } = state.nodes;
|
|
15571
|
-
newNodes = rest;
|
|
15572
|
-
} else if (targetScope === "root") {
|
|
15573
|
-
newNodes = {};
|
|
15574
|
-
for (const [key, value] of Object.entries(state.nodes)) {
|
|
15575
|
-
if (!isTSLNode(value)) newNodes[key] = value;
|
|
15576
|
-
}
|
|
15577
|
-
} else {
|
|
15578
|
-
newNodes = {};
|
|
15579
|
-
}
|
|
15580
|
-
return { nodes: newNodes, _hmrVersion: state._hmrVersion + 1 };
|
|
15581
|
-
});
|
|
15582
|
-
},
|
|
15740
|
+
(targetScope) => rebuildResource(store, "nodes", targetScope),
|
|
15583
15741
|
[store]
|
|
15584
15742
|
);
|
|
15585
15743
|
const isReader = creatorOrScope === void 0 || typeof creatorOrScope === "string";
|
|
15586
15744
|
const storeNodes = usePrimaryThree((s) => s.nodes);
|
|
15587
|
-
const
|
|
15588
|
-
|
|
15589
|
-
|
|
15590
|
-
|
|
15591
|
-
|
|
15592
|
-
|
|
15593
|
-
return
|
|
15594
|
-
|
|
15595
|
-
|
|
15596
|
-
|
|
15597
|
-
|
|
15598
|
-
return
|
|
15599
|
-
}
|
|
15600
|
-
const state = store.getState();
|
|
15601
|
-
const set = store.setState;
|
|
15602
|
-
const creator = creatorOrScope;
|
|
15603
|
-
const wrappedState = createLazyCreatorState(state);
|
|
15604
|
-
const created = creator(wrappedState);
|
|
15605
|
-
const result = {};
|
|
15606
|
-
let hasNewNodes = false;
|
|
15607
|
-
if (scope) {
|
|
15608
|
-
const currentScope = state.nodes[scope] ?? {};
|
|
15609
|
-
for (const [name, node] of Object.entries(created)) {
|
|
15610
|
-
if (currentScope[name]) {
|
|
15611
|
-
result[name] = currentScope[name];
|
|
15612
|
-
} else {
|
|
15613
|
-
node.setName?.(`${scope}.${name}`);
|
|
15614
|
-
result[name] = node;
|
|
15615
|
-
hasNewNodes = true;
|
|
15616
|
-
}
|
|
15617
|
-
}
|
|
15618
|
-
if (hasNewNodes) {
|
|
15619
|
-
set((s) => ({
|
|
15620
|
-
nodes: {
|
|
15621
|
-
...s.nodes,
|
|
15622
|
-
[scope]: { ...s.nodes[scope], ...result }
|
|
15623
|
-
}
|
|
15624
|
-
}));
|
|
15625
|
-
}
|
|
15626
|
-
return result;
|
|
15627
|
-
}
|
|
15628
|
-
for (const [name, node] of Object.entries(created)) {
|
|
15629
|
-
const existing = state.nodes[name];
|
|
15630
|
-
if (existing && isTSLNode(existing)) {
|
|
15631
|
-
result[name] = existing;
|
|
15632
|
-
} else {
|
|
15633
|
-
node.setName?.(name);
|
|
15634
|
-
result[name] = node;
|
|
15635
|
-
hasNewNodes = true;
|
|
15636
|
-
}
|
|
15637
|
-
}
|
|
15638
|
-
if (hasNewNodes) {
|
|
15639
|
-
set((s) => ({ nodes: { ...s.nodes, ...result } }));
|
|
15745
|
+
const created = useScopedResource({
|
|
15746
|
+
store,
|
|
15747
|
+
kind: "nodes",
|
|
15748
|
+
scope: isReader ? void 0 : scope,
|
|
15749
|
+
isLeaf: isTSLNode,
|
|
15750
|
+
create: () => {
|
|
15751
|
+
if (isReader) return {};
|
|
15752
|
+
return creatorOrScope(createLazyCreatorState(store.getState(), store));
|
|
15753
|
+
},
|
|
15754
|
+
prepare: (name, node) => {
|
|
15755
|
+
node.setName?.(scope ? `${scope}.${name}` : name);
|
|
15756
|
+
return node;
|
|
15640
15757
|
}
|
|
15641
|
-
|
|
15642
|
-
|
|
15758
|
+
});
|
|
15759
|
+
let nodes = created;
|
|
15760
|
+
if (creatorOrScope === void 0) {
|
|
15761
|
+
nodes = storeNodes;
|
|
15762
|
+
} else if (typeof creatorOrScope === "string") {
|
|
15763
|
+
const scopeData = storeNodes[creatorOrScope];
|
|
15764
|
+
nodes = scopeData && !isTSLNode(scopeData) ? scopeData : {};
|
|
15765
|
+
}
|
|
15643
15766
|
return { ...nodes, removeNodes: removeNodes2, clearNodes, rebuildNodes };
|
|
15644
15767
|
}
|
|
15645
15768
|
function rebuildAllNodes(store, scope) {
|
|
15646
|
-
store
|
|
15647
|
-
store.setState((state) => {
|
|
15648
|
-
let newNodes = state.nodes;
|
|
15649
|
-
if (scope && scope !== "root") {
|
|
15650
|
-
const { [scope]: _, ...rest } = state.nodes;
|
|
15651
|
-
newNodes = rest;
|
|
15652
|
-
} else if (scope === "root") {
|
|
15653
|
-
newNodes = {};
|
|
15654
|
-
for (const [key, value] of Object.entries(state.nodes)) {
|
|
15655
|
-
if (!isTSLNode(value)) newNodes[key] = value;
|
|
15656
|
-
}
|
|
15657
|
-
} else {
|
|
15658
|
-
newNodes = {};
|
|
15659
|
-
}
|
|
15660
|
-
return { nodes: newNodes, _hmrVersion: state._hmrVersion + 1 };
|
|
15661
|
-
});
|
|
15769
|
+
rebuildResource(store, "nodes", scope);
|
|
15662
15770
|
}
|
|
15663
15771
|
function removeNodes(set, names, scope) {
|
|
15664
15772
|
set((state) => {
|
|
@@ -15694,7 +15802,7 @@ function useLocalNodes(creator) {
|
|
|
15694
15802
|
const textures = usePrimaryThree((s) => s.textures);
|
|
15695
15803
|
const hmrVersion = usePrimaryThree((s) => s._hmrVersion);
|
|
15696
15804
|
return useMemo(() => {
|
|
15697
|
-
const wrappedState = createLazyCreatorState(store.getState());
|
|
15805
|
+
const wrappedState = createLazyCreatorState(store.getState(), store);
|
|
15698
15806
|
return creator(wrappedState);
|
|
15699
15807
|
}, [store, creator, uniforms, nodes, textures, hmrVersion]);
|
|
15700
15808
|
}
|
|
@@ -15715,58 +15823,15 @@ const disposeBuffer = (buffer) => {
|
|
|
15715
15823
|
function useBuffers(creatorOrScope, scope) {
|
|
15716
15824
|
const store = usePrimaryStore();
|
|
15717
15825
|
const removeBuffers = useCallback(
|
|
15718
|
-
(names, targetScope) =>
|
|
15719
|
-
const nameArray = Array.isArray(names) ? names : [names];
|
|
15720
|
-
store.setState((state) => {
|
|
15721
|
-
if (targetScope) {
|
|
15722
|
-
const currentScope = { ...state.buffers[targetScope] };
|
|
15723
|
-
for (const name of nameArray) delete currentScope[name];
|
|
15724
|
-
return { buffers: { ...state.buffers, [targetScope]: currentScope } };
|
|
15725
|
-
}
|
|
15726
|
-
const buffers2 = { ...state.buffers };
|
|
15727
|
-
for (const name of nameArray) if (isBufferLike(buffers2[name])) delete buffers2[name];
|
|
15728
|
-
return { buffers: buffers2 };
|
|
15729
|
-
});
|
|
15730
|
-
},
|
|
15826
|
+
(names, targetScope) => removeResourceEntries(store, "buffers", Array.isArray(names) ? names : [names], targetScope, isBufferLike),
|
|
15731
15827
|
[store]
|
|
15732
15828
|
);
|
|
15733
15829
|
const clearBuffers = useCallback(
|
|
15734
|
-
(targetScope) =>
|
|
15735
|
-
store.setState((state) => {
|
|
15736
|
-
if (targetScope && targetScope !== "root") {
|
|
15737
|
-
const { [targetScope]: _, ...rest } = state.buffers;
|
|
15738
|
-
return { buffers: rest };
|
|
15739
|
-
}
|
|
15740
|
-
if (targetScope === "root") {
|
|
15741
|
-
const buffers2 = {};
|
|
15742
|
-
for (const [key, value] of Object.entries(state.buffers)) {
|
|
15743
|
-
if (!isBufferLike(value)) buffers2[key] = value;
|
|
15744
|
-
}
|
|
15745
|
-
return { buffers: buffers2 };
|
|
15746
|
-
}
|
|
15747
|
-
return { buffers: {} };
|
|
15748
|
-
});
|
|
15749
|
-
},
|
|
15830
|
+
(targetScope) => clearResourceEntries(store, "buffers", targetScope, isBufferLike),
|
|
15750
15831
|
[store]
|
|
15751
15832
|
);
|
|
15752
15833
|
const rebuildBuffers = useCallback(
|
|
15753
|
-
(targetScope) =>
|
|
15754
|
-
store.setState((state) => {
|
|
15755
|
-
let newBuffers = state.buffers;
|
|
15756
|
-
if (targetScope && targetScope !== "root") {
|
|
15757
|
-
const { [targetScope]: _, ...rest } = state.buffers;
|
|
15758
|
-
newBuffers = rest;
|
|
15759
|
-
} else if (targetScope === "root") {
|
|
15760
|
-
newBuffers = {};
|
|
15761
|
-
for (const [key, value] of Object.entries(state.buffers)) {
|
|
15762
|
-
if (!isBufferLike(value)) newBuffers[key] = value;
|
|
15763
|
-
}
|
|
15764
|
-
} else {
|
|
15765
|
-
newBuffers = {};
|
|
15766
|
-
}
|
|
15767
|
-
return { buffers: newBuffers, _hmrVersion: state._hmrVersion + 1 };
|
|
15768
|
-
});
|
|
15769
|
-
},
|
|
15834
|
+
(targetScope) => rebuildResource(store, "buffers", targetScope),
|
|
15770
15835
|
[store]
|
|
15771
15836
|
);
|
|
15772
15837
|
const disposeBuffers = useCallback(
|
|
@@ -15785,85 +15850,33 @@ function useBuffers(creatorOrScope, scope) {
|
|
|
15785
15850
|
);
|
|
15786
15851
|
const isReader = creatorOrScope === void 0 || typeof creatorOrScope === "string";
|
|
15787
15852
|
const storeBuffers = usePrimaryThree((s) => s.buffers);
|
|
15788
|
-
const
|
|
15789
|
-
|
|
15790
|
-
|
|
15791
|
-
|
|
15792
|
-
|
|
15793
|
-
|
|
15794
|
-
return
|
|
15795
|
-
|
|
15796
|
-
|
|
15797
|
-
|
|
15798
|
-
if (
|
|
15799
|
-
|
|
15800
|
-
}
|
|
15801
|
-
const state = store.getState();
|
|
15802
|
-
const set = store.setState;
|
|
15803
|
-
const creator = creatorOrScope;
|
|
15804
|
-
const wrappedState = createLazyCreatorState(state);
|
|
15805
|
-
const created = creator(wrappedState);
|
|
15806
|
-
const result = {};
|
|
15807
|
-
let hasNewBuffers = false;
|
|
15808
|
-
if (scope) {
|
|
15809
|
-
const currentScope = state.buffers[scope] ?? {};
|
|
15810
|
-
for (const [name, buffer] of Object.entries(created)) {
|
|
15811
|
-
if (currentScope[name]) {
|
|
15812
|
-
result[name] = currentScope[name];
|
|
15813
|
-
} else {
|
|
15814
|
-
if ("setName" in buffer && typeof buffer.setName === "function") {
|
|
15815
|
-
buffer.setName(`${scope}.${name}`);
|
|
15816
|
-
}
|
|
15817
|
-
result[name] = buffer;
|
|
15818
|
-
hasNewBuffers = true;
|
|
15819
|
-
}
|
|
15820
|
-
}
|
|
15821
|
-
if (hasNewBuffers) {
|
|
15822
|
-
set((s) => ({
|
|
15823
|
-
buffers: {
|
|
15824
|
-
...s.buffers,
|
|
15825
|
-
[scope]: { ...s.buffers[scope], ...result }
|
|
15826
|
-
}
|
|
15827
|
-
}));
|
|
15828
|
-
}
|
|
15829
|
-
return result;
|
|
15830
|
-
}
|
|
15831
|
-
for (const [name, buffer] of Object.entries(created)) {
|
|
15832
|
-
const existing = state.buffers[name];
|
|
15833
|
-
if (existing && isBufferLike(existing)) {
|
|
15834
|
-
result[name] = existing;
|
|
15835
|
-
} else {
|
|
15836
|
-
if ("setName" in buffer && typeof buffer.setName === "function") {
|
|
15837
|
-
buffer.setName(name);
|
|
15838
|
-
}
|
|
15839
|
-
result[name] = buffer;
|
|
15840
|
-
hasNewBuffers = true;
|
|
15853
|
+
const created = useScopedResource({
|
|
15854
|
+
store,
|
|
15855
|
+
kind: "buffers",
|
|
15856
|
+
scope: isReader ? void 0 : scope,
|
|
15857
|
+
isLeaf: isBufferLike,
|
|
15858
|
+
create: () => {
|
|
15859
|
+
if (isReader) return {};
|
|
15860
|
+
return creatorOrScope(createLazyCreatorState(store.getState(), store));
|
|
15861
|
+
},
|
|
15862
|
+
prepare: (name, buffer) => {
|
|
15863
|
+
if ("setName" in buffer && typeof buffer.setName === "function") {
|
|
15864
|
+
buffer.setName(scope ? `${scope}.${name}` : name);
|
|
15841
15865
|
}
|
|
15866
|
+
return buffer;
|
|
15842
15867
|
}
|
|
15843
|
-
|
|
15844
|
-
|
|
15845
|
-
|
|
15846
|
-
|
|
15847
|
-
}
|
|
15868
|
+
});
|
|
15869
|
+
let buffers = created;
|
|
15870
|
+
if (creatorOrScope === void 0) {
|
|
15871
|
+
buffers = storeBuffers;
|
|
15872
|
+
} else if (typeof creatorOrScope === "string") {
|
|
15873
|
+
const scopeData = storeBuffers[creatorOrScope];
|
|
15874
|
+
buffers = scopeData && !isBufferLike(scopeData) ? scopeData : {};
|
|
15875
|
+
}
|
|
15848
15876
|
return { ...buffers, removeBuffers, clearBuffers, rebuildBuffers, disposeBuffers };
|
|
15849
15877
|
}
|
|
15850
15878
|
function rebuildAllBuffers(store, scope) {
|
|
15851
|
-
store
|
|
15852
|
-
store.setState((state) => {
|
|
15853
|
-
let newBuffers = state.buffers;
|
|
15854
|
-
if (scope && scope !== "root") {
|
|
15855
|
-
const { [scope]: _, ...rest } = state.buffers;
|
|
15856
|
-
newBuffers = rest;
|
|
15857
|
-
} else if (scope === "root") {
|
|
15858
|
-
newBuffers = {};
|
|
15859
|
-
for (const [key, value] of Object.entries(state.buffers)) {
|
|
15860
|
-
if (!isBufferLike(value)) newBuffers[key] = value;
|
|
15861
|
-
}
|
|
15862
|
-
} else {
|
|
15863
|
-
newBuffers = {};
|
|
15864
|
-
}
|
|
15865
|
-
return { buffers: newBuffers, _hmrVersion: state._hmrVersion + 1 };
|
|
15866
|
-
});
|
|
15879
|
+
rebuildResource(store, "buffers", scope);
|
|
15867
15880
|
}
|
|
15868
15881
|
|
|
15869
15882
|
const isStorageLike = (value) => {
|
|
@@ -15882,58 +15895,15 @@ const disposeStorage = (storage) => {
|
|
|
15882
15895
|
function useGPUStorage(creatorOrScope, scope) {
|
|
15883
15896
|
const store = usePrimaryStore();
|
|
15884
15897
|
const removeStorage = useCallback(
|
|
15885
|
-
(names, targetScope) =>
|
|
15886
|
-
const nameArray = Array.isArray(names) ? names : [names];
|
|
15887
|
-
store.setState((state) => {
|
|
15888
|
-
if (targetScope) {
|
|
15889
|
-
const currentScope = { ...state.gpuStorage[targetScope] };
|
|
15890
|
-
for (const name of nameArray) delete currentScope[name];
|
|
15891
|
-
return { gpuStorage: { ...state.gpuStorage, [targetScope]: currentScope } };
|
|
15892
|
-
}
|
|
15893
|
-
const gpuStorage2 = { ...state.gpuStorage };
|
|
15894
|
-
for (const name of nameArray) if (isStorageLike(gpuStorage2[name])) delete gpuStorage2[name];
|
|
15895
|
-
return { gpuStorage: gpuStorage2 };
|
|
15896
|
-
});
|
|
15897
|
-
},
|
|
15898
|
+
(names, targetScope) => removeResourceEntries(store, "gpuStorage", Array.isArray(names) ? names : [names], targetScope, isStorageLike),
|
|
15898
15899
|
[store]
|
|
15899
15900
|
);
|
|
15900
15901
|
const clearStorage = useCallback(
|
|
15901
|
-
(targetScope) =>
|
|
15902
|
-
store.setState((state) => {
|
|
15903
|
-
if (targetScope && targetScope !== "root") {
|
|
15904
|
-
const { [targetScope]: _, ...rest } = state.gpuStorage;
|
|
15905
|
-
return { gpuStorage: rest };
|
|
15906
|
-
}
|
|
15907
|
-
if (targetScope === "root") {
|
|
15908
|
-
const gpuStorage2 = {};
|
|
15909
|
-
for (const [key, value] of Object.entries(state.gpuStorage)) {
|
|
15910
|
-
if (!isStorageLike(value)) gpuStorage2[key] = value;
|
|
15911
|
-
}
|
|
15912
|
-
return { gpuStorage: gpuStorage2 };
|
|
15913
|
-
}
|
|
15914
|
-
return { gpuStorage: {} };
|
|
15915
|
-
});
|
|
15916
|
-
},
|
|
15902
|
+
(targetScope) => clearResourceEntries(store, "gpuStorage", targetScope, isStorageLike),
|
|
15917
15903
|
[store]
|
|
15918
15904
|
);
|
|
15919
15905
|
const rebuildStorage = useCallback(
|
|
15920
|
-
(targetScope) =>
|
|
15921
|
-
store.setState((state) => {
|
|
15922
|
-
let newStorage = state.gpuStorage;
|
|
15923
|
-
if (targetScope && targetScope !== "root") {
|
|
15924
|
-
const { [targetScope]: _, ...rest } = state.gpuStorage;
|
|
15925
|
-
newStorage = rest;
|
|
15926
|
-
} else if (targetScope === "root") {
|
|
15927
|
-
newStorage = {};
|
|
15928
|
-
for (const [key, value] of Object.entries(state.gpuStorage)) {
|
|
15929
|
-
if (!isStorageLike(value)) newStorage[key] = value;
|
|
15930
|
-
}
|
|
15931
|
-
} else {
|
|
15932
|
-
newStorage = {};
|
|
15933
|
-
}
|
|
15934
|
-
return { gpuStorage: newStorage, _hmrVersion: state._hmrVersion + 1 };
|
|
15935
|
-
});
|
|
15936
|
-
},
|
|
15906
|
+
(targetScope) => rebuildResource(store, "gpuStorage", targetScope),
|
|
15937
15907
|
[store]
|
|
15938
15908
|
);
|
|
15939
15909
|
const disposeStorageFn = useCallback(
|
|
@@ -15952,72 +15922,33 @@ function useGPUStorage(creatorOrScope, scope) {
|
|
|
15952
15922
|
);
|
|
15953
15923
|
const isReader = creatorOrScope === void 0 || typeof creatorOrScope === "string";
|
|
15954
15924
|
const storeStorage = usePrimaryThree((s) => s.gpuStorage);
|
|
15955
|
-
const
|
|
15956
|
-
|
|
15957
|
-
|
|
15958
|
-
|
|
15959
|
-
|
|
15960
|
-
|
|
15961
|
-
return
|
|
15962
|
-
|
|
15963
|
-
|
|
15964
|
-
|
|
15965
|
-
|
|
15966
|
-
|
|
15967
|
-
|
|
15968
|
-
const state = store.getState();
|
|
15969
|
-
const set = store.setState;
|
|
15970
|
-
const creator = creatorOrScope;
|
|
15971
|
-
const wrappedState = createLazyCreatorState(state);
|
|
15972
|
-
const created = creator(wrappedState);
|
|
15973
|
-
const result = {};
|
|
15974
|
-
let hasNewStorage = false;
|
|
15975
|
-
if (scope) {
|
|
15976
|
-
const currentScope = state.gpuStorage[scope] ?? {};
|
|
15977
|
-
for (const [name, storage] of Object.entries(created)) {
|
|
15978
|
-
if (currentScope[name]) {
|
|
15979
|
-
result[name] = currentScope[name];
|
|
15980
|
-
} else {
|
|
15981
|
-
if ("setName" in storage && typeof storage.setName === "function") {
|
|
15982
|
-
storage.setName(`${scope}.${name}`);
|
|
15983
|
-
}
|
|
15984
|
-
if ("name" in storage && typeof storage.name === "string") {
|
|
15985
|
-
storage.name = `${scope}.${name}`;
|
|
15986
|
-
}
|
|
15987
|
-
result[name] = storage;
|
|
15988
|
-
hasNewStorage = true;
|
|
15989
|
-
}
|
|
15990
|
-
}
|
|
15991
|
-
if (hasNewStorage) {
|
|
15992
|
-
set((s) => ({
|
|
15993
|
-
gpuStorage: {
|
|
15994
|
-
...s.gpuStorage,
|
|
15995
|
-
[scope]: { ...s.gpuStorage[scope], ...result }
|
|
15996
|
-
}
|
|
15997
|
-
}));
|
|
15925
|
+
const created = useScopedResource({
|
|
15926
|
+
store,
|
|
15927
|
+
kind: "gpuStorage",
|
|
15928
|
+
scope: isReader ? void 0 : scope,
|
|
15929
|
+
isLeaf: isStorageLike,
|
|
15930
|
+
create: () => {
|
|
15931
|
+
if (isReader) return {};
|
|
15932
|
+
return creatorOrScope(createLazyCreatorState(store.getState(), store));
|
|
15933
|
+
},
|
|
15934
|
+
prepare: (name, storage) => {
|
|
15935
|
+
const label = scope ? `${scope}.${name}` : name;
|
|
15936
|
+
if ("setName" in storage && typeof storage.setName === "function") {
|
|
15937
|
+
storage.setName(label);
|
|
15998
15938
|
}
|
|
15999
|
-
|
|
16000
|
-
|
|
16001
|
-
for (const [name, storage] of Object.entries(created)) {
|
|
16002
|
-
const existing = state.gpuStorage[name];
|
|
16003
|
-
if (existing && isStorageLike(existing)) {
|
|
16004
|
-
result[name] = existing;
|
|
16005
|
-
} else {
|
|
16006
|
-
if ("setName" in storage && typeof storage.setName === "function") {
|
|
16007
|
-
storage.setName(name);
|
|
16008
|
-
}
|
|
16009
|
-
if ("name" in storage && typeof storage.name === "string") {
|
|
16010
|
-
storage.name = name;
|
|
16011
|
-
}
|
|
16012
|
-
result[name] = storage;
|
|
16013
|
-
hasNewStorage = true;
|
|
15939
|
+
if ("name" in storage && typeof storage.name === "string") {
|
|
15940
|
+
storage.name = label;
|
|
16014
15941
|
}
|
|
15942
|
+
return storage;
|
|
16015
15943
|
}
|
|
16016
|
-
|
|
16017
|
-
|
|
16018
|
-
|
|
16019
|
-
|
|
16020
|
-
}
|
|
15944
|
+
});
|
|
15945
|
+
let gpuStorage = created;
|
|
15946
|
+
if (creatorOrScope === void 0) {
|
|
15947
|
+
gpuStorage = storeStorage;
|
|
15948
|
+
} else if (typeof creatorOrScope === "string") {
|
|
15949
|
+
const scopeData = storeStorage[creatorOrScope];
|
|
15950
|
+
gpuStorage = scopeData && !isStorageLike(scopeData) ? scopeData : {};
|
|
15951
|
+
}
|
|
16021
15952
|
return {
|
|
16022
15953
|
...gpuStorage,
|
|
16023
15954
|
removeStorage,
|
|
@@ -16027,22 +15958,7 @@ function useGPUStorage(creatorOrScope, scope) {
|
|
|
16027
15958
|
};
|
|
16028
15959
|
}
|
|
16029
15960
|
function rebuildAllStorage(store, scope) {
|
|
16030
|
-
store
|
|
16031
|
-
store.setState((state) => {
|
|
16032
|
-
let newStorage = state.gpuStorage;
|
|
16033
|
-
if (scope && scope !== "root") {
|
|
16034
|
-
const { [scope]: _, ...rest } = state.gpuStorage;
|
|
16035
|
-
newStorage = rest;
|
|
16036
|
-
} else if (scope === "root") {
|
|
16037
|
-
newStorage = {};
|
|
16038
|
-
for (const [key, value] of Object.entries(state.gpuStorage)) {
|
|
16039
|
-
if (!isStorageLike(value)) newStorage[key] = value;
|
|
16040
|
-
}
|
|
16041
|
-
} else {
|
|
16042
|
-
newStorage = {};
|
|
16043
|
-
}
|
|
16044
|
-
return { gpuStorage: newStorage, _hmrVersion: state._hmrVersion + 1 };
|
|
16045
|
-
});
|
|
15961
|
+
rebuildResource(store, "gpuStorage", scope);
|
|
16046
15962
|
}
|
|
16047
15963
|
|
|
16048
15964
|
function useRenderPipeline(mainCB, setupCB) {
|
|
@@ -16140,4 +16056,4 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
16140
16056
|
|
|
16141
16057
|
extend(THREE);
|
|
16142
16058
|
|
|
16143
|
-
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,
|
|
16059
|
+
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 };
|