@react-three/fiber 10.0.0-canary.76d2134 → 10.0.0-canary.8f5b4d3
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 +2178 -2179
- package/dist/index.d.cts +3 -4
- package/dist/index.d.mts +3 -4
- package/dist/index.d.ts +3 -4
- package/dist/index.mjs +2181 -2182
- package/dist/legacy.cjs +2176 -2177
- package/dist/legacy.d.cts +3 -4
- package/dist/legacy.d.mts +3 -4
- package/dist/legacy.d.ts +3 -4
- package/dist/legacy.mjs +2179 -2180
- package/dist/webgpu/index.cjs +2176 -2177
- package/dist/webgpu/index.d.cts +3 -4
- package/dist/webgpu/index.d.mts +3 -4
- package/dist/webgpu/index.d.ts +3 -4
- package/dist/webgpu/index.mjs +2179 -2180
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import * as webgpu from 'three/webgpu';
|
|
2
|
-
import { CubeRenderTarget, RenderTarget,
|
|
2
|
+
import { CubeRenderTarget, RenderTarget, Frustum, Matrix4, Group, BoxGeometry, MeshBasicNodeMaterial, Mesh, Node, NodeUpdateType, Layers, ShaderMaterial, Uniform, SRGBColorSpace, RGBAFormat, UnsignedByteType, Vector3, Vector2, TextureLoader, Texture as Texture$1, CubeReflectionMapping, EquirectangularReflectionMapping, CubeTextureLoader, CanvasTarget, Raycaster, OrthographicCamera, PerspectiveCamera, Scene, PCFShadowMap, VSMShadowMap, BasicShadowMap, ACESFilmicToneMapping, WebGPURenderer, HalfFloatType, Color } from 'three/webgpu';
|
|
3
3
|
import { WebGLCubeRenderTarget, WebGLRenderTarget, WebGLRenderer } from 'three';
|
|
4
4
|
import { Inspector } from 'three/addons/inspector/Inspector.js';
|
|
5
5
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
6
6
|
import * as React from 'react';
|
|
7
|
-
import React__default, {
|
|
7
|
+
import React__default, { useRef, useMemo, useLayoutEffect, useEffect, useContext, useImperativeHandle, useCallback, useState } from 'react';
|
|
8
8
|
import useMeasure from 'react-use-measure';
|
|
9
9
|
import { useFiber, useContextBridge, traverseFiber, FiberProvider } from 'its-fine';
|
|
10
|
-
import {
|
|
10
|
+
import { createWithEqualityFn } from 'zustand/traditional';
|
|
11
|
+
import { getScheduler } from '@pmndrs/scheduler';
|
|
12
|
+
export { Scheduler, getScheduler } from '@pmndrs/scheduler';
|
|
13
|
+
import Tb, { unstable_getCurrentPriorityLevel, unstable_IdlePriority, unstable_LowPriority, unstable_NormalPriority, unstable_UserBlockingPriority, unstable_ImmediatePriority, unstable_scheduleCallback } from 'scheduler';
|
|
11
14
|
import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
|
|
12
15
|
import { HDRLoader } from 'three/examples/jsm/loaders/HDRLoader.js';
|
|
13
16
|
import { EXRLoader } from 'three/examples/jsm/loaders/EXRLoader.js';
|
|
14
17
|
import { UltraHDRLoader } from 'three/examples/jsm/loaders/UltraHDRLoader.js';
|
|
15
18
|
import { GainMapLoader } from '@monogrid/gainmap-js';
|
|
16
|
-
import Tb, { unstable_getCurrentPriorityLevel, unstable_IdlePriority, unstable_LowPriority, unstable_NormalPriority, unstable_UserBlockingPriority, unstable_ImmediatePriority, unstable_scheduleCallback } from 'scheduler';
|
|
17
|
-
import { createWithEqualityFn } from 'zustand/traditional';
|
|
18
|
-
import { getScheduler } from '@pmndrs/scheduler';
|
|
19
|
-
export { Scheduler, getScheduler } from '@pmndrs/scheduler';
|
|
20
19
|
import { suspend, preload, clear } from 'suspend-react';
|
|
21
20
|
|
|
22
21
|
function _mergeNamespaces(n, m) {
|
|
@@ -105,555 +104,229 @@ function getPrimaryIds() {
|
|
|
105
104
|
return Array.from(primaryRegistry.keys());
|
|
106
105
|
}
|
|
107
106
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
107
|
+
var __defProp = Object.defineProperty;
|
|
108
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
109
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
110
|
+
const useIsomorphicLayoutEffect = /* @__PURE__ */ (() => typeof window !== "undefined" && (window.document?.createElement || window.navigator?.product === "ReactNative"))() ? React.useLayoutEffect : React.useEffect;
|
|
111
|
+
function useMutableCallback(fn) {
|
|
112
|
+
const ref = React.useRef(fn);
|
|
113
|
+
useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
|
|
114
|
+
return ref;
|
|
115
|
+
}
|
|
116
|
+
function useBridge() {
|
|
117
|
+
const fiber = useFiber();
|
|
118
|
+
const ContextBridge = useContextBridge();
|
|
119
|
+
return React.useMemo(
|
|
120
|
+
() => ({ children }) => {
|
|
121
|
+
const strict = !!traverseFiber(fiber, true, (node) => node.type === React.StrictMode);
|
|
122
|
+
const Root = strict ? React.StrictMode : React.Fragment;
|
|
123
|
+
return /* @__PURE__ */ jsx(Root, { children: /* @__PURE__ */ jsx(ContextBridge, { children }) });
|
|
124
|
+
},
|
|
125
|
+
[fiber, ContextBridge]
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
function Block({ set }) {
|
|
129
|
+
useIsomorphicLayoutEffect(() => {
|
|
130
|
+
set(new Promise(() => null));
|
|
131
|
+
return () => set(false);
|
|
132
|
+
}, [set]);
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
const ErrorBoundary = /* @__PURE__ */ (() => {
|
|
136
|
+
var _a;
|
|
137
|
+
return _a = class extends React.Component {
|
|
138
|
+
constructor() {
|
|
139
|
+
super(...arguments);
|
|
140
|
+
__publicField(this, "state", { error: false });
|
|
141
|
+
}
|
|
142
|
+
componentDidCatch(err) {
|
|
143
|
+
this.props.set(err);
|
|
144
|
+
}
|
|
145
|
+
render() {
|
|
146
|
+
return this.state.error ? null : this.props.children;
|
|
147
|
+
}
|
|
148
|
+
}, __publicField(_a, "getDerivedStateFromError", () => ({ error: true })), _a;
|
|
149
|
+
})();
|
|
120
150
|
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
} = {}) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
useLoader$1.clear(loader, multiFile ? [files] : files);
|
|
151
|
+
const is = {
|
|
152
|
+
obj: (a) => a === Object(a) && !is.arr(a) && typeof a !== "function",
|
|
153
|
+
fun: (a) => typeof a === "function",
|
|
154
|
+
str: (a) => typeof a === "string",
|
|
155
|
+
num: (a) => typeof a === "number",
|
|
156
|
+
boo: (a) => typeof a === "boolean",
|
|
157
|
+
und: (a) => a === void 0,
|
|
158
|
+
nul: (a) => a === null,
|
|
159
|
+
arr: (a) => Array.isArray(a),
|
|
160
|
+
equ(a, b, { arrays = "shallow", objects = "reference", strict = true } = {}) {
|
|
161
|
+
if (typeof a !== typeof b || !!a !== !!b) return false;
|
|
162
|
+
if (is.str(a) || is.num(a) || is.boo(a)) return a === b;
|
|
163
|
+
const isObj = is.obj(a);
|
|
164
|
+
if (isObj && objects === "reference") return a === b;
|
|
165
|
+
const isArr = is.arr(a);
|
|
166
|
+
if (isArr && arrays === "reference") return a === b;
|
|
167
|
+
if ((isArr || isObj) && a === b) return true;
|
|
168
|
+
let i;
|
|
169
|
+
for (i in a) if (!(i in b)) return false;
|
|
170
|
+
if (isObj && arrays === "shallow" && objects === "shallow") {
|
|
171
|
+
for (i in strict ? b : a) if (!is.equ(a[i], b[i], { strict, objects: "reference" })) return false;
|
|
172
|
+
} else {
|
|
173
|
+
for (i in strict ? b : a) if (a[i] !== b[i]) return false;
|
|
145
174
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
multiFile ? [files] : files,
|
|
151
|
-
(loader2) => {
|
|
152
|
-
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
153
|
-
loader2.setRenderer?.(renderer);
|
|
154
|
-
}
|
|
155
|
-
loader2.setPath?.(path);
|
|
156
|
-
if (extensions) extensions(loader2);
|
|
175
|
+
if (is.und(i)) {
|
|
176
|
+
if (isArr && a.length === 0 && b.length === 0) return true;
|
|
177
|
+
if (isObj && Object.keys(a).length === 0 && Object.keys(b).length === 0) return true;
|
|
178
|
+
if (a !== b) return false;
|
|
157
179
|
}
|
|
158
|
-
|
|
159
|
-
let texture = multiFile ? (
|
|
160
|
-
// @ts-ignore
|
|
161
|
-
loaderResult[0]
|
|
162
|
-
) : loaderResult;
|
|
163
|
-
if (extension === "jpg" || extension === "jpeg" || extension === "webp") {
|
|
164
|
-
texture = texture.renderTarget?.texture;
|
|
165
|
-
}
|
|
166
|
-
texture.mapping = isCubemap ? CubeReflectionMapping : EquirectangularReflectionMapping;
|
|
167
|
-
texture.colorSpace = colorSpace ?? (isCubemap ? "srgb" : "srgb-linear");
|
|
168
|
-
return texture;
|
|
169
|
-
}
|
|
170
|
-
const preloadDefaultOptions = {
|
|
171
|
-
files: defaultFiles,
|
|
172
|
-
path: "",
|
|
173
|
-
preset: void 0,
|
|
174
|
-
extensions: void 0
|
|
175
|
-
};
|
|
176
|
-
useEnvironment.preload = (preloadOptions) => {
|
|
177
|
-
const options = { ...preloadDefaultOptions, ...preloadOptions };
|
|
178
|
-
let { files, path = "" } = options;
|
|
179
|
-
const { preset, extensions } = options;
|
|
180
|
-
if (preset) {
|
|
181
|
-
validatePreset(preset);
|
|
182
|
-
files = presetsObj[preset];
|
|
183
|
-
path = CUBEMAP_ROOT;
|
|
184
|
-
}
|
|
185
|
-
const { extension } = getExtension(files);
|
|
186
|
-
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
187
|
-
throw new Error("useEnvironment: Preloading gainmaps is not supported");
|
|
188
|
-
}
|
|
189
|
-
const loader = getLoader$1(extension);
|
|
190
|
-
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
191
|
-
useLoader$1.preload(loader, isArray(files) ? [files] : files, (loader2) => {
|
|
192
|
-
loader2.setPath?.(path);
|
|
193
|
-
if (extensions) extensions(loader2);
|
|
194
|
-
});
|
|
195
|
-
};
|
|
196
|
-
const clearDefaultOptins = {
|
|
197
|
-
files: defaultFiles,
|
|
198
|
-
preset: void 0
|
|
199
|
-
};
|
|
200
|
-
useEnvironment.clear = (clearOptions) => {
|
|
201
|
-
const options = { ...clearDefaultOptins, ...clearOptions };
|
|
202
|
-
let { files } = options;
|
|
203
|
-
const { preset } = options;
|
|
204
|
-
if (preset) {
|
|
205
|
-
validatePreset(preset);
|
|
206
|
-
files = presetsObj[preset];
|
|
180
|
+
return true;
|
|
207
181
|
}
|
|
208
|
-
const { extension } = getExtension(files);
|
|
209
|
-
const loader = getLoader$1(extension);
|
|
210
|
-
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
211
|
-
useLoader$1.clear(loader, isArray(files) ? [files] : files);
|
|
212
182
|
};
|
|
213
|
-
|
|
214
|
-
|
|
183
|
+
const isOrthographicCamera = (def) => def && def.isOrthographicCamera;
|
|
184
|
+
const isRef$1 = (obj) => obj !== null && typeof obj === "object" && obj.hasOwnProperty("current");
|
|
185
|
+
const isColorRepresentation = (value) => value != null && (typeof value === "string" || typeof value === "number" || value.isColor);
|
|
186
|
+
const isObject3D = (object) => object?.isObject3D;
|
|
187
|
+
const isTexture = (value) => !!value?.isTexture;
|
|
188
|
+
const isVectorLike = (object) => object !== null && typeof object === "object" && "set" in object && typeof object.set === "function";
|
|
189
|
+
const isCopyable = (object) => isVectorLike(object) && "copy" in object && typeof object.copy === "function";
|
|
190
|
+
const hasConstructor = (object) => !!object?.constructor;
|
|
191
|
+
|
|
192
|
+
function calculateDpr(dpr) {
|
|
193
|
+
const target = typeof window !== "undefined" ? window.devicePixelRatio ?? 2 : 1;
|
|
194
|
+
return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
|
|
215
195
|
}
|
|
216
|
-
function
|
|
217
|
-
|
|
218
|
-
const isGainmap = isArray(files) && files.length === 3 && files.some((file) => file.endsWith("json"));
|
|
219
|
-
const firstEntry = isArray(files) ? files[0] : files;
|
|
220
|
-
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();
|
|
221
|
-
return { extension, isCubemap, isGainmap };
|
|
196
|
+
function getUuidPrefix(uuid) {
|
|
197
|
+
return uuid.split("-")[0];
|
|
222
198
|
}
|
|
223
|
-
function
|
|
224
|
-
|
|
225
|
-
|
|
199
|
+
function updateCamera(camera, size) {
|
|
200
|
+
if (camera.manual) return;
|
|
201
|
+
if (isOrthographicCamera(camera)) {
|
|
202
|
+
camera.left = size.width / -2;
|
|
203
|
+
camera.right = size.width / 2;
|
|
204
|
+
camera.top = size.height / 2;
|
|
205
|
+
camera.bottom = size.height / -2;
|
|
206
|
+
} else {
|
|
207
|
+
camera.aspect = size.width / size.height;
|
|
208
|
+
}
|
|
209
|
+
camera.updateProjectionMatrix();
|
|
226
210
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
backgroundIntensity: 1,
|
|
234
|
-
backgroundRotation: [0, 0, 0],
|
|
235
|
-
environmentIntensity: 1,
|
|
236
|
-
environmentRotation: [0, 0, 0],
|
|
237
|
-
...sceneProps
|
|
238
|
-
};
|
|
239
|
-
const target = resolveScene(scene || defaultScene);
|
|
240
|
-
const oldbg = target.background;
|
|
241
|
-
const oldenv = target.environment;
|
|
242
|
-
const oldSceneProps = {
|
|
243
|
-
// @ts-ignore
|
|
244
|
-
backgroundBlurriness: target.backgroundBlurriness,
|
|
245
|
-
// @ts-ignore
|
|
246
|
-
backgroundIntensity: target.backgroundIntensity,
|
|
247
|
-
// @ts-ignore
|
|
248
|
-
backgroundRotation: target.backgroundRotation?.clone?.() ?? [0, 0, 0],
|
|
249
|
-
// @ts-ignore
|
|
250
|
-
environmentIntensity: target.environmentIntensity,
|
|
251
|
-
// @ts-ignore
|
|
252
|
-
environmentRotation: target.environmentRotation?.clone?.() ?? [0, 0, 0]
|
|
253
|
-
};
|
|
254
|
-
if (background !== "only") target.environment = texture;
|
|
255
|
-
if (background) target.background = texture;
|
|
256
|
-
applyProps$1(target, sceneProps);
|
|
257
|
-
return () => {
|
|
258
|
-
if (background !== "only") target.environment = oldenv;
|
|
259
|
-
if (background) target.background = oldbg;
|
|
260
|
-
applyProps$1(target, oldSceneProps);
|
|
261
|
-
};
|
|
211
|
+
const frustumMatrix = new Matrix4();
|
|
212
|
+
function updateFrustum(camera, frustum) {
|
|
213
|
+
const target = frustum ?? new Frustum();
|
|
214
|
+
frustumMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
215
|
+
target.setFromProjectionMatrix(frustumMatrix);
|
|
216
|
+
return target;
|
|
262
217
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
return
|
|
218
|
+
|
|
219
|
+
const REACT_INTERNAL_PROPS = ["children", "key", "ref"];
|
|
220
|
+
function findInitialRoot(instance) {
|
|
221
|
+
let root = instance.root;
|
|
222
|
+
while (root.getState().previousRoot) root = root.getState().previousRoot;
|
|
223
|
+
return root;
|
|
269
224
|
}
|
|
270
|
-
function
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
...rest
|
|
280
|
-
}) {
|
|
281
|
-
const texture = useEnvironment(rest);
|
|
282
|
-
const defaultScene = useThree$1((state) => state.scene);
|
|
283
|
-
React.useLayoutEffect(() => {
|
|
284
|
-
return setEnvProps(background, scene, defaultScene, texture, {
|
|
285
|
-
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
286
|
-
backgroundIntensity,
|
|
287
|
-
backgroundRotation,
|
|
288
|
-
environmentIntensity,
|
|
289
|
-
environmentRotation
|
|
225
|
+
function getRootState(obj) {
|
|
226
|
+
let state = obj.__r3f?.root.getState();
|
|
227
|
+
if (!state) {
|
|
228
|
+
obj.traverseAncestors((ancestor) => {
|
|
229
|
+
const parentState = ancestor.__r3f?.root.getState();
|
|
230
|
+
if (parentState) {
|
|
231
|
+
state = parentState;
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
290
234
|
});
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
return () => {
|
|
294
|
-
texture.dispose();
|
|
295
|
-
};
|
|
296
|
-
}, [texture]);
|
|
297
|
-
return null;
|
|
235
|
+
}
|
|
236
|
+
return state;
|
|
298
237
|
}
|
|
299
|
-
function
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
path,
|
|
316
|
-
preset = void 0,
|
|
317
|
-
extensions
|
|
318
|
-
}) {
|
|
319
|
-
const renderer = useThree$1((state) => state.renderer);
|
|
320
|
-
const isLegacy = useThree$1((state) => state.isLegacy);
|
|
321
|
-
const defaultScene = useThree$1((state) => state.scene);
|
|
322
|
-
const camera = React.useRef(null);
|
|
323
|
-
const [virtualScene] = React.useState(() => new Scene());
|
|
324
|
-
const fbo = React.useMemo(() => {
|
|
325
|
-
const fbo2 = isLegacy ? new WebGLCubeRenderTarget(resolution) : new CubeRenderTarget(resolution);
|
|
326
|
-
fbo2.texture.type = HalfFloatType;
|
|
327
|
-
return fbo2;
|
|
328
|
-
}, [resolution, isLegacy]);
|
|
329
|
-
React.useEffect(() => {
|
|
330
|
-
return () => {
|
|
331
|
-
fbo.dispose();
|
|
332
|
-
};
|
|
333
|
-
}, [fbo]);
|
|
334
|
-
React.useLayoutEffect(() => {
|
|
335
|
-
if (frames === 1) {
|
|
336
|
-
const autoClear = renderer.autoClear;
|
|
337
|
-
renderer.autoClear = true;
|
|
338
|
-
camera.current.update(renderer, virtualScene);
|
|
339
|
-
renderer.autoClear = autoClear;
|
|
340
|
-
}
|
|
341
|
-
return setEnvProps(background, scene, defaultScene, fbo.texture, {
|
|
342
|
-
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
343
|
-
backgroundIntensity,
|
|
344
|
-
backgroundRotation,
|
|
345
|
-
environmentIntensity,
|
|
346
|
-
environmentRotation
|
|
238
|
+
function buildGraph(object) {
|
|
239
|
+
const data = { nodes: {}, materials: {}, meshes: {} };
|
|
240
|
+
if (object) {
|
|
241
|
+
object.traverse((obj) => {
|
|
242
|
+
if (obj.name) data.nodes[obj.name] = obj;
|
|
243
|
+
if (obj.material) {
|
|
244
|
+
const material = Array.isArray(obj.material) ? obj.material[0] : obj.material;
|
|
245
|
+
const nameAlreadyUsed = data.materials[material.name];
|
|
246
|
+
let materialName = material.name;
|
|
247
|
+
if (nameAlreadyUsed) {
|
|
248
|
+
materialName = materialName + `-${getUuidPrefix(material.uuid)}`;
|
|
249
|
+
material.userData.materialCacheName = materialName;
|
|
250
|
+
}
|
|
251
|
+
data.materials[materialName] = material;
|
|
252
|
+
}
|
|
253
|
+
if (obj.isMesh && !data.meshes[obj.name]) data.meshes[obj.name] = obj;
|
|
347
254
|
});
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
virtualScene,
|
|
351
|
-
fbo.texture,
|
|
352
|
-
scene,
|
|
353
|
-
defaultScene,
|
|
354
|
-
background,
|
|
355
|
-
frames,
|
|
356
|
-
renderer,
|
|
357
|
-
blur,
|
|
358
|
-
backgroundBlurriness,
|
|
359
|
-
backgroundIntensity,
|
|
360
|
-
backgroundRotation,
|
|
361
|
-
environmentIntensity,
|
|
362
|
-
environmentRotation
|
|
363
|
-
]);
|
|
364
|
-
let count = 1;
|
|
365
|
-
useFrame$1(() => {
|
|
366
|
-
if (frames === Infinity || count < frames) {
|
|
367
|
-
const autoClear = renderer.autoClear;
|
|
368
|
-
renderer.autoClear = true;
|
|
369
|
-
camera.current.update(renderer, virtualScene);
|
|
370
|
-
renderer.autoClear = autoClear;
|
|
371
|
-
count++;
|
|
372
|
-
}
|
|
373
|
-
});
|
|
374
|
-
return /* @__PURE__ */ jsx(Fragment, { children: createPortal$1(
|
|
375
|
-
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
376
|
-
children,
|
|
377
|
-
/* @__PURE__ */ jsx("cubeCamera", { ref: camera, args: [near, far, fbo] }),
|
|
378
|
-
files || preset ? /* @__PURE__ */ jsx(EnvironmentCube, { background: true, files, preset, path, extensions }) : map ? /* @__PURE__ */ jsx(EnvironmentMap, { background: true, map, extensions }) : null
|
|
379
|
-
] }),
|
|
380
|
-
virtualScene
|
|
381
|
-
) });
|
|
255
|
+
}
|
|
256
|
+
return data;
|
|
382
257
|
}
|
|
383
|
-
function
|
|
384
|
-
|
|
385
|
-
const
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
textureDefault.dispose();
|
|
390
|
-
};
|
|
391
|
-
}, [textureDefault]);
|
|
392
|
-
const height = props.ground?.height ?? 15;
|
|
393
|
-
const radius = props.ground?.radius ?? 60;
|
|
394
|
-
const scale = props.ground?.scale ?? 1e3;
|
|
395
|
-
const args = React.useMemo(
|
|
396
|
-
() => [texture, height, radius],
|
|
397
|
-
[texture, height, radius]
|
|
398
|
-
);
|
|
399
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
400
|
-
/* @__PURE__ */ jsx(EnvironmentMap, { ...props, map: texture }),
|
|
401
|
-
/* @__PURE__ */ jsx("groundProjectedEnvImpl", { args, scale })
|
|
402
|
-
] });
|
|
258
|
+
function dispose(obj) {
|
|
259
|
+
if (obj.type !== "Scene") obj.dispose?.();
|
|
260
|
+
for (const p in obj) {
|
|
261
|
+
const prop = obj[p];
|
|
262
|
+
if (prop?.type !== "Scene") prop?.dispose?.();
|
|
263
|
+
}
|
|
403
264
|
}
|
|
404
|
-
function
|
|
405
|
-
const
|
|
406
|
-
|
|
407
|
-
if (
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
265
|
+
function getInstanceProps(pendingProps) {
|
|
266
|
+
const props = {};
|
|
267
|
+
for (const key in pendingProps) {
|
|
268
|
+
if (!REACT_INTERNAL_PROPS.includes(key)) props[key] = pendingProps[key];
|
|
269
|
+
}
|
|
270
|
+
return props;
|
|
271
|
+
}
|
|
272
|
+
function prepare(target, root, type, props) {
|
|
273
|
+
const object = target;
|
|
274
|
+
let instance = object?.__r3f;
|
|
275
|
+
if (!instance) {
|
|
276
|
+
instance = {
|
|
277
|
+
root,
|
|
278
|
+
type,
|
|
279
|
+
parent: null,
|
|
280
|
+
children: [],
|
|
281
|
+
props: getInstanceProps(props),
|
|
282
|
+
object,
|
|
283
|
+
eventCount: 0,
|
|
284
|
+
handlers: {},
|
|
285
|
+
isHidden: false
|
|
413
286
|
};
|
|
414
|
-
|
|
415
|
-
|
|
287
|
+
if (object) object.__r3f = instance;
|
|
288
|
+
}
|
|
289
|
+
return instance;
|
|
416
290
|
}
|
|
417
|
-
function
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
] });
|
|
291
|
+
function invalidateInstance(instance) {
|
|
292
|
+
if (!instance.parent) return;
|
|
293
|
+
instance.props.onUpdate?.(instance.object);
|
|
294
|
+
const state = instance.root?.getState?.();
|
|
295
|
+
if (state && state.internal.frames === 0) state.invalidate();
|
|
423
296
|
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
297
|
+
|
|
298
|
+
const tempFrustum = new Frustum();
|
|
299
|
+
let hasWarnedWebGL = false;
|
|
300
|
+
let tslModule = null;
|
|
301
|
+
async function loadTSL() {
|
|
302
|
+
if (tslModule) return tslModule;
|
|
303
|
+
try {
|
|
304
|
+
const tsl = await import('three/tsl');
|
|
305
|
+
tslModule = { uniform: tsl.uniform, nodeObject: tsl.nodeObject };
|
|
306
|
+
return tslModule;
|
|
307
|
+
} catch {
|
|
308
|
+
return null;
|
|
430
309
|
}
|
|
431
|
-
return props.ground ? /* @__PURE__ */ jsx(EnvironmentGround, { ...props }) : props.map ? /* @__PURE__ */ jsx(EnvironmentMap, { ...props }) : props.children ? /* @__PURE__ */ jsx(EnvironmentPortal, { ...props }) : /* @__PURE__ */ jsx(EnvironmentCube, { ...props });
|
|
432
310
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
const
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
[fiber, ContextBridge]
|
|
453
|
-
);
|
|
454
|
-
}
|
|
455
|
-
function Block({ set }) {
|
|
456
|
-
useIsomorphicLayoutEffect(() => {
|
|
457
|
-
set(new Promise(() => null));
|
|
458
|
-
return () => set(false);
|
|
459
|
-
}, [set]);
|
|
460
|
-
return null;
|
|
461
|
-
}
|
|
462
|
-
const ErrorBoundary = /* @__PURE__ */ (() => {
|
|
463
|
-
var _a;
|
|
464
|
-
return _a = class extends React.Component {
|
|
465
|
-
constructor() {
|
|
466
|
-
super(...arguments);
|
|
467
|
-
__publicField(this, "state", { error: false });
|
|
468
|
-
}
|
|
469
|
-
componentDidCatch(err) {
|
|
470
|
-
this.props.set(err);
|
|
471
|
-
}
|
|
472
|
-
render() {
|
|
473
|
-
return this.state.error ? null : this.props.children;
|
|
474
|
-
}
|
|
475
|
-
}, __publicField(_a, "getDerivedStateFromError", () => ({ error: true })), _a;
|
|
476
|
-
})();
|
|
477
|
-
|
|
478
|
-
const is = {
|
|
479
|
-
obj: (a) => a === Object(a) && !is.arr(a) && typeof a !== "function",
|
|
480
|
-
fun: (a) => typeof a === "function",
|
|
481
|
-
str: (a) => typeof a === "string",
|
|
482
|
-
num: (a) => typeof a === "number",
|
|
483
|
-
boo: (a) => typeof a === "boolean",
|
|
484
|
-
und: (a) => a === void 0,
|
|
485
|
-
nul: (a) => a === null,
|
|
486
|
-
arr: (a) => Array.isArray(a),
|
|
487
|
-
equ(a, b, { arrays = "shallow", objects = "reference", strict = true } = {}) {
|
|
488
|
-
if (typeof a !== typeof b || !!a !== !!b) return false;
|
|
489
|
-
if (is.str(a) || is.num(a) || is.boo(a)) return a === b;
|
|
490
|
-
const isObj = is.obj(a);
|
|
491
|
-
if (isObj && objects === "reference") return a === b;
|
|
492
|
-
const isArr = is.arr(a);
|
|
493
|
-
if (isArr && arrays === "reference") return a === b;
|
|
494
|
-
if ((isArr || isObj) && a === b) return true;
|
|
495
|
-
let i;
|
|
496
|
-
for (i in a) if (!(i in b)) return false;
|
|
497
|
-
if (isObj && arrays === "shallow" && objects === "shallow") {
|
|
498
|
-
for (i in strict ? b : a) if (!is.equ(a[i], b[i], { strict, objects: "reference" })) return false;
|
|
499
|
-
} else {
|
|
500
|
-
for (i in strict ? b : a) if (a[i] !== b[i]) return false;
|
|
501
|
-
}
|
|
502
|
-
if (is.und(i)) {
|
|
503
|
-
if (isArr && a.length === 0 && b.length === 0) return true;
|
|
504
|
-
if (isObj && Object.keys(a).length === 0 && Object.keys(b).length === 0) return true;
|
|
505
|
-
if (a !== b) return false;
|
|
506
|
-
}
|
|
507
|
-
return true;
|
|
508
|
-
}
|
|
509
|
-
};
|
|
510
|
-
const isOrthographicCamera = (def) => def && def.isOrthographicCamera;
|
|
511
|
-
const isRef = (obj) => obj !== null && typeof obj === "object" && obj.hasOwnProperty("current");
|
|
512
|
-
const isColorRepresentation = (value) => value != null && (typeof value === "string" || typeof value === "number" || value.isColor);
|
|
513
|
-
const isObject3D = (object) => object?.isObject3D;
|
|
514
|
-
const isTexture = (value) => !!value?.isTexture;
|
|
515
|
-
const isVectorLike = (object) => object !== null && typeof object === "object" && "set" in object && typeof object.set === "function";
|
|
516
|
-
const isCopyable = (object) => isVectorLike(object) && "copy" in object && typeof object.copy === "function";
|
|
517
|
-
const hasConstructor = (object) => !!object?.constructor;
|
|
518
|
-
|
|
519
|
-
function calculateDpr(dpr) {
|
|
520
|
-
const target = typeof window !== "undefined" ? window.devicePixelRatio ?? 2 : 1;
|
|
521
|
-
return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
|
|
522
|
-
}
|
|
523
|
-
function getUuidPrefix(uuid) {
|
|
524
|
-
return uuid.split("-")[0];
|
|
525
|
-
}
|
|
526
|
-
function updateCamera(camera, size) {
|
|
527
|
-
if (camera.manual) return;
|
|
528
|
-
if (isOrthographicCamera(camera)) {
|
|
529
|
-
camera.left = size.width / -2;
|
|
530
|
-
camera.right = size.width / 2;
|
|
531
|
-
camera.top = size.height / 2;
|
|
532
|
-
camera.bottom = size.height / -2;
|
|
533
|
-
} else {
|
|
534
|
-
camera.aspect = size.width / size.height;
|
|
535
|
-
}
|
|
536
|
-
camera.updateProjectionMatrix();
|
|
537
|
-
}
|
|
538
|
-
const frustumMatrix = new Matrix4();
|
|
539
|
-
function updateFrustum(camera, frustum) {
|
|
540
|
-
const target = frustum ?? new Frustum();
|
|
541
|
-
frustumMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
542
|
-
target.setFromProjectionMatrix(frustumMatrix);
|
|
543
|
-
return target;
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
const REACT_INTERNAL_PROPS = ["children", "key", "ref"];
|
|
547
|
-
function findInitialRoot(instance) {
|
|
548
|
-
let root = instance.root;
|
|
549
|
-
while (root.getState().previousRoot) root = root.getState().previousRoot;
|
|
550
|
-
return root;
|
|
551
|
-
}
|
|
552
|
-
function getRootState(obj) {
|
|
553
|
-
let state = obj.__r3f?.root.getState();
|
|
554
|
-
if (!state) {
|
|
555
|
-
obj.traverseAncestors((ancestor) => {
|
|
556
|
-
const parentState = ancestor.__r3f?.root.getState();
|
|
557
|
-
if (parentState) {
|
|
558
|
-
state = parentState;
|
|
559
|
-
return false;
|
|
560
|
-
}
|
|
561
|
-
});
|
|
562
|
-
}
|
|
563
|
-
return state;
|
|
564
|
-
}
|
|
565
|
-
function buildGraph(object) {
|
|
566
|
-
const data = { nodes: {}, materials: {}, meshes: {} };
|
|
567
|
-
if (object) {
|
|
568
|
-
object.traverse((obj) => {
|
|
569
|
-
if (obj.name) data.nodes[obj.name] = obj;
|
|
570
|
-
if (obj.material) {
|
|
571
|
-
const material = Array.isArray(obj.material) ? obj.material[0] : obj.material;
|
|
572
|
-
const nameAlreadyUsed = data.materials[material.name];
|
|
573
|
-
let materialName = material.name;
|
|
574
|
-
if (nameAlreadyUsed) {
|
|
575
|
-
materialName = materialName + `-${getUuidPrefix(material.uuid)}`;
|
|
576
|
-
material.userData.materialCacheName = materialName;
|
|
577
|
-
}
|
|
578
|
-
data.materials[materialName] = material;
|
|
579
|
-
}
|
|
580
|
-
if (obj.isMesh && !data.meshes[obj.name]) data.meshes[obj.name] = obj;
|
|
581
|
-
});
|
|
582
|
-
}
|
|
583
|
-
return data;
|
|
584
|
-
}
|
|
585
|
-
function dispose(obj) {
|
|
586
|
-
if (obj.type !== "Scene") obj.dispose?.();
|
|
587
|
-
for (const p in obj) {
|
|
588
|
-
const prop = obj[p];
|
|
589
|
-
if (prop?.type !== "Scene") prop?.dispose?.();
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
function getInstanceProps(pendingProps) {
|
|
593
|
-
const props = {};
|
|
594
|
-
for (const key in pendingProps) {
|
|
595
|
-
if (!REACT_INTERNAL_PROPS.includes(key)) props[key] = pendingProps[key];
|
|
596
|
-
}
|
|
597
|
-
return props;
|
|
598
|
-
}
|
|
599
|
-
function prepare(target, root, type, props) {
|
|
600
|
-
const object = target;
|
|
601
|
-
let instance = object?.__r3f;
|
|
602
|
-
if (!instance) {
|
|
603
|
-
instance = {
|
|
604
|
-
root,
|
|
605
|
-
type,
|
|
606
|
-
parent: null,
|
|
607
|
-
children: [],
|
|
608
|
-
props: getInstanceProps(props),
|
|
609
|
-
object,
|
|
610
|
-
eventCount: 0,
|
|
611
|
-
handlers: {},
|
|
612
|
-
isHidden: false
|
|
613
|
-
};
|
|
614
|
-
if (object) object.__r3f = instance;
|
|
615
|
-
}
|
|
616
|
-
return instance;
|
|
617
|
-
}
|
|
618
|
-
function invalidateInstance(instance) {
|
|
619
|
-
if (!instance.parent) return;
|
|
620
|
-
instance.props.onUpdate?.(instance.object);
|
|
621
|
-
const state = instance.root?.getState?.();
|
|
622
|
-
if (state && state.internal.frames === 0) state.invalidate();
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
const tempFrustum = new Frustum();
|
|
626
|
-
let hasWarnedWebGL = false;
|
|
627
|
-
let tslModule = null;
|
|
628
|
-
async function loadTSL() {
|
|
629
|
-
if (tslModule) return tslModule;
|
|
630
|
-
try {
|
|
631
|
-
const tsl = await import('three/tsl');
|
|
632
|
-
tslModule = { uniform: tsl.uniform, nodeObject: tsl.nodeObject };
|
|
633
|
-
return tslModule;
|
|
634
|
-
} catch {
|
|
635
|
-
return null;
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
function createOcclusionObserverNode(store, uniform) {
|
|
639
|
-
const node = new Node("float");
|
|
640
|
-
node.updateType = NodeUpdateType.OBJECT;
|
|
641
|
-
node.update = function(frame) {
|
|
642
|
-
const { internal } = store.getState();
|
|
643
|
-
const registry = internal.visibilityRegistry;
|
|
644
|
-
const cache = internal.occlusionCache;
|
|
645
|
-
for (const entry of registry.values()) {
|
|
646
|
-
const { object, handlers } = entry;
|
|
647
|
-
if (handlers.onOccluded || handlers.onVisible) {
|
|
648
|
-
const isOccluded = frame.renderer.isOccluded(object);
|
|
649
|
-
cache.set(object, isOccluded);
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
};
|
|
653
|
-
node.setup = function() {
|
|
654
|
-
return uniform(0);
|
|
655
|
-
};
|
|
656
|
-
return node;
|
|
311
|
+
function createOcclusionObserverNode(store, uniform) {
|
|
312
|
+
const node = new Node("float");
|
|
313
|
+
node.updateType = NodeUpdateType.OBJECT;
|
|
314
|
+
node.update = function(frame) {
|
|
315
|
+
const { internal } = store.getState();
|
|
316
|
+
const registry = internal.visibilityRegistry;
|
|
317
|
+
const cache = internal.occlusionCache;
|
|
318
|
+
for (const entry of registry.values()) {
|
|
319
|
+
const { object, handlers } = entry;
|
|
320
|
+
if (handlers.onOccluded || handlers.onVisible) {
|
|
321
|
+
const isOccluded = frame.renderer.isOccluded(object);
|
|
322
|
+
cache.set(object, isOccluded);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
node.setup = function() {
|
|
327
|
+
return uniform(0);
|
|
328
|
+
};
|
|
329
|
+
return node;
|
|
657
330
|
}
|
|
658
331
|
let occlusionSetupPromise = null;
|
|
659
332
|
function enableOcclusion(store) {
|
|
@@ -1056,1350 +729,890 @@ function applyProps(object, props) {
|
|
|
1056
729
|
return object;
|
|
1057
730
|
}
|
|
1058
731
|
|
|
1059
|
-
const
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
if (!state) {
|
|
1064
|
-
state = {
|
|
1065
|
-
hovered: /* @__PURE__ */ new Map(),
|
|
1066
|
-
captured: /* @__PURE__ */ new Map(),
|
|
1067
|
-
initialClick: [0, 0],
|
|
1068
|
-
initialHits: []
|
|
1069
|
-
};
|
|
1070
|
-
internal.pointerMap.set(pointerId, state);
|
|
732
|
+
const shownNotices = /* @__PURE__ */ new Set();
|
|
733
|
+
function notifyDepreciated({ heading, body, link }) {
|
|
734
|
+
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_DEPRECATION_WARNINGS !== "true") {
|
|
735
|
+
return;
|
|
1071
736
|
}
|
|
1072
|
-
return
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
function makeId(event) {
|
|
1078
|
-
return (event.eventObject || event.object).uuid + "/" + event.index + event.instanceId;
|
|
1079
|
-
}
|
|
1080
|
-
function releaseInternalPointerCapture(internal, obj, pointerId) {
|
|
1081
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1082
|
-
if (!pointerState) return;
|
|
1083
|
-
const captureData = pointerState.captured.get(obj);
|
|
1084
|
-
if (captureData) {
|
|
1085
|
-
pointerState.captured.delete(obj);
|
|
1086
|
-
captureData.target.releasePointerCapture(pointerId);
|
|
737
|
+
if (shownNotices.has(heading)) return;
|
|
738
|
+
shownNotices.add(heading);
|
|
739
|
+
const caller = getCallerFrame();
|
|
740
|
+
if (caller) {
|
|
741
|
+
console.log();
|
|
1087
742
|
}
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
for (let i = 0; i < internal.interaction.length; i++) {
|
|
1092
|
-
if (internal.interaction[i] === object) internal.interaction[i] = newObject;
|
|
743
|
+
const boxStyle = "background: #ff9800; color: #1a1a1a; padding: 8px 12px; border-radius: 4px; font-weight: 500;";
|
|
744
|
+
if (caller) {
|
|
745
|
+
console.log(`%c\u26A0\uFE0F ${heading}`, boxStyle);
|
|
1093
746
|
}
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
if (value.eventObject === object || value.object === object) {
|
|
1100
|
-
pointerState.hovered.delete(key);
|
|
1101
|
-
const next = {
|
|
1102
|
-
...value,
|
|
1103
|
-
eventObject: value.eventObject === object ? newObject : value.eventObject,
|
|
1104
|
-
object: value.object === object ? newObject : value.object
|
|
1105
|
-
};
|
|
1106
|
-
pointerState.hovered.set(makeId(next), next);
|
|
1107
|
-
}
|
|
1108
|
-
});
|
|
1109
|
-
const captureData = pointerState.captured.get(object);
|
|
1110
|
-
if (captureData) {
|
|
1111
|
-
pointerState.captured.delete(object);
|
|
1112
|
-
pointerState.captured.set(newObject, {
|
|
1113
|
-
...captureData,
|
|
1114
|
-
intersection: {
|
|
1115
|
-
...captureData.intersection,
|
|
1116
|
-
object: captureData.intersection.object === object ? newObject : captureData.intersection.object,
|
|
1117
|
-
eventObject: captureData.intersection.eventObject === object ? newObject : captureData.intersection.eventObject
|
|
1118
|
-
}
|
|
1119
|
-
});
|
|
1120
|
-
}
|
|
747
|
+
if (body || link) {
|
|
748
|
+
let message = "";
|
|
749
|
+
if (body) message += body;
|
|
750
|
+
if (link) message += (body ? "\n\n" : "") + `More info: ${link}`;
|
|
751
|
+
console.warn(`%c${message}`, "font-weight: bold;");
|
|
1121
752
|
}
|
|
1122
|
-
unregisterVisibility(store, object);
|
|
1123
753
|
}
|
|
1124
|
-
function
|
|
1125
|
-
const
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
});
|
|
1134
|
-
if (pointerState.captured.has(object)) {
|
|
1135
|
-
releaseInternalPointerCapture(internal, object, pointerId);
|
|
1136
|
-
}
|
|
754
|
+
function getCallerFrame(depth = 3) {
|
|
755
|
+
const stack = new Error().stack;
|
|
756
|
+
if (!stack) return null;
|
|
757
|
+
const lines = stack.split("\n");
|
|
758
|
+
const frame = lines[depth];
|
|
759
|
+
if (!frame) return null;
|
|
760
|
+
let match = frame.match(/^\s*at (?:(.+?) )?\(?(.+?):(\d+):(\d+)\)?$/);
|
|
761
|
+
if (!match) {
|
|
762
|
+
match = frame.match(/^(?:(.+?)@)?(.+?):(\d+):(\d+)$/);
|
|
1137
763
|
}
|
|
1138
|
-
|
|
764
|
+
if (!match) return null;
|
|
765
|
+
const [, fn, url, line] = match;
|
|
766
|
+
return {
|
|
767
|
+
functionName: fn ?? "<anonymous>",
|
|
768
|
+
location: formatLocation(url, Number(line))
|
|
769
|
+
};
|
|
1139
770
|
}
|
|
1140
|
-
function
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
return Math.round(Math.sqrt(dx * dx + dy * dy));
|
|
771
|
+
function formatLocation(url, line) {
|
|
772
|
+
const clean = url.split("?")[0];
|
|
773
|
+
const file = clean.split("/").pop() ?? clean;
|
|
774
|
+
return `${file}:${line}`;
|
|
775
|
+
}
|
|
776
|
+
function notifyAlpha({ message, link }) {
|
|
777
|
+
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_ALPHA_WARNINGS !== "true") {
|
|
778
|
+
return;
|
|
1149
779
|
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
) || obj.__r3f?.handlers.onDrop
|
|
1157
|
-
);
|
|
780
|
+
if (shownNotices.has(message)) return;
|
|
781
|
+
shownNotices.add(message);
|
|
782
|
+
const boxStyle = "background: #6366f1; color: #ffffff; padding: 6px 10px; border-radius: 4px; font-weight: 500;";
|
|
783
|
+
console.log(`%c\u{1F52C} ${message}`, boxStyle);
|
|
784
|
+
{
|
|
785
|
+
console.log(`%cMore info: ${link}`, "color: #6366f1; font-weight: normal;");
|
|
1158
786
|
}
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
const INTERNAL_LIB_MARKERS = ["zustand", "setState", "Object.assign"];
|
|
790
|
+
function isInternalRendererAccess(stack, callerDepth = 2) {
|
|
791
|
+
if (!stack) return false;
|
|
792
|
+
const caller = stack.split("\n")[callerDepth] ?? "";
|
|
793
|
+
return INTERNAL_LIB_MARKERS.some((m) => caller.includes(m));
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
const R3F_CONTEXT = Symbol.for("@react-three/fiber.context");
|
|
797
|
+
const context = globalThis[R3F_CONTEXT] ?? (globalThis[R3F_CONTEXT] = React.createContext(null));
|
|
798
|
+
const createStore = (invalidate, advance) => {
|
|
799
|
+
const rootStore = createWithEqualityFn((set, get) => {
|
|
800
|
+
const position = new Vector3();
|
|
801
|
+
const defaultTarget = new Vector3();
|
|
802
|
+
const tempTarget = new Vector3();
|
|
803
|
+
function getCurrentViewport(camera = get().camera, target = defaultTarget, size = get().size) {
|
|
804
|
+
const { width, height, top, left } = size;
|
|
805
|
+
const aspect = width / height;
|
|
806
|
+
if (target.isVector3) tempTarget.copy(target);
|
|
807
|
+
else tempTarget.set(...target);
|
|
808
|
+
const distance = camera.getWorldPosition(position).distanceTo(tempTarget);
|
|
809
|
+
if (isOrthographicCamera(camera)) {
|
|
810
|
+
return { width: width / camera.zoom, height: height / camera.zoom, top, left, factor: 1, distance, aspect };
|
|
811
|
+
} else {
|
|
812
|
+
const fov = camera.fov * Math.PI / 180;
|
|
813
|
+
const h = 2 * Math.tan(fov / 2) * distance;
|
|
814
|
+
const w = h * (width / height);
|
|
815
|
+
return { width: w, height: h, top, left, factor: width / w, distance, aspect };
|
|
1179
816
|
}
|
|
1180
|
-
return state2.raycaster.camera ? state2.raycaster.intersectObject(obj, true) : [];
|
|
1181
817
|
}
|
|
1182
|
-
let
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
818
|
+
let performanceTimeout = void 0;
|
|
819
|
+
const setPerformanceCurrent = (current) => set((state2) => ({ performance: { ...state2.performance, current } }));
|
|
820
|
+
const pointer = new Vector2();
|
|
821
|
+
const rootState = {
|
|
822
|
+
set,
|
|
823
|
+
get,
|
|
824
|
+
// Mock objects that have to be configured
|
|
825
|
+
// primaryStore is set after store creation (self-reference for primary, primary's store for secondary)
|
|
826
|
+
primaryStore: null,
|
|
827
|
+
gl: null,
|
|
828
|
+
renderer: null,
|
|
829
|
+
camera: null,
|
|
830
|
+
frustum: new Frustum(),
|
|
831
|
+
autoUpdateFrustum: true,
|
|
832
|
+
raycaster: null,
|
|
833
|
+
events: {
|
|
834
|
+
priority: 1,
|
|
835
|
+
enabled: true,
|
|
836
|
+
connected: false,
|
|
837
|
+
frameTimedRaycasts: true,
|
|
838
|
+
alwaysFireOnScroll: true,
|
|
839
|
+
updateOnFrame: false
|
|
840
|
+
},
|
|
841
|
+
scene: null,
|
|
842
|
+
rootScene: null,
|
|
843
|
+
xr: null,
|
|
844
|
+
inspector: null,
|
|
845
|
+
invalidate: (frames = 1, stackFrames = false) => invalidate(get(), frames, stackFrames),
|
|
846
|
+
advance: (timestamp, runGlobalEffects) => advance(timestamp, runGlobalEffects, get()),
|
|
847
|
+
textureColorSpace: SRGBColorSpace,
|
|
848
|
+
isLegacy: false,
|
|
849
|
+
webGPUSupported: false,
|
|
850
|
+
isNative: false,
|
|
851
|
+
controls: null,
|
|
852
|
+
pointer,
|
|
853
|
+
mouse: pointer,
|
|
854
|
+
frameloop: "always",
|
|
855
|
+
onPointerMissed: void 0,
|
|
856
|
+
onDragOverMissed: void 0,
|
|
857
|
+
onDropMissed: void 0,
|
|
858
|
+
performance: {
|
|
859
|
+
current: 1,
|
|
860
|
+
min: 0.5,
|
|
861
|
+
max: 1,
|
|
862
|
+
debounce: 200,
|
|
863
|
+
regress: () => {
|
|
864
|
+
const state2 = get();
|
|
865
|
+
if (performanceTimeout) clearTimeout(performanceTimeout);
|
|
866
|
+
if (state2.performance.current !== state2.performance.min) setPerformanceCurrent(state2.performance.min);
|
|
867
|
+
performanceTimeout = setTimeout(
|
|
868
|
+
() => setPerformanceCurrent(get().performance.max),
|
|
869
|
+
state2.performance.debounce
|
|
870
|
+
);
|
|
1190
871
|
}
|
|
1191
|
-
}
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
872
|
+
},
|
|
873
|
+
size: { width: 0, height: 0, top: 0, left: 0 },
|
|
874
|
+
viewport: {
|
|
875
|
+
initialDpr: 0,
|
|
876
|
+
dpr: 0,
|
|
877
|
+
width: 0,
|
|
878
|
+
height: 0,
|
|
879
|
+
top: 0,
|
|
880
|
+
left: 0,
|
|
881
|
+
aspect: 0,
|
|
882
|
+
distance: 0,
|
|
883
|
+
factor: 0,
|
|
884
|
+
getCurrentViewport
|
|
885
|
+
},
|
|
886
|
+
setEvents: (events) => set((state2) => ({ ...state2, events: { ...state2.events, ...events } })),
|
|
887
|
+
setSize: (width, height, top, left) => {
|
|
888
|
+
const state2 = get();
|
|
889
|
+
if (width === void 0) {
|
|
890
|
+
set({ _sizeImperative: false });
|
|
891
|
+
if (state2._sizeProps) {
|
|
892
|
+
const { width: propW, height: propH } = state2._sizeProps;
|
|
893
|
+
if (propW !== void 0 || propH !== void 0) {
|
|
894
|
+
const currentSize = state2.size;
|
|
895
|
+
const newSize = {
|
|
896
|
+
width: propW ?? currentSize.width,
|
|
897
|
+
height: propH ?? currentSize.height,
|
|
898
|
+
top: currentSize.top,
|
|
899
|
+
left: currentSize.left
|
|
900
|
+
};
|
|
901
|
+
set((s) => ({
|
|
902
|
+
size: newSize,
|
|
903
|
+
viewport: { ...s.viewport, ...getCurrentViewport(state2.camera, defaultTarget, newSize) }
|
|
904
|
+
}));
|
|
905
|
+
getScheduler().invalidate();
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
return;
|
|
1209
909
|
}
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
910
|
+
const w = width;
|
|
911
|
+
const h = height ?? width;
|
|
912
|
+
const t = top ?? state2.size.top;
|
|
913
|
+
const l = left ?? state2.size.left;
|
|
914
|
+
const size = { width: w, height: h, top: t, left: l };
|
|
915
|
+
set((s) => ({
|
|
916
|
+
size,
|
|
917
|
+
viewport: { ...s.viewport, ...getCurrentViewport(state2.camera, defaultTarget, size) },
|
|
918
|
+
_sizeImperative: true
|
|
919
|
+
}));
|
|
920
|
+
getScheduler().invalidate();
|
|
921
|
+
},
|
|
922
|
+
setDpr: (dpr) => set((state2) => {
|
|
923
|
+
const resolved = calculateDpr(dpr);
|
|
924
|
+
return { viewport: { ...state2.viewport, dpr: resolved, initialDpr: state2.viewport.initialDpr || resolved } };
|
|
925
|
+
}),
|
|
926
|
+
setFrameloop: (frameloop = "always") => {
|
|
927
|
+
set(() => ({ frameloop }));
|
|
928
|
+
getScheduler().frameloop = frameloop;
|
|
929
|
+
},
|
|
930
|
+
setError: (error) => set(() => ({ error })),
|
|
931
|
+
error: null,
|
|
932
|
+
//* TSL State (managed via hooks: useUniforms, useNodes, useBuffers, useGPUStorage, useTextures, useRenderPipeline) ==============================
|
|
933
|
+
uniforms: {},
|
|
934
|
+
nodes: {},
|
|
935
|
+
buffers: {},
|
|
936
|
+
gpuStorage: {},
|
|
937
|
+
textures: /* @__PURE__ */ new Map(),
|
|
938
|
+
_textureRefs: /* @__PURE__ */ new Map(),
|
|
939
|
+
renderPipeline: null,
|
|
940
|
+
passes: {},
|
|
941
|
+
_hmrVersion: 0,
|
|
942
|
+
_sizeImperative: false,
|
|
943
|
+
_sizeProps: null,
|
|
944
|
+
previousRoot: void 0,
|
|
945
|
+
internal: {
|
|
946
|
+
// Events
|
|
947
|
+
interaction: [],
|
|
948
|
+
subscribers: [],
|
|
949
|
+
// Per-pointer state (new unified structure)
|
|
950
|
+
pointerMap: /* @__PURE__ */ new Map(),
|
|
951
|
+
pointerDirty: /* @__PURE__ */ new Map(),
|
|
952
|
+
lastEvent: React.createRef(),
|
|
953
|
+
// Deprecated but kept for backwards compatibility
|
|
954
|
+
hovered: /* @__PURE__ */ new Map(),
|
|
955
|
+
initialClick: [0, 0],
|
|
956
|
+
initialHits: [],
|
|
957
|
+
capturedMap: /* @__PURE__ */ new Map(),
|
|
958
|
+
// Visibility tracking (onFramed, onOccluded, onVisible)
|
|
959
|
+
visibilityRegistry: /* @__PURE__ */ new Map(),
|
|
960
|
+
// Occlusion system (WebGPU only)
|
|
961
|
+
occlusionEnabled: false,
|
|
962
|
+
occlusionObserver: null,
|
|
963
|
+
occlusionCache: /* @__PURE__ */ new Map(),
|
|
964
|
+
helperGroup: null,
|
|
965
|
+
// Updates
|
|
966
|
+
active: false,
|
|
967
|
+
frames: 0,
|
|
968
|
+
priority: 0,
|
|
969
|
+
subscribe: (ref, priority, store) => {
|
|
970
|
+
const internal = get().internal;
|
|
971
|
+
internal.priority = internal.priority + (priority > 0 ? 1 : 0);
|
|
972
|
+
internal.subscribers.push({ ref, priority, store });
|
|
973
|
+
internal.subscribers = internal.subscribers.sort((a, b) => a.priority - b.priority);
|
|
974
|
+
return () => {
|
|
975
|
+
const internal2 = get().internal;
|
|
976
|
+
if (internal2?.subscribers) {
|
|
977
|
+
internal2.priority = internal2.priority - (priority > 0 ? 1 : 0);
|
|
978
|
+
internal2.subscribers = internal2.subscribers.filter((s) => s.ref !== ref);
|
|
979
|
+
}
|
|
980
|
+
};
|
|
981
|
+
},
|
|
982
|
+
// Renderer Storage (single source of truth)
|
|
983
|
+
actualRenderer: null,
|
|
984
|
+
// Scheduler for useFrameNext (initialized in renderer.tsx)
|
|
985
|
+
scheduler: null
|
|
986
|
+
}
|
|
987
|
+
};
|
|
988
|
+
return rootState;
|
|
989
|
+
});
|
|
990
|
+
const state = rootStore.getState();
|
|
991
|
+
Object.defineProperty(state, "gl", {
|
|
992
|
+
get() {
|
|
993
|
+
const currentState = rootStore.getState();
|
|
994
|
+
if (!currentState.isLegacy && currentState.internal.actualRenderer) {
|
|
995
|
+
const stack = new Error().stack || "";
|
|
996
|
+
if (!isInternalRendererAccess(stack)) {
|
|
997
|
+
const cleanedStack = stack.split("\n").slice(2).join("\n") || "Stack trace unavailable";
|
|
998
|
+
notifyDepreciated({
|
|
999
|
+
heading: "Accessing state.gl in WebGPU mode",
|
|
1000
|
+
body: "Please use state.renderer instead. state.gl is deprecated and will be removed in future versions.\n\nFor backwards compatibility, state.gl currently maps to state.renderer, but this may cause issues with libraries expecting WebGLRenderer.\n\nAccessed from:\n" + cleanedStack
|
|
1001
|
+
});
|
|
1219
1002
|
}
|
|
1220
1003
|
}
|
|
1004
|
+
return currentState.internal.actualRenderer;
|
|
1005
|
+
},
|
|
1006
|
+
set(value) {
|
|
1007
|
+
rootStore.getState().internal.actualRenderer = value;
|
|
1008
|
+
},
|
|
1009
|
+
enumerable: true,
|
|
1010
|
+
configurable: true
|
|
1011
|
+
});
|
|
1012
|
+
Object.defineProperty(state, "renderer", {
|
|
1013
|
+
get() {
|
|
1014
|
+
return rootStore.getState().internal.actualRenderer;
|
|
1015
|
+
},
|
|
1016
|
+
set(value) {
|
|
1017
|
+
rootStore.getState().internal.actualRenderer = value;
|
|
1018
|
+
},
|
|
1019
|
+
enumerable: true,
|
|
1020
|
+
configurable: true
|
|
1021
|
+
});
|
|
1022
|
+
let oldScene = state.scene;
|
|
1023
|
+
rootStore.subscribe(() => {
|
|
1024
|
+
const currentState = rootStore.getState();
|
|
1025
|
+
const { scene, rootScene, set } = currentState;
|
|
1026
|
+
if (scene !== oldScene) {
|
|
1027
|
+
oldScene = scene;
|
|
1028
|
+
if (scene?.isScene && scene !== rootScene) {
|
|
1029
|
+
set({ rootScene: scene });
|
|
1030
|
+
}
|
|
1221
1031
|
}
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
releaseInternalPointerCapture(internal, hit.eventObject, id);
|
|
1244
|
-
};
|
|
1245
|
-
const extractEventProps = {};
|
|
1246
|
-
for (const prop in event) {
|
|
1247
|
-
const property = event[prop];
|
|
1248
|
-
if (typeof property !== "function") extractEventProps[prop] = property;
|
|
1249
|
-
}
|
|
1250
|
-
const eventPointerId = "pointerId" in event ? event.pointerId : void 0;
|
|
1251
|
-
const raycastEvent = {
|
|
1252
|
-
...hit,
|
|
1253
|
-
...extractEventProps,
|
|
1254
|
-
pointer,
|
|
1255
|
-
intersections,
|
|
1256
|
-
stopped: localState.stopped,
|
|
1257
|
-
delta,
|
|
1258
|
-
unprojectedPoint,
|
|
1259
|
-
ray: raycaster.ray,
|
|
1260
|
-
camera,
|
|
1261
|
-
pointerId: eventPointerId,
|
|
1262
|
-
// Hijack stopPropagation, which just sets a flag
|
|
1263
|
-
stopPropagation() {
|
|
1264
|
-
const pointerState = eventPointerId !== void 0 ? internal.pointerMap.get(eventPointerId) : void 0;
|
|
1265
|
-
if (
|
|
1266
|
-
// ...if this pointer hasn't been captured
|
|
1267
|
-
!pointerState?.captured.size || // ... or if the hit object is capturing the pointer
|
|
1268
|
-
pointerState.captured.has(hit.eventObject)
|
|
1269
|
-
) {
|
|
1270
|
-
raycastEvent.stopped = localState.stopped = true;
|
|
1271
|
-
if (pointerState?.hovered.size && Array.from(pointerState.hovered.values()).find((i) => i.eventObject === hit.eventObject)) {
|
|
1272
|
-
const higher = intersections.slice(0, intersections.indexOf(hit));
|
|
1273
|
-
cancelPointer([...higher, hit], eventPointerId);
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
1276
|
-
},
|
|
1277
|
-
// there should be a distinction between target and currentTarget
|
|
1278
|
-
target: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
1279
|
-
currentTarget: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
1280
|
-
nativeEvent: event
|
|
1281
|
-
};
|
|
1282
|
-
callback(raycastEvent);
|
|
1283
|
-
if (localState.stopped === true) break;
|
|
1032
|
+
});
|
|
1033
|
+
let oldSize = state.size;
|
|
1034
|
+
let oldDpr = state.viewport.dpr;
|
|
1035
|
+
let oldCamera = state.camera;
|
|
1036
|
+
rootStore.subscribe(() => {
|
|
1037
|
+
const { camera, size, viewport, set, internal } = rootStore.getState();
|
|
1038
|
+
const actualRenderer = internal.actualRenderer;
|
|
1039
|
+
const canvasTarget = internal.canvasTarget;
|
|
1040
|
+
if (size.width !== oldSize.width || size.height !== oldSize.height || viewport.dpr !== oldDpr) {
|
|
1041
|
+
oldSize = size;
|
|
1042
|
+
oldDpr = viewport.dpr;
|
|
1043
|
+
updateCamera(camera, size);
|
|
1044
|
+
if (internal.isSecondary && canvasTarget) {
|
|
1045
|
+
if (viewport.dpr > 0) canvasTarget.setPixelRatio(viewport.dpr);
|
|
1046
|
+
canvasTarget.setSize(size.width, size.height, false);
|
|
1047
|
+
} else {
|
|
1048
|
+
if (viewport.dpr > 0) actualRenderer.setPixelRatio(viewport.dpr);
|
|
1049
|
+
actualRenderer.setSize(size.width, size.height, false);
|
|
1050
|
+
if (canvasTarget) {
|
|
1051
|
+
if (viewport.dpr > 0) canvasTarget.setPixelRatio(viewport.dpr);
|
|
1052
|
+
canvasTarget.setSize(size.width, size.height, false);
|
|
1284
1053
|
}
|
|
1285
1054
|
}
|
|
1286
1055
|
}
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
if (
|
|
1296
|
-
(
|
|
1297
|
-
)) {
|
|
1298
|
-
const eventObject = hoveredObj.eventObject;
|
|
1299
|
-
const instance = eventObject.__r3f;
|
|
1300
|
-
pointerState.hovered.delete(hoveredId);
|
|
1301
|
-
if (instance?.eventCount) {
|
|
1302
|
-
const handlers = instance.handlers;
|
|
1303
|
-
const data = { ...hoveredObj, intersections };
|
|
1304
|
-
handlers.onPointerOut?.(data);
|
|
1305
|
-
handlers.onPointerLeave?.(data);
|
|
1306
|
-
handlers.onDragOverLeave?.(data);
|
|
1307
|
-
}
|
|
1056
|
+
if (camera !== oldCamera) {
|
|
1057
|
+
oldCamera = camera;
|
|
1058
|
+
const { rootScene } = rootStore.getState();
|
|
1059
|
+
if (camera && rootScene && !camera.parent) {
|
|
1060
|
+
rootScene.add(camera);
|
|
1061
|
+
}
|
|
1062
|
+
set((state2) => ({ viewport: { ...state2.viewport, ...state2.viewport.getCurrentViewport(camera) } }));
|
|
1063
|
+
const currentState = rootStore.getState();
|
|
1064
|
+
if (currentState.autoUpdateFrustum && camera) {
|
|
1065
|
+
updateFrustum(camera, currentState.frustum);
|
|
1308
1066
|
}
|
|
1309
1067
|
}
|
|
1310
|
-
}
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1068
|
+
});
|
|
1069
|
+
rootStore.subscribe((state2) => invalidate(state2));
|
|
1070
|
+
return rootStore;
|
|
1071
|
+
};
|
|
1072
|
+
|
|
1073
|
+
const memoizedLoaders = /* @__PURE__ */ new WeakMap();
|
|
1074
|
+
const isConstructor$1 = (value) => typeof value === "function" && value?.prototype?.constructor === value;
|
|
1075
|
+
function getLoader$1(Proto) {
|
|
1076
|
+
if (isConstructor$1(Proto)) {
|
|
1077
|
+
let loader = memoizedLoaders.get(Proto);
|
|
1078
|
+
if (!loader) {
|
|
1079
|
+
loader = new Proto();
|
|
1080
|
+
memoizedLoaders.set(Proto, loader);
|
|
1315
1081
|
}
|
|
1082
|
+
return loader;
|
|
1316
1083
|
}
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
}
|
|
1329
|
-
function cleanupPointer(pointerId) {
|
|
1330
|
-
const { internal } = store.getState();
|
|
1331
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1332
|
-
if (pointerState) {
|
|
1333
|
-
for (const [, hoveredObj] of pointerState.hovered) {
|
|
1334
|
-
const eventObject = hoveredObj.eventObject;
|
|
1335
|
-
const instance = eventObject.__r3f;
|
|
1336
|
-
if (instance?.eventCount) {
|
|
1337
|
-
const handlers = instance.handlers;
|
|
1338
|
-
const data = { ...hoveredObj, intersections: [] };
|
|
1339
|
-
handlers.onPointerOut?.(data);
|
|
1340
|
-
handlers.onPointerLeave?.(data);
|
|
1341
|
-
}
|
|
1342
|
-
}
|
|
1343
|
-
internal.pointerMap.delete(pointerId);
|
|
1084
|
+
return Proto;
|
|
1085
|
+
}
|
|
1086
|
+
function loadingFn(extensions, onProgress) {
|
|
1087
|
+
return function(Proto, input) {
|
|
1088
|
+
const loader = getLoader$1(Proto);
|
|
1089
|
+
if (extensions) extensions(loader);
|
|
1090
|
+
if ("loadAsync" in loader && typeof loader.loadAsync === "function") {
|
|
1091
|
+
return loader.loadAsync(input, onProgress).then((data) => {
|
|
1092
|
+
if (isObject3D(data?.scene)) Object.assign(data, buildGraph(data.scene));
|
|
1093
|
+
return data;
|
|
1094
|
+
});
|
|
1344
1095
|
}
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1096
|
+
return new Promise(
|
|
1097
|
+
(res, reject) => loader.load(
|
|
1098
|
+
input,
|
|
1099
|
+
(data) => {
|
|
1100
|
+
if (isObject3D(data?.scene)) Object.assign(data, buildGraph(data.scene));
|
|
1101
|
+
res(data);
|
|
1102
|
+
},
|
|
1103
|
+
onProgress,
|
|
1104
|
+
(error) => reject(new Error(`Could not load ${input}: ${error?.message}`))
|
|
1105
|
+
)
|
|
1106
|
+
);
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
function useLoader(loader, input, extensions, onProgress, cacheKey) {
|
|
1110
|
+
const inputs = Array.isArray(input) ? input : [input];
|
|
1111
|
+
const cacheKeys = Array.isArray(cacheKey ?? input) ? cacheKey ?? input : [cacheKey ?? input];
|
|
1112
|
+
const fn = loadingFn(extensions, onProgress);
|
|
1113
|
+
const results = cacheKeys.map(
|
|
1114
|
+
(key, index) => suspend(() => fn(loader, inputs[index]), [loader, key], { equal: is.equ })
|
|
1115
|
+
);
|
|
1116
|
+
return Array.isArray(input) ? results : results[0];
|
|
1117
|
+
}
|
|
1118
|
+
useLoader.preload = function(loader, input, extensions, onProgress, cacheKey) {
|
|
1119
|
+
const inputs = Array.isArray(input) ? input : [input];
|
|
1120
|
+
const cacheKeys = Array.isArray(cacheKey ?? input) ? cacheKey ?? input : [cacheKey ?? input];
|
|
1121
|
+
cacheKeys.forEach(
|
|
1122
|
+
(key, index) => preload(() => loadingFn(extensions, onProgress)(loader, inputs[index]), [loader, key])
|
|
1123
|
+
);
|
|
1124
|
+
};
|
|
1125
|
+
useLoader.clear = function(loader, input, cacheKey) {
|
|
1126
|
+
const cacheKeys = Array.isArray(cacheKey ?? input) ? cacheKey ?? input : [cacheKey ?? input];
|
|
1127
|
+
cacheKeys.forEach((key) => clear([loader, key]));
|
|
1128
|
+
};
|
|
1129
|
+
useLoader.loader = getLoader$1;
|
|
1130
|
+
|
|
1131
|
+
function useFrame(callback, priorityOrOptions) {
|
|
1132
|
+
const store = React.useContext(context);
|
|
1133
|
+
const isInsideCanvas = store !== null;
|
|
1134
|
+
const scheduler = getScheduler();
|
|
1135
|
+
const optionsKey = typeof priorityOrOptions === "number" ? `p:${priorityOrOptions}` : priorityOrOptions ? JSON.stringify({
|
|
1136
|
+
id: priorityOrOptions.id,
|
|
1137
|
+
phase: priorityOrOptions.phase,
|
|
1138
|
+
priority: priorityOrOptions.priority,
|
|
1139
|
+
fps: priorityOrOptions.fps,
|
|
1140
|
+
drop: priorityOrOptions.drop,
|
|
1141
|
+
enabled: priorityOrOptions.enabled,
|
|
1142
|
+
before: priorityOrOptions.before,
|
|
1143
|
+
after: priorityOrOptions.after
|
|
1144
|
+
}) : "";
|
|
1145
|
+
const options = React.useMemo(() => {
|
|
1146
|
+
return typeof priorityOrOptions === "number" ? { priority: priorityOrOptions } : priorityOrOptions ?? {};
|
|
1147
|
+
}, [optionsKey]);
|
|
1148
|
+
const reactId = React.useId();
|
|
1149
|
+
const id = options.id ?? reactId;
|
|
1150
|
+
const callbackRef = useMutableCallback(callback);
|
|
1151
|
+
const isLegacyPriority = typeof priorityOrOptions === "number" && priorityOrOptions > 0;
|
|
1152
|
+
useIsomorphicLayoutEffect(() => {
|
|
1153
|
+
if (!callback) return;
|
|
1154
|
+
if (isInsideCanvas) {
|
|
1155
|
+
const state = store.getState();
|
|
1156
|
+
const rootId = state.internal.rootId;
|
|
1157
|
+
if (isLegacyPriority) {
|
|
1158
|
+
state.internal.priority++;
|
|
1159
|
+
let parentRoot = state.previousRoot;
|
|
1160
|
+
while (parentRoot) {
|
|
1161
|
+
const parentState = parentRoot.getState();
|
|
1162
|
+
if (parentState?.internal) parentState.internal.priority++;
|
|
1163
|
+
parentRoot = parentState?.previousRoot;
|
|
1369
1164
|
}
|
|
1165
|
+
notifyDepreciated({
|
|
1166
|
+
heading: "useFrame with numeric priority is deprecated",
|
|
1167
|
+
body: 'Using useFrame(callback, number) to control render order is deprecated.\n\nFor custom rendering, use: useFrame(callback, { phase: "render" })\nFor execution order within update phase, use: useFrame(callback, { priority: number })',
|
|
1168
|
+
link: "https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe"
|
|
1169
|
+
});
|
|
1370
1170
|
}
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
return () => cancelPointer([]);
|
|
1380
|
-
// Global cancel of these events
|
|
1381
|
-
case "onPointerCancel":
|
|
1382
|
-
return (event) => {
|
|
1383
|
-
const pointerId = getPointerId(event);
|
|
1384
|
-
cleanupPointer(pointerId);
|
|
1171
|
+
const wrappedCallback = (frameState, delta) => {
|
|
1172
|
+
const localState = store.getState();
|
|
1173
|
+
const mergedState = {
|
|
1174
|
+
...localState,
|
|
1175
|
+
time: frameState.time,
|
|
1176
|
+
delta: frameState.delta,
|
|
1177
|
+
elapsed: frameState.elapsed,
|
|
1178
|
+
frame: frameState.frame
|
|
1385
1179
|
};
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1180
|
+
callbackRef.current?.(mergedState, delta);
|
|
1181
|
+
};
|
|
1182
|
+
const unregister = scheduler.register(wrappedCallback, {
|
|
1183
|
+
id,
|
|
1184
|
+
rootId,
|
|
1185
|
+
...options
|
|
1186
|
+
});
|
|
1187
|
+
return () => {
|
|
1188
|
+
unregister();
|
|
1189
|
+
if (isLegacyPriority) {
|
|
1190
|
+
const currentState = store.getState();
|
|
1191
|
+
if (currentState.internal) {
|
|
1192
|
+
currentState.internal.priority--;
|
|
1193
|
+
let parentRoot = currentState.previousRoot;
|
|
1194
|
+
while (parentRoot) {
|
|
1195
|
+
const parentState = parentRoot.getState();
|
|
1196
|
+
if (parentState?.internal) parentState.internal.priority--;
|
|
1197
|
+
parentRoot = parentState?.previousRoot;
|
|
1198
|
+
}
|
|
1399
1199
|
}
|
|
1400
|
-
};
|
|
1401
|
-
}
|
|
1402
|
-
return function handleEvent(event) {
|
|
1403
|
-
const state = store.getState();
|
|
1404
|
-
const { onPointerMissed, onDragOverMissed, onDropMissed, internal, events } = state;
|
|
1405
|
-
const pointerId = getPointerId(event);
|
|
1406
|
-
internal.lastEvent.current = event;
|
|
1407
|
-
if (!events.enabled) return;
|
|
1408
|
-
const isPointerMove = name === "onPointerMove";
|
|
1409
|
-
const isDragOver = name === "onDragOver";
|
|
1410
|
-
const isDrop = name === "onDrop";
|
|
1411
|
-
const isClickEvent = name === "onClick" || name === "onContextMenu" || name === "onDoubleClick";
|
|
1412
|
-
const isPointerDown = name === "onPointerDown";
|
|
1413
|
-
const isPointerUp = name === "onPointerUp";
|
|
1414
|
-
const isWheel = name === "onWheel";
|
|
1415
|
-
const canDeferRaycasts = events.frameTimedRaycasts && state.frameloop === "always";
|
|
1416
|
-
if (isPointerMove && canDeferRaycasts) {
|
|
1417
|
-
events.compute?.(event, state);
|
|
1418
|
-
internal.pointerDirty.set(pointerId, event);
|
|
1419
|
-
return;
|
|
1420
|
-
}
|
|
1421
|
-
if (isWheel && canDeferRaycasts && !events.alwaysFireOnScroll) {
|
|
1422
|
-
events.compute?.(event, state);
|
|
1423
|
-
internal.pointerDirty.set(pointerId, event);
|
|
1424
|
-
return;
|
|
1425
|
-
}
|
|
1426
|
-
if ((isClickEvent || isPointerDown || isPointerUp) && internal.pointerDirty.has(pointerId)) {
|
|
1427
|
-
const deferredEvent = internal.pointerDirty.get(pointerId);
|
|
1428
|
-
internal.pointerDirty.delete(pointerId);
|
|
1429
|
-
processDeferredPointer(deferredEvent, pointerId);
|
|
1430
|
-
}
|
|
1431
|
-
const filter = isPointerMove || isDragOver || isDrop ? filterPointerEvents : void 0;
|
|
1432
|
-
const hits = intersect(event, filter);
|
|
1433
|
-
const delta = isClickEvent ? calculateDistance(event, pointerId) : 0;
|
|
1434
|
-
if (isPointerDown) {
|
|
1435
|
-
const pointerState2 = getPointerState(internal, pointerId);
|
|
1436
|
-
pointerState2.initialClick = [event.offsetX, event.offsetY];
|
|
1437
|
-
pointerState2.initialHits = hits.map((hit) => hit.eventObject);
|
|
1438
|
-
}
|
|
1439
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1440
|
-
const initialHits = pointerState?.initialHits ?? [];
|
|
1441
|
-
if (isClickEvent && !hits.length) {
|
|
1442
|
-
if (delta <= 2) {
|
|
1443
|
-
pointerMissed(event, internal.interaction);
|
|
1444
|
-
if (onPointerMissed) onPointerMissed(event);
|
|
1445
1200
|
}
|
|
1446
|
-
}
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
}
|
|
1510
|
-
|
|
1201
|
+
};
|
|
1202
|
+
} else {
|
|
1203
|
+
return scheduler.register(
|
|
1204
|
+
(state, delta) => {
|
|
1205
|
+
const frameState = state;
|
|
1206
|
+
if (!frameState.renderer) return;
|
|
1207
|
+
callbackRef.current?.(frameState, delta);
|
|
1208
|
+
},
|
|
1209
|
+
{ id, ...options }
|
|
1210
|
+
);
|
|
1211
|
+
}
|
|
1212
|
+
}, [store, scheduler, id, optionsKey, isLegacyPriority, isInsideCanvas]);
|
|
1213
|
+
const isPaused = React.useSyncExternalStore(
|
|
1214
|
+
// Subscribe function
|
|
1215
|
+
React.useCallback(
|
|
1216
|
+
(onStoreChange) => {
|
|
1217
|
+
return getScheduler().subscribeJobState(id, onStoreChange);
|
|
1218
|
+
},
|
|
1219
|
+
[id]
|
|
1220
|
+
),
|
|
1221
|
+
// getSnapshot function
|
|
1222
|
+
React.useCallback(() => getScheduler().isJobPaused(id), [id]),
|
|
1223
|
+
// getServerSnapshot function (SSR)
|
|
1224
|
+
React.useCallback(() => false, [])
|
|
1225
|
+
);
|
|
1226
|
+
const controls = React.useMemo(() => {
|
|
1227
|
+
const scheduler2 = getScheduler();
|
|
1228
|
+
return {
|
|
1229
|
+
/** The job's unique ID */
|
|
1230
|
+
id,
|
|
1231
|
+
/**
|
|
1232
|
+
* Access to the global scheduler for frame loop control.
|
|
1233
|
+
* Use for controlling the entire frame loop, adding phases, etc.
|
|
1234
|
+
*/
|
|
1235
|
+
scheduler: scheduler2,
|
|
1236
|
+
/**
|
|
1237
|
+
* Manually step this job only.
|
|
1238
|
+
* Bypasses FPS limiting - always runs.
|
|
1239
|
+
* @param timestamp Optional timestamp (defaults to performance.now())
|
|
1240
|
+
*/
|
|
1241
|
+
step: (timestamp) => {
|
|
1242
|
+
getScheduler().stepJob(id, timestamp);
|
|
1243
|
+
},
|
|
1244
|
+
/**
|
|
1245
|
+
* Manually step ALL jobs in the scheduler.
|
|
1246
|
+
* Useful for frameloop='never' mode.
|
|
1247
|
+
* @param timestamp Optional timestamp (defaults to performance.now())
|
|
1248
|
+
*/
|
|
1249
|
+
stepAll: (timestamp) => {
|
|
1250
|
+
getScheduler().step(timestamp);
|
|
1251
|
+
},
|
|
1252
|
+
/**
|
|
1253
|
+
* Pause this job (set enabled=false).
|
|
1254
|
+
* Job remains registered but won't run.
|
|
1255
|
+
*/
|
|
1256
|
+
pause: () => {
|
|
1257
|
+
getScheduler().pauseJob(id);
|
|
1258
|
+
},
|
|
1259
|
+
/**
|
|
1260
|
+
* Resume this job (set enabled=true).
|
|
1261
|
+
*/
|
|
1262
|
+
resume: () => {
|
|
1263
|
+
getScheduler().resumeJob(id);
|
|
1264
|
+
},
|
|
1265
|
+
/**
|
|
1266
|
+
* Reactive paused state - automatically updates when pause/resume is called.
|
|
1267
|
+
* No need for forceUpdate() in your components.
|
|
1268
|
+
*/
|
|
1269
|
+
isPaused
|
|
1511
1270
|
};
|
|
1512
|
-
}
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1271
|
+
}, [id, isPaused]);
|
|
1272
|
+
return controls;
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
const IsObject = (url) => url === Object(url) && !Array.isArray(url) && typeof url !== "function";
|
|
1276
|
+
function getUrls(input) {
|
|
1277
|
+
if (typeof input === "string") return [input];
|
|
1278
|
+
if (Array.isArray(input)) return input;
|
|
1279
|
+
return Object.values(input);
|
|
1280
|
+
}
|
|
1281
|
+
function allUrlsCached(urls, textureCache) {
|
|
1282
|
+
return urls.every((url) => textureCache.has(url));
|
|
1283
|
+
}
|
|
1284
|
+
function buildFromCache(input, textureCache) {
|
|
1285
|
+
if (typeof input === "string") {
|
|
1286
|
+
return textureCache.get(input);
|
|
1287
|
+
} else if (Array.isArray(input)) {
|
|
1288
|
+
return input.map((url) => textureCache.get(url));
|
|
1289
|
+
} else {
|
|
1290
|
+
const result = {};
|
|
1291
|
+
const objInput = input;
|
|
1292
|
+
for (const key in objInput) {
|
|
1293
|
+
result[key] = textureCache.get(objInput[key]);
|
|
1518
1294
|
}
|
|
1519
|
-
|
|
1295
|
+
return result;
|
|
1520
1296
|
}
|
|
1521
|
-
return { handlePointer, flushDeferredPointers, processDeferredPointer };
|
|
1522
1297
|
}
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
const
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
const { events, internal } = store.getState();
|
|
1560
|
-
if (!events.handlers) return;
|
|
1561
|
-
if (pointerId !== void 0) {
|
|
1562
|
-
const event = internal.pointerDirty.get(pointerId);
|
|
1563
|
-
if (event) {
|
|
1564
|
-
internal.pointerDirty.delete(pointerId);
|
|
1565
|
-
processDeferredPointer(event, pointerId);
|
|
1566
|
-
} else if (internal.lastEvent?.current) {
|
|
1567
|
-
processDeferredPointer(internal.lastEvent.current, pointerId);
|
|
1568
|
-
}
|
|
1569
|
-
} else {
|
|
1570
|
-
flushDeferredPointers();
|
|
1571
|
-
if (internal.lastEvent?.current) {
|
|
1572
|
-
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
1573
|
-
}
|
|
1574
|
-
}
|
|
1575
|
-
},
|
|
1576
|
-
flush: () => {
|
|
1577
|
-
const { events, internal } = store.getState();
|
|
1578
|
-
flushDeferredPointers();
|
|
1579
|
-
if (events.updateOnFrame && internal.lastEvent?.current && events.handlers) {
|
|
1580
|
-
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
1298
|
+
function useTexture(input, optionsOrOnLoad) {
|
|
1299
|
+
const renderer = useThree((state) => state.internal.actualRenderer);
|
|
1300
|
+
const store = useStore();
|
|
1301
|
+
const options = typeof optionsOrOnLoad === "function" ? { onLoad: optionsOrOnLoad } : optionsOrOnLoad ?? {};
|
|
1302
|
+
const { onLoad, cache = true } = options;
|
|
1303
|
+
const onLoadRef = useRef(onLoad);
|
|
1304
|
+
onLoadRef.current = onLoad;
|
|
1305
|
+
const onLoadCalledForRef = useRef(null);
|
|
1306
|
+
const urls = useMemo(() => getUrls(input), [input]);
|
|
1307
|
+
const cachedResult = useMemo(() => {
|
|
1308
|
+
if (!cache) return null;
|
|
1309
|
+
const textures = store.getState().textures;
|
|
1310
|
+
if (!allUrlsCached(urls, textures)) return null;
|
|
1311
|
+
return buildFromCache(input, textures);
|
|
1312
|
+
}, [cache, urls, input, store]);
|
|
1313
|
+
const loadedTextures = useLoader(
|
|
1314
|
+
TextureLoader,
|
|
1315
|
+
IsObject(input) ? Object.values(input) : input
|
|
1316
|
+
);
|
|
1317
|
+
const inputKey = urls.join("\0");
|
|
1318
|
+
useLayoutEffect(() => {
|
|
1319
|
+
if (cachedResult) return;
|
|
1320
|
+
if (onLoadCalledForRef.current === inputKey) return;
|
|
1321
|
+
onLoadCalledForRef.current = inputKey;
|
|
1322
|
+
onLoadRef.current?.(loadedTextures);
|
|
1323
|
+
}, [cachedResult, loadedTextures, inputKey]);
|
|
1324
|
+
useEffect(() => {
|
|
1325
|
+
if (cachedResult) return;
|
|
1326
|
+
if ("initTexture" in renderer) {
|
|
1327
|
+
let textureArray = [];
|
|
1328
|
+
if (Array.isArray(loadedTextures)) {
|
|
1329
|
+
textureArray = loadedTextures;
|
|
1330
|
+
} else if (loadedTextures instanceof Texture$1) {
|
|
1331
|
+
textureArray = [loadedTextures];
|
|
1332
|
+
} else if (IsObject(loadedTextures)) {
|
|
1333
|
+
textureArray = Object.values(loadedTextures);
|
|
1581
1334
|
}
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
const { set, events } = store.getState();
|
|
1586
|
-
events.disconnect?.();
|
|
1587
|
-
set((state) => ({ events: { ...state.events, connected: target } }));
|
|
1588
|
-
if (events.handlers) {
|
|
1589
|
-
for (const name in events.handlers) {
|
|
1590
|
-
const event = events.handlers[name];
|
|
1591
|
-
const [eventName, passive] = DOM_EVENTS[name];
|
|
1592
|
-
target.addEventListener(eventName, event, { passive });
|
|
1335
|
+
textureArray.forEach((texture) => {
|
|
1336
|
+
if (texture instanceof Texture$1) {
|
|
1337
|
+
renderer.initTexture(texture);
|
|
1593
1338
|
}
|
|
1594
|
-
}
|
|
1595
|
-
}
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1341
|
+
}, [renderer, loadedTextures, cachedResult]);
|
|
1342
|
+
const mappedTextures = useMemo(() => {
|
|
1343
|
+
if (cachedResult) return cachedResult;
|
|
1344
|
+
if (IsObject(input)) {
|
|
1345
|
+
const keyed = {};
|
|
1346
|
+
const textureArray = loadedTextures;
|
|
1347
|
+
let i = 0;
|
|
1348
|
+
for (const key in input) keyed[key] = textureArray[i++];
|
|
1349
|
+
return keyed;
|
|
1350
|
+
} else {
|
|
1351
|
+
return loadedTextures;
|
|
1352
|
+
}
|
|
1353
|
+
}, [input, loadedTextures, cachedResult]);
|
|
1354
|
+
useEffect(() => {
|
|
1355
|
+
if (!cache) return;
|
|
1356
|
+
const urlTextureMap = [];
|
|
1357
|
+
if (typeof input === "string") {
|
|
1358
|
+
urlTextureMap.push([input, mappedTextures]);
|
|
1359
|
+
} else if (Array.isArray(input)) {
|
|
1360
|
+
const textureArray = mappedTextures;
|
|
1361
|
+
input.forEach((url, i) => urlTextureMap.push([url, textureArray[i]]));
|
|
1362
|
+
} else if (IsObject(input)) {
|
|
1363
|
+
const textureRecord = mappedTextures;
|
|
1364
|
+
for (const key in input) {
|
|
1365
|
+
const url = input[key];
|
|
1366
|
+
urlTextureMap.push([url, textureRecord[key]]);
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
store.setState((state) => {
|
|
1370
|
+
const refs = new Map(state._textureRefs);
|
|
1371
|
+
let textures = state.textures;
|
|
1372
|
+
let added = false;
|
|
1373
|
+
for (const [url, texture] of urlTextureMap) {
|
|
1374
|
+
if (!textures.has(url)) {
|
|
1375
|
+
if (!added) {
|
|
1376
|
+
textures = new Map(textures);
|
|
1377
|
+
added = true;
|
|
1604
1378
|
}
|
|
1379
|
+
textures.set(url, texture);
|
|
1605
1380
|
}
|
|
1606
|
-
set(
|
|
1381
|
+
refs.set(url, (refs.get(url) ?? 0) + 1);
|
|
1607
1382
|
}
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
const
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1383
|
+
return added ? { textures, _textureRefs: refs } : { _textureRefs: refs };
|
|
1384
|
+
});
|
|
1385
|
+
return () => store.setState((state) => {
|
|
1386
|
+
const refs = new Map(state._textureRefs);
|
|
1387
|
+
for (const [url] of urlTextureMap) {
|
|
1388
|
+
const next = (refs.get(url) ?? 0) - 1;
|
|
1389
|
+
if (next <= 0) refs.delete(url);
|
|
1390
|
+
else refs.set(url, next);
|
|
1391
|
+
}
|
|
1392
|
+
return { _textureRefs: refs };
|
|
1393
|
+
});
|
|
1394
|
+
}, [cache, input, mappedTextures, store]);
|
|
1395
|
+
return mappedTextures;
|
|
1396
|
+
}
|
|
1397
|
+
useTexture.preload = (url) => useLoader.preload(TextureLoader, url);
|
|
1398
|
+
useTexture.clear = (input) => useLoader.clear(TextureLoader, input);
|
|
1399
|
+
const Texture = ({
|
|
1400
|
+
children,
|
|
1401
|
+
input,
|
|
1402
|
+
onLoad,
|
|
1403
|
+
cache
|
|
1404
|
+
}) => {
|
|
1405
|
+
const options = typeof onLoad === "function" ? { onLoad, cache } : { ...onLoad, cache };
|
|
1406
|
+
const ret = useTexture(input, options);
|
|
1407
|
+
return /* @__PURE__ */ jsx(Fragment, { children: children?.(ret) });
|
|
1408
|
+
};
|
|
1409
|
+
|
|
1410
|
+
function useTextures(selector) {
|
|
1411
|
+
const store = useStore();
|
|
1412
|
+
const registry = useMemo(() => {
|
|
1413
|
+
const getState = store.getState;
|
|
1414
|
+
const setState = store.setState;
|
|
1415
|
+
const getOne = (key) => getState().textures.get(key);
|
|
1416
|
+
return {
|
|
1417
|
+
get all() {
|
|
1418
|
+
return getState().textures;
|
|
1419
|
+
},
|
|
1420
|
+
get(input) {
|
|
1421
|
+
if (typeof input === "string") return getOne(input);
|
|
1422
|
+
if (Array.isArray(input)) return input.map(getOne);
|
|
1423
|
+
const out = {};
|
|
1424
|
+
for (const name in input) out[name] = getOne(input[name]);
|
|
1425
|
+
return out;
|
|
1426
|
+
},
|
|
1427
|
+
has: (key) => getState().textures.has(key),
|
|
1428
|
+
add(keyOrRecord, texture) {
|
|
1429
|
+
setState((state) => {
|
|
1430
|
+
const textures = new Map(state.textures);
|
|
1431
|
+
if (typeof keyOrRecord === "string") {
|
|
1432
|
+
textures.set(keyOrRecord, texture);
|
|
1433
|
+
} else {
|
|
1434
|
+
for (const key in keyOrRecord) textures.set(key, keyOrRecord[key]);
|
|
1630
1435
|
}
|
|
1436
|
+
return { textures };
|
|
1437
|
+
});
|
|
1438
|
+
},
|
|
1439
|
+
dispose(key, options) {
|
|
1440
|
+
const state = getState();
|
|
1441
|
+
const refs = state._textureRefs.get(key) ?? 0;
|
|
1442
|
+
if (refs > 0 && !options?.force) {
|
|
1443
|
+
console.warn(
|
|
1444
|
+
`[useTextures] "${key}" still has ${refs} active reference(s); skipping dispose. Pass { force: true } to override.`
|
|
1445
|
+
);
|
|
1446
|
+
return false;
|
|
1631
1447
|
}
|
|
1632
|
-
|
|
1448
|
+
state.textures.get(key)?.dispose();
|
|
1449
|
+
setState((s) => {
|
|
1450
|
+
const textures = new Map(s.textures);
|
|
1451
|
+
textures.delete(key);
|
|
1452
|
+
const nextRefs = new Map(s._textureRefs);
|
|
1453
|
+
nextRefs.delete(key);
|
|
1454
|
+
return { textures, _textureRefs: nextRefs };
|
|
1455
|
+
});
|
|
1456
|
+
return true;
|
|
1457
|
+
},
|
|
1458
|
+
disposeAll() {
|
|
1459
|
+
for (const texture of getState().textures.values()) texture.dispose();
|
|
1460
|
+
setState({ textures: /* @__PURE__ */ new Map(), _textureRefs: /* @__PURE__ */ new Map() });
|
|
1633
1461
|
}
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1462
|
+
};
|
|
1463
|
+
}, [store]);
|
|
1464
|
+
const subscribe = selector ? () => selector(registry) : (state) => state.textures;
|
|
1465
|
+
const selected = useThree(subscribe);
|
|
1466
|
+
return selector ? selected : registry;
|
|
1637
1467
|
}
|
|
1638
1468
|
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
if (
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
console.warn(`%c${message}`, "font-weight: bold;");
|
|
1659
|
-
}
|
|
1660
|
-
}
|
|
1661
|
-
function getCallerFrame(depth = 3) {
|
|
1662
|
-
const stack = new Error().stack;
|
|
1663
|
-
if (!stack) return null;
|
|
1664
|
-
const lines = stack.split("\n");
|
|
1665
|
-
const frame = lines[depth];
|
|
1666
|
-
if (!frame) return null;
|
|
1667
|
-
let match = frame.match(/^\s*at (?:(.+?) )?\(?(.+?):(\d+):(\d+)\)?$/);
|
|
1668
|
-
if (!match) {
|
|
1669
|
-
match = frame.match(/^(?:(.+?)@)?(.+?):(\d+):(\d+)$/);
|
|
1670
|
-
}
|
|
1671
|
-
if (!match) return null;
|
|
1672
|
-
const [, fn, url, line] = match;
|
|
1673
|
-
return {
|
|
1674
|
-
functionName: fn ?? "<anonymous>",
|
|
1675
|
-
location: formatLocation(url, Number(line))
|
|
1676
|
-
};
|
|
1677
|
-
}
|
|
1678
|
-
function formatLocation(url, line) {
|
|
1679
|
-
const clean = url.split("?")[0];
|
|
1680
|
-
const file = clean.split("/").pop() ?? clean;
|
|
1681
|
-
return `${file}:${line}`;
|
|
1682
|
-
}
|
|
1683
|
-
function notifyAlpha({ message, link }) {
|
|
1684
|
-
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_ALPHA_WARNINGS !== "true") {
|
|
1685
|
-
return;
|
|
1686
|
-
}
|
|
1687
|
-
if (shownNotices.has(message)) return;
|
|
1688
|
-
shownNotices.add(message);
|
|
1689
|
-
const boxStyle = "background: #6366f1; color: #ffffff; padding: 6px 10px; border-radius: 4px; font-weight: 500;";
|
|
1690
|
-
console.log(`%c\u{1F52C} ${message}`, boxStyle);
|
|
1691
|
-
{
|
|
1692
|
-
console.log(`%cMore info: ${link}`, "color: #6366f1; font-weight: normal;");
|
|
1469
|
+
function useRenderTarget(widthOrOptions, heightOrOptions, options) {
|
|
1470
|
+
const isLegacy = useThree((s) => s.isLegacy);
|
|
1471
|
+
const size = useThree((s) => s.size);
|
|
1472
|
+
let width;
|
|
1473
|
+
let height;
|
|
1474
|
+
let opts;
|
|
1475
|
+
if (typeof widthOrOptions === "object") {
|
|
1476
|
+
opts = widthOrOptions;
|
|
1477
|
+
} else if (typeof widthOrOptions === "number") {
|
|
1478
|
+
width = widthOrOptions;
|
|
1479
|
+
if (typeof heightOrOptions === "object") {
|
|
1480
|
+
height = widthOrOptions;
|
|
1481
|
+
opts = heightOrOptions;
|
|
1482
|
+
} else if (typeof heightOrOptions === "number") {
|
|
1483
|
+
height = heightOrOptions;
|
|
1484
|
+
opts = options;
|
|
1485
|
+
} else {
|
|
1486
|
+
height = widthOrOptions;
|
|
1487
|
+
}
|
|
1693
1488
|
}
|
|
1489
|
+
return useMemo(() => {
|
|
1490
|
+
const w = width ?? size.width;
|
|
1491
|
+
const h = height ?? size.height;
|
|
1492
|
+
{
|
|
1493
|
+
return isLegacy ? new WebGLRenderTarget(w, h, opts) : new RenderTarget(w, h, opts);
|
|
1494
|
+
}
|
|
1495
|
+
}, [width, height, size.width, size.height, opts, isLegacy]);
|
|
1694
1496
|
}
|
|
1695
1497
|
|
|
1696
|
-
const
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1498
|
+
const presetsObj = {
|
|
1499
|
+
apartment: "lebombo_1k.hdr",
|
|
1500
|
+
city: "potsdamer_platz_1k.hdr",
|
|
1501
|
+
dawn: "kiara_1_dawn_1k.hdr",
|
|
1502
|
+
forest: "forest_slope_1k.hdr",
|
|
1503
|
+
lobby: "st_fagans_interior_1k.hdr",
|
|
1504
|
+
night: "dikhololo_night_1k.hdr",
|
|
1505
|
+
park: "rooitou_park_1k.hdr",
|
|
1506
|
+
studio: "studio_small_03_1k.hdr",
|
|
1507
|
+
sunset: "venice_sunset_1k.hdr",
|
|
1508
|
+
warehouse: "empty_warehouse_01_1k.hdr"
|
|
1509
|
+
};
|
|
1702
1510
|
|
|
1703
|
-
const
|
|
1704
|
-
const
|
|
1705
|
-
const
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
return { width: width / camera.zoom, height: height / camera.zoom, top, left, factor: 1, distance, aspect };
|
|
1718
|
-
} else {
|
|
1719
|
-
const fov = camera.fov * Math.PI / 180;
|
|
1720
|
-
const h = 2 * Math.tan(fov / 2) * distance;
|
|
1721
|
-
const w = h * (width / height);
|
|
1722
|
-
return { width: w, height: h, top, left, factor: width / w, distance, aspect };
|
|
1723
|
-
}
|
|
1724
|
-
}
|
|
1725
|
-
let performanceTimeout = void 0;
|
|
1726
|
-
const setPerformanceCurrent = (current) => set((state2) => ({ performance: { ...state2.performance, current } }));
|
|
1727
|
-
const pointer = new Vector2();
|
|
1728
|
-
const rootState = {
|
|
1729
|
-
set,
|
|
1730
|
-
get,
|
|
1731
|
-
// Mock objects that have to be configured
|
|
1732
|
-
// primaryStore is set after store creation (self-reference for primary, primary's store for secondary)
|
|
1733
|
-
primaryStore: null,
|
|
1734
|
-
gl: null,
|
|
1735
|
-
renderer: null,
|
|
1736
|
-
camera: null,
|
|
1737
|
-
frustum: new Frustum(),
|
|
1738
|
-
autoUpdateFrustum: true,
|
|
1739
|
-
raycaster: null,
|
|
1740
|
-
events: {
|
|
1741
|
-
priority: 1,
|
|
1742
|
-
enabled: true,
|
|
1743
|
-
connected: false,
|
|
1744
|
-
frameTimedRaycasts: true,
|
|
1745
|
-
alwaysFireOnScroll: true,
|
|
1746
|
-
updateOnFrame: false
|
|
1747
|
-
},
|
|
1748
|
-
scene: null,
|
|
1749
|
-
rootScene: null,
|
|
1750
|
-
xr: null,
|
|
1751
|
-
inspector: null,
|
|
1752
|
-
invalidate: (frames = 1, stackFrames = false) => invalidate(get(), frames, stackFrames),
|
|
1753
|
-
advance: (timestamp, runGlobalEffects) => advance(timestamp, runGlobalEffects, get()),
|
|
1754
|
-
textureColorSpace: SRGBColorSpace,
|
|
1755
|
-
isLegacy: false,
|
|
1756
|
-
webGPUSupported: false,
|
|
1757
|
-
isNative: false,
|
|
1758
|
-
controls: null,
|
|
1759
|
-
pointer,
|
|
1760
|
-
mouse: pointer,
|
|
1761
|
-
frameloop: "always",
|
|
1762
|
-
onPointerMissed: void 0,
|
|
1763
|
-
onDragOverMissed: void 0,
|
|
1764
|
-
onDropMissed: void 0,
|
|
1765
|
-
performance: {
|
|
1766
|
-
current: 1,
|
|
1767
|
-
min: 0.5,
|
|
1768
|
-
max: 1,
|
|
1769
|
-
debounce: 200,
|
|
1770
|
-
regress: () => {
|
|
1771
|
-
const state2 = get();
|
|
1772
|
-
if (performanceTimeout) clearTimeout(performanceTimeout);
|
|
1773
|
-
if (state2.performance.current !== state2.performance.min) setPerformanceCurrent(state2.performance.min);
|
|
1774
|
-
performanceTimeout = setTimeout(
|
|
1775
|
-
() => setPerformanceCurrent(get().performance.max),
|
|
1776
|
-
state2.performance.debounce
|
|
1777
|
-
);
|
|
1778
|
-
}
|
|
1779
|
-
},
|
|
1780
|
-
size: { width: 0, height: 0, top: 0, left: 0 },
|
|
1781
|
-
viewport: {
|
|
1782
|
-
initialDpr: 0,
|
|
1783
|
-
dpr: 0,
|
|
1784
|
-
width: 0,
|
|
1785
|
-
height: 0,
|
|
1786
|
-
top: 0,
|
|
1787
|
-
left: 0,
|
|
1788
|
-
aspect: 0,
|
|
1789
|
-
distance: 0,
|
|
1790
|
-
factor: 0,
|
|
1791
|
-
getCurrentViewport
|
|
1792
|
-
},
|
|
1793
|
-
setEvents: (events) => set((state2) => ({ ...state2, events: { ...state2.events, ...events } })),
|
|
1794
|
-
setSize: (width, height, top, left) => {
|
|
1795
|
-
const state2 = get();
|
|
1796
|
-
if (width === void 0) {
|
|
1797
|
-
set({ _sizeImperative: false });
|
|
1798
|
-
if (state2._sizeProps) {
|
|
1799
|
-
const { width: propW, height: propH } = state2._sizeProps;
|
|
1800
|
-
if (propW !== void 0 || propH !== void 0) {
|
|
1801
|
-
const currentSize = state2.size;
|
|
1802
|
-
const newSize = {
|
|
1803
|
-
width: propW ?? currentSize.width,
|
|
1804
|
-
height: propH ?? currentSize.height,
|
|
1805
|
-
top: currentSize.top,
|
|
1806
|
-
left: currentSize.left
|
|
1807
|
-
};
|
|
1808
|
-
set((s) => ({
|
|
1809
|
-
size: newSize,
|
|
1810
|
-
viewport: { ...s.viewport, ...getCurrentViewport(state2.camera, defaultTarget, newSize) }
|
|
1811
|
-
}));
|
|
1812
|
-
getScheduler().invalidate();
|
|
1813
|
-
}
|
|
1814
|
-
}
|
|
1815
|
-
return;
|
|
1816
|
-
}
|
|
1817
|
-
const w = width;
|
|
1818
|
-
const h = height ?? width;
|
|
1819
|
-
const t = top ?? state2.size.top;
|
|
1820
|
-
const l = left ?? state2.size.left;
|
|
1821
|
-
const size = { width: w, height: h, top: t, left: l };
|
|
1822
|
-
set((s) => ({
|
|
1823
|
-
size,
|
|
1824
|
-
viewport: { ...s.viewport, ...getCurrentViewport(state2.camera, defaultTarget, size) },
|
|
1825
|
-
_sizeImperative: true
|
|
1826
|
-
}));
|
|
1827
|
-
getScheduler().invalidate();
|
|
1828
|
-
},
|
|
1829
|
-
setDpr: (dpr) => set((state2) => {
|
|
1830
|
-
const resolved = calculateDpr(dpr);
|
|
1831
|
-
return { viewport: { ...state2.viewport, dpr: resolved, initialDpr: state2.viewport.initialDpr || resolved } };
|
|
1832
|
-
}),
|
|
1833
|
-
setFrameloop: (frameloop = "always") => {
|
|
1834
|
-
set(() => ({ frameloop }));
|
|
1835
|
-
getScheduler().frameloop = frameloop;
|
|
1836
|
-
},
|
|
1837
|
-
setError: (error) => set(() => ({ error })),
|
|
1838
|
-
error: null,
|
|
1839
|
-
//* TSL State (managed via hooks: useUniforms, useNodes, useBuffers, useGPUStorage, useTextures, useRenderPipeline) ==============================
|
|
1840
|
-
uniforms: {},
|
|
1841
|
-
nodes: {},
|
|
1842
|
-
buffers: {},
|
|
1843
|
-
gpuStorage: {},
|
|
1844
|
-
textures: /* @__PURE__ */ new Map(),
|
|
1845
|
-
_textureRefs: /* @__PURE__ */ new Map(),
|
|
1846
|
-
renderPipeline: null,
|
|
1847
|
-
passes: {},
|
|
1848
|
-
_hmrVersion: 0,
|
|
1849
|
-
_sizeImperative: false,
|
|
1850
|
-
_sizeProps: null,
|
|
1851
|
-
previousRoot: void 0,
|
|
1852
|
-
internal: {
|
|
1853
|
-
// Events
|
|
1854
|
-
interaction: [],
|
|
1855
|
-
subscribers: [],
|
|
1856
|
-
// Per-pointer state (new unified structure)
|
|
1857
|
-
pointerMap: /* @__PURE__ */ new Map(),
|
|
1858
|
-
pointerDirty: /* @__PURE__ */ new Map(),
|
|
1859
|
-
lastEvent: React.createRef(),
|
|
1860
|
-
// Deprecated but kept for backwards compatibility
|
|
1861
|
-
hovered: /* @__PURE__ */ new Map(),
|
|
1862
|
-
initialClick: [0, 0],
|
|
1863
|
-
initialHits: [],
|
|
1864
|
-
capturedMap: /* @__PURE__ */ new Map(),
|
|
1865
|
-
// Visibility tracking (onFramed, onOccluded, onVisible)
|
|
1866
|
-
visibilityRegistry: /* @__PURE__ */ new Map(),
|
|
1867
|
-
// Occlusion system (WebGPU only)
|
|
1868
|
-
occlusionEnabled: false,
|
|
1869
|
-
occlusionObserver: null,
|
|
1870
|
-
occlusionCache: /* @__PURE__ */ new Map(),
|
|
1871
|
-
helperGroup: null,
|
|
1872
|
-
// Updates
|
|
1873
|
-
active: false,
|
|
1874
|
-
frames: 0,
|
|
1875
|
-
priority: 0,
|
|
1876
|
-
subscribe: (ref, priority, store) => {
|
|
1877
|
-
const internal = get().internal;
|
|
1878
|
-
internal.priority = internal.priority + (priority > 0 ? 1 : 0);
|
|
1879
|
-
internal.subscribers.push({ ref, priority, store });
|
|
1880
|
-
internal.subscribers = internal.subscribers.sort((a, b) => a.priority - b.priority);
|
|
1881
|
-
return () => {
|
|
1882
|
-
const internal2 = get().internal;
|
|
1883
|
-
if (internal2?.subscribers) {
|
|
1884
|
-
internal2.priority = internal2.priority - (priority > 0 ? 1 : 0);
|
|
1885
|
-
internal2.subscribers = internal2.subscribers.filter((s) => s.ref !== ref);
|
|
1886
|
-
}
|
|
1887
|
-
};
|
|
1888
|
-
},
|
|
1889
|
-
// Renderer Storage (single source of truth)
|
|
1890
|
-
actualRenderer: null,
|
|
1891
|
-
// Scheduler for useFrameNext (initialized in renderer.tsx)
|
|
1892
|
-
scheduler: null
|
|
1893
|
-
}
|
|
1894
|
-
};
|
|
1895
|
-
return rootState;
|
|
1896
|
-
});
|
|
1897
|
-
const state = rootStore.getState();
|
|
1898
|
-
Object.defineProperty(state, "gl", {
|
|
1899
|
-
get() {
|
|
1900
|
-
const currentState = rootStore.getState();
|
|
1901
|
-
if (!currentState.isLegacy && currentState.internal.actualRenderer) {
|
|
1902
|
-
const stack = new Error().stack || "";
|
|
1903
|
-
if (!isInternalRendererAccess(stack)) {
|
|
1904
|
-
const cleanedStack = stack.split("\n").slice(2).join("\n") || "Stack trace unavailable";
|
|
1905
|
-
notifyDepreciated({
|
|
1906
|
-
heading: "Accessing state.gl in WebGPU mode",
|
|
1907
|
-
body: "Please use state.renderer instead. state.gl is deprecated and will be removed in future versions.\n\nFor backwards compatibility, state.gl currently maps to state.renderer, but this may cause issues with libraries expecting WebGLRenderer.\n\nAccessed from:\n" + cleanedStack
|
|
1908
|
-
});
|
|
1909
|
-
}
|
|
1910
|
-
}
|
|
1911
|
-
return currentState.internal.actualRenderer;
|
|
1912
|
-
},
|
|
1913
|
-
set(value) {
|
|
1914
|
-
rootStore.getState().internal.actualRenderer = value;
|
|
1915
|
-
},
|
|
1916
|
-
enumerable: true,
|
|
1917
|
-
configurable: true
|
|
1918
|
-
});
|
|
1919
|
-
Object.defineProperty(state, "renderer", {
|
|
1920
|
-
get() {
|
|
1921
|
-
return rootStore.getState().internal.actualRenderer;
|
|
1922
|
-
},
|
|
1923
|
-
set(value) {
|
|
1924
|
-
rootStore.getState().internal.actualRenderer = value;
|
|
1925
|
-
},
|
|
1926
|
-
enumerable: true,
|
|
1927
|
-
configurable: true
|
|
1928
|
-
});
|
|
1929
|
-
let oldScene = state.scene;
|
|
1930
|
-
rootStore.subscribe(() => {
|
|
1931
|
-
const currentState = rootStore.getState();
|
|
1932
|
-
const { scene, rootScene, set } = currentState;
|
|
1933
|
-
if (scene !== oldScene) {
|
|
1934
|
-
oldScene = scene;
|
|
1935
|
-
if (scene?.isScene && scene !== rootScene) {
|
|
1936
|
-
set({ rootScene: scene });
|
|
1937
|
-
}
|
|
1938
|
-
}
|
|
1939
|
-
});
|
|
1940
|
-
let oldSize = state.size;
|
|
1941
|
-
let oldDpr = state.viewport.dpr;
|
|
1942
|
-
let oldCamera = state.camera;
|
|
1943
|
-
rootStore.subscribe(() => {
|
|
1944
|
-
const { camera, size, viewport, set, internal } = rootStore.getState();
|
|
1945
|
-
const actualRenderer = internal.actualRenderer;
|
|
1946
|
-
const canvasTarget = internal.canvasTarget;
|
|
1947
|
-
if (size.width !== oldSize.width || size.height !== oldSize.height || viewport.dpr !== oldDpr) {
|
|
1948
|
-
oldSize = size;
|
|
1949
|
-
oldDpr = viewport.dpr;
|
|
1950
|
-
updateCamera(camera, size);
|
|
1951
|
-
if (internal.isSecondary && canvasTarget) {
|
|
1952
|
-
if (viewport.dpr > 0) canvasTarget.setPixelRatio(viewport.dpr);
|
|
1953
|
-
canvasTarget.setSize(size.width, size.height, false);
|
|
1954
|
-
} else {
|
|
1955
|
-
if (viewport.dpr > 0) actualRenderer.setPixelRatio(viewport.dpr);
|
|
1956
|
-
actualRenderer.setSize(size.width, size.height, false);
|
|
1957
|
-
if (canvasTarget) {
|
|
1958
|
-
if (viewport.dpr > 0) canvasTarget.setPixelRatio(viewport.dpr);
|
|
1959
|
-
canvasTarget.setSize(size.width, size.height, false);
|
|
1960
|
-
}
|
|
1961
|
-
}
|
|
1962
|
-
}
|
|
1963
|
-
if (camera !== oldCamera) {
|
|
1964
|
-
oldCamera = camera;
|
|
1965
|
-
const { rootScene } = rootStore.getState();
|
|
1966
|
-
if (camera && rootScene && !camera.parent) {
|
|
1967
|
-
rootScene.add(camera);
|
|
1968
|
-
}
|
|
1969
|
-
set((state2) => ({ viewport: { ...state2.viewport, ...state2.viewport.getCurrentViewport(camera) } }));
|
|
1970
|
-
const currentState = rootStore.getState();
|
|
1971
|
-
if (currentState.autoUpdateFrustum && camera) {
|
|
1972
|
-
updateFrustum(camera, currentState.frustum);
|
|
1973
|
-
}
|
|
1974
|
-
}
|
|
1975
|
-
});
|
|
1976
|
-
rootStore.subscribe((state2) => invalidate(state2));
|
|
1977
|
-
return rootStore;
|
|
1978
|
-
};
|
|
1979
|
-
|
|
1980
|
-
const memoizedLoaders = /* @__PURE__ */ new WeakMap();
|
|
1981
|
-
const isConstructor$1 = (value) => typeof value === "function" && value?.prototype?.constructor === value;
|
|
1982
|
-
function getLoader(Proto) {
|
|
1983
|
-
if (isConstructor$1(Proto)) {
|
|
1984
|
-
let loader = memoizedLoaders.get(Proto);
|
|
1985
|
-
if (!loader) {
|
|
1986
|
-
loader = new Proto();
|
|
1987
|
-
memoizedLoaders.set(Proto, loader);
|
|
1988
|
-
}
|
|
1989
|
-
return loader;
|
|
1990
|
-
}
|
|
1991
|
-
return Proto;
|
|
1992
|
-
}
|
|
1993
|
-
function loadingFn(extensions, onProgress) {
|
|
1994
|
-
return function(Proto, input) {
|
|
1995
|
-
const loader = getLoader(Proto);
|
|
1996
|
-
if (extensions) extensions(loader);
|
|
1997
|
-
if ("loadAsync" in loader && typeof loader.loadAsync === "function") {
|
|
1998
|
-
return loader.loadAsync(input, onProgress).then((data) => {
|
|
1999
|
-
if (isObject3D(data?.scene)) Object.assign(data, buildGraph(data.scene));
|
|
2000
|
-
return data;
|
|
2001
|
-
});
|
|
2002
|
-
}
|
|
2003
|
-
return new Promise(
|
|
2004
|
-
(res, reject) => loader.load(
|
|
2005
|
-
input,
|
|
2006
|
-
(data) => {
|
|
2007
|
-
if (isObject3D(data?.scene)) Object.assign(data, buildGraph(data.scene));
|
|
2008
|
-
res(data);
|
|
2009
|
-
},
|
|
2010
|
-
onProgress,
|
|
2011
|
-
(error) => reject(new Error(`Could not load ${input}: ${error?.message}`))
|
|
2012
|
-
)
|
|
2013
|
-
);
|
|
2014
|
-
};
|
|
2015
|
-
}
|
|
2016
|
-
function useLoader(loader, input, extensions, onProgress, cacheKey) {
|
|
2017
|
-
const inputs = Array.isArray(input) ? input : [input];
|
|
2018
|
-
const cacheKeys = Array.isArray(cacheKey ?? input) ? cacheKey ?? input : [cacheKey ?? input];
|
|
2019
|
-
const fn = loadingFn(extensions, onProgress);
|
|
2020
|
-
const results = cacheKeys.map(
|
|
2021
|
-
(key, index) => suspend(() => fn(loader, inputs[index]), [loader, key], { equal: is.equ })
|
|
2022
|
-
);
|
|
2023
|
-
return Array.isArray(input) ? results : results[0];
|
|
2024
|
-
}
|
|
2025
|
-
useLoader.preload = function(loader, input, extensions, onProgress, cacheKey) {
|
|
2026
|
-
const inputs = Array.isArray(input) ? input : [input];
|
|
2027
|
-
const cacheKeys = Array.isArray(cacheKey ?? input) ? cacheKey ?? input : [cacheKey ?? input];
|
|
2028
|
-
cacheKeys.forEach(
|
|
2029
|
-
(key, index) => preload(() => loadingFn(extensions, onProgress)(loader, inputs[index]), [loader, key])
|
|
2030
|
-
);
|
|
2031
|
-
};
|
|
2032
|
-
useLoader.clear = function(loader, input, cacheKey) {
|
|
2033
|
-
const cacheKeys = Array.isArray(cacheKey ?? input) ? cacheKey ?? input : [cacheKey ?? input];
|
|
2034
|
-
cacheKeys.forEach((key) => clear([loader, key]));
|
|
2035
|
-
};
|
|
2036
|
-
useLoader.loader = getLoader;
|
|
2037
|
-
|
|
2038
|
-
function useFrame(callback, priorityOrOptions) {
|
|
2039
|
-
const store = React.useContext(context);
|
|
2040
|
-
const isInsideCanvas = store !== null;
|
|
2041
|
-
const scheduler = getScheduler();
|
|
2042
|
-
const optionsKey = typeof priorityOrOptions === "number" ? `p:${priorityOrOptions}` : priorityOrOptions ? JSON.stringify({
|
|
2043
|
-
id: priorityOrOptions.id,
|
|
2044
|
-
phase: priorityOrOptions.phase,
|
|
2045
|
-
priority: priorityOrOptions.priority,
|
|
2046
|
-
fps: priorityOrOptions.fps,
|
|
2047
|
-
drop: priorityOrOptions.drop,
|
|
2048
|
-
enabled: priorityOrOptions.enabled,
|
|
2049
|
-
before: priorityOrOptions.before,
|
|
2050
|
-
after: priorityOrOptions.after
|
|
2051
|
-
}) : "";
|
|
2052
|
-
const options = React.useMemo(() => {
|
|
2053
|
-
return typeof priorityOrOptions === "number" ? { priority: priorityOrOptions } : priorityOrOptions ?? {};
|
|
2054
|
-
}, [optionsKey]);
|
|
2055
|
-
const reactId = React.useId();
|
|
2056
|
-
const id = options.id ?? reactId;
|
|
2057
|
-
const callbackRef = useMutableCallback(callback);
|
|
2058
|
-
const isLegacyPriority = typeof priorityOrOptions === "number" && priorityOrOptions > 0;
|
|
2059
|
-
useIsomorphicLayoutEffect(() => {
|
|
2060
|
-
if (!callback) return;
|
|
2061
|
-
if (isInsideCanvas) {
|
|
2062
|
-
const state = store.getState();
|
|
2063
|
-
const rootId = state.internal.rootId;
|
|
2064
|
-
if (isLegacyPriority) {
|
|
2065
|
-
state.internal.priority++;
|
|
2066
|
-
let parentRoot = state.previousRoot;
|
|
2067
|
-
while (parentRoot) {
|
|
2068
|
-
const parentState = parentRoot.getState();
|
|
2069
|
-
if (parentState?.internal) parentState.internal.priority++;
|
|
2070
|
-
parentRoot = parentState?.previousRoot;
|
|
2071
|
-
}
|
|
2072
|
-
notifyDepreciated({
|
|
2073
|
-
heading: "useFrame with numeric priority is deprecated",
|
|
2074
|
-
body: 'Using useFrame(callback, number) to control render order is deprecated.\n\nFor custom rendering, use: useFrame(callback, { phase: "render" })\nFor execution order within update phase, use: useFrame(callback, { priority: number })',
|
|
2075
|
-
link: "https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe"
|
|
2076
|
-
});
|
|
2077
|
-
}
|
|
2078
|
-
const wrappedCallback = (frameState, delta) => {
|
|
2079
|
-
const localState = store.getState();
|
|
2080
|
-
const mergedState = {
|
|
2081
|
-
...localState,
|
|
2082
|
-
time: frameState.time,
|
|
2083
|
-
delta: frameState.delta,
|
|
2084
|
-
elapsed: frameState.elapsed,
|
|
2085
|
-
frame: frameState.frame
|
|
2086
|
-
};
|
|
2087
|
-
callbackRef.current?.(mergedState, delta);
|
|
2088
|
-
};
|
|
2089
|
-
const unregister = scheduler.register(wrappedCallback, {
|
|
2090
|
-
id,
|
|
2091
|
-
rootId,
|
|
2092
|
-
...options
|
|
2093
|
-
});
|
|
2094
|
-
return () => {
|
|
2095
|
-
unregister();
|
|
2096
|
-
if (isLegacyPriority) {
|
|
2097
|
-
const currentState = store.getState();
|
|
2098
|
-
if (currentState.internal) {
|
|
2099
|
-
currentState.internal.priority--;
|
|
2100
|
-
let parentRoot = currentState.previousRoot;
|
|
2101
|
-
while (parentRoot) {
|
|
2102
|
-
const parentState = parentRoot.getState();
|
|
2103
|
-
if (parentState?.internal) parentState.internal.priority--;
|
|
2104
|
-
parentRoot = parentState?.previousRoot;
|
|
2105
|
-
}
|
|
2106
|
-
}
|
|
2107
|
-
}
|
|
2108
|
-
};
|
|
2109
|
-
} else {
|
|
2110
|
-
return scheduler.register(
|
|
2111
|
-
(state, delta) => {
|
|
2112
|
-
const frameState = state;
|
|
2113
|
-
if (!frameState.renderer) return;
|
|
2114
|
-
callbackRef.current?.(frameState, delta);
|
|
2115
|
-
},
|
|
2116
|
-
{ id, ...options }
|
|
2117
|
-
);
|
|
2118
|
-
}
|
|
2119
|
-
}, [store, scheduler, id, optionsKey, isLegacyPriority, isInsideCanvas]);
|
|
2120
|
-
const isPaused = React.useSyncExternalStore(
|
|
2121
|
-
// Subscribe function
|
|
2122
|
-
React.useCallback(
|
|
2123
|
-
(onStoreChange) => {
|
|
2124
|
-
return getScheduler().subscribeJobState(id, onStoreChange);
|
|
2125
|
-
},
|
|
2126
|
-
[id]
|
|
2127
|
-
),
|
|
2128
|
-
// getSnapshot function
|
|
2129
|
-
React.useCallback(() => getScheduler().isJobPaused(id), [id]),
|
|
2130
|
-
// getServerSnapshot function (SSR)
|
|
2131
|
-
React.useCallback(() => false, [])
|
|
2132
|
-
);
|
|
2133
|
-
const controls = React.useMemo(() => {
|
|
2134
|
-
const scheduler2 = getScheduler();
|
|
2135
|
-
return {
|
|
2136
|
-
/** The job's unique ID */
|
|
2137
|
-
id,
|
|
2138
|
-
/**
|
|
2139
|
-
* Access to the global scheduler for frame loop control.
|
|
2140
|
-
* Use for controlling the entire frame loop, adding phases, etc.
|
|
2141
|
-
*/
|
|
2142
|
-
scheduler: scheduler2,
|
|
2143
|
-
/**
|
|
2144
|
-
* Manually step this job only.
|
|
2145
|
-
* Bypasses FPS limiting - always runs.
|
|
2146
|
-
* @param timestamp Optional timestamp (defaults to performance.now())
|
|
2147
|
-
*/
|
|
2148
|
-
step: (timestamp) => {
|
|
2149
|
-
getScheduler().stepJob(id, timestamp);
|
|
2150
|
-
},
|
|
2151
|
-
/**
|
|
2152
|
-
* Manually step ALL jobs in the scheduler.
|
|
2153
|
-
* Useful for frameloop='never' mode.
|
|
2154
|
-
* @param timestamp Optional timestamp (defaults to performance.now())
|
|
2155
|
-
*/
|
|
2156
|
-
stepAll: (timestamp) => {
|
|
2157
|
-
getScheduler().step(timestamp);
|
|
2158
|
-
},
|
|
2159
|
-
/**
|
|
2160
|
-
* Pause this job (set enabled=false).
|
|
2161
|
-
* Job remains registered but won't run.
|
|
2162
|
-
*/
|
|
2163
|
-
pause: () => {
|
|
2164
|
-
getScheduler().pauseJob(id);
|
|
2165
|
-
},
|
|
2166
|
-
/**
|
|
2167
|
-
* Resume this job (set enabled=true).
|
|
2168
|
-
*/
|
|
2169
|
-
resume: () => {
|
|
2170
|
-
getScheduler().resumeJob(id);
|
|
2171
|
-
},
|
|
2172
|
-
/**
|
|
2173
|
-
* Reactive paused state - automatically updates when pause/resume is called.
|
|
2174
|
-
* No need for forceUpdate() in your components.
|
|
2175
|
-
*/
|
|
2176
|
-
isPaused
|
|
2177
|
-
};
|
|
2178
|
-
}, [id, isPaused]);
|
|
2179
|
-
return controls;
|
|
2180
|
-
}
|
|
2181
|
-
|
|
2182
|
-
const IsObject = (url) => url === Object(url) && !Array.isArray(url) && typeof url !== "function";
|
|
2183
|
-
function getUrls(input) {
|
|
2184
|
-
if (typeof input === "string") return [input];
|
|
2185
|
-
if (Array.isArray(input)) return input;
|
|
2186
|
-
return Object.values(input);
|
|
2187
|
-
}
|
|
2188
|
-
function allUrlsCached(urls, textureCache) {
|
|
2189
|
-
return urls.every((url) => textureCache.has(url));
|
|
2190
|
-
}
|
|
2191
|
-
function buildFromCache(input, textureCache) {
|
|
2192
|
-
if (typeof input === "string") {
|
|
2193
|
-
return textureCache.get(input);
|
|
2194
|
-
} else if (Array.isArray(input)) {
|
|
2195
|
-
return input.map((url) => textureCache.get(url));
|
|
2196
|
-
} else {
|
|
2197
|
-
const result = {};
|
|
2198
|
-
const objInput = input;
|
|
2199
|
-
for (const key in objInput) {
|
|
2200
|
-
result[key] = textureCache.get(objInput[key]);
|
|
2201
|
-
}
|
|
2202
|
-
return result;
|
|
1511
|
+
const CUBEMAP_ROOT = "https://raw.githack.com/pmndrs/drei-assets/456060a26bbeb8fdf79326f224b6d99b8bcce736/hdri/";
|
|
1512
|
+
const isArray = (arr) => Array.isArray(arr);
|
|
1513
|
+
const defaultFiles = ["/px.png", "/nx.png", "/py.png", "/ny.png", "/pz.png", "/nz.png"];
|
|
1514
|
+
function useEnvironment({
|
|
1515
|
+
files = defaultFiles,
|
|
1516
|
+
path = "",
|
|
1517
|
+
preset = void 0,
|
|
1518
|
+
colorSpace = void 0,
|
|
1519
|
+
extensions
|
|
1520
|
+
} = {}) {
|
|
1521
|
+
if (preset) {
|
|
1522
|
+
validatePreset(preset);
|
|
1523
|
+
files = presetsObj[preset];
|
|
1524
|
+
path = CUBEMAP_ROOT;
|
|
2203
1525
|
}
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
const
|
|
2207
|
-
|
|
2208
|
-
const
|
|
2209
|
-
const { onLoad, cache = true } = options;
|
|
2210
|
-
const onLoadRef = useRef(onLoad);
|
|
2211
|
-
onLoadRef.current = onLoad;
|
|
2212
|
-
const onLoadCalledForRef = useRef(null);
|
|
2213
|
-
const urls = useMemo(() => getUrls(input), [input]);
|
|
2214
|
-
const cachedResult = useMemo(() => {
|
|
2215
|
-
if (!cache) return null;
|
|
2216
|
-
const textures = store.getState().textures;
|
|
2217
|
-
if (!allUrlsCached(urls, textures)) return null;
|
|
2218
|
-
return buildFromCache(input, textures);
|
|
2219
|
-
}, [cache, urls, input, store]);
|
|
2220
|
-
const loadedTextures = useLoader(
|
|
2221
|
-
TextureLoader,
|
|
2222
|
-
IsObject(input) ? Object.values(input) : input
|
|
2223
|
-
);
|
|
2224
|
-
const inputKey = urls.join("\0");
|
|
1526
|
+
const multiFile = isArray(files);
|
|
1527
|
+
const { extension, isCubemap } = getExtension(files);
|
|
1528
|
+
const loader = getLoader(extension);
|
|
1529
|
+
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1530
|
+
const renderer = useThree((state) => state.renderer);
|
|
2225
1531
|
useLayoutEffect(() => {
|
|
2226
|
-
if (
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
onLoadRef.current?.(loadedTextures);
|
|
2230
|
-
}, [cachedResult, loadedTextures, inputKey]);
|
|
2231
|
-
useEffect(() => {
|
|
2232
|
-
if (cachedResult) return;
|
|
2233
|
-
if ("initTexture" in renderer) {
|
|
2234
|
-
let textureArray = [];
|
|
2235
|
-
if (Array.isArray(loadedTextures)) {
|
|
2236
|
-
textureArray = loadedTextures;
|
|
2237
|
-
} else if (loadedTextures instanceof Texture$1) {
|
|
2238
|
-
textureArray = [loadedTextures];
|
|
2239
|
-
} else if (IsObject(loadedTextures)) {
|
|
2240
|
-
textureArray = Object.values(loadedTextures);
|
|
2241
|
-
}
|
|
2242
|
-
textureArray.forEach((texture) => {
|
|
2243
|
-
if (texture instanceof Texture$1) {
|
|
2244
|
-
renderer.initTexture(texture);
|
|
2245
|
-
}
|
|
2246
|
-
});
|
|
2247
|
-
}
|
|
2248
|
-
}, [renderer, loadedTextures, cachedResult]);
|
|
2249
|
-
const mappedTextures = useMemo(() => {
|
|
2250
|
-
if (cachedResult) return cachedResult;
|
|
2251
|
-
if (IsObject(input)) {
|
|
2252
|
-
const keyed = {};
|
|
2253
|
-
const textureArray = loadedTextures;
|
|
2254
|
-
let i = 0;
|
|
2255
|
-
for (const key in input) keyed[key] = textureArray[i++];
|
|
2256
|
-
return keyed;
|
|
2257
|
-
} else {
|
|
2258
|
-
return loadedTextures;
|
|
1532
|
+
if (extension !== "webp" && extension !== "jpg" && extension !== "jpeg") return;
|
|
1533
|
+
function clearGainmapTexture() {
|
|
1534
|
+
useLoader.clear(loader, multiFile ? [files] : files);
|
|
2259
1535
|
}
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
input.forEach((url, i) => urlTextureMap.push([url, textureArray[i]]));
|
|
2269
|
-
} else if (IsObject(input)) {
|
|
2270
|
-
const textureRecord = mappedTextures;
|
|
2271
|
-
for (const key in input) {
|
|
2272
|
-
const url = input[key];
|
|
2273
|
-
urlTextureMap.push([url, textureRecord[key]]);
|
|
1536
|
+
renderer.domElement.addEventListener("webglcontextlost", clearGainmapTexture, { once: true });
|
|
1537
|
+
}, [extension, files, loader, multiFile, renderer.domElement]);
|
|
1538
|
+
const loaderResult = useLoader(
|
|
1539
|
+
loader,
|
|
1540
|
+
multiFile ? [files] : files,
|
|
1541
|
+
(loader2) => {
|
|
1542
|
+
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
1543
|
+
loader2.setRenderer?.(renderer);
|
|
2274
1544
|
}
|
|
1545
|
+
loader2.setPath?.(path);
|
|
1546
|
+
if (extensions) extensions(loader2);
|
|
2275
1547
|
}
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
}
|
|
2288
|
-
refs.set(url, (refs.get(url) ?? 0) + 1);
|
|
2289
|
-
}
|
|
2290
|
-
return added ? { textures, _textureRefs: refs } : { _textureRefs: refs };
|
|
2291
|
-
});
|
|
2292
|
-
return () => store.setState((state) => {
|
|
2293
|
-
const refs = new Map(state._textureRefs);
|
|
2294
|
-
for (const [url] of urlTextureMap) {
|
|
2295
|
-
const next = (refs.get(url) ?? 0) - 1;
|
|
2296
|
-
if (next <= 0) refs.delete(url);
|
|
2297
|
-
else refs.set(url, next);
|
|
2298
|
-
}
|
|
2299
|
-
return { _textureRefs: refs };
|
|
2300
|
-
});
|
|
2301
|
-
}, [cache, input, mappedTextures, store]);
|
|
2302
|
-
return mappedTextures;
|
|
2303
|
-
}
|
|
2304
|
-
useTexture.preload = (url) => useLoader.preload(TextureLoader, url);
|
|
2305
|
-
useTexture.clear = (input) => useLoader.clear(TextureLoader, input);
|
|
2306
|
-
const Texture = ({
|
|
2307
|
-
children,
|
|
2308
|
-
input,
|
|
2309
|
-
onLoad,
|
|
2310
|
-
cache
|
|
2311
|
-
}) => {
|
|
2312
|
-
const options = typeof onLoad === "function" ? { onLoad, cache } : { ...onLoad, cache };
|
|
2313
|
-
const ret = useTexture(input, options);
|
|
2314
|
-
return /* @__PURE__ */ jsx(Fragment, { children: children?.(ret) });
|
|
2315
|
-
};
|
|
2316
|
-
|
|
2317
|
-
function useTextures(selector) {
|
|
2318
|
-
const store = useStore();
|
|
2319
|
-
const registry = useMemo(() => {
|
|
2320
|
-
const getState = store.getState;
|
|
2321
|
-
const setState = store.setState;
|
|
2322
|
-
const getOne = (key) => getState().textures.get(key);
|
|
2323
|
-
return {
|
|
2324
|
-
get all() {
|
|
2325
|
-
return getState().textures;
|
|
2326
|
-
},
|
|
2327
|
-
get(input) {
|
|
2328
|
-
if (typeof input === "string") return getOne(input);
|
|
2329
|
-
if (Array.isArray(input)) return input.map(getOne);
|
|
2330
|
-
const out = {};
|
|
2331
|
-
for (const name in input) out[name] = getOne(input[name]);
|
|
2332
|
-
return out;
|
|
2333
|
-
},
|
|
2334
|
-
has: (key) => getState().textures.has(key),
|
|
2335
|
-
add(keyOrRecord, texture) {
|
|
2336
|
-
setState((state) => {
|
|
2337
|
-
const textures = new Map(state.textures);
|
|
2338
|
-
if (typeof keyOrRecord === "string") {
|
|
2339
|
-
textures.set(keyOrRecord, texture);
|
|
2340
|
-
} else {
|
|
2341
|
-
for (const key in keyOrRecord) textures.set(key, keyOrRecord[key]);
|
|
2342
|
-
}
|
|
2343
|
-
return { textures };
|
|
2344
|
-
});
|
|
2345
|
-
},
|
|
2346
|
-
dispose(key, options) {
|
|
2347
|
-
const state = getState();
|
|
2348
|
-
const refs = state._textureRefs.get(key) ?? 0;
|
|
2349
|
-
if (refs > 0 && !options?.force) {
|
|
2350
|
-
console.warn(
|
|
2351
|
-
`[useTextures] "${key}" still has ${refs} active reference(s); skipping dispose. Pass { force: true } to override.`
|
|
2352
|
-
);
|
|
2353
|
-
return false;
|
|
2354
|
-
}
|
|
2355
|
-
state.textures.get(key)?.dispose();
|
|
2356
|
-
setState((s) => {
|
|
2357
|
-
const textures = new Map(s.textures);
|
|
2358
|
-
textures.delete(key);
|
|
2359
|
-
const nextRefs = new Map(s._textureRefs);
|
|
2360
|
-
nextRefs.delete(key);
|
|
2361
|
-
return { textures, _textureRefs: nextRefs };
|
|
2362
|
-
});
|
|
2363
|
-
return true;
|
|
2364
|
-
},
|
|
2365
|
-
disposeAll() {
|
|
2366
|
-
for (const texture of getState().textures.values()) texture.dispose();
|
|
2367
|
-
setState({ textures: /* @__PURE__ */ new Map(), _textureRefs: /* @__PURE__ */ new Map() });
|
|
2368
|
-
}
|
|
2369
|
-
};
|
|
2370
|
-
}, [store]);
|
|
2371
|
-
const subscribe = selector ? () => selector(registry) : (state) => state.textures;
|
|
2372
|
-
const selected = useThree(subscribe);
|
|
2373
|
-
return selector ? selected : registry;
|
|
1548
|
+
);
|
|
1549
|
+
let texture = multiFile ? (
|
|
1550
|
+
// @ts-ignore
|
|
1551
|
+
loaderResult[0]
|
|
1552
|
+
) : loaderResult;
|
|
1553
|
+
if (extension === "jpg" || extension === "jpeg" || extension === "webp") {
|
|
1554
|
+
texture = texture.renderTarget?.texture;
|
|
1555
|
+
}
|
|
1556
|
+
texture.mapping = isCubemap ? CubeReflectionMapping : EquirectangularReflectionMapping;
|
|
1557
|
+
texture.colorSpace = colorSpace ?? (isCubemap ? "srgb" : "srgb-linear");
|
|
1558
|
+
return texture;
|
|
2374
1559
|
}
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
} else if (typeof heightOrOptions === "number") {
|
|
2390
|
-
height = heightOrOptions;
|
|
2391
|
-
opts = options;
|
|
2392
|
-
} else {
|
|
2393
|
-
height = widthOrOptions;
|
|
2394
|
-
}
|
|
1560
|
+
const preloadDefaultOptions = {
|
|
1561
|
+
files: defaultFiles,
|
|
1562
|
+
path: "",
|
|
1563
|
+
preset: void 0,
|
|
1564
|
+
extensions: void 0
|
|
1565
|
+
};
|
|
1566
|
+
useEnvironment.preload = (preloadOptions) => {
|
|
1567
|
+
const options = { ...preloadDefaultOptions, ...preloadOptions };
|
|
1568
|
+
let { files, path = "" } = options;
|
|
1569
|
+
const { preset, extensions } = options;
|
|
1570
|
+
if (preset) {
|
|
1571
|
+
validatePreset(preset);
|
|
1572
|
+
files = presetsObj[preset];
|
|
1573
|
+
path = CUBEMAP_ROOT;
|
|
2395
1574
|
}
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
1575
|
+
const { extension } = getExtension(files);
|
|
1576
|
+
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
1577
|
+
throw new Error("useEnvironment: Preloading gainmaps is not supported");
|
|
1578
|
+
}
|
|
1579
|
+
const loader = getLoader(extension);
|
|
1580
|
+
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1581
|
+
useLoader.preload(loader, isArray(files) ? [files] : files, (loader2) => {
|
|
1582
|
+
loader2.setPath?.(path);
|
|
1583
|
+
if (extensions) extensions(loader2);
|
|
1584
|
+
});
|
|
1585
|
+
};
|
|
1586
|
+
const clearDefaultOptins = {
|
|
1587
|
+
files: defaultFiles,
|
|
1588
|
+
preset: void 0
|
|
1589
|
+
};
|
|
1590
|
+
useEnvironment.clear = (clearOptions) => {
|
|
1591
|
+
const options = { ...clearDefaultOptins, ...clearOptions };
|
|
1592
|
+
let { files } = options;
|
|
1593
|
+
const { preset } = options;
|
|
1594
|
+
if (preset) {
|
|
1595
|
+
validatePreset(preset);
|
|
1596
|
+
files = presetsObj[preset];
|
|
1597
|
+
}
|
|
1598
|
+
const { extension } = getExtension(files);
|
|
1599
|
+
const loader = getLoader(extension);
|
|
1600
|
+
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1601
|
+
useLoader.clear(loader, isArray(files) ? [files] : files);
|
|
1602
|
+
};
|
|
1603
|
+
function validatePreset(preset) {
|
|
1604
|
+
if (!(preset in presetsObj)) throw new Error("Preset must be one of: " + Object.keys(presetsObj).join(", "));
|
|
1605
|
+
}
|
|
1606
|
+
function getExtension(files) {
|
|
1607
|
+
const isCubemap = isArray(files) && files.length === 6;
|
|
1608
|
+
const isGainmap = isArray(files) && files.length === 3 && files.some((file) => file.endsWith("json"));
|
|
1609
|
+
const firstEntry = isArray(files) ? files[0] : files;
|
|
1610
|
+
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();
|
|
1611
|
+
return { extension, isCubemap, isGainmap };
|
|
1612
|
+
}
|
|
1613
|
+
function getLoader(extension) {
|
|
1614
|
+
const loader = extension === "cube" ? CubeTextureLoader : extension === "hdr" ? HDRLoader : extension === "exr" ? EXRLoader : extension === "jpg" || extension === "jpeg" ? UltraHDRLoader : extension === "webp" ? GainMapLoader : null;
|
|
1615
|
+
return loader;
|
|
2403
1616
|
}
|
|
2404
1617
|
|
|
2405
1618
|
function useStore() {
|
|
@@ -2419,6 +1632,8 @@ function useGraph(object) {
|
|
|
2419
1632
|
return useMemo(() => buildGraph(object), [object]);
|
|
2420
1633
|
}
|
|
2421
1634
|
|
|
1635
|
+
const t = 1, o = 8, r = 32, e = 2, i$1 = 268435456;
|
|
1636
|
+
|
|
2422
1637
|
let effectId = 0;
|
|
2423
1638
|
function addEffect(callback) {
|
|
2424
1639
|
notifyDepreciated({
|
|
@@ -13326,390 +12541,968 @@ Check the top-level render call using <` + i + ">.");
|
|
|
13326
12541
|
var i = x.H;
|
|
13327
12542
|
x.H = $o;
|
|
13328
12543
|
try {
|
|
13329
|
-
return Br(e, n, o);
|
|
13330
|
-
} finally {
|
|
13331
|
-
x.H = i;
|
|
12544
|
+
return Br(e, n, o);
|
|
12545
|
+
} finally {
|
|
12546
|
+
x.H = i;
|
|
12547
|
+
}
|
|
12548
|
+
}, useRef: function() {
|
|
12549
|
+
return z = "useRef", D(), N(), xe().memoizedState;
|
|
12550
|
+
}, useState: function() {
|
|
12551
|
+
z = "useState", D(), N();
|
|
12552
|
+
var e = x.H;
|
|
12553
|
+
x.H = $o;
|
|
12554
|
+
try {
|
|
12555
|
+
return Br(gr);
|
|
12556
|
+
} finally {
|
|
12557
|
+
x.H = e;
|
|
12558
|
+
}
|
|
12559
|
+
}, useDebugValue: function() {
|
|
12560
|
+
z = "useDebugValue", D(), N();
|
|
12561
|
+
}, useDeferredValue: function(e, n) {
|
|
12562
|
+
return z = "useDeferredValue", D(), N(), nc(e, n);
|
|
12563
|
+
}, useTransition: function() {
|
|
12564
|
+
return z = "useTransition", D(), N(), Qp();
|
|
12565
|
+
}, useSyncExternalStore: function(e, n, o) {
|
|
12566
|
+
return z = "useSyncExternalStore", D(), N(), ta(e, n, o);
|
|
12567
|
+
}, useId: function() {
|
|
12568
|
+
return z = "useId", D(), N(), xe().memoizedState;
|
|
12569
|
+
}, useFormState: function(e) {
|
|
12570
|
+
return z = "useFormState", D(), N(), hs(e);
|
|
12571
|
+
}, useActionState: function(e) {
|
|
12572
|
+
return z = "useActionState", D(), N(), hs(e);
|
|
12573
|
+
}, useOptimistic: function(e, n) {
|
|
12574
|
+
return z = "useOptimistic", D(), N(), rf(e, n);
|
|
12575
|
+
}, useMemoCache: function(e) {
|
|
12576
|
+
return D(), Oa(e);
|
|
12577
|
+
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
12578
|
+
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
12579
|
+
}, useEffectEvent: function(e) {
|
|
12580
|
+
return z = "useEffectEvent", D(), N(), oa(e);
|
|
12581
|
+
} }, dm = { readContext: function(e) {
|
|
12582
|
+
return Ce(), Ee(e);
|
|
12583
|
+
}, use: function(e) {
|
|
12584
|
+
return D(), we(e);
|
|
12585
|
+
}, useCallback: function(e, n) {
|
|
12586
|
+
return z = "useCallback", D(), N(), Ma(e, n);
|
|
12587
|
+
}, useContext: function(e) {
|
|
12588
|
+
return z = "useContext", D(), N(), Ee(e);
|
|
12589
|
+
}, useEffect: function(e, n) {
|
|
12590
|
+
z = "useEffect", D(), N(), Qn(2048, Ut, e, n);
|
|
12591
|
+
}, useImperativeHandle: function(e, n, o) {
|
|
12592
|
+
return z = "useImperativeHandle", D(), N(), aa(e, n, o);
|
|
12593
|
+
}, useInsertionEffect: function(e, n) {
|
|
12594
|
+
return z = "useInsertionEffect", D(), N(), Qn(4, Wt, e, n);
|
|
12595
|
+
}, useLayoutEffect: function(e, n) {
|
|
12596
|
+
return z = "useLayoutEffect", D(), N(), Qn(4, Rr, e, n);
|
|
12597
|
+
}, useMemo: function(e, n) {
|
|
12598
|
+
z = "useMemo", D(), N();
|
|
12599
|
+
var o = x.H;
|
|
12600
|
+
x.H = $o;
|
|
12601
|
+
try {
|
|
12602
|
+
return Vi(e, n);
|
|
12603
|
+
} finally {
|
|
12604
|
+
x.H = o;
|
|
12605
|
+
}
|
|
12606
|
+
}, useReducer: function(e, n, o) {
|
|
12607
|
+
z = "useReducer", D(), N();
|
|
12608
|
+
var i = x.H;
|
|
12609
|
+
x.H = $o;
|
|
12610
|
+
try {
|
|
12611
|
+
return Qi(e, n, o);
|
|
12612
|
+
} finally {
|
|
12613
|
+
x.H = i;
|
|
12614
|
+
}
|
|
12615
|
+
}, useRef: function() {
|
|
12616
|
+
return z = "useRef", D(), N(), xe().memoizedState;
|
|
12617
|
+
}, useState: function() {
|
|
12618
|
+
z = "useState", D(), N();
|
|
12619
|
+
var e = x.H;
|
|
12620
|
+
x.H = $o;
|
|
12621
|
+
try {
|
|
12622
|
+
return Qi(gr);
|
|
12623
|
+
} finally {
|
|
12624
|
+
x.H = e;
|
|
12625
|
+
}
|
|
12626
|
+
}, useDebugValue: function() {
|
|
12627
|
+
z = "useDebugValue", D(), N();
|
|
12628
|
+
}, useDeferredValue: function(e, n) {
|
|
12629
|
+
return z = "useDeferredValue", D(), N(), sf(e, n);
|
|
12630
|
+
}, useTransition: function() {
|
|
12631
|
+
return z = "useTransition", D(), N(), Ro();
|
|
12632
|
+
}, useSyncExternalStore: function(e, n, o) {
|
|
12633
|
+
return z = "useSyncExternalStore", D(), N(), ta(e, n, o);
|
|
12634
|
+
}, useId: function() {
|
|
12635
|
+
return z = "useId", D(), N(), xe().memoizedState;
|
|
12636
|
+
}, useFormState: function(e) {
|
|
12637
|
+
return z = "useFormState", D(), N(), $t(e);
|
|
12638
|
+
}, useActionState: function(e) {
|
|
12639
|
+
return z = "useActionState", D(), N(), $t(e);
|
|
12640
|
+
}, useOptimistic: function(e, n) {
|
|
12641
|
+
return z = "useOptimistic", D(), N(), of(e, n);
|
|
12642
|
+
}, useMemoCache: function(e) {
|
|
12643
|
+
return D(), Oa(e);
|
|
12644
|
+
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
12645
|
+
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
12646
|
+
}, useEffectEvent: function(e) {
|
|
12647
|
+
return z = "useEffectEvent", D(), N(), oa(e);
|
|
12648
|
+
} };
|
|
12649
|
+
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();
|
|
12650
|
+
Object.freeze(Fy);
|
|
12651
|
+
var zg = { enqueueSetState: function(e, n, o) {
|
|
12652
|
+
e = e._reactInternals;
|
|
12653
|
+
var i = Nt(e), s = zo(i);
|
|
12654
|
+
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));
|
|
12655
|
+
}, enqueueReplaceState: function(e, n, o) {
|
|
12656
|
+
e = e._reactInternals;
|
|
12657
|
+
var i = Nt(e), s = zo(i);
|
|
12658
|
+
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));
|
|
12659
|
+
}, enqueueForceUpdate: function(e, n) {
|
|
12660
|
+
e = e._reactInternals;
|
|
12661
|
+
var o = Nt(e), i = zo(o);
|
|
12662
|
+
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));
|
|
12663
|
+
} }, 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;
|
|
12664
|
+
Yy = /* @__PURE__ */ new Set();
|
|
12665
|
+
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) {
|
|
12666
|
+
var n = Ee(un), o = n.data.get(e);
|
|
12667
|
+
return o === void 0 && (o = e(), n.data.set(e, o)), o;
|
|
12668
|
+
}, cacheSignal: function() {
|
|
12669
|
+
return Ee(un).controller.signal;
|
|
12670
|
+
}, getOwner: function() {
|
|
12671
|
+
return di;
|
|
12672
|
+
} }, pm = 0, hm = 1, mm = 2, gm = 3, ym = 4;
|
|
12673
|
+
if (typeof Symbol == "function" && Symbol.for) {
|
|
12674
|
+
var bp = Symbol.for;
|
|
12675
|
+
pm = bp("selector.component"), hm = bp("selector.has_pseudo_class"), mm = bp("selector.role"), gm = bp("selector.test_id"), ym = bp("selector.text");
|
|
12676
|
+
}
|
|
12677
|
+
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;
|
|
12678
|
+
try {
|
|
12679
|
+
var o0 = Object.preventExtensions({});
|
|
12680
|
+
} catch {
|
|
12681
|
+
pb = true;
|
|
12682
|
+
}
|
|
12683
|
+
var hb = false, mb = {}, gb = null, yb = null, bb = null, vb = null, Sb = null, kb = null, wb = null, Pb = null, xb = null, zb = null;
|
|
12684
|
+
return gb = function(e, n, o, i) {
|
|
12685
|
+
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));
|
|
12686
|
+
}, yb = function(e, n, o) {
|
|
12687
|
+
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));
|
|
12688
|
+
}, bb = function(e, n, o, i) {
|
|
12689
|
+
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));
|
|
12690
|
+
}, vb = function(e, n, o) {
|
|
12691
|
+
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);
|
|
12692
|
+
}, Sb = function(e, n) {
|
|
12693
|
+
e.pendingProps = du(e.memoizedProps, n, 0), e.alternate && (e.alternate.pendingProps = e.pendingProps), n = On(e, 2), n !== null && We(n, e, 2);
|
|
12694
|
+
}, kb = function(e, n, o) {
|
|
12695
|
+
e.pendingProps = F(e.memoizedProps, n, o), e.alternate && (e.alternate.pendingProps = e.pendingProps), n = On(e, 2), n !== null && We(n, e, 2);
|
|
12696
|
+
}, wb = function(e) {
|
|
12697
|
+
var n = On(e, 2);
|
|
12698
|
+
n !== null && We(n, e, 2);
|
|
12699
|
+
}, Pb = function(e) {
|
|
12700
|
+
var n = ut(), o = On(e, n);
|
|
12701
|
+
o !== null && We(o, e, n);
|
|
12702
|
+
}, xb = function(e) {
|
|
12703
|
+
pu = e;
|
|
12704
|
+
}, zb = function(e) {
|
|
12705
|
+
fu = e;
|
|
12706
|
+
}, le.attemptContinuousHydration = function(e) {
|
|
12707
|
+
if (e.tag === 13 || e.tag === 31) {
|
|
12708
|
+
var n = On(e, 67108864);
|
|
12709
|
+
n !== null && We(n, e, 67108864), rl(e, 67108864);
|
|
12710
|
+
}
|
|
12711
|
+
}, le.attemptHydrationAtCurrentPriority = function(e) {
|
|
12712
|
+
if (e.tag === 13 || e.tag === 31) {
|
|
12713
|
+
var n = Nt(e);
|
|
12714
|
+
n = Xo(n);
|
|
12715
|
+
var o = On(e, n);
|
|
12716
|
+
o !== null && We(o, e, n), rl(e, n);
|
|
12717
|
+
}
|
|
12718
|
+
}, le.attemptSynchronousHydration = function(e) {
|
|
12719
|
+
switch (e.tag) {
|
|
12720
|
+
case 3:
|
|
12721
|
+
if (e = e.stateNode, e.current.memoizedState.isDehydrated) {
|
|
12722
|
+
var n = _t(e.pendingLanes);
|
|
12723
|
+
if (n !== 0) {
|
|
12724
|
+
for (e.pendingLanes |= 2, e.entangledLanes |= 2; n; ) {
|
|
12725
|
+
var o = 1 << 31 - vn(n);
|
|
12726
|
+
e.entanglements[1] |= o, n &= ~o;
|
|
12727
|
+
}
|
|
12728
|
+
Kn(e), (ye & (Zn | uo)) === Jn && (Pp = me() + Fg, Wa(0));
|
|
12729
|
+
}
|
|
12730
|
+
}
|
|
12731
|
+
break;
|
|
12732
|
+
case 31:
|
|
12733
|
+
case 13:
|
|
12734
|
+
n = On(e, 2), n !== null && We(n, e, 2), Ls(), rl(e, 2);
|
|
12735
|
+
}
|
|
12736
|
+
}, le.batchedUpdates = function(e, n) {
|
|
12737
|
+
return e(n);
|
|
12738
|
+
}, le.createComponentSelector = function(e) {
|
|
12739
|
+
return { $$typeof: pm, value: e };
|
|
12740
|
+
}, le.createContainer = function(e, n, o, i, s, u, f, p, g, S) {
|
|
12741
|
+
return Ka(e, n, false, null, o, i, u, null, f, p, g, S);
|
|
12742
|
+
}, le.createHasPseudoClassSelector = function(e) {
|
|
12743
|
+
return { $$typeof: hm, value: e };
|
|
12744
|
+
}, le.createHydrationContainer = function(e, n, o, i, s, u, f, p, g, S, T, _, I, O) {
|
|
12745
|
+
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;
|
|
12746
|
+
}, le.createPortal = function(e, n, o) {
|
|
12747
|
+
var i = 3 < arguments.length && arguments[3] !== void 0 ? arguments[3] : null;
|
|
12748
|
+
try {
|
|
12749
|
+
vt(i);
|
|
12750
|
+
var s = false;
|
|
12751
|
+
} catch {
|
|
12752
|
+
s = true;
|
|
13332
12753
|
}
|
|
13333
|
-
|
|
13334
|
-
|
|
13335
|
-
|
|
13336
|
-
|
|
13337
|
-
|
|
13338
|
-
|
|
12754
|
+
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 };
|
|
12755
|
+
}, le.createRoleSelector = function(e) {
|
|
12756
|
+
return { $$typeof: mm, value: e };
|
|
12757
|
+
}, le.createTestNameSelector = function(e) {
|
|
12758
|
+
return { $$typeof: gm, value: e };
|
|
12759
|
+
}, le.createTextSelector = function(e) {
|
|
12760
|
+
return { $$typeof: ym, value: e };
|
|
12761
|
+
}, le.defaultOnCaughtError = function(e) {
|
|
12762
|
+
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") + ".");
|
|
12763
|
+
typeof e == "object" && e !== null && typeof e.environmentName == "string" ? ri("error", [`%o
|
|
12764
|
+
|
|
12765
|
+
%s
|
|
12766
|
+
|
|
12767
|
+
%s
|
|
12768
|
+
`, e, n, o], e.environmentName)() : console.error(`%o
|
|
12769
|
+
|
|
12770
|
+
%s
|
|
12771
|
+
|
|
12772
|
+
%s
|
|
12773
|
+
`, e, n, o);
|
|
12774
|
+
}, le.defaultOnRecoverableError = function(e) {
|
|
12775
|
+
qg(e);
|
|
12776
|
+
}, le.defaultOnUncaughtError = function(e) {
|
|
12777
|
+
qg(e), console.warn(`%s
|
|
12778
|
+
|
|
12779
|
+
%s
|
|
12780
|
+
`, 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.
|
|
12781
|
+
Visit https://react.dev/link/error-boundaries to learn more about error boundaries.`);
|
|
12782
|
+
}, le.deferredUpdates = function(e) {
|
|
12783
|
+
var n = x.T, o = wt();
|
|
13339
12784
|
try {
|
|
13340
|
-
return
|
|
12785
|
+
return an(32), x.T = null, e();
|
|
13341
12786
|
} finally {
|
|
13342
|
-
x.
|
|
12787
|
+
an(o), x.T = n;
|
|
13343
12788
|
}
|
|
13344
|
-
},
|
|
13345
|
-
|
|
13346
|
-
}, useDeferredValue: function(e, n) {
|
|
13347
|
-
return z = "useDeferredValue", D(), N(), nc(e, n);
|
|
13348
|
-
}, useTransition: function() {
|
|
13349
|
-
return z = "useTransition", D(), N(), Qp();
|
|
13350
|
-
}, useSyncExternalStore: function(e, n, o) {
|
|
13351
|
-
return z = "useSyncExternalStore", D(), N(), ta(e, n, o);
|
|
13352
|
-
}, useId: function() {
|
|
13353
|
-
return z = "useId", D(), N(), xe().memoizedState;
|
|
13354
|
-
}, useFormState: function(e) {
|
|
13355
|
-
return z = "useFormState", D(), N(), hs(e);
|
|
13356
|
-
}, useActionState: function(e) {
|
|
13357
|
-
return z = "useActionState", D(), N(), hs(e);
|
|
13358
|
-
}, useOptimistic: function(e, n) {
|
|
13359
|
-
return z = "useOptimistic", D(), N(), rf(e, n);
|
|
13360
|
-
}, useMemoCache: function(e) {
|
|
13361
|
-
return D(), Oa(e);
|
|
13362
|
-
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
13363
|
-
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
13364
|
-
}, useEffectEvent: function(e) {
|
|
13365
|
-
return z = "useEffectEvent", D(), N(), oa(e);
|
|
13366
|
-
} }, dm = { readContext: function(e) {
|
|
13367
|
-
return Ce(), Ee(e);
|
|
13368
|
-
}, use: function(e) {
|
|
13369
|
-
return D(), we(e);
|
|
13370
|
-
}, useCallback: function(e, n) {
|
|
13371
|
-
return z = "useCallback", D(), N(), Ma(e, n);
|
|
13372
|
-
}, useContext: function(e) {
|
|
13373
|
-
return z = "useContext", D(), N(), Ee(e);
|
|
13374
|
-
}, useEffect: function(e, n) {
|
|
13375
|
-
z = "useEffect", D(), N(), Qn(2048, Ut, e, n);
|
|
13376
|
-
}, useImperativeHandle: function(e, n, o) {
|
|
13377
|
-
return z = "useImperativeHandle", D(), N(), aa(e, n, o);
|
|
13378
|
-
}, useInsertionEffect: function(e, n) {
|
|
13379
|
-
return z = "useInsertionEffect", D(), N(), Qn(4, Wt, e, n);
|
|
13380
|
-
}, useLayoutEffect: function(e, n) {
|
|
13381
|
-
return z = "useLayoutEffect", D(), N(), Qn(4, Rr, e, n);
|
|
13382
|
-
}, useMemo: function(e, n) {
|
|
13383
|
-
z = "useMemo", D(), N();
|
|
13384
|
-
var o = x.H;
|
|
13385
|
-
x.H = $o;
|
|
12789
|
+
}, le.discreteUpdates = function(e, n, o, i, s) {
|
|
12790
|
+
var u = x.T, f = wt();
|
|
13386
12791
|
try {
|
|
13387
|
-
return
|
|
12792
|
+
return an(2), x.T = null, e(n, o, i, s);
|
|
13388
12793
|
} finally {
|
|
13389
|
-
x.
|
|
12794
|
+
an(f), x.T = u, ye === Jn && (Pp = me() + Fg);
|
|
13390
12795
|
}
|
|
13391
|
-
},
|
|
13392
|
-
|
|
13393
|
-
|
|
13394
|
-
|
|
13395
|
-
|
|
13396
|
-
|
|
13397
|
-
|
|
13398
|
-
|
|
12796
|
+
}, le.findAllNodes = kc, le.findBoundingRects = function(e, n) {
|
|
12797
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12798
|
+
n = kc(e, n), e = [];
|
|
12799
|
+
for (var o = 0; o < n.length; o++) e.push(ma(n[o]));
|
|
12800
|
+
for (n = e.length - 1; 0 < n; n--) {
|
|
12801
|
+
o = e[n];
|
|
12802
|
+
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) {
|
|
12803
|
+
var g = e[p], S = g.x, T = S + g.width, _ = g.y, I = _ + g.height;
|
|
12804
|
+
if (i >= S && u >= _ && s <= T && f <= I) {
|
|
12805
|
+
e.splice(n, 1);
|
|
12806
|
+
break;
|
|
12807
|
+
} else if (i !== S || o.width !== g.width || I < u || _ > f) {
|
|
12808
|
+
if (!(u !== _ || o.height !== g.height || T < i || S > s)) {
|
|
12809
|
+
S > i && (g.width += S - i, g.x = i), T < s && (g.width = s - S), e.splice(n, 1);
|
|
12810
|
+
break;
|
|
12811
|
+
}
|
|
12812
|
+
} else {
|
|
12813
|
+
_ > u && (g.height += _ - u, g.y = u), I < f && (g.height = f - _), e.splice(n, 1);
|
|
12814
|
+
break;
|
|
12815
|
+
}
|
|
12816
|
+
}
|
|
13399
12817
|
}
|
|
13400
|
-
|
|
13401
|
-
|
|
13402
|
-
|
|
13403
|
-
|
|
13404
|
-
|
|
13405
|
-
|
|
12818
|
+
return e;
|
|
12819
|
+
}, le.findHostInstance = function(e) {
|
|
12820
|
+
var n = e._reactInternals;
|
|
12821
|
+
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));
|
|
12822
|
+
return e = mu(n), e === null ? null : ot(e.stateNode);
|
|
12823
|
+
}, le.findHostInstanceWithNoPortals = function(e) {
|
|
12824
|
+
return e = Ed(e), e = e !== null ? _p(e) : null, e === null ? null : ot(e.stateNode);
|
|
12825
|
+
}, le.findHostInstanceWithWarning = function(e, n) {
|
|
12826
|
+
var o = e._reactInternals;
|
|
12827
|
+
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));
|
|
12828
|
+
if (e = mu(o), e === null) return null;
|
|
12829
|
+
if (e.mode & 8) {
|
|
12830
|
+
var i = G(o) || "Component";
|
|
12831
|
+
mb[i] || (mb[i] = true, B(e, function() {
|
|
12832
|
+
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);
|
|
12833
|
+
}));
|
|
12834
|
+
}
|
|
12835
|
+
return ot(e.stateNode);
|
|
12836
|
+
}, le.flushPassiveEffects = el, le.flushSyncFromReconciler = function(e) {
|
|
12837
|
+
var n = ye;
|
|
12838
|
+
ye |= 1;
|
|
12839
|
+
var o = x.T, i = wt();
|
|
13406
12840
|
try {
|
|
13407
|
-
return
|
|
12841
|
+
if (an(2), x.T = null, e) return e();
|
|
13408
12842
|
} finally {
|
|
13409
|
-
x.
|
|
12843
|
+
an(i), x.T = o, ye = n, (ye & (Zn | uo)) === Jn && Wa(0);
|
|
12844
|
+
}
|
|
12845
|
+
}, le.flushSyncWork = Ls, le.focusWithin = function(e, n) {
|
|
12846
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12847
|
+
for (e = Ef(e), n = hh(e, n), n = Array.from(n), e = 0; e < n.length; ) {
|
|
12848
|
+
var o = n[e++], i = o.tag;
|
|
12849
|
+
if (!Kr(o)) {
|
|
12850
|
+
if ((i === 5 || i === 26 || i === 27) && Ft(o.stateNode)) return true;
|
|
12851
|
+
for (o = o.child; o !== null; ) n.push(o), o = o.sibling;
|
|
12852
|
+
}
|
|
12853
|
+
}
|
|
12854
|
+
return false;
|
|
12855
|
+
}, le.getFindAllNodesFailureDescription = function(e, n) {
|
|
12856
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12857
|
+
var o = 0, i = [];
|
|
12858
|
+
e = [Ef(e), 0];
|
|
12859
|
+
for (var s = 0; s < e.length; ) {
|
|
12860
|
+
var u = e[s++], f = u.tag, p = e[s++], g = n[p];
|
|
12861
|
+
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;
|
|
12862
|
+
}
|
|
12863
|
+
if (o < n.length) {
|
|
12864
|
+
for (e = []; o < n.length; o++) e.push(Sc(n[o]));
|
|
12865
|
+
return `findAllNodes was able to match part of the selector:
|
|
12866
|
+
` + (i.join(" > ") + `
|
|
12867
|
+
|
|
12868
|
+
No matching component was found for:
|
|
12869
|
+
`) + e.join(" > ");
|
|
12870
|
+
}
|
|
12871
|
+
return null;
|
|
12872
|
+
}, le.getPublicRootInstance = function(e) {
|
|
12873
|
+
if (e = e.current, !e.child) return null;
|
|
12874
|
+
switch (e.child.tag) {
|
|
12875
|
+
case 27:
|
|
12876
|
+
case 5:
|
|
12877
|
+
return ot(e.child.stateNode);
|
|
12878
|
+
default:
|
|
12879
|
+
return e.child.stateNode;
|
|
12880
|
+
}
|
|
12881
|
+
}, le.injectIntoDevTools = function() {
|
|
12882
|
+
var e = { bundleType: 1, version: Jt, rendererPackageName: Zt, currentDispatcherRef: x, reconcilerVersion: "19.2.0" };
|
|
12883
|
+
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);
|
|
12884
|
+
}, le.isAlreadyRendering = Ns, le.observeVisibleRects = function(e, n, o, i) {
|
|
12885
|
+
function s() {
|
|
12886
|
+
var S = kc(e, n);
|
|
12887
|
+
u.forEach(function(T) {
|
|
12888
|
+
0 > S.indexOf(T) && g(T);
|
|
12889
|
+
}), S.forEach(function(T) {
|
|
12890
|
+
0 > u.indexOf(T) && p(T);
|
|
12891
|
+
});
|
|
12892
|
+
}
|
|
12893
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12894
|
+
var u = kc(e, n);
|
|
12895
|
+
o = zr(u, o, i);
|
|
12896
|
+
var f = o.disconnect, p = o.observe, g = o.unobserve;
|
|
12897
|
+
return bm.push(s), { disconnect: function() {
|
|
12898
|
+
var S = bm.indexOf(s);
|
|
12899
|
+
0 <= S && bm.splice(S, 1), f();
|
|
12900
|
+
} };
|
|
12901
|
+
}, le.shouldError = function(e) {
|
|
12902
|
+
return pu(e);
|
|
12903
|
+
}, le.shouldSuspend = function(e) {
|
|
12904
|
+
return fu(e);
|
|
12905
|
+
}, le.startHostTransition = function(e, n, o, i) {
|
|
12906
|
+
if (e.tag !== 5) throw Error("Expected the form instance to be a HostComponent. This is a bug in React.");
|
|
12907
|
+
var s = uf(e).queue;
|
|
12908
|
+
Hp(e), nt(e, s, n, Xt, o === null ? Em : function() {
|
|
12909
|
+
x.T === null && console.error("requestFormReset was called outside a transition or action. To fix, move to an action, or wrap with startTransition.");
|
|
12910
|
+
var u = uf(e);
|
|
12911
|
+
return u.next === null && (u = e.alternate.memoizedState), qi(e, u.next.queue, {}, Nt(e)), o(i);
|
|
12912
|
+
});
|
|
12913
|
+
}, le.updateContainer = function(e, n, o, i) {
|
|
12914
|
+
var s = n.current, u = Nt(s);
|
|
12915
|
+
return As(s, u, e, n, o, i), u;
|
|
12916
|
+
}, le.updateContainerSync = Wh, le;
|
|
12917
|
+
}, Tt.exports.default = Tt.exports, Object.defineProperty(Tt.exports, "__esModule", { value: true }));
|
|
12918
|
+
})(Mg)), Mg.exports;
|
|
12919
|
+
}
|
|
12920
|
+
var Eb;
|
|
12921
|
+
function n0() {
|
|
12922
|
+
return Eb || (Eb = 1, process.env.NODE_ENV === "production" ? Rm.exports = Kb() : Rm.exports = e0()), Rm.exports;
|
|
12923
|
+
}
|
|
12924
|
+
var t0 = n0();
|
|
12925
|
+
const r0 = Xb(t0);
|
|
12926
|
+
|
|
12927
|
+
const DEFAULT_POINTER_ID = 0;
|
|
12928
|
+
const XR_POINTER_ID_START = 1e3;
|
|
12929
|
+
function getPointerState(internal, pointerId) {
|
|
12930
|
+
let state = internal.pointerMap.get(pointerId);
|
|
12931
|
+
if (!state) {
|
|
12932
|
+
state = {
|
|
12933
|
+
hovered: /* @__PURE__ */ new Map(),
|
|
12934
|
+
captured: /* @__PURE__ */ new Map(),
|
|
12935
|
+
initialClick: [0, 0],
|
|
12936
|
+
initialHits: []
|
|
12937
|
+
};
|
|
12938
|
+
internal.pointerMap.set(pointerId, state);
|
|
12939
|
+
}
|
|
12940
|
+
return state;
|
|
12941
|
+
}
|
|
12942
|
+
function getPointerId(event) {
|
|
12943
|
+
return "pointerId" in event ? event.pointerId : DEFAULT_POINTER_ID;
|
|
12944
|
+
}
|
|
12945
|
+
function makeId(event) {
|
|
12946
|
+
return (event.eventObject || event.object).uuid + "/" + event.index + event.instanceId;
|
|
12947
|
+
}
|
|
12948
|
+
function releaseInternalPointerCapture(internal, obj, pointerId) {
|
|
12949
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
12950
|
+
if (!pointerState) return;
|
|
12951
|
+
const captureData = pointerState.captured.get(obj);
|
|
12952
|
+
if (captureData) {
|
|
12953
|
+
pointerState.captured.delete(obj);
|
|
12954
|
+
captureData.target.releasePointerCapture(pointerId);
|
|
12955
|
+
}
|
|
12956
|
+
}
|
|
12957
|
+
function swapInteractivity(store, object, newObject) {
|
|
12958
|
+
const { internal } = store.getState();
|
|
12959
|
+
for (let i = 0; i < internal.interaction.length; i++) {
|
|
12960
|
+
if (internal.interaction[i] === object) internal.interaction[i] = newObject;
|
|
12961
|
+
}
|
|
12962
|
+
for (const pointerState of internal.pointerMap.values()) {
|
|
12963
|
+
for (let i = 0; i < pointerState.initialHits.length; i++) {
|
|
12964
|
+
if (pointerState.initialHits[i] === object) pointerState.initialHits[i] = newObject;
|
|
12965
|
+
}
|
|
12966
|
+
pointerState.hovered.forEach((value, key) => {
|
|
12967
|
+
if (value.eventObject === object || value.object === object) {
|
|
12968
|
+
pointerState.hovered.delete(key);
|
|
12969
|
+
const next = {
|
|
12970
|
+
...value,
|
|
12971
|
+
eventObject: value.eventObject === object ? newObject : value.eventObject,
|
|
12972
|
+
object: value.object === object ? newObject : value.object
|
|
12973
|
+
};
|
|
12974
|
+
pointerState.hovered.set(makeId(next), next);
|
|
12975
|
+
}
|
|
12976
|
+
});
|
|
12977
|
+
const captureData = pointerState.captured.get(object);
|
|
12978
|
+
if (captureData) {
|
|
12979
|
+
pointerState.captured.delete(object);
|
|
12980
|
+
pointerState.captured.set(newObject, {
|
|
12981
|
+
...captureData,
|
|
12982
|
+
intersection: {
|
|
12983
|
+
...captureData.intersection,
|
|
12984
|
+
object: captureData.intersection.object === object ? newObject : captureData.intersection.object,
|
|
12985
|
+
eventObject: captureData.intersection.eventObject === object ? newObject : captureData.intersection.eventObject
|
|
13410
12986
|
}
|
|
13411
|
-
}
|
|
13412
|
-
|
|
13413
|
-
|
|
13414
|
-
|
|
13415
|
-
|
|
13416
|
-
|
|
13417
|
-
|
|
13418
|
-
|
|
13419
|
-
|
|
13420
|
-
|
|
13421
|
-
|
|
13422
|
-
|
|
13423
|
-
|
|
13424
|
-
return z = "useActionState", D(), N(), $t(e);
|
|
13425
|
-
}, useOptimistic: function(e, n) {
|
|
13426
|
-
return z = "useOptimistic", D(), N(), of(e, n);
|
|
13427
|
-
}, useMemoCache: function(e) {
|
|
13428
|
-
return D(), Oa(e);
|
|
13429
|
-
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
13430
|
-
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
13431
|
-
}, useEffectEvent: function(e) {
|
|
13432
|
-
return z = "useEffectEvent", D(), N(), oa(e);
|
|
13433
|
-
} };
|
|
13434
|
-
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();
|
|
13435
|
-
Object.freeze(Fy);
|
|
13436
|
-
var zg = { enqueueSetState: function(e, n, o) {
|
|
13437
|
-
e = e._reactInternals;
|
|
13438
|
-
var i = Nt(e), s = zo(i);
|
|
13439
|
-
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));
|
|
13440
|
-
}, enqueueReplaceState: function(e, n, o) {
|
|
13441
|
-
e = e._reactInternals;
|
|
13442
|
-
var i = Nt(e), s = zo(i);
|
|
13443
|
-
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));
|
|
13444
|
-
}, enqueueForceUpdate: function(e, n) {
|
|
13445
|
-
e = e._reactInternals;
|
|
13446
|
-
var o = Nt(e), i = zo(o);
|
|
13447
|
-
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));
|
|
13448
|
-
} }, 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;
|
|
13449
|
-
Yy = /* @__PURE__ */ new Set();
|
|
13450
|
-
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) {
|
|
13451
|
-
var n = Ee(un), o = n.data.get(e);
|
|
13452
|
-
return o === void 0 && (o = e(), n.data.set(e, o)), o;
|
|
13453
|
-
}, cacheSignal: function() {
|
|
13454
|
-
return Ee(un).controller.signal;
|
|
13455
|
-
}, getOwner: function() {
|
|
13456
|
-
return di;
|
|
13457
|
-
} }, pm = 0, hm = 1, mm = 2, gm = 3, ym = 4;
|
|
13458
|
-
if (typeof Symbol == "function" && Symbol.for) {
|
|
13459
|
-
var bp = Symbol.for;
|
|
13460
|
-
pm = bp("selector.component"), hm = bp("selector.has_pseudo_class"), mm = bp("selector.role"), gm = bp("selector.test_id"), ym = bp("selector.text");
|
|
12987
|
+
});
|
|
12988
|
+
}
|
|
12989
|
+
}
|
|
12990
|
+
unregisterVisibility(store, object);
|
|
12991
|
+
}
|
|
12992
|
+
function removeInteractivity(store, object) {
|
|
12993
|
+
const { internal } = store.getState();
|
|
12994
|
+
internal.interaction = internal.interaction.filter((o) => o !== object);
|
|
12995
|
+
for (const [pointerId, pointerState] of internal.pointerMap) {
|
|
12996
|
+
pointerState.initialHits = pointerState.initialHits.filter((o) => o !== object);
|
|
12997
|
+
pointerState.hovered.forEach((value, key) => {
|
|
12998
|
+
if (value.eventObject === object || value.object === object) {
|
|
12999
|
+
pointerState.hovered.delete(key);
|
|
13461
13000
|
}
|
|
13462
|
-
|
|
13463
|
-
|
|
13464
|
-
|
|
13465
|
-
|
|
13466
|
-
|
|
13001
|
+
});
|
|
13002
|
+
if (pointerState.captured.has(object)) {
|
|
13003
|
+
releaseInternalPointerCapture(internal, object, pointerId);
|
|
13004
|
+
}
|
|
13005
|
+
}
|
|
13006
|
+
unregisterVisibility(store, object);
|
|
13007
|
+
}
|
|
13008
|
+
function createEvents(store) {
|
|
13009
|
+
function calculateDistance(event, pointerId) {
|
|
13010
|
+
const { internal } = store.getState();
|
|
13011
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13012
|
+
if (!pointerState) return 0;
|
|
13013
|
+
const [initialX, initialY] = pointerState.initialClick;
|
|
13014
|
+
const dx = event.offsetX - initialX;
|
|
13015
|
+
const dy = event.offsetY - initialY;
|
|
13016
|
+
return Math.round(Math.sqrt(dx * dx + dy * dy));
|
|
13017
|
+
}
|
|
13018
|
+
function filterPointerEvents(objects) {
|
|
13019
|
+
return objects.filter(
|
|
13020
|
+
(obj) => ["Move", "Over", "Enter", "Out", "Leave"].some(
|
|
13021
|
+
(name) => obj.__r3f?.handlers["onPointer" + name]
|
|
13022
|
+
) || ["OverEnter", "OverLeave", "Over"].some(
|
|
13023
|
+
(name) => obj.__r3f?.handlers["onDrag" + name]
|
|
13024
|
+
) || obj.__r3f?.handlers.onDrop
|
|
13025
|
+
);
|
|
13026
|
+
}
|
|
13027
|
+
function intersect(event, filter) {
|
|
13028
|
+
const state = store.getState();
|
|
13029
|
+
const duplicates = /* @__PURE__ */ new Set();
|
|
13030
|
+
const intersections = [];
|
|
13031
|
+
const eventsObjects = filter ? filter(state.internal.interaction) : state.internal.interaction;
|
|
13032
|
+
for (let i = 0; i < eventsObjects.length; i++) {
|
|
13033
|
+
const state2 = getRootState(eventsObjects[i]);
|
|
13034
|
+
if (state2) {
|
|
13035
|
+
state2.raycaster.camera = void 0;
|
|
13467
13036
|
}
|
|
13468
|
-
|
|
13469
|
-
|
|
13470
|
-
|
|
13471
|
-
|
|
13472
|
-
|
|
13473
|
-
|
|
13474
|
-
|
|
13475
|
-
|
|
13476
|
-
|
|
13477
|
-
|
|
13478
|
-
|
|
13479
|
-
|
|
13480
|
-
|
|
13481
|
-
|
|
13482
|
-
|
|
13483
|
-
|
|
13484
|
-
|
|
13485
|
-
|
|
13486
|
-
|
|
13487
|
-
|
|
13488
|
-
|
|
13489
|
-
}, zb = function(e) {
|
|
13490
|
-
fu = e;
|
|
13491
|
-
}, le.attemptContinuousHydration = function(e) {
|
|
13492
|
-
if (e.tag === 13 || e.tag === 31) {
|
|
13493
|
-
var n = On(e, 67108864);
|
|
13494
|
-
n !== null && We(n, e, 67108864), rl(e, 67108864);
|
|
13037
|
+
}
|
|
13038
|
+
if (!state.previousRoot) {
|
|
13039
|
+
state.events.compute?.(event, state);
|
|
13040
|
+
}
|
|
13041
|
+
function handleRaycast(obj) {
|
|
13042
|
+
const state2 = getRootState(obj);
|
|
13043
|
+
if (!state2 || !state2.events.enabled || state2.raycaster.camera === null) return [];
|
|
13044
|
+
if (state2.raycaster.camera === void 0) {
|
|
13045
|
+
state2.events.compute?.(event, state2, state2.previousRoot?.getState());
|
|
13046
|
+
if (state2.raycaster.camera === void 0) state2.raycaster.camera = null;
|
|
13047
|
+
}
|
|
13048
|
+
return state2.raycaster.camera ? state2.raycaster.intersectObject(obj, true) : [];
|
|
13049
|
+
}
|
|
13050
|
+
let hits = eventsObjects.flatMap(handleRaycast).sort((a, b) => {
|
|
13051
|
+
const aInteractivePriority = a.object.userData?.interactivePriority;
|
|
13052
|
+
const bInteractivePriority = b.object.userData?.interactivePriority;
|
|
13053
|
+
if (aInteractivePriority !== void 0 || bInteractivePriority !== void 0) {
|
|
13054
|
+
if (aInteractivePriority !== void 0 && bInteractivePriority === void 0) return -1;
|
|
13055
|
+
if (bInteractivePriority !== void 0 && aInteractivePriority === void 0) return 1;
|
|
13056
|
+
if (aInteractivePriority !== bInteractivePriority) {
|
|
13057
|
+
return (bInteractivePriority ?? 0) - (aInteractivePriority ?? 0);
|
|
13495
13058
|
}
|
|
13496
|
-
}
|
|
13497
|
-
|
|
13498
|
-
|
|
13499
|
-
|
|
13500
|
-
|
|
13501
|
-
|
|
13059
|
+
}
|
|
13060
|
+
const aState = getRootState(a.object);
|
|
13061
|
+
const bState = getRootState(b.object);
|
|
13062
|
+
const aPriority = aState?.events?.priority ?? 1;
|
|
13063
|
+
const bPriority = bState?.events?.priority ?? 1;
|
|
13064
|
+
return bPriority - aPriority || a.distance - b.distance;
|
|
13065
|
+
}).filter((item) => {
|
|
13066
|
+
const id = makeId(item);
|
|
13067
|
+
if (duplicates.has(id)) return false;
|
|
13068
|
+
duplicates.add(id);
|
|
13069
|
+
return true;
|
|
13070
|
+
});
|
|
13071
|
+
if (state.events.filter) hits = state.events.filter(hits, state);
|
|
13072
|
+
for (const hit of hits) {
|
|
13073
|
+
let eventObject = hit.object;
|
|
13074
|
+
while (eventObject) {
|
|
13075
|
+
if (eventObject.__r3f?.eventCount) {
|
|
13076
|
+
intersections.push({ ...hit, eventObject });
|
|
13502
13077
|
}
|
|
13503
|
-
|
|
13504
|
-
|
|
13505
|
-
|
|
13506
|
-
|
|
13507
|
-
|
|
13508
|
-
|
|
13509
|
-
|
|
13510
|
-
|
|
13511
|
-
|
|
13078
|
+
eventObject = eventObject.parent;
|
|
13079
|
+
}
|
|
13080
|
+
}
|
|
13081
|
+
if ("pointerId" in event) {
|
|
13082
|
+
const pointerId = event.pointerId;
|
|
13083
|
+
const pointerState = state.internal.pointerMap.get(pointerId);
|
|
13084
|
+
if (pointerState?.captured.size) {
|
|
13085
|
+
for (const captureData of pointerState.captured.values()) {
|
|
13086
|
+
if (!duplicates.has(makeId(captureData.intersection))) intersections.push(captureData.intersection);
|
|
13087
|
+
}
|
|
13088
|
+
}
|
|
13089
|
+
}
|
|
13090
|
+
return intersections;
|
|
13091
|
+
}
|
|
13092
|
+
function handleIntersects(intersections, event, delta, callback) {
|
|
13093
|
+
if (intersections.length) {
|
|
13094
|
+
const localState = { stopped: false };
|
|
13095
|
+
for (const hit of intersections) {
|
|
13096
|
+
const state = getRootState(hit.object);
|
|
13097
|
+
if (state) {
|
|
13098
|
+
const { raycaster, pointer, camera, internal } = state;
|
|
13099
|
+
const unprojectedPoint = new Vector3(pointer.x, pointer.y, 0).unproject(camera);
|
|
13100
|
+
const hasPointerCapture = (id) => {
|
|
13101
|
+
const pointerState = internal.pointerMap.get(id);
|
|
13102
|
+
return pointerState?.captured.has(hit.eventObject) ?? false;
|
|
13103
|
+
};
|
|
13104
|
+
const setPointerCapture = (id) => {
|
|
13105
|
+
const captureData = { intersection: hit, target: event.target };
|
|
13106
|
+
const pointerState = getPointerState(internal, id);
|
|
13107
|
+
pointerState.captured.set(hit.eventObject, captureData);
|
|
13108
|
+
event.target.setPointerCapture(id);
|
|
13109
|
+
};
|
|
13110
|
+
const releasePointerCapture = (id) => {
|
|
13111
|
+
releaseInternalPointerCapture(internal, hit.eventObject, id);
|
|
13112
|
+
};
|
|
13113
|
+
const extractEventProps = {};
|
|
13114
|
+
for (const prop in event) {
|
|
13115
|
+
const property = event[prop];
|
|
13116
|
+
if (typeof property !== "function") extractEventProps[prop] = property;
|
|
13117
|
+
}
|
|
13118
|
+
const eventPointerId = "pointerId" in event ? event.pointerId : void 0;
|
|
13119
|
+
const raycastEvent = {
|
|
13120
|
+
...hit,
|
|
13121
|
+
...extractEventProps,
|
|
13122
|
+
pointer,
|
|
13123
|
+
intersections,
|
|
13124
|
+
stopped: localState.stopped,
|
|
13125
|
+
delta,
|
|
13126
|
+
unprojectedPoint,
|
|
13127
|
+
ray: raycaster.ray,
|
|
13128
|
+
camera,
|
|
13129
|
+
pointerId: eventPointerId,
|
|
13130
|
+
// Hijack stopPropagation, which just sets a flag
|
|
13131
|
+
stopPropagation() {
|
|
13132
|
+
const pointerState = eventPointerId !== void 0 ? internal.pointerMap.get(eventPointerId) : void 0;
|
|
13133
|
+
if (
|
|
13134
|
+
// ...if this pointer hasn't been captured
|
|
13135
|
+
!pointerState?.captured.size || // ... or if the hit object is capturing the pointer
|
|
13136
|
+
pointerState.captured.has(hit.eventObject)
|
|
13137
|
+
) {
|
|
13138
|
+
raycastEvent.stopped = localState.stopped = true;
|
|
13139
|
+
if (pointerState?.hovered.size && Array.from(pointerState.hovered.values()).find((i) => i.eventObject === hit.eventObject)) {
|
|
13140
|
+
const higher = intersections.slice(0, intersections.indexOf(hit));
|
|
13141
|
+
cancelPointer([...higher, hit], eventPointerId);
|
|
13512
13142
|
}
|
|
13513
|
-
Kn(e), (ye & (Zn | uo)) === Jn && (Pp = me() + Fg, Wa(0));
|
|
13514
13143
|
}
|
|
13515
|
-
}
|
|
13516
|
-
|
|
13517
|
-
|
|
13518
|
-
|
|
13519
|
-
|
|
13144
|
+
},
|
|
13145
|
+
// there should be a distinction between target and currentTarget
|
|
13146
|
+
target: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
13147
|
+
currentTarget: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
13148
|
+
nativeEvent: event
|
|
13149
|
+
};
|
|
13150
|
+
callback(raycastEvent);
|
|
13151
|
+
if (localState.stopped === true) break;
|
|
13520
13152
|
}
|
|
13521
|
-
}
|
|
13522
|
-
|
|
13523
|
-
|
|
13524
|
-
|
|
13525
|
-
|
|
13526
|
-
|
|
13527
|
-
|
|
13528
|
-
|
|
13529
|
-
|
|
13530
|
-
|
|
13531
|
-
|
|
13532
|
-
|
|
13533
|
-
|
|
13534
|
-
|
|
13535
|
-
|
|
13536
|
-
|
|
13537
|
-
|
|
13153
|
+
}
|
|
13154
|
+
}
|
|
13155
|
+
return intersections;
|
|
13156
|
+
}
|
|
13157
|
+
function cancelPointer(intersections, pointerId) {
|
|
13158
|
+
const { internal } = store.getState();
|
|
13159
|
+
const pid = pointerId ?? DEFAULT_POINTER_ID;
|
|
13160
|
+
const pointerState = internal.pointerMap.get(pid);
|
|
13161
|
+
if (!pointerState) return;
|
|
13162
|
+
for (const [hoveredId, hoveredObj] of pointerState.hovered) {
|
|
13163
|
+
if (!intersections.length || !intersections.find(
|
|
13164
|
+
(hit) => hit.object === hoveredObj.object && hit.index === hoveredObj.index && hit.instanceId === hoveredObj.instanceId
|
|
13165
|
+
)) {
|
|
13166
|
+
const eventObject = hoveredObj.eventObject;
|
|
13167
|
+
const instance = eventObject.__r3f;
|
|
13168
|
+
pointerState.hovered.delete(hoveredId);
|
|
13169
|
+
if (instance?.eventCount) {
|
|
13170
|
+
const handlers = instance.handlers;
|
|
13171
|
+
const data = { ...hoveredObj, intersections };
|
|
13172
|
+
handlers.onPointerOut?.(data);
|
|
13173
|
+
handlers.onPointerLeave?.(data);
|
|
13174
|
+
handlers.onDragOverLeave?.(data);
|
|
13538
13175
|
}
|
|
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
|
-
|
|
13567
|
-
|
|
13568
|
-
|
|
13569
|
-
|
|
13570
|
-
|
|
13571
|
-
|
|
13572
|
-
an(o), x.T = n;
|
|
13176
|
+
}
|
|
13177
|
+
}
|
|
13178
|
+
}
|
|
13179
|
+
function pointerMissed(event, objects) {
|
|
13180
|
+
for (let i = 0; i < objects.length; i++) {
|
|
13181
|
+
const instance = objects[i].__r3f;
|
|
13182
|
+
instance?.handlers.onPointerMissed?.(event);
|
|
13183
|
+
}
|
|
13184
|
+
}
|
|
13185
|
+
function dragOverMissed(event, objects) {
|
|
13186
|
+
for (let i = 0; i < objects.length; i++) {
|
|
13187
|
+
const instance = objects[i].__r3f;
|
|
13188
|
+
instance?.handlers.onDragOverMissed?.(event);
|
|
13189
|
+
}
|
|
13190
|
+
}
|
|
13191
|
+
function dropMissed(event, objects) {
|
|
13192
|
+
for (let i = 0; i < objects.length; i++) {
|
|
13193
|
+
const instance = objects[i].__r3f;
|
|
13194
|
+
instance?.handlers.onDropMissed?.(event);
|
|
13195
|
+
}
|
|
13196
|
+
}
|
|
13197
|
+
function cleanupPointer(pointerId) {
|
|
13198
|
+
const { internal } = store.getState();
|
|
13199
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13200
|
+
if (pointerState) {
|
|
13201
|
+
for (const [, hoveredObj] of pointerState.hovered) {
|
|
13202
|
+
const eventObject = hoveredObj.eventObject;
|
|
13203
|
+
const instance = eventObject.__r3f;
|
|
13204
|
+
if (instance?.eventCount) {
|
|
13205
|
+
const handlers = instance.handlers;
|
|
13206
|
+
const data = { ...hoveredObj, intersections: [] };
|
|
13207
|
+
handlers.onPointerOut?.(data);
|
|
13208
|
+
handlers.onPointerLeave?.(data);
|
|
13573
13209
|
}
|
|
13574
|
-
}
|
|
13575
|
-
|
|
13576
|
-
|
|
13577
|
-
|
|
13578
|
-
|
|
13579
|
-
|
|
13210
|
+
}
|
|
13211
|
+
internal.pointerMap.delete(pointerId);
|
|
13212
|
+
}
|
|
13213
|
+
internal.pointerDirty.delete(pointerId);
|
|
13214
|
+
}
|
|
13215
|
+
function processDeferredPointer(event, pointerId) {
|
|
13216
|
+
const state = store.getState();
|
|
13217
|
+
const { internal } = state;
|
|
13218
|
+
if (!state.events.enabled) return;
|
|
13219
|
+
const filter = filterPointerEvents;
|
|
13220
|
+
const hits = intersect(event, filter);
|
|
13221
|
+
cancelPointer(hits, pointerId);
|
|
13222
|
+
function onIntersect(data) {
|
|
13223
|
+
const eventObject = data.eventObject;
|
|
13224
|
+
const instance = eventObject.__r3f;
|
|
13225
|
+
if (!instance?.eventCount) return;
|
|
13226
|
+
const handlers = instance.handlers;
|
|
13227
|
+
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
13228
|
+
const id = makeId(data);
|
|
13229
|
+
const pointerState = getPointerState(internal, pointerId);
|
|
13230
|
+
const hoveredItem = pointerState.hovered.get(id);
|
|
13231
|
+
if (!hoveredItem) {
|
|
13232
|
+
pointerState.hovered.set(id, data);
|
|
13233
|
+
handlers.onPointerOver?.(data);
|
|
13234
|
+
handlers.onPointerEnter?.(data);
|
|
13235
|
+
} else if (hoveredItem.stopped) {
|
|
13236
|
+
data.stopPropagation();
|
|
13237
|
+
}
|
|
13238
|
+
}
|
|
13239
|
+
handlers.onPointerMove?.(data);
|
|
13240
|
+
}
|
|
13241
|
+
handleIntersects(hits, event, 0, onIntersect);
|
|
13242
|
+
}
|
|
13243
|
+
function handlePointer(name) {
|
|
13244
|
+
switch (name) {
|
|
13245
|
+
case "onPointerLeave":
|
|
13246
|
+
case "onDragLeave":
|
|
13247
|
+
return () => cancelPointer([]);
|
|
13248
|
+
// Global cancel of these events
|
|
13249
|
+
case "onPointerCancel":
|
|
13250
|
+
return (event) => {
|
|
13251
|
+
const pointerId = getPointerId(event);
|
|
13252
|
+
cleanupPointer(pointerId);
|
|
13253
|
+
};
|
|
13254
|
+
case "onLostPointerCapture":
|
|
13255
|
+
return (event) => {
|
|
13256
|
+
const { internal } = store.getState();
|
|
13257
|
+
const pointerId = getPointerId(event);
|
|
13258
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13259
|
+
if (pointerState?.captured.size) {
|
|
13260
|
+
requestAnimationFrame(() => {
|
|
13261
|
+
const pointerState2 = internal.pointerMap.get(pointerId);
|
|
13262
|
+
if (pointerState2?.captured.size) {
|
|
13263
|
+
pointerState2.captured.clear();
|
|
13264
|
+
}
|
|
13265
|
+
cancelPointer([], pointerId);
|
|
13266
|
+
});
|
|
13267
|
+
}
|
|
13268
|
+
};
|
|
13269
|
+
}
|
|
13270
|
+
return function handleEvent(event) {
|
|
13271
|
+
const state = store.getState();
|
|
13272
|
+
const { onPointerMissed, onDragOverMissed, onDropMissed, internal, events } = state;
|
|
13273
|
+
const pointerId = getPointerId(event);
|
|
13274
|
+
internal.lastEvent.current = event;
|
|
13275
|
+
if (!events.enabled) return;
|
|
13276
|
+
const isPointerMove = name === "onPointerMove";
|
|
13277
|
+
const isDragOver = name === "onDragOver";
|
|
13278
|
+
const isDrop = name === "onDrop";
|
|
13279
|
+
const isClickEvent = name === "onClick" || name === "onContextMenu" || name === "onDoubleClick";
|
|
13280
|
+
const isPointerDown = name === "onPointerDown";
|
|
13281
|
+
const isPointerUp = name === "onPointerUp";
|
|
13282
|
+
const isWheel = name === "onWheel";
|
|
13283
|
+
const canDeferRaycasts = events.frameTimedRaycasts && state.frameloop === "always";
|
|
13284
|
+
if (isPointerMove && canDeferRaycasts) {
|
|
13285
|
+
events.compute?.(event, state);
|
|
13286
|
+
internal.pointerDirty.set(pointerId, event);
|
|
13287
|
+
return;
|
|
13288
|
+
}
|
|
13289
|
+
if (isWheel && canDeferRaycasts && !events.alwaysFireOnScroll) {
|
|
13290
|
+
events.compute?.(event, state);
|
|
13291
|
+
internal.pointerDirty.set(pointerId, event);
|
|
13292
|
+
return;
|
|
13293
|
+
}
|
|
13294
|
+
if ((isClickEvent || isPointerDown || isPointerUp) && internal.pointerDirty.has(pointerId)) {
|
|
13295
|
+
const deferredEvent = internal.pointerDirty.get(pointerId);
|
|
13296
|
+
internal.pointerDirty.delete(pointerId);
|
|
13297
|
+
processDeferredPointer(deferredEvent, pointerId);
|
|
13298
|
+
}
|
|
13299
|
+
const filter = isPointerMove || isDragOver || isDrop ? filterPointerEvents : void 0;
|
|
13300
|
+
const hits = intersect(event, filter);
|
|
13301
|
+
const delta = isClickEvent ? calculateDistance(event, pointerId) : 0;
|
|
13302
|
+
if (isPointerDown) {
|
|
13303
|
+
const pointerState2 = getPointerState(internal, pointerId);
|
|
13304
|
+
pointerState2.initialClick = [event.offsetX, event.offsetY];
|
|
13305
|
+
pointerState2.initialHits = hits.map((hit) => hit.eventObject);
|
|
13306
|
+
}
|
|
13307
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13308
|
+
const initialHits = pointerState?.initialHits ?? [];
|
|
13309
|
+
if (isClickEvent && !hits.length) {
|
|
13310
|
+
if (delta <= 2) {
|
|
13311
|
+
pointerMissed(event, internal.interaction);
|
|
13312
|
+
if (onPointerMissed) onPointerMissed(event);
|
|
13580
13313
|
}
|
|
13581
|
-
}
|
|
13582
|
-
|
|
13583
|
-
|
|
13584
|
-
|
|
13585
|
-
|
|
13586
|
-
|
|
13587
|
-
|
|
13588
|
-
|
|
13589
|
-
|
|
13590
|
-
|
|
13591
|
-
|
|
13592
|
-
|
|
13593
|
-
|
|
13594
|
-
|
|
13595
|
-
|
|
13596
|
-
|
|
13597
|
-
|
|
13598
|
-
|
|
13599
|
-
|
|
13314
|
+
}
|
|
13315
|
+
if (isDragOver && !hits.length) {
|
|
13316
|
+
dragOverMissed(event, internal.interaction);
|
|
13317
|
+
if (onDragOverMissed) onDragOverMissed(event);
|
|
13318
|
+
}
|
|
13319
|
+
if (isDrop && !hits.length) {
|
|
13320
|
+
dropMissed(event, internal.interaction);
|
|
13321
|
+
if (onDropMissed) onDropMissed(event);
|
|
13322
|
+
}
|
|
13323
|
+
if (isPointerMove || isDragOver) {
|
|
13324
|
+
cancelPointer(hits, pointerId);
|
|
13325
|
+
}
|
|
13326
|
+
function onIntersect(data) {
|
|
13327
|
+
const eventObject = data.eventObject;
|
|
13328
|
+
const instance = eventObject.__r3f;
|
|
13329
|
+
if (!instance?.eventCount) return;
|
|
13330
|
+
const handlers = instance.handlers;
|
|
13331
|
+
if (isPointerMove) {
|
|
13332
|
+
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
13333
|
+
const id = makeId(data);
|
|
13334
|
+
const pointerState2 = getPointerState(internal, pointerId);
|
|
13335
|
+
const hoveredItem = pointerState2.hovered.get(id);
|
|
13336
|
+
if (!hoveredItem) {
|
|
13337
|
+
pointerState2.hovered.set(id, data);
|
|
13338
|
+
handlers.onPointerOver?.(data);
|
|
13339
|
+
handlers.onPointerEnter?.(data);
|
|
13340
|
+
} else if (hoveredItem.stopped) {
|
|
13341
|
+
data.stopPropagation();
|
|
13600
13342
|
}
|
|
13601
13343
|
}
|
|
13602
|
-
|
|
13603
|
-
|
|
13604
|
-
|
|
13605
|
-
|
|
13606
|
-
|
|
13607
|
-
|
|
13608
|
-
|
|
13609
|
-
|
|
13610
|
-
|
|
13611
|
-
|
|
13612
|
-
|
|
13613
|
-
|
|
13614
|
-
if (
|
|
13615
|
-
|
|
13616
|
-
|
|
13617
|
-
|
|
13618
|
-
|
|
13619
|
-
|
|
13620
|
-
|
|
13621
|
-
|
|
13622
|
-
|
|
13623
|
-
|
|
13624
|
-
|
|
13625
|
-
|
|
13626
|
-
|
|
13627
|
-
|
|
13628
|
-
|
|
13629
|
-
|
|
13630
|
-
|
|
13631
|
-
|
|
13632
|
-
|
|
13633
|
-
var o = n[e++], i = o.tag;
|
|
13634
|
-
if (!Kr(o)) {
|
|
13635
|
-
if ((i === 5 || i === 26 || i === 27) && Ft(o.stateNode)) return true;
|
|
13636
|
-
for (o = o.child; o !== null; ) n.push(o), o = o.sibling;
|
|
13344
|
+
handlers.onPointerMove?.(data);
|
|
13345
|
+
} else if (isDragOver) {
|
|
13346
|
+
const id = makeId(data);
|
|
13347
|
+
const pointerState2 = getPointerState(internal, pointerId);
|
|
13348
|
+
const hoveredItem = pointerState2.hovered.get(id);
|
|
13349
|
+
if (!hoveredItem) {
|
|
13350
|
+
pointerState2.hovered.set(id, data);
|
|
13351
|
+
handlers.onDragOverEnter?.(data);
|
|
13352
|
+
} else if (hoveredItem.stopped) {
|
|
13353
|
+
data.stopPropagation();
|
|
13354
|
+
}
|
|
13355
|
+
handlers.onDragOver?.(data);
|
|
13356
|
+
} else if (isDrop) {
|
|
13357
|
+
handlers.onDrop?.(data);
|
|
13358
|
+
} else {
|
|
13359
|
+
const handler = handlers[name];
|
|
13360
|
+
if (handler) {
|
|
13361
|
+
if (!isClickEvent || initialHits.includes(eventObject)) {
|
|
13362
|
+
pointerMissed(
|
|
13363
|
+
event,
|
|
13364
|
+
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
13365
|
+
);
|
|
13366
|
+
handler(data);
|
|
13367
|
+
}
|
|
13368
|
+
} else {
|
|
13369
|
+
if (isClickEvent && initialHits.includes(eventObject)) {
|
|
13370
|
+
pointerMissed(
|
|
13371
|
+
event,
|
|
13372
|
+
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
13373
|
+
);
|
|
13374
|
+
}
|
|
13637
13375
|
}
|
|
13638
13376
|
}
|
|
13639
|
-
|
|
13640
|
-
|
|
13641
|
-
|
|
13642
|
-
|
|
13643
|
-
|
|
13644
|
-
|
|
13645
|
-
|
|
13646
|
-
|
|
13377
|
+
}
|
|
13378
|
+
handleIntersects(hits, event, delta, onIntersect);
|
|
13379
|
+
};
|
|
13380
|
+
}
|
|
13381
|
+
function flushDeferredPointers() {
|
|
13382
|
+
const { internal, events } = store.getState();
|
|
13383
|
+
if (!events.frameTimedRaycasts) return;
|
|
13384
|
+
for (const [pointerId, event] of internal.pointerDirty) {
|
|
13385
|
+
processDeferredPointer(event, pointerId);
|
|
13386
|
+
}
|
|
13387
|
+
internal.pointerDirty.clear();
|
|
13388
|
+
}
|
|
13389
|
+
return { handlePointer, flushDeferredPointers, processDeferredPointer };
|
|
13390
|
+
}
|
|
13391
|
+
const DOM_EVENTS = {
|
|
13392
|
+
onClick: ["click", false],
|
|
13393
|
+
onContextMenu: ["contextmenu", false],
|
|
13394
|
+
onDoubleClick: ["dblclick", false],
|
|
13395
|
+
onDragEnter: ["dragenter", false],
|
|
13396
|
+
onDragLeave: ["dragleave", false],
|
|
13397
|
+
onDragOver: ["dragover", false],
|
|
13398
|
+
onDrop: ["drop", false],
|
|
13399
|
+
onWheel: ["wheel", true],
|
|
13400
|
+
onPointerDown: ["pointerdown", true],
|
|
13401
|
+
onPointerUp: ["pointerup", true],
|
|
13402
|
+
onPointerLeave: ["pointerleave", true],
|
|
13403
|
+
onPointerMove: ["pointermove", true],
|
|
13404
|
+
onPointerCancel: ["pointercancel", true],
|
|
13405
|
+
onLostPointerCapture: ["lostpointercapture", true]
|
|
13406
|
+
};
|
|
13407
|
+
function createPointerEvents(store) {
|
|
13408
|
+
const { handlePointer, flushDeferredPointers, processDeferredPointer } = createEvents(store);
|
|
13409
|
+
let nextXRPointerId = XR_POINTER_ID_START;
|
|
13410
|
+
const xrPointers = /* @__PURE__ */ new Map();
|
|
13411
|
+
return {
|
|
13412
|
+
priority: 1,
|
|
13413
|
+
enabled: true,
|
|
13414
|
+
frameTimedRaycasts: true,
|
|
13415
|
+
alwaysFireOnScroll: true,
|
|
13416
|
+
updateOnFrame: false,
|
|
13417
|
+
compute(event, state) {
|
|
13418
|
+
state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
|
|
13419
|
+
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
13420
|
+
},
|
|
13421
|
+
connected: void 0,
|
|
13422
|
+
handlers: Object.keys(DOM_EVENTS).reduce(
|
|
13423
|
+
(acc, key) => ({ ...acc, [key]: handlePointer(key) }),
|
|
13424
|
+
{}
|
|
13425
|
+
),
|
|
13426
|
+
update: (pointerId) => {
|
|
13427
|
+
const { events, internal } = store.getState();
|
|
13428
|
+
if (!events.handlers) return;
|
|
13429
|
+
if (pointerId !== void 0) {
|
|
13430
|
+
const event = internal.pointerDirty.get(pointerId);
|
|
13431
|
+
if (event) {
|
|
13432
|
+
internal.pointerDirty.delete(pointerId);
|
|
13433
|
+
processDeferredPointer(event, pointerId);
|
|
13434
|
+
} else if (internal.lastEvent?.current) {
|
|
13435
|
+
processDeferredPointer(internal.lastEvent.current, pointerId);
|
|
13647
13436
|
}
|
|
13648
|
-
|
|
13649
|
-
|
|
13650
|
-
|
|
13651
|
-
|
|
13652
|
-
|
|
13653
|
-
No matching component was found for:
|
|
13654
|
-
`) + e.join(" > ");
|
|
13437
|
+
} else {
|
|
13438
|
+
flushDeferredPointers();
|
|
13439
|
+
if (internal.lastEvent?.current) {
|
|
13440
|
+
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
13655
13441
|
}
|
|
13656
|
-
|
|
13657
|
-
|
|
13658
|
-
|
|
13659
|
-
|
|
13660
|
-
|
|
13661
|
-
|
|
13662
|
-
|
|
13663
|
-
|
|
13664
|
-
|
|
13442
|
+
}
|
|
13443
|
+
},
|
|
13444
|
+
flush: () => {
|
|
13445
|
+
const { events, internal } = store.getState();
|
|
13446
|
+
flushDeferredPointers();
|
|
13447
|
+
if (events.updateOnFrame && internal.lastEvent?.current && events.handlers) {
|
|
13448
|
+
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
13449
|
+
}
|
|
13450
|
+
},
|
|
13451
|
+
connect: (target) => {
|
|
13452
|
+
if (!target) return;
|
|
13453
|
+
const { set, events } = store.getState();
|
|
13454
|
+
events.disconnect?.();
|
|
13455
|
+
set((state) => ({ events: { ...state.events, connected: target } }));
|
|
13456
|
+
if (events.handlers) {
|
|
13457
|
+
for (const name in events.handlers) {
|
|
13458
|
+
const event = events.handlers[name];
|
|
13459
|
+
const [eventName, passive] = DOM_EVENTS[name];
|
|
13460
|
+
target.addEventListener(eventName, event, { passive });
|
|
13665
13461
|
}
|
|
13666
|
-
}
|
|
13667
|
-
|
|
13668
|
-
|
|
13669
|
-
|
|
13670
|
-
|
|
13671
|
-
|
|
13672
|
-
|
|
13673
|
-
|
|
13674
|
-
|
|
13675
|
-
|
|
13676
|
-
}
|
|
13462
|
+
}
|
|
13463
|
+
},
|
|
13464
|
+
disconnect: () => {
|
|
13465
|
+
const { set, events } = store.getState();
|
|
13466
|
+
if (events.connected) {
|
|
13467
|
+
if (events.handlers) {
|
|
13468
|
+
for (const name in events.handlers) {
|
|
13469
|
+
const event = events.handlers[name];
|
|
13470
|
+
const [eventName] = DOM_EVENTS[name];
|
|
13471
|
+
events.connected.removeEventListener(eventName, event);
|
|
13472
|
+
}
|
|
13473
|
+
}
|
|
13474
|
+
set((state) => ({ events: { ...state.events, connected: void 0 } }));
|
|
13475
|
+
}
|
|
13476
|
+
},
|
|
13477
|
+
// PREVIEW (A8): the XR pointer registration API may change before stable.
|
|
13478
|
+
registerPointer: (config) => {
|
|
13479
|
+
const pointerId = nextXRPointerId++;
|
|
13480
|
+
xrPointers.set(pointerId, config);
|
|
13481
|
+
const { internal } = store.getState();
|
|
13482
|
+
getPointerState(internal, pointerId);
|
|
13483
|
+
return pointerId;
|
|
13484
|
+
},
|
|
13485
|
+
unregisterPointer: (pointerId) => {
|
|
13486
|
+
xrPointers.delete(pointerId);
|
|
13487
|
+
const { internal } = store.getState();
|
|
13488
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13489
|
+
if (pointerState) {
|
|
13490
|
+
for (const [, hoveredObj] of pointerState.hovered) {
|
|
13491
|
+
const eventObject = hoveredObj.eventObject;
|
|
13492
|
+
const instance = eventObject.__r3f;
|
|
13493
|
+
if (instance?.eventCount) {
|
|
13494
|
+
const handlers = instance.handlers;
|
|
13495
|
+
const data = { ...hoveredObj, intersections: [] };
|
|
13496
|
+
handlers.onPointerOut?.(data);
|
|
13497
|
+
handlers.onPointerLeave?.(data);
|
|
13498
|
+
}
|
|
13677
13499
|
}
|
|
13678
|
-
|
|
13679
|
-
|
|
13680
|
-
|
|
13681
|
-
|
|
13682
|
-
|
|
13683
|
-
var S = bm.indexOf(s);
|
|
13684
|
-
0 <= S && bm.splice(S, 1), f();
|
|
13685
|
-
} };
|
|
13686
|
-
}, le.shouldError = function(e) {
|
|
13687
|
-
return pu(e);
|
|
13688
|
-
}, le.shouldSuspend = function(e) {
|
|
13689
|
-
return fu(e);
|
|
13690
|
-
}, le.startHostTransition = function(e, n, o, i) {
|
|
13691
|
-
if (e.tag !== 5) throw Error("Expected the form instance to be a HostComponent. This is a bug in React.");
|
|
13692
|
-
var s = uf(e).queue;
|
|
13693
|
-
Hp(e), nt(e, s, n, Xt, o === null ? Em : function() {
|
|
13694
|
-
x.T === null && console.error("requestFormReset was called outside a transition or action. To fix, move to an action, or wrap with startTransition.");
|
|
13695
|
-
var u = uf(e);
|
|
13696
|
-
return u.next === null && (u = e.alternate.memoizedState), qi(e, u.next.queue, {}, Nt(e)), o(i);
|
|
13697
|
-
});
|
|
13698
|
-
}, le.updateContainer = function(e, n, o, i) {
|
|
13699
|
-
var s = n.current, u = Nt(s);
|
|
13700
|
-
return As(s, u, e, n, o, i), u;
|
|
13701
|
-
}, le.updateContainerSync = Wh, le;
|
|
13702
|
-
}, Tt.exports.default = Tt.exports, Object.defineProperty(Tt.exports, "__esModule", { value: true }));
|
|
13703
|
-
})(Mg)), Mg.exports;
|
|
13704
|
-
}
|
|
13705
|
-
var Eb;
|
|
13706
|
-
function n0() {
|
|
13707
|
-
return Eb || (Eb = 1, process.env.NODE_ENV === "production" ? Rm.exports = Kb() : Rm.exports = e0()), Rm.exports;
|
|
13500
|
+
internal.pointerMap.delete(pointerId);
|
|
13501
|
+
}
|
|
13502
|
+
internal.pointerDirty.delete(pointerId);
|
|
13503
|
+
}
|
|
13504
|
+
};
|
|
13708
13505
|
}
|
|
13709
|
-
var t0 = n0();
|
|
13710
|
-
const r0 = Xb(t0);
|
|
13711
|
-
|
|
13712
|
-
const t = 1, o = 8, r = 32, e = 2, i$1 = 268435456;
|
|
13713
13506
|
|
|
13714
13507
|
function createReconciler(config) {
|
|
13715
13508
|
const reconciler2 = r0(config);
|
|
@@ -14895,6 +14688,212 @@ function flushSync(fn) {
|
|
|
14895
14688
|
return reconciler.flushSyncFromReconciler(fn);
|
|
14896
14689
|
}
|
|
14897
14690
|
|
|
14691
|
+
const isRef = (obj) => obj.current && obj.current.isScene;
|
|
14692
|
+
const resolveScene = (scene) => isRef(scene) ? scene.current : scene;
|
|
14693
|
+
function setEnvProps(background, scene, defaultScene, texture, sceneProps = {}) {
|
|
14694
|
+
sceneProps = {
|
|
14695
|
+
backgroundBlurriness: 0,
|
|
14696
|
+
backgroundIntensity: 1,
|
|
14697
|
+
backgroundRotation: [0, 0, 0],
|
|
14698
|
+
environmentIntensity: 1,
|
|
14699
|
+
environmentRotation: [0, 0, 0],
|
|
14700
|
+
...sceneProps
|
|
14701
|
+
};
|
|
14702
|
+
const target = resolveScene(scene || defaultScene);
|
|
14703
|
+
const oldbg = target.background;
|
|
14704
|
+
const oldenv = target.environment;
|
|
14705
|
+
const oldSceneProps = {
|
|
14706
|
+
// @ts-ignore
|
|
14707
|
+
backgroundBlurriness: target.backgroundBlurriness,
|
|
14708
|
+
// @ts-ignore
|
|
14709
|
+
backgroundIntensity: target.backgroundIntensity,
|
|
14710
|
+
// @ts-ignore
|
|
14711
|
+
backgroundRotation: target.backgroundRotation?.clone?.() ?? [0, 0, 0],
|
|
14712
|
+
// @ts-ignore
|
|
14713
|
+
environmentIntensity: target.environmentIntensity,
|
|
14714
|
+
// @ts-ignore
|
|
14715
|
+
environmentRotation: target.environmentRotation?.clone?.() ?? [0, 0, 0]
|
|
14716
|
+
};
|
|
14717
|
+
if (background !== "only") target.environment = texture;
|
|
14718
|
+
if (background) target.background = texture;
|
|
14719
|
+
applyProps(target, sceneProps);
|
|
14720
|
+
return () => {
|
|
14721
|
+
if (background !== "only") target.environment = oldenv;
|
|
14722
|
+
if (background) target.background = oldbg;
|
|
14723
|
+
applyProps(target, oldSceneProps);
|
|
14724
|
+
};
|
|
14725
|
+
}
|
|
14726
|
+
function EnvironmentMap({ scene, background = false, map, ...config }) {
|
|
14727
|
+
const defaultScene = useThree((state) => state.scene);
|
|
14728
|
+
React.useLayoutEffect(() => {
|
|
14729
|
+
if (map) return setEnvProps(background, scene, defaultScene, map, config);
|
|
14730
|
+
});
|
|
14731
|
+
return null;
|
|
14732
|
+
}
|
|
14733
|
+
function EnvironmentCube({
|
|
14734
|
+
background = false,
|
|
14735
|
+
scene,
|
|
14736
|
+
blur,
|
|
14737
|
+
backgroundBlurriness,
|
|
14738
|
+
backgroundIntensity,
|
|
14739
|
+
backgroundRotation,
|
|
14740
|
+
environmentIntensity,
|
|
14741
|
+
environmentRotation,
|
|
14742
|
+
...rest
|
|
14743
|
+
}) {
|
|
14744
|
+
const texture = useEnvironment(rest);
|
|
14745
|
+
const defaultScene = useThree((state) => state.scene);
|
|
14746
|
+
React.useLayoutEffect(() => {
|
|
14747
|
+
return setEnvProps(background, scene, defaultScene, texture, {
|
|
14748
|
+
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
14749
|
+
backgroundIntensity,
|
|
14750
|
+
backgroundRotation,
|
|
14751
|
+
environmentIntensity,
|
|
14752
|
+
environmentRotation
|
|
14753
|
+
});
|
|
14754
|
+
});
|
|
14755
|
+
React.useEffect(() => {
|
|
14756
|
+
return () => {
|
|
14757
|
+
texture.dispose();
|
|
14758
|
+
};
|
|
14759
|
+
}, [texture]);
|
|
14760
|
+
return null;
|
|
14761
|
+
}
|
|
14762
|
+
function EnvironmentPortal({
|
|
14763
|
+
children,
|
|
14764
|
+
near = 0.1,
|
|
14765
|
+
far = 1e3,
|
|
14766
|
+
resolution = 256,
|
|
14767
|
+
frames = 1,
|
|
14768
|
+
map,
|
|
14769
|
+
background = false,
|
|
14770
|
+
blur,
|
|
14771
|
+
backgroundBlurriness,
|
|
14772
|
+
backgroundIntensity,
|
|
14773
|
+
backgroundRotation,
|
|
14774
|
+
environmentIntensity,
|
|
14775
|
+
environmentRotation,
|
|
14776
|
+
scene,
|
|
14777
|
+
files,
|
|
14778
|
+
path,
|
|
14779
|
+
preset = void 0,
|
|
14780
|
+
extensions
|
|
14781
|
+
}) {
|
|
14782
|
+
const renderer = useThree((state) => state.renderer);
|
|
14783
|
+
const isLegacy = useThree((state) => state.isLegacy);
|
|
14784
|
+
const defaultScene = useThree((state) => state.scene);
|
|
14785
|
+
const camera = React.useRef(null);
|
|
14786
|
+
const [virtualScene] = React.useState(() => new Scene());
|
|
14787
|
+
const fbo = React.useMemo(() => {
|
|
14788
|
+
const fbo2 = isLegacy ? new WebGLCubeRenderTarget(resolution) : new CubeRenderTarget(resolution);
|
|
14789
|
+
fbo2.texture.type = HalfFloatType;
|
|
14790
|
+
return fbo2;
|
|
14791
|
+
}, [resolution, isLegacy]);
|
|
14792
|
+
React.useEffect(() => {
|
|
14793
|
+
return () => {
|
|
14794
|
+
fbo.dispose();
|
|
14795
|
+
};
|
|
14796
|
+
}, [fbo]);
|
|
14797
|
+
React.useLayoutEffect(() => {
|
|
14798
|
+
if (frames === 1) {
|
|
14799
|
+
const autoClear = renderer.autoClear;
|
|
14800
|
+
renderer.autoClear = true;
|
|
14801
|
+
camera.current.update(renderer, virtualScene);
|
|
14802
|
+
renderer.autoClear = autoClear;
|
|
14803
|
+
}
|
|
14804
|
+
return setEnvProps(background, scene, defaultScene, fbo.texture, {
|
|
14805
|
+
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
14806
|
+
backgroundIntensity,
|
|
14807
|
+
backgroundRotation,
|
|
14808
|
+
environmentIntensity,
|
|
14809
|
+
environmentRotation
|
|
14810
|
+
});
|
|
14811
|
+
}, [
|
|
14812
|
+
children,
|
|
14813
|
+
virtualScene,
|
|
14814
|
+
fbo.texture,
|
|
14815
|
+
scene,
|
|
14816
|
+
defaultScene,
|
|
14817
|
+
background,
|
|
14818
|
+
frames,
|
|
14819
|
+
renderer,
|
|
14820
|
+
blur,
|
|
14821
|
+
backgroundBlurriness,
|
|
14822
|
+
backgroundIntensity,
|
|
14823
|
+
backgroundRotation,
|
|
14824
|
+
environmentIntensity,
|
|
14825
|
+
environmentRotation
|
|
14826
|
+
]);
|
|
14827
|
+
let count = 1;
|
|
14828
|
+
useFrame(() => {
|
|
14829
|
+
if (frames === Infinity || count < frames) {
|
|
14830
|
+
const autoClear = renderer.autoClear;
|
|
14831
|
+
renderer.autoClear = true;
|
|
14832
|
+
camera.current.update(renderer, virtualScene);
|
|
14833
|
+
renderer.autoClear = autoClear;
|
|
14834
|
+
count++;
|
|
14835
|
+
}
|
|
14836
|
+
});
|
|
14837
|
+
return /* @__PURE__ */ jsx(Fragment, { children: createPortal(
|
|
14838
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
14839
|
+
children,
|
|
14840
|
+
/* @__PURE__ */ jsx("cubeCamera", { ref: camera, args: [near, far, fbo] }),
|
|
14841
|
+
files || preset ? /* @__PURE__ */ jsx(EnvironmentCube, { background: true, files, preset, path, extensions }) : map ? /* @__PURE__ */ jsx(EnvironmentMap, { background: true, map, extensions }) : null
|
|
14842
|
+
] }),
|
|
14843
|
+
virtualScene
|
|
14844
|
+
) });
|
|
14845
|
+
}
|
|
14846
|
+
function EnvironmentGround(props) {
|
|
14847
|
+
const textureDefault = useEnvironment(props);
|
|
14848
|
+
const texture = props.map || textureDefault;
|
|
14849
|
+
React.useMemo(() => extend({ GroundProjectedEnvImpl: GroundedSkybox }), []);
|
|
14850
|
+
React.useEffect(() => {
|
|
14851
|
+
return () => {
|
|
14852
|
+
textureDefault.dispose();
|
|
14853
|
+
};
|
|
14854
|
+
}, [textureDefault]);
|
|
14855
|
+
const height = props.ground?.height ?? 15;
|
|
14856
|
+
const radius = props.ground?.radius ?? 60;
|
|
14857
|
+
const scale = props.ground?.scale ?? 1e3;
|
|
14858
|
+
const args = React.useMemo(
|
|
14859
|
+
() => [texture, height, radius],
|
|
14860
|
+
[texture, height, radius]
|
|
14861
|
+
);
|
|
14862
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
14863
|
+
/* @__PURE__ */ jsx(EnvironmentMap, { ...props, map: texture }),
|
|
14864
|
+
/* @__PURE__ */ jsx("groundProjectedEnvImpl", { args, scale })
|
|
14865
|
+
] });
|
|
14866
|
+
}
|
|
14867
|
+
function EnvironmentColor({ color, scene }) {
|
|
14868
|
+
const defaultScene = useThree((state) => state.scene);
|
|
14869
|
+
React.useLayoutEffect(() => {
|
|
14870
|
+
if (color === void 0) return;
|
|
14871
|
+
const target = resolveScene(scene || defaultScene);
|
|
14872
|
+
const oldBg = target.background;
|
|
14873
|
+
target.background = new Color(color);
|
|
14874
|
+
return () => {
|
|
14875
|
+
target.background = oldBg;
|
|
14876
|
+
};
|
|
14877
|
+
});
|
|
14878
|
+
return null;
|
|
14879
|
+
}
|
|
14880
|
+
function EnvironmentDualSource(props) {
|
|
14881
|
+
const { backgroundFiles, ...envProps } = props;
|
|
14882
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
14883
|
+
/* @__PURE__ */ jsx(EnvironmentCube, { ...envProps, background: false }),
|
|
14884
|
+
/* @__PURE__ */ jsx(EnvironmentCube, { ...props, files: backgroundFiles, background: "only" })
|
|
14885
|
+
] });
|
|
14886
|
+
}
|
|
14887
|
+
function Environment(props) {
|
|
14888
|
+
if (props.color && !props.files && !props.preset && !props.map) {
|
|
14889
|
+
return /* @__PURE__ */ jsx(EnvironmentColor, { ...props });
|
|
14890
|
+
}
|
|
14891
|
+
if (props.backgroundFiles && props.backgroundFiles !== props.files) {
|
|
14892
|
+
return /* @__PURE__ */ jsx(EnvironmentDualSource, { ...props });
|
|
14893
|
+
}
|
|
14894
|
+
return props.ground ? /* @__PURE__ */ jsx(EnvironmentGround, { ...props }) : props.map ? /* @__PURE__ */ jsx(EnvironmentMap, { ...props }) : props.children ? /* @__PURE__ */ jsx(EnvironmentPortal, { ...props }) : /* @__PURE__ */ jsx(EnvironmentCube, { ...props });
|
|
14895
|
+
}
|
|
14896
|
+
|
|
14898
14897
|
function parseBackground(background) {
|
|
14899
14898
|
if (!background) return null;
|
|
14900
14899
|
if (typeof background === "object" && !background.isColor) {
|
|
@@ -15104,7 +15103,7 @@ function CanvasImpl({
|
|
|
15104
15103
|
onDropMissed: (...args) => handleDropMissed.current?.(...args),
|
|
15105
15104
|
onCreated: (state) => {
|
|
15106
15105
|
state.events.connect?.(
|
|
15107
|
-
eventSource ? isRef(eventSource) ? eventSource.current : eventSource : divRef.current
|
|
15106
|
+
eventSource ? isRef$1(eventSource) ? eventSource.current : eventSource : divRef.current
|
|
15108
15107
|
);
|
|
15109
15108
|
if (eventPrefix) {
|
|
15110
15109
|
state.setEvents({
|
|
@@ -15217,4 +15216,4 @@ function Canvas(props) {
|
|
|
15217
15216
|
|
|
15218
15217
|
extend(THREE);
|
|
15219
15218
|
|
|
15220
|
-
export { Block, Canvas, Environment, EnvironmentCube, EnvironmentMap, EnvironmentPortal, ErrorBoundary, FROM_REF, IsObject, ONCE, Portal, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, Texture, _roots, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, context, createEvents, createPointerEvents, createPortal, createRoot, createStore, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, fromRef, getInstanceProps, getPrimary, getPrimaryIds, getRootState, getUuidPrefix, hasConstructor, hasPrimary, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isFromRef, isObject3D, isOnce, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, reconciler, registerPrimary, removeInteractivity, resolve, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useEnvironment, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useRenderTarget, useStore, useTexture, useTextures, useThree, waitForPrimary };
|
|
15219
|
+
export { Block, Canvas, Environment, EnvironmentCube, EnvironmentMap, EnvironmentPortal, ErrorBoundary, FROM_REF, IsObject, ONCE, Portal, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, Texture, _roots, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, context, createEvents, createPointerEvents, createPortal, createRoot, createStore, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, fromRef, getInstanceProps, getPrimary, getPrimaryIds, getRootState, getUuidPrefix, hasConstructor, hasPrimary, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isFromRef, isObject3D, isOnce, isOrthographicCamera, isRef$1 as isRef, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, reconciler, registerPrimary, removeInteractivity, resolve, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useEnvironment, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useRenderTarget, useStore, useTexture, useTextures, useThree, waitForPrimary };
|