@react-three/fiber 10.0.0-canary.0706a92 → 10.0.0-canary.0f7fc9b
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 +1747 -1575
- package/dist/index.d.cts +82 -27
- package/dist/index.d.mts +82 -27
- package/dist/index.d.ts +82 -27
- package/dist/index.mjs +1750 -1578
- package/dist/legacy.cjs +2207 -2040
- package/dist/legacy.d.cts +81 -29
- package/dist/legacy.d.mts +81 -29
- package/dist/legacy.d.ts +81 -29
- package/dist/legacy.mjs +2209 -2042
- package/dist/webgpu/index.cjs +2195 -2246
- package/dist/webgpu/index.d.cts +120 -80
- package/dist/webgpu/index.d.mts +120 -80
- package/dist/webgpu/index.d.ts +120 -80
- package/dist/webgpu/index.mjs +2462 -2513
- 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,555 +131,229 @@ 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;
|
|
282
|
+
}
|
|
283
|
+
return data;
|
|
441
284
|
}
|
|
442
|
-
function
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
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?.();
|
|
290
|
+
}
|
|
448
291
|
}
|
|
449
|
-
function
|
|
450
|
-
|
|
451
|
-
|
|
292
|
+
function getInstanceProps(pendingProps) {
|
|
293
|
+
const props = {};
|
|
294
|
+
for (const key in pendingProps) {
|
|
295
|
+
if (!REACT_INTERNAL_PROPS.includes(key)) props[key] = pendingProps[key];
|
|
452
296
|
}
|
|
453
|
-
|
|
454
|
-
|
|
297
|
+
return props;
|
|
298
|
+
}
|
|
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;
|
|
455
315
|
}
|
|
456
|
-
return
|
|
316
|
+
return instance;
|
|
457
317
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
const useIsomorphicLayoutEffect = /* @__PURE__ */ (() => typeof window !== "undefined" && (window.document?.createElement || window.navigator?.product === "ReactNative"))() ? React__namespace.useLayoutEffect : React__namespace.useEffect;
|
|
464
|
-
function useMutableCallback(fn) {
|
|
465
|
-
const ref = React__namespace.useRef(fn);
|
|
466
|
-
useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
|
|
467
|
-
return ref;
|
|
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();
|
|
468
323
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
|
|
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
|
+
}
|
|
480
337
|
}
|
|
481
|
-
function
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
const
|
|
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
|
-
};
|
|
640
|
-
if (object) object.__r3f = instance;
|
|
641
|
-
}
|
|
642
|
-
return instance;
|
|
643
|
-
}
|
|
644
|
-
function invalidateInstance(instance) {
|
|
645
|
-
if (!instance.parent) return;
|
|
646
|
-
instance.props.onUpdate?.(instance.object);
|
|
647
|
-
const state = instance.root?.getState?.();
|
|
648
|
-
if (state && state.internal.frames === 0) state.invalidate();
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
const tempFrustum = new three.Frustum();
|
|
652
|
-
let hasWarnedWebGL = false;
|
|
653
|
-
let tslModule = null;
|
|
654
|
-
async function loadTSL() {
|
|
655
|
-
if (tslModule) return tslModule;
|
|
656
|
-
try {
|
|
657
|
-
const tsl = await import('three/tsl');
|
|
658
|
-
tslModule = { uniform: tsl.uniform, nodeObject: tsl.nodeObject };
|
|
659
|
-
return tslModule;
|
|
660
|
-
} catch {
|
|
661
|
-
return null;
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
function createOcclusionObserverNode(store, uniform) {
|
|
665
|
-
const node = new three.Node("float");
|
|
666
|
-
node.updateType = three.NodeUpdateType.OBJECT;
|
|
667
|
-
node.update = function(frame) {
|
|
668
|
-
const { internal } = store.getState();
|
|
669
|
-
const registry = internal.visibilityRegistry;
|
|
670
|
-
const cache = internal.occlusionCache;
|
|
671
|
-
for (const entry of registry.values()) {
|
|
672
|
-
const { object, handlers } = entry;
|
|
673
|
-
if (handlers.onOccluded || handlers.onVisible) {
|
|
674
|
-
const isOccluded = frame.renderer.isOccluded(object);
|
|
675
|
-
cache.set(object, isOccluded);
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
};
|
|
679
|
-
node.setup = function() {
|
|
680
|
-
return uniform(0);
|
|
681
|
-
};
|
|
682
|
-
return node;
|
|
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
|
+
}
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
node.setup = function() {
|
|
354
|
+
return uniform(0);
|
|
355
|
+
};
|
|
356
|
+
return node;
|
|
683
357
|
}
|
|
684
358
|
let occlusionSetupPromise = null;
|
|
685
359
|
function enableOcclusion(store) {
|
|
@@ -963,9 +637,9 @@ function diffProps(instance, newProps) {
|
|
|
963
637
|
const { root, key } = resolve(instance.object, prop);
|
|
964
638
|
if (root.constructor && root.constructor.length === 0) {
|
|
965
639
|
const ctor = getMemoizedPrototype(root);
|
|
966
|
-
if (!is.und(ctor)) changedProps[
|
|
640
|
+
if (!is.und(ctor)) changedProps[prop] = ctor[key];
|
|
967
641
|
} else {
|
|
968
|
-
changedProps[
|
|
642
|
+
changedProps[prop] = 0;
|
|
969
643
|
}
|
|
970
644
|
}
|
|
971
645
|
return changedProps;
|
|
@@ -1082,1333 +756,912 @@ function applyProps(object, props) {
|
|
|
1082
756
|
return object;
|
|
1083
757
|
}
|
|
1084
758
|
|
|
1085
|
-
const
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
if (!state) {
|
|
1090
|
-
state = {
|
|
1091
|
-
hovered: /* @__PURE__ */ new Map(),
|
|
1092
|
-
captured: /* @__PURE__ */ new Map(),
|
|
1093
|
-
initialClick: [0, 0],
|
|
1094
|
-
initialHits: []
|
|
1095
|
-
};
|
|
1096
|
-
internal.pointerMap.set(pointerId, state);
|
|
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;
|
|
1097
763
|
}
|
|
1098
|
-
return
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
function makeId(event) {
|
|
1104
|
-
return (event.eventObject || event.object).uuid + "/" + event.index + event.instanceId;
|
|
1105
|
-
}
|
|
1106
|
-
function releaseInternalPointerCapture(internal, obj, pointerId) {
|
|
1107
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1108
|
-
if (!pointerState) return;
|
|
1109
|
-
const captureData = pointerState.captured.get(obj);
|
|
1110
|
-
if (captureData) {
|
|
1111
|
-
pointerState.captured.delete(obj);
|
|
1112
|
-
captureData.target.releasePointerCapture(pointerId);
|
|
764
|
+
if (shownNotices.has(heading)) return;
|
|
765
|
+
shownNotices.add(heading);
|
|
766
|
+
const caller = getCallerFrame();
|
|
767
|
+
if (caller) {
|
|
768
|
+
console.log();
|
|
1113
769
|
}
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
}
|
|
1124
|
-
});
|
|
1125
|
-
if (pointerState.captured.has(object)) {
|
|
1126
|
-
releaseInternalPointerCapture(internal, object, pointerId);
|
|
1127
|
-
}
|
|
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;");
|
|
1128
779
|
}
|
|
1129
|
-
unregisterVisibility(store, object);
|
|
1130
780
|
}
|
|
1131
|
-
function
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
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+)$/);
|
|
1140
790
|
}
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
791
|
+
if (!match) return null;
|
|
792
|
+
const [, fn, url, line] = match;
|
|
793
|
+
return {
|
|
794
|
+
functionName: fn ?? "<anonymous>",
|
|
795
|
+
location: formatLocation(url, Number(line))
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
function formatLocation(url, line) {
|
|
799
|
+
const clean = url.split("?")[0];
|
|
800
|
+
const file = clean.split("/").pop() ?? clean;
|
|
801
|
+
return `${file}:${line}`;
|
|
802
|
+
}
|
|
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;
|
|
1149
806
|
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
const
|
|
1175
|
-
const
|
|
1176
|
-
if (
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
const bPriority = bState?.events?.priority ?? 1;
|
|
1187
|
-
return bPriority - aPriority || a.distance - b.distance;
|
|
1188
|
-
}).filter((item) => {
|
|
1189
|
-
const id = makeId(item);
|
|
1190
|
-
if (duplicates.has(id)) return false;
|
|
1191
|
-
duplicates.add(id);
|
|
1192
|
-
return true;
|
|
1193
|
-
});
|
|
1194
|
-
if (state.events.filter) hits = state.events.filter(hits, state);
|
|
1195
|
-
for (const hit of hits) {
|
|
1196
|
-
let eventObject = hit.object;
|
|
1197
|
-
while (eventObject) {
|
|
1198
|
-
if (eventObject.__r3f?.eventCount) {
|
|
1199
|
-
intersections.push({ ...hit, eventObject });
|
|
1200
|
-
}
|
|
1201
|
-
eventObject = eventObject.parent;
|
|
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;");
|
|
813
|
+
}
|
|
814
|
+
}
|
|
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 };
|
|
1202
843
|
}
|
|
1203
844
|
}
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
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
|
+
);
|
|
1210
898
|
}
|
|
1211
|
-
}
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
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
|
+
}
|
|
1240
934
|
}
|
|
1241
|
-
|
|
1242
|
-
const raycastEvent = {
|
|
1243
|
-
...hit,
|
|
1244
|
-
...extractEventProps,
|
|
1245
|
-
pointer,
|
|
1246
|
-
intersections,
|
|
1247
|
-
stopped: localState.stopped,
|
|
1248
|
-
delta,
|
|
1249
|
-
unprojectedPoint,
|
|
1250
|
-
ray: raycaster.ray,
|
|
1251
|
-
camera,
|
|
1252
|
-
pointerId: eventPointerId,
|
|
1253
|
-
// Hijack stopPropagation, which just sets a flag
|
|
1254
|
-
stopPropagation() {
|
|
1255
|
-
const pointerState = eventPointerId !== void 0 ? internal.pointerMap.get(eventPointerId) : void 0;
|
|
1256
|
-
if (
|
|
1257
|
-
// ...if this pointer hasn't been captured
|
|
1258
|
-
!pointerState?.captured.size || // ... or if the hit object is capturing the pointer
|
|
1259
|
-
pointerState.captured.has(hit.eventObject)
|
|
1260
|
-
) {
|
|
1261
|
-
raycastEvent.stopped = localState.stopped = true;
|
|
1262
|
-
if (pointerState?.hovered.size && Array.from(pointerState.hovered.values()).find((i) => i.eventObject === hit.eventObject)) {
|
|
1263
|
-
const higher = intersections.slice(0, intersections.indexOf(hit));
|
|
1264
|
-
cancelPointer([...higher, hit], eventPointerId);
|
|
1265
|
-
}
|
|
1266
|
-
}
|
|
1267
|
-
},
|
|
1268
|
-
// there should be a distinction between target and currentTarget
|
|
1269
|
-
target: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
1270
|
-
currentTarget: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
1271
|
-
nativeEvent: event
|
|
1272
|
-
};
|
|
1273
|
-
callback(raycastEvent);
|
|
1274
|
-
if (localState.stopped === true) break;
|
|
935
|
+
return;
|
|
1275
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
|
+
}
|
|
1007
|
+
};
|
|
1008
|
+
},
|
|
1009
|
+
// Renderer Storage (single source of truth)
|
|
1010
|
+
actualRenderer: null,
|
|
1011
|
+
// Scheduler for useFrameNext (initialized in renderer.tsx)
|
|
1012
|
+
scheduler: null
|
|
1276
1013
|
}
|
|
1277
|
-
}
|
|
1278
|
-
return
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
if (instance?.eventCount) {
|
|
1293
|
-
const handlers = instance.handlers;
|
|
1294
|
-
const data = { ...hoveredObj, intersections };
|
|
1295
|
-
handlers.onPointerOut?.(data);
|
|
1296
|
-
handlers.onPointerLeave?.(data);
|
|
1297
|
-
handlers.onDragOverLeave?.(data);
|
|
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
|
+
});
|
|
1298
1029
|
}
|
|
1299
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
|
+
}
|
|
1300
1058
|
}
|
|
1301
|
-
}
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
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
|
+
const resizeTarget = canvasTarget ?? actualRenderer;
|
|
1072
|
+
if (viewport.dpr > 0) resizeTarget.setPixelRatio(viewport.dpr);
|
|
1073
|
+
resizeTarget.setSize(size.width, size.height, false);
|
|
1074
|
+
internal.canvasTargetSizeDirty = true;
|
|
1306
1075
|
}
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1076
|
+
if (camera !== oldCamera) {
|
|
1077
|
+
oldCamera = camera;
|
|
1078
|
+
const { rootScene } = rootStore.getState();
|
|
1079
|
+
if (camera && rootScene && !camera.parent) {
|
|
1080
|
+
rootScene.add(camera);
|
|
1081
|
+
}
|
|
1082
|
+
set((state2) => ({ viewport: { ...state2.viewport, ...state2.viewport.getCurrentViewport(camera) } }));
|
|
1083
|
+
const currentState = rootStore.getState();
|
|
1084
|
+
if (currentState.autoUpdateFrustum && camera) {
|
|
1085
|
+
updateFrustum(camera, currentState.frustum);
|
|
1086
|
+
}
|
|
1312
1087
|
}
|
|
1313
|
-
}
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1088
|
+
});
|
|
1089
|
+
rootStore.subscribe((state2) => invalidate(state2));
|
|
1090
|
+
return rootStore;
|
|
1091
|
+
};
|
|
1092
|
+
|
|
1093
|
+
const memoizedLoaders = /* @__PURE__ */ new WeakMap();
|
|
1094
|
+
const isConstructor$1 = (value) => typeof value === "function" && value?.prototype?.constructor === value;
|
|
1095
|
+
function getLoader$1(Proto) {
|
|
1096
|
+
if (isConstructor$1(Proto)) {
|
|
1097
|
+
let loader = memoizedLoaders.get(Proto);
|
|
1098
|
+
if (!loader) {
|
|
1099
|
+
loader = new Proto();
|
|
1100
|
+
memoizedLoaders.set(Proto, loader);
|
|
1318
1101
|
}
|
|
1102
|
+
return loader;
|
|
1319
1103
|
}
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
handlers.onPointerLeave?.(data);
|
|
1332
|
-
}
|
|
1333
|
-
}
|
|
1334
|
-
internal.pointerMap.delete(pointerId);
|
|
1104
|
+
return Proto;
|
|
1105
|
+
}
|
|
1106
|
+
function loadingFn(extensions, onProgress) {
|
|
1107
|
+
return function(Proto, input) {
|
|
1108
|
+
const loader = getLoader$1(Proto);
|
|
1109
|
+
if (extensions) extensions(loader);
|
|
1110
|
+
if ("loadAsync" in loader && typeof loader.loadAsync === "function") {
|
|
1111
|
+
return loader.loadAsync(input, onProgress).then((data) => {
|
|
1112
|
+
if (isObject3D(data?.scene)) Object.assign(data, buildGraph(data.scene));
|
|
1113
|
+
return data;
|
|
1114
|
+
});
|
|
1335
1115
|
}
|
|
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
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1116
|
+
return new Promise(
|
|
1117
|
+
(res, reject) => loader.load(
|
|
1118
|
+
input,
|
|
1119
|
+
(data) => {
|
|
1120
|
+
if (isObject3D(data?.scene)) Object.assign(data, buildGraph(data.scene));
|
|
1121
|
+
res(data);
|
|
1122
|
+
},
|
|
1123
|
+
onProgress,
|
|
1124
|
+
(error) => reject(new Error(`Could not load ${input}: ${error?.message}`))
|
|
1125
|
+
)
|
|
1126
|
+
);
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
function useLoader(loader, input, extensions, onProgress, cacheKey) {
|
|
1130
|
+
const inputs = Array.isArray(input) ? input : [input];
|
|
1131
|
+
const cacheKeys = Array.isArray(cacheKey ?? input) ? cacheKey ?? input : [cacheKey ?? input];
|
|
1132
|
+
const fn = loadingFn(extensions, onProgress);
|
|
1133
|
+
const results = cacheKeys.map(
|
|
1134
|
+
(key, index) => suspendReact.suspend(() => fn(loader, inputs[index]), [loader, key], { equal: is.equ })
|
|
1135
|
+
);
|
|
1136
|
+
const stableRef = React.useRef(null);
|
|
1137
|
+
const previous = stableRef.current;
|
|
1138
|
+
const stable = previous !== null && previous.length === results.length && previous.every((value, i) => value === results[i]) ? previous : results;
|
|
1139
|
+
stableRef.current = stable;
|
|
1140
|
+
return Array.isArray(input) ? stable : stable[0];
|
|
1141
|
+
}
|
|
1142
|
+
useLoader.preload = function(loader, input, extensions, onProgress, cacheKey) {
|
|
1143
|
+
const inputs = Array.isArray(input) ? input : [input];
|
|
1144
|
+
const cacheKeys = Array.isArray(cacheKey ?? input) ? cacheKey ?? input : [cacheKey ?? input];
|
|
1145
|
+
cacheKeys.forEach(
|
|
1146
|
+
(key, index) => suspendReact.preload(() => loadingFn(extensions, onProgress)(loader, inputs[index]), [loader, key])
|
|
1147
|
+
);
|
|
1148
|
+
};
|
|
1149
|
+
useLoader.clear = function(loader, input, cacheKey) {
|
|
1150
|
+
const cacheKeys = Array.isArray(cacheKey ?? input) ? cacheKey ?? input : [cacheKey ?? input];
|
|
1151
|
+
cacheKeys.forEach((key) => suspendReact.clear([loader, key]));
|
|
1152
|
+
};
|
|
1153
|
+
useLoader.loader = getLoader$1;
|
|
1154
|
+
|
|
1155
|
+
function useFrame(callback, priorityOrOptions) {
|
|
1156
|
+
const store = React__namespace.useContext(context);
|
|
1157
|
+
const isInsideCanvas = store !== null;
|
|
1158
|
+
const scheduler$1 = scheduler.getScheduler();
|
|
1159
|
+
const optionsKey = typeof priorityOrOptions === "number" ? `p:${priorityOrOptions}` : priorityOrOptions ? JSON.stringify({
|
|
1160
|
+
id: priorityOrOptions.id,
|
|
1161
|
+
phase: priorityOrOptions.phase,
|
|
1162
|
+
priority: priorityOrOptions.priority,
|
|
1163
|
+
fps: priorityOrOptions.fps,
|
|
1164
|
+
drop: priorityOrOptions.drop,
|
|
1165
|
+
enabled: priorityOrOptions.enabled,
|
|
1166
|
+
before: priorityOrOptions.before,
|
|
1167
|
+
after: priorityOrOptions.after
|
|
1168
|
+
}) : "";
|
|
1169
|
+
const options = React__namespace.useMemo(() => {
|
|
1170
|
+
return typeof priorityOrOptions === "number" ? { priority: priorityOrOptions } : priorityOrOptions ?? {};
|
|
1171
|
+
}, [optionsKey]);
|
|
1172
|
+
const reactId = React__namespace.useId();
|
|
1173
|
+
const id = options.id ?? reactId;
|
|
1174
|
+
const callbackRef = useMutableCallback(callback);
|
|
1175
|
+
const isLegacyPriority = typeof priorityOrOptions === "number" && priorityOrOptions > 0;
|
|
1176
|
+
useIsomorphicLayoutEffect(() => {
|
|
1177
|
+
if (!callback) return;
|
|
1178
|
+
if (isInsideCanvas) {
|
|
1394
1179
|
const state = store.getState();
|
|
1395
|
-
const
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
const isPointerDown = name === "onPointerDown";
|
|
1404
|
-
const isPointerUp = name === "onPointerUp";
|
|
1405
|
-
const isWheel = name === "onWheel";
|
|
1406
|
-
const canDeferRaycasts = events.frameTimedRaycasts && state.frameloop === "always";
|
|
1407
|
-
if (isPointerMove && canDeferRaycasts) {
|
|
1408
|
-
events.compute?.(event, state);
|
|
1409
|
-
internal.pointerDirty.set(pointerId, event);
|
|
1410
|
-
return;
|
|
1411
|
-
}
|
|
1412
|
-
if (isWheel && canDeferRaycasts && !events.alwaysFireOnScroll) {
|
|
1413
|
-
events.compute?.(event, state);
|
|
1414
|
-
internal.pointerDirty.set(pointerId, event);
|
|
1415
|
-
return;
|
|
1416
|
-
}
|
|
1417
|
-
if ((isClickEvent || isPointerDown || isPointerUp) && internal.pointerDirty.has(pointerId)) {
|
|
1418
|
-
const deferredEvent = internal.pointerDirty.get(pointerId);
|
|
1419
|
-
internal.pointerDirty.delete(pointerId);
|
|
1420
|
-
processDeferredPointer(deferredEvent, pointerId);
|
|
1421
|
-
}
|
|
1422
|
-
const filter = isPointerMove || isDragOver || isDrop ? filterPointerEvents : void 0;
|
|
1423
|
-
const hits = intersect(event, filter);
|
|
1424
|
-
const delta = isClickEvent ? calculateDistance(event, pointerId) : 0;
|
|
1425
|
-
if (isPointerDown) {
|
|
1426
|
-
const pointerState2 = getPointerState(internal, pointerId);
|
|
1427
|
-
pointerState2.initialClick = [event.offsetX, event.offsetY];
|
|
1428
|
-
pointerState2.initialHits = hits.map((hit) => hit.eventObject);
|
|
1429
|
-
}
|
|
1430
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1431
|
-
const initialHits = pointerState?.initialHits ?? [];
|
|
1432
|
-
if (isClickEvent && !hits.length) {
|
|
1433
|
-
if (delta <= 2) {
|
|
1434
|
-
pointerMissed(event, internal.interaction);
|
|
1435
|
-
if (onPointerMissed) onPointerMissed(event);
|
|
1180
|
+
const rootId = state.internal.rootId;
|
|
1181
|
+
if (isLegacyPriority) {
|
|
1182
|
+
state.internal.priority++;
|
|
1183
|
+
let parentRoot = state.previousRoot;
|
|
1184
|
+
while (parentRoot) {
|
|
1185
|
+
const parentState = parentRoot.getState();
|
|
1186
|
+
if (parentState?.internal) parentState.internal.priority++;
|
|
1187
|
+
parentRoot = parentState?.previousRoot;
|
|
1436
1188
|
}
|
|
1189
|
+
notifyDepreciated({
|
|
1190
|
+
heading: "useFrame with numeric priority is deprecated",
|
|
1191
|
+
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 })',
|
|
1192
|
+
link: "https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe"
|
|
1193
|
+
});
|
|
1437
1194
|
}
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
}
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
}
|
|
1466
|
-
}
|
|
1467
|
-
handlers.onPointerMove?.(data);
|
|
1468
|
-
} else if (isDragOver) {
|
|
1469
|
-
const id = makeId(data);
|
|
1470
|
-
const pointerState2 = getPointerState(internal, pointerId);
|
|
1471
|
-
const hoveredItem = pointerState2.hovered.get(id);
|
|
1472
|
-
if (!hoveredItem) {
|
|
1473
|
-
pointerState2.hovered.set(id, data);
|
|
1474
|
-
handlers.onDragOverEnter?.(data);
|
|
1475
|
-
} else if (hoveredItem.stopped) {
|
|
1476
|
-
data.stopPropagation();
|
|
1477
|
-
}
|
|
1478
|
-
handlers.onDragOver?.(data);
|
|
1479
|
-
} else if (isDrop) {
|
|
1480
|
-
handlers.onDrop?.(data);
|
|
1481
|
-
} else {
|
|
1482
|
-
const handler = handlers[name];
|
|
1483
|
-
if (handler) {
|
|
1484
|
-
if (!isClickEvent || initialHits.includes(eventObject)) {
|
|
1485
|
-
pointerMissed(
|
|
1486
|
-
event,
|
|
1487
|
-
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
1488
|
-
);
|
|
1489
|
-
handler(data);
|
|
1490
|
-
}
|
|
1491
|
-
} else {
|
|
1492
|
-
if (isClickEvent && initialHits.includes(eventObject)) {
|
|
1493
|
-
pointerMissed(
|
|
1494
|
-
event,
|
|
1495
|
-
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
1496
|
-
);
|
|
1195
|
+
const wrappedCallback = (frameState, delta) => {
|
|
1196
|
+
const localState = store.getState();
|
|
1197
|
+
const mergedState = {
|
|
1198
|
+
...localState,
|
|
1199
|
+
time: frameState.time,
|
|
1200
|
+
delta: frameState.delta,
|
|
1201
|
+
elapsed: frameState.elapsed,
|
|
1202
|
+
frame: frameState.frame
|
|
1203
|
+
};
|
|
1204
|
+
callbackRef.current?.(mergedState, delta);
|
|
1205
|
+
};
|
|
1206
|
+
const unregister = scheduler$1.register(wrappedCallback, {
|
|
1207
|
+
id,
|
|
1208
|
+
rootId,
|
|
1209
|
+
...options
|
|
1210
|
+
});
|
|
1211
|
+
return () => {
|
|
1212
|
+
unregister();
|
|
1213
|
+
if (isLegacyPriority) {
|
|
1214
|
+
const currentState = store.getState();
|
|
1215
|
+
if (currentState.internal) {
|
|
1216
|
+
currentState.internal.priority--;
|
|
1217
|
+
let parentRoot = currentState.previousRoot;
|
|
1218
|
+
while (parentRoot) {
|
|
1219
|
+
const parentState = parentRoot.getState();
|
|
1220
|
+
if (parentState?.internal) parentState.internal.priority--;
|
|
1221
|
+
parentRoot = parentState?.previousRoot;
|
|
1497
1222
|
}
|
|
1498
1223
|
}
|
|
1499
1224
|
}
|
|
1500
|
-
}
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
internal.pointerDirty.clear();
|
|
1511
|
-
}
|
|
1512
|
-
return { handlePointer, flushDeferredPointers, processDeferredPointer };
|
|
1513
|
-
}
|
|
1514
|
-
const DOM_EVENTS = {
|
|
1515
|
-
onClick: ["click", false],
|
|
1516
|
-
onContextMenu: ["contextmenu", false],
|
|
1517
|
-
onDoubleClick: ["dblclick", false],
|
|
1518
|
-
onDragEnter: ["dragenter", false],
|
|
1519
|
-
onDragLeave: ["dragleave", false],
|
|
1520
|
-
onDragOver: ["dragover", false],
|
|
1521
|
-
onDrop: ["drop", false],
|
|
1522
|
-
onWheel: ["wheel", true],
|
|
1523
|
-
onPointerDown: ["pointerdown", true],
|
|
1524
|
-
onPointerUp: ["pointerup", true],
|
|
1525
|
-
onPointerLeave: ["pointerleave", true],
|
|
1526
|
-
onPointerMove: ["pointermove", true],
|
|
1527
|
-
onPointerCancel: ["pointercancel", true],
|
|
1528
|
-
onLostPointerCapture: ["lostpointercapture", true]
|
|
1529
|
-
};
|
|
1530
|
-
function createPointerEvents(store) {
|
|
1531
|
-
const { handlePointer, flushDeferredPointers, processDeferredPointer } = createEvents(store);
|
|
1532
|
-
let nextXRPointerId = XR_POINTER_ID_START;
|
|
1533
|
-
const xrPointers = /* @__PURE__ */ new Map();
|
|
1534
|
-
return {
|
|
1535
|
-
priority: 1,
|
|
1536
|
-
enabled: true,
|
|
1537
|
-
frameTimedRaycasts: true,
|
|
1538
|
-
alwaysFireOnScroll: true,
|
|
1539
|
-
updateOnFrame: false,
|
|
1540
|
-
compute(event, state) {
|
|
1541
|
-
state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
|
|
1542
|
-
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
1543
|
-
},
|
|
1544
|
-
connected: void 0,
|
|
1545
|
-
handlers: Object.keys(DOM_EVENTS).reduce(
|
|
1546
|
-
(acc, key) => ({ ...acc, [key]: handlePointer(key) }),
|
|
1547
|
-
{}
|
|
1548
|
-
),
|
|
1549
|
-
update: (pointerId) => {
|
|
1550
|
-
const { events, internal } = store.getState();
|
|
1551
|
-
if (!events.handlers) return;
|
|
1552
|
-
if (pointerId !== void 0) {
|
|
1553
|
-
const event = internal.pointerDirty.get(pointerId);
|
|
1554
|
-
if (event) {
|
|
1555
|
-
internal.pointerDirty.delete(pointerId);
|
|
1556
|
-
processDeferredPointer(event, pointerId);
|
|
1557
|
-
} else if (internal.lastEvent?.current) {
|
|
1558
|
-
processDeferredPointer(internal.lastEvent.current, pointerId);
|
|
1559
|
-
}
|
|
1560
|
-
} else {
|
|
1561
|
-
flushDeferredPointers();
|
|
1562
|
-
if (internal.lastEvent?.current) {
|
|
1563
|
-
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
1564
|
-
}
|
|
1565
|
-
}
|
|
1566
|
-
},
|
|
1567
|
-
flush: () => {
|
|
1568
|
-
const { events, internal } = store.getState();
|
|
1569
|
-
flushDeferredPointers();
|
|
1570
|
-
if (events.updateOnFrame && internal.lastEvent?.current && events.handlers) {
|
|
1571
|
-
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
1572
|
-
}
|
|
1573
|
-
},
|
|
1574
|
-
connect: (target) => {
|
|
1575
|
-
if (!target) return;
|
|
1576
|
-
const { set, events } = store.getState();
|
|
1577
|
-
events.disconnect?.();
|
|
1578
|
-
set((state) => ({ events: { ...state.events, connected: target } }));
|
|
1579
|
-
if (events.handlers) {
|
|
1580
|
-
for (const name in events.handlers) {
|
|
1581
|
-
const event = events.handlers[name];
|
|
1582
|
-
const [eventName, passive] = DOM_EVENTS[name];
|
|
1583
|
-
target.addEventListener(eventName, event, { passive });
|
|
1584
|
-
}
|
|
1585
|
-
}
|
|
1586
|
-
},
|
|
1587
|
-
disconnect: () => {
|
|
1588
|
-
const { set, events } = store.getState();
|
|
1589
|
-
if (events.connected) {
|
|
1590
|
-
if (events.handlers) {
|
|
1591
|
-
for (const name in events.handlers) {
|
|
1592
|
-
const event = events.handlers[name];
|
|
1593
|
-
const [eventName] = DOM_EVENTS[name];
|
|
1594
|
-
events.connected.removeEventListener(eventName, event);
|
|
1595
|
-
}
|
|
1596
|
-
}
|
|
1597
|
-
set((state) => ({ events: { ...state.events, connected: void 0 } }));
|
|
1598
|
-
}
|
|
1599
|
-
},
|
|
1600
|
-
// PREVIEW (A8): the XR pointer registration API may change before stable.
|
|
1601
|
-
registerPointer: (config) => {
|
|
1602
|
-
const pointerId = nextXRPointerId++;
|
|
1603
|
-
xrPointers.set(pointerId, config);
|
|
1604
|
-
const { internal } = store.getState();
|
|
1605
|
-
getPointerState(internal, pointerId);
|
|
1606
|
-
return pointerId;
|
|
1607
|
-
},
|
|
1608
|
-
unregisterPointer: (pointerId) => {
|
|
1609
|
-
xrPointers.delete(pointerId);
|
|
1610
|
-
const { internal } = store.getState();
|
|
1611
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1612
|
-
if (pointerState) {
|
|
1613
|
-
for (const [, hoveredObj] of pointerState.hovered) {
|
|
1614
|
-
const eventObject = hoveredObj.eventObject;
|
|
1615
|
-
const instance = eventObject.__r3f;
|
|
1616
|
-
if (instance?.eventCount) {
|
|
1617
|
-
const handlers = instance.handlers;
|
|
1618
|
-
const data = { ...hoveredObj, intersections: [] };
|
|
1619
|
-
handlers.onPointerOut?.(data);
|
|
1620
|
-
handlers.onPointerLeave?.(data);
|
|
1621
|
-
}
|
|
1622
|
-
}
|
|
1623
|
-
internal.pointerMap.delete(pointerId);
|
|
1624
|
-
}
|
|
1625
|
-
internal.pointerDirty.delete(pointerId);
|
|
1225
|
+
};
|
|
1226
|
+
} else {
|
|
1227
|
+
return scheduler$1.register(
|
|
1228
|
+
(state, delta) => {
|
|
1229
|
+
const frameState = state;
|
|
1230
|
+
if (!frameState.renderer) return;
|
|
1231
|
+
callbackRef.current?.(frameState, delta);
|
|
1232
|
+
},
|
|
1233
|
+
{ id, ...options }
|
|
1234
|
+
);
|
|
1626
1235
|
}
|
|
1627
|
-
};
|
|
1236
|
+
}, [store, scheduler$1, id, optionsKey, isLegacyPriority, isInsideCanvas]);
|
|
1237
|
+
const isPaused = React__namespace.useSyncExternalStore(
|
|
1238
|
+
// Subscribe function
|
|
1239
|
+
React__namespace.useCallback(
|
|
1240
|
+
(onStoreChange) => {
|
|
1241
|
+
return scheduler.getScheduler().subscribeJobState(id, onStoreChange);
|
|
1242
|
+
},
|
|
1243
|
+
[id]
|
|
1244
|
+
),
|
|
1245
|
+
// getSnapshot function
|
|
1246
|
+
React__namespace.useCallback(() => scheduler.getScheduler().isJobPaused(id), [id]),
|
|
1247
|
+
// getServerSnapshot function (SSR)
|
|
1248
|
+
React__namespace.useCallback(() => false, [])
|
|
1249
|
+
);
|
|
1250
|
+
const controls = React__namespace.useMemo(() => {
|
|
1251
|
+
const scheduler2 = scheduler.getScheduler();
|
|
1252
|
+
return {
|
|
1253
|
+
/** The job's unique ID */
|
|
1254
|
+
id,
|
|
1255
|
+
/**
|
|
1256
|
+
* Access to the global scheduler for frame loop control.
|
|
1257
|
+
* Use for controlling the entire frame loop, adding phases, etc.
|
|
1258
|
+
*/
|
|
1259
|
+
scheduler: scheduler2,
|
|
1260
|
+
/**
|
|
1261
|
+
* Manually step this job only.
|
|
1262
|
+
* Bypasses FPS limiting - always runs.
|
|
1263
|
+
* @param timestamp Optional timestamp (defaults to performance.now())
|
|
1264
|
+
*/
|
|
1265
|
+
step: (timestamp) => {
|
|
1266
|
+
scheduler.getScheduler().stepJob(id, timestamp);
|
|
1267
|
+
},
|
|
1268
|
+
/**
|
|
1269
|
+
* Manually step ALL jobs in the scheduler.
|
|
1270
|
+
* Useful for frameloop='never' mode.
|
|
1271
|
+
* @param timestamp Optional timestamp (defaults to performance.now())
|
|
1272
|
+
*/
|
|
1273
|
+
stepAll: (timestamp) => {
|
|
1274
|
+
scheduler.getScheduler().step(timestamp);
|
|
1275
|
+
},
|
|
1276
|
+
/**
|
|
1277
|
+
* Pause this job (set enabled=false).
|
|
1278
|
+
* Job remains registered but won't run.
|
|
1279
|
+
*/
|
|
1280
|
+
pause: () => {
|
|
1281
|
+
scheduler.getScheduler().pauseJob(id);
|
|
1282
|
+
},
|
|
1283
|
+
/**
|
|
1284
|
+
* Resume this job (set enabled=true).
|
|
1285
|
+
*/
|
|
1286
|
+
resume: () => {
|
|
1287
|
+
scheduler.getScheduler().resumeJob(id);
|
|
1288
|
+
},
|
|
1289
|
+
/**
|
|
1290
|
+
* Reactive paused state - automatically updates when pause/resume is called.
|
|
1291
|
+
* No need for forceUpdate() in your components.
|
|
1292
|
+
*/
|
|
1293
|
+
isPaused
|
|
1294
|
+
};
|
|
1295
|
+
}, [id, isPaused]);
|
|
1296
|
+
return controls;
|
|
1628
1297
|
}
|
|
1629
1298
|
|
|
1630
|
-
const
|
|
1631
|
-
function
|
|
1632
|
-
if (typeof
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
if (shownNotices.has(heading)) return;
|
|
1636
|
-
shownNotices.add(heading);
|
|
1637
|
-
const caller = getCallerFrame();
|
|
1638
|
-
if (caller) {
|
|
1639
|
-
console.log();
|
|
1640
|
-
}
|
|
1641
|
-
const boxStyle = "background: #ff9800; color: #1a1a1a; padding: 8px 12px; border-radius: 4px; font-weight: 500;";
|
|
1642
|
-
if (caller) {
|
|
1643
|
-
console.log(`%c\u26A0\uFE0F ${heading}`, boxStyle);
|
|
1644
|
-
}
|
|
1645
|
-
if (body || link) {
|
|
1646
|
-
let message = "";
|
|
1647
|
-
if (body) message += body;
|
|
1648
|
-
if (link) message += (body ? "\n\n" : "") + `More info: ${link}`;
|
|
1649
|
-
console.warn(`%c${message}`, "font-weight: bold;");
|
|
1650
|
-
}
|
|
1299
|
+
const IsObject = (url) => url === Object(url) && !Array.isArray(url) && typeof url !== "function";
|
|
1300
|
+
function getUrls(input) {
|
|
1301
|
+
if (typeof input === "string") return [input];
|
|
1302
|
+
if (Array.isArray(input)) return input;
|
|
1303
|
+
return Object.values(input);
|
|
1651
1304
|
}
|
|
1652
|
-
function
|
|
1653
|
-
|
|
1654
|
-
if (
|
|
1655
|
-
|
|
1656
|
-
const frame = lines[depth];
|
|
1657
|
-
if (!frame) return null;
|
|
1658
|
-
let match = frame.match(/^\s*at (?:(.+?) )?\(?(.+?):(\d+):(\d+)\)?$/);
|
|
1659
|
-
if (!match) {
|
|
1660
|
-
match = frame.match(/^(?:(.+?)@)?(.+?):(\d+):(\d+)$/);
|
|
1661
|
-
}
|
|
1662
|
-
if (!match) return null;
|
|
1663
|
-
const [, fn, url, line] = match;
|
|
1664
|
-
return {
|
|
1665
|
-
functionName: fn ?? "<anonymous>",
|
|
1666
|
-
location: formatLocation(url, Number(line))
|
|
1667
|
-
};
|
|
1305
|
+
function inputSignature(input) {
|
|
1306
|
+
if (typeof input === "string") return input;
|
|
1307
|
+
if (Array.isArray(input)) return input.join("\0");
|
|
1308
|
+
return Object.keys(input).sort().map((key) => `${key}\0${input[key]}`).join("");
|
|
1668
1309
|
}
|
|
1669
|
-
function
|
|
1670
|
-
|
|
1671
|
-
const file = clean.split("/").pop() ?? clean;
|
|
1672
|
-
return `${file}:${line}`;
|
|
1310
|
+
function allUrlsCached(urls, textureCache) {
|
|
1311
|
+
return urls.every((url) => textureCache.has(url));
|
|
1673
1312
|
}
|
|
1674
|
-
function
|
|
1675
|
-
if (typeof
|
|
1676
|
-
return;
|
|
1677
|
-
}
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1313
|
+
function buildFromCache(input, textureCache) {
|
|
1314
|
+
if (typeof input === "string") {
|
|
1315
|
+
return textureCache.get(input);
|
|
1316
|
+
} else if (Array.isArray(input)) {
|
|
1317
|
+
return input.map((url) => textureCache.get(url));
|
|
1318
|
+
} else {
|
|
1319
|
+
const result = {};
|
|
1320
|
+
const objInput = input;
|
|
1321
|
+
for (const key in objInput) {
|
|
1322
|
+
result[key] = textureCache.get(objInput[key]);
|
|
1323
|
+
}
|
|
1324
|
+
return result;
|
|
1684
1325
|
}
|
|
1685
1326
|
}
|
|
1686
|
-
|
|
1687
|
-
const
|
|
1688
|
-
const
|
|
1689
|
-
function
|
|
1690
|
-
|
|
1691
|
-
const
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
const
|
|
1696
|
-
const
|
|
1697
|
-
const
|
|
1698
|
-
|
|
1699
|
-
const
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1327
|
+
function useTexture(input, optionsOrOnLoad) {
|
|
1328
|
+
const renderer = useThree((state) => state.internal.actualRenderer);
|
|
1329
|
+
const store = useStore();
|
|
1330
|
+
const options = typeof optionsOrOnLoad === "function" ? { onLoad: optionsOrOnLoad } : optionsOrOnLoad ?? {};
|
|
1331
|
+
const { onLoad, cache = true } = options;
|
|
1332
|
+
const onLoadRef = React.useRef(onLoad);
|
|
1333
|
+
onLoadRef.current = onLoad;
|
|
1334
|
+
const onLoadCalledForRef = React.useRef(null);
|
|
1335
|
+
const inputKey = React.useMemo(() => inputSignature(input), [input]);
|
|
1336
|
+
const stableInput = React.useMemo(() => input, [inputKey]);
|
|
1337
|
+
const urls = React.useMemo(() => getUrls(stableInput), [stableInput]);
|
|
1338
|
+
const cachedResult = React.useMemo(() => {
|
|
1339
|
+
if (!cache) return null;
|
|
1340
|
+
const textures = store.getState().textures;
|
|
1341
|
+
if (!allUrlsCached(urls, textures)) return null;
|
|
1342
|
+
return buildFromCache(stableInput, textures);
|
|
1343
|
+
}, [cache, urls, stableInput, store]);
|
|
1344
|
+
const loadedTextures = useLoader(
|
|
1345
|
+
three.TextureLoader,
|
|
1346
|
+
IsObject(stableInput) ? Object.values(stableInput) : stableInput
|
|
1347
|
+
);
|
|
1348
|
+
React.useLayoutEffect(() => {
|
|
1349
|
+
if (cachedResult) return;
|
|
1350
|
+
if (onLoadCalledForRef.current === inputKey) return;
|
|
1351
|
+
onLoadCalledForRef.current = inputKey;
|
|
1352
|
+
onLoadRef.current?.(loadedTextures);
|
|
1353
|
+
}, [cachedResult, loadedTextures, inputKey]);
|
|
1354
|
+
React.useEffect(() => {
|
|
1355
|
+
if (cachedResult) return;
|
|
1356
|
+
if ("initTexture" in renderer) {
|
|
1357
|
+
let textureArray = [];
|
|
1358
|
+
if (Array.isArray(loadedTextures)) {
|
|
1359
|
+
textureArray = loadedTextures;
|
|
1360
|
+
} else if (loadedTextures instanceof three.Texture) {
|
|
1361
|
+
textureArray = [loadedTextures];
|
|
1362
|
+
} else if (IsObject(loadedTextures)) {
|
|
1363
|
+
textureArray = Object.values(loadedTextures);
|
|
1715
1364
|
}
|
|
1365
|
+
textureArray.forEach((texture) => {
|
|
1366
|
+
if (texture instanceof three.Texture) {
|
|
1367
|
+
renderer.initTexture(texture);
|
|
1368
|
+
}
|
|
1369
|
+
});
|
|
1716
1370
|
}
|
|
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
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
onDropMissed: void 0,
|
|
1757
|
-
performance: {
|
|
1758
|
-
current: 1,
|
|
1759
|
-
min: 0.5,
|
|
1760
|
-
max: 1,
|
|
1761
|
-
debounce: 200,
|
|
1762
|
-
regress: () => {
|
|
1763
|
-
const state2 = get();
|
|
1764
|
-
if (performanceTimeout) clearTimeout(performanceTimeout);
|
|
1765
|
-
if (state2.performance.current !== state2.performance.min) setPerformanceCurrent(state2.performance.min);
|
|
1766
|
-
performanceTimeout = setTimeout(
|
|
1767
|
-
() => setPerformanceCurrent(get().performance.max),
|
|
1768
|
-
state2.performance.debounce
|
|
1769
|
-
);
|
|
1371
|
+
}, [renderer, loadedTextures, cachedResult]);
|
|
1372
|
+
const mappedTextures = React.useMemo(() => {
|
|
1373
|
+
if (cachedResult) return cachedResult;
|
|
1374
|
+
if (IsObject(stableInput)) {
|
|
1375
|
+
const keyed = {};
|
|
1376
|
+
const textureArray = loadedTextures;
|
|
1377
|
+
let i = 0;
|
|
1378
|
+
for (const key in stableInput) keyed[key] = textureArray[i++];
|
|
1379
|
+
return keyed;
|
|
1380
|
+
} else {
|
|
1381
|
+
return loadedTextures;
|
|
1382
|
+
}
|
|
1383
|
+
}, [stableInput, loadedTextures, cachedResult]);
|
|
1384
|
+
React.useEffect(() => {
|
|
1385
|
+
if (!cache) return;
|
|
1386
|
+
const urlTextureMap = [];
|
|
1387
|
+
if (typeof stableInput === "string") {
|
|
1388
|
+
urlTextureMap.push([stableInput, mappedTextures]);
|
|
1389
|
+
} else if (Array.isArray(stableInput)) {
|
|
1390
|
+
const textureArray = mappedTextures;
|
|
1391
|
+
stableInput.forEach((url, i) => urlTextureMap.push([url, textureArray[i]]));
|
|
1392
|
+
} else if (IsObject(stableInput)) {
|
|
1393
|
+
const textureRecord = mappedTextures;
|
|
1394
|
+
for (const key in stableInput) {
|
|
1395
|
+
const url = stableInput[key];
|
|
1396
|
+
urlTextureMap.push([url, textureRecord[key]]);
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
store.setState((state) => {
|
|
1400
|
+
const refs = new Map(state._textureRefs);
|
|
1401
|
+
let textures = state.textures;
|
|
1402
|
+
let added = false;
|
|
1403
|
+
for (const [url, texture] of urlTextureMap) {
|
|
1404
|
+
if (!textures.has(url)) {
|
|
1405
|
+
if (!added) {
|
|
1406
|
+
textures = new Map(textures);
|
|
1407
|
+
added = true;
|
|
1408
|
+
}
|
|
1409
|
+
textures.set(url, texture);
|
|
1770
1410
|
}
|
|
1411
|
+
refs.set(url, (refs.get(url) ?? 0) + 1);
|
|
1412
|
+
}
|
|
1413
|
+
return added ? { textures, _textureRefs: refs } : { _textureRefs: refs };
|
|
1414
|
+
});
|
|
1415
|
+
return () => store.setState((state) => {
|
|
1416
|
+
const refs = new Map(state._textureRefs);
|
|
1417
|
+
for (const [url] of urlTextureMap) {
|
|
1418
|
+
const next = (refs.get(url) ?? 0) - 1;
|
|
1419
|
+
if (next <= 0) refs.delete(url);
|
|
1420
|
+
else refs.set(url, next);
|
|
1421
|
+
}
|
|
1422
|
+
return { _textureRefs: refs };
|
|
1423
|
+
});
|
|
1424
|
+
}, [cache, stableInput, mappedTextures, store]);
|
|
1425
|
+
return mappedTextures;
|
|
1426
|
+
}
|
|
1427
|
+
useTexture.preload = (url) => useLoader.preload(three.TextureLoader, url);
|
|
1428
|
+
useTexture.clear = (input) => useLoader.clear(three.TextureLoader, input);
|
|
1429
|
+
const Texture = ({
|
|
1430
|
+
children,
|
|
1431
|
+
input,
|
|
1432
|
+
onLoad,
|
|
1433
|
+
cache
|
|
1434
|
+
}) => {
|
|
1435
|
+
const options = typeof onLoad === "function" ? { onLoad, cache } : { ...onLoad, cache };
|
|
1436
|
+
const ret = useTexture(input, options);
|
|
1437
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: children?.(ret) });
|
|
1438
|
+
};
|
|
1439
|
+
|
|
1440
|
+
function useTextures(selector) {
|
|
1441
|
+
const store = useStore();
|
|
1442
|
+
const registry = React.useMemo(() => {
|
|
1443
|
+
const getState = store.getState;
|
|
1444
|
+
const setState = store.setState;
|
|
1445
|
+
const getOne = (key) => getState().textures.get(key);
|
|
1446
|
+
return {
|
|
1447
|
+
get all() {
|
|
1448
|
+
return getState().textures;
|
|
1771
1449
|
},
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
top: 0,
|
|
1779
|
-
left: 0,
|
|
1780
|
-
aspect: 0,
|
|
1781
|
-
distance: 0,
|
|
1782
|
-
factor: 0,
|
|
1783
|
-
getCurrentViewport
|
|
1450
|
+
get(input) {
|
|
1451
|
+
if (typeof input === "string") return getOne(input);
|
|
1452
|
+
if (Array.isArray(input)) return input.map(getOne);
|
|
1453
|
+
const out = {};
|
|
1454
|
+
for (const name in input) out[name] = getOne(input[name]);
|
|
1455
|
+
return out;
|
|
1784
1456
|
},
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
const currentSize = state2.size;
|
|
1794
|
-
const newSize = {
|
|
1795
|
-
width: propW ?? currentSize.width,
|
|
1796
|
-
height: propH ?? currentSize.height,
|
|
1797
|
-
top: currentSize.top,
|
|
1798
|
-
left: currentSize.left
|
|
1799
|
-
};
|
|
1800
|
-
set((s) => ({
|
|
1801
|
-
size: newSize,
|
|
1802
|
-
viewport: { ...s.viewport, ...getCurrentViewport(state2.camera, defaultTarget, newSize) }
|
|
1803
|
-
}));
|
|
1804
|
-
scheduler.getScheduler().invalidate();
|
|
1805
|
-
}
|
|
1457
|
+
has: (key) => getState().textures.has(key),
|
|
1458
|
+
add(keyOrRecord, texture) {
|
|
1459
|
+
setState((state) => {
|
|
1460
|
+
const textures = new Map(state.textures);
|
|
1461
|
+
if (typeof keyOrRecord === "string") {
|
|
1462
|
+
textures.set(keyOrRecord, texture);
|
|
1463
|
+
} else {
|
|
1464
|
+
for (const key in keyOrRecord) textures.set(key, keyOrRecord[key]);
|
|
1806
1465
|
}
|
|
1807
|
-
return;
|
|
1808
|
-
}
|
|
1809
|
-
const w = width;
|
|
1810
|
-
const h = height ?? width;
|
|
1811
|
-
const t = top ?? state2.size.top;
|
|
1812
|
-
const l = left ?? state2.size.left;
|
|
1813
|
-
const size = { width: w, height: h, top: t, left: l };
|
|
1814
|
-
set((s) => ({
|
|
1815
|
-
size,
|
|
1816
|
-
viewport: { ...s.viewport, ...getCurrentViewport(state2.camera, defaultTarget, size) },
|
|
1817
|
-
_sizeImperative: true
|
|
1818
|
-
}));
|
|
1819
|
-
scheduler.getScheduler().invalidate();
|
|
1820
|
-
},
|
|
1821
|
-
setDpr: (dpr) => set((state2) => {
|
|
1822
|
-
const resolved = calculateDpr(dpr);
|
|
1823
|
-
return { viewport: { ...state2.viewport, dpr: resolved, initialDpr: state2.viewport.initialDpr || resolved } };
|
|
1824
|
-
}),
|
|
1825
|
-
setFrameloop: (frameloop = "always") => {
|
|
1826
|
-
set(() => ({ frameloop }));
|
|
1827
|
-
scheduler.getScheduler().frameloop = frameloop;
|
|
1466
|
+
return { textures };
|
|
1467
|
+
});
|
|
1828
1468
|
},
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
_textureRefs: /* @__PURE__ */ new Map(),
|
|
1838
|
-
renderPipeline: null,
|
|
1839
|
-
passes: {},
|
|
1840
|
-
_hmrVersion: 0,
|
|
1841
|
-
_sizeImperative: false,
|
|
1842
|
-
_sizeProps: null,
|
|
1843
|
-
previousRoot: void 0,
|
|
1844
|
-
internal: {
|
|
1845
|
-
// Events
|
|
1846
|
-
interaction: [],
|
|
1847
|
-
subscribers: [],
|
|
1848
|
-
// Per-pointer state (new unified structure)
|
|
1849
|
-
pointerMap: /* @__PURE__ */ new Map(),
|
|
1850
|
-
pointerDirty: /* @__PURE__ */ new Map(),
|
|
1851
|
-
lastEvent: React__namespace.createRef(),
|
|
1852
|
-
// Deprecated but kept for backwards compatibility
|
|
1853
|
-
hovered: /* @__PURE__ */ new Map(),
|
|
1854
|
-
initialClick: [0, 0],
|
|
1855
|
-
initialHits: [],
|
|
1856
|
-
capturedMap: /* @__PURE__ */ new Map(),
|
|
1857
|
-
// Visibility tracking (onFramed, onOccluded, onVisible)
|
|
1858
|
-
visibilityRegistry: /* @__PURE__ */ new Map(),
|
|
1859
|
-
// Occlusion system (WebGPU only)
|
|
1860
|
-
occlusionEnabled: false,
|
|
1861
|
-
occlusionObserver: null,
|
|
1862
|
-
occlusionCache: /* @__PURE__ */ new Map(),
|
|
1863
|
-
helperGroup: null,
|
|
1864
|
-
// Updates
|
|
1865
|
-
active: false,
|
|
1866
|
-
frames: 0,
|
|
1867
|
-
priority: 0,
|
|
1868
|
-
subscribe: (ref, priority, store) => {
|
|
1869
|
-
const internal = get().internal;
|
|
1870
|
-
internal.priority = internal.priority + (priority > 0 ? 1 : 0);
|
|
1871
|
-
internal.subscribers.push({ ref, priority, store });
|
|
1872
|
-
internal.subscribers = internal.subscribers.sort((a, b) => a.priority - b.priority);
|
|
1873
|
-
return () => {
|
|
1874
|
-
const internal2 = get().internal;
|
|
1875
|
-
if (internal2?.subscribers) {
|
|
1876
|
-
internal2.priority = internal2.priority - (priority > 0 ? 1 : 0);
|
|
1877
|
-
internal2.subscribers = internal2.subscribers.filter((s) => s.ref !== ref);
|
|
1878
|
-
}
|
|
1879
|
-
};
|
|
1880
|
-
},
|
|
1881
|
-
// Renderer Storage (single source of truth)
|
|
1882
|
-
actualRenderer: null,
|
|
1883
|
-
// Scheduler for useFrameNext (initialized in renderer.tsx)
|
|
1884
|
-
scheduler: null
|
|
1885
|
-
}
|
|
1886
|
-
};
|
|
1887
|
-
return rootState;
|
|
1888
|
-
});
|
|
1889
|
-
const state = rootStore.getState();
|
|
1890
|
-
Object.defineProperty(state, "gl", {
|
|
1891
|
-
get() {
|
|
1892
|
-
const currentState = rootStore.getState();
|
|
1893
|
-
if (!currentState.isLegacy && currentState.internal.actualRenderer) {
|
|
1894
|
-
const stack = new Error().stack || "";
|
|
1895
|
-
if (!isInternalRendererAccess(stack)) {
|
|
1896
|
-
const cleanedStack = stack.split("\n").slice(2).join("\n") || "Stack trace unavailable";
|
|
1897
|
-
notifyDepreciated({
|
|
1898
|
-
heading: "Accessing state.gl in WebGPU mode",
|
|
1899
|
-
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
|
|
1900
|
-
});
|
|
1901
|
-
}
|
|
1902
|
-
}
|
|
1903
|
-
return currentState.internal.actualRenderer;
|
|
1904
|
-
},
|
|
1905
|
-
set(value) {
|
|
1906
|
-
rootStore.getState().internal.actualRenderer = value;
|
|
1907
|
-
},
|
|
1908
|
-
enumerable: true,
|
|
1909
|
-
configurable: true
|
|
1910
|
-
});
|
|
1911
|
-
Object.defineProperty(state, "renderer", {
|
|
1912
|
-
get() {
|
|
1913
|
-
return rootStore.getState().internal.actualRenderer;
|
|
1914
|
-
},
|
|
1915
|
-
set(value) {
|
|
1916
|
-
rootStore.getState().internal.actualRenderer = value;
|
|
1917
|
-
},
|
|
1918
|
-
enumerable: true,
|
|
1919
|
-
configurable: true
|
|
1920
|
-
});
|
|
1921
|
-
let oldScene = state.scene;
|
|
1922
|
-
rootStore.subscribe(() => {
|
|
1923
|
-
const currentState = rootStore.getState();
|
|
1924
|
-
const { scene, rootScene, set } = currentState;
|
|
1925
|
-
if (scene !== oldScene) {
|
|
1926
|
-
oldScene = scene;
|
|
1927
|
-
if (scene?.isScene && scene !== rootScene) {
|
|
1928
|
-
set({ rootScene: scene });
|
|
1929
|
-
}
|
|
1930
|
-
}
|
|
1931
|
-
});
|
|
1932
|
-
let oldSize = state.size;
|
|
1933
|
-
let oldDpr = state.viewport.dpr;
|
|
1934
|
-
let oldCamera = state.camera;
|
|
1935
|
-
rootStore.subscribe(() => {
|
|
1936
|
-
const { camera, size, viewport, set, internal } = rootStore.getState();
|
|
1937
|
-
const actualRenderer = internal.actualRenderer;
|
|
1938
|
-
const canvasTarget = internal.canvasTarget;
|
|
1939
|
-
if (size.width !== oldSize.width || size.height !== oldSize.height || viewport.dpr !== oldDpr) {
|
|
1940
|
-
oldSize = size;
|
|
1941
|
-
oldDpr = viewport.dpr;
|
|
1942
|
-
updateCamera(camera, size);
|
|
1943
|
-
if (internal.isSecondary && canvasTarget) {
|
|
1944
|
-
if (viewport.dpr > 0) canvasTarget.setPixelRatio(viewport.dpr);
|
|
1945
|
-
canvasTarget.setSize(size.width, size.height, false);
|
|
1946
|
-
} else {
|
|
1947
|
-
if (viewport.dpr > 0) actualRenderer.setPixelRatio(viewport.dpr);
|
|
1948
|
-
actualRenderer.setSize(size.width, size.height, false);
|
|
1949
|
-
if (canvasTarget) {
|
|
1950
|
-
if (viewport.dpr > 0) canvasTarget.setPixelRatio(viewport.dpr);
|
|
1951
|
-
canvasTarget.setSize(size.width, size.height, false);
|
|
1469
|
+
dispose(key, options) {
|
|
1470
|
+
const state = getState();
|
|
1471
|
+
const refs = state._textureRefs.get(key) ?? 0;
|
|
1472
|
+
if (refs > 0 && !options?.force) {
|
|
1473
|
+
console.warn(
|
|
1474
|
+
`[useTextures] "${key}" still has ${refs} active reference(s); skipping dispose. Pass { force: true } to override.`
|
|
1475
|
+
);
|
|
1476
|
+
return false;
|
|
1952
1477
|
}
|
|
1478
|
+
state.textures.get(key)?.dispose();
|
|
1479
|
+
setState((s) => {
|
|
1480
|
+
const textures = new Map(s.textures);
|
|
1481
|
+
textures.delete(key);
|
|
1482
|
+
const nextRefs = new Map(s._textureRefs);
|
|
1483
|
+
nextRefs.delete(key);
|
|
1484
|
+
return { textures, _textureRefs: nextRefs };
|
|
1485
|
+
});
|
|
1486
|
+
return true;
|
|
1487
|
+
},
|
|
1488
|
+
disposeAll() {
|
|
1489
|
+
for (const texture of getState().textures.values()) texture.dispose();
|
|
1490
|
+
setState({ textures: /* @__PURE__ */ new Map(), _textureRefs: /* @__PURE__ */ new Map() });
|
|
1953
1491
|
}
|
|
1954
|
-
}
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
}
|
|
1961
|
-
set((state2) => ({ viewport: { ...state2.viewport, ...state2.viewport.getCurrentViewport(camera) } }));
|
|
1962
|
-
const currentState = rootStore.getState();
|
|
1963
|
-
if (currentState.autoUpdateFrustum && camera) {
|
|
1964
|
-
updateFrustum(camera, currentState.frustum);
|
|
1965
|
-
}
|
|
1966
|
-
}
|
|
1967
|
-
});
|
|
1968
|
-
rootStore.subscribe((state2) => invalidate(state2));
|
|
1969
|
-
return rootStore;
|
|
1970
|
-
};
|
|
1492
|
+
};
|
|
1493
|
+
}, [store]);
|
|
1494
|
+
const subscribe = selector ? () => selector(registry) : (state) => state.textures;
|
|
1495
|
+
const selected = useThree(subscribe);
|
|
1496
|
+
return selector ? selected : registry;
|
|
1497
|
+
}
|
|
1971
1498
|
|
|
1972
|
-
|
|
1973
|
-
const
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1499
|
+
function useRenderTarget(widthOrOptions, heightOrOptions, options) {
|
|
1500
|
+
const isLegacy = useThree((s) => s.isLegacy);
|
|
1501
|
+
const size = useThree((s) => s.size);
|
|
1502
|
+
let width;
|
|
1503
|
+
let height;
|
|
1504
|
+
let opts;
|
|
1505
|
+
if (typeof widthOrOptions === "object") {
|
|
1506
|
+
opts = widthOrOptions;
|
|
1507
|
+
} else if (typeof widthOrOptions === "number") {
|
|
1508
|
+
width = widthOrOptions;
|
|
1509
|
+
if (typeof heightOrOptions === "object") {
|
|
1510
|
+
height = widthOrOptions;
|
|
1511
|
+
opts = heightOrOptions;
|
|
1512
|
+
} else if (typeof heightOrOptions === "number") {
|
|
1513
|
+
height = heightOrOptions;
|
|
1514
|
+
opts = options;
|
|
1515
|
+
} else {
|
|
1516
|
+
height = widthOrOptions;
|
|
1980
1517
|
}
|
|
1981
|
-
return loader;
|
|
1982
1518
|
}
|
|
1983
|
-
return
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
if (extensions) extensions(loader);
|
|
1989
|
-
if ("loadAsync" in loader && typeof loader.loadAsync === "function") {
|
|
1990
|
-
return loader.loadAsync(input, onProgress).then((data) => {
|
|
1991
|
-
if (isObject3D(data?.scene)) Object.assign(data, buildGraph(data.scene));
|
|
1992
|
-
return data;
|
|
1993
|
-
});
|
|
1994
|
-
}
|
|
1995
|
-
return new Promise(
|
|
1996
|
-
(res, reject) => loader.load(
|
|
1997
|
-
input,
|
|
1998
|
-
(data) => {
|
|
1999
|
-
if (isObject3D(data?.scene)) Object.assign(data, buildGraph(data.scene));
|
|
2000
|
-
res(data);
|
|
2001
|
-
},
|
|
2002
|
-
onProgress,
|
|
2003
|
-
(error) => reject(new Error(`Could not load ${input}: ${error?.message}`))
|
|
2004
|
-
)
|
|
2005
|
-
);
|
|
2006
|
-
};
|
|
2007
|
-
}
|
|
2008
|
-
function useLoader(loader, input, extensions, onProgress, cacheKey) {
|
|
2009
|
-
const inputs = Array.isArray(input) ? input : [input];
|
|
2010
|
-
const cacheKeys = Array.isArray(cacheKey ?? input) ? cacheKey ?? input : [cacheKey ?? input];
|
|
2011
|
-
const fn = loadingFn(extensions, onProgress);
|
|
2012
|
-
const results = cacheKeys.map(
|
|
2013
|
-
(key, index) => suspendReact.suspend(() => fn(loader, inputs[index]), [loader, key], { equal: is.equ })
|
|
2014
|
-
);
|
|
2015
|
-
return Array.isArray(input) ? results : results[0];
|
|
1519
|
+
return React.useMemo(() => {
|
|
1520
|
+
const w = width ?? size.width;
|
|
1521
|
+
const h = height ?? size.height;
|
|
1522
|
+
return new three.WebGLRenderTarget(w, h, opts);
|
|
1523
|
+
}, [width, height, size.width, size.height, opts, isLegacy]);
|
|
2016
1524
|
}
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
1525
|
+
|
|
1526
|
+
const presetsObj = {
|
|
1527
|
+
apartment: "lebombo_1k.hdr",
|
|
1528
|
+
city: "potsdamer_platz_1k.hdr",
|
|
1529
|
+
dawn: "kiara_1_dawn_1k.hdr",
|
|
1530
|
+
forest: "forest_slope_1k.hdr",
|
|
1531
|
+
lobby: "st_fagans_interior_1k.hdr",
|
|
1532
|
+
night: "dikhololo_night_1k.hdr",
|
|
1533
|
+
park: "rooitou_park_1k.hdr",
|
|
1534
|
+
studio: "studio_small_03_1k.hdr",
|
|
1535
|
+
sunset: "venice_sunset_1k.hdr",
|
|
1536
|
+
warehouse: "empty_warehouse_01_1k.hdr"
|
|
2027
1537
|
};
|
|
2028
|
-
useLoader.loader = getLoader;
|
|
2029
1538
|
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
const
|
|
2048
|
-
|
|
2049
|
-
const
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
}
|
|
2064
|
-
notifyDepreciated({
|
|
2065
|
-
heading: "useFrame with numeric priority is deprecated",
|
|
2066
|
-
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 })',
|
|
2067
|
-
link: "https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe"
|
|
2068
|
-
});
|
|
1539
|
+
const CUBEMAP_ROOT = "https://raw.githack.com/pmndrs/drei-assets/456060a26bbeb8fdf79326f224b6d99b8bcce736/hdri/";
|
|
1540
|
+
const isArray = (arr) => Array.isArray(arr);
|
|
1541
|
+
const defaultFiles = ["/px.png", "/nx.png", "/py.png", "/ny.png", "/pz.png", "/nz.png"];
|
|
1542
|
+
function useEnvironment({
|
|
1543
|
+
files = defaultFiles,
|
|
1544
|
+
path = "",
|
|
1545
|
+
preset = void 0,
|
|
1546
|
+
colorSpace = void 0,
|
|
1547
|
+
extensions
|
|
1548
|
+
} = {}) {
|
|
1549
|
+
if (preset) {
|
|
1550
|
+
validatePreset(preset);
|
|
1551
|
+
files = presetsObj[preset];
|
|
1552
|
+
path = CUBEMAP_ROOT;
|
|
1553
|
+
}
|
|
1554
|
+
const multiFile = isArray(files);
|
|
1555
|
+
const { extension, isCubemap } = getExtension(files);
|
|
1556
|
+
const loader = getLoader(extension);
|
|
1557
|
+
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1558
|
+
const renderer = useThree((state) => state.renderer);
|
|
1559
|
+
React.useLayoutEffect(() => {
|
|
1560
|
+
if (extension !== "webp" && extension !== "jpg" && extension !== "jpeg") return;
|
|
1561
|
+
function clearGainmapTexture() {
|
|
1562
|
+
useLoader.clear(loader, multiFile ? [files] : files);
|
|
1563
|
+
}
|
|
1564
|
+
renderer.domElement.addEventListener("webglcontextlost", clearGainmapTexture, { once: true });
|
|
1565
|
+
}, [extension, files, loader, multiFile, renderer.domElement]);
|
|
1566
|
+
const loaderResult = useLoader(
|
|
1567
|
+
loader,
|
|
1568
|
+
multiFile ? [files] : files,
|
|
1569
|
+
(loader2) => {
|
|
1570
|
+
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
1571
|
+
loader2.setRenderer?.(renderer);
|
|
2069
1572
|
}
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
const mergedState = {
|
|
2073
|
-
...localState,
|
|
2074
|
-
time: frameState.time,
|
|
2075
|
-
delta: frameState.delta,
|
|
2076
|
-
elapsed: frameState.elapsed,
|
|
2077
|
-
frame: frameState.frame
|
|
2078
|
-
};
|
|
2079
|
-
callbackRef.current?.(mergedState, delta);
|
|
2080
|
-
};
|
|
2081
|
-
const unregister = scheduler$1.register(wrappedCallback, {
|
|
2082
|
-
id,
|
|
2083
|
-
rootId,
|
|
2084
|
-
...options
|
|
2085
|
-
});
|
|
2086
|
-
return () => {
|
|
2087
|
-
unregister();
|
|
2088
|
-
if (isLegacyPriority) {
|
|
2089
|
-
const currentState = store.getState();
|
|
2090
|
-
if (currentState.internal) {
|
|
2091
|
-
currentState.internal.priority--;
|
|
2092
|
-
let parentRoot = currentState.previousRoot;
|
|
2093
|
-
while (parentRoot) {
|
|
2094
|
-
const parentState = parentRoot.getState();
|
|
2095
|
-
if (parentState?.internal) parentState.internal.priority--;
|
|
2096
|
-
parentRoot = parentState?.previousRoot;
|
|
2097
|
-
}
|
|
2098
|
-
}
|
|
2099
|
-
}
|
|
2100
|
-
};
|
|
2101
|
-
} else {
|
|
2102
|
-
return scheduler$1.register(
|
|
2103
|
-
(state, delta) => {
|
|
2104
|
-
const frameState = state;
|
|
2105
|
-
if (!frameState.renderer) return;
|
|
2106
|
-
callbackRef.current?.(frameState, delta);
|
|
2107
|
-
},
|
|
2108
|
-
{ id, ...options }
|
|
2109
|
-
);
|
|
1573
|
+
loader2.setPath?.(path);
|
|
1574
|
+
if (extensions) extensions(loader2);
|
|
2110
1575
|
}
|
|
2111
|
-
}, [store, scheduler$1, id, optionsKey, isLegacyPriority, isInsideCanvas]);
|
|
2112
|
-
const isPaused = React__namespace.useSyncExternalStore(
|
|
2113
|
-
// Subscribe function
|
|
2114
|
-
React__namespace.useCallback(
|
|
2115
|
-
(onStoreChange) => {
|
|
2116
|
-
return scheduler.getScheduler().subscribeJobState(id, onStoreChange);
|
|
2117
|
-
},
|
|
2118
|
-
[id]
|
|
2119
|
-
),
|
|
2120
|
-
// getSnapshot function
|
|
2121
|
-
React__namespace.useCallback(() => scheduler.getScheduler().isJobPaused(id), [id]),
|
|
2122
|
-
// getServerSnapshot function (SSR)
|
|
2123
|
-
React__namespace.useCallback(() => false, [])
|
|
2124
1576
|
);
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
1577
|
+
let texture = multiFile ? (
|
|
1578
|
+
// @ts-ignore
|
|
1579
|
+
loaderResult[0]
|
|
1580
|
+
) : loaderResult;
|
|
1581
|
+
if (extension === "jpg" || extension === "jpeg" || extension === "webp") {
|
|
1582
|
+
texture = texture.renderTarget?.texture;
|
|
1583
|
+
}
|
|
1584
|
+
texture.mapping = isCubemap ? three.CubeReflectionMapping : three.EquirectangularReflectionMapping;
|
|
1585
|
+
texture.colorSpace = colorSpace ?? (isCubemap ? "srgb" : "srgb-linear");
|
|
1586
|
+
return texture;
|
|
1587
|
+
}
|
|
1588
|
+
const preloadDefaultOptions = {
|
|
1589
|
+
files: defaultFiles,
|
|
1590
|
+
path: "",
|
|
1591
|
+
preset: void 0,
|
|
1592
|
+
extensions: void 0
|
|
1593
|
+
};
|
|
1594
|
+
useEnvironment.preload = (preloadOptions) => {
|
|
1595
|
+
const options = { ...preloadDefaultOptions, ...preloadOptions };
|
|
1596
|
+
let { files, path = "" } = options;
|
|
1597
|
+
const { preset, extensions } = options;
|
|
1598
|
+
if (preset) {
|
|
1599
|
+
validatePreset(preset);
|
|
1600
|
+
files = presetsObj[preset];
|
|
1601
|
+
path = CUBEMAP_ROOT;
|
|
1602
|
+
}
|
|
1603
|
+
const { extension } = getExtension(files);
|
|
1604
|
+
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
1605
|
+
throw new Error("useEnvironment: Preloading gainmaps is not supported");
|
|
1606
|
+
}
|
|
1607
|
+
const loader = getLoader(extension);
|
|
1608
|
+
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1609
|
+
useLoader.preload(loader, isArray(files) ? [files] : files, (loader2) => {
|
|
1610
|
+
loader2.setPath?.(path);
|
|
1611
|
+
if (extensions) extensions(loader2);
|
|
1612
|
+
});
|
|
1613
|
+
};
|
|
1614
|
+
const clearDefaultOptins = {
|
|
1615
|
+
files: defaultFiles,
|
|
1616
|
+
preset: void 0
|
|
1617
|
+
};
|
|
1618
|
+
useEnvironment.clear = (clearOptions) => {
|
|
1619
|
+
const options = { ...clearDefaultOptins, ...clearOptions };
|
|
1620
|
+
let { files } = options;
|
|
1621
|
+
const { preset } = options;
|
|
1622
|
+
if (preset) {
|
|
1623
|
+
validatePreset(preset);
|
|
1624
|
+
files = presetsObj[preset];
|
|
1625
|
+
}
|
|
1626
|
+
const { extension } = getExtension(files);
|
|
1627
|
+
const loader = getLoader(extension);
|
|
1628
|
+
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1629
|
+
useLoader.clear(loader, isArray(files) ? [files] : files);
|
|
1630
|
+
};
|
|
1631
|
+
function validatePreset(preset) {
|
|
1632
|
+
if (!(preset in presetsObj)) throw new Error("Preset must be one of: " + Object.keys(presetsObj).join(", "));
|
|
1633
|
+
}
|
|
1634
|
+
function getExtension(files) {
|
|
1635
|
+
const isCubemap = isArray(files) && files.length === 6;
|
|
1636
|
+
const isGainmap = isArray(files) && files.length === 3 && files.some((file) => file.endsWith("json"));
|
|
1637
|
+
const firstEntry = isArray(files) ? files[0] : files;
|
|
1638
|
+
const extension = isCubemap ? "cube" : isGainmap ? "webp" : firstEntry.startsWith("data:application/exr") ? "exr" : firstEntry.startsWith("data:application/hdr") ? "hdr" : firstEntry.startsWith("data:image/jpeg") ? "jpg" : firstEntry.split(".").pop()?.split("?")?.shift()?.toLowerCase();
|
|
1639
|
+
return { extension, isCubemap, isGainmap };
|
|
1640
|
+
}
|
|
1641
|
+
function getLoader(extension) {
|
|
1642
|
+
const loader = extension === "cube" ? three.CubeTextureLoader : extension === "hdr" ? HDRLoader_js.HDRLoader : extension === "exr" ? EXRLoader_js.EXRLoader : extension === "jpg" || extension === "jpeg" ? UltraHDRLoader_js.UltraHDRLoader : extension === "webp" ? gainmapJs.GainMapLoader : null;
|
|
1643
|
+
return loader;
|
|
2172
1644
|
}
|
|
2173
1645
|
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
if (
|
|
2177
|
-
|
|
2178
|
-
return Object.values(input);
|
|
1646
|
+
function useStore() {
|
|
1647
|
+
const store = React.useContext(context);
|
|
1648
|
+
if (!store) throw new Error("R3F: Hooks can only be used within the Canvas component!");
|
|
1649
|
+
return store;
|
|
2179
1650
|
}
|
|
2180
|
-
function
|
|
2181
|
-
return
|
|
1651
|
+
function useThree(selector = (state) => state, equalityFn) {
|
|
1652
|
+
return useStore()(selector, equalityFn);
|
|
2182
1653
|
}
|
|
2183
|
-
function
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
return input.map((url) => textureCache.get(url));
|
|
2188
|
-
} else {
|
|
2189
|
-
const result = {};
|
|
2190
|
-
const objInput = input;
|
|
2191
|
-
for (const key in objInput) {
|
|
2192
|
-
result[key] = textureCache.get(objInput[key]);
|
|
2193
|
-
}
|
|
2194
|
-
return result;
|
|
2195
|
-
}
|
|
2196
|
-
}
|
|
2197
|
-
function useTexture(input, optionsOrOnLoad) {
|
|
2198
|
-
const renderer = useThree((state) => state.internal.actualRenderer);
|
|
2199
|
-
const store = useStore();
|
|
2200
|
-
const options = typeof optionsOrOnLoad === "function" ? { onLoad: optionsOrOnLoad } : optionsOrOnLoad ?? {};
|
|
2201
|
-
const { onLoad, cache = true } = options;
|
|
2202
|
-
const onLoadRef = React.useRef(onLoad);
|
|
2203
|
-
onLoadRef.current = onLoad;
|
|
2204
|
-
const onLoadCalledForRef = React.useRef(null);
|
|
2205
|
-
const urls = React.useMemo(() => getUrls(input), [input]);
|
|
2206
|
-
const cachedResult = React.useMemo(() => {
|
|
2207
|
-
if (!cache) return null;
|
|
2208
|
-
const textures = store.getState().textures;
|
|
2209
|
-
if (!allUrlsCached(urls, textures)) return null;
|
|
2210
|
-
return buildFromCache(input, textures);
|
|
2211
|
-
}, [cache, urls, input, store]);
|
|
2212
|
-
const loadedTextures = useLoader(
|
|
2213
|
-
three.TextureLoader,
|
|
2214
|
-
IsObject(input) ? Object.values(input) : input
|
|
2215
|
-
);
|
|
2216
|
-
const inputKey = urls.join("\0");
|
|
2217
|
-
React.useLayoutEffect(() => {
|
|
2218
|
-
if (cachedResult) return;
|
|
2219
|
-
if (onLoadCalledForRef.current === inputKey) return;
|
|
2220
|
-
onLoadCalledForRef.current = inputKey;
|
|
2221
|
-
onLoadRef.current?.(loadedTextures);
|
|
2222
|
-
}, [cachedResult, loadedTextures, inputKey]);
|
|
2223
|
-
React.useEffect(() => {
|
|
2224
|
-
if (cachedResult) return;
|
|
2225
|
-
if ("initTexture" in renderer) {
|
|
2226
|
-
let textureArray = [];
|
|
2227
|
-
if (Array.isArray(loadedTextures)) {
|
|
2228
|
-
textureArray = loadedTextures;
|
|
2229
|
-
} else if (loadedTextures instanceof three.Texture) {
|
|
2230
|
-
textureArray = [loadedTextures];
|
|
2231
|
-
} else if (IsObject(loadedTextures)) {
|
|
2232
|
-
textureArray = Object.values(loadedTextures);
|
|
2233
|
-
}
|
|
2234
|
-
textureArray.forEach((texture) => {
|
|
2235
|
-
if (texture instanceof three.Texture) {
|
|
2236
|
-
renderer.initTexture(texture);
|
|
2237
|
-
}
|
|
2238
|
-
});
|
|
2239
|
-
}
|
|
2240
|
-
}, [renderer, loadedTextures, cachedResult]);
|
|
2241
|
-
const mappedTextures = React.useMemo(() => {
|
|
2242
|
-
if (cachedResult) return cachedResult;
|
|
2243
|
-
if (IsObject(input)) {
|
|
2244
|
-
const keyed = {};
|
|
2245
|
-
const textureArray = loadedTextures;
|
|
2246
|
-
let i = 0;
|
|
2247
|
-
for (const key in input) keyed[key] = textureArray[i++];
|
|
2248
|
-
return keyed;
|
|
2249
|
-
} else {
|
|
2250
|
-
return loadedTextures;
|
|
2251
|
-
}
|
|
2252
|
-
}, [input, loadedTextures, cachedResult]);
|
|
2253
|
-
React.useEffect(() => {
|
|
2254
|
-
if (!cache) return;
|
|
2255
|
-
const urlTextureMap = [];
|
|
2256
|
-
if (typeof input === "string") {
|
|
2257
|
-
urlTextureMap.push([input, mappedTextures]);
|
|
2258
|
-
} else if (Array.isArray(input)) {
|
|
2259
|
-
const textureArray = mappedTextures;
|
|
2260
|
-
input.forEach((url, i) => urlTextureMap.push([url, textureArray[i]]));
|
|
2261
|
-
} else if (IsObject(input)) {
|
|
2262
|
-
const textureRecord = mappedTextures;
|
|
2263
|
-
for (const key in input) {
|
|
2264
|
-
const url = input[key];
|
|
2265
|
-
urlTextureMap.push([url, textureRecord[key]]);
|
|
2266
|
-
}
|
|
2267
|
-
}
|
|
2268
|
-
store.setState((state) => {
|
|
2269
|
-
const refs = new Map(state._textureRefs);
|
|
2270
|
-
let textures = state.textures;
|
|
2271
|
-
let added = false;
|
|
2272
|
-
for (const [url, texture] of urlTextureMap) {
|
|
2273
|
-
if (!textures.has(url)) {
|
|
2274
|
-
if (!added) {
|
|
2275
|
-
textures = new Map(textures);
|
|
2276
|
-
added = true;
|
|
2277
|
-
}
|
|
2278
|
-
textures.set(url, texture);
|
|
2279
|
-
}
|
|
2280
|
-
refs.set(url, (refs.get(url) ?? 0) + 1);
|
|
2281
|
-
}
|
|
2282
|
-
return added ? { textures, _textureRefs: refs } : { _textureRefs: refs };
|
|
2283
|
-
});
|
|
2284
|
-
return () => store.setState((state) => {
|
|
2285
|
-
const refs = new Map(state._textureRefs);
|
|
2286
|
-
for (const [url] of urlTextureMap) {
|
|
2287
|
-
const next = (refs.get(url) ?? 0) - 1;
|
|
2288
|
-
if (next <= 0) refs.delete(url);
|
|
2289
|
-
else refs.set(url, next);
|
|
2290
|
-
}
|
|
2291
|
-
return { _textureRefs: refs };
|
|
2292
|
-
});
|
|
2293
|
-
}, [cache, input, mappedTextures, store]);
|
|
2294
|
-
return mappedTextures;
|
|
2295
|
-
}
|
|
2296
|
-
useTexture.preload = (url) => useLoader.preload(three.TextureLoader, url);
|
|
2297
|
-
useTexture.clear = (input) => useLoader.clear(three.TextureLoader, input);
|
|
2298
|
-
const Texture = ({
|
|
2299
|
-
children,
|
|
2300
|
-
input,
|
|
2301
|
-
onLoad,
|
|
2302
|
-
cache
|
|
2303
|
-
}) => {
|
|
2304
|
-
const options = typeof onLoad === "function" ? { onLoad, cache } : { ...onLoad, cache };
|
|
2305
|
-
const ret = useTexture(input, options);
|
|
2306
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: children?.(ret) });
|
|
2307
|
-
};
|
|
2308
|
-
|
|
2309
|
-
function useTextures(selector) {
|
|
2310
|
-
const store = useStore();
|
|
2311
|
-
const registry = React.useMemo(() => {
|
|
2312
|
-
const getState = store.getState;
|
|
2313
|
-
const setState = store.setState;
|
|
2314
|
-
const getOne = (key) => getState().textures.get(key);
|
|
2315
|
-
return {
|
|
2316
|
-
get all() {
|
|
2317
|
-
return getState().textures;
|
|
2318
|
-
},
|
|
2319
|
-
get(input) {
|
|
2320
|
-
if (typeof input === "string") return getOne(input);
|
|
2321
|
-
if (Array.isArray(input)) return input.map(getOne);
|
|
2322
|
-
const out = {};
|
|
2323
|
-
for (const name in input) out[name] = getOne(input[name]);
|
|
2324
|
-
return out;
|
|
2325
|
-
},
|
|
2326
|
-
has: (key) => getState().textures.has(key),
|
|
2327
|
-
add(keyOrRecord, texture) {
|
|
2328
|
-
setState((state) => {
|
|
2329
|
-
const textures = new Map(state.textures);
|
|
2330
|
-
if (typeof keyOrRecord === "string") {
|
|
2331
|
-
textures.set(keyOrRecord, texture);
|
|
2332
|
-
} else {
|
|
2333
|
-
for (const key in keyOrRecord) textures.set(key, keyOrRecord[key]);
|
|
2334
|
-
}
|
|
2335
|
-
return { textures };
|
|
2336
|
-
});
|
|
2337
|
-
},
|
|
2338
|
-
dispose(key, options) {
|
|
2339
|
-
const state = getState();
|
|
2340
|
-
const refs = state._textureRefs.get(key) ?? 0;
|
|
2341
|
-
if (refs > 0 && !options?.force) {
|
|
2342
|
-
console.warn(
|
|
2343
|
-
`[useTextures] "${key}" still has ${refs} active reference(s); skipping dispose. Pass { force: true } to override.`
|
|
2344
|
-
);
|
|
2345
|
-
return false;
|
|
2346
|
-
}
|
|
2347
|
-
state.textures.get(key)?.dispose();
|
|
2348
|
-
setState((s) => {
|
|
2349
|
-
const textures = new Map(s.textures);
|
|
2350
|
-
textures.delete(key);
|
|
2351
|
-
const nextRefs = new Map(s._textureRefs);
|
|
2352
|
-
nextRefs.delete(key);
|
|
2353
|
-
return { textures, _textureRefs: nextRefs };
|
|
2354
|
-
});
|
|
2355
|
-
return true;
|
|
2356
|
-
},
|
|
2357
|
-
disposeAll() {
|
|
2358
|
-
for (const texture of getState().textures.values()) texture.dispose();
|
|
2359
|
-
setState({ textures: /* @__PURE__ */ new Map(), _textureRefs: /* @__PURE__ */ new Map() });
|
|
2360
|
-
}
|
|
2361
|
-
};
|
|
2362
|
-
}, [store]);
|
|
2363
|
-
const subscribe = selector ? () => selector(registry) : (state) => state.textures;
|
|
2364
|
-
const selected = useThree(subscribe);
|
|
2365
|
-
return selector ? selected : registry;
|
|
2366
|
-
}
|
|
2367
|
-
|
|
2368
|
-
function useRenderTarget(widthOrOptions, heightOrOptions, options) {
|
|
2369
|
-
const isLegacy = useThree((s) => s.isLegacy);
|
|
2370
|
-
const size = useThree((s) => s.size);
|
|
2371
|
-
let width;
|
|
2372
|
-
let height;
|
|
2373
|
-
let opts;
|
|
2374
|
-
if (typeof widthOrOptions === "object") {
|
|
2375
|
-
opts = widthOrOptions;
|
|
2376
|
-
} else if (typeof widthOrOptions === "number") {
|
|
2377
|
-
width = widthOrOptions;
|
|
2378
|
-
if (typeof heightOrOptions === "object") {
|
|
2379
|
-
height = widthOrOptions;
|
|
2380
|
-
opts = heightOrOptions;
|
|
2381
|
-
} else if (typeof heightOrOptions === "number") {
|
|
2382
|
-
height = heightOrOptions;
|
|
2383
|
-
opts = options;
|
|
2384
|
-
} else {
|
|
2385
|
-
height = widthOrOptions;
|
|
2386
|
-
}
|
|
2387
|
-
}
|
|
2388
|
-
return React.useMemo(() => {
|
|
2389
|
-
const w = width ?? size.width;
|
|
2390
|
-
const h = height ?? size.height;
|
|
2391
|
-
return new three.WebGLRenderTarget(w, h, opts);
|
|
2392
|
-
}, [width, height, size.width, size.height, opts, isLegacy]);
|
|
2393
|
-
}
|
|
2394
|
-
|
|
2395
|
-
function useStore() {
|
|
2396
|
-
const store = React.useContext(context);
|
|
2397
|
-
if (!store) throw new Error("R3F: Hooks can only be used within the Canvas component!");
|
|
2398
|
-
return store;
|
|
2399
|
-
}
|
|
2400
|
-
function useThree(selector = (state) => state, equalityFn) {
|
|
2401
|
-
return useStore()(selector, equalityFn);
|
|
2402
|
-
}
|
|
2403
|
-
function useInstanceHandle(ref) {
|
|
2404
|
-
const instance = React.useRef(null);
|
|
2405
|
-
React.useImperativeHandle(instance, () => ref.current.__r3f, [ref]);
|
|
2406
|
-
return instance;
|
|
1654
|
+
function useInstanceHandle(ref) {
|
|
1655
|
+
const instance = React.useRef(null);
|
|
1656
|
+
React.useImperativeHandle(instance, () => ref.current.__r3f, [ref]);
|
|
1657
|
+
return instance;
|
|
2407
1658
|
}
|
|
2408
1659
|
function useGraph(object) {
|
|
2409
1660
|
return React.useMemo(() => buildGraph(object), [object]);
|
|
2410
1661
|
}
|
|
2411
1662
|
|
|
1663
|
+
const t = 1, o = 8, r = 32, e = 2, i$1 = 268435456;
|
|
1664
|
+
|
|
2412
1665
|
let effectId = 0;
|
|
2413
1666
|
function addEffect(callback) {
|
|
2414
1667
|
notifyDepreciated({
|
|
@@ -13500,206 +12753,789 @@ Check the top-level render call using <` + i + ">.");
|
|
|
13500
12753
|
var o = 1 << 31 - vn(n);
|
|
13501
12754
|
e.entanglements[1] |= o, n &= ~o;
|
|
13502
12755
|
}
|
|
13503
|
-
Kn(e), (ye & (Zn | uo)) === Jn && (Pp = me() + Fg, Wa(0));
|
|
12756
|
+
Kn(e), (ye & (Zn | uo)) === Jn && (Pp = me() + Fg, Wa(0));
|
|
12757
|
+
}
|
|
12758
|
+
}
|
|
12759
|
+
break;
|
|
12760
|
+
case 31:
|
|
12761
|
+
case 13:
|
|
12762
|
+
n = On(e, 2), n !== null && We(n, e, 2), Ls(), rl(e, 2);
|
|
12763
|
+
}
|
|
12764
|
+
}, le.batchedUpdates = function(e, n) {
|
|
12765
|
+
return e(n);
|
|
12766
|
+
}, le.createComponentSelector = function(e) {
|
|
12767
|
+
return { $$typeof: pm, value: e };
|
|
12768
|
+
}, le.createContainer = function(e, n, o, i, s, u, f, p, g, S) {
|
|
12769
|
+
return Ka(e, n, false, null, o, i, u, null, f, p, g, S);
|
|
12770
|
+
}, le.createHasPseudoClassSelector = function(e) {
|
|
12771
|
+
return { $$typeof: hm, value: e };
|
|
12772
|
+
}, le.createHydrationContainer = function(e, n, o, i, s, u, f, p, g, S, T, _, I, O) {
|
|
12773
|
+
return e = Ka(o, i, true, e, s, u, p, O, g, S, T, _), e.context = Dh(null), o = e.current, i = Nt(o), i = Xo(i), s = zo(i), s.callback = n ?? null, Mt(o, s, i), ur(i, "hydrateRoot()", null), n = i, e.current.lanes = n, Ci(e, n), Kn(e), e;
|
|
12774
|
+
}, le.createPortal = function(e, n, o) {
|
|
12775
|
+
var i = 3 < arguments.length && arguments[3] !== void 0 ? arguments[3] : null;
|
|
12776
|
+
try {
|
|
12777
|
+
vt(i);
|
|
12778
|
+
var s = false;
|
|
12779
|
+
} catch {
|
|
12780
|
+
s = true;
|
|
12781
|
+
}
|
|
12782
|
+
return s && (console.error("The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", typeof Symbol == "function" && Symbol.toStringTag && i[Symbol.toStringTag] || i.constructor.name || "Object"), vt(i)), { $$typeof: Ao, key: i == null ? null : "" + i, children: e, containerInfo: n, implementation: o };
|
|
12783
|
+
}, le.createRoleSelector = function(e) {
|
|
12784
|
+
return { $$typeof: mm, value: e };
|
|
12785
|
+
}, le.createTestNameSelector = function(e) {
|
|
12786
|
+
return { $$typeof: gm, value: e };
|
|
12787
|
+
}, le.createTextSelector = function(e) {
|
|
12788
|
+
return { $$typeof: ym, value: e };
|
|
12789
|
+
}, le.defaultOnCaughtError = function(e) {
|
|
12790
|
+
var n = bd ? "The above error occurred in the <" + bd + "> component." : "The above error occurred in one of your React components.", o = "React will try to recreate this component tree from scratch using the error boundary you provided, " + ((Cg || "Anonymous") + ".");
|
|
12791
|
+
typeof e == "object" && e !== null && typeof e.environmentName == "string" ? ri("error", [`%o
|
|
12792
|
+
|
|
12793
|
+
%s
|
|
12794
|
+
|
|
12795
|
+
%s
|
|
12796
|
+
`, e, n, o], e.environmentName)() : console.error(`%o
|
|
12797
|
+
|
|
12798
|
+
%s
|
|
12799
|
+
|
|
12800
|
+
%s
|
|
12801
|
+
`, e, n, o);
|
|
12802
|
+
}, le.defaultOnRecoverableError = function(e) {
|
|
12803
|
+
qg(e);
|
|
12804
|
+
}, le.defaultOnUncaughtError = function(e) {
|
|
12805
|
+
qg(e), console.warn(`%s
|
|
12806
|
+
|
|
12807
|
+
%s
|
|
12808
|
+
`, bd ? "An error occurred in the <" + bd + "> component." : "An error occurred in one of your React components.", `Consider adding an error boundary to your tree to customize error handling behavior.
|
|
12809
|
+
Visit https://react.dev/link/error-boundaries to learn more about error boundaries.`);
|
|
12810
|
+
}, le.deferredUpdates = function(e) {
|
|
12811
|
+
var n = x.T, o = wt();
|
|
12812
|
+
try {
|
|
12813
|
+
return an(32), x.T = null, e();
|
|
12814
|
+
} finally {
|
|
12815
|
+
an(o), x.T = n;
|
|
12816
|
+
}
|
|
12817
|
+
}, le.discreteUpdates = function(e, n, o, i, s) {
|
|
12818
|
+
var u = x.T, f = wt();
|
|
12819
|
+
try {
|
|
12820
|
+
return an(2), x.T = null, e(n, o, i, s);
|
|
12821
|
+
} finally {
|
|
12822
|
+
an(f), x.T = u, ye === Jn && (Pp = me() + Fg);
|
|
12823
|
+
}
|
|
12824
|
+
}, le.findAllNodes = kc, le.findBoundingRects = function(e, n) {
|
|
12825
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12826
|
+
n = kc(e, n), e = [];
|
|
12827
|
+
for (var o = 0; o < n.length; o++) e.push(ma(n[o]));
|
|
12828
|
+
for (n = e.length - 1; 0 < n; n--) {
|
|
12829
|
+
o = e[n];
|
|
12830
|
+
for (var i = o.x, s = i + o.width, u = o.y, f = u + o.height, p = n - 1; 0 <= p; p--) if (n !== p) {
|
|
12831
|
+
var g = e[p], S = g.x, T = S + g.width, _ = g.y, I = _ + g.height;
|
|
12832
|
+
if (i >= S && u >= _ && s <= T && f <= I) {
|
|
12833
|
+
e.splice(n, 1);
|
|
12834
|
+
break;
|
|
12835
|
+
} else if (i !== S || o.width !== g.width || I < u || _ > f) {
|
|
12836
|
+
if (!(u !== _ || o.height !== g.height || T < i || S > s)) {
|
|
12837
|
+
S > i && (g.width += S - i, g.x = i), T < s && (g.width = s - S), e.splice(n, 1);
|
|
12838
|
+
break;
|
|
12839
|
+
}
|
|
12840
|
+
} else {
|
|
12841
|
+
_ > u && (g.height += _ - u, g.y = u), I < f && (g.height = f - _), e.splice(n, 1);
|
|
12842
|
+
break;
|
|
12843
|
+
}
|
|
12844
|
+
}
|
|
12845
|
+
}
|
|
12846
|
+
return e;
|
|
12847
|
+
}, le.findHostInstance = function(e) {
|
|
12848
|
+
var n = e._reactInternals;
|
|
12849
|
+
if (n === void 0) throw typeof e.render == "function" ? Error("Unable to find node on an unmounted component.") : (e = Object.keys(e).join(","), Error("Argument appears to not be a ReactComponent. Keys: " + e));
|
|
12850
|
+
return e = mu(n), e === null ? null : ot(e.stateNode);
|
|
12851
|
+
}, le.findHostInstanceWithNoPortals = function(e) {
|
|
12852
|
+
return e = Ed(e), e = e !== null ? _p(e) : null, e === null ? null : ot(e.stateNode);
|
|
12853
|
+
}, le.findHostInstanceWithWarning = function(e, n) {
|
|
12854
|
+
var o = e._reactInternals;
|
|
12855
|
+
if (o === void 0) throw typeof e.render == "function" ? Error("Unable to find node on an unmounted component.") : (e = Object.keys(e).join(","), Error("Argument appears to not be a ReactComponent. Keys: " + e));
|
|
12856
|
+
if (e = mu(o), e === null) return null;
|
|
12857
|
+
if (e.mode & 8) {
|
|
12858
|
+
var i = G(o) || "Component";
|
|
12859
|
+
mb[i] || (mb[i] = true, B(e, function() {
|
|
12860
|
+
o.mode & 8 ? console.error("%s is deprecated in StrictMode. %s was passed an instance of %s which is inside StrictMode. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://react.dev/link/strict-mode-find-node", n, n, i) : console.error("%s is deprecated in StrictMode. %s was passed an instance of %s which renders StrictMode children. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://react.dev/link/strict-mode-find-node", n, n, i);
|
|
12861
|
+
}));
|
|
12862
|
+
}
|
|
12863
|
+
return ot(e.stateNode);
|
|
12864
|
+
}, le.flushPassiveEffects = el, le.flushSyncFromReconciler = function(e) {
|
|
12865
|
+
var n = ye;
|
|
12866
|
+
ye |= 1;
|
|
12867
|
+
var o = x.T, i = wt();
|
|
12868
|
+
try {
|
|
12869
|
+
if (an(2), x.T = null, e) return e();
|
|
12870
|
+
} finally {
|
|
12871
|
+
an(i), x.T = o, ye = n, (ye & (Zn | uo)) === Jn && Wa(0);
|
|
12872
|
+
}
|
|
12873
|
+
}, le.flushSyncWork = Ls, le.focusWithin = function(e, n) {
|
|
12874
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12875
|
+
for (e = Ef(e), n = hh(e, n), n = Array.from(n), e = 0; e < n.length; ) {
|
|
12876
|
+
var o = n[e++], i = o.tag;
|
|
12877
|
+
if (!Kr(o)) {
|
|
12878
|
+
if ((i === 5 || i === 26 || i === 27) && Ft(o.stateNode)) return true;
|
|
12879
|
+
for (o = o.child; o !== null; ) n.push(o), o = o.sibling;
|
|
12880
|
+
}
|
|
12881
|
+
}
|
|
12882
|
+
return false;
|
|
12883
|
+
}, le.getFindAllNodesFailureDescription = function(e, n) {
|
|
12884
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12885
|
+
var o = 0, i = [];
|
|
12886
|
+
e = [Ef(e), 0];
|
|
12887
|
+
for (var s = 0; s < e.length; ) {
|
|
12888
|
+
var u = e[s++], f = u.tag, p = e[s++], g = n[p];
|
|
12889
|
+
if ((f !== 5 && f !== 26 && f !== 27 || !Kr(u)) && (If(u, g) && (i.push(Sc(g)), p++, p > o && (o = p)), p < n.length)) for (u = u.child; u !== null; ) e.push(u, p), u = u.sibling;
|
|
12890
|
+
}
|
|
12891
|
+
if (o < n.length) {
|
|
12892
|
+
for (e = []; o < n.length; o++) e.push(Sc(n[o]));
|
|
12893
|
+
return `findAllNodes was able to match part of the selector:
|
|
12894
|
+
` + (i.join(" > ") + `
|
|
12895
|
+
|
|
12896
|
+
No matching component was found for:
|
|
12897
|
+
`) + e.join(" > ");
|
|
12898
|
+
}
|
|
12899
|
+
return null;
|
|
12900
|
+
}, le.getPublicRootInstance = function(e) {
|
|
12901
|
+
if (e = e.current, !e.child) return null;
|
|
12902
|
+
switch (e.child.tag) {
|
|
12903
|
+
case 27:
|
|
12904
|
+
case 5:
|
|
12905
|
+
return ot(e.child.stateNode);
|
|
12906
|
+
default:
|
|
12907
|
+
return e.child.stateNode;
|
|
12908
|
+
}
|
|
12909
|
+
}, le.injectIntoDevTools = function() {
|
|
12910
|
+
var e = { bundleType: 1, version: Jt, rendererPackageName: Zt, currentDispatcherRef: x, reconcilerVersion: "19.2.0" };
|
|
12911
|
+
return jo !== null && (e.rendererConfig = jo), e.overrideHookState = gb, e.overrideHookStateDeletePath = yb, e.overrideHookStateRenamePath = bb, e.overrideProps = vb, e.overridePropsDeletePath = Sb, e.overridePropsRenamePath = kb, e.scheduleUpdate = wb, e.scheduleRetry = Pb, e.setErrorHandler = xb, e.setSuspenseHandler = zb, e.scheduleRefresh = hu, e.scheduleRoot = Fl, e.setRefreshHandler = Ir, e.getCurrentFiber = Ic, Ep(e);
|
|
12912
|
+
}, le.isAlreadyRendering = Ns, le.observeVisibleRects = function(e, n, o, i) {
|
|
12913
|
+
function s() {
|
|
12914
|
+
var S = kc(e, n);
|
|
12915
|
+
u.forEach(function(T) {
|
|
12916
|
+
0 > S.indexOf(T) && g(T);
|
|
12917
|
+
}), S.forEach(function(T) {
|
|
12918
|
+
0 > u.indexOf(T) && p(T);
|
|
12919
|
+
});
|
|
12920
|
+
}
|
|
12921
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12922
|
+
var u = kc(e, n);
|
|
12923
|
+
o = zr(u, o, i);
|
|
12924
|
+
var f = o.disconnect, p = o.observe, g = o.unobserve;
|
|
12925
|
+
return bm.push(s), { disconnect: function() {
|
|
12926
|
+
var S = bm.indexOf(s);
|
|
12927
|
+
0 <= S && bm.splice(S, 1), f();
|
|
12928
|
+
} };
|
|
12929
|
+
}, le.shouldError = function(e) {
|
|
12930
|
+
return pu(e);
|
|
12931
|
+
}, le.shouldSuspend = function(e) {
|
|
12932
|
+
return fu(e);
|
|
12933
|
+
}, le.startHostTransition = function(e, n, o, i) {
|
|
12934
|
+
if (e.tag !== 5) throw Error("Expected the form instance to be a HostComponent. This is a bug in React.");
|
|
12935
|
+
var s = uf(e).queue;
|
|
12936
|
+
Hp(e), nt(e, s, n, Xt, o === null ? Em : function() {
|
|
12937
|
+
x.T === null && console.error("requestFormReset was called outside a transition or action. To fix, move to an action, or wrap with startTransition.");
|
|
12938
|
+
var u = uf(e);
|
|
12939
|
+
return u.next === null && (u = e.alternate.memoizedState), qi(e, u.next.queue, {}, Nt(e)), o(i);
|
|
12940
|
+
});
|
|
12941
|
+
}, le.updateContainer = function(e, n, o, i) {
|
|
12942
|
+
var s = n.current, u = Nt(s);
|
|
12943
|
+
return As(s, u, e, n, o, i), u;
|
|
12944
|
+
}, le.updateContainerSync = Wh, le;
|
|
12945
|
+
}, Tt.exports.default = Tt.exports, Object.defineProperty(Tt.exports, "__esModule", { value: true }));
|
|
12946
|
+
})(Mg)), Mg.exports;
|
|
12947
|
+
}
|
|
12948
|
+
var Eb;
|
|
12949
|
+
function n0() {
|
|
12950
|
+
return Eb || (Eb = 1, process.env.NODE_ENV === "production" ? Rm.exports = Kb() : Rm.exports = e0()), Rm.exports;
|
|
12951
|
+
}
|
|
12952
|
+
var t0 = n0();
|
|
12953
|
+
const r0 = Xb(t0);
|
|
12954
|
+
|
|
12955
|
+
const DEFAULT_POINTER_ID = 0;
|
|
12956
|
+
const XR_POINTER_ID_START = 1e3;
|
|
12957
|
+
function getPointerState(internal, pointerId) {
|
|
12958
|
+
let state = internal.pointerMap.get(pointerId);
|
|
12959
|
+
if (!state) {
|
|
12960
|
+
state = {
|
|
12961
|
+
hovered: /* @__PURE__ */ new Map(),
|
|
12962
|
+
captured: /* @__PURE__ */ new Map(),
|
|
12963
|
+
initialClick: [0, 0],
|
|
12964
|
+
initialHits: []
|
|
12965
|
+
};
|
|
12966
|
+
internal.pointerMap.set(pointerId, state);
|
|
12967
|
+
}
|
|
12968
|
+
return state;
|
|
12969
|
+
}
|
|
12970
|
+
function getPointerId(event) {
|
|
12971
|
+
return "pointerId" in event ? event.pointerId : DEFAULT_POINTER_ID;
|
|
12972
|
+
}
|
|
12973
|
+
function makeId(event) {
|
|
12974
|
+
return (event.eventObject || event.object).uuid + "/" + event.index + event.instanceId;
|
|
12975
|
+
}
|
|
12976
|
+
function releaseInternalPointerCapture(internal, obj, pointerId) {
|
|
12977
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
12978
|
+
if (!pointerState) return;
|
|
12979
|
+
const captureData = pointerState.captured.get(obj);
|
|
12980
|
+
if (captureData) {
|
|
12981
|
+
pointerState.captured.delete(obj);
|
|
12982
|
+
try {
|
|
12983
|
+
captureData.target.releasePointerCapture?.(pointerId);
|
|
12984
|
+
} catch {
|
|
12985
|
+
}
|
|
12986
|
+
}
|
|
12987
|
+
}
|
|
12988
|
+
function swapInteractivity(store, object, newObject) {
|
|
12989
|
+
const { internal } = store.getState();
|
|
12990
|
+
for (let i = 0; i < internal.interaction.length; i++) {
|
|
12991
|
+
if (internal.interaction[i] === object) internal.interaction[i] = newObject;
|
|
12992
|
+
}
|
|
12993
|
+
for (const pointerState of internal.pointerMap.values()) {
|
|
12994
|
+
for (let i = 0; i < pointerState.initialHits.length; i++) {
|
|
12995
|
+
if (pointerState.initialHits[i] === object) pointerState.initialHits[i] = newObject;
|
|
12996
|
+
}
|
|
12997
|
+
pointerState.hovered.forEach((value, key) => {
|
|
12998
|
+
if (value.eventObject === object || value.object === object) {
|
|
12999
|
+
pointerState.hovered.delete(key);
|
|
13000
|
+
const next = {
|
|
13001
|
+
...value,
|
|
13002
|
+
eventObject: value.eventObject === object ? newObject : value.eventObject,
|
|
13003
|
+
object: value.object === object ? newObject : value.object
|
|
13004
|
+
};
|
|
13005
|
+
pointerState.hovered.set(makeId(next), next);
|
|
13006
|
+
}
|
|
13007
|
+
});
|
|
13008
|
+
const captureData = pointerState.captured.get(object);
|
|
13009
|
+
if (captureData) {
|
|
13010
|
+
pointerState.captured.delete(object);
|
|
13011
|
+
pointerState.captured.set(newObject, {
|
|
13012
|
+
...captureData,
|
|
13013
|
+
intersection: {
|
|
13014
|
+
...captureData.intersection,
|
|
13015
|
+
object: captureData.intersection.object === object ? newObject : captureData.intersection.object,
|
|
13016
|
+
eventObject: captureData.intersection.eventObject === object ? newObject : captureData.intersection.eventObject
|
|
13017
|
+
}
|
|
13018
|
+
});
|
|
13019
|
+
}
|
|
13020
|
+
}
|
|
13021
|
+
unregisterVisibility(store, object);
|
|
13022
|
+
}
|
|
13023
|
+
function removeInteractivity(store, object) {
|
|
13024
|
+
const { internal } = store.getState();
|
|
13025
|
+
internal.interaction = internal.interaction.filter((o) => o !== object);
|
|
13026
|
+
for (const [pointerId, pointerState] of internal.pointerMap) {
|
|
13027
|
+
pointerState.initialHits = pointerState.initialHits.filter((o) => o !== object);
|
|
13028
|
+
pointerState.hovered.forEach((value, key) => {
|
|
13029
|
+
if (value.eventObject === object || value.object === object) {
|
|
13030
|
+
pointerState.hovered.delete(key);
|
|
13031
|
+
}
|
|
13032
|
+
});
|
|
13033
|
+
if (pointerState.captured.has(object)) {
|
|
13034
|
+
releaseInternalPointerCapture(internal, object, pointerId);
|
|
13035
|
+
}
|
|
13036
|
+
}
|
|
13037
|
+
unregisterVisibility(store, object);
|
|
13038
|
+
}
|
|
13039
|
+
function createEvents(store) {
|
|
13040
|
+
function calculateDistance(event, pointerId) {
|
|
13041
|
+
const { internal } = store.getState();
|
|
13042
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13043
|
+
if (!pointerState) return 0;
|
|
13044
|
+
const [initialX, initialY] = pointerState.initialClick;
|
|
13045
|
+
const dx = event.offsetX - initialX;
|
|
13046
|
+
const dy = event.offsetY - initialY;
|
|
13047
|
+
return Math.round(Math.sqrt(dx * dx + dy * dy));
|
|
13048
|
+
}
|
|
13049
|
+
function filterPointerEvents(objects) {
|
|
13050
|
+
return objects.filter(
|
|
13051
|
+
(obj) => ["Move", "Over", "Enter", "Out", "Leave"].some(
|
|
13052
|
+
(name) => obj.__r3f?.handlers["onPointer" + name]
|
|
13053
|
+
) || ["OverEnter", "OverLeave", "Over"].some(
|
|
13054
|
+
(name) => obj.__r3f?.handlers["onDrag" + name]
|
|
13055
|
+
) || obj.__r3f?.handlers.onDrop
|
|
13056
|
+
);
|
|
13057
|
+
}
|
|
13058
|
+
function intersect(event, filter) {
|
|
13059
|
+
const state = store.getState();
|
|
13060
|
+
const duplicates = /* @__PURE__ */ new Set();
|
|
13061
|
+
const intersections = [];
|
|
13062
|
+
const eventsObjects = filter ? filter(state.internal.interaction) : state.internal.interaction;
|
|
13063
|
+
for (let i = 0; i < eventsObjects.length; i++) {
|
|
13064
|
+
const state2 = getRootState(eventsObjects[i]);
|
|
13065
|
+
if (state2) {
|
|
13066
|
+
state2.raycaster.camera = void 0;
|
|
13067
|
+
}
|
|
13068
|
+
}
|
|
13069
|
+
if (!state.previousRoot) {
|
|
13070
|
+
state.events.compute?.(event, state);
|
|
13071
|
+
}
|
|
13072
|
+
function handleRaycast(obj) {
|
|
13073
|
+
const state2 = getRootState(obj);
|
|
13074
|
+
if (!state2 || !state2.events.enabled || state2.raycaster.camera === null) return [];
|
|
13075
|
+
if (state2.raycaster.camera === void 0) {
|
|
13076
|
+
state2.events.compute?.(event, state2, state2.previousRoot?.getState());
|
|
13077
|
+
if (state2.raycaster.camera === void 0) state2.raycaster.camera = null;
|
|
13078
|
+
}
|
|
13079
|
+
if (!state2.raycaster.camera) return [];
|
|
13080
|
+
obj.updateWorldMatrix(true, true);
|
|
13081
|
+
return state2.raycaster.intersectObject(obj, true);
|
|
13082
|
+
}
|
|
13083
|
+
let hits = eventsObjects.flatMap(handleRaycast).sort((a, b) => {
|
|
13084
|
+
const aInteractivePriority = a.object.userData?.interactivePriority;
|
|
13085
|
+
const bInteractivePriority = b.object.userData?.interactivePriority;
|
|
13086
|
+
if (aInteractivePriority !== void 0 || bInteractivePriority !== void 0) {
|
|
13087
|
+
if (aInteractivePriority !== void 0 && bInteractivePriority === void 0) return -1;
|
|
13088
|
+
if (bInteractivePriority !== void 0 && aInteractivePriority === void 0) return 1;
|
|
13089
|
+
if (aInteractivePriority !== bInteractivePriority) {
|
|
13090
|
+
return (bInteractivePriority ?? 0) - (aInteractivePriority ?? 0);
|
|
13091
|
+
}
|
|
13092
|
+
}
|
|
13093
|
+
const aState = getRootState(a.object);
|
|
13094
|
+
const bState = getRootState(b.object);
|
|
13095
|
+
const aPriority = aState?.events?.priority ?? 1;
|
|
13096
|
+
const bPriority = bState?.events?.priority ?? 1;
|
|
13097
|
+
return bPriority - aPriority || a.distance - b.distance;
|
|
13098
|
+
}).filter((item) => {
|
|
13099
|
+
const id = makeId(item);
|
|
13100
|
+
if (duplicates.has(id)) return false;
|
|
13101
|
+
duplicates.add(id);
|
|
13102
|
+
return true;
|
|
13103
|
+
});
|
|
13104
|
+
if (state.events.filter) hits = state.events.filter(hits, state);
|
|
13105
|
+
for (const hit of hits) {
|
|
13106
|
+
let eventObject = hit.object;
|
|
13107
|
+
while (eventObject) {
|
|
13108
|
+
if (eventObject.__r3f?.eventCount) {
|
|
13109
|
+
intersections.push({ ...hit, eventObject });
|
|
13110
|
+
}
|
|
13111
|
+
eventObject = eventObject.parent;
|
|
13112
|
+
}
|
|
13113
|
+
}
|
|
13114
|
+
if ("pointerId" in event) {
|
|
13115
|
+
const pointerId = event.pointerId;
|
|
13116
|
+
const pointerState = state.internal.pointerMap.get(pointerId);
|
|
13117
|
+
if (pointerState?.captured.size) {
|
|
13118
|
+
for (const captureData of pointerState.captured.values()) {
|
|
13119
|
+
if (!duplicates.has(makeId(captureData.intersection))) intersections.push(captureData.intersection);
|
|
13120
|
+
}
|
|
13121
|
+
}
|
|
13122
|
+
}
|
|
13123
|
+
return intersections;
|
|
13124
|
+
}
|
|
13125
|
+
function handleIntersects(intersections, event, delta, callback) {
|
|
13126
|
+
if (intersections.length) {
|
|
13127
|
+
const localState = { stopped: false };
|
|
13128
|
+
for (const hit of intersections) {
|
|
13129
|
+
const state = getRootState(hit.object);
|
|
13130
|
+
if (state) {
|
|
13131
|
+
const { raycaster, pointer, camera, internal } = state;
|
|
13132
|
+
const unprojectedPoint = new three.Vector3(pointer.x, pointer.y, 0).unproject(camera);
|
|
13133
|
+
const hasPointerCapture = (id) => {
|
|
13134
|
+
const pointerState = internal.pointerMap.get(id);
|
|
13135
|
+
return pointerState?.captured.has(hit.eventObject) ?? false;
|
|
13136
|
+
};
|
|
13137
|
+
const setPointerCapture = (id) => {
|
|
13138
|
+
const captureData = { intersection: hit, target: event.target };
|
|
13139
|
+
const pointerState = getPointerState(internal, id);
|
|
13140
|
+
pointerState.captured.set(hit.eventObject, captureData);
|
|
13141
|
+
event.target.setPointerCapture(id);
|
|
13142
|
+
};
|
|
13143
|
+
const releasePointerCapture = (id) => {
|
|
13144
|
+
releaseInternalPointerCapture(internal, hit.eventObject, id);
|
|
13145
|
+
};
|
|
13146
|
+
const extractEventProps = {};
|
|
13147
|
+
for (const prop in event) {
|
|
13148
|
+
const property = event[prop];
|
|
13149
|
+
if (typeof property !== "function") extractEventProps[prop] = property;
|
|
13150
|
+
}
|
|
13151
|
+
const eventPointerId = "pointerId" in event ? event.pointerId : void 0;
|
|
13152
|
+
const raycastEvent = {
|
|
13153
|
+
...hit,
|
|
13154
|
+
...extractEventProps,
|
|
13155
|
+
pointer,
|
|
13156
|
+
intersections,
|
|
13157
|
+
stopped: localState.stopped,
|
|
13158
|
+
delta,
|
|
13159
|
+
unprojectedPoint,
|
|
13160
|
+
ray: raycaster.ray,
|
|
13161
|
+
camera,
|
|
13162
|
+
pointerId: eventPointerId,
|
|
13163
|
+
// Hijack stopPropagation, which just sets a flag
|
|
13164
|
+
stopPropagation() {
|
|
13165
|
+
const pointerState = eventPointerId !== void 0 ? internal.pointerMap.get(eventPointerId) : void 0;
|
|
13166
|
+
if (
|
|
13167
|
+
// ...if this pointer hasn't been captured
|
|
13168
|
+
!pointerState?.captured.size || // ... or if the hit object is capturing the pointer
|
|
13169
|
+
pointerState.captured.has(hit.eventObject)
|
|
13170
|
+
) {
|
|
13171
|
+
raycastEvent.stopped = localState.stopped = true;
|
|
13172
|
+
if (pointerState?.hovered.size && Array.from(pointerState.hovered.values()).find((i) => i.eventObject === hit.eventObject)) {
|
|
13173
|
+
const higher = intersections.slice(0, intersections.indexOf(hit));
|
|
13174
|
+
cancelPointer([...higher, hit], eventPointerId);
|
|
13175
|
+
}
|
|
13504
13176
|
}
|
|
13505
|
-
}
|
|
13506
|
-
|
|
13507
|
-
|
|
13508
|
-
|
|
13509
|
-
|
|
13177
|
+
},
|
|
13178
|
+
// there should be a distinction between target and currentTarget
|
|
13179
|
+
target: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
13180
|
+
currentTarget: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
13181
|
+
nativeEvent: event
|
|
13182
|
+
};
|
|
13183
|
+
callback(raycastEvent);
|
|
13184
|
+
if (localState.stopped === true) break;
|
|
13510
13185
|
}
|
|
13511
|
-
}
|
|
13512
|
-
|
|
13513
|
-
|
|
13514
|
-
|
|
13515
|
-
|
|
13516
|
-
|
|
13517
|
-
|
|
13518
|
-
|
|
13519
|
-
|
|
13520
|
-
|
|
13521
|
-
|
|
13522
|
-
|
|
13523
|
-
|
|
13524
|
-
|
|
13525
|
-
|
|
13526
|
-
|
|
13527
|
-
|
|
13186
|
+
}
|
|
13187
|
+
}
|
|
13188
|
+
return intersections;
|
|
13189
|
+
}
|
|
13190
|
+
function cancelPointer(intersections, pointerId) {
|
|
13191
|
+
const { internal } = store.getState();
|
|
13192
|
+
const pid = pointerId ?? DEFAULT_POINTER_ID;
|
|
13193
|
+
const pointerState = internal.pointerMap.get(pid);
|
|
13194
|
+
if (!pointerState) return;
|
|
13195
|
+
for (const [hoveredId, hoveredObj] of pointerState.hovered) {
|
|
13196
|
+
if (!intersections.length || !intersections.find(
|
|
13197
|
+
(hit) => hit.object === hoveredObj.object && hit.index === hoveredObj.index && hit.instanceId === hoveredObj.instanceId
|
|
13198
|
+
)) {
|
|
13199
|
+
const eventObject = hoveredObj.eventObject;
|
|
13200
|
+
const instance = eventObject.__r3f;
|
|
13201
|
+
pointerState.hovered.delete(hoveredId);
|
|
13202
|
+
if (instance?.eventCount) {
|
|
13203
|
+
const handlers = instance.handlers;
|
|
13204
|
+
const data = { ...hoveredObj, intersections };
|
|
13205
|
+
handlers.onPointerOut?.(data);
|
|
13206
|
+
handlers.onPointerLeave?.(data);
|
|
13207
|
+
handlers.onDragOverLeave?.(data);
|
|
13528
13208
|
}
|
|
13529
|
-
|
|
13530
|
-
|
|
13531
|
-
|
|
13532
|
-
|
|
13533
|
-
|
|
13534
|
-
|
|
13535
|
-
|
|
13536
|
-
|
|
13537
|
-
|
|
13538
|
-
|
|
13539
|
-
|
|
13540
|
-
|
|
13541
|
-
|
|
13542
|
-
|
|
13543
|
-
|
|
13544
|
-
|
|
13545
|
-
|
|
13546
|
-
|
|
13547
|
-
|
|
13548
|
-
|
|
13549
|
-
|
|
13550
|
-
|
|
13551
|
-
|
|
13552
|
-
|
|
13553
|
-
|
|
13554
|
-
|
|
13555
|
-
|
|
13556
|
-
|
|
13557
|
-
|
|
13558
|
-
|
|
13559
|
-
|
|
13560
|
-
|
|
13561
|
-
|
|
13562
|
-
an(o), x.T = n;
|
|
13209
|
+
}
|
|
13210
|
+
}
|
|
13211
|
+
}
|
|
13212
|
+
function pointerMissed(event, objects) {
|
|
13213
|
+
for (let i = 0; i < objects.length; i++) {
|
|
13214
|
+
const instance = objects[i].__r3f;
|
|
13215
|
+
instance?.handlers.onPointerMissed?.(event);
|
|
13216
|
+
}
|
|
13217
|
+
}
|
|
13218
|
+
function dragOverMissed(event, objects) {
|
|
13219
|
+
for (let i = 0; i < objects.length; i++) {
|
|
13220
|
+
const instance = objects[i].__r3f;
|
|
13221
|
+
instance?.handlers.onDragOverMissed?.(event);
|
|
13222
|
+
}
|
|
13223
|
+
}
|
|
13224
|
+
function dropMissed(event, objects) {
|
|
13225
|
+
for (let i = 0; i < objects.length; i++) {
|
|
13226
|
+
const instance = objects[i].__r3f;
|
|
13227
|
+
instance?.handlers.onDropMissed?.(event);
|
|
13228
|
+
}
|
|
13229
|
+
}
|
|
13230
|
+
function cleanupPointer(pointerId) {
|
|
13231
|
+
const { internal } = store.getState();
|
|
13232
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13233
|
+
if (pointerState) {
|
|
13234
|
+
for (const [, hoveredObj] of pointerState.hovered) {
|
|
13235
|
+
const eventObject = hoveredObj.eventObject;
|
|
13236
|
+
const instance = eventObject.__r3f;
|
|
13237
|
+
if (instance?.eventCount) {
|
|
13238
|
+
const handlers = instance.handlers;
|
|
13239
|
+
const data = { ...hoveredObj, intersections: [] };
|
|
13240
|
+
handlers.onPointerOut?.(data);
|
|
13241
|
+
handlers.onPointerLeave?.(data);
|
|
13563
13242
|
}
|
|
13564
|
-
}
|
|
13565
|
-
|
|
13566
|
-
|
|
13567
|
-
|
|
13568
|
-
|
|
13569
|
-
|
|
13243
|
+
}
|
|
13244
|
+
internal.pointerMap.delete(pointerId);
|
|
13245
|
+
}
|
|
13246
|
+
internal.pointerDirty.delete(pointerId);
|
|
13247
|
+
}
|
|
13248
|
+
function processDeferredPointer(event, pointerId) {
|
|
13249
|
+
const state = store.getState();
|
|
13250
|
+
const { internal } = state;
|
|
13251
|
+
if (!state.events.enabled) return;
|
|
13252
|
+
const filter = filterPointerEvents;
|
|
13253
|
+
const hits = intersect(event, filter);
|
|
13254
|
+
cancelPointer(hits, pointerId);
|
|
13255
|
+
function onIntersect(data) {
|
|
13256
|
+
const eventObject = data.eventObject;
|
|
13257
|
+
const instance = eventObject.__r3f;
|
|
13258
|
+
if (!instance?.eventCount) return;
|
|
13259
|
+
const handlers = instance.handlers;
|
|
13260
|
+
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
13261
|
+
const id = makeId(data);
|
|
13262
|
+
const pointerState = getPointerState(internal, pointerId);
|
|
13263
|
+
const hoveredItem = pointerState.hovered.get(id);
|
|
13264
|
+
if (!hoveredItem) {
|
|
13265
|
+
pointerState.hovered.set(id, data);
|
|
13266
|
+
handlers.onPointerOver?.(data);
|
|
13267
|
+
handlers.onPointerEnter?.(data);
|
|
13268
|
+
} else if (hoveredItem.stopped) {
|
|
13269
|
+
data.stopPropagation();
|
|
13570
13270
|
}
|
|
13571
|
-
}
|
|
13572
|
-
|
|
13573
|
-
|
|
13574
|
-
|
|
13575
|
-
|
|
13576
|
-
|
|
13577
|
-
|
|
13578
|
-
|
|
13579
|
-
|
|
13580
|
-
|
|
13581
|
-
|
|
13582
|
-
|
|
13583
|
-
|
|
13584
|
-
|
|
13585
|
-
|
|
13271
|
+
}
|
|
13272
|
+
handlers.onPointerMove?.(data);
|
|
13273
|
+
}
|
|
13274
|
+
handleIntersects(hits, event, 0, onIntersect);
|
|
13275
|
+
}
|
|
13276
|
+
function handlePointer(name) {
|
|
13277
|
+
switch (name) {
|
|
13278
|
+
case "onPointerLeave":
|
|
13279
|
+
case "onDragLeave":
|
|
13280
|
+
return () => cancelPointer([]);
|
|
13281
|
+
// Global cancel of these events
|
|
13282
|
+
case "onPointerCancel":
|
|
13283
|
+
return (event) => {
|
|
13284
|
+
const pointerId = getPointerId(event);
|
|
13285
|
+
cleanupPointer(pointerId);
|
|
13286
|
+
};
|
|
13287
|
+
case "onLostPointerCapture":
|
|
13288
|
+
return (event) => {
|
|
13289
|
+
const { internal } = store.getState();
|
|
13290
|
+
const pointerId = getPointerId(event);
|
|
13291
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13292
|
+
if (pointerState?.captured.size) {
|
|
13293
|
+
requestAnimationFrame(() => {
|
|
13294
|
+
const pointerState2 = internal.pointerMap.get(pointerId);
|
|
13295
|
+
if (pointerState2?.captured.size) {
|
|
13296
|
+
pointerState2.captured.clear();
|
|
13586
13297
|
}
|
|
13587
|
-
|
|
13588
|
-
|
|
13589
|
-
|
|
13298
|
+
cancelPointer([], pointerId);
|
|
13299
|
+
});
|
|
13300
|
+
}
|
|
13301
|
+
};
|
|
13302
|
+
}
|
|
13303
|
+
return function handleEvent(event) {
|
|
13304
|
+
const state = store.getState();
|
|
13305
|
+
const { onPointerMissed, onDragOverMissed, onDropMissed, internal, events } = state;
|
|
13306
|
+
const pointerId = getPointerId(event);
|
|
13307
|
+
internal.lastEvent.current = event;
|
|
13308
|
+
if (!events.enabled) return;
|
|
13309
|
+
const isPointerMove = name === "onPointerMove";
|
|
13310
|
+
const isDragOver = name === "onDragOver";
|
|
13311
|
+
const isDrop = name === "onDrop";
|
|
13312
|
+
const isClickEvent = name === "onClick" || name === "onContextMenu" || name === "onDoubleClick";
|
|
13313
|
+
const isPointerDown = name === "onPointerDown";
|
|
13314
|
+
const isPointerUp = name === "onPointerUp";
|
|
13315
|
+
const isWheel = name === "onWheel";
|
|
13316
|
+
const canDeferRaycasts = events.frameTimedRaycasts && state.frameloop === "always";
|
|
13317
|
+
if (isPointerMove && canDeferRaycasts) {
|
|
13318
|
+
events.compute?.(event, state);
|
|
13319
|
+
internal.pointerDirty.set(pointerId, event);
|
|
13320
|
+
return;
|
|
13321
|
+
}
|
|
13322
|
+
if (isWheel && canDeferRaycasts && !events.alwaysFireOnScroll) {
|
|
13323
|
+
events.compute?.(event, state);
|
|
13324
|
+
internal.pointerDirty.set(pointerId, event);
|
|
13325
|
+
return;
|
|
13326
|
+
}
|
|
13327
|
+
if ((isClickEvent || isPointerDown || isPointerUp) && internal.pointerDirty.has(pointerId)) {
|
|
13328
|
+
const deferredEvent = internal.pointerDirty.get(pointerId);
|
|
13329
|
+
internal.pointerDirty.delete(pointerId);
|
|
13330
|
+
processDeferredPointer(deferredEvent, pointerId);
|
|
13331
|
+
}
|
|
13332
|
+
const filter = isPointerMove || isDragOver || isDrop ? filterPointerEvents : void 0;
|
|
13333
|
+
const hits = intersect(event, filter);
|
|
13334
|
+
const delta = isClickEvent ? calculateDistance(event, pointerId) : 0;
|
|
13335
|
+
if (isPointerDown) {
|
|
13336
|
+
const pointerState2 = getPointerState(internal, pointerId);
|
|
13337
|
+
pointerState2.initialClick = [event.offsetX, event.offsetY];
|
|
13338
|
+
pointerState2.initialHits = hits.map((hit) => hit.eventObject);
|
|
13339
|
+
}
|
|
13340
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13341
|
+
const initialHits = pointerState?.initialHits ?? [];
|
|
13342
|
+
if (isClickEvent && !hits.length) {
|
|
13343
|
+
if (delta <= 2) {
|
|
13344
|
+
pointerMissed(event, internal.interaction);
|
|
13345
|
+
if (onPointerMissed) onPointerMissed(event);
|
|
13346
|
+
}
|
|
13347
|
+
}
|
|
13348
|
+
if (isDragOver && !hits.length) {
|
|
13349
|
+
dragOverMissed(event, internal.interaction);
|
|
13350
|
+
if (onDragOverMissed) onDragOverMissed(event);
|
|
13351
|
+
}
|
|
13352
|
+
if (isDrop && !hits.length) {
|
|
13353
|
+
dropMissed(event, internal.interaction);
|
|
13354
|
+
if (onDropMissed) onDropMissed(event);
|
|
13355
|
+
}
|
|
13356
|
+
if (isPointerMove || isDragOver) {
|
|
13357
|
+
cancelPointer(hits, pointerId);
|
|
13358
|
+
}
|
|
13359
|
+
function onIntersect(data) {
|
|
13360
|
+
const eventObject = data.eventObject;
|
|
13361
|
+
const instance = eventObject.__r3f;
|
|
13362
|
+
if (!instance?.eventCount) return;
|
|
13363
|
+
const handlers = instance.handlers;
|
|
13364
|
+
if (isPointerMove) {
|
|
13365
|
+
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
13366
|
+
const id = makeId(data);
|
|
13367
|
+
const pointerState2 = getPointerState(internal, pointerId);
|
|
13368
|
+
const hoveredItem = pointerState2.hovered.get(id);
|
|
13369
|
+
if (!hoveredItem) {
|
|
13370
|
+
pointerState2.hovered.set(id, data);
|
|
13371
|
+
handlers.onPointerOver?.(data);
|
|
13372
|
+
handlers.onPointerEnter?.(data);
|
|
13373
|
+
} else if (hoveredItem.stopped) {
|
|
13374
|
+
data.stopPropagation();
|
|
13590
13375
|
}
|
|
13591
13376
|
}
|
|
13592
|
-
|
|
13593
|
-
|
|
13594
|
-
|
|
13595
|
-
|
|
13596
|
-
|
|
13597
|
-
|
|
13598
|
-
|
|
13599
|
-
|
|
13600
|
-
|
|
13601
|
-
|
|
13602
|
-
|
|
13603
|
-
|
|
13604
|
-
if (
|
|
13605
|
-
|
|
13606
|
-
|
|
13607
|
-
|
|
13608
|
-
|
|
13609
|
-
|
|
13610
|
-
|
|
13611
|
-
|
|
13612
|
-
|
|
13613
|
-
|
|
13614
|
-
|
|
13615
|
-
|
|
13616
|
-
|
|
13617
|
-
|
|
13618
|
-
|
|
13619
|
-
|
|
13620
|
-
|
|
13621
|
-
|
|
13622
|
-
|
|
13623
|
-
var o = n[e++], i = o.tag;
|
|
13624
|
-
if (!Kr(o)) {
|
|
13625
|
-
if ((i === 5 || i === 26 || i === 27) && Ft(o.stateNode)) return true;
|
|
13626
|
-
for (o = o.child; o !== null; ) n.push(o), o = o.sibling;
|
|
13377
|
+
handlers.onPointerMove?.(data);
|
|
13378
|
+
} else if (isDragOver) {
|
|
13379
|
+
const id = makeId(data);
|
|
13380
|
+
const pointerState2 = getPointerState(internal, pointerId);
|
|
13381
|
+
const hoveredItem = pointerState2.hovered.get(id);
|
|
13382
|
+
if (!hoveredItem) {
|
|
13383
|
+
pointerState2.hovered.set(id, data);
|
|
13384
|
+
handlers.onDragOverEnter?.(data);
|
|
13385
|
+
} else if (hoveredItem.stopped) {
|
|
13386
|
+
data.stopPropagation();
|
|
13387
|
+
}
|
|
13388
|
+
handlers.onDragOver?.(data);
|
|
13389
|
+
} else if (isDrop) {
|
|
13390
|
+
handlers.onDrop?.(data);
|
|
13391
|
+
} else {
|
|
13392
|
+
const handler = handlers[name];
|
|
13393
|
+
if (handler) {
|
|
13394
|
+
if (!isClickEvent || initialHits.includes(eventObject)) {
|
|
13395
|
+
pointerMissed(
|
|
13396
|
+
event,
|
|
13397
|
+
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
13398
|
+
);
|
|
13399
|
+
handler(data);
|
|
13400
|
+
}
|
|
13401
|
+
} else {
|
|
13402
|
+
if (isClickEvent && initialHits.includes(eventObject)) {
|
|
13403
|
+
pointerMissed(
|
|
13404
|
+
event,
|
|
13405
|
+
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
13406
|
+
);
|
|
13407
|
+
}
|
|
13627
13408
|
}
|
|
13628
13409
|
}
|
|
13629
|
-
|
|
13630
|
-
|
|
13631
|
-
|
|
13632
|
-
|
|
13633
|
-
|
|
13634
|
-
|
|
13635
|
-
|
|
13636
|
-
|
|
13410
|
+
}
|
|
13411
|
+
handleIntersects(hits, event, delta, onIntersect);
|
|
13412
|
+
};
|
|
13413
|
+
}
|
|
13414
|
+
function flushDeferredPointers() {
|
|
13415
|
+
const { internal, events } = store.getState();
|
|
13416
|
+
if (!events.frameTimedRaycasts) return;
|
|
13417
|
+
for (const [pointerId, event] of internal.pointerDirty) {
|
|
13418
|
+
processDeferredPointer(event, pointerId);
|
|
13419
|
+
}
|
|
13420
|
+
internal.pointerDirty.clear();
|
|
13421
|
+
}
|
|
13422
|
+
return { handlePointer, flushDeferredPointers, processDeferredPointer };
|
|
13423
|
+
}
|
|
13424
|
+
const DOM_EVENTS = {
|
|
13425
|
+
onClick: ["click", false],
|
|
13426
|
+
onContextMenu: ["contextmenu", false],
|
|
13427
|
+
onDoubleClick: ["dblclick", false],
|
|
13428
|
+
onDragEnter: ["dragenter", false],
|
|
13429
|
+
onDragLeave: ["dragleave", false],
|
|
13430
|
+
onDragOver: ["dragover", false],
|
|
13431
|
+
onDrop: ["drop", false],
|
|
13432
|
+
onWheel: ["wheel", true],
|
|
13433
|
+
onPointerDown: ["pointerdown", true],
|
|
13434
|
+
onPointerUp: ["pointerup", true],
|
|
13435
|
+
onPointerLeave: ["pointerleave", true],
|
|
13436
|
+
onPointerMove: ["pointermove", true],
|
|
13437
|
+
onPointerCancel: ["pointercancel", true],
|
|
13438
|
+
onLostPointerCapture: ["lostpointercapture", true]
|
|
13439
|
+
};
|
|
13440
|
+
function createPointerEvents(store) {
|
|
13441
|
+
const { handlePointer, flushDeferredPointers, processDeferredPointer } = createEvents(store);
|
|
13442
|
+
let nextXRPointerId = XR_POINTER_ID_START;
|
|
13443
|
+
const xrPointers = /* @__PURE__ */ new Map();
|
|
13444
|
+
return {
|
|
13445
|
+
priority: 1,
|
|
13446
|
+
enabled: true,
|
|
13447
|
+
frameTimedRaycasts: true,
|
|
13448
|
+
alwaysFireOnScroll: true,
|
|
13449
|
+
updateOnFrame: false,
|
|
13450
|
+
compute(event, state) {
|
|
13451
|
+
state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
|
|
13452
|
+
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
13453
|
+
},
|
|
13454
|
+
connected: void 0,
|
|
13455
|
+
handlers: Object.keys(DOM_EVENTS).reduce(
|
|
13456
|
+
(acc, key) => ({ ...acc, [key]: handlePointer(key) }),
|
|
13457
|
+
{}
|
|
13458
|
+
),
|
|
13459
|
+
update: (pointerId) => {
|
|
13460
|
+
const { events, internal } = store.getState();
|
|
13461
|
+
if (!events.handlers) return;
|
|
13462
|
+
if (pointerId !== void 0) {
|
|
13463
|
+
const event = internal.pointerDirty.get(pointerId);
|
|
13464
|
+
if (event) {
|
|
13465
|
+
internal.pointerDirty.delete(pointerId);
|
|
13466
|
+
processDeferredPointer(event, pointerId);
|
|
13467
|
+
} else if (internal.lastEvent?.current) {
|
|
13468
|
+
processDeferredPointer(internal.lastEvent.current, pointerId);
|
|
13637
13469
|
}
|
|
13638
|
-
|
|
13639
|
-
|
|
13640
|
-
|
|
13641
|
-
|
|
13642
|
-
|
|
13643
|
-
No matching component was found for:
|
|
13644
|
-
`) + e.join(" > ");
|
|
13470
|
+
} else {
|
|
13471
|
+
flushDeferredPointers();
|
|
13472
|
+
if (internal.lastEvent?.current) {
|
|
13473
|
+
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
13645
13474
|
}
|
|
13646
|
-
|
|
13647
|
-
|
|
13648
|
-
|
|
13649
|
-
|
|
13650
|
-
|
|
13651
|
-
|
|
13652
|
-
|
|
13653
|
-
|
|
13654
|
-
|
|
13475
|
+
}
|
|
13476
|
+
},
|
|
13477
|
+
flush: () => {
|
|
13478
|
+
const { events, internal } = store.getState();
|
|
13479
|
+
flushDeferredPointers();
|
|
13480
|
+
if (events.updateOnFrame && internal.lastEvent?.current && events.handlers) {
|
|
13481
|
+
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
13482
|
+
}
|
|
13483
|
+
},
|
|
13484
|
+
connect: (target) => {
|
|
13485
|
+
if (!target) return;
|
|
13486
|
+
const { set, events } = store.getState();
|
|
13487
|
+
events.disconnect?.();
|
|
13488
|
+
set((state) => ({ events: { ...state.events, connected: target } }));
|
|
13489
|
+
if (events.handlers) {
|
|
13490
|
+
for (const name in events.handlers) {
|
|
13491
|
+
const event = events.handlers[name];
|
|
13492
|
+
const [eventName, passive] = DOM_EVENTS[name];
|
|
13493
|
+
target.addEventListener(eventName, event, { passive });
|
|
13655
13494
|
}
|
|
13656
|
-
}
|
|
13657
|
-
|
|
13658
|
-
|
|
13659
|
-
|
|
13660
|
-
|
|
13661
|
-
|
|
13662
|
-
|
|
13663
|
-
|
|
13664
|
-
|
|
13665
|
-
|
|
13666
|
-
}
|
|
13495
|
+
}
|
|
13496
|
+
},
|
|
13497
|
+
disconnect: () => {
|
|
13498
|
+
const { set, events } = store.getState();
|
|
13499
|
+
if (events.connected) {
|
|
13500
|
+
if (events.handlers) {
|
|
13501
|
+
for (const name in events.handlers) {
|
|
13502
|
+
const event = events.handlers[name];
|
|
13503
|
+
const [eventName] = DOM_EVENTS[name];
|
|
13504
|
+
events.connected.removeEventListener(eventName, event);
|
|
13505
|
+
}
|
|
13506
|
+
}
|
|
13507
|
+
set((state) => ({ events: { ...state.events, connected: void 0 } }));
|
|
13508
|
+
}
|
|
13509
|
+
},
|
|
13510
|
+
// PREVIEW (A8): the XR pointer registration API may change before stable.
|
|
13511
|
+
registerPointer: (config) => {
|
|
13512
|
+
const pointerId = nextXRPointerId++;
|
|
13513
|
+
xrPointers.set(pointerId, config);
|
|
13514
|
+
const { internal } = store.getState();
|
|
13515
|
+
getPointerState(internal, pointerId);
|
|
13516
|
+
return pointerId;
|
|
13517
|
+
},
|
|
13518
|
+
unregisterPointer: (pointerId) => {
|
|
13519
|
+
xrPointers.delete(pointerId);
|
|
13520
|
+
const { internal } = store.getState();
|
|
13521
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13522
|
+
if (pointerState) {
|
|
13523
|
+
for (const [, hoveredObj] of pointerState.hovered) {
|
|
13524
|
+
const eventObject = hoveredObj.eventObject;
|
|
13525
|
+
const instance = eventObject.__r3f;
|
|
13526
|
+
if (instance?.eventCount) {
|
|
13527
|
+
const handlers = instance.handlers;
|
|
13528
|
+
const data = { ...hoveredObj, intersections: [] };
|
|
13529
|
+
handlers.onPointerOut?.(data);
|
|
13530
|
+
handlers.onPointerLeave?.(data);
|
|
13531
|
+
}
|
|
13667
13532
|
}
|
|
13668
|
-
|
|
13669
|
-
|
|
13670
|
-
|
|
13671
|
-
|
|
13672
|
-
|
|
13673
|
-
var S = bm.indexOf(s);
|
|
13674
|
-
0 <= S && bm.splice(S, 1), f();
|
|
13675
|
-
} };
|
|
13676
|
-
}, le.shouldError = function(e) {
|
|
13677
|
-
return pu(e);
|
|
13678
|
-
}, le.shouldSuspend = function(e) {
|
|
13679
|
-
return fu(e);
|
|
13680
|
-
}, le.startHostTransition = function(e, n, o, i) {
|
|
13681
|
-
if (e.tag !== 5) throw Error("Expected the form instance to be a HostComponent. This is a bug in React.");
|
|
13682
|
-
var s = uf(e).queue;
|
|
13683
|
-
Hp(e), nt(e, s, n, Xt, o === null ? Em : function() {
|
|
13684
|
-
x.T === null && console.error("requestFormReset was called outside a transition or action. To fix, move to an action, or wrap with startTransition.");
|
|
13685
|
-
var u = uf(e);
|
|
13686
|
-
return u.next === null && (u = e.alternate.memoizedState), qi(e, u.next.queue, {}, Nt(e)), o(i);
|
|
13687
|
-
});
|
|
13688
|
-
}, le.updateContainer = function(e, n, o, i) {
|
|
13689
|
-
var s = n.current, u = Nt(s);
|
|
13690
|
-
return As(s, u, e, n, o, i), u;
|
|
13691
|
-
}, le.updateContainerSync = Wh, le;
|
|
13692
|
-
}, Tt.exports.default = Tt.exports, Object.defineProperty(Tt.exports, "__esModule", { value: true }));
|
|
13693
|
-
})(Mg)), Mg.exports;
|
|
13694
|
-
}
|
|
13695
|
-
var Eb;
|
|
13696
|
-
function n0() {
|
|
13697
|
-
return Eb || (Eb = 1, process.env.NODE_ENV === "production" ? Rm.exports = Kb() : Rm.exports = e0()), Rm.exports;
|
|
13533
|
+
internal.pointerMap.delete(pointerId);
|
|
13534
|
+
}
|
|
13535
|
+
internal.pointerDirty.delete(pointerId);
|
|
13536
|
+
}
|
|
13537
|
+
};
|
|
13698
13538
|
}
|
|
13699
|
-
var t0 = n0();
|
|
13700
|
-
const r0 = Xb(t0);
|
|
13701
|
-
|
|
13702
|
-
const t = 1, o = 8, r = 32, e = 2;
|
|
13703
13539
|
|
|
13704
13540
|
function createReconciler(config) {
|
|
13705
13541
|
const reconciler2 = r0(config);
|
|
@@ -13864,7 +13700,15 @@ function setFiberRef(fiber, publicInstance) {
|
|
|
13864
13700
|
}
|
|
13865
13701
|
}
|
|
13866
13702
|
const reconstructed = [];
|
|
13867
|
-
function
|
|
13703
|
+
function flushReconstructedInstances() {
|
|
13704
|
+
if (reconstructed.length === 0) return;
|
|
13705
|
+
try {
|
|
13706
|
+
swapReconstructedInstances();
|
|
13707
|
+
} finally {
|
|
13708
|
+
reconstructed.length = 0;
|
|
13709
|
+
}
|
|
13710
|
+
}
|
|
13711
|
+
function swapReconstructedInstances() {
|
|
13868
13712
|
for (const [instance] of reconstructed) {
|
|
13869
13713
|
const parent = instance.parent;
|
|
13870
13714
|
if (parent) {
|
|
@@ -13882,7 +13726,9 @@ function swapInstances() {
|
|
|
13882
13726
|
}
|
|
13883
13727
|
}
|
|
13884
13728
|
if (instance.isHidden) unhideInstance(instance);
|
|
13885
|
-
if (isObject3D(instance.object)
|
|
13729
|
+
if (isObject3D(instance.object) && !instance.parent) {
|
|
13730
|
+
removeInteractivity(findInitialRoot(instance), instance.object);
|
|
13731
|
+
}
|
|
13886
13732
|
if (instance.object.__r3f) delete instance.object.__r3f;
|
|
13887
13733
|
if (instance.type !== "primitive") disposeOnIdle(instance.object);
|
|
13888
13734
|
}
|
|
@@ -13891,9 +13737,13 @@ function swapInstances() {
|
|
|
13891
13737
|
const parent = instance.parent;
|
|
13892
13738
|
if (parent) {
|
|
13893
13739
|
const target = catalogue[toPascalCase(instance.type)];
|
|
13740
|
+
const prevObject = instance.object;
|
|
13894
13741
|
instance.object = instance.props.object ?? new target(...instance.props.args ?? []);
|
|
13895
13742
|
instance.object.__r3f = instance;
|
|
13896
13743
|
setFiberRef(fiber, instance.object);
|
|
13744
|
+
if (isObject3D(prevObject) && isObject3D(instance.object)) {
|
|
13745
|
+
swapInteractivity(findInitialRoot(instance), prevObject, instance.object);
|
|
13746
|
+
}
|
|
13897
13747
|
delete instance.appliedOnce;
|
|
13898
13748
|
instance.eventCount = 0;
|
|
13899
13749
|
instance.handlers = {};
|
|
@@ -13913,14 +13763,114 @@ function swapInstances() {
|
|
|
13913
13763
|
invalidateInstance(instance);
|
|
13914
13764
|
}
|
|
13915
13765
|
}
|
|
13916
|
-
reconstructed.length = 0;
|
|
13917
13766
|
}
|
|
13918
13767
|
const handleTextInstance = () => {
|
|
13919
13768
|
};
|
|
13920
13769
|
const NO_CONTEXT = {};
|
|
13921
13770
|
let currentUpdatePriority = NoEventPriority;
|
|
13922
|
-
|
|
13923
|
-
|
|
13771
|
+
function getEventPriority(type) {
|
|
13772
|
+
switch (type) {
|
|
13773
|
+
case "beforetoggle":
|
|
13774
|
+
case "cancel":
|
|
13775
|
+
case "click":
|
|
13776
|
+
case "close":
|
|
13777
|
+
case "contextmenu":
|
|
13778
|
+
case "copy":
|
|
13779
|
+
case "cut":
|
|
13780
|
+
case "auxclick":
|
|
13781
|
+
case "dblclick":
|
|
13782
|
+
case "dragend":
|
|
13783
|
+
case "dragstart":
|
|
13784
|
+
case "drop":
|
|
13785
|
+
case "focusin":
|
|
13786
|
+
case "focusout":
|
|
13787
|
+
case "input":
|
|
13788
|
+
case "invalid":
|
|
13789
|
+
case "keydown":
|
|
13790
|
+
case "keypress":
|
|
13791
|
+
case "keyup":
|
|
13792
|
+
case "mousedown":
|
|
13793
|
+
case "mouseup":
|
|
13794
|
+
case "paste":
|
|
13795
|
+
case "pause":
|
|
13796
|
+
case "play":
|
|
13797
|
+
case "pointercancel":
|
|
13798
|
+
case "pointerdown":
|
|
13799
|
+
case "pointerup":
|
|
13800
|
+
case "ratechange":
|
|
13801
|
+
case "reset":
|
|
13802
|
+
case "resize":
|
|
13803
|
+
case "seeked":
|
|
13804
|
+
case "submit":
|
|
13805
|
+
case "touchcancel":
|
|
13806
|
+
case "touchend":
|
|
13807
|
+
case "touchstart":
|
|
13808
|
+
case "volumechange":
|
|
13809
|
+
case "change":
|
|
13810
|
+
case "selectionchange":
|
|
13811
|
+
case "compositionstart":
|
|
13812
|
+
case "compositionend":
|
|
13813
|
+
case "compositionupdate":
|
|
13814
|
+
case "beforeinput":
|
|
13815
|
+
case "blur":
|
|
13816
|
+
case "fullscreenchange":
|
|
13817
|
+
case "focus":
|
|
13818
|
+
case "hashchange":
|
|
13819
|
+
case "popstate":
|
|
13820
|
+
case "select":
|
|
13821
|
+
case "selectstart":
|
|
13822
|
+
return e;
|
|
13823
|
+
case "drag":
|
|
13824
|
+
case "dragenter":
|
|
13825
|
+
case "dragexit":
|
|
13826
|
+
case "dragleave":
|
|
13827
|
+
case "dragover":
|
|
13828
|
+
case "mousemove":
|
|
13829
|
+
case "mouseout":
|
|
13830
|
+
case "mouseover":
|
|
13831
|
+
case "pointermove":
|
|
13832
|
+
case "pointerout":
|
|
13833
|
+
case "pointerover":
|
|
13834
|
+
case "scroll":
|
|
13835
|
+
case "touchmove":
|
|
13836
|
+
case "wheel":
|
|
13837
|
+
case "mouseenter":
|
|
13838
|
+
case "mouseleave":
|
|
13839
|
+
case "pointerenter":
|
|
13840
|
+
case "pointerleave":
|
|
13841
|
+
return o;
|
|
13842
|
+
case "message": {
|
|
13843
|
+
switch (Tb.unstable_getCurrentPriorityLevel()) {
|
|
13844
|
+
case Tb.unstable_ImmediatePriority:
|
|
13845
|
+
return e;
|
|
13846
|
+
case Tb.unstable_UserBlockingPriority:
|
|
13847
|
+
return o;
|
|
13848
|
+
case Tb.unstable_NormalPriority:
|
|
13849
|
+
case Tb.unstable_LowPriority:
|
|
13850
|
+
return r;
|
|
13851
|
+
case Tb.unstable_IdlePriority:
|
|
13852
|
+
return i$1;
|
|
13853
|
+
default:
|
|
13854
|
+
return r;
|
|
13855
|
+
}
|
|
13856
|
+
}
|
|
13857
|
+
default:
|
|
13858
|
+
return r;
|
|
13859
|
+
}
|
|
13860
|
+
}
|
|
13861
|
+
function scheduleMicrotask(callback) {
|
|
13862
|
+
if (typeof queueMicrotask === "function") {
|
|
13863
|
+
queueMicrotask(callback);
|
|
13864
|
+
} else if (typeof Promise !== "undefined") {
|
|
13865
|
+
Promise.resolve().then(callback).catch((error) => {
|
|
13866
|
+
setTimeout(() => {
|
|
13867
|
+
throw error;
|
|
13868
|
+
});
|
|
13869
|
+
});
|
|
13870
|
+
} else {
|
|
13871
|
+
setTimeout(callback);
|
|
13872
|
+
}
|
|
13873
|
+
}
|
|
13924
13874
|
const reconciler = /* @__PURE__ */ createReconciler({
|
|
13925
13875
|
isPrimaryRenderer: false,
|
|
13926
13876
|
warnsIfNotActing: false,
|
|
@@ -13959,16 +13909,15 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13959
13909
|
else if (newProps.args?.length !== oldProps.args?.length) reconstruct = true;
|
|
13960
13910
|
else if (newProps.args?.some((value, index) => value !== oldProps.args?.[index])) reconstruct = true;
|
|
13961
13911
|
if (reconstruct) {
|
|
13962
|
-
reconstructed.push([instance,
|
|
13912
|
+
reconstructed.push([instance, getInstanceProps(newProps), fiber]);
|
|
13963
13913
|
} else {
|
|
13964
13914
|
const changedProps = diffProps(instance, newProps);
|
|
13965
|
-
|
|
13966
|
-
|
|
13967
|
-
|
|
13968
|
-
|
|
13915
|
+
const attach2 = instance.props.attach;
|
|
13916
|
+
instance.props = getInstanceProps(newProps);
|
|
13917
|
+
if (attach2 !== void 0) instance.props.attach = attach2;
|
|
13918
|
+
else delete instance.props.attach;
|
|
13919
|
+
if (Object.keys(changedProps).length) applyProps(instance.object, changedProps);
|
|
13969
13920
|
}
|
|
13970
|
-
const isTailSibling = fiber.sibling === null || (fiber.flags & Update) === NoFlags;
|
|
13971
|
-
if (isTailSibling) swapInstances();
|
|
13972
13921
|
},
|
|
13973
13922
|
finalizeInitialChildren: (instance) => {
|
|
13974
13923
|
for (const prop in instance.props) {
|
|
@@ -13993,8 +13942,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13993
13942
|
const target = container.getState().internal.container ?? container.getState().scene;
|
|
13994
13943
|
return prepare(target, container, "", {});
|
|
13995
13944
|
},
|
|
13996
|
-
|
|
13997
|
-
|
|
13945
|
+
// Reconstructed instances are swapped once all mutations are committed,
|
|
13946
|
+
// before layout effects run so refs point to the new objects
|
|
13947
|
+
resetAfterCommit: flushReconstructedInstances,
|
|
13998
13948
|
shouldSetTextContent: () => false,
|
|
13999
13949
|
clearContainer: () => false,
|
|
14000
13950
|
hideInstance,
|
|
@@ -14002,6 +13952,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
14002
13952
|
createTextInstance: handleTextInstance,
|
|
14003
13953
|
hideTextInstance: handleTextInstance,
|
|
14004
13954
|
unhideTextInstance: handleTextInstance,
|
|
13955
|
+
// Mirrors react-dom, which flushes discrete work in microtasks
|
|
13956
|
+
supportsMicrotasks: true,
|
|
13957
|
+
scheduleMicrotask,
|
|
14005
13958
|
scheduleTimeout: typeof setTimeout === "function" ? setTimeout : void 0,
|
|
14006
13959
|
cancelTimeout: typeof clearTimeout === "function" ? clearTimeout : void 0,
|
|
14007
13960
|
noTimeout: -1,
|
|
@@ -14042,28 +13995,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
14042
13995
|
},
|
|
14043
13996
|
resolveUpdatePriority() {
|
|
14044
13997
|
if (currentUpdatePriority !== NoEventPriority) return currentUpdatePriority;
|
|
14045
|
-
|
|
14046
|
-
|
|
14047
|
-
|
|
14048
|
-
case "dblclick":
|
|
14049
|
-
case "dragenter":
|
|
14050
|
-
case "dragleave":
|
|
14051
|
-
case "drop":
|
|
14052
|
-
case "pointercancel":
|
|
14053
|
-
case "pointerdown":
|
|
14054
|
-
case "pointerup":
|
|
14055
|
-
return e;
|
|
14056
|
-
case "dragover":
|
|
14057
|
-
case "pointermove":
|
|
14058
|
-
case "pointerout":
|
|
14059
|
-
case "pointerover":
|
|
14060
|
-
case "pointerenter":
|
|
14061
|
-
case "pointerleave":
|
|
14062
|
-
case "wheel":
|
|
14063
|
-
return o;
|
|
14064
|
-
default:
|
|
14065
|
-
return r;
|
|
14066
|
-
}
|
|
13998
|
+
const eventType = typeof window !== "undefined" ? window.event?.type : void 0;
|
|
13999
|
+
if (eventType === void 0) return r;
|
|
14000
|
+
return getEventPriority(eventType);
|
|
14067
14001
|
},
|
|
14068
14002
|
resetFormInstance() {
|
|
14069
14003
|
},
|
|
@@ -14472,6 +14406,10 @@ function createRoot(canvas) {
|
|
|
14472
14406
|
if (state2.internal.isMultiCanvas && state2.internal.canvasTarget) {
|
|
14473
14407
|
const renderer2 = state2.internal.actualRenderer;
|
|
14474
14408
|
renderer2.setCanvasTarget(state2.internal.canvasTarget);
|
|
14409
|
+
if (state2.internal.canvasTargetSizeDirty) {
|
|
14410
|
+
state2.internal.canvasTargetSizeDirty = false;
|
|
14411
|
+
renderer2.backend?.updateSize?.();
|
|
14412
|
+
}
|
|
14475
14413
|
}
|
|
14476
14414
|
},
|
|
14477
14415
|
{
|
|
@@ -14628,7 +14566,8 @@ function unmountComponentAtNode(canvas, callback) {
|
|
|
14628
14566
|
dispose(state.scene);
|
|
14629
14567
|
_roots.delete(canvas);
|
|
14630
14568
|
if (callback) callback(canvas);
|
|
14631
|
-
} catch {
|
|
14569
|
+
} catch (error) {
|
|
14570
|
+
console.warn("[R3F] Error while unmounting root; teardown may be incomplete:", error);
|
|
14632
14571
|
}
|
|
14633
14572
|
}, 500);
|
|
14634
14573
|
}
|
|
@@ -14739,6 +14678,212 @@ function flushSync(fn) {
|
|
|
14739
14678
|
return reconciler.flushSyncFromReconciler(fn);
|
|
14740
14679
|
}
|
|
14741
14680
|
|
|
14681
|
+
const isRef = (obj) => obj.current && obj.current.isScene;
|
|
14682
|
+
const resolveScene = (scene) => isRef(scene) ? scene.current : scene;
|
|
14683
|
+
function setEnvProps(background, scene, defaultScene, texture, sceneProps = {}) {
|
|
14684
|
+
sceneProps = {
|
|
14685
|
+
backgroundBlurriness: 0,
|
|
14686
|
+
backgroundIntensity: 1,
|
|
14687
|
+
backgroundRotation: [0, 0, 0],
|
|
14688
|
+
environmentIntensity: 1,
|
|
14689
|
+
environmentRotation: [0, 0, 0],
|
|
14690
|
+
...sceneProps
|
|
14691
|
+
};
|
|
14692
|
+
const target = resolveScene(scene || defaultScene);
|
|
14693
|
+
const oldbg = target.background;
|
|
14694
|
+
const oldenv = target.environment;
|
|
14695
|
+
const oldSceneProps = {
|
|
14696
|
+
// @ts-ignore
|
|
14697
|
+
backgroundBlurriness: target.backgroundBlurriness,
|
|
14698
|
+
// @ts-ignore
|
|
14699
|
+
backgroundIntensity: target.backgroundIntensity,
|
|
14700
|
+
// @ts-ignore
|
|
14701
|
+
backgroundRotation: target.backgroundRotation?.clone?.() ?? [0, 0, 0],
|
|
14702
|
+
// @ts-ignore
|
|
14703
|
+
environmentIntensity: target.environmentIntensity,
|
|
14704
|
+
// @ts-ignore
|
|
14705
|
+
environmentRotation: target.environmentRotation?.clone?.() ?? [0, 0, 0]
|
|
14706
|
+
};
|
|
14707
|
+
if (background !== "only") target.environment = texture;
|
|
14708
|
+
if (background) target.background = texture;
|
|
14709
|
+
applyProps(target, sceneProps);
|
|
14710
|
+
return () => {
|
|
14711
|
+
if (background !== "only") target.environment = oldenv;
|
|
14712
|
+
if (background) target.background = oldbg;
|
|
14713
|
+
applyProps(target, oldSceneProps);
|
|
14714
|
+
};
|
|
14715
|
+
}
|
|
14716
|
+
function EnvironmentMap({ scene, background = false, map, ...config }) {
|
|
14717
|
+
const defaultScene = useThree((state) => state.scene);
|
|
14718
|
+
React__namespace.useLayoutEffect(() => {
|
|
14719
|
+
if (map) return setEnvProps(background, scene, defaultScene, map, config);
|
|
14720
|
+
});
|
|
14721
|
+
return null;
|
|
14722
|
+
}
|
|
14723
|
+
function EnvironmentCube({
|
|
14724
|
+
background = false,
|
|
14725
|
+
scene,
|
|
14726
|
+
blur,
|
|
14727
|
+
backgroundBlurriness,
|
|
14728
|
+
backgroundIntensity,
|
|
14729
|
+
backgroundRotation,
|
|
14730
|
+
environmentIntensity,
|
|
14731
|
+
environmentRotation,
|
|
14732
|
+
...rest
|
|
14733
|
+
}) {
|
|
14734
|
+
const texture = useEnvironment(rest);
|
|
14735
|
+
const defaultScene = useThree((state) => state.scene);
|
|
14736
|
+
React__namespace.useLayoutEffect(() => {
|
|
14737
|
+
return setEnvProps(background, scene, defaultScene, texture, {
|
|
14738
|
+
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
14739
|
+
backgroundIntensity,
|
|
14740
|
+
backgroundRotation,
|
|
14741
|
+
environmentIntensity,
|
|
14742
|
+
environmentRotation
|
|
14743
|
+
});
|
|
14744
|
+
});
|
|
14745
|
+
React__namespace.useEffect(() => {
|
|
14746
|
+
return () => {
|
|
14747
|
+
texture.dispose();
|
|
14748
|
+
};
|
|
14749
|
+
}, [texture]);
|
|
14750
|
+
return null;
|
|
14751
|
+
}
|
|
14752
|
+
function EnvironmentPortal({
|
|
14753
|
+
children,
|
|
14754
|
+
near = 0.1,
|
|
14755
|
+
far = 1e3,
|
|
14756
|
+
resolution = 256,
|
|
14757
|
+
frames = 1,
|
|
14758
|
+
map,
|
|
14759
|
+
background = false,
|
|
14760
|
+
blur,
|
|
14761
|
+
backgroundBlurriness,
|
|
14762
|
+
backgroundIntensity,
|
|
14763
|
+
backgroundRotation,
|
|
14764
|
+
environmentIntensity,
|
|
14765
|
+
environmentRotation,
|
|
14766
|
+
scene,
|
|
14767
|
+
files,
|
|
14768
|
+
path,
|
|
14769
|
+
preset = void 0,
|
|
14770
|
+
extensions
|
|
14771
|
+
}) {
|
|
14772
|
+
const renderer = useThree((state) => state.renderer);
|
|
14773
|
+
const isLegacy = useThree((state) => state.isLegacy);
|
|
14774
|
+
const defaultScene = useThree((state) => state.scene);
|
|
14775
|
+
const camera = React__namespace.useRef(null);
|
|
14776
|
+
const [virtualScene] = React__namespace.useState(() => new three.Scene());
|
|
14777
|
+
const fbo = React__namespace.useMemo(() => {
|
|
14778
|
+
const fbo2 = isLegacy ? new three.WebGLCubeRenderTarget(resolution) : new CubeRenderTarget(resolution);
|
|
14779
|
+
fbo2.texture.type = three.HalfFloatType;
|
|
14780
|
+
return fbo2;
|
|
14781
|
+
}, [resolution, isLegacy]);
|
|
14782
|
+
React__namespace.useEffect(() => {
|
|
14783
|
+
return () => {
|
|
14784
|
+
fbo.dispose();
|
|
14785
|
+
};
|
|
14786
|
+
}, [fbo]);
|
|
14787
|
+
React__namespace.useLayoutEffect(() => {
|
|
14788
|
+
if (frames === 1) {
|
|
14789
|
+
const autoClear = renderer.autoClear;
|
|
14790
|
+
renderer.autoClear = true;
|
|
14791
|
+
camera.current.update(renderer, virtualScene);
|
|
14792
|
+
renderer.autoClear = autoClear;
|
|
14793
|
+
}
|
|
14794
|
+
return setEnvProps(background, scene, defaultScene, fbo.texture, {
|
|
14795
|
+
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
14796
|
+
backgroundIntensity,
|
|
14797
|
+
backgroundRotation,
|
|
14798
|
+
environmentIntensity,
|
|
14799
|
+
environmentRotation
|
|
14800
|
+
});
|
|
14801
|
+
}, [
|
|
14802
|
+
children,
|
|
14803
|
+
virtualScene,
|
|
14804
|
+
fbo.texture,
|
|
14805
|
+
scene,
|
|
14806
|
+
defaultScene,
|
|
14807
|
+
background,
|
|
14808
|
+
frames,
|
|
14809
|
+
renderer,
|
|
14810
|
+
blur,
|
|
14811
|
+
backgroundBlurriness,
|
|
14812
|
+
backgroundIntensity,
|
|
14813
|
+
backgroundRotation,
|
|
14814
|
+
environmentIntensity,
|
|
14815
|
+
environmentRotation
|
|
14816
|
+
]);
|
|
14817
|
+
let count = 1;
|
|
14818
|
+
useFrame(() => {
|
|
14819
|
+
if (frames === Infinity || count < frames) {
|
|
14820
|
+
const autoClear = renderer.autoClear;
|
|
14821
|
+
renderer.autoClear = true;
|
|
14822
|
+
camera.current.update(renderer, virtualScene);
|
|
14823
|
+
renderer.autoClear = autoClear;
|
|
14824
|
+
count++;
|
|
14825
|
+
}
|
|
14826
|
+
});
|
|
14827
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: createPortal(
|
|
14828
|
+
/* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
14829
|
+
children,
|
|
14830
|
+
/* @__PURE__ */ jsxRuntime.jsx("cubeCamera", { ref: camera, args: [near, far, fbo] }),
|
|
14831
|
+
files || preset ? /* @__PURE__ */ jsxRuntime.jsx(EnvironmentCube, { background: true, files, preset, path, extensions }) : map ? /* @__PURE__ */ jsxRuntime.jsx(EnvironmentMap, { background: true, map, extensions }) : null
|
|
14832
|
+
] }),
|
|
14833
|
+
virtualScene
|
|
14834
|
+
) });
|
|
14835
|
+
}
|
|
14836
|
+
function EnvironmentGround(props) {
|
|
14837
|
+
const textureDefault = useEnvironment(props);
|
|
14838
|
+
const texture = props.map || textureDefault;
|
|
14839
|
+
React__namespace.useMemo(() => extend({ GroundProjectedEnvImpl: GroundedSkybox_js.GroundedSkybox }), []);
|
|
14840
|
+
React__namespace.useEffect(() => {
|
|
14841
|
+
return () => {
|
|
14842
|
+
textureDefault.dispose();
|
|
14843
|
+
};
|
|
14844
|
+
}, [textureDefault]);
|
|
14845
|
+
const height = props.ground?.height ?? 15;
|
|
14846
|
+
const radius = props.ground?.radius ?? 60;
|
|
14847
|
+
const scale = props.ground?.scale ?? 1e3;
|
|
14848
|
+
const args = React__namespace.useMemo(
|
|
14849
|
+
() => [texture, height, radius],
|
|
14850
|
+
[texture, height, radius]
|
|
14851
|
+
);
|
|
14852
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
14853
|
+
/* @__PURE__ */ jsxRuntime.jsx(EnvironmentMap, { ...props, map: texture }),
|
|
14854
|
+
/* @__PURE__ */ jsxRuntime.jsx("groundProjectedEnvImpl", { args, scale })
|
|
14855
|
+
] });
|
|
14856
|
+
}
|
|
14857
|
+
function EnvironmentColor({ color, scene }) {
|
|
14858
|
+
const defaultScene = useThree((state) => state.scene);
|
|
14859
|
+
React__namespace.useLayoutEffect(() => {
|
|
14860
|
+
if (color === void 0) return;
|
|
14861
|
+
const target = resolveScene(scene || defaultScene);
|
|
14862
|
+
const oldBg = target.background;
|
|
14863
|
+
target.background = new three.Color(color);
|
|
14864
|
+
return () => {
|
|
14865
|
+
target.background = oldBg;
|
|
14866
|
+
};
|
|
14867
|
+
});
|
|
14868
|
+
return null;
|
|
14869
|
+
}
|
|
14870
|
+
function EnvironmentDualSource(props) {
|
|
14871
|
+
const { backgroundFiles, ...envProps } = props;
|
|
14872
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
14873
|
+
/* @__PURE__ */ jsxRuntime.jsx(EnvironmentCube, { ...envProps, background: false }),
|
|
14874
|
+
/* @__PURE__ */ jsxRuntime.jsx(EnvironmentCube, { ...props, files: backgroundFiles, background: "only" })
|
|
14875
|
+
] });
|
|
14876
|
+
}
|
|
14877
|
+
function Environment(props) {
|
|
14878
|
+
if (props.color && !props.files && !props.preset && !props.map) {
|
|
14879
|
+
return /* @__PURE__ */ jsxRuntime.jsx(EnvironmentColor, { ...props });
|
|
14880
|
+
}
|
|
14881
|
+
if (props.backgroundFiles && props.backgroundFiles !== props.files) {
|
|
14882
|
+
return /* @__PURE__ */ jsxRuntime.jsx(EnvironmentDualSource, { ...props });
|
|
14883
|
+
}
|
|
14884
|
+
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 });
|
|
14885
|
+
}
|
|
14886
|
+
|
|
14742
14887
|
function parseBackground(background) {
|
|
14743
14888
|
if (!background) return null;
|
|
14744
14889
|
if (typeof background === "object" && !background.isColor) {
|
|
@@ -14782,14 +14927,36 @@ function parseRendererConfig(rendererProp) {
|
|
|
14782
14927
|
return { primaryCanvas: void 0, scheduler: void 0, renderer: rendererProp };
|
|
14783
14928
|
}
|
|
14784
14929
|
|
|
14930
|
+
const RESOURCE_KINDS = ["nodes", "uniforms", "buffers", "gpuStorage"];
|
|
14931
|
+
const registries = /* @__PURE__ */ new WeakMap();
|
|
14932
|
+
function getKindRegistry(store, kind) {
|
|
14933
|
+
let registry = registries.get(store);
|
|
14934
|
+
if (!registry) {
|
|
14935
|
+
registry = {
|
|
14936
|
+
nodes: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() },
|
|
14937
|
+
uniforms: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() },
|
|
14938
|
+
buffers: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() },
|
|
14939
|
+
gpuStorage: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() }
|
|
14940
|
+
};
|
|
14941
|
+
registries.set(store, registry);
|
|
14942
|
+
}
|
|
14943
|
+
return registry[kind];
|
|
14944
|
+
}
|
|
14945
|
+
function invalidateResource(store, kind, scopeKey) {
|
|
14946
|
+
const registry = getKindRegistry(store, kind);
|
|
14947
|
+
{
|
|
14948
|
+
registry.valid.clear();
|
|
14949
|
+
registry.staged.clear();
|
|
14950
|
+
}
|
|
14951
|
+
}
|
|
14952
|
+
function invalidateAllResources(store) {
|
|
14953
|
+
for (const kind of RESOURCE_KINDS) invalidateResource(store, kind);
|
|
14954
|
+
}
|
|
14955
|
+
|
|
14785
14956
|
function clearHmrCaches(store) {
|
|
14786
|
-
store.
|
|
14787
|
-
|
|
14788
|
-
|
|
14789
|
-
buffers: {},
|
|
14790
|
-
gpuStorage: {},
|
|
14791
|
-
_hmrVersion: state._hmrVersion + 1
|
|
14792
|
-
}));
|
|
14957
|
+
const primary = store.getState().primaryStore ?? store;
|
|
14958
|
+
invalidateAllResources(primary);
|
|
14959
|
+
primary.setState((state) => ({ _hmrVersion: state._hmrVersion + 1 }));
|
|
14793
14960
|
}
|
|
14794
14961
|
|
|
14795
14962
|
function CanvasImpl({
|
|
@@ -14926,7 +15093,7 @@ function CanvasImpl({
|
|
|
14926
15093
|
onDropMissed: (...args) => handleDropMissed.current?.(...args),
|
|
14927
15094
|
onCreated: (state) => {
|
|
14928
15095
|
state.events.connect?.(
|
|
14929
|
-
eventSource ? isRef(eventSource) ? eventSource.current : eventSource : divRef.current
|
|
15096
|
+
eventSource ? isRef$1(eventSource) ? eventSource.current : eventSource : divRef.current
|
|
14930
15097
|
);
|
|
14931
15098
|
if (eventPrefix) {
|
|
14932
15099
|
state.setEvents({
|
|
@@ -15058,7 +15225,6 @@ exports.REACT_INTERNAL_PROPS = REACT_INTERNAL_PROPS;
|
|
|
15058
15225
|
exports.RESERVED_PROPS = RESERVED_PROPS;
|
|
15059
15226
|
exports.Texture = Texture;
|
|
15060
15227
|
exports._roots = _roots;
|
|
15061
|
-
exports.act = act;
|
|
15062
15228
|
exports.addAfterEffect = addAfterEffect;
|
|
15063
15229
|
exports.addEffect = addEffect;
|
|
15064
15230
|
exports.addTail = addTail;
|
|
@@ -15097,7 +15263,7 @@ exports.isFromRef = isFromRef;
|
|
|
15097
15263
|
exports.isObject3D = isObject3D;
|
|
15098
15264
|
exports.isOnce = isOnce;
|
|
15099
15265
|
exports.isOrthographicCamera = isOrthographicCamera;
|
|
15100
|
-
exports.isRef = isRef;
|
|
15266
|
+
exports.isRef = isRef$1;
|
|
15101
15267
|
exports.isRenderer = isRenderer;
|
|
15102
15268
|
exports.isTexture = isTexture;
|
|
15103
15269
|
exports.isVectorLike = isVectorLike;
|
|
@@ -15108,6 +15274,7 @@ exports.reconciler = reconciler;
|
|
|
15108
15274
|
exports.registerPrimary = registerPrimary;
|
|
15109
15275
|
exports.removeInteractivity = removeInteractivity;
|
|
15110
15276
|
exports.resolve = resolve;
|
|
15277
|
+
exports.swapInteractivity = swapInteractivity;
|
|
15111
15278
|
exports.unmountComponentAtNode = unmountComponentAtNode;
|
|
15112
15279
|
exports.unregisterPrimary = unregisterPrimary;
|
|
15113
15280
|
exports.updateCamera = updateCamera;
|