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