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