@react-three/fiber 10.0.0-canary.0706a92 → 10.0.0-canary.07c4f9d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1799 -1583
- package/dist/index.d.cts +110 -38
- package/dist/index.d.mts +110 -38
- package/dist/index.d.ts +110 -38
- package/dist/index.mjs +1802 -1586
- package/dist/legacy.cjs +2264 -2053
- package/dist/legacy.d.cts +109 -40
- package/dist/legacy.d.mts +109 -40
- package/dist/legacy.d.ts +109 -40
- package/dist/legacy.mjs +2266 -2055
- package/dist/webgpu/index.cjs +2131 -2132
- package/dist/webgpu/index.d.cts +147 -90
- package/dist/webgpu/index.d.mts +147 -90
- package/dist/webgpu/index.d.ts +147 -90
- package/dist/webgpu/index.mjs +2527 -2528
- package/package.json +6 -6
- package/readme.md +1 -2
- package/react-reconciler/constants.d.ts +0 -7
- package/react-reconciler/constants.js +0 -1
- package/react-reconciler/index.d.ts +0 -1044
- package/react-reconciler/index.js +0 -208
package/dist/index.mjs
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import * as webgpu from 'three/webgpu';
|
|
2
|
-
import {
|
|
3
|
-
import { WebGLRenderTarget, WebGLRenderer } from 'three';
|
|
4
|
-
import { Inspector } from 'three/addons/inspector/Inspector.js';
|
|
2
|
+
import { CubeRenderTarget, RenderTarget, Frustum, Matrix4, Group, BoxGeometry, MeshBasicNodeMaterial, Mesh, Node, NodeUpdateType, Layers, ShaderMaterial, Uniform, SRGBColorSpace, RGBAFormat, UnsignedByteType, Vector3, Vector2, TextureLoader, Texture as Texture$1, CubeReflectionMapping, EquirectangularReflectionMapping, CubeTextureLoader, CanvasTarget, Raycaster, OrthographicCamera, PerspectiveCamera, Scene, PCFShadowMap, VSMShadowMap, BasicShadowMap, ACESFilmicToneMapping, WebGPURenderer, HalfFloatType, Color } from 'three/webgpu';
|
|
3
|
+
import { WebGLCubeRenderTarget, WebGLRenderTarget, WebGLRenderer } from 'three';
|
|
5
4
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
6
5
|
import * as React from 'react';
|
|
7
|
-
import React__default, {
|
|
6
|
+
import React__default, { useRef, useMemo, useLayoutEffect, useEffect, useContext, useImperativeHandle, useCallback, useState } from 'react';
|
|
8
7
|
import useMeasure from 'react-use-measure';
|
|
9
8
|
import { useFiber, useContextBridge, traverseFiber, FiberProvider } from 'its-fine';
|
|
10
|
-
import {
|
|
9
|
+
import { createWithEqualityFn } from 'zustand/traditional';
|
|
10
|
+
import { getScheduler } from '@pmndrs/scheduler';
|
|
11
|
+
export { Scheduler, getScheduler } from '@pmndrs/scheduler';
|
|
12
|
+
import Tb, { unstable_getCurrentPriorityLevel, unstable_IdlePriority, unstable_LowPriority, unstable_NormalPriority, unstable_UserBlockingPriority, unstable_ImmediatePriority, unstable_scheduleCallback } from 'scheduler';
|
|
11
13
|
import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
|
|
12
14
|
import { HDRLoader } from 'three/examples/jsm/loaders/HDRLoader.js';
|
|
13
15
|
import { EXRLoader } from 'three/examples/jsm/loaders/EXRLoader.js';
|
|
14
16
|
import { UltraHDRLoader } from 'three/examples/jsm/loaders/UltraHDRLoader.js';
|
|
15
17
|
import { GainMapLoader } from '@monogrid/gainmap-js';
|
|
16
|
-
import Tb, { unstable_scheduleCallback, unstable_IdlePriority } from 'scheduler';
|
|
17
|
-
import { createWithEqualityFn } from 'zustand/traditional';
|
|
18
|
-
import { getScheduler } from '@pmndrs/scheduler';
|
|
19
|
-
export { Scheduler, getScheduler } from '@pmndrs/scheduler';
|
|
20
18
|
import { suspend, preload, clear } from 'suspend-react';
|
|
21
19
|
|
|
22
20
|
function _mergeNamespaces(n, m) {
|
|
@@ -33,15 +31,22 @@ function _mergeNamespaces(n, m) {
|
|
|
33
31
|
|
|
34
32
|
const R3F_BUILD_LEGACY = true;
|
|
35
33
|
const R3F_BUILD_WEBGPU = true;
|
|
34
|
+
async function loadInspector() {
|
|
35
|
+
const { Inspector } = await import('three/addons/inspector/Inspector.js');
|
|
36
|
+
return Inspector;
|
|
37
|
+
}
|
|
36
38
|
|
|
37
39
|
const THREE = /*#__PURE__*/_mergeNamespaces({
|
|
38
40
|
__proto__: null,
|
|
39
|
-
|
|
41
|
+
CubeRenderTarget: CubeRenderTarget,
|
|
42
|
+
CubeRenderTargetCompat: CubeRenderTarget,
|
|
40
43
|
R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
|
|
41
44
|
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
42
45
|
RenderTargetCompat: RenderTarget,
|
|
46
|
+
WebGLCubeRenderTarget: WebGLCubeRenderTarget,
|
|
43
47
|
WebGLRenderTarget: WebGLRenderTarget,
|
|
44
|
-
WebGLRenderer: WebGLRenderer
|
|
48
|
+
WebGLRenderer: WebGLRenderer,
|
|
49
|
+
loadInspector: loadInspector
|
|
45
50
|
}, [webgpu]);
|
|
46
51
|
|
|
47
52
|
const primaryRegistry = /* @__PURE__ */ new Map();
|
|
@@ -102,549 +107,223 @@ function getPrimaryIds() {
|
|
|
102
107
|
return Array.from(primaryRegistry.keys());
|
|
103
108
|
}
|
|
104
109
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
110
|
+
var __defProp = Object.defineProperty;
|
|
111
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
112
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
113
|
+
const useIsomorphicLayoutEffect = /* @__PURE__ */ (() => typeof window !== "undefined" && (window.document?.createElement || window.navigator?.product === "ReactNative"))() ? React.useLayoutEffect : React.useEffect;
|
|
114
|
+
function useMutableCallback(fn) {
|
|
115
|
+
const ref = React.useRef(fn);
|
|
116
|
+
useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
|
|
117
|
+
return ref;
|
|
118
|
+
}
|
|
119
|
+
function useBridge() {
|
|
120
|
+
const fiber = useFiber();
|
|
121
|
+
const ContextBridge = useContextBridge();
|
|
122
|
+
return React.useMemo(
|
|
123
|
+
() => ({ children }) => {
|
|
124
|
+
const strict = !!traverseFiber(fiber, true, (node) => node.type === React.StrictMode);
|
|
125
|
+
const Root = strict ? React.StrictMode : React.Fragment;
|
|
126
|
+
return /* @__PURE__ */ jsx(Root, { children: /* @__PURE__ */ jsx(ContextBridge, { children }) });
|
|
127
|
+
},
|
|
128
|
+
[fiber, ContextBridge]
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
function Block({ set }) {
|
|
132
|
+
useIsomorphicLayoutEffect(() => {
|
|
133
|
+
set(new Promise(() => null));
|
|
134
|
+
return () => set(false);
|
|
135
|
+
}, [set]);
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
const ErrorBoundary = /* @__PURE__ */ (() => {
|
|
139
|
+
var _a;
|
|
140
|
+
return _a = class extends React.Component {
|
|
141
|
+
constructor() {
|
|
142
|
+
super(...arguments);
|
|
143
|
+
__publicField(this, "state", { error: false });
|
|
144
|
+
}
|
|
145
|
+
componentDidCatch(err) {
|
|
146
|
+
this.props.set(err);
|
|
147
|
+
}
|
|
148
|
+
render() {
|
|
149
|
+
return this.state.error ? null : this.props.children;
|
|
150
|
+
}
|
|
151
|
+
}, __publicField(_a, "getDerivedStateFromError", () => ({ error: true })), _a;
|
|
152
|
+
})();
|
|
117
153
|
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
} = {}) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
useLoader$1.clear(loader, multiFile ? [files] : files);
|
|
154
|
+
const is = {
|
|
155
|
+
obj: (a) => a === Object(a) && !is.arr(a) && typeof a !== "function",
|
|
156
|
+
fun: (a) => typeof a === "function",
|
|
157
|
+
str: (a) => typeof a === "string",
|
|
158
|
+
num: (a) => typeof a === "number",
|
|
159
|
+
boo: (a) => typeof a === "boolean",
|
|
160
|
+
und: (a) => a === void 0,
|
|
161
|
+
nul: (a) => a === null,
|
|
162
|
+
arr: (a) => Array.isArray(a),
|
|
163
|
+
equ(a, b, { arrays = "shallow", objects = "reference", strict = true } = {}) {
|
|
164
|
+
if (typeof a !== typeof b || !!a !== !!b) return false;
|
|
165
|
+
if (is.str(a) || is.num(a) || is.boo(a)) return a === b;
|
|
166
|
+
const isObj = is.obj(a);
|
|
167
|
+
if (isObj && objects === "reference") return a === b;
|
|
168
|
+
const isArr = is.arr(a);
|
|
169
|
+
if (isArr && arrays === "reference") return a === b;
|
|
170
|
+
if ((isArr || isObj) && a === b) return true;
|
|
171
|
+
let i;
|
|
172
|
+
for (i in a) if (!(i in b)) return false;
|
|
173
|
+
if (isObj && arrays === "shallow" && objects === "shallow") {
|
|
174
|
+
for (i in strict ? b : a) if (!is.equ(a[i], b[i], { strict, objects: "reference" })) return false;
|
|
175
|
+
} else {
|
|
176
|
+
for (i in strict ? b : a) if (a[i] !== b[i]) return false;
|
|
142
177
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
multiFile ? [files] : files,
|
|
148
|
-
(loader2) => {
|
|
149
|
-
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
150
|
-
loader2.setRenderer?.(renderer);
|
|
151
|
-
}
|
|
152
|
-
loader2.setPath?.(path);
|
|
153
|
-
if (extensions) extensions(loader2);
|
|
178
|
+
if (is.und(i)) {
|
|
179
|
+
if (isArr && a.length === 0 && b.length === 0) return true;
|
|
180
|
+
if (isObj && Object.keys(a).length === 0 && Object.keys(b).length === 0) return true;
|
|
181
|
+
if (a !== b) return false;
|
|
154
182
|
}
|
|
155
|
-
|
|
156
|
-
let texture = multiFile ? (
|
|
157
|
-
// @ts-ignore
|
|
158
|
-
loaderResult[0]
|
|
159
|
-
) : loaderResult;
|
|
160
|
-
if (extension === "jpg" || extension === "jpeg" || extension === "webp") {
|
|
161
|
-
texture = texture.renderTarget?.texture;
|
|
162
|
-
}
|
|
163
|
-
texture.mapping = isCubemap ? CubeReflectionMapping : EquirectangularReflectionMapping;
|
|
164
|
-
texture.colorSpace = colorSpace ?? (isCubemap ? "srgb" : "srgb-linear");
|
|
165
|
-
return texture;
|
|
166
|
-
}
|
|
167
|
-
const preloadDefaultOptions = {
|
|
168
|
-
files: defaultFiles,
|
|
169
|
-
path: "",
|
|
170
|
-
preset: void 0,
|
|
171
|
-
extensions: void 0
|
|
172
|
-
};
|
|
173
|
-
useEnvironment.preload = (preloadOptions) => {
|
|
174
|
-
const options = { ...preloadDefaultOptions, ...preloadOptions };
|
|
175
|
-
let { files, path = "" } = options;
|
|
176
|
-
const { preset, extensions } = options;
|
|
177
|
-
if (preset) {
|
|
178
|
-
validatePreset(preset);
|
|
179
|
-
files = presetsObj[preset];
|
|
180
|
-
path = CUBEMAP_ROOT;
|
|
181
|
-
}
|
|
182
|
-
const { extension } = getExtension(files);
|
|
183
|
-
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
184
|
-
throw new Error("useEnvironment: Preloading gainmaps is not supported");
|
|
185
|
-
}
|
|
186
|
-
const loader = getLoader$1(extension);
|
|
187
|
-
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
188
|
-
useLoader$1.preload(loader, isArray(files) ? [files] : files, (loader2) => {
|
|
189
|
-
loader2.setPath?.(path);
|
|
190
|
-
if (extensions) extensions(loader2);
|
|
191
|
-
});
|
|
192
|
-
};
|
|
193
|
-
const clearDefaultOptins = {
|
|
194
|
-
files: defaultFiles,
|
|
195
|
-
preset: void 0
|
|
196
|
-
};
|
|
197
|
-
useEnvironment.clear = (clearOptions) => {
|
|
198
|
-
const options = { ...clearDefaultOptins, ...clearOptions };
|
|
199
|
-
let { files } = options;
|
|
200
|
-
const { preset } = options;
|
|
201
|
-
if (preset) {
|
|
202
|
-
validatePreset(preset);
|
|
203
|
-
files = presetsObj[preset];
|
|
183
|
+
return true;
|
|
204
184
|
}
|
|
205
|
-
const { extension } = getExtension(files);
|
|
206
|
-
const loader = getLoader$1(extension);
|
|
207
|
-
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
208
|
-
useLoader$1.clear(loader, isArray(files) ? [files] : files);
|
|
209
185
|
};
|
|
210
|
-
|
|
211
|
-
|
|
186
|
+
const isOrthographicCamera = (def) => def && def.isOrthographicCamera;
|
|
187
|
+
const isRef$1 = (obj) => obj !== null && typeof obj === "object" && obj.hasOwnProperty("current");
|
|
188
|
+
const isColorRepresentation = (value) => value != null && (typeof value === "string" || typeof value === "number" || value.isColor);
|
|
189
|
+
const isObject3D = (object) => object?.isObject3D;
|
|
190
|
+
const isTexture = (value) => !!value?.isTexture;
|
|
191
|
+
const isVectorLike = (object) => object !== null && typeof object === "object" && "set" in object && typeof object.set === "function";
|
|
192
|
+
const isCopyable = (object) => isVectorLike(object) && "copy" in object && typeof object.copy === "function";
|
|
193
|
+
const hasConstructor = (object) => !!object?.constructor;
|
|
194
|
+
|
|
195
|
+
function calculateDpr(dpr) {
|
|
196
|
+
const target = typeof window !== "undefined" ? window.devicePixelRatio ?? 2 : 1;
|
|
197
|
+
return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
|
|
212
198
|
}
|
|
213
|
-
function
|
|
214
|
-
|
|
215
|
-
const isGainmap = isArray(files) && files.length === 3 && files.some((file) => file.endsWith("json"));
|
|
216
|
-
const firstEntry = isArray(files) ? files[0] : files;
|
|
217
|
-
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();
|
|
218
|
-
return { extension, isCubemap, isGainmap };
|
|
199
|
+
function getUuidPrefix(uuid) {
|
|
200
|
+
return uuid.split("-")[0];
|
|
219
201
|
}
|
|
220
|
-
function
|
|
221
|
-
|
|
222
|
-
|
|
202
|
+
function updateCamera(camera, size) {
|
|
203
|
+
if (camera.manual) return;
|
|
204
|
+
if (isOrthographicCamera(camera)) {
|
|
205
|
+
camera.left = size.width / -2;
|
|
206
|
+
camera.right = size.width / 2;
|
|
207
|
+
camera.top = size.height / 2;
|
|
208
|
+
camera.bottom = size.height / -2;
|
|
209
|
+
} else {
|
|
210
|
+
camera.aspect = size.width / size.height;
|
|
211
|
+
}
|
|
212
|
+
camera.updateProjectionMatrix();
|
|
223
213
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
backgroundIntensity: 1,
|
|
231
|
-
backgroundRotation: [0, 0, 0],
|
|
232
|
-
environmentIntensity: 1,
|
|
233
|
-
environmentRotation: [0, 0, 0],
|
|
234
|
-
...sceneProps
|
|
235
|
-
};
|
|
236
|
-
const target = resolveScene(scene || defaultScene);
|
|
237
|
-
const oldbg = target.background;
|
|
238
|
-
const oldenv = target.environment;
|
|
239
|
-
const oldSceneProps = {
|
|
240
|
-
// @ts-ignore
|
|
241
|
-
backgroundBlurriness: target.backgroundBlurriness,
|
|
242
|
-
// @ts-ignore
|
|
243
|
-
backgroundIntensity: target.backgroundIntensity,
|
|
244
|
-
// @ts-ignore
|
|
245
|
-
backgroundRotation: target.backgroundRotation?.clone?.() ?? [0, 0, 0],
|
|
246
|
-
// @ts-ignore
|
|
247
|
-
environmentIntensity: target.environmentIntensity,
|
|
248
|
-
// @ts-ignore
|
|
249
|
-
environmentRotation: target.environmentRotation?.clone?.() ?? [0, 0, 0]
|
|
250
|
-
};
|
|
251
|
-
if (background !== "only") target.environment = texture;
|
|
252
|
-
if (background) target.background = texture;
|
|
253
|
-
applyProps$1(target, sceneProps);
|
|
254
|
-
return () => {
|
|
255
|
-
if (background !== "only") target.environment = oldenv;
|
|
256
|
-
if (background) target.background = oldbg;
|
|
257
|
-
applyProps$1(target, oldSceneProps);
|
|
258
|
-
};
|
|
214
|
+
const frustumMatrix = new Matrix4();
|
|
215
|
+
function updateFrustum(camera, frustum) {
|
|
216
|
+
const target = frustum ?? new Frustum();
|
|
217
|
+
frustumMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
218
|
+
target.setFromProjectionMatrix(frustumMatrix);
|
|
219
|
+
return target;
|
|
259
220
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
return
|
|
221
|
+
|
|
222
|
+
const REACT_INTERNAL_PROPS = ["children", "key", "ref"];
|
|
223
|
+
function findInitialRoot(instance) {
|
|
224
|
+
let root = instance.root;
|
|
225
|
+
while (root.getState().previousRoot) root = root.getState().previousRoot;
|
|
226
|
+
return root;
|
|
266
227
|
}
|
|
267
|
-
function
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
...rest
|
|
277
|
-
}) {
|
|
278
|
-
const texture = useEnvironment(rest);
|
|
279
|
-
const defaultScene = useThree$1((state) => state.scene);
|
|
280
|
-
React.useLayoutEffect(() => {
|
|
281
|
-
return setEnvProps(background, scene, defaultScene, texture, {
|
|
282
|
-
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
283
|
-
backgroundIntensity,
|
|
284
|
-
backgroundRotation,
|
|
285
|
-
environmentIntensity,
|
|
286
|
-
environmentRotation
|
|
228
|
+
function getRootState(obj) {
|
|
229
|
+
let state = obj.__r3f?.root.getState();
|
|
230
|
+
if (!state) {
|
|
231
|
+
obj.traverseAncestors((ancestor) => {
|
|
232
|
+
const parentState = ancestor.__r3f?.root.getState();
|
|
233
|
+
if (parentState) {
|
|
234
|
+
state = parentState;
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
287
237
|
});
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
return () => {
|
|
291
|
-
texture.dispose();
|
|
292
|
-
};
|
|
293
|
-
}, [texture]);
|
|
294
|
-
return null;
|
|
238
|
+
}
|
|
239
|
+
return state;
|
|
295
240
|
}
|
|
296
|
-
function
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
path,
|
|
313
|
-
preset = void 0,
|
|
314
|
-
extensions
|
|
315
|
-
}) {
|
|
316
|
-
const gl = useThree$1((state) => state.gl);
|
|
317
|
-
const defaultScene = useThree$1((state) => state.scene);
|
|
318
|
-
const camera = React.useRef(null);
|
|
319
|
-
const [virtualScene] = React.useState(() => new Scene());
|
|
320
|
-
const fbo = React.useMemo(() => {
|
|
321
|
-
const fbo2 = new WebGLCubeRenderTarget(resolution);
|
|
322
|
-
fbo2.texture.type = HalfFloatType;
|
|
323
|
-
return fbo2;
|
|
324
|
-
}, [resolution]);
|
|
325
|
-
React.useEffect(() => {
|
|
326
|
-
return () => {
|
|
327
|
-
fbo.dispose();
|
|
328
|
-
};
|
|
329
|
-
}, [fbo]);
|
|
330
|
-
React.useLayoutEffect(() => {
|
|
331
|
-
if (frames === 1) {
|
|
332
|
-
const autoClear = gl.autoClear;
|
|
333
|
-
gl.autoClear = true;
|
|
334
|
-
camera.current.update(gl, virtualScene);
|
|
335
|
-
gl.autoClear = autoClear;
|
|
336
|
-
}
|
|
337
|
-
return setEnvProps(background, scene, defaultScene, fbo.texture, {
|
|
338
|
-
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
339
|
-
backgroundIntensity,
|
|
340
|
-
backgroundRotation,
|
|
341
|
-
environmentIntensity,
|
|
342
|
-
environmentRotation
|
|
241
|
+
function buildGraph(object) {
|
|
242
|
+
const data = { nodes: {}, materials: {}, meshes: {} };
|
|
243
|
+
if (object) {
|
|
244
|
+
object.traverse((obj) => {
|
|
245
|
+
if (obj.name) data.nodes[obj.name] = obj;
|
|
246
|
+
if (obj.material) {
|
|
247
|
+
const material = Array.isArray(obj.material) ? obj.material[0] : obj.material;
|
|
248
|
+
const nameAlreadyUsed = data.materials[material.name];
|
|
249
|
+
let materialName = material.name;
|
|
250
|
+
if (nameAlreadyUsed) {
|
|
251
|
+
materialName = materialName + `-${getUuidPrefix(material.uuid)}`;
|
|
252
|
+
material.userData.materialCacheName = materialName;
|
|
253
|
+
}
|
|
254
|
+
data.materials[materialName] = material;
|
|
255
|
+
}
|
|
256
|
+
if (obj.isMesh && !data.meshes[obj.name]) data.meshes[obj.name] = obj;
|
|
343
257
|
});
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
virtualScene,
|
|
347
|
-
fbo.texture,
|
|
348
|
-
scene,
|
|
349
|
-
defaultScene,
|
|
350
|
-
background,
|
|
351
|
-
frames,
|
|
352
|
-
gl,
|
|
353
|
-
blur,
|
|
354
|
-
backgroundBlurriness,
|
|
355
|
-
backgroundIntensity,
|
|
356
|
-
backgroundRotation,
|
|
357
|
-
environmentIntensity,
|
|
358
|
-
environmentRotation
|
|
359
|
-
]);
|
|
360
|
-
let count = 1;
|
|
361
|
-
useFrame$1(() => {
|
|
362
|
-
if (frames === Infinity || count < frames) {
|
|
363
|
-
const autoClear = gl.autoClear;
|
|
364
|
-
gl.autoClear = true;
|
|
365
|
-
camera.current.update(gl, virtualScene);
|
|
366
|
-
gl.autoClear = autoClear;
|
|
367
|
-
count++;
|
|
368
|
-
}
|
|
369
|
-
});
|
|
370
|
-
return /* @__PURE__ */ jsx(Fragment, { children: createPortal$1(
|
|
371
|
-
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
372
|
-
children,
|
|
373
|
-
/* @__PURE__ */ jsx("cubeCamera", { ref: camera, args: [near, far, fbo] }),
|
|
374
|
-
files || preset ? /* @__PURE__ */ jsx(EnvironmentCube, { background: true, files, preset, path, extensions }) : map ? /* @__PURE__ */ jsx(EnvironmentMap, { background: true, map, extensions }) : null
|
|
375
|
-
] }),
|
|
376
|
-
virtualScene
|
|
377
|
-
) });
|
|
378
|
-
}
|
|
379
|
-
function EnvironmentGround(props) {
|
|
380
|
-
const textureDefault = useEnvironment(props);
|
|
381
|
-
const texture = props.map || textureDefault;
|
|
382
|
-
React.useMemo(() => extend$1({ GroundProjectedEnvImpl: GroundedSkybox }), []);
|
|
383
|
-
React.useEffect(() => {
|
|
384
|
-
return () => {
|
|
385
|
-
textureDefault.dispose();
|
|
386
|
-
};
|
|
387
|
-
}, [textureDefault]);
|
|
388
|
-
const height = props.ground?.height ?? 15;
|
|
389
|
-
const radius = props.ground?.radius ?? 60;
|
|
390
|
-
const scale = props.ground?.scale ?? 1e3;
|
|
391
|
-
const args = React.useMemo(
|
|
392
|
-
() => [texture, height, radius],
|
|
393
|
-
[texture, height, radius]
|
|
394
|
-
);
|
|
395
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
396
|
-
/* @__PURE__ */ jsx(EnvironmentMap, { ...props, map: texture }),
|
|
397
|
-
/* @__PURE__ */ jsx("groundProjectedEnvImpl", { args, scale })
|
|
398
|
-
] });
|
|
399
|
-
}
|
|
400
|
-
function EnvironmentColor({ color, scene }) {
|
|
401
|
-
const defaultScene = useThree$1((state) => state.scene);
|
|
402
|
-
React.useLayoutEffect(() => {
|
|
403
|
-
if (color === void 0) return;
|
|
404
|
-
const target = resolveScene(scene || defaultScene);
|
|
405
|
-
const oldBg = target.background;
|
|
406
|
-
target.background = new Color(color);
|
|
407
|
-
return () => {
|
|
408
|
-
target.background = oldBg;
|
|
409
|
-
};
|
|
410
|
-
});
|
|
411
|
-
return null;
|
|
412
|
-
}
|
|
413
|
-
function EnvironmentDualSource(props) {
|
|
414
|
-
const { backgroundFiles, ...envProps } = props;
|
|
415
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
416
|
-
/* @__PURE__ */ jsx(EnvironmentCube, { ...envProps, background: false }),
|
|
417
|
-
/* @__PURE__ */ jsx(EnvironmentCube, { ...props, files: backgroundFiles, background: "only" })
|
|
418
|
-
] });
|
|
258
|
+
}
|
|
259
|
+
return data;
|
|
419
260
|
}
|
|
420
|
-
function
|
|
421
|
-
if (
|
|
422
|
-
|
|
261
|
+
function dispose(obj) {
|
|
262
|
+
if (obj.type !== "Scene") obj.dispose?.();
|
|
263
|
+
for (const p in obj) {
|
|
264
|
+
const prop = obj[p];
|
|
265
|
+
if (prop?.type !== "Scene") prop?.dispose?.();
|
|
423
266
|
}
|
|
424
|
-
|
|
425
|
-
|
|
267
|
+
}
|
|
268
|
+
function getInstanceProps(pendingProps) {
|
|
269
|
+
const props = {};
|
|
270
|
+
for (const key in pendingProps) {
|
|
271
|
+
if (!REACT_INTERNAL_PROPS.includes(key)) props[key] = pendingProps[key];
|
|
426
272
|
}
|
|
427
|
-
return props
|
|
273
|
+
return props;
|
|
428
274
|
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
275
|
+
function prepare(target, root, type, props) {
|
|
276
|
+
const object = target;
|
|
277
|
+
let instance = object?.__r3f;
|
|
278
|
+
if (!instance) {
|
|
279
|
+
instance = {
|
|
280
|
+
root,
|
|
281
|
+
type,
|
|
282
|
+
parent: null,
|
|
283
|
+
children: [],
|
|
284
|
+
props: getInstanceProps(props),
|
|
285
|
+
object,
|
|
286
|
+
eventCount: 0,
|
|
287
|
+
handlers: {},
|
|
288
|
+
isHidden: false
|
|
289
|
+
};
|
|
290
|
+
if (object) object.__r3f = instance;
|
|
291
|
+
}
|
|
292
|
+
return instance;
|
|
439
293
|
}
|
|
440
|
-
function
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
const strict = !!traverseFiber(fiber, true, (node) => node.type === React.StrictMode);
|
|
446
|
-
const Root = strict ? React.StrictMode : React.Fragment;
|
|
447
|
-
return /* @__PURE__ */ jsx(Root, { children: /* @__PURE__ */ jsx(ContextBridge, { children }) });
|
|
448
|
-
},
|
|
449
|
-
[fiber, ContextBridge]
|
|
450
|
-
);
|
|
294
|
+
function invalidateInstance(instance) {
|
|
295
|
+
if (!instance.parent) return;
|
|
296
|
+
instance.props.onUpdate?.(instance.object);
|
|
297
|
+
const state = instance.root?.getState?.();
|
|
298
|
+
if (state && state.internal.frames === 0) state.invalidate();
|
|
451
299
|
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
return
|
|
300
|
+
|
|
301
|
+
const tempFrustum = new Frustum();
|
|
302
|
+
let hasWarnedWebGL = false;
|
|
303
|
+
let tslModule = null;
|
|
304
|
+
async function loadTSL() {
|
|
305
|
+
if (tslModule) return tslModule;
|
|
306
|
+
try {
|
|
307
|
+
const tsl = await import('three/tsl');
|
|
308
|
+
tslModule = { uniform: tsl.uniform, nodeObject: tsl.nodeObject };
|
|
309
|
+
return tslModule;
|
|
310
|
+
} catch {
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
458
313
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
}, __publicField(_a, "getDerivedStateFromError", () => ({ error: true })), _a;
|
|
473
|
-
})();
|
|
474
|
-
|
|
475
|
-
const is = {
|
|
476
|
-
obj: (a) => a === Object(a) && !is.arr(a) && typeof a !== "function",
|
|
477
|
-
fun: (a) => typeof a === "function",
|
|
478
|
-
str: (a) => typeof a === "string",
|
|
479
|
-
num: (a) => typeof a === "number",
|
|
480
|
-
boo: (a) => typeof a === "boolean",
|
|
481
|
-
und: (a) => a === void 0,
|
|
482
|
-
nul: (a) => a === null,
|
|
483
|
-
arr: (a) => Array.isArray(a),
|
|
484
|
-
equ(a, b, { arrays = "shallow", objects = "reference", strict = true } = {}) {
|
|
485
|
-
if (typeof a !== typeof b || !!a !== !!b) return false;
|
|
486
|
-
if (is.str(a) || is.num(a) || is.boo(a)) return a === b;
|
|
487
|
-
const isObj = is.obj(a);
|
|
488
|
-
if (isObj && objects === "reference") return a === b;
|
|
489
|
-
const isArr = is.arr(a);
|
|
490
|
-
if (isArr && arrays === "reference") return a === b;
|
|
491
|
-
if ((isArr || isObj) && a === b) return true;
|
|
492
|
-
let i;
|
|
493
|
-
for (i in a) if (!(i in b)) return false;
|
|
494
|
-
if (isObj && arrays === "shallow" && objects === "shallow") {
|
|
495
|
-
for (i in strict ? b : a) if (!is.equ(a[i], b[i], { strict, objects: "reference" })) return false;
|
|
496
|
-
} else {
|
|
497
|
-
for (i in strict ? b : a) if (a[i] !== b[i]) return false;
|
|
498
|
-
}
|
|
499
|
-
if (is.und(i)) {
|
|
500
|
-
if (isArr && a.length === 0 && b.length === 0) return true;
|
|
501
|
-
if (isObj && Object.keys(a).length === 0 && Object.keys(b).length === 0) return true;
|
|
502
|
-
if (a !== b) return false;
|
|
503
|
-
}
|
|
504
|
-
return true;
|
|
505
|
-
}
|
|
506
|
-
};
|
|
507
|
-
const isOrthographicCamera = (def) => def && def.isOrthographicCamera;
|
|
508
|
-
const isRef = (obj) => obj !== null && typeof obj === "object" && obj.hasOwnProperty("current");
|
|
509
|
-
const isColorRepresentation = (value) => value != null && (typeof value === "string" || typeof value === "number" || value.isColor);
|
|
510
|
-
const isObject3D = (object) => object?.isObject3D;
|
|
511
|
-
const isTexture = (value) => !!value?.isTexture;
|
|
512
|
-
const isVectorLike = (object) => object !== null && typeof object === "object" && "set" in object && typeof object.set === "function";
|
|
513
|
-
const isCopyable = (object) => isVectorLike(object) && "copy" in object && typeof object.copy === "function";
|
|
514
|
-
const hasConstructor = (object) => !!object?.constructor;
|
|
515
|
-
|
|
516
|
-
function calculateDpr(dpr) {
|
|
517
|
-
const target = typeof window !== "undefined" ? window.devicePixelRatio ?? 2 : 1;
|
|
518
|
-
return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
|
|
519
|
-
}
|
|
520
|
-
function getUuidPrefix(uuid) {
|
|
521
|
-
return uuid.split("-")[0];
|
|
522
|
-
}
|
|
523
|
-
function updateCamera(camera, size) {
|
|
524
|
-
if (camera.manual) return;
|
|
525
|
-
if (isOrthographicCamera(camera)) {
|
|
526
|
-
camera.left = size.width / -2;
|
|
527
|
-
camera.right = size.width / 2;
|
|
528
|
-
camera.top = size.height / 2;
|
|
529
|
-
camera.bottom = size.height / -2;
|
|
530
|
-
} else {
|
|
531
|
-
camera.aspect = size.width / size.height;
|
|
532
|
-
}
|
|
533
|
-
camera.updateProjectionMatrix();
|
|
534
|
-
}
|
|
535
|
-
const frustumMatrix = new Matrix4();
|
|
536
|
-
function updateFrustum(camera, frustum) {
|
|
537
|
-
const target = frustum ?? new Frustum();
|
|
538
|
-
frustumMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
539
|
-
target.setFromProjectionMatrix(frustumMatrix);
|
|
540
|
-
return target;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
const REACT_INTERNAL_PROPS = ["children", "key", "ref"];
|
|
544
|
-
function findInitialRoot(instance) {
|
|
545
|
-
let root = instance.root;
|
|
546
|
-
while (root.getState().previousRoot) root = root.getState().previousRoot;
|
|
547
|
-
return root;
|
|
548
|
-
}
|
|
549
|
-
function getRootState(obj) {
|
|
550
|
-
let state = obj.__r3f?.root.getState();
|
|
551
|
-
if (!state) {
|
|
552
|
-
obj.traverseAncestors((ancestor) => {
|
|
553
|
-
const parentState = ancestor.__r3f?.root.getState();
|
|
554
|
-
if (parentState) {
|
|
555
|
-
state = parentState;
|
|
556
|
-
return false;
|
|
557
|
-
}
|
|
558
|
-
});
|
|
559
|
-
}
|
|
560
|
-
return state;
|
|
561
|
-
}
|
|
562
|
-
function buildGraph(object) {
|
|
563
|
-
const data = { nodes: {}, materials: {}, meshes: {} };
|
|
564
|
-
if (object) {
|
|
565
|
-
object.traverse((obj) => {
|
|
566
|
-
if (obj.name) data.nodes[obj.name] = obj;
|
|
567
|
-
if (obj.material) {
|
|
568
|
-
const material = Array.isArray(obj.material) ? obj.material[0] : obj.material;
|
|
569
|
-
const nameAlreadyUsed = data.materials[material.name];
|
|
570
|
-
let materialName = material.name;
|
|
571
|
-
if (nameAlreadyUsed) {
|
|
572
|
-
materialName = materialName + `-${getUuidPrefix(material.uuid)}`;
|
|
573
|
-
material.userData.materialCacheName = materialName;
|
|
574
|
-
}
|
|
575
|
-
data.materials[materialName] = material;
|
|
576
|
-
}
|
|
577
|
-
if (obj.isMesh && !data.meshes[obj.name]) data.meshes[obj.name] = obj;
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
return data;
|
|
581
|
-
}
|
|
582
|
-
function dispose(obj) {
|
|
583
|
-
if (obj.type !== "Scene") obj.dispose?.();
|
|
584
|
-
for (const p in obj) {
|
|
585
|
-
const prop = obj[p];
|
|
586
|
-
if (prop?.type !== "Scene") prop?.dispose?.();
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
function getInstanceProps(pendingProps) {
|
|
590
|
-
const props = {};
|
|
591
|
-
for (const key in pendingProps) {
|
|
592
|
-
if (!REACT_INTERNAL_PROPS.includes(key)) props[key] = pendingProps[key];
|
|
593
|
-
}
|
|
594
|
-
return props;
|
|
595
|
-
}
|
|
596
|
-
function prepare(target, root, type, props) {
|
|
597
|
-
const object = target;
|
|
598
|
-
let instance = object?.__r3f;
|
|
599
|
-
if (!instance) {
|
|
600
|
-
instance = {
|
|
601
|
-
root,
|
|
602
|
-
type,
|
|
603
|
-
parent: null,
|
|
604
|
-
children: [],
|
|
605
|
-
props: getInstanceProps(props),
|
|
606
|
-
object,
|
|
607
|
-
eventCount: 0,
|
|
608
|
-
handlers: {},
|
|
609
|
-
isHidden: false
|
|
610
|
-
};
|
|
611
|
-
if (object) object.__r3f = instance;
|
|
612
|
-
}
|
|
613
|
-
return instance;
|
|
614
|
-
}
|
|
615
|
-
function invalidateInstance(instance) {
|
|
616
|
-
if (!instance.parent) return;
|
|
617
|
-
instance.props.onUpdate?.(instance.object);
|
|
618
|
-
const state = instance.root?.getState?.();
|
|
619
|
-
if (state && state.internal.frames === 0) state.invalidate();
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
const tempFrustum = new Frustum();
|
|
623
|
-
let hasWarnedWebGL = false;
|
|
624
|
-
let tslModule = null;
|
|
625
|
-
async function loadTSL() {
|
|
626
|
-
if (tslModule) return tslModule;
|
|
627
|
-
try {
|
|
628
|
-
const tsl = await import('three/tsl');
|
|
629
|
-
tslModule = { uniform: tsl.uniform, nodeObject: tsl.nodeObject };
|
|
630
|
-
return tslModule;
|
|
631
|
-
} catch {
|
|
632
|
-
return null;
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
function createOcclusionObserverNode(store, uniform) {
|
|
636
|
-
const node = new Node("float");
|
|
637
|
-
node.updateType = NodeUpdateType.OBJECT;
|
|
638
|
-
node.update = function(frame) {
|
|
639
|
-
const { internal } = store.getState();
|
|
640
|
-
const registry = internal.visibilityRegistry;
|
|
641
|
-
const cache = internal.occlusionCache;
|
|
642
|
-
for (const entry of registry.values()) {
|
|
643
|
-
const { object, handlers } = entry;
|
|
644
|
-
if (handlers.onOccluded || handlers.onVisible) {
|
|
645
|
-
const isOccluded = frame.renderer.isOccluded(object);
|
|
646
|
-
cache.set(object, isOccluded);
|
|
647
|
-
}
|
|
314
|
+
function createOcclusionObserverNode(store, uniform) {
|
|
315
|
+
const node = new Node("float");
|
|
316
|
+
node.updateType = NodeUpdateType.OBJECT;
|
|
317
|
+
node.update = function(frame) {
|
|
318
|
+
const { internal } = store.getState();
|
|
319
|
+
const registry = internal.visibilityRegistry;
|
|
320
|
+
const cache = internal.occlusionCache;
|
|
321
|
+
for (const entry of registry.values()) {
|
|
322
|
+
const { object, handlers } = entry;
|
|
323
|
+
if (handlers.onOccluded || handlers.onVisible) {
|
|
324
|
+
const isOccluded = frame.renderer.isOccluded(object);
|
|
325
|
+
cache.set(object, isOccluded);
|
|
326
|
+
}
|
|
648
327
|
}
|
|
649
328
|
};
|
|
650
329
|
node.setup = function() {
|
|
@@ -934,9 +613,9 @@ function diffProps(instance, newProps) {
|
|
|
934
613
|
const { root, key } = resolve(instance.object, prop);
|
|
935
614
|
if (root.constructor && root.constructor.length === 0) {
|
|
936
615
|
const ctor = getMemoizedPrototype(root);
|
|
937
|
-
if (!is.und(ctor)) changedProps[
|
|
616
|
+
if (!is.und(ctor)) changedProps[prop] = ctor[key];
|
|
938
617
|
} else {
|
|
939
|
-
changedProps[
|
|
618
|
+
changedProps[prop] = 0;
|
|
940
619
|
}
|
|
941
620
|
}
|
|
942
621
|
return changedProps;
|
|
@@ -1053,614 +732,68 @@ function applyProps(object, props) {
|
|
|
1053
732
|
return object;
|
|
1054
733
|
}
|
|
1055
734
|
|
|
1056
|
-
const
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
735
|
+
const shownNotices = /* @__PURE__ */ new Set();
|
|
736
|
+
function notifyDepreciated({ heading, body, link }) {
|
|
737
|
+
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_DEPRECATION_WARNINGS !== "true") {
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
if (shownNotices.has(heading)) return;
|
|
741
|
+
shownNotices.add(heading);
|
|
742
|
+
const caller = getCallerFrame();
|
|
743
|
+
if (caller) {
|
|
744
|
+
console.log();
|
|
745
|
+
}
|
|
746
|
+
const boxStyle = "background: #ff9800; color: #1a1a1a; padding: 8px 12px; border-radius: 4px; font-weight: 500;";
|
|
747
|
+
if (caller) {
|
|
748
|
+
console.log(`%c\u26A0\uFE0F ${heading}`, boxStyle);
|
|
749
|
+
}
|
|
750
|
+
if (body || link) {
|
|
751
|
+
let message = "";
|
|
752
|
+
if (body) message += body;
|
|
753
|
+
if (link) message += (body ? "\n\n" : "") + `More info: ${link}`;
|
|
754
|
+
console.warn(`%c${message}`, "font-weight: bold;");
|
|
1068
755
|
}
|
|
1069
|
-
return state;
|
|
1070
756
|
}
|
|
1071
|
-
function
|
|
1072
|
-
|
|
757
|
+
function getCallerFrame(depth = 3) {
|
|
758
|
+
const stack = new Error().stack;
|
|
759
|
+
if (!stack) return null;
|
|
760
|
+
const lines = stack.split("\n");
|
|
761
|
+
const frame = lines[depth];
|
|
762
|
+
if (!frame) return null;
|
|
763
|
+
let match = frame.match(/^\s*at (?:(.+?) )?\(?(.+?):(\d+):(\d+)\)?$/);
|
|
764
|
+
if (!match) {
|
|
765
|
+
match = frame.match(/^(?:(.+?)@)?(.+?):(\d+):(\d+)$/);
|
|
766
|
+
}
|
|
767
|
+
if (!match) return null;
|
|
768
|
+
const [, fn, url, line] = match;
|
|
769
|
+
return {
|
|
770
|
+
functionName: fn ?? "<anonymous>",
|
|
771
|
+
location: formatLocation(url, Number(line))
|
|
772
|
+
};
|
|
1073
773
|
}
|
|
1074
|
-
function
|
|
1075
|
-
|
|
774
|
+
function formatLocation(url, line) {
|
|
775
|
+
const clean = url.split("?")[0];
|
|
776
|
+
const file = clean.split("/").pop() ?? clean;
|
|
777
|
+
return `${file}:${line}`;
|
|
1076
778
|
}
|
|
1077
|
-
function
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
if (
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
const { internal } = store.getState();
|
|
1088
|
-
internal.interaction = internal.interaction.filter((o) => o !== object);
|
|
1089
|
-
for (const [pointerId, pointerState] of internal.pointerMap) {
|
|
1090
|
-
pointerState.initialHits = pointerState.initialHits.filter((o) => o !== object);
|
|
1091
|
-
pointerState.hovered.forEach((value, key) => {
|
|
1092
|
-
if (value.eventObject === object || value.object === object) {
|
|
1093
|
-
pointerState.hovered.delete(key);
|
|
1094
|
-
}
|
|
1095
|
-
});
|
|
1096
|
-
if (pointerState.captured.has(object)) {
|
|
1097
|
-
releaseInternalPointerCapture(internal, object, pointerId);
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
unregisterVisibility(store, object);
|
|
1101
|
-
}
|
|
1102
|
-
function createEvents(store) {
|
|
1103
|
-
function calculateDistance(event, pointerId) {
|
|
1104
|
-
const { internal } = store.getState();
|
|
1105
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1106
|
-
if (!pointerState) return 0;
|
|
1107
|
-
const [initialX, initialY] = pointerState.initialClick;
|
|
1108
|
-
const dx = event.offsetX - initialX;
|
|
1109
|
-
const dy = event.offsetY - initialY;
|
|
1110
|
-
return Math.round(Math.sqrt(dx * dx + dy * dy));
|
|
1111
|
-
}
|
|
1112
|
-
function filterPointerEvents(objects) {
|
|
1113
|
-
return objects.filter(
|
|
1114
|
-
(obj) => ["Move", "Over", "Enter", "Out", "Leave"].some(
|
|
1115
|
-
(name) => obj.__r3f?.handlers["onPointer" + name]
|
|
1116
|
-
) || ["OverEnter", "OverLeave", "Over"].some(
|
|
1117
|
-
(name) => obj.__r3f?.handlers["onDrag" + name]
|
|
1118
|
-
) || obj.__r3f?.handlers.onDrop
|
|
1119
|
-
);
|
|
1120
|
-
}
|
|
1121
|
-
function intersect(event, filter) {
|
|
1122
|
-
const state = store.getState();
|
|
1123
|
-
const duplicates = /* @__PURE__ */ new Set();
|
|
1124
|
-
const intersections = [];
|
|
1125
|
-
const eventsObjects = filter ? filter(state.internal.interaction) : state.internal.interaction;
|
|
1126
|
-
for (let i = 0; i < eventsObjects.length; i++) {
|
|
1127
|
-
const state2 = getRootState(eventsObjects[i]);
|
|
1128
|
-
if (state2) {
|
|
1129
|
-
state2.raycaster.camera = void 0;
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
if (!state.previousRoot) {
|
|
1133
|
-
state.events.compute?.(event, state);
|
|
1134
|
-
}
|
|
1135
|
-
function handleRaycast(obj) {
|
|
1136
|
-
const state2 = getRootState(obj);
|
|
1137
|
-
if (!state2 || !state2.events.enabled || state2.raycaster.camera === null) return [];
|
|
1138
|
-
if (state2.raycaster.camera === void 0) {
|
|
1139
|
-
state2.events.compute?.(event, state2, state2.previousRoot?.getState());
|
|
1140
|
-
if (state2.raycaster.camera === void 0) state2.raycaster.camera = null;
|
|
1141
|
-
}
|
|
1142
|
-
return state2.raycaster.camera ? state2.raycaster.intersectObject(obj, true) : [];
|
|
1143
|
-
}
|
|
1144
|
-
let hits = eventsObjects.flatMap(handleRaycast).sort((a, b) => {
|
|
1145
|
-
const aInteractivePriority = a.object.userData?.interactivePriority;
|
|
1146
|
-
const bInteractivePriority = b.object.userData?.interactivePriority;
|
|
1147
|
-
if (aInteractivePriority !== void 0 || bInteractivePriority !== void 0) {
|
|
1148
|
-
if (aInteractivePriority !== void 0 && bInteractivePriority === void 0) return -1;
|
|
1149
|
-
if (bInteractivePriority !== void 0 && aInteractivePriority === void 0) return 1;
|
|
1150
|
-
if (aInteractivePriority !== bInteractivePriority) {
|
|
1151
|
-
return (bInteractivePriority ?? 0) - (aInteractivePriority ?? 0);
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
const aState = getRootState(a.object);
|
|
1155
|
-
const bState = getRootState(b.object);
|
|
1156
|
-
const aPriority = aState?.events?.priority ?? 1;
|
|
1157
|
-
const bPriority = bState?.events?.priority ?? 1;
|
|
1158
|
-
return bPriority - aPriority || a.distance - b.distance;
|
|
1159
|
-
}).filter((item) => {
|
|
1160
|
-
const id = makeId(item);
|
|
1161
|
-
if (duplicates.has(id)) return false;
|
|
1162
|
-
duplicates.add(id);
|
|
1163
|
-
return true;
|
|
1164
|
-
});
|
|
1165
|
-
if (state.events.filter) hits = state.events.filter(hits, state);
|
|
1166
|
-
for (const hit of hits) {
|
|
1167
|
-
let eventObject = hit.object;
|
|
1168
|
-
while (eventObject) {
|
|
1169
|
-
if (eventObject.__r3f?.eventCount) {
|
|
1170
|
-
intersections.push({ ...hit, eventObject });
|
|
1171
|
-
}
|
|
1172
|
-
eventObject = eventObject.parent;
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
if ("pointerId" in event) {
|
|
1176
|
-
const pointerId = event.pointerId;
|
|
1177
|
-
const pointerState = state.internal.pointerMap.get(pointerId);
|
|
1178
|
-
if (pointerState?.captured.size) {
|
|
1179
|
-
for (const captureData of pointerState.captured.values()) {
|
|
1180
|
-
if (!duplicates.has(makeId(captureData.intersection))) intersections.push(captureData.intersection);
|
|
1181
|
-
}
|
|
1182
|
-
}
|
|
1183
|
-
}
|
|
1184
|
-
return intersections;
|
|
1185
|
-
}
|
|
1186
|
-
function handleIntersects(intersections, event, delta, callback) {
|
|
1187
|
-
if (intersections.length) {
|
|
1188
|
-
const localState = { stopped: false };
|
|
1189
|
-
for (const hit of intersections) {
|
|
1190
|
-
const state = getRootState(hit.object);
|
|
1191
|
-
if (state) {
|
|
1192
|
-
const { raycaster, pointer, camera, internal } = state;
|
|
1193
|
-
const unprojectedPoint = new Vector3(pointer.x, pointer.y, 0).unproject(camera);
|
|
1194
|
-
const hasPointerCapture = (id) => {
|
|
1195
|
-
const pointerState = internal.pointerMap.get(id);
|
|
1196
|
-
return pointerState?.captured.has(hit.eventObject) ?? false;
|
|
1197
|
-
};
|
|
1198
|
-
const setPointerCapture = (id) => {
|
|
1199
|
-
const captureData = { intersection: hit, target: event.target };
|
|
1200
|
-
const pointerState = getPointerState(internal, id);
|
|
1201
|
-
pointerState.captured.set(hit.eventObject, captureData);
|
|
1202
|
-
event.target.setPointerCapture(id);
|
|
1203
|
-
};
|
|
1204
|
-
const releasePointerCapture = (id) => {
|
|
1205
|
-
releaseInternalPointerCapture(internal, hit.eventObject, id);
|
|
1206
|
-
};
|
|
1207
|
-
const extractEventProps = {};
|
|
1208
|
-
for (const prop in event) {
|
|
1209
|
-
const property = event[prop];
|
|
1210
|
-
if (typeof property !== "function") extractEventProps[prop] = property;
|
|
1211
|
-
}
|
|
1212
|
-
const eventPointerId = "pointerId" in event ? event.pointerId : void 0;
|
|
1213
|
-
const raycastEvent = {
|
|
1214
|
-
...hit,
|
|
1215
|
-
...extractEventProps,
|
|
1216
|
-
pointer,
|
|
1217
|
-
intersections,
|
|
1218
|
-
stopped: localState.stopped,
|
|
1219
|
-
delta,
|
|
1220
|
-
unprojectedPoint,
|
|
1221
|
-
ray: raycaster.ray,
|
|
1222
|
-
camera,
|
|
1223
|
-
pointerId: eventPointerId,
|
|
1224
|
-
// Hijack stopPropagation, which just sets a flag
|
|
1225
|
-
stopPropagation() {
|
|
1226
|
-
const pointerState = eventPointerId !== void 0 ? internal.pointerMap.get(eventPointerId) : void 0;
|
|
1227
|
-
if (
|
|
1228
|
-
// ...if this pointer hasn't been captured
|
|
1229
|
-
!pointerState?.captured.size || // ... or if the hit object is capturing the pointer
|
|
1230
|
-
pointerState.captured.has(hit.eventObject)
|
|
1231
|
-
) {
|
|
1232
|
-
raycastEvent.stopped = localState.stopped = true;
|
|
1233
|
-
if (pointerState?.hovered.size && Array.from(pointerState.hovered.values()).find((i) => i.eventObject === hit.eventObject)) {
|
|
1234
|
-
const higher = intersections.slice(0, intersections.indexOf(hit));
|
|
1235
|
-
cancelPointer([...higher, hit], eventPointerId);
|
|
1236
|
-
}
|
|
1237
|
-
}
|
|
1238
|
-
},
|
|
1239
|
-
// there should be a distinction between target and currentTarget
|
|
1240
|
-
target: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
1241
|
-
currentTarget: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
1242
|
-
nativeEvent: event
|
|
1243
|
-
};
|
|
1244
|
-
callback(raycastEvent);
|
|
1245
|
-
if (localState.stopped === true) break;
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
return intersections;
|
|
1250
|
-
}
|
|
1251
|
-
function cancelPointer(intersections, pointerId) {
|
|
1252
|
-
const { internal } = store.getState();
|
|
1253
|
-
const pid = pointerId ?? DEFAULT_POINTER_ID;
|
|
1254
|
-
const pointerState = internal.pointerMap.get(pid);
|
|
1255
|
-
if (!pointerState) return;
|
|
1256
|
-
for (const [hoveredId, hoveredObj] of pointerState.hovered) {
|
|
1257
|
-
if (!intersections.length || !intersections.find(
|
|
1258
|
-
(hit) => hit.object === hoveredObj.object && hit.index === hoveredObj.index && hit.instanceId === hoveredObj.instanceId
|
|
1259
|
-
)) {
|
|
1260
|
-
const eventObject = hoveredObj.eventObject;
|
|
1261
|
-
const instance = eventObject.__r3f;
|
|
1262
|
-
pointerState.hovered.delete(hoveredId);
|
|
1263
|
-
if (instance?.eventCount) {
|
|
1264
|
-
const handlers = instance.handlers;
|
|
1265
|
-
const data = { ...hoveredObj, intersections };
|
|
1266
|
-
handlers.onPointerOut?.(data);
|
|
1267
|
-
handlers.onPointerLeave?.(data);
|
|
1268
|
-
handlers.onDragOverLeave?.(data);
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
}
|
|
1273
|
-
function pointerMissed(event, objects) {
|
|
1274
|
-
for (let i = 0; i < objects.length; i++) {
|
|
1275
|
-
const instance = objects[i].__r3f;
|
|
1276
|
-
instance?.handlers.onPointerMissed?.(event);
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
function dragOverMissed(event, objects) {
|
|
1280
|
-
for (let i = 0; i < objects.length; i++) {
|
|
1281
|
-
const instance = objects[i].__r3f;
|
|
1282
|
-
instance?.handlers.onDragOverMissed?.(event);
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1285
|
-
function dropMissed(event, objects) {
|
|
1286
|
-
for (let i = 0; i < objects.length; i++) {
|
|
1287
|
-
const instance = objects[i].__r3f;
|
|
1288
|
-
instance?.handlers.onDropMissed?.(event);
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
|
-
function cleanupPointer(pointerId) {
|
|
1292
|
-
const { internal } = store.getState();
|
|
1293
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1294
|
-
if (pointerState) {
|
|
1295
|
-
for (const [, hoveredObj] of pointerState.hovered) {
|
|
1296
|
-
const eventObject = hoveredObj.eventObject;
|
|
1297
|
-
const instance = eventObject.__r3f;
|
|
1298
|
-
if (instance?.eventCount) {
|
|
1299
|
-
const handlers = instance.handlers;
|
|
1300
|
-
const data = { ...hoveredObj, intersections: [] };
|
|
1301
|
-
handlers.onPointerOut?.(data);
|
|
1302
|
-
handlers.onPointerLeave?.(data);
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1305
|
-
internal.pointerMap.delete(pointerId);
|
|
1306
|
-
}
|
|
1307
|
-
internal.pointerDirty.delete(pointerId);
|
|
1308
|
-
}
|
|
1309
|
-
function processDeferredPointer(event, pointerId) {
|
|
1310
|
-
const state = store.getState();
|
|
1311
|
-
const { internal } = state;
|
|
1312
|
-
if (!state.events.enabled) return;
|
|
1313
|
-
const filter = filterPointerEvents;
|
|
1314
|
-
const hits = intersect(event, filter);
|
|
1315
|
-
cancelPointer(hits, pointerId);
|
|
1316
|
-
function onIntersect(data) {
|
|
1317
|
-
const eventObject = data.eventObject;
|
|
1318
|
-
const instance = eventObject.__r3f;
|
|
1319
|
-
if (!instance?.eventCount) return;
|
|
1320
|
-
const handlers = instance.handlers;
|
|
1321
|
-
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
1322
|
-
const id = makeId(data);
|
|
1323
|
-
const pointerState = getPointerState(internal, pointerId);
|
|
1324
|
-
const hoveredItem = pointerState.hovered.get(id);
|
|
1325
|
-
if (!hoveredItem) {
|
|
1326
|
-
pointerState.hovered.set(id, data);
|
|
1327
|
-
handlers.onPointerOver?.(data);
|
|
1328
|
-
handlers.onPointerEnter?.(data);
|
|
1329
|
-
} else if (hoveredItem.stopped) {
|
|
1330
|
-
data.stopPropagation();
|
|
1331
|
-
}
|
|
1332
|
-
}
|
|
1333
|
-
handlers.onPointerMove?.(data);
|
|
1334
|
-
}
|
|
1335
|
-
handleIntersects(hits, event, 0, onIntersect);
|
|
1336
|
-
}
|
|
1337
|
-
function handlePointer(name) {
|
|
1338
|
-
switch (name) {
|
|
1339
|
-
case "onPointerLeave":
|
|
1340
|
-
case "onDragLeave":
|
|
1341
|
-
return () => cancelPointer([]);
|
|
1342
|
-
// Global cancel of these events
|
|
1343
|
-
case "onPointerCancel":
|
|
1344
|
-
return (event) => {
|
|
1345
|
-
const pointerId = getPointerId(event);
|
|
1346
|
-
cleanupPointer(pointerId);
|
|
1347
|
-
};
|
|
1348
|
-
case "onLostPointerCapture":
|
|
1349
|
-
return (event) => {
|
|
1350
|
-
const { internal } = store.getState();
|
|
1351
|
-
const pointerId = getPointerId(event);
|
|
1352
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1353
|
-
if (pointerState?.captured.size) {
|
|
1354
|
-
requestAnimationFrame(() => {
|
|
1355
|
-
const pointerState2 = internal.pointerMap.get(pointerId);
|
|
1356
|
-
if (pointerState2?.captured.size) {
|
|
1357
|
-
pointerState2.captured.clear();
|
|
1358
|
-
}
|
|
1359
|
-
cancelPointer([], pointerId);
|
|
1360
|
-
});
|
|
1361
|
-
}
|
|
1362
|
-
};
|
|
1363
|
-
}
|
|
1364
|
-
return function handleEvent(event) {
|
|
1365
|
-
const state = store.getState();
|
|
1366
|
-
const { onPointerMissed, onDragOverMissed, onDropMissed, internal, events } = state;
|
|
1367
|
-
const pointerId = getPointerId(event);
|
|
1368
|
-
internal.lastEvent.current = event;
|
|
1369
|
-
if (!events.enabled) return;
|
|
1370
|
-
const isPointerMove = name === "onPointerMove";
|
|
1371
|
-
const isDragOver = name === "onDragOver";
|
|
1372
|
-
const isDrop = name === "onDrop";
|
|
1373
|
-
const isClickEvent = name === "onClick" || name === "onContextMenu" || name === "onDoubleClick";
|
|
1374
|
-
const isPointerDown = name === "onPointerDown";
|
|
1375
|
-
const isPointerUp = name === "onPointerUp";
|
|
1376
|
-
const isWheel = name === "onWheel";
|
|
1377
|
-
const canDeferRaycasts = events.frameTimedRaycasts && state.frameloop === "always";
|
|
1378
|
-
if (isPointerMove && canDeferRaycasts) {
|
|
1379
|
-
events.compute?.(event, state);
|
|
1380
|
-
internal.pointerDirty.set(pointerId, event);
|
|
1381
|
-
return;
|
|
1382
|
-
}
|
|
1383
|
-
if (isWheel && canDeferRaycasts && !events.alwaysFireOnScroll) {
|
|
1384
|
-
events.compute?.(event, state);
|
|
1385
|
-
internal.pointerDirty.set(pointerId, event);
|
|
1386
|
-
return;
|
|
1387
|
-
}
|
|
1388
|
-
if ((isClickEvent || isPointerDown || isPointerUp) && internal.pointerDirty.has(pointerId)) {
|
|
1389
|
-
const deferredEvent = internal.pointerDirty.get(pointerId);
|
|
1390
|
-
internal.pointerDirty.delete(pointerId);
|
|
1391
|
-
processDeferredPointer(deferredEvent, pointerId);
|
|
1392
|
-
}
|
|
1393
|
-
const filter = isPointerMove || isDragOver || isDrop ? filterPointerEvents : void 0;
|
|
1394
|
-
const hits = intersect(event, filter);
|
|
1395
|
-
const delta = isClickEvent ? calculateDistance(event, pointerId) : 0;
|
|
1396
|
-
if (isPointerDown) {
|
|
1397
|
-
const pointerState2 = getPointerState(internal, pointerId);
|
|
1398
|
-
pointerState2.initialClick = [event.offsetX, event.offsetY];
|
|
1399
|
-
pointerState2.initialHits = hits.map((hit) => hit.eventObject);
|
|
1400
|
-
}
|
|
1401
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1402
|
-
const initialHits = pointerState?.initialHits ?? [];
|
|
1403
|
-
if (isClickEvent && !hits.length) {
|
|
1404
|
-
if (delta <= 2) {
|
|
1405
|
-
pointerMissed(event, internal.interaction);
|
|
1406
|
-
if (onPointerMissed) onPointerMissed(event);
|
|
1407
|
-
}
|
|
1408
|
-
}
|
|
1409
|
-
if (isDragOver && !hits.length) {
|
|
1410
|
-
dragOverMissed(event, internal.interaction);
|
|
1411
|
-
if (onDragOverMissed) onDragOverMissed(event);
|
|
1412
|
-
}
|
|
1413
|
-
if (isDrop && !hits.length) {
|
|
1414
|
-
dropMissed(event, internal.interaction);
|
|
1415
|
-
if (onDropMissed) onDropMissed(event);
|
|
1416
|
-
}
|
|
1417
|
-
if (isPointerMove || isDragOver) {
|
|
1418
|
-
cancelPointer(hits, pointerId);
|
|
1419
|
-
}
|
|
1420
|
-
function onIntersect(data) {
|
|
1421
|
-
const eventObject = data.eventObject;
|
|
1422
|
-
const instance = eventObject.__r3f;
|
|
1423
|
-
if (!instance?.eventCount) return;
|
|
1424
|
-
const handlers = instance.handlers;
|
|
1425
|
-
if (isPointerMove) {
|
|
1426
|
-
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
1427
|
-
const id = makeId(data);
|
|
1428
|
-
const pointerState2 = getPointerState(internal, pointerId);
|
|
1429
|
-
const hoveredItem = pointerState2.hovered.get(id);
|
|
1430
|
-
if (!hoveredItem) {
|
|
1431
|
-
pointerState2.hovered.set(id, data);
|
|
1432
|
-
handlers.onPointerOver?.(data);
|
|
1433
|
-
handlers.onPointerEnter?.(data);
|
|
1434
|
-
} else if (hoveredItem.stopped) {
|
|
1435
|
-
data.stopPropagation();
|
|
1436
|
-
}
|
|
1437
|
-
}
|
|
1438
|
-
handlers.onPointerMove?.(data);
|
|
1439
|
-
} else if (isDragOver) {
|
|
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.onDragOverEnter?.(data);
|
|
1446
|
-
} else if (hoveredItem.stopped) {
|
|
1447
|
-
data.stopPropagation();
|
|
1448
|
-
}
|
|
1449
|
-
handlers.onDragOver?.(data);
|
|
1450
|
-
} else if (isDrop) {
|
|
1451
|
-
handlers.onDrop?.(data);
|
|
1452
|
-
} else {
|
|
1453
|
-
const handler = handlers[name];
|
|
1454
|
-
if (handler) {
|
|
1455
|
-
if (!isClickEvent || initialHits.includes(eventObject)) {
|
|
1456
|
-
pointerMissed(
|
|
1457
|
-
event,
|
|
1458
|
-
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
1459
|
-
);
|
|
1460
|
-
handler(data);
|
|
1461
|
-
}
|
|
1462
|
-
} else {
|
|
1463
|
-
if (isClickEvent && initialHits.includes(eventObject)) {
|
|
1464
|
-
pointerMissed(
|
|
1465
|
-
event,
|
|
1466
|
-
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
1467
|
-
);
|
|
1468
|
-
}
|
|
1469
|
-
}
|
|
1470
|
-
}
|
|
1471
|
-
}
|
|
1472
|
-
handleIntersects(hits, event, delta, onIntersect);
|
|
1473
|
-
};
|
|
1474
|
-
}
|
|
1475
|
-
function flushDeferredPointers() {
|
|
1476
|
-
const { internal, events } = store.getState();
|
|
1477
|
-
if (!events.frameTimedRaycasts) return;
|
|
1478
|
-
for (const [pointerId, event] of internal.pointerDirty) {
|
|
1479
|
-
processDeferredPointer(event, pointerId);
|
|
1480
|
-
}
|
|
1481
|
-
internal.pointerDirty.clear();
|
|
1482
|
-
}
|
|
1483
|
-
return { handlePointer, flushDeferredPointers, processDeferredPointer };
|
|
1484
|
-
}
|
|
1485
|
-
const DOM_EVENTS = {
|
|
1486
|
-
onClick: ["click", false],
|
|
1487
|
-
onContextMenu: ["contextmenu", false],
|
|
1488
|
-
onDoubleClick: ["dblclick", false],
|
|
1489
|
-
onDragEnter: ["dragenter", false],
|
|
1490
|
-
onDragLeave: ["dragleave", false],
|
|
1491
|
-
onDragOver: ["dragover", false],
|
|
1492
|
-
onDrop: ["drop", false],
|
|
1493
|
-
onWheel: ["wheel", true],
|
|
1494
|
-
onPointerDown: ["pointerdown", true],
|
|
1495
|
-
onPointerUp: ["pointerup", true],
|
|
1496
|
-
onPointerLeave: ["pointerleave", true],
|
|
1497
|
-
onPointerMove: ["pointermove", true],
|
|
1498
|
-
onPointerCancel: ["pointercancel", true],
|
|
1499
|
-
onLostPointerCapture: ["lostpointercapture", true]
|
|
1500
|
-
};
|
|
1501
|
-
function createPointerEvents(store) {
|
|
1502
|
-
const { handlePointer, flushDeferredPointers, processDeferredPointer } = createEvents(store);
|
|
1503
|
-
let nextXRPointerId = XR_POINTER_ID_START;
|
|
1504
|
-
const xrPointers = /* @__PURE__ */ new Map();
|
|
1505
|
-
return {
|
|
1506
|
-
priority: 1,
|
|
1507
|
-
enabled: true,
|
|
1508
|
-
frameTimedRaycasts: true,
|
|
1509
|
-
alwaysFireOnScroll: true,
|
|
1510
|
-
updateOnFrame: false,
|
|
1511
|
-
compute(event, state) {
|
|
1512
|
-
state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
|
|
1513
|
-
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
1514
|
-
},
|
|
1515
|
-
connected: void 0,
|
|
1516
|
-
handlers: Object.keys(DOM_EVENTS).reduce(
|
|
1517
|
-
(acc, key) => ({ ...acc, [key]: handlePointer(key) }),
|
|
1518
|
-
{}
|
|
1519
|
-
),
|
|
1520
|
-
update: (pointerId) => {
|
|
1521
|
-
const { events, internal } = store.getState();
|
|
1522
|
-
if (!events.handlers) return;
|
|
1523
|
-
if (pointerId !== void 0) {
|
|
1524
|
-
const event = internal.pointerDirty.get(pointerId);
|
|
1525
|
-
if (event) {
|
|
1526
|
-
internal.pointerDirty.delete(pointerId);
|
|
1527
|
-
processDeferredPointer(event, pointerId);
|
|
1528
|
-
} else if (internal.lastEvent?.current) {
|
|
1529
|
-
processDeferredPointer(internal.lastEvent.current, pointerId);
|
|
1530
|
-
}
|
|
1531
|
-
} else {
|
|
1532
|
-
flushDeferredPointers();
|
|
1533
|
-
if (internal.lastEvent?.current) {
|
|
1534
|
-
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
1535
|
-
}
|
|
1536
|
-
}
|
|
1537
|
-
},
|
|
1538
|
-
flush: () => {
|
|
1539
|
-
const { events, internal } = store.getState();
|
|
1540
|
-
flushDeferredPointers();
|
|
1541
|
-
if (events.updateOnFrame && internal.lastEvent?.current && events.handlers) {
|
|
1542
|
-
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
1543
|
-
}
|
|
1544
|
-
},
|
|
1545
|
-
connect: (target) => {
|
|
1546
|
-
if (!target) return;
|
|
1547
|
-
const { set, events } = store.getState();
|
|
1548
|
-
events.disconnect?.();
|
|
1549
|
-
set((state) => ({ events: { ...state.events, connected: target } }));
|
|
1550
|
-
if (events.handlers) {
|
|
1551
|
-
for (const name in events.handlers) {
|
|
1552
|
-
const event = events.handlers[name];
|
|
1553
|
-
const [eventName, passive] = DOM_EVENTS[name];
|
|
1554
|
-
target.addEventListener(eventName, event, { passive });
|
|
1555
|
-
}
|
|
1556
|
-
}
|
|
1557
|
-
},
|
|
1558
|
-
disconnect: () => {
|
|
1559
|
-
const { set, events } = store.getState();
|
|
1560
|
-
if (events.connected) {
|
|
1561
|
-
if (events.handlers) {
|
|
1562
|
-
for (const name in events.handlers) {
|
|
1563
|
-
const event = events.handlers[name];
|
|
1564
|
-
const [eventName] = DOM_EVENTS[name];
|
|
1565
|
-
events.connected.removeEventListener(eventName, event);
|
|
1566
|
-
}
|
|
1567
|
-
}
|
|
1568
|
-
set((state) => ({ events: { ...state.events, connected: void 0 } }));
|
|
1569
|
-
}
|
|
1570
|
-
},
|
|
1571
|
-
// PREVIEW (A8): the XR pointer registration API may change before stable.
|
|
1572
|
-
registerPointer: (config) => {
|
|
1573
|
-
const pointerId = nextXRPointerId++;
|
|
1574
|
-
xrPointers.set(pointerId, config);
|
|
1575
|
-
const { internal } = store.getState();
|
|
1576
|
-
getPointerState(internal, pointerId);
|
|
1577
|
-
return pointerId;
|
|
1578
|
-
},
|
|
1579
|
-
unregisterPointer: (pointerId) => {
|
|
1580
|
-
xrPointers.delete(pointerId);
|
|
1581
|
-
const { internal } = store.getState();
|
|
1582
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1583
|
-
if (pointerState) {
|
|
1584
|
-
for (const [, hoveredObj] of pointerState.hovered) {
|
|
1585
|
-
const eventObject = hoveredObj.eventObject;
|
|
1586
|
-
const instance = eventObject.__r3f;
|
|
1587
|
-
if (instance?.eventCount) {
|
|
1588
|
-
const handlers = instance.handlers;
|
|
1589
|
-
const data = { ...hoveredObj, intersections: [] };
|
|
1590
|
-
handlers.onPointerOut?.(data);
|
|
1591
|
-
handlers.onPointerLeave?.(data);
|
|
1592
|
-
}
|
|
1593
|
-
}
|
|
1594
|
-
internal.pointerMap.delete(pointerId);
|
|
1595
|
-
}
|
|
1596
|
-
internal.pointerDirty.delete(pointerId);
|
|
1597
|
-
}
|
|
1598
|
-
};
|
|
1599
|
-
}
|
|
1600
|
-
|
|
1601
|
-
const shownNotices = /* @__PURE__ */ new Set();
|
|
1602
|
-
function notifyDepreciated({ heading, body, link }) {
|
|
1603
|
-
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_DEPRECATION_WARNINGS !== "true") {
|
|
1604
|
-
return;
|
|
1605
|
-
}
|
|
1606
|
-
if (shownNotices.has(heading)) return;
|
|
1607
|
-
shownNotices.add(heading);
|
|
1608
|
-
const caller = getCallerFrame();
|
|
1609
|
-
if (caller) {
|
|
1610
|
-
console.log();
|
|
1611
|
-
}
|
|
1612
|
-
const boxStyle = "background: #ff9800; color: #1a1a1a; padding: 8px 12px; border-radius: 4px; font-weight: 500;";
|
|
1613
|
-
if (caller) {
|
|
1614
|
-
console.log(`%c\u26A0\uFE0F ${heading}`, boxStyle);
|
|
1615
|
-
}
|
|
1616
|
-
if (body || link) {
|
|
1617
|
-
let message = "";
|
|
1618
|
-
if (body) message += body;
|
|
1619
|
-
if (link) message += (body ? "\n\n" : "") + `More info: ${link}`;
|
|
1620
|
-
console.warn(`%c${message}`, "font-weight: bold;");
|
|
1621
|
-
}
|
|
1622
|
-
}
|
|
1623
|
-
function getCallerFrame(depth = 3) {
|
|
1624
|
-
const stack = new Error().stack;
|
|
1625
|
-
if (!stack) return null;
|
|
1626
|
-
const lines = stack.split("\n");
|
|
1627
|
-
const frame = lines[depth];
|
|
1628
|
-
if (!frame) return null;
|
|
1629
|
-
let match = frame.match(/^\s*at (?:(.+?) )?\(?(.+?):(\d+):(\d+)\)?$/);
|
|
1630
|
-
if (!match) {
|
|
1631
|
-
match = frame.match(/^(?:(.+?)@)?(.+?):(\d+):(\d+)$/);
|
|
1632
|
-
}
|
|
1633
|
-
if (!match) return null;
|
|
1634
|
-
const [, fn, url, line] = match;
|
|
1635
|
-
return {
|
|
1636
|
-
functionName: fn ?? "<anonymous>",
|
|
1637
|
-
location: formatLocation(url, Number(line))
|
|
1638
|
-
};
|
|
1639
|
-
}
|
|
1640
|
-
function formatLocation(url, line) {
|
|
1641
|
-
const clean = url.split("?")[0];
|
|
1642
|
-
const file = clean.split("/").pop() ?? clean;
|
|
1643
|
-
return `${file}:${line}`;
|
|
1644
|
-
}
|
|
1645
|
-
function notifyAlpha({ message, link }) {
|
|
1646
|
-
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_ALPHA_WARNINGS !== "true") {
|
|
1647
|
-
return;
|
|
1648
|
-
}
|
|
1649
|
-
if (shownNotices.has(message)) return;
|
|
1650
|
-
shownNotices.add(message);
|
|
1651
|
-
const boxStyle = "background: #6366f1; color: #ffffff; padding: 6px 10px; border-radius: 4px; font-weight: 500;";
|
|
1652
|
-
console.log(`%c\u{1F52C} ${message}`, boxStyle);
|
|
1653
|
-
{
|
|
1654
|
-
console.log(`%cMore info: ${link}`, "color: #6366f1; font-weight: normal;");
|
|
779
|
+
function notifyAlpha({ message, link }) {
|
|
780
|
+
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_ALPHA_WARNINGS !== "true") {
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
if (shownNotices.has(message)) return;
|
|
784
|
+
shownNotices.add(message);
|
|
785
|
+
const boxStyle = "background: #6366f1; color: #ffffff; padding: 6px 10px; border-radius: 4px; font-weight: 500;";
|
|
786
|
+
console.log(`%c\u{1F52C} ${message}`, boxStyle);
|
|
787
|
+
{
|
|
788
|
+
console.log(`%cMore info: ${link}`, "color: #6366f1; font-weight: normal;");
|
|
1655
789
|
}
|
|
1656
790
|
}
|
|
1657
791
|
|
|
1658
792
|
const INTERNAL_LIB_MARKERS = ["zustand", "setState", "Object.assign"];
|
|
1659
|
-
const INTERNAL_FIBER_MARKERS = ["packages/fiber/src", "packages/fiber/dist", "@react-three/fiber", "@react-three_fiber"];
|
|
1660
793
|
function isInternalRendererAccess(stack, callerDepth = 2) {
|
|
1661
794
|
if (!stack) return false;
|
|
1662
795
|
const caller = stack.split("\n")[callerDepth] ?? "";
|
|
1663
|
-
return INTERNAL_LIB_MARKERS.some((m) => caller.includes(m))
|
|
796
|
+
return INTERNAL_LIB_MARKERS.some((m) => caller.includes(m));
|
|
1664
797
|
}
|
|
1665
798
|
|
|
1666
799
|
const R3F_CONTEXT = Symbol.for("@react-three/fiber.context");
|
|
@@ -1772,7 +905,7 @@ const createStore = (invalidate, advance) => {
|
|
|
1772
905
|
size: newSize,
|
|
1773
906
|
viewport: { ...s.viewport, ...getCurrentViewport(state2.camera, defaultTarget, newSize) }
|
|
1774
907
|
}));
|
|
1775
|
-
|
|
908
|
+
get().invalidate();
|
|
1776
909
|
}
|
|
1777
910
|
}
|
|
1778
911
|
return;
|
|
@@ -1787,15 +920,16 @@ const createStore = (invalidate, advance) => {
|
|
|
1787
920
|
viewport: { ...s.viewport, ...getCurrentViewport(state2.camera, defaultTarget, size) },
|
|
1788
921
|
_sizeImperative: true
|
|
1789
922
|
}));
|
|
1790
|
-
|
|
923
|
+
get().invalidate();
|
|
1791
924
|
},
|
|
1792
925
|
setDpr: (dpr) => set((state2) => {
|
|
1793
926
|
const resolved = calculateDpr(dpr);
|
|
1794
927
|
return { viewport: { ...state2.viewport, dpr: resolved, initialDpr: state2.viewport.initialDpr || resolved } };
|
|
1795
928
|
}),
|
|
1796
929
|
setFrameloop: (frameloop = "always") => {
|
|
930
|
+
const rootId = get().internal.rootId;
|
|
931
|
+
if (rootId) getScheduler().setRootFrameloop(rootId, frameloop);
|
|
1797
932
|
set(() => ({ frameloop }));
|
|
1798
|
-
getScheduler().frameloop = frameloop;
|
|
1799
933
|
},
|
|
1800
934
|
setError: (error) => set(() => ({ error })),
|
|
1801
935
|
error: null,
|
|
@@ -1911,17 +1045,10 @@ const createStore = (invalidate, advance) => {
|
|
|
1911
1045
|
oldSize = size;
|
|
1912
1046
|
oldDpr = viewport.dpr;
|
|
1913
1047
|
updateCamera(camera, size);
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
if (viewport.dpr > 0) actualRenderer.setPixelRatio(viewport.dpr);
|
|
1919
|
-
actualRenderer.setSize(size.width, size.height, false);
|
|
1920
|
-
if (canvasTarget) {
|
|
1921
|
-
if (viewport.dpr > 0) canvasTarget.setPixelRatio(viewport.dpr);
|
|
1922
|
-
canvasTarget.setSize(size.width, size.height, false);
|
|
1923
|
-
}
|
|
1924
|
-
}
|
|
1048
|
+
const resizeTarget = canvasTarget ?? actualRenderer;
|
|
1049
|
+
if (viewport.dpr > 0) resizeTarget.setPixelRatio(viewport.dpr);
|
|
1050
|
+
resizeTarget.setSize(size.width, size.height, false);
|
|
1051
|
+
internal.canvasTargetSizeDirty = true;
|
|
1925
1052
|
}
|
|
1926
1053
|
if (camera !== oldCamera) {
|
|
1927
1054
|
oldCamera = camera;
|
|
@@ -1942,7 +1069,7 @@ const createStore = (invalidate, advance) => {
|
|
|
1942
1069
|
|
|
1943
1070
|
const memoizedLoaders = /* @__PURE__ */ new WeakMap();
|
|
1944
1071
|
const isConstructor$1 = (value) => typeof value === "function" && value?.prototype?.constructor === value;
|
|
1945
|
-
function getLoader(Proto) {
|
|
1072
|
+
function getLoader$1(Proto) {
|
|
1946
1073
|
if (isConstructor$1(Proto)) {
|
|
1947
1074
|
let loader = memoizedLoaders.get(Proto);
|
|
1948
1075
|
if (!loader) {
|
|
@@ -1955,7 +1082,7 @@ function getLoader(Proto) {
|
|
|
1955
1082
|
}
|
|
1956
1083
|
function loadingFn(extensions, onProgress) {
|
|
1957
1084
|
return function(Proto, input) {
|
|
1958
|
-
const loader = getLoader(Proto);
|
|
1085
|
+
const loader = getLoader$1(Proto);
|
|
1959
1086
|
if (extensions) extensions(loader);
|
|
1960
1087
|
if ("loadAsync" in loader && typeof loader.loadAsync === "function") {
|
|
1961
1088
|
return loader.loadAsync(input, onProgress).then((data) => {
|
|
@@ -1983,7 +1110,11 @@ function useLoader(loader, input, extensions, onProgress, cacheKey) {
|
|
|
1983
1110
|
const results = cacheKeys.map(
|
|
1984
1111
|
(key, index) => suspend(() => fn(loader, inputs[index]), [loader, key], { equal: is.equ })
|
|
1985
1112
|
);
|
|
1986
|
-
|
|
1113
|
+
const stableRef = useRef(null);
|
|
1114
|
+
const previous = stableRef.current;
|
|
1115
|
+
const stable = previous !== null && previous.length === results.length && previous.every((value, i) => value === results[i]) ? previous : results;
|
|
1116
|
+
stableRef.current = stable;
|
|
1117
|
+
return Array.isArray(input) ? stable : stable[0];
|
|
1987
1118
|
}
|
|
1988
1119
|
useLoader.preload = function(loader, input, extensions, onProgress, cacheKey) {
|
|
1989
1120
|
const inputs = Array.isArray(input) ? input : [input];
|
|
@@ -1996,7 +1127,7 @@ useLoader.clear = function(loader, input, cacheKey) {
|
|
|
1996
1127
|
const cacheKeys = Array.isArray(cacheKey ?? input) ? cacheKey ?? input : [cacheKey ?? input];
|
|
1997
1128
|
cacheKeys.forEach((key) => clear([loader, key]));
|
|
1998
1129
|
};
|
|
1999
|
-
useLoader.loader = getLoader;
|
|
1130
|
+
useLoader.loader = getLoader$1;
|
|
2000
1131
|
|
|
2001
1132
|
function useFrame(callback, priorityOrOptions) {
|
|
2002
1133
|
const store = React.useContext(context);
|
|
@@ -2103,6 +1234,13 @@ function useFrame(callback, priorityOrOptions) {
|
|
|
2103
1234
|
* Use for controlling the entire frame loop, adding phases, etc.
|
|
2104
1235
|
*/
|
|
2105
1236
|
scheduler: scheduler2,
|
|
1237
|
+
/**
|
|
1238
|
+
* The root that currently owns this job. Resolve on access because ambient
|
|
1239
|
+
* jobs can be adopted by a Canvas after the controls object is created.
|
|
1240
|
+
*/
|
|
1241
|
+
get rootId() {
|
|
1242
|
+
return getScheduler().getJobRootId(id);
|
|
1243
|
+
},
|
|
2106
1244
|
/**
|
|
2107
1245
|
* Manually step this job only.
|
|
2108
1246
|
* Bypasses FPS limiting - always runs.
|
|
@@ -2119,6 +1257,14 @@ function useFrame(callback, priorityOrOptions) {
|
|
|
2119
1257
|
stepAll: (timestamp) => {
|
|
2120
1258
|
getScheduler().step(timestamp);
|
|
2121
1259
|
},
|
|
1260
|
+
/**
|
|
1261
|
+
* Request frames for this job's owning root without waking sibling roots.
|
|
1262
|
+
*/
|
|
1263
|
+
invalidate: (frames, stackFrames) => {
|
|
1264
|
+
const scheduler3 = getScheduler();
|
|
1265
|
+
const rootId = scheduler3.getJobRootId(id);
|
|
1266
|
+
if (rootId) scheduler3.invalidateRoot(rootId, frames, stackFrames);
|
|
1267
|
+
},
|
|
2122
1268
|
/**
|
|
2123
1269
|
* Pause this job (set enabled=false).
|
|
2124
1270
|
* Job remains registered but won't run.
|
|
@@ -2148,6 +1294,11 @@ function getUrls(input) {
|
|
|
2148
1294
|
if (Array.isArray(input)) return input;
|
|
2149
1295
|
return Object.values(input);
|
|
2150
1296
|
}
|
|
1297
|
+
function inputSignature(input) {
|
|
1298
|
+
if (typeof input === "string") return input;
|
|
1299
|
+
if (Array.isArray(input)) return input.join("\0");
|
|
1300
|
+
return Object.keys(input).sort().map((key) => `${key}\0${input[key]}`).join("");
|
|
1301
|
+
}
|
|
2151
1302
|
function allUrlsCached(urls, textureCache) {
|
|
2152
1303
|
return urls.every((url) => textureCache.has(url));
|
|
2153
1304
|
}
|
|
@@ -2173,18 +1324,19 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
2173
1324
|
const onLoadRef = useRef(onLoad);
|
|
2174
1325
|
onLoadRef.current = onLoad;
|
|
2175
1326
|
const onLoadCalledForRef = useRef(null);
|
|
2176
|
-
const
|
|
1327
|
+
const inputKey = useMemo(() => inputSignature(input), [input]);
|
|
1328
|
+
const stableInput = useMemo(() => input, [inputKey]);
|
|
1329
|
+
const urls = useMemo(() => getUrls(stableInput), [stableInput]);
|
|
2177
1330
|
const cachedResult = useMemo(() => {
|
|
2178
1331
|
if (!cache) return null;
|
|
2179
1332
|
const textures = store.getState().textures;
|
|
2180
1333
|
if (!allUrlsCached(urls, textures)) return null;
|
|
2181
|
-
return buildFromCache(
|
|
2182
|
-
}, [cache, urls,
|
|
1334
|
+
return buildFromCache(stableInput, textures);
|
|
1335
|
+
}, [cache, urls, stableInput, store]);
|
|
2183
1336
|
const loadedTextures = useLoader(
|
|
2184
1337
|
TextureLoader,
|
|
2185
|
-
IsObject(
|
|
1338
|
+
IsObject(stableInput) ? Object.values(stableInput) : stableInput
|
|
2186
1339
|
);
|
|
2187
|
-
const inputKey = urls.join("\0");
|
|
2188
1340
|
useLayoutEffect(() => {
|
|
2189
1341
|
if (cachedResult) return;
|
|
2190
1342
|
if (onLoadCalledForRef.current === inputKey) return;
|
|
@@ -2211,28 +1363,28 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
2211
1363
|
}, [renderer, loadedTextures, cachedResult]);
|
|
2212
1364
|
const mappedTextures = useMemo(() => {
|
|
2213
1365
|
if (cachedResult) return cachedResult;
|
|
2214
|
-
if (IsObject(
|
|
1366
|
+
if (IsObject(stableInput)) {
|
|
2215
1367
|
const keyed = {};
|
|
2216
1368
|
const textureArray = loadedTextures;
|
|
2217
1369
|
let i = 0;
|
|
2218
|
-
for (const key in
|
|
1370
|
+
for (const key in stableInput) keyed[key] = textureArray[i++];
|
|
2219
1371
|
return keyed;
|
|
2220
1372
|
} else {
|
|
2221
1373
|
return loadedTextures;
|
|
2222
1374
|
}
|
|
2223
|
-
}, [
|
|
1375
|
+
}, [stableInput, loadedTextures, cachedResult]);
|
|
2224
1376
|
useEffect(() => {
|
|
2225
1377
|
if (!cache) return;
|
|
2226
1378
|
const urlTextureMap = [];
|
|
2227
|
-
if (typeof
|
|
2228
|
-
urlTextureMap.push([
|
|
2229
|
-
} else if (Array.isArray(
|
|
1379
|
+
if (typeof stableInput === "string") {
|
|
1380
|
+
urlTextureMap.push([stableInput, mappedTextures]);
|
|
1381
|
+
} else if (Array.isArray(stableInput)) {
|
|
2230
1382
|
const textureArray = mappedTextures;
|
|
2231
|
-
|
|
2232
|
-
} else if (IsObject(
|
|
1383
|
+
stableInput.forEach((url, i) => urlTextureMap.push([url, textureArray[i]]));
|
|
1384
|
+
} else if (IsObject(stableInput)) {
|
|
2233
1385
|
const textureRecord = mappedTextures;
|
|
2234
|
-
for (const key in
|
|
2235
|
-
const url =
|
|
1386
|
+
for (const key in stableInput) {
|
|
1387
|
+
const url = stableInput[key];
|
|
2236
1388
|
urlTextureMap.push([url, textureRecord[key]]);
|
|
2237
1389
|
}
|
|
2238
1390
|
}
|
|
@@ -2261,7 +1413,7 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
2261
1413
|
}
|
|
2262
1414
|
return { _textureRefs: refs };
|
|
2263
1415
|
});
|
|
2264
|
-
}, [cache,
|
|
1416
|
+
}, [cache, stableInput, mappedTextures, store]);
|
|
2265
1417
|
return mappedTextures;
|
|
2266
1418
|
}
|
|
2267
1419
|
useTexture.preload = (url) => useLoader.preload(TextureLoader, url);
|
|
@@ -2356,13 +1508,133 @@ function useRenderTarget(widthOrOptions, heightOrOptions, options) {
|
|
|
2356
1508
|
height = widthOrOptions;
|
|
2357
1509
|
}
|
|
2358
1510
|
}
|
|
2359
|
-
return useMemo(() => {
|
|
2360
|
-
const w = width ?? size.width;
|
|
2361
|
-
const h = height ?? size.height;
|
|
2362
|
-
{
|
|
2363
|
-
return isLegacy ? new WebGLRenderTarget(w, h, opts) : new RenderTarget(w, h, opts);
|
|
2364
|
-
}
|
|
2365
|
-
}, [width, height, size.width, size.height, opts, isLegacy]);
|
|
1511
|
+
return useMemo(() => {
|
|
1512
|
+
const w = width ?? size.width;
|
|
1513
|
+
const h = height ?? size.height;
|
|
1514
|
+
{
|
|
1515
|
+
return isLegacy ? new WebGLRenderTarget(w, h, opts) : new RenderTarget(w, h, opts);
|
|
1516
|
+
}
|
|
1517
|
+
}, [width, height, size.width, size.height, opts, isLegacy]);
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
const presetsObj = {
|
|
1521
|
+
apartment: "lebombo_1k.hdr",
|
|
1522
|
+
city: "potsdamer_platz_1k.hdr",
|
|
1523
|
+
dawn: "kiara_1_dawn_1k.hdr",
|
|
1524
|
+
forest: "forest_slope_1k.hdr",
|
|
1525
|
+
lobby: "st_fagans_interior_1k.hdr",
|
|
1526
|
+
night: "dikhololo_night_1k.hdr",
|
|
1527
|
+
park: "rooitou_park_1k.hdr",
|
|
1528
|
+
studio: "studio_small_03_1k.hdr",
|
|
1529
|
+
sunset: "venice_sunset_1k.hdr",
|
|
1530
|
+
warehouse: "empty_warehouse_01_1k.hdr"
|
|
1531
|
+
};
|
|
1532
|
+
|
|
1533
|
+
const CUBEMAP_ROOT = "https://raw.githack.com/pmndrs/drei-assets/456060a26bbeb8fdf79326f224b6d99b8bcce736/hdri/";
|
|
1534
|
+
const isArray = (arr) => Array.isArray(arr);
|
|
1535
|
+
const defaultFiles = ["/px.png", "/nx.png", "/py.png", "/ny.png", "/pz.png", "/nz.png"];
|
|
1536
|
+
function useEnvironment({
|
|
1537
|
+
files = defaultFiles,
|
|
1538
|
+
path = "",
|
|
1539
|
+
preset = void 0,
|
|
1540
|
+
colorSpace = void 0,
|
|
1541
|
+
extensions
|
|
1542
|
+
} = {}) {
|
|
1543
|
+
if (preset) {
|
|
1544
|
+
validatePreset(preset);
|
|
1545
|
+
files = presetsObj[preset];
|
|
1546
|
+
path = CUBEMAP_ROOT;
|
|
1547
|
+
}
|
|
1548
|
+
const multiFile = isArray(files);
|
|
1549
|
+
const { extension, isCubemap } = getExtension(files);
|
|
1550
|
+
const loader = getLoader(extension);
|
|
1551
|
+
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1552
|
+
const renderer = useThree((state) => state.renderer);
|
|
1553
|
+
useLayoutEffect(() => {
|
|
1554
|
+
if (extension !== "webp" && extension !== "jpg" && extension !== "jpeg") return;
|
|
1555
|
+
function clearGainmapTexture() {
|
|
1556
|
+
useLoader.clear(loader, multiFile ? [files] : files);
|
|
1557
|
+
}
|
|
1558
|
+
renderer.domElement.addEventListener("webglcontextlost", clearGainmapTexture, { once: true });
|
|
1559
|
+
}, [extension, files, loader, multiFile, renderer.domElement]);
|
|
1560
|
+
const loaderResult = useLoader(
|
|
1561
|
+
loader,
|
|
1562
|
+
multiFile ? [files] : files,
|
|
1563
|
+
(loader2) => {
|
|
1564
|
+
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
1565
|
+
loader2.setRenderer?.(renderer);
|
|
1566
|
+
}
|
|
1567
|
+
loader2.setPath?.(path);
|
|
1568
|
+
if (extensions) extensions(loader2);
|
|
1569
|
+
}
|
|
1570
|
+
);
|
|
1571
|
+
let texture = multiFile ? (
|
|
1572
|
+
// @ts-ignore
|
|
1573
|
+
loaderResult[0]
|
|
1574
|
+
) : loaderResult;
|
|
1575
|
+
if (extension === "jpg" || extension === "jpeg" || extension === "webp") {
|
|
1576
|
+
texture = texture.renderTarget?.texture;
|
|
1577
|
+
}
|
|
1578
|
+
texture.mapping = isCubemap ? CubeReflectionMapping : EquirectangularReflectionMapping;
|
|
1579
|
+
texture.colorSpace = colorSpace ?? (isCubemap ? "srgb" : "srgb-linear");
|
|
1580
|
+
return texture;
|
|
1581
|
+
}
|
|
1582
|
+
const preloadDefaultOptions = {
|
|
1583
|
+
files: defaultFiles,
|
|
1584
|
+
path: "",
|
|
1585
|
+
preset: void 0,
|
|
1586
|
+
extensions: void 0
|
|
1587
|
+
};
|
|
1588
|
+
useEnvironment.preload = (preloadOptions) => {
|
|
1589
|
+
const options = { ...preloadDefaultOptions, ...preloadOptions };
|
|
1590
|
+
let { files, path = "" } = options;
|
|
1591
|
+
const { preset, extensions } = options;
|
|
1592
|
+
if (preset) {
|
|
1593
|
+
validatePreset(preset);
|
|
1594
|
+
files = presetsObj[preset];
|
|
1595
|
+
path = CUBEMAP_ROOT;
|
|
1596
|
+
}
|
|
1597
|
+
const { extension } = getExtension(files);
|
|
1598
|
+
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
1599
|
+
throw new Error("useEnvironment: Preloading gainmaps is not supported");
|
|
1600
|
+
}
|
|
1601
|
+
const loader = getLoader(extension);
|
|
1602
|
+
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1603
|
+
useLoader.preload(loader, isArray(files) ? [files] : files, (loader2) => {
|
|
1604
|
+
loader2.setPath?.(path);
|
|
1605
|
+
if (extensions) extensions(loader2);
|
|
1606
|
+
});
|
|
1607
|
+
};
|
|
1608
|
+
const clearDefaultOptins = {
|
|
1609
|
+
files: defaultFiles,
|
|
1610
|
+
preset: void 0
|
|
1611
|
+
};
|
|
1612
|
+
useEnvironment.clear = (clearOptions) => {
|
|
1613
|
+
const options = { ...clearDefaultOptins, ...clearOptions };
|
|
1614
|
+
let { files } = options;
|
|
1615
|
+
const { preset } = options;
|
|
1616
|
+
if (preset) {
|
|
1617
|
+
validatePreset(preset);
|
|
1618
|
+
files = presetsObj[preset];
|
|
1619
|
+
}
|
|
1620
|
+
const { extension } = getExtension(files);
|
|
1621
|
+
const loader = getLoader(extension);
|
|
1622
|
+
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1623
|
+
useLoader.clear(loader, isArray(files) ? [files] : files);
|
|
1624
|
+
};
|
|
1625
|
+
function validatePreset(preset) {
|
|
1626
|
+
if (!(preset in presetsObj)) throw new Error("Preset must be one of: " + Object.keys(presetsObj).join(", "));
|
|
1627
|
+
}
|
|
1628
|
+
function getExtension(files) {
|
|
1629
|
+
const isCubemap = isArray(files) && files.length === 6;
|
|
1630
|
+
const isGainmap = isArray(files) && files.length === 3 && files.some((file) => file.endsWith("json"));
|
|
1631
|
+
const firstEntry = isArray(files) ? files[0] : files;
|
|
1632
|
+
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();
|
|
1633
|
+
return { extension, isCubemap, isGainmap };
|
|
1634
|
+
}
|
|
1635
|
+
function getLoader(extension) {
|
|
1636
|
+
const loader = extension === "cube" ? CubeTextureLoader : extension === "hdr" ? HDRLoader : extension === "exr" ? EXRLoader : extension === "jpg" || extension === "jpeg" ? UltraHDRLoader : extension === "webp" ? GainMapLoader : null;
|
|
1637
|
+
return loader;
|
|
2366
1638
|
}
|
|
2367
1639
|
|
|
2368
1640
|
function useStore() {
|
|
@@ -2382,6 +1654,8 @@ function useGraph(object) {
|
|
|
2382
1654
|
return useMemo(() => buildGraph(object), [object]);
|
|
2383
1655
|
}
|
|
2384
1656
|
|
|
1657
|
+
const t = 1, o = 8, r = 32, e = 2, i$1 = 268435456;
|
|
1658
|
+
|
|
2385
1659
|
let effectId = 0;
|
|
2386
1660
|
function addEffect(callback) {
|
|
2387
1661
|
notifyDepreciated({
|
|
@@ -2410,13 +1684,19 @@ function addTail(callback) {
|
|
|
2410
1684
|
return getScheduler().onIdle(callback);
|
|
2411
1685
|
}
|
|
2412
1686
|
function invalidate(state, frames = 1, stackFrames = false) {
|
|
2413
|
-
|
|
1687
|
+
const rootId = state?.internal?.rootId;
|
|
1688
|
+
const scheduler = getScheduler();
|
|
1689
|
+
if (rootId) scheduler.invalidateRoot(rootId, frames, stackFrames);
|
|
1690
|
+
else scheduler.invalidate(frames, stackFrames);
|
|
2414
1691
|
}
|
|
2415
|
-
function advance(timestamp) {
|
|
2416
|
-
|
|
1692
|
+
function advance(timestamp, runGlobalEffects, state) {
|
|
1693
|
+
const rootId = state?.internal?.rootId;
|
|
1694
|
+
const scheduler = getScheduler();
|
|
1695
|
+
if (rootId) scheduler.stepRoot(rootId, timestamp);
|
|
1696
|
+
else scheduler.step(timestamp);
|
|
2417
1697
|
}
|
|
2418
1698
|
|
|
2419
|
-
const version = "10.0.0-alpha.
|
|
1699
|
+
const version = "10.0.0-alpha.4";
|
|
2420
1700
|
const packageData = {
|
|
2421
1701
|
version: version};
|
|
2422
1702
|
|
|
@@ -13289,390 +12569,973 @@ Check the top-level render call using <` + i + ">.");
|
|
|
13289
12569
|
var i = x.H;
|
|
13290
12570
|
x.H = $o;
|
|
13291
12571
|
try {
|
|
13292
|
-
return Br(e, n, o);
|
|
13293
|
-
} finally {
|
|
13294
|
-
x.H = i;
|
|
12572
|
+
return Br(e, n, o);
|
|
12573
|
+
} finally {
|
|
12574
|
+
x.H = i;
|
|
12575
|
+
}
|
|
12576
|
+
}, useRef: function() {
|
|
12577
|
+
return z = "useRef", D(), N(), xe().memoizedState;
|
|
12578
|
+
}, useState: function() {
|
|
12579
|
+
z = "useState", D(), N();
|
|
12580
|
+
var e = x.H;
|
|
12581
|
+
x.H = $o;
|
|
12582
|
+
try {
|
|
12583
|
+
return Br(gr);
|
|
12584
|
+
} finally {
|
|
12585
|
+
x.H = e;
|
|
12586
|
+
}
|
|
12587
|
+
}, useDebugValue: function() {
|
|
12588
|
+
z = "useDebugValue", D(), N();
|
|
12589
|
+
}, useDeferredValue: function(e, n) {
|
|
12590
|
+
return z = "useDeferredValue", D(), N(), nc(e, n);
|
|
12591
|
+
}, useTransition: function() {
|
|
12592
|
+
return z = "useTransition", D(), N(), Qp();
|
|
12593
|
+
}, useSyncExternalStore: function(e, n, o) {
|
|
12594
|
+
return z = "useSyncExternalStore", D(), N(), ta(e, n, o);
|
|
12595
|
+
}, useId: function() {
|
|
12596
|
+
return z = "useId", D(), N(), xe().memoizedState;
|
|
12597
|
+
}, useFormState: function(e) {
|
|
12598
|
+
return z = "useFormState", D(), N(), hs(e);
|
|
12599
|
+
}, useActionState: function(e) {
|
|
12600
|
+
return z = "useActionState", D(), N(), hs(e);
|
|
12601
|
+
}, useOptimistic: function(e, n) {
|
|
12602
|
+
return z = "useOptimistic", D(), N(), rf(e, n);
|
|
12603
|
+
}, useMemoCache: function(e) {
|
|
12604
|
+
return D(), Oa(e);
|
|
12605
|
+
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
12606
|
+
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
12607
|
+
}, useEffectEvent: function(e) {
|
|
12608
|
+
return z = "useEffectEvent", D(), N(), oa(e);
|
|
12609
|
+
} }, dm = { readContext: function(e) {
|
|
12610
|
+
return Ce(), Ee(e);
|
|
12611
|
+
}, use: function(e) {
|
|
12612
|
+
return D(), we(e);
|
|
12613
|
+
}, useCallback: function(e, n) {
|
|
12614
|
+
return z = "useCallback", D(), N(), Ma(e, n);
|
|
12615
|
+
}, useContext: function(e) {
|
|
12616
|
+
return z = "useContext", D(), N(), Ee(e);
|
|
12617
|
+
}, useEffect: function(e, n) {
|
|
12618
|
+
z = "useEffect", D(), N(), Qn(2048, Ut, e, n);
|
|
12619
|
+
}, useImperativeHandle: function(e, n, o) {
|
|
12620
|
+
return z = "useImperativeHandle", D(), N(), aa(e, n, o);
|
|
12621
|
+
}, useInsertionEffect: function(e, n) {
|
|
12622
|
+
return z = "useInsertionEffect", D(), N(), Qn(4, Wt, e, n);
|
|
12623
|
+
}, useLayoutEffect: function(e, n) {
|
|
12624
|
+
return z = "useLayoutEffect", D(), N(), Qn(4, Rr, e, n);
|
|
12625
|
+
}, useMemo: function(e, n) {
|
|
12626
|
+
z = "useMemo", D(), N();
|
|
12627
|
+
var o = x.H;
|
|
12628
|
+
x.H = $o;
|
|
12629
|
+
try {
|
|
12630
|
+
return Vi(e, n);
|
|
12631
|
+
} finally {
|
|
12632
|
+
x.H = o;
|
|
12633
|
+
}
|
|
12634
|
+
}, useReducer: function(e, n, o) {
|
|
12635
|
+
z = "useReducer", D(), N();
|
|
12636
|
+
var i = x.H;
|
|
12637
|
+
x.H = $o;
|
|
12638
|
+
try {
|
|
12639
|
+
return Qi(e, n, o);
|
|
12640
|
+
} finally {
|
|
12641
|
+
x.H = i;
|
|
12642
|
+
}
|
|
12643
|
+
}, useRef: function() {
|
|
12644
|
+
return z = "useRef", D(), N(), xe().memoizedState;
|
|
12645
|
+
}, useState: function() {
|
|
12646
|
+
z = "useState", D(), N();
|
|
12647
|
+
var e = x.H;
|
|
12648
|
+
x.H = $o;
|
|
12649
|
+
try {
|
|
12650
|
+
return Qi(gr);
|
|
12651
|
+
} finally {
|
|
12652
|
+
x.H = e;
|
|
12653
|
+
}
|
|
12654
|
+
}, useDebugValue: function() {
|
|
12655
|
+
z = "useDebugValue", D(), N();
|
|
12656
|
+
}, useDeferredValue: function(e, n) {
|
|
12657
|
+
return z = "useDeferredValue", D(), N(), sf(e, n);
|
|
12658
|
+
}, useTransition: function() {
|
|
12659
|
+
return z = "useTransition", D(), N(), Ro();
|
|
12660
|
+
}, useSyncExternalStore: function(e, n, o) {
|
|
12661
|
+
return z = "useSyncExternalStore", D(), N(), ta(e, n, o);
|
|
12662
|
+
}, useId: function() {
|
|
12663
|
+
return z = "useId", D(), N(), xe().memoizedState;
|
|
12664
|
+
}, useFormState: function(e) {
|
|
12665
|
+
return z = "useFormState", D(), N(), $t(e);
|
|
12666
|
+
}, useActionState: function(e) {
|
|
12667
|
+
return z = "useActionState", D(), N(), $t(e);
|
|
12668
|
+
}, useOptimistic: function(e, n) {
|
|
12669
|
+
return z = "useOptimistic", D(), N(), of(e, n);
|
|
12670
|
+
}, useMemoCache: function(e) {
|
|
12671
|
+
return D(), Oa(e);
|
|
12672
|
+
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
12673
|
+
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
12674
|
+
}, useEffectEvent: function(e) {
|
|
12675
|
+
return z = "useEffectEvent", D(), N(), oa(e);
|
|
12676
|
+
} };
|
|
12677
|
+
var Fy = {}, Hy = /* @__PURE__ */ new Set(), Ay = /* @__PURE__ */ new Set(), jy = /* @__PURE__ */ new Set(), Dy = /* @__PURE__ */ new Set(), Wy = /* @__PURE__ */ new Set(), Uy = /* @__PURE__ */ new Set(), By = /* @__PURE__ */ new Set(), Oy = /* @__PURE__ */ new Set(), My = /* @__PURE__ */ new Set(), Qy = /* @__PURE__ */ new Set();
|
|
12678
|
+
Object.freeze(Fy);
|
|
12679
|
+
var zg = { enqueueSetState: function(e, n, o) {
|
|
12680
|
+
e = e._reactInternals;
|
|
12681
|
+
var i = Nt(e), s = zo(i);
|
|
12682
|
+
s.payload = n, o != null && (df(o), s.callback = o), n = Mt(e, s, i), n !== null && (ur(i, "this.setState()", e), We(n, e, i), Bi(n, e, i));
|
|
12683
|
+
}, enqueueReplaceState: function(e, n, o) {
|
|
12684
|
+
e = e._reactInternals;
|
|
12685
|
+
var i = Nt(e), s = zo(i);
|
|
12686
|
+
s.tag = Cy, s.payload = n, o != null && (df(o), s.callback = o), n = Mt(e, s, i), n !== null && (ur(i, "this.replaceState()", e), We(n, e, i), Bi(n, e, i));
|
|
12687
|
+
}, enqueueForceUpdate: function(e, n) {
|
|
12688
|
+
e = e._reactInternals;
|
|
12689
|
+
var o = Nt(e), i = zo(o);
|
|
12690
|
+
i.tag = Ty, n != null && (df(n), i.callback = n), n = Mt(e, i, o), n !== null && (ur(o, "this.forceUpdate()", e), We(n, e, o), Bi(n, e, o));
|
|
12691
|
+
} }, bd = null, Cg = null, Tg = Error("This is not a real error. It's an implementation detail of React's selective hydration feature. If this leaks into userspace, it's a bug in React. Please file an issue."), Cn = false, $y = {}, Vy = {}, qy = {}, Gy = {}, vd = false, Jy = {}, fm = {}, _g = { dehydrated: null, treeContext: null, retryLane: 0, hydrationErrors: null }, Zy = false, Yy = null;
|
|
12692
|
+
Yy = /* @__PURE__ */ new Set();
|
|
12693
|
+
var Si = false, Tn = false, Rg = false, Xy = typeof WeakSet == "function" ? WeakSet : Set, Gn = null, Sd = null, kd = null, _n = null, nr = false, Vo = null, Wn = false, wd = 8192, Vb = { getCacheForType: function(e) {
|
|
12694
|
+
var n = Ee(un), o = n.data.get(e);
|
|
12695
|
+
return o === void 0 && (o = e(), n.data.set(e, o)), o;
|
|
12696
|
+
}, cacheSignal: function() {
|
|
12697
|
+
return Ee(un).controller.signal;
|
|
12698
|
+
}, getOwner: function() {
|
|
12699
|
+
return di;
|
|
12700
|
+
} }, pm = 0, hm = 1, mm = 2, gm = 3, ym = 4;
|
|
12701
|
+
if (typeof Symbol == "function" && Symbol.for) {
|
|
12702
|
+
var bp = Symbol.for;
|
|
12703
|
+
pm = bp("selector.component"), hm = bp("selector.has_pseudo_class"), mm = bp("selector.role"), gm = bp("selector.test_id"), ym = bp("selector.text");
|
|
12704
|
+
}
|
|
12705
|
+
var bm = [], qb = typeof WeakMap == "function" ? WeakMap : Map, Jn = 0, Zn = 2, uo = 4, ki = 0, vp = 1, iu = 2, vm = 3, Tl = 4, Sm = 6, Ky = 5, ye = Jn, je = null, se = null, ae = 0, tr = 0, km = 1, lu = 2, Sp = 3, eb = 4, Eg = 5, kp = 6, wm = 7, Ig = 8, su = 9, Le = tr, Er = null, _l = false, Pd = false, Lg = false, Ta = 0, nn = ki, Rl = 0, El = 0, Ng = 0, rr = 0, uu = 0, wp = null, Bt = null, Pm = false, xm = 0, nb = 0, tb = 300, Pp = 1 / 0, Fg = 500, xp = null, gn = null, Il = null, zm = 0, Hg = 1, Ag = 2, rb = 3, Ll = 0, ob = 1, ab = 2, ib = 3, lb = 4, Cm = 5, Rn = 0, Nl = null, xd = null, qo = 0, jg = 0, Dg = -0, Wg = null, sb = null, ub = null, Go = zm, cb = null, Gb = 50, zp = 0, Ug = null, Bg = false, Tm = false, Jb = 50, cu = 0, Cp = null, zd = false, _m = null, db = false, fb = /* @__PURE__ */ new Set(), Zb = {}, co = null, Cd = null, pb = false;
|
|
12706
|
+
try {
|
|
12707
|
+
var o0 = Object.preventExtensions({});
|
|
12708
|
+
} catch {
|
|
12709
|
+
pb = true;
|
|
12710
|
+
}
|
|
12711
|
+
var hb = false, mb = {}, gb = null, yb = null, bb = null, vb = null, Sb = null, kb = null, wb = null, Pb = null, xb = null, zb = null;
|
|
12712
|
+
return gb = function(e, n, o, i) {
|
|
12713
|
+
n = Yn(e, n), n !== null && (o = _d(n.memoizedState, o, 0, i), n.memoizedState = o, n.baseState = o, e.memoizedProps = ze({}, e.memoizedProps), o = On(e, 2), o !== null && We(o, e, 2));
|
|
12714
|
+
}, yb = function(e, n, o) {
|
|
12715
|
+
n = Yn(e, n), n !== null && (o = du(n.memoizedState, o, 0), n.memoizedState = o, n.baseState = o, e.memoizedProps = ze({}, e.memoizedProps), o = On(e, 2), o !== null && We(o, e, 2));
|
|
12716
|
+
}, bb = function(e, n, o, i) {
|
|
12717
|
+
n = Yn(e, n), n !== null && (o = F(n.memoizedState, o, i), n.memoizedState = o, n.baseState = o, e.memoizedProps = ze({}, e.memoizedProps), o = On(e, 2), o !== null && We(o, e, 2));
|
|
12718
|
+
}, vb = function(e, n, o) {
|
|
12719
|
+
e.pendingProps = _d(e.memoizedProps, n, 0, o), e.alternate && (e.alternate.pendingProps = e.pendingProps), n = On(e, 2), n !== null && We(n, e, 2);
|
|
12720
|
+
}, Sb = function(e, n) {
|
|
12721
|
+
e.pendingProps = du(e.memoizedProps, n, 0), e.alternate && (e.alternate.pendingProps = e.pendingProps), n = On(e, 2), n !== null && We(n, e, 2);
|
|
12722
|
+
}, kb = function(e, n, o) {
|
|
12723
|
+
e.pendingProps = F(e.memoizedProps, n, o), e.alternate && (e.alternate.pendingProps = e.pendingProps), n = On(e, 2), n !== null && We(n, e, 2);
|
|
12724
|
+
}, wb = function(e) {
|
|
12725
|
+
var n = On(e, 2);
|
|
12726
|
+
n !== null && We(n, e, 2);
|
|
12727
|
+
}, Pb = function(e) {
|
|
12728
|
+
var n = ut(), o = On(e, n);
|
|
12729
|
+
o !== null && We(o, e, n);
|
|
12730
|
+
}, xb = function(e) {
|
|
12731
|
+
pu = e;
|
|
12732
|
+
}, zb = function(e) {
|
|
12733
|
+
fu = e;
|
|
12734
|
+
}, le.attemptContinuousHydration = function(e) {
|
|
12735
|
+
if (e.tag === 13 || e.tag === 31) {
|
|
12736
|
+
var n = On(e, 67108864);
|
|
12737
|
+
n !== null && We(n, e, 67108864), rl(e, 67108864);
|
|
12738
|
+
}
|
|
12739
|
+
}, le.attemptHydrationAtCurrentPriority = function(e) {
|
|
12740
|
+
if (e.tag === 13 || e.tag === 31) {
|
|
12741
|
+
var n = Nt(e);
|
|
12742
|
+
n = Xo(n);
|
|
12743
|
+
var o = On(e, n);
|
|
12744
|
+
o !== null && We(o, e, n), rl(e, n);
|
|
12745
|
+
}
|
|
12746
|
+
}, le.attemptSynchronousHydration = function(e) {
|
|
12747
|
+
switch (e.tag) {
|
|
12748
|
+
case 3:
|
|
12749
|
+
if (e = e.stateNode, e.current.memoizedState.isDehydrated) {
|
|
12750
|
+
var n = _t(e.pendingLanes);
|
|
12751
|
+
if (n !== 0) {
|
|
12752
|
+
for (e.pendingLanes |= 2, e.entangledLanes |= 2; n; ) {
|
|
12753
|
+
var o = 1 << 31 - vn(n);
|
|
12754
|
+
e.entanglements[1] |= o, n &= ~o;
|
|
12755
|
+
}
|
|
12756
|
+
Kn(e), (ye & (Zn | uo)) === Jn && (Pp = me() + Fg, Wa(0));
|
|
12757
|
+
}
|
|
12758
|
+
}
|
|
12759
|
+
break;
|
|
12760
|
+
case 31:
|
|
12761
|
+
case 13:
|
|
12762
|
+
n = On(e, 2), n !== null && We(n, e, 2), Ls(), rl(e, 2);
|
|
12763
|
+
}
|
|
12764
|
+
}, le.batchedUpdates = function(e, n) {
|
|
12765
|
+
return e(n);
|
|
12766
|
+
}, le.createComponentSelector = function(e) {
|
|
12767
|
+
return { $$typeof: pm, value: e };
|
|
12768
|
+
}, le.createContainer = function(e, n, o, i, s, u, f, p, g, S) {
|
|
12769
|
+
return Ka(e, n, false, null, o, i, u, null, f, p, g, S);
|
|
12770
|
+
}, le.createHasPseudoClassSelector = function(e) {
|
|
12771
|
+
return { $$typeof: hm, value: e };
|
|
12772
|
+
}, le.createHydrationContainer = function(e, n, o, i, s, u, f, p, g, S, T, _, I, O) {
|
|
12773
|
+
return e = Ka(o, i, true, e, s, u, p, O, g, S, T, _), e.context = Dh(null), o = e.current, i = Nt(o), i = Xo(i), s = zo(i), s.callback = n ?? null, Mt(o, s, i), ur(i, "hydrateRoot()", null), n = i, e.current.lanes = n, Ci(e, n), Kn(e), e;
|
|
12774
|
+
}, le.createPortal = function(e, n, o) {
|
|
12775
|
+
var i = 3 < arguments.length && arguments[3] !== void 0 ? arguments[3] : null;
|
|
12776
|
+
try {
|
|
12777
|
+
vt(i);
|
|
12778
|
+
var s = false;
|
|
12779
|
+
} catch {
|
|
12780
|
+
s = true;
|
|
13295
12781
|
}
|
|
13296
|
-
|
|
13297
|
-
|
|
13298
|
-
|
|
13299
|
-
|
|
13300
|
-
|
|
13301
|
-
|
|
12782
|
+
return s && (console.error("The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", typeof Symbol == "function" && Symbol.toStringTag && i[Symbol.toStringTag] || i.constructor.name || "Object"), vt(i)), { $$typeof: Ao, key: i == null ? null : "" + i, children: e, containerInfo: n, implementation: o };
|
|
12783
|
+
}, le.createRoleSelector = function(e) {
|
|
12784
|
+
return { $$typeof: mm, value: e };
|
|
12785
|
+
}, le.createTestNameSelector = function(e) {
|
|
12786
|
+
return { $$typeof: gm, value: e };
|
|
12787
|
+
}, le.createTextSelector = function(e) {
|
|
12788
|
+
return { $$typeof: ym, value: e };
|
|
12789
|
+
}, le.defaultOnCaughtError = function(e) {
|
|
12790
|
+
var n = bd ? "The above error occurred in the <" + bd + "> component." : "The above error occurred in one of your React components.", o = "React will try to recreate this component tree from scratch using the error boundary you provided, " + ((Cg || "Anonymous") + ".");
|
|
12791
|
+
typeof e == "object" && e !== null && typeof e.environmentName == "string" ? ri("error", [`%o
|
|
12792
|
+
|
|
12793
|
+
%s
|
|
12794
|
+
|
|
12795
|
+
%s
|
|
12796
|
+
`, e, n, o], e.environmentName)() : console.error(`%o
|
|
12797
|
+
|
|
12798
|
+
%s
|
|
12799
|
+
|
|
12800
|
+
%s
|
|
12801
|
+
`, e, n, o);
|
|
12802
|
+
}, le.defaultOnRecoverableError = function(e) {
|
|
12803
|
+
qg(e);
|
|
12804
|
+
}, le.defaultOnUncaughtError = function(e) {
|
|
12805
|
+
qg(e), console.warn(`%s
|
|
12806
|
+
|
|
12807
|
+
%s
|
|
12808
|
+
`, bd ? "An error occurred in the <" + bd + "> component." : "An error occurred in one of your React components.", `Consider adding an error boundary to your tree to customize error handling behavior.
|
|
12809
|
+
Visit https://react.dev/link/error-boundaries to learn more about error boundaries.`);
|
|
12810
|
+
}, le.deferredUpdates = function(e) {
|
|
12811
|
+
var n = x.T, o = wt();
|
|
13302
12812
|
try {
|
|
13303
|
-
return
|
|
12813
|
+
return an(32), x.T = null, e();
|
|
13304
12814
|
} finally {
|
|
13305
|
-
x.
|
|
12815
|
+
an(o), x.T = n;
|
|
13306
12816
|
}
|
|
13307
|
-
},
|
|
13308
|
-
|
|
13309
|
-
}, useDeferredValue: function(e, n) {
|
|
13310
|
-
return z = "useDeferredValue", D(), N(), nc(e, n);
|
|
13311
|
-
}, useTransition: function() {
|
|
13312
|
-
return z = "useTransition", D(), N(), Qp();
|
|
13313
|
-
}, useSyncExternalStore: function(e, n, o) {
|
|
13314
|
-
return z = "useSyncExternalStore", D(), N(), ta(e, n, o);
|
|
13315
|
-
}, useId: function() {
|
|
13316
|
-
return z = "useId", D(), N(), xe().memoizedState;
|
|
13317
|
-
}, useFormState: function(e) {
|
|
13318
|
-
return z = "useFormState", D(), N(), hs(e);
|
|
13319
|
-
}, useActionState: function(e) {
|
|
13320
|
-
return z = "useActionState", D(), N(), hs(e);
|
|
13321
|
-
}, useOptimistic: function(e, n) {
|
|
13322
|
-
return z = "useOptimistic", D(), N(), rf(e, n);
|
|
13323
|
-
}, useMemoCache: function(e) {
|
|
13324
|
-
return D(), Oa(e);
|
|
13325
|
-
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
13326
|
-
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
13327
|
-
}, useEffectEvent: function(e) {
|
|
13328
|
-
return z = "useEffectEvent", D(), N(), oa(e);
|
|
13329
|
-
} }, dm = { readContext: function(e) {
|
|
13330
|
-
return Ce(), Ee(e);
|
|
13331
|
-
}, use: function(e) {
|
|
13332
|
-
return D(), we(e);
|
|
13333
|
-
}, useCallback: function(e, n) {
|
|
13334
|
-
return z = "useCallback", D(), N(), Ma(e, n);
|
|
13335
|
-
}, useContext: function(e) {
|
|
13336
|
-
return z = "useContext", D(), N(), Ee(e);
|
|
13337
|
-
}, useEffect: function(e, n) {
|
|
13338
|
-
z = "useEffect", D(), N(), Qn(2048, Ut, e, n);
|
|
13339
|
-
}, useImperativeHandle: function(e, n, o) {
|
|
13340
|
-
return z = "useImperativeHandle", D(), N(), aa(e, n, o);
|
|
13341
|
-
}, useInsertionEffect: function(e, n) {
|
|
13342
|
-
return z = "useInsertionEffect", D(), N(), Qn(4, Wt, e, n);
|
|
13343
|
-
}, useLayoutEffect: function(e, n) {
|
|
13344
|
-
return z = "useLayoutEffect", D(), N(), Qn(4, Rr, e, n);
|
|
13345
|
-
}, useMemo: function(e, n) {
|
|
13346
|
-
z = "useMemo", D(), N();
|
|
13347
|
-
var o = x.H;
|
|
13348
|
-
x.H = $o;
|
|
12817
|
+
}, le.discreteUpdates = function(e, n, o, i, s) {
|
|
12818
|
+
var u = x.T, f = wt();
|
|
13349
12819
|
try {
|
|
13350
|
-
return
|
|
12820
|
+
return an(2), x.T = null, e(n, o, i, s);
|
|
13351
12821
|
} finally {
|
|
13352
|
-
x.
|
|
12822
|
+
an(f), x.T = u, ye === Jn && (Pp = me() + Fg);
|
|
13353
12823
|
}
|
|
13354
|
-
},
|
|
13355
|
-
|
|
13356
|
-
|
|
13357
|
-
|
|
13358
|
-
|
|
13359
|
-
|
|
13360
|
-
|
|
13361
|
-
|
|
12824
|
+
}, le.findAllNodes = kc, le.findBoundingRects = function(e, n) {
|
|
12825
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12826
|
+
n = kc(e, n), e = [];
|
|
12827
|
+
for (var o = 0; o < n.length; o++) e.push(ma(n[o]));
|
|
12828
|
+
for (n = e.length - 1; 0 < n; n--) {
|
|
12829
|
+
o = e[n];
|
|
12830
|
+
for (var i = o.x, s = i + o.width, u = o.y, f = u + o.height, p = n - 1; 0 <= p; p--) if (n !== p) {
|
|
12831
|
+
var g = e[p], S = g.x, T = S + g.width, _ = g.y, I = _ + g.height;
|
|
12832
|
+
if (i >= S && u >= _ && s <= T && f <= I) {
|
|
12833
|
+
e.splice(n, 1);
|
|
12834
|
+
break;
|
|
12835
|
+
} else if (i !== S || o.width !== g.width || I < u || _ > f) {
|
|
12836
|
+
if (!(u !== _ || o.height !== g.height || T < i || S > s)) {
|
|
12837
|
+
S > i && (g.width += S - i, g.x = i), T < s && (g.width = s - S), e.splice(n, 1);
|
|
12838
|
+
break;
|
|
12839
|
+
}
|
|
12840
|
+
} else {
|
|
12841
|
+
_ > u && (g.height += _ - u, g.y = u), I < f && (g.height = f - _), e.splice(n, 1);
|
|
12842
|
+
break;
|
|
12843
|
+
}
|
|
12844
|
+
}
|
|
13362
12845
|
}
|
|
13363
|
-
|
|
13364
|
-
|
|
13365
|
-
|
|
13366
|
-
|
|
13367
|
-
|
|
13368
|
-
|
|
12846
|
+
return e;
|
|
12847
|
+
}, le.findHostInstance = function(e) {
|
|
12848
|
+
var n = e._reactInternals;
|
|
12849
|
+
if (n === void 0) throw typeof e.render == "function" ? Error("Unable to find node on an unmounted component.") : (e = Object.keys(e).join(","), Error("Argument appears to not be a ReactComponent. Keys: " + e));
|
|
12850
|
+
return e = mu(n), e === null ? null : ot(e.stateNode);
|
|
12851
|
+
}, le.findHostInstanceWithNoPortals = function(e) {
|
|
12852
|
+
return e = Ed(e), e = e !== null ? _p(e) : null, e === null ? null : ot(e.stateNode);
|
|
12853
|
+
}, le.findHostInstanceWithWarning = function(e, n) {
|
|
12854
|
+
var o = e._reactInternals;
|
|
12855
|
+
if (o === void 0) throw typeof e.render == "function" ? Error("Unable to find node on an unmounted component.") : (e = Object.keys(e).join(","), Error("Argument appears to not be a ReactComponent. Keys: " + e));
|
|
12856
|
+
if (e = mu(o), e === null) return null;
|
|
12857
|
+
if (e.mode & 8) {
|
|
12858
|
+
var i = G(o) || "Component";
|
|
12859
|
+
mb[i] || (mb[i] = true, B(e, function() {
|
|
12860
|
+
o.mode & 8 ? console.error("%s is deprecated in StrictMode. %s was passed an instance of %s which is inside StrictMode. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://react.dev/link/strict-mode-find-node", n, n, i) : console.error("%s is deprecated in StrictMode. %s was passed an instance of %s which renders StrictMode children. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://react.dev/link/strict-mode-find-node", n, n, i);
|
|
12861
|
+
}));
|
|
12862
|
+
}
|
|
12863
|
+
return ot(e.stateNode);
|
|
12864
|
+
}, le.flushPassiveEffects = el, le.flushSyncFromReconciler = function(e) {
|
|
12865
|
+
var n = ye;
|
|
12866
|
+
ye |= 1;
|
|
12867
|
+
var o = x.T, i = wt();
|
|
13369
12868
|
try {
|
|
13370
|
-
return
|
|
12869
|
+
if (an(2), x.T = null, e) return e();
|
|
13371
12870
|
} finally {
|
|
13372
|
-
x.
|
|
12871
|
+
an(i), x.T = o, ye = n, (ye & (Zn | uo)) === Jn && Wa(0);
|
|
12872
|
+
}
|
|
12873
|
+
}, le.flushSyncWork = Ls, le.focusWithin = function(e, n) {
|
|
12874
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12875
|
+
for (e = Ef(e), n = hh(e, n), n = Array.from(n), e = 0; e < n.length; ) {
|
|
12876
|
+
var o = n[e++], i = o.tag;
|
|
12877
|
+
if (!Kr(o)) {
|
|
12878
|
+
if ((i === 5 || i === 26 || i === 27) && Ft(o.stateNode)) return true;
|
|
12879
|
+
for (o = o.child; o !== null; ) n.push(o), o = o.sibling;
|
|
12880
|
+
}
|
|
12881
|
+
}
|
|
12882
|
+
return false;
|
|
12883
|
+
}, le.getFindAllNodesFailureDescription = function(e, n) {
|
|
12884
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12885
|
+
var o = 0, i = [];
|
|
12886
|
+
e = [Ef(e), 0];
|
|
12887
|
+
for (var s = 0; s < e.length; ) {
|
|
12888
|
+
var u = e[s++], f = u.tag, p = e[s++], g = n[p];
|
|
12889
|
+
if ((f !== 5 && f !== 26 && f !== 27 || !Kr(u)) && (If(u, g) && (i.push(Sc(g)), p++, p > o && (o = p)), p < n.length)) for (u = u.child; u !== null; ) e.push(u, p), u = u.sibling;
|
|
12890
|
+
}
|
|
12891
|
+
if (o < n.length) {
|
|
12892
|
+
for (e = []; o < n.length; o++) e.push(Sc(n[o]));
|
|
12893
|
+
return `findAllNodes was able to match part of the selector:
|
|
12894
|
+
` + (i.join(" > ") + `
|
|
12895
|
+
|
|
12896
|
+
No matching component was found for:
|
|
12897
|
+
`) + e.join(" > ");
|
|
12898
|
+
}
|
|
12899
|
+
return null;
|
|
12900
|
+
}, le.getPublicRootInstance = function(e) {
|
|
12901
|
+
if (e = e.current, !e.child) return null;
|
|
12902
|
+
switch (e.child.tag) {
|
|
12903
|
+
case 27:
|
|
12904
|
+
case 5:
|
|
12905
|
+
return ot(e.child.stateNode);
|
|
12906
|
+
default:
|
|
12907
|
+
return e.child.stateNode;
|
|
12908
|
+
}
|
|
12909
|
+
}, le.injectIntoDevTools = function() {
|
|
12910
|
+
var e = { bundleType: 1, version: Jt, rendererPackageName: Zt, currentDispatcherRef: x, reconcilerVersion: "19.2.0" };
|
|
12911
|
+
return jo !== null && (e.rendererConfig = jo), e.overrideHookState = gb, e.overrideHookStateDeletePath = yb, e.overrideHookStateRenamePath = bb, e.overrideProps = vb, e.overridePropsDeletePath = Sb, e.overridePropsRenamePath = kb, e.scheduleUpdate = wb, e.scheduleRetry = Pb, e.setErrorHandler = xb, e.setSuspenseHandler = zb, e.scheduleRefresh = hu, e.scheduleRoot = Fl, e.setRefreshHandler = Ir, e.getCurrentFiber = Ic, Ep(e);
|
|
12912
|
+
}, le.isAlreadyRendering = Ns, le.observeVisibleRects = function(e, n, o, i) {
|
|
12913
|
+
function s() {
|
|
12914
|
+
var S = kc(e, n);
|
|
12915
|
+
u.forEach(function(T) {
|
|
12916
|
+
0 > S.indexOf(T) && g(T);
|
|
12917
|
+
}), S.forEach(function(T) {
|
|
12918
|
+
0 > u.indexOf(T) && p(T);
|
|
12919
|
+
});
|
|
12920
|
+
}
|
|
12921
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12922
|
+
var u = kc(e, n);
|
|
12923
|
+
o = zr(u, o, i);
|
|
12924
|
+
var f = o.disconnect, p = o.observe, g = o.unobserve;
|
|
12925
|
+
return bm.push(s), { disconnect: function() {
|
|
12926
|
+
var S = bm.indexOf(s);
|
|
12927
|
+
0 <= S && bm.splice(S, 1), f();
|
|
12928
|
+
} };
|
|
12929
|
+
}, le.shouldError = function(e) {
|
|
12930
|
+
return pu(e);
|
|
12931
|
+
}, le.shouldSuspend = function(e) {
|
|
12932
|
+
return fu(e);
|
|
12933
|
+
}, le.startHostTransition = function(e, n, o, i) {
|
|
12934
|
+
if (e.tag !== 5) throw Error("Expected the form instance to be a HostComponent. This is a bug in React.");
|
|
12935
|
+
var s = uf(e).queue;
|
|
12936
|
+
Hp(e), nt(e, s, n, Xt, o === null ? Em : function() {
|
|
12937
|
+
x.T === null && console.error("requestFormReset was called outside a transition or action. To fix, move to an action, or wrap with startTransition.");
|
|
12938
|
+
var u = uf(e);
|
|
12939
|
+
return u.next === null && (u = e.alternate.memoizedState), qi(e, u.next.queue, {}, Nt(e)), o(i);
|
|
12940
|
+
});
|
|
12941
|
+
}, le.updateContainer = function(e, n, o, i) {
|
|
12942
|
+
var s = n.current, u = Nt(s);
|
|
12943
|
+
return As(s, u, e, n, o, i), u;
|
|
12944
|
+
}, le.updateContainerSync = Wh, le;
|
|
12945
|
+
}, Tt.exports.default = Tt.exports, Object.defineProperty(Tt.exports, "__esModule", { value: true }));
|
|
12946
|
+
})(Mg)), Mg.exports;
|
|
12947
|
+
}
|
|
12948
|
+
var Eb;
|
|
12949
|
+
function n0() {
|
|
12950
|
+
return Eb || (Eb = 1, process.env.NODE_ENV === "production" ? Rm.exports = Kb() : Rm.exports = e0()), Rm.exports;
|
|
12951
|
+
}
|
|
12952
|
+
var t0 = n0();
|
|
12953
|
+
const r0 = Xb(t0);
|
|
12954
|
+
|
|
12955
|
+
const DEFAULT_POINTER_ID = 0;
|
|
12956
|
+
const XR_POINTER_ID_START = 1e3;
|
|
12957
|
+
function getPointerState(internal, pointerId) {
|
|
12958
|
+
let state = internal.pointerMap.get(pointerId);
|
|
12959
|
+
if (!state) {
|
|
12960
|
+
state = {
|
|
12961
|
+
hovered: /* @__PURE__ */ new Map(),
|
|
12962
|
+
captured: /* @__PURE__ */ new Map(),
|
|
12963
|
+
initialClick: [0, 0],
|
|
12964
|
+
initialHits: []
|
|
12965
|
+
};
|
|
12966
|
+
internal.pointerMap.set(pointerId, state);
|
|
12967
|
+
}
|
|
12968
|
+
return state;
|
|
12969
|
+
}
|
|
12970
|
+
function getPointerId(event) {
|
|
12971
|
+
return "pointerId" in event ? event.pointerId : DEFAULT_POINTER_ID;
|
|
12972
|
+
}
|
|
12973
|
+
function makeId(event) {
|
|
12974
|
+
return (event.eventObject || event.object).uuid + "/" + event.index + event.instanceId;
|
|
12975
|
+
}
|
|
12976
|
+
function releaseInternalPointerCapture(internal, obj, pointerId) {
|
|
12977
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
12978
|
+
if (!pointerState) return;
|
|
12979
|
+
const captureData = pointerState.captured.get(obj);
|
|
12980
|
+
if (captureData) {
|
|
12981
|
+
pointerState.captured.delete(obj);
|
|
12982
|
+
try {
|
|
12983
|
+
captureData.target.releasePointerCapture?.(pointerId);
|
|
12984
|
+
} catch {
|
|
12985
|
+
}
|
|
12986
|
+
}
|
|
12987
|
+
}
|
|
12988
|
+
function swapInteractivity(store, object, newObject) {
|
|
12989
|
+
const { internal } = store.getState();
|
|
12990
|
+
for (let i = 0; i < internal.interaction.length; i++) {
|
|
12991
|
+
if (internal.interaction[i] === object) internal.interaction[i] = newObject;
|
|
12992
|
+
}
|
|
12993
|
+
for (const pointerState of internal.pointerMap.values()) {
|
|
12994
|
+
for (let i = 0; i < pointerState.initialHits.length; i++) {
|
|
12995
|
+
if (pointerState.initialHits[i] === object) pointerState.initialHits[i] = newObject;
|
|
12996
|
+
}
|
|
12997
|
+
pointerState.hovered.forEach((value, key) => {
|
|
12998
|
+
if (value.eventObject === object || value.object === object) {
|
|
12999
|
+
pointerState.hovered.delete(key);
|
|
13000
|
+
const next = {
|
|
13001
|
+
...value,
|
|
13002
|
+
eventObject: value.eventObject === object ? newObject : value.eventObject,
|
|
13003
|
+
object: value.object === object ? newObject : value.object
|
|
13004
|
+
};
|
|
13005
|
+
pointerState.hovered.set(makeId(next), next);
|
|
13006
|
+
}
|
|
13007
|
+
});
|
|
13008
|
+
const captureData = pointerState.captured.get(object);
|
|
13009
|
+
if (captureData) {
|
|
13010
|
+
pointerState.captured.delete(object);
|
|
13011
|
+
pointerState.captured.set(newObject, {
|
|
13012
|
+
...captureData,
|
|
13013
|
+
intersection: {
|
|
13014
|
+
...captureData.intersection,
|
|
13015
|
+
object: captureData.intersection.object === object ? newObject : captureData.intersection.object,
|
|
13016
|
+
eventObject: captureData.intersection.eventObject === object ? newObject : captureData.intersection.eventObject
|
|
13373
13017
|
}
|
|
13374
|
-
}
|
|
13375
|
-
|
|
13376
|
-
|
|
13377
|
-
|
|
13378
|
-
|
|
13379
|
-
|
|
13380
|
-
|
|
13381
|
-
|
|
13382
|
-
|
|
13383
|
-
|
|
13384
|
-
|
|
13385
|
-
|
|
13386
|
-
|
|
13387
|
-
return z = "useActionState", D(), N(), $t(e);
|
|
13388
|
-
}, useOptimistic: function(e, n) {
|
|
13389
|
-
return z = "useOptimistic", D(), N(), of(e, n);
|
|
13390
|
-
}, useMemoCache: function(e) {
|
|
13391
|
-
return D(), Oa(e);
|
|
13392
|
-
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
13393
|
-
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
13394
|
-
}, useEffectEvent: function(e) {
|
|
13395
|
-
return z = "useEffectEvent", D(), N(), oa(e);
|
|
13396
|
-
} };
|
|
13397
|
-
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();
|
|
13398
|
-
Object.freeze(Fy);
|
|
13399
|
-
var zg = { enqueueSetState: function(e, n, o) {
|
|
13400
|
-
e = e._reactInternals;
|
|
13401
|
-
var i = Nt(e), s = zo(i);
|
|
13402
|
-
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));
|
|
13403
|
-
}, enqueueReplaceState: function(e, n, o) {
|
|
13404
|
-
e = e._reactInternals;
|
|
13405
|
-
var i = Nt(e), s = zo(i);
|
|
13406
|
-
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));
|
|
13407
|
-
}, enqueueForceUpdate: function(e, n) {
|
|
13408
|
-
e = e._reactInternals;
|
|
13409
|
-
var o = Nt(e), i = zo(o);
|
|
13410
|
-
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));
|
|
13411
|
-
} }, 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;
|
|
13412
|
-
Yy = /* @__PURE__ */ new Set();
|
|
13413
|
-
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) {
|
|
13414
|
-
var n = Ee(un), o = n.data.get(e);
|
|
13415
|
-
return o === void 0 && (o = e(), n.data.set(e, o)), o;
|
|
13416
|
-
}, cacheSignal: function() {
|
|
13417
|
-
return Ee(un).controller.signal;
|
|
13418
|
-
}, getOwner: function() {
|
|
13419
|
-
return di;
|
|
13420
|
-
} }, pm = 0, hm = 1, mm = 2, gm = 3, ym = 4;
|
|
13421
|
-
if (typeof Symbol == "function" && Symbol.for) {
|
|
13422
|
-
var bp = Symbol.for;
|
|
13423
|
-
pm = bp("selector.component"), hm = bp("selector.has_pseudo_class"), mm = bp("selector.role"), gm = bp("selector.test_id"), ym = bp("selector.text");
|
|
13018
|
+
});
|
|
13019
|
+
}
|
|
13020
|
+
}
|
|
13021
|
+
unregisterVisibility(store, object);
|
|
13022
|
+
}
|
|
13023
|
+
function removeInteractivity(store, object) {
|
|
13024
|
+
const { internal } = store.getState();
|
|
13025
|
+
internal.interaction = internal.interaction.filter((o) => o !== object);
|
|
13026
|
+
for (const [pointerId, pointerState] of internal.pointerMap) {
|
|
13027
|
+
pointerState.initialHits = pointerState.initialHits.filter((o) => o !== object);
|
|
13028
|
+
pointerState.hovered.forEach((value, key) => {
|
|
13029
|
+
if (value.eventObject === object || value.object === object) {
|
|
13030
|
+
pointerState.hovered.delete(key);
|
|
13424
13031
|
}
|
|
13425
|
-
|
|
13426
|
-
|
|
13427
|
-
|
|
13428
|
-
|
|
13429
|
-
|
|
13032
|
+
});
|
|
13033
|
+
if (pointerState.captured.has(object)) {
|
|
13034
|
+
releaseInternalPointerCapture(internal, object, pointerId);
|
|
13035
|
+
}
|
|
13036
|
+
}
|
|
13037
|
+
unregisterVisibility(store, object);
|
|
13038
|
+
}
|
|
13039
|
+
function createEvents(store) {
|
|
13040
|
+
function calculateDistance(event, pointerId) {
|
|
13041
|
+
const { internal } = store.getState();
|
|
13042
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13043
|
+
if (!pointerState) return 0;
|
|
13044
|
+
const [initialX, initialY] = pointerState.initialClick;
|
|
13045
|
+
const dx = event.offsetX - initialX;
|
|
13046
|
+
const dy = event.offsetY - initialY;
|
|
13047
|
+
return Math.round(Math.sqrt(dx * dx + dy * dy));
|
|
13048
|
+
}
|
|
13049
|
+
function filterPointerEvents(objects) {
|
|
13050
|
+
return objects.filter(
|
|
13051
|
+
(obj) => ["Move", "Over", "Enter", "Out", "Leave"].some(
|
|
13052
|
+
(name) => obj.__r3f?.handlers["onPointer" + name]
|
|
13053
|
+
) || ["OverEnter", "OverLeave", "Over"].some(
|
|
13054
|
+
(name) => obj.__r3f?.handlers["onDrag" + name]
|
|
13055
|
+
) || obj.__r3f?.handlers.onDrop
|
|
13056
|
+
);
|
|
13057
|
+
}
|
|
13058
|
+
function intersect(event, filter) {
|
|
13059
|
+
const state = store.getState();
|
|
13060
|
+
const duplicates = /* @__PURE__ */ new Set();
|
|
13061
|
+
const intersections = [];
|
|
13062
|
+
const eventsObjects = filter ? filter(state.internal.interaction) : state.internal.interaction;
|
|
13063
|
+
for (let i = 0; i < eventsObjects.length; i++) {
|
|
13064
|
+
const state2 = getRootState(eventsObjects[i]);
|
|
13065
|
+
if (state2) {
|
|
13066
|
+
state2.raycaster.camera = void 0;
|
|
13430
13067
|
}
|
|
13431
|
-
|
|
13432
|
-
|
|
13433
|
-
|
|
13434
|
-
|
|
13435
|
-
|
|
13436
|
-
|
|
13437
|
-
|
|
13438
|
-
|
|
13439
|
-
|
|
13440
|
-
|
|
13441
|
-
|
|
13442
|
-
|
|
13443
|
-
|
|
13444
|
-
|
|
13445
|
-
|
|
13446
|
-
|
|
13447
|
-
|
|
13448
|
-
|
|
13449
|
-
|
|
13450
|
-
|
|
13451
|
-
|
|
13452
|
-
|
|
13453
|
-
|
|
13454
|
-
}, le.attemptContinuousHydration = function(e) {
|
|
13455
|
-
if (e.tag === 13 || e.tag === 31) {
|
|
13456
|
-
var n = On(e, 67108864);
|
|
13457
|
-
n !== null && We(n, e, 67108864), rl(e, 67108864);
|
|
13068
|
+
}
|
|
13069
|
+
if (!state.previousRoot) {
|
|
13070
|
+
state.events.compute?.(event, state);
|
|
13071
|
+
}
|
|
13072
|
+
function handleRaycast(obj) {
|
|
13073
|
+
const state2 = getRootState(obj);
|
|
13074
|
+
if (!state2 || !state2.events.enabled || state2.raycaster.camera === null) return [];
|
|
13075
|
+
if (state2.raycaster.camera === void 0) {
|
|
13076
|
+
state2.events.compute?.(event, state2, state2.previousRoot?.getState());
|
|
13077
|
+
if (state2.raycaster.camera === void 0) state2.raycaster.camera = null;
|
|
13078
|
+
}
|
|
13079
|
+
if (!state2.raycaster.camera) return [];
|
|
13080
|
+
obj.updateWorldMatrix(true, true);
|
|
13081
|
+
return state2.raycaster.intersectObject(obj, true);
|
|
13082
|
+
}
|
|
13083
|
+
let hits = eventsObjects.flatMap(handleRaycast).sort((a, b) => {
|
|
13084
|
+
const aInteractivePriority = a.object.userData?.interactivePriority;
|
|
13085
|
+
const bInteractivePriority = b.object.userData?.interactivePriority;
|
|
13086
|
+
if (aInteractivePriority !== void 0 || bInteractivePriority !== void 0) {
|
|
13087
|
+
if (aInteractivePriority !== void 0 && bInteractivePriority === void 0) return -1;
|
|
13088
|
+
if (bInteractivePriority !== void 0 && aInteractivePriority === void 0) return 1;
|
|
13089
|
+
if (aInteractivePriority !== bInteractivePriority) {
|
|
13090
|
+
return (bInteractivePriority ?? 0) - (aInteractivePriority ?? 0);
|
|
13458
13091
|
}
|
|
13459
|
-
}
|
|
13460
|
-
|
|
13461
|
-
|
|
13462
|
-
|
|
13463
|
-
|
|
13464
|
-
|
|
13092
|
+
}
|
|
13093
|
+
const aState = getRootState(a.object);
|
|
13094
|
+
const bState = getRootState(b.object);
|
|
13095
|
+
const aPriority = aState?.events?.priority ?? 1;
|
|
13096
|
+
const bPriority = bState?.events?.priority ?? 1;
|
|
13097
|
+
return bPriority - aPriority || a.distance - b.distance;
|
|
13098
|
+
}).filter((item) => {
|
|
13099
|
+
const id = makeId(item);
|
|
13100
|
+
if (duplicates.has(id)) return false;
|
|
13101
|
+
duplicates.add(id);
|
|
13102
|
+
return true;
|
|
13103
|
+
});
|
|
13104
|
+
if (state.events.filter) hits = state.events.filter(hits, state);
|
|
13105
|
+
for (const hit of hits) {
|
|
13106
|
+
let eventObject = hit.object;
|
|
13107
|
+
while (eventObject) {
|
|
13108
|
+
if (eventObject.__r3f?.eventCount) {
|
|
13109
|
+
intersections.push({ ...hit, eventObject });
|
|
13465
13110
|
}
|
|
13466
|
-
|
|
13467
|
-
|
|
13468
|
-
|
|
13469
|
-
|
|
13470
|
-
|
|
13471
|
-
|
|
13472
|
-
|
|
13473
|
-
|
|
13474
|
-
|
|
13111
|
+
eventObject = eventObject.parent;
|
|
13112
|
+
}
|
|
13113
|
+
}
|
|
13114
|
+
if ("pointerId" in event) {
|
|
13115
|
+
const pointerId = event.pointerId;
|
|
13116
|
+
const pointerState = state.internal.pointerMap.get(pointerId);
|
|
13117
|
+
if (pointerState?.captured.size) {
|
|
13118
|
+
for (const captureData of pointerState.captured.values()) {
|
|
13119
|
+
if (!duplicates.has(makeId(captureData.intersection))) intersections.push(captureData.intersection);
|
|
13120
|
+
}
|
|
13121
|
+
}
|
|
13122
|
+
}
|
|
13123
|
+
return intersections;
|
|
13124
|
+
}
|
|
13125
|
+
function handleIntersects(intersections, event, delta, callback) {
|
|
13126
|
+
if (intersections.length) {
|
|
13127
|
+
const localState = { stopped: false };
|
|
13128
|
+
for (const hit of intersections) {
|
|
13129
|
+
const state = getRootState(hit.object);
|
|
13130
|
+
if (state) {
|
|
13131
|
+
const { raycaster, pointer, camera, internal } = state;
|
|
13132
|
+
const unprojectedPoint = new Vector3(pointer.x, pointer.y, 0).unproject(camera);
|
|
13133
|
+
const hasPointerCapture = (id) => {
|
|
13134
|
+
const pointerState = internal.pointerMap.get(id);
|
|
13135
|
+
return pointerState?.captured.has(hit.eventObject) ?? false;
|
|
13136
|
+
};
|
|
13137
|
+
const setPointerCapture = (id) => {
|
|
13138
|
+
const captureData = { intersection: hit, target: event.target };
|
|
13139
|
+
const pointerState = getPointerState(internal, id);
|
|
13140
|
+
pointerState.captured.set(hit.eventObject, captureData);
|
|
13141
|
+
event.target.setPointerCapture(id);
|
|
13142
|
+
};
|
|
13143
|
+
const releasePointerCapture = (id) => {
|
|
13144
|
+
releaseInternalPointerCapture(internal, hit.eventObject, id);
|
|
13145
|
+
};
|
|
13146
|
+
const extractEventProps = {};
|
|
13147
|
+
for (const prop in event) {
|
|
13148
|
+
const property = event[prop];
|
|
13149
|
+
if (typeof property !== "function") extractEventProps[prop] = property;
|
|
13150
|
+
}
|
|
13151
|
+
const eventPointerId = "pointerId" in event ? event.pointerId : void 0;
|
|
13152
|
+
const raycastEvent = {
|
|
13153
|
+
...hit,
|
|
13154
|
+
...extractEventProps,
|
|
13155
|
+
pointer,
|
|
13156
|
+
intersections,
|
|
13157
|
+
stopped: localState.stopped,
|
|
13158
|
+
delta,
|
|
13159
|
+
unprojectedPoint,
|
|
13160
|
+
ray: raycaster.ray,
|
|
13161
|
+
camera,
|
|
13162
|
+
pointerId: eventPointerId,
|
|
13163
|
+
// Hijack stopPropagation, which just sets a flag
|
|
13164
|
+
stopPropagation() {
|
|
13165
|
+
const pointerState = eventPointerId !== void 0 ? internal.pointerMap.get(eventPointerId) : void 0;
|
|
13166
|
+
if (
|
|
13167
|
+
// ...if this pointer hasn't been captured
|
|
13168
|
+
!pointerState?.captured.size || // ... or if the hit object is capturing the pointer
|
|
13169
|
+
pointerState.captured.has(hit.eventObject)
|
|
13170
|
+
) {
|
|
13171
|
+
raycastEvent.stopped = localState.stopped = true;
|
|
13172
|
+
if (pointerState?.hovered.size && Array.from(pointerState.hovered.values()).find((i) => i.eventObject === hit.eventObject)) {
|
|
13173
|
+
const higher = intersections.slice(0, intersections.indexOf(hit));
|
|
13174
|
+
cancelPointer([...higher, hit], eventPointerId);
|
|
13475
13175
|
}
|
|
13476
|
-
Kn(e), (ye & (Zn | uo)) === Jn && (Pp = me() + Fg, Wa(0));
|
|
13477
13176
|
}
|
|
13478
|
-
}
|
|
13479
|
-
|
|
13480
|
-
|
|
13481
|
-
|
|
13482
|
-
|
|
13177
|
+
},
|
|
13178
|
+
// there should be a distinction between target and currentTarget
|
|
13179
|
+
target: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
13180
|
+
currentTarget: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
13181
|
+
nativeEvent: event
|
|
13182
|
+
};
|
|
13183
|
+
callback(raycastEvent);
|
|
13184
|
+
if (localState.stopped === true) break;
|
|
13483
13185
|
}
|
|
13484
|
-
}
|
|
13485
|
-
|
|
13486
|
-
|
|
13487
|
-
|
|
13488
|
-
|
|
13489
|
-
|
|
13490
|
-
|
|
13491
|
-
|
|
13492
|
-
|
|
13493
|
-
|
|
13494
|
-
|
|
13495
|
-
|
|
13496
|
-
|
|
13497
|
-
|
|
13498
|
-
|
|
13499
|
-
|
|
13500
|
-
|
|
13186
|
+
}
|
|
13187
|
+
}
|
|
13188
|
+
return intersections;
|
|
13189
|
+
}
|
|
13190
|
+
function cancelPointer(intersections, pointerId) {
|
|
13191
|
+
const { internal } = store.getState();
|
|
13192
|
+
const pid = pointerId ?? DEFAULT_POINTER_ID;
|
|
13193
|
+
const pointerState = internal.pointerMap.get(pid);
|
|
13194
|
+
if (!pointerState) return;
|
|
13195
|
+
for (const [hoveredId, hoveredObj] of pointerState.hovered) {
|
|
13196
|
+
if (!intersections.length || !intersections.find(
|
|
13197
|
+
(hit) => hit.object === hoveredObj.object && hit.index === hoveredObj.index && hit.instanceId === hoveredObj.instanceId
|
|
13198
|
+
)) {
|
|
13199
|
+
const eventObject = hoveredObj.eventObject;
|
|
13200
|
+
const instance = eventObject.__r3f;
|
|
13201
|
+
pointerState.hovered.delete(hoveredId);
|
|
13202
|
+
if (instance?.eventCount) {
|
|
13203
|
+
const handlers = instance.handlers;
|
|
13204
|
+
const data = { ...hoveredObj, intersections };
|
|
13205
|
+
handlers.onPointerOut?.(data);
|
|
13206
|
+
handlers.onPointerLeave?.(data);
|
|
13207
|
+
handlers.onDragOverLeave?.(data);
|
|
13501
13208
|
}
|
|
13502
|
-
|
|
13503
|
-
|
|
13504
|
-
|
|
13505
|
-
|
|
13506
|
-
|
|
13507
|
-
|
|
13508
|
-
|
|
13509
|
-
|
|
13510
|
-
|
|
13511
|
-
|
|
13512
|
-
|
|
13513
|
-
|
|
13514
|
-
|
|
13515
|
-
|
|
13516
|
-
|
|
13517
|
-
|
|
13518
|
-
|
|
13519
|
-
|
|
13520
|
-
|
|
13521
|
-
|
|
13522
|
-
|
|
13523
|
-
|
|
13524
|
-
|
|
13525
|
-
|
|
13526
|
-
|
|
13527
|
-
|
|
13528
|
-
|
|
13529
|
-
|
|
13530
|
-
|
|
13531
|
-
|
|
13532
|
-
|
|
13533
|
-
|
|
13534
|
-
|
|
13535
|
-
an(o), x.T = n;
|
|
13209
|
+
}
|
|
13210
|
+
}
|
|
13211
|
+
}
|
|
13212
|
+
function pointerMissed(event, objects) {
|
|
13213
|
+
for (let i = 0; i < objects.length; i++) {
|
|
13214
|
+
const instance = objects[i].__r3f;
|
|
13215
|
+
instance?.handlers.onPointerMissed?.(event);
|
|
13216
|
+
}
|
|
13217
|
+
}
|
|
13218
|
+
function dragOverMissed(event, objects) {
|
|
13219
|
+
for (let i = 0; i < objects.length; i++) {
|
|
13220
|
+
const instance = objects[i].__r3f;
|
|
13221
|
+
instance?.handlers.onDragOverMissed?.(event);
|
|
13222
|
+
}
|
|
13223
|
+
}
|
|
13224
|
+
function dropMissed(event, objects) {
|
|
13225
|
+
for (let i = 0; i < objects.length; i++) {
|
|
13226
|
+
const instance = objects[i].__r3f;
|
|
13227
|
+
instance?.handlers.onDropMissed?.(event);
|
|
13228
|
+
}
|
|
13229
|
+
}
|
|
13230
|
+
function cleanupPointer(pointerId) {
|
|
13231
|
+
const { internal } = store.getState();
|
|
13232
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13233
|
+
if (pointerState) {
|
|
13234
|
+
for (const [, hoveredObj] of pointerState.hovered) {
|
|
13235
|
+
const eventObject = hoveredObj.eventObject;
|
|
13236
|
+
const instance = eventObject.__r3f;
|
|
13237
|
+
if (instance?.eventCount) {
|
|
13238
|
+
const handlers = instance.handlers;
|
|
13239
|
+
const data = { ...hoveredObj, intersections: [] };
|
|
13240
|
+
handlers.onPointerOut?.(data);
|
|
13241
|
+
handlers.onPointerLeave?.(data);
|
|
13536
13242
|
}
|
|
13537
|
-
}
|
|
13538
|
-
|
|
13539
|
-
|
|
13540
|
-
|
|
13541
|
-
|
|
13542
|
-
|
|
13243
|
+
}
|
|
13244
|
+
internal.pointerMap.delete(pointerId);
|
|
13245
|
+
}
|
|
13246
|
+
internal.pointerDirty.delete(pointerId);
|
|
13247
|
+
}
|
|
13248
|
+
function processDeferredPointer(event, pointerId) {
|
|
13249
|
+
const state = store.getState();
|
|
13250
|
+
const { internal } = state;
|
|
13251
|
+
if (!state.events.enabled) return;
|
|
13252
|
+
const filter = filterPointerEvents;
|
|
13253
|
+
const hits = intersect(event, filter);
|
|
13254
|
+
cancelPointer(hits, pointerId);
|
|
13255
|
+
function onIntersect(data) {
|
|
13256
|
+
const eventObject = data.eventObject;
|
|
13257
|
+
const instance = eventObject.__r3f;
|
|
13258
|
+
if (!instance?.eventCount) return;
|
|
13259
|
+
const handlers = instance.handlers;
|
|
13260
|
+
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
13261
|
+
const id = makeId(data);
|
|
13262
|
+
const pointerState = getPointerState(internal, pointerId);
|
|
13263
|
+
const hoveredItem = pointerState.hovered.get(id);
|
|
13264
|
+
if (!hoveredItem) {
|
|
13265
|
+
pointerState.hovered.set(id, data);
|
|
13266
|
+
handlers.onPointerOver?.(data);
|
|
13267
|
+
handlers.onPointerEnter?.(data);
|
|
13268
|
+
} else if (hoveredItem.stopped) {
|
|
13269
|
+
data.stopPropagation();
|
|
13543
13270
|
}
|
|
13544
|
-
}
|
|
13545
|
-
|
|
13546
|
-
|
|
13547
|
-
|
|
13548
|
-
|
|
13549
|
-
|
|
13550
|
-
|
|
13551
|
-
|
|
13552
|
-
|
|
13553
|
-
|
|
13554
|
-
|
|
13555
|
-
|
|
13556
|
-
|
|
13557
|
-
|
|
13558
|
-
|
|
13271
|
+
}
|
|
13272
|
+
handlers.onPointerMove?.(data);
|
|
13273
|
+
}
|
|
13274
|
+
handleIntersects(hits, event, 0, onIntersect);
|
|
13275
|
+
}
|
|
13276
|
+
function handlePointer(name) {
|
|
13277
|
+
switch (name) {
|
|
13278
|
+
case "onPointerLeave":
|
|
13279
|
+
case "onDragLeave":
|
|
13280
|
+
return () => cancelPointer([]);
|
|
13281
|
+
// Global cancel of these events
|
|
13282
|
+
case "onPointerCancel":
|
|
13283
|
+
return (event) => {
|
|
13284
|
+
const pointerId = getPointerId(event);
|
|
13285
|
+
cleanupPointer(pointerId);
|
|
13286
|
+
};
|
|
13287
|
+
case "onLostPointerCapture":
|
|
13288
|
+
return (event) => {
|
|
13289
|
+
const { internal } = store.getState();
|
|
13290
|
+
const pointerId = getPointerId(event);
|
|
13291
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13292
|
+
if (pointerState?.captured.size) {
|
|
13293
|
+
requestAnimationFrame(() => {
|
|
13294
|
+
const pointerState2 = internal.pointerMap.get(pointerId);
|
|
13295
|
+
if (pointerState2?.captured.size) {
|
|
13296
|
+
pointerState2.captured.clear();
|
|
13559
13297
|
}
|
|
13560
|
-
|
|
13561
|
-
|
|
13562
|
-
|
|
13298
|
+
cancelPointer([], pointerId);
|
|
13299
|
+
});
|
|
13300
|
+
}
|
|
13301
|
+
};
|
|
13302
|
+
}
|
|
13303
|
+
return function handleEvent(event) {
|
|
13304
|
+
const state = store.getState();
|
|
13305
|
+
const { onPointerMissed, onDragOverMissed, onDropMissed, internal, events } = state;
|
|
13306
|
+
const pointerId = getPointerId(event);
|
|
13307
|
+
internal.lastEvent.current = event;
|
|
13308
|
+
if (!events.enabled) return;
|
|
13309
|
+
const isPointerMove = name === "onPointerMove";
|
|
13310
|
+
const isDragOver = name === "onDragOver";
|
|
13311
|
+
const isDrop = name === "onDrop";
|
|
13312
|
+
const isClickEvent = name === "onClick" || name === "onContextMenu" || name === "onDoubleClick";
|
|
13313
|
+
const isPointerDown = name === "onPointerDown";
|
|
13314
|
+
const isPointerUp = name === "onPointerUp";
|
|
13315
|
+
const isWheel = name === "onWheel";
|
|
13316
|
+
const canDeferRaycasts = events.frameTimedRaycasts && state.frameloop === "always";
|
|
13317
|
+
if (isPointerMove && canDeferRaycasts) {
|
|
13318
|
+
events.compute?.(event, state);
|
|
13319
|
+
internal.pointerDirty.set(pointerId, event);
|
|
13320
|
+
return;
|
|
13321
|
+
}
|
|
13322
|
+
if (isWheel && canDeferRaycasts && !events.alwaysFireOnScroll) {
|
|
13323
|
+
events.compute?.(event, state);
|
|
13324
|
+
internal.pointerDirty.set(pointerId, event);
|
|
13325
|
+
return;
|
|
13326
|
+
}
|
|
13327
|
+
if ((isClickEvent || isPointerDown || isPointerUp) && internal.pointerDirty.has(pointerId)) {
|
|
13328
|
+
const deferredEvent = internal.pointerDirty.get(pointerId);
|
|
13329
|
+
internal.pointerDirty.delete(pointerId);
|
|
13330
|
+
processDeferredPointer(deferredEvent, pointerId);
|
|
13331
|
+
}
|
|
13332
|
+
const filter = isPointerMove || isDragOver || isDrop ? filterPointerEvents : void 0;
|
|
13333
|
+
const hits = intersect(event, filter);
|
|
13334
|
+
const delta = isClickEvent ? calculateDistance(event, pointerId) : 0;
|
|
13335
|
+
if (isPointerDown) {
|
|
13336
|
+
const pointerState2 = getPointerState(internal, pointerId);
|
|
13337
|
+
pointerState2.initialClick = [event.offsetX, event.offsetY];
|
|
13338
|
+
pointerState2.initialHits = hits.map((hit) => hit.eventObject);
|
|
13339
|
+
}
|
|
13340
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13341
|
+
const initialHits = pointerState?.initialHits ?? [];
|
|
13342
|
+
if (isClickEvent && !hits.length) {
|
|
13343
|
+
if (delta <= 2) {
|
|
13344
|
+
pointerMissed(event, internal.interaction);
|
|
13345
|
+
if (onPointerMissed) onPointerMissed(event);
|
|
13346
|
+
}
|
|
13347
|
+
}
|
|
13348
|
+
if (isDragOver && !hits.length) {
|
|
13349
|
+
dragOverMissed(event, internal.interaction);
|
|
13350
|
+
if (onDragOverMissed) onDragOverMissed(event);
|
|
13351
|
+
}
|
|
13352
|
+
if (isDrop && !hits.length) {
|
|
13353
|
+
dropMissed(event, internal.interaction);
|
|
13354
|
+
if (onDropMissed) onDropMissed(event);
|
|
13355
|
+
}
|
|
13356
|
+
if (isPointerMove || isDragOver) {
|
|
13357
|
+
cancelPointer(hits, pointerId);
|
|
13358
|
+
}
|
|
13359
|
+
function onIntersect(data) {
|
|
13360
|
+
const eventObject = data.eventObject;
|
|
13361
|
+
const instance = eventObject.__r3f;
|
|
13362
|
+
if (!instance?.eventCount) return;
|
|
13363
|
+
const handlers = instance.handlers;
|
|
13364
|
+
if (isPointerMove) {
|
|
13365
|
+
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
13366
|
+
const id = makeId(data);
|
|
13367
|
+
const pointerState2 = getPointerState(internal, pointerId);
|
|
13368
|
+
const hoveredItem = pointerState2.hovered.get(id);
|
|
13369
|
+
if (!hoveredItem) {
|
|
13370
|
+
pointerState2.hovered.set(id, data);
|
|
13371
|
+
handlers.onPointerOver?.(data);
|
|
13372
|
+
handlers.onPointerEnter?.(data);
|
|
13373
|
+
} else if (hoveredItem.stopped) {
|
|
13374
|
+
data.stopPropagation();
|
|
13563
13375
|
}
|
|
13564
13376
|
}
|
|
13565
|
-
|
|
13566
|
-
|
|
13567
|
-
|
|
13568
|
-
|
|
13569
|
-
|
|
13570
|
-
|
|
13571
|
-
|
|
13572
|
-
|
|
13573
|
-
|
|
13574
|
-
|
|
13575
|
-
|
|
13576
|
-
|
|
13577
|
-
if (
|
|
13578
|
-
|
|
13579
|
-
|
|
13580
|
-
|
|
13581
|
-
|
|
13582
|
-
|
|
13583
|
-
|
|
13584
|
-
|
|
13585
|
-
|
|
13586
|
-
|
|
13587
|
-
|
|
13588
|
-
|
|
13589
|
-
|
|
13590
|
-
|
|
13591
|
-
|
|
13592
|
-
|
|
13593
|
-
|
|
13594
|
-
|
|
13595
|
-
|
|
13596
|
-
var o = n[e++], i = o.tag;
|
|
13597
|
-
if (!Kr(o)) {
|
|
13598
|
-
if ((i === 5 || i === 26 || i === 27) && Ft(o.stateNode)) return true;
|
|
13599
|
-
for (o = o.child; o !== null; ) n.push(o), o = o.sibling;
|
|
13377
|
+
handlers.onPointerMove?.(data);
|
|
13378
|
+
} else if (isDragOver) {
|
|
13379
|
+
const id = makeId(data);
|
|
13380
|
+
const pointerState2 = getPointerState(internal, pointerId);
|
|
13381
|
+
const hoveredItem = pointerState2.hovered.get(id);
|
|
13382
|
+
if (!hoveredItem) {
|
|
13383
|
+
pointerState2.hovered.set(id, data);
|
|
13384
|
+
handlers.onDragOverEnter?.(data);
|
|
13385
|
+
} else if (hoveredItem.stopped) {
|
|
13386
|
+
data.stopPropagation();
|
|
13387
|
+
}
|
|
13388
|
+
handlers.onDragOver?.(data);
|
|
13389
|
+
} else if (isDrop) {
|
|
13390
|
+
handlers.onDrop?.(data);
|
|
13391
|
+
} else {
|
|
13392
|
+
const handler = handlers[name];
|
|
13393
|
+
if (handler) {
|
|
13394
|
+
if (!isClickEvent || initialHits.includes(eventObject)) {
|
|
13395
|
+
pointerMissed(
|
|
13396
|
+
event,
|
|
13397
|
+
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
13398
|
+
);
|
|
13399
|
+
handler(data);
|
|
13400
|
+
}
|
|
13401
|
+
} else {
|
|
13402
|
+
if (isClickEvent && initialHits.includes(eventObject)) {
|
|
13403
|
+
pointerMissed(
|
|
13404
|
+
event,
|
|
13405
|
+
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
13406
|
+
);
|
|
13407
|
+
}
|
|
13600
13408
|
}
|
|
13601
13409
|
}
|
|
13602
|
-
|
|
13603
|
-
|
|
13604
|
-
|
|
13605
|
-
|
|
13606
|
-
|
|
13607
|
-
|
|
13608
|
-
|
|
13609
|
-
|
|
13410
|
+
}
|
|
13411
|
+
handleIntersects(hits, event, delta, onIntersect);
|
|
13412
|
+
};
|
|
13413
|
+
}
|
|
13414
|
+
function flushDeferredPointers() {
|
|
13415
|
+
const { internal, events } = store.getState();
|
|
13416
|
+
if (!events.frameTimedRaycasts) return;
|
|
13417
|
+
for (const [pointerId, event] of internal.pointerDirty) {
|
|
13418
|
+
processDeferredPointer(event, pointerId);
|
|
13419
|
+
}
|
|
13420
|
+
internal.pointerDirty.clear();
|
|
13421
|
+
}
|
|
13422
|
+
return { handlePointer, flushDeferredPointers, processDeferredPointer };
|
|
13423
|
+
}
|
|
13424
|
+
const DOM_EVENTS = {
|
|
13425
|
+
onClick: ["click", false],
|
|
13426
|
+
onContextMenu: ["contextmenu", false],
|
|
13427
|
+
onDoubleClick: ["dblclick", false],
|
|
13428
|
+
onDragEnter: ["dragenter", false],
|
|
13429
|
+
onDragLeave: ["dragleave", false],
|
|
13430
|
+
onDragOver: ["dragover", false],
|
|
13431
|
+
onDrop: ["drop", false],
|
|
13432
|
+
onWheel: ["wheel", true],
|
|
13433
|
+
onPointerDown: ["pointerdown", true],
|
|
13434
|
+
onPointerUp: ["pointerup", true],
|
|
13435
|
+
onPointerLeave: ["pointerleave", true],
|
|
13436
|
+
onPointerMove: ["pointermove", true],
|
|
13437
|
+
onPointerCancel: ["pointercancel", true],
|
|
13438
|
+
onLostPointerCapture: ["lostpointercapture", true]
|
|
13439
|
+
};
|
|
13440
|
+
function createPointerEvents(store) {
|
|
13441
|
+
const { handlePointer, flushDeferredPointers, processDeferredPointer } = createEvents(store);
|
|
13442
|
+
let nextXRPointerId = XR_POINTER_ID_START;
|
|
13443
|
+
const xrPointers = /* @__PURE__ */ new Map();
|
|
13444
|
+
return {
|
|
13445
|
+
priority: 1,
|
|
13446
|
+
enabled: true,
|
|
13447
|
+
frameTimedRaycasts: true,
|
|
13448
|
+
alwaysFireOnScroll: true,
|
|
13449
|
+
updateOnFrame: false,
|
|
13450
|
+
compute(event, state) {
|
|
13451
|
+
state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
|
|
13452
|
+
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
13453
|
+
},
|
|
13454
|
+
connected: void 0,
|
|
13455
|
+
handlers: Object.keys(DOM_EVENTS).reduce(
|
|
13456
|
+
(acc, key) => ({ ...acc, [key]: handlePointer(key) }),
|
|
13457
|
+
{}
|
|
13458
|
+
),
|
|
13459
|
+
update: (pointerId) => {
|
|
13460
|
+
const { events, internal } = store.getState();
|
|
13461
|
+
if (!events.handlers) return;
|
|
13462
|
+
if (pointerId !== void 0) {
|
|
13463
|
+
const event = internal.pointerDirty.get(pointerId);
|
|
13464
|
+
if (event) {
|
|
13465
|
+
internal.pointerDirty.delete(pointerId);
|
|
13466
|
+
processDeferredPointer(event, pointerId);
|
|
13467
|
+
} else if (internal.lastEvent?.current) {
|
|
13468
|
+
processDeferredPointer(internal.lastEvent.current, pointerId);
|
|
13610
13469
|
}
|
|
13611
|
-
|
|
13612
|
-
|
|
13613
|
-
|
|
13614
|
-
|
|
13615
|
-
|
|
13616
|
-
No matching component was found for:
|
|
13617
|
-
`) + e.join(" > ");
|
|
13470
|
+
} else {
|
|
13471
|
+
flushDeferredPointers();
|
|
13472
|
+
if (internal.lastEvent?.current) {
|
|
13473
|
+
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
13618
13474
|
}
|
|
13619
|
-
|
|
13620
|
-
|
|
13621
|
-
|
|
13622
|
-
|
|
13623
|
-
|
|
13624
|
-
|
|
13625
|
-
|
|
13626
|
-
|
|
13627
|
-
|
|
13475
|
+
}
|
|
13476
|
+
},
|
|
13477
|
+
flush: () => {
|
|
13478
|
+
const { events, internal } = store.getState();
|
|
13479
|
+
flushDeferredPointers();
|
|
13480
|
+
if (events.updateOnFrame && internal.lastEvent?.current && events.handlers) {
|
|
13481
|
+
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
13482
|
+
}
|
|
13483
|
+
},
|
|
13484
|
+
connect: (target) => {
|
|
13485
|
+
if (!target) return;
|
|
13486
|
+
const { set, events } = store.getState();
|
|
13487
|
+
events.disconnect?.();
|
|
13488
|
+
set((state) => ({ events: { ...state.events, connected: target } }));
|
|
13489
|
+
if (events.handlers) {
|
|
13490
|
+
for (const name in events.handlers) {
|
|
13491
|
+
const event = events.handlers[name];
|
|
13492
|
+
const [eventName, passive] = DOM_EVENTS[name];
|
|
13493
|
+
target.addEventListener(eventName, event, { passive });
|
|
13628
13494
|
}
|
|
13629
|
-
}
|
|
13630
|
-
|
|
13631
|
-
|
|
13632
|
-
|
|
13633
|
-
|
|
13634
|
-
|
|
13635
|
-
|
|
13636
|
-
|
|
13637
|
-
|
|
13638
|
-
|
|
13639
|
-
}
|
|
13495
|
+
}
|
|
13496
|
+
},
|
|
13497
|
+
disconnect: () => {
|
|
13498
|
+
const { set, events } = store.getState();
|
|
13499
|
+
if (events.connected) {
|
|
13500
|
+
if (events.handlers) {
|
|
13501
|
+
for (const name in events.handlers) {
|
|
13502
|
+
const event = events.handlers[name];
|
|
13503
|
+
const [eventName] = DOM_EVENTS[name];
|
|
13504
|
+
events.connected.removeEventListener(eventName, event);
|
|
13505
|
+
}
|
|
13640
13506
|
}
|
|
13641
|
-
|
|
13642
|
-
|
|
13643
|
-
|
|
13644
|
-
|
|
13645
|
-
|
|
13646
|
-
|
|
13647
|
-
|
|
13648
|
-
|
|
13649
|
-
|
|
13650
|
-
|
|
13651
|
-
|
|
13652
|
-
|
|
13653
|
-
|
|
13654
|
-
|
|
13655
|
-
|
|
13656
|
-
|
|
13657
|
-
|
|
13658
|
-
|
|
13659
|
-
|
|
13660
|
-
|
|
13661
|
-
|
|
13662
|
-
|
|
13663
|
-
|
|
13664
|
-
|
|
13665
|
-
|
|
13666
|
-
|
|
13667
|
-
|
|
13668
|
-
|
|
13669
|
-
|
|
13670
|
-
|
|
13507
|
+
set((state) => ({ events: { ...state.events, connected: void 0 } }));
|
|
13508
|
+
}
|
|
13509
|
+
},
|
|
13510
|
+
// PREVIEW (A8): the XR pointer registration API may change before stable.
|
|
13511
|
+
registerPointer: (config) => {
|
|
13512
|
+
const pointerId = nextXRPointerId++;
|
|
13513
|
+
xrPointers.set(pointerId, config);
|
|
13514
|
+
const { internal } = store.getState();
|
|
13515
|
+
getPointerState(internal, pointerId);
|
|
13516
|
+
return pointerId;
|
|
13517
|
+
},
|
|
13518
|
+
unregisterPointer: (pointerId) => {
|
|
13519
|
+
xrPointers.delete(pointerId);
|
|
13520
|
+
const { internal } = store.getState();
|
|
13521
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13522
|
+
if (pointerState) {
|
|
13523
|
+
for (const [, hoveredObj] of pointerState.hovered) {
|
|
13524
|
+
const eventObject = hoveredObj.eventObject;
|
|
13525
|
+
const instance = eventObject.__r3f;
|
|
13526
|
+
if (instance?.eventCount) {
|
|
13527
|
+
const handlers = instance.handlers;
|
|
13528
|
+
const data = { ...hoveredObj, intersections: [] };
|
|
13529
|
+
handlers.onPointerOut?.(data);
|
|
13530
|
+
handlers.onPointerLeave?.(data);
|
|
13531
|
+
}
|
|
13532
|
+
}
|
|
13533
|
+
internal.pointerMap.delete(pointerId);
|
|
13534
|
+
}
|
|
13535
|
+
internal.pointerDirty.delete(pointerId);
|
|
13536
|
+
}
|
|
13537
|
+
};
|
|
13671
13538
|
}
|
|
13672
|
-
var t0 = n0();
|
|
13673
|
-
const r0 = Xb(t0);
|
|
13674
|
-
|
|
13675
|
-
const t = 1, o = 8, r = 32, e = 2;
|
|
13676
13539
|
|
|
13677
13540
|
function createReconciler(config) {
|
|
13678
13541
|
const reconciler2 = r0(config);
|
|
@@ -13837,7 +13700,15 @@ function setFiberRef(fiber, publicInstance) {
|
|
|
13837
13700
|
}
|
|
13838
13701
|
}
|
|
13839
13702
|
const reconstructed = [];
|
|
13840
|
-
function
|
|
13703
|
+
function flushReconstructedInstances() {
|
|
13704
|
+
if (reconstructed.length === 0) return;
|
|
13705
|
+
try {
|
|
13706
|
+
swapReconstructedInstances();
|
|
13707
|
+
} finally {
|
|
13708
|
+
reconstructed.length = 0;
|
|
13709
|
+
}
|
|
13710
|
+
}
|
|
13711
|
+
function swapReconstructedInstances() {
|
|
13841
13712
|
for (const [instance] of reconstructed) {
|
|
13842
13713
|
const parent = instance.parent;
|
|
13843
13714
|
if (parent) {
|
|
@@ -13855,7 +13726,9 @@ function swapInstances() {
|
|
|
13855
13726
|
}
|
|
13856
13727
|
}
|
|
13857
13728
|
if (instance.isHidden) unhideInstance(instance);
|
|
13858
|
-
if (isObject3D(instance.object)
|
|
13729
|
+
if (isObject3D(instance.object) && !instance.parent) {
|
|
13730
|
+
removeInteractivity(findInitialRoot(instance), instance.object);
|
|
13731
|
+
}
|
|
13859
13732
|
if (instance.object.__r3f) delete instance.object.__r3f;
|
|
13860
13733
|
if (instance.type !== "primitive") disposeOnIdle(instance.object);
|
|
13861
13734
|
}
|
|
@@ -13864,9 +13737,13 @@ function swapInstances() {
|
|
|
13864
13737
|
const parent = instance.parent;
|
|
13865
13738
|
if (parent) {
|
|
13866
13739
|
const target = catalogue[toPascalCase(instance.type)];
|
|
13740
|
+
const prevObject = instance.object;
|
|
13867
13741
|
instance.object = instance.props.object ?? new target(...instance.props.args ?? []);
|
|
13868
13742
|
instance.object.__r3f = instance;
|
|
13869
13743
|
setFiberRef(fiber, instance.object);
|
|
13744
|
+
if (isObject3D(prevObject) && isObject3D(instance.object)) {
|
|
13745
|
+
swapInteractivity(findInitialRoot(instance), prevObject, instance.object);
|
|
13746
|
+
}
|
|
13870
13747
|
delete instance.appliedOnce;
|
|
13871
13748
|
instance.eventCount = 0;
|
|
13872
13749
|
instance.handlers = {};
|
|
@@ -13886,14 +13763,114 @@ function swapInstances() {
|
|
|
13886
13763
|
invalidateInstance(instance);
|
|
13887
13764
|
}
|
|
13888
13765
|
}
|
|
13889
|
-
reconstructed.length = 0;
|
|
13890
13766
|
}
|
|
13891
13767
|
const handleTextInstance = () => {
|
|
13892
13768
|
};
|
|
13893
13769
|
const NO_CONTEXT = {};
|
|
13894
13770
|
let currentUpdatePriority = NoEventPriority;
|
|
13895
|
-
|
|
13896
|
-
|
|
13771
|
+
function getEventPriority(type) {
|
|
13772
|
+
switch (type) {
|
|
13773
|
+
case "beforetoggle":
|
|
13774
|
+
case "cancel":
|
|
13775
|
+
case "click":
|
|
13776
|
+
case "close":
|
|
13777
|
+
case "contextmenu":
|
|
13778
|
+
case "copy":
|
|
13779
|
+
case "cut":
|
|
13780
|
+
case "auxclick":
|
|
13781
|
+
case "dblclick":
|
|
13782
|
+
case "dragend":
|
|
13783
|
+
case "dragstart":
|
|
13784
|
+
case "drop":
|
|
13785
|
+
case "focusin":
|
|
13786
|
+
case "focusout":
|
|
13787
|
+
case "input":
|
|
13788
|
+
case "invalid":
|
|
13789
|
+
case "keydown":
|
|
13790
|
+
case "keypress":
|
|
13791
|
+
case "keyup":
|
|
13792
|
+
case "mousedown":
|
|
13793
|
+
case "mouseup":
|
|
13794
|
+
case "paste":
|
|
13795
|
+
case "pause":
|
|
13796
|
+
case "play":
|
|
13797
|
+
case "pointercancel":
|
|
13798
|
+
case "pointerdown":
|
|
13799
|
+
case "pointerup":
|
|
13800
|
+
case "ratechange":
|
|
13801
|
+
case "reset":
|
|
13802
|
+
case "resize":
|
|
13803
|
+
case "seeked":
|
|
13804
|
+
case "submit":
|
|
13805
|
+
case "touchcancel":
|
|
13806
|
+
case "touchend":
|
|
13807
|
+
case "touchstart":
|
|
13808
|
+
case "volumechange":
|
|
13809
|
+
case "change":
|
|
13810
|
+
case "selectionchange":
|
|
13811
|
+
case "compositionstart":
|
|
13812
|
+
case "compositionend":
|
|
13813
|
+
case "compositionupdate":
|
|
13814
|
+
case "beforeinput":
|
|
13815
|
+
case "blur":
|
|
13816
|
+
case "fullscreenchange":
|
|
13817
|
+
case "focus":
|
|
13818
|
+
case "hashchange":
|
|
13819
|
+
case "popstate":
|
|
13820
|
+
case "select":
|
|
13821
|
+
case "selectstart":
|
|
13822
|
+
return e;
|
|
13823
|
+
case "drag":
|
|
13824
|
+
case "dragenter":
|
|
13825
|
+
case "dragexit":
|
|
13826
|
+
case "dragleave":
|
|
13827
|
+
case "dragover":
|
|
13828
|
+
case "mousemove":
|
|
13829
|
+
case "mouseout":
|
|
13830
|
+
case "mouseover":
|
|
13831
|
+
case "pointermove":
|
|
13832
|
+
case "pointerout":
|
|
13833
|
+
case "pointerover":
|
|
13834
|
+
case "scroll":
|
|
13835
|
+
case "touchmove":
|
|
13836
|
+
case "wheel":
|
|
13837
|
+
case "mouseenter":
|
|
13838
|
+
case "mouseleave":
|
|
13839
|
+
case "pointerenter":
|
|
13840
|
+
case "pointerleave":
|
|
13841
|
+
return o;
|
|
13842
|
+
case "message": {
|
|
13843
|
+
switch (unstable_getCurrentPriorityLevel()) {
|
|
13844
|
+
case unstable_ImmediatePriority:
|
|
13845
|
+
return e;
|
|
13846
|
+
case unstable_UserBlockingPriority:
|
|
13847
|
+
return o;
|
|
13848
|
+
case unstable_NormalPriority:
|
|
13849
|
+
case unstable_LowPriority:
|
|
13850
|
+
return r;
|
|
13851
|
+
case unstable_IdlePriority:
|
|
13852
|
+
return i$1;
|
|
13853
|
+
default:
|
|
13854
|
+
return r;
|
|
13855
|
+
}
|
|
13856
|
+
}
|
|
13857
|
+
default:
|
|
13858
|
+
return r;
|
|
13859
|
+
}
|
|
13860
|
+
}
|
|
13861
|
+
function scheduleMicrotask(callback) {
|
|
13862
|
+
if (typeof queueMicrotask === "function") {
|
|
13863
|
+
queueMicrotask(callback);
|
|
13864
|
+
} else if (typeof Promise !== "undefined") {
|
|
13865
|
+
Promise.resolve().then(callback).catch((error) => {
|
|
13866
|
+
setTimeout(() => {
|
|
13867
|
+
throw error;
|
|
13868
|
+
});
|
|
13869
|
+
});
|
|
13870
|
+
} else {
|
|
13871
|
+
setTimeout(callback);
|
|
13872
|
+
}
|
|
13873
|
+
}
|
|
13897
13874
|
const reconciler = /* @__PURE__ */ createReconciler({
|
|
13898
13875
|
isPrimaryRenderer: false,
|
|
13899
13876
|
warnsIfNotActing: false,
|
|
@@ -13932,16 +13909,15 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13932
13909
|
else if (newProps.args?.length !== oldProps.args?.length) reconstruct = true;
|
|
13933
13910
|
else if (newProps.args?.some((value, index) => value !== oldProps.args?.[index])) reconstruct = true;
|
|
13934
13911
|
if (reconstruct) {
|
|
13935
|
-
reconstructed.push([instance,
|
|
13912
|
+
reconstructed.push([instance, getInstanceProps(newProps), fiber]);
|
|
13936
13913
|
} else {
|
|
13937
13914
|
const changedProps = diffProps(instance, newProps);
|
|
13938
|
-
|
|
13939
|
-
|
|
13940
|
-
|
|
13941
|
-
|
|
13915
|
+
const attach2 = instance.props.attach;
|
|
13916
|
+
instance.props = getInstanceProps(newProps);
|
|
13917
|
+
if (attach2 !== void 0) instance.props.attach = attach2;
|
|
13918
|
+
else delete instance.props.attach;
|
|
13919
|
+
if (Object.keys(changedProps).length) applyProps(instance.object, changedProps);
|
|
13942
13920
|
}
|
|
13943
|
-
const isTailSibling = fiber.sibling === null || (fiber.flags & Update) === NoFlags;
|
|
13944
|
-
if (isTailSibling) swapInstances();
|
|
13945
13921
|
},
|
|
13946
13922
|
finalizeInitialChildren: (instance) => {
|
|
13947
13923
|
for (const prop in instance.props) {
|
|
@@ -13966,8 +13942,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13966
13942
|
const target = container.getState().internal.container ?? container.getState().scene;
|
|
13967
13943
|
return prepare(target, container, "", {});
|
|
13968
13944
|
},
|
|
13969
|
-
|
|
13970
|
-
|
|
13945
|
+
// Reconstructed instances are swapped once all mutations are committed,
|
|
13946
|
+
// before layout effects run so refs point to the new objects
|
|
13947
|
+
resetAfterCommit: flushReconstructedInstances,
|
|
13971
13948
|
shouldSetTextContent: () => false,
|
|
13972
13949
|
clearContainer: () => false,
|
|
13973
13950
|
hideInstance,
|
|
@@ -13975,6 +13952,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13975
13952
|
createTextInstance: handleTextInstance,
|
|
13976
13953
|
hideTextInstance: handleTextInstance,
|
|
13977
13954
|
unhideTextInstance: handleTextInstance,
|
|
13955
|
+
// Mirrors react-dom, which flushes discrete work in microtasks
|
|
13956
|
+
supportsMicrotasks: true,
|
|
13957
|
+
scheduleMicrotask,
|
|
13978
13958
|
scheduleTimeout: typeof setTimeout === "function" ? setTimeout : void 0,
|
|
13979
13959
|
cancelTimeout: typeof clearTimeout === "function" ? clearTimeout : void 0,
|
|
13980
13960
|
noTimeout: -1,
|
|
@@ -14015,28 +13995,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
14015
13995
|
},
|
|
14016
13996
|
resolveUpdatePriority() {
|
|
14017
13997
|
if (currentUpdatePriority !== NoEventPriority) return currentUpdatePriority;
|
|
14018
|
-
|
|
14019
|
-
|
|
14020
|
-
|
|
14021
|
-
case "dblclick":
|
|
14022
|
-
case "dragenter":
|
|
14023
|
-
case "dragleave":
|
|
14024
|
-
case "drop":
|
|
14025
|
-
case "pointercancel":
|
|
14026
|
-
case "pointerdown":
|
|
14027
|
-
case "pointerup":
|
|
14028
|
-
return e;
|
|
14029
|
-
case "dragover":
|
|
14030
|
-
case "pointermove":
|
|
14031
|
-
case "pointerout":
|
|
14032
|
-
case "pointerover":
|
|
14033
|
-
case "pointerenter":
|
|
14034
|
-
case "pointerleave":
|
|
14035
|
-
case "wheel":
|
|
14036
|
-
return o;
|
|
14037
|
-
default:
|
|
14038
|
-
return r;
|
|
14039
|
-
}
|
|
13998
|
+
const eventType = typeof window !== "undefined" ? window.event?.type : void 0;
|
|
13999
|
+
if (eventType === void 0) return r;
|
|
14000
|
+
return getEventPriority(eventType);
|
|
14040
14001
|
},
|
|
14041
14002
|
resetFormInstance() {
|
|
14042
14003
|
},
|
|
@@ -14394,7 +14355,7 @@ function createRoot(canvas) {
|
|
|
14394
14355
|
const handleXRFrame = (timestamp, _frame) => {
|
|
14395
14356
|
const state2 = store.getState();
|
|
14396
14357
|
if (state2.frameloop === "never") return;
|
|
14397
|
-
advance(timestamp);
|
|
14358
|
+
advance(timestamp, true, state2);
|
|
14398
14359
|
};
|
|
14399
14360
|
const actualRenderer = state.internal.actualRenderer;
|
|
14400
14361
|
const handleSessionChange = () => {
|
|
@@ -14402,7 +14363,7 @@ function createRoot(canvas) {
|
|
|
14402
14363
|
const renderer2 = state2.internal.actualRenderer;
|
|
14403
14364
|
actualRenderer.xr.enabled = actualRenderer.xr.isPresenting;
|
|
14404
14365
|
renderer2.xr.setAnimationLoop(renderer2.xr.isPresenting ? handleXRFrame : null);
|
|
14405
|
-
if (!renderer2.xr.isPresenting) invalidate();
|
|
14366
|
+
if (!renderer2.xr.isPresenting) invalidate(state2);
|
|
14406
14367
|
};
|
|
14407
14368
|
const xr = {
|
|
14408
14369
|
connect() {
|
|
@@ -14484,7 +14445,11 @@ function createRoot(canvas) {
|
|
|
14484
14445
|
const newRootId = canvasId || scheduler.generateRootId();
|
|
14485
14446
|
const unregisterRoot = scheduler.registerRoot(newRootId, {
|
|
14486
14447
|
getState: () => store.getState(),
|
|
14487
|
-
onError: (err) => store.getState().setError(err)
|
|
14448
|
+
onError: (err) => store.getState().setError(err),
|
|
14449
|
+
frameloop: store.getState().frameloop,
|
|
14450
|
+
before: schedulerConfig?.before,
|
|
14451
|
+
after: schedulerConfig?.after,
|
|
14452
|
+
order: schedulerConfig?.order
|
|
14488
14453
|
});
|
|
14489
14454
|
const unregisterCanvasTarget = scheduler.register(
|
|
14490
14455
|
() => {
|
|
@@ -14492,6 +14457,10 @@ function createRoot(canvas) {
|
|
|
14492
14457
|
if (state2.internal.isMultiCanvas && state2.internal.canvasTarget) {
|
|
14493
14458
|
const renderer2 = state2.internal.actualRenderer;
|
|
14494
14459
|
renderer2.setCanvasTarget(state2.internal.canvasTarget);
|
|
14460
|
+
if (state2.internal.canvasTargetSizeDirty) {
|
|
14461
|
+
state2.internal.canvasTargetSizeDirty = false;
|
|
14462
|
+
renderer2.backend?.updateSize?.();
|
|
14463
|
+
}
|
|
14495
14464
|
}
|
|
14496
14465
|
},
|
|
14497
14466
|
{
|
|
@@ -14560,8 +14529,7 @@ function createRoot(canvas) {
|
|
|
14560
14529
|
phase: "render",
|
|
14561
14530
|
system: true,
|
|
14562
14531
|
// Internal flag: this is a system job, not user-controlled
|
|
14563
|
-
//
|
|
14564
|
-
...schedulerConfig?.after && { after: schedulerConfig.after },
|
|
14532
|
+
// FPS throttles only the default render job; Canvas ordering belongs to the root.
|
|
14565
14533
|
...schedulerConfig?.fps && { fps: schedulerConfig.fps }
|
|
14566
14534
|
}
|
|
14567
14535
|
);
|
|
@@ -14580,8 +14548,21 @@ function createRoot(canvas) {
|
|
|
14580
14548
|
scheduler
|
|
14581
14549
|
}
|
|
14582
14550
|
}));
|
|
14551
|
+
} else {
|
|
14552
|
+
const constraintsChanged = !is.equ(schedulerConfig?.before, lastConfiguredProps.schedulerBefore, shallowLoose) || !is.equ(schedulerConfig?.after, lastConfiguredProps.schedulerAfter, shallowLoose);
|
|
14553
|
+
if (constraintsChanged) {
|
|
14554
|
+
scheduler.setRootConstraints(rootId, {
|
|
14555
|
+
before: schedulerConfig?.before,
|
|
14556
|
+
after: schedulerConfig?.after
|
|
14557
|
+
});
|
|
14558
|
+
}
|
|
14559
|
+
if (schedulerConfig?.order !== lastConfiguredProps.schedulerOrder) {
|
|
14560
|
+
scheduler.setRootOrder(rootId, schedulerConfig?.order ?? 0);
|
|
14561
|
+
}
|
|
14583
14562
|
}
|
|
14584
|
-
|
|
14563
|
+
lastConfiguredProps.schedulerBefore = schedulerConfig?.before;
|
|
14564
|
+
lastConfiguredProps.schedulerAfter = schedulerConfig?.after;
|
|
14565
|
+
lastConfiguredProps.schedulerOrder = schedulerConfig?.order;
|
|
14585
14566
|
onCreated = onCreatedCallback;
|
|
14586
14567
|
configured = true;
|
|
14587
14568
|
resolve();
|
|
@@ -14623,14 +14604,19 @@ function unmountComponentAtNode(canvas, callback) {
|
|
|
14623
14604
|
const fiber = root?.fiber;
|
|
14624
14605
|
if (fiber) {
|
|
14625
14606
|
const state = root?.store.getState();
|
|
14626
|
-
if (state)
|
|
14607
|
+
if (state) {
|
|
14608
|
+
state.internal.active = false;
|
|
14609
|
+
const unregisterRoot = state.internal.unregisterRoot;
|
|
14610
|
+
if (unregisterRoot) {
|
|
14611
|
+
unregisterRoot();
|
|
14612
|
+
state.internal.unregisterRoot = void 0;
|
|
14613
|
+
}
|
|
14614
|
+
}
|
|
14627
14615
|
reconciler.updateContainer(null, fiber, null, () => {
|
|
14628
14616
|
if (state) {
|
|
14629
14617
|
setTimeout(() => {
|
|
14630
14618
|
try {
|
|
14631
14619
|
const renderer = state.internal.actualRenderer;
|
|
14632
|
-
const unregisterRoot = state.internal.unregisterRoot;
|
|
14633
|
-
if (unregisterRoot) unregisterRoot();
|
|
14634
14620
|
const unregisterPrimary = state.internal.unregisterPrimary;
|
|
14635
14621
|
if (unregisterPrimary) unregisterPrimary();
|
|
14636
14622
|
const canvasTarget = state.internal.canvasTarget;
|
|
@@ -14648,7 +14634,8 @@ function unmountComponentAtNode(canvas, callback) {
|
|
|
14648
14634
|
dispose(state.scene);
|
|
14649
14635
|
_roots.delete(canvas);
|
|
14650
14636
|
if (callback) callback(canvas);
|
|
14651
|
-
} catch {
|
|
14637
|
+
} catch (error) {
|
|
14638
|
+
console.warn("[R3F] Error while unmounting root; teardown may be incomplete:", error);
|
|
14652
14639
|
}
|
|
14653
14640
|
}, 500);
|
|
14654
14641
|
}
|
|
@@ -14759,6 +14746,212 @@ function flushSync(fn) {
|
|
|
14759
14746
|
return reconciler.flushSyncFromReconciler(fn);
|
|
14760
14747
|
}
|
|
14761
14748
|
|
|
14749
|
+
const isRef = (obj) => obj.current && obj.current.isScene;
|
|
14750
|
+
const resolveScene = (scene) => isRef(scene) ? scene.current : scene;
|
|
14751
|
+
function setEnvProps(background, scene, defaultScene, texture, sceneProps = {}) {
|
|
14752
|
+
sceneProps = {
|
|
14753
|
+
backgroundBlurriness: 0,
|
|
14754
|
+
backgroundIntensity: 1,
|
|
14755
|
+
backgroundRotation: [0, 0, 0],
|
|
14756
|
+
environmentIntensity: 1,
|
|
14757
|
+
environmentRotation: [0, 0, 0],
|
|
14758
|
+
...sceneProps
|
|
14759
|
+
};
|
|
14760
|
+
const target = resolveScene(scene || defaultScene);
|
|
14761
|
+
const oldbg = target.background;
|
|
14762
|
+
const oldenv = target.environment;
|
|
14763
|
+
const oldSceneProps = {
|
|
14764
|
+
// @ts-ignore
|
|
14765
|
+
backgroundBlurriness: target.backgroundBlurriness,
|
|
14766
|
+
// @ts-ignore
|
|
14767
|
+
backgroundIntensity: target.backgroundIntensity,
|
|
14768
|
+
// @ts-ignore
|
|
14769
|
+
backgroundRotation: target.backgroundRotation?.clone?.() ?? [0, 0, 0],
|
|
14770
|
+
// @ts-ignore
|
|
14771
|
+
environmentIntensity: target.environmentIntensity,
|
|
14772
|
+
// @ts-ignore
|
|
14773
|
+
environmentRotation: target.environmentRotation?.clone?.() ?? [0, 0, 0]
|
|
14774
|
+
};
|
|
14775
|
+
if (background !== "only") target.environment = texture;
|
|
14776
|
+
if (background) target.background = texture;
|
|
14777
|
+
applyProps(target, sceneProps);
|
|
14778
|
+
return () => {
|
|
14779
|
+
if (background !== "only") target.environment = oldenv;
|
|
14780
|
+
if (background) target.background = oldbg;
|
|
14781
|
+
applyProps(target, oldSceneProps);
|
|
14782
|
+
};
|
|
14783
|
+
}
|
|
14784
|
+
function EnvironmentMap({ scene, background = false, map, ...config }) {
|
|
14785
|
+
const defaultScene = useThree((state) => state.scene);
|
|
14786
|
+
React.useLayoutEffect(() => {
|
|
14787
|
+
if (map) return setEnvProps(background, scene, defaultScene, map, config);
|
|
14788
|
+
});
|
|
14789
|
+
return null;
|
|
14790
|
+
}
|
|
14791
|
+
function EnvironmentCube({
|
|
14792
|
+
background = false,
|
|
14793
|
+
scene,
|
|
14794
|
+
blur,
|
|
14795
|
+
backgroundBlurriness,
|
|
14796
|
+
backgroundIntensity,
|
|
14797
|
+
backgroundRotation,
|
|
14798
|
+
environmentIntensity,
|
|
14799
|
+
environmentRotation,
|
|
14800
|
+
...rest
|
|
14801
|
+
}) {
|
|
14802
|
+
const texture = useEnvironment(rest);
|
|
14803
|
+
const defaultScene = useThree((state) => state.scene);
|
|
14804
|
+
React.useLayoutEffect(() => {
|
|
14805
|
+
return setEnvProps(background, scene, defaultScene, texture, {
|
|
14806
|
+
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
14807
|
+
backgroundIntensity,
|
|
14808
|
+
backgroundRotation,
|
|
14809
|
+
environmentIntensity,
|
|
14810
|
+
environmentRotation
|
|
14811
|
+
});
|
|
14812
|
+
});
|
|
14813
|
+
React.useEffect(() => {
|
|
14814
|
+
return () => {
|
|
14815
|
+
texture.dispose();
|
|
14816
|
+
};
|
|
14817
|
+
}, [texture]);
|
|
14818
|
+
return null;
|
|
14819
|
+
}
|
|
14820
|
+
function EnvironmentPortal({
|
|
14821
|
+
children,
|
|
14822
|
+
near = 0.1,
|
|
14823
|
+
far = 1e3,
|
|
14824
|
+
resolution = 256,
|
|
14825
|
+
frames = 1,
|
|
14826
|
+
map,
|
|
14827
|
+
background = false,
|
|
14828
|
+
blur,
|
|
14829
|
+
backgroundBlurriness,
|
|
14830
|
+
backgroundIntensity,
|
|
14831
|
+
backgroundRotation,
|
|
14832
|
+
environmentIntensity,
|
|
14833
|
+
environmentRotation,
|
|
14834
|
+
scene,
|
|
14835
|
+
files,
|
|
14836
|
+
path,
|
|
14837
|
+
preset = void 0,
|
|
14838
|
+
extensions
|
|
14839
|
+
}) {
|
|
14840
|
+
const renderer = useThree((state) => state.renderer);
|
|
14841
|
+
const isLegacy = useThree((state) => state.isLegacy);
|
|
14842
|
+
const defaultScene = useThree((state) => state.scene);
|
|
14843
|
+
const camera = React.useRef(null);
|
|
14844
|
+
const [virtualScene] = React.useState(() => new Scene());
|
|
14845
|
+
const fbo = React.useMemo(() => {
|
|
14846
|
+
const fbo2 = isLegacy ? new WebGLCubeRenderTarget(resolution) : new CubeRenderTarget(resolution);
|
|
14847
|
+
fbo2.texture.type = HalfFloatType;
|
|
14848
|
+
return fbo2;
|
|
14849
|
+
}, [resolution, isLegacy]);
|
|
14850
|
+
React.useEffect(() => {
|
|
14851
|
+
return () => {
|
|
14852
|
+
fbo.dispose();
|
|
14853
|
+
};
|
|
14854
|
+
}, [fbo]);
|
|
14855
|
+
React.useLayoutEffect(() => {
|
|
14856
|
+
if (frames === 1) {
|
|
14857
|
+
const autoClear = renderer.autoClear;
|
|
14858
|
+
renderer.autoClear = true;
|
|
14859
|
+
camera.current.update(renderer, virtualScene);
|
|
14860
|
+
renderer.autoClear = autoClear;
|
|
14861
|
+
}
|
|
14862
|
+
return setEnvProps(background, scene, defaultScene, fbo.texture, {
|
|
14863
|
+
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
14864
|
+
backgroundIntensity,
|
|
14865
|
+
backgroundRotation,
|
|
14866
|
+
environmentIntensity,
|
|
14867
|
+
environmentRotation
|
|
14868
|
+
});
|
|
14869
|
+
}, [
|
|
14870
|
+
children,
|
|
14871
|
+
virtualScene,
|
|
14872
|
+
fbo.texture,
|
|
14873
|
+
scene,
|
|
14874
|
+
defaultScene,
|
|
14875
|
+
background,
|
|
14876
|
+
frames,
|
|
14877
|
+
renderer,
|
|
14878
|
+
blur,
|
|
14879
|
+
backgroundBlurriness,
|
|
14880
|
+
backgroundIntensity,
|
|
14881
|
+
backgroundRotation,
|
|
14882
|
+
environmentIntensity,
|
|
14883
|
+
environmentRotation
|
|
14884
|
+
]);
|
|
14885
|
+
let count = 1;
|
|
14886
|
+
useFrame(() => {
|
|
14887
|
+
if (frames === Infinity || count < frames) {
|
|
14888
|
+
const autoClear = renderer.autoClear;
|
|
14889
|
+
renderer.autoClear = true;
|
|
14890
|
+
camera.current.update(renderer, virtualScene);
|
|
14891
|
+
renderer.autoClear = autoClear;
|
|
14892
|
+
count++;
|
|
14893
|
+
}
|
|
14894
|
+
});
|
|
14895
|
+
return /* @__PURE__ */ jsx(Fragment, { children: createPortal(
|
|
14896
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
14897
|
+
children,
|
|
14898
|
+
/* @__PURE__ */ jsx("cubeCamera", { ref: camera, args: [near, far, fbo] }),
|
|
14899
|
+
files || preset ? /* @__PURE__ */ jsx(EnvironmentCube, { background: true, files, preset, path, extensions }) : map ? /* @__PURE__ */ jsx(EnvironmentMap, { background: true, map, extensions }) : null
|
|
14900
|
+
] }),
|
|
14901
|
+
virtualScene
|
|
14902
|
+
) });
|
|
14903
|
+
}
|
|
14904
|
+
function EnvironmentGround(props) {
|
|
14905
|
+
const textureDefault = useEnvironment(props);
|
|
14906
|
+
const texture = props.map || textureDefault;
|
|
14907
|
+
React.useMemo(() => extend({ GroundProjectedEnvImpl: GroundedSkybox }), []);
|
|
14908
|
+
React.useEffect(() => {
|
|
14909
|
+
return () => {
|
|
14910
|
+
textureDefault.dispose();
|
|
14911
|
+
};
|
|
14912
|
+
}, [textureDefault]);
|
|
14913
|
+
const height = props.ground?.height ?? 15;
|
|
14914
|
+
const radius = props.ground?.radius ?? 60;
|
|
14915
|
+
const scale = props.ground?.scale ?? 1e3;
|
|
14916
|
+
const args = React.useMemo(
|
|
14917
|
+
() => [texture, height, radius],
|
|
14918
|
+
[texture, height, radius]
|
|
14919
|
+
);
|
|
14920
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
14921
|
+
/* @__PURE__ */ jsx(EnvironmentMap, { ...props, map: texture }),
|
|
14922
|
+
/* @__PURE__ */ jsx("groundProjectedEnvImpl", { args, scale })
|
|
14923
|
+
] });
|
|
14924
|
+
}
|
|
14925
|
+
function EnvironmentColor({ color, scene }) {
|
|
14926
|
+
const defaultScene = useThree((state) => state.scene);
|
|
14927
|
+
React.useLayoutEffect(() => {
|
|
14928
|
+
if (color === void 0) return;
|
|
14929
|
+
const target = resolveScene(scene || defaultScene);
|
|
14930
|
+
const oldBg = target.background;
|
|
14931
|
+
target.background = new Color(color);
|
|
14932
|
+
return () => {
|
|
14933
|
+
target.background = oldBg;
|
|
14934
|
+
};
|
|
14935
|
+
});
|
|
14936
|
+
return null;
|
|
14937
|
+
}
|
|
14938
|
+
function EnvironmentDualSource(props) {
|
|
14939
|
+
const { backgroundFiles, ...envProps } = props;
|
|
14940
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
14941
|
+
/* @__PURE__ */ jsx(EnvironmentCube, { ...envProps, background: false }),
|
|
14942
|
+
/* @__PURE__ */ jsx(EnvironmentCube, { ...props, files: backgroundFiles, background: "only" })
|
|
14943
|
+
] });
|
|
14944
|
+
}
|
|
14945
|
+
function Environment(props) {
|
|
14946
|
+
if (props.color && !props.files && !props.preset && !props.map) {
|
|
14947
|
+
return /* @__PURE__ */ jsx(EnvironmentColor, { ...props });
|
|
14948
|
+
}
|
|
14949
|
+
if (props.backgroundFiles && props.backgroundFiles !== props.files) {
|
|
14950
|
+
return /* @__PURE__ */ jsx(EnvironmentDualSource, { ...props });
|
|
14951
|
+
}
|
|
14952
|
+
return props.ground ? /* @__PURE__ */ jsx(EnvironmentGround, { ...props }) : props.map ? /* @__PURE__ */ jsx(EnvironmentMap, { ...props }) : props.children ? /* @__PURE__ */ jsx(EnvironmentPortal, { ...props }) : /* @__PURE__ */ jsx(EnvironmentCube, { ...props });
|
|
14953
|
+
}
|
|
14954
|
+
|
|
14762
14955
|
function parseBackground(background) {
|
|
14763
14956
|
if (!background) return null;
|
|
14764
14957
|
if (typeof background === "object" && !background.isColor) {
|
|
@@ -14802,14 +14995,36 @@ function parseRendererConfig(rendererProp) {
|
|
|
14802
14995
|
return { primaryCanvas: void 0, scheduler: void 0, renderer: rendererProp };
|
|
14803
14996
|
}
|
|
14804
14997
|
|
|
14998
|
+
const RESOURCE_KINDS = ["nodes", "uniforms", "buffers", "gpuStorage"];
|
|
14999
|
+
const registries = /* @__PURE__ */ new WeakMap();
|
|
15000
|
+
function getKindRegistry(store, kind) {
|
|
15001
|
+
let registry = registries.get(store);
|
|
15002
|
+
if (!registry) {
|
|
15003
|
+
registry = {
|
|
15004
|
+
nodes: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() },
|
|
15005
|
+
uniforms: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() },
|
|
15006
|
+
buffers: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() },
|
|
15007
|
+
gpuStorage: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() }
|
|
15008
|
+
};
|
|
15009
|
+
registries.set(store, registry);
|
|
15010
|
+
}
|
|
15011
|
+
return registry[kind];
|
|
15012
|
+
}
|
|
15013
|
+
function invalidateResource(store, kind, scopeKey) {
|
|
15014
|
+
const registry = getKindRegistry(store, kind);
|
|
15015
|
+
{
|
|
15016
|
+
registry.valid.clear();
|
|
15017
|
+
registry.staged.clear();
|
|
15018
|
+
}
|
|
15019
|
+
}
|
|
15020
|
+
function invalidateAllResources(store) {
|
|
15021
|
+
for (const kind of RESOURCE_KINDS) invalidateResource(store, kind);
|
|
15022
|
+
}
|
|
15023
|
+
|
|
14805
15024
|
function clearHmrCaches(store) {
|
|
14806
|
-
store.
|
|
14807
|
-
|
|
14808
|
-
|
|
14809
|
-
buffers: {},
|
|
14810
|
-
gpuStorage: {},
|
|
14811
|
-
_hmrVersion: state._hmrVersion + 1
|
|
14812
|
-
}));
|
|
15025
|
+
const primary = store.getState().primaryStore ?? store;
|
|
15026
|
+
invalidateAllResources(primary);
|
|
15027
|
+
primary.setState((state) => ({ _hmrVersion: state._hmrVersion + 1 }));
|
|
14813
15028
|
}
|
|
14814
15029
|
|
|
14815
15030
|
function CanvasImpl({
|
|
@@ -14946,7 +15161,7 @@ function CanvasImpl({
|
|
|
14946
15161
|
onDropMissed: (...args) => handleDropMissed.current?.(...args),
|
|
14947
15162
|
onCreated: (state) => {
|
|
14948
15163
|
state.events.connect?.(
|
|
14949
|
-
eventSource ? isRef(eventSource) ? eventSource.current : eventSource : divRef.current
|
|
15164
|
+
eventSource ? isRef$1(eventSource) ? eventSource.current : eventSource : divRef.current
|
|
14950
15165
|
);
|
|
14951
15166
|
if (eventPrefix) {
|
|
14952
15167
|
state.setEvents({
|
|
@@ -14995,6 +15210,7 @@ function CanvasImpl({
|
|
|
14995
15210
|
const canvas = canvasRef.current;
|
|
14996
15211
|
if (canvas) {
|
|
14997
15212
|
return () => {
|
|
15213
|
+
if (canvas.isConnected) return;
|
|
14998
15214
|
unmountComponentAtNode(canvas);
|
|
14999
15215
|
root.current = null;
|
|
15000
15216
|
};
|
|
@@ -15059,4 +15275,4 @@ function Canvas(props) {
|
|
|
15059
15275
|
|
|
15060
15276
|
extend(THREE);
|
|
15061
15277
|
|
|
15062
|
-
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,
|
|
15278
|
+
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, removeInteractivity, resolve, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useEnvironment, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useRenderTarget, useStore, useTexture, useTextures, useThree, waitForPrimary };
|