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