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