@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.cjs
CHANGED
|
@@ -6,15 +6,14 @@ const jsxRuntime = require('react/jsx-runtime');
|
|
|
6
6
|
const React = require('react');
|
|
7
7
|
const useMeasure = require('react-use-measure');
|
|
8
8
|
const itsFine = require('its-fine');
|
|
9
|
-
const
|
|
9
|
+
const traditional = require('zustand/traditional');
|
|
10
|
+
const scheduler = require('@pmndrs/scheduler');
|
|
11
|
+
const Tb = require('scheduler');
|
|
10
12
|
const GroundedSkybox_js = require('three/examples/jsm/objects/GroundedSkybox.js');
|
|
11
13
|
const HDRLoader_js = require('three/examples/jsm/loaders/HDRLoader.js');
|
|
12
14
|
const EXRLoader_js = require('three/examples/jsm/loaders/EXRLoader.js');
|
|
13
15
|
const UltraHDRLoader_js = require('three/examples/jsm/loaders/UltraHDRLoader.js');
|
|
14
16
|
const gainmapJs = require('@monogrid/gainmap-js');
|
|
15
|
-
const Tb = require('scheduler');
|
|
16
|
-
const traditional = require('zustand/traditional');
|
|
17
|
-
const scheduler = require('@pmndrs/scheduler');
|
|
18
17
|
const suspendReact = require('suspend-react');
|
|
19
18
|
const lite = require('dequal/lite');
|
|
20
19
|
require('zustand/shallow');
|
|
@@ -135,556 +134,229 @@ function getPrimaryIds() {
|
|
|
135
134
|
return Array.from(primaryRegistry.keys());
|
|
136
135
|
}
|
|
137
136
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
137
|
+
var __defProp$1 = Object.defineProperty;
|
|
138
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
139
|
+
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
140
|
+
const useIsomorphicLayoutEffect = /* @__PURE__ */ (() => typeof window !== "undefined" && (window.document?.createElement || window.navigator?.product === "ReactNative"))() ? React__namespace.useLayoutEffect : React__namespace.useEffect;
|
|
141
|
+
function useMutableCallback(fn) {
|
|
142
|
+
const ref = React__namespace.useRef(fn);
|
|
143
|
+
useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
|
|
144
|
+
return ref;
|
|
145
|
+
}
|
|
146
|
+
function useBridge() {
|
|
147
|
+
const fiber = itsFine.useFiber();
|
|
148
|
+
const ContextBridge = itsFine.useContextBridge();
|
|
149
|
+
return React__namespace.useMemo(
|
|
150
|
+
() => ({ children }) => {
|
|
151
|
+
const strict = !!itsFine.traverseFiber(fiber, true, (node) => node.type === React__namespace.StrictMode);
|
|
152
|
+
const Root = strict ? React__namespace.StrictMode : React__namespace.Fragment;
|
|
153
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Root, { children: /* @__PURE__ */ jsxRuntime.jsx(ContextBridge, { children }) });
|
|
154
|
+
},
|
|
155
|
+
[fiber, ContextBridge]
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
function Block({ set }) {
|
|
159
|
+
useIsomorphicLayoutEffect(() => {
|
|
160
|
+
set(new Promise(() => null));
|
|
161
|
+
return () => set(false);
|
|
162
|
+
}, [set]);
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
const ErrorBoundary = /* @__PURE__ */ (() => {
|
|
166
|
+
var _a;
|
|
167
|
+
return _a = class extends React__namespace.Component {
|
|
168
|
+
constructor() {
|
|
169
|
+
super(...arguments);
|
|
170
|
+
__publicField$1(this, "state", { error: false });
|
|
171
|
+
}
|
|
172
|
+
componentDidCatch(err) {
|
|
173
|
+
this.props.set(err);
|
|
174
|
+
}
|
|
175
|
+
render() {
|
|
176
|
+
return this.state.error ? null : this.props.children;
|
|
177
|
+
}
|
|
178
|
+
}, __publicField$1(_a, "getDerivedStateFromError", () => ({ error: true })), _a;
|
|
179
|
+
})();
|
|
150
180
|
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
} = {}) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
fiber.useLoader.clear(loader, multiFile ? [files] : files);
|
|
181
|
+
const is = {
|
|
182
|
+
obj: (a) => a === Object(a) && !is.arr(a) && typeof a !== "function",
|
|
183
|
+
fun: (a) => typeof a === "function",
|
|
184
|
+
str: (a) => typeof a === "string",
|
|
185
|
+
num: (a) => typeof a === "number",
|
|
186
|
+
boo: (a) => typeof a === "boolean",
|
|
187
|
+
und: (a) => a === void 0,
|
|
188
|
+
nul: (a) => a === null,
|
|
189
|
+
arr: (a) => Array.isArray(a),
|
|
190
|
+
equ(a, b, { arrays = "shallow", objects = "reference", strict = true } = {}) {
|
|
191
|
+
if (typeof a !== typeof b || !!a !== !!b) return false;
|
|
192
|
+
if (is.str(a) || is.num(a) || is.boo(a)) return a === b;
|
|
193
|
+
const isObj = is.obj(a);
|
|
194
|
+
if (isObj && objects === "reference") return a === b;
|
|
195
|
+
const isArr = is.arr(a);
|
|
196
|
+
if (isArr && arrays === "reference") return a === b;
|
|
197
|
+
if ((isArr || isObj) && a === b) return true;
|
|
198
|
+
let i;
|
|
199
|
+
for (i in a) if (!(i in b)) return false;
|
|
200
|
+
if (isObj && arrays === "shallow" && objects === "shallow") {
|
|
201
|
+
for (i in strict ? b : a) if (!is.equ(a[i], b[i], { strict, objects: "reference" })) return false;
|
|
202
|
+
} else {
|
|
203
|
+
for (i in strict ? b : a) if (a[i] !== b[i]) return false;
|
|
175
204
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
multiFile ? [files] : files,
|
|
181
|
-
(loader2) => {
|
|
182
|
-
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
183
|
-
loader2.setRenderer?.(renderer);
|
|
184
|
-
}
|
|
185
|
-
loader2.setPath?.(path);
|
|
186
|
-
if (extensions) extensions(loader2);
|
|
205
|
+
if (is.und(i)) {
|
|
206
|
+
if (isArr && a.length === 0 && b.length === 0) return true;
|
|
207
|
+
if (isObj && Object.keys(a).length === 0 && Object.keys(b).length === 0) return true;
|
|
208
|
+
if (a !== b) return false;
|
|
187
209
|
}
|
|
188
|
-
|
|
189
|
-
let texture = multiFile ? (
|
|
190
|
-
// @ts-ignore
|
|
191
|
-
loaderResult[0]
|
|
192
|
-
) : loaderResult;
|
|
193
|
-
if (extension === "jpg" || extension === "jpeg" || extension === "webp") {
|
|
194
|
-
texture = texture.renderTarget?.texture;
|
|
195
|
-
}
|
|
196
|
-
texture.mapping = isCubemap ? webgpu.CubeReflectionMapping : webgpu.EquirectangularReflectionMapping;
|
|
197
|
-
texture.colorSpace = colorSpace ?? (isCubemap ? "srgb" : "srgb-linear");
|
|
198
|
-
return texture;
|
|
199
|
-
}
|
|
200
|
-
const preloadDefaultOptions = {
|
|
201
|
-
files: defaultFiles,
|
|
202
|
-
path: "",
|
|
203
|
-
preset: void 0,
|
|
204
|
-
extensions: void 0
|
|
205
|
-
};
|
|
206
|
-
useEnvironment.preload = (preloadOptions) => {
|
|
207
|
-
const options = { ...preloadDefaultOptions, ...preloadOptions };
|
|
208
|
-
let { files, path = "" } = options;
|
|
209
|
-
const { preset, extensions } = options;
|
|
210
|
-
if (preset) {
|
|
211
|
-
validatePreset(preset);
|
|
212
|
-
files = presetsObj[preset];
|
|
213
|
-
path = CUBEMAP_ROOT;
|
|
214
|
-
}
|
|
215
|
-
const { extension } = getExtension(files);
|
|
216
|
-
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
217
|
-
throw new Error("useEnvironment: Preloading gainmaps is not supported");
|
|
218
|
-
}
|
|
219
|
-
const loader = getLoader$1(extension);
|
|
220
|
-
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
221
|
-
fiber.useLoader.preload(loader, isArray(files) ? [files] : files, (loader2) => {
|
|
222
|
-
loader2.setPath?.(path);
|
|
223
|
-
if (extensions) extensions(loader2);
|
|
224
|
-
});
|
|
225
|
-
};
|
|
226
|
-
const clearDefaultOptins = {
|
|
227
|
-
files: defaultFiles,
|
|
228
|
-
preset: void 0
|
|
229
|
-
};
|
|
230
|
-
useEnvironment.clear = (clearOptions) => {
|
|
231
|
-
const options = { ...clearDefaultOptins, ...clearOptions };
|
|
232
|
-
let { files } = options;
|
|
233
|
-
const { preset } = options;
|
|
234
|
-
if (preset) {
|
|
235
|
-
validatePreset(preset);
|
|
236
|
-
files = presetsObj[preset];
|
|
210
|
+
return true;
|
|
237
211
|
}
|
|
238
|
-
const { extension } = getExtension(files);
|
|
239
|
-
const loader = getLoader$1(extension);
|
|
240
|
-
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
241
|
-
fiber.useLoader.clear(loader, isArray(files) ? [files] : files);
|
|
242
212
|
};
|
|
243
|
-
|
|
244
|
-
|
|
213
|
+
const isOrthographicCamera = (def) => def && def.isOrthographicCamera;
|
|
214
|
+
const isRef$1 = (obj) => obj !== null && typeof obj === "object" && obj.hasOwnProperty("current");
|
|
215
|
+
const isColorRepresentation = (value) => value != null && (typeof value === "string" || typeof value === "number" || value.isColor);
|
|
216
|
+
const isObject3D = (object) => object?.isObject3D;
|
|
217
|
+
const isTexture = (value) => !!value?.isTexture;
|
|
218
|
+
const isVectorLike = (object) => object !== null && typeof object === "object" && "set" in object && typeof object.set === "function";
|
|
219
|
+
const isCopyable = (object) => isVectorLike(object) && "copy" in object && typeof object.copy === "function";
|
|
220
|
+
const hasConstructor = (object) => !!object?.constructor;
|
|
221
|
+
|
|
222
|
+
function calculateDpr(dpr) {
|
|
223
|
+
const target = typeof window !== "undefined" ? window.devicePixelRatio ?? 2 : 1;
|
|
224
|
+
return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
|
|
245
225
|
}
|
|
246
|
-
function
|
|
247
|
-
|
|
248
|
-
const isGainmap = isArray(files) && files.length === 3 && files.some((file) => file.endsWith("json"));
|
|
249
|
-
const firstEntry = isArray(files) ? files[0] : files;
|
|
250
|
-
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();
|
|
251
|
-
return { extension, isCubemap, isGainmap };
|
|
226
|
+
function getUuidPrefix(uuid) {
|
|
227
|
+
return uuid.split("-")[0];
|
|
252
228
|
}
|
|
253
|
-
function
|
|
254
|
-
|
|
255
|
-
|
|
229
|
+
function updateCamera(camera, size) {
|
|
230
|
+
if (camera.manual) return;
|
|
231
|
+
if (isOrthographicCamera(camera)) {
|
|
232
|
+
camera.left = size.width / -2;
|
|
233
|
+
camera.right = size.width / 2;
|
|
234
|
+
camera.top = size.height / 2;
|
|
235
|
+
camera.bottom = size.height / -2;
|
|
236
|
+
} else {
|
|
237
|
+
camera.aspect = size.width / size.height;
|
|
238
|
+
}
|
|
239
|
+
camera.updateProjectionMatrix();
|
|
256
240
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
backgroundIntensity: 1,
|
|
264
|
-
backgroundRotation: [0, 0, 0],
|
|
265
|
-
environmentIntensity: 1,
|
|
266
|
-
environmentRotation: [0, 0, 0],
|
|
267
|
-
...sceneProps
|
|
268
|
-
};
|
|
269
|
-
const target = resolveScene(scene || defaultScene);
|
|
270
|
-
const oldbg = target.background;
|
|
271
|
-
const oldenv = target.environment;
|
|
272
|
-
const oldSceneProps = {
|
|
273
|
-
// @ts-ignore
|
|
274
|
-
backgroundBlurriness: target.backgroundBlurriness,
|
|
275
|
-
// @ts-ignore
|
|
276
|
-
backgroundIntensity: target.backgroundIntensity,
|
|
277
|
-
// @ts-ignore
|
|
278
|
-
backgroundRotation: target.backgroundRotation?.clone?.() ?? [0, 0, 0],
|
|
279
|
-
// @ts-ignore
|
|
280
|
-
environmentIntensity: target.environmentIntensity,
|
|
281
|
-
// @ts-ignore
|
|
282
|
-
environmentRotation: target.environmentRotation?.clone?.() ?? [0, 0, 0]
|
|
283
|
-
};
|
|
284
|
-
if (background !== "only") target.environment = texture;
|
|
285
|
-
if (background) target.background = texture;
|
|
286
|
-
fiber.applyProps(target, sceneProps);
|
|
287
|
-
return () => {
|
|
288
|
-
if (background !== "only") target.environment = oldenv;
|
|
289
|
-
if (background) target.background = oldbg;
|
|
290
|
-
fiber.applyProps(target, oldSceneProps);
|
|
291
|
-
};
|
|
241
|
+
const frustumMatrix = new webgpu.Matrix4();
|
|
242
|
+
function updateFrustum(camera, frustum) {
|
|
243
|
+
const target = frustum ?? new webgpu.Frustum();
|
|
244
|
+
frustumMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
245
|
+
target.setFromProjectionMatrix(frustumMatrix);
|
|
246
|
+
return target;
|
|
292
247
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
return
|
|
248
|
+
|
|
249
|
+
const REACT_INTERNAL_PROPS = ["children", "key", "ref"];
|
|
250
|
+
function findInitialRoot(instance) {
|
|
251
|
+
let root = instance.root;
|
|
252
|
+
while (root.getState().previousRoot) root = root.getState().previousRoot;
|
|
253
|
+
return root;
|
|
299
254
|
}
|
|
300
|
-
function
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
...rest
|
|
310
|
-
}) {
|
|
311
|
-
const texture = useEnvironment(rest);
|
|
312
|
-
const defaultScene = fiber.useThree((state) => state.scene);
|
|
313
|
-
React__namespace.useLayoutEffect(() => {
|
|
314
|
-
return setEnvProps(background, scene, defaultScene, texture, {
|
|
315
|
-
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
316
|
-
backgroundIntensity,
|
|
317
|
-
backgroundRotation,
|
|
318
|
-
environmentIntensity,
|
|
319
|
-
environmentRotation
|
|
255
|
+
function getRootState(obj) {
|
|
256
|
+
let state = obj.__r3f?.root.getState();
|
|
257
|
+
if (!state) {
|
|
258
|
+
obj.traverseAncestors((ancestor) => {
|
|
259
|
+
const parentState = ancestor.__r3f?.root.getState();
|
|
260
|
+
if (parentState) {
|
|
261
|
+
state = parentState;
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
320
264
|
});
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
return () => {
|
|
324
|
-
texture.dispose();
|
|
325
|
-
};
|
|
326
|
-
}, [texture]);
|
|
327
|
-
return null;
|
|
265
|
+
}
|
|
266
|
+
return state;
|
|
328
267
|
}
|
|
329
|
-
function
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
path,
|
|
346
|
-
preset = void 0,
|
|
347
|
-
extensions
|
|
348
|
-
}) {
|
|
349
|
-
const renderer = fiber.useThree((state) => state.renderer);
|
|
350
|
-
const isLegacy = fiber.useThree((state) => state.isLegacy);
|
|
351
|
-
const defaultScene = fiber.useThree((state) => state.scene);
|
|
352
|
-
const camera = React__namespace.useRef(null);
|
|
353
|
-
const [virtualScene] = React__namespace.useState(() => new webgpu.Scene());
|
|
354
|
-
const fbo = React__namespace.useMemo(() => {
|
|
355
|
-
const fbo2 = isLegacy ? new WebGLCubeRenderTarget(resolution) : new webgpu.CubeRenderTarget(resolution);
|
|
356
|
-
fbo2.texture.type = webgpu.HalfFloatType;
|
|
357
|
-
return fbo2;
|
|
358
|
-
}, [resolution, isLegacy]);
|
|
359
|
-
React__namespace.useEffect(() => {
|
|
360
|
-
return () => {
|
|
361
|
-
fbo.dispose();
|
|
362
|
-
};
|
|
363
|
-
}, [fbo]);
|
|
364
|
-
React__namespace.useLayoutEffect(() => {
|
|
365
|
-
if (frames === 1) {
|
|
366
|
-
const autoClear = renderer.autoClear;
|
|
367
|
-
renderer.autoClear = true;
|
|
368
|
-
camera.current.update(renderer, virtualScene);
|
|
369
|
-
renderer.autoClear = autoClear;
|
|
370
|
-
}
|
|
371
|
-
return setEnvProps(background, scene, defaultScene, fbo.texture, {
|
|
372
|
-
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
373
|
-
backgroundIntensity,
|
|
374
|
-
backgroundRotation,
|
|
375
|
-
environmentIntensity,
|
|
376
|
-
environmentRotation
|
|
268
|
+
function buildGraph(object) {
|
|
269
|
+
const data = { nodes: {}, materials: {}, meshes: {} };
|
|
270
|
+
if (object) {
|
|
271
|
+
object.traverse((obj) => {
|
|
272
|
+
if (obj.name) data.nodes[obj.name] = obj;
|
|
273
|
+
if (obj.material) {
|
|
274
|
+
const material = Array.isArray(obj.material) ? obj.material[0] : obj.material;
|
|
275
|
+
const nameAlreadyUsed = data.materials[material.name];
|
|
276
|
+
let materialName = material.name;
|
|
277
|
+
if (nameAlreadyUsed) {
|
|
278
|
+
materialName = materialName + `-${getUuidPrefix(material.uuid)}`;
|
|
279
|
+
material.userData.materialCacheName = materialName;
|
|
280
|
+
}
|
|
281
|
+
data.materials[materialName] = material;
|
|
282
|
+
}
|
|
283
|
+
if (obj.isMesh && !data.meshes[obj.name]) data.meshes[obj.name] = obj;
|
|
377
284
|
});
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
virtualScene,
|
|
381
|
-
fbo.texture,
|
|
382
|
-
scene,
|
|
383
|
-
defaultScene,
|
|
384
|
-
background,
|
|
385
|
-
frames,
|
|
386
|
-
renderer,
|
|
387
|
-
blur,
|
|
388
|
-
backgroundBlurriness,
|
|
389
|
-
backgroundIntensity,
|
|
390
|
-
backgroundRotation,
|
|
391
|
-
environmentIntensity,
|
|
392
|
-
environmentRotation
|
|
393
|
-
]);
|
|
394
|
-
let count = 1;
|
|
395
|
-
fiber.useFrame(() => {
|
|
396
|
-
if (frames === Infinity || count < frames) {
|
|
397
|
-
const autoClear = renderer.autoClear;
|
|
398
|
-
renderer.autoClear = true;
|
|
399
|
-
camera.current.update(renderer, virtualScene);
|
|
400
|
-
renderer.autoClear = autoClear;
|
|
401
|
-
count++;
|
|
402
|
-
}
|
|
403
|
-
});
|
|
404
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fiber.createPortal(
|
|
405
|
-
/* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
406
|
-
children,
|
|
407
|
-
/* @__PURE__ */ jsxRuntime.jsx("cubeCamera", { ref: camera, args: [near, far, fbo] }),
|
|
408
|
-
files || preset ? /* @__PURE__ */ jsxRuntime.jsx(EnvironmentCube, { background: true, files, preset, path, extensions }) : map ? /* @__PURE__ */ jsxRuntime.jsx(EnvironmentMap, { background: true, map, extensions }) : null
|
|
409
|
-
] }),
|
|
410
|
-
virtualScene
|
|
411
|
-
) });
|
|
412
|
-
}
|
|
413
|
-
function EnvironmentGround(props) {
|
|
414
|
-
const textureDefault = useEnvironment(props);
|
|
415
|
-
const texture = props.map || textureDefault;
|
|
416
|
-
React__namespace.useMemo(() => fiber.extend({ GroundProjectedEnvImpl: GroundedSkybox_js.GroundedSkybox }), []);
|
|
417
|
-
React__namespace.useEffect(() => {
|
|
418
|
-
return () => {
|
|
419
|
-
textureDefault.dispose();
|
|
420
|
-
};
|
|
421
|
-
}, [textureDefault]);
|
|
422
|
-
const height = props.ground?.height ?? 15;
|
|
423
|
-
const radius = props.ground?.radius ?? 60;
|
|
424
|
-
const scale = props.ground?.scale ?? 1e3;
|
|
425
|
-
const args = React__namespace.useMemo(
|
|
426
|
-
() => [texture, height, radius],
|
|
427
|
-
[texture, height, radius]
|
|
428
|
-
);
|
|
429
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
430
|
-
/* @__PURE__ */ jsxRuntime.jsx(EnvironmentMap, { ...props, map: texture }),
|
|
431
|
-
/* @__PURE__ */ jsxRuntime.jsx("groundProjectedEnvImpl", { args, scale })
|
|
432
|
-
] });
|
|
433
|
-
}
|
|
434
|
-
function EnvironmentColor({ color, scene }) {
|
|
435
|
-
const defaultScene = fiber.useThree((state) => state.scene);
|
|
436
|
-
React__namespace.useLayoutEffect(() => {
|
|
437
|
-
if (color === void 0) return;
|
|
438
|
-
const target = resolveScene(scene || defaultScene);
|
|
439
|
-
const oldBg = target.background;
|
|
440
|
-
target.background = new webgpu.Color(color);
|
|
441
|
-
return () => {
|
|
442
|
-
target.background = oldBg;
|
|
443
|
-
};
|
|
444
|
-
});
|
|
445
|
-
return null;
|
|
285
|
+
}
|
|
286
|
+
return data;
|
|
446
287
|
}
|
|
447
|
-
function
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
288
|
+
function dispose(obj) {
|
|
289
|
+
if (obj.type !== "Scene") obj.dispose?.();
|
|
290
|
+
for (const p in obj) {
|
|
291
|
+
const prop = obj[p];
|
|
292
|
+
if (prop?.type !== "Scene") prop?.dispose?.();
|
|
293
|
+
}
|
|
453
294
|
}
|
|
454
|
-
function
|
|
455
|
-
|
|
456
|
-
|
|
295
|
+
function getInstanceProps(pendingProps) {
|
|
296
|
+
const props = {};
|
|
297
|
+
for (const key in pendingProps) {
|
|
298
|
+
if (!REACT_INTERNAL_PROPS.includes(key)) props[key] = pendingProps[key];
|
|
457
299
|
}
|
|
458
|
-
|
|
459
|
-
|
|
300
|
+
return props;
|
|
301
|
+
}
|
|
302
|
+
function prepare(target, root, type, props) {
|
|
303
|
+
const object = target;
|
|
304
|
+
let instance = object?.__r3f;
|
|
305
|
+
if (!instance) {
|
|
306
|
+
instance = {
|
|
307
|
+
root,
|
|
308
|
+
type,
|
|
309
|
+
parent: null,
|
|
310
|
+
children: [],
|
|
311
|
+
props: getInstanceProps(props),
|
|
312
|
+
object,
|
|
313
|
+
eventCount: 0,
|
|
314
|
+
handlers: {},
|
|
315
|
+
isHidden: false
|
|
316
|
+
};
|
|
317
|
+
if (object) object.__r3f = instance;
|
|
460
318
|
}
|
|
461
|
-
return
|
|
319
|
+
return instance;
|
|
320
|
+
}
|
|
321
|
+
function invalidateInstance(instance) {
|
|
322
|
+
if (!instance.parent) return;
|
|
323
|
+
instance.props.onUpdate?.(instance.object);
|
|
324
|
+
const state = instance.root?.getState?.();
|
|
325
|
+
if (state && state.internal.frames === 0) state.invalidate();
|
|
462
326
|
}
|
|
463
327
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
328
|
+
const tempFrustum = new webgpu.Frustum();
|
|
329
|
+
let hasWarnedWebGL = false;
|
|
330
|
+
let tslModule = null;
|
|
331
|
+
async function loadTSL() {
|
|
332
|
+
if (tslModule) return tslModule;
|
|
333
|
+
try {
|
|
334
|
+
const tsl = await import('three/tsl');
|
|
335
|
+
tslModule = { uniform: tsl.uniform, nodeObject: tsl.nodeObject };
|
|
336
|
+
return tslModule;
|
|
337
|
+
} catch {
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
473
340
|
}
|
|
474
|
-
function
|
|
475
|
-
const
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
const ErrorBoundary = /* @__PURE__ */ (() => {
|
|
494
|
-
var _a;
|
|
495
|
-
return _a = class extends React__namespace.Component {
|
|
496
|
-
constructor() {
|
|
497
|
-
super(...arguments);
|
|
498
|
-
__publicField$1(this, "state", { error: false });
|
|
499
|
-
}
|
|
500
|
-
componentDidCatch(err) {
|
|
501
|
-
this.props.set(err);
|
|
502
|
-
}
|
|
503
|
-
render() {
|
|
504
|
-
return this.state.error ? null : this.props.children;
|
|
505
|
-
}
|
|
506
|
-
}, __publicField$1(_a, "getDerivedStateFromError", () => ({ error: true })), _a;
|
|
507
|
-
})();
|
|
508
|
-
|
|
509
|
-
const is = {
|
|
510
|
-
obj: (a) => a === Object(a) && !is.arr(a) && typeof a !== "function",
|
|
511
|
-
fun: (a) => typeof a === "function",
|
|
512
|
-
str: (a) => typeof a === "string",
|
|
513
|
-
num: (a) => typeof a === "number",
|
|
514
|
-
boo: (a) => typeof a === "boolean",
|
|
515
|
-
und: (a) => a === void 0,
|
|
516
|
-
nul: (a) => a === null,
|
|
517
|
-
arr: (a) => Array.isArray(a),
|
|
518
|
-
equ(a, b, { arrays = "shallow", objects = "reference", strict = true } = {}) {
|
|
519
|
-
if (typeof a !== typeof b || !!a !== !!b) return false;
|
|
520
|
-
if (is.str(a) || is.num(a) || is.boo(a)) return a === b;
|
|
521
|
-
const isObj = is.obj(a);
|
|
522
|
-
if (isObj && objects === "reference") return a === b;
|
|
523
|
-
const isArr = is.arr(a);
|
|
524
|
-
if (isArr && arrays === "reference") return a === b;
|
|
525
|
-
if ((isArr || isObj) && a === b) return true;
|
|
526
|
-
let i;
|
|
527
|
-
for (i in a) if (!(i in b)) return false;
|
|
528
|
-
if (isObj && arrays === "shallow" && objects === "shallow") {
|
|
529
|
-
for (i in strict ? b : a) if (!is.equ(a[i], b[i], { strict, objects: "reference" })) return false;
|
|
530
|
-
} else {
|
|
531
|
-
for (i in strict ? b : a) if (a[i] !== b[i]) return false;
|
|
532
|
-
}
|
|
533
|
-
if (is.und(i)) {
|
|
534
|
-
if (isArr && a.length === 0 && b.length === 0) return true;
|
|
535
|
-
if (isObj && Object.keys(a).length === 0 && Object.keys(b).length === 0) return true;
|
|
536
|
-
if (a !== b) return false;
|
|
537
|
-
}
|
|
538
|
-
return true;
|
|
539
|
-
}
|
|
540
|
-
};
|
|
541
|
-
const isOrthographicCamera = (def) => def && def.isOrthographicCamera;
|
|
542
|
-
const isRef = (obj) => obj !== null && typeof obj === "object" && obj.hasOwnProperty("current");
|
|
543
|
-
const isColorRepresentation = (value) => value != null && (typeof value === "string" || typeof value === "number" || value.isColor);
|
|
544
|
-
const isObject3D = (object) => object?.isObject3D;
|
|
545
|
-
const isTexture = (value) => !!value?.isTexture;
|
|
546
|
-
const isVectorLike = (object) => object !== null && typeof object === "object" && "set" in object && typeof object.set === "function";
|
|
547
|
-
const isCopyable = (object) => isVectorLike(object) && "copy" in object && typeof object.copy === "function";
|
|
548
|
-
const hasConstructor = (object) => !!object?.constructor;
|
|
549
|
-
|
|
550
|
-
function calculateDpr(dpr) {
|
|
551
|
-
const target = typeof window !== "undefined" ? window.devicePixelRatio ?? 2 : 1;
|
|
552
|
-
return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
|
|
553
|
-
}
|
|
554
|
-
function getUuidPrefix(uuid) {
|
|
555
|
-
return uuid.split("-")[0];
|
|
556
|
-
}
|
|
557
|
-
function updateCamera(camera, size) {
|
|
558
|
-
if (camera.manual) return;
|
|
559
|
-
if (isOrthographicCamera(camera)) {
|
|
560
|
-
camera.left = size.width / -2;
|
|
561
|
-
camera.right = size.width / 2;
|
|
562
|
-
camera.top = size.height / 2;
|
|
563
|
-
camera.bottom = size.height / -2;
|
|
564
|
-
} else {
|
|
565
|
-
camera.aspect = size.width / size.height;
|
|
566
|
-
}
|
|
567
|
-
camera.updateProjectionMatrix();
|
|
568
|
-
}
|
|
569
|
-
const frustumMatrix = new webgpu.Matrix4();
|
|
570
|
-
function updateFrustum(camera, frustum) {
|
|
571
|
-
const target = frustum ?? new webgpu.Frustum();
|
|
572
|
-
frustumMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
573
|
-
target.setFromProjectionMatrix(frustumMatrix);
|
|
574
|
-
return target;
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
const REACT_INTERNAL_PROPS = ["children", "key", "ref"];
|
|
578
|
-
function findInitialRoot(instance) {
|
|
579
|
-
let root = instance.root;
|
|
580
|
-
while (root.getState().previousRoot) root = root.getState().previousRoot;
|
|
581
|
-
return root;
|
|
582
|
-
}
|
|
583
|
-
function getRootState(obj) {
|
|
584
|
-
let state = obj.__r3f?.root.getState();
|
|
585
|
-
if (!state) {
|
|
586
|
-
obj.traverseAncestors((ancestor) => {
|
|
587
|
-
const parentState = ancestor.__r3f?.root.getState();
|
|
588
|
-
if (parentState) {
|
|
589
|
-
state = parentState;
|
|
590
|
-
return false;
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
}
|
|
594
|
-
return state;
|
|
595
|
-
}
|
|
596
|
-
function buildGraph(object) {
|
|
597
|
-
const data = { nodes: {}, materials: {}, meshes: {} };
|
|
598
|
-
if (object) {
|
|
599
|
-
object.traverse((obj) => {
|
|
600
|
-
if (obj.name) data.nodes[obj.name] = obj;
|
|
601
|
-
if (obj.material) {
|
|
602
|
-
const material = Array.isArray(obj.material) ? obj.material[0] : obj.material;
|
|
603
|
-
const nameAlreadyUsed = data.materials[material.name];
|
|
604
|
-
let materialName = material.name;
|
|
605
|
-
if (nameAlreadyUsed) {
|
|
606
|
-
materialName = materialName + `-${getUuidPrefix(material.uuid)}`;
|
|
607
|
-
material.userData.materialCacheName = materialName;
|
|
608
|
-
}
|
|
609
|
-
data.materials[materialName] = material;
|
|
610
|
-
}
|
|
611
|
-
if (obj.isMesh && !data.meshes[obj.name]) data.meshes[obj.name] = obj;
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
|
-
return data;
|
|
615
|
-
}
|
|
616
|
-
function dispose(obj) {
|
|
617
|
-
if (obj.type !== "Scene") obj.dispose?.();
|
|
618
|
-
for (const p in obj) {
|
|
619
|
-
const prop = obj[p];
|
|
620
|
-
if (prop?.type !== "Scene") prop?.dispose?.();
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
function getInstanceProps(pendingProps) {
|
|
624
|
-
const props = {};
|
|
625
|
-
for (const key in pendingProps) {
|
|
626
|
-
if (!REACT_INTERNAL_PROPS.includes(key)) props[key] = pendingProps[key];
|
|
627
|
-
}
|
|
628
|
-
return props;
|
|
629
|
-
}
|
|
630
|
-
function prepare(target, root, type, props) {
|
|
631
|
-
const object = target;
|
|
632
|
-
let instance = object?.__r3f;
|
|
633
|
-
if (!instance) {
|
|
634
|
-
instance = {
|
|
635
|
-
root,
|
|
636
|
-
type,
|
|
637
|
-
parent: null,
|
|
638
|
-
children: [],
|
|
639
|
-
props: getInstanceProps(props),
|
|
640
|
-
object,
|
|
641
|
-
eventCount: 0,
|
|
642
|
-
handlers: {},
|
|
643
|
-
isHidden: false
|
|
644
|
-
};
|
|
645
|
-
if (object) object.__r3f = instance;
|
|
646
|
-
}
|
|
647
|
-
return instance;
|
|
648
|
-
}
|
|
649
|
-
function invalidateInstance(instance) {
|
|
650
|
-
if (!instance.parent) return;
|
|
651
|
-
instance.props.onUpdate?.(instance.object);
|
|
652
|
-
const state = instance.root?.getState?.();
|
|
653
|
-
if (state && state.internal.frames === 0) state.invalidate();
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
const tempFrustum = new webgpu.Frustum();
|
|
657
|
-
let hasWarnedWebGL = false;
|
|
658
|
-
let tslModule = null;
|
|
659
|
-
async function loadTSL() {
|
|
660
|
-
if (tslModule) return tslModule;
|
|
661
|
-
try {
|
|
662
|
-
const tsl = await import('three/tsl');
|
|
663
|
-
tslModule = { uniform: tsl.uniform, nodeObject: tsl.nodeObject };
|
|
664
|
-
return tslModule;
|
|
665
|
-
} catch {
|
|
666
|
-
return null;
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
function createOcclusionObserverNode(store, uniform) {
|
|
670
|
-
const node = new webgpu.Node("float");
|
|
671
|
-
node.updateType = webgpu.NodeUpdateType.OBJECT;
|
|
672
|
-
node.update = function(frame) {
|
|
673
|
-
const { internal } = store.getState();
|
|
674
|
-
const registry = internal.visibilityRegistry;
|
|
675
|
-
const cache = internal.occlusionCache;
|
|
676
|
-
for (const entry of registry.values()) {
|
|
677
|
-
const { object, handlers } = entry;
|
|
678
|
-
if (handlers.onOccluded || handlers.onVisible) {
|
|
679
|
-
const isOccluded = frame.renderer.isOccluded(object);
|
|
680
|
-
cache.set(object, isOccluded);
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
};
|
|
684
|
-
node.setup = function() {
|
|
685
|
-
return uniform(0);
|
|
686
|
-
};
|
|
687
|
-
return node;
|
|
341
|
+
function createOcclusionObserverNode(store, uniform) {
|
|
342
|
+
const node = new webgpu.Node("float");
|
|
343
|
+
node.updateType = webgpu.NodeUpdateType.OBJECT;
|
|
344
|
+
node.update = function(frame) {
|
|
345
|
+
const { internal } = store.getState();
|
|
346
|
+
const registry = internal.visibilityRegistry;
|
|
347
|
+
const cache = internal.occlusionCache;
|
|
348
|
+
for (const entry of registry.values()) {
|
|
349
|
+
const { object, handlers } = entry;
|
|
350
|
+
if (handlers.onOccluded || handlers.onVisible) {
|
|
351
|
+
const isOccluded = frame.renderer.isOccluded(object);
|
|
352
|
+
cache.set(object, isOccluded);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
node.setup = function() {
|
|
357
|
+
return uniform(0);
|
|
358
|
+
};
|
|
359
|
+
return node;
|
|
688
360
|
}
|
|
689
361
|
let occlusionSetupPromise = null;
|
|
690
362
|
function enableOcclusion(store) {
|
|
@@ -968,9 +640,9 @@ function diffProps(instance, newProps) {
|
|
|
968
640
|
const { root, key } = resolve(instance.object, prop);
|
|
969
641
|
if (root.constructor && root.constructor.length === 0) {
|
|
970
642
|
const ctor = getMemoizedPrototype(root);
|
|
971
|
-
if (!is.und(ctor)) changedProps[
|
|
643
|
+
if (!is.und(ctor)) changedProps[prop] = ctor[key];
|
|
972
644
|
} else {
|
|
973
|
-
changedProps[
|
|
645
|
+
changedProps[prop] = 0;
|
|
974
646
|
}
|
|
975
647
|
}
|
|
976
648
|
return changedProps;
|
|
@@ -1087,635 +759,90 @@ function applyProps(object, props) {
|
|
|
1087
759
|
return object;
|
|
1088
760
|
}
|
|
1089
761
|
|
|
1090
|
-
const
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
if (!state) {
|
|
1095
|
-
state = {
|
|
1096
|
-
hovered: /* @__PURE__ */ new Map(),
|
|
1097
|
-
captured: /* @__PURE__ */ new Map(),
|
|
1098
|
-
initialClick: [0, 0],
|
|
1099
|
-
initialHits: []
|
|
1100
|
-
};
|
|
1101
|
-
internal.pointerMap.set(pointerId, state);
|
|
762
|
+
const shownNotices = /* @__PURE__ */ new Set();
|
|
763
|
+
function notifyDepreciated({ heading, body, link }) {
|
|
764
|
+
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_DEPRECATION_WARNINGS !== "true") {
|
|
765
|
+
return;
|
|
1102
766
|
}
|
|
1103
|
-
return
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
function makeId(event) {
|
|
1109
|
-
return (event.eventObject || event.object).uuid + "/" + event.index + event.instanceId;
|
|
1110
|
-
}
|
|
1111
|
-
function releaseInternalPointerCapture(internal, obj, pointerId) {
|
|
1112
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1113
|
-
if (!pointerState) return;
|
|
1114
|
-
const captureData = pointerState.captured.get(obj);
|
|
1115
|
-
if (captureData) {
|
|
1116
|
-
pointerState.captured.delete(obj);
|
|
1117
|
-
captureData.target.releasePointerCapture(pointerId);
|
|
767
|
+
if (shownNotices.has(heading)) return;
|
|
768
|
+
shownNotices.add(heading);
|
|
769
|
+
const caller = getCallerFrame();
|
|
770
|
+
if (caller) {
|
|
771
|
+
console.log();
|
|
1118
772
|
}
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
internal.interaction = internal.interaction.filter((o) => o !== object);
|
|
1123
|
-
for (const [pointerId, pointerState] of internal.pointerMap) {
|
|
1124
|
-
pointerState.initialHits = pointerState.initialHits.filter((o) => o !== object);
|
|
1125
|
-
pointerState.hovered.forEach((value, key) => {
|
|
1126
|
-
if (value.eventObject === object || value.object === object) {
|
|
1127
|
-
pointerState.hovered.delete(key);
|
|
1128
|
-
}
|
|
1129
|
-
});
|
|
1130
|
-
if (pointerState.captured.has(object)) {
|
|
1131
|
-
releaseInternalPointerCapture(internal, object, pointerId);
|
|
1132
|
-
}
|
|
773
|
+
const boxStyle = "background: #ff9800; color: #1a1a1a; padding: 8px 12px; border-radius: 4px; font-weight: 500;";
|
|
774
|
+
if (caller) {
|
|
775
|
+
console.log(`%c\u26A0\uFE0F ${heading}`, boxStyle);
|
|
1133
776
|
}
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1140
|
-
if (!pointerState) return 0;
|
|
1141
|
-
const [initialX, initialY] = pointerState.initialClick;
|
|
1142
|
-
const dx = event.offsetX - initialX;
|
|
1143
|
-
const dy = event.offsetY - initialY;
|
|
1144
|
-
return Math.round(Math.sqrt(dx * dx + dy * dy));
|
|
777
|
+
if (body || link) {
|
|
778
|
+
let message = "";
|
|
779
|
+
if (body) message += body;
|
|
780
|
+
if (link) message += (body ? "\n\n" : "") + `More info: ${link}`;
|
|
781
|
+
console.warn(`%c${message}`, "font-weight: bold;");
|
|
1145
782
|
}
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
783
|
+
}
|
|
784
|
+
function getCallerFrame(depth = 3) {
|
|
785
|
+
const stack = new Error().stack;
|
|
786
|
+
if (!stack) return null;
|
|
787
|
+
const lines = stack.split("\n");
|
|
788
|
+
const frame = lines[depth];
|
|
789
|
+
if (!frame) return null;
|
|
790
|
+
let match = frame.match(/^\s*at (?:(.+?) )?\(?(.+?):(\d+):(\d+)\)?$/);
|
|
791
|
+
if (!match) {
|
|
792
|
+
match = frame.match(/^(?:(.+?)@)?(.+?):(\d+):(\d+)$/);
|
|
1154
793
|
}
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
const state2 = getRootState(obj);
|
|
1171
|
-
if (!state2 || !state2.events.enabled || state2.raycaster.camera === null) return [];
|
|
1172
|
-
if (state2.raycaster.camera === void 0) {
|
|
1173
|
-
state2.events.compute?.(event, state2, state2.previousRoot?.getState());
|
|
1174
|
-
if (state2.raycaster.camera === void 0) state2.raycaster.camera = null;
|
|
1175
|
-
}
|
|
1176
|
-
return state2.raycaster.camera ? state2.raycaster.intersectObject(obj, true) : [];
|
|
1177
|
-
}
|
|
1178
|
-
let hits = eventsObjects.flatMap(handleRaycast).sort((a, b) => {
|
|
1179
|
-
const aInteractivePriority = a.object.userData?.interactivePriority;
|
|
1180
|
-
const bInteractivePriority = b.object.userData?.interactivePriority;
|
|
1181
|
-
if (aInteractivePriority !== void 0 || bInteractivePriority !== void 0) {
|
|
1182
|
-
if (aInteractivePriority !== void 0 && bInteractivePriority === void 0) return -1;
|
|
1183
|
-
if (bInteractivePriority !== void 0 && aInteractivePriority === void 0) return 1;
|
|
1184
|
-
if (aInteractivePriority !== bInteractivePriority) {
|
|
1185
|
-
return (bInteractivePriority ?? 0) - (aInteractivePriority ?? 0);
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
const aState = getRootState(a.object);
|
|
1189
|
-
const bState = getRootState(b.object);
|
|
1190
|
-
const aPriority = aState?.events?.priority ?? 1;
|
|
1191
|
-
const bPriority = bState?.events?.priority ?? 1;
|
|
1192
|
-
return bPriority - aPriority || a.distance - b.distance;
|
|
1193
|
-
}).filter((item) => {
|
|
1194
|
-
const id = makeId(item);
|
|
1195
|
-
if (duplicates.has(id)) return false;
|
|
1196
|
-
duplicates.add(id);
|
|
1197
|
-
return true;
|
|
1198
|
-
});
|
|
1199
|
-
if (state.events.filter) hits = state.events.filter(hits, state);
|
|
1200
|
-
for (const hit of hits) {
|
|
1201
|
-
let eventObject = hit.object;
|
|
1202
|
-
while (eventObject) {
|
|
1203
|
-
if (eventObject.__r3f?.eventCount) {
|
|
1204
|
-
intersections.push({ ...hit, eventObject });
|
|
1205
|
-
}
|
|
1206
|
-
eventObject = eventObject.parent;
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
if ("pointerId" in event) {
|
|
1210
|
-
const pointerId = event.pointerId;
|
|
1211
|
-
const pointerState = state.internal.pointerMap.get(pointerId);
|
|
1212
|
-
if (pointerState?.captured.size) {
|
|
1213
|
-
for (const captureData of pointerState.captured.values()) {
|
|
1214
|
-
if (!duplicates.has(makeId(captureData.intersection))) intersections.push(captureData.intersection);
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
}
|
|
1218
|
-
return intersections;
|
|
794
|
+
if (!match) return null;
|
|
795
|
+
const [, fn, url, line] = match;
|
|
796
|
+
return {
|
|
797
|
+
functionName: fn ?? "<anonymous>",
|
|
798
|
+
location: formatLocation(url, Number(line))
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
function formatLocation(url, line) {
|
|
802
|
+
const clean = url.split("?")[0];
|
|
803
|
+
const file = clean.split("/").pop() ?? clean;
|
|
804
|
+
return `${file}:${line}`;
|
|
805
|
+
}
|
|
806
|
+
function notifyAlpha({ message, link }) {
|
|
807
|
+
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_ALPHA_WARNINGS !== "true") {
|
|
808
|
+
return;
|
|
1219
809
|
}
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
const { raycaster, pointer, camera, internal } = state;
|
|
1227
|
-
const unprojectedPoint = new webgpu.Vector3(pointer.x, pointer.y, 0).unproject(camera);
|
|
1228
|
-
const hasPointerCapture = (id) => {
|
|
1229
|
-
const pointerState = internal.pointerMap.get(id);
|
|
1230
|
-
return pointerState?.captured.has(hit.eventObject) ?? false;
|
|
1231
|
-
};
|
|
1232
|
-
const setPointerCapture = (id) => {
|
|
1233
|
-
const captureData = { intersection: hit, target: event.target };
|
|
1234
|
-
const pointerState = getPointerState(internal, id);
|
|
1235
|
-
pointerState.captured.set(hit.eventObject, captureData);
|
|
1236
|
-
event.target.setPointerCapture(id);
|
|
1237
|
-
};
|
|
1238
|
-
const releasePointerCapture = (id) => {
|
|
1239
|
-
releaseInternalPointerCapture(internal, hit.eventObject, id);
|
|
1240
|
-
};
|
|
1241
|
-
const extractEventProps = {};
|
|
1242
|
-
for (const prop in event) {
|
|
1243
|
-
const property = event[prop];
|
|
1244
|
-
if (typeof property !== "function") extractEventProps[prop] = property;
|
|
1245
|
-
}
|
|
1246
|
-
const eventPointerId = "pointerId" in event ? event.pointerId : void 0;
|
|
1247
|
-
const raycastEvent = {
|
|
1248
|
-
...hit,
|
|
1249
|
-
...extractEventProps,
|
|
1250
|
-
pointer,
|
|
1251
|
-
intersections,
|
|
1252
|
-
stopped: localState.stopped,
|
|
1253
|
-
delta,
|
|
1254
|
-
unprojectedPoint,
|
|
1255
|
-
ray: raycaster.ray,
|
|
1256
|
-
camera,
|
|
1257
|
-
pointerId: eventPointerId,
|
|
1258
|
-
// Hijack stopPropagation, which just sets a flag
|
|
1259
|
-
stopPropagation() {
|
|
1260
|
-
const pointerState = eventPointerId !== void 0 ? internal.pointerMap.get(eventPointerId) : void 0;
|
|
1261
|
-
if (
|
|
1262
|
-
// ...if this pointer hasn't been captured
|
|
1263
|
-
!pointerState?.captured.size || // ... or if the hit object is capturing the pointer
|
|
1264
|
-
pointerState.captured.has(hit.eventObject)
|
|
1265
|
-
) {
|
|
1266
|
-
raycastEvent.stopped = localState.stopped = true;
|
|
1267
|
-
if (pointerState?.hovered.size && Array.from(pointerState.hovered.values()).find((i) => i.eventObject === hit.eventObject)) {
|
|
1268
|
-
const higher = intersections.slice(0, intersections.indexOf(hit));
|
|
1269
|
-
cancelPointer([...higher, hit], eventPointerId);
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
},
|
|
1273
|
-
// there should be a distinction between target and currentTarget
|
|
1274
|
-
target: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
1275
|
-
currentTarget: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
1276
|
-
nativeEvent: event
|
|
1277
|
-
};
|
|
1278
|
-
callback(raycastEvent);
|
|
1279
|
-
if (localState.stopped === true) break;
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1283
|
-
return intersections;
|
|
810
|
+
if (shownNotices.has(message)) return;
|
|
811
|
+
shownNotices.add(message);
|
|
812
|
+
const boxStyle = "background: #6366f1; color: #ffffff; padding: 6px 10px; border-radius: 4px; font-weight: 500;";
|
|
813
|
+
console.log(`%c\u{1F52C} ${message}`, boxStyle);
|
|
814
|
+
{
|
|
815
|
+
console.log(`%cMore info: ${link}`, "color: #6366f1; font-weight: normal;");
|
|
1284
816
|
}
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
for (let i = 0; i < objects.length; i++) {
|
|
1315
|
-
const instance = objects[i].__r3f;
|
|
1316
|
-
instance?.handlers.onDragOverMissed?.(event);
|
|
1317
|
-
}
|
|
1318
|
-
}
|
|
1319
|
-
function dropMissed(event, objects) {
|
|
1320
|
-
for (let i = 0; i < objects.length; i++) {
|
|
1321
|
-
const instance = objects[i].__r3f;
|
|
1322
|
-
instance?.handlers.onDropMissed?.(event);
|
|
1323
|
-
}
|
|
1324
|
-
}
|
|
1325
|
-
function cleanupPointer(pointerId) {
|
|
1326
|
-
const { internal } = store.getState();
|
|
1327
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1328
|
-
if (pointerState) {
|
|
1329
|
-
for (const [, hoveredObj] of pointerState.hovered) {
|
|
1330
|
-
const eventObject = hoveredObj.eventObject;
|
|
1331
|
-
const instance = eventObject.__r3f;
|
|
1332
|
-
if (instance?.eventCount) {
|
|
1333
|
-
const handlers = instance.handlers;
|
|
1334
|
-
const data = { ...hoveredObj, intersections: [] };
|
|
1335
|
-
handlers.onPointerOut?.(data);
|
|
1336
|
-
handlers.onPointerLeave?.(data);
|
|
1337
|
-
}
|
|
1338
|
-
}
|
|
1339
|
-
internal.pointerMap.delete(pointerId);
|
|
1340
|
-
}
|
|
1341
|
-
internal.pointerDirty.delete(pointerId);
|
|
1342
|
-
}
|
|
1343
|
-
function processDeferredPointer(event, pointerId) {
|
|
1344
|
-
const state = store.getState();
|
|
1345
|
-
const { internal } = state;
|
|
1346
|
-
if (!state.events.enabled) return;
|
|
1347
|
-
const filter = filterPointerEvents;
|
|
1348
|
-
const hits = intersect(event, filter);
|
|
1349
|
-
cancelPointer(hits, pointerId);
|
|
1350
|
-
function onIntersect(data) {
|
|
1351
|
-
const eventObject = data.eventObject;
|
|
1352
|
-
const instance = eventObject.__r3f;
|
|
1353
|
-
if (!instance?.eventCount) return;
|
|
1354
|
-
const handlers = instance.handlers;
|
|
1355
|
-
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
1356
|
-
const id = makeId(data);
|
|
1357
|
-
const pointerState = getPointerState(internal, pointerId);
|
|
1358
|
-
const hoveredItem = pointerState.hovered.get(id);
|
|
1359
|
-
if (!hoveredItem) {
|
|
1360
|
-
pointerState.hovered.set(id, data);
|
|
1361
|
-
handlers.onPointerOver?.(data);
|
|
1362
|
-
handlers.onPointerEnter?.(data);
|
|
1363
|
-
} else if (hoveredItem.stopped) {
|
|
1364
|
-
data.stopPropagation();
|
|
1365
|
-
}
|
|
1366
|
-
}
|
|
1367
|
-
handlers.onPointerMove?.(data);
|
|
1368
|
-
}
|
|
1369
|
-
handleIntersects(hits, event, 0, onIntersect);
|
|
1370
|
-
}
|
|
1371
|
-
function handlePointer(name) {
|
|
1372
|
-
switch (name) {
|
|
1373
|
-
case "onPointerLeave":
|
|
1374
|
-
case "onDragLeave":
|
|
1375
|
-
return () => cancelPointer([]);
|
|
1376
|
-
// Global cancel of these events
|
|
1377
|
-
case "onPointerCancel":
|
|
1378
|
-
return (event) => {
|
|
1379
|
-
const pointerId = getPointerId(event);
|
|
1380
|
-
cleanupPointer(pointerId);
|
|
1381
|
-
};
|
|
1382
|
-
case "onLostPointerCapture":
|
|
1383
|
-
return (event) => {
|
|
1384
|
-
const { internal } = store.getState();
|
|
1385
|
-
const pointerId = getPointerId(event);
|
|
1386
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1387
|
-
if (pointerState?.captured.size) {
|
|
1388
|
-
requestAnimationFrame(() => {
|
|
1389
|
-
const pointerState2 = internal.pointerMap.get(pointerId);
|
|
1390
|
-
if (pointerState2?.captured.size) {
|
|
1391
|
-
pointerState2.captured.clear();
|
|
1392
|
-
}
|
|
1393
|
-
cancelPointer([], pointerId);
|
|
1394
|
-
});
|
|
1395
|
-
}
|
|
1396
|
-
};
|
|
1397
|
-
}
|
|
1398
|
-
return function handleEvent(event) {
|
|
1399
|
-
const state = store.getState();
|
|
1400
|
-
const { onPointerMissed, onDragOverMissed, onDropMissed, internal, events } = state;
|
|
1401
|
-
const pointerId = getPointerId(event);
|
|
1402
|
-
internal.lastEvent.current = event;
|
|
1403
|
-
if (!events.enabled) return;
|
|
1404
|
-
const isPointerMove = name === "onPointerMove";
|
|
1405
|
-
const isDragOver = name === "onDragOver";
|
|
1406
|
-
const isDrop = name === "onDrop";
|
|
1407
|
-
const isClickEvent = name === "onClick" || name === "onContextMenu" || name === "onDoubleClick";
|
|
1408
|
-
const isPointerDown = name === "onPointerDown";
|
|
1409
|
-
const isPointerUp = name === "onPointerUp";
|
|
1410
|
-
const isWheel = name === "onWheel";
|
|
1411
|
-
const canDeferRaycasts = events.frameTimedRaycasts && state.frameloop === "always";
|
|
1412
|
-
if (isPointerMove && canDeferRaycasts) {
|
|
1413
|
-
events.compute?.(event, state);
|
|
1414
|
-
internal.pointerDirty.set(pointerId, event);
|
|
1415
|
-
return;
|
|
1416
|
-
}
|
|
1417
|
-
if (isWheel && canDeferRaycasts && !events.alwaysFireOnScroll) {
|
|
1418
|
-
events.compute?.(event, state);
|
|
1419
|
-
internal.pointerDirty.set(pointerId, event);
|
|
1420
|
-
return;
|
|
1421
|
-
}
|
|
1422
|
-
if ((isClickEvent || isPointerDown || isPointerUp) && internal.pointerDirty.has(pointerId)) {
|
|
1423
|
-
const deferredEvent = internal.pointerDirty.get(pointerId);
|
|
1424
|
-
internal.pointerDirty.delete(pointerId);
|
|
1425
|
-
processDeferredPointer(deferredEvent, pointerId);
|
|
1426
|
-
}
|
|
1427
|
-
const filter = isPointerMove || isDragOver || isDrop ? filterPointerEvents : void 0;
|
|
1428
|
-
const hits = intersect(event, filter);
|
|
1429
|
-
const delta = isClickEvent ? calculateDistance(event, pointerId) : 0;
|
|
1430
|
-
if (isPointerDown) {
|
|
1431
|
-
const pointerState2 = getPointerState(internal, pointerId);
|
|
1432
|
-
pointerState2.initialClick = [event.offsetX, event.offsetY];
|
|
1433
|
-
pointerState2.initialHits = hits.map((hit) => hit.eventObject);
|
|
1434
|
-
}
|
|
1435
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1436
|
-
const initialHits = pointerState?.initialHits ?? [];
|
|
1437
|
-
if (isClickEvent && !hits.length) {
|
|
1438
|
-
if (delta <= 2) {
|
|
1439
|
-
pointerMissed(event, internal.interaction);
|
|
1440
|
-
if (onPointerMissed) onPointerMissed(event);
|
|
1441
|
-
}
|
|
1442
|
-
}
|
|
1443
|
-
if (isDragOver && !hits.length) {
|
|
1444
|
-
dragOverMissed(event, internal.interaction);
|
|
1445
|
-
if (onDragOverMissed) onDragOverMissed(event);
|
|
1446
|
-
}
|
|
1447
|
-
if (isDrop && !hits.length) {
|
|
1448
|
-
dropMissed(event, internal.interaction);
|
|
1449
|
-
if (onDropMissed) onDropMissed(event);
|
|
1450
|
-
}
|
|
1451
|
-
if (isPointerMove || isDragOver) {
|
|
1452
|
-
cancelPointer(hits, pointerId);
|
|
1453
|
-
}
|
|
1454
|
-
function onIntersect(data) {
|
|
1455
|
-
const eventObject = data.eventObject;
|
|
1456
|
-
const instance = eventObject.__r3f;
|
|
1457
|
-
if (!instance?.eventCount) return;
|
|
1458
|
-
const handlers = instance.handlers;
|
|
1459
|
-
if (isPointerMove) {
|
|
1460
|
-
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
1461
|
-
const id = makeId(data);
|
|
1462
|
-
const pointerState2 = getPointerState(internal, pointerId);
|
|
1463
|
-
const hoveredItem = pointerState2.hovered.get(id);
|
|
1464
|
-
if (!hoveredItem) {
|
|
1465
|
-
pointerState2.hovered.set(id, data);
|
|
1466
|
-
handlers.onPointerOver?.(data);
|
|
1467
|
-
handlers.onPointerEnter?.(data);
|
|
1468
|
-
} else if (hoveredItem.stopped) {
|
|
1469
|
-
data.stopPropagation();
|
|
1470
|
-
}
|
|
1471
|
-
}
|
|
1472
|
-
handlers.onPointerMove?.(data);
|
|
1473
|
-
} else if (isDragOver) {
|
|
1474
|
-
const id = makeId(data);
|
|
1475
|
-
const pointerState2 = getPointerState(internal, pointerId);
|
|
1476
|
-
const hoveredItem = pointerState2.hovered.get(id);
|
|
1477
|
-
if (!hoveredItem) {
|
|
1478
|
-
pointerState2.hovered.set(id, data);
|
|
1479
|
-
handlers.onDragOverEnter?.(data);
|
|
1480
|
-
} else if (hoveredItem.stopped) {
|
|
1481
|
-
data.stopPropagation();
|
|
1482
|
-
}
|
|
1483
|
-
handlers.onDragOver?.(data);
|
|
1484
|
-
} else if (isDrop) {
|
|
1485
|
-
handlers.onDrop?.(data);
|
|
1486
|
-
} else {
|
|
1487
|
-
const handler = handlers[name];
|
|
1488
|
-
if (handler) {
|
|
1489
|
-
if (!isClickEvent || initialHits.includes(eventObject)) {
|
|
1490
|
-
pointerMissed(
|
|
1491
|
-
event,
|
|
1492
|
-
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
1493
|
-
);
|
|
1494
|
-
handler(data);
|
|
1495
|
-
}
|
|
1496
|
-
} else {
|
|
1497
|
-
if (isClickEvent && initialHits.includes(eventObject)) {
|
|
1498
|
-
pointerMissed(
|
|
1499
|
-
event,
|
|
1500
|
-
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
1501
|
-
);
|
|
1502
|
-
}
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
}
|
|
1506
|
-
handleIntersects(hits, event, delta, onIntersect);
|
|
1507
|
-
};
|
|
1508
|
-
}
|
|
1509
|
-
function flushDeferredPointers() {
|
|
1510
|
-
const { internal, events } = store.getState();
|
|
1511
|
-
if (!events.frameTimedRaycasts) return;
|
|
1512
|
-
for (const [pointerId, event] of internal.pointerDirty) {
|
|
1513
|
-
processDeferredPointer(event, pointerId);
|
|
1514
|
-
}
|
|
1515
|
-
internal.pointerDirty.clear();
|
|
1516
|
-
}
|
|
1517
|
-
return { handlePointer, flushDeferredPointers, processDeferredPointer };
|
|
1518
|
-
}
|
|
1519
|
-
const DOM_EVENTS = {
|
|
1520
|
-
onClick: ["click", false],
|
|
1521
|
-
onContextMenu: ["contextmenu", false],
|
|
1522
|
-
onDoubleClick: ["dblclick", false],
|
|
1523
|
-
onDragEnter: ["dragenter", false],
|
|
1524
|
-
onDragLeave: ["dragleave", false],
|
|
1525
|
-
onDragOver: ["dragover", false],
|
|
1526
|
-
onDrop: ["drop", false],
|
|
1527
|
-
onWheel: ["wheel", true],
|
|
1528
|
-
onPointerDown: ["pointerdown", true],
|
|
1529
|
-
onPointerUp: ["pointerup", true],
|
|
1530
|
-
onPointerLeave: ["pointerleave", true],
|
|
1531
|
-
onPointerMove: ["pointermove", true],
|
|
1532
|
-
onPointerCancel: ["pointercancel", true],
|
|
1533
|
-
onLostPointerCapture: ["lostpointercapture", true]
|
|
1534
|
-
};
|
|
1535
|
-
function createPointerEvents(store) {
|
|
1536
|
-
const { handlePointer, flushDeferredPointers, processDeferredPointer } = createEvents(store);
|
|
1537
|
-
let nextXRPointerId = XR_POINTER_ID_START;
|
|
1538
|
-
const xrPointers = /* @__PURE__ */ new Map();
|
|
1539
|
-
return {
|
|
1540
|
-
priority: 1,
|
|
1541
|
-
enabled: true,
|
|
1542
|
-
frameTimedRaycasts: true,
|
|
1543
|
-
alwaysFireOnScroll: true,
|
|
1544
|
-
updateOnFrame: false,
|
|
1545
|
-
compute(event, state) {
|
|
1546
|
-
state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
|
|
1547
|
-
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
1548
|
-
},
|
|
1549
|
-
connected: void 0,
|
|
1550
|
-
handlers: Object.keys(DOM_EVENTS).reduce(
|
|
1551
|
-
(acc, key) => ({ ...acc, [key]: handlePointer(key) }),
|
|
1552
|
-
{}
|
|
1553
|
-
),
|
|
1554
|
-
update: (pointerId) => {
|
|
1555
|
-
const { events, internal } = store.getState();
|
|
1556
|
-
if (!events.handlers) return;
|
|
1557
|
-
if (pointerId !== void 0) {
|
|
1558
|
-
const event = internal.pointerDirty.get(pointerId);
|
|
1559
|
-
if (event) {
|
|
1560
|
-
internal.pointerDirty.delete(pointerId);
|
|
1561
|
-
processDeferredPointer(event, pointerId);
|
|
1562
|
-
} else if (internal.lastEvent?.current) {
|
|
1563
|
-
processDeferredPointer(internal.lastEvent.current, pointerId);
|
|
1564
|
-
}
|
|
1565
|
-
} else {
|
|
1566
|
-
flushDeferredPointers();
|
|
1567
|
-
if (internal.lastEvent?.current) {
|
|
1568
|
-
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1571
|
-
},
|
|
1572
|
-
flush: () => {
|
|
1573
|
-
const { events, internal } = store.getState();
|
|
1574
|
-
flushDeferredPointers();
|
|
1575
|
-
if (events.updateOnFrame && internal.lastEvent?.current && events.handlers) {
|
|
1576
|
-
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
1577
|
-
}
|
|
1578
|
-
},
|
|
1579
|
-
connect: (target) => {
|
|
1580
|
-
if (!target) return;
|
|
1581
|
-
const { set, events } = store.getState();
|
|
1582
|
-
events.disconnect?.();
|
|
1583
|
-
set((state) => ({ events: { ...state.events, connected: target } }));
|
|
1584
|
-
if (events.handlers) {
|
|
1585
|
-
for (const name in events.handlers) {
|
|
1586
|
-
const event = events.handlers[name];
|
|
1587
|
-
const [eventName, passive] = DOM_EVENTS[name];
|
|
1588
|
-
target.addEventListener(eventName, event, { passive });
|
|
1589
|
-
}
|
|
1590
|
-
}
|
|
1591
|
-
},
|
|
1592
|
-
disconnect: () => {
|
|
1593
|
-
const { set, events } = store.getState();
|
|
1594
|
-
if (events.connected) {
|
|
1595
|
-
if (events.handlers) {
|
|
1596
|
-
for (const name in events.handlers) {
|
|
1597
|
-
const event = events.handlers[name];
|
|
1598
|
-
const [eventName] = DOM_EVENTS[name];
|
|
1599
|
-
events.connected.removeEventListener(eventName, event);
|
|
1600
|
-
}
|
|
1601
|
-
}
|
|
1602
|
-
set((state) => ({ events: { ...state.events, connected: void 0 } }));
|
|
1603
|
-
}
|
|
1604
|
-
},
|
|
1605
|
-
// PREVIEW (A8): the XR pointer registration API may change before stable.
|
|
1606
|
-
registerPointer: (config) => {
|
|
1607
|
-
const pointerId = nextXRPointerId++;
|
|
1608
|
-
xrPointers.set(pointerId, config);
|
|
1609
|
-
const { internal } = store.getState();
|
|
1610
|
-
getPointerState(internal, pointerId);
|
|
1611
|
-
return pointerId;
|
|
1612
|
-
},
|
|
1613
|
-
unregisterPointer: (pointerId) => {
|
|
1614
|
-
xrPointers.delete(pointerId);
|
|
1615
|
-
const { internal } = store.getState();
|
|
1616
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1617
|
-
if (pointerState) {
|
|
1618
|
-
for (const [, hoveredObj] of pointerState.hovered) {
|
|
1619
|
-
const eventObject = hoveredObj.eventObject;
|
|
1620
|
-
const instance = eventObject.__r3f;
|
|
1621
|
-
if (instance?.eventCount) {
|
|
1622
|
-
const handlers = instance.handlers;
|
|
1623
|
-
const data = { ...hoveredObj, intersections: [] };
|
|
1624
|
-
handlers.onPointerOut?.(data);
|
|
1625
|
-
handlers.onPointerLeave?.(data);
|
|
1626
|
-
}
|
|
1627
|
-
}
|
|
1628
|
-
internal.pointerMap.delete(pointerId);
|
|
1629
|
-
}
|
|
1630
|
-
internal.pointerDirty.delete(pointerId);
|
|
1631
|
-
}
|
|
1632
|
-
};
|
|
1633
|
-
}
|
|
1634
|
-
|
|
1635
|
-
const shownNotices = /* @__PURE__ */ new Set();
|
|
1636
|
-
function notifyDepreciated({ heading, body, link }) {
|
|
1637
|
-
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_DEPRECATION_WARNINGS !== "true") {
|
|
1638
|
-
return;
|
|
1639
|
-
}
|
|
1640
|
-
if (shownNotices.has(heading)) return;
|
|
1641
|
-
shownNotices.add(heading);
|
|
1642
|
-
const caller = getCallerFrame();
|
|
1643
|
-
if (caller) {
|
|
1644
|
-
console.log();
|
|
1645
|
-
}
|
|
1646
|
-
const boxStyle = "background: #ff9800; color: #1a1a1a; padding: 8px 12px; border-radius: 4px; font-weight: 500;";
|
|
1647
|
-
if (caller) {
|
|
1648
|
-
console.log(`%c\u26A0\uFE0F ${heading}`, boxStyle);
|
|
1649
|
-
}
|
|
1650
|
-
if (body || link) {
|
|
1651
|
-
let message = "";
|
|
1652
|
-
if (body) message += body;
|
|
1653
|
-
if (link) message += (body ? "\n\n" : "") + `More info: ${link}`;
|
|
1654
|
-
console.warn(`%c${message}`, "font-weight: bold;");
|
|
1655
|
-
}
|
|
1656
|
-
}
|
|
1657
|
-
function getCallerFrame(depth = 3) {
|
|
1658
|
-
const stack = new Error().stack;
|
|
1659
|
-
if (!stack) return null;
|
|
1660
|
-
const lines = stack.split("\n");
|
|
1661
|
-
const frame = lines[depth];
|
|
1662
|
-
if (!frame) return null;
|
|
1663
|
-
let match = frame.match(/^\s*at (?:(.+?) )?\(?(.+?):(\d+):(\d+)\)?$/);
|
|
1664
|
-
if (!match) {
|
|
1665
|
-
match = frame.match(/^(?:(.+?)@)?(.+?):(\d+):(\d+)$/);
|
|
1666
|
-
}
|
|
1667
|
-
if (!match) return null;
|
|
1668
|
-
const [, fn, url, line] = match;
|
|
1669
|
-
return {
|
|
1670
|
-
functionName: fn ?? "<anonymous>",
|
|
1671
|
-
location: formatLocation(url, Number(line))
|
|
1672
|
-
};
|
|
1673
|
-
}
|
|
1674
|
-
function formatLocation(url, line) {
|
|
1675
|
-
const clean = url.split("?")[0];
|
|
1676
|
-
const file = clean.split("/").pop() ?? clean;
|
|
1677
|
-
return `${file}:${line}`;
|
|
1678
|
-
}
|
|
1679
|
-
function notifyAlpha({ message, link }) {
|
|
1680
|
-
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_ALPHA_WARNINGS !== "true") {
|
|
1681
|
-
return;
|
|
1682
|
-
}
|
|
1683
|
-
if (shownNotices.has(message)) return;
|
|
1684
|
-
shownNotices.add(message);
|
|
1685
|
-
const boxStyle = "background: #6366f1; color: #ffffff; padding: 6px 10px; border-radius: 4px; font-weight: 500;";
|
|
1686
|
-
console.log(`%c\u{1F52C} ${message}`, boxStyle);
|
|
1687
|
-
{
|
|
1688
|
-
console.log(`%cMore info: ${link}`, "color: #6366f1; font-weight: normal;");
|
|
1689
|
-
}
|
|
1690
|
-
}
|
|
1691
|
-
|
|
1692
|
-
const INTERNAL_LIB_MARKERS = ["zustand", "setState", "Object.assign"];
|
|
1693
|
-
function isInternalRendererAccess(stack, callerDepth = 2) {
|
|
1694
|
-
if (!stack) return false;
|
|
1695
|
-
const caller = stack.split("\n")[callerDepth] ?? "";
|
|
1696
|
-
return INTERNAL_LIB_MARKERS.some((m) => caller.includes(m));
|
|
1697
|
-
}
|
|
1698
|
-
|
|
1699
|
-
const R3F_CONTEXT = Symbol.for("@react-three/fiber.context");
|
|
1700
|
-
const context = globalThis[R3F_CONTEXT] ?? (globalThis[R3F_CONTEXT] = React__namespace.createContext(null));
|
|
1701
|
-
const createStore = (invalidate, advance) => {
|
|
1702
|
-
const rootStore = traditional.createWithEqualityFn((set, get) => {
|
|
1703
|
-
const position = new webgpu.Vector3();
|
|
1704
|
-
const defaultTarget = new webgpu.Vector3();
|
|
1705
|
-
const tempTarget = new webgpu.Vector3();
|
|
1706
|
-
function getCurrentViewport(camera = get().camera, target = defaultTarget, size = get().size) {
|
|
1707
|
-
const { width, height, top, left } = size;
|
|
1708
|
-
const aspect = width / height;
|
|
1709
|
-
if (target.isVector3) tempTarget.copy(target);
|
|
1710
|
-
else tempTarget.set(...target);
|
|
1711
|
-
const distance = camera.getWorldPosition(position).distanceTo(tempTarget);
|
|
1712
|
-
if (isOrthographicCamera(camera)) {
|
|
1713
|
-
return { width: width / camera.zoom, height: height / camera.zoom, top, left, factor: 1, distance, aspect };
|
|
1714
|
-
} else {
|
|
1715
|
-
const fov = camera.fov * Math.PI / 180;
|
|
1716
|
-
const h = 2 * Math.tan(fov / 2) * distance;
|
|
1717
|
-
const w = h * (width / height);
|
|
1718
|
-
return { width: w, height: h, top, left, factor: width / w, distance, aspect };
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
const INTERNAL_LIB_MARKERS = ["zustand", "setState", "Object.assign"];
|
|
820
|
+
function isInternalRendererAccess(stack, callerDepth = 2) {
|
|
821
|
+
if (!stack) return false;
|
|
822
|
+
const caller = stack.split("\n")[callerDepth] ?? "";
|
|
823
|
+
return INTERNAL_LIB_MARKERS.some((m) => caller.includes(m));
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
const R3F_CONTEXT = Symbol.for("@react-three/fiber.context");
|
|
827
|
+
const context = globalThis[R3F_CONTEXT] ?? (globalThis[R3F_CONTEXT] = React__namespace.createContext(null));
|
|
828
|
+
const createStore = (invalidate, advance) => {
|
|
829
|
+
const rootStore = traditional.createWithEqualityFn((set, get) => {
|
|
830
|
+
const position = new webgpu.Vector3();
|
|
831
|
+
const defaultTarget = new webgpu.Vector3();
|
|
832
|
+
const tempTarget = new webgpu.Vector3();
|
|
833
|
+
function getCurrentViewport(camera = get().camera, target = defaultTarget, size = get().size) {
|
|
834
|
+
const { width, height, top, left } = size;
|
|
835
|
+
const aspect = width / height;
|
|
836
|
+
if (target.isVector3) tempTarget.copy(target);
|
|
837
|
+
else tempTarget.set(...target);
|
|
838
|
+
const distance = camera.getWorldPosition(position).distanceTo(tempTarget);
|
|
839
|
+
if (isOrthographicCamera(camera)) {
|
|
840
|
+
return { width: width / camera.zoom, height: height / camera.zoom, top, left, factor: 1, distance, aspect };
|
|
841
|
+
} else {
|
|
842
|
+
const fov = camera.fov * Math.PI / 180;
|
|
843
|
+
const h = 2 * Math.tan(fov / 2) * distance;
|
|
844
|
+
const w = h * (width / height);
|
|
845
|
+
return { width: w, height: h, top, left, factor: width / w, distance, aspect };
|
|
1719
846
|
}
|
|
1720
847
|
}
|
|
1721
848
|
let performanceTimeout = void 0;
|
|
@@ -1975,7 +1102,7 @@ const createStore = (invalidate, advance) => {
|
|
|
1975
1102
|
|
|
1976
1103
|
const memoizedLoaders = /* @__PURE__ */ new WeakMap();
|
|
1977
1104
|
const isConstructor$1 = (value) => typeof value === "function" && value?.prototype?.constructor === value;
|
|
1978
|
-
function getLoader(Proto) {
|
|
1105
|
+
function getLoader$1(Proto) {
|
|
1979
1106
|
if (isConstructor$1(Proto)) {
|
|
1980
1107
|
let loader = memoizedLoaders.get(Proto);
|
|
1981
1108
|
if (!loader) {
|
|
@@ -1988,7 +1115,7 @@ function getLoader(Proto) {
|
|
|
1988
1115
|
}
|
|
1989
1116
|
function loadingFn(extensions, onProgress) {
|
|
1990
1117
|
return function(Proto, input) {
|
|
1991
|
-
const loader = getLoader(Proto);
|
|
1118
|
+
const loader = getLoader$1(Proto);
|
|
1992
1119
|
if (extensions) extensions(loader);
|
|
1993
1120
|
if ("loadAsync" in loader && typeof loader.loadAsync === "function") {
|
|
1994
1121
|
return loader.loadAsync(input, onProgress).then((data) => {
|
|
@@ -2029,7 +1156,7 @@ useLoader.clear = function(loader, input, cacheKey) {
|
|
|
2029
1156
|
const cacheKeys = Array.isArray(cacheKey ?? input) ? cacheKey ?? input : [cacheKey ?? input];
|
|
2030
1157
|
cacheKeys.forEach((key) => suspendReact.clear([loader, key]));
|
|
2031
1158
|
};
|
|
2032
|
-
useLoader.loader = getLoader;
|
|
1159
|
+
useLoader.loader = getLoader$1;
|
|
2033
1160
|
|
|
2034
1161
|
function useFrame(callback, priorityOrOptions) {
|
|
2035
1162
|
const store = React__namespace.useContext(context);
|
|
@@ -2389,11 +1516,131 @@ function useRenderTarget(widthOrOptions, heightOrOptions, options) {
|
|
|
2389
1516
|
height = widthOrOptions;
|
|
2390
1517
|
}
|
|
2391
1518
|
}
|
|
2392
|
-
return React.useMemo(() => {
|
|
2393
|
-
const w = width ?? size.width;
|
|
2394
|
-
const h = height ?? size.height;
|
|
2395
|
-
return new webgpu.RenderTarget(w, h, opts);
|
|
2396
|
-
}, [width, height, size.width, size.height, opts, isLegacy]);
|
|
1519
|
+
return React.useMemo(() => {
|
|
1520
|
+
const w = width ?? size.width;
|
|
1521
|
+
const h = height ?? size.height;
|
|
1522
|
+
return new webgpu.RenderTarget(w, h, opts);
|
|
1523
|
+
}, [width, height, size.width, size.height, opts, isLegacy]);
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
const presetsObj = {
|
|
1527
|
+
apartment: "lebombo_1k.hdr",
|
|
1528
|
+
city: "potsdamer_platz_1k.hdr",
|
|
1529
|
+
dawn: "kiara_1_dawn_1k.hdr",
|
|
1530
|
+
forest: "forest_slope_1k.hdr",
|
|
1531
|
+
lobby: "st_fagans_interior_1k.hdr",
|
|
1532
|
+
night: "dikhololo_night_1k.hdr",
|
|
1533
|
+
park: "rooitou_park_1k.hdr",
|
|
1534
|
+
studio: "studio_small_03_1k.hdr",
|
|
1535
|
+
sunset: "venice_sunset_1k.hdr",
|
|
1536
|
+
warehouse: "empty_warehouse_01_1k.hdr"
|
|
1537
|
+
};
|
|
1538
|
+
|
|
1539
|
+
const CUBEMAP_ROOT = "https://raw.githack.com/pmndrs/drei-assets/456060a26bbeb8fdf79326f224b6d99b8bcce736/hdri/";
|
|
1540
|
+
const isArray = (arr) => Array.isArray(arr);
|
|
1541
|
+
const defaultFiles = ["/px.png", "/nx.png", "/py.png", "/ny.png", "/pz.png", "/nz.png"];
|
|
1542
|
+
function useEnvironment({
|
|
1543
|
+
files = defaultFiles,
|
|
1544
|
+
path = "",
|
|
1545
|
+
preset = void 0,
|
|
1546
|
+
colorSpace = void 0,
|
|
1547
|
+
extensions
|
|
1548
|
+
} = {}) {
|
|
1549
|
+
if (preset) {
|
|
1550
|
+
validatePreset(preset);
|
|
1551
|
+
files = presetsObj[preset];
|
|
1552
|
+
path = CUBEMAP_ROOT;
|
|
1553
|
+
}
|
|
1554
|
+
const multiFile = isArray(files);
|
|
1555
|
+
const { extension, isCubemap } = getExtension(files);
|
|
1556
|
+
const loader = getLoader(extension);
|
|
1557
|
+
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1558
|
+
const renderer = useThree((state) => state.renderer);
|
|
1559
|
+
React.useLayoutEffect(() => {
|
|
1560
|
+
if (extension !== "webp" && extension !== "jpg" && extension !== "jpeg") return;
|
|
1561
|
+
function clearGainmapTexture() {
|
|
1562
|
+
useLoader.clear(loader, multiFile ? [files] : files);
|
|
1563
|
+
}
|
|
1564
|
+
renderer.domElement.addEventListener("webglcontextlost", clearGainmapTexture, { once: true });
|
|
1565
|
+
}, [extension, files, loader, multiFile, renderer.domElement]);
|
|
1566
|
+
const loaderResult = useLoader(
|
|
1567
|
+
loader,
|
|
1568
|
+
multiFile ? [files] : files,
|
|
1569
|
+
(loader2) => {
|
|
1570
|
+
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
1571
|
+
loader2.setRenderer?.(renderer);
|
|
1572
|
+
}
|
|
1573
|
+
loader2.setPath?.(path);
|
|
1574
|
+
if (extensions) extensions(loader2);
|
|
1575
|
+
}
|
|
1576
|
+
);
|
|
1577
|
+
let texture = multiFile ? (
|
|
1578
|
+
// @ts-ignore
|
|
1579
|
+
loaderResult[0]
|
|
1580
|
+
) : loaderResult;
|
|
1581
|
+
if (extension === "jpg" || extension === "jpeg" || extension === "webp") {
|
|
1582
|
+
texture = texture.renderTarget?.texture;
|
|
1583
|
+
}
|
|
1584
|
+
texture.mapping = isCubemap ? webgpu.CubeReflectionMapping : webgpu.EquirectangularReflectionMapping;
|
|
1585
|
+
texture.colorSpace = colorSpace ?? (isCubemap ? "srgb" : "srgb-linear");
|
|
1586
|
+
return texture;
|
|
1587
|
+
}
|
|
1588
|
+
const preloadDefaultOptions = {
|
|
1589
|
+
files: defaultFiles,
|
|
1590
|
+
path: "",
|
|
1591
|
+
preset: void 0,
|
|
1592
|
+
extensions: void 0
|
|
1593
|
+
};
|
|
1594
|
+
useEnvironment.preload = (preloadOptions) => {
|
|
1595
|
+
const options = { ...preloadDefaultOptions, ...preloadOptions };
|
|
1596
|
+
let { files, path = "" } = options;
|
|
1597
|
+
const { preset, extensions } = options;
|
|
1598
|
+
if (preset) {
|
|
1599
|
+
validatePreset(preset);
|
|
1600
|
+
files = presetsObj[preset];
|
|
1601
|
+
path = CUBEMAP_ROOT;
|
|
1602
|
+
}
|
|
1603
|
+
const { extension } = getExtension(files);
|
|
1604
|
+
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
1605
|
+
throw new Error("useEnvironment: Preloading gainmaps is not supported");
|
|
1606
|
+
}
|
|
1607
|
+
const loader = getLoader(extension);
|
|
1608
|
+
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1609
|
+
useLoader.preload(loader, isArray(files) ? [files] : files, (loader2) => {
|
|
1610
|
+
loader2.setPath?.(path);
|
|
1611
|
+
if (extensions) extensions(loader2);
|
|
1612
|
+
});
|
|
1613
|
+
};
|
|
1614
|
+
const clearDefaultOptins = {
|
|
1615
|
+
files: defaultFiles,
|
|
1616
|
+
preset: void 0
|
|
1617
|
+
};
|
|
1618
|
+
useEnvironment.clear = (clearOptions) => {
|
|
1619
|
+
const options = { ...clearDefaultOptins, ...clearOptions };
|
|
1620
|
+
let { files } = options;
|
|
1621
|
+
const { preset } = options;
|
|
1622
|
+
if (preset) {
|
|
1623
|
+
validatePreset(preset);
|
|
1624
|
+
files = presetsObj[preset];
|
|
1625
|
+
}
|
|
1626
|
+
const { extension } = getExtension(files);
|
|
1627
|
+
const loader = getLoader(extension);
|
|
1628
|
+
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1629
|
+
useLoader.clear(loader, isArray(files) ? [files] : files);
|
|
1630
|
+
};
|
|
1631
|
+
function validatePreset(preset) {
|
|
1632
|
+
if (!(preset in presetsObj)) throw new Error("Preset must be one of: " + Object.keys(presetsObj).join(", "));
|
|
1633
|
+
}
|
|
1634
|
+
function getExtension(files) {
|
|
1635
|
+
const isCubemap = isArray(files) && files.length === 6;
|
|
1636
|
+
const isGainmap = isArray(files) && files.length === 3 && files.some((file) => file.endsWith("json"));
|
|
1637
|
+
const firstEntry = isArray(files) ? files[0] : files;
|
|
1638
|
+
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();
|
|
1639
|
+
return { extension, isCubemap, isGainmap };
|
|
1640
|
+
}
|
|
1641
|
+
function getLoader(extension) {
|
|
1642
|
+
const loader = extension === "cube" ? webgpu.CubeTextureLoader : extension === "hdr" ? HDRLoader_js.HDRLoader : extension === "exr" ? EXRLoader_js.EXRLoader : extension === "jpg" || extension === "jpeg" ? UltraHDRLoader_js.UltraHDRLoader : extension === "webp" ? gainmapJs.GainMapLoader : null;
|
|
1643
|
+
return loader;
|
|
2397
1644
|
}
|
|
2398
1645
|
|
|
2399
1646
|
function useStore() {
|
|
@@ -2413,6 +1660,8 @@ function useGraph(object) {
|
|
|
2413
1660
|
return React.useMemo(() => buildGraph(object), [object]);
|
|
2414
1661
|
}
|
|
2415
1662
|
|
|
1663
|
+
const t = 1, o = 8, r = 32, e = 2, i$1 = 268435456;
|
|
1664
|
+
|
|
2416
1665
|
let effectId = 0;
|
|
2417
1666
|
function addEffect(callback) {
|
|
2418
1667
|
notifyDepreciated({
|
|
@@ -13315,395 +12564,978 @@ Check the top-level render call using <` + i + ">.");
|
|
|
13315
12564
|
} finally {
|
|
13316
12565
|
x.H = o;
|
|
13317
12566
|
}
|
|
13318
|
-
}, useReducer: function(e, n, o) {
|
|
13319
|
-
z = "useReducer", D(), N();
|
|
13320
|
-
var i = x.H;
|
|
13321
|
-
x.H = $o;
|
|
12567
|
+
}, useReducer: function(e, n, o) {
|
|
12568
|
+
z = "useReducer", D(), N();
|
|
12569
|
+
var i = x.H;
|
|
12570
|
+
x.H = $o;
|
|
12571
|
+
try {
|
|
12572
|
+
return Br(e, n, o);
|
|
12573
|
+
} finally {
|
|
12574
|
+
x.H = i;
|
|
12575
|
+
}
|
|
12576
|
+
}, useRef: function() {
|
|
12577
|
+
return z = "useRef", D(), N(), xe().memoizedState;
|
|
12578
|
+
}, useState: function() {
|
|
12579
|
+
z = "useState", D(), N();
|
|
12580
|
+
var e = x.H;
|
|
12581
|
+
x.H = $o;
|
|
12582
|
+
try {
|
|
12583
|
+
return Br(gr);
|
|
12584
|
+
} finally {
|
|
12585
|
+
x.H = e;
|
|
12586
|
+
}
|
|
12587
|
+
}, useDebugValue: function() {
|
|
12588
|
+
z = "useDebugValue", D(), N();
|
|
12589
|
+
}, useDeferredValue: function(e, n) {
|
|
12590
|
+
return z = "useDeferredValue", D(), N(), nc(e, n);
|
|
12591
|
+
}, useTransition: function() {
|
|
12592
|
+
return z = "useTransition", D(), N(), Qp();
|
|
12593
|
+
}, useSyncExternalStore: function(e, n, o) {
|
|
12594
|
+
return z = "useSyncExternalStore", D(), N(), ta(e, n, o);
|
|
12595
|
+
}, useId: function() {
|
|
12596
|
+
return z = "useId", D(), N(), xe().memoizedState;
|
|
12597
|
+
}, useFormState: function(e) {
|
|
12598
|
+
return z = "useFormState", D(), N(), hs(e);
|
|
12599
|
+
}, useActionState: function(e) {
|
|
12600
|
+
return z = "useActionState", D(), N(), hs(e);
|
|
12601
|
+
}, useOptimistic: function(e, n) {
|
|
12602
|
+
return z = "useOptimistic", D(), N(), rf(e, n);
|
|
12603
|
+
}, useMemoCache: function(e) {
|
|
12604
|
+
return D(), Oa(e);
|
|
12605
|
+
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
12606
|
+
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
12607
|
+
}, useEffectEvent: function(e) {
|
|
12608
|
+
return z = "useEffectEvent", D(), N(), oa(e);
|
|
12609
|
+
} }, dm = { readContext: function(e) {
|
|
12610
|
+
return Ce(), Ee(e);
|
|
12611
|
+
}, use: function(e) {
|
|
12612
|
+
return D(), we(e);
|
|
12613
|
+
}, useCallback: function(e, n) {
|
|
12614
|
+
return z = "useCallback", D(), N(), Ma(e, n);
|
|
12615
|
+
}, useContext: function(e) {
|
|
12616
|
+
return z = "useContext", D(), N(), Ee(e);
|
|
12617
|
+
}, useEffect: function(e, n) {
|
|
12618
|
+
z = "useEffect", D(), N(), Qn(2048, Ut, e, n);
|
|
12619
|
+
}, useImperativeHandle: function(e, n, o) {
|
|
12620
|
+
return z = "useImperativeHandle", D(), N(), aa(e, n, o);
|
|
12621
|
+
}, useInsertionEffect: function(e, n) {
|
|
12622
|
+
return z = "useInsertionEffect", D(), N(), Qn(4, Wt, e, n);
|
|
12623
|
+
}, useLayoutEffect: function(e, n) {
|
|
12624
|
+
return z = "useLayoutEffect", D(), N(), Qn(4, Rr, e, n);
|
|
12625
|
+
}, useMemo: function(e, n) {
|
|
12626
|
+
z = "useMemo", D(), N();
|
|
12627
|
+
var o = x.H;
|
|
12628
|
+
x.H = $o;
|
|
12629
|
+
try {
|
|
12630
|
+
return Vi(e, n);
|
|
12631
|
+
} finally {
|
|
12632
|
+
x.H = o;
|
|
12633
|
+
}
|
|
12634
|
+
}, useReducer: function(e, n, o) {
|
|
12635
|
+
z = "useReducer", D(), N();
|
|
12636
|
+
var i = x.H;
|
|
12637
|
+
x.H = $o;
|
|
12638
|
+
try {
|
|
12639
|
+
return Qi(e, n, o);
|
|
12640
|
+
} finally {
|
|
12641
|
+
x.H = i;
|
|
12642
|
+
}
|
|
12643
|
+
}, useRef: function() {
|
|
12644
|
+
return z = "useRef", D(), N(), xe().memoizedState;
|
|
12645
|
+
}, useState: function() {
|
|
12646
|
+
z = "useState", D(), N();
|
|
12647
|
+
var e = x.H;
|
|
12648
|
+
x.H = $o;
|
|
12649
|
+
try {
|
|
12650
|
+
return Qi(gr);
|
|
12651
|
+
} finally {
|
|
12652
|
+
x.H = e;
|
|
12653
|
+
}
|
|
12654
|
+
}, useDebugValue: function() {
|
|
12655
|
+
z = "useDebugValue", D(), N();
|
|
12656
|
+
}, useDeferredValue: function(e, n) {
|
|
12657
|
+
return z = "useDeferredValue", D(), N(), sf(e, n);
|
|
12658
|
+
}, useTransition: function() {
|
|
12659
|
+
return z = "useTransition", D(), N(), Ro();
|
|
12660
|
+
}, useSyncExternalStore: function(e, n, o) {
|
|
12661
|
+
return z = "useSyncExternalStore", D(), N(), ta(e, n, o);
|
|
12662
|
+
}, useId: function() {
|
|
12663
|
+
return z = "useId", D(), N(), xe().memoizedState;
|
|
12664
|
+
}, useFormState: function(e) {
|
|
12665
|
+
return z = "useFormState", D(), N(), $t(e);
|
|
12666
|
+
}, useActionState: function(e) {
|
|
12667
|
+
return z = "useActionState", D(), N(), $t(e);
|
|
12668
|
+
}, useOptimistic: function(e, n) {
|
|
12669
|
+
return z = "useOptimistic", D(), N(), of(e, n);
|
|
12670
|
+
}, useMemoCache: function(e) {
|
|
12671
|
+
return D(), Oa(e);
|
|
12672
|
+
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
12673
|
+
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
12674
|
+
}, useEffectEvent: function(e) {
|
|
12675
|
+
return z = "useEffectEvent", D(), N(), oa(e);
|
|
12676
|
+
} };
|
|
12677
|
+
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();
|
|
12678
|
+
Object.freeze(Fy);
|
|
12679
|
+
var zg = { enqueueSetState: function(e, n, o) {
|
|
12680
|
+
e = e._reactInternals;
|
|
12681
|
+
var i = Nt(e), s = zo(i);
|
|
12682
|
+
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));
|
|
12683
|
+
}, enqueueReplaceState: function(e, n, o) {
|
|
12684
|
+
e = e._reactInternals;
|
|
12685
|
+
var i = Nt(e), s = zo(i);
|
|
12686
|
+
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));
|
|
12687
|
+
}, enqueueForceUpdate: function(e, n) {
|
|
12688
|
+
e = e._reactInternals;
|
|
12689
|
+
var o = Nt(e), i = zo(o);
|
|
12690
|
+
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));
|
|
12691
|
+
} }, 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;
|
|
12692
|
+
Yy = /* @__PURE__ */ new Set();
|
|
12693
|
+
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) {
|
|
12694
|
+
var n = Ee(un), o = n.data.get(e);
|
|
12695
|
+
return o === void 0 && (o = e(), n.data.set(e, o)), o;
|
|
12696
|
+
}, cacheSignal: function() {
|
|
12697
|
+
return Ee(un).controller.signal;
|
|
12698
|
+
}, getOwner: function() {
|
|
12699
|
+
return di;
|
|
12700
|
+
} }, pm = 0, hm = 1, mm = 2, gm = 3, ym = 4;
|
|
12701
|
+
if (typeof Symbol == "function" && Symbol.for) {
|
|
12702
|
+
var bp = Symbol.for;
|
|
12703
|
+
pm = bp("selector.component"), hm = bp("selector.has_pseudo_class"), mm = bp("selector.role"), gm = bp("selector.test_id"), ym = bp("selector.text");
|
|
12704
|
+
}
|
|
12705
|
+
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;
|
|
12706
|
+
try {
|
|
12707
|
+
var o0 = Object.preventExtensions({});
|
|
12708
|
+
} catch {
|
|
12709
|
+
pb = true;
|
|
12710
|
+
}
|
|
12711
|
+
var hb = false, mb = {}, gb = null, yb = null, bb = null, vb = null, Sb = null, kb = null, wb = null, Pb = null, xb = null, zb = null;
|
|
12712
|
+
return gb = function(e, n, o, i) {
|
|
12713
|
+
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));
|
|
12714
|
+
}, yb = function(e, n, o) {
|
|
12715
|
+
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));
|
|
12716
|
+
}, bb = function(e, n, o, i) {
|
|
12717
|
+
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));
|
|
12718
|
+
}, vb = function(e, n, o) {
|
|
12719
|
+
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);
|
|
12720
|
+
}, Sb = function(e, n) {
|
|
12721
|
+
e.pendingProps = du(e.memoizedProps, n, 0), e.alternate && (e.alternate.pendingProps = e.pendingProps), n = On(e, 2), n !== null && We(n, e, 2);
|
|
12722
|
+
}, kb = function(e, n, o) {
|
|
12723
|
+
e.pendingProps = F(e.memoizedProps, n, o), e.alternate && (e.alternate.pendingProps = e.pendingProps), n = On(e, 2), n !== null && We(n, e, 2);
|
|
12724
|
+
}, wb = function(e) {
|
|
12725
|
+
var n = On(e, 2);
|
|
12726
|
+
n !== null && We(n, e, 2);
|
|
12727
|
+
}, Pb = function(e) {
|
|
12728
|
+
var n = ut(), o = On(e, n);
|
|
12729
|
+
o !== null && We(o, e, n);
|
|
12730
|
+
}, xb = function(e) {
|
|
12731
|
+
pu = e;
|
|
12732
|
+
}, zb = function(e) {
|
|
12733
|
+
fu = e;
|
|
12734
|
+
}, le.attemptContinuousHydration = function(e) {
|
|
12735
|
+
if (e.tag === 13 || e.tag === 31) {
|
|
12736
|
+
var n = On(e, 67108864);
|
|
12737
|
+
n !== null && We(n, e, 67108864), rl(e, 67108864);
|
|
12738
|
+
}
|
|
12739
|
+
}, le.attemptHydrationAtCurrentPriority = function(e) {
|
|
12740
|
+
if (e.tag === 13 || e.tag === 31) {
|
|
12741
|
+
var n = Nt(e);
|
|
12742
|
+
n = Xo(n);
|
|
12743
|
+
var o = On(e, n);
|
|
12744
|
+
o !== null && We(o, e, n), rl(e, n);
|
|
12745
|
+
}
|
|
12746
|
+
}, le.attemptSynchronousHydration = function(e) {
|
|
12747
|
+
switch (e.tag) {
|
|
12748
|
+
case 3:
|
|
12749
|
+
if (e = e.stateNode, e.current.memoizedState.isDehydrated) {
|
|
12750
|
+
var n = _t(e.pendingLanes);
|
|
12751
|
+
if (n !== 0) {
|
|
12752
|
+
for (e.pendingLanes |= 2, e.entangledLanes |= 2; n; ) {
|
|
12753
|
+
var o = 1 << 31 - vn(n);
|
|
12754
|
+
e.entanglements[1] |= o, n &= ~o;
|
|
12755
|
+
}
|
|
12756
|
+
Kn(e), (ye & (Zn | uo)) === Jn && (Pp = me() + Fg, Wa(0));
|
|
12757
|
+
}
|
|
12758
|
+
}
|
|
12759
|
+
break;
|
|
12760
|
+
case 31:
|
|
12761
|
+
case 13:
|
|
12762
|
+
n = On(e, 2), n !== null && We(n, e, 2), Ls(), rl(e, 2);
|
|
12763
|
+
}
|
|
12764
|
+
}, le.batchedUpdates = function(e, n) {
|
|
12765
|
+
return e(n);
|
|
12766
|
+
}, le.createComponentSelector = function(e) {
|
|
12767
|
+
return { $$typeof: pm, value: e };
|
|
12768
|
+
}, le.createContainer = function(e, n, o, i, s, u, f, p, g, S) {
|
|
12769
|
+
return Ka(e, n, false, null, o, i, u, null, f, p, g, S);
|
|
12770
|
+
}, le.createHasPseudoClassSelector = function(e) {
|
|
12771
|
+
return { $$typeof: hm, value: e };
|
|
12772
|
+
}, le.createHydrationContainer = function(e, n, o, i, s, u, f, p, g, S, T, _, I, O) {
|
|
12773
|
+
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;
|
|
12774
|
+
}, le.createPortal = function(e, n, o) {
|
|
12775
|
+
var i = 3 < arguments.length && arguments[3] !== void 0 ? arguments[3] : null;
|
|
13322
12776
|
try {
|
|
13323
|
-
|
|
13324
|
-
|
|
13325
|
-
|
|
12777
|
+
vt(i);
|
|
12778
|
+
var s = false;
|
|
12779
|
+
} catch {
|
|
12780
|
+
s = true;
|
|
13326
12781
|
}
|
|
13327
|
-
|
|
13328
|
-
|
|
13329
|
-
|
|
13330
|
-
|
|
13331
|
-
|
|
13332
|
-
|
|
12782
|
+
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 };
|
|
12783
|
+
}, le.createRoleSelector = function(e) {
|
|
12784
|
+
return { $$typeof: mm, value: e };
|
|
12785
|
+
}, le.createTestNameSelector = function(e) {
|
|
12786
|
+
return { $$typeof: gm, value: e };
|
|
12787
|
+
}, le.createTextSelector = function(e) {
|
|
12788
|
+
return { $$typeof: ym, value: e };
|
|
12789
|
+
}, le.defaultOnCaughtError = function(e) {
|
|
12790
|
+
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") + ".");
|
|
12791
|
+
typeof e == "object" && e !== null && typeof e.environmentName == "string" ? ri("error", [`%o
|
|
12792
|
+
|
|
12793
|
+
%s
|
|
12794
|
+
|
|
12795
|
+
%s
|
|
12796
|
+
`, e, n, o], e.environmentName)() : console.error(`%o
|
|
12797
|
+
|
|
12798
|
+
%s
|
|
12799
|
+
|
|
12800
|
+
%s
|
|
12801
|
+
`, e, n, o);
|
|
12802
|
+
}, le.defaultOnRecoverableError = function(e) {
|
|
12803
|
+
qg(e);
|
|
12804
|
+
}, le.defaultOnUncaughtError = function(e) {
|
|
12805
|
+
qg(e), console.warn(`%s
|
|
12806
|
+
|
|
12807
|
+
%s
|
|
12808
|
+
`, 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.
|
|
12809
|
+
Visit https://react.dev/link/error-boundaries to learn more about error boundaries.`);
|
|
12810
|
+
}, le.deferredUpdates = function(e) {
|
|
12811
|
+
var n = x.T, o = wt();
|
|
13333
12812
|
try {
|
|
13334
|
-
return
|
|
12813
|
+
return an(32), x.T = null, e();
|
|
13335
12814
|
} finally {
|
|
13336
|
-
x.
|
|
12815
|
+
an(o), x.T = n;
|
|
13337
12816
|
}
|
|
13338
|
-
},
|
|
13339
|
-
|
|
13340
|
-
}, useDeferredValue: function(e, n) {
|
|
13341
|
-
return z = "useDeferredValue", D(), N(), nc(e, n);
|
|
13342
|
-
}, useTransition: function() {
|
|
13343
|
-
return z = "useTransition", D(), N(), Qp();
|
|
13344
|
-
}, useSyncExternalStore: function(e, n, o) {
|
|
13345
|
-
return z = "useSyncExternalStore", D(), N(), ta(e, n, o);
|
|
13346
|
-
}, useId: function() {
|
|
13347
|
-
return z = "useId", D(), N(), xe().memoizedState;
|
|
13348
|
-
}, useFormState: function(e) {
|
|
13349
|
-
return z = "useFormState", D(), N(), hs(e);
|
|
13350
|
-
}, useActionState: function(e) {
|
|
13351
|
-
return z = "useActionState", D(), N(), hs(e);
|
|
13352
|
-
}, useOptimistic: function(e, n) {
|
|
13353
|
-
return z = "useOptimistic", D(), N(), rf(e, n);
|
|
13354
|
-
}, useMemoCache: function(e) {
|
|
13355
|
-
return D(), Oa(e);
|
|
13356
|
-
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
13357
|
-
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
13358
|
-
}, useEffectEvent: function(e) {
|
|
13359
|
-
return z = "useEffectEvent", D(), N(), oa(e);
|
|
13360
|
-
} }, dm = { readContext: function(e) {
|
|
13361
|
-
return Ce(), Ee(e);
|
|
13362
|
-
}, use: function(e) {
|
|
13363
|
-
return D(), we(e);
|
|
13364
|
-
}, useCallback: function(e, n) {
|
|
13365
|
-
return z = "useCallback", D(), N(), Ma(e, n);
|
|
13366
|
-
}, useContext: function(e) {
|
|
13367
|
-
return z = "useContext", D(), N(), Ee(e);
|
|
13368
|
-
}, useEffect: function(e, n) {
|
|
13369
|
-
z = "useEffect", D(), N(), Qn(2048, Ut, e, n);
|
|
13370
|
-
}, useImperativeHandle: function(e, n, o) {
|
|
13371
|
-
return z = "useImperativeHandle", D(), N(), aa(e, n, o);
|
|
13372
|
-
}, useInsertionEffect: function(e, n) {
|
|
13373
|
-
return z = "useInsertionEffect", D(), N(), Qn(4, Wt, e, n);
|
|
13374
|
-
}, useLayoutEffect: function(e, n) {
|
|
13375
|
-
return z = "useLayoutEffect", D(), N(), Qn(4, Rr, e, n);
|
|
13376
|
-
}, useMemo: function(e, n) {
|
|
13377
|
-
z = "useMemo", D(), N();
|
|
13378
|
-
var o = x.H;
|
|
13379
|
-
x.H = $o;
|
|
12817
|
+
}, le.discreteUpdates = function(e, n, o, i, s) {
|
|
12818
|
+
var u = x.T, f = wt();
|
|
13380
12819
|
try {
|
|
13381
|
-
return
|
|
12820
|
+
return an(2), x.T = null, e(n, o, i, s);
|
|
13382
12821
|
} finally {
|
|
13383
|
-
x.
|
|
12822
|
+
an(f), x.T = u, ye === Jn && (Pp = me() + Fg);
|
|
13384
12823
|
}
|
|
13385
|
-
},
|
|
13386
|
-
|
|
13387
|
-
|
|
13388
|
-
|
|
13389
|
-
|
|
13390
|
-
|
|
13391
|
-
|
|
13392
|
-
|
|
12824
|
+
}, le.findAllNodes = kc, le.findBoundingRects = function(e, n) {
|
|
12825
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12826
|
+
n = kc(e, n), e = [];
|
|
12827
|
+
for (var o = 0; o < n.length; o++) e.push(ma(n[o]));
|
|
12828
|
+
for (n = e.length - 1; 0 < n; n--) {
|
|
12829
|
+
o = e[n];
|
|
12830
|
+
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) {
|
|
12831
|
+
var g = e[p], S = g.x, T = S + g.width, _ = g.y, I = _ + g.height;
|
|
12832
|
+
if (i >= S && u >= _ && s <= T && f <= I) {
|
|
12833
|
+
e.splice(n, 1);
|
|
12834
|
+
break;
|
|
12835
|
+
} else if (i !== S || o.width !== g.width || I < u || _ > f) {
|
|
12836
|
+
if (!(u !== _ || o.height !== g.height || T < i || S > s)) {
|
|
12837
|
+
S > i && (g.width += S - i, g.x = i), T < s && (g.width = s - S), e.splice(n, 1);
|
|
12838
|
+
break;
|
|
12839
|
+
}
|
|
12840
|
+
} else {
|
|
12841
|
+
_ > u && (g.height += _ - u, g.y = u), I < f && (g.height = f - _), e.splice(n, 1);
|
|
12842
|
+
break;
|
|
12843
|
+
}
|
|
12844
|
+
}
|
|
13393
12845
|
}
|
|
13394
|
-
|
|
13395
|
-
|
|
13396
|
-
|
|
13397
|
-
|
|
13398
|
-
|
|
13399
|
-
|
|
12846
|
+
return e;
|
|
12847
|
+
}, le.findHostInstance = function(e) {
|
|
12848
|
+
var n = e._reactInternals;
|
|
12849
|
+
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));
|
|
12850
|
+
return e = mu(n), e === null ? null : ot(e.stateNode);
|
|
12851
|
+
}, le.findHostInstanceWithNoPortals = function(e) {
|
|
12852
|
+
return e = Ed(e), e = e !== null ? _p(e) : null, e === null ? null : ot(e.stateNode);
|
|
12853
|
+
}, le.findHostInstanceWithWarning = function(e, n) {
|
|
12854
|
+
var o = e._reactInternals;
|
|
12855
|
+
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));
|
|
12856
|
+
if (e = mu(o), e === null) return null;
|
|
12857
|
+
if (e.mode & 8) {
|
|
12858
|
+
var i = G(o) || "Component";
|
|
12859
|
+
mb[i] || (mb[i] = true, B(e, function() {
|
|
12860
|
+
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);
|
|
12861
|
+
}));
|
|
12862
|
+
}
|
|
12863
|
+
return ot(e.stateNode);
|
|
12864
|
+
}, le.flushPassiveEffects = el, le.flushSyncFromReconciler = function(e) {
|
|
12865
|
+
var n = ye;
|
|
12866
|
+
ye |= 1;
|
|
12867
|
+
var o = x.T, i = wt();
|
|
13400
12868
|
try {
|
|
13401
|
-
return
|
|
12869
|
+
if (an(2), x.T = null, e) return e();
|
|
13402
12870
|
} finally {
|
|
13403
|
-
x.
|
|
12871
|
+
an(i), x.T = o, ye = n, (ye & (Zn | uo)) === Jn && Wa(0);
|
|
12872
|
+
}
|
|
12873
|
+
}, le.flushSyncWork = Ls, le.focusWithin = function(e, n) {
|
|
12874
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12875
|
+
for (e = Ef(e), n = hh(e, n), n = Array.from(n), e = 0; e < n.length; ) {
|
|
12876
|
+
var o = n[e++], i = o.tag;
|
|
12877
|
+
if (!Kr(o)) {
|
|
12878
|
+
if ((i === 5 || i === 26 || i === 27) && Ft(o.stateNode)) return true;
|
|
12879
|
+
for (o = o.child; o !== null; ) n.push(o), o = o.sibling;
|
|
12880
|
+
}
|
|
12881
|
+
}
|
|
12882
|
+
return false;
|
|
12883
|
+
}, le.getFindAllNodesFailureDescription = function(e, n) {
|
|
12884
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12885
|
+
var o = 0, i = [];
|
|
12886
|
+
e = [Ef(e), 0];
|
|
12887
|
+
for (var s = 0; s < e.length; ) {
|
|
12888
|
+
var u = e[s++], f = u.tag, p = e[s++], g = n[p];
|
|
12889
|
+
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;
|
|
12890
|
+
}
|
|
12891
|
+
if (o < n.length) {
|
|
12892
|
+
for (e = []; o < n.length; o++) e.push(Sc(n[o]));
|
|
12893
|
+
return `findAllNodes was able to match part of the selector:
|
|
12894
|
+
` + (i.join(" > ") + `
|
|
12895
|
+
|
|
12896
|
+
No matching component was found for:
|
|
12897
|
+
`) + e.join(" > ");
|
|
12898
|
+
}
|
|
12899
|
+
return null;
|
|
12900
|
+
}, le.getPublicRootInstance = function(e) {
|
|
12901
|
+
if (e = e.current, !e.child) return null;
|
|
12902
|
+
switch (e.child.tag) {
|
|
12903
|
+
case 27:
|
|
12904
|
+
case 5:
|
|
12905
|
+
return ot(e.child.stateNode);
|
|
12906
|
+
default:
|
|
12907
|
+
return e.child.stateNode;
|
|
12908
|
+
}
|
|
12909
|
+
}, le.injectIntoDevTools = function() {
|
|
12910
|
+
var e = { bundleType: 1, version: Jt, rendererPackageName: Zt, currentDispatcherRef: x, reconcilerVersion: "19.2.0" };
|
|
12911
|
+
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);
|
|
12912
|
+
}, le.isAlreadyRendering = Ns, le.observeVisibleRects = function(e, n, o, i) {
|
|
12913
|
+
function s() {
|
|
12914
|
+
var S = kc(e, n);
|
|
12915
|
+
u.forEach(function(T) {
|
|
12916
|
+
0 > S.indexOf(T) && g(T);
|
|
12917
|
+
}), S.forEach(function(T) {
|
|
12918
|
+
0 > u.indexOf(T) && p(T);
|
|
12919
|
+
});
|
|
12920
|
+
}
|
|
12921
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12922
|
+
var u = kc(e, n);
|
|
12923
|
+
o = zr(u, o, i);
|
|
12924
|
+
var f = o.disconnect, p = o.observe, g = o.unobserve;
|
|
12925
|
+
return bm.push(s), { disconnect: function() {
|
|
12926
|
+
var S = bm.indexOf(s);
|
|
12927
|
+
0 <= S && bm.splice(S, 1), f();
|
|
12928
|
+
} };
|
|
12929
|
+
}, le.shouldError = function(e) {
|
|
12930
|
+
return pu(e);
|
|
12931
|
+
}, le.shouldSuspend = function(e) {
|
|
12932
|
+
return fu(e);
|
|
12933
|
+
}, le.startHostTransition = function(e, n, o, i) {
|
|
12934
|
+
if (e.tag !== 5) throw Error("Expected the form instance to be a HostComponent. This is a bug in React.");
|
|
12935
|
+
var s = uf(e).queue;
|
|
12936
|
+
Hp(e), nt(e, s, n, Xt, o === null ? Em : function() {
|
|
12937
|
+
x.T === null && console.error("requestFormReset was called outside a transition or action. To fix, move to an action, or wrap with startTransition.");
|
|
12938
|
+
var u = uf(e);
|
|
12939
|
+
return u.next === null && (u = e.alternate.memoizedState), qi(e, u.next.queue, {}, Nt(e)), o(i);
|
|
12940
|
+
});
|
|
12941
|
+
}, le.updateContainer = function(e, n, o, i) {
|
|
12942
|
+
var s = n.current, u = Nt(s);
|
|
12943
|
+
return As(s, u, e, n, o, i), u;
|
|
12944
|
+
}, le.updateContainerSync = Wh, le;
|
|
12945
|
+
}, Tt.exports.default = Tt.exports, Object.defineProperty(Tt.exports, "__esModule", { value: true }));
|
|
12946
|
+
})(Mg)), Mg.exports;
|
|
12947
|
+
}
|
|
12948
|
+
var Eb;
|
|
12949
|
+
function n0() {
|
|
12950
|
+
return Eb || (Eb = 1, process.env.NODE_ENV === "production" ? Rm.exports = Kb() : Rm.exports = e0()), Rm.exports;
|
|
12951
|
+
}
|
|
12952
|
+
var t0 = n0();
|
|
12953
|
+
const r0 = Xb(t0);
|
|
12954
|
+
|
|
12955
|
+
const DEFAULT_POINTER_ID = 0;
|
|
12956
|
+
const XR_POINTER_ID_START = 1e3;
|
|
12957
|
+
function getPointerState(internal, pointerId) {
|
|
12958
|
+
let state = internal.pointerMap.get(pointerId);
|
|
12959
|
+
if (!state) {
|
|
12960
|
+
state = {
|
|
12961
|
+
hovered: /* @__PURE__ */ new Map(),
|
|
12962
|
+
captured: /* @__PURE__ */ new Map(),
|
|
12963
|
+
initialClick: [0, 0],
|
|
12964
|
+
initialHits: []
|
|
12965
|
+
};
|
|
12966
|
+
internal.pointerMap.set(pointerId, state);
|
|
12967
|
+
}
|
|
12968
|
+
return state;
|
|
12969
|
+
}
|
|
12970
|
+
function getPointerId(event) {
|
|
12971
|
+
return "pointerId" in event ? event.pointerId : DEFAULT_POINTER_ID;
|
|
12972
|
+
}
|
|
12973
|
+
function makeId(event) {
|
|
12974
|
+
return (event.eventObject || event.object).uuid + "/" + event.index + event.instanceId;
|
|
12975
|
+
}
|
|
12976
|
+
function releaseInternalPointerCapture(internal, obj, pointerId) {
|
|
12977
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
12978
|
+
if (!pointerState) return;
|
|
12979
|
+
const captureData = pointerState.captured.get(obj);
|
|
12980
|
+
if (captureData) {
|
|
12981
|
+
pointerState.captured.delete(obj);
|
|
12982
|
+
try {
|
|
12983
|
+
captureData.target.releasePointerCapture?.(pointerId);
|
|
12984
|
+
} catch {
|
|
12985
|
+
}
|
|
12986
|
+
}
|
|
12987
|
+
}
|
|
12988
|
+
function swapInteractivity(store, object, newObject) {
|
|
12989
|
+
const { internal } = store.getState();
|
|
12990
|
+
for (let i = 0; i < internal.interaction.length; i++) {
|
|
12991
|
+
if (internal.interaction[i] === object) internal.interaction[i] = newObject;
|
|
12992
|
+
}
|
|
12993
|
+
for (const pointerState of internal.pointerMap.values()) {
|
|
12994
|
+
for (let i = 0; i < pointerState.initialHits.length; i++) {
|
|
12995
|
+
if (pointerState.initialHits[i] === object) pointerState.initialHits[i] = newObject;
|
|
12996
|
+
}
|
|
12997
|
+
pointerState.hovered.forEach((value, key) => {
|
|
12998
|
+
if (value.eventObject === object || value.object === object) {
|
|
12999
|
+
pointerState.hovered.delete(key);
|
|
13000
|
+
const next = {
|
|
13001
|
+
...value,
|
|
13002
|
+
eventObject: value.eventObject === object ? newObject : value.eventObject,
|
|
13003
|
+
object: value.object === object ? newObject : value.object
|
|
13004
|
+
};
|
|
13005
|
+
pointerState.hovered.set(makeId(next), next);
|
|
13006
|
+
}
|
|
13007
|
+
});
|
|
13008
|
+
const captureData = pointerState.captured.get(object);
|
|
13009
|
+
if (captureData) {
|
|
13010
|
+
pointerState.captured.delete(object);
|
|
13011
|
+
pointerState.captured.set(newObject, {
|
|
13012
|
+
...captureData,
|
|
13013
|
+
intersection: {
|
|
13014
|
+
...captureData.intersection,
|
|
13015
|
+
object: captureData.intersection.object === object ? newObject : captureData.intersection.object,
|
|
13016
|
+
eventObject: captureData.intersection.eventObject === object ? newObject : captureData.intersection.eventObject
|
|
13404
13017
|
}
|
|
13405
|
-
}
|
|
13406
|
-
|
|
13407
|
-
|
|
13408
|
-
|
|
13409
|
-
|
|
13410
|
-
|
|
13411
|
-
|
|
13412
|
-
|
|
13413
|
-
|
|
13414
|
-
|
|
13415
|
-
|
|
13416
|
-
|
|
13417
|
-
|
|
13418
|
-
return z = "useActionState", D(), N(), $t(e);
|
|
13419
|
-
}, useOptimistic: function(e, n) {
|
|
13420
|
-
return z = "useOptimistic", D(), N(), of(e, n);
|
|
13421
|
-
}, useMemoCache: function(e) {
|
|
13422
|
-
return D(), Oa(e);
|
|
13423
|
-
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
13424
|
-
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
13425
|
-
}, useEffectEvent: function(e) {
|
|
13426
|
-
return z = "useEffectEvent", D(), N(), oa(e);
|
|
13427
|
-
} };
|
|
13428
|
-
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();
|
|
13429
|
-
Object.freeze(Fy);
|
|
13430
|
-
var zg = { enqueueSetState: function(e, n, o) {
|
|
13431
|
-
e = e._reactInternals;
|
|
13432
|
-
var i = Nt(e), s = zo(i);
|
|
13433
|
-
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));
|
|
13434
|
-
}, enqueueReplaceState: function(e, n, o) {
|
|
13435
|
-
e = e._reactInternals;
|
|
13436
|
-
var i = Nt(e), s = zo(i);
|
|
13437
|
-
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));
|
|
13438
|
-
}, enqueueForceUpdate: function(e, n) {
|
|
13439
|
-
e = e._reactInternals;
|
|
13440
|
-
var o = Nt(e), i = zo(o);
|
|
13441
|
-
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));
|
|
13442
|
-
} }, 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;
|
|
13443
|
-
Yy = /* @__PURE__ */ new Set();
|
|
13444
|
-
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) {
|
|
13445
|
-
var n = Ee(un), o = n.data.get(e);
|
|
13446
|
-
return o === void 0 && (o = e(), n.data.set(e, o)), o;
|
|
13447
|
-
}, cacheSignal: function() {
|
|
13448
|
-
return Ee(un).controller.signal;
|
|
13449
|
-
}, getOwner: function() {
|
|
13450
|
-
return di;
|
|
13451
|
-
} }, pm = 0, hm = 1, mm = 2, gm = 3, ym = 4;
|
|
13452
|
-
if (typeof Symbol == "function" && Symbol.for) {
|
|
13453
|
-
var bp = Symbol.for;
|
|
13454
|
-
pm = bp("selector.component"), hm = bp("selector.has_pseudo_class"), mm = bp("selector.role"), gm = bp("selector.test_id"), ym = bp("selector.text");
|
|
13018
|
+
});
|
|
13019
|
+
}
|
|
13020
|
+
}
|
|
13021
|
+
unregisterVisibility(store, object);
|
|
13022
|
+
}
|
|
13023
|
+
function removeInteractivity(store, object) {
|
|
13024
|
+
const { internal } = store.getState();
|
|
13025
|
+
internal.interaction = internal.interaction.filter((o) => o !== object);
|
|
13026
|
+
for (const [pointerId, pointerState] of internal.pointerMap) {
|
|
13027
|
+
pointerState.initialHits = pointerState.initialHits.filter((o) => o !== object);
|
|
13028
|
+
pointerState.hovered.forEach((value, key) => {
|
|
13029
|
+
if (value.eventObject === object || value.object === object) {
|
|
13030
|
+
pointerState.hovered.delete(key);
|
|
13455
13031
|
}
|
|
13456
|
-
|
|
13457
|
-
|
|
13458
|
-
|
|
13459
|
-
|
|
13460
|
-
|
|
13032
|
+
});
|
|
13033
|
+
if (pointerState.captured.has(object)) {
|
|
13034
|
+
releaseInternalPointerCapture(internal, object, pointerId);
|
|
13035
|
+
}
|
|
13036
|
+
}
|
|
13037
|
+
unregisterVisibility(store, object);
|
|
13038
|
+
}
|
|
13039
|
+
function createEvents(store) {
|
|
13040
|
+
function calculateDistance(event, pointerId) {
|
|
13041
|
+
const { internal } = store.getState();
|
|
13042
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13043
|
+
if (!pointerState) return 0;
|
|
13044
|
+
const [initialX, initialY] = pointerState.initialClick;
|
|
13045
|
+
const dx = event.offsetX - initialX;
|
|
13046
|
+
const dy = event.offsetY - initialY;
|
|
13047
|
+
return Math.round(Math.sqrt(dx * dx + dy * dy));
|
|
13048
|
+
}
|
|
13049
|
+
function filterPointerEvents(objects) {
|
|
13050
|
+
return objects.filter(
|
|
13051
|
+
(obj) => ["Move", "Over", "Enter", "Out", "Leave"].some(
|
|
13052
|
+
(name) => obj.__r3f?.handlers["onPointer" + name]
|
|
13053
|
+
) || ["OverEnter", "OverLeave", "Over"].some(
|
|
13054
|
+
(name) => obj.__r3f?.handlers["onDrag" + name]
|
|
13055
|
+
) || obj.__r3f?.handlers.onDrop
|
|
13056
|
+
);
|
|
13057
|
+
}
|
|
13058
|
+
function intersect(event, filter) {
|
|
13059
|
+
const state = store.getState();
|
|
13060
|
+
const duplicates = /* @__PURE__ */ new Set();
|
|
13061
|
+
const intersections = [];
|
|
13062
|
+
const eventsObjects = filter ? filter(state.internal.interaction) : state.internal.interaction;
|
|
13063
|
+
for (let i = 0; i < eventsObjects.length; i++) {
|
|
13064
|
+
const state2 = getRootState(eventsObjects[i]);
|
|
13065
|
+
if (state2) {
|
|
13066
|
+
state2.raycaster.camera = void 0;
|
|
13461
13067
|
}
|
|
13462
|
-
|
|
13463
|
-
|
|
13464
|
-
|
|
13465
|
-
|
|
13466
|
-
|
|
13467
|
-
|
|
13468
|
-
|
|
13469
|
-
|
|
13470
|
-
|
|
13471
|
-
|
|
13472
|
-
|
|
13473
|
-
|
|
13474
|
-
|
|
13475
|
-
|
|
13476
|
-
|
|
13477
|
-
|
|
13478
|
-
|
|
13479
|
-
|
|
13480
|
-
|
|
13481
|
-
|
|
13482
|
-
|
|
13483
|
-
|
|
13484
|
-
|
|
13485
|
-
}, le.attemptContinuousHydration = function(e) {
|
|
13486
|
-
if (e.tag === 13 || e.tag === 31) {
|
|
13487
|
-
var n = On(e, 67108864);
|
|
13488
|
-
n !== null && We(n, e, 67108864), rl(e, 67108864);
|
|
13068
|
+
}
|
|
13069
|
+
if (!state.previousRoot) {
|
|
13070
|
+
state.events.compute?.(event, state);
|
|
13071
|
+
}
|
|
13072
|
+
function handleRaycast(obj) {
|
|
13073
|
+
const state2 = getRootState(obj);
|
|
13074
|
+
if (!state2 || !state2.events.enabled || state2.raycaster.camera === null) return [];
|
|
13075
|
+
if (state2.raycaster.camera === void 0) {
|
|
13076
|
+
state2.events.compute?.(event, state2, state2.previousRoot?.getState());
|
|
13077
|
+
if (state2.raycaster.camera === void 0) state2.raycaster.camera = null;
|
|
13078
|
+
}
|
|
13079
|
+
if (!state2.raycaster.camera) return [];
|
|
13080
|
+
obj.updateWorldMatrix(true, true);
|
|
13081
|
+
return state2.raycaster.intersectObject(obj, true);
|
|
13082
|
+
}
|
|
13083
|
+
let hits = eventsObjects.flatMap(handleRaycast).sort((a, b) => {
|
|
13084
|
+
const aInteractivePriority = a.object.userData?.interactivePriority;
|
|
13085
|
+
const bInteractivePriority = b.object.userData?.interactivePriority;
|
|
13086
|
+
if (aInteractivePriority !== void 0 || bInteractivePriority !== void 0) {
|
|
13087
|
+
if (aInteractivePriority !== void 0 && bInteractivePriority === void 0) return -1;
|
|
13088
|
+
if (bInteractivePriority !== void 0 && aInteractivePriority === void 0) return 1;
|
|
13089
|
+
if (aInteractivePriority !== bInteractivePriority) {
|
|
13090
|
+
return (bInteractivePriority ?? 0) - (aInteractivePriority ?? 0);
|
|
13489
13091
|
}
|
|
13490
|
-
}
|
|
13491
|
-
|
|
13492
|
-
|
|
13493
|
-
|
|
13494
|
-
|
|
13495
|
-
|
|
13092
|
+
}
|
|
13093
|
+
const aState = getRootState(a.object);
|
|
13094
|
+
const bState = getRootState(b.object);
|
|
13095
|
+
const aPriority = aState?.events?.priority ?? 1;
|
|
13096
|
+
const bPriority = bState?.events?.priority ?? 1;
|
|
13097
|
+
return bPriority - aPriority || a.distance - b.distance;
|
|
13098
|
+
}).filter((item) => {
|
|
13099
|
+
const id = makeId(item);
|
|
13100
|
+
if (duplicates.has(id)) return false;
|
|
13101
|
+
duplicates.add(id);
|
|
13102
|
+
return true;
|
|
13103
|
+
});
|
|
13104
|
+
if (state.events.filter) hits = state.events.filter(hits, state);
|
|
13105
|
+
for (const hit of hits) {
|
|
13106
|
+
let eventObject = hit.object;
|
|
13107
|
+
while (eventObject) {
|
|
13108
|
+
if (eventObject.__r3f?.eventCount) {
|
|
13109
|
+
intersections.push({ ...hit, eventObject });
|
|
13496
13110
|
}
|
|
13497
|
-
|
|
13498
|
-
|
|
13499
|
-
|
|
13500
|
-
|
|
13501
|
-
|
|
13502
|
-
|
|
13503
|
-
|
|
13504
|
-
|
|
13505
|
-
|
|
13111
|
+
eventObject = eventObject.parent;
|
|
13112
|
+
}
|
|
13113
|
+
}
|
|
13114
|
+
if ("pointerId" in event) {
|
|
13115
|
+
const pointerId = event.pointerId;
|
|
13116
|
+
const pointerState = state.internal.pointerMap.get(pointerId);
|
|
13117
|
+
if (pointerState?.captured.size) {
|
|
13118
|
+
for (const captureData of pointerState.captured.values()) {
|
|
13119
|
+
if (!duplicates.has(makeId(captureData.intersection))) intersections.push(captureData.intersection);
|
|
13120
|
+
}
|
|
13121
|
+
}
|
|
13122
|
+
}
|
|
13123
|
+
return intersections;
|
|
13124
|
+
}
|
|
13125
|
+
function handleIntersects(intersections, event, delta, callback) {
|
|
13126
|
+
if (intersections.length) {
|
|
13127
|
+
const localState = { stopped: false };
|
|
13128
|
+
for (const hit of intersections) {
|
|
13129
|
+
const state = getRootState(hit.object);
|
|
13130
|
+
if (state) {
|
|
13131
|
+
const { raycaster, pointer, camera, internal } = state;
|
|
13132
|
+
const unprojectedPoint = new webgpu.Vector3(pointer.x, pointer.y, 0).unproject(camera);
|
|
13133
|
+
const hasPointerCapture = (id) => {
|
|
13134
|
+
const pointerState = internal.pointerMap.get(id);
|
|
13135
|
+
return pointerState?.captured.has(hit.eventObject) ?? false;
|
|
13136
|
+
};
|
|
13137
|
+
const setPointerCapture = (id) => {
|
|
13138
|
+
const captureData = { intersection: hit, target: event.target };
|
|
13139
|
+
const pointerState = getPointerState(internal, id);
|
|
13140
|
+
pointerState.captured.set(hit.eventObject, captureData);
|
|
13141
|
+
event.target.setPointerCapture(id);
|
|
13142
|
+
};
|
|
13143
|
+
const releasePointerCapture = (id) => {
|
|
13144
|
+
releaseInternalPointerCapture(internal, hit.eventObject, id);
|
|
13145
|
+
};
|
|
13146
|
+
const extractEventProps = {};
|
|
13147
|
+
for (const prop in event) {
|
|
13148
|
+
const property = event[prop];
|
|
13149
|
+
if (typeof property !== "function") extractEventProps[prop] = property;
|
|
13150
|
+
}
|
|
13151
|
+
const eventPointerId = "pointerId" in event ? event.pointerId : void 0;
|
|
13152
|
+
const raycastEvent = {
|
|
13153
|
+
...hit,
|
|
13154
|
+
...extractEventProps,
|
|
13155
|
+
pointer,
|
|
13156
|
+
intersections,
|
|
13157
|
+
stopped: localState.stopped,
|
|
13158
|
+
delta,
|
|
13159
|
+
unprojectedPoint,
|
|
13160
|
+
ray: raycaster.ray,
|
|
13161
|
+
camera,
|
|
13162
|
+
pointerId: eventPointerId,
|
|
13163
|
+
// Hijack stopPropagation, which just sets a flag
|
|
13164
|
+
stopPropagation() {
|
|
13165
|
+
const pointerState = eventPointerId !== void 0 ? internal.pointerMap.get(eventPointerId) : void 0;
|
|
13166
|
+
if (
|
|
13167
|
+
// ...if this pointer hasn't been captured
|
|
13168
|
+
!pointerState?.captured.size || // ... or if the hit object is capturing the pointer
|
|
13169
|
+
pointerState.captured.has(hit.eventObject)
|
|
13170
|
+
) {
|
|
13171
|
+
raycastEvent.stopped = localState.stopped = true;
|
|
13172
|
+
if (pointerState?.hovered.size && Array.from(pointerState.hovered.values()).find((i) => i.eventObject === hit.eventObject)) {
|
|
13173
|
+
const higher = intersections.slice(0, intersections.indexOf(hit));
|
|
13174
|
+
cancelPointer([...higher, hit], eventPointerId);
|
|
13506
13175
|
}
|
|
13507
|
-
Kn(e), (ye & (Zn | uo)) === Jn && (Pp = me() + Fg, Wa(0));
|
|
13508
13176
|
}
|
|
13509
|
-
}
|
|
13510
|
-
|
|
13511
|
-
|
|
13512
|
-
|
|
13513
|
-
|
|
13177
|
+
},
|
|
13178
|
+
// there should be a distinction between target and currentTarget
|
|
13179
|
+
target: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
13180
|
+
currentTarget: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
13181
|
+
nativeEvent: event
|
|
13182
|
+
};
|
|
13183
|
+
callback(raycastEvent);
|
|
13184
|
+
if (localState.stopped === true) break;
|
|
13514
13185
|
}
|
|
13515
|
-
}
|
|
13516
|
-
|
|
13517
|
-
|
|
13518
|
-
|
|
13519
|
-
|
|
13520
|
-
|
|
13521
|
-
|
|
13522
|
-
|
|
13523
|
-
|
|
13524
|
-
|
|
13525
|
-
|
|
13526
|
-
|
|
13527
|
-
|
|
13528
|
-
|
|
13529
|
-
|
|
13530
|
-
|
|
13531
|
-
|
|
13186
|
+
}
|
|
13187
|
+
}
|
|
13188
|
+
return intersections;
|
|
13189
|
+
}
|
|
13190
|
+
function cancelPointer(intersections, pointerId) {
|
|
13191
|
+
const { internal } = store.getState();
|
|
13192
|
+
const pid = pointerId ?? DEFAULT_POINTER_ID;
|
|
13193
|
+
const pointerState = internal.pointerMap.get(pid);
|
|
13194
|
+
if (!pointerState) return;
|
|
13195
|
+
for (const [hoveredId, hoveredObj] of pointerState.hovered) {
|
|
13196
|
+
if (!intersections.length || !intersections.find(
|
|
13197
|
+
(hit) => hit.object === hoveredObj.object && hit.index === hoveredObj.index && hit.instanceId === hoveredObj.instanceId
|
|
13198
|
+
)) {
|
|
13199
|
+
const eventObject = hoveredObj.eventObject;
|
|
13200
|
+
const instance = eventObject.__r3f;
|
|
13201
|
+
pointerState.hovered.delete(hoveredId);
|
|
13202
|
+
if (instance?.eventCount) {
|
|
13203
|
+
const handlers = instance.handlers;
|
|
13204
|
+
const data = { ...hoveredObj, intersections };
|
|
13205
|
+
handlers.onPointerOut?.(data);
|
|
13206
|
+
handlers.onPointerLeave?.(data);
|
|
13207
|
+
handlers.onDragOverLeave?.(data);
|
|
13532
13208
|
}
|
|
13533
|
-
|
|
13534
|
-
|
|
13535
|
-
|
|
13536
|
-
|
|
13537
|
-
|
|
13538
|
-
|
|
13539
|
-
|
|
13540
|
-
|
|
13541
|
-
|
|
13542
|
-
|
|
13543
|
-
|
|
13544
|
-
|
|
13545
|
-
|
|
13546
|
-
|
|
13547
|
-
|
|
13548
|
-
|
|
13549
|
-
|
|
13550
|
-
|
|
13551
|
-
|
|
13552
|
-
|
|
13553
|
-
|
|
13554
|
-
|
|
13555
|
-
|
|
13556
|
-
|
|
13557
|
-
|
|
13558
|
-
|
|
13559
|
-
|
|
13560
|
-
|
|
13561
|
-
|
|
13562
|
-
|
|
13563
|
-
|
|
13564
|
-
|
|
13565
|
-
|
|
13566
|
-
an(o), x.T = n;
|
|
13209
|
+
}
|
|
13210
|
+
}
|
|
13211
|
+
}
|
|
13212
|
+
function pointerMissed(event, objects) {
|
|
13213
|
+
for (let i = 0; i < objects.length; i++) {
|
|
13214
|
+
const instance = objects[i].__r3f;
|
|
13215
|
+
instance?.handlers.onPointerMissed?.(event);
|
|
13216
|
+
}
|
|
13217
|
+
}
|
|
13218
|
+
function dragOverMissed(event, objects) {
|
|
13219
|
+
for (let i = 0; i < objects.length; i++) {
|
|
13220
|
+
const instance = objects[i].__r3f;
|
|
13221
|
+
instance?.handlers.onDragOverMissed?.(event);
|
|
13222
|
+
}
|
|
13223
|
+
}
|
|
13224
|
+
function dropMissed(event, objects) {
|
|
13225
|
+
for (let i = 0; i < objects.length; i++) {
|
|
13226
|
+
const instance = objects[i].__r3f;
|
|
13227
|
+
instance?.handlers.onDropMissed?.(event);
|
|
13228
|
+
}
|
|
13229
|
+
}
|
|
13230
|
+
function cleanupPointer(pointerId) {
|
|
13231
|
+
const { internal } = store.getState();
|
|
13232
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13233
|
+
if (pointerState) {
|
|
13234
|
+
for (const [, hoveredObj] of pointerState.hovered) {
|
|
13235
|
+
const eventObject = hoveredObj.eventObject;
|
|
13236
|
+
const instance = eventObject.__r3f;
|
|
13237
|
+
if (instance?.eventCount) {
|
|
13238
|
+
const handlers = instance.handlers;
|
|
13239
|
+
const data = { ...hoveredObj, intersections: [] };
|
|
13240
|
+
handlers.onPointerOut?.(data);
|
|
13241
|
+
handlers.onPointerLeave?.(data);
|
|
13567
13242
|
}
|
|
13568
|
-
}
|
|
13569
|
-
|
|
13570
|
-
|
|
13571
|
-
|
|
13572
|
-
|
|
13573
|
-
|
|
13243
|
+
}
|
|
13244
|
+
internal.pointerMap.delete(pointerId);
|
|
13245
|
+
}
|
|
13246
|
+
internal.pointerDirty.delete(pointerId);
|
|
13247
|
+
}
|
|
13248
|
+
function processDeferredPointer(event, pointerId) {
|
|
13249
|
+
const state = store.getState();
|
|
13250
|
+
const { internal } = state;
|
|
13251
|
+
if (!state.events.enabled) return;
|
|
13252
|
+
const filter = filterPointerEvents;
|
|
13253
|
+
const hits = intersect(event, filter);
|
|
13254
|
+
cancelPointer(hits, pointerId);
|
|
13255
|
+
function onIntersect(data) {
|
|
13256
|
+
const eventObject = data.eventObject;
|
|
13257
|
+
const instance = eventObject.__r3f;
|
|
13258
|
+
if (!instance?.eventCount) return;
|
|
13259
|
+
const handlers = instance.handlers;
|
|
13260
|
+
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
13261
|
+
const id = makeId(data);
|
|
13262
|
+
const pointerState = getPointerState(internal, pointerId);
|
|
13263
|
+
const hoveredItem = pointerState.hovered.get(id);
|
|
13264
|
+
if (!hoveredItem) {
|
|
13265
|
+
pointerState.hovered.set(id, data);
|
|
13266
|
+
handlers.onPointerOver?.(data);
|
|
13267
|
+
handlers.onPointerEnter?.(data);
|
|
13268
|
+
} else if (hoveredItem.stopped) {
|
|
13269
|
+
data.stopPropagation();
|
|
13270
|
+
}
|
|
13271
|
+
}
|
|
13272
|
+
handlers.onPointerMove?.(data);
|
|
13273
|
+
}
|
|
13274
|
+
handleIntersects(hits, event, 0, onIntersect);
|
|
13275
|
+
}
|
|
13276
|
+
function handlePointer(name) {
|
|
13277
|
+
switch (name) {
|
|
13278
|
+
case "onPointerLeave":
|
|
13279
|
+
case "onDragLeave":
|
|
13280
|
+
return () => cancelPointer([]);
|
|
13281
|
+
// Global cancel of these events
|
|
13282
|
+
case "onPointerCancel":
|
|
13283
|
+
return (event) => {
|
|
13284
|
+
const pointerId = getPointerId(event);
|
|
13285
|
+
cleanupPointer(pointerId);
|
|
13286
|
+
};
|
|
13287
|
+
case "onLostPointerCapture":
|
|
13288
|
+
return (event) => {
|
|
13289
|
+
const { internal } = store.getState();
|
|
13290
|
+
const pointerId = getPointerId(event);
|
|
13291
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13292
|
+
if (pointerState?.captured.size) {
|
|
13293
|
+
requestAnimationFrame(() => {
|
|
13294
|
+
const pointerState2 = internal.pointerMap.get(pointerId);
|
|
13295
|
+
if (pointerState2?.captured.size) {
|
|
13296
|
+
pointerState2.captured.clear();
|
|
13297
|
+
}
|
|
13298
|
+
cancelPointer([], pointerId);
|
|
13299
|
+
});
|
|
13300
|
+
}
|
|
13301
|
+
};
|
|
13302
|
+
}
|
|
13303
|
+
return function handleEvent(event) {
|
|
13304
|
+
const state = store.getState();
|
|
13305
|
+
const { onPointerMissed, onDragOverMissed, onDropMissed, internal, events } = state;
|
|
13306
|
+
const pointerId = getPointerId(event);
|
|
13307
|
+
internal.lastEvent.current = event;
|
|
13308
|
+
if (!events.enabled) return;
|
|
13309
|
+
const isPointerMove = name === "onPointerMove";
|
|
13310
|
+
const isDragOver = name === "onDragOver";
|
|
13311
|
+
const isDrop = name === "onDrop";
|
|
13312
|
+
const isClickEvent = name === "onClick" || name === "onContextMenu" || name === "onDoubleClick";
|
|
13313
|
+
const isPointerDown = name === "onPointerDown";
|
|
13314
|
+
const isPointerUp = name === "onPointerUp";
|
|
13315
|
+
const isWheel = name === "onWheel";
|
|
13316
|
+
const canDeferRaycasts = events.frameTimedRaycasts && state.frameloop === "always";
|
|
13317
|
+
if (isPointerMove && canDeferRaycasts) {
|
|
13318
|
+
events.compute?.(event, state);
|
|
13319
|
+
internal.pointerDirty.set(pointerId, event);
|
|
13320
|
+
return;
|
|
13321
|
+
}
|
|
13322
|
+
if (isWheel && canDeferRaycasts && !events.alwaysFireOnScroll) {
|
|
13323
|
+
events.compute?.(event, state);
|
|
13324
|
+
internal.pointerDirty.set(pointerId, event);
|
|
13325
|
+
return;
|
|
13326
|
+
}
|
|
13327
|
+
if ((isClickEvent || isPointerDown || isPointerUp) && internal.pointerDirty.has(pointerId)) {
|
|
13328
|
+
const deferredEvent = internal.pointerDirty.get(pointerId);
|
|
13329
|
+
internal.pointerDirty.delete(pointerId);
|
|
13330
|
+
processDeferredPointer(deferredEvent, pointerId);
|
|
13331
|
+
}
|
|
13332
|
+
const filter = isPointerMove || isDragOver || isDrop ? filterPointerEvents : void 0;
|
|
13333
|
+
const hits = intersect(event, filter);
|
|
13334
|
+
const delta = isClickEvent ? calculateDistance(event, pointerId) : 0;
|
|
13335
|
+
if (isPointerDown) {
|
|
13336
|
+
const pointerState2 = getPointerState(internal, pointerId);
|
|
13337
|
+
pointerState2.initialClick = [event.offsetX, event.offsetY];
|
|
13338
|
+
pointerState2.initialHits = hits.map((hit) => hit.eventObject);
|
|
13339
|
+
}
|
|
13340
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13341
|
+
const initialHits = pointerState?.initialHits ?? [];
|
|
13342
|
+
if (isClickEvent && !hits.length) {
|
|
13343
|
+
if (delta <= 2) {
|
|
13344
|
+
pointerMissed(event, internal.interaction);
|
|
13345
|
+
if (onPointerMissed) onPointerMissed(event);
|
|
13574
13346
|
}
|
|
13575
|
-
}
|
|
13576
|
-
|
|
13577
|
-
|
|
13578
|
-
|
|
13579
|
-
|
|
13580
|
-
|
|
13581
|
-
|
|
13582
|
-
|
|
13583
|
-
|
|
13584
|
-
|
|
13585
|
-
|
|
13586
|
-
|
|
13587
|
-
|
|
13588
|
-
|
|
13589
|
-
|
|
13590
|
-
|
|
13591
|
-
|
|
13592
|
-
|
|
13593
|
-
|
|
13347
|
+
}
|
|
13348
|
+
if (isDragOver && !hits.length) {
|
|
13349
|
+
dragOverMissed(event, internal.interaction);
|
|
13350
|
+
if (onDragOverMissed) onDragOverMissed(event);
|
|
13351
|
+
}
|
|
13352
|
+
if (isDrop && !hits.length) {
|
|
13353
|
+
dropMissed(event, internal.interaction);
|
|
13354
|
+
if (onDropMissed) onDropMissed(event);
|
|
13355
|
+
}
|
|
13356
|
+
if (isPointerMove || isDragOver) {
|
|
13357
|
+
cancelPointer(hits, pointerId);
|
|
13358
|
+
}
|
|
13359
|
+
function onIntersect(data) {
|
|
13360
|
+
const eventObject = data.eventObject;
|
|
13361
|
+
const instance = eventObject.__r3f;
|
|
13362
|
+
if (!instance?.eventCount) return;
|
|
13363
|
+
const handlers = instance.handlers;
|
|
13364
|
+
if (isPointerMove) {
|
|
13365
|
+
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
13366
|
+
const id = makeId(data);
|
|
13367
|
+
const pointerState2 = getPointerState(internal, pointerId);
|
|
13368
|
+
const hoveredItem = pointerState2.hovered.get(id);
|
|
13369
|
+
if (!hoveredItem) {
|
|
13370
|
+
pointerState2.hovered.set(id, data);
|
|
13371
|
+
handlers.onPointerOver?.(data);
|
|
13372
|
+
handlers.onPointerEnter?.(data);
|
|
13373
|
+
} else if (hoveredItem.stopped) {
|
|
13374
|
+
data.stopPropagation();
|
|
13594
13375
|
}
|
|
13595
13376
|
}
|
|
13596
|
-
|
|
13597
|
-
|
|
13598
|
-
|
|
13599
|
-
|
|
13600
|
-
|
|
13601
|
-
|
|
13602
|
-
|
|
13603
|
-
|
|
13604
|
-
|
|
13605
|
-
|
|
13606
|
-
|
|
13607
|
-
|
|
13608
|
-
if (
|
|
13609
|
-
|
|
13610
|
-
|
|
13611
|
-
|
|
13612
|
-
|
|
13613
|
-
|
|
13614
|
-
|
|
13615
|
-
|
|
13616
|
-
|
|
13617
|
-
|
|
13618
|
-
|
|
13619
|
-
|
|
13620
|
-
|
|
13621
|
-
|
|
13622
|
-
|
|
13623
|
-
|
|
13624
|
-
|
|
13625
|
-
|
|
13626
|
-
|
|
13627
|
-
var o = n[e++], i = o.tag;
|
|
13628
|
-
if (!Kr(o)) {
|
|
13629
|
-
if ((i === 5 || i === 26 || i === 27) && Ft(o.stateNode)) return true;
|
|
13630
|
-
for (o = o.child; o !== null; ) n.push(o), o = o.sibling;
|
|
13377
|
+
handlers.onPointerMove?.(data);
|
|
13378
|
+
} else if (isDragOver) {
|
|
13379
|
+
const id = makeId(data);
|
|
13380
|
+
const pointerState2 = getPointerState(internal, pointerId);
|
|
13381
|
+
const hoveredItem = pointerState2.hovered.get(id);
|
|
13382
|
+
if (!hoveredItem) {
|
|
13383
|
+
pointerState2.hovered.set(id, data);
|
|
13384
|
+
handlers.onDragOverEnter?.(data);
|
|
13385
|
+
} else if (hoveredItem.stopped) {
|
|
13386
|
+
data.stopPropagation();
|
|
13387
|
+
}
|
|
13388
|
+
handlers.onDragOver?.(data);
|
|
13389
|
+
} else if (isDrop) {
|
|
13390
|
+
handlers.onDrop?.(data);
|
|
13391
|
+
} else {
|
|
13392
|
+
const handler = handlers[name];
|
|
13393
|
+
if (handler) {
|
|
13394
|
+
if (!isClickEvent || initialHits.includes(eventObject)) {
|
|
13395
|
+
pointerMissed(
|
|
13396
|
+
event,
|
|
13397
|
+
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
13398
|
+
);
|
|
13399
|
+
handler(data);
|
|
13400
|
+
}
|
|
13401
|
+
} else {
|
|
13402
|
+
if (isClickEvent && initialHits.includes(eventObject)) {
|
|
13403
|
+
pointerMissed(
|
|
13404
|
+
event,
|
|
13405
|
+
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
13406
|
+
);
|
|
13407
|
+
}
|
|
13631
13408
|
}
|
|
13632
13409
|
}
|
|
13633
|
-
|
|
13634
|
-
|
|
13635
|
-
|
|
13636
|
-
|
|
13637
|
-
|
|
13638
|
-
|
|
13639
|
-
|
|
13640
|
-
|
|
13410
|
+
}
|
|
13411
|
+
handleIntersects(hits, event, delta, onIntersect);
|
|
13412
|
+
};
|
|
13413
|
+
}
|
|
13414
|
+
function flushDeferredPointers() {
|
|
13415
|
+
const { internal, events } = store.getState();
|
|
13416
|
+
if (!events.frameTimedRaycasts) return;
|
|
13417
|
+
for (const [pointerId, event] of internal.pointerDirty) {
|
|
13418
|
+
processDeferredPointer(event, pointerId);
|
|
13419
|
+
}
|
|
13420
|
+
internal.pointerDirty.clear();
|
|
13421
|
+
}
|
|
13422
|
+
return { handlePointer, flushDeferredPointers, processDeferredPointer };
|
|
13423
|
+
}
|
|
13424
|
+
const DOM_EVENTS = {
|
|
13425
|
+
onClick: ["click", false],
|
|
13426
|
+
onContextMenu: ["contextmenu", false],
|
|
13427
|
+
onDoubleClick: ["dblclick", false],
|
|
13428
|
+
onDragEnter: ["dragenter", false],
|
|
13429
|
+
onDragLeave: ["dragleave", false],
|
|
13430
|
+
onDragOver: ["dragover", false],
|
|
13431
|
+
onDrop: ["drop", false],
|
|
13432
|
+
onWheel: ["wheel", true],
|
|
13433
|
+
onPointerDown: ["pointerdown", true],
|
|
13434
|
+
onPointerUp: ["pointerup", true],
|
|
13435
|
+
onPointerLeave: ["pointerleave", true],
|
|
13436
|
+
onPointerMove: ["pointermove", true],
|
|
13437
|
+
onPointerCancel: ["pointercancel", true],
|
|
13438
|
+
onLostPointerCapture: ["lostpointercapture", true]
|
|
13439
|
+
};
|
|
13440
|
+
function createPointerEvents(store) {
|
|
13441
|
+
const { handlePointer, flushDeferredPointers, processDeferredPointer } = createEvents(store);
|
|
13442
|
+
let nextXRPointerId = XR_POINTER_ID_START;
|
|
13443
|
+
const xrPointers = /* @__PURE__ */ new Map();
|
|
13444
|
+
return {
|
|
13445
|
+
priority: 1,
|
|
13446
|
+
enabled: true,
|
|
13447
|
+
frameTimedRaycasts: true,
|
|
13448
|
+
alwaysFireOnScroll: true,
|
|
13449
|
+
updateOnFrame: false,
|
|
13450
|
+
compute(event, state) {
|
|
13451
|
+
state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
|
|
13452
|
+
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
13453
|
+
},
|
|
13454
|
+
connected: void 0,
|
|
13455
|
+
handlers: Object.keys(DOM_EVENTS).reduce(
|
|
13456
|
+
(acc, key) => ({ ...acc, [key]: handlePointer(key) }),
|
|
13457
|
+
{}
|
|
13458
|
+
),
|
|
13459
|
+
update: (pointerId) => {
|
|
13460
|
+
const { events, internal } = store.getState();
|
|
13461
|
+
if (!events.handlers) return;
|
|
13462
|
+
if (pointerId !== void 0) {
|
|
13463
|
+
const event = internal.pointerDirty.get(pointerId);
|
|
13464
|
+
if (event) {
|
|
13465
|
+
internal.pointerDirty.delete(pointerId);
|
|
13466
|
+
processDeferredPointer(event, pointerId);
|
|
13467
|
+
} else if (internal.lastEvent?.current) {
|
|
13468
|
+
processDeferredPointer(internal.lastEvent.current, pointerId);
|
|
13641
13469
|
}
|
|
13642
|
-
|
|
13643
|
-
|
|
13644
|
-
|
|
13645
|
-
|
|
13646
|
-
|
|
13647
|
-
No matching component was found for:
|
|
13648
|
-
`) + e.join(" > ");
|
|
13470
|
+
} else {
|
|
13471
|
+
flushDeferredPointers();
|
|
13472
|
+
if (internal.lastEvent?.current) {
|
|
13473
|
+
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
13649
13474
|
}
|
|
13650
|
-
|
|
13651
|
-
|
|
13652
|
-
|
|
13653
|
-
|
|
13654
|
-
|
|
13655
|
-
|
|
13656
|
-
|
|
13657
|
-
|
|
13658
|
-
|
|
13475
|
+
}
|
|
13476
|
+
},
|
|
13477
|
+
flush: () => {
|
|
13478
|
+
const { events, internal } = store.getState();
|
|
13479
|
+
flushDeferredPointers();
|
|
13480
|
+
if (events.updateOnFrame && internal.lastEvent?.current && events.handlers) {
|
|
13481
|
+
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
13482
|
+
}
|
|
13483
|
+
},
|
|
13484
|
+
connect: (target) => {
|
|
13485
|
+
if (!target) return;
|
|
13486
|
+
const { set, events } = store.getState();
|
|
13487
|
+
events.disconnect?.();
|
|
13488
|
+
set((state) => ({ events: { ...state.events, connected: target } }));
|
|
13489
|
+
if (events.handlers) {
|
|
13490
|
+
for (const name in events.handlers) {
|
|
13491
|
+
const event = events.handlers[name];
|
|
13492
|
+
const [eventName, passive] = DOM_EVENTS[name];
|
|
13493
|
+
target.addEventListener(eventName, event, { passive });
|
|
13659
13494
|
}
|
|
13660
|
-
}
|
|
13661
|
-
|
|
13662
|
-
|
|
13663
|
-
|
|
13664
|
-
|
|
13665
|
-
|
|
13666
|
-
|
|
13667
|
-
|
|
13668
|
-
|
|
13669
|
-
|
|
13670
|
-
}
|
|
13495
|
+
}
|
|
13496
|
+
},
|
|
13497
|
+
disconnect: () => {
|
|
13498
|
+
const { set, events } = store.getState();
|
|
13499
|
+
if (events.connected) {
|
|
13500
|
+
if (events.handlers) {
|
|
13501
|
+
for (const name in events.handlers) {
|
|
13502
|
+
const event = events.handlers[name];
|
|
13503
|
+
const [eventName] = DOM_EVENTS[name];
|
|
13504
|
+
events.connected.removeEventListener(eventName, event);
|
|
13505
|
+
}
|
|
13506
|
+
}
|
|
13507
|
+
set((state) => ({ events: { ...state.events, connected: void 0 } }));
|
|
13508
|
+
}
|
|
13509
|
+
},
|
|
13510
|
+
// PREVIEW (A8): the XR pointer registration API may change before stable.
|
|
13511
|
+
registerPointer: (config) => {
|
|
13512
|
+
const pointerId = nextXRPointerId++;
|
|
13513
|
+
xrPointers.set(pointerId, config);
|
|
13514
|
+
const { internal } = store.getState();
|
|
13515
|
+
getPointerState(internal, pointerId);
|
|
13516
|
+
return pointerId;
|
|
13517
|
+
},
|
|
13518
|
+
unregisterPointer: (pointerId) => {
|
|
13519
|
+
xrPointers.delete(pointerId);
|
|
13520
|
+
const { internal } = store.getState();
|
|
13521
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13522
|
+
if (pointerState) {
|
|
13523
|
+
for (const [, hoveredObj] of pointerState.hovered) {
|
|
13524
|
+
const eventObject = hoveredObj.eventObject;
|
|
13525
|
+
const instance = eventObject.__r3f;
|
|
13526
|
+
if (instance?.eventCount) {
|
|
13527
|
+
const handlers = instance.handlers;
|
|
13528
|
+
const data = { ...hoveredObj, intersections: [] };
|
|
13529
|
+
handlers.onPointerOut?.(data);
|
|
13530
|
+
handlers.onPointerLeave?.(data);
|
|
13531
|
+
}
|
|
13671
13532
|
}
|
|
13672
|
-
|
|
13673
|
-
|
|
13674
|
-
|
|
13675
|
-
|
|
13676
|
-
|
|
13677
|
-
var S = bm.indexOf(s);
|
|
13678
|
-
0 <= S && bm.splice(S, 1), f();
|
|
13679
|
-
} };
|
|
13680
|
-
}, le.shouldError = function(e) {
|
|
13681
|
-
return pu(e);
|
|
13682
|
-
}, le.shouldSuspend = function(e) {
|
|
13683
|
-
return fu(e);
|
|
13684
|
-
}, le.startHostTransition = function(e, n, o, i) {
|
|
13685
|
-
if (e.tag !== 5) throw Error("Expected the form instance to be a HostComponent. This is a bug in React.");
|
|
13686
|
-
var s = uf(e).queue;
|
|
13687
|
-
Hp(e), nt(e, s, n, Xt, o === null ? Em : function() {
|
|
13688
|
-
x.T === null && console.error("requestFormReset was called outside a transition or action. To fix, move to an action, or wrap with startTransition.");
|
|
13689
|
-
var u = uf(e);
|
|
13690
|
-
return u.next === null && (u = e.alternate.memoizedState), qi(e, u.next.queue, {}, Nt(e)), o(i);
|
|
13691
|
-
});
|
|
13692
|
-
}, le.updateContainer = function(e, n, o, i) {
|
|
13693
|
-
var s = n.current, u = Nt(s);
|
|
13694
|
-
return As(s, u, e, n, o, i), u;
|
|
13695
|
-
}, le.updateContainerSync = Wh, le;
|
|
13696
|
-
}, Tt.exports.default = Tt.exports, Object.defineProperty(Tt.exports, "__esModule", { value: true }));
|
|
13697
|
-
})(Mg)), Mg.exports;
|
|
13698
|
-
}
|
|
13699
|
-
var Eb;
|
|
13700
|
-
function n0() {
|
|
13701
|
-
return Eb || (Eb = 1, process.env.NODE_ENV === "production" ? Rm.exports = Kb() : Rm.exports = e0()), Rm.exports;
|
|
13533
|
+
internal.pointerMap.delete(pointerId);
|
|
13534
|
+
}
|
|
13535
|
+
internal.pointerDirty.delete(pointerId);
|
|
13536
|
+
}
|
|
13537
|
+
};
|
|
13702
13538
|
}
|
|
13703
|
-
var t0 = n0();
|
|
13704
|
-
const r0 = Xb(t0);
|
|
13705
|
-
|
|
13706
|
-
const t = 1, o = 8, r = 32, e = 2;
|
|
13707
13539
|
|
|
13708
13540
|
function createReconciler(config) {
|
|
13709
13541
|
const reconciler2 = r0(config);
|
|
@@ -13868,7 +13700,15 @@ function setFiberRef(fiber, publicInstance) {
|
|
|
13868
13700
|
}
|
|
13869
13701
|
}
|
|
13870
13702
|
const reconstructed = [];
|
|
13871
|
-
function
|
|
13703
|
+
function flushReconstructedInstances() {
|
|
13704
|
+
if (reconstructed.length === 0) return;
|
|
13705
|
+
try {
|
|
13706
|
+
swapReconstructedInstances();
|
|
13707
|
+
} finally {
|
|
13708
|
+
reconstructed.length = 0;
|
|
13709
|
+
}
|
|
13710
|
+
}
|
|
13711
|
+
function swapReconstructedInstances() {
|
|
13872
13712
|
for (const [instance] of reconstructed) {
|
|
13873
13713
|
const parent = instance.parent;
|
|
13874
13714
|
if (parent) {
|
|
@@ -13886,7 +13726,9 @@ function swapInstances() {
|
|
|
13886
13726
|
}
|
|
13887
13727
|
}
|
|
13888
13728
|
if (instance.isHidden) unhideInstance(instance);
|
|
13889
|
-
if (isObject3D(instance.object)
|
|
13729
|
+
if (isObject3D(instance.object) && !instance.parent) {
|
|
13730
|
+
removeInteractivity(findInitialRoot(instance), instance.object);
|
|
13731
|
+
}
|
|
13890
13732
|
if (instance.object.__r3f) delete instance.object.__r3f;
|
|
13891
13733
|
if (instance.type !== "primitive") disposeOnIdle(instance.object);
|
|
13892
13734
|
}
|
|
@@ -13895,9 +13737,13 @@ function swapInstances() {
|
|
|
13895
13737
|
const parent = instance.parent;
|
|
13896
13738
|
if (parent) {
|
|
13897
13739
|
const target = catalogue[toPascalCase(instance.type)];
|
|
13740
|
+
const prevObject = instance.object;
|
|
13898
13741
|
instance.object = instance.props.object ?? new target(...instance.props.args ?? []);
|
|
13899
13742
|
instance.object.__r3f = instance;
|
|
13900
13743
|
setFiberRef(fiber, instance.object);
|
|
13744
|
+
if (isObject3D(prevObject) && isObject3D(instance.object)) {
|
|
13745
|
+
swapInteractivity(findInitialRoot(instance), prevObject, instance.object);
|
|
13746
|
+
}
|
|
13901
13747
|
delete instance.appliedOnce;
|
|
13902
13748
|
instance.eventCount = 0;
|
|
13903
13749
|
instance.handlers = {};
|
|
@@ -13917,14 +13763,114 @@ function swapInstances() {
|
|
|
13917
13763
|
invalidateInstance(instance);
|
|
13918
13764
|
}
|
|
13919
13765
|
}
|
|
13920
|
-
reconstructed.length = 0;
|
|
13921
13766
|
}
|
|
13922
13767
|
const handleTextInstance = () => {
|
|
13923
13768
|
};
|
|
13924
13769
|
const NO_CONTEXT = {};
|
|
13925
13770
|
let currentUpdatePriority = NoEventPriority;
|
|
13926
|
-
|
|
13927
|
-
|
|
13771
|
+
function getEventPriority(type) {
|
|
13772
|
+
switch (type) {
|
|
13773
|
+
case "beforetoggle":
|
|
13774
|
+
case "cancel":
|
|
13775
|
+
case "click":
|
|
13776
|
+
case "close":
|
|
13777
|
+
case "contextmenu":
|
|
13778
|
+
case "copy":
|
|
13779
|
+
case "cut":
|
|
13780
|
+
case "auxclick":
|
|
13781
|
+
case "dblclick":
|
|
13782
|
+
case "dragend":
|
|
13783
|
+
case "dragstart":
|
|
13784
|
+
case "drop":
|
|
13785
|
+
case "focusin":
|
|
13786
|
+
case "focusout":
|
|
13787
|
+
case "input":
|
|
13788
|
+
case "invalid":
|
|
13789
|
+
case "keydown":
|
|
13790
|
+
case "keypress":
|
|
13791
|
+
case "keyup":
|
|
13792
|
+
case "mousedown":
|
|
13793
|
+
case "mouseup":
|
|
13794
|
+
case "paste":
|
|
13795
|
+
case "pause":
|
|
13796
|
+
case "play":
|
|
13797
|
+
case "pointercancel":
|
|
13798
|
+
case "pointerdown":
|
|
13799
|
+
case "pointerup":
|
|
13800
|
+
case "ratechange":
|
|
13801
|
+
case "reset":
|
|
13802
|
+
case "resize":
|
|
13803
|
+
case "seeked":
|
|
13804
|
+
case "submit":
|
|
13805
|
+
case "touchcancel":
|
|
13806
|
+
case "touchend":
|
|
13807
|
+
case "touchstart":
|
|
13808
|
+
case "volumechange":
|
|
13809
|
+
case "change":
|
|
13810
|
+
case "selectionchange":
|
|
13811
|
+
case "compositionstart":
|
|
13812
|
+
case "compositionend":
|
|
13813
|
+
case "compositionupdate":
|
|
13814
|
+
case "beforeinput":
|
|
13815
|
+
case "blur":
|
|
13816
|
+
case "fullscreenchange":
|
|
13817
|
+
case "focus":
|
|
13818
|
+
case "hashchange":
|
|
13819
|
+
case "popstate":
|
|
13820
|
+
case "select":
|
|
13821
|
+
case "selectstart":
|
|
13822
|
+
return e;
|
|
13823
|
+
case "drag":
|
|
13824
|
+
case "dragenter":
|
|
13825
|
+
case "dragexit":
|
|
13826
|
+
case "dragleave":
|
|
13827
|
+
case "dragover":
|
|
13828
|
+
case "mousemove":
|
|
13829
|
+
case "mouseout":
|
|
13830
|
+
case "mouseover":
|
|
13831
|
+
case "pointermove":
|
|
13832
|
+
case "pointerout":
|
|
13833
|
+
case "pointerover":
|
|
13834
|
+
case "scroll":
|
|
13835
|
+
case "touchmove":
|
|
13836
|
+
case "wheel":
|
|
13837
|
+
case "mouseenter":
|
|
13838
|
+
case "mouseleave":
|
|
13839
|
+
case "pointerenter":
|
|
13840
|
+
case "pointerleave":
|
|
13841
|
+
return o;
|
|
13842
|
+
case "message": {
|
|
13843
|
+
switch (Tb.unstable_getCurrentPriorityLevel()) {
|
|
13844
|
+
case Tb.unstable_ImmediatePriority:
|
|
13845
|
+
return e;
|
|
13846
|
+
case Tb.unstable_UserBlockingPriority:
|
|
13847
|
+
return o;
|
|
13848
|
+
case Tb.unstable_NormalPriority:
|
|
13849
|
+
case Tb.unstable_LowPriority:
|
|
13850
|
+
return r;
|
|
13851
|
+
case Tb.unstable_IdlePriority:
|
|
13852
|
+
return i$1;
|
|
13853
|
+
default:
|
|
13854
|
+
return r;
|
|
13855
|
+
}
|
|
13856
|
+
}
|
|
13857
|
+
default:
|
|
13858
|
+
return r;
|
|
13859
|
+
}
|
|
13860
|
+
}
|
|
13861
|
+
function scheduleMicrotask(callback) {
|
|
13862
|
+
if (typeof queueMicrotask === "function") {
|
|
13863
|
+
queueMicrotask(callback);
|
|
13864
|
+
} else if (typeof Promise !== "undefined") {
|
|
13865
|
+
Promise.resolve().then(callback).catch((error) => {
|
|
13866
|
+
setTimeout(() => {
|
|
13867
|
+
throw error;
|
|
13868
|
+
});
|
|
13869
|
+
});
|
|
13870
|
+
} else {
|
|
13871
|
+
setTimeout(callback);
|
|
13872
|
+
}
|
|
13873
|
+
}
|
|
13928
13874
|
const reconciler = /* @__PURE__ */ createReconciler({
|
|
13929
13875
|
isPrimaryRenderer: false,
|
|
13930
13876
|
warnsIfNotActing: false,
|
|
@@ -13963,16 +13909,15 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13963
13909
|
else if (newProps.args?.length !== oldProps.args?.length) reconstruct = true;
|
|
13964
13910
|
else if (newProps.args?.some((value, index) => value !== oldProps.args?.[index])) reconstruct = true;
|
|
13965
13911
|
if (reconstruct) {
|
|
13966
|
-
reconstructed.push([instance,
|
|
13912
|
+
reconstructed.push([instance, getInstanceProps(newProps), fiber]);
|
|
13967
13913
|
} else {
|
|
13968
13914
|
const changedProps = diffProps(instance, newProps);
|
|
13969
|
-
|
|
13970
|
-
|
|
13971
|
-
|
|
13972
|
-
|
|
13915
|
+
const attach2 = instance.props.attach;
|
|
13916
|
+
instance.props = getInstanceProps(newProps);
|
|
13917
|
+
if (attach2 !== void 0) instance.props.attach = attach2;
|
|
13918
|
+
else delete instance.props.attach;
|
|
13919
|
+
if (Object.keys(changedProps).length) applyProps(instance.object, changedProps);
|
|
13973
13920
|
}
|
|
13974
|
-
const isTailSibling = fiber.sibling === null || (fiber.flags & Update) === NoFlags;
|
|
13975
|
-
if (isTailSibling) swapInstances();
|
|
13976
13921
|
},
|
|
13977
13922
|
finalizeInitialChildren: (instance) => {
|
|
13978
13923
|
for (const prop in instance.props) {
|
|
@@ -13997,8 +13942,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13997
13942
|
const target = container.getState().internal.container ?? container.getState().scene;
|
|
13998
13943
|
return prepare(target, container, "", {});
|
|
13999
13944
|
},
|
|
14000
|
-
|
|
14001
|
-
|
|
13945
|
+
// Reconstructed instances are swapped once all mutations are committed,
|
|
13946
|
+
// before layout effects run so refs point to the new objects
|
|
13947
|
+
resetAfterCommit: flushReconstructedInstances,
|
|
14002
13948
|
shouldSetTextContent: () => false,
|
|
14003
13949
|
clearContainer: () => false,
|
|
14004
13950
|
hideInstance,
|
|
@@ -14006,6 +13952,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
14006
13952
|
createTextInstance: handleTextInstance,
|
|
14007
13953
|
hideTextInstance: handleTextInstance,
|
|
14008
13954
|
unhideTextInstance: handleTextInstance,
|
|
13955
|
+
// Mirrors react-dom, which flushes discrete work in microtasks
|
|
13956
|
+
supportsMicrotasks: true,
|
|
13957
|
+
scheduleMicrotask,
|
|
14009
13958
|
scheduleTimeout: typeof setTimeout === "function" ? setTimeout : void 0,
|
|
14010
13959
|
cancelTimeout: typeof clearTimeout === "function" ? clearTimeout : void 0,
|
|
14011
13960
|
noTimeout: -1,
|
|
@@ -14046,28 +13995,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
14046
13995
|
},
|
|
14047
13996
|
resolveUpdatePriority() {
|
|
14048
13997
|
if (currentUpdatePriority !== NoEventPriority) return currentUpdatePriority;
|
|
14049
|
-
|
|
14050
|
-
|
|
14051
|
-
|
|
14052
|
-
case "dblclick":
|
|
14053
|
-
case "dragenter":
|
|
14054
|
-
case "dragleave":
|
|
14055
|
-
case "drop":
|
|
14056
|
-
case "pointercancel":
|
|
14057
|
-
case "pointerdown":
|
|
14058
|
-
case "pointerup":
|
|
14059
|
-
return e;
|
|
14060
|
-
case "dragover":
|
|
14061
|
-
case "pointermove":
|
|
14062
|
-
case "pointerout":
|
|
14063
|
-
case "pointerover":
|
|
14064
|
-
case "pointerenter":
|
|
14065
|
-
case "pointerleave":
|
|
14066
|
-
case "wheel":
|
|
14067
|
-
return o;
|
|
14068
|
-
default:
|
|
14069
|
-
return r;
|
|
14070
|
-
}
|
|
13998
|
+
const eventType = typeof window !== "undefined" ? window.event?.type : void 0;
|
|
13999
|
+
if (eventType === void 0) return r;
|
|
14000
|
+
return getEventPriority(eventType);
|
|
14071
14001
|
},
|
|
14072
14002
|
resetFormInstance() {
|
|
14073
14003
|
},
|
|
@@ -14769,8 +14699,214 @@ function PortalInner({ state = {}, children, container }) {
|
|
|
14769
14699
|
) })
|
|
14770
14700
|
);
|
|
14771
14701
|
}
|
|
14772
|
-
function flushSync(fn) {
|
|
14773
|
-
return reconciler.flushSyncFromReconciler(fn);
|
|
14702
|
+
function flushSync(fn) {
|
|
14703
|
+
return reconciler.flushSyncFromReconciler(fn);
|
|
14704
|
+
}
|
|
14705
|
+
|
|
14706
|
+
const isRef = (obj) => obj.current && obj.current.isScene;
|
|
14707
|
+
const resolveScene = (scene) => isRef(scene) ? scene.current : scene;
|
|
14708
|
+
function setEnvProps(background, scene, defaultScene, texture, sceneProps = {}) {
|
|
14709
|
+
sceneProps = {
|
|
14710
|
+
backgroundBlurriness: 0,
|
|
14711
|
+
backgroundIntensity: 1,
|
|
14712
|
+
backgroundRotation: [0, 0, 0],
|
|
14713
|
+
environmentIntensity: 1,
|
|
14714
|
+
environmentRotation: [0, 0, 0],
|
|
14715
|
+
...sceneProps
|
|
14716
|
+
};
|
|
14717
|
+
const target = resolveScene(scene || defaultScene);
|
|
14718
|
+
const oldbg = target.background;
|
|
14719
|
+
const oldenv = target.environment;
|
|
14720
|
+
const oldSceneProps = {
|
|
14721
|
+
// @ts-ignore
|
|
14722
|
+
backgroundBlurriness: target.backgroundBlurriness,
|
|
14723
|
+
// @ts-ignore
|
|
14724
|
+
backgroundIntensity: target.backgroundIntensity,
|
|
14725
|
+
// @ts-ignore
|
|
14726
|
+
backgroundRotation: target.backgroundRotation?.clone?.() ?? [0, 0, 0],
|
|
14727
|
+
// @ts-ignore
|
|
14728
|
+
environmentIntensity: target.environmentIntensity,
|
|
14729
|
+
// @ts-ignore
|
|
14730
|
+
environmentRotation: target.environmentRotation?.clone?.() ?? [0, 0, 0]
|
|
14731
|
+
};
|
|
14732
|
+
if (background !== "only") target.environment = texture;
|
|
14733
|
+
if (background) target.background = texture;
|
|
14734
|
+
applyProps(target, sceneProps);
|
|
14735
|
+
return () => {
|
|
14736
|
+
if (background !== "only") target.environment = oldenv;
|
|
14737
|
+
if (background) target.background = oldbg;
|
|
14738
|
+
applyProps(target, oldSceneProps);
|
|
14739
|
+
};
|
|
14740
|
+
}
|
|
14741
|
+
function EnvironmentMap({ scene, background = false, map, ...config }) {
|
|
14742
|
+
const defaultScene = useThree((state) => state.scene);
|
|
14743
|
+
React__namespace.useLayoutEffect(() => {
|
|
14744
|
+
if (map) return setEnvProps(background, scene, defaultScene, map, config);
|
|
14745
|
+
});
|
|
14746
|
+
return null;
|
|
14747
|
+
}
|
|
14748
|
+
function EnvironmentCube({
|
|
14749
|
+
background = false,
|
|
14750
|
+
scene,
|
|
14751
|
+
blur,
|
|
14752
|
+
backgroundBlurriness,
|
|
14753
|
+
backgroundIntensity,
|
|
14754
|
+
backgroundRotation,
|
|
14755
|
+
environmentIntensity,
|
|
14756
|
+
environmentRotation,
|
|
14757
|
+
...rest
|
|
14758
|
+
}) {
|
|
14759
|
+
const texture = useEnvironment(rest);
|
|
14760
|
+
const defaultScene = useThree((state) => state.scene);
|
|
14761
|
+
React__namespace.useLayoutEffect(() => {
|
|
14762
|
+
return setEnvProps(background, scene, defaultScene, texture, {
|
|
14763
|
+
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
14764
|
+
backgroundIntensity,
|
|
14765
|
+
backgroundRotation,
|
|
14766
|
+
environmentIntensity,
|
|
14767
|
+
environmentRotation
|
|
14768
|
+
});
|
|
14769
|
+
});
|
|
14770
|
+
React__namespace.useEffect(() => {
|
|
14771
|
+
return () => {
|
|
14772
|
+
texture.dispose();
|
|
14773
|
+
};
|
|
14774
|
+
}, [texture]);
|
|
14775
|
+
return null;
|
|
14776
|
+
}
|
|
14777
|
+
function EnvironmentPortal({
|
|
14778
|
+
children,
|
|
14779
|
+
near = 0.1,
|
|
14780
|
+
far = 1e3,
|
|
14781
|
+
resolution = 256,
|
|
14782
|
+
frames = 1,
|
|
14783
|
+
map,
|
|
14784
|
+
background = false,
|
|
14785
|
+
blur,
|
|
14786
|
+
backgroundBlurriness,
|
|
14787
|
+
backgroundIntensity,
|
|
14788
|
+
backgroundRotation,
|
|
14789
|
+
environmentIntensity,
|
|
14790
|
+
environmentRotation,
|
|
14791
|
+
scene,
|
|
14792
|
+
files,
|
|
14793
|
+
path,
|
|
14794
|
+
preset = void 0,
|
|
14795
|
+
extensions
|
|
14796
|
+
}) {
|
|
14797
|
+
const renderer = useThree((state) => state.renderer);
|
|
14798
|
+
const isLegacy = useThree((state) => state.isLegacy);
|
|
14799
|
+
const defaultScene = useThree((state) => state.scene);
|
|
14800
|
+
const camera = React__namespace.useRef(null);
|
|
14801
|
+
const [virtualScene] = React__namespace.useState(() => new webgpu.Scene());
|
|
14802
|
+
const fbo = React__namespace.useMemo(() => {
|
|
14803
|
+
const fbo2 = isLegacy ? new WebGLCubeRenderTarget(resolution) : new webgpu.CubeRenderTarget(resolution);
|
|
14804
|
+
fbo2.texture.type = webgpu.HalfFloatType;
|
|
14805
|
+
return fbo2;
|
|
14806
|
+
}, [resolution, isLegacy]);
|
|
14807
|
+
React__namespace.useEffect(() => {
|
|
14808
|
+
return () => {
|
|
14809
|
+
fbo.dispose();
|
|
14810
|
+
};
|
|
14811
|
+
}, [fbo]);
|
|
14812
|
+
React__namespace.useLayoutEffect(() => {
|
|
14813
|
+
if (frames === 1) {
|
|
14814
|
+
const autoClear = renderer.autoClear;
|
|
14815
|
+
renderer.autoClear = true;
|
|
14816
|
+
camera.current.update(renderer, virtualScene);
|
|
14817
|
+
renderer.autoClear = autoClear;
|
|
14818
|
+
}
|
|
14819
|
+
return setEnvProps(background, scene, defaultScene, fbo.texture, {
|
|
14820
|
+
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
14821
|
+
backgroundIntensity,
|
|
14822
|
+
backgroundRotation,
|
|
14823
|
+
environmentIntensity,
|
|
14824
|
+
environmentRotation
|
|
14825
|
+
});
|
|
14826
|
+
}, [
|
|
14827
|
+
children,
|
|
14828
|
+
virtualScene,
|
|
14829
|
+
fbo.texture,
|
|
14830
|
+
scene,
|
|
14831
|
+
defaultScene,
|
|
14832
|
+
background,
|
|
14833
|
+
frames,
|
|
14834
|
+
renderer,
|
|
14835
|
+
blur,
|
|
14836
|
+
backgroundBlurriness,
|
|
14837
|
+
backgroundIntensity,
|
|
14838
|
+
backgroundRotation,
|
|
14839
|
+
environmentIntensity,
|
|
14840
|
+
environmentRotation
|
|
14841
|
+
]);
|
|
14842
|
+
let count = 1;
|
|
14843
|
+
useFrame(() => {
|
|
14844
|
+
if (frames === Infinity || count < frames) {
|
|
14845
|
+
const autoClear = renderer.autoClear;
|
|
14846
|
+
renderer.autoClear = true;
|
|
14847
|
+
camera.current.update(renderer, virtualScene);
|
|
14848
|
+
renderer.autoClear = autoClear;
|
|
14849
|
+
count++;
|
|
14850
|
+
}
|
|
14851
|
+
});
|
|
14852
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: createPortal(
|
|
14853
|
+
/* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
14854
|
+
children,
|
|
14855
|
+
/* @__PURE__ */ jsxRuntime.jsx("cubeCamera", { ref: camera, args: [near, far, fbo] }),
|
|
14856
|
+
files || preset ? /* @__PURE__ */ jsxRuntime.jsx(EnvironmentCube, { background: true, files, preset, path, extensions }) : map ? /* @__PURE__ */ jsxRuntime.jsx(EnvironmentMap, { background: true, map, extensions }) : null
|
|
14857
|
+
] }),
|
|
14858
|
+
virtualScene
|
|
14859
|
+
) });
|
|
14860
|
+
}
|
|
14861
|
+
function EnvironmentGround(props) {
|
|
14862
|
+
const textureDefault = useEnvironment(props);
|
|
14863
|
+
const texture = props.map || textureDefault;
|
|
14864
|
+
React__namespace.useMemo(() => extend({ GroundProjectedEnvImpl: GroundedSkybox_js.GroundedSkybox }), []);
|
|
14865
|
+
React__namespace.useEffect(() => {
|
|
14866
|
+
return () => {
|
|
14867
|
+
textureDefault.dispose();
|
|
14868
|
+
};
|
|
14869
|
+
}, [textureDefault]);
|
|
14870
|
+
const height = props.ground?.height ?? 15;
|
|
14871
|
+
const radius = props.ground?.radius ?? 60;
|
|
14872
|
+
const scale = props.ground?.scale ?? 1e3;
|
|
14873
|
+
const args = React__namespace.useMemo(
|
|
14874
|
+
() => [texture, height, radius],
|
|
14875
|
+
[texture, height, radius]
|
|
14876
|
+
);
|
|
14877
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
14878
|
+
/* @__PURE__ */ jsxRuntime.jsx(EnvironmentMap, { ...props, map: texture }),
|
|
14879
|
+
/* @__PURE__ */ jsxRuntime.jsx("groundProjectedEnvImpl", { args, scale })
|
|
14880
|
+
] });
|
|
14881
|
+
}
|
|
14882
|
+
function EnvironmentColor({ color, scene }) {
|
|
14883
|
+
const defaultScene = useThree((state) => state.scene);
|
|
14884
|
+
React__namespace.useLayoutEffect(() => {
|
|
14885
|
+
if (color === void 0) return;
|
|
14886
|
+
const target = resolveScene(scene || defaultScene);
|
|
14887
|
+
const oldBg = target.background;
|
|
14888
|
+
target.background = new webgpu.Color(color);
|
|
14889
|
+
return () => {
|
|
14890
|
+
target.background = oldBg;
|
|
14891
|
+
};
|
|
14892
|
+
});
|
|
14893
|
+
return null;
|
|
14894
|
+
}
|
|
14895
|
+
function EnvironmentDualSource(props) {
|
|
14896
|
+
const { backgroundFiles, ...envProps } = props;
|
|
14897
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
14898
|
+
/* @__PURE__ */ jsxRuntime.jsx(EnvironmentCube, { ...envProps, background: false }),
|
|
14899
|
+
/* @__PURE__ */ jsxRuntime.jsx(EnvironmentCube, { ...props, files: backgroundFiles, background: "only" })
|
|
14900
|
+
] });
|
|
14901
|
+
}
|
|
14902
|
+
function Environment(props) {
|
|
14903
|
+
if (props.color && !props.files && !props.preset && !props.map) {
|
|
14904
|
+
return /* @__PURE__ */ jsxRuntime.jsx(EnvironmentColor, { ...props });
|
|
14905
|
+
}
|
|
14906
|
+
if (props.backgroundFiles && props.backgroundFiles !== props.files) {
|
|
14907
|
+
return /* @__PURE__ */ jsxRuntime.jsx(EnvironmentDualSource, { ...props });
|
|
14908
|
+
}
|
|
14909
|
+
return props.ground ? /* @__PURE__ */ jsxRuntime.jsx(EnvironmentGround, { ...props }) : props.map ? /* @__PURE__ */ jsxRuntime.jsx(EnvironmentMap, { ...props }) : props.children ? /* @__PURE__ */ jsxRuntime.jsx(EnvironmentPortal, { ...props }) : /* @__PURE__ */ jsxRuntime.jsx(EnvironmentCube, { ...props });
|
|
14774
14910
|
}
|
|
14775
14911
|
|
|
14776
14912
|
function parseBackground(background) {
|
|
@@ -14816,14 +14952,133 @@ function parseRendererConfig(rendererProp) {
|
|
|
14816
14952
|
return { primaryCanvas: void 0, scheduler: void 0, renderer: rendererProp };
|
|
14817
14953
|
}
|
|
14818
14954
|
|
|
14955
|
+
const RESOURCE_KINDS = ["nodes", "uniforms", "buffers", "gpuStorage"];
|
|
14956
|
+
const ROOT_SCOPE = "";
|
|
14957
|
+
const registries = /* @__PURE__ */ new WeakMap();
|
|
14958
|
+
function getKindRegistry(store, kind) {
|
|
14959
|
+
let registry = registries.get(store);
|
|
14960
|
+
if (!registry) {
|
|
14961
|
+
registry = {
|
|
14962
|
+
nodes: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() },
|
|
14963
|
+
uniforms: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() },
|
|
14964
|
+
buffers: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() },
|
|
14965
|
+
gpuStorage: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() }
|
|
14966
|
+
};
|
|
14967
|
+
registries.set(store, registry);
|
|
14968
|
+
}
|
|
14969
|
+
return registry[kind];
|
|
14970
|
+
}
|
|
14971
|
+
function resolvePrimary$1(store) {
|
|
14972
|
+
return store.getState().primaryStore ?? store;
|
|
14973
|
+
}
|
|
14974
|
+
function isScopeValid(store, kind, scopeKey) {
|
|
14975
|
+
return getKindRegistry(store, kind).valid.has(scopeKey);
|
|
14976
|
+
}
|
|
14977
|
+
function peekStaged(store, kind, scopeKey) {
|
|
14978
|
+
return getKindRegistry(store, kind).staged.get(scopeKey);
|
|
14979
|
+
}
|
|
14980
|
+
function stageEntries(store, kind, scopeKey, entries) {
|
|
14981
|
+
const { staged } = getKindRegistry(store, kind);
|
|
14982
|
+
const current = staged.get(scopeKey);
|
|
14983
|
+
if (current) Object.assign(current, entries);
|
|
14984
|
+
else staged.set(scopeKey, { ...entries });
|
|
14985
|
+
}
|
|
14986
|
+
function readCommittedScope(map, scopeKey, isLeaf) {
|
|
14987
|
+
if (scopeKey === ROOT_SCOPE) {
|
|
14988
|
+
const leaves = {};
|
|
14989
|
+
for (const [key, value] of Object.entries(map)) if (isLeaf(value)) leaves[key] = value;
|
|
14990
|
+
return leaves;
|
|
14991
|
+
}
|
|
14992
|
+
const scopeData = map[scopeKey];
|
|
14993
|
+
if (scopeData && typeof scopeData === "object" && !isLeaf(scopeData)) return scopeData;
|
|
14994
|
+
return {};
|
|
14995
|
+
}
|
|
14996
|
+
function withStagedOverlay(store, kind, committed) {
|
|
14997
|
+
const { staged } = getKindRegistry(store, kind);
|
|
14998
|
+
if (staged.size === 0) return committed;
|
|
14999
|
+
const view = { ...committed };
|
|
15000
|
+
for (const [scopeKey, entries] of staged) {
|
|
15001
|
+
if (scopeKey === ROOT_SCOPE) Object.assign(view, entries);
|
|
15002
|
+
else view[scopeKey] = { ...view[scopeKey], ...entries };
|
|
15003
|
+
}
|
|
15004
|
+
return view;
|
|
15005
|
+
}
|
|
15006
|
+
function flushStagedScope(store, kind, scopeKey, isLeaf) {
|
|
15007
|
+
const registry = getKindRegistry(store, kind);
|
|
15008
|
+
const staged = registry.staged.get(scopeKey);
|
|
15009
|
+
if (!staged) return;
|
|
15010
|
+
registry.staged.delete(scopeKey);
|
|
15011
|
+
const replace = !registry.valid.has(scopeKey);
|
|
15012
|
+
store.setState((state) => {
|
|
15013
|
+
const map = state[kind];
|
|
15014
|
+
if (scopeKey === ROOT_SCOPE) {
|
|
15015
|
+
if (!replace) return { [kind]: { ...map, ...staged } };
|
|
15016
|
+
const next = {};
|
|
15017
|
+
for (const [key, value] of Object.entries(map)) if (!isLeaf(value)) next[key] = value;
|
|
15018
|
+
return { [kind]: { ...next, ...staged } };
|
|
15019
|
+
}
|
|
15020
|
+
const current = replace ? {} : map[scopeKey] ?? {};
|
|
15021
|
+
return { [kind]: { ...map, [scopeKey]: { ...current, ...staged } } };
|
|
15022
|
+
});
|
|
15023
|
+
registry.valid.add(scopeKey);
|
|
15024
|
+
}
|
|
15025
|
+
function invalidateResource(store, kind, scopeKey) {
|
|
15026
|
+
const registry = getKindRegistry(store, kind);
|
|
15027
|
+
if (scopeKey === void 0) {
|
|
15028
|
+
registry.valid.clear();
|
|
15029
|
+
registry.staged.clear();
|
|
15030
|
+
} else {
|
|
15031
|
+
registry.valid.delete(scopeKey);
|
|
15032
|
+
registry.staged.delete(scopeKey);
|
|
15033
|
+
}
|
|
15034
|
+
}
|
|
15035
|
+
function rebuildResource(store, kind, userScope) {
|
|
15036
|
+
const primary = resolvePrimary$1(store);
|
|
15037
|
+
invalidateResource(primary, kind, userScope === "root" ? ROOT_SCOPE : userScope);
|
|
15038
|
+
primary.setState((state) => ({ _hmrVersion: state._hmrVersion + 1 }));
|
|
15039
|
+
}
|
|
15040
|
+
function invalidateAllResources(store) {
|
|
15041
|
+
for (const kind of RESOURCE_KINDS) invalidateResource(store, kind);
|
|
15042
|
+
}
|
|
15043
|
+
function removeResourceEntries(store, kind, names, scope, isLeaf) {
|
|
15044
|
+
const staged = peekStaged(store, kind, scope ?? ROOT_SCOPE);
|
|
15045
|
+
if (staged) for (const name of names) delete staged[name];
|
|
15046
|
+
store.setState((state) => {
|
|
15047
|
+
const map = state[kind];
|
|
15048
|
+
if (scope) {
|
|
15049
|
+
const currentScope = { ...map[scope] };
|
|
15050
|
+
for (const name of names) delete currentScope[name];
|
|
15051
|
+
return { [kind]: { ...map, [scope]: currentScope } };
|
|
15052
|
+
}
|
|
15053
|
+
const next = { ...map };
|
|
15054
|
+
for (const name of names) if (isLeaf(next[name])) delete next[name];
|
|
15055
|
+
return { [kind]: next };
|
|
15056
|
+
});
|
|
15057
|
+
}
|
|
15058
|
+
function clearResourceEntries(store, kind, scope, isLeaf) {
|
|
15059
|
+
const registry = getKindRegistry(store, kind);
|
|
15060
|
+
if (scope && scope !== "root") registry.staged.delete(scope);
|
|
15061
|
+
else if (scope === "root") registry.staged.delete(ROOT_SCOPE);
|
|
15062
|
+
else registry.staged.clear();
|
|
15063
|
+
store.setState((state) => {
|
|
15064
|
+
const map = state[kind];
|
|
15065
|
+
if (scope && scope !== "root") {
|
|
15066
|
+
const { [scope]: _, ...rest } = map;
|
|
15067
|
+
return { [kind]: rest };
|
|
15068
|
+
}
|
|
15069
|
+
if (scope === "root") {
|
|
15070
|
+
const next = {};
|
|
15071
|
+
for (const [key, value] of Object.entries(map)) if (!isLeaf(value)) next[key] = value;
|
|
15072
|
+
return { [kind]: next };
|
|
15073
|
+
}
|
|
15074
|
+
return { [kind]: {} };
|
|
15075
|
+
});
|
|
15076
|
+
}
|
|
15077
|
+
|
|
14819
15078
|
function clearHmrCaches(store) {
|
|
14820
|
-
store.
|
|
14821
|
-
|
|
14822
|
-
|
|
14823
|
-
buffers: {},
|
|
14824
|
-
gpuStorage: {},
|
|
14825
|
-
_hmrVersion: state._hmrVersion + 1
|
|
14826
|
-
}));
|
|
15079
|
+
const primary = store.getState().primaryStore ?? store;
|
|
15080
|
+
invalidateAllResources(primary);
|
|
15081
|
+
primary.setState((state) => ({ _hmrVersion: state._hmrVersion + 1 }));
|
|
14827
15082
|
}
|
|
14828
15083
|
|
|
14829
15084
|
function CanvasImpl({
|
|
@@ -14960,7 +15215,7 @@ function CanvasImpl({
|
|
|
14960
15215
|
onDropMissed: (...args) => handleDropMissed.current?.(...args),
|
|
14961
15216
|
onCreated: (state) => {
|
|
14962
15217
|
state.events.connect?.(
|
|
14963
|
-
eventSource ? isRef(eventSource) ? eventSource.current : eventSource : divRef.current
|
|
15218
|
+
eventSource ? isRef$1(eventSource) ? eventSource.current : eventSource : divRef.current
|
|
14964
15219
|
);
|
|
14965
15220
|
if (eventPrefix) {
|
|
14966
15221
|
state.setEvents({
|
|
@@ -15136,30 +15391,31 @@ let ScopedStore = _ScopedStore;
|
|
|
15136
15391
|
function createScopedStore(data) {
|
|
15137
15392
|
return new ScopedStore(data);
|
|
15138
15393
|
}
|
|
15139
|
-
function createLazyCreatorState(state) {
|
|
15394
|
+
function createLazyCreatorState(state, store) {
|
|
15140
15395
|
let _uniforms = null;
|
|
15141
15396
|
let _nodes = null;
|
|
15142
15397
|
let _buffers = null;
|
|
15143
15398
|
let _gpuStorage = null;
|
|
15399
|
+
const view = (kind) => store ? withStagedOverlay(store, kind, state[kind]) : state[kind];
|
|
15144
15400
|
return Object.create(state, {
|
|
15145
15401
|
uniforms: {
|
|
15146
15402
|
get() {
|
|
15147
|
-
return _uniforms ?? (_uniforms = createScopedStore(
|
|
15403
|
+
return _uniforms ?? (_uniforms = createScopedStore(view("uniforms")));
|
|
15148
15404
|
}
|
|
15149
15405
|
},
|
|
15150
15406
|
nodes: {
|
|
15151
15407
|
get() {
|
|
15152
|
-
return _nodes ?? (_nodes = createScopedStore(
|
|
15408
|
+
return _nodes ?? (_nodes = createScopedStore(view("nodes")));
|
|
15153
15409
|
}
|
|
15154
15410
|
},
|
|
15155
15411
|
buffers: {
|
|
15156
15412
|
get() {
|
|
15157
|
-
return _buffers ?? (_buffers = createScopedStore(
|
|
15413
|
+
return _buffers ?? (_buffers = createScopedStore(view("buffers")));
|
|
15158
15414
|
}
|
|
15159
15415
|
},
|
|
15160
15416
|
gpuStorage: {
|
|
15161
15417
|
get() {
|
|
15162
|
-
return _gpuStorage ?? (_gpuStorage = createScopedStore(
|
|
15418
|
+
return _gpuStorage ?? (_gpuStorage = createScopedStore(view("gpuStorage")));
|
|
15163
15419
|
}
|
|
15164
15420
|
}
|
|
15165
15421
|
});
|
|
@@ -15282,65 +15538,56 @@ function useCompareMemoize(value, deep) {
|
|
|
15282
15538
|
return ref.current;
|
|
15283
15539
|
}
|
|
15284
15540
|
|
|
15541
|
+
function useScopedResource(options) {
|
|
15542
|
+
const { store, kind, scope, isLeaf, create, prepare, reconcile, input } = options;
|
|
15543
|
+
const scopeKey = scope ?? ROOT_SCOPE;
|
|
15544
|
+
const version = store((s) => s._hmrVersion);
|
|
15545
|
+
const entries = React.useMemo(() => {
|
|
15546
|
+
const staged = peekStaged(store, kind, scopeKey);
|
|
15547
|
+
const reusable = isScopeValid(store, kind, scopeKey);
|
|
15548
|
+
const map = store.getState()[kind];
|
|
15549
|
+
const committed = reusable ? readCommittedScope(map, scopeKey, isLeaf) : void 0;
|
|
15550
|
+
const result = {};
|
|
15551
|
+
let fresh = null;
|
|
15552
|
+
for (const [name, candidate] of Object.entries(create())) {
|
|
15553
|
+
const existing = staged?.[name] ?? committed?.[name];
|
|
15554
|
+
if (existing !== void 0) {
|
|
15555
|
+
result[name] = existing;
|
|
15556
|
+
reconcile?.(existing, candidate);
|
|
15557
|
+
} else {
|
|
15558
|
+
const value = prepare ? prepare(name, candidate) : candidate;
|
|
15559
|
+
result[name] = value;
|
|
15560
|
+
(fresh ?? (fresh = {}))[name] = value;
|
|
15561
|
+
}
|
|
15562
|
+
}
|
|
15563
|
+
if (fresh) stageEntries(store, kind, scopeKey, fresh);
|
|
15564
|
+
return result;
|
|
15565
|
+
}, [store, kind, scopeKey, version, input]);
|
|
15566
|
+
useIsomorphicLayoutEffect(() => {
|
|
15567
|
+
flushStagedScope(store, kind, scopeKey, isLeaf);
|
|
15568
|
+
});
|
|
15569
|
+
return entries;
|
|
15570
|
+
}
|
|
15571
|
+
|
|
15285
15572
|
const isUniformNode$1 = (value) => value !== null && typeof value === "object" && "value" in value && "uuid" in value;
|
|
15286
15573
|
function useUniforms(creatorOrScope, scope) {
|
|
15287
15574
|
const store = usePrimaryStore();
|
|
15288
15575
|
const removeUniforms2 = React.useCallback(
|
|
15289
|
-
(names, targetScope) =>
|
|
15290
|
-
const nameArray = Array.isArray(names) ? names : [names];
|
|
15291
|
-
store.setState((state) => {
|
|
15292
|
-
if (targetScope) {
|
|
15293
|
-
const currentScope = { ...state.uniforms[targetScope] };
|
|
15294
|
-
for (const name of nameArray) delete currentScope[name];
|
|
15295
|
-
return { uniforms: { ...state.uniforms, [targetScope]: currentScope } };
|
|
15296
|
-
}
|
|
15297
|
-
const uniforms2 = { ...state.uniforms };
|
|
15298
|
-
for (const name of nameArray) if (isUniformNode$1(uniforms2[name])) delete uniforms2[name];
|
|
15299
|
-
return { uniforms: uniforms2 };
|
|
15300
|
-
});
|
|
15301
|
-
},
|
|
15576
|
+
(names, targetScope) => removeResourceEntries(store, "uniforms", Array.isArray(names) ? names : [names], targetScope, isUniformNode$1),
|
|
15302
15577
|
[store]
|
|
15303
15578
|
);
|
|
15304
15579
|
const clearUniforms = React.useCallback(
|
|
15305
|
-
(targetScope) =>
|
|
15306
|
-
store.setState((state) => {
|
|
15307
|
-
if (targetScope && targetScope !== "root") {
|
|
15308
|
-
const { [targetScope]: _, ...rest } = state.uniforms;
|
|
15309
|
-
return { uniforms: rest };
|
|
15310
|
-
}
|
|
15311
|
-
if (targetScope === "root") {
|
|
15312
|
-
const uniforms2 = {};
|
|
15313
|
-
for (const [key, value] of Object.entries(state.uniforms)) {
|
|
15314
|
-
if (!isUniformNode$1(value)) uniforms2[key] = value;
|
|
15315
|
-
}
|
|
15316
|
-
return { uniforms: uniforms2 };
|
|
15317
|
-
}
|
|
15318
|
-
return { uniforms: {} };
|
|
15319
|
-
});
|
|
15320
|
-
},
|
|
15580
|
+
(targetScope) => clearResourceEntries(store, "uniforms", targetScope, isUniformNode$1),
|
|
15321
15581
|
[store]
|
|
15322
15582
|
);
|
|
15323
15583
|
const rebuildUniforms = React.useCallback(
|
|
15324
|
-
(targetScope) =>
|
|
15325
|
-
store.setState((state) => {
|
|
15326
|
-
let newUniforms = {};
|
|
15327
|
-
if (targetScope && targetScope !== "root") {
|
|
15328
|
-
const { [targetScope]: _, ...rest } = state.uniforms;
|
|
15329
|
-
newUniforms = rest;
|
|
15330
|
-
} else if (targetScope === "root") {
|
|
15331
|
-
for (const [key, value] of Object.entries(state.uniforms)) {
|
|
15332
|
-
if (!isUniformNode$1(value)) newUniforms[key] = value;
|
|
15333
|
-
}
|
|
15334
|
-
}
|
|
15335
|
-
return { uniforms: newUniforms, _hmrVersion: state._hmrVersion + 1 };
|
|
15336
|
-
});
|
|
15337
|
-
},
|
|
15584
|
+
(targetScope) => rebuildResource(store, "uniforms", targetScope),
|
|
15338
15585
|
[store]
|
|
15339
15586
|
);
|
|
15340
15587
|
const inputForMemoization = React.useMemo(() => {
|
|
15341
15588
|
let raw = creatorOrScope;
|
|
15342
15589
|
if (is.fun(creatorOrScope)) {
|
|
15343
|
-
const wrappedState = createLazyCreatorState(store.getState());
|
|
15590
|
+
const wrappedState = createLazyCreatorState(store.getState(), store);
|
|
15344
15591
|
raw = creatorOrScope(wrappedState);
|
|
15345
15592
|
}
|
|
15346
15593
|
if (raw && typeof raw === "object" && !Array.isArray(raw)) {
|
|
@@ -15355,80 +15602,43 @@ function useUniforms(creatorOrScope, scope) {
|
|
|
15355
15602
|
const memoizedInput = useCompareMemoize(inputForMemoization);
|
|
15356
15603
|
const isReader = memoizedInput === void 0 || typeof memoizedInput === "string";
|
|
15357
15604
|
const storeUniforms = usePrimaryThree((s) => s.uniforms);
|
|
15358
|
-
const
|
|
15359
|
-
|
|
15360
|
-
|
|
15361
|
-
|
|
15362
|
-
|
|
15363
|
-
|
|
15364
|
-
|
|
15365
|
-
|
|
15366
|
-
|
|
15367
|
-
|
|
15368
|
-
|
|
15369
|
-
|
|
15370
|
-
|
|
15371
|
-
|
|
15372
|
-
|
|
15373
|
-
|
|
15374
|
-
|
|
15375
|
-
|
|
15376
|
-
|
|
15377
|
-
|
|
15378
|
-
|
|
15379
|
-
|
|
15380
|
-
|
|
15381
|
-
|
|
15382
|
-
}
|
|
15383
|
-
for (const [name, node] of Object.entries(created)) {
|
|
15384
|
-
if (targetRecord[name]) {
|
|
15385
|
-
result[name] = targetRecord[name];
|
|
15386
|
-
const existingVal = result[name].value;
|
|
15387
|
-
const newVal = vectorize(node);
|
|
15388
|
-
let equals = newVal === existingVal;
|
|
15389
|
-
if (!equals && hasEqualsMethod(existingVal) && hasEqualsMethod(newVal)) {
|
|
15390
|
-
if (isThreeVector(existingVal) && isThreeVector(newVal)) {
|
|
15391
|
-
equals = vectorEquals(existingVal, newVal);
|
|
15392
|
-
} else if (isSameThreeType(existingVal, newVal)) {
|
|
15393
|
-
equals = existingVal.equals(newVal);
|
|
15394
|
-
}
|
|
15395
|
-
}
|
|
15396
|
-
if (!equals) result[name].value = newVal;
|
|
15397
|
-
} else {
|
|
15398
|
-
result[name] = createUniform(name, node, scope);
|
|
15399
|
-
hasNewUniforms = true;
|
|
15400
|
-
}
|
|
15401
|
-
}
|
|
15402
|
-
if (hasNewUniforms) {
|
|
15403
|
-
if (scope) {
|
|
15404
|
-
set((s) => ({
|
|
15405
|
-
uniforms: {
|
|
15406
|
-
...s.uniforms,
|
|
15407
|
-
[scope]: { ...s.uniforms[scope], ...result }
|
|
15408
|
-
}
|
|
15409
|
-
}));
|
|
15410
|
-
} else {
|
|
15411
|
-
set((s) => ({ uniforms: { ...s.uniforms, ...result } }));
|
|
15412
|
-
}
|
|
15605
|
+
const created = useScopedResource({
|
|
15606
|
+
store,
|
|
15607
|
+
kind: "uniforms",
|
|
15608
|
+
scope: isReader ? void 0 : scope,
|
|
15609
|
+
isLeaf: isUniformNode$1,
|
|
15610
|
+
input: memoizedInput,
|
|
15611
|
+
create: () => {
|
|
15612
|
+
if (isReader) return {};
|
|
15613
|
+
if (typeof memoizedInput !== "object" || memoizedInput === null) throw new Error("Invalid uniform input");
|
|
15614
|
+
return memoizedInput;
|
|
15615
|
+
},
|
|
15616
|
+
prepare: (name, candidate) => createUniform(name, candidate, scope),
|
|
15617
|
+
reconcile: (existing, candidate) => {
|
|
15618
|
+
const existingVal = existing.value;
|
|
15619
|
+
const newVal = vectorize(candidate);
|
|
15620
|
+
let equals = newVal === existingVal;
|
|
15621
|
+
if (!equals && hasEqualsMethod(existingVal) && hasEqualsMethod(newVal)) {
|
|
15622
|
+
if (isThreeVector(existingVal) && isThreeVector(newVal)) {
|
|
15623
|
+
equals = vectorEquals(existingVal, newVal);
|
|
15624
|
+
} else if (isSameThreeType(existingVal, newVal)) {
|
|
15625
|
+
equals = existingVal.equals(newVal);
|
|
15626
|
+
}
|
|
15627
|
+
}
|
|
15628
|
+
if (!equals) existing.value = newVal;
|
|
15413
15629
|
}
|
|
15414
|
-
|
|
15415
|
-
|
|
15630
|
+
});
|
|
15631
|
+
let uniforms = created;
|
|
15632
|
+
if (memoizedInput === void 0) {
|
|
15633
|
+
uniforms = storeUniforms;
|
|
15634
|
+
} else if (typeof memoizedInput === "string") {
|
|
15635
|
+
const scopeData = storeUniforms[memoizedInput];
|
|
15636
|
+
uniforms = scopeData && !isUniformNode$1(scopeData) ? scopeData : {};
|
|
15637
|
+
}
|
|
15416
15638
|
return { ...uniforms, removeUniforms: removeUniforms2, clearUniforms, rebuildUniforms };
|
|
15417
15639
|
}
|
|
15418
15640
|
function rebuildAllUniforms(store, scope) {
|
|
15419
|
-
store
|
|
15420
|
-
store.setState((state) => {
|
|
15421
|
-
let newUniforms = {};
|
|
15422
|
-
if (scope && scope !== "root") {
|
|
15423
|
-
const { [scope]: _, ...rest } = state.uniforms;
|
|
15424
|
-
newUniforms = rest;
|
|
15425
|
-
} else if (scope === "root") {
|
|
15426
|
-
for (const [key, value] of Object.entries(state.uniforms)) {
|
|
15427
|
-
if (!isUniformNode$1(value)) newUniforms[key] = value;
|
|
15428
|
-
}
|
|
15429
|
-
}
|
|
15430
|
-
return { uniforms: newUniforms, _hmrVersion: state._hmrVersion + 1 };
|
|
15431
|
-
});
|
|
15641
|
+
rebuildResource(store, "uniforms", scope);
|
|
15432
15642
|
}
|
|
15433
15643
|
function removeUniforms(set, names, scope) {
|
|
15434
15644
|
set((state) => {
|
|
@@ -15497,188 +15707,86 @@ const isUniformNode = (value) => value !== null && typeof value === "object" &&
|
|
|
15497
15707
|
const isTSLNode$1 = (value) => value !== null && typeof value === "object" && "uuid" in value && "nodeType" in value;
|
|
15498
15708
|
function useUniform(name, value) {
|
|
15499
15709
|
const store = useStore();
|
|
15500
|
-
const
|
|
15501
|
-
|
|
15502
|
-
|
|
15503
|
-
|
|
15504
|
-
|
|
15505
|
-
|
|
15710
|
+
const registered = useScopedResource({
|
|
15711
|
+
store,
|
|
15712
|
+
kind: "uniforms",
|
|
15713
|
+
scope: void 0,
|
|
15714
|
+
isLeaf: isUniformNode,
|
|
15715
|
+
input: name,
|
|
15716
|
+
create: () => value === void 0 ? {} : { [name]: value },
|
|
15717
|
+
prepare: createNamedUniform,
|
|
15718
|
+
reconcile: (existing2) => {
|
|
15506
15719
|
if (value !== void 0 && !isTSLNode$1(value) && !isUniformNode(value)) {
|
|
15507
|
-
|
|
15720
|
+
existing2.value = typeof value === "string" ? new webgpu.Color(value) : value;
|
|
15508
15721
|
}
|
|
15509
|
-
return existing;
|
|
15510
|
-
}
|
|
15511
|
-
if (value === void 0) {
|
|
15512
|
-
throw new Error(
|
|
15513
|
-
`[useUniform] Uniform "${name}" not found. Create it first with: useUniform('${name}', initialValue)`
|
|
15514
|
-
);
|
|
15515
|
-
}
|
|
15516
|
-
if (isUniformNode(value)) {
|
|
15517
|
-
const node2 = value;
|
|
15518
|
-
if (typeof node2.setName === "function") {
|
|
15519
|
-
node2.setName(name);
|
|
15520
|
-
}
|
|
15521
|
-
set((s) => ({
|
|
15522
|
-
uniforms: { ...s.uniforms, [name]: node2 }
|
|
15523
|
-
}));
|
|
15524
|
-
return node2;
|
|
15525
|
-
}
|
|
15526
|
-
let node;
|
|
15527
|
-
if (isTSLNode$1(value)) {
|
|
15528
|
-
node = uniformOf(value);
|
|
15529
|
-
} else if (typeof value === "string") {
|
|
15530
|
-
node = tsl.uniform(new webgpu.Color(value));
|
|
15531
|
-
} else {
|
|
15532
|
-
node = uniformOf(value);
|
|
15533
|
-
}
|
|
15534
|
-
if (typeof node.setName === "function") {
|
|
15535
|
-
node.setName(name);
|
|
15536
15722
|
}
|
|
15537
|
-
|
|
15538
|
-
|
|
15539
|
-
|
|
15540
|
-
|
|
15541
|
-
|
|
15542
|
-
})
|
|
15543
|
-
|
|
15544
|
-
|
|
15723
|
+
});
|
|
15724
|
+
if (registered[name]) return registered[name];
|
|
15725
|
+
const existing = peekStaged(store, "uniforms", ROOT_SCOPE)?.[name] ?? store.getState().uniforms[name];
|
|
15726
|
+
if (existing && isUniformNode(existing)) return existing;
|
|
15727
|
+
throw new Error(
|
|
15728
|
+
`[useUniform] Uniform "${name}" not found. Create it first with: useUniform('${name}', initialValue)`
|
|
15729
|
+
);
|
|
15730
|
+
}
|
|
15731
|
+
function createNamedUniform(name, value) {
|
|
15732
|
+
let node;
|
|
15733
|
+
if (isUniformNode(value)) {
|
|
15734
|
+
node = value;
|
|
15735
|
+
} else if (isTSLNode$1(value)) {
|
|
15736
|
+
node = uniformOf(value);
|
|
15737
|
+
} else if (typeof value === "string") {
|
|
15738
|
+
node = tsl.uniform(new webgpu.Color(value));
|
|
15739
|
+
} else {
|
|
15740
|
+
node = uniformOf(value);
|
|
15741
|
+
}
|
|
15742
|
+
if (typeof node.setName === "function") {
|
|
15743
|
+
node.setName(name);
|
|
15744
|
+
}
|
|
15745
|
+
return node;
|
|
15545
15746
|
}
|
|
15546
15747
|
|
|
15547
15748
|
const isTSLNode = (value) => value !== null && typeof value === "object" && ("uuid" in value || "nodeType" in value);
|
|
15548
15749
|
function useNodes(creatorOrScope, scope) {
|
|
15549
15750
|
const store = usePrimaryStore();
|
|
15550
15751
|
const removeNodes2 = React.useCallback(
|
|
15551
|
-
(names, targetScope) =>
|
|
15552
|
-
const nameArray = Array.isArray(names) ? names : [names];
|
|
15553
|
-
store.setState((state) => {
|
|
15554
|
-
if (targetScope) {
|
|
15555
|
-
const currentScope = { ...state.nodes[targetScope] };
|
|
15556
|
-
for (const name of nameArray) delete currentScope[name];
|
|
15557
|
-
return { nodes: { ...state.nodes, [targetScope]: currentScope } };
|
|
15558
|
-
}
|
|
15559
|
-
const nodes2 = { ...state.nodes };
|
|
15560
|
-
for (const name of nameArray) if (isTSLNode(nodes2[name])) delete nodes2[name];
|
|
15561
|
-
return { nodes: nodes2 };
|
|
15562
|
-
});
|
|
15563
|
-
},
|
|
15752
|
+
(names, targetScope) => removeResourceEntries(store, "nodes", Array.isArray(names) ? names : [names], targetScope, isTSLNode),
|
|
15564
15753
|
[store]
|
|
15565
15754
|
);
|
|
15566
15755
|
const clearNodes = React.useCallback(
|
|
15567
|
-
(targetScope) =>
|
|
15568
|
-
store.setState((state) => {
|
|
15569
|
-
if (targetScope && targetScope !== "root") {
|
|
15570
|
-
const { [targetScope]: _, ...rest } = state.nodes;
|
|
15571
|
-
return { nodes: rest };
|
|
15572
|
-
}
|
|
15573
|
-
if (targetScope === "root") {
|
|
15574
|
-
const nodes2 = {};
|
|
15575
|
-
for (const [key, value] of Object.entries(state.nodes)) {
|
|
15576
|
-
if (!isTSLNode(value)) nodes2[key] = value;
|
|
15577
|
-
}
|
|
15578
|
-
return { nodes: nodes2 };
|
|
15579
|
-
}
|
|
15580
|
-
return { nodes: {} };
|
|
15581
|
-
});
|
|
15582
|
-
},
|
|
15756
|
+
(targetScope) => clearResourceEntries(store, "nodes", targetScope, isTSLNode),
|
|
15583
15757
|
[store]
|
|
15584
15758
|
);
|
|
15585
15759
|
const rebuildNodes = React.useCallback(
|
|
15586
|
-
(targetScope) =>
|
|
15587
|
-
store.setState((state) => {
|
|
15588
|
-
let newNodes = state.nodes;
|
|
15589
|
-
if (targetScope && targetScope !== "root") {
|
|
15590
|
-
const { [targetScope]: _, ...rest } = state.nodes;
|
|
15591
|
-
newNodes = rest;
|
|
15592
|
-
} else if (targetScope === "root") {
|
|
15593
|
-
newNodes = {};
|
|
15594
|
-
for (const [key, value] of Object.entries(state.nodes)) {
|
|
15595
|
-
if (!isTSLNode(value)) newNodes[key] = value;
|
|
15596
|
-
}
|
|
15597
|
-
} else {
|
|
15598
|
-
newNodes = {};
|
|
15599
|
-
}
|
|
15600
|
-
return { nodes: newNodes, _hmrVersion: state._hmrVersion + 1 };
|
|
15601
|
-
});
|
|
15602
|
-
},
|
|
15760
|
+
(targetScope) => rebuildResource(store, "nodes", targetScope),
|
|
15603
15761
|
[store]
|
|
15604
15762
|
);
|
|
15605
15763
|
const isReader = creatorOrScope === void 0 || typeof creatorOrScope === "string";
|
|
15606
15764
|
const storeNodes = usePrimaryThree((s) => s.nodes);
|
|
15607
|
-
const
|
|
15608
|
-
|
|
15609
|
-
|
|
15610
|
-
|
|
15611
|
-
|
|
15612
|
-
|
|
15613
|
-
return
|
|
15614
|
-
|
|
15615
|
-
|
|
15616
|
-
|
|
15617
|
-
|
|
15618
|
-
return
|
|
15619
|
-
}
|
|
15620
|
-
const state = store.getState();
|
|
15621
|
-
const set = store.setState;
|
|
15622
|
-
const creator = creatorOrScope;
|
|
15623
|
-
const wrappedState = createLazyCreatorState(state);
|
|
15624
|
-
const created = creator(wrappedState);
|
|
15625
|
-
const result = {};
|
|
15626
|
-
let hasNewNodes = false;
|
|
15627
|
-
if (scope) {
|
|
15628
|
-
const currentScope = state.nodes[scope] ?? {};
|
|
15629
|
-
for (const [name, node] of Object.entries(created)) {
|
|
15630
|
-
if (currentScope[name]) {
|
|
15631
|
-
result[name] = currentScope[name];
|
|
15632
|
-
} else {
|
|
15633
|
-
node.setName?.(`${scope}.${name}`);
|
|
15634
|
-
result[name] = node;
|
|
15635
|
-
hasNewNodes = true;
|
|
15636
|
-
}
|
|
15637
|
-
}
|
|
15638
|
-
if (hasNewNodes) {
|
|
15639
|
-
set((s) => ({
|
|
15640
|
-
nodes: {
|
|
15641
|
-
...s.nodes,
|
|
15642
|
-
[scope]: { ...s.nodes[scope], ...result }
|
|
15643
|
-
}
|
|
15644
|
-
}));
|
|
15645
|
-
}
|
|
15646
|
-
return result;
|
|
15647
|
-
}
|
|
15648
|
-
for (const [name, node] of Object.entries(created)) {
|
|
15649
|
-
const existing = state.nodes[name];
|
|
15650
|
-
if (existing && isTSLNode(existing)) {
|
|
15651
|
-
result[name] = existing;
|
|
15652
|
-
} else {
|
|
15653
|
-
node.setName?.(name);
|
|
15654
|
-
result[name] = node;
|
|
15655
|
-
hasNewNodes = true;
|
|
15656
|
-
}
|
|
15657
|
-
}
|
|
15658
|
-
if (hasNewNodes) {
|
|
15659
|
-
set((s) => ({ nodes: { ...s.nodes, ...result } }));
|
|
15765
|
+
const created = useScopedResource({
|
|
15766
|
+
store,
|
|
15767
|
+
kind: "nodes",
|
|
15768
|
+
scope: isReader ? void 0 : scope,
|
|
15769
|
+
isLeaf: isTSLNode,
|
|
15770
|
+
create: () => {
|
|
15771
|
+
if (isReader) return {};
|
|
15772
|
+
return creatorOrScope(createLazyCreatorState(store.getState(), store));
|
|
15773
|
+
},
|
|
15774
|
+
prepare: (name, node) => {
|
|
15775
|
+
node.setName?.(scope ? `${scope}.${name}` : name);
|
|
15776
|
+
return node;
|
|
15660
15777
|
}
|
|
15661
|
-
|
|
15662
|
-
|
|
15778
|
+
});
|
|
15779
|
+
let nodes = created;
|
|
15780
|
+
if (creatorOrScope === void 0) {
|
|
15781
|
+
nodes = storeNodes;
|
|
15782
|
+
} else if (typeof creatorOrScope === "string") {
|
|
15783
|
+
const scopeData = storeNodes[creatorOrScope];
|
|
15784
|
+
nodes = scopeData && !isTSLNode(scopeData) ? scopeData : {};
|
|
15785
|
+
}
|
|
15663
15786
|
return { ...nodes, removeNodes: removeNodes2, clearNodes, rebuildNodes };
|
|
15664
15787
|
}
|
|
15665
15788
|
function rebuildAllNodes(store, scope) {
|
|
15666
|
-
store
|
|
15667
|
-
store.setState((state) => {
|
|
15668
|
-
let newNodes = state.nodes;
|
|
15669
|
-
if (scope && scope !== "root") {
|
|
15670
|
-
const { [scope]: _, ...rest } = state.nodes;
|
|
15671
|
-
newNodes = rest;
|
|
15672
|
-
} else if (scope === "root") {
|
|
15673
|
-
newNodes = {};
|
|
15674
|
-
for (const [key, value] of Object.entries(state.nodes)) {
|
|
15675
|
-
if (!isTSLNode(value)) newNodes[key] = value;
|
|
15676
|
-
}
|
|
15677
|
-
} else {
|
|
15678
|
-
newNodes = {};
|
|
15679
|
-
}
|
|
15680
|
-
return { nodes: newNodes, _hmrVersion: state._hmrVersion + 1 };
|
|
15681
|
-
});
|
|
15789
|
+
rebuildResource(store, "nodes", scope);
|
|
15682
15790
|
}
|
|
15683
15791
|
function removeNodes(set, names, scope) {
|
|
15684
15792
|
set((state) => {
|
|
@@ -15714,7 +15822,7 @@ function useLocalNodes(creator) {
|
|
|
15714
15822
|
const textures = usePrimaryThree((s) => s.textures);
|
|
15715
15823
|
const hmrVersion = usePrimaryThree((s) => s._hmrVersion);
|
|
15716
15824
|
return React.useMemo(() => {
|
|
15717
|
-
const wrappedState = createLazyCreatorState(store.getState());
|
|
15825
|
+
const wrappedState = createLazyCreatorState(store.getState(), store);
|
|
15718
15826
|
return creator(wrappedState);
|
|
15719
15827
|
}, [store, creator, uniforms, nodes, textures, hmrVersion]);
|
|
15720
15828
|
}
|
|
@@ -15735,58 +15843,15 @@ const disposeBuffer = (buffer) => {
|
|
|
15735
15843
|
function useBuffers(creatorOrScope, scope) {
|
|
15736
15844
|
const store = usePrimaryStore();
|
|
15737
15845
|
const removeBuffers = React.useCallback(
|
|
15738
|
-
(names, targetScope) =>
|
|
15739
|
-
const nameArray = Array.isArray(names) ? names : [names];
|
|
15740
|
-
store.setState((state) => {
|
|
15741
|
-
if (targetScope) {
|
|
15742
|
-
const currentScope = { ...state.buffers[targetScope] };
|
|
15743
|
-
for (const name of nameArray) delete currentScope[name];
|
|
15744
|
-
return { buffers: { ...state.buffers, [targetScope]: currentScope } };
|
|
15745
|
-
}
|
|
15746
|
-
const buffers2 = { ...state.buffers };
|
|
15747
|
-
for (const name of nameArray) if (isBufferLike(buffers2[name])) delete buffers2[name];
|
|
15748
|
-
return { buffers: buffers2 };
|
|
15749
|
-
});
|
|
15750
|
-
},
|
|
15846
|
+
(names, targetScope) => removeResourceEntries(store, "buffers", Array.isArray(names) ? names : [names], targetScope, isBufferLike),
|
|
15751
15847
|
[store]
|
|
15752
15848
|
);
|
|
15753
15849
|
const clearBuffers = React.useCallback(
|
|
15754
|
-
(targetScope) =>
|
|
15755
|
-
store.setState((state) => {
|
|
15756
|
-
if (targetScope && targetScope !== "root") {
|
|
15757
|
-
const { [targetScope]: _, ...rest } = state.buffers;
|
|
15758
|
-
return { buffers: rest };
|
|
15759
|
-
}
|
|
15760
|
-
if (targetScope === "root") {
|
|
15761
|
-
const buffers2 = {};
|
|
15762
|
-
for (const [key, value] of Object.entries(state.buffers)) {
|
|
15763
|
-
if (!isBufferLike(value)) buffers2[key] = value;
|
|
15764
|
-
}
|
|
15765
|
-
return { buffers: buffers2 };
|
|
15766
|
-
}
|
|
15767
|
-
return { buffers: {} };
|
|
15768
|
-
});
|
|
15769
|
-
},
|
|
15850
|
+
(targetScope) => clearResourceEntries(store, "buffers", targetScope, isBufferLike),
|
|
15770
15851
|
[store]
|
|
15771
15852
|
);
|
|
15772
15853
|
const rebuildBuffers = React.useCallback(
|
|
15773
|
-
(targetScope) =>
|
|
15774
|
-
store.setState((state) => {
|
|
15775
|
-
let newBuffers = state.buffers;
|
|
15776
|
-
if (targetScope && targetScope !== "root") {
|
|
15777
|
-
const { [targetScope]: _, ...rest } = state.buffers;
|
|
15778
|
-
newBuffers = rest;
|
|
15779
|
-
} else if (targetScope === "root") {
|
|
15780
|
-
newBuffers = {};
|
|
15781
|
-
for (const [key, value] of Object.entries(state.buffers)) {
|
|
15782
|
-
if (!isBufferLike(value)) newBuffers[key] = value;
|
|
15783
|
-
}
|
|
15784
|
-
} else {
|
|
15785
|
-
newBuffers = {};
|
|
15786
|
-
}
|
|
15787
|
-
return { buffers: newBuffers, _hmrVersion: state._hmrVersion + 1 };
|
|
15788
|
-
});
|
|
15789
|
-
},
|
|
15854
|
+
(targetScope) => rebuildResource(store, "buffers", targetScope),
|
|
15790
15855
|
[store]
|
|
15791
15856
|
);
|
|
15792
15857
|
const disposeBuffers = React.useCallback(
|
|
@@ -15805,85 +15870,33 @@ function useBuffers(creatorOrScope, scope) {
|
|
|
15805
15870
|
);
|
|
15806
15871
|
const isReader = creatorOrScope === void 0 || typeof creatorOrScope === "string";
|
|
15807
15872
|
const storeBuffers = usePrimaryThree((s) => s.buffers);
|
|
15808
|
-
const
|
|
15809
|
-
|
|
15810
|
-
|
|
15811
|
-
|
|
15812
|
-
|
|
15813
|
-
|
|
15814
|
-
return
|
|
15815
|
-
|
|
15816
|
-
|
|
15817
|
-
|
|
15818
|
-
if (
|
|
15819
|
-
|
|
15820
|
-
}
|
|
15821
|
-
const state = store.getState();
|
|
15822
|
-
const set = store.setState;
|
|
15823
|
-
const creator = creatorOrScope;
|
|
15824
|
-
const wrappedState = createLazyCreatorState(state);
|
|
15825
|
-
const created = creator(wrappedState);
|
|
15826
|
-
const result = {};
|
|
15827
|
-
let hasNewBuffers = false;
|
|
15828
|
-
if (scope) {
|
|
15829
|
-
const currentScope = state.buffers[scope] ?? {};
|
|
15830
|
-
for (const [name, buffer] of Object.entries(created)) {
|
|
15831
|
-
if (currentScope[name]) {
|
|
15832
|
-
result[name] = currentScope[name];
|
|
15833
|
-
} else {
|
|
15834
|
-
if ("setName" in buffer && typeof buffer.setName === "function") {
|
|
15835
|
-
buffer.setName(`${scope}.${name}`);
|
|
15836
|
-
}
|
|
15837
|
-
result[name] = buffer;
|
|
15838
|
-
hasNewBuffers = true;
|
|
15839
|
-
}
|
|
15840
|
-
}
|
|
15841
|
-
if (hasNewBuffers) {
|
|
15842
|
-
set((s) => ({
|
|
15843
|
-
buffers: {
|
|
15844
|
-
...s.buffers,
|
|
15845
|
-
[scope]: { ...s.buffers[scope], ...result }
|
|
15846
|
-
}
|
|
15847
|
-
}));
|
|
15848
|
-
}
|
|
15849
|
-
return result;
|
|
15850
|
-
}
|
|
15851
|
-
for (const [name, buffer] of Object.entries(created)) {
|
|
15852
|
-
const existing = state.buffers[name];
|
|
15853
|
-
if (existing && isBufferLike(existing)) {
|
|
15854
|
-
result[name] = existing;
|
|
15855
|
-
} else {
|
|
15856
|
-
if ("setName" in buffer && typeof buffer.setName === "function") {
|
|
15857
|
-
buffer.setName(name);
|
|
15858
|
-
}
|
|
15859
|
-
result[name] = buffer;
|
|
15860
|
-
hasNewBuffers = true;
|
|
15873
|
+
const created = useScopedResource({
|
|
15874
|
+
store,
|
|
15875
|
+
kind: "buffers",
|
|
15876
|
+
scope: isReader ? void 0 : scope,
|
|
15877
|
+
isLeaf: isBufferLike,
|
|
15878
|
+
create: () => {
|
|
15879
|
+
if (isReader) return {};
|
|
15880
|
+
return creatorOrScope(createLazyCreatorState(store.getState(), store));
|
|
15881
|
+
},
|
|
15882
|
+
prepare: (name, buffer) => {
|
|
15883
|
+
if ("setName" in buffer && typeof buffer.setName === "function") {
|
|
15884
|
+
buffer.setName(scope ? `${scope}.${name}` : name);
|
|
15861
15885
|
}
|
|
15886
|
+
return buffer;
|
|
15862
15887
|
}
|
|
15863
|
-
|
|
15864
|
-
|
|
15865
|
-
|
|
15866
|
-
|
|
15867
|
-
}
|
|
15888
|
+
});
|
|
15889
|
+
let buffers = created;
|
|
15890
|
+
if (creatorOrScope === void 0) {
|
|
15891
|
+
buffers = storeBuffers;
|
|
15892
|
+
} else if (typeof creatorOrScope === "string") {
|
|
15893
|
+
const scopeData = storeBuffers[creatorOrScope];
|
|
15894
|
+
buffers = scopeData && !isBufferLike(scopeData) ? scopeData : {};
|
|
15895
|
+
}
|
|
15868
15896
|
return { ...buffers, removeBuffers, clearBuffers, rebuildBuffers, disposeBuffers };
|
|
15869
15897
|
}
|
|
15870
15898
|
function rebuildAllBuffers(store, scope) {
|
|
15871
|
-
store
|
|
15872
|
-
store.setState((state) => {
|
|
15873
|
-
let newBuffers = state.buffers;
|
|
15874
|
-
if (scope && scope !== "root") {
|
|
15875
|
-
const { [scope]: _, ...rest } = state.buffers;
|
|
15876
|
-
newBuffers = rest;
|
|
15877
|
-
} else if (scope === "root") {
|
|
15878
|
-
newBuffers = {};
|
|
15879
|
-
for (const [key, value] of Object.entries(state.buffers)) {
|
|
15880
|
-
if (!isBufferLike(value)) newBuffers[key] = value;
|
|
15881
|
-
}
|
|
15882
|
-
} else {
|
|
15883
|
-
newBuffers = {};
|
|
15884
|
-
}
|
|
15885
|
-
return { buffers: newBuffers, _hmrVersion: state._hmrVersion + 1 };
|
|
15886
|
-
});
|
|
15899
|
+
rebuildResource(store, "buffers", scope);
|
|
15887
15900
|
}
|
|
15888
15901
|
|
|
15889
15902
|
const isStorageLike = (value) => {
|
|
@@ -15902,58 +15915,15 @@ const disposeStorage = (storage) => {
|
|
|
15902
15915
|
function useGPUStorage(creatorOrScope, scope) {
|
|
15903
15916
|
const store = usePrimaryStore();
|
|
15904
15917
|
const removeStorage = React.useCallback(
|
|
15905
|
-
(names, targetScope) =>
|
|
15906
|
-
const nameArray = Array.isArray(names) ? names : [names];
|
|
15907
|
-
store.setState((state) => {
|
|
15908
|
-
if (targetScope) {
|
|
15909
|
-
const currentScope = { ...state.gpuStorage[targetScope] };
|
|
15910
|
-
for (const name of nameArray) delete currentScope[name];
|
|
15911
|
-
return { gpuStorage: { ...state.gpuStorage, [targetScope]: currentScope } };
|
|
15912
|
-
}
|
|
15913
|
-
const gpuStorage2 = { ...state.gpuStorage };
|
|
15914
|
-
for (const name of nameArray) if (isStorageLike(gpuStorage2[name])) delete gpuStorage2[name];
|
|
15915
|
-
return { gpuStorage: gpuStorage2 };
|
|
15916
|
-
});
|
|
15917
|
-
},
|
|
15918
|
+
(names, targetScope) => removeResourceEntries(store, "gpuStorage", Array.isArray(names) ? names : [names], targetScope, isStorageLike),
|
|
15918
15919
|
[store]
|
|
15919
15920
|
);
|
|
15920
15921
|
const clearStorage = React.useCallback(
|
|
15921
|
-
(targetScope) =>
|
|
15922
|
-
store.setState((state) => {
|
|
15923
|
-
if (targetScope && targetScope !== "root") {
|
|
15924
|
-
const { [targetScope]: _, ...rest } = state.gpuStorage;
|
|
15925
|
-
return { gpuStorage: rest };
|
|
15926
|
-
}
|
|
15927
|
-
if (targetScope === "root") {
|
|
15928
|
-
const gpuStorage2 = {};
|
|
15929
|
-
for (const [key, value] of Object.entries(state.gpuStorage)) {
|
|
15930
|
-
if (!isStorageLike(value)) gpuStorage2[key] = value;
|
|
15931
|
-
}
|
|
15932
|
-
return { gpuStorage: gpuStorage2 };
|
|
15933
|
-
}
|
|
15934
|
-
return { gpuStorage: {} };
|
|
15935
|
-
});
|
|
15936
|
-
},
|
|
15922
|
+
(targetScope) => clearResourceEntries(store, "gpuStorage", targetScope, isStorageLike),
|
|
15937
15923
|
[store]
|
|
15938
15924
|
);
|
|
15939
15925
|
const rebuildStorage = React.useCallback(
|
|
15940
|
-
(targetScope) =>
|
|
15941
|
-
store.setState((state) => {
|
|
15942
|
-
let newStorage = state.gpuStorage;
|
|
15943
|
-
if (targetScope && targetScope !== "root") {
|
|
15944
|
-
const { [targetScope]: _, ...rest } = state.gpuStorage;
|
|
15945
|
-
newStorage = rest;
|
|
15946
|
-
} else if (targetScope === "root") {
|
|
15947
|
-
newStorage = {};
|
|
15948
|
-
for (const [key, value] of Object.entries(state.gpuStorage)) {
|
|
15949
|
-
if (!isStorageLike(value)) newStorage[key] = value;
|
|
15950
|
-
}
|
|
15951
|
-
} else {
|
|
15952
|
-
newStorage = {};
|
|
15953
|
-
}
|
|
15954
|
-
return { gpuStorage: newStorage, _hmrVersion: state._hmrVersion + 1 };
|
|
15955
|
-
});
|
|
15956
|
-
},
|
|
15926
|
+
(targetScope) => rebuildResource(store, "gpuStorage", targetScope),
|
|
15957
15927
|
[store]
|
|
15958
15928
|
);
|
|
15959
15929
|
const disposeStorageFn = React.useCallback(
|
|
@@ -15972,72 +15942,33 @@ function useGPUStorage(creatorOrScope, scope) {
|
|
|
15972
15942
|
);
|
|
15973
15943
|
const isReader = creatorOrScope === void 0 || typeof creatorOrScope === "string";
|
|
15974
15944
|
const storeStorage = usePrimaryThree((s) => s.gpuStorage);
|
|
15975
|
-
const
|
|
15976
|
-
|
|
15977
|
-
|
|
15978
|
-
|
|
15979
|
-
|
|
15980
|
-
|
|
15981
|
-
return
|
|
15982
|
-
|
|
15983
|
-
|
|
15984
|
-
|
|
15985
|
-
|
|
15986
|
-
|
|
15987
|
-
|
|
15988
|
-
const state = store.getState();
|
|
15989
|
-
const set = store.setState;
|
|
15990
|
-
const creator = creatorOrScope;
|
|
15991
|
-
const wrappedState = createLazyCreatorState(state);
|
|
15992
|
-
const created = creator(wrappedState);
|
|
15993
|
-
const result = {};
|
|
15994
|
-
let hasNewStorage = false;
|
|
15995
|
-
if (scope) {
|
|
15996
|
-
const currentScope = state.gpuStorage[scope] ?? {};
|
|
15997
|
-
for (const [name, storage] of Object.entries(created)) {
|
|
15998
|
-
if (currentScope[name]) {
|
|
15999
|
-
result[name] = currentScope[name];
|
|
16000
|
-
} else {
|
|
16001
|
-
if ("setName" in storage && typeof storage.setName === "function") {
|
|
16002
|
-
storage.setName(`${scope}.${name}`);
|
|
16003
|
-
}
|
|
16004
|
-
if ("name" in storage && typeof storage.name === "string") {
|
|
16005
|
-
storage.name = `${scope}.${name}`;
|
|
16006
|
-
}
|
|
16007
|
-
result[name] = storage;
|
|
16008
|
-
hasNewStorage = true;
|
|
16009
|
-
}
|
|
16010
|
-
}
|
|
16011
|
-
if (hasNewStorage) {
|
|
16012
|
-
set((s) => ({
|
|
16013
|
-
gpuStorage: {
|
|
16014
|
-
...s.gpuStorage,
|
|
16015
|
-
[scope]: { ...s.gpuStorage[scope], ...result }
|
|
16016
|
-
}
|
|
16017
|
-
}));
|
|
15945
|
+
const created = useScopedResource({
|
|
15946
|
+
store,
|
|
15947
|
+
kind: "gpuStorage",
|
|
15948
|
+
scope: isReader ? void 0 : scope,
|
|
15949
|
+
isLeaf: isStorageLike,
|
|
15950
|
+
create: () => {
|
|
15951
|
+
if (isReader) return {};
|
|
15952
|
+
return creatorOrScope(createLazyCreatorState(store.getState(), store));
|
|
15953
|
+
},
|
|
15954
|
+
prepare: (name, storage) => {
|
|
15955
|
+
const label = scope ? `${scope}.${name}` : name;
|
|
15956
|
+
if ("setName" in storage && typeof storage.setName === "function") {
|
|
15957
|
+
storage.setName(label);
|
|
16018
15958
|
}
|
|
16019
|
-
|
|
16020
|
-
|
|
16021
|
-
for (const [name, storage] of Object.entries(created)) {
|
|
16022
|
-
const existing = state.gpuStorage[name];
|
|
16023
|
-
if (existing && isStorageLike(existing)) {
|
|
16024
|
-
result[name] = existing;
|
|
16025
|
-
} else {
|
|
16026
|
-
if ("setName" in storage && typeof storage.setName === "function") {
|
|
16027
|
-
storage.setName(name);
|
|
16028
|
-
}
|
|
16029
|
-
if ("name" in storage && typeof storage.name === "string") {
|
|
16030
|
-
storage.name = name;
|
|
16031
|
-
}
|
|
16032
|
-
result[name] = storage;
|
|
16033
|
-
hasNewStorage = true;
|
|
15959
|
+
if ("name" in storage && typeof storage.name === "string") {
|
|
15960
|
+
storage.name = label;
|
|
16034
15961
|
}
|
|
15962
|
+
return storage;
|
|
16035
15963
|
}
|
|
16036
|
-
|
|
16037
|
-
|
|
16038
|
-
|
|
16039
|
-
|
|
16040
|
-
}
|
|
15964
|
+
});
|
|
15965
|
+
let gpuStorage = created;
|
|
15966
|
+
if (creatorOrScope === void 0) {
|
|
15967
|
+
gpuStorage = storeStorage;
|
|
15968
|
+
} else if (typeof creatorOrScope === "string") {
|
|
15969
|
+
const scopeData = storeStorage[creatorOrScope];
|
|
15970
|
+
gpuStorage = scopeData && !isStorageLike(scopeData) ? scopeData : {};
|
|
15971
|
+
}
|
|
16041
15972
|
return {
|
|
16042
15973
|
...gpuStorage,
|
|
16043
15974
|
removeStorage,
|
|
@@ -16047,22 +15978,7 @@ function useGPUStorage(creatorOrScope, scope) {
|
|
|
16047
15978
|
};
|
|
16048
15979
|
}
|
|
16049
15980
|
function rebuildAllStorage(store, scope) {
|
|
16050
|
-
store
|
|
16051
|
-
store.setState((state) => {
|
|
16052
|
-
let newStorage = state.gpuStorage;
|
|
16053
|
-
if (scope && scope !== "root") {
|
|
16054
|
-
const { [scope]: _, ...rest } = state.gpuStorage;
|
|
16055
|
-
newStorage = rest;
|
|
16056
|
-
} else if (scope === "root") {
|
|
16057
|
-
newStorage = {};
|
|
16058
|
-
for (const [key, value] of Object.entries(state.gpuStorage)) {
|
|
16059
|
-
if (!isStorageLike(value)) newStorage[key] = value;
|
|
16060
|
-
}
|
|
16061
|
-
} else {
|
|
16062
|
-
newStorage = {};
|
|
16063
|
-
}
|
|
16064
|
-
return { gpuStorage: newStorage, _hmrVersion: state._hmrVersion + 1 };
|
|
16065
|
-
});
|
|
15981
|
+
rebuildResource(store, "gpuStorage", scope);
|
|
16066
15982
|
}
|
|
16067
15983
|
|
|
16068
15984
|
function useRenderPipeline(mainCB, setupCB) {
|
|
@@ -16179,7 +16095,6 @@ exports.REACT_INTERNAL_PROPS = REACT_INTERNAL_PROPS;
|
|
|
16179
16095
|
exports.RESERVED_PROPS = RESERVED_PROPS;
|
|
16180
16096
|
exports.Texture = Texture;
|
|
16181
16097
|
exports._roots = _roots;
|
|
16182
|
-
exports.act = act;
|
|
16183
16098
|
exports.addAfterEffect = addAfterEffect;
|
|
16184
16099
|
exports.addEffect = addEffect;
|
|
16185
16100
|
exports.addTail = addTail;
|
|
@@ -16224,7 +16139,7 @@ exports.isFromRef = isFromRef;
|
|
|
16224
16139
|
exports.isObject3D = isObject3D;
|
|
16225
16140
|
exports.isOnce = isOnce;
|
|
16226
16141
|
exports.isOrthographicCamera = isOrthographicCamera;
|
|
16227
|
-
exports.isRef = isRef;
|
|
16142
|
+
exports.isRef = isRef$1;
|
|
16228
16143
|
exports.isRenderer = isRenderer;
|
|
16229
16144
|
exports.isTexture = isTexture;
|
|
16230
16145
|
exports.isVectorLike = isVectorLike;
|
|
@@ -16241,6 +16156,7 @@ exports.removeInteractivity = removeInteractivity;
|
|
|
16241
16156
|
exports.removeNodes = removeNodes;
|
|
16242
16157
|
exports.removeUniforms = removeUniforms;
|
|
16243
16158
|
exports.resolve = resolve;
|
|
16159
|
+
exports.swapInteractivity = swapInteractivity;
|
|
16244
16160
|
exports.unmountComponentAtNode = unmountComponentAtNode;
|
|
16245
16161
|
exports.unregisterPrimary = unregisterPrimary;
|
|
16246
16162
|
exports.updateCamera = updateCamera;
|