@react-three/fiber 10.0.0-canary.4a21acb → 10.0.0-canary.4bf885a
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/extension.cjs +278 -0
- package/dist/extension.d.cts +1675 -0
- package/dist/extension.d.mts +1675 -0
- package/dist/extension.d.ts +1647 -0
- package/dist/extension.mjs +258 -0
- package/dist/index.cjs +2771 -2550
- package/dist/index.d.cts +358 -165
- package/dist/index.d.mts +358 -165
- package/dist/index.d.ts +356 -191
- package/dist/index.mjs +2771 -2552
- package/dist/legacy.cjs +2558 -2338
- package/dist/legacy.d.cts +379 -218
- package/dist/legacy.d.mts +379 -218
- package/dist/legacy.d.ts +377 -242
- package/dist/legacy.mjs +2208 -1990
- package/dist/webgpu/index.cjs +3113 -2814
- package/dist/webgpu/index.d.cts +433 -271
- package/dist/webgpu/index.d.mts +433 -271
- package/dist/webgpu/index.d.ts +431 -297
- package/dist/webgpu/index.mjs +2587 -2290
- package/package.json +9 -4
- package/readme.md +1 -1
- 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.mjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import * as three from 'three';
|
|
2
|
-
import { WebGLCubeRenderTarget, WebGLRenderTarget,
|
|
2
|
+
import { WebGLCubeRenderTarget, WebGLRenderTarget, Frustum, Matrix4, Group, BoxGeometry, MeshBasicNodeMaterial, Mesh, Node, NodeUpdateType, Layers, ShaderMaterial, Uniform, SRGBColorSpace, RGBAFormat, UnsignedByteType, TextureLoader, Texture as Texture$1, CubeReflectionMapping, EquirectangularReflectionMapping, CubeTextureLoader, Vector3, Vector2, Raycaster, OrthographicCamera, PerspectiveCamera, Scene, PCFShadowMap, VSMShadowMap, BasicShadowMap, ACESFilmicToneMapping, WebGLRenderer, HalfFloatType, Color } from 'three';
|
|
3
3
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import React__default, {
|
|
5
|
+
import React__default, { useContext, useRef, useMemo, useLayoutEffect, useEffect, useImperativeHandle, useCallback, useState } from 'react';
|
|
6
6
|
import useMeasure from 'react-use-measure';
|
|
7
7
|
import { useFiber, useContextBridge, traverseFiber, FiberProvider } from 'its-fine';
|
|
8
|
-
import {
|
|
8
|
+
import { createWithEqualityFn } from 'zustand/traditional';
|
|
9
|
+
import { getScheduler } from '@pmndrs/scheduler';
|
|
10
|
+
export { Scheduler, getScheduler } from '@pmndrs/scheduler';
|
|
11
|
+
import Tb, { unstable_getCurrentPriorityLevel, unstable_IdlePriority, unstable_LowPriority, unstable_NormalPriority, unstable_UserBlockingPriority, unstable_ImmediatePriority, unstable_scheduleCallback } from 'scheduler';
|
|
9
12
|
import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
|
|
10
13
|
import { HDRLoader } from 'three/examples/jsm/loaders/HDRLoader.js';
|
|
14
|
+
import { HDRCubeTextureLoader } from 'three/examples/jsm/loaders/HDRCubeTextureLoader.js';
|
|
11
15
|
import { EXRLoader } from 'three/examples/jsm/loaders/EXRLoader.js';
|
|
12
16
|
import { UltraHDRLoader } from 'three/examples/jsm/loaders/UltraHDRLoader.js';
|
|
13
17
|
import { GainMapLoader } from '@monogrid/gainmap-js';
|
|
14
|
-
import Tb, { unstable_scheduleCallback, unstable_IdlePriority } from 'scheduler';
|
|
15
|
-
import { createWithEqualityFn } from 'zustand/traditional';
|
|
16
|
-
import { getScheduler } from '@pmndrs/scheduler';
|
|
17
|
-
export { Scheduler, getScheduler } from '@pmndrs/scheduler';
|
|
18
18
|
import { suspend, preload, clear } from 'suspend-react';
|
|
19
19
|
|
|
20
20
|
function _mergeNamespaces(n, m) {
|
|
@@ -31,16 +31,14 @@ function _mergeNamespaces(n, m) {
|
|
|
31
31
|
|
|
32
32
|
const R3F_BUILD_LEGACY = true;
|
|
33
33
|
const R3F_BUILD_WEBGPU = false;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
39
|
-
const WebGPURenderer = class WebGPURenderer2 {
|
|
34
|
+
async function loadInspector() {
|
|
35
|
+
throw new Error("Inspector is not available in legacy builds. Use @react-three/fiber/webgpu instead.");
|
|
36
|
+
}
|
|
37
|
+
class WebGPURenderer {
|
|
40
38
|
constructor() {
|
|
41
39
|
throw new Error("WebGPURenderer is not available in legacy builds. Use @react-three/fiber/webgpu instead.");
|
|
42
40
|
}
|
|
43
|
-
}
|
|
41
|
+
}
|
|
44
42
|
const RenderTarget = null;
|
|
45
43
|
const CubeRenderTarget = null;
|
|
46
44
|
|
|
@@ -48,12 +46,12 @@ const THREE = /*#__PURE__*/_mergeNamespaces({
|
|
|
48
46
|
__proto__: null,
|
|
49
47
|
CubeRenderTarget: CubeRenderTarget,
|
|
50
48
|
CubeRenderTargetCompat: WebGLCubeRenderTarget,
|
|
51
|
-
Inspector: Inspector,
|
|
52
49
|
R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
|
|
53
50
|
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
54
51
|
RenderTarget: RenderTarget,
|
|
55
52
|
RenderTargetCompat: WebGLRenderTarget,
|
|
56
|
-
WebGPURenderer: WebGPURenderer
|
|
53
|
+
WebGPURenderer: WebGPURenderer,
|
|
54
|
+
loadInspector: loadInspector
|
|
57
55
|
}, [three]);
|
|
58
56
|
|
|
59
57
|
const primaryRegistry = /* @__PURE__ */ new Map();
|
|
@@ -114,556 +112,228 @@ function getPrimaryIds() {
|
|
|
114
112
|
return Array.from(primaryRegistry.keys());
|
|
115
113
|
}
|
|
116
114
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
115
|
+
var __defProp = Object.defineProperty;
|
|
116
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
117
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
118
|
+
const useIsomorphicLayoutEffect = /* @__PURE__ */ (() => typeof window !== "undefined" && (window.document?.createElement || window.navigator?.product === "ReactNative"))() ? React.useLayoutEffect : React.useEffect;
|
|
119
|
+
function useMutableCallback(fn) {
|
|
120
|
+
const ref = React.useRef(fn);
|
|
121
|
+
useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
|
|
122
|
+
return ref;
|
|
123
|
+
}
|
|
124
|
+
function useBridge() {
|
|
125
|
+
const fiber = useFiber();
|
|
126
|
+
const ContextBridge = useContextBridge();
|
|
127
|
+
return React.useMemo(
|
|
128
|
+
() => ({ children }) => {
|
|
129
|
+
const strict = !!traverseFiber(fiber, true, (node) => node.type === React.StrictMode);
|
|
130
|
+
const Root = strict ? React.StrictMode : React.Fragment;
|
|
131
|
+
return /* @__PURE__ */ jsx(Root, { children: /* @__PURE__ */ jsx(ContextBridge, { children }) });
|
|
132
|
+
},
|
|
133
|
+
[fiber, ContextBridge]
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
function Block({ set }) {
|
|
137
|
+
useIsomorphicLayoutEffect(() => {
|
|
138
|
+
set(new Promise(() => null));
|
|
139
|
+
return () => set(false);
|
|
140
|
+
}, [set]);
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
const ErrorBoundary = /* @__PURE__ */ (() => {
|
|
144
|
+
var _a;
|
|
145
|
+
return _a = class extends React.Component {
|
|
146
|
+
constructor() {
|
|
147
|
+
super(...arguments);
|
|
148
|
+
__publicField(this, "state", { error: false });
|
|
149
|
+
}
|
|
150
|
+
componentDidCatch(err) {
|
|
151
|
+
this.props.set(err);
|
|
152
|
+
}
|
|
153
|
+
render() {
|
|
154
|
+
return this.state.error ? null : this.props.children;
|
|
155
|
+
}
|
|
156
|
+
}, __publicField(_a, "getDerivedStateFromError", () => ({ error: true })), _a;
|
|
157
|
+
})();
|
|
129
158
|
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
} = {}) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
useLoader$1.clear(loader, multiFile ? [files] : files);
|
|
159
|
+
const is = {
|
|
160
|
+
obj: (a) => a === Object(a) && !is.arr(a) && typeof a !== "function",
|
|
161
|
+
fun: (a) => typeof a === "function",
|
|
162
|
+
str: (a) => typeof a === "string",
|
|
163
|
+
num: (a) => typeof a === "number",
|
|
164
|
+
boo: (a) => typeof a === "boolean",
|
|
165
|
+
und: (a) => a === void 0,
|
|
166
|
+
nul: (a) => a === null,
|
|
167
|
+
arr: (a) => Array.isArray(a),
|
|
168
|
+
equ(a, b, { arrays = "shallow", objects = "reference", strict = true } = {}) {
|
|
169
|
+
if (typeof a !== typeof b || !!a !== !!b) return false;
|
|
170
|
+
if (is.str(a) || is.num(a) || is.boo(a)) return a === b;
|
|
171
|
+
const isObj = is.obj(a);
|
|
172
|
+
if (isObj && objects === "reference") return a === b;
|
|
173
|
+
const isArr = is.arr(a);
|
|
174
|
+
if (isArr && arrays === "reference") return a === b;
|
|
175
|
+
if ((isArr || isObj) && a === b) return true;
|
|
176
|
+
let i;
|
|
177
|
+
for (i in a) if (!(i in b)) return false;
|
|
178
|
+
if (isObj && arrays === "shallow" && objects === "shallow") {
|
|
179
|
+
for (i in strict ? b : a) if (!is.equ(a[i], b[i], { strict, objects: "reference" })) return false;
|
|
180
|
+
} else {
|
|
181
|
+
for (i in strict ? b : a) if (a[i] !== b[i]) return false;
|
|
154
182
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
multiFile ? [files] : files,
|
|
160
|
-
(loader2) => {
|
|
161
|
-
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
162
|
-
loader2.setRenderer?.(renderer);
|
|
163
|
-
}
|
|
164
|
-
loader2.setPath?.(path);
|
|
165
|
-
if (extensions) extensions(loader2);
|
|
183
|
+
if (is.und(i)) {
|
|
184
|
+
if (isArr && a.length === 0 && b.length === 0) return true;
|
|
185
|
+
if (isObj && Object.keys(a).length === 0 && Object.keys(b).length === 0) return true;
|
|
186
|
+
if (a !== b) return false;
|
|
166
187
|
}
|
|
167
|
-
|
|
168
|
-
let texture = multiFile ? (
|
|
169
|
-
// @ts-ignore
|
|
170
|
-
loaderResult[0]
|
|
171
|
-
) : loaderResult;
|
|
172
|
-
if (extension === "jpg" || extension === "jpeg" || extension === "webp") {
|
|
173
|
-
texture = texture.renderTarget?.texture;
|
|
174
|
-
}
|
|
175
|
-
texture.mapping = isCubemap ? CubeReflectionMapping : EquirectangularReflectionMapping;
|
|
176
|
-
texture.colorSpace = colorSpace ?? (isCubemap ? "srgb" : "srgb-linear");
|
|
177
|
-
return texture;
|
|
178
|
-
}
|
|
179
|
-
const preloadDefaultOptions = {
|
|
180
|
-
files: defaultFiles,
|
|
181
|
-
path: "",
|
|
182
|
-
preset: void 0,
|
|
183
|
-
extensions: void 0
|
|
184
|
-
};
|
|
185
|
-
useEnvironment.preload = (preloadOptions) => {
|
|
186
|
-
const options = { ...preloadDefaultOptions, ...preloadOptions };
|
|
187
|
-
let { files, path = "" } = options;
|
|
188
|
-
const { preset, extensions } = options;
|
|
189
|
-
if (preset) {
|
|
190
|
-
validatePreset(preset);
|
|
191
|
-
files = presetsObj[preset];
|
|
192
|
-
path = CUBEMAP_ROOT;
|
|
193
|
-
}
|
|
194
|
-
const { extension } = getExtension(files);
|
|
195
|
-
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
196
|
-
throw new Error("useEnvironment: Preloading gainmaps is not supported");
|
|
197
|
-
}
|
|
198
|
-
const loader = getLoader$1(extension);
|
|
199
|
-
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
200
|
-
useLoader$1.preload(loader, isArray(files) ? [files] : files, (loader2) => {
|
|
201
|
-
loader2.setPath?.(path);
|
|
202
|
-
if (extensions) extensions(loader2);
|
|
203
|
-
});
|
|
204
|
-
};
|
|
205
|
-
const clearDefaultOptins = {
|
|
206
|
-
files: defaultFiles,
|
|
207
|
-
preset: void 0
|
|
208
|
-
};
|
|
209
|
-
useEnvironment.clear = (clearOptions) => {
|
|
210
|
-
const options = { ...clearDefaultOptins, ...clearOptions };
|
|
211
|
-
let { files } = options;
|
|
212
|
-
const { preset } = options;
|
|
213
|
-
if (preset) {
|
|
214
|
-
validatePreset(preset);
|
|
215
|
-
files = presetsObj[preset];
|
|
188
|
+
return true;
|
|
216
189
|
}
|
|
217
|
-
const { extension } = getExtension(files);
|
|
218
|
-
const loader = getLoader$1(extension);
|
|
219
|
-
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
220
|
-
useLoader$1.clear(loader, isArray(files) ? [files] : files);
|
|
221
190
|
};
|
|
222
|
-
|
|
223
|
-
|
|
191
|
+
const isOrthographicCamera = (def) => def && def.isOrthographicCamera;
|
|
192
|
+
const isRef$1 = (obj) => obj !== null && typeof obj === "object" && obj.hasOwnProperty("current");
|
|
193
|
+
const isColorRepresentation = (value) => value != null && (typeof value === "string" || typeof value === "number" || value.isColor);
|
|
194
|
+
const isObject3D = (object) => object?.isObject3D;
|
|
195
|
+
const isTexture = (value) => !!value?.isTexture;
|
|
196
|
+
const isVectorLike = (object) => object !== null && typeof object === "object" && "set" in object && typeof object.set === "function";
|
|
197
|
+
const isCopyable = (object) => isVectorLike(object) && "copy" in object && typeof object.copy === "function";
|
|
198
|
+
const hasConstructor = (object) => !!object?.constructor;
|
|
199
|
+
|
|
200
|
+
function calculateDpr(dpr) {
|
|
201
|
+
const target = typeof window !== "undefined" ? window.devicePixelRatio ?? 2 : 1;
|
|
202
|
+
return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
|
|
224
203
|
}
|
|
225
|
-
function
|
|
226
|
-
|
|
227
|
-
const isGainmap = isArray(files) && files.length === 3 && files.some((file) => file.endsWith("json"));
|
|
228
|
-
const firstEntry = isArray(files) ? files[0] : files;
|
|
229
|
-
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();
|
|
230
|
-
return { extension, isCubemap, isGainmap };
|
|
204
|
+
function getUuidPrefix(uuid) {
|
|
205
|
+
return uuid.split("-")[0];
|
|
231
206
|
}
|
|
232
|
-
function
|
|
233
|
-
|
|
234
|
-
|
|
207
|
+
function updateCamera(camera, size) {
|
|
208
|
+
if (camera.manual) return;
|
|
209
|
+
if (isOrthographicCamera(camera)) {
|
|
210
|
+
camera.left = size.width / -2;
|
|
211
|
+
camera.right = size.width / 2;
|
|
212
|
+
camera.top = size.height / 2;
|
|
213
|
+
camera.bottom = size.height / -2;
|
|
214
|
+
} else {
|
|
215
|
+
camera.aspect = size.width / size.height;
|
|
216
|
+
}
|
|
217
|
+
camera.updateProjectionMatrix();
|
|
235
218
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
backgroundIntensity: 1,
|
|
243
|
-
backgroundRotation: [0, 0, 0],
|
|
244
|
-
environmentIntensity: 1,
|
|
245
|
-
environmentRotation: [0, 0, 0],
|
|
246
|
-
...sceneProps
|
|
247
|
-
};
|
|
248
|
-
const target = resolveScene(scene || defaultScene);
|
|
249
|
-
const oldbg = target.background;
|
|
250
|
-
const oldenv = target.environment;
|
|
251
|
-
const oldSceneProps = {
|
|
252
|
-
// @ts-ignore
|
|
253
|
-
backgroundBlurriness: target.backgroundBlurriness,
|
|
254
|
-
// @ts-ignore
|
|
255
|
-
backgroundIntensity: target.backgroundIntensity,
|
|
256
|
-
// @ts-ignore
|
|
257
|
-
backgroundRotation: target.backgroundRotation?.clone?.() ?? [0, 0, 0],
|
|
258
|
-
// @ts-ignore
|
|
259
|
-
environmentIntensity: target.environmentIntensity,
|
|
260
|
-
// @ts-ignore
|
|
261
|
-
environmentRotation: target.environmentRotation?.clone?.() ?? [0, 0, 0]
|
|
262
|
-
};
|
|
263
|
-
if (background !== "only") target.environment = texture;
|
|
264
|
-
if (background) target.background = texture;
|
|
265
|
-
applyProps$1(target, sceneProps);
|
|
266
|
-
return () => {
|
|
267
|
-
if (background !== "only") target.environment = oldenv;
|
|
268
|
-
if (background) target.background = oldbg;
|
|
269
|
-
applyProps$1(target, oldSceneProps);
|
|
270
|
-
};
|
|
219
|
+
const frustumMatrix = new Matrix4();
|
|
220
|
+
function updateFrustum(camera, frustum) {
|
|
221
|
+
const target = frustum ?? new Frustum();
|
|
222
|
+
frustumMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
223
|
+
target.setFromProjectionMatrix(frustumMatrix);
|
|
224
|
+
return target;
|
|
271
225
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
return
|
|
226
|
+
|
|
227
|
+
const REACT_INTERNAL_PROPS = ["children", "key", "ref"];
|
|
228
|
+
function findInitialRoot(instance) {
|
|
229
|
+
let root = instance.root;
|
|
230
|
+
while (root.getState().previousRoot) root = root.getState().previousRoot;
|
|
231
|
+
return root;
|
|
278
232
|
}
|
|
279
|
-
function
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
...rest
|
|
289
|
-
}) {
|
|
290
|
-
const texture = useEnvironment(rest);
|
|
291
|
-
const defaultScene = useThree$1((state) => state.scene);
|
|
292
|
-
React.useLayoutEffect(() => {
|
|
293
|
-
return setEnvProps(background, scene, defaultScene, texture, {
|
|
294
|
-
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
295
|
-
backgroundIntensity,
|
|
296
|
-
backgroundRotation,
|
|
297
|
-
environmentIntensity,
|
|
298
|
-
environmentRotation
|
|
233
|
+
function getRootState(obj) {
|
|
234
|
+
let state = obj.__r3f?.root.getState();
|
|
235
|
+
if (!state) {
|
|
236
|
+
obj.traverseAncestors((ancestor) => {
|
|
237
|
+
const parentState = ancestor.__r3f?.root.getState();
|
|
238
|
+
if (parentState) {
|
|
239
|
+
state = parentState;
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
299
242
|
});
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
return () => {
|
|
303
|
-
texture.dispose();
|
|
304
|
-
};
|
|
305
|
-
}, [texture]);
|
|
306
|
-
return null;
|
|
243
|
+
}
|
|
244
|
+
return state;
|
|
307
245
|
}
|
|
308
|
-
function
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
path,
|
|
325
|
-
preset = void 0,
|
|
326
|
-
extensions
|
|
327
|
-
}) {
|
|
328
|
-
const renderer = useThree$1((state) => state.renderer);
|
|
329
|
-
const isLegacy = useThree$1((state) => state.isLegacy);
|
|
330
|
-
const defaultScene = useThree$1((state) => state.scene);
|
|
331
|
-
const camera = React.useRef(null);
|
|
332
|
-
const [virtualScene] = React.useState(() => new Scene());
|
|
333
|
-
const fbo = React.useMemo(() => {
|
|
334
|
-
const fbo2 = isLegacy ? new WebGLCubeRenderTarget(resolution) : new CubeRenderTarget(resolution);
|
|
335
|
-
fbo2.texture.type = HalfFloatType;
|
|
336
|
-
return fbo2;
|
|
337
|
-
}, [resolution, isLegacy]);
|
|
338
|
-
React.useEffect(() => {
|
|
339
|
-
return () => {
|
|
340
|
-
fbo.dispose();
|
|
341
|
-
};
|
|
342
|
-
}, [fbo]);
|
|
343
|
-
React.useLayoutEffect(() => {
|
|
344
|
-
if (frames === 1) {
|
|
345
|
-
const autoClear = renderer.autoClear;
|
|
346
|
-
renderer.autoClear = true;
|
|
347
|
-
camera.current.update(renderer, virtualScene);
|
|
348
|
-
renderer.autoClear = autoClear;
|
|
349
|
-
}
|
|
350
|
-
return setEnvProps(background, scene, defaultScene, fbo.texture, {
|
|
351
|
-
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
352
|
-
backgroundIntensity,
|
|
353
|
-
backgroundRotation,
|
|
354
|
-
environmentIntensity,
|
|
355
|
-
environmentRotation
|
|
246
|
+
function buildGraph(object) {
|
|
247
|
+
const data = { nodes: {}, materials: {}, meshes: {} };
|
|
248
|
+
if (object) {
|
|
249
|
+
object.traverse((obj) => {
|
|
250
|
+
if (obj.name) data.nodes[obj.name] = obj;
|
|
251
|
+
if (obj.material) {
|
|
252
|
+
const material = Array.isArray(obj.material) ? obj.material[0] : obj.material;
|
|
253
|
+
const nameAlreadyUsed = data.materials[material.name];
|
|
254
|
+
let materialName = material.name;
|
|
255
|
+
if (nameAlreadyUsed) {
|
|
256
|
+
materialName = materialName + `-${getUuidPrefix(material.uuid)}`;
|
|
257
|
+
material.userData.materialCacheName = materialName;
|
|
258
|
+
}
|
|
259
|
+
data.materials[materialName] = material;
|
|
260
|
+
}
|
|
261
|
+
if (obj.isMesh && !data.meshes[obj.name]) data.meshes[obj.name] = obj;
|
|
356
262
|
});
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
virtualScene,
|
|
360
|
-
fbo.texture,
|
|
361
|
-
scene,
|
|
362
|
-
defaultScene,
|
|
363
|
-
background,
|
|
364
|
-
frames,
|
|
365
|
-
renderer,
|
|
366
|
-
blur,
|
|
367
|
-
backgroundBlurriness,
|
|
368
|
-
backgroundIntensity,
|
|
369
|
-
backgroundRotation,
|
|
370
|
-
environmentIntensity,
|
|
371
|
-
environmentRotation
|
|
372
|
-
]);
|
|
373
|
-
let count = 1;
|
|
374
|
-
useFrame$1(() => {
|
|
375
|
-
if (frames === Infinity || count < frames) {
|
|
376
|
-
const autoClear = renderer.autoClear;
|
|
377
|
-
renderer.autoClear = true;
|
|
378
|
-
camera.current.update(renderer, virtualScene);
|
|
379
|
-
renderer.autoClear = autoClear;
|
|
380
|
-
count++;
|
|
381
|
-
}
|
|
382
|
-
});
|
|
383
|
-
return /* @__PURE__ */ jsx(Fragment, { children: createPortal$1(
|
|
384
|
-
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
385
|
-
children,
|
|
386
|
-
/* @__PURE__ */ jsx("cubeCamera", { ref: camera, args: [near, far, fbo] }),
|
|
387
|
-
files || preset ? /* @__PURE__ */ jsx(EnvironmentCube, { background: true, files, preset, path, extensions }) : map ? /* @__PURE__ */ jsx(EnvironmentMap, { background: true, map, extensions }) : null
|
|
388
|
-
] }),
|
|
389
|
-
virtualScene
|
|
390
|
-
) });
|
|
263
|
+
}
|
|
264
|
+
return data;
|
|
391
265
|
}
|
|
392
|
-
function
|
|
393
|
-
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
textureDefault.dispose();
|
|
399
|
-
};
|
|
400
|
-
}, [textureDefault]);
|
|
401
|
-
const height = props.ground?.height ?? 15;
|
|
402
|
-
const radius = props.ground?.radius ?? 60;
|
|
403
|
-
const scale = props.ground?.scale ?? 1e3;
|
|
404
|
-
const args = React.useMemo(
|
|
405
|
-
() => [texture, height, radius],
|
|
406
|
-
[texture, height, radius]
|
|
407
|
-
);
|
|
408
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
409
|
-
/* @__PURE__ */ jsx(EnvironmentMap, { ...props, map: texture }),
|
|
410
|
-
/* @__PURE__ */ jsx("groundProjectedEnvImpl", { args, scale })
|
|
411
|
-
] });
|
|
266
|
+
function dispose(obj) {
|
|
267
|
+
if (obj.type !== "Scene") obj.dispose?.();
|
|
268
|
+
for (const p in obj) {
|
|
269
|
+
const prop = obj[p];
|
|
270
|
+
if (prop?.type !== "Scene") prop?.dispose?.();
|
|
271
|
+
}
|
|
412
272
|
}
|
|
413
|
-
function
|
|
414
|
-
const
|
|
415
|
-
|
|
416
|
-
if (
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
273
|
+
function getInstanceProps(pendingProps) {
|
|
274
|
+
const props = {};
|
|
275
|
+
for (const key in pendingProps) {
|
|
276
|
+
if (!REACT_INTERNAL_PROPS.includes(key)) props[key] = pendingProps[key];
|
|
277
|
+
}
|
|
278
|
+
return props;
|
|
279
|
+
}
|
|
280
|
+
function prepare(target, root, type, props) {
|
|
281
|
+
const object = target;
|
|
282
|
+
let instance = object?.__r3f;
|
|
283
|
+
if (!instance) {
|
|
284
|
+
instance = {
|
|
285
|
+
root,
|
|
286
|
+
type,
|
|
287
|
+
parent: null,
|
|
288
|
+
children: [],
|
|
289
|
+
props: getInstanceProps(props),
|
|
290
|
+
object,
|
|
291
|
+
eventCount: 0,
|
|
292
|
+
handlers: {},
|
|
293
|
+
isHidden: false
|
|
422
294
|
};
|
|
423
|
-
|
|
424
|
-
|
|
295
|
+
if (object) object.__r3f = instance;
|
|
296
|
+
}
|
|
297
|
+
return instance;
|
|
425
298
|
}
|
|
426
|
-
function
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
/* @__PURE__ */ jsx(EnvironmentCube, { ...props, files: backgroundFiles, background: "only" })
|
|
431
|
-
] });
|
|
299
|
+
function invalidateInstance(instance) {
|
|
300
|
+
if (!instance.parent) return;
|
|
301
|
+
const state = instance.root?.getState?.();
|
|
302
|
+
if (state && state.internal.frames === 0) state.invalidate();
|
|
432
303
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
304
|
+
|
|
305
|
+
const tempFrustum = new Frustum();
|
|
306
|
+
let hasWarnedWebGL = false;
|
|
307
|
+
let tslModule = null;
|
|
308
|
+
async function loadTSL() {
|
|
309
|
+
if (tslModule) return tslModule;
|
|
310
|
+
try {
|
|
311
|
+
const tsl = await import('three/tsl');
|
|
312
|
+
tslModule = { uniform: tsl.uniform, nodeObject: tsl.nodeObject };
|
|
313
|
+
return tslModule;
|
|
314
|
+
} catch {
|
|
315
|
+
return null;
|
|
439
316
|
}
|
|
440
|
-
return props.ground ? /* @__PURE__ */ jsx(EnvironmentGround, { ...props }) : props.map ? /* @__PURE__ */ jsx(EnvironmentMap, { ...props }) : props.children ? /* @__PURE__ */ jsx(EnvironmentPortal, { ...props }) : /* @__PURE__ */ jsx(EnvironmentCube, { ...props });
|
|
441
317
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
const
|
|
447
|
-
const
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
},
|
|
462
|
-
[fiber, ContextBridge]
|
|
463
|
-
);
|
|
464
|
-
}
|
|
465
|
-
function Block({ set }) {
|
|
466
|
-
useIsomorphicLayoutEffect(() => {
|
|
467
|
-
set(new Promise(() => null));
|
|
468
|
-
return () => set(false);
|
|
469
|
-
}, [set]);
|
|
470
|
-
return null;
|
|
471
|
-
}
|
|
472
|
-
const ErrorBoundary = /* @__PURE__ */ (() => {
|
|
473
|
-
var _a;
|
|
474
|
-
return _a = class extends React.Component {
|
|
475
|
-
constructor() {
|
|
476
|
-
super(...arguments);
|
|
477
|
-
__publicField(this, "state", { error: false });
|
|
478
|
-
}
|
|
479
|
-
componentDidCatch(err) {
|
|
480
|
-
this.props.set(err);
|
|
481
|
-
}
|
|
482
|
-
render() {
|
|
483
|
-
return this.state.error ? null : this.props.children;
|
|
484
|
-
}
|
|
485
|
-
}, __publicField(_a, "getDerivedStateFromError", () => ({ error: true })), _a;
|
|
486
|
-
})();
|
|
487
|
-
|
|
488
|
-
const is = {
|
|
489
|
-
obj: (a) => a === Object(a) && !is.arr(a) && typeof a !== "function",
|
|
490
|
-
fun: (a) => typeof a === "function",
|
|
491
|
-
str: (a) => typeof a === "string",
|
|
492
|
-
num: (a) => typeof a === "number",
|
|
493
|
-
boo: (a) => typeof a === "boolean",
|
|
494
|
-
und: (a) => a === void 0,
|
|
495
|
-
nul: (a) => a === null,
|
|
496
|
-
arr: (a) => Array.isArray(a),
|
|
497
|
-
equ(a, b, { arrays = "shallow", objects = "reference", strict = true } = {}) {
|
|
498
|
-
if (typeof a !== typeof b || !!a !== !!b) return false;
|
|
499
|
-
if (is.str(a) || is.num(a) || is.boo(a)) return a === b;
|
|
500
|
-
const isObj = is.obj(a);
|
|
501
|
-
if (isObj && objects === "reference") return a === b;
|
|
502
|
-
const isArr = is.arr(a);
|
|
503
|
-
if (isArr && arrays === "reference") return a === b;
|
|
504
|
-
if ((isArr || isObj) && a === b) return true;
|
|
505
|
-
let i;
|
|
506
|
-
for (i in a) if (!(i in b)) return false;
|
|
507
|
-
if (isObj && arrays === "shallow" && objects === "shallow") {
|
|
508
|
-
for (i in strict ? b : a) if (!is.equ(a[i], b[i], { strict, objects: "reference" })) return false;
|
|
509
|
-
} else {
|
|
510
|
-
for (i in strict ? b : a) if (a[i] !== b[i]) return false;
|
|
511
|
-
}
|
|
512
|
-
if (is.und(i)) {
|
|
513
|
-
if (isArr && a.length === 0 && b.length === 0) return true;
|
|
514
|
-
if (isObj && Object.keys(a).length === 0 && Object.keys(b).length === 0) return true;
|
|
515
|
-
if (a !== b) return false;
|
|
516
|
-
}
|
|
517
|
-
return true;
|
|
518
|
-
}
|
|
519
|
-
};
|
|
520
|
-
const isOrthographicCamera = (def) => def && def.isOrthographicCamera;
|
|
521
|
-
const isRef = (obj) => obj !== null && typeof obj === "object" && obj.hasOwnProperty("current");
|
|
522
|
-
const isColorRepresentation = (value) => value != null && (typeof value === "string" || typeof value === "number" || value.isColor);
|
|
523
|
-
const isObject3D = (object) => object?.isObject3D;
|
|
524
|
-
const isTexture = (value) => !!value?.isTexture;
|
|
525
|
-
const isVectorLike = (object) => object !== null && typeof object === "object" && "set" in object && typeof object.set === "function";
|
|
526
|
-
const isCopyable = (object) => isVectorLike(object) && "copy" in object && typeof object.copy === "function";
|
|
527
|
-
const hasConstructor = (object) => !!object?.constructor;
|
|
528
|
-
|
|
529
|
-
function calculateDpr(dpr) {
|
|
530
|
-
const target = typeof window !== "undefined" ? window.devicePixelRatio ?? 2 : 1;
|
|
531
|
-
return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
|
|
532
|
-
}
|
|
533
|
-
function getUuidPrefix(uuid) {
|
|
534
|
-
return uuid.split("-")[0];
|
|
535
|
-
}
|
|
536
|
-
function updateCamera(camera, size) {
|
|
537
|
-
if (camera.manual) return;
|
|
538
|
-
if (isOrthographicCamera(camera)) {
|
|
539
|
-
camera.left = size.width / -2;
|
|
540
|
-
camera.right = size.width / 2;
|
|
541
|
-
camera.top = size.height / 2;
|
|
542
|
-
camera.bottom = size.height / -2;
|
|
543
|
-
} else {
|
|
544
|
-
camera.aspect = size.width / size.height;
|
|
545
|
-
}
|
|
546
|
-
camera.updateProjectionMatrix();
|
|
547
|
-
}
|
|
548
|
-
const frustumMatrix = new Matrix4();
|
|
549
|
-
function updateFrustum(camera, frustum) {
|
|
550
|
-
const target = frustum ?? new Frustum();
|
|
551
|
-
frustumMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
552
|
-
target.setFromProjectionMatrix(frustumMatrix);
|
|
553
|
-
return target;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
const REACT_INTERNAL_PROPS = ["children", "key", "ref"];
|
|
557
|
-
function findInitialRoot(instance) {
|
|
558
|
-
let root = instance.root;
|
|
559
|
-
while (root.getState().previousRoot) root = root.getState().previousRoot;
|
|
560
|
-
return root;
|
|
561
|
-
}
|
|
562
|
-
function getRootState(obj) {
|
|
563
|
-
let state = obj.__r3f?.root.getState();
|
|
564
|
-
if (!state) {
|
|
565
|
-
obj.traverseAncestors((ancestor) => {
|
|
566
|
-
const parentState = ancestor.__r3f?.root.getState();
|
|
567
|
-
if (parentState) {
|
|
568
|
-
state = parentState;
|
|
569
|
-
return false;
|
|
570
|
-
}
|
|
571
|
-
});
|
|
572
|
-
}
|
|
573
|
-
return state;
|
|
574
|
-
}
|
|
575
|
-
function buildGraph(object) {
|
|
576
|
-
const data = { nodes: {}, materials: {}, meshes: {} };
|
|
577
|
-
if (object) {
|
|
578
|
-
object.traverse((obj) => {
|
|
579
|
-
if (obj.name) data.nodes[obj.name] = obj;
|
|
580
|
-
if (obj.material) {
|
|
581
|
-
const material = Array.isArray(obj.material) ? obj.material[0] : obj.material;
|
|
582
|
-
const nameAlreadyUsed = data.materials[material.name];
|
|
583
|
-
let materialName = material.name;
|
|
584
|
-
if (nameAlreadyUsed) {
|
|
585
|
-
materialName = materialName + `-${getUuidPrefix(material.uuid)}`;
|
|
586
|
-
material.userData.materialCacheName = materialName;
|
|
587
|
-
}
|
|
588
|
-
data.materials[materialName] = material;
|
|
589
|
-
}
|
|
590
|
-
if (obj.isMesh && !data.meshes[obj.name]) data.meshes[obj.name] = obj;
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
|
-
return data;
|
|
594
|
-
}
|
|
595
|
-
function dispose(obj) {
|
|
596
|
-
if (obj.type !== "Scene") obj.dispose?.();
|
|
597
|
-
for (const p in obj) {
|
|
598
|
-
const prop = obj[p];
|
|
599
|
-
if (prop?.type !== "Scene") prop?.dispose?.();
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
function getInstanceProps(pendingProps) {
|
|
603
|
-
const props = {};
|
|
604
|
-
for (const key in pendingProps) {
|
|
605
|
-
if (!REACT_INTERNAL_PROPS.includes(key)) props[key] = pendingProps[key];
|
|
606
|
-
}
|
|
607
|
-
return props;
|
|
608
|
-
}
|
|
609
|
-
function prepare(target, root, type, props) {
|
|
610
|
-
const object = target;
|
|
611
|
-
let instance = object?.__r3f;
|
|
612
|
-
if (!instance) {
|
|
613
|
-
instance = {
|
|
614
|
-
root,
|
|
615
|
-
type,
|
|
616
|
-
parent: null,
|
|
617
|
-
children: [],
|
|
618
|
-
props: getInstanceProps(props),
|
|
619
|
-
object,
|
|
620
|
-
eventCount: 0,
|
|
621
|
-
handlers: {},
|
|
622
|
-
isHidden: false
|
|
623
|
-
};
|
|
624
|
-
if (object) object.__r3f = instance;
|
|
625
|
-
}
|
|
626
|
-
return instance;
|
|
627
|
-
}
|
|
628
|
-
function invalidateInstance(instance) {
|
|
629
|
-
if (!instance.parent) return;
|
|
630
|
-
instance.props.onUpdate?.(instance.object);
|
|
631
|
-
const state = instance.root?.getState?.();
|
|
632
|
-
if (state && state.internal.frames === 0) state.invalidate();
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
const tempFrustum = new Frustum();
|
|
636
|
-
let hasWarnedWebGL = false;
|
|
637
|
-
let tslModule = null;
|
|
638
|
-
async function loadTSL() {
|
|
639
|
-
if (tslModule) return tslModule;
|
|
640
|
-
try {
|
|
641
|
-
const tsl = await import('three/tsl');
|
|
642
|
-
tslModule = { uniform: tsl.uniform, nodeObject: tsl.nodeObject };
|
|
643
|
-
return tslModule;
|
|
644
|
-
} catch {
|
|
645
|
-
return null;
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
function createOcclusionObserverNode(store, uniform) {
|
|
649
|
-
const node = new Node("float");
|
|
650
|
-
node.updateType = NodeUpdateType.OBJECT;
|
|
651
|
-
node.update = function(frame) {
|
|
652
|
-
const { internal } = store.getState();
|
|
653
|
-
const registry = internal.visibilityRegistry;
|
|
654
|
-
const cache = internal.occlusionCache;
|
|
655
|
-
for (const entry of registry.values()) {
|
|
656
|
-
const { object, handlers } = entry;
|
|
657
|
-
if (handlers.onOccluded || handlers.onVisible) {
|
|
658
|
-
const isOccluded = frame.renderer.isOccluded(object);
|
|
659
|
-
cache.set(object, isOccluded);
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
};
|
|
663
|
-
node.setup = function() {
|
|
664
|
-
return uniform(0);
|
|
665
|
-
};
|
|
666
|
-
return node;
|
|
318
|
+
function createOcclusionObserverNode(store, uniform) {
|
|
319
|
+
const node = new Node("float");
|
|
320
|
+
node.updateType = NodeUpdateType.OBJECT;
|
|
321
|
+
node.update = function(frame) {
|
|
322
|
+
const { internal } = store.getState();
|
|
323
|
+
const registry = internal.visibilityRegistry;
|
|
324
|
+
const cache = internal.occlusionCache;
|
|
325
|
+
for (const entry of registry.values()) {
|
|
326
|
+
const { object, handlers } = entry;
|
|
327
|
+
if (handlers.onOccluded || handlers.onVisible) {
|
|
328
|
+
const isOccluded = frame.renderer.isOccluded(object);
|
|
329
|
+
cache.set(object, isOccluded);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
node.setup = function() {
|
|
334
|
+
return uniform(0);
|
|
335
|
+
};
|
|
336
|
+
return node;
|
|
667
337
|
}
|
|
668
338
|
let occlusionSetupPromise = null;
|
|
669
339
|
function enableOcclusion(store) {
|
|
@@ -843,8 +513,10 @@ function hasVisibilityHandlers(handlers) {
|
|
|
843
513
|
}
|
|
844
514
|
|
|
845
515
|
const FROM_REF = Symbol.for("@react-three/fiber.fromRef");
|
|
846
|
-
function fromRef(ref) {
|
|
847
|
-
|
|
516
|
+
function fromRef(ref, transform) {
|
|
517
|
+
const marker = { [FROM_REF]: ref };
|
|
518
|
+
if (transform) marker.transform = transform;
|
|
519
|
+
return marker;
|
|
848
520
|
}
|
|
849
521
|
function isFromRef(value) {
|
|
850
522
|
return value !== null && typeof value === "object" && FROM_REF in value;
|
|
@@ -858,51 +530,107 @@ function isOnce(value) {
|
|
|
858
530
|
return value !== null && typeof value === "object" && ONCE in value;
|
|
859
531
|
}
|
|
860
532
|
|
|
861
|
-
const
|
|
862
|
-
|
|
863
|
-
"
|
|
864
|
-
|
|
865
|
-
// Instance props
|
|
866
|
-
"args",
|
|
867
|
-
"dispose",
|
|
868
|
-
"attach",
|
|
869
|
-
"object",
|
|
870
|
-
"onUpdate",
|
|
871
|
-
// Behavior flags
|
|
872
|
-
"dispose"
|
|
873
|
-
];
|
|
874
|
-
const EVENT_REGEX = /^on(Pointer|Drag|Drop|Click|DoubleClick|ContextMenu|Wheel)/;
|
|
875
|
-
const VISIBILITY_EVENT_REGEX = /^on(Framed|Occluded|Visible)$/;
|
|
876
|
-
const INDEX_REGEX = /-\d+$/;
|
|
877
|
-
const MEMOIZED_PROTOTYPES = /* @__PURE__ */ new Map();
|
|
878
|
-
const colorMaps = ["map", "emissiveMap", "sheenColorMap", "specularColorMap", "envMap"];
|
|
879
|
-
function resolve(root, key) {
|
|
880
|
-
if (!key.includes("-")) return { root, key, target: root[key] };
|
|
881
|
-
if (key in root) return { root, key, target: root[key] };
|
|
882
|
-
const originalKey = key;
|
|
883
|
-
let target = root;
|
|
884
|
-
const parts = key.split("-");
|
|
885
|
-
for (const part of parts) {
|
|
886
|
-
if (typeof target !== "object" || target === null) {
|
|
887
|
-
if (target !== void 0) {
|
|
888
|
-
const remaining = parts.slice(parts.indexOf(part)).join("-");
|
|
889
|
-
return { root: target, key: remaining, target: void 0 };
|
|
890
|
-
}
|
|
891
|
-
return { root, key: originalKey, target: void 0 };
|
|
892
|
-
}
|
|
893
|
-
key = part;
|
|
894
|
-
root = target;
|
|
895
|
-
target = target[key];
|
|
533
|
+
const shownNotices = /* @__PURE__ */ new Set();
|
|
534
|
+
function notifyDepreciated({ heading, body, link }) {
|
|
535
|
+
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_DEPRECATION_WARNINGS !== "true") {
|
|
536
|
+
return;
|
|
896
537
|
}
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
if (
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
}
|
|
538
|
+
if (shownNotices.has(heading)) return;
|
|
539
|
+
shownNotices.add(heading);
|
|
540
|
+
const caller = getCallerFrame();
|
|
541
|
+
if (caller) {
|
|
542
|
+
console.log();
|
|
543
|
+
}
|
|
544
|
+
const boxStyle = "background: #ff9800; color: #1a1a1a; padding: 8px 12px; border-radius: 4px; font-weight: 500;";
|
|
545
|
+
if (caller) {
|
|
546
|
+
console.log(`%c\u26A0\uFE0F ${heading}`, boxStyle);
|
|
547
|
+
}
|
|
548
|
+
if (body || link) {
|
|
549
|
+
let message = "";
|
|
550
|
+
if (body) message += body;
|
|
551
|
+
if (link) message += (body ? "\n\n" : "") + `More info: ${link}`;
|
|
552
|
+
console.warn(`%c${message}`, "font-weight: bold;");
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
function getCallerFrame(depth = 3) {
|
|
556
|
+
const stack = new Error().stack;
|
|
557
|
+
if (!stack) return null;
|
|
558
|
+
const lines = stack.split("\n");
|
|
559
|
+
const frame = lines[depth];
|
|
560
|
+
if (!frame) return null;
|
|
561
|
+
let match = frame.match(/^\s*at (?:(.+?) )?\(?(.+?):(\d+):(\d+)\)?$/);
|
|
562
|
+
if (!match) {
|
|
563
|
+
match = frame.match(/^(?:(.+?)@)?(.+?):(\d+):(\d+)$/);
|
|
564
|
+
}
|
|
565
|
+
if (!match) return null;
|
|
566
|
+
const [, fn, url, line] = match;
|
|
567
|
+
return {
|
|
568
|
+
functionName: fn ?? "<anonymous>",
|
|
569
|
+
location: formatLocation(url, Number(line))
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
function formatLocation(url, line) {
|
|
573
|
+
const clean = url.split("?")[0];
|
|
574
|
+
const file = clean.split("/").pop() ?? clean;
|
|
575
|
+
return `${file}:${line}`;
|
|
576
|
+
}
|
|
577
|
+
function notifyAlpha({ message, link }) {
|
|
578
|
+
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_ALPHA_WARNINGS !== "true") {
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
if (shownNotices.has(message)) return;
|
|
582
|
+
shownNotices.add(message);
|
|
583
|
+
const boxStyle = "background: #6366f1; color: #ffffff; padding: 6px 10px; border-radius: 4px; font-weight: 500;";
|
|
584
|
+
console.log(`%c\u{1F52C} ${message}`, boxStyle);
|
|
585
|
+
{
|
|
586
|
+
console.log(`%cMore info: ${link}`, "color: #6366f1; font-weight: normal;");
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
const RESERVED_PROPS = [
|
|
591
|
+
"children",
|
|
592
|
+
"key",
|
|
593
|
+
"ref",
|
|
594
|
+
// Instance props
|
|
595
|
+
"args",
|
|
596
|
+
"dispose",
|
|
597
|
+
"attach",
|
|
598
|
+
"object",
|
|
599
|
+
// Behavior flags
|
|
600
|
+
"dispose"
|
|
601
|
+
];
|
|
602
|
+
const EVENT_REGEX = /^on(Pointer|Drag|Drop|Click|DoubleClick|ContextMenu|Wheel)/;
|
|
603
|
+
const VISIBILITY_EVENT_REGEX = /^on(Framed|Occluded|Visible)$/;
|
|
604
|
+
const INDEX_REGEX = /-\d+$/;
|
|
605
|
+
const MEMOIZED_PROTOTYPES = /* @__PURE__ */ new Map();
|
|
606
|
+
const colorMaps = ["map", "emissiveMap", "sheenColorMap", "specularColorMap", "envMap"];
|
|
607
|
+
function resolve(root, key) {
|
|
608
|
+
if (!key.includes("-")) return { root, key, target: root[key] };
|
|
609
|
+
if (key in root) return { root, key, target: root[key] };
|
|
610
|
+
const originalKey = key;
|
|
611
|
+
let target = root;
|
|
612
|
+
const parts = key.split("-");
|
|
613
|
+
for (const part of parts) {
|
|
614
|
+
if (typeof target !== "object" || target === null) {
|
|
615
|
+
if (target !== void 0) {
|
|
616
|
+
const remaining = parts.slice(parts.indexOf(part)).join("-");
|
|
617
|
+
return { root: target, key: remaining, target: void 0 };
|
|
618
|
+
}
|
|
619
|
+
return { root, key: originalKey, target: void 0 };
|
|
620
|
+
}
|
|
621
|
+
key = part;
|
|
622
|
+
root = target;
|
|
623
|
+
target = target[key];
|
|
624
|
+
}
|
|
625
|
+
return { root, key, target };
|
|
626
|
+
}
|
|
627
|
+
function attach(parent, child) {
|
|
628
|
+
if (is.str(child.props.attach)) {
|
|
629
|
+
if (INDEX_REGEX.test(child.props.attach)) {
|
|
630
|
+
const index = child.props.attach.replace(INDEX_REGEX, "");
|
|
631
|
+
const { root: root2, key: key2 } = resolve(parent.object, index);
|
|
632
|
+
if (!Array.isArray(root2[key2])) root2[key2] = [];
|
|
633
|
+
}
|
|
906
634
|
const { root, key } = resolve(parent.object, child.props.attach);
|
|
907
635
|
child.previousAttach = root[key];
|
|
908
636
|
root[key] = child.object;
|
|
@@ -945,11 +673,9 @@ function diffProps(instance, newProps) {
|
|
|
945
673
|
for (const prop in instance.props) {
|
|
946
674
|
if (RESERVED_PROPS.includes(prop) || newProps.hasOwnProperty(prop)) continue;
|
|
947
675
|
const { root, key } = resolve(instance.object, prop);
|
|
948
|
-
if (
|
|
676
|
+
if (typeof root?.constructor === "function") {
|
|
949
677
|
const ctor = getMemoizedPrototype(root);
|
|
950
|
-
if (!is.und(ctor)) changedProps[
|
|
951
|
-
} else {
|
|
952
|
-
changedProps[key] = 0;
|
|
678
|
+
if (!is.und(ctor)) changedProps[prop] = ctor[key];
|
|
953
679
|
}
|
|
954
680
|
}
|
|
955
681
|
return changedProps;
|
|
@@ -961,6 +687,13 @@ function applyProps(object, props) {
|
|
|
961
687
|
for (const prop in props) {
|
|
962
688
|
const value = props[prop];
|
|
963
689
|
if (RESERVED_PROPS.includes(prop)) continue;
|
|
690
|
+
if (prop === "onUpdate") {
|
|
691
|
+
notifyDepreciated({
|
|
692
|
+
heading: "onUpdate is no longer an R3F prop",
|
|
693
|
+
body: "v10 removed the onUpdate hook: R3F no longer calls it after prop updates. The value is assigned to the object by name. On a Texture that sets three's Texture.onUpdate, which the renderer calls after a GPU upload, not after prop changes. On a node it replaces the Node.onUpdate() method. On other objects it is never called.\n\nUse an effect keyed on the props that change, read the object in useFrame, or use a ref callback.",
|
|
694
|
+
link: "https://docs.pmnd.rs/react-three-fiber/migration/v10#onupdate-removed"
|
|
695
|
+
});
|
|
696
|
+
}
|
|
964
697
|
if (instance && EVENT_REGEX.test(prop)) {
|
|
965
698
|
if (typeof value === "function") instance.handlers[prop] = value;
|
|
966
699
|
else delete instance.handlers[prop];
|
|
@@ -1066,914 +799,40 @@ function applyProps(object, props) {
|
|
|
1066
799
|
return object;
|
|
1067
800
|
}
|
|
1068
801
|
|
|
1069
|
-
const
|
|
1070
|
-
const
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
captured: /* @__PURE__ */ new Map(),
|
|
1077
|
-
initialClick: [0, 0],
|
|
1078
|
-
initialHits: []
|
|
1079
|
-
};
|
|
1080
|
-
internal.pointerMap.set(pointerId, state);
|
|
1081
|
-
}
|
|
1082
|
-
return state;
|
|
1083
|
-
}
|
|
1084
|
-
function getPointerId(event) {
|
|
1085
|
-
return "pointerId" in event ? event.pointerId : DEFAULT_POINTER_ID;
|
|
1086
|
-
}
|
|
1087
|
-
function makeId(event) {
|
|
1088
|
-
return (event.eventObject || event.object).uuid + "/" + event.index + event.instanceId;
|
|
802
|
+
const R3F_CONTEXT = Symbol.for("@react-three/fiber.context");
|
|
803
|
+
const context = globalThis[R3F_CONTEXT] ?? (globalThis[R3F_CONTEXT] = React.createContext(null));
|
|
804
|
+
|
|
805
|
+
function useStore() {
|
|
806
|
+
const store = useContext(context);
|
|
807
|
+
if (!store) throw new Error("R3F: Hooks can only be used within the Canvas component!");
|
|
808
|
+
return store;
|
|
1089
809
|
}
|
|
1090
|
-
function
|
|
1091
|
-
|
|
1092
|
-
if (!pointerState) return;
|
|
1093
|
-
const captureData = pointerState.captured.get(obj);
|
|
1094
|
-
if (captureData) {
|
|
1095
|
-
pointerState.captured.delete(obj);
|
|
1096
|
-
captureData.target.releasePointerCapture(pointerId);
|
|
1097
|
-
}
|
|
810
|
+
function useThree$1(selector = (state) => state, equalityFn) {
|
|
811
|
+
return useStore()(selector, equalityFn);
|
|
1098
812
|
}
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
});
|
|
1109
|
-
if (pointerState.captured.has(object)) {
|
|
1110
|
-
releaseInternalPointerCapture(internal, object, pointerId);
|
|
813
|
+
|
|
814
|
+
const memoizedLoaders = /* @__PURE__ */ new WeakMap();
|
|
815
|
+
const isConstructor$1 = (value) => typeof value === "function" && value?.prototype?.constructor === value;
|
|
816
|
+
function getLoader$1(Proto) {
|
|
817
|
+
if (isConstructor$1(Proto)) {
|
|
818
|
+
let loader = memoizedLoaders.get(Proto);
|
|
819
|
+
if (!loader) {
|
|
820
|
+
loader = new Proto();
|
|
821
|
+
memoizedLoaders.set(Proto, loader);
|
|
1111
822
|
}
|
|
823
|
+
return loader;
|
|
1112
824
|
}
|
|
1113
|
-
|
|
825
|
+
return Proto;
|
|
1114
826
|
}
|
|
1115
|
-
function
|
|
1116
|
-
function
|
|
1117
|
-
const
|
|
1118
|
-
|
|
1119
|
-
if (
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
}
|
|
1125
|
-
function filterPointerEvents(objects) {
|
|
1126
|
-
return objects.filter(
|
|
1127
|
-
(obj) => ["Move", "Over", "Enter", "Out", "Leave"].some(
|
|
1128
|
-
(name) => obj.__r3f?.handlers["onPointer" + name]
|
|
1129
|
-
) || ["OverEnter", "OverLeave", "Over"].some(
|
|
1130
|
-
(name) => obj.__r3f?.handlers["onDrag" + name]
|
|
1131
|
-
) || obj.__r3f?.handlers.onDrop
|
|
1132
|
-
);
|
|
1133
|
-
}
|
|
1134
|
-
function intersect(event, filter) {
|
|
1135
|
-
const state = store.getState();
|
|
1136
|
-
const duplicates = /* @__PURE__ */ new Set();
|
|
1137
|
-
const intersections = [];
|
|
1138
|
-
const eventsObjects = filter ? filter(state.internal.interaction) : state.internal.interaction;
|
|
1139
|
-
for (let i = 0; i < eventsObjects.length; i++) {
|
|
1140
|
-
const state2 = getRootState(eventsObjects[i]);
|
|
1141
|
-
if (state2) {
|
|
1142
|
-
state2.raycaster.camera = void 0;
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
if (!state.previousRoot) {
|
|
1146
|
-
state.events.compute?.(event, state);
|
|
1147
|
-
}
|
|
1148
|
-
function handleRaycast(obj) {
|
|
1149
|
-
const state2 = getRootState(obj);
|
|
1150
|
-
if (!state2 || !state2.events.enabled || state2.raycaster.camera === null) return [];
|
|
1151
|
-
if (state2.raycaster.camera === void 0) {
|
|
1152
|
-
state2.events.compute?.(event, state2, state2.previousRoot?.getState());
|
|
1153
|
-
if (state2.raycaster.camera === void 0) state2.raycaster.camera = null;
|
|
1154
|
-
}
|
|
1155
|
-
return state2.raycaster.camera ? state2.raycaster.intersectObject(obj, true) : [];
|
|
1156
|
-
}
|
|
1157
|
-
let hits = eventsObjects.flatMap(handleRaycast).sort((a, b) => {
|
|
1158
|
-
const aInteractivePriority = a.object.userData?.interactivePriority;
|
|
1159
|
-
const bInteractivePriority = b.object.userData?.interactivePriority;
|
|
1160
|
-
if (aInteractivePriority !== void 0 || bInteractivePriority !== void 0) {
|
|
1161
|
-
if (aInteractivePriority !== void 0 && bInteractivePriority === void 0) return -1;
|
|
1162
|
-
if (bInteractivePriority !== void 0 && aInteractivePriority === void 0) return 1;
|
|
1163
|
-
if (aInteractivePriority !== bInteractivePriority) {
|
|
1164
|
-
return (bInteractivePriority ?? 0) - (aInteractivePriority ?? 0);
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
const aState = getRootState(a.object);
|
|
1168
|
-
const bState = getRootState(b.object);
|
|
1169
|
-
const aPriority = aState?.events?.priority ?? 1;
|
|
1170
|
-
const bPriority = bState?.events?.priority ?? 1;
|
|
1171
|
-
return bPriority - aPriority || a.distance - b.distance;
|
|
1172
|
-
}).filter((item) => {
|
|
1173
|
-
const id = makeId(item);
|
|
1174
|
-
if (duplicates.has(id)) return false;
|
|
1175
|
-
duplicates.add(id);
|
|
1176
|
-
return true;
|
|
1177
|
-
});
|
|
1178
|
-
if (state.events.filter) hits = state.events.filter(hits, state);
|
|
1179
|
-
for (const hit of hits) {
|
|
1180
|
-
let eventObject = hit.object;
|
|
1181
|
-
while (eventObject) {
|
|
1182
|
-
if (eventObject.__r3f?.eventCount) {
|
|
1183
|
-
intersections.push({ ...hit, eventObject });
|
|
1184
|
-
}
|
|
1185
|
-
eventObject = eventObject.parent;
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
if ("pointerId" in event) {
|
|
1189
|
-
const pointerId = event.pointerId;
|
|
1190
|
-
const pointerState = state.internal.pointerMap.get(pointerId);
|
|
1191
|
-
if (pointerState?.captured.size) {
|
|
1192
|
-
for (const captureData of pointerState.captured.values()) {
|
|
1193
|
-
if (!duplicates.has(makeId(captureData.intersection))) intersections.push(captureData.intersection);
|
|
1194
|
-
}
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
return intersections;
|
|
1198
|
-
}
|
|
1199
|
-
function handleIntersects(intersections, event, delta, callback) {
|
|
1200
|
-
if (intersections.length) {
|
|
1201
|
-
const localState = { stopped: false };
|
|
1202
|
-
for (const hit of intersections) {
|
|
1203
|
-
const state = getRootState(hit.object);
|
|
1204
|
-
if (state) {
|
|
1205
|
-
const { raycaster, pointer, camera, internal } = state;
|
|
1206
|
-
const unprojectedPoint = new Vector3(pointer.x, pointer.y, 0).unproject(camera);
|
|
1207
|
-
const hasPointerCapture = (id) => {
|
|
1208
|
-
const pointerState = internal.pointerMap.get(id);
|
|
1209
|
-
return pointerState?.captured.has(hit.eventObject) ?? false;
|
|
1210
|
-
};
|
|
1211
|
-
const setPointerCapture = (id) => {
|
|
1212
|
-
const captureData = { intersection: hit, target: event.target };
|
|
1213
|
-
const pointerState = getPointerState(internal, id);
|
|
1214
|
-
pointerState.captured.set(hit.eventObject, captureData);
|
|
1215
|
-
event.target.setPointerCapture(id);
|
|
1216
|
-
};
|
|
1217
|
-
const releasePointerCapture = (id) => {
|
|
1218
|
-
releaseInternalPointerCapture(internal, hit.eventObject, id);
|
|
1219
|
-
};
|
|
1220
|
-
const extractEventProps = {};
|
|
1221
|
-
for (const prop in event) {
|
|
1222
|
-
const property = event[prop];
|
|
1223
|
-
if (typeof property !== "function") extractEventProps[prop] = property;
|
|
1224
|
-
}
|
|
1225
|
-
const eventPointerId = "pointerId" in event ? event.pointerId : void 0;
|
|
1226
|
-
const raycastEvent = {
|
|
1227
|
-
...hit,
|
|
1228
|
-
...extractEventProps,
|
|
1229
|
-
pointer,
|
|
1230
|
-
intersections,
|
|
1231
|
-
stopped: localState.stopped,
|
|
1232
|
-
delta,
|
|
1233
|
-
unprojectedPoint,
|
|
1234
|
-
ray: raycaster.ray,
|
|
1235
|
-
camera,
|
|
1236
|
-
pointerId: eventPointerId,
|
|
1237
|
-
// Hijack stopPropagation, which just sets a flag
|
|
1238
|
-
stopPropagation() {
|
|
1239
|
-
const pointerState = eventPointerId !== void 0 ? internal.pointerMap.get(eventPointerId) : void 0;
|
|
1240
|
-
if (
|
|
1241
|
-
// ...if this pointer hasn't been captured
|
|
1242
|
-
!pointerState?.captured.size || // ... or if the hit object is capturing the pointer
|
|
1243
|
-
pointerState.captured.has(hit.eventObject)
|
|
1244
|
-
) {
|
|
1245
|
-
raycastEvent.stopped = localState.stopped = true;
|
|
1246
|
-
if (pointerState?.hovered.size && Array.from(pointerState.hovered.values()).find((i) => i.eventObject === hit.eventObject)) {
|
|
1247
|
-
const higher = intersections.slice(0, intersections.indexOf(hit));
|
|
1248
|
-
cancelPointer([...higher, hit], eventPointerId);
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
},
|
|
1252
|
-
// there should be a distinction between target and currentTarget
|
|
1253
|
-
target: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
1254
|
-
currentTarget: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
1255
|
-
nativeEvent: event
|
|
1256
|
-
};
|
|
1257
|
-
callback(raycastEvent);
|
|
1258
|
-
if (localState.stopped === true) break;
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
return intersections;
|
|
1263
|
-
}
|
|
1264
|
-
function cancelPointer(intersections, pointerId) {
|
|
1265
|
-
const { internal } = store.getState();
|
|
1266
|
-
const pid = pointerId ?? DEFAULT_POINTER_ID;
|
|
1267
|
-
const pointerState = internal.pointerMap.get(pid);
|
|
1268
|
-
if (!pointerState) return;
|
|
1269
|
-
for (const [hoveredId, hoveredObj] of pointerState.hovered) {
|
|
1270
|
-
if (!intersections.length || !intersections.find(
|
|
1271
|
-
(hit) => hit.object === hoveredObj.object && hit.index === hoveredObj.index && hit.instanceId === hoveredObj.instanceId
|
|
1272
|
-
)) {
|
|
1273
|
-
const eventObject = hoveredObj.eventObject;
|
|
1274
|
-
const instance = eventObject.__r3f;
|
|
1275
|
-
pointerState.hovered.delete(hoveredId);
|
|
1276
|
-
if (instance?.eventCount) {
|
|
1277
|
-
const handlers = instance.handlers;
|
|
1278
|
-
const data = { ...hoveredObj, intersections };
|
|
1279
|
-
handlers.onPointerOut?.(data);
|
|
1280
|
-
handlers.onPointerLeave?.(data);
|
|
1281
|
-
handlers.onDragOverLeave?.(data);
|
|
1282
|
-
}
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
function pointerMissed(event, objects) {
|
|
1287
|
-
for (let i = 0; i < objects.length; i++) {
|
|
1288
|
-
const instance = objects[i].__r3f;
|
|
1289
|
-
instance?.handlers.onPointerMissed?.(event);
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
function dragOverMissed(event, objects) {
|
|
1293
|
-
for (let i = 0; i < objects.length; i++) {
|
|
1294
|
-
const instance = objects[i].__r3f;
|
|
1295
|
-
instance?.handlers.onDragOverMissed?.(event);
|
|
1296
|
-
}
|
|
1297
|
-
}
|
|
1298
|
-
function dropMissed(event, objects) {
|
|
1299
|
-
for (let i = 0; i < objects.length; i++) {
|
|
1300
|
-
const instance = objects[i].__r3f;
|
|
1301
|
-
instance?.handlers.onDropMissed?.(event);
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1304
|
-
function cleanupPointer(pointerId) {
|
|
1305
|
-
const { internal } = store.getState();
|
|
1306
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1307
|
-
if (pointerState) {
|
|
1308
|
-
for (const [, hoveredObj] of pointerState.hovered) {
|
|
1309
|
-
const eventObject = hoveredObj.eventObject;
|
|
1310
|
-
const instance = eventObject.__r3f;
|
|
1311
|
-
if (instance?.eventCount) {
|
|
1312
|
-
const handlers = instance.handlers;
|
|
1313
|
-
const data = { ...hoveredObj, intersections: [] };
|
|
1314
|
-
handlers.onPointerOut?.(data);
|
|
1315
|
-
handlers.onPointerLeave?.(data);
|
|
1316
|
-
}
|
|
1317
|
-
}
|
|
1318
|
-
internal.pointerMap.delete(pointerId);
|
|
1319
|
-
}
|
|
1320
|
-
internal.pointerDirty.delete(pointerId);
|
|
1321
|
-
}
|
|
1322
|
-
function processDeferredPointer(event, pointerId) {
|
|
1323
|
-
const state = store.getState();
|
|
1324
|
-
const { internal } = state;
|
|
1325
|
-
if (!state.events.enabled) return;
|
|
1326
|
-
const filter = filterPointerEvents;
|
|
1327
|
-
const hits = intersect(event, filter);
|
|
1328
|
-
cancelPointer(hits, pointerId);
|
|
1329
|
-
function onIntersect(data) {
|
|
1330
|
-
const eventObject = data.eventObject;
|
|
1331
|
-
const instance = eventObject.__r3f;
|
|
1332
|
-
if (!instance?.eventCount) return;
|
|
1333
|
-
const handlers = instance.handlers;
|
|
1334
|
-
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
1335
|
-
const id = makeId(data);
|
|
1336
|
-
const pointerState = getPointerState(internal, pointerId);
|
|
1337
|
-
const hoveredItem = pointerState.hovered.get(id);
|
|
1338
|
-
if (!hoveredItem) {
|
|
1339
|
-
pointerState.hovered.set(id, data);
|
|
1340
|
-
handlers.onPointerOver?.(data);
|
|
1341
|
-
handlers.onPointerEnter?.(data);
|
|
1342
|
-
} else if (hoveredItem.stopped) {
|
|
1343
|
-
data.stopPropagation();
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
handlers.onPointerMove?.(data);
|
|
1347
|
-
}
|
|
1348
|
-
handleIntersects(hits, event, 0, onIntersect);
|
|
1349
|
-
}
|
|
1350
|
-
function handlePointer(name) {
|
|
1351
|
-
switch (name) {
|
|
1352
|
-
case "onPointerLeave":
|
|
1353
|
-
case "onDragLeave":
|
|
1354
|
-
return () => cancelPointer([]);
|
|
1355
|
-
// Global cancel of these events
|
|
1356
|
-
case "onPointerCancel":
|
|
1357
|
-
return (event) => {
|
|
1358
|
-
const pointerId = getPointerId(event);
|
|
1359
|
-
cleanupPointer(pointerId);
|
|
1360
|
-
};
|
|
1361
|
-
case "onLostPointerCapture":
|
|
1362
|
-
return (event) => {
|
|
1363
|
-
const { internal } = store.getState();
|
|
1364
|
-
const pointerId = getPointerId(event);
|
|
1365
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1366
|
-
if (pointerState?.captured.size) {
|
|
1367
|
-
requestAnimationFrame(() => {
|
|
1368
|
-
const pointerState2 = internal.pointerMap.get(pointerId);
|
|
1369
|
-
if (pointerState2?.captured.size) {
|
|
1370
|
-
pointerState2.captured.clear();
|
|
1371
|
-
}
|
|
1372
|
-
cancelPointer([], pointerId);
|
|
1373
|
-
});
|
|
1374
|
-
}
|
|
1375
|
-
};
|
|
1376
|
-
}
|
|
1377
|
-
return function handleEvent(event) {
|
|
1378
|
-
const state = store.getState();
|
|
1379
|
-
const { onPointerMissed, onDragOverMissed, onDropMissed, internal, events } = state;
|
|
1380
|
-
const pointerId = getPointerId(event);
|
|
1381
|
-
internal.lastEvent.current = event;
|
|
1382
|
-
if (!events.enabled) return;
|
|
1383
|
-
const isPointerMove = name === "onPointerMove";
|
|
1384
|
-
const isDragOver = name === "onDragOver";
|
|
1385
|
-
const isDrop = name === "onDrop";
|
|
1386
|
-
const isClickEvent = name === "onClick" || name === "onContextMenu" || name === "onDoubleClick";
|
|
1387
|
-
const isPointerDown = name === "onPointerDown";
|
|
1388
|
-
const isPointerUp = name === "onPointerUp";
|
|
1389
|
-
const isWheel = name === "onWheel";
|
|
1390
|
-
const canDeferRaycasts = events.frameTimedRaycasts && state.frameloop === "always";
|
|
1391
|
-
if (isPointerMove && canDeferRaycasts) {
|
|
1392
|
-
events.compute?.(event, state);
|
|
1393
|
-
internal.pointerDirty.set(pointerId, event);
|
|
1394
|
-
return;
|
|
1395
|
-
}
|
|
1396
|
-
if (isWheel && canDeferRaycasts && !events.alwaysFireOnScroll) {
|
|
1397
|
-
events.compute?.(event, state);
|
|
1398
|
-
internal.pointerDirty.set(pointerId, event);
|
|
1399
|
-
return;
|
|
1400
|
-
}
|
|
1401
|
-
if ((isClickEvent || isPointerDown || isPointerUp) && internal.pointerDirty.has(pointerId)) {
|
|
1402
|
-
const deferredEvent = internal.pointerDirty.get(pointerId);
|
|
1403
|
-
internal.pointerDirty.delete(pointerId);
|
|
1404
|
-
processDeferredPointer(deferredEvent, pointerId);
|
|
1405
|
-
}
|
|
1406
|
-
const filter = isPointerMove || isDragOver || isDrop ? filterPointerEvents : void 0;
|
|
1407
|
-
const hits = intersect(event, filter);
|
|
1408
|
-
const delta = isClickEvent ? calculateDistance(event, pointerId) : 0;
|
|
1409
|
-
if (isPointerDown) {
|
|
1410
|
-
const pointerState2 = getPointerState(internal, pointerId);
|
|
1411
|
-
pointerState2.initialClick = [event.offsetX, event.offsetY];
|
|
1412
|
-
pointerState2.initialHits = hits.map((hit) => hit.eventObject);
|
|
1413
|
-
}
|
|
1414
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1415
|
-
const initialHits = pointerState?.initialHits ?? [];
|
|
1416
|
-
if (isClickEvent && !hits.length) {
|
|
1417
|
-
if (delta <= 2) {
|
|
1418
|
-
pointerMissed(event, internal.interaction);
|
|
1419
|
-
if (onPointerMissed) onPointerMissed(event);
|
|
1420
|
-
}
|
|
1421
|
-
}
|
|
1422
|
-
if (isDragOver && !hits.length) {
|
|
1423
|
-
dragOverMissed(event, internal.interaction);
|
|
1424
|
-
if (onDragOverMissed) onDragOverMissed(event);
|
|
1425
|
-
}
|
|
1426
|
-
if (isDrop && !hits.length) {
|
|
1427
|
-
dropMissed(event, internal.interaction);
|
|
1428
|
-
if (onDropMissed) onDropMissed(event);
|
|
1429
|
-
}
|
|
1430
|
-
if (isPointerMove || isDragOver) {
|
|
1431
|
-
cancelPointer(hits, pointerId);
|
|
1432
|
-
}
|
|
1433
|
-
function onIntersect(data) {
|
|
1434
|
-
const eventObject = data.eventObject;
|
|
1435
|
-
const instance = eventObject.__r3f;
|
|
1436
|
-
if (!instance?.eventCount) return;
|
|
1437
|
-
const handlers = instance.handlers;
|
|
1438
|
-
if (isPointerMove) {
|
|
1439
|
-
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
1440
|
-
const id = makeId(data);
|
|
1441
|
-
const pointerState2 = getPointerState(internal, pointerId);
|
|
1442
|
-
const hoveredItem = pointerState2.hovered.get(id);
|
|
1443
|
-
if (!hoveredItem) {
|
|
1444
|
-
pointerState2.hovered.set(id, data);
|
|
1445
|
-
handlers.onPointerOver?.(data);
|
|
1446
|
-
handlers.onPointerEnter?.(data);
|
|
1447
|
-
} else if (hoveredItem.stopped) {
|
|
1448
|
-
data.stopPropagation();
|
|
1449
|
-
}
|
|
1450
|
-
}
|
|
1451
|
-
handlers.onPointerMove?.(data);
|
|
1452
|
-
} else if (isDragOver) {
|
|
1453
|
-
const id = makeId(data);
|
|
1454
|
-
const pointerState2 = getPointerState(internal, pointerId);
|
|
1455
|
-
const hoveredItem = pointerState2.hovered.get(id);
|
|
1456
|
-
if (!hoveredItem) {
|
|
1457
|
-
pointerState2.hovered.set(id, data);
|
|
1458
|
-
handlers.onDragOverEnter?.(data);
|
|
1459
|
-
} else if (hoveredItem.stopped) {
|
|
1460
|
-
data.stopPropagation();
|
|
1461
|
-
}
|
|
1462
|
-
handlers.onDragOver?.(data);
|
|
1463
|
-
} else if (isDrop) {
|
|
1464
|
-
handlers.onDrop?.(data);
|
|
1465
|
-
} else {
|
|
1466
|
-
const handler = handlers[name];
|
|
1467
|
-
if (handler) {
|
|
1468
|
-
if (!isClickEvent || initialHits.includes(eventObject)) {
|
|
1469
|
-
pointerMissed(
|
|
1470
|
-
event,
|
|
1471
|
-
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
1472
|
-
);
|
|
1473
|
-
handler(data);
|
|
1474
|
-
}
|
|
1475
|
-
} else {
|
|
1476
|
-
if (isClickEvent && initialHits.includes(eventObject)) {
|
|
1477
|
-
pointerMissed(
|
|
1478
|
-
event,
|
|
1479
|
-
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
1480
|
-
);
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1483
|
-
}
|
|
1484
|
-
}
|
|
1485
|
-
handleIntersects(hits, event, delta, onIntersect);
|
|
1486
|
-
};
|
|
1487
|
-
}
|
|
1488
|
-
function flushDeferredPointers() {
|
|
1489
|
-
const { internal, events } = store.getState();
|
|
1490
|
-
if (!events.frameTimedRaycasts) return;
|
|
1491
|
-
for (const [pointerId, event] of internal.pointerDirty) {
|
|
1492
|
-
processDeferredPointer(event, pointerId);
|
|
1493
|
-
}
|
|
1494
|
-
internal.pointerDirty.clear();
|
|
1495
|
-
}
|
|
1496
|
-
return { handlePointer, flushDeferredPointers, processDeferredPointer };
|
|
1497
|
-
}
|
|
1498
|
-
const DOM_EVENTS = {
|
|
1499
|
-
onClick: ["click", false],
|
|
1500
|
-
onContextMenu: ["contextmenu", false],
|
|
1501
|
-
onDoubleClick: ["dblclick", false],
|
|
1502
|
-
onDragEnter: ["dragenter", false],
|
|
1503
|
-
onDragLeave: ["dragleave", false],
|
|
1504
|
-
onDragOver: ["dragover", false],
|
|
1505
|
-
onDrop: ["drop", false],
|
|
1506
|
-
onWheel: ["wheel", true],
|
|
1507
|
-
onPointerDown: ["pointerdown", true],
|
|
1508
|
-
onPointerUp: ["pointerup", true],
|
|
1509
|
-
onPointerLeave: ["pointerleave", true],
|
|
1510
|
-
onPointerMove: ["pointermove", true],
|
|
1511
|
-
onPointerCancel: ["pointercancel", true],
|
|
1512
|
-
onLostPointerCapture: ["lostpointercapture", true]
|
|
1513
|
-
};
|
|
1514
|
-
function createPointerEvents(store) {
|
|
1515
|
-
const { handlePointer, flushDeferredPointers, processDeferredPointer } = createEvents(store);
|
|
1516
|
-
let nextXRPointerId = XR_POINTER_ID_START;
|
|
1517
|
-
const xrPointers = /* @__PURE__ */ new Map();
|
|
1518
|
-
return {
|
|
1519
|
-
priority: 1,
|
|
1520
|
-
enabled: true,
|
|
1521
|
-
frameTimedRaycasts: true,
|
|
1522
|
-
alwaysFireOnScroll: true,
|
|
1523
|
-
updateOnFrame: false,
|
|
1524
|
-
compute(event, state) {
|
|
1525
|
-
state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
|
|
1526
|
-
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
1527
|
-
},
|
|
1528
|
-
connected: void 0,
|
|
1529
|
-
handlers: Object.keys(DOM_EVENTS).reduce(
|
|
1530
|
-
(acc, key) => ({ ...acc, [key]: handlePointer(key) }),
|
|
1531
|
-
{}
|
|
1532
|
-
),
|
|
1533
|
-
update: (pointerId) => {
|
|
1534
|
-
const { events, internal } = store.getState();
|
|
1535
|
-
if (!events.handlers) return;
|
|
1536
|
-
if (pointerId !== void 0) {
|
|
1537
|
-
const event = internal.pointerDirty.get(pointerId);
|
|
1538
|
-
if (event) {
|
|
1539
|
-
internal.pointerDirty.delete(pointerId);
|
|
1540
|
-
processDeferredPointer(event, pointerId);
|
|
1541
|
-
} else if (internal.lastEvent?.current) {
|
|
1542
|
-
processDeferredPointer(internal.lastEvent.current, pointerId);
|
|
1543
|
-
}
|
|
1544
|
-
} else {
|
|
1545
|
-
flushDeferredPointers();
|
|
1546
|
-
if (internal.lastEvent?.current) {
|
|
1547
|
-
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
1548
|
-
}
|
|
1549
|
-
}
|
|
1550
|
-
},
|
|
1551
|
-
flush: () => {
|
|
1552
|
-
const { events, internal } = store.getState();
|
|
1553
|
-
flushDeferredPointers();
|
|
1554
|
-
if (events.updateOnFrame && internal.lastEvent?.current && events.handlers) {
|
|
1555
|
-
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
1556
|
-
}
|
|
1557
|
-
},
|
|
1558
|
-
connect: (target) => {
|
|
1559
|
-
if (!target) return;
|
|
1560
|
-
const { set, events } = store.getState();
|
|
1561
|
-
events.disconnect?.();
|
|
1562
|
-
set((state) => ({ events: { ...state.events, connected: target } }));
|
|
1563
|
-
if (events.handlers) {
|
|
1564
|
-
for (const name in events.handlers) {
|
|
1565
|
-
const event = events.handlers[name];
|
|
1566
|
-
const [eventName, passive] = DOM_EVENTS[name];
|
|
1567
|
-
target.addEventListener(eventName, event, { passive });
|
|
1568
|
-
}
|
|
1569
|
-
}
|
|
1570
|
-
},
|
|
1571
|
-
disconnect: () => {
|
|
1572
|
-
const { set, events } = store.getState();
|
|
1573
|
-
if (events.connected) {
|
|
1574
|
-
if (events.handlers) {
|
|
1575
|
-
for (const name in events.handlers) {
|
|
1576
|
-
const event = events.handlers[name];
|
|
1577
|
-
const [eventName] = DOM_EVENTS[name];
|
|
1578
|
-
events.connected.removeEventListener(eventName, event);
|
|
1579
|
-
}
|
|
1580
|
-
}
|
|
1581
|
-
set((state) => ({ events: { ...state.events, connected: void 0 } }));
|
|
1582
|
-
}
|
|
1583
|
-
},
|
|
1584
|
-
// PREVIEW (A8): the XR pointer registration API may change before stable.
|
|
1585
|
-
registerPointer: (config) => {
|
|
1586
|
-
const pointerId = nextXRPointerId++;
|
|
1587
|
-
xrPointers.set(pointerId, config);
|
|
1588
|
-
const { internal } = store.getState();
|
|
1589
|
-
getPointerState(internal, pointerId);
|
|
1590
|
-
return pointerId;
|
|
1591
|
-
},
|
|
1592
|
-
unregisterPointer: (pointerId) => {
|
|
1593
|
-
xrPointers.delete(pointerId);
|
|
1594
|
-
const { internal } = store.getState();
|
|
1595
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1596
|
-
if (pointerState) {
|
|
1597
|
-
for (const [, hoveredObj] of pointerState.hovered) {
|
|
1598
|
-
const eventObject = hoveredObj.eventObject;
|
|
1599
|
-
const instance = eventObject.__r3f;
|
|
1600
|
-
if (instance?.eventCount) {
|
|
1601
|
-
const handlers = instance.handlers;
|
|
1602
|
-
const data = { ...hoveredObj, intersections: [] };
|
|
1603
|
-
handlers.onPointerOut?.(data);
|
|
1604
|
-
handlers.onPointerLeave?.(data);
|
|
1605
|
-
}
|
|
1606
|
-
}
|
|
1607
|
-
internal.pointerMap.delete(pointerId);
|
|
1608
|
-
}
|
|
1609
|
-
internal.pointerDirty.delete(pointerId);
|
|
1610
|
-
}
|
|
1611
|
-
};
|
|
1612
|
-
}
|
|
1613
|
-
|
|
1614
|
-
const shownNotices = /* @__PURE__ */ new Set();
|
|
1615
|
-
function notifyDepreciated({ heading, body, link }) {
|
|
1616
|
-
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_DEPRECATION_WARNINGS !== "true") {
|
|
1617
|
-
return;
|
|
1618
|
-
}
|
|
1619
|
-
if (shownNotices.has(heading)) return;
|
|
1620
|
-
shownNotices.add(heading);
|
|
1621
|
-
const caller = getCallerFrame();
|
|
1622
|
-
if (caller) {
|
|
1623
|
-
console.log();
|
|
1624
|
-
}
|
|
1625
|
-
const boxStyle = "background: #ff9800; color: #1a1a1a; padding: 8px 12px; border-radius: 4px; font-weight: 500;";
|
|
1626
|
-
if (caller) {
|
|
1627
|
-
console.log(`%c\u26A0\uFE0F ${heading}`, boxStyle);
|
|
1628
|
-
}
|
|
1629
|
-
if (body || link) {
|
|
1630
|
-
let message = "";
|
|
1631
|
-
if (body) message += body;
|
|
1632
|
-
if (link) message += (body ? "\n\n" : "") + `More info: ${link}`;
|
|
1633
|
-
console.warn(`%c${message}`, "font-weight: bold;");
|
|
1634
|
-
}
|
|
1635
|
-
}
|
|
1636
|
-
function getCallerFrame(depth = 3) {
|
|
1637
|
-
const stack = new Error().stack;
|
|
1638
|
-
if (!stack) return null;
|
|
1639
|
-
const lines = stack.split("\n");
|
|
1640
|
-
const frame = lines[depth];
|
|
1641
|
-
if (!frame) return null;
|
|
1642
|
-
let match = frame.match(/^\s*at (?:(.+?) )?\(?(.+?):(\d+):(\d+)\)?$/);
|
|
1643
|
-
if (!match) {
|
|
1644
|
-
match = frame.match(/^(?:(.+?)@)?(.+?):(\d+):(\d+)$/);
|
|
1645
|
-
}
|
|
1646
|
-
if (!match) return null;
|
|
1647
|
-
const [, fn, url, line] = match;
|
|
1648
|
-
return {
|
|
1649
|
-
functionName: fn ?? "<anonymous>",
|
|
1650
|
-
location: formatLocation(url, Number(line))
|
|
1651
|
-
};
|
|
1652
|
-
}
|
|
1653
|
-
function formatLocation(url, line) {
|
|
1654
|
-
const clean = url.split("?")[0];
|
|
1655
|
-
const file = clean.split("/").pop() ?? clean;
|
|
1656
|
-
return `${file}:${line}`;
|
|
1657
|
-
}
|
|
1658
|
-
function notifyAlpha({ message, link }) {
|
|
1659
|
-
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_ALPHA_WARNINGS !== "true") {
|
|
1660
|
-
return;
|
|
1661
|
-
}
|
|
1662
|
-
if (shownNotices.has(message)) return;
|
|
1663
|
-
shownNotices.add(message);
|
|
1664
|
-
const boxStyle = "background: #6366f1; color: #ffffff; padding: 6px 10px; border-radius: 4px; font-weight: 500;";
|
|
1665
|
-
console.log(`%c\u{1F52C} ${message}`, boxStyle);
|
|
1666
|
-
{
|
|
1667
|
-
console.log(`%cMore info: ${link}`, "color: #6366f1; font-weight: normal;");
|
|
1668
|
-
}
|
|
1669
|
-
}
|
|
1670
|
-
|
|
1671
|
-
const INTERNAL_LIB_MARKERS = ["zustand", "setState", "Object.assign"];
|
|
1672
|
-
function isInternalRendererAccess(stack, callerDepth = 2) {
|
|
1673
|
-
if (!stack) return false;
|
|
1674
|
-
const caller = stack.split("\n")[callerDepth] ?? "";
|
|
1675
|
-
return INTERNAL_LIB_MARKERS.some((m) => caller.includes(m));
|
|
1676
|
-
}
|
|
1677
|
-
|
|
1678
|
-
const R3F_CONTEXT = Symbol.for("@react-three/fiber.context");
|
|
1679
|
-
const context = globalThis[R3F_CONTEXT] ?? (globalThis[R3F_CONTEXT] = React.createContext(null));
|
|
1680
|
-
const createStore = (invalidate, advance) => {
|
|
1681
|
-
const rootStore = createWithEqualityFn((set, get) => {
|
|
1682
|
-
const position = new Vector3();
|
|
1683
|
-
const defaultTarget = new Vector3();
|
|
1684
|
-
const tempTarget = new Vector3();
|
|
1685
|
-
function getCurrentViewport(camera = get().camera, target = defaultTarget, size = get().size) {
|
|
1686
|
-
const { width, height, top, left } = size;
|
|
1687
|
-
const aspect = width / height;
|
|
1688
|
-
if (target.isVector3) tempTarget.copy(target);
|
|
1689
|
-
else tempTarget.set(...target);
|
|
1690
|
-
const distance = camera.getWorldPosition(position).distanceTo(tempTarget);
|
|
1691
|
-
if (isOrthographicCamera(camera)) {
|
|
1692
|
-
return { width: width / camera.zoom, height: height / camera.zoom, top, left, factor: 1, distance, aspect };
|
|
1693
|
-
} else {
|
|
1694
|
-
const fov = camera.fov * Math.PI / 180;
|
|
1695
|
-
const h = 2 * Math.tan(fov / 2) * distance;
|
|
1696
|
-
const w = h * (width / height);
|
|
1697
|
-
return { width: w, height: h, top, left, factor: width / w, distance, aspect };
|
|
1698
|
-
}
|
|
1699
|
-
}
|
|
1700
|
-
let performanceTimeout = void 0;
|
|
1701
|
-
const setPerformanceCurrent = (current) => set((state2) => ({ performance: { ...state2.performance, current } }));
|
|
1702
|
-
const pointer = new Vector2();
|
|
1703
|
-
const rootState = {
|
|
1704
|
-
set,
|
|
1705
|
-
get,
|
|
1706
|
-
// Mock objects that have to be configured
|
|
1707
|
-
// primaryStore is set after store creation (self-reference for primary, primary's store for secondary)
|
|
1708
|
-
primaryStore: null,
|
|
1709
|
-
gl: null,
|
|
1710
|
-
renderer: null,
|
|
1711
|
-
camera: null,
|
|
1712
|
-
frustum: new Frustum(),
|
|
1713
|
-
autoUpdateFrustum: true,
|
|
1714
|
-
raycaster: null,
|
|
1715
|
-
events: {
|
|
1716
|
-
priority: 1,
|
|
1717
|
-
enabled: true,
|
|
1718
|
-
connected: false,
|
|
1719
|
-
frameTimedRaycasts: true,
|
|
1720
|
-
alwaysFireOnScroll: true,
|
|
1721
|
-
updateOnFrame: false
|
|
1722
|
-
},
|
|
1723
|
-
scene: null,
|
|
1724
|
-
rootScene: null,
|
|
1725
|
-
xr: null,
|
|
1726
|
-
inspector: null,
|
|
1727
|
-
invalidate: (frames = 1, stackFrames = false) => invalidate(get(), frames, stackFrames),
|
|
1728
|
-
advance: (timestamp, runGlobalEffects) => advance(timestamp, runGlobalEffects, get()),
|
|
1729
|
-
textureColorSpace: SRGBColorSpace,
|
|
1730
|
-
isLegacy: false,
|
|
1731
|
-
webGPUSupported: false,
|
|
1732
|
-
isNative: false,
|
|
1733
|
-
controls: null,
|
|
1734
|
-
pointer,
|
|
1735
|
-
mouse: pointer,
|
|
1736
|
-
frameloop: "always",
|
|
1737
|
-
onPointerMissed: void 0,
|
|
1738
|
-
onDragOverMissed: void 0,
|
|
1739
|
-
onDropMissed: void 0,
|
|
1740
|
-
performance: {
|
|
1741
|
-
current: 1,
|
|
1742
|
-
min: 0.5,
|
|
1743
|
-
max: 1,
|
|
1744
|
-
debounce: 200,
|
|
1745
|
-
regress: () => {
|
|
1746
|
-
const state2 = get();
|
|
1747
|
-
if (performanceTimeout) clearTimeout(performanceTimeout);
|
|
1748
|
-
if (state2.performance.current !== state2.performance.min) setPerformanceCurrent(state2.performance.min);
|
|
1749
|
-
performanceTimeout = setTimeout(
|
|
1750
|
-
() => setPerformanceCurrent(get().performance.max),
|
|
1751
|
-
state2.performance.debounce
|
|
1752
|
-
);
|
|
1753
|
-
}
|
|
1754
|
-
},
|
|
1755
|
-
size: { width: 0, height: 0, top: 0, left: 0 },
|
|
1756
|
-
viewport: {
|
|
1757
|
-
initialDpr: 0,
|
|
1758
|
-
dpr: 0,
|
|
1759
|
-
width: 0,
|
|
1760
|
-
height: 0,
|
|
1761
|
-
top: 0,
|
|
1762
|
-
left: 0,
|
|
1763
|
-
aspect: 0,
|
|
1764
|
-
distance: 0,
|
|
1765
|
-
factor: 0,
|
|
1766
|
-
getCurrentViewport
|
|
1767
|
-
},
|
|
1768
|
-
setEvents: (events) => set((state2) => ({ ...state2, events: { ...state2.events, ...events } })),
|
|
1769
|
-
setSize: (width, height, top, left) => {
|
|
1770
|
-
const state2 = get();
|
|
1771
|
-
if (width === void 0) {
|
|
1772
|
-
set({ _sizeImperative: false });
|
|
1773
|
-
if (state2._sizeProps) {
|
|
1774
|
-
const { width: propW, height: propH } = state2._sizeProps;
|
|
1775
|
-
if (propW !== void 0 || propH !== void 0) {
|
|
1776
|
-
const currentSize = state2.size;
|
|
1777
|
-
const newSize = {
|
|
1778
|
-
width: propW ?? currentSize.width,
|
|
1779
|
-
height: propH ?? currentSize.height,
|
|
1780
|
-
top: currentSize.top,
|
|
1781
|
-
left: currentSize.left
|
|
1782
|
-
};
|
|
1783
|
-
set((s) => ({
|
|
1784
|
-
size: newSize,
|
|
1785
|
-
viewport: { ...s.viewport, ...getCurrentViewport(state2.camera, defaultTarget, newSize) }
|
|
1786
|
-
}));
|
|
1787
|
-
getScheduler().invalidate();
|
|
1788
|
-
}
|
|
1789
|
-
}
|
|
1790
|
-
return;
|
|
1791
|
-
}
|
|
1792
|
-
const w = width;
|
|
1793
|
-
const h = height ?? width;
|
|
1794
|
-
const t = top ?? state2.size.top;
|
|
1795
|
-
const l = left ?? state2.size.left;
|
|
1796
|
-
const size = { width: w, height: h, top: t, left: l };
|
|
1797
|
-
set((s) => ({
|
|
1798
|
-
size,
|
|
1799
|
-
viewport: { ...s.viewport, ...getCurrentViewport(state2.camera, defaultTarget, size) },
|
|
1800
|
-
_sizeImperative: true
|
|
1801
|
-
}));
|
|
1802
|
-
getScheduler().invalidate();
|
|
1803
|
-
},
|
|
1804
|
-
setDpr: (dpr) => set((state2) => {
|
|
1805
|
-
const resolved = calculateDpr(dpr);
|
|
1806
|
-
return { viewport: { ...state2.viewport, dpr: resolved, initialDpr: state2.viewport.initialDpr || resolved } };
|
|
1807
|
-
}),
|
|
1808
|
-
setFrameloop: (frameloop = "always") => {
|
|
1809
|
-
set(() => ({ frameloop }));
|
|
1810
|
-
getScheduler().frameloop = frameloop;
|
|
1811
|
-
},
|
|
1812
|
-
setError: (error) => set(() => ({ error })),
|
|
1813
|
-
error: null,
|
|
1814
|
-
//* TSL State (managed via hooks: useUniforms, useNodes, useBuffers, useGPUStorage, useTextures, useRenderPipeline) ==============================
|
|
1815
|
-
uniforms: {},
|
|
1816
|
-
nodes: {},
|
|
1817
|
-
buffers: {},
|
|
1818
|
-
gpuStorage: {},
|
|
1819
|
-
textures: /* @__PURE__ */ new Map(),
|
|
1820
|
-
_textureRefs: /* @__PURE__ */ new Map(),
|
|
1821
|
-
renderPipeline: null,
|
|
1822
|
-
passes: {},
|
|
1823
|
-
_hmrVersion: 0,
|
|
1824
|
-
_sizeImperative: false,
|
|
1825
|
-
_sizeProps: null,
|
|
1826
|
-
previousRoot: void 0,
|
|
1827
|
-
internal: {
|
|
1828
|
-
// Events
|
|
1829
|
-
interaction: [],
|
|
1830
|
-
subscribers: [],
|
|
1831
|
-
// Per-pointer state (new unified structure)
|
|
1832
|
-
pointerMap: /* @__PURE__ */ new Map(),
|
|
1833
|
-
pointerDirty: /* @__PURE__ */ new Map(),
|
|
1834
|
-
lastEvent: React.createRef(),
|
|
1835
|
-
// Deprecated but kept for backwards compatibility
|
|
1836
|
-
hovered: /* @__PURE__ */ new Map(),
|
|
1837
|
-
initialClick: [0, 0],
|
|
1838
|
-
initialHits: [],
|
|
1839
|
-
capturedMap: /* @__PURE__ */ new Map(),
|
|
1840
|
-
// Visibility tracking (onFramed, onOccluded, onVisible)
|
|
1841
|
-
visibilityRegistry: /* @__PURE__ */ new Map(),
|
|
1842
|
-
// Occlusion system (WebGPU only)
|
|
1843
|
-
occlusionEnabled: false,
|
|
1844
|
-
occlusionObserver: null,
|
|
1845
|
-
occlusionCache: /* @__PURE__ */ new Map(),
|
|
1846
|
-
helperGroup: null,
|
|
1847
|
-
// Updates
|
|
1848
|
-
active: false,
|
|
1849
|
-
frames: 0,
|
|
1850
|
-
priority: 0,
|
|
1851
|
-
subscribe: (ref, priority, store) => {
|
|
1852
|
-
const internal = get().internal;
|
|
1853
|
-
internal.priority = internal.priority + (priority > 0 ? 1 : 0);
|
|
1854
|
-
internal.subscribers.push({ ref, priority, store });
|
|
1855
|
-
internal.subscribers = internal.subscribers.sort((a, b) => a.priority - b.priority);
|
|
1856
|
-
return () => {
|
|
1857
|
-
const internal2 = get().internal;
|
|
1858
|
-
if (internal2?.subscribers) {
|
|
1859
|
-
internal2.priority = internal2.priority - (priority > 0 ? 1 : 0);
|
|
1860
|
-
internal2.subscribers = internal2.subscribers.filter((s) => s.ref !== ref);
|
|
1861
|
-
}
|
|
1862
|
-
};
|
|
1863
|
-
},
|
|
1864
|
-
// Renderer Storage (single source of truth)
|
|
1865
|
-
actualRenderer: null,
|
|
1866
|
-
// Scheduler for useFrameNext (initialized in renderer.tsx)
|
|
1867
|
-
scheduler: null
|
|
1868
|
-
}
|
|
1869
|
-
};
|
|
1870
|
-
return rootState;
|
|
1871
|
-
});
|
|
1872
|
-
const state = rootStore.getState();
|
|
1873
|
-
Object.defineProperty(state, "gl", {
|
|
1874
|
-
get() {
|
|
1875
|
-
const currentState = rootStore.getState();
|
|
1876
|
-
if (!currentState.isLegacy && currentState.internal.actualRenderer) {
|
|
1877
|
-
const stack = new Error().stack || "";
|
|
1878
|
-
if (!isInternalRendererAccess(stack)) {
|
|
1879
|
-
const cleanedStack = stack.split("\n").slice(2).join("\n") || "Stack trace unavailable";
|
|
1880
|
-
notifyDepreciated({
|
|
1881
|
-
heading: "Accessing state.gl in WebGPU mode",
|
|
1882
|
-
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
|
|
1883
|
-
});
|
|
1884
|
-
}
|
|
1885
|
-
}
|
|
1886
|
-
return currentState.internal.actualRenderer;
|
|
1887
|
-
},
|
|
1888
|
-
set(value) {
|
|
1889
|
-
rootStore.getState().internal.actualRenderer = value;
|
|
1890
|
-
},
|
|
1891
|
-
enumerable: true,
|
|
1892
|
-
configurable: true
|
|
1893
|
-
});
|
|
1894
|
-
Object.defineProperty(state, "renderer", {
|
|
1895
|
-
get() {
|
|
1896
|
-
return rootStore.getState().internal.actualRenderer;
|
|
1897
|
-
},
|
|
1898
|
-
set(value) {
|
|
1899
|
-
rootStore.getState().internal.actualRenderer = value;
|
|
1900
|
-
},
|
|
1901
|
-
enumerable: true,
|
|
1902
|
-
configurable: true
|
|
1903
|
-
});
|
|
1904
|
-
let oldScene = state.scene;
|
|
1905
|
-
rootStore.subscribe(() => {
|
|
1906
|
-
const currentState = rootStore.getState();
|
|
1907
|
-
const { scene, rootScene, set } = currentState;
|
|
1908
|
-
if (scene !== oldScene) {
|
|
1909
|
-
oldScene = scene;
|
|
1910
|
-
if (scene?.isScene && scene !== rootScene) {
|
|
1911
|
-
set({ rootScene: scene });
|
|
1912
|
-
}
|
|
1913
|
-
}
|
|
1914
|
-
});
|
|
1915
|
-
let oldSize = state.size;
|
|
1916
|
-
let oldDpr = state.viewport.dpr;
|
|
1917
|
-
let oldCamera = state.camera;
|
|
1918
|
-
rootStore.subscribe(() => {
|
|
1919
|
-
const { camera, size, viewport, set, internal } = rootStore.getState();
|
|
1920
|
-
const actualRenderer = internal.actualRenderer;
|
|
1921
|
-
const canvasTarget = internal.canvasTarget;
|
|
1922
|
-
if (size.width !== oldSize.width || size.height !== oldSize.height || viewport.dpr !== oldDpr) {
|
|
1923
|
-
oldSize = size;
|
|
1924
|
-
oldDpr = viewport.dpr;
|
|
1925
|
-
updateCamera(camera, size);
|
|
1926
|
-
if (internal.isSecondary && canvasTarget) {
|
|
1927
|
-
if (viewport.dpr > 0) canvasTarget.setPixelRatio(viewport.dpr);
|
|
1928
|
-
canvasTarget.setSize(size.width, size.height, false);
|
|
1929
|
-
} else {
|
|
1930
|
-
if (viewport.dpr > 0) actualRenderer.setPixelRatio(viewport.dpr);
|
|
1931
|
-
actualRenderer.setSize(size.width, size.height, false);
|
|
1932
|
-
if (canvasTarget) {
|
|
1933
|
-
if (viewport.dpr > 0) canvasTarget.setPixelRatio(viewport.dpr);
|
|
1934
|
-
canvasTarget.setSize(size.width, size.height, false);
|
|
1935
|
-
}
|
|
1936
|
-
}
|
|
1937
|
-
}
|
|
1938
|
-
if (camera !== oldCamera) {
|
|
1939
|
-
oldCamera = camera;
|
|
1940
|
-
const { rootScene } = rootStore.getState();
|
|
1941
|
-
if (camera && rootScene && !camera.parent) {
|
|
1942
|
-
rootScene.add(camera);
|
|
1943
|
-
}
|
|
1944
|
-
set((state2) => ({ viewport: { ...state2.viewport, ...state2.viewport.getCurrentViewport(camera) } }));
|
|
1945
|
-
const currentState = rootStore.getState();
|
|
1946
|
-
if (currentState.autoUpdateFrustum && camera) {
|
|
1947
|
-
updateFrustum(camera, currentState.frustum);
|
|
1948
|
-
}
|
|
1949
|
-
}
|
|
1950
|
-
});
|
|
1951
|
-
rootStore.subscribe((state2) => invalidate(state2));
|
|
1952
|
-
return rootStore;
|
|
1953
|
-
};
|
|
1954
|
-
|
|
1955
|
-
const memoizedLoaders = /* @__PURE__ */ new WeakMap();
|
|
1956
|
-
const isConstructor$1 = (value) => typeof value === "function" && value?.prototype?.constructor === value;
|
|
1957
|
-
function getLoader(Proto) {
|
|
1958
|
-
if (isConstructor$1(Proto)) {
|
|
1959
|
-
let loader = memoizedLoaders.get(Proto);
|
|
1960
|
-
if (!loader) {
|
|
1961
|
-
loader = new Proto();
|
|
1962
|
-
memoizedLoaders.set(Proto, loader);
|
|
1963
|
-
}
|
|
1964
|
-
return loader;
|
|
1965
|
-
}
|
|
1966
|
-
return Proto;
|
|
1967
|
-
}
|
|
1968
|
-
function loadingFn(extensions, onProgress) {
|
|
1969
|
-
return function(Proto, input) {
|
|
1970
|
-
const loader = getLoader(Proto);
|
|
1971
|
-
if (extensions) extensions(loader);
|
|
1972
|
-
if ("loadAsync" in loader && typeof loader.loadAsync === "function") {
|
|
1973
|
-
return loader.loadAsync(input, onProgress).then((data) => {
|
|
1974
|
-
if (isObject3D(data?.scene)) Object.assign(data, buildGraph(data.scene));
|
|
1975
|
-
return data;
|
|
1976
|
-
});
|
|
827
|
+
function loadingFn(extensions, onProgress) {
|
|
828
|
+
return function(Proto, input) {
|
|
829
|
+
const loader = getLoader$1(Proto);
|
|
830
|
+
if (extensions) extensions(loader);
|
|
831
|
+
if ("loadAsync" in loader && typeof loader.loadAsync === "function") {
|
|
832
|
+
return loader.loadAsync(input, onProgress).then((data) => {
|
|
833
|
+
if (isObject3D(data?.scene)) Object.assign(data, buildGraph(data.scene));
|
|
834
|
+
return data;
|
|
835
|
+
});
|
|
1977
836
|
}
|
|
1978
837
|
return new Promise(
|
|
1979
838
|
(res, reject) => loader.load(
|
|
@@ -1995,7 +854,11 @@ function useLoader(loader, input, extensions, onProgress, cacheKey) {
|
|
|
1995
854
|
const results = cacheKeys.map(
|
|
1996
855
|
(key, index) => suspend(() => fn(loader, inputs[index]), [loader, key], { equal: is.equ })
|
|
1997
856
|
);
|
|
1998
|
-
|
|
857
|
+
const stableRef = useRef(null);
|
|
858
|
+
const previous = stableRef.current;
|
|
859
|
+
const stable = previous !== null && previous.length === results.length && previous.every((value, i) => value === results[i]) ? previous : results;
|
|
860
|
+
stableRef.current = stable;
|
|
861
|
+
return Array.isArray(input) ? stable : stable[0];
|
|
1999
862
|
}
|
|
2000
863
|
useLoader.preload = function(loader, input, extensions, onProgress, cacheKey) {
|
|
2001
864
|
const inputs = Array.isArray(input) ? input : [input];
|
|
@@ -2008,9 +871,9 @@ useLoader.clear = function(loader, input, cacheKey) {
|
|
|
2008
871
|
const cacheKeys = Array.isArray(cacheKey ?? input) ? cacheKey ?? input : [cacheKey ?? input];
|
|
2009
872
|
cacheKeys.forEach((key) => clear([loader, key]));
|
|
2010
873
|
};
|
|
2011
|
-
useLoader.loader = getLoader;
|
|
874
|
+
useLoader.loader = getLoader$1;
|
|
2012
875
|
|
|
2013
|
-
function useFrame(callback, priorityOrOptions) {
|
|
876
|
+
function useFrame$1(callback, priorityOrOptions) {
|
|
2014
877
|
const store = React.useContext(context);
|
|
2015
878
|
const isInsideCanvas = store !== null;
|
|
2016
879
|
const scheduler = getScheduler();
|
|
@@ -2115,6 +978,13 @@ function useFrame(callback, priorityOrOptions) {
|
|
|
2115
978
|
* Use for controlling the entire frame loop, adding phases, etc.
|
|
2116
979
|
*/
|
|
2117
980
|
scheduler: scheduler2,
|
|
981
|
+
/**
|
|
982
|
+
* The root that currently owns this job. Resolve on access because ambient
|
|
983
|
+
* jobs can be adopted by a Canvas after the controls object is created.
|
|
984
|
+
*/
|
|
985
|
+
get rootId() {
|
|
986
|
+
return getScheduler().getJobRootId(id);
|
|
987
|
+
},
|
|
2118
988
|
/**
|
|
2119
989
|
* Manually step this job only.
|
|
2120
990
|
* Bypasses FPS limiting - always runs.
|
|
@@ -2131,6 +1001,14 @@ function useFrame(callback, priorityOrOptions) {
|
|
|
2131
1001
|
stepAll: (timestamp) => {
|
|
2132
1002
|
getScheduler().step(timestamp);
|
|
2133
1003
|
},
|
|
1004
|
+
/**
|
|
1005
|
+
* Request frames for this job's owning root without waking sibling roots.
|
|
1006
|
+
*/
|
|
1007
|
+
invalidate: (frames, stackFrames) => {
|
|
1008
|
+
const scheduler3 = getScheduler();
|
|
1009
|
+
const rootId = scheduler3.getJobRootId(id);
|
|
1010
|
+
if (rootId) scheduler3.invalidateRoot(rootId, frames, stackFrames);
|
|
1011
|
+
},
|
|
2134
1012
|
/**
|
|
2135
1013
|
* Pause this job (set enabled=false).
|
|
2136
1014
|
* Job remains registered but won't run.
|
|
@@ -2160,6 +1038,11 @@ function getUrls(input) {
|
|
|
2160
1038
|
if (Array.isArray(input)) return input;
|
|
2161
1039
|
return Object.values(input);
|
|
2162
1040
|
}
|
|
1041
|
+
function inputSignature(input) {
|
|
1042
|
+
if (typeof input === "string") return input;
|
|
1043
|
+
if (Array.isArray(input)) return input.join("\0");
|
|
1044
|
+
return Object.keys(input).sort().map((key) => `${key}\0${input[key]}`).join("");
|
|
1045
|
+
}
|
|
2163
1046
|
function allUrlsCached(urls, textureCache) {
|
|
2164
1047
|
return urls.every((url) => textureCache.has(url));
|
|
2165
1048
|
}
|
|
@@ -2178,31 +1061,44 @@ function buildFromCache(input, textureCache) {
|
|
|
2178
1061
|
}
|
|
2179
1062
|
}
|
|
2180
1063
|
function useTexture(input, optionsOrOnLoad) {
|
|
2181
|
-
const renderer = useThree((state) => state.internal.actualRenderer);
|
|
1064
|
+
const renderer = useThree$1((state) => state.internal.actualRenderer);
|
|
2182
1065
|
const store = useStore();
|
|
2183
1066
|
const options = typeof optionsOrOnLoad === "function" ? { onLoad: optionsOrOnLoad } : optionsOrOnLoad ?? {};
|
|
2184
1067
|
const { onLoad, cache = true } = options;
|
|
2185
1068
|
const onLoadRef = useRef(onLoad);
|
|
2186
1069
|
onLoadRef.current = onLoad;
|
|
2187
1070
|
const onLoadCalledForRef = useRef(null);
|
|
2188
|
-
const
|
|
1071
|
+
const inputKey = useMemo(() => inputSignature(input), [input]);
|
|
1072
|
+
const stableInput = useMemo(() => input, [inputKey]);
|
|
1073
|
+
const urls = useMemo(() => getUrls(stableInput), [stableInput]);
|
|
2189
1074
|
const cachedResult = useMemo(() => {
|
|
2190
1075
|
if (!cache) return null;
|
|
2191
1076
|
const textures = store.getState().textures;
|
|
2192
1077
|
if (!allUrlsCached(urls, textures)) return null;
|
|
2193
|
-
return buildFromCache(
|
|
2194
|
-
}, [cache, urls,
|
|
1078
|
+
return buildFromCache(stableInput, textures);
|
|
1079
|
+
}, [cache, urls, stableInput, store]);
|
|
2195
1080
|
const loadedTextures = useLoader(
|
|
2196
1081
|
TextureLoader,
|
|
2197
|
-
IsObject(
|
|
1082
|
+
IsObject(stableInput) ? Object.values(stableInput) : stableInput
|
|
2198
1083
|
);
|
|
2199
|
-
const
|
|
1084
|
+
const mappedTextures = useMemo(() => {
|
|
1085
|
+
if (cachedResult) return cachedResult;
|
|
1086
|
+
if (IsObject(stableInput)) {
|
|
1087
|
+
const keyed = {};
|
|
1088
|
+
const textureArray = loadedTextures;
|
|
1089
|
+
let i = 0;
|
|
1090
|
+
for (const key in stableInput) keyed[key] = textureArray[i++];
|
|
1091
|
+
return keyed;
|
|
1092
|
+
} else {
|
|
1093
|
+
return loadedTextures;
|
|
1094
|
+
}
|
|
1095
|
+
}, [stableInput, loadedTextures, cachedResult]);
|
|
2200
1096
|
useLayoutEffect(() => {
|
|
2201
1097
|
if (cachedResult) return;
|
|
2202
1098
|
if (onLoadCalledForRef.current === inputKey) return;
|
|
2203
1099
|
onLoadCalledForRef.current = inputKey;
|
|
2204
|
-
onLoadRef.current?.(
|
|
2205
|
-
}, [cachedResult,
|
|
1100
|
+
onLoadRef.current?.(mappedTextures);
|
|
1101
|
+
}, [cachedResult, mappedTextures, inputKey]);
|
|
2206
1102
|
useEffect(() => {
|
|
2207
1103
|
if (cachedResult) return;
|
|
2208
1104
|
if ("initTexture" in renderer) {
|
|
@@ -2221,30 +1117,18 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
2221
1117
|
});
|
|
2222
1118
|
}
|
|
2223
1119
|
}, [renderer, loadedTextures, cachedResult]);
|
|
2224
|
-
const mappedTextures = useMemo(() => {
|
|
2225
|
-
if (cachedResult) return cachedResult;
|
|
2226
|
-
if (IsObject(input)) {
|
|
2227
|
-
const keyed = {};
|
|
2228
|
-
const textureArray = loadedTextures;
|
|
2229
|
-
let i = 0;
|
|
2230
|
-
for (const key in input) keyed[key] = textureArray[i++];
|
|
2231
|
-
return keyed;
|
|
2232
|
-
} else {
|
|
2233
|
-
return loadedTextures;
|
|
2234
|
-
}
|
|
2235
|
-
}, [input, loadedTextures, cachedResult]);
|
|
2236
1120
|
useEffect(() => {
|
|
2237
1121
|
if (!cache) return;
|
|
2238
1122
|
const urlTextureMap = [];
|
|
2239
|
-
if (typeof
|
|
2240
|
-
urlTextureMap.push([
|
|
2241
|
-
} else if (Array.isArray(
|
|
1123
|
+
if (typeof stableInput === "string") {
|
|
1124
|
+
urlTextureMap.push([stableInput, mappedTextures]);
|
|
1125
|
+
} else if (Array.isArray(stableInput)) {
|
|
2242
1126
|
const textureArray = mappedTextures;
|
|
2243
|
-
|
|
2244
|
-
} else if (IsObject(
|
|
1127
|
+
stableInput.forEach((url, i) => urlTextureMap.push([url, textureArray[i]]));
|
|
1128
|
+
} else if (IsObject(stableInput)) {
|
|
2245
1129
|
const textureRecord = mappedTextures;
|
|
2246
|
-
for (const key in
|
|
2247
|
-
const url =
|
|
1130
|
+
for (const key in stableInput) {
|
|
1131
|
+
const url = stableInput[key];
|
|
2248
1132
|
urlTextureMap.push([url, textureRecord[key]]);
|
|
2249
1133
|
}
|
|
2250
1134
|
}
|
|
@@ -2273,7 +1157,7 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
2273
1157
|
}
|
|
2274
1158
|
return { _textureRefs: refs };
|
|
2275
1159
|
});
|
|
2276
|
-
}, [cache,
|
|
1160
|
+
}, [cache, stableInput, mappedTextures, store]);
|
|
2277
1161
|
return mappedTextures;
|
|
2278
1162
|
}
|
|
2279
1163
|
useTexture.preload = (url) => useLoader.preload(TextureLoader, url);
|
|
@@ -2344,13 +1228,13 @@ function useTextures(selector) {
|
|
|
2344
1228
|
};
|
|
2345
1229
|
}, [store]);
|
|
2346
1230
|
const subscribe = selector ? () => selector(registry) : (state) => state.textures;
|
|
2347
|
-
const selected = useThree(subscribe);
|
|
1231
|
+
const selected = useThree$1(subscribe);
|
|
2348
1232
|
return selector ? selected : registry;
|
|
2349
1233
|
}
|
|
2350
1234
|
|
|
2351
1235
|
function useRenderTarget(widthOrOptions, heightOrOptions, options) {
|
|
2352
|
-
const isLegacy = useThree((s) => s.isLegacy);
|
|
2353
|
-
const size = useThree((s) => s.size);
|
|
1236
|
+
const isLegacy = useThree$1((s) => s.isLegacy);
|
|
1237
|
+
const size = useThree$1((s) => s.size);
|
|
2354
1238
|
let width;
|
|
2355
1239
|
let height;
|
|
2356
1240
|
let opts;
|
|
@@ -2368,21 +1252,134 @@ function useRenderTarget(widthOrOptions, heightOrOptions, options) {
|
|
|
2368
1252
|
height = widthOrOptions;
|
|
2369
1253
|
}
|
|
2370
1254
|
}
|
|
2371
|
-
return useMemo(() => {
|
|
2372
|
-
const w = width ?? size.width;
|
|
2373
|
-
const h = height ?? size.height;
|
|
2374
|
-
return new WebGLRenderTarget(w, h, opts);
|
|
2375
|
-
}, [width, height, size.width, size.height, opts, isLegacy]);
|
|
1255
|
+
return useMemo(() => {
|
|
1256
|
+
const w = width ?? size.width;
|
|
1257
|
+
const h = height ?? size.height;
|
|
1258
|
+
return new WebGLRenderTarget(w, h, opts);
|
|
1259
|
+
}, [width, height, size.width, size.height, opts, isLegacy]);
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
const presetsObj = {
|
|
1263
|
+
apartment: "lebombo_1k.hdr",
|
|
1264
|
+
city: "potsdamer_platz_1k.hdr",
|
|
1265
|
+
dawn: "kiara_1_dawn_1k.hdr",
|
|
1266
|
+
forest: "forest_slope_1k.hdr",
|
|
1267
|
+
lobby: "st_fagans_interior_1k.hdr",
|
|
1268
|
+
night: "dikhololo_night_1k.hdr",
|
|
1269
|
+
park: "rooitou_park_1k.hdr",
|
|
1270
|
+
studio: "studio_small_03_1k.hdr",
|
|
1271
|
+
sunset: "venice_sunset_1k.hdr",
|
|
1272
|
+
warehouse: "empty_warehouse_01_1k.hdr"
|
|
1273
|
+
};
|
|
1274
|
+
|
|
1275
|
+
const CUBEMAP_ROOT = "https://raw.githack.com/pmndrs/drei-assets/456060a26bbeb8fdf79326f224b6d99b8bcce736/hdri/";
|
|
1276
|
+
const isArray = (arr) => Array.isArray(arr);
|
|
1277
|
+
const defaultFiles = ["/px.png", "/nx.png", "/py.png", "/ny.png", "/pz.png", "/nz.png"];
|
|
1278
|
+
function useEnvironment({
|
|
1279
|
+
files = defaultFiles,
|
|
1280
|
+
path = "",
|
|
1281
|
+
preset = void 0,
|
|
1282
|
+
colorSpace = void 0,
|
|
1283
|
+
extensions
|
|
1284
|
+
} = {}) {
|
|
1285
|
+
if (preset) {
|
|
1286
|
+
validatePreset(preset);
|
|
1287
|
+
files = presetsObj[preset];
|
|
1288
|
+
path = CUBEMAP_ROOT;
|
|
1289
|
+
}
|
|
1290
|
+
const multiFile = isArray(files);
|
|
1291
|
+
const { extension, isCubemap } = getExtension(files);
|
|
1292
|
+
const loader = getLoader(extension);
|
|
1293
|
+
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1294
|
+
const renderer = useThree$1((state) => state.renderer);
|
|
1295
|
+
useLayoutEffect(() => {
|
|
1296
|
+
if (extension !== "webp" && extension !== "jpg" && extension !== "jpeg") return;
|
|
1297
|
+
function clearGainmapTexture() {
|
|
1298
|
+
useLoader.clear(loader, multiFile ? [files] : files);
|
|
1299
|
+
}
|
|
1300
|
+
renderer.domElement.addEventListener("webglcontextlost", clearGainmapTexture, { once: true });
|
|
1301
|
+
}, [extension, files, loader, multiFile, renderer.domElement]);
|
|
1302
|
+
const loaderResult = useLoader(
|
|
1303
|
+
loader,
|
|
1304
|
+
multiFile ? [files] : files,
|
|
1305
|
+
(loader2) => {
|
|
1306
|
+
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
1307
|
+
loader2.setRenderer?.(renderer);
|
|
1308
|
+
}
|
|
1309
|
+
loader2.setPath?.(path);
|
|
1310
|
+
if (extensions) extensions(loader2);
|
|
1311
|
+
}
|
|
1312
|
+
);
|
|
1313
|
+
let texture = multiFile ? (
|
|
1314
|
+
// @ts-ignore
|
|
1315
|
+
loaderResult[0]
|
|
1316
|
+
) : loaderResult;
|
|
1317
|
+
if (extension === "jpg" || extension === "jpeg" || extension === "webp") {
|
|
1318
|
+
texture = texture.renderTarget?.texture;
|
|
1319
|
+
}
|
|
1320
|
+
texture.mapping = isCubemap ? CubeReflectionMapping : EquirectangularReflectionMapping;
|
|
1321
|
+
texture.colorSpace = colorSpace ?? (isCubemap && extension !== "hdr-cube" ? "srgb" : "srgb-linear");
|
|
1322
|
+
return texture;
|
|
1323
|
+
}
|
|
1324
|
+
const preloadDefaultOptions = {
|
|
1325
|
+
files: defaultFiles,
|
|
1326
|
+
path: "",
|
|
1327
|
+
preset: void 0,
|
|
1328
|
+
extensions: void 0
|
|
1329
|
+
};
|
|
1330
|
+
useEnvironment.preload = (preloadOptions) => {
|
|
1331
|
+
const options = { ...preloadDefaultOptions, ...preloadOptions };
|
|
1332
|
+
let { files, path = "" } = options;
|
|
1333
|
+
const { preset, extensions } = options;
|
|
1334
|
+
if (preset) {
|
|
1335
|
+
validatePreset(preset);
|
|
1336
|
+
files = presetsObj[preset];
|
|
1337
|
+
path = CUBEMAP_ROOT;
|
|
1338
|
+
}
|
|
1339
|
+
const { extension } = getExtension(files);
|
|
1340
|
+
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
1341
|
+
throw new Error("useEnvironment: Preloading gainmaps is not supported");
|
|
1342
|
+
}
|
|
1343
|
+
const loader = getLoader(extension);
|
|
1344
|
+
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1345
|
+
useLoader.preload(loader, isArray(files) ? [files] : files, (loader2) => {
|
|
1346
|
+
loader2.setPath?.(path);
|
|
1347
|
+
if (extensions) extensions(loader2);
|
|
1348
|
+
});
|
|
1349
|
+
};
|
|
1350
|
+
const clearDefaultOptins = {
|
|
1351
|
+
files: defaultFiles,
|
|
1352
|
+
preset: void 0
|
|
1353
|
+
};
|
|
1354
|
+
useEnvironment.clear = (clearOptions) => {
|
|
1355
|
+
const options = { ...clearDefaultOptins, ...clearOptions };
|
|
1356
|
+
let { files } = options;
|
|
1357
|
+
const { preset } = options;
|
|
1358
|
+
if (preset) {
|
|
1359
|
+
validatePreset(preset);
|
|
1360
|
+
files = presetsObj[preset];
|
|
1361
|
+
}
|
|
1362
|
+
const { extension } = getExtension(files);
|
|
1363
|
+
const loader = getLoader(extension);
|
|
1364
|
+
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1365
|
+
useLoader.clear(loader, isArray(files) ? [files] : files);
|
|
1366
|
+
};
|
|
1367
|
+
function validatePreset(preset) {
|
|
1368
|
+
if (!(preset in presetsObj)) throw new Error("Preset must be one of: " + Object.keys(presetsObj).join(", "));
|
|
2376
1369
|
}
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
const
|
|
2380
|
-
|
|
2381
|
-
|
|
1370
|
+
function getExtension(files) {
|
|
1371
|
+
const isCubemap = isArray(files) && files.length === 6;
|
|
1372
|
+
const isGainmap = isArray(files) && files.length === 3 && files.some((file) => file.endsWith("json"));
|
|
1373
|
+
const firstEntry = isArray(files) ? files[0] : files;
|
|
1374
|
+
const firstExtension = firstEntry.split(".").pop()?.split("?")?.shift()?.toLowerCase();
|
|
1375
|
+
const extension = isCubemap ? firstExtension === "hdr" ? "hdr-cube" : "cube" : isGainmap ? "webp" : firstEntry.startsWith("data:application/exr") ? "exr" : firstEntry.startsWith("data:application/hdr") ? "hdr" : firstEntry.startsWith("data:image/jpeg") ? "jpg" : firstExtension;
|
|
1376
|
+
return { extension, isCubemap, isGainmap };
|
|
2382
1377
|
}
|
|
2383
|
-
function
|
|
2384
|
-
|
|
1378
|
+
function getLoader(extension) {
|
|
1379
|
+
const loader = extension === "cube" ? CubeTextureLoader : extension === "hdr-cube" ? HDRCubeTextureLoader : extension === "hdr" ? HDRLoader : extension === "exr" ? EXRLoader : extension === "jpg" || extension === "jpeg" ? UltraHDRLoader : extension === "webp" ? GainMapLoader : null;
|
|
1380
|
+
return loader;
|
|
2385
1381
|
}
|
|
1382
|
+
|
|
2386
1383
|
function useInstanceHandle(ref) {
|
|
2387
1384
|
const instance = useRef(null);
|
|
2388
1385
|
useImperativeHandle(instance, () => ref.current.__r3f, [ref]);
|
|
@@ -2392,6 +1389,8 @@ function useGraph(object) {
|
|
|
2392
1389
|
return useMemo(() => buildGraph(object), [object]);
|
|
2393
1390
|
}
|
|
2394
1391
|
|
|
1392
|
+
const t = 1, o = 8, r = 32, e = 2, i$1 = 268435456;
|
|
1393
|
+
|
|
2395
1394
|
let effectId = 0;
|
|
2396
1395
|
function addEffect(callback) {
|
|
2397
1396
|
notifyDepreciated({
|
|
@@ -2420,13 +1419,19 @@ function addTail(callback) {
|
|
|
2420
1419
|
return getScheduler().onIdle(callback);
|
|
2421
1420
|
}
|
|
2422
1421
|
function invalidate(state, frames = 1, stackFrames = false) {
|
|
2423
|
-
|
|
1422
|
+
const rootId = state?.internal?.rootId;
|
|
1423
|
+
const scheduler = getScheduler();
|
|
1424
|
+
if (rootId) scheduler.invalidateRoot(rootId, frames, stackFrames);
|
|
1425
|
+
else scheduler.invalidate(frames, stackFrames);
|
|
2424
1426
|
}
|
|
2425
|
-
function advance(timestamp) {
|
|
2426
|
-
|
|
1427
|
+
function advance(timestamp, runGlobalEffects, state) {
|
|
1428
|
+
const rootId = state?.internal?.rootId;
|
|
1429
|
+
const scheduler = getScheduler();
|
|
1430
|
+
if (rootId) scheduler.stepRoot(rootId, timestamp);
|
|
1431
|
+
else scheduler.step(timestamp);
|
|
2427
1432
|
}
|
|
2428
1433
|
|
|
2429
|
-
const version = "10.0.0-alpha.
|
|
1434
|
+
const version = "10.0.0-alpha.5";
|
|
2430
1435
|
const packageData = {
|
|
2431
1436
|
version: version};
|
|
2432
1437
|
|
|
@@ -13310,379 +12315,962 @@ Check the top-level render call using <` + i + ">.");
|
|
|
13310
12315
|
var e = x.H;
|
|
13311
12316
|
x.H = $o;
|
|
13312
12317
|
try {
|
|
13313
|
-
return Br(gr);
|
|
12318
|
+
return Br(gr);
|
|
12319
|
+
} finally {
|
|
12320
|
+
x.H = e;
|
|
12321
|
+
}
|
|
12322
|
+
}, useDebugValue: function() {
|
|
12323
|
+
z = "useDebugValue", D(), N();
|
|
12324
|
+
}, useDeferredValue: function(e, n) {
|
|
12325
|
+
return z = "useDeferredValue", D(), N(), nc(e, n);
|
|
12326
|
+
}, useTransition: function() {
|
|
12327
|
+
return z = "useTransition", D(), N(), Qp();
|
|
12328
|
+
}, useSyncExternalStore: function(e, n, o) {
|
|
12329
|
+
return z = "useSyncExternalStore", D(), N(), ta(e, n, o);
|
|
12330
|
+
}, useId: function() {
|
|
12331
|
+
return z = "useId", D(), N(), xe().memoizedState;
|
|
12332
|
+
}, useFormState: function(e) {
|
|
12333
|
+
return z = "useFormState", D(), N(), hs(e);
|
|
12334
|
+
}, useActionState: function(e) {
|
|
12335
|
+
return z = "useActionState", D(), N(), hs(e);
|
|
12336
|
+
}, useOptimistic: function(e, n) {
|
|
12337
|
+
return z = "useOptimistic", D(), N(), rf(e, n);
|
|
12338
|
+
}, useMemoCache: function(e) {
|
|
12339
|
+
return D(), Oa(e);
|
|
12340
|
+
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
12341
|
+
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
12342
|
+
}, useEffectEvent: function(e) {
|
|
12343
|
+
return z = "useEffectEvent", D(), N(), oa(e);
|
|
12344
|
+
} }, dm = { readContext: function(e) {
|
|
12345
|
+
return Ce(), Ee(e);
|
|
12346
|
+
}, use: function(e) {
|
|
12347
|
+
return D(), we(e);
|
|
12348
|
+
}, useCallback: function(e, n) {
|
|
12349
|
+
return z = "useCallback", D(), N(), Ma(e, n);
|
|
12350
|
+
}, useContext: function(e) {
|
|
12351
|
+
return z = "useContext", D(), N(), Ee(e);
|
|
12352
|
+
}, useEffect: function(e, n) {
|
|
12353
|
+
z = "useEffect", D(), N(), Qn(2048, Ut, e, n);
|
|
12354
|
+
}, useImperativeHandle: function(e, n, o) {
|
|
12355
|
+
return z = "useImperativeHandle", D(), N(), aa(e, n, o);
|
|
12356
|
+
}, useInsertionEffect: function(e, n) {
|
|
12357
|
+
return z = "useInsertionEffect", D(), N(), Qn(4, Wt, e, n);
|
|
12358
|
+
}, useLayoutEffect: function(e, n) {
|
|
12359
|
+
return z = "useLayoutEffect", D(), N(), Qn(4, Rr, e, n);
|
|
12360
|
+
}, useMemo: function(e, n) {
|
|
12361
|
+
z = "useMemo", D(), N();
|
|
12362
|
+
var o = x.H;
|
|
12363
|
+
x.H = $o;
|
|
12364
|
+
try {
|
|
12365
|
+
return Vi(e, n);
|
|
12366
|
+
} finally {
|
|
12367
|
+
x.H = o;
|
|
12368
|
+
}
|
|
12369
|
+
}, useReducer: function(e, n, o) {
|
|
12370
|
+
z = "useReducer", D(), N();
|
|
12371
|
+
var i = x.H;
|
|
12372
|
+
x.H = $o;
|
|
12373
|
+
try {
|
|
12374
|
+
return Qi(e, n, o);
|
|
12375
|
+
} finally {
|
|
12376
|
+
x.H = i;
|
|
12377
|
+
}
|
|
12378
|
+
}, useRef: function() {
|
|
12379
|
+
return z = "useRef", D(), N(), xe().memoizedState;
|
|
12380
|
+
}, useState: function() {
|
|
12381
|
+
z = "useState", D(), N();
|
|
12382
|
+
var e = x.H;
|
|
12383
|
+
x.H = $o;
|
|
12384
|
+
try {
|
|
12385
|
+
return Qi(gr);
|
|
12386
|
+
} finally {
|
|
12387
|
+
x.H = e;
|
|
12388
|
+
}
|
|
12389
|
+
}, useDebugValue: function() {
|
|
12390
|
+
z = "useDebugValue", D(), N();
|
|
12391
|
+
}, useDeferredValue: function(e, n) {
|
|
12392
|
+
return z = "useDeferredValue", D(), N(), sf(e, n);
|
|
12393
|
+
}, useTransition: function() {
|
|
12394
|
+
return z = "useTransition", D(), N(), Ro();
|
|
12395
|
+
}, useSyncExternalStore: function(e, n, o) {
|
|
12396
|
+
return z = "useSyncExternalStore", D(), N(), ta(e, n, o);
|
|
12397
|
+
}, useId: function() {
|
|
12398
|
+
return z = "useId", D(), N(), xe().memoizedState;
|
|
12399
|
+
}, useFormState: function(e) {
|
|
12400
|
+
return z = "useFormState", D(), N(), $t(e);
|
|
12401
|
+
}, useActionState: function(e) {
|
|
12402
|
+
return z = "useActionState", D(), N(), $t(e);
|
|
12403
|
+
}, useOptimistic: function(e, n) {
|
|
12404
|
+
return z = "useOptimistic", D(), N(), of(e, n);
|
|
12405
|
+
}, useMemoCache: function(e) {
|
|
12406
|
+
return D(), Oa(e);
|
|
12407
|
+
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
12408
|
+
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
12409
|
+
}, useEffectEvent: function(e) {
|
|
12410
|
+
return z = "useEffectEvent", D(), N(), oa(e);
|
|
12411
|
+
} };
|
|
12412
|
+
var Fy = {}, Hy = /* @__PURE__ */ new Set(), Ay = /* @__PURE__ */ new Set(), jy = /* @__PURE__ */ new Set(), Dy = /* @__PURE__ */ new Set(), Wy = /* @__PURE__ */ new Set(), Uy = /* @__PURE__ */ new Set(), By = /* @__PURE__ */ new Set(), Oy = /* @__PURE__ */ new Set(), My = /* @__PURE__ */ new Set(), Qy = /* @__PURE__ */ new Set();
|
|
12413
|
+
Object.freeze(Fy);
|
|
12414
|
+
var zg = { enqueueSetState: function(e, n, o) {
|
|
12415
|
+
e = e._reactInternals;
|
|
12416
|
+
var i = Nt(e), s = zo(i);
|
|
12417
|
+
s.payload = n, o != null && (df(o), s.callback = o), n = Mt(e, s, i), n !== null && (ur(i, "this.setState()", e), We(n, e, i), Bi(n, e, i));
|
|
12418
|
+
}, enqueueReplaceState: function(e, n, o) {
|
|
12419
|
+
e = e._reactInternals;
|
|
12420
|
+
var i = Nt(e), s = zo(i);
|
|
12421
|
+
s.tag = Cy, s.payload = n, o != null && (df(o), s.callback = o), n = Mt(e, s, i), n !== null && (ur(i, "this.replaceState()", e), We(n, e, i), Bi(n, e, i));
|
|
12422
|
+
}, enqueueForceUpdate: function(e, n) {
|
|
12423
|
+
e = e._reactInternals;
|
|
12424
|
+
var o = Nt(e), i = zo(o);
|
|
12425
|
+
i.tag = Ty, n != null && (df(n), i.callback = n), n = Mt(e, i, o), n !== null && (ur(o, "this.forceUpdate()", e), We(n, e, o), Bi(n, e, o));
|
|
12426
|
+
} }, bd = null, Cg = null, Tg = Error("This is not a real error. It's an implementation detail of React's selective hydration feature. If this leaks into userspace, it's a bug in React. Please file an issue."), Cn = false, $y = {}, Vy = {}, qy = {}, Gy = {}, vd = false, Jy = {}, fm = {}, _g = { dehydrated: null, treeContext: null, retryLane: 0, hydrationErrors: null }, Zy = false, Yy = null;
|
|
12427
|
+
Yy = /* @__PURE__ */ new Set();
|
|
12428
|
+
var Si = false, Tn = false, Rg = false, Xy = typeof WeakSet == "function" ? WeakSet : Set, Gn = null, Sd = null, kd = null, _n = null, nr = false, Vo = null, Wn = false, wd = 8192, Vb = { getCacheForType: function(e) {
|
|
12429
|
+
var n = Ee(un), o = n.data.get(e);
|
|
12430
|
+
return o === void 0 && (o = e(), n.data.set(e, o)), o;
|
|
12431
|
+
}, cacheSignal: function() {
|
|
12432
|
+
return Ee(un).controller.signal;
|
|
12433
|
+
}, getOwner: function() {
|
|
12434
|
+
return di;
|
|
12435
|
+
} }, pm = 0, hm = 1, mm = 2, gm = 3, ym = 4;
|
|
12436
|
+
if (typeof Symbol == "function" && Symbol.for) {
|
|
12437
|
+
var bp = Symbol.for;
|
|
12438
|
+
pm = bp("selector.component"), hm = bp("selector.has_pseudo_class"), mm = bp("selector.role"), gm = bp("selector.test_id"), ym = bp("selector.text");
|
|
12439
|
+
}
|
|
12440
|
+
var bm = [], qb = typeof WeakMap == "function" ? WeakMap : Map, Jn = 0, Zn = 2, uo = 4, ki = 0, vp = 1, iu = 2, vm = 3, Tl = 4, Sm = 6, Ky = 5, ye = Jn, je = null, se = null, ae = 0, tr = 0, km = 1, lu = 2, Sp = 3, eb = 4, Eg = 5, kp = 6, wm = 7, Ig = 8, su = 9, Le = tr, Er = null, _l = false, Pd = false, Lg = false, Ta = 0, nn = ki, Rl = 0, El = 0, Ng = 0, rr = 0, uu = 0, wp = null, Bt = null, Pm = false, xm = 0, nb = 0, tb = 300, Pp = 1 / 0, Fg = 500, xp = null, gn = null, Il = null, zm = 0, Hg = 1, Ag = 2, rb = 3, Ll = 0, ob = 1, ab = 2, ib = 3, lb = 4, Cm = 5, Rn = 0, Nl = null, xd = null, qo = 0, jg = 0, Dg = -0, Wg = null, sb = null, ub = null, Go = zm, cb = null, Gb = 50, zp = 0, Ug = null, Bg = false, Tm = false, Jb = 50, cu = 0, Cp = null, zd = false, _m = null, db = false, fb = /* @__PURE__ */ new Set(), Zb = {}, co = null, Cd = null, pb = false;
|
|
12441
|
+
try {
|
|
12442
|
+
var o0 = Object.preventExtensions({});
|
|
12443
|
+
} catch {
|
|
12444
|
+
pb = true;
|
|
12445
|
+
}
|
|
12446
|
+
var hb = false, mb = {}, gb = null, yb = null, bb = null, vb = null, Sb = null, kb = null, wb = null, Pb = null, xb = null, zb = null;
|
|
12447
|
+
return gb = function(e, n, o, i) {
|
|
12448
|
+
n = Yn(e, n), n !== null && (o = _d(n.memoizedState, o, 0, i), n.memoizedState = o, n.baseState = o, e.memoizedProps = ze({}, e.memoizedProps), o = On(e, 2), o !== null && We(o, e, 2));
|
|
12449
|
+
}, yb = function(e, n, o) {
|
|
12450
|
+
n = Yn(e, n), n !== null && (o = du(n.memoizedState, o, 0), n.memoizedState = o, n.baseState = o, e.memoizedProps = ze({}, e.memoizedProps), o = On(e, 2), o !== null && We(o, e, 2));
|
|
12451
|
+
}, bb = function(e, n, o, i) {
|
|
12452
|
+
n = Yn(e, n), n !== null && (o = F(n.memoizedState, o, i), n.memoizedState = o, n.baseState = o, e.memoizedProps = ze({}, e.memoizedProps), o = On(e, 2), o !== null && We(o, e, 2));
|
|
12453
|
+
}, vb = function(e, n, o) {
|
|
12454
|
+
e.pendingProps = _d(e.memoizedProps, n, 0, o), e.alternate && (e.alternate.pendingProps = e.pendingProps), n = On(e, 2), n !== null && We(n, e, 2);
|
|
12455
|
+
}, Sb = function(e, n) {
|
|
12456
|
+
e.pendingProps = du(e.memoizedProps, n, 0), e.alternate && (e.alternate.pendingProps = e.pendingProps), n = On(e, 2), n !== null && We(n, e, 2);
|
|
12457
|
+
}, kb = function(e, n, o) {
|
|
12458
|
+
e.pendingProps = F(e.memoizedProps, n, o), e.alternate && (e.alternate.pendingProps = e.pendingProps), n = On(e, 2), n !== null && We(n, e, 2);
|
|
12459
|
+
}, wb = function(e) {
|
|
12460
|
+
var n = On(e, 2);
|
|
12461
|
+
n !== null && We(n, e, 2);
|
|
12462
|
+
}, Pb = function(e) {
|
|
12463
|
+
var n = ut(), o = On(e, n);
|
|
12464
|
+
o !== null && We(o, e, n);
|
|
12465
|
+
}, xb = function(e) {
|
|
12466
|
+
pu = e;
|
|
12467
|
+
}, zb = function(e) {
|
|
12468
|
+
fu = e;
|
|
12469
|
+
}, le.attemptContinuousHydration = function(e) {
|
|
12470
|
+
if (e.tag === 13 || e.tag === 31) {
|
|
12471
|
+
var n = On(e, 67108864);
|
|
12472
|
+
n !== null && We(n, e, 67108864), rl(e, 67108864);
|
|
12473
|
+
}
|
|
12474
|
+
}, le.attemptHydrationAtCurrentPriority = function(e) {
|
|
12475
|
+
if (e.tag === 13 || e.tag === 31) {
|
|
12476
|
+
var n = Nt(e);
|
|
12477
|
+
n = Xo(n);
|
|
12478
|
+
var o = On(e, n);
|
|
12479
|
+
o !== null && We(o, e, n), rl(e, n);
|
|
12480
|
+
}
|
|
12481
|
+
}, le.attemptSynchronousHydration = function(e) {
|
|
12482
|
+
switch (e.tag) {
|
|
12483
|
+
case 3:
|
|
12484
|
+
if (e = e.stateNode, e.current.memoizedState.isDehydrated) {
|
|
12485
|
+
var n = _t(e.pendingLanes);
|
|
12486
|
+
if (n !== 0) {
|
|
12487
|
+
for (e.pendingLanes |= 2, e.entangledLanes |= 2; n; ) {
|
|
12488
|
+
var o = 1 << 31 - vn(n);
|
|
12489
|
+
e.entanglements[1] |= o, n &= ~o;
|
|
12490
|
+
}
|
|
12491
|
+
Kn(e), (ye & (Zn | uo)) === Jn && (Pp = me() + Fg, Wa(0));
|
|
12492
|
+
}
|
|
12493
|
+
}
|
|
12494
|
+
break;
|
|
12495
|
+
case 31:
|
|
12496
|
+
case 13:
|
|
12497
|
+
n = On(e, 2), n !== null && We(n, e, 2), Ls(), rl(e, 2);
|
|
12498
|
+
}
|
|
12499
|
+
}, le.batchedUpdates = function(e, n) {
|
|
12500
|
+
return e(n);
|
|
12501
|
+
}, le.createComponentSelector = function(e) {
|
|
12502
|
+
return { $$typeof: pm, value: e };
|
|
12503
|
+
}, le.createContainer = function(e, n, o, i, s, u, f, p, g, S) {
|
|
12504
|
+
return Ka(e, n, false, null, o, i, u, null, f, p, g, S);
|
|
12505
|
+
}, le.createHasPseudoClassSelector = function(e) {
|
|
12506
|
+
return { $$typeof: hm, value: e };
|
|
12507
|
+
}, le.createHydrationContainer = function(e, n, o, i, s, u, f, p, g, S, T, _, I, O) {
|
|
12508
|
+
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;
|
|
12509
|
+
}, le.createPortal = function(e, n, o) {
|
|
12510
|
+
var i = 3 < arguments.length && arguments[3] !== void 0 ? arguments[3] : null;
|
|
12511
|
+
try {
|
|
12512
|
+
vt(i);
|
|
12513
|
+
var s = false;
|
|
12514
|
+
} catch {
|
|
12515
|
+
s = true;
|
|
12516
|
+
}
|
|
12517
|
+
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 };
|
|
12518
|
+
}, le.createRoleSelector = function(e) {
|
|
12519
|
+
return { $$typeof: mm, value: e };
|
|
12520
|
+
}, le.createTestNameSelector = function(e) {
|
|
12521
|
+
return { $$typeof: gm, value: e };
|
|
12522
|
+
}, le.createTextSelector = function(e) {
|
|
12523
|
+
return { $$typeof: ym, value: e };
|
|
12524
|
+
}, le.defaultOnCaughtError = function(e) {
|
|
12525
|
+
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") + ".");
|
|
12526
|
+
typeof e == "object" && e !== null && typeof e.environmentName == "string" ? ri("error", [`%o
|
|
12527
|
+
|
|
12528
|
+
%s
|
|
12529
|
+
|
|
12530
|
+
%s
|
|
12531
|
+
`, e, n, o], e.environmentName)() : console.error(`%o
|
|
12532
|
+
|
|
12533
|
+
%s
|
|
12534
|
+
|
|
12535
|
+
%s
|
|
12536
|
+
`, e, n, o);
|
|
12537
|
+
}, le.defaultOnRecoverableError = function(e) {
|
|
12538
|
+
qg(e);
|
|
12539
|
+
}, le.defaultOnUncaughtError = function(e) {
|
|
12540
|
+
qg(e), console.warn(`%s
|
|
12541
|
+
|
|
12542
|
+
%s
|
|
12543
|
+
`, 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.
|
|
12544
|
+
Visit https://react.dev/link/error-boundaries to learn more about error boundaries.`);
|
|
12545
|
+
}, le.deferredUpdates = function(e) {
|
|
12546
|
+
var n = x.T, o = wt();
|
|
12547
|
+
try {
|
|
12548
|
+
return an(32), x.T = null, e();
|
|
13314
12549
|
} finally {
|
|
13315
|
-
x.
|
|
12550
|
+
an(o), x.T = n;
|
|
13316
12551
|
}
|
|
13317
|
-
},
|
|
13318
|
-
|
|
13319
|
-
}, useDeferredValue: function(e, n) {
|
|
13320
|
-
return z = "useDeferredValue", D(), N(), nc(e, n);
|
|
13321
|
-
}, useTransition: function() {
|
|
13322
|
-
return z = "useTransition", D(), N(), Qp();
|
|
13323
|
-
}, useSyncExternalStore: function(e, n, o) {
|
|
13324
|
-
return z = "useSyncExternalStore", D(), N(), ta(e, n, o);
|
|
13325
|
-
}, useId: function() {
|
|
13326
|
-
return z = "useId", D(), N(), xe().memoizedState;
|
|
13327
|
-
}, useFormState: function(e) {
|
|
13328
|
-
return z = "useFormState", D(), N(), hs(e);
|
|
13329
|
-
}, useActionState: function(e) {
|
|
13330
|
-
return z = "useActionState", D(), N(), hs(e);
|
|
13331
|
-
}, useOptimistic: function(e, n) {
|
|
13332
|
-
return z = "useOptimistic", D(), N(), rf(e, n);
|
|
13333
|
-
}, useMemoCache: function(e) {
|
|
13334
|
-
return D(), Oa(e);
|
|
13335
|
-
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
13336
|
-
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
13337
|
-
}, useEffectEvent: function(e) {
|
|
13338
|
-
return z = "useEffectEvent", D(), N(), oa(e);
|
|
13339
|
-
} }, dm = { readContext: function(e) {
|
|
13340
|
-
return Ce(), Ee(e);
|
|
13341
|
-
}, use: function(e) {
|
|
13342
|
-
return D(), we(e);
|
|
13343
|
-
}, useCallback: function(e, n) {
|
|
13344
|
-
return z = "useCallback", D(), N(), Ma(e, n);
|
|
13345
|
-
}, useContext: function(e) {
|
|
13346
|
-
return z = "useContext", D(), N(), Ee(e);
|
|
13347
|
-
}, useEffect: function(e, n) {
|
|
13348
|
-
z = "useEffect", D(), N(), Qn(2048, Ut, e, n);
|
|
13349
|
-
}, useImperativeHandle: function(e, n, o) {
|
|
13350
|
-
return z = "useImperativeHandle", D(), N(), aa(e, n, o);
|
|
13351
|
-
}, useInsertionEffect: function(e, n) {
|
|
13352
|
-
return z = "useInsertionEffect", D(), N(), Qn(4, Wt, e, n);
|
|
13353
|
-
}, useLayoutEffect: function(e, n) {
|
|
13354
|
-
return z = "useLayoutEffect", D(), N(), Qn(4, Rr, e, n);
|
|
13355
|
-
}, useMemo: function(e, n) {
|
|
13356
|
-
z = "useMemo", D(), N();
|
|
13357
|
-
var o = x.H;
|
|
13358
|
-
x.H = $o;
|
|
12552
|
+
}, le.discreteUpdates = function(e, n, o, i, s) {
|
|
12553
|
+
var u = x.T, f = wt();
|
|
13359
12554
|
try {
|
|
13360
|
-
return
|
|
12555
|
+
return an(2), x.T = null, e(n, o, i, s);
|
|
13361
12556
|
} finally {
|
|
13362
|
-
x.
|
|
12557
|
+
an(f), x.T = u, ye === Jn && (Pp = me() + Fg);
|
|
13363
12558
|
}
|
|
13364
|
-
},
|
|
13365
|
-
|
|
13366
|
-
|
|
13367
|
-
|
|
13368
|
-
|
|
13369
|
-
|
|
13370
|
-
|
|
13371
|
-
|
|
12559
|
+
}, le.findAllNodes = kc, le.findBoundingRects = function(e, n) {
|
|
12560
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12561
|
+
n = kc(e, n), e = [];
|
|
12562
|
+
for (var o = 0; o < n.length; o++) e.push(ma(n[o]));
|
|
12563
|
+
for (n = e.length - 1; 0 < n; n--) {
|
|
12564
|
+
o = e[n];
|
|
12565
|
+
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) {
|
|
12566
|
+
var g = e[p], S = g.x, T = S + g.width, _ = g.y, I = _ + g.height;
|
|
12567
|
+
if (i >= S && u >= _ && s <= T && f <= I) {
|
|
12568
|
+
e.splice(n, 1);
|
|
12569
|
+
break;
|
|
12570
|
+
} else if (i !== S || o.width !== g.width || I < u || _ > f) {
|
|
12571
|
+
if (!(u !== _ || o.height !== g.height || T < i || S > s)) {
|
|
12572
|
+
S > i && (g.width += S - i, g.x = i), T < s && (g.width = s - S), e.splice(n, 1);
|
|
12573
|
+
break;
|
|
12574
|
+
}
|
|
12575
|
+
} else {
|
|
12576
|
+
_ > u && (g.height += _ - u, g.y = u), I < f && (g.height = f - _), e.splice(n, 1);
|
|
12577
|
+
break;
|
|
12578
|
+
}
|
|
12579
|
+
}
|
|
13372
12580
|
}
|
|
13373
|
-
|
|
13374
|
-
|
|
13375
|
-
|
|
13376
|
-
|
|
13377
|
-
|
|
13378
|
-
|
|
12581
|
+
return e;
|
|
12582
|
+
}, le.findHostInstance = function(e) {
|
|
12583
|
+
var n = e._reactInternals;
|
|
12584
|
+
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));
|
|
12585
|
+
return e = mu(n), e === null ? null : ot(e.stateNode);
|
|
12586
|
+
}, le.findHostInstanceWithNoPortals = function(e) {
|
|
12587
|
+
return e = Ed(e), e = e !== null ? _p(e) : null, e === null ? null : ot(e.stateNode);
|
|
12588
|
+
}, le.findHostInstanceWithWarning = function(e, n) {
|
|
12589
|
+
var o = e._reactInternals;
|
|
12590
|
+
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));
|
|
12591
|
+
if (e = mu(o), e === null) return null;
|
|
12592
|
+
if (e.mode & 8) {
|
|
12593
|
+
var i = G(o) || "Component";
|
|
12594
|
+
mb[i] || (mb[i] = true, B(e, function() {
|
|
12595
|
+
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);
|
|
12596
|
+
}));
|
|
12597
|
+
}
|
|
12598
|
+
return ot(e.stateNode);
|
|
12599
|
+
}, le.flushPassiveEffects = el, le.flushSyncFromReconciler = function(e) {
|
|
12600
|
+
var n = ye;
|
|
12601
|
+
ye |= 1;
|
|
12602
|
+
var o = x.T, i = wt();
|
|
13379
12603
|
try {
|
|
13380
|
-
return
|
|
12604
|
+
if (an(2), x.T = null, e) return e();
|
|
13381
12605
|
} finally {
|
|
13382
|
-
x.
|
|
12606
|
+
an(i), x.T = o, ye = n, (ye & (Zn | uo)) === Jn && Wa(0);
|
|
13383
12607
|
}
|
|
13384
|
-
},
|
|
13385
|
-
|
|
13386
|
-
|
|
13387
|
-
|
|
13388
|
-
|
|
13389
|
-
|
|
13390
|
-
|
|
13391
|
-
|
|
13392
|
-
|
|
13393
|
-
return
|
|
13394
|
-
},
|
|
13395
|
-
|
|
13396
|
-
|
|
13397
|
-
|
|
13398
|
-
|
|
13399
|
-
|
|
13400
|
-
|
|
13401
|
-
|
|
13402
|
-
|
|
13403
|
-
|
|
13404
|
-
|
|
13405
|
-
|
|
13406
|
-
|
|
13407
|
-
|
|
13408
|
-
|
|
13409
|
-
|
|
13410
|
-
|
|
13411
|
-
|
|
13412
|
-
|
|
13413
|
-
|
|
13414
|
-
|
|
13415
|
-
|
|
13416
|
-
|
|
13417
|
-
|
|
13418
|
-
|
|
13419
|
-
|
|
13420
|
-
|
|
13421
|
-
|
|
13422
|
-
|
|
13423
|
-
|
|
13424
|
-
|
|
13425
|
-
|
|
13426
|
-
|
|
13427
|
-
|
|
13428
|
-
|
|
13429
|
-
|
|
13430
|
-
|
|
13431
|
-
|
|
13432
|
-
|
|
13433
|
-
|
|
12608
|
+
}, le.flushSyncWork = Ls, le.focusWithin = function(e, n) {
|
|
12609
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12610
|
+
for (e = Ef(e), n = hh(e, n), n = Array.from(n), e = 0; e < n.length; ) {
|
|
12611
|
+
var o = n[e++], i = o.tag;
|
|
12612
|
+
if (!Kr(o)) {
|
|
12613
|
+
if ((i === 5 || i === 26 || i === 27) && Ft(o.stateNode)) return true;
|
|
12614
|
+
for (o = o.child; o !== null; ) n.push(o), o = o.sibling;
|
|
12615
|
+
}
|
|
12616
|
+
}
|
|
12617
|
+
return false;
|
|
12618
|
+
}, le.getFindAllNodesFailureDescription = function(e, n) {
|
|
12619
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12620
|
+
var o = 0, i = [];
|
|
12621
|
+
e = [Ef(e), 0];
|
|
12622
|
+
for (var s = 0; s < e.length; ) {
|
|
12623
|
+
var u = e[s++], f = u.tag, p = e[s++], g = n[p];
|
|
12624
|
+
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;
|
|
12625
|
+
}
|
|
12626
|
+
if (o < n.length) {
|
|
12627
|
+
for (e = []; o < n.length; o++) e.push(Sc(n[o]));
|
|
12628
|
+
return `findAllNodes was able to match part of the selector:
|
|
12629
|
+
` + (i.join(" > ") + `
|
|
12630
|
+
|
|
12631
|
+
No matching component was found for:
|
|
12632
|
+
`) + e.join(" > ");
|
|
12633
|
+
}
|
|
12634
|
+
return null;
|
|
12635
|
+
}, le.getPublicRootInstance = function(e) {
|
|
12636
|
+
if (e = e.current, !e.child) return null;
|
|
12637
|
+
switch (e.child.tag) {
|
|
12638
|
+
case 27:
|
|
12639
|
+
case 5:
|
|
12640
|
+
return ot(e.child.stateNode);
|
|
12641
|
+
default:
|
|
12642
|
+
return e.child.stateNode;
|
|
12643
|
+
}
|
|
12644
|
+
}, le.injectIntoDevTools = function() {
|
|
12645
|
+
var e = { bundleType: 1, version: Jt, rendererPackageName: Zt, currentDispatcherRef: x, reconcilerVersion: "19.2.0" };
|
|
12646
|
+
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);
|
|
12647
|
+
}, le.isAlreadyRendering = Ns, le.observeVisibleRects = function(e, n, o, i) {
|
|
12648
|
+
function s() {
|
|
12649
|
+
var S = kc(e, n);
|
|
12650
|
+
u.forEach(function(T) {
|
|
12651
|
+
0 > S.indexOf(T) && g(T);
|
|
12652
|
+
}), S.forEach(function(T) {
|
|
12653
|
+
0 > u.indexOf(T) && p(T);
|
|
12654
|
+
});
|
|
12655
|
+
}
|
|
12656
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12657
|
+
var u = kc(e, n);
|
|
12658
|
+
o = zr(u, o, i);
|
|
12659
|
+
var f = o.disconnect, p = o.observe, g = o.unobserve;
|
|
12660
|
+
return bm.push(s), { disconnect: function() {
|
|
12661
|
+
var S = bm.indexOf(s);
|
|
12662
|
+
0 <= S && bm.splice(S, 1), f();
|
|
12663
|
+
} };
|
|
12664
|
+
}, le.shouldError = function(e) {
|
|
12665
|
+
return pu(e);
|
|
12666
|
+
}, le.shouldSuspend = function(e) {
|
|
12667
|
+
return fu(e);
|
|
12668
|
+
}, le.startHostTransition = function(e, n, o, i) {
|
|
12669
|
+
if (e.tag !== 5) throw Error("Expected the form instance to be a HostComponent. This is a bug in React.");
|
|
12670
|
+
var s = uf(e).queue;
|
|
12671
|
+
Hp(e), nt(e, s, n, Xt, o === null ? Em : function() {
|
|
12672
|
+
x.T === null && console.error("requestFormReset was called outside a transition or action. To fix, move to an action, or wrap with startTransition.");
|
|
12673
|
+
var u = uf(e);
|
|
12674
|
+
return u.next === null && (u = e.alternate.memoizedState), qi(e, u.next.queue, {}, Nt(e)), o(i);
|
|
12675
|
+
});
|
|
12676
|
+
}, le.updateContainer = function(e, n, o, i) {
|
|
12677
|
+
var s = n.current, u = Nt(s);
|
|
12678
|
+
return As(s, u, e, n, o, i), u;
|
|
12679
|
+
}, le.updateContainerSync = Wh, le;
|
|
12680
|
+
}, Tt.exports.default = Tt.exports, Object.defineProperty(Tt.exports, "__esModule", { value: true }));
|
|
12681
|
+
})(Mg)), Mg.exports;
|
|
12682
|
+
}
|
|
12683
|
+
var Eb;
|
|
12684
|
+
function n0() {
|
|
12685
|
+
return Eb || (Eb = 1, process.env.NODE_ENV === "production" ? Rm.exports = Kb() : Rm.exports = e0()), Rm.exports;
|
|
12686
|
+
}
|
|
12687
|
+
var t0 = n0();
|
|
12688
|
+
const r0 = Xb(t0);
|
|
12689
|
+
|
|
12690
|
+
const DEFAULT_POINTER_ID = 0;
|
|
12691
|
+
const XR_POINTER_ID_START = 1e3;
|
|
12692
|
+
function getPointerState(internal, pointerId) {
|
|
12693
|
+
let state = internal.pointerMap.get(pointerId);
|
|
12694
|
+
if (!state) {
|
|
12695
|
+
state = {
|
|
12696
|
+
hovered: /* @__PURE__ */ new Map(),
|
|
12697
|
+
captured: /* @__PURE__ */ new Map(),
|
|
12698
|
+
initialClick: [0, 0],
|
|
12699
|
+
initialHits: []
|
|
12700
|
+
};
|
|
12701
|
+
internal.pointerMap.set(pointerId, state);
|
|
12702
|
+
}
|
|
12703
|
+
return state;
|
|
12704
|
+
}
|
|
12705
|
+
function getPointerId(event) {
|
|
12706
|
+
return "pointerId" in event ? event.pointerId : DEFAULT_POINTER_ID;
|
|
12707
|
+
}
|
|
12708
|
+
function makeId(event) {
|
|
12709
|
+
return (event.eventObject || event.object).uuid + "/" + event.index + event.instanceId;
|
|
12710
|
+
}
|
|
12711
|
+
function releaseInternalPointerCapture(internal, obj, pointerId) {
|
|
12712
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
12713
|
+
if (!pointerState) return;
|
|
12714
|
+
const captureData = pointerState.captured.get(obj);
|
|
12715
|
+
if (captureData) {
|
|
12716
|
+
pointerState.captured.delete(obj);
|
|
12717
|
+
try {
|
|
12718
|
+
captureData.target.releasePointerCapture?.(pointerId);
|
|
12719
|
+
} catch {
|
|
12720
|
+
}
|
|
12721
|
+
}
|
|
12722
|
+
}
|
|
12723
|
+
function swapInteractivity(store, object, newObject) {
|
|
12724
|
+
const { internal } = store.getState();
|
|
12725
|
+
for (let i = 0; i < internal.interaction.length; i++) {
|
|
12726
|
+
if (internal.interaction[i] === object) internal.interaction[i] = newObject;
|
|
12727
|
+
}
|
|
12728
|
+
for (const pointerState of internal.pointerMap.values()) {
|
|
12729
|
+
for (let i = 0; i < pointerState.initialHits.length; i++) {
|
|
12730
|
+
if (pointerState.initialHits[i] === object) pointerState.initialHits[i] = newObject;
|
|
12731
|
+
}
|
|
12732
|
+
pointerState.hovered.forEach((value, key) => {
|
|
12733
|
+
if (value.eventObject === object || value.object === object) {
|
|
12734
|
+
pointerState.hovered.delete(key);
|
|
12735
|
+
const next = {
|
|
12736
|
+
...value,
|
|
12737
|
+
eventObject: value.eventObject === object ? newObject : value.eventObject,
|
|
12738
|
+
object: value.object === object ? newObject : value.object
|
|
12739
|
+
};
|
|
12740
|
+
pointerState.hovered.set(makeId(next), next);
|
|
13434
12741
|
}
|
|
13435
|
-
|
|
13436
|
-
|
|
13437
|
-
|
|
13438
|
-
|
|
13439
|
-
|
|
12742
|
+
});
|
|
12743
|
+
const captureData = pointerState.captured.get(object);
|
|
12744
|
+
if (captureData) {
|
|
12745
|
+
pointerState.captured.delete(object);
|
|
12746
|
+
pointerState.captured.set(newObject, {
|
|
12747
|
+
...captureData,
|
|
12748
|
+
intersection: {
|
|
12749
|
+
...captureData.intersection,
|
|
12750
|
+
object: captureData.intersection.object === object ? newObject : captureData.intersection.object,
|
|
12751
|
+
eventObject: captureData.intersection.eventObject === object ? newObject : captureData.intersection.eventObject
|
|
12752
|
+
}
|
|
12753
|
+
});
|
|
12754
|
+
}
|
|
12755
|
+
}
|
|
12756
|
+
unregisterVisibility(store, object);
|
|
12757
|
+
}
|
|
12758
|
+
function removeInteractivity(store, object) {
|
|
12759
|
+
const { internal } = store.getState();
|
|
12760
|
+
internal.interaction = internal.interaction.filter((o) => o !== object);
|
|
12761
|
+
for (const [pointerId, pointerState] of internal.pointerMap) {
|
|
12762
|
+
pointerState.initialHits = pointerState.initialHits.filter((o) => o !== object);
|
|
12763
|
+
pointerState.hovered.forEach((value, key) => {
|
|
12764
|
+
if (value.eventObject === object || value.object === object) {
|
|
12765
|
+
pointerState.hovered.delete(key);
|
|
13440
12766
|
}
|
|
13441
|
-
|
|
13442
|
-
|
|
13443
|
-
|
|
13444
|
-
|
|
13445
|
-
|
|
13446
|
-
|
|
13447
|
-
|
|
13448
|
-
|
|
13449
|
-
|
|
13450
|
-
|
|
13451
|
-
|
|
13452
|
-
|
|
13453
|
-
|
|
13454
|
-
|
|
13455
|
-
|
|
13456
|
-
|
|
13457
|
-
|
|
13458
|
-
|
|
13459
|
-
|
|
13460
|
-
|
|
13461
|
-
|
|
13462
|
-
|
|
13463
|
-
|
|
13464
|
-
|
|
13465
|
-
|
|
13466
|
-
|
|
13467
|
-
|
|
12767
|
+
});
|
|
12768
|
+
if (pointerState.captured.has(object)) {
|
|
12769
|
+
releaseInternalPointerCapture(internal, object, pointerId);
|
|
12770
|
+
}
|
|
12771
|
+
}
|
|
12772
|
+
unregisterVisibility(store, object);
|
|
12773
|
+
}
|
|
12774
|
+
function createEvents(store) {
|
|
12775
|
+
function calculateDistance(event, pointerId) {
|
|
12776
|
+
const { internal } = store.getState();
|
|
12777
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
12778
|
+
if (!pointerState) return 0;
|
|
12779
|
+
const [initialX, initialY] = pointerState.initialClick;
|
|
12780
|
+
const dx = event.offsetX - initialX;
|
|
12781
|
+
const dy = event.offsetY - initialY;
|
|
12782
|
+
return Math.round(Math.sqrt(dx * dx + dy * dy));
|
|
12783
|
+
}
|
|
12784
|
+
function filterPointerEvents(objects) {
|
|
12785
|
+
return objects.filter(
|
|
12786
|
+
(obj) => ["Move", "Over", "Enter", "Out", "Leave"].some(
|
|
12787
|
+
(name) => obj.__r3f?.handlers["onPointer" + name]
|
|
12788
|
+
) || ["OverEnter", "OverLeave", "Over"].some(
|
|
12789
|
+
(name) => obj.__r3f?.handlers["onDrag" + name]
|
|
12790
|
+
) || obj.__r3f?.handlers.onDrop
|
|
12791
|
+
);
|
|
12792
|
+
}
|
|
12793
|
+
function intersect(event, filter) {
|
|
12794
|
+
const state = store.getState();
|
|
12795
|
+
const duplicates = /* @__PURE__ */ new Set();
|
|
12796
|
+
const intersections = [];
|
|
12797
|
+
const eventsObjects = filter ? filter(state.internal.interaction) : state.internal.interaction;
|
|
12798
|
+
for (let i = 0; i < eventsObjects.length; i++) {
|
|
12799
|
+
const state2 = getRootState(eventsObjects[i]);
|
|
12800
|
+
if (state2) {
|
|
12801
|
+
state2.raycaster.camera = void 0;
|
|
12802
|
+
}
|
|
12803
|
+
}
|
|
12804
|
+
if (!state.previousRoot) {
|
|
12805
|
+
state.events.compute?.(event, state);
|
|
12806
|
+
}
|
|
12807
|
+
function handleRaycast(obj) {
|
|
12808
|
+
const state2 = getRootState(obj);
|
|
12809
|
+
if (!state2 || !state2.events.enabled || state2.raycaster.camera === null) return [];
|
|
12810
|
+
if (state2.raycaster.camera === void 0) {
|
|
12811
|
+
state2.events.compute?.(event, state2, state2.previousRoot?.getState());
|
|
12812
|
+
if (state2.raycaster.camera === void 0) state2.raycaster.camera = null;
|
|
12813
|
+
}
|
|
12814
|
+
if (!state2.raycaster.camera) return [];
|
|
12815
|
+
obj.updateWorldMatrix(true, true);
|
|
12816
|
+
return state2.raycaster.intersectObject(obj, true);
|
|
12817
|
+
}
|
|
12818
|
+
let hits = eventsObjects.flatMap(handleRaycast).sort((a, b) => {
|
|
12819
|
+
const aInteractivePriority = a.object.userData?.interactivePriority;
|
|
12820
|
+
const bInteractivePriority = b.object.userData?.interactivePriority;
|
|
12821
|
+
if (aInteractivePriority !== void 0 || bInteractivePriority !== void 0) {
|
|
12822
|
+
if (aInteractivePriority !== void 0 && bInteractivePriority === void 0) return -1;
|
|
12823
|
+
if (bInteractivePriority !== void 0 && aInteractivePriority === void 0) return 1;
|
|
12824
|
+
if (aInteractivePriority !== bInteractivePriority) {
|
|
12825
|
+
return (bInteractivePriority ?? 0) - (aInteractivePriority ?? 0);
|
|
13468
12826
|
}
|
|
13469
|
-
}
|
|
13470
|
-
|
|
13471
|
-
|
|
13472
|
-
|
|
13473
|
-
|
|
13474
|
-
|
|
12827
|
+
}
|
|
12828
|
+
const aState = getRootState(a.object);
|
|
12829
|
+
const bState = getRootState(b.object);
|
|
12830
|
+
const aPriority = aState?.events?.priority ?? 1;
|
|
12831
|
+
const bPriority = bState?.events?.priority ?? 1;
|
|
12832
|
+
return bPriority - aPriority || a.distance - b.distance;
|
|
12833
|
+
}).filter((item) => {
|
|
12834
|
+
const id = makeId(item);
|
|
12835
|
+
if (duplicates.has(id)) return false;
|
|
12836
|
+
duplicates.add(id);
|
|
12837
|
+
return true;
|
|
12838
|
+
});
|
|
12839
|
+
if (state.events.filter) hits = state.events.filter(hits, state);
|
|
12840
|
+
for (const hit of hits) {
|
|
12841
|
+
let eventObject = hit.object;
|
|
12842
|
+
while (eventObject) {
|
|
12843
|
+
if (eventObject.__r3f?.eventCount) {
|
|
12844
|
+
intersections.push({ ...hit, eventObject });
|
|
13475
12845
|
}
|
|
13476
|
-
|
|
13477
|
-
|
|
13478
|
-
|
|
13479
|
-
|
|
13480
|
-
|
|
13481
|
-
|
|
13482
|
-
|
|
13483
|
-
|
|
13484
|
-
|
|
12846
|
+
eventObject = eventObject.parent;
|
|
12847
|
+
}
|
|
12848
|
+
}
|
|
12849
|
+
if ("pointerId" in event) {
|
|
12850
|
+
const pointerId = event.pointerId;
|
|
12851
|
+
const pointerState = state.internal.pointerMap.get(pointerId);
|
|
12852
|
+
if (pointerState?.captured.size) {
|
|
12853
|
+
for (const captureData of pointerState.captured.values()) {
|
|
12854
|
+
if (!duplicates.has(makeId(captureData.intersection))) intersections.push(captureData.intersection);
|
|
12855
|
+
}
|
|
12856
|
+
}
|
|
12857
|
+
}
|
|
12858
|
+
return intersections;
|
|
12859
|
+
}
|
|
12860
|
+
function handleIntersects(intersections, event, delta, callback) {
|
|
12861
|
+
if (intersections.length) {
|
|
12862
|
+
const localState = { stopped: false };
|
|
12863
|
+
for (const hit of intersections) {
|
|
12864
|
+
const state = getRootState(hit.object);
|
|
12865
|
+
if (state) {
|
|
12866
|
+
const { raycaster, pointer, camera, internal } = state;
|
|
12867
|
+
const unprojectedPoint = new Vector3(pointer.x, pointer.y, 0).unproject(camera);
|
|
12868
|
+
const hasPointerCapture = (id) => {
|
|
12869
|
+
const pointerState = internal.pointerMap.get(id);
|
|
12870
|
+
return pointerState?.captured.has(hit.eventObject) ?? false;
|
|
12871
|
+
};
|
|
12872
|
+
const setPointerCapture = (id) => {
|
|
12873
|
+
const captureData = { intersection: hit, target: event.target };
|
|
12874
|
+
const pointerState = getPointerState(internal, id);
|
|
12875
|
+
pointerState.captured.set(hit.eventObject, captureData);
|
|
12876
|
+
event.target.setPointerCapture(id);
|
|
12877
|
+
};
|
|
12878
|
+
const releasePointerCapture = (id) => {
|
|
12879
|
+
releaseInternalPointerCapture(internal, hit.eventObject, id);
|
|
12880
|
+
};
|
|
12881
|
+
const extractEventProps = {};
|
|
12882
|
+
for (const prop in event) {
|
|
12883
|
+
const property = event[prop];
|
|
12884
|
+
if (typeof property !== "function") extractEventProps[prop] = property;
|
|
12885
|
+
}
|
|
12886
|
+
const eventPointerId = "pointerId" in event ? event.pointerId : void 0;
|
|
12887
|
+
const raycastEvent = {
|
|
12888
|
+
...hit,
|
|
12889
|
+
...extractEventProps,
|
|
12890
|
+
pointer,
|
|
12891
|
+
intersections,
|
|
12892
|
+
stopped: localState.stopped,
|
|
12893
|
+
delta,
|
|
12894
|
+
unprojectedPoint,
|
|
12895
|
+
ray: raycaster.ray,
|
|
12896
|
+
camera,
|
|
12897
|
+
pointerId: eventPointerId,
|
|
12898
|
+
// Hijack stopPropagation, which just sets a flag
|
|
12899
|
+
stopPropagation() {
|
|
12900
|
+
const pointerState = eventPointerId !== void 0 ? internal.pointerMap.get(eventPointerId) : void 0;
|
|
12901
|
+
if (
|
|
12902
|
+
// ...if this pointer hasn't been captured
|
|
12903
|
+
!pointerState?.captured.size || // ... or if the hit object is capturing the pointer
|
|
12904
|
+
pointerState.captured.has(hit.eventObject)
|
|
12905
|
+
) {
|
|
12906
|
+
raycastEvent.stopped = localState.stopped = true;
|
|
12907
|
+
if (pointerState?.hovered.size && Array.from(pointerState.hovered.values()).find((i) => i.eventObject === hit.eventObject)) {
|
|
12908
|
+
const higher = intersections.slice(0, intersections.indexOf(hit));
|
|
12909
|
+
cancelPointer([...higher, hit], eventPointerId);
|
|
13485
12910
|
}
|
|
13486
|
-
Kn(e), (ye & (Zn | uo)) === Jn && (Pp = me() + Fg, Wa(0));
|
|
13487
12911
|
}
|
|
13488
|
-
}
|
|
13489
|
-
|
|
13490
|
-
|
|
13491
|
-
|
|
13492
|
-
|
|
13493
|
-
|
|
13494
|
-
|
|
13495
|
-
|
|
13496
|
-
}, le.createComponentSelector = function(e) {
|
|
13497
|
-
return { $$typeof: pm, value: e };
|
|
13498
|
-
}, le.createContainer = function(e, n, o, i, s, u, f, p, g, S) {
|
|
13499
|
-
return Ka(e, n, false, null, o, i, u, null, f, p, g, S);
|
|
13500
|
-
}, le.createHasPseudoClassSelector = function(e) {
|
|
13501
|
-
return { $$typeof: hm, value: e };
|
|
13502
|
-
}, le.createHydrationContainer = function(e, n, o, i, s, u, f, p, g, S, T, _, I, O) {
|
|
13503
|
-
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;
|
|
13504
|
-
}, le.createPortal = function(e, n, o) {
|
|
13505
|
-
var i = 3 < arguments.length && arguments[3] !== void 0 ? arguments[3] : null;
|
|
13506
|
-
try {
|
|
13507
|
-
vt(i);
|
|
13508
|
-
var s = false;
|
|
13509
|
-
} catch {
|
|
13510
|
-
s = true;
|
|
12912
|
+
},
|
|
12913
|
+
// there should be a distinction between target and currentTarget
|
|
12914
|
+
target: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
12915
|
+
currentTarget: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
12916
|
+
nativeEvent: event
|
|
12917
|
+
};
|
|
12918
|
+
callback(raycastEvent);
|
|
12919
|
+
if (localState.stopped === true) break;
|
|
13511
12920
|
}
|
|
13512
|
-
|
|
13513
|
-
|
|
13514
|
-
|
|
13515
|
-
|
|
13516
|
-
|
|
13517
|
-
|
|
13518
|
-
|
|
13519
|
-
|
|
13520
|
-
|
|
13521
|
-
|
|
13522
|
-
|
|
13523
|
-
|
|
13524
|
-
|
|
13525
|
-
|
|
13526
|
-
|
|
13527
|
-
|
|
13528
|
-
|
|
13529
|
-
|
|
13530
|
-
|
|
13531
|
-
|
|
13532
|
-
|
|
13533
|
-
|
|
13534
|
-
}, le.defaultOnUncaughtError = function(e) {
|
|
13535
|
-
qg(e), console.warn(`%s
|
|
13536
|
-
|
|
13537
|
-
%s
|
|
13538
|
-
`, 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.
|
|
13539
|
-
Visit https://react.dev/link/error-boundaries to learn more about error boundaries.`);
|
|
13540
|
-
}, le.deferredUpdates = function(e) {
|
|
13541
|
-
var n = x.T, o = wt();
|
|
13542
|
-
try {
|
|
13543
|
-
return an(32), x.T = null, e();
|
|
13544
|
-
} finally {
|
|
13545
|
-
an(o), x.T = n;
|
|
12921
|
+
}
|
|
12922
|
+
}
|
|
12923
|
+
return intersections;
|
|
12924
|
+
}
|
|
12925
|
+
function cancelPointer(intersections, pointerId) {
|
|
12926
|
+
const { internal } = store.getState();
|
|
12927
|
+
const pid = pointerId ?? DEFAULT_POINTER_ID;
|
|
12928
|
+
const pointerState = internal.pointerMap.get(pid);
|
|
12929
|
+
if (!pointerState) return;
|
|
12930
|
+
for (const [hoveredId, hoveredObj] of pointerState.hovered) {
|
|
12931
|
+
if (!intersections.length || !intersections.find(
|
|
12932
|
+
(hit) => hit.object === hoveredObj.object && hit.index === hoveredObj.index && hit.instanceId === hoveredObj.instanceId
|
|
12933
|
+
)) {
|
|
12934
|
+
const eventObject = hoveredObj.eventObject;
|
|
12935
|
+
const instance = eventObject.__r3f;
|
|
12936
|
+
pointerState.hovered.delete(hoveredId);
|
|
12937
|
+
if (instance?.eventCount) {
|
|
12938
|
+
const handlers = instance.handlers;
|
|
12939
|
+
const data = { ...hoveredObj, intersections };
|
|
12940
|
+
handlers.onPointerOut?.(data);
|
|
12941
|
+
handlers.onPointerLeave?.(data);
|
|
12942
|
+
handlers.onDragOverLeave?.(data);
|
|
13546
12943
|
}
|
|
13547
|
-
}
|
|
13548
|
-
|
|
13549
|
-
|
|
13550
|
-
|
|
13551
|
-
|
|
13552
|
-
|
|
12944
|
+
}
|
|
12945
|
+
}
|
|
12946
|
+
}
|
|
12947
|
+
function pointerMissed(event, objects) {
|
|
12948
|
+
for (let i = 0; i < objects.length; i++) {
|
|
12949
|
+
const instance = objects[i].__r3f;
|
|
12950
|
+
instance?.handlers.onPointerMissed?.(event);
|
|
12951
|
+
}
|
|
12952
|
+
}
|
|
12953
|
+
function dragOverMissed(event, objects) {
|
|
12954
|
+
for (let i = 0; i < objects.length; i++) {
|
|
12955
|
+
const instance = objects[i].__r3f;
|
|
12956
|
+
instance?.handlers.onDragOverMissed?.(event);
|
|
12957
|
+
}
|
|
12958
|
+
}
|
|
12959
|
+
function dropMissed(event, objects) {
|
|
12960
|
+
for (let i = 0; i < objects.length; i++) {
|
|
12961
|
+
const instance = objects[i].__r3f;
|
|
12962
|
+
instance?.handlers.onDropMissed?.(event);
|
|
12963
|
+
}
|
|
12964
|
+
}
|
|
12965
|
+
function cleanupPointer(pointerId) {
|
|
12966
|
+
const { internal } = store.getState();
|
|
12967
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
12968
|
+
if (pointerState) {
|
|
12969
|
+
for (const [, hoveredObj] of pointerState.hovered) {
|
|
12970
|
+
const eventObject = hoveredObj.eventObject;
|
|
12971
|
+
const instance = eventObject.__r3f;
|
|
12972
|
+
if (instance?.eventCount) {
|
|
12973
|
+
const handlers = instance.handlers;
|
|
12974
|
+
const data = { ...hoveredObj, intersections: [] };
|
|
12975
|
+
handlers.onPointerOut?.(data);
|
|
12976
|
+
handlers.onPointerLeave?.(data);
|
|
13553
12977
|
}
|
|
13554
|
-
}
|
|
13555
|
-
|
|
13556
|
-
|
|
13557
|
-
|
|
13558
|
-
|
|
13559
|
-
|
|
13560
|
-
|
|
13561
|
-
|
|
13562
|
-
|
|
13563
|
-
|
|
13564
|
-
|
|
13565
|
-
|
|
13566
|
-
|
|
13567
|
-
|
|
13568
|
-
|
|
12978
|
+
}
|
|
12979
|
+
internal.pointerMap.delete(pointerId);
|
|
12980
|
+
}
|
|
12981
|
+
internal.pointerDirty.delete(pointerId);
|
|
12982
|
+
}
|
|
12983
|
+
function processDeferredPointer(event, pointerId) {
|
|
12984
|
+
const state = store.getState();
|
|
12985
|
+
const { internal } = state;
|
|
12986
|
+
if (!state.events.enabled) return;
|
|
12987
|
+
const filter = filterPointerEvents;
|
|
12988
|
+
const hits = intersect(event, filter);
|
|
12989
|
+
cancelPointer(hits, pointerId);
|
|
12990
|
+
function onIntersect(data) {
|
|
12991
|
+
const eventObject = data.eventObject;
|
|
12992
|
+
const instance = eventObject.__r3f;
|
|
12993
|
+
if (!instance?.eventCount) return;
|
|
12994
|
+
const handlers = instance.handlers;
|
|
12995
|
+
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
12996
|
+
const id = makeId(data);
|
|
12997
|
+
const pointerState = getPointerState(internal, pointerId);
|
|
12998
|
+
const hoveredItem = pointerState.hovered.get(id);
|
|
12999
|
+
if (!hoveredItem) {
|
|
13000
|
+
pointerState.hovered.set(id, data);
|
|
13001
|
+
handlers.onPointerOver?.(data);
|
|
13002
|
+
handlers.onPointerEnter?.(data);
|
|
13003
|
+
} else if (hoveredItem.stopped) {
|
|
13004
|
+
data.stopPropagation();
|
|
13005
|
+
}
|
|
13006
|
+
}
|
|
13007
|
+
handlers.onPointerMove?.(data);
|
|
13008
|
+
}
|
|
13009
|
+
handleIntersects(hits, event, 0, onIntersect);
|
|
13010
|
+
}
|
|
13011
|
+
function handlePointer(name) {
|
|
13012
|
+
switch (name) {
|
|
13013
|
+
case "onPointerLeave":
|
|
13014
|
+
case "onDragLeave":
|
|
13015
|
+
return () => cancelPointer([]);
|
|
13016
|
+
// Global cancel of these events
|
|
13017
|
+
case "onPointerCancel":
|
|
13018
|
+
return (event) => {
|
|
13019
|
+
const pointerId = getPointerId(event);
|
|
13020
|
+
cleanupPointer(pointerId);
|
|
13021
|
+
};
|
|
13022
|
+
case "onLostPointerCapture":
|
|
13023
|
+
return (event) => {
|
|
13024
|
+
const { internal } = store.getState();
|
|
13025
|
+
const pointerId = getPointerId(event);
|
|
13026
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13027
|
+
if (pointerState?.captured.size) {
|
|
13028
|
+
requestAnimationFrame(() => {
|
|
13029
|
+
const pointerState2 = internal.pointerMap.get(pointerId);
|
|
13030
|
+
if (pointerState2?.captured.size) {
|
|
13031
|
+
pointerState2.captured.clear();
|
|
13569
13032
|
}
|
|
13570
|
-
|
|
13571
|
-
|
|
13572
|
-
|
|
13033
|
+
cancelPointer([], pointerId);
|
|
13034
|
+
});
|
|
13035
|
+
}
|
|
13036
|
+
};
|
|
13037
|
+
}
|
|
13038
|
+
return function handleEvent(event) {
|
|
13039
|
+
const state = store.getState();
|
|
13040
|
+
const { onPointerMissed, onDragOverMissed, onDropMissed, internal, events } = state;
|
|
13041
|
+
const pointerId = getPointerId(event);
|
|
13042
|
+
internal.lastEvent.current = event;
|
|
13043
|
+
if (!events.enabled) return;
|
|
13044
|
+
const isPointerMove = name === "onPointerMove";
|
|
13045
|
+
const isDragOver = name === "onDragOver";
|
|
13046
|
+
const isDrop = name === "onDrop";
|
|
13047
|
+
const isClickEvent = name === "onClick" || name === "onContextMenu" || name === "onDoubleClick";
|
|
13048
|
+
const isPointerDown = name === "onPointerDown";
|
|
13049
|
+
const isPointerUp = name === "onPointerUp";
|
|
13050
|
+
const isWheel = name === "onWheel";
|
|
13051
|
+
const canDeferRaycasts = events.frameTimedRaycasts && state.frameloop === "always";
|
|
13052
|
+
if (isPointerMove && canDeferRaycasts) {
|
|
13053
|
+
events.compute?.(event, state);
|
|
13054
|
+
internal.pointerDirty.set(pointerId, event);
|
|
13055
|
+
return;
|
|
13056
|
+
}
|
|
13057
|
+
if (isWheel && canDeferRaycasts && !events.alwaysFireOnScroll) {
|
|
13058
|
+
events.compute?.(event, state);
|
|
13059
|
+
internal.pointerDirty.set(pointerId, event);
|
|
13060
|
+
return;
|
|
13061
|
+
}
|
|
13062
|
+
if ((isClickEvent || isPointerDown || isPointerUp) && internal.pointerDirty.has(pointerId)) {
|
|
13063
|
+
const deferredEvent = internal.pointerDirty.get(pointerId);
|
|
13064
|
+
internal.pointerDirty.delete(pointerId);
|
|
13065
|
+
processDeferredPointer(deferredEvent, pointerId);
|
|
13066
|
+
}
|
|
13067
|
+
const filter = isPointerMove || isDragOver || isDrop ? filterPointerEvents : void 0;
|
|
13068
|
+
const hits = intersect(event, filter);
|
|
13069
|
+
const delta = isClickEvent ? calculateDistance(event, pointerId) : 0;
|
|
13070
|
+
if (isPointerDown) {
|
|
13071
|
+
const pointerState2 = getPointerState(internal, pointerId);
|
|
13072
|
+
pointerState2.initialClick = [event.offsetX, event.offsetY];
|
|
13073
|
+
pointerState2.initialHits = hits.map((hit) => hit.eventObject);
|
|
13074
|
+
}
|
|
13075
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13076
|
+
const initialHits = pointerState?.initialHits ?? [];
|
|
13077
|
+
if (isClickEvent && !hits.length) {
|
|
13078
|
+
if (delta <= 2) {
|
|
13079
|
+
pointerMissed(event, internal.interaction);
|
|
13080
|
+
if (onPointerMissed) onPointerMissed(event);
|
|
13081
|
+
}
|
|
13082
|
+
}
|
|
13083
|
+
if (isDragOver && !hits.length) {
|
|
13084
|
+
dragOverMissed(event, internal.interaction);
|
|
13085
|
+
if (onDragOverMissed) onDragOverMissed(event);
|
|
13086
|
+
}
|
|
13087
|
+
if (isDrop && !hits.length) {
|
|
13088
|
+
dropMissed(event, internal.interaction);
|
|
13089
|
+
if (onDropMissed) onDropMissed(event);
|
|
13090
|
+
}
|
|
13091
|
+
if (isPointerMove || isDragOver) {
|
|
13092
|
+
cancelPointer(hits, pointerId);
|
|
13093
|
+
}
|
|
13094
|
+
function onIntersect(data) {
|
|
13095
|
+
const eventObject = data.eventObject;
|
|
13096
|
+
const instance = eventObject.__r3f;
|
|
13097
|
+
if (!instance?.eventCount) return;
|
|
13098
|
+
const handlers = instance.handlers;
|
|
13099
|
+
if (isPointerMove) {
|
|
13100
|
+
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
13101
|
+
const id = makeId(data);
|
|
13102
|
+
const pointerState2 = getPointerState(internal, pointerId);
|
|
13103
|
+
const hoveredItem = pointerState2.hovered.get(id);
|
|
13104
|
+
if (!hoveredItem) {
|
|
13105
|
+
pointerState2.hovered.set(id, data);
|
|
13106
|
+
handlers.onPointerOver?.(data);
|
|
13107
|
+
handlers.onPointerEnter?.(data);
|
|
13108
|
+
} else if (hoveredItem.stopped) {
|
|
13109
|
+
data.stopPropagation();
|
|
13110
|
+
}
|
|
13111
|
+
}
|
|
13112
|
+
handlers.onPointerMove?.(data);
|
|
13113
|
+
} else if (isDragOver) {
|
|
13114
|
+
const id = makeId(data);
|
|
13115
|
+
const pointerState2 = getPointerState(internal, pointerId);
|
|
13116
|
+
const hoveredItem = pointerState2.hovered.get(id);
|
|
13117
|
+
if (!hoveredItem) {
|
|
13118
|
+
pointerState2.hovered.set(id, data);
|
|
13119
|
+
handlers.onDragOverEnter?.(data);
|
|
13120
|
+
} else if (hoveredItem.stopped) {
|
|
13121
|
+
data.stopPropagation();
|
|
13122
|
+
}
|
|
13123
|
+
handlers.onDragOver?.(data);
|
|
13124
|
+
} else if (isDrop) {
|
|
13125
|
+
handlers.onDrop?.(data);
|
|
13126
|
+
} else {
|
|
13127
|
+
const handler = handlers[name];
|
|
13128
|
+
if (handler) {
|
|
13129
|
+
if (!isClickEvent || initialHits.includes(eventObject)) {
|
|
13130
|
+
pointerMissed(
|
|
13131
|
+
event,
|
|
13132
|
+
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
13133
|
+
);
|
|
13134
|
+
handler(data);
|
|
13135
|
+
}
|
|
13136
|
+
} else {
|
|
13137
|
+
if (isClickEvent && initialHits.includes(eventObject)) {
|
|
13138
|
+
pointerMissed(
|
|
13139
|
+
event,
|
|
13140
|
+
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
13141
|
+
);
|
|
13573
13142
|
}
|
|
13574
13143
|
}
|
|
13575
13144
|
}
|
|
13576
|
-
|
|
13577
|
-
|
|
13578
|
-
|
|
13579
|
-
|
|
13580
|
-
|
|
13581
|
-
|
|
13582
|
-
|
|
13583
|
-
|
|
13584
|
-
|
|
13585
|
-
|
|
13586
|
-
|
|
13587
|
-
|
|
13588
|
-
|
|
13589
|
-
|
|
13590
|
-
|
|
13591
|
-
|
|
13592
|
-
|
|
13593
|
-
|
|
13594
|
-
|
|
13595
|
-
|
|
13596
|
-
|
|
13597
|
-
|
|
13598
|
-
|
|
13599
|
-
|
|
13600
|
-
|
|
13601
|
-
|
|
13602
|
-
|
|
13603
|
-
|
|
13604
|
-
|
|
13605
|
-
|
|
13606
|
-
|
|
13607
|
-
|
|
13608
|
-
|
|
13609
|
-
|
|
13610
|
-
|
|
13145
|
+
}
|
|
13146
|
+
handleIntersects(hits, event, delta, onIntersect);
|
|
13147
|
+
};
|
|
13148
|
+
}
|
|
13149
|
+
function flushDeferredPointers() {
|
|
13150
|
+
const { internal, events } = store.getState();
|
|
13151
|
+
if (!events.frameTimedRaycasts) return;
|
|
13152
|
+
for (const [pointerId, event] of internal.pointerDirty) {
|
|
13153
|
+
processDeferredPointer(event, pointerId);
|
|
13154
|
+
}
|
|
13155
|
+
internal.pointerDirty.clear();
|
|
13156
|
+
}
|
|
13157
|
+
return { handlePointer, flushDeferredPointers, processDeferredPointer };
|
|
13158
|
+
}
|
|
13159
|
+
const DOM_EVENTS = {
|
|
13160
|
+
onClick: ["click", false],
|
|
13161
|
+
onContextMenu: ["contextmenu", false],
|
|
13162
|
+
onDoubleClick: ["dblclick", false],
|
|
13163
|
+
onDragEnter: ["dragenter", false],
|
|
13164
|
+
onDragLeave: ["dragleave", false],
|
|
13165
|
+
onDragOver: ["dragover", false],
|
|
13166
|
+
onDrop: ["drop", false],
|
|
13167
|
+
onWheel: ["wheel", true],
|
|
13168
|
+
onPointerDown: ["pointerdown", true],
|
|
13169
|
+
onPointerUp: ["pointerup", true],
|
|
13170
|
+
onPointerLeave: ["pointerleave", true],
|
|
13171
|
+
onPointerMove: ["pointermove", true],
|
|
13172
|
+
onPointerCancel: ["pointercancel", true],
|
|
13173
|
+
onLostPointerCapture: ["lostpointercapture", true]
|
|
13174
|
+
};
|
|
13175
|
+
function createPointerEvents(store) {
|
|
13176
|
+
const { handlePointer, flushDeferredPointers, processDeferredPointer } = createEvents(store);
|
|
13177
|
+
let nextXRPointerId = XR_POINTER_ID_START;
|
|
13178
|
+
const xrPointers = /* @__PURE__ */ new Map();
|
|
13179
|
+
return {
|
|
13180
|
+
priority: 1,
|
|
13181
|
+
enabled: true,
|
|
13182
|
+
frameTimedRaycasts: true,
|
|
13183
|
+
alwaysFireOnScroll: true,
|
|
13184
|
+
updateOnFrame: false,
|
|
13185
|
+
compute(event, state) {
|
|
13186
|
+
state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
|
|
13187
|
+
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
13188
|
+
},
|
|
13189
|
+
connected: void 0,
|
|
13190
|
+
handlers: Object.keys(DOM_EVENTS).reduce(
|
|
13191
|
+
(acc, key) => ({ ...acc, [key]: handlePointer(key) }),
|
|
13192
|
+
{}
|
|
13193
|
+
),
|
|
13194
|
+
update: (pointerId) => {
|
|
13195
|
+
const { events, internal } = store.getState();
|
|
13196
|
+
if (!events.handlers) return;
|
|
13197
|
+
if (pointerId !== void 0) {
|
|
13198
|
+
const event = internal.pointerDirty.get(pointerId);
|
|
13199
|
+
if (event) {
|
|
13200
|
+
internal.pointerDirty.delete(pointerId);
|
|
13201
|
+
processDeferredPointer(event, pointerId);
|
|
13202
|
+
} else if (internal.lastEvent?.current) {
|
|
13203
|
+
processDeferredPointer(internal.lastEvent.current, pointerId);
|
|
13611
13204
|
}
|
|
13612
|
-
|
|
13613
|
-
|
|
13614
|
-
if (
|
|
13615
|
-
|
|
13616
|
-
e = [Ef(e), 0];
|
|
13617
|
-
for (var s = 0; s < e.length; ) {
|
|
13618
|
-
var u = e[s++], f = u.tag, p = e[s++], g = n[p];
|
|
13619
|
-
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;
|
|
13205
|
+
} else {
|
|
13206
|
+
flushDeferredPointers();
|
|
13207
|
+
if (internal.lastEvent?.current) {
|
|
13208
|
+
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
13620
13209
|
}
|
|
13621
|
-
|
|
13622
|
-
|
|
13623
|
-
|
|
13624
|
-
|
|
13625
|
-
|
|
13626
|
-
|
|
13627
|
-
|
|
13210
|
+
}
|
|
13211
|
+
},
|
|
13212
|
+
flush: () => {
|
|
13213
|
+
const { events, internal } = store.getState();
|
|
13214
|
+
flushDeferredPointers();
|
|
13215
|
+
if (events.updateOnFrame && internal.lastEvent?.current && events.handlers) {
|
|
13216
|
+
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
13217
|
+
}
|
|
13218
|
+
},
|
|
13219
|
+
connect: (target) => {
|
|
13220
|
+
if (!target) return;
|
|
13221
|
+
const { set, events } = store.getState();
|
|
13222
|
+
events.disconnect?.();
|
|
13223
|
+
set((state) => ({ events: { ...state.events, connected: target } }));
|
|
13224
|
+
if (events.handlers) {
|
|
13225
|
+
for (const name in events.handlers) {
|
|
13226
|
+
const event = events.handlers[name];
|
|
13227
|
+
const [eventName, passive] = DOM_EVENTS[name];
|
|
13228
|
+
target.addEventListener(eventName, event, { passive });
|
|
13628
13229
|
}
|
|
13629
|
-
|
|
13630
|
-
|
|
13631
|
-
|
|
13632
|
-
|
|
13633
|
-
|
|
13634
|
-
|
|
13635
|
-
|
|
13636
|
-
|
|
13637
|
-
|
|
13230
|
+
}
|
|
13231
|
+
},
|
|
13232
|
+
disconnect: () => {
|
|
13233
|
+
const { set, events } = store.getState();
|
|
13234
|
+
if (events.connected) {
|
|
13235
|
+
if (events.handlers) {
|
|
13236
|
+
for (const name in events.handlers) {
|
|
13237
|
+
const event = events.handlers[name];
|
|
13238
|
+
const [eventName] = DOM_EVENTS[name];
|
|
13239
|
+
events.connected.removeEventListener(eventName, event);
|
|
13240
|
+
}
|
|
13638
13241
|
}
|
|
13639
|
-
|
|
13640
|
-
|
|
13641
|
-
|
|
13642
|
-
|
|
13643
|
-
|
|
13644
|
-
|
|
13645
|
-
|
|
13646
|
-
|
|
13647
|
-
|
|
13648
|
-
|
|
13649
|
-
|
|
13242
|
+
set((state) => ({ events: { ...state.events, connected: void 0 } }));
|
|
13243
|
+
}
|
|
13244
|
+
},
|
|
13245
|
+
// PREVIEW (A8): the XR pointer registration API may change before stable.
|
|
13246
|
+
registerPointer: (config) => {
|
|
13247
|
+
const pointerId = nextXRPointerId++;
|
|
13248
|
+
xrPointers.set(pointerId, config);
|
|
13249
|
+
const { internal } = store.getState();
|
|
13250
|
+
getPointerState(internal, pointerId);
|
|
13251
|
+
return pointerId;
|
|
13252
|
+
},
|
|
13253
|
+
unregisterPointer: (pointerId) => {
|
|
13254
|
+
xrPointers.delete(pointerId);
|
|
13255
|
+
const { internal } = store.getState();
|
|
13256
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13257
|
+
if (pointerState) {
|
|
13258
|
+
for (const [, hoveredObj] of pointerState.hovered) {
|
|
13259
|
+
const eventObject = hoveredObj.eventObject;
|
|
13260
|
+
const instance = eventObject.__r3f;
|
|
13261
|
+
if (instance?.eventCount) {
|
|
13262
|
+
const handlers = instance.handlers;
|
|
13263
|
+
const data = { ...hoveredObj, intersections: [] };
|
|
13264
|
+
handlers.onPointerOut?.(data);
|
|
13265
|
+
handlers.onPointerLeave?.(data);
|
|
13266
|
+
}
|
|
13650
13267
|
}
|
|
13651
|
-
|
|
13652
|
-
|
|
13653
|
-
|
|
13654
|
-
|
|
13655
|
-
|
|
13656
|
-
var S = bm.indexOf(s);
|
|
13657
|
-
0 <= S && bm.splice(S, 1), f();
|
|
13658
|
-
} };
|
|
13659
|
-
}, le.shouldError = function(e) {
|
|
13660
|
-
return pu(e);
|
|
13661
|
-
}, le.shouldSuspend = function(e) {
|
|
13662
|
-
return fu(e);
|
|
13663
|
-
}, le.startHostTransition = function(e, n, o, i) {
|
|
13664
|
-
if (e.tag !== 5) throw Error("Expected the form instance to be a HostComponent. This is a bug in React.");
|
|
13665
|
-
var s = uf(e).queue;
|
|
13666
|
-
Hp(e), nt(e, s, n, Xt, o === null ? Em : function() {
|
|
13667
|
-
x.T === null && console.error("requestFormReset was called outside a transition or action. To fix, move to an action, or wrap with startTransition.");
|
|
13668
|
-
var u = uf(e);
|
|
13669
|
-
return u.next === null && (u = e.alternate.memoizedState), qi(e, u.next.queue, {}, Nt(e)), o(i);
|
|
13670
|
-
});
|
|
13671
|
-
}, le.updateContainer = function(e, n, o, i) {
|
|
13672
|
-
var s = n.current, u = Nt(s);
|
|
13673
|
-
return As(s, u, e, n, o, i), u;
|
|
13674
|
-
}, le.updateContainerSync = Wh, le;
|
|
13675
|
-
}, Tt.exports.default = Tt.exports, Object.defineProperty(Tt.exports, "__esModule", { value: true }));
|
|
13676
|
-
})(Mg)), Mg.exports;
|
|
13677
|
-
}
|
|
13678
|
-
var Eb;
|
|
13679
|
-
function n0() {
|
|
13680
|
-
return Eb || (Eb = 1, process.env.NODE_ENV === "production" ? Rm.exports = Kb() : Rm.exports = e0()), Rm.exports;
|
|
13268
|
+
internal.pointerMap.delete(pointerId);
|
|
13269
|
+
}
|
|
13270
|
+
internal.pointerDirty.delete(pointerId);
|
|
13271
|
+
}
|
|
13272
|
+
};
|
|
13681
13273
|
}
|
|
13682
|
-
var t0 = n0();
|
|
13683
|
-
const r0 = Xb(t0);
|
|
13684
|
-
|
|
13685
|
-
const t = 1, o = 8, r = 32, e = 2;
|
|
13686
13274
|
|
|
13687
13275
|
function createReconciler(config) {
|
|
13688
13276
|
const reconciler2 = r0(config);
|
|
@@ -13702,7 +13290,10 @@ function extend(objects) {
|
|
|
13702
13290
|
catalogue[Component] = objects;
|
|
13703
13291
|
return Component;
|
|
13704
13292
|
} else {
|
|
13705
|
-
|
|
13293
|
+
for (const name in objects) {
|
|
13294
|
+
const object = objects[name];
|
|
13295
|
+
if (isConstructor(object)) catalogue[name] = object;
|
|
13296
|
+
}
|
|
13706
13297
|
}
|
|
13707
13298
|
}
|
|
13708
13299
|
function validateInstance(type, props) {
|
|
@@ -13846,8 +13437,16 @@ function setFiberRef(fiber, publicInstance) {
|
|
|
13846
13437
|
}
|
|
13847
13438
|
}
|
|
13848
13439
|
}
|
|
13849
|
-
const reconstructed = [];
|
|
13850
|
-
function
|
|
13440
|
+
const reconstructed = [];
|
|
13441
|
+
function flushReconstructedInstances() {
|
|
13442
|
+
if (reconstructed.length === 0) return;
|
|
13443
|
+
try {
|
|
13444
|
+
swapReconstructedInstances();
|
|
13445
|
+
} finally {
|
|
13446
|
+
reconstructed.length = 0;
|
|
13447
|
+
}
|
|
13448
|
+
}
|
|
13449
|
+
function swapReconstructedInstances() {
|
|
13851
13450
|
for (const [instance] of reconstructed) {
|
|
13852
13451
|
const parent = instance.parent;
|
|
13853
13452
|
if (parent) {
|
|
@@ -13865,7 +13464,9 @@ function swapInstances() {
|
|
|
13865
13464
|
}
|
|
13866
13465
|
}
|
|
13867
13466
|
if (instance.isHidden) unhideInstance(instance);
|
|
13868
|
-
if (isObject3D(instance.object)
|
|
13467
|
+
if (isObject3D(instance.object) && !instance.parent) {
|
|
13468
|
+
removeInteractivity(findInitialRoot(instance), instance.object);
|
|
13469
|
+
}
|
|
13869
13470
|
if (instance.object.__r3f) delete instance.object.__r3f;
|
|
13870
13471
|
if (instance.type !== "primitive") disposeOnIdle(instance.object);
|
|
13871
13472
|
}
|
|
@@ -13874,9 +13475,13 @@ function swapInstances() {
|
|
|
13874
13475
|
const parent = instance.parent;
|
|
13875
13476
|
if (parent) {
|
|
13876
13477
|
const target = catalogue[toPascalCase(instance.type)];
|
|
13478
|
+
const prevObject = instance.object;
|
|
13877
13479
|
instance.object = instance.props.object ?? new target(...instance.props.args ?? []);
|
|
13878
13480
|
instance.object.__r3f = instance;
|
|
13879
13481
|
setFiberRef(fiber, instance.object);
|
|
13482
|
+
if (isObject3D(prevObject) && isObject3D(instance.object)) {
|
|
13483
|
+
swapInteractivity(findInitialRoot(instance), prevObject, instance.object);
|
|
13484
|
+
}
|
|
13880
13485
|
delete instance.appliedOnce;
|
|
13881
13486
|
instance.eventCount = 0;
|
|
13882
13487
|
instance.handlers = {};
|
|
@@ -13896,14 +13501,114 @@ function swapInstances() {
|
|
|
13896
13501
|
invalidateInstance(instance);
|
|
13897
13502
|
}
|
|
13898
13503
|
}
|
|
13899
|
-
reconstructed.length = 0;
|
|
13900
13504
|
}
|
|
13901
13505
|
const handleTextInstance = () => {
|
|
13902
13506
|
};
|
|
13903
13507
|
const NO_CONTEXT = {};
|
|
13904
13508
|
let currentUpdatePriority = NoEventPriority;
|
|
13905
|
-
|
|
13906
|
-
|
|
13509
|
+
function getEventPriority(type) {
|
|
13510
|
+
switch (type) {
|
|
13511
|
+
case "beforetoggle":
|
|
13512
|
+
case "cancel":
|
|
13513
|
+
case "click":
|
|
13514
|
+
case "close":
|
|
13515
|
+
case "contextmenu":
|
|
13516
|
+
case "copy":
|
|
13517
|
+
case "cut":
|
|
13518
|
+
case "auxclick":
|
|
13519
|
+
case "dblclick":
|
|
13520
|
+
case "dragend":
|
|
13521
|
+
case "dragstart":
|
|
13522
|
+
case "drop":
|
|
13523
|
+
case "focusin":
|
|
13524
|
+
case "focusout":
|
|
13525
|
+
case "input":
|
|
13526
|
+
case "invalid":
|
|
13527
|
+
case "keydown":
|
|
13528
|
+
case "keypress":
|
|
13529
|
+
case "keyup":
|
|
13530
|
+
case "mousedown":
|
|
13531
|
+
case "mouseup":
|
|
13532
|
+
case "paste":
|
|
13533
|
+
case "pause":
|
|
13534
|
+
case "play":
|
|
13535
|
+
case "pointercancel":
|
|
13536
|
+
case "pointerdown":
|
|
13537
|
+
case "pointerup":
|
|
13538
|
+
case "ratechange":
|
|
13539
|
+
case "reset":
|
|
13540
|
+
case "resize":
|
|
13541
|
+
case "seeked":
|
|
13542
|
+
case "submit":
|
|
13543
|
+
case "touchcancel":
|
|
13544
|
+
case "touchend":
|
|
13545
|
+
case "touchstart":
|
|
13546
|
+
case "volumechange":
|
|
13547
|
+
case "change":
|
|
13548
|
+
case "selectionchange":
|
|
13549
|
+
case "compositionstart":
|
|
13550
|
+
case "compositionend":
|
|
13551
|
+
case "compositionupdate":
|
|
13552
|
+
case "beforeinput":
|
|
13553
|
+
case "blur":
|
|
13554
|
+
case "fullscreenchange":
|
|
13555
|
+
case "focus":
|
|
13556
|
+
case "hashchange":
|
|
13557
|
+
case "popstate":
|
|
13558
|
+
case "select":
|
|
13559
|
+
case "selectstart":
|
|
13560
|
+
return e;
|
|
13561
|
+
case "drag":
|
|
13562
|
+
case "dragenter":
|
|
13563
|
+
case "dragexit":
|
|
13564
|
+
case "dragleave":
|
|
13565
|
+
case "dragover":
|
|
13566
|
+
case "mousemove":
|
|
13567
|
+
case "mouseout":
|
|
13568
|
+
case "mouseover":
|
|
13569
|
+
case "pointermove":
|
|
13570
|
+
case "pointerout":
|
|
13571
|
+
case "pointerover":
|
|
13572
|
+
case "scroll":
|
|
13573
|
+
case "touchmove":
|
|
13574
|
+
case "wheel":
|
|
13575
|
+
case "mouseenter":
|
|
13576
|
+
case "mouseleave":
|
|
13577
|
+
case "pointerenter":
|
|
13578
|
+
case "pointerleave":
|
|
13579
|
+
return o;
|
|
13580
|
+
case "message": {
|
|
13581
|
+
switch (unstable_getCurrentPriorityLevel()) {
|
|
13582
|
+
case unstable_ImmediatePriority:
|
|
13583
|
+
return e;
|
|
13584
|
+
case unstable_UserBlockingPriority:
|
|
13585
|
+
return o;
|
|
13586
|
+
case unstable_NormalPriority:
|
|
13587
|
+
case unstable_LowPriority:
|
|
13588
|
+
return r;
|
|
13589
|
+
case unstable_IdlePriority:
|
|
13590
|
+
return i$1;
|
|
13591
|
+
default:
|
|
13592
|
+
return r;
|
|
13593
|
+
}
|
|
13594
|
+
}
|
|
13595
|
+
default:
|
|
13596
|
+
return r;
|
|
13597
|
+
}
|
|
13598
|
+
}
|
|
13599
|
+
function scheduleMicrotask(callback) {
|
|
13600
|
+
if (typeof queueMicrotask === "function") {
|
|
13601
|
+
queueMicrotask(callback);
|
|
13602
|
+
} else if (typeof Promise !== "undefined") {
|
|
13603
|
+
Promise.resolve().then(callback).catch((error) => {
|
|
13604
|
+
setTimeout(() => {
|
|
13605
|
+
throw error;
|
|
13606
|
+
});
|
|
13607
|
+
});
|
|
13608
|
+
} else {
|
|
13609
|
+
setTimeout(callback);
|
|
13610
|
+
}
|
|
13611
|
+
}
|
|
13907
13612
|
const reconciler = /* @__PURE__ */ createReconciler({
|
|
13908
13613
|
isPrimaryRenderer: false,
|
|
13909
13614
|
warnsIfNotActing: false,
|
|
@@ -13936,22 +13641,21 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13936
13641
|
getRootHostContext: () => NO_CONTEXT,
|
|
13937
13642
|
getChildHostContext: () => NO_CONTEXT,
|
|
13938
13643
|
commitUpdate(instance, type, oldProps, newProps, fiber) {
|
|
13939
|
-
validateInstance(type, newProps);
|
|
13644
|
+
validateInstance(instance.type, newProps);
|
|
13940
13645
|
let reconstruct = false;
|
|
13941
13646
|
if (instance.type === "primitive" && oldProps.object !== newProps.object) reconstruct = true;
|
|
13942
13647
|
else if (newProps.args?.length !== oldProps.args?.length) reconstruct = true;
|
|
13943
13648
|
else if (newProps.args?.some((value, index) => value !== oldProps.args?.[index])) reconstruct = true;
|
|
13944
13649
|
if (reconstruct) {
|
|
13945
|
-
reconstructed.push([instance,
|
|
13650
|
+
reconstructed.push([instance, getInstanceProps(newProps), fiber]);
|
|
13946
13651
|
} else {
|
|
13947
13652
|
const changedProps = diffProps(instance, newProps);
|
|
13948
|
-
|
|
13949
|
-
|
|
13950
|
-
|
|
13951
|
-
|
|
13653
|
+
const attach2 = instance.props.attach;
|
|
13654
|
+
instance.props = getInstanceProps(newProps);
|
|
13655
|
+
if (attach2 !== void 0) instance.props.attach = attach2;
|
|
13656
|
+
else delete instance.props.attach;
|
|
13657
|
+
if (Object.keys(changedProps).length) applyProps(instance.object, changedProps);
|
|
13952
13658
|
}
|
|
13953
|
-
const isTailSibling = fiber.sibling === null || (fiber.flags & Update) === NoFlags;
|
|
13954
|
-
if (isTailSibling) swapInstances();
|
|
13955
13659
|
},
|
|
13956
13660
|
finalizeInitialChildren: (instance) => {
|
|
13957
13661
|
for (const prop in instance.props) {
|
|
@@ -13964,8 +13668,8 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13964
13668
|
for (const prop in instance.props) {
|
|
13965
13669
|
const value = instance.props[prop];
|
|
13966
13670
|
if (isFromRef(value)) {
|
|
13967
|
-
const ref = value
|
|
13968
|
-
if (ref.current != null) resolved[prop] = ref.current;
|
|
13671
|
+
const { [FROM_REF]: ref, transform } = value;
|
|
13672
|
+
if (ref.current != null) resolved[prop] = transform ? transform(ref.current) : ref.current;
|
|
13969
13673
|
}
|
|
13970
13674
|
}
|
|
13971
13675
|
if (Object.keys(resolved).length) applyProps(instance.object, resolved);
|
|
@@ -13976,8 +13680,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13976
13680
|
const target = container.getState().internal.container ?? container.getState().scene;
|
|
13977
13681
|
return prepare(target, container, "", {});
|
|
13978
13682
|
},
|
|
13979
|
-
|
|
13980
|
-
|
|
13683
|
+
// Reconstructed instances are swapped once all mutations are committed,
|
|
13684
|
+
// before layout effects run so refs point to the new objects
|
|
13685
|
+
resetAfterCommit: flushReconstructedInstances,
|
|
13981
13686
|
shouldSetTextContent: () => false,
|
|
13982
13687
|
clearContainer: () => false,
|
|
13983
13688
|
hideInstance,
|
|
@@ -13985,6 +13690,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13985
13690
|
createTextInstance: handleTextInstance,
|
|
13986
13691
|
hideTextInstance: handleTextInstance,
|
|
13987
13692
|
unhideTextInstance: handleTextInstance,
|
|
13693
|
+
// Mirrors react-dom, which flushes discrete work in microtasks
|
|
13694
|
+
supportsMicrotasks: true,
|
|
13695
|
+
scheduleMicrotask,
|
|
13988
13696
|
scheduleTimeout: typeof setTimeout === "function" ? setTimeout : void 0,
|
|
13989
13697
|
cancelTimeout: typeof clearTimeout === "function" ? clearTimeout : void 0,
|
|
13990
13698
|
noTimeout: -1,
|
|
@@ -14025,28 +13733,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
14025
13733
|
},
|
|
14026
13734
|
resolveUpdatePriority() {
|
|
14027
13735
|
if (currentUpdatePriority !== NoEventPriority) return currentUpdatePriority;
|
|
14028
|
-
|
|
14029
|
-
|
|
14030
|
-
|
|
14031
|
-
case "dblclick":
|
|
14032
|
-
case "dragenter":
|
|
14033
|
-
case "dragleave":
|
|
14034
|
-
case "drop":
|
|
14035
|
-
case "pointercancel":
|
|
14036
|
-
case "pointerdown":
|
|
14037
|
-
case "pointerup":
|
|
14038
|
-
return e;
|
|
14039
|
-
case "dragover":
|
|
14040
|
-
case "pointermove":
|
|
14041
|
-
case "pointerout":
|
|
14042
|
-
case "pointerover":
|
|
14043
|
-
case "pointerenter":
|
|
14044
|
-
case "pointerleave":
|
|
14045
|
-
case "wheel":
|
|
14046
|
-
return o;
|
|
14047
|
-
default:
|
|
14048
|
-
return r;
|
|
14049
|
-
}
|
|
13736
|
+
const eventType = typeof window !== "undefined" ? window.event?.type : void 0;
|
|
13737
|
+
if (eventType === void 0) return r;
|
|
13738
|
+
return getEventPriority(eventType);
|
|
14050
13739
|
},
|
|
14051
13740
|
resetFormInstance() {
|
|
14052
13741
|
},
|
|
@@ -14124,6 +13813,335 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
14124
13813
|
getSuspendedCommitReason: (_state, _rootContainer) => null
|
|
14125
13814
|
});
|
|
14126
13815
|
|
|
13816
|
+
const INTERNAL_LIB_MARKERS = ["zustand", "setState", "Object.assign"];
|
|
13817
|
+
function isInternalRendererAccess(stack, callerDepth = 2) {
|
|
13818
|
+
if (!stack) return false;
|
|
13819
|
+
const caller = stack.split("\n")[callerDepth] ?? "";
|
|
13820
|
+
return INTERNAL_LIB_MARKERS.some((m) => caller.includes(m));
|
|
13821
|
+
}
|
|
13822
|
+
|
|
13823
|
+
const createStore = (invalidate, advance) => {
|
|
13824
|
+
const rootStore = createWithEqualityFn((set, get) => {
|
|
13825
|
+
const position = new Vector3();
|
|
13826
|
+
const defaultTarget = new Vector3();
|
|
13827
|
+
const tempTarget = new Vector3();
|
|
13828
|
+
function getCurrentViewport(camera = get().camera, target = defaultTarget, size = get().size) {
|
|
13829
|
+
const { width, height, top, left } = size;
|
|
13830
|
+
const aspect = width / height;
|
|
13831
|
+
if (target.isVector3) tempTarget.copy(target);
|
|
13832
|
+
else tempTarget.set(...target);
|
|
13833
|
+
const distance = camera.getWorldPosition(position).distanceTo(tempTarget);
|
|
13834
|
+
if (isOrthographicCamera(camera)) {
|
|
13835
|
+
return { width: width / camera.zoom, height: height / camera.zoom, top, left, factor: 1, distance, aspect };
|
|
13836
|
+
} else {
|
|
13837
|
+
const fov = camera.fov * Math.PI / 180;
|
|
13838
|
+
const h = 2 * Math.tan(fov / 2) * distance;
|
|
13839
|
+
const w = h * (width / height);
|
|
13840
|
+
return { width: w, height: h, top, left, factor: width / w, distance, aspect };
|
|
13841
|
+
}
|
|
13842
|
+
}
|
|
13843
|
+
let performanceTimeout = void 0;
|
|
13844
|
+
const setPerformanceCurrent = (current) => set((state2) => ({ performance: { ...state2.performance, current } }));
|
|
13845
|
+
const pointer = new Vector2();
|
|
13846
|
+
const rootState = {
|
|
13847
|
+
set,
|
|
13848
|
+
get,
|
|
13849
|
+
// Mock objects that have to be configured
|
|
13850
|
+
// primaryStore is set after store creation (self-reference for primary, primary's store for secondary)
|
|
13851
|
+
primaryStore: null,
|
|
13852
|
+
gl: null,
|
|
13853
|
+
renderer: null,
|
|
13854
|
+
camera: null,
|
|
13855
|
+
frustum: new Frustum(),
|
|
13856
|
+
autoUpdateFrustum: true,
|
|
13857
|
+
raycaster: null,
|
|
13858
|
+
events: {
|
|
13859
|
+
priority: 1,
|
|
13860
|
+
enabled: true,
|
|
13861
|
+
connected: false,
|
|
13862
|
+
frameTimedRaycasts: true,
|
|
13863
|
+
alwaysFireOnScroll: true,
|
|
13864
|
+
updateOnFrame: false
|
|
13865
|
+
},
|
|
13866
|
+
scene: null,
|
|
13867
|
+
rootScene: null,
|
|
13868
|
+
xr: null,
|
|
13869
|
+
inspector: null,
|
|
13870
|
+
invalidate: (frames = 1, stackFrames = false) => invalidate(get(), frames, stackFrames),
|
|
13871
|
+
advance: (timestamp, runGlobalEffects) => advance(timestamp, runGlobalEffects, get()),
|
|
13872
|
+
textureColorSpace: SRGBColorSpace,
|
|
13873
|
+
isLegacy: false,
|
|
13874
|
+
webGPUSupported: false,
|
|
13875
|
+
isNative: false,
|
|
13876
|
+
controls: null,
|
|
13877
|
+
pointer,
|
|
13878
|
+
mouse: pointer,
|
|
13879
|
+
frameloop: "always",
|
|
13880
|
+
onPointerMissed: void 0,
|
|
13881
|
+
onDragOverMissed: void 0,
|
|
13882
|
+
onDropMissed: void 0,
|
|
13883
|
+
performance: {
|
|
13884
|
+
current: 1,
|
|
13885
|
+
min: 0.5,
|
|
13886
|
+
max: 1,
|
|
13887
|
+
debounce: 200,
|
|
13888
|
+
regress: () => {
|
|
13889
|
+
const state2 = get();
|
|
13890
|
+
if (performanceTimeout) clearTimeout(performanceTimeout);
|
|
13891
|
+
if (state2.performance.current !== state2.performance.min) setPerformanceCurrent(state2.performance.min);
|
|
13892
|
+
performanceTimeout = setTimeout(
|
|
13893
|
+
() => setPerformanceCurrent(get().performance.max),
|
|
13894
|
+
state2.performance.debounce
|
|
13895
|
+
);
|
|
13896
|
+
}
|
|
13897
|
+
},
|
|
13898
|
+
size: { width: 0, height: 0, top: 0, left: 0 },
|
|
13899
|
+
viewport: {
|
|
13900
|
+
initialDpr: 0,
|
|
13901
|
+
dpr: 0,
|
|
13902
|
+
width: 0,
|
|
13903
|
+
height: 0,
|
|
13904
|
+
top: 0,
|
|
13905
|
+
left: 0,
|
|
13906
|
+
aspect: 0,
|
|
13907
|
+
distance: 0,
|
|
13908
|
+
factor: 0,
|
|
13909
|
+
getCurrentViewport
|
|
13910
|
+
},
|
|
13911
|
+
setEvents: (events) => set((state2) => ({ ...state2, events: { ...state2.events, ...events } })),
|
|
13912
|
+
setSize: (width, height, top, left) => {
|
|
13913
|
+
const state2 = get();
|
|
13914
|
+
if (width === void 0) {
|
|
13915
|
+
set({ _sizeImperative: false });
|
|
13916
|
+
if (state2._sizeProps) {
|
|
13917
|
+
const { width: propW, height: propH } = state2._sizeProps;
|
|
13918
|
+
if (propW !== void 0 || propH !== void 0) {
|
|
13919
|
+
const currentSize = state2.size;
|
|
13920
|
+
const newSize = {
|
|
13921
|
+
width: propW ?? currentSize.width,
|
|
13922
|
+
height: propH ?? currentSize.height,
|
|
13923
|
+
top: currentSize.top,
|
|
13924
|
+
left: currentSize.left
|
|
13925
|
+
};
|
|
13926
|
+
set((s) => ({
|
|
13927
|
+
size: newSize,
|
|
13928
|
+
viewport: { ...s.viewport, ...getCurrentViewport(state2.camera, defaultTarget, newSize) }
|
|
13929
|
+
}));
|
|
13930
|
+
get().invalidate();
|
|
13931
|
+
}
|
|
13932
|
+
}
|
|
13933
|
+
return;
|
|
13934
|
+
}
|
|
13935
|
+
const w = width;
|
|
13936
|
+
const h = height ?? width;
|
|
13937
|
+
const t = top ?? state2.size.top;
|
|
13938
|
+
const l = left ?? state2.size.left;
|
|
13939
|
+
const size = { width: w, height: h, top: t, left: l };
|
|
13940
|
+
set((s) => ({
|
|
13941
|
+
size,
|
|
13942
|
+
viewport: { ...s.viewport, ...getCurrentViewport(state2.camera, defaultTarget, size) },
|
|
13943
|
+
_sizeImperative: true
|
|
13944
|
+
}));
|
|
13945
|
+
get().invalidate();
|
|
13946
|
+
},
|
|
13947
|
+
setDpr: (dpr) => set((state2) => {
|
|
13948
|
+
const resolved = calculateDpr(dpr);
|
|
13949
|
+
return { viewport: { ...state2.viewport, dpr: resolved, initialDpr: state2.viewport.initialDpr || resolved } };
|
|
13950
|
+
}),
|
|
13951
|
+
setFrameloop: (frameloop = "always") => {
|
|
13952
|
+
const rootId = get().internal.rootId;
|
|
13953
|
+
if (rootId) getScheduler().setRootFrameloop(rootId, frameloop);
|
|
13954
|
+
set(() => ({ frameloop }));
|
|
13955
|
+
},
|
|
13956
|
+
setError: (error) => set(() => ({ error })),
|
|
13957
|
+
error: null,
|
|
13958
|
+
//* TSL State (managed via hooks: useUniforms, useNodes, useBuffers, useGPUStorage, useTextures, useRenderPipeline) ==============================
|
|
13959
|
+
uniforms: {},
|
|
13960
|
+
nodes: {},
|
|
13961
|
+
buffers: {},
|
|
13962
|
+
gpuStorage: {},
|
|
13963
|
+
textures: /* @__PURE__ */ new Map(),
|
|
13964
|
+
_textureRefs: /* @__PURE__ */ new Map(),
|
|
13965
|
+
renderPipeline: null,
|
|
13966
|
+
passes: {},
|
|
13967
|
+
_hmrVersion: 0,
|
|
13968
|
+
_sizeImperative: false,
|
|
13969
|
+
_sizeProps: null,
|
|
13970
|
+
previousRoot: void 0,
|
|
13971
|
+
internal: {
|
|
13972
|
+
// Events
|
|
13973
|
+
interaction: [],
|
|
13974
|
+
subscribers: [],
|
|
13975
|
+
// Per-pointer state (new unified structure)
|
|
13976
|
+
pointerMap: /* @__PURE__ */ new Map(),
|
|
13977
|
+
pointerDirty: /* @__PURE__ */ new Map(),
|
|
13978
|
+
lastEvent: React.createRef(),
|
|
13979
|
+
// Deprecated but kept for backwards compatibility
|
|
13980
|
+
hovered: /* @__PURE__ */ new Map(),
|
|
13981
|
+
initialClick: [0, 0],
|
|
13982
|
+
initialHits: [],
|
|
13983
|
+
capturedMap: /* @__PURE__ */ new Map(),
|
|
13984
|
+
// Visibility tracking (onFramed, onOccluded, onVisible)
|
|
13985
|
+
visibilityRegistry: /* @__PURE__ */ new Map(),
|
|
13986
|
+
// Occlusion system (WebGPU only)
|
|
13987
|
+
occlusionEnabled: false,
|
|
13988
|
+
occlusionObserver: null,
|
|
13989
|
+
occlusionCache: /* @__PURE__ */ new Map(),
|
|
13990
|
+
helperGroup: null,
|
|
13991
|
+
// Updates
|
|
13992
|
+
active: false,
|
|
13993
|
+
frames: 0,
|
|
13994
|
+
priority: 0,
|
|
13995
|
+
subscribe: (ref, priority, store) => {
|
|
13996
|
+
const internal = get().internal;
|
|
13997
|
+
internal.priority = internal.priority + (priority > 0 ? 1 : 0);
|
|
13998
|
+
internal.subscribers.push({ ref, priority, store });
|
|
13999
|
+
internal.subscribers = internal.subscribers.sort((a, b) => a.priority - b.priority);
|
|
14000
|
+
return () => {
|
|
14001
|
+
const internal2 = get().internal;
|
|
14002
|
+
if (internal2?.subscribers) {
|
|
14003
|
+
internal2.priority = internal2.priority - (priority > 0 ? 1 : 0);
|
|
14004
|
+
internal2.subscribers = internal2.subscribers.filter((s) => s.ref !== ref);
|
|
14005
|
+
}
|
|
14006
|
+
};
|
|
14007
|
+
},
|
|
14008
|
+
// Renderer Storage (single source of truth)
|
|
14009
|
+
actualRenderer: null,
|
|
14010
|
+
// Scheduler for useFrameNext (initialized in renderer.tsx)
|
|
14011
|
+
scheduler: null,
|
|
14012
|
+
// Replaces the default render call when set (see setRenderOverride)
|
|
14013
|
+
renderOverride: null
|
|
14014
|
+
}
|
|
14015
|
+
};
|
|
14016
|
+
return rootState;
|
|
14017
|
+
});
|
|
14018
|
+
const state = rootStore.getState();
|
|
14019
|
+
Object.defineProperty(state, "gl", {
|
|
14020
|
+
get() {
|
|
14021
|
+
const currentState = rootStore.getState();
|
|
14022
|
+
if (!currentState.isLegacy && currentState.internal.actualRenderer) {
|
|
14023
|
+
const stack = new Error().stack || "";
|
|
14024
|
+
if (!isInternalRendererAccess(stack)) {
|
|
14025
|
+
const cleanedStack = stack.split("\n").slice(2).join("\n") || "Stack trace unavailable";
|
|
14026
|
+
notifyDepreciated({
|
|
14027
|
+
heading: "Accessing state.gl in WebGPU mode",
|
|
14028
|
+
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
|
|
14029
|
+
});
|
|
14030
|
+
}
|
|
14031
|
+
}
|
|
14032
|
+
return currentState.internal.actualRenderer;
|
|
14033
|
+
},
|
|
14034
|
+
set(value) {
|
|
14035
|
+
rootStore.getState().internal.actualRenderer = value;
|
|
14036
|
+
},
|
|
14037
|
+
enumerable: true,
|
|
14038
|
+
configurable: true
|
|
14039
|
+
});
|
|
14040
|
+
Object.defineProperty(state, "renderer", {
|
|
14041
|
+
get() {
|
|
14042
|
+
return rootStore.getState().internal.actualRenderer;
|
|
14043
|
+
},
|
|
14044
|
+
set(value) {
|
|
14045
|
+
rootStore.getState().internal.actualRenderer = value;
|
|
14046
|
+
},
|
|
14047
|
+
enumerable: true,
|
|
14048
|
+
configurable: true
|
|
14049
|
+
});
|
|
14050
|
+
let oldScene = state.scene;
|
|
14051
|
+
rootStore.subscribe(() => {
|
|
14052
|
+
const currentState = rootStore.getState();
|
|
14053
|
+
const { scene, rootScene, set } = currentState;
|
|
14054
|
+
if (scene !== oldScene) {
|
|
14055
|
+
oldScene = scene;
|
|
14056
|
+
if (scene?.isScene && scene !== rootScene) {
|
|
14057
|
+
set({ rootScene: scene });
|
|
14058
|
+
}
|
|
14059
|
+
}
|
|
14060
|
+
});
|
|
14061
|
+
let oldSize = state.size;
|
|
14062
|
+
let oldDpr = state.viewport.dpr;
|
|
14063
|
+
let oldCamera = state.camera;
|
|
14064
|
+
rootStore.subscribe(() => {
|
|
14065
|
+
const { camera, size, viewport, set, internal } = rootStore.getState();
|
|
14066
|
+
const actualRenderer = internal.actualRenderer;
|
|
14067
|
+
const canvasTarget = internal.canvasTarget;
|
|
14068
|
+
if (size.width !== oldSize.width || size.height !== oldSize.height || viewport.dpr !== oldDpr) {
|
|
14069
|
+
oldSize = size;
|
|
14070
|
+
oldDpr = viewport.dpr;
|
|
14071
|
+
updateCamera(camera, size);
|
|
14072
|
+
const resizeTarget = canvasTarget ?? actualRenderer;
|
|
14073
|
+
if (viewport.dpr > 0) resizeTarget.setPixelRatio(viewport.dpr);
|
|
14074
|
+
resizeTarget.setSize(size.width, size.height, false);
|
|
14075
|
+
const activeTarget = actualRenderer.getCanvasTarget?.();
|
|
14076
|
+
if (!canvasTarget || activeTarget !== canvasTarget) internal.canvasTargetSizeDirty = true;
|
|
14077
|
+
}
|
|
14078
|
+
if (camera !== oldCamera) {
|
|
14079
|
+
oldCamera = camera;
|
|
14080
|
+
const { rootScene } = rootStore.getState();
|
|
14081
|
+
if (camera && rootScene && !camera.parent) {
|
|
14082
|
+
rootScene.add(camera);
|
|
14083
|
+
}
|
|
14084
|
+
set((state2) => ({ viewport: { ...state2.viewport, ...state2.viewport.getCurrentViewport(camera) } }));
|
|
14085
|
+
const currentState = rootStore.getState();
|
|
14086
|
+
if (currentState.autoUpdateFrustum && camera) {
|
|
14087
|
+
updateFrustum(camera, currentState.frustum);
|
|
14088
|
+
}
|
|
14089
|
+
}
|
|
14090
|
+
});
|
|
14091
|
+
rootStore.subscribe((state2) => invalidate(state2));
|
|
14092
|
+
return rootStore;
|
|
14093
|
+
};
|
|
14094
|
+
|
|
14095
|
+
const R3F_EXTENSIONS = Symbol.for("@react-three/fiber.extensions");
|
|
14096
|
+
function getRegistry() {
|
|
14097
|
+
return globalThis[R3F_EXTENSIONS] ?? (globalThis[R3F_EXTENSIONS] = {
|
|
14098
|
+
extensions: /* @__PURE__ */ new Map(),
|
|
14099
|
+
roots: /* @__PURE__ */ new Set(),
|
|
14100
|
+
applied: /* @__PURE__ */ new WeakMap()
|
|
14101
|
+
});
|
|
14102
|
+
}
|
|
14103
|
+
function setupRoot(registry, store, extension) {
|
|
14104
|
+
let applied = registry.applied.get(store);
|
|
14105
|
+
if (!applied) registry.applied.set(store, applied = /* @__PURE__ */ new Map());
|
|
14106
|
+
if (applied.has(extension.name)) return;
|
|
14107
|
+
applied.set(extension.name, extension);
|
|
14108
|
+
const patch = extension.setup?.(store);
|
|
14109
|
+
if (patch) store.setState(patch);
|
|
14110
|
+
}
|
|
14111
|
+
function registerRootExtension(extension) {
|
|
14112
|
+
const registry = getRegistry();
|
|
14113
|
+
registry.extensions.set(extension.name, extension);
|
|
14114
|
+
for (const store of registry.roots) setupRoot(registry, store, extension);
|
|
14115
|
+
return () => {
|
|
14116
|
+
if (registry.extensions.get(extension.name) === extension) registry.extensions.delete(extension.name);
|
|
14117
|
+
};
|
|
14118
|
+
}
|
|
14119
|
+
function setRenderOverride(store, render) {
|
|
14120
|
+
store.getState().internal.renderOverride = render;
|
|
14121
|
+
}
|
|
14122
|
+
function attachRootExtensions(store) {
|
|
14123
|
+
const registry = getRegistry();
|
|
14124
|
+
registry.roots.add(store);
|
|
14125
|
+
for (const extension of registry.extensions.values()) setupRoot(registry, store, extension);
|
|
14126
|
+
}
|
|
14127
|
+
function current(registry, setUpBy) {
|
|
14128
|
+
return registry.extensions.get(setUpBy.name) ?? setUpBy;
|
|
14129
|
+
}
|
|
14130
|
+
function detachRootExtensions(store) {
|
|
14131
|
+
const registry = getRegistry();
|
|
14132
|
+
if (!registry.roots.delete(store)) return;
|
|
14133
|
+
const applied = registry.applied.get(store);
|
|
14134
|
+
registry.applied.delete(store);
|
|
14135
|
+
if (!applied) return;
|
|
14136
|
+
for (const setUpBy of applied.values()) current(registry, setUpBy).dispose?.(store);
|
|
14137
|
+
}
|
|
14138
|
+
function notifyRootExtensionsHmr(store) {
|
|
14139
|
+
const registry = getRegistry();
|
|
14140
|
+
const applied = registry.applied.get(store);
|
|
14141
|
+
if (!applied) return;
|
|
14142
|
+
for (const setUpBy of applied.values()) current(registry, setUpBy).hmr?.(store);
|
|
14143
|
+
}
|
|
14144
|
+
|
|
14127
14145
|
const isRenderer = (def) => !!def?.render;
|
|
14128
14146
|
const _roots = /* @__PURE__ */ new Map();
|
|
14129
14147
|
const shallowLoose = { objects: "shallow", strict: false };
|
|
@@ -14357,7 +14375,7 @@ function createRoot(canvas) {
|
|
|
14357
14375
|
const handleXRFrame = (timestamp, _frame) => {
|
|
14358
14376
|
const state2 = store.getState();
|
|
14359
14377
|
if (state2.frameloop === "never") return;
|
|
14360
|
-
advance(timestamp);
|
|
14378
|
+
advance(timestamp, true, state2);
|
|
14361
14379
|
};
|
|
14362
14380
|
const actualRenderer = state.internal.actualRenderer;
|
|
14363
14381
|
const handleSessionChange = () => {
|
|
@@ -14365,7 +14383,7 @@ function createRoot(canvas) {
|
|
|
14365
14383
|
const renderer2 = state2.internal.actualRenderer;
|
|
14366
14384
|
actualRenderer.xr.enabled = actualRenderer.xr.isPresenting;
|
|
14367
14385
|
renderer2.xr.setAnimationLoop(renderer2.xr.isPresenting ? handleXRFrame : null);
|
|
14368
|
-
if (!renderer2.xr.isPresenting) invalidate();
|
|
14386
|
+
if (!renderer2.xr.isPresenting) invalidate(state2);
|
|
14369
14387
|
};
|
|
14370
14388
|
const xr = {
|
|
14371
14389
|
connect() {
|
|
@@ -14447,14 +14465,23 @@ function createRoot(canvas) {
|
|
|
14447
14465
|
const newRootId = canvasId || scheduler.generateRootId();
|
|
14448
14466
|
const unregisterRoot = scheduler.registerRoot(newRootId, {
|
|
14449
14467
|
getState: () => store.getState(),
|
|
14450
|
-
onError: (err) => store.getState().setError(err)
|
|
14468
|
+
onError: (err) => store.getState().setError(err),
|
|
14469
|
+
frameloop: store.getState().frameloop,
|
|
14470
|
+
before: schedulerConfig?.before,
|
|
14471
|
+
after: schedulerConfig?.after,
|
|
14472
|
+
order: schedulerConfig?.order
|
|
14451
14473
|
});
|
|
14452
14474
|
const unregisterCanvasTarget = scheduler.register(
|
|
14453
14475
|
() => {
|
|
14454
14476
|
const state2 = store.getState();
|
|
14455
|
-
|
|
14477
|
+
const canvasTarget = state2.internal.canvasTarget;
|
|
14478
|
+
if (canvasTarget) {
|
|
14456
14479
|
const renderer2 = state2.internal.actualRenderer;
|
|
14457
|
-
renderer2.setCanvasTarget(
|
|
14480
|
+
if (renderer2.getCanvasTarget() !== canvasTarget) renderer2.setCanvasTarget(canvasTarget);
|
|
14481
|
+
if (state2.internal.canvasTargetSizeDirty) {
|
|
14482
|
+
state2.internal.canvasTargetSizeDirty = false;
|
|
14483
|
+
renderer2.backend?.updateSize?.();
|
|
14484
|
+
}
|
|
14458
14485
|
}
|
|
14459
14486
|
},
|
|
14460
14487
|
{
|
|
@@ -14510,7 +14537,8 @@ function createRoot(canvas) {
|
|
|
14510
14537
|
const userHandlesRender = scheduler.hasUserJobsInPhase("render", newRootId);
|
|
14511
14538
|
if (userHandlesRender || state2.internal.priority) return;
|
|
14512
14539
|
try {
|
|
14513
|
-
|
|
14540
|
+
const renderOverride = state2.internal.renderOverride;
|
|
14541
|
+
if (renderOverride) renderOverride();
|
|
14514
14542
|
else if (renderer2?.render) renderer2.render(state2.scene, state2.camera);
|
|
14515
14543
|
} catch (error) {
|
|
14516
14544
|
state2.setError(error instanceof Error ? error : new Error(String(error)));
|
|
@@ -14523,8 +14551,7 @@ function createRoot(canvas) {
|
|
|
14523
14551
|
phase: "render",
|
|
14524
14552
|
system: true,
|
|
14525
14553
|
// Internal flag: this is a system job, not user-controlled
|
|
14526
|
-
//
|
|
14527
|
-
...schedulerConfig?.after && { after: schedulerConfig.after },
|
|
14554
|
+
// FPS throttles only the default render job; Canvas ordering belongs to the root.
|
|
14528
14555
|
...schedulerConfig?.fps && { fps: schedulerConfig.fps }
|
|
14529
14556
|
}
|
|
14530
14557
|
);
|
|
@@ -14543,8 +14570,22 @@ function createRoot(canvas) {
|
|
|
14543
14570
|
scheduler
|
|
14544
14571
|
}
|
|
14545
14572
|
}));
|
|
14573
|
+
} else {
|
|
14574
|
+
const constraintsChanged = !is.equ(schedulerConfig?.before, lastConfiguredProps.schedulerBefore, shallowLoose) || !is.equ(schedulerConfig?.after, lastConfiguredProps.schedulerAfter, shallowLoose);
|
|
14575
|
+
if (constraintsChanged) {
|
|
14576
|
+
scheduler.setRootConstraints(rootId, {
|
|
14577
|
+
before: schedulerConfig?.before,
|
|
14578
|
+
after: schedulerConfig?.after
|
|
14579
|
+
});
|
|
14580
|
+
}
|
|
14581
|
+
if (schedulerConfig?.order !== lastConfiguredProps.schedulerOrder) {
|
|
14582
|
+
scheduler.setRootOrder(rootId, schedulerConfig?.order ?? 0);
|
|
14583
|
+
}
|
|
14546
14584
|
}
|
|
14547
|
-
|
|
14585
|
+
lastConfiguredProps.schedulerBefore = schedulerConfig?.before;
|
|
14586
|
+
lastConfiguredProps.schedulerAfter = schedulerConfig?.after;
|
|
14587
|
+
lastConfiguredProps.schedulerOrder = schedulerConfig?.order;
|
|
14588
|
+
attachRootExtensions(store);
|
|
14548
14589
|
onCreated = onCreatedCallback;
|
|
14549
14590
|
configured = true;
|
|
14550
14591
|
resolve();
|
|
@@ -14586,18 +14627,24 @@ function unmountComponentAtNode(canvas, callback) {
|
|
|
14586
14627
|
const fiber = root?.fiber;
|
|
14587
14628
|
if (fiber) {
|
|
14588
14629
|
const state = root?.store.getState();
|
|
14589
|
-
if (state)
|
|
14630
|
+
if (state) {
|
|
14631
|
+
state.internal.active = false;
|
|
14632
|
+
const unregisterRoot = state.internal.unregisterRoot;
|
|
14633
|
+
if (unregisterRoot) {
|
|
14634
|
+
unregisterRoot();
|
|
14635
|
+
state.internal.unregisterRoot = void 0;
|
|
14636
|
+
}
|
|
14637
|
+
}
|
|
14590
14638
|
reconciler.updateContainer(null, fiber, null, () => {
|
|
14639
|
+
if (root?.store) detachRootExtensions(root.store);
|
|
14591
14640
|
if (state) {
|
|
14592
14641
|
setTimeout(() => {
|
|
14593
14642
|
try {
|
|
14594
14643
|
const renderer = state.internal.actualRenderer;
|
|
14595
|
-
const unregisterRoot = state.internal.unregisterRoot;
|
|
14596
|
-
if (unregisterRoot) unregisterRoot();
|
|
14597
14644
|
const unregisterPrimary = state.internal.unregisterPrimary;
|
|
14598
14645
|
if (unregisterPrimary) unregisterPrimary();
|
|
14599
14646
|
const canvasTarget = state.internal.canvasTarget;
|
|
14600
|
-
if (canvasTarget?.dispose) canvasTarget.dispose();
|
|
14647
|
+
if (state.internal.isSecondary && canvasTarget?.dispose) canvasTarget.dispose();
|
|
14601
14648
|
state.events.disconnect?.();
|
|
14602
14649
|
cleanupHelperGroup(root.store);
|
|
14603
14650
|
if (state.isLegacy && renderer) {
|
|
@@ -14723,6 +14770,207 @@ function flushSync(fn) {
|
|
|
14723
14770
|
return reconciler.flushSyncFromReconciler(fn);
|
|
14724
14771
|
}
|
|
14725
14772
|
|
|
14773
|
+
const isRef = (obj) => obj.current && obj.current.isScene;
|
|
14774
|
+
const resolveScene = (scene) => isRef(scene) ? scene.current : scene;
|
|
14775
|
+
function setEnvProps(background, scene, defaultScene, texture, sceneProps = {}) {
|
|
14776
|
+
sceneProps = {
|
|
14777
|
+
backgroundBlurriness: 0,
|
|
14778
|
+
backgroundIntensity: 1,
|
|
14779
|
+
backgroundRotation: [0, 0, 0],
|
|
14780
|
+
environmentIntensity: 1,
|
|
14781
|
+
environmentRotation: [0, 0, 0],
|
|
14782
|
+
...sceneProps
|
|
14783
|
+
};
|
|
14784
|
+
const target = resolveScene(scene || defaultScene);
|
|
14785
|
+
const oldbg = target.background;
|
|
14786
|
+
const oldenv = target.environment;
|
|
14787
|
+
const oldSceneProps = {
|
|
14788
|
+
backgroundBlurriness: target.backgroundBlurriness,
|
|
14789
|
+
backgroundIntensity: target.backgroundIntensity,
|
|
14790
|
+
backgroundRotation: target.backgroundRotation.clone(),
|
|
14791
|
+
environmentIntensity: target.environmentIntensity,
|
|
14792
|
+
environmentRotation: target.environmentRotation.clone()
|
|
14793
|
+
};
|
|
14794
|
+
if (background !== "only") target.environment = texture;
|
|
14795
|
+
if (background) target.background = texture;
|
|
14796
|
+
applyProps(target, sceneProps);
|
|
14797
|
+
return () => {
|
|
14798
|
+
if (background !== "only") target.environment = oldenv;
|
|
14799
|
+
if (background) target.background = oldbg;
|
|
14800
|
+
applyProps(target, oldSceneProps);
|
|
14801
|
+
};
|
|
14802
|
+
}
|
|
14803
|
+
function EnvironmentMap({ scene, background = false, map, ...config }) {
|
|
14804
|
+
const defaultScene = useThree$1((state) => state.scene);
|
|
14805
|
+
React.useLayoutEffect(() => {
|
|
14806
|
+
if (map) return setEnvProps(background, scene, defaultScene, map, config);
|
|
14807
|
+
});
|
|
14808
|
+
return null;
|
|
14809
|
+
}
|
|
14810
|
+
function EnvironmentCube({
|
|
14811
|
+
background = false,
|
|
14812
|
+
scene,
|
|
14813
|
+
blur,
|
|
14814
|
+
backgroundBlurriness,
|
|
14815
|
+
backgroundIntensity,
|
|
14816
|
+
backgroundRotation,
|
|
14817
|
+
environmentIntensity,
|
|
14818
|
+
environmentRotation,
|
|
14819
|
+
...rest
|
|
14820
|
+
}) {
|
|
14821
|
+
const texture = useEnvironment(rest);
|
|
14822
|
+
const defaultScene = useThree$1((state) => state.scene);
|
|
14823
|
+
React.useLayoutEffect(() => {
|
|
14824
|
+
return setEnvProps(background, scene, defaultScene, texture, {
|
|
14825
|
+
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
14826
|
+
backgroundIntensity,
|
|
14827
|
+
backgroundRotation,
|
|
14828
|
+
environmentIntensity,
|
|
14829
|
+
environmentRotation
|
|
14830
|
+
});
|
|
14831
|
+
});
|
|
14832
|
+
React.useEffect(() => {
|
|
14833
|
+
return () => {
|
|
14834
|
+
texture.dispose();
|
|
14835
|
+
};
|
|
14836
|
+
}, [texture]);
|
|
14837
|
+
return null;
|
|
14838
|
+
}
|
|
14839
|
+
function EnvironmentPortal({
|
|
14840
|
+
children,
|
|
14841
|
+
near = 0.1,
|
|
14842
|
+
far = 1e3,
|
|
14843
|
+
resolution = 256,
|
|
14844
|
+
frames = 1,
|
|
14845
|
+
map,
|
|
14846
|
+
background = false,
|
|
14847
|
+
blur,
|
|
14848
|
+
backgroundBlurriness,
|
|
14849
|
+
backgroundIntensity,
|
|
14850
|
+
backgroundRotation,
|
|
14851
|
+
environmentIntensity,
|
|
14852
|
+
environmentRotation,
|
|
14853
|
+
scene,
|
|
14854
|
+
files,
|
|
14855
|
+
path,
|
|
14856
|
+
preset = void 0,
|
|
14857
|
+
extensions
|
|
14858
|
+
}) {
|
|
14859
|
+
const renderer = useThree$1((state) => state.renderer);
|
|
14860
|
+
const isLegacy = useThree$1((state) => state.isLegacy);
|
|
14861
|
+
const defaultScene = useThree$1((state) => state.scene);
|
|
14862
|
+
const camera = React.useRef(null);
|
|
14863
|
+
const [virtualScene] = React.useState(() => new Scene());
|
|
14864
|
+
const fbo = React.useMemo(() => {
|
|
14865
|
+
const fbo2 = isLegacy ? new WebGLCubeRenderTarget(resolution) : new CubeRenderTarget(resolution);
|
|
14866
|
+
fbo2.texture.type = HalfFloatType;
|
|
14867
|
+
return fbo2;
|
|
14868
|
+
}, [resolution, isLegacy]);
|
|
14869
|
+
React.useEffect(() => {
|
|
14870
|
+
return () => {
|
|
14871
|
+
fbo.dispose();
|
|
14872
|
+
};
|
|
14873
|
+
}, [fbo]);
|
|
14874
|
+
React.useLayoutEffect(() => {
|
|
14875
|
+
if (frames === 1) {
|
|
14876
|
+
const autoClear = renderer.autoClear;
|
|
14877
|
+
renderer.autoClear = true;
|
|
14878
|
+
camera.current.update(renderer, virtualScene);
|
|
14879
|
+
renderer.autoClear = autoClear;
|
|
14880
|
+
}
|
|
14881
|
+
return setEnvProps(background, scene, defaultScene, fbo.texture, {
|
|
14882
|
+
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
14883
|
+
backgroundIntensity,
|
|
14884
|
+
backgroundRotation,
|
|
14885
|
+
environmentIntensity,
|
|
14886
|
+
environmentRotation
|
|
14887
|
+
});
|
|
14888
|
+
}, [
|
|
14889
|
+
children,
|
|
14890
|
+
virtualScene,
|
|
14891
|
+
fbo.texture,
|
|
14892
|
+
scene,
|
|
14893
|
+
defaultScene,
|
|
14894
|
+
background,
|
|
14895
|
+
frames,
|
|
14896
|
+
renderer,
|
|
14897
|
+
blur,
|
|
14898
|
+
backgroundBlurriness,
|
|
14899
|
+
backgroundIntensity,
|
|
14900
|
+
backgroundRotation,
|
|
14901
|
+
environmentIntensity,
|
|
14902
|
+
environmentRotation
|
|
14903
|
+
]);
|
|
14904
|
+
let count = 1;
|
|
14905
|
+
useFrame$1(() => {
|
|
14906
|
+
if (frames === Infinity || count < frames) {
|
|
14907
|
+
const autoClear = renderer.autoClear;
|
|
14908
|
+
renderer.autoClear = true;
|
|
14909
|
+
camera.current.update(renderer, virtualScene);
|
|
14910
|
+
renderer.autoClear = autoClear;
|
|
14911
|
+
count++;
|
|
14912
|
+
}
|
|
14913
|
+
});
|
|
14914
|
+
return /* @__PURE__ */ jsx(Fragment, { children: createPortal(
|
|
14915
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
14916
|
+
children,
|
|
14917
|
+
/* @__PURE__ */ jsx("cubeCamera", { ref: camera, args: [near, far, fbo] }),
|
|
14918
|
+
files || preset ? /* @__PURE__ */ jsx(EnvironmentCube, { background: true, files, preset, path, extensions }) : map ? /* @__PURE__ */ jsx(EnvironmentMap, { background: true, map, extensions }) : null
|
|
14919
|
+
] }),
|
|
14920
|
+
virtualScene
|
|
14921
|
+
) });
|
|
14922
|
+
}
|
|
14923
|
+
function EnvironmentGround(props) {
|
|
14924
|
+
const textureDefault = useEnvironment(props);
|
|
14925
|
+
const texture = props.map || textureDefault;
|
|
14926
|
+
React.useMemo(() => extend({ GroundProjectedEnvImpl: GroundedSkybox }), []);
|
|
14927
|
+
React.useEffect(() => {
|
|
14928
|
+
return () => {
|
|
14929
|
+
textureDefault.dispose();
|
|
14930
|
+
};
|
|
14931
|
+
}, [textureDefault]);
|
|
14932
|
+
const height = props.ground?.height ?? 15;
|
|
14933
|
+
const radius = props.ground?.radius ?? 60;
|
|
14934
|
+
const scale = props.ground?.scale ?? 1e3;
|
|
14935
|
+
const args = React.useMemo(
|
|
14936
|
+
() => [texture, height, radius],
|
|
14937
|
+
[texture, height, radius]
|
|
14938
|
+
);
|
|
14939
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
14940
|
+
/* @__PURE__ */ jsx(EnvironmentMap, { ...props, map: texture }),
|
|
14941
|
+
/* @__PURE__ */ jsx("groundProjectedEnvImpl", { args, scale })
|
|
14942
|
+
] });
|
|
14943
|
+
}
|
|
14944
|
+
function EnvironmentColor({ color, scene }) {
|
|
14945
|
+
const defaultScene = useThree$1((state) => state.scene);
|
|
14946
|
+
React.useLayoutEffect(() => {
|
|
14947
|
+
if (color === void 0) return;
|
|
14948
|
+
const target = resolveScene(scene || defaultScene);
|
|
14949
|
+
const oldBg = target.background;
|
|
14950
|
+
target.background = new Color(color);
|
|
14951
|
+
return () => {
|
|
14952
|
+
target.background = oldBg;
|
|
14953
|
+
};
|
|
14954
|
+
});
|
|
14955
|
+
return null;
|
|
14956
|
+
}
|
|
14957
|
+
function EnvironmentDualSource(props) {
|
|
14958
|
+
const { backgroundFiles, ...envProps } = props;
|
|
14959
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
14960
|
+
/* @__PURE__ */ jsx(EnvironmentCube, { ...envProps, background: false }),
|
|
14961
|
+
/* @__PURE__ */ jsx(EnvironmentCube, { ...props, files: backgroundFiles, background: "only" })
|
|
14962
|
+
] });
|
|
14963
|
+
}
|
|
14964
|
+
function Environment(props) {
|
|
14965
|
+
if (props.color && !props.files && !props.preset && !props.map) {
|
|
14966
|
+
return /* @__PURE__ */ jsx(EnvironmentColor, { ...props });
|
|
14967
|
+
}
|
|
14968
|
+
if (props.backgroundFiles && props.backgroundFiles !== props.files) {
|
|
14969
|
+
return /* @__PURE__ */ jsx(EnvironmentDualSource, { ...props });
|
|
14970
|
+
}
|
|
14971
|
+
return props.ground ? /* @__PURE__ */ jsx(EnvironmentGround, { ...props }) : props.map ? /* @__PURE__ */ jsx(EnvironmentMap, { ...props }) : props.children ? /* @__PURE__ */ jsx(EnvironmentPortal, { ...props }) : /* @__PURE__ */ jsx(EnvironmentCube, { ...props });
|
|
14972
|
+
}
|
|
14973
|
+
|
|
14726
14974
|
function parseBackground(background) {
|
|
14727
14975
|
if (!background) return null;
|
|
14728
14976
|
if (typeof background === "object" && !background.isColor) {
|
|
@@ -14766,38 +15014,6 @@ function parseRendererConfig(rendererProp) {
|
|
|
14766
15014
|
return { primaryCanvas: void 0, scheduler: void 0, renderer: rendererProp };
|
|
14767
15015
|
}
|
|
14768
15016
|
|
|
14769
|
-
const RESOURCE_KINDS = ["nodes", "uniforms", "buffers", "gpuStorage"];
|
|
14770
|
-
const registries = /* @__PURE__ */ new WeakMap();
|
|
14771
|
-
function getKindRegistry(store, kind) {
|
|
14772
|
-
let registry = registries.get(store);
|
|
14773
|
-
if (!registry) {
|
|
14774
|
-
registry = {
|
|
14775
|
-
nodes: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() },
|
|
14776
|
-
uniforms: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() },
|
|
14777
|
-
buffers: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() },
|
|
14778
|
-
gpuStorage: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() }
|
|
14779
|
-
};
|
|
14780
|
-
registries.set(store, registry);
|
|
14781
|
-
}
|
|
14782
|
-
return registry[kind];
|
|
14783
|
-
}
|
|
14784
|
-
function invalidateResource(store, kind, scopeKey) {
|
|
14785
|
-
const registry = getKindRegistry(store, kind);
|
|
14786
|
-
{
|
|
14787
|
-
registry.valid.clear();
|
|
14788
|
-
registry.staged.clear();
|
|
14789
|
-
}
|
|
14790
|
-
}
|
|
14791
|
-
function invalidateAllResources(store) {
|
|
14792
|
-
for (const kind of RESOURCE_KINDS) invalidateResource(store, kind);
|
|
14793
|
-
}
|
|
14794
|
-
|
|
14795
|
-
function clearHmrCaches(store) {
|
|
14796
|
-
const primary = store.getState().primaryStore ?? store;
|
|
14797
|
-
invalidateAllResources(primary);
|
|
14798
|
-
primary.setState((state) => ({ _hmrVersion: state._hmrVersion + 1 }));
|
|
14799
|
-
}
|
|
14800
|
-
|
|
14801
15017
|
function CanvasImpl({
|
|
14802
15018
|
ref,
|
|
14803
15019
|
children,
|
|
@@ -14835,9 +15051,9 @@ function CanvasImpl({
|
|
|
14835
15051
|
React.useMemo(() => extend(THREE), []);
|
|
14836
15052
|
const Bridge = useBridge();
|
|
14837
15053
|
const backgroundProps = React.useMemo(() => parseBackground(background), [background]);
|
|
14838
|
-
const
|
|
15054
|
+
const [hasInitialSize, setHasInitialSize] = React.useState(false);
|
|
14839
15055
|
const measureConfig = React.useMemo(() => {
|
|
14840
|
-
if (!
|
|
15056
|
+
if (!hasInitialSize) {
|
|
14841
15057
|
return {
|
|
14842
15058
|
...resize,
|
|
14843
15059
|
scroll: resize?.scroll ?? true,
|
|
@@ -14849,7 +15065,7 @@ function CanvasImpl({
|
|
|
14849
15065
|
debounce: { scroll: 50, resize: 0 },
|
|
14850
15066
|
...resize
|
|
14851
15067
|
};
|
|
14852
|
-
}, [
|
|
15068
|
+
}, [hasInitialSize, resize]);
|
|
14853
15069
|
const [containerRef, containerRect] = useMeasure(measureConfig);
|
|
14854
15070
|
const effectiveSize = React.useMemo(() => {
|
|
14855
15071
|
let w = width ?? containerRect.width;
|
|
@@ -14865,9 +15081,7 @@ function CanvasImpl({
|
|
|
14865
15081
|
left: containerRect.left
|
|
14866
15082
|
};
|
|
14867
15083
|
}, [width, height, containerRect, forceEven]);
|
|
14868
|
-
if (!
|
|
14869
|
-
hasInitialSizeRef.current = true;
|
|
14870
|
-
}
|
|
15084
|
+
if (!hasInitialSize && effectiveSize.width > 0 && effectiveSize.height > 0) setHasInitialSize(true);
|
|
14871
15085
|
const canvasRef = React.useRef(null);
|
|
14872
15086
|
const divRef = React.useRef(null);
|
|
14873
15087
|
React.useImperativeHandle(ref, () => canvasRef.current);
|
|
@@ -14932,7 +15146,7 @@ function CanvasImpl({
|
|
|
14932
15146
|
onDropMissed: (...args) => handleDropMissed.current?.(...args),
|
|
14933
15147
|
onCreated: (state) => {
|
|
14934
15148
|
state.events.connect?.(
|
|
14935
|
-
eventSource ? isRef(eventSource) ? eventSource.current : eventSource : divRef.current
|
|
15149
|
+
eventSource ? isRef$1(eventSource) ? eventSource.current : eventSource : divRef.current
|
|
14936
15150
|
);
|
|
14937
15151
|
if (eventPrefix) {
|
|
14938
15152
|
state.setEvents({
|
|
@@ -14981,6 +15195,7 @@ function CanvasImpl({
|
|
|
14981
15195
|
const canvas = canvasRef.current;
|
|
14982
15196
|
if (canvas) {
|
|
14983
15197
|
return () => {
|
|
15198
|
+
if (canvas.isConnected) return;
|
|
14984
15199
|
unmountComponentAtNode(canvas);
|
|
14985
15200
|
root.current = null;
|
|
14986
15201
|
};
|
|
@@ -14993,7 +15208,7 @@ function CanvasImpl({
|
|
|
14993
15208
|
const handleHMR = () => {
|
|
14994
15209
|
queueMicrotask(() => {
|
|
14995
15210
|
const rootEntry = _roots.get(canvas);
|
|
14996
|
-
if (rootEntry?.store)
|
|
15211
|
+
if (rootEntry?.store) notifyRootExtensionsHmr(rootEntry.store);
|
|
14997
15212
|
});
|
|
14998
15213
|
};
|
|
14999
15214
|
if (typeof import.meta !== "undefined" && import.meta.hot) {
|
|
@@ -15039,10 +15254,13 @@ function CanvasImpl({
|
|
|
15039
15254
|
}
|
|
15040
15255
|
);
|
|
15041
15256
|
}
|
|
15042
|
-
function Canvas(props) {
|
|
15257
|
+
function Canvas$1(props) {
|
|
15043
15258
|
return /* @__PURE__ */ jsx(FiberProvider, { children: /* @__PURE__ */ jsx(CanvasImpl, { ...props }) });
|
|
15044
15259
|
}
|
|
15045
15260
|
|
|
15046
15261
|
extend(THREE);
|
|
15262
|
+
const useThree = useThree$1;
|
|
15263
|
+
const useFrame = useFrame$1;
|
|
15264
|
+
const Canvas = Canvas$1;
|
|
15047
15265
|
|
|
15048
|
-
export { Block, Canvas, Environment, EnvironmentCube, EnvironmentMap, EnvironmentPortal, ErrorBoundary, FROM_REF, IsObject, ONCE, Portal, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, Texture, _roots,
|
|
15266
|
+
export { Block, Canvas, Environment, EnvironmentCube, EnvironmentMap, EnvironmentPortal, ErrorBoundary, FROM_REF, IsObject, ONCE, Portal, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, Texture, _roots, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, context, createEvents, createPointerEvents, createPortal, createRoot, createStore, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, fromRef, getInstanceProps, getPrimary, getPrimaryIds, getRootState, getUuidPrefix, hasConstructor, hasPrimary, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isFromRef, isObject3D, isOnce, isOrthographicCamera, isRef$1 as isRef, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, reconciler, registerPrimary, registerRootExtension, removeInteractivity, resolve, setRenderOverride, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useEnvironment, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useRenderTarget, useStore, useTexture, useTextures, useThree, waitForPrimary };
|