@react-three/fiber 10.0.0-canary.c49d4cb → 10.0.0-canary.c4ecb6a
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 +2088 -1872
- package/dist/index.d.cts +310 -155
- package/dist/index.d.mts +310 -155
- package/dist/index.d.ts +308 -181
- package/dist/index.mjs +2090 -1874
- package/dist/legacy.cjs +2500 -2285
- package/dist/legacy.d.cts +336 -213
- package/dist/legacy.d.mts +336 -213
- package/dist/legacy.d.ts +334 -237
- package/dist/legacy.mjs +1929 -1714
- package/dist/webgpu/index.cjs +2598 -2598
- package/dist/webgpu/index.d.cts +406 -270
- package/dist/webgpu/index.d.mts +406 -270
- package/dist/webgpu/index.d.ts +404 -296
- package/dist/webgpu/index.mjs +2435 -2435
- package/package.json +4 -4
- package/readme.md +1 -1
- package/react-reconciler/constants.d.ts +0 -7
- package/react-reconciler/constants.js +0 -1
- package/react-reconciler/index.d.ts +0 -1044
- package/react-reconciler/index.js +0 -208
package/dist/legacy.mjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import * as three from 'three';
|
|
2
|
-
import { WebGLCubeRenderTarget, WebGLRenderTarget,
|
|
2
|
+
import { WebGLCubeRenderTarget, WebGLRenderTarget, Frustum, Matrix4, Group, BoxGeometry, MeshBasicNodeMaterial, Mesh, Node, NodeUpdateType, Layers, ShaderMaterial, Uniform, SRGBColorSpace, RGBAFormat, UnsignedByteType, Vector3, Vector2, TextureLoader, Texture as Texture$1, CubeReflectionMapping, EquirectangularReflectionMapping, CubeTextureLoader, Raycaster, OrthographicCamera, PerspectiveCamera, Scene, PCFShadowMap, VSMShadowMap, BasicShadowMap, ACESFilmicToneMapping, WebGLRenderer, HalfFloatType, Color } from 'three';
|
|
3
3
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import React__default, {
|
|
5
|
+
import React__default, { useRef, useMemo, useLayoutEffect, useEffect, useContext, useImperativeHandle, useCallback, useState } from 'react';
|
|
6
6
|
import useMeasure from 'react-use-measure';
|
|
7
7
|
import { useFiber, useContextBridge, traverseFiber, FiberProvider } from 'its-fine';
|
|
8
|
-
import {
|
|
8
|
+
import { createWithEqualityFn } from 'zustand/traditional';
|
|
9
|
+
import { getScheduler } from '@pmndrs/scheduler';
|
|
10
|
+
export { Scheduler, getScheduler } from '@pmndrs/scheduler';
|
|
11
|
+
import Tb, { unstable_getCurrentPriorityLevel, unstable_IdlePriority, unstable_LowPriority, unstable_NormalPriority, unstable_UserBlockingPriority, unstable_ImmediatePriority, unstable_scheduleCallback } from 'scheduler';
|
|
9
12
|
import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
|
|
10
13
|
import { HDRLoader } from 'three/examples/jsm/loaders/HDRLoader.js';
|
|
14
|
+
import { HDRCubeTextureLoader } from 'three/examples/jsm/loaders/HDRCubeTextureLoader.js';
|
|
11
15
|
import { EXRLoader } from 'three/examples/jsm/loaders/EXRLoader.js';
|
|
12
16
|
import { UltraHDRLoader } from 'three/examples/jsm/loaders/UltraHDRLoader.js';
|
|
13
17
|
import { GainMapLoader } from '@monogrid/gainmap-js';
|
|
14
|
-
import Tb, { unstable_scheduleCallback, unstable_IdlePriority } from 'scheduler';
|
|
15
|
-
import { createWithEqualityFn } from 'zustand/traditional';
|
|
16
|
-
import { getScheduler } from '@pmndrs/scheduler';
|
|
17
|
-
export { Scheduler, getScheduler } from '@pmndrs/scheduler';
|
|
18
18
|
import { suspend, preload, clear } from 'suspend-react';
|
|
19
19
|
|
|
20
20
|
function _mergeNamespaces(n, m) {
|
|
@@ -31,16 +31,14 @@ function _mergeNamespaces(n, m) {
|
|
|
31
31
|
|
|
32
32
|
const R3F_BUILD_LEGACY = true;
|
|
33
33
|
const R3F_BUILD_WEBGPU = false;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
39
|
-
const WebGPURenderer = class WebGPURenderer2 {
|
|
34
|
+
async function loadInspector() {
|
|
35
|
+
throw new Error("Inspector is not available in legacy builds. Use @react-three/fiber/webgpu instead.");
|
|
36
|
+
}
|
|
37
|
+
class WebGPURenderer {
|
|
40
38
|
constructor() {
|
|
41
39
|
throw new Error("WebGPURenderer is not available in legacy builds. Use @react-three/fiber/webgpu instead.");
|
|
42
40
|
}
|
|
43
|
-
}
|
|
41
|
+
}
|
|
44
42
|
const RenderTarget = null;
|
|
45
43
|
const CubeRenderTarget = null;
|
|
46
44
|
|
|
@@ -48,12 +46,12 @@ const THREE = /*#__PURE__*/_mergeNamespaces({
|
|
|
48
46
|
__proto__: null,
|
|
49
47
|
CubeRenderTarget: CubeRenderTarget,
|
|
50
48
|
CubeRenderTargetCompat: WebGLCubeRenderTarget,
|
|
51
|
-
Inspector: Inspector,
|
|
52
49
|
R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
|
|
53
50
|
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
54
51
|
RenderTarget: RenderTarget,
|
|
55
52
|
RenderTargetCompat: WebGLRenderTarget,
|
|
56
|
-
WebGPURenderer: WebGPURenderer
|
|
53
|
+
WebGPURenderer: WebGPURenderer,
|
|
54
|
+
loadInspector: loadInspector
|
|
57
55
|
}, [three]);
|
|
58
56
|
|
|
59
57
|
const primaryRegistry = /* @__PURE__ */ new Map();
|
|
@@ -114,556 +112,228 @@ function getPrimaryIds() {
|
|
|
114
112
|
return Array.from(primaryRegistry.keys());
|
|
115
113
|
}
|
|
116
114
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
115
|
+
var __defProp = Object.defineProperty;
|
|
116
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
117
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
118
|
+
const useIsomorphicLayoutEffect = /* @__PURE__ */ (() => typeof window !== "undefined" && (window.document?.createElement || window.navigator?.product === "ReactNative"))() ? React.useLayoutEffect : React.useEffect;
|
|
119
|
+
function useMutableCallback(fn) {
|
|
120
|
+
const ref = React.useRef(fn);
|
|
121
|
+
useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
|
|
122
|
+
return ref;
|
|
123
|
+
}
|
|
124
|
+
function useBridge() {
|
|
125
|
+
const fiber = useFiber();
|
|
126
|
+
const ContextBridge = useContextBridge();
|
|
127
|
+
return React.useMemo(
|
|
128
|
+
() => ({ children }) => {
|
|
129
|
+
const strict = !!traverseFiber(fiber, true, (node) => node.type === React.StrictMode);
|
|
130
|
+
const Root = strict ? React.StrictMode : React.Fragment;
|
|
131
|
+
return /* @__PURE__ */ jsx(Root, { children: /* @__PURE__ */ jsx(ContextBridge, { children }) });
|
|
132
|
+
},
|
|
133
|
+
[fiber, ContextBridge]
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
function Block({ set }) {
|
|
137
|
+
useIsomorphicLayoutEffect(() => {
|
|
138
|
+
set(new Promise(() => null));
|
|
139
|
+
return () => set(false);
|
|
140
|
+
}, [set]);
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
const ErrorBoundary = /* @__PURE__ */ (() => {
|
|
144
|
+
var _a;
|
|
145
|
+
return _a = class extends React.Component {
|
|
146
|
+
constructor() {
|
|
147
|
+
super(...arguments);
|
|
148
|
+
__publicField(this, "state", { error: false });
|
|
149
|
+
}
|
|
150
|
+
componentDidCatch(err) {
|
|
151
|
+
this.props.set(err);
|
|
152
|
+
}
|
|
153
|
+
render() {
|
|
154
|
+
return this.state.error ? null : this.props.children;
|
|
155
|
+
}
|
|
156
|
+
}, __publicField(_a, "getDerivedStateFromError", () => ({ error: true })), _a;
|
|
157
|
+
})();
|
|
129
158
|
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
} = {}) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
useLoader$1.clear(loader, multiFile ? [files] : files);
|
|
159
|
+
const is = {
|
|
160
|
+
obj: (a) => a === Object(a) && !is.arr(a) && typeof a !== "function",
|
|
161
|
+
fun: (a) => typeof a === "function",
|
|
162
|
+
str: (a) => typeof a === "string",
|
|
163
|
+
num: (a) => typeof a === "number",
|
|
164
|
+
boo: (a) => typeof a === "boolean",
|
|
165
|
+
und: (a) => a === void 0,
|
|
166
|
+
nul: (a) => a === null,
|
|
167
|
+
arr: (a) => Array.isArray(a),
|
|
168
|
+
equ(a, b, { arrays = "shallow", objects = "reference", strict = true } = {}) {
|
|
169
|
+
if (typeof a !== typeof b || !!a !== !!b) return false;
|
|
170
|
+
if (is.str(a) || is.num(a) || is.boo(a)) return a === b;
|
|
171
|
+
const isObj = is.obj(a);
|
|
172
|
+
if (isObj && objects === "reference") return a === b;
|
|
173
|
+
const isArr = is.arr(a);
|
|
174
|
+
if (isArr && arrays === "reference") return a === b;
|
|
175
|
+
if ((isArr || isObj) && a === b) return true;
|
|
176
|
+
let i;
|
|
177
|
+
for (i in a) if (!(i in b)) return false;
|
|
178
|
+
if (isObj && arrays === "shallow" && objects === "shallow") {
|
|
179
|
+
for (i in strict ? b : a) if (!is.equ(a[i], b[i], { strict, objects: "reference" })) return false;
|
|
180
|
+
} else {
|
|
181
|
+
for (i in strict ? b : a) if (a[i] !== b[i]) return false;
|
|
154
182
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
multiFile ? [files] : files,
|
|
160
|
-
(loader2) => {
|
|
161
|
-
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
162
|
-
loader2.setRenderer?.(renderer);
|
|
163
|
-
}
|
|
164
|
-
loader2.setPath?.(path);
|
|
165
|
-
if (extensions) extensions(loader2);
|
|
183
|
+
if (is.und(i)) {
|
|
184
|
+
if (isArr && a.length === 0 && b.length === 0) return true;
|
|
185
|
+
if (isObj && Object.keys(a).length === 0 && Object.keys(b).length === 0) return true;
|
|
186
|
+
if (a !== b) return false;
|
|
166
187
|
}
|
|
167
|
-
|
|
168
|
-
let texture = multiFile ? (
|
|
169
|
-
// @ts-ignore
|
|
170
|
-
loaderResult[0]
|
|
171
|
-
) : loaderResult;
|
|
172
|
-
if (extension === "jpg" || extension === "jpeg" || extension === "webp") {
|
|
173
|
-
texture = texture.renderTarget?.texture;
|
|
174
|
-
}
|
|
175
|
-
texture.mapping = isCubemap ? CubeReflectionMapping : EquirectangularReflectionMapping;
|
|
176
|
-
texture.colorSpace = colorSpace ?? (isCubemap ? "srgb" : "srgb-linear");
|
|
177
|
-
return texture;
|
|
178
|
-
}
|
|
179
|
-
const preloadDefaultOptions = {
|
|
180
|
-
files: defaultFiles,
|
|
181
|
-
path: "",
|
|
182
|
-
preset: void 0,
|
|
183
|
-
extensions: void 0
|
|
184
|
-
};
|
|
185
|
-
useEnvironment.preload = (preloadOptions) => {
|
|
186
|
-
const options = { ...preloadDefaultOptions, ...preloadOptions };
|
|
187
|
-
let { files, path = "" } = options;
|
|
188
|
-
const { preset, extensions } = options;
|
|
189
|
-
if (preset) {
|
|
190
|
-
validatePreset(preset);
|
|
191
|
-
files = presetsObj[preset];
|
|
192
|
-
path = CUBEMAP_ROOT;
|
|
193
|
-
}
|
|
194
|
-
const { extension } = getExtension(files);
|
|
195
|
-
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
196
|
-
throw new Error("useEnvironment: Preloading gainmaps is not supported");
|
|
197
|
-
}
|
|
198
|
-
const loader = getLoader$1(extension);
|
|
199
|
-
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
200
|
-
useLoader$1.preload(loader, isArray(files) ? [files] : files, (loader2) => {
|
|
201
|
-
loader2.setPath?.(path);
|
|
202
|
-
if (extensions) extensions(loader2);
|
|
203
|
-
});
|
|
204
|
-
};
|
|
205
|
-
const clearDefaultOptins = {
|
|
206
|
-
files: defaultFiles,
|
|
207
|
-
preset: void 0
|
|
208
|
-
};
|
|
209
|
-
useEnvironment.clear = (clearOptions) => {
|
|
210
|
-
const options = { ...clearDefaultOptins, ...clearOptions };
|
|
211
|
-
let { files } = options;
|
|
212
|
-
const { preset } = options;
|
|
213
|
-
if (preset) {
|
|
214
|
-
validatePreset(preset);
|
|
215
|
-
files = presetsObj[preset];
|
|
188
|
+
return true;
|
|
216
189
|
}
|
|
217
|
-
const { extension } = getExtension(files);
|
|
218
|
-
const loader = getLoader$1(extension);
|
|
219
|
-
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
220
|
-
useLoader$1.clear(loader, isArray(files) ? [files] : files);
|
|
221
190
|
};
|
|
222
|
-
|
|
223
|
-
|
|
191
|
+
const isOrthographicCamera = (def) => def && def.isOrthographicCamera;
|
|
192
|
+
const isRef$1 = (obj) => obj !== null && typeof obj === "object" && obj.hasOwnProperty("current");
|
|
193
|
+
const isColorRepresentation = (value) => value != null && (typeof value === "string" || typeof value === "number" || value.isColor);
|
|
194
|
+
const isObject3D = (object) => object?.isObject3D;
|
|
195
|
+
const isTexture = (value) => !!value?.isTexture;
|
|
196
|
+
const isVectorLike = (object) => object !== null && typeof object === "object" && "set" in object && typeof object.set === "function";
|
|
197
|
+
const isCopyable = (object) => isVectorLike(object) && "copy" in object && typeof object.copy === "function";
|
|
198
|
+
const hasConstructor = (object) => !!object?.constructor;
|
|
199
|
+
|
|
200
|
+
function calculateDpr(dpr) {
|
|
201
|
+
const target = typeof window !== "undefined" ? window.devicePixelRatio ?? 2 : 1;
|
|
202
|
+
return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
|
|
224
203
|
}
|
|
225
|
-
function
|
|
226
|
-
|
|
227
|
-
const isGainmap = isArray(files) && files.length === 3 && files.some((file) => file.endsWith("json"));
|
|
228
|
-
const firstEntry = isArray(files) ? files[0] : files;
|
|
229
|
-
const extension = isCubemap ? "cube" : isGainmap ? "webp" : firstEntry.startsWith("data:application/exr") ? "exr" : firstEntry.startsWith("data:application/hdr") ? "hdr" : firstEntry.startsWith("data:image/jpeg") ? "jpg" : firstEntry.split(".").pop()?.split("?")?.shift()?.toLowerCase();
|
|
230
|
-
return { extension, isCubemap, isGainmap };
|
|
204
|
+
function getUuidPrefix(uuid) {
|
|
205
|
+
return uuid.split("-")[0];
|
|
231
206
|
}
|
|
232
|
-
function
|
|
233
|
-
|
|
234
|
-
|
|
207
|
+
function updateCamera(camera, size) {
|
|
208
|
+
if (camera.manual) return;
|
|
209
|
+
if (isOrthographicCamera(camera)) {
|
|
210
|
+
camera.left = size.width / -2;
|
|
211
|
+
camera.right = size.width / 2;
|
|
212
|
+
camera.top = size.height / 2;
|
|
213
|
+
camera.bottom = size.height / -2;
|
|
214
|
+
} else {
|
|
215
|
+
camera.aspect = size.width / size.height;
|
|
216
|
+
}
|
|
217
|
+
camera.updateProjectionMatrix();
|
|
235
218
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
backgroundIntensity: 1,
|
|
243
|
-
backgroundRotation: [0, 0, 0],
|
|
244
|
-
environmentIntensity: 1,
|
|
245
|
-
environmentRotation: [0, 0, 0],
|
|
246
|
-
...sceneProps
|
|
247
|
-
};
|
|
248
|
-
const target = resolveScene(scene || defaultScene);
|
|
249
|
-
const oldbg = target.background;
|
|
250
|
-
const oldenv = target.environment;
|
|
251
|
-
const oldSceneProps = {
|
|
252
|
-
// @ts-ignore
|
|
253
|
-
backgroundBlurriness: target.backgroundBlurriness,
|
|
254
|
-
// @ts-ignore
|
|
255
|
-
backgroundIntensity: target.backgroundIntensity,
|
|
256
|
-
// @ts-ignore
|
|
257
|
-
backgroundRotation: target.backgroundRotation?.clone?.() ?? [0, 0, 0],
|
|
258
|
-
// @ts-ignore
|
|
259
|
-
environmentIntensity: target.environmentIntensity,
|
|
260
|
-
// @ts-ignore
|
|
261
|
-
environmentRotation: target.environmentRotation?.clone?.() ?? [0, 0, 0]
|
|
262
|
-
};
|
|
263
|
-
if (background !== "only") target.environment = texture;
|
|
264
|
-
if (background) target.background = texture;
|
|
265
|
-
applyProps$1(target, sceneProps);
|
|
266
|
-
return () => {
|
|
267
|
-
if (background !== "only") target.environment = oldenv;
|
|
268
|
-
if (background) target.background = oldbg;
|
|
269
|
-
applyProps$1(target, oldSceneProps);
|
|
270
|
-
};
|
|
219
|
+
const frustumMatrix = new Matrix4();
|
|
220
|
+
function updateFrustum(camera, frustum) {
|
|
221
|
+
const target = frustum ?? new Frustum();
|
|
222
|
+
frustumMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
223
|
+
target.setFromProjectionMatrix(frustumMatrix);
|
|
224
|
+
return target;
|
|
271
225
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
return
|
|
226
|
+
|
|
227
|
+
const REACT_INTERNAL_PROPS = ["children", "key", "ref"];
|
|
228
|
+
function findInitialRoot(instance) {
|
|
229
|
+
let root = instance.root;
|
|
230
|
+
while (root.getState().previousRoot) root = root.getState().previousRoot;
|
|
231
|
+
return root;
|
|
278
232
|
}
|
|
279
|
-
function
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
...rest
|
|
289
|
-
}) {
|
|
290
|
-
const texture = useEnvironment(rest);
|
|
291
|
-
const defaultScene = useThree$1((state) => state.scene);
|
|
292
|
-
React.useLayoutEffect(() => {
|
|
293
|
-
return setEnvProps(background, scene, defaultScene, texture, {
|
|
294
|
-
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
295
|
-
backgroundIntensity,
|
|
296
|
-
backgroundRotation,
|
|
297
|
-
environmentIntensity,
|
|
298
|
-
environmentRotation
|
|
233
|
+
function getRootState(obj) {
|
|
234
|
+
let state = obj.__r3f?.root.getState();
|
|
235
|
+
if (!state) {
|
|
236
|
+
obj.traverseAncestors((ancestor) => {
|
|
237
|
+
const parentState = ancestor.__r3f?.root.getState();
|
|
238
|
+
if (parentState) {
|
|
239
|
+
state = parentState;
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
299
242
|
});
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
return () => {
|
|
303
|
-
texture.dispose();
|
|
304
|
-
};
|
|
305
|
-
}, [texture]);
|
|
306
|
-
return null;
|
|
243
|
+
}
|
|
244
|
+
return state;
|
|
307
245
|
}
|
|
308
|
-
function
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
path,
|
|
325
|
-
preset = void 0,
|
|
326
|
-
extensions
|
|
327
|
-
}) {
|
|
328
|
-
const renderer = useThree$1((state) => state.renderer);
|
|
329
|
-
const isLegacy = useThree$1((state) => state.isLegacy);
|
|
330
|
-
const defaultScene = useThree$1((state) => state.scene);
|
|
331
|
-
const camera = React.useRef(null);
|
|
332
|
-
const [virtualScene] = React.useState(() => new Scene());
|
|
333
|
-
const fbo = React.useMemo(() => {
|
|
334
|
-
const fbo2 = isLegacy ? new WebGLCubeRenderTarget(resolution) : new CubeRenderTarget(resolution);
|
|
335
|
-
fbo2.texture.type = HalfFloatType;
|
|
336
|
-
return fbo2;
|
|
337
|
-
}, [resolution, isLegacy]);
|
|
338
|
-
React.useEffect(() => {
|
|
339
|
-
return () => {
|
|
340
|
-
fbo.dispose();
|
|
341
|
-
};
|
|
342
|
-
}, [fbo]);
|
|
343
|
-
React.useLayoutEffect(() => {
|
|
344
|
-
if (frames === 1) {
|
|
345
|
-
const autoClear = renderer.autoClear;
|
|
346
|
-
renderer.autoClear = true;
|
|
347
|
-
camera.current.update(renderer, virtualScene);
|
|
348
|
-
renderer.autoClear = autoClear;
|
|
349
|
-
}
|
|
350
|
-
return setEnvProps(background, scene, defaultScene, fbo.texture, {
|
|
351
|
-
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
352
|
-
backgroundIntensity,
|
|
353
|
-
backgroundRotation,
|
|
354
|
-
environmentIntensity,
|
|
355
|
-
environmentRotation
|
|
246
|
+
function buildGraph(object) {
|
|
247
|
+
const data = { nodes: {}, materials: {}, meshes: {} };
|
|
248
|
+
if (object) {
|
|
249
|
+
object.traverse((obj) => {
|
|
250
|
+
if (obj.name) data.nodes[obj.name] = obj;
|
|
251
|
+
if (obj.material) {
|
|
252
|
+
const material = Array.isArray(obj.material) ? obj.material[0] : obj.material;
|
|
253
|
+
const nameAlreadyUsed = data.materials[material.name];
|
|
254
|
+
let materialName = material.name;
|
|
255
|
+
if (nameAlreadyUsed) {
|
|
256
|
+
materialName = materialName + `-${getUuidPrefix(material.uuid)}`;
|
|
257
|
+
material.userData.materialCacheName = materialName;
|
|
258
|
+
}
|
|
259
|
+
data.materials[materialName] = material;
|
|
260
|
+
}
|
|
261
|
+
if (obj.isMesh && !data.meshes[obj.name]) data.meshes[obj.name] = obj;
|
|
356
262
|
});
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
virtualScene,
|
|
360
|
-
fbo.texture,
|
|
361
|
-
scene,
|
|
362
|
-
defaultScene,
|
|
363
|
-
background,
|
|
364
|
-
frames,
|
|
365
|
-
renderer,
|
|
366
|
-
blur,
|
|
367
|
-
backgroundBlurriness,
|
|
368
|
-
backgroundIntensity,
|
|
369
|
-
backgroundRotation,
|
|
370
|
-
environmentIntensity,
|
|
371
|
-
environmentRotation
|
|
372
|
-
]);
|
|
373
|
-
let count = 1;
|
|
374
|
-
useFrame$1(() => {
|
|
375
|
-
if (frames === Infinity || count < frames) {
|
|
376
|
-
const autoClear = renderer.autoClear;
|
|
377
|
-
renderer.autoClear = true;
|
|
378
|
-
camera.current.update(renderer, virtualScene);
|
|
379
|
-
renderer.autoClear = autoClear;
|
|
380
|
-
count++;
|
|
381
|
-
}
|
|
382
|
-
});
|
|
383
|
-
return /* @__PURE__ */ jsx(Fragment, { children: createPortal$1(
|
|
384
|
-
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
385
|
-
children,
|
|
386
|
-
/* @__PURE__ */ jsx("cubeCamera", { ref: camera, args: [near, far, fbo] }),
|
|
387
|
-
files || preset ? /* @__PURE__ */ jsx(EnvironmentCube, { background: true, files, preset, path, extensions }) : map ? /* @__PURE__ */ jsx(EnvironmentMap, { background: true, map, extensions }) : null
|
|
388
|
-
] }),
|
|
389
|
-
virtualScene
|
|
390
|
-
) });
|
|
263
|
+
}
|
|
264
|
+
return data;
|
|
391
265
|
}
|
|
392
|
-
function
|
|
393
|
-
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
textureDefault.dispose();
|
|
399
|
-
};
|
|
400
|
-
}, [textureDefault]);
|
|
401
|
-
const height = props.ground?.height ?? 15;
|
|
402
|
-
const radius = props.ground?.radius ?? 60;
|
|
403
|
-
const scale = props.ground?.scale ?? 1e3;
|
|
404
|
-
const args = React.useMemo(
|
|
405
|
-
() => [texture, height, radius],
|
|
406
|
-
[texture, height, radius]
|
|
407
|
-
);
|
|
408
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
409
|
-
/* @__PURE__ */ jsx(EnvironmentMap, { ...props, map: texture }),
|
|
410
|
-
/* @__PURE__ */ jsx("groundProjectedEnvImpl", { args, scale })
|
|
411
|
-
] });
|
|
266
|
+
function dispose(obj) {
|
|
267
|
+
if (obj.type !== "Scene") obj.dispose?.();
|
|
268
|
+
for (const p in obj) {
|
|
269
|
+
const prop = obj[p];
|
|
270
|
+
if (prop?.type !== "Scene") prop?.dispose?.();
|
|
271
|
+
}
|
|
412
272
|
}
|
|
413
|
-
function
|
|
414
|
-
const
|
|
415
|
-
|
|
416
|
-
if (
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
273
|
+
function getInstanceProps(pendingProps) {
|
|
274
|
+
const props = {};
|
|
275
|
+
for (const key in pendingProps) {
|
|
276
|
+
if (!REACT_INTERNAL_PROPS.includes(key)) props[key] = pendingProps[key];
|
|
277
|
+
}
|
|
278
|
+
return props;
|
|
279
|
+
}
|
|
280
|
+
function prepare(target, root, type, props) {
|
|
281
|
+
const object = target;
|
|
282
|
+
let instance = object?.__r3f;
|
|
283
|
+
if (!instance) {
|
|
284
|
+
instance = {
|
|
285
|
+
root,
|
|
286
|
+
type,
|
|
287
|
+
parent: null,
|
|
288
|
+
children: [],
|
|
289
|
+
props: getInstanceProps(props),
|
|
290
|
+
object,
|
|
291
|
+
eventCount: 0,
|
|
292
|
+
handlers: {},
|
|
293
|
+
isHidden: false
|
|
422
294
|
};
|
|
423
|
-
|
|
424
|
-
|
|
295
|
+
if (object) object.__r3f = instance;
|
|
296
|
+
}
|
|
297
|
+
return instance;
|
|
425
298
|
}
|
|
426
|
-
function
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
/* @__PURE__ */ jsx(EnvironmentCube, { ...props, files: backgroundFiles, background: "only" })
|
|
431
|
-
] });
|
|
299
|
+
function invalidateInstance(instance) {
|
|
300
|
+
if (!instance.parent) return;
|
|
301
|
+
const state = instance.root?.getState?.();
|
|
302
|
+
if (state && state.internal.frames === 0) state.invalidate();
|
|
432
303
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
304
|
+
|
|
305
|
+
const tempFrustum = new Frustum();
|
|
306
|
+
let hasWarnedWebGL = false;
|
|
307
|
+
let tslModule = null;
|
|
308
|
+
async function loadTSL() {
|
|
309
|
+
if (tslModule) return tslModule;
|
|
310
|
+
try {
|
|
311
|
+
const tsl = await import('three/tsl');
|
|
312
|
+
tslModule = { uniform: tsl.uniform, nodeObject: tsl.nodeObject };
|
|
313
|
+
return tslModule;
|
|
314
|
+
} catch {
|
|
315
|
+
return null;
|
|
439
316
|
}
|
|
440
|
-
return props.ground ? /* @__PURE__ */ jsx(EnvironmentGround, { ...props }) : props.map ? /* @__PURE__ */ jsx(EnvironmentMap, { ...props }) : props.children ? /* @__PURE__ */ jsx(EnvironmentPortal, { ...props }) : /* @__PURE__ */ jsx(EnvironmentCube, { ...props });
|
|
441
317
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
const
|
|
447
|
-
const
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
},
|
|
462
|
-
[fiber, ContextBridge]
|
|
463
|
-
);
|
|
464
|
-
}
|
|
465
|
-
function Block({ set }) {
|
|
466
|
-
useIsomorphicLayoutEffect(() => {
|
|
467
|
-
set(new Promise(() => null));
|
|
468
|
-
return () => set(false);
|
|
469
|
-
}, [set]);
|
|
470
|
-
return null;
|
|
471
|
-
}
|
|
472
|
-
const ErrorBoundary = /* @__PURE__ */ (() => {
|
|
473
|
-
var _a;
|
|
474
|
-
return _a = class extends React.Component {
|
|
475
|
-
constructor() {
|
|
476
|
-
super(...arguments);
|
|
477
|
-
__publicField(this, "state", { error: false });
|
|
478
|
-
}
|
|
479
|
-
componentDidCatch(err) {
|
|
480
|
-
this.props.set(err);
|
|
481
|
-
}
|
|
482
|
-
render() {
|
|
483
|
-
return this.state.error ? null : this.props.children;
|
|
484
|
-
}
|
|
485
|
-
}, __publicField(_a, "getDerivedStateFromError", () => ({ error: true })), _a;
|
|
486
|
-
})();
|
|
487
|
-
|
|
488
|
-
const is = {
|
|
489
|
-
obj: (a) => a === Object(a) && !is.arr(a) && typeof a !== "function",
|
|
490
|
-
fun: (a) => typeof a === "function",
|
|
491
|
-
str: (a) => typeof a === "string",
|
|
492
|
-
num: (a) => typeof a === "number",
|
|
493
|
-
boo: (a) => typeof a === "boolean",
|
|
494
|
-
und: (a) => a === void 0,
|
|
495
|
-
nul: (a) => a === null,
|
|
496
|
-
arr: (a) => Array.isArray(a),
|
|
497
|
-
equ(a, b, { arrays = "shallow", objects = "reference", strict = true } = {}) {
|
|
498
|
-
if (typeof a !== typeof b || !!a !== !!b) return false;
|
|
499
|
-
if (is.str(a) || is.num(a) || is.boo(a)) return a === b;
|
|
500
|
-
const isObj = is.obj(a);
|
|
501
|
-
if (isObj && objects === "reference") return a === b;
|
|
502
|
-
const isArr = is.arr(a);
|
|
503
|
-
if (isArr && arrays === "reference") return a === b;
|
|
504
|
-
if ((isArr || isObj) && a === b) return true;
|
|
505
|
-
let i;
|
|
506
|
-
for (i in a) if (!(i in b)) return false;
|
|
507
|
-
if (isObj && arrays === "shallow" && objects === "shallow") {
|
|
508
|
-
for (i in strict ? b : a) if (!is.equ(a[i], b[i], { strict, objects: "reference" })) return false;
|
|
509
|
-
} else {
|
|
510
|
-
for (i in strict ? b : a) if (a[i] !== b[i]) return false;
|
|
511
|
-
}
|
|
512
|
-
if (is.und(i)) {
|
|
513
|
-
if (isArr && a.length === 0 && b.length === 0) return true;
|
|
514
|
-
if (isObj && Object.keys(a).length === 0 && Object.keys(b).length === 0) return true;
|
|
515
|
-
if (a !== b) return false;
|
|
516
|
-
}
|
|
517
|
-
return true;
|
|
518
|
-
}
|
|
519
|
-
};
|
|
520
|
-
const isOrthographicCamera = (def) => def && def.isOrthographicCamera;
|
|
521
|
-
const isRef = (obj) => obj !== null && typeof obj === "object" && obj.hasOwnProperty("current");
|
|
522
|
-
const isColorRepresentation = (value) => value != null && (typeof value === "string" || typeof value === "number" || value.isColor);
|
|
523
|
-
const isObject3D = (object) => object?.isObject3D;
|
|
524
|
-
const isTexture = (value) => !!value?.isTexture;
|
|
525
|
-
const isVectorLike = (object) => object !== null && typeof object === "object" && "set" in object && typeof object.set === "function";
|
|
526
|
-
const isCopyable = (object) => isVectorLike(object) && "copy" in object && typeof object.copy === "function";
|
|
527
|
-
const hasConstructor = (object) => !!object?.constructor;
|
|
528
|
-
|
|
529
|
-
function calculateDpr(dpr) {
|
|
530
|
-
const target = typeof window !== "undefined" ? window.devicePixelRatio ?? 2 : 1;
|
|
531
|
-
return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
|
|
532
|
-
}
|
|
533
|
-
function getUuidPrefix(uuid) {
|
|
534
|
-
return uuid.split("-")[0];
|
|
535
|
-
}
|
|
536
|
-
function updateCamera(camera, size) {
|
|
537
|
-
if (camera.manual) return;
|
|
538
|
-
if (isOrthographicCamera(camera)) {
|
|
539
|
-
camera.left = size.width / -2;
|
|
540
|
-
camera.right = size.width / 2;
|
|
541
|
-
camera.top = size.height / 2;
|
|
542
|
-
camera.bottom = size.height / -2;
|
|
543
|
-
} else {
|
|
544
|
-
camera.aspect = size.width / size.height;
|
|
545
|
-
}
|
|
546
|
-
camera.updateProjectionMatrix();
|
|
547
|
-
}
|
|
548
|
-
const frustumMatrix = new Matrix4();
|
|
549
|
-
function updateFrustum(camera, frustum) {
|
|
550
|
-
const target = frustum ?? new Frustum();
|
|
551
|
-
frustumMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
552
|
-
target.setFromProjectionMatrix(frustumMatrix);
|
|
553
|
-
return target;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
const REACT_INTERNAL_PROPS = ["children", "key", "ref"];
|
|
557
|
-
function findInitialRoot(instance) {
|
|
558
|
-
let root = instance.root;
|
|
559
|
-
while (root.getState().previousRoot) root = root.getState().previousRoot;
|
|
560
|
-
return root;
|
|
561
|
-
}
|
|
562
|
-
function getRootState(obj) {
|
|
563
|
-
let state = obj.__r3f?.root.getState();
|
|
564
|
-
if (!state) {
|
|
565
|
-
obj.traverseAncestors((ancestor) => {
|
|
566
|
-
const parentState = ancestor.__r3f?.root.getState();
|
|
567
|
-
if (parentState) {
|
|
568
|
-
state = parentState;
|
|
569
|
-
return false;
|
|
570
|
-
}
|
|
571
|
-
});
|
|
572
|
-
}
|
|
573
|
-
return state;
|
|
574
|
-
}
|
|
575
|
-
function buildGraph(object) {
|
|
576
|
-
const data = { nodes: {}, materials: {}, meshes: {} };
|
|
577
|
-
if (object) {
|
|
578
|
-
object.traverse((obj) => {
|
|
579
|
-
if (obj.name) data.nodes[obj.name] = obj;
|
|
580
|
-
if (obj.material) {
|
|
581
|
-
const material = Array.isArray(obj.material) ? obj.material[0] : obj.material;
|
|
582
|
-
const nameAlreadyUsed = data.materials[material.name];
|
|
583
|
-
let materialName = material.name;
|
|
584
|
-
if (nameAlreadyUsed) {
|
|
585
|
-
materialName = materialName + `-${getUuidPrefix(material.uuid)}`;
|
|
586
|
-
material.userData.materialCacheName = materialName;
|
|
587
|
-
}
|
|
588
|
-
data.materials[materialName] = material;
|
|
589
|
-
}
|
|
590
|
-
if (obj.isMesh && !data.meshes[obj.name]) data.meshes[obj.name] = obj;
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
|
-
return data;
|
|
594
|
-
}
|
|
595
|
-
function dispose(obj) {
|
|
596
|
-
if (obj.type !== "Scene") obj.dispose?.();
|
|
597
|
-
for (const p in obj) {
|
|
598
|
-
const prop = obj[p];
|
|
599
|
-
if (prop?.type !== "Scene") prop?.dispose?.();
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
function getInstanceProps(pendingProps) {
|
|
603
|
-
const props = {};
|
|
604
|
-
for (const key in pendingProps) {
|
|
605
|
-
if (!REACT_INTERNAL_PROPS.includes(key)) props[key] = pendingProps[key];
|
|
606
|
-
}
|
|
607
|
-
return props;
|
|
608
|
-
}
|
|
609
|
-
function prepare(target, root, type, props) {
|
|
610
|
-
const object = target;
|
|
611
|
-
let instance = object?.__r3f;
|
|
612
|
-
if (!instance) {
|
|
613
|
-
instance = {
|
|
614
|
-
root,
|
|
615
|
-
type,
|
|
616
|
-
parent: null,
|
|
617
|
-
children: [],
|
|
618
|
-
props: getInstanceProps(props),
|
|
619
|
-
object,
|
|
620
|
-
eventCount: 0,
|
|
621
|
-
handlers: {},
|
|
622
|
-
isHidden: false
|
|
623
|
-
};
|
|
624
|
-
if (object) object.__r3f = instance;
|
|
625
|
-
}
|
|
626
|
-
return instance;
|
|
627
|
-
}
|
|
628
|
-
function invalidateInstance(instance) {
|
|
629
|
-
if (!instance.parent) return;
|
|
630
|
-
instance.props.onUpdate?.(instance.object);
|
|
631
|
-
const state = instance.root?.getState?.();
|
|
632
|
-
if (state && state.internal.frames === 0) state.invalidate();
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
const tempFrustum = new Frustum();
|
|
636
|
-
let hasWarnedWebGL = false;
|
|
637
|
-
let tslModule = null;
|
|
638
|
-
async function loadTSL() {
|
|
639
|
-
if (tslModule) return tslModule;
|
|
640
|
-
try {
|
|
641
|
-
const tsl = await import('three/tsl');
|
|
642
|
-
tslModule = { uniform: tsl.uniform, nodeObject: tsl.nodeObject };
|
|
643
|
-
return tslModule;
|
|
644
|
-
} catch {
|
|
645
|
-
return null;
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
function createOcclusionObserverNode(store, uniform) {
|
|
649
|
-
const node = new Node("float");
|
|
650
|
-
node.updateType = NodeUpdateType.OBJECT;
|
|
651
|
-
node.update = function(frame) {
|
|
652
|
-
const { internal } = store.getState();
|
|
653
|
-
const registry = internal.visibilityRegistry;
|
|
654
|
-
const cache = internal.occlusionCache;
|
|
655
|
-
for (const entry of registry.values()) {
|
|
656
|
-
const { object, handlers } = entry;
|
|
657
|
-
if (handlers.onOccluded || handlers.onVisible) {
|
|
658
|
-
const isOccluded = frame.renderer.isOccluded(object);
|
|
659
|
-
cache.set(object, isOccluded);
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
};
|
|
663
|
-
node.setup = function() {
|
|
664
|
-
return uniform(0);
|
|
665
|
-
};
|
|
666
|
-
return node;
|
|
318
|
+
function createOcclusionObserverNode(store, uniform) {
|
|
319
|
+
const node = new Node("float");
|
|
320
|
+
node.updateType = NodeUpdateType.OBJECT;
|
|
321
|
+
node.update = function(frame) {
|
|
322
|
+
const { internal } = store.getState();
|
|
323
|
+
const registry = internal.visibilityRegistry;
|
|
324
|
+
const cache = internal.occlusionCache;
|
|
325
|
+
for (const entry of registry.values()) {
|
|
326
|
+
const { object, handlers } = entry;
|
|
327
|
+
if (handlers.onOccluded || handlers.onVisible) {
|
|
328
|
+
const isOccluded = frame.renderer.isOccluded(object);
|
|
329
|
+
cache.set(object, isOccluded);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
node.setup = function() {
|
|
334
|
+
return uniform(0);
|
|
335
|
+
};
|
|
336
|
+
return node;
|
|
667
337
|
}
|
|
668
338
|
let occlusionSetupPromise = null;
|
|
669
339
|
function enableOcclusion(store) {
|
|
@@ -843,8 +513,10 @@ function hasVisibilityHandlers(handlers) {
|
|
|
843
513
|
}
|
|
844
514
|
|
|
845
515
|
const FROM_REF = Symbol.for("@react-three/fiber.fromRef");
|
|
846
|
-
function fromRef(ref) {
|
|
847
|
-
|
|
516
|
+
function fromRef(ref, transform) {
|
|
517
|
+
const marker = { [FROM_REF]: ref };
|
|
518
|
+
if (transform) marker.transform = transform;
|
|
519
|
+
return marker;
|
|
848
520
|
}
|
|
849
521
|
function isFromRef(value) {
|
|
850
522
|
return value !== null && typeof value === "object" && FROM_REF in value;
|
|
@@ -858,51 +530,107 @@ function isOnce(value) {
|
|
|
858
530
|
return value !== null && typeof value === "object" && ONCE in value;
|
|
859
531
|
}
|
|
860
532
|
|
|
861
|
-
const
|
|
862
|
-
|
|
863
|
-
"
|
|
864
|
-
|
|
865
|
-
// Instance props
|
|
866
|
-
"args",
|
|
867
|
-
"dispose",
|
|
868
|
-
"attach",
|
|
869
|
-
"object",
|
|
870
|
-
"onUpdate",
|
|
871
|
-
// Behavior flags
|
|
872
|
-
"dispose"
|
|
873
|
-
];
|
|
874
|
-
const EVENT_REGEX = /^on(Pointer|Drag|Drop|Click|DoubleClick|ContextMenu|Wheel)/;
|
|
875
|
-
const VISIBILITY_EVENT_REGEX = /^on(Framed|Occluded|Visible)$/;
|
|
876
|
-
const INDEX_REGEX = /-\d+$/;
|
|
877
|
-
const MEMOIZED_PROTOTYPES = /* @__PURE__ */ new Map();
|
|
878
|
-
const colorMaps = ["map", "emissiveMap", "sheenColorMap", "specularColorMap", "envMap"];
|
|
879
|
-
function resolve(root, key) {
|
|
880
|
-
if (!key.includes("-")) return { root, key, target: root[key] };
|
|
881
|
-
if (key in root) return { root, key, target: root[key] };
|
|
882
|
-
const originalKey = key;
|
|
883
|
-
let target = root;
|
|
884
|
-
const parts = key.split("-");
|
|
885
|
-
for (const part of parts) {
|
|
886
|
-
if (typeof target !== "object" || target === null) {
|
|
887
|
-
if (target !== void 0) {
|
|
888
|
-
const remaining = parts.slice(parts.indexOf(part)).join("-");
|
|
889
|
-
return { root: target, key: remaining, target: void 0 };
|
|
890
|
-
}
|
|
891
|
-
return { root, key: originalKey, target: void 0 };
|
|
892
|
-
}
|
|
893
|
-
key = part;
|
|
894
|
-
root = target;
|
|
895
|
-
target = target[key];
|
|
533
|
+
const shownNotices = /* @__PURE__ */ new Set();
|
|
534
|
+
function notifyDepreciated({ heading, body, link }) {
|
|
535
|
+
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_DEPRECATION_WARNINGS !== "true") {
|
|
536
|
+
return;
|
|
896
537
|
}
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
if (
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
}
|
|
538
|
+
if (shownNotices.has(heading)) return;
|
|
539
|
+
shownNotices.add(heading);
|
|
540
|
+
const caller = getCallerFrame();
|
|
541
|
+
if (caller) {
|
|
542
|
+
console.log();
|
|
543
|
+
}
|
|
544
|
+
const boxStyle = "background: #ff9800; color: #1a1a1a; padding: 8px 12px; border-radius: 4px; font-weight: 500;";
|
|
545
|
+
if (caller) {
|
|
546
|
+
console.log(`%c\u26A0\uFE0F ${heading}`, boxStyle);
|
|
547
|
+
}
|
|
548
|
+
if (body || link) {
|
|
549
|
+
let message = "";
|
|
550
|
+
if (body) message += body;
|
|
551
|
+
if (link) message += (body ? "\n\n" : "") + `More info: ${link}`;
|
|
552
|
+
console.warn(`%c${message}`, "font-weight: bold;");
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
function getCallerFrame(depth = 3) {
|
|
556
|
+
const stack = new Error().stack;
|
|
557
|
+
if (!stack) return null;
|
|
558
|
+
const lines = stack.split("\n");
|
|
559
|
+
const frame = lines[depth];
|
|
560
|
+
if (!frame) return null;
|
|
561
|
+
let match = frame.match(/^\s*at (?:(.+?) )?\(?(.+?):(\d+):(\d+)\)?$/);
|
|
562
|
+
if (!match) {
|
|
563
|
+
match = frame.match(/^(?:(.+?)@)?(.+?):(\d+):(\d+)$/);
|
|
564
|
+
}
|
|
565
|
+
if (!match) return null;
|
|
566
|
+
const [, fn, url, line] = match;
|
|
567
|
+
return {
|
|
568
|
+
functionName: fn ?? "<anonymous>",
|
|
569
|
+
location: formatLocation(url, Number(line))
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
function formatLocation(url, line) {
|
|
573
|
+
const clean = url.split("?")[0];
|
|
574
|
+
const file = clean.split("/").pop() ?? clean;
|
|
575
|
+
return `${file}:${line}`;
|
|
576
|
+
}
|
|
577
|
+
function notifyAlpha({ message, link }) {
|
|
578
|
+
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_ALPHA_WARNINGS !== "true") {
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
if (shownNotices.has(message)) return;
|
|
582
|
+
shownNotices.add(message);
|
|
583
|
+
const boxStyle = "background: #6366f1; color: #ffffff; padding: 6px 10px; border-radius: 4px; font-weight: 500;";
|
|
584
|
+
console.log(`%c\u{1F52C} ${message}`, boxStyle);
|
|
585
|
+
{
|
|
586
|
+
console.log(`%cMore info: ${link}`, "color: #6366f1; font-weight: normal;");
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
const RESERVED_PROPS = [
|
|
591
|
+
"children",
|
|
592
|
+
"key",
|
|
593
|
+
"ref",
|
|
594
|
+
// Instance props
|
|
595
|
+
"args",
|
|
596
|
+
"dispose",
|
|
597
|
+
"attach",
|
|
598
|
+
"object",
|
|
599
|
+
// Behavior flags
|
|
600
|
+
"dispose"
|
|
601
|
+
];
|
|
602
|
+
const EVENT_REGEX = /^on(Pointer|Drag|Drop|Click|DoubleClick|ContextMenu|Wheel)/;
|
|
603
|
+
const VISIBILITY_EVENT_REGEX = /^on(Framed|Occluded|Visible)$/;
|
|
604
|
+
const INDEX_REGEX = /-\d+$/;
|
|
605
|
+
const MEMOIZED_PROTOTYPES = /* @__PURE__ */ new Map();
|
|
606
|
+
const colorMaps = ["map", "emissiveMap", "sheenColorMap", "specularColorMap", "envMap"];
|
|
607
|
+
function resolve(root, key) {
|
|
608
|
+
if (!key.includes("-")) return { root, key, target: root[key] };
|
|
609
|
+
if (key in root) return { root, key, target: root[key] };
|
|
610
|
+
const originalKey = key;
|
|
611
|
+
let target = root;
|
|
612
|
+
const parts = key.split("-");
|
|
613
|
+
for (const part of parts) {
|
|
614
|
+
if (typeof target !== "object" || target === null) {
|
|
615
|
+
if (target !== void 0) {
|
|
616
|
+
const remaining = parts.slice(parts.indexOf(part)).join("-");
|
|
617
|
+
return { root: target, key: remaining, target: void 0 };
|
|
618
|
+
}
|
|
619
|
+
return { root, key: originalKey, target: void 0 };
|
|
620
|
+
}
|
|
621
|
+
key = part;
|
|
622
|
+
root = target;
|
|
623
|
+
target = target[key];
|
|
624
|
+
}
|
|
625
|
+
return { root, key, target };
|
|
626
|
+
}
|
|
627
|
+
function attach(parent, child) {
|
|
628
|
+
if (is.str(child.props.attach)) {
|
|
629
|
+
if (INDEX_REGEX.test(child.props.attach)) {
|
|
630
|
+
const index = child.props.attach.replace(INDEX_REGEX, "");
|
|
631
|
+
const { root: root2, key: key2 } = resolve(parent.object, index);
|
|
632
|
+
if (!Array.isArray(root2[key2])) root2[key2] = [];
|
|
633
|
+
}
|
|
906
634
|
const { root, key } = resolve(parent.object, child.props.attach);
|
|
907
635
|
child.previousAttach = root[key];
|
|
908
636
|
root[key] = child.object;
|
|
@@ -945,11 +673,9 @@ function diffProps(instance, newProps) {
|
|
|
945
673
|
for (const prop in instance.props) {
|
|
946
674
|
if (RESERVED_PROPS.includes(prop) || newProps.hasOwnProperty(prop)) continue;
|
|
947
675
|
const { root, key } = resolve(instance.object, prop);
|
|
948
|
-
if (
|
|
676
|
+
if (typeof root?.constructor === "function") {
|
|
949
677
|
const ctor = getMemoizedPrototype(root);
|
|
950
|
-
if (!is.und(ctor)) changedProps[
|
|
951
|
-
} else {
|
|
952
|
-
changedProps[key] = 0;
|
|
678
|
+
if (!is.und(ctor)) changedProps[prop] = ctor[key];
|
|
953
679
|
}
|
|
954
680
|
}
|
|
955
681
|
return changedProps;
|
|
@@ -961,6 +687,13 @@ function applyProps(object, props) {
|
|
|
961
687
|
for (const prop in props) {
|
|
962
688
|
const value = props[prop];
|
|
963
689
|
if (RESERVED_PROPS.includes(prop)) continue;
|
|
690
|
+
if (prop === "onUpdate") {
|
|
691
|
+
notifyDepreciated({
|
|
692
|
+
heading: "onUpdate is no longer an R3F prop",
|
|
693
|
+
body: "v10 removed the onUpdate hook: R3F no longer calls it after prop updates. The value is assigned to the object by name. On a Texture that sets three's Texture.onUpdate, which the renderer calls after a GPU upload, not after prop changes. On a node it replaces the Node.onUpdate() method. On other objects it is never called.\n\nUse an effect keyed on the props that change, read the object in useFrame, or use a ref callback.",
|
|
694
|
+
link: "https://docs.pmnd.rs/react-three-fiber/migration/v10#onupdate-removed"
|
|
695
|
+
});
|
|
696
|
+
}
|
|
964
697
|
if (instance && EVENT_REGEX.test(prop)) {
|
|
965
698
|
if (typeof value === "function") instance.handlers[prop] = value;
|
|
966
699
|
else delete instance.handlers[prop];
|
|
@@ -1066,635 +799,33 @@ function applyProps(object, props) {
|
|
|
1066
799
|
return object;
|
|
1067
800
|
}
|
|
1068
801
|
|
|
1069
|
-
const
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
state = {
|
|
1075
|
-
hovered: /* @__PURE__ */ new Map(),
|
|
1076
|
-
captured: /* @__PURE__ */ new Map(),
|
|
1077
|
-
initialClick: [0, 0],
|
|
1078
|
-
initialHits: []
|
|
1079
|
-
};
|
|
1080
|
-
internal.pointerMap.set(pointerId, state);
|
|
1081
|
-
}
|
|
1082
|
-
return state;
|
|
1083
|
-
}
|
|
1084
|
-
function getPointerId(event) {
|
|
1085
|
-
return "pointerId" in event ? event.pointerId : DEFAULT_POINTER_ID;
|
|
1086
|
-
}
|
|
1087
|
-
function makeId(event) {
|
|
1088
|
-
return (event.eventObject || event.object).uuid + "/" + event.index + event.instanceId;
|
|
1089
|
-
}
|
|
1090
|
-
function releaseInternalPointerCapture(internal, obj, pointerId) {
|
|
1091
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1092
|
-
if (!pointerState) return;
|
|
1093
|
-
const captureData = pointerState.captured.get(obj);
|
|
1094
|
-
if (captureData) {
|
|
1095
|
-
pointerState.captured.delete(obj);
|
|
1096
|
-
captureData.target.releasePointerCapture(pointerId);
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
function removeInteractivity(store, object) {
|
|
1100
|
-
const { internal } = store.getState();
|
|
1101
|
-
internal.interaction = internal.interaction.filter((o) => o !== object);
|
|
1102
|
-
for (const [pointerId, pointerState] of internal.pointerMap) {
|
|
1103
|
-
pointerState.initialHits = pointerState.initialHits.filter((o) => o !== object);
|
|
1104
|
-
pointerState.hovered.forEach((value, key) => {
|
|
1105
|
-
if (value.eventObject === object || value.object === object) {
|
|
1106
|
-
pointerState.hovered.delete(key);
|
|
1107
|
-
}
|
|
1108
|
-
});
|
|
1109
|
-
if (pointerState.captured.has(object)) {
|
|
1110
|
-
releaseInternalPointerCapture(internal, object, pointerId);
|
|
1111
|
-
}
|
|
1112
|
-
}
|
|
1113
|
-
unregisterVisibility(store, object);
|
|
802
|
+
const INTERNAL_LIB_MARKERS = ["zustand", "setState", "Object.assign"];
|
|
803
|
+
function isInternalRendererAccess(stack, callerDepth = 2) {
|
|
804
|
+
if (!stack) return false;
|
|
805
|
+
const caller = stack.split("\n")[callerDepth] ?? "";
|
|
806
|
+
return INTERNAL_LIB_MARKERS.some((m) => caller.includes(m));
|
|
1114
807
|
}
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
const
|
|
1121
|
-
const
|
|
1122
|
-
const
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
)
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
const duplicates = /* @__PURE__ */ new Set();
|
|
1137
|
-
const intersections = [];
|
|
1138
|
-
const eventsObjects = filter ? filter(state.internal.interaction) : state.internal.interaction;
|
|
1139
|
-
for (let i = 0; i < eventsObjects.length; i++) {
|
|
1140
|
-
const state2 = getRootState(eventsObjects[i]);
|
|
1141
|
-
if (state2) {
|
|
1142
|
-
state2.raycaster.camera = void 0;
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
if (!state.previousRoot) {
|
|
1146
|
-
state.events.compute?.(event, state);
|
|
1147
|
-
}
|
|
1148
|
-
function handleRaycast(obj) {
|
|
1149
|
-
const state2 = getRootState(obj);
|
|
1150
|
-
if (!state2 || !state2.events.enabled || state2.raycaster.camera === null) return [];
|
|
1151
|
-
if (state2.raycaster.camera === void 0) {
|
|
1152
|
-
state2.events.compute?.(event, state2, state2.previousRoot?.getState());
|
|
1153
|
-
if (state2.raycaster.camera === void 0) state2.raycaster.camera = null;
|
|
1154
|
-
}
|
|
1155
|
-
return state2.raycaster.camera ? state2.raycaster.intersectObject(obj, true) : [];
|
|
1156
|
-
}
|
|
1157
|
-
let hits = eventsObjects.flatMap(handleRaycast).sort((a, b) => {
|
|
1158
|
-
const aInteractivePriority = a.object.userData?.interactivePriority;
|
|
1159
|
-
const bInteractivePriority = b.object.userData?.interactivePriority;
|
|
1160
|
-
if (aInteractivePriority !== void 0 || bInteractivePriority !== void 0) {
|
|
1161
|
-
if (aInteractivePriority !== void 0 && bInteractivePriority === void 0) return -1;
|
|
1162
|
-
if (bInteractivePriority !== void 0 && aInteractivePriority === void 0) return 1;
|
|
1163
|
-
if (aInteractivePriority !== bInteractivePriority) {
|
|
1164
|
-
return (bInteractivePriority ?? 0) - (aInteractivePriority ?? 0);
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
const aState = getRootState(a.object);
|
|
1168
|
-
const bState = getRootState(b.object);
|
|
1169
|
-
const aPriority = aState?.events?.priority ?? 1;
|
|
1170
|
-
const bPriority = bState?.events?.priority ?? 1;
|
|
1171
|
-
return bPriority - aPriority || a.distance - b.distance;
|
|
1172
|
-
}).filter((item) => {
|
|
1173
|
-
const id = makeId(item);
|
|
1174
|
-
if (duplicates.has(id)) return false;
|
|
1175
|
-
duplicates.add(id);
|
|
1176
|
-
return true;
|
|
1177
|
-
});
|
|
1178
|
-
if (state.events.filter) hits = state.events.filter(hits, state);
|
|
1179
|
-
for (const hit of hits) {
|
|
1180
|
-
let eventObject = hit.object;
|
|
1181
|
-
while (eventObject) {
|
|
1182
|
-
if (eventObject.__r3f?.eventCount) {
|
|
1183
|
-
intersections.push({ ...hit, eventObject });
|
|
1184
|
-
}
|
|
1185
|
-
eventObject = eventObject.parent;
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
if ("pointerId" in event) {
|
|
1189
|
-
const pointerId = event.pointerId;
|
|
1190
|
-
const pointerState = state.internal.pointerMap.get(pointerId);
|
|
1191
|
-
if (pointerState?.captured.size) {
|
|
1192
|
-
for (const captureData of pointerState.captured.values()) {
|
|
1193
|
-
if (!duplicates.has(makeId(captureData.intersection))) intersections.push(captureData.intersection);
|
|
1194
|
-
}
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
return intersections;
|
|
1198
|
-
}
|
|
1199
|
-
function handleIntersects(intersections, event, delta, callback) {
|
|
1200
|
-
if (intersections.length) {
|
|
1201
|
-
const localState = { stopped: false };
|
|
1202
|
-
for (const hit of intersections) {
|
|
1203
|
-
const state = getRootState(hit.object);
|
|
1204
|
-
if (state) {
|
|
1205
|
-
const { raycaster, pointer, camera, internal } = state;
|
|
1206
|
-
const unprojectedPoint = new Vector3(pointer.x, pointer.y, 0).unproject(camera);
|
|
1207
|
-
const hasPointerCapture = (id) => {
|
|
1208
|
-
const pointerState = internal.pointerMap.get(id);
|
|
1209
|
-
return pointerState?.captured.has(hit.eventObject) ?? false;
|
|
1210
|
-
};
|
|
1211
|
-
const setPointerCapture = (id) => {
|
|
1212
|
-
const captureData = { intersection: hit, target: event.target };
|
|
1213
|
-
const pointerState = getPointerState(internal, id);
|
|
1214
|
-
pointerState.captured.set(hit.eventObject, captureData);
|
|
1215
|
-
event.target.setPointerCapture(id);
|
|
1216
|
-
};
|
|
1217
|
-
const releasePointerCapture = (id) => {
|
|
1218
|
-
releaseInternalPointerCapture(internal, hit.eventObject, id);
|
|
1219
|
-
};
|
|
1220
|
-
const extractEventProps = {};
|
|
1221
|
-
for (const prop in event) {
|
|
1222
|
-
const property = event[prop];
|
|
1223
|
-
if (typeof property !== "function") extractEventProps[prop] = property;
|
|
1224
|
-
}
|
|
1225
|
-
const eventPointerId = "pointerId" in event ? event.pointerId : void 0;
|
|
1226
|
-
const raycastEvent = {
|
|
1227
|
-
...hit,
|
|
1228
|
-
...extractEventProps,
|
|
1229
|
-
pointer,
|
|
1230
|
-
intersections,
|
|
1231
|
-
stopped: localState.stopped,
|
|
1232
|
-
delta,
|
|
1233
|
-
unprojectedPoint,
|
|
1234
|
-
ray: raycaster.ray,
|
|
1235
|
-
camera,
|
|
1236
|
-
pointerId: eventPointerId,
|
|
1237
|
-
// Hijack stopPropagation, which just sets a flag
|
|
1238
|
-
stopPropagation() {
|
|
1239
|
-
const pointerState = eventPointerId !== void 0 ? internal.pointerMap.get(eventPointerId) : void 0;
|
|
1240
|
-
if (
|
|
1241
|
-
// ...if this pointer hasn't been captured
|
|
1242
|
-
!pointerState?.captured.size || // ... or if the hit object is capturing the pointer
|
|
1243
|
-
pointerState.captured.has(hit.eventObject)
|
|
1244
|
-
) {
|
|
1245
|
-
raycastEvent.stopped = localState.stopped = true;
|
|
1246
|
-
if (pointerState?.hovered.size && Array.from(pointerState.hovered.values()).find((i) => i.eventObject === hit.eventObject)) {
|
|
1247
|
-
const higher = intersections.slice(0, intersections.indexOf(hit));
|
|
1248
|
-
cancelPointer([...higher, hit], eventPointerId);
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
},
|
|
1252
|
-
// there should be a distinction between target and currentTarget
|
|
1253
|
-
target: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
1254
|
-
currentTarget: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
1255
|
-
nativeEvent: event
|
|
1256
|
-
};
|
|
1257
|
-
callback(raycastEvent);
|
|
1258
|
-
if (localState.stopped === true) break;
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
return intersections;
|
|
1263
|
-
}
|
|
1264
|
-
function cancelPointer(intersections, pointerId) {
|
|
1265
|
-
const { internal } = store.getState();
|
|
1266
|
-
const pid = pointerId ?? DEFAULT_POINTER_ID;
|
|
1267
|
-
const pointerState = internal.pointerMap.get(pid);
|
|
1268
|
-
if (!pointerState) return;
|
|
1269
|
-
for (const [hoveredId, hoveredObj] of pointerState.hovered) {
|
|
1270
|
-
if (!intersections.length || !intersections.find(
|
|
1271
|
-
(hit) => hit.object === hoveredObj.object && hit.index === hoveredObj.index && hit.instanceId === hoveredObj.instanceId
|
|
1272
|
-
)) {
|
|
1273
|
-
const eventObject = hoveredObj.eventObject;
|
|
1274
|
-
const instance = eventObject.__r3f;
|
|
1275
|
-
pointerState.hovered.delete(hoveredId);
|
|
1276
|
-
if (instance?.eventCount) {
|
|
1277
|
-
const handlers = instance.handlers;
|
|
1278
|
-
const data = { ...hoveredObj, intersections };
|
|
1279
|
-
handlers.onPointerOut?.(data);
|
|
1280
|
-
handlers.onPointerLeave?.(data);
|
|
1281
|
-
handlers.onDragOverLeave?.(data);
|
|
1282
|
-
}
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
function pointerMissed(event, objects) {
|
|
1287
|
-
for (let i = 0; i < objects.length; i++) {
|
|
1288
|
-
const instance = objects[i].__r3f;
|
|
1289
|
-
instance?.handlers.onPointerMissed?.(event);
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
function dragOverMissed(event, objects) {
|
|
1293
|
-
for (let i = 0; i < objects.length; i++) {
|
|
1294
|
-
const instance = objects[i].__r3f;
|
|
1295
|
-
instance?.handlers.onDragOverMissed?.(event);
|
|
1296
|
-
}
|
|
1297
|
-
}
|
|
1298
|
-
function dropMissed(event, objects) {
|
|
1299
|
-
for (let i = 0; i < objects.length; i++) {
|
|
1300
|
-
const instance = objects[i].__r3f;
|
|
1301
|
-
instance?.handlers.onDropMissed?.(event);
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1304
|
-
function cleanupPointer(pointerId) {
|
|
1305
|
-
const { internal } = store.getState();
|
|
1306
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1307
|
-
if (pointerState) {
|
|
1308
|
-
for (const [, hoveredObj] of pointerState.hovered) {
|
|
1309
|
-
const eventObject = hoveredObj.eventObject;
|
|
1310
|
-
const instance = eventObject.__r3f;
|
|
1311
|
-
if (instance?.eventCount) {
|
|
1312
|
-
const handlers = instance.handlers;
|
|
1313
|
-
const data = { ...hoveredObj, intersections: [] };
|
|
1314
|
-
handlers.onPointerOut?.(data);
|
|
1315
|
-
handlers.onPointerLeave?.(data);
|
|
1316
|
-
}
|
|
1317
|
-
}
|
|
1318
|
-
internal.pointerMap.delete(pointerId);
|
|
1319
|
-
}
|
|
1320
|
-
internal.pointerDirty.delete(pointerId);
|
|
1321
|
-
}
|
|
1322
|
-
function processDeferredPointer(event, pointerId) {
|
|
1323
|
-
const state = store.getState();
|
|
1324
|
-
const { internal } = state;
|
|
1325
|
-
if (!state.events.enabled) return;
|
|
1326
|
-
const filter = filterPointerEvents;
|
|
1327
|
-
const hits = intersect(event, filter);
|
|
1328
|
-
cancelPointer(hits, pointerId);
|
|
1329
|
-
function onIntersect(data) {
|
|
1330
|
-
const eventObject = data.eventObject;
|
|
1331
|
-
const instance = eventObject.__r3f;
|
|
1332
|
-
if (!instance?.eventCount) return;
|
|
1333
|
-
const handlers = instance.handlers;
|
|
1334
|
-
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
1335
|
-
const id = makeId(data);
|
|
1336
|
-
const pointerState = getPointerState(internal, pointerId);
|
|
1337
|
-
const hoveredItem = pointerState.hovered.get(id);
|
|
1338
|
-
if (!hoveredItem) {
|
|
1339
|
-
pointerState.hovered.set(id, data);
|
|
1340
|
-
handlers.onPointerOver?.(data);
|
|
1341
|
-
handlers.onPointerEnter?.(data);
|
|
1342
|
-
} else if (hoveredItem.stopped) {
|
|
1343
|
-
data.stopPropagation();
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
handlers.onPointerMove?.(data);
|
|
1347
|
-
}
|
|
1348
|
-
handleIntersects(hits, event, 0, onIntersect);
|
|
1349
|
-
}
|
|
1350
|
-
function handlePointer(name) {
|
|
1351
|
-
switch (name) {
|
|
1352
|
-
case "onPointerLeave":
|
|
1353
|
-
case "onDragLeave":
|
|
1354
|
-
return () => cancelPointer([]);
|
|
1355
|
-
// Global cancel of these events
|
|
1356
|
-
case "onPointerCancel":
|
|
1357
|
-
return (event) => {
|
|
1358
|
-
const pointerId = getPointerId(event);
|
|
1359
|
-
cleanupPointer(pointerId);
|
|
1360
|
-
};
|
|
1361
|
-
case "onLostPointerCapture":
|
|
1362
|
-
return (event) => {
|
|
1363
|
-
const { internal } = store.getState();
|
|
1364
|
-
const pointerId = getPointerId(event);
|
|
1365
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1366
|
-
if (pointerState?.captured.size) {
|
|
1367
|
-
requestAnimationFrame(() => {
|
|
1368
|
-
const pointerState2 = internal.pointerMap.get(pointerId);
|
|
1369
|
-
if (pointerState2?.captured.size) {
|
|
1370
|
-
pointerState2.captured.clear();
|
|
1371
|
-
}
|
|
1372
|
-
cancelPointer([], pointerId);
|
|
1373
|
-
});
|
|
1374
|
-
}
|
|
1375
|
-
};
|
|
1376
|
-
}
|
|
1377
|
-
return function handleEvent(event) {
|
|
1378
|
-
const state = store.getState();
|
|
1379
|
-
const { onPointerMissed, onDragOverMissed, onDropMissed, internal, events } = state;
|
|
1380
|
-
const pointerId = getPointerId(event);
|
|
1381
|
-
internal.lastEvent.current = event;
|
|
1382
|
-
if (!events.enabled) return;
|
|
1383
|
-
const isPointerMove = name === "onPointerMove";
|
|
1384
|
-
const isDragOver = name === "onDragOver";
|
|
1385
|
-
const isDrop = name === "onDrop";
|
|
1386
|
-
const isClickEvent = name === "onClick" || name === "onContextMenu" || name === "onDoubleClick";
|
|
1387
|
-
const isPointerDown = name === "onPointerDown";
|
|
1388
|
-
const isPointerUp = name === "onPointerUp";
|
|
1389
|
-
const isWheel = name === "onWheel";
|
|
1390
|
-
const canDeferRaycasts = events.frameTimedRaycasts && state.frameloop === "always";
|
|
1391
|
-
if (isPointerMove && canDeferRaycasts) {
|
|
1392
|
-
events.compute?.(event, state);
|
|
1393
|
-
internal.pointerDirty.set(pointerId, event);
|
|
1394
|
-
return;
|
|
1395
|
-
}
|
|
1396
|
-
if (isWheel && canDeferRaycasts && !events.alwaysFireOnScroll) {
|
|
1397
|
-
events.compute?.(event, state);
|
|
1398
|
-
internal.pointerDirty.set(pointerId, event);
|
|
1399
|
-
return;
|
|
1400
|
-
}
|
|
1401
|
-
if ((isClickEvent || isPointerDown || isPointerUp) && internal.pointerDirty.has(pointerId)) {
|
|
1402
|
-
const deferredEvent = internal.pointerDirty.get(pointerId);
|
|
1403
|
-
internal.pointerDirty.delete(pointerId);
|
|
1404
|
-
processDeferredPointer(deferredEvent, pointerId);
|
|
1405
|
-
}
|
|
1406
|
-
const filter = isPointerMove || isDragOver || isDrop ? filterPointerEvents : void 0;
|
|
1407
|
-
const hits = intersect(event, filter);
|
|
1408
|
-
const delta = isClickEvent ? calculateDistance(event, pointerId) : 0;
|
|
1409
|
-
if (isPointerDown) {
|
|
1410
|
-
const pointerState2 = getPointerState(internal, pointerId);
|
|
1411
|
-
pointerState2.initialClick = [event.offsetX, event.offsetY];
|
|
1412
|
-
pointerState2.initialHits = hits.map((hit) => hit.eventObject);
|
|
1413
|
-
}
|
|
1414
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1415
|
-
const initialHits = pointerState?.initialHits ?? [];
|
|
1416
|
-
if (isClickEvent && !hits.length) {
|
|
1417
|
-
if (delta <= 2) {
|
|
1418
|
-
pointerMissed(event, internal.interaction);
|
|
1419
|
-
if (onPointerMissed) onPointerMissed(event);
|
|
1420
|
-
}
|
|
1421
|
-
}
|
|
1422
|
-
if (isDragOver && !hits.length) {
|
|
1423
|
-
dragOverMissed(event, internal.interaction);
|
|
1424
|
-
if (onDragOverMissed) onDragOverMissed(event);
|
|
1425
|
-
}
|
|
1426
|
-
if (isDrop && !hits.length) {
|
|
1427
|
-
dropMissed(event, internal.interaction);
|
|
1428
|
-
if (onDropMissed) onDropMissed(event);
|
|
1429
|
-
}
|
|
1430
|
-
if (isPointerMove || isDragOver) {
|
|
1431
|
-
cancelPointer(hits, pointerId);
|
|
1432
|
-
}
|
|
1433
|
-
function onIntersect(data) {
|
|
1434
|
-
const eventObject = data.eventObject;
|
|
1435
|
-
const instance = eventObject.__r3f;
|
|
1436
|
-
if (!instance?.eventCount) return;
|
|
1437
|
-
const handlers = instance.handlers;
|
|
1438
|
-
if (isPointerMove) {
|
|
1439
|
-
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
1440
|
-
const id = makeId(data);
|
|
1441
|
-
const pointerState2 = getPointerState(internal, pointerId);
|
|
1442
|
-
const hoveredItem = pointerState2.hovered.get(id);
|
|
1443
|
-
if (!hoveredItem) {
|
|
1444
|
-
pointerState2.hovered.set(id, data);
|
|
1445
|
-
handlers.onPointerOver?.(data);
|
|
1446
|
-
handlers.onPointerEnter?.(data);
|
|
1447
|
-
} else if (hoveredItem.stopped) {
|
|
1448
|
-
data.stopPropagation();
|
|
1449
|
-
}
|
|
1450
|
-
}
|
|
1451
|
-
handlers.onPointerMove?.(data);
|
|
1452
|
-
} else if (isDragOver) {
|
|
1453
|
-
const id = makeId(data);
|
|
1454
|
-
const pointerState2 = getPointerState(internal, pointerId);
|
|
1455
|
-
const hoveredItem = pointerState2.hovered.get(id);
|
|
1456
|
-
if (!hoveredItem) {
|
|
1457
|
-
pointerState2.hovered.set(id, data);
|
|
1458
|
-
handlers.onDragOverEnter?.(data);
|
|
1459
|
-
} else if (hoveredItem.stopped) {
|
|
1460
|
-
data.stopPropagation();
|
|
1461
|
-
}
|
|
1462
|
-
handlers.onDragOver?.(data);
|
|
1463
|
-
} else if (isDrop) {
|
|
1464
|
-
handlers.onDrop?.(data);
|
|
1465
|
-
} else {
|
|
1466
|
-
const handler = handlers[name];
|
|
1467
|
-
if (handler) {
|
|
1468
|
-
if (!isClickEvent || initialHits.includes(eventObject)) {
|
|
1469
|
-
pointerMissed(
|
|
1470
|
-
event,
|
|
1471
|
-
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
1472
|
-
);
|
|
1473
|
-
handler(data);
|
|
1474
|
-
}
|
|
1475
|
-
} else {
|
|
1476
|
-
if (isClickEvent && initialHits.includes(eventObject)) {
|
|
1477
|
-
pointerMissed(
|
|
1478
|
-
event,
|
|
1479
|
-
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
1480
|
-
);
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1483
|
-
}
|
|
1484
|
-
}
|
|
1485
|
-
handleIntersects(hits, event, delta, onIntersect);
|
|
1486
|
-
};
|
|
1487
|
-
}
|
|
1488
|
-
function flushDeferredPointers() {
|
|
1489
|
-
const { internal, events } = store.getState();
|
|
1490
|
-
if (!events.frameTimedRaycasts) return;
|
|
1491
|
-
for (const [pointerId, event] of internal.pointerDirty) {
|
|
1492
|
-
processDeferredPointer(event, pointerId);
|
|
1493
|
-
}
|
|
1494
|
-
internal.pointerDirty.clear();
|
|
1495
|
-
}
|
|
1496
|
-
return { handlePointer, flushDeferredPointers, processDeferredPointer };
|
|
1497
|
-
}
|
|
1498
|
-
const DOM_EVENTS = {
|
|
1499
|
-
onClick: ["click", false],
|
|
1500
|
-
onContextMenu: ["contextmenu", false],
|
|
1501
|
-
onDoubleClick: ["dblclick", false],
|
|
1502
|
-
onDragEnter: ["dragenter", false],
|
|
1503
|
-
onDragLeave: ["dragleave", false],
|
|
1504
|
-
onDragOver: ["dragover", false],
|
|
1505
|
-
onDrop: ["drop", false],
|
|
1506
|
-
onWheel: ["wheel", true],
|
|
1507
|
-
onPointerDown: ["pointerdown", true],
|
|
1508
|
-
onPointerUp: ["pointerup", true],
|
|
1509
|
-
onPointerLeave: ["pointerleave", true],
|
|
1510
|
-
onPointerMove: ["pointermove", true],
|
|
1511
|
-
onPointerCancel: ["pointercancel", true],
|
|
1512
|
-
onLostPointerCapture: ["lostpointercapture", true]
|
|
1513
|
-
};
|
|
1514
|
-
function createPointerEvents(store) {
|
|
1515
|
-
const { handlePointer, flushDeferredPointers, processDeferredPointer } = createEvents(store);
|
|
1516
|
-
let nextXRPointerId = XR_POINTER_ID_START;
|
|
1517
|
-
const xrPointers = /* @__PURE__ */ new Map();
|
|
1518
|
-
return {
|
|
1519
|
-
priority: 1,
|
|
1520
|
-
enabled: true,
|
|
1521
|
-
frameTimedRaycasts: true,
|
|
1522
|
-
alwaysFireOnScroll: true,
|
|
1523
|
-
updateOnFrame: false,
|
|
1524
|
-
compute(event, state) {
|
|
1525
|
-
state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
|
|
1526
|
-
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
1527
|
-
},
|
|
1528
|
-
connected: void 0,
|
|
1529
|
-
handlers: Object.keys(DOM_EVENTS).reduce(
|
|
1530
|
-
(acc, key) => ({ ...acc, [key]: handlePointer(key) }),
|
|
1531
|
-
{}
|
|
1532
|
-
),
|
|
1533
|
-
update: (pointerId) => {
|
|
1534
|
-
const { events, internal } = store.getState();
|
|
1535
|
-
if (!events.handlers) return;
|
|
1536
|
-
if (pointerId !== void 0) {
|
|
1537
|
-
const event = internal.pointerDirty.get(pointerId);
|
|
1538
|
-
if (event) {
|
|
1539
|
-
internal.pointerDirty.delete(pointerId);
|
|
1540
|
-
processDeferredPointer(event, pointerId);
|
|
1541
|
-
} else if (internal.lastEvent?.current) {
|
|
1542
|
-
processDeferredPointer(internal.lastEvent.current, pointerId);
|
|
1543
|
-
}
|
|
1544
|
-
} else {
|
|
1545
|
-
flushDeferredPointers();
|
|
1546
|
-
if (internal.lastEvent?.current) {
|
|
1547
|
-
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
1548
|
-
}
|
|
1549
|
-
}
|
|
1550
|
-
},
|
|
1551
|
-
flush: () => {
|
|
1552
|
-
const { events, internal } = store.getState();
|
|
1553
|
-
flushDeferredPointers();
|
|
1554
|
-
if (events.updateOnFrame && internal.lastEvent?.current && events.handlers) {
|
|
1555
|
-
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
1556
|
-
}
|
|
1557
|
-
},
|
|
1558
|
-
connect: (target) => {
|
|
1559
|
-
if (!target) return;
|
|
1560
|
-
const { set, events } = store.getState();
|
|
1561
|
-
events.disconnect?.();
|
|
1562
|
-
set((state) => ({ events: { ...state.events, connected: target } }));
|
|
1563
|
-
if (events.handlers) {
|
|
1564
|
-
for (const name in events.handlers) {
|
|
1565
|
-
const event = events.handlers[name];
|
|
1566
|
-
const [eventName, passive] = DOM_EVENTS[name];
|
|
1567
|
-
target.addEventListener(eventName, event, { passive });
|
|
1568
|
-
}
|
|
1569
|
-
}
|
|
1570
|
-
},
|
|
1571
|
-
disconnect: () => {
|
|
1572
|
-
const { set, events } = store.getState();
|
|
1573
|
-
if (events.connected) {
|
|
1574
|
-
if (events.handlers) {
|
|
1575
|
-
for (const name in events.handlers) {
|
|
1576
|
-
const event = events.handlers[name];
|
|
1577
|
-
const [eventName] = DOM_EVENTS[name];
|
|
1578
|
-
events.connected.removeEventListener(eventName, event);
|
|
1579
|
-
}
|
|
1580
|
-
}
|
|
1581
|
-
set((state) => ({ events: { ...state.events, connected: void 0 } }));
|
|
1582
|
-
}
|
|
1583
|
-
},
|
|
1584
|
-
// PREVIEW (A8): the XR pointer registration API may change before stable.
|
|
1585
|
-
registerPointer: (config) => {
|
|
1586
|
-
const pointerId = nextXRPointerId++;
|
|
1587
|
-
xrPointers.set(pointerId, config);
|
|
1588
|
-
const { internal } = store.getState();
|
|
1589
|
-
getPointerState(internal, pointerId);
|
|
1590
|
-
return pointerId;
|
|
1591
|
-
},
|
|
1592
|
-
unregisterPointer: (pointerId) => {
|
|
1593
|
-
xrPointers.delete(pointerId);
|
|
1594
|
-
const { internal } = store.getState();
|
|
1595
|
-
const pointerState = internal.pointerMap.get(pointerId);
|
|
1596
|
-
if (pointerState) {
|
|
1597
|
-
for (const [, hoveredObj] of pointerState.hovered) {
|
|
1598
|
-
const eventObject = hoveredObj.eventObject;
|
|
1599
|
-
const instance = eventObject.__r3f;
|
|
1600
|
-
if (instance?.eventCount) {
|
|
1601
|
-
const handlers = instance.handlers;
|
|
1602
|
-
const data = { ...hoveredObj, intersections: [] };
|
|
1603
|
-
handlers.onPointerOut?.(data);
|
|
1604
|
-
handlers.onPointerLeave?.(data);
|
|
1605
|
-
}
|
|
1606
|
-
}
|
|
1607
|
-
internal.pointerMap.delete(pointerId);
|
|
1608
|
-
}
|
|
1609
|
-
internal.pointerDirty.delete(pointerId);
|
|
1610
|
-
}
|
|
1611
|
-
};
|
|
1612
|
-
}
|
|
1613
|
-
|
|
1614
|
-
const shownNotices = /* @__PURE__ */ new Set();
|
|
1615
|
-
function notifyDepreciated({ heading, body, link }) {
|
|
1616
|
-
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_DEPRECATION_WARNINGS !== "true") {
|
|
1617
|
-
return;
|
|
1618
|
-
}
|
|
1619
|
-
if (shownNotices.has(heading)) return;
|
|
1620
|
-
shownNotices.add(heading);
|
|
1621
|
-
const caller = getCallerFrame();
|
|
1622
|
-
if (caller) {
|
|
1623
|
-
console.log();
|
|
1624
|
-
}
|
|
1625
|
-
const boxStyle = "background: #ff9800; color: #1a1a1a; padding: 8px 12px; border-radius: 4px; font-weight: 500;";
|
|
1626
|
-
if (caller) {
|
|
1627
|
-
console.log(`%c\u26A0\uFE0F ${heading}`, boxStyle);
|
|
1628
|
-
}
|
|
1629
|
-
if (body || link) {
|
|
1630
|
-
let message = "";
|
|
1631
|
-
if (body) message += body;
|
|
1632
|
-
if (link) message += (body ? "\n\n" : "") + `More info: ${link}`;
|
|
1633
|
-
console.warn(`%c${message}`, "font-weight: bold;");
|
|
1634
|
-
}
|
|
1635
|
-
}
|
|
1636
|
-
function getCallerFrame(depth = 3) {
|
|
1637
|
-
const stack = new Error().stack;
|
|
1638
|
-
if (!stack) return null;
|
|
1639
|
-
const lines = stack.split("\n");
|
|
1640
|
-
const frame = lines[depth];
|
|
1641
|
-
if (!frame) return null;
|
|
1642
|
-
let match = frame.match(/^\s*at (?:(.+?) )?\(?(.+?):(\d+):(\d+)\)?$/);
|
|
1643
|
-
if (!match) {
|
|
1644
|
-
match = frame.match(/^(?:(.+?)@)?(.+?):(\d+):(\d+)$/);
|
|
1645
|
-
}
|
|
1646
|
-
if (!match) return null;
|
|
1647
|
-
const [, fn, url, line] = match;
|
|
1648
|
-
return {
|
|
1649
|
-
functionName: fn ?? "<anonymous>",
|
|
1650
|
-
location: formatLocation(url, Number(line))
|
|
1651
|
-
};
|
|
1652
|
-
}
|
|
1653
|
-
function formatLocation(url, line) {
|
|
1654
|
-
const clean = url.split("?")[0];
|
|
1655
|
-
const file = clean.split("/").pop() ?? clean;
|
|
1656
|
-
return `${file}:${line}`;
|
|
1657
|
-
}
|
|
1658
|
-
function notifyAlpha({ message, link }) {
|
|
1659
|
-
if (typeof process !== "undefined" && (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== void 0) && process.env.R3F_SHOW_ALPHA_WARNINGS !== "true") {
|
|
1660
|
-
return;
|
|
1661
|
-
}
|
|
1662
|
-
if (shownNotices.has(message)) return;
|
|
1663
|
-
shownNotices.add(message);
|
|
1664
|
-
const boxStyle = "background: #6366f1; color: #ffffff; padding: 6px 10px; border-radius: 4px; font-weight: 500;";
|
|
1665
|
-
console.log(`%c\u{1F52C} ${message}`, boxStyle);
|
|
1666
|
-
{
|
|
1667
|
-
console.log(`%cMore info: ${link}`, "color: #6366f1; font-weight: normal;");
|
|
1668
|
-
}
|
|
1669
|
-
}
|
|
1670
|
-
|
|
1671
|
-
const INTERNAL_LIB_MARKERS = ["zustand", "setState", "Object.assign"];
|
|
1672
|
-
function isInternalRendererAccess(stack, callerDepth = 2) {
|
|
1673
|
-
if (!stack) return false;
|
|
1674
|
-
const caller = stack.split("\n")[callerDepth] ?? "";
|
|
1675
|
-
return INTERNAL_LIB_MARKERS.some((m) => caller.includes(m));
|
|
1676
|
-
}
|
|
1677
|
-
|
|
1678
|
-
const R3F_CONTEXT = Symbol.for("@react-three/fiber.context");
|
|
1679
|
-
const context = globalThis[R3F_CONTEXT] ?? (globalThis[R3F_CONTEXT] = React.createContext(null));
|
|
1680
|
-
const createStore = (invalidate, advance) => {
|
|
1681
|
-
const rootStore = createWithEqualityFn((set, get) => {
|
|
1682
|
-
const position = new Vector3();
|
|
1683
|
-
const defaultTarget = new Vector3();
|
|
1684
|
-
const tempTarget = new Vector3();
|
|
1685
|
-
function getCurrentViewport(camera = get().camera, target = defaultTarget, size = get().size) {
|
|
1686
|
-
const { width, height, top, left } = size;
|
|
1687
|
-
const aspect = width / height;
|
|
1688
|
-
if (target.isVector3) tempTarget.copy(target);
|
|
1689
|
-
else tempTarget.set(...target);
|
|
1690
|
-
const distance = camera.getWorldPosition(position).distanceTo(tempTarget);
|
|
1691
|
-
if (isOrthographicCamera(camera)) {
|
|
1692
|
-
return { width: width / camera.zoom, height: height / camera.zoom, top, left, factor: 1, distance, aspect };
|
|
1693
|
-
} else {
|
|
1694
|
-
const fov = camera.fov * Math.PI / 180;
|
|
1695
|
-
const h = 2 * Math.tan(fov / 2) * distance;
|
|
1696
|
-
const w = h * (width / height);
|
|
1697
|
-
return { width: w, height: h, top, left, factor: width / w, distance, aspect };
|
|
808
|
+
|
|
809
|
+
const R3F_CONTEXT = Symbol.for("@react-three/fiber.context");
|
|
810
|
+
const context = globalThis[R3F_CONTEXT] ?? (globalThis[R3F_CONTEXT] = React.createContext(null));
|
|
811
|
+
const createStore = (invalidate, advance) => {
|
|
812
|
+
const rootStore = createWithEqualityFn((set, get) => {
|
|
813
|
+
const position = new Vector3();
|
|
814
|
+
const defaultTarget = new Vector3();
|
|
815
|
+
const tempTarget = new Vector3();
|
|
816
|
+
function getCurrentViewport(camera = get().camera, target = defaultTarget, size = get().size) {
|
|
817
|
+
const { width, height, top, left } = size;
|
|
818
|
+
const aspect = width / height;
|
|
819
|
+
if (target.isVector3) tempTarget.copy(target);
|
|
820
|
+
else tempTarget.set(...target);
|
|
821
|
+
const distance = camera.getWorldPosition(position).distanceTo(tempTarget);
|
|
822
|
+
if (isOrthographicCamera(camera)) {
|
|
823
|
+
return { width: width / camera.zoom, height: height / camera.zoom, top, left, factor: 1, distance, aspect };
|
|
824
|
+
} else {
|
|
825
|
+
const fov = camera.fov * Math.PI / 180;
|
|
826
|
+
const h = 2 * Math.tan(fov / 2) * distance;
|
|
827
|
+
const w = h * (width / height);
|
|
828
|
+
return { width: w, height: h, top, left, factor: width / w, distance, aspect };
|
|
1698
829
|
}
|
|
1699
830
|
}
|
|
1700
831
|
let performanceTimeout = void 0;
|
|
@@ -1784,7 +915,7 @@ const createStore = (invalidate, advance) => {
|
|
|
1784
915
|
size: newSize,
|
|
1785
916
|
viewport: { ...s.viewport, ...getCurrentViewport(state2.camera, defaultTarget, newSize) }
|
|
1786
917
|
}));
|
|
1787
|
-
|
|
918
|
+
get().invalidate();
|
|
1788
919
|
}
|
|
1789
920
|
}
|
|
1790
921
|
return;
|
|
@@ -1799,15 +930,16 @@ const createStore = (invalidate, advance) => {
|
|
|
1799
930
|
viewport: { ...s.viewport, ...getCurrentViewport(state2.camera, defaultTarget, size) },
|
|
1800
931
|
_sizeImperative: true
|
|
1801
932
|
}));
|
|
1802
|
-
|
|
933
|
+
get().invalidate();
|
|
1803
934
|
},
|
|
1804
935
|
setDpr: (dpr) => set((state2) => {
|
|
1805
936
|
const resolved = calculateDpr(dpr);
|
|
1806
937
|
return { viewport: { ...state2.viewport, dpr: resolved, initialDpr: state2.viewport.initialDpr || resolved } };
|
|
1807
938
|
}),
|
|
1808
939
|
setFrameloop: (frameloop = "always") => {
|
|
940
|
+
const rootId = get().internal.rootId;
|
|
941
|
+
if (rootId) getScheduler().setRootFrameloop(rootId, frameloop);
|
|
1809
942
|
set(() => ({ frameloop }));
|
|
1810
|
-
getScheduler().frameloop = frameloop;
|
|
1811
943
|
},
|
|
1812
944
|
setError: (error) => set(() => ({ error })),
|
|
1813
945
|
error: null,
|
|
@@ -1923,17 +1055,11 @@ const createStore = (invalidate, advance) => {
|
|
|
1923
1055
|
oldSize = size;
|
|
1924
1056
|
oldDpr = viewport.dpr;
|
|
1925
1057
|
updateCamera(camera, size);
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
actualRenderer.setSize(size.width, size.height, false);
|
|
1932
|
-
if (canvasTarget) {
|
|
1933
|
-
if (viewport.dpr > 0) canvasTarget.setPixelRatio(viewport.dpr);
|
|
1934
|
-
canvasTarget.setSize(size.width, size.height, false);
|
|
1935
|
-
}
|
|
1936
|
-
}
|
|
1058
|
+
const resizeTarget = canvasTarget ?? actualRenderer;
|
|
1059
|
+
if (viewport.dpr > 0) resizeTarget.setPixelRatio(viewport.dpr);
|
|
1060
|
+
resizeTarget.setSize(size.width, size.height, false);
|
|
1061
|
+
const activeTarget = actualRenderer.getCanvasTarget?.();
|
|
1062
|
+
if (!canvasTarget || activeTarget !== canvasTarget) internal.canvasTargetSizeDirty = true;
|
|
1937
1063
|
}
|
|
1938
1064
|
if (camera !== oldCamera) {
|
|
1939
1065
|
oldCamera = camera;
|
|
@@ -1954,7 +1080,7 @@ const createStore = (invalidate, advance) => {
|
|
|
1954
1080
|
|
|
1955
1081
|
const memoizedLoaders = /* @__PURE__ */ new WeakMap();
|
|
1956
1082
|
const isConstructor$1 = (value) => typeof value === "function" && value?.prototype?.constructor === value;
|
|
1957
|
-
function getLoader(Proto) {
|
|
1083
|
+
function getLoader$1(Proto) {
|
|
1958
1084
|
if (isConstructor$1(Proto)) {
|
|
1959
1085
|
let loader = memoizedLoaders.get(Proto);
|
|
1960
1086
|
if (!loader) {
|
|
@@ -1967,7 +1093,7 @@ function getLoader(Proto) {
|
|
|
1967
1093
|
}
|
|
1968
1094
|
function loadingFn(extensions, onProgress) {
|
|
1969
1095
|
return function(Proto, input) {
|
|
1970
|
-
const loader = getLoader(Proto);
|
|
1096
|
+
const loader = getLoader$1(Proto);
|
|
1971
1097
|
if (extensions) extensions(loader);
|
|
1972
1098
|
if ("loadAsync" in loader && typeof loader.loadAsync === "function") {
|
|
1973
1099
|
return loader.loadAsync(input, onProgress).then((data) => {
|
|
@@ -1995,7 +1121,11 @@ function useLoader(loader, input, extensions, onProgress, cacheKey) {
|
|
|
1995
1121
|
const results = cacheKeys.map(
|
|
1996
1122
|
(key, index) => suspend(() => fn(loader, inputs[index]), [loader, key], { equal: is.equ })
|
|
1997
1123
|
);
|
|
1998
|
-
|
|
1124
|
+
const stableRef = useRef(null);
|
|
1125
|
+
const previous = stableRef.current;
|
|
1126
|
+
const stable = previous !== null && previous.length === results.length && previous.every((value, i) => value === results[i]) ? previous : results;
|
|
1127
|
+
stableRef.current = stable;
|
|
1128
|
+
return Array.isArray(input) ? stable : stable[0];
|
|
1999
1129
|
}
|
|
2000
1130
|
useLoader.preload = function(loader, input, extensions, onProgress, cacheKey) {
|
|
2001
1131
|
const inputs = Array.isArray(input) ? input : [input];
|
|
@@ -2008,9 +1138,9 @@ useLoader.clear = function(loader, input, cacheKey) {
|
|
|
2008
1138
|
const cacheKeys = Array.isArray(cacheKey ?? input) ? cacheKey ?? input : [cacheKey ?? input];
|
|
2009
1139
|
cacheKeys.forEach((key) => clear([loader, key]));
|
|
2010
1140
|
};
|
|
2011
|
-
useLoader.loader = getLoader;
|
|
1141
|
+
useLoader.loader = getLoader$1;
|
|
2012
1142
|
|
|
2013
|
-
function useFrame(callback, priorityOrOptions) {
|
|
1143
|
+
function useFrame$1(callback, priorityOrOptions) {
|
|
2014
1144
|
const store = React.useContext(context);
|
|
2015
1145
|
const isInsideCanvas = store !== null;
|
|
2016
1146
|
const scheduler = getScheduler();
|
|
@@ -2115,6 +1245,13 @@ function useFrame(callback, priorityOrOptions) {
|
|
|
2115
1245
|
* Use for controlling the entire frame loop, adding phases, etc.
|
|
2116
1246
|
*/
|
|
2117
1247
|
scheduler: scheduler2,
|
|
1248
|
+
/**
|
|
1249
|
+
* The root that currently owns this job. Resolve on access because ambient
|
|
1250
|
+
* jobs can be adopted by a Canvas after the controls object is created.
|
|
1251
|
+
*/
|
|
1252
|
+
get rootId() {
|
|
1253
|
+
return getScheduler().getJobRootId(id);
|
|
1254
|
+
},
|
|
2118
1255
|
/**
|
|
2119
1256
|
* Manually step this job only.
|
|
2120
1257
|
* Bypasses FPS limiting - always runs.
|
|
@@ -2131,6 +1268,14 @@ function useFrame(callback, priorityOrOptions) {
|
|
|
2131
1268
|
stepAll: (timestamp) => {
|
|
2132
1269
|
getScheduler().step(timestamp);
|
|
2133
1270
|
},
|
|
1271
|
+
/**
|
|
1272
|
+
* Request frames for this job's owning root without waking sibling roots.
|
|
1273
|
+
*/
|
|
1274
|
+
invalidate: (frames, stackFrames) => {
|
|
1275
|
+
const scheduler3 = getScheduler();
|
|
1276
|
+
const rootId = scheduler3.getJobRootId(id);
|
|
1277
|
+
if (rootId) scheduler3.invalidateRoot(rootId, frames, stackFrames);
|
|
1278
|
+
},
|
|
2134
1279
|
/**
|
|
2135
1280
|
* Pause this job (set enabled=false).
|
|
2136
1281
|
* Job remains registered but won't run.
|
|
@@ -2160,6 +1305,11 @@ function getUrls(input) {
|
|
|
2160
1305
|
if (Array.isArray(input)) return input;
|
|
2161
1306
|
return Object.values(input);
|
|
2162
1307
|
}
|
|
1308
|
+
function inputSignature(input) {
|
|
1309
|
+
if (typeof input === "string") return input;
|
|
1310
|
+
if (Array.isArray(input)) return input.join("\0");
|
|
1311
|
+
return Object.keys(input).sort().map((key) => `${key}\0${input[key]}`).join("");
|
|
1312
|
+
}
|
|
2163
1313
|
function allUrlsCached(urls, textureCache) {
|
|
2164
1314
|
return urls.every((url) => textureCache.has(url));
|
|
2165
1315
|
}
|
|
@@ -2178,31 +1328,44 @@ function buildFromCache(input, textureCache) {
|
|
|
2178
1328
|
}
|
|
2179
1329
|
}
|
|
2180
1330
|
function useTexture(input, optionsOrOnLoad) {
|
|
2181
|
-
const renderer = useThree((state) => state.internal.actualRenderer);
|
|
1331
|
+
const renderer = useThree$1((state) => state.internal.actualRenderer);
|
|
2182
1332
|
const store = useStore();
|
|
2183
1333
|
const options = typeof optionsOrOnLoad === "function" ? { onLoad: optionsOrOnLoad } : optionsOrOnLoad ?? {};
|
|
2184
1334
|
const { onLoad, cache = true } = options;
|
|
2185
1335
|
const onLoadRef = useRef(onLoad);
|
|
2186
1336
|
onLoadRef.current = onLoad;
|
|
2187
1337
|
const onLoadCalledForRef = useRef(null);
|
|
2188
|
-
const
|
|
1338
|
+
const inputKey = useMemo(() => inputSignature(input), [input]);
|
|
1339
|
+
const stableInput = useMemo(() => input, [inputKey]);
|
|
1340
|
+
const urls = useMemo(() => getUrls(stableInput), [stableInput]);
|
|
2189
1341
|
const cachedResult = useMemo(() => {
|
|
2190
1342
|
if (!cache) return null;
|
|
2191
1343
|
const textures = store.getState().textures;
|
|
2192
1344
|
if (!allUrlsCached(urls, textures)) return null;
|
|
2193
|
-
return buildFromCache(
|
|
2194
|
-
}, [cache, urls,
|
|
1345
|
+
return buildFromCache(stableInput, textures);
|
|
1346
|
+
}, [cache, urls, stableInput, store]);
|
|
2195
1347
|
const loadedTextures = useLoader(
|
|
2196
1348
|
TextureLoader,
|
|
2197
|
-
IsObject(
|
|
1349
|
+
IsObject(stableInput) ? Object.values(stableInput) : stableInput
|
|
2198
1350
|
);
|
|
2199
|
-
const
|
|
1351
|
+
const mappedTextures = useMemo(() => {
|
|
1352
|
+
if (cachedResult) return cachedResult;
|
|
1353
|
+
if (IsObject(stableInput)) {
|
|
1354
|
+
const keyed = {};
|
|
1355
|
+
const textureArray = loadedTextures;
|
|
1356
|
+
let i = 0;
|
|
1357
|
+
for (const key in stableInput) keyed[key] = textureArray[i++];
|
|
1358
|
+
return keyed;
|
|
1359
|
+
} else {
|
|
1360
|
+
return loadedTextures;
|
|
1361
|
+
}
|
|
1362
|
+
}, [stableInput, loadedTextures, cachedResult]);
|
|
2200
1363
|
useLayoutEffect(() => {
|
|
2201
1364
|
if (cachedResult) return;
|
|
2202
1365
|
if (onLoadCalledForRef.current === inputKey) return;
|
|
2203
1366
|
onLoadCalledForRef.current = inputKey;
|
|
2204
|
-
onLoadRef.current?.(
|
|
2205
|
-
}, [cachedResult,
|
|
1367
|
+
onLoadRef.current?.(mappedTextures);
|
|
1368
|
+
}, [cachedResult, mappedTextures, inputKey]);
|
|
2206
1369
|
useEffect(() => {
|
|
2207
1370
|
if (cachedResult) return;
|
|
2208
1371
|
if ("initTexture" in renderer) {
|
|
@@ -2221,30 +1384,18 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
2221
1384
|
});
|
|
2222
1385
|
}
|
|
2223
1386
|
}, [renderer, loadedTextures, cachedResult]);
|
|
2224
|
-
const mappedTextures = useMemo(() => {
|
|
2225
|
-
if (cachedResult) return cachedResult;
|
|
2226
|
-
if (IsObject(input)) {
|
|
2227
|
-
const keyed = {};
|
|
2228
|
-
const textureArray = loadedTextures;
|
|
2229
|
-
let i = 0;
|
|
2230
|
-
for (const key in input) keyed[key] = textureArray[i++];
|
|
2231
|
-
return keyed;
|
|
2232
|
-
} else {
|
|
2233
|
-
return loadedTextures;
|
|
2234
|
-
}
|
|
2235
|
-
}, [input, loadedTextures, cachedResult]);
|
|
2236
1387
|
useEffect(() => {
|
|
2237
1388
|
if (!cache) return;
|
|
2238
1389
|
const urlTextureMap = [];
|
|
2239
|
-
if (typeof
|
|
2240
|
-
urlTextureMap.push([
|
|
2241
|
-
} else if (Array.isArray(
|
|
1390
|
+
if (typeof stableInput === "string") {
|
|
1391
|
+
urlTextureMap.push([stableInput, mappedTextures]);
|
|
1392
|
+
} else if (Array.isArray(stableInput)) {
|
|
2242
1393
|
const textureArray = mappedTextures;
|
|
2243
|
-
|
|
2244
|
-
} else if (IsObject(
|
|
1394
|
+
stableInput.forEach((url, i) => urlTextureMap.push([url, textureArray[i]]));
|
|
1395
|
+
} else if (IsObject(stableInput)) {
|
|
2245
1396
|
const textureRecord = mappedTextures;
|
|
2246
|
-
for (const key in
|
|
2247
|
-
const url =
|
|
1397
|
+
for (const key in stableInput) {
|
|
1398
|
+
const url = stableInput[key];
|
|
2248
1399
|
urlTextureMap.push([url, textureRecord[key]]);
|
|
2249
1400
|
}
|
|
2250
1401
|
}
|
|
@@ -2273,7 +1424,7 @@ function useTexture(input, optionsOrOnLoad) {
|
|
|
2273
1424
|
}
|
|
2274
1425
|
return { _textureRefs: refs };
|
|
2275
1426
|
});
|
|
2276
|
-
}, [cache,
|
|
1427
|
+
}, [cache, stableInput, mappedTextures, store]);
|
|
2277
1428
|
return mappedTextures;
|
|
2278
1429
|
}
|
|
2279
1430
|
useTexture.preload = (url) => useLoader.preload(TextureLoader, url);
|
|
@@ -2344,13 +1495,13 @@ function useTextures(selector) {
|
|
|
2344
1495
|
};
|
|
2345
1496
|
}, [store]);
|
|
2346
1497
|
const subscribe = selector ? () => selector(registry) : (state) => state.textures;
|
|
2347
|
-
const selected = useThree(subscribe);
|
|
1498
|
+
const selected = useThree$1(subscribe);
|
|
2348
1499
|
return selector ? selected : registry;
|
|
2349
1500
|
}
|
|
2350
1501
|
|
|
2351
1502
|
function useRenderTarget(widthOrOptions, heightOrOptions, options) {
|
|
2352
|
-
const isLegacy = useThree((s) => s.isLegacy);
|
|
2353
|
-
const size = useThree((s) => s.size);
|
|
1503
|
+
const isLegacy = useThree$1((s) => s.isLegacy);
|
|
1504
|
+
const size = useThree$1((s) => s.size);
|
|
2354
1505
|
let width;
|
|
2355
1506
|
let height;
|
|
2356
1507
|
let opts;
|
|
@@ -2368,11 +1519,132 @@ function useRenderTarget(widthOrOptions, heightOrOptions, options) {
|
|
|
2368
1519
|
height = widthOrOptions;
|
|
2369
1520
|
}
|
|
2370
1521
|
}
|
|
2371
|
-
return useMemo(() => {
|
|
2372
|
-
const w = width ?? size.width;
|
|
2373
|
-
const h = height ?? size.height;
|
|
2374
|
-
return new WebGLRenderTarget(w, h, opts);
|
|
2375
|
-
}, [width, height, size.width, size.height, opts, isLegacy]);
|
|
1522
|
+
return useMemo(() => {
|
|
1523
|
+
const w = width ?? size.width;
|
|
1524
|
+
const h = height ?? size.height;
|
|
1525
|
+
return new WebGLRenderTarget(w, h, opts);
|
|
1526
|
+
}, [width, height, size.width, size.height, opts, isLegacy]);
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
const presetsObj = {
|
|
1530
|
+
apartment: "lebombo_1k.hdr",
|
|
1531
|
+
city: "potsdamer_platz_1k.hdr",
|
|
1532
|
+
dawn: "kiara_1_dawn_1k.hdr",
|
|
1533
|
+
forest: "forest_slope_1k.hdr",
|
|
1534
|
+
lobby: "st_fagans_interior_1k.hdr",
|
|
1535
|
+
night: "dikhololo_night_1k.hdr",
|
|
1536
|
+
park: "rooitou_park_1k.hdr",
|
|
1537
|
+
studio: "studio_small_03_1k.hdr",
|
|
1538
|
+
sunset: "venice_sunset_1k.hdr",
|
|
1539
|
+
warehouse: "empty_warehouse_01_1k.hdr"
|
|
1540
|
+
};
|
|
1541
|
+
|
|
1542
|
+
const CUBEMAP_ROOT = "https://raw.githack.com/pmndrs/drei-assets/456060a26bbeb8fdf79326f224b6d99b8bcce736/hdri/";
|
|
1543
|
+
const isArray = (arr) => Array.isArray(arr);
|
|
1544
|
+
const defaultFiles = ["/px.png", "/nx.png", "/py.png", "/ny.png", "/pz.png", "/nz.png"];
|
|
1545
|
+
function useEnvironment({
|
|
1546
|
+
files = defaultFiles,
|
|
1547
|
+
path = "",
|
|
1548
|
+
preset = void 0,
|
|
1549
|
+
colorSpace = void 0,
|
|
1550
|
+
extensions
|
|
1551
|
+
} = {}) {
|
|
1552
|
+
if (preset) {
|
|
1553
|
+
validatePreset(preset);
|
|
1554
|
+
files = presetsObj[preset];
|
|
1555
|
+
path = CUBEMAP_ROOT;
|
|
1556
|
+
}
|
|
1557
|
+
const multiFile = isArray(files);
|
|
1558
|
+
const { extension, isCubemap } = getExtension(files);
|
|
1559
|
+
const loader = getLoader(extension);
|
|
1560
|
+
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1561
|
+
const renderer = useThree$1((state) => state.renderer);
|
|
1562
|
+
useLayoutEffect(() => {
|
|
1563
|
+
if (extension !== "webp" && extension !== "jpg" && extension !== "jpeg") return;
|
|
1564
|
+
function clearGainmapTexture() {
|
|
1565
|
+
useLoader.clear(loader, multiFile ? [files] : files);
|
|
1566
|
+
}
|
|
1567
|
+
renderer.domElement.addEventListener("webglcontextlost", clearGainmapTexture, { once: true });
|
|
1568
|
+
}, [extension, files, loader, multiFile, renderer.domElement]);
|
|
1569
|
+
const loaderResult = useLoader(
|
|
1570
|
+
loader,
|
|
1571
|
+
multiFile ? [files] : files,
|
|
1572
|
+
(loader2) => {
|
|
1573
|
+
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
1574
|
+
loader2.setRenderer?.(renderer);
|
|
1575
|
+
}
|
|
1576
|
+
loader2.setPath?.(path);
|
|
1577
|
+
if (extensions) extensions(loader2);
|
|
1578
|
+
}
|
|
1579
|
+
);
|
|
1580
|
+
let texture = multiFile ? (
|
|
1581
|
+
// @ts-ignore
|
|
1582
|
+
loaderResult[0]
|
|
1583
|
+
) : loaderResult;
|
|
1584
|
+
if (extension === "jpg" || extension === "jpeg" || extension === "webp") {
|
|
1585
|
+
texture = texture.renderTarget?.texture;
|
|
1586
|
+
}
|
|
1587
|
+
texture.mapping = isCubemap ? CubeReflectionMapping : EquirectangularReflectionMapping;
|
|
1588
|
+
texture.colorSpace = colorSpace ?? (isCubemap && extension !== "hdr-cube" ? "srgb" : "srgb-linear");
|
|
1589
|
+
return texture;
|
|
1590
|
+
}
|
|
1591
|
+
const preloadDefaultOptions = {
|
|
1592
|
+
files: defaultFiles,
|
|
1593
|
+
path: "",
|
|
1594
|
+
preset: void 0,
|
|
1595
|
+
extensions: void 0
|
|
1596
|
+
};
|
|
1597
|
+
useEnvironment.preload = (preloadOptions) => {
|
|
1598
|
+
const options = { ...preloadDefaultOptions, ...preloadOptions };
|
|
1599
|
+
let { files, path = "" } = options;
|
|
1600
|
+
const { preset, extensions } = options;
|
|
1601
|
+
if (preset) {
|
|
1602
|
+
validatePreset(preset);
|
|
1603
|
+
files = presetsObj[preset];
|
|
1604
|
+
path = CUBEMAP_ROOT;
|
|
1605
|
+
}
|
|
1606
|
+
const { extension } = getExtension(files);
|
|
1607
|
+
if (extension === "webp" || extension === "jpg" || extension === "jpeg") {
|
|
1608
|
+
throw new Error("useEnvironment: Preloading gainmaps is not supported");
|
|
1609
|
+
}
|
|
1610
|
+
const loader = getLoader(extension);
|
|
1611
|
+
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1612
|
+
useLoader.preload(loader, isArray(files) ? [files] : files, (loader2) => {
|
|
1613
|
+
loader2.setPath?.(path);
|
|
1614
|
+
if (extensions) extensions(loader2);
|
|
1615
|
+
});
|
|
1616
|
+
};
|
|
1617
|
+
const clearDefaultOptins = {
|
|
1618
|
+
files: defaultFiles,
|
|
1619
|
+
preset: void 0
|
|
1620
|
+
};
|
|
1621
|
+
useEnvironment.clear = (clearOptions) => {
|
|
1622
|
+
const options = { ...clearDefaultOptins, ...clearOptions };
|
|
1623
|
+
let { files } = options;
|
|
1624
|
+
const { preset } = options;
|
|
1625
|
+
if (preset) {
|
|
1626
|
+
validatePreset(preset);
|
|
1627
|
+
files = presetsObj[preset];
|
|
1628
|
+
}
|
|
1629
|
+
const { extension } = getExtension(files);
|
|
1630
|
+
const loader = getLoader(extension);
|
|
1631
|
+
if (!loader) throw new Error("useEnvironment: Unrecognized file extension: " + files);
|
|
1632
|
+
useLoader.clear(loader, isArray(files) ? [files] : files);
|
|
1633
|
+
};
|
|
1634
|
+
function validatePreset(preset) {
|
|
1635
|
+
if (!(preset in presetsObj)) throw new Error("Preset must be one of: " + Object.keys(presetsObj).join(", "));
|
|
1636
|
+
}
|
|
1637
|
+
function getExtension(files) {
|
|
1638
|
+
const isCubemap = isArray(files) && files.length === 6;
|
|
1639
|
+
const isGainmap = isArray(files) && files.length === 3 && files.some((file) => file.endsWith("json"));
|
|
1640
|
+
const firstEntry = isArray(files) ? files[0] : files;
|
|
1641
|
+
const firstExtension = firstEntry.split(".").pop()?.split("?")?.shift()?.toLowerCase();
|
|
1642
|
+
const extension = isCubemap ? firstExtension === "hdr" ? "hdr-cube" : "cube" : isGainmap ? "webp" : firstEntry.startsWith("data:application/exr") ? "exr" : firstEntry.startsWith("data:application/hdr") ? "hdr" : firstEntry.startsWith("data:image/jpeg") ? "jpg" : firstExtension;
|
|
1643
|
+
return { extension, isCubemap, isGainmap };
|
|
1644
|
+
}
|
|
1645
|
+
function getLoader(extension) {
|
|
1646
|
+
const loader = extension === "cube" ? CubeTextureLoader : extension === "hdr-cube" ? HDRCubeTextureLoader : extension === "hdr" ? HDRLoader : extension === "exr" ? EXRLoader : extension === "jpg" || extension === "jpeg" ? UltraHDRLoader : extension === "webp" ? GainMapLoader : null;
|
|
1647
|
+
return loader;
|
|
2376
1648
|
}
|
|
2377
1649
|
|
|
2378
1650
|
function useStore() {
|
|
@@ -2380,7 +1652,7 @@ function useStore() {
|
|
|
2380
1652
|
if (!store) throw new Error("R3F: Hooks can only be used within the Canvas component!");
|
|
2381
1653
|
return store;
|
|
2382
1654
|
}
|
|
2383
|
-
function useThree(selector = (state) => state, equalityFn) {
|
|
1655
|
+
function useThree$1(selector = (state) => state, equalityFn) {
|
|
2384
1656
|
return useStore()(selector, equalityFn);
|
|
2385
1657
|
}
|
|
2386
1658
|
function useInstanceHandle(ref) {
|
|
@@ -2392,6 +1664,8 @@ function useGraph(object) {
|
|
|
2392
1664
|
return useMemo(() => buildGraph(object), [object]);
|
|
2393
1665
|
}
|
|
2394
1666
|
|
|
1667
|
+
const t = 1, o = 8, r = 32, e = 2, i$1 = 268435456;
|
|
1668
|
+
|
|
2395
1669
|
let effectId = 0;
|
|
2396
1670
|
function addEffect(callback) {
|
|
2397
1671
|
notifyDepreciated({
|
|
@@ -2420,13 +1694,19 @@ function addTail(callback) {
|
|
|
2420
1694
|
return getScheduler().onIdle(callback);
|
|
2421
1695
|
}
|
|
2422
1696
|
function invalidate(state, frames = 1, stackFrames = false) {
|
|
2423
|
-
|
|
1697
|
+
const rootId = state?.internal?.rootId;
|
|
1698
|
+
const scheduler = getScheduler();
|
|
1699
|
+
if (rootId) scheduler.invalidateRoot(rootId, frames, stackFrames);
|
|
1700
|
+
else scheduler.invalidate(frames, stackFrames);
|
|
2424
1701
|
}
|
|
2425
|
-
function advance(timestamp) {
|
|
2426
|
-
|
|
1702
|
+
function advance(timestamp, runGlobalEffects, state) {
|
|
1703
|
+
const rootId = state?.internal?.rootId;
|
|
1704
|
+
const scheduler = getScheduler();
|
|
1705
|
+
if (rootId) scheduler.stepRoot(rootId, timestamp);
|
|
1706
|
+
else scheduler.step(timestamp);
|
|
2427
1707
|
}
|
|
2428
1708
|
|
|
2429
|
-
const version = "10.0.0-alpha.
|
|
1709
|
+
const version = "10.0.0-alpha.5";
|
|
2430
1710
|
const packageData = {
|
|
2431
1711
|
version: version};
|
|
2432
1712
|
|
|
@@ -13290,399 +12570,982 @@ Check the top-level render call using <` + i + ">.");
|
|
|
13290
12570
|
var o = x.H;
|
|
13291
12571
|
x.H = $o;
|
|
13292
12572
|
try {
|
|
13293
|
-
return Vi(e, n);
|
|
12573
|
+
return Vi(e, n);
|
|
12574
|
+
} finally {
|
|
12575
|
+
x.H = o;
|
|
12576
|
+
}
|
|
12577
|
+
}, useReducer: function(e, n, o) {
|
|
12578
|
+
z = "useReducer", D(), N();
|
|
12579
|
+
var i = x.H;
|
|
12580
|
+
x.H = $o;
|
|
12581
|
+
try {
|
|
12582
|
+
return Br(e, n, o);
|
|
12583
|
+
} finally {
|
|
12584
|
+
x.H = i;
|
|
12585
|
+
}
|
|
12586
|
+
}, useRef: function() {
|
|
12587
|
+
return z = "useRef", D(), N(), xe().memoizedState;
|
|
12588
|
+
}, useState: function() {
|
|
12589
|
+
z = "useState", D(), N();
|
|
12590
|
+
var e = x.H;
|
|
12591
|
+
x.H = $o;
|
|
12592
|
+
try {
|
|
12593
|
+
return Br(gr);
|
|
12594
|
+
} finally {
|
|
12595
|
+
x.H = e;
|
|
12596
|
+
}
|
|
12597
|
+
}, useDebugValue: function() {
|
|
12598
|
+
z = "useDebugValue", D(), N();
|
|
12599
|
+
}, useDeferredValue: function(e, n) {
|
|
12600
|
+
return z = "useDeferredValue", D(), N(), nc(e, n);
|
|
12601
|
+
}, useTransition: function() {
|
|
12602
|
+
return z = "useTransition", D(), N(), Qp();
|
|
12603
|
+
}, useSyncExternalStore: function(e, n, o) {
|
|
12604
|
+
return z = "useSyncExternalStore", D(), N(), ta(e, n, o);
|
|
12605
|
+
}, useId: function() {
|
|
12606
|
+
return z = "useId", D(), N(), xe().memoizedState;
|
|
12607
|
+
}, useFormState: function(e) {
|
|
12608
|
+
return z = "useFormState", D(), N(), hs(e);
|
|
12609
|
+
}, useActionState: function(e) {
|
|
12610
|
+
return z = "useActionState", D(), N(), hs(e);
|
|
12611
|
+
}, useOptimistic: function(e, n) {
|
|
12612
|
+
return z = "useOptimistic", D(), N(), rf(e, n);
|
|
12613
|
+
}, useMemoCache: function(e) {
|
|
12614
|
+
return D(), Oa(e);
|
|
12615
|
+
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
12616
|
+
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
12617
|
+
}, useEffectEvent: function(e) {
|
|
12618
|
+
return z = "useEffectEvent", D(), N(), oa(e);
|
|
12619
|
+
} }, dm = { readContext: function(e) {
|
|
12620
|
+
return Ce(), Ee(e);
|
|
12621
|
+
}, use: function(e) {
|
|
12622
|
+
return D(), we(e);
|
|
12623
|
+
}, useCallback: function(e, n) {
|
|
12624
|
+
return z = "useCallback", D(), N(), Ma(e, n);
|
|
12625
|
+
}, useContext: function(e) {
|
|
12626
|
+
return z = "useContext", D(), N(), Ee(e);
|
|
12627
|
+
}, useEffect: function(e, n) {
|
|
12628
|
+
z = "useEffect", D(), N(), Qn(2048, Ut, e, n);
|
|
12629
|
+
}, useImperativeHandle: function(e, n, o) {
|
|
12630
|
+
return z = "useImperativeHandle", D(), N(), aa(e, n, o);
|
|
12631
|
+
}, useInsertionEffect: function(e, n) {
|
|
12632
|
+
return z = "useInsertionEffect", D(), N(), Qn(4, Wt, e, n);
|
|
12633
|
+
}, useLayoutEffect: function(e, n) {
|
|
12634
|
+
return z = "useLayoutEffect", D(), N(), Qn(4, Rr, e, n);
|
|
12635
|
+
}, useMemo: function(e, n) {
|
|
12636
|
+
z = "useMemo", D(), N();
|
|
12637
|
+
var o = x.H;
|
|
12638
|
+
x.H = $o;
|
|
12639
|
+
try {
|
|
12640
|
+
return Vi(e, n);
|
|
12641
|
+
} finally {
|
|
12642
|
+
x.H = o;
|
|
12643
|
+
}
|
|
12644
|
+
}, useReducer: function(e, n, o) {
|
|
12645
|
+
z = "useReducer", D(), N();
|
|
12646
|
+
var i = x.H;
|
|
12647
|
+
x.H = $o;
|
|
12648
|
+
try {
|
|
12649
|
+
return Qi(e, n, o);
|
|
12650
|
+
} finally {
|
|
12651
|
+
x.H = i;
|
|
12652
|
+
}
|
|
12653
|
+
}, useRef: function() {
|
|
12654
|
+
return z = "useRef", D(), N(), xe().memoizedState;
|
|
12655
|
+
}, useState: function() {
|
|
12656
|
+
z = "useState", D(), N();
|
|
12657
|
+
var e = x.H;
|
|
12658
|
+
x.H = $o;
|
|
12659
|
+
try {
|
|
12660
|
+
return Qi(gr);
|
|
12661
|
+
} finally {
|
|
12662
|
+
x.H = e;
|
|
12663
|
+
}
|
|
12664
|
+
}, useDebugValue: function() {
|
|
12665
|
+
z = "useDebugValue", D(), N();
|
|
12666
|
+
}, useDeferredValue: function(e, n) {
|
|
12667
|
+
return z = "useDeferredValue", D(), N(), sf(e, n);
|
|
12668
|
+
}, useTransition: function() {
|
|
12669
|
+
return z = "useTransition", D(), N(), Ro();
|
|
12670
|
+
}, useSyncExternalStore: function(e, n, o) {
|
|
12671
|
+
return z = "useSyncExternalStore", D(), N(), ta(e, n, o);
|
|
12672
|
+
}, useId: function() {
|
|
12673
|
+
return z = "useId", D(), N(), xe().memoizedState;
|
|
12674
|
+
}, useFormState: function(e) {
|
|
12675
|
+
return z = "useFormState", D(), N(), $t(e);
|
|
12676
|
+
}, useActionState: function(e) {
|
|
12677
|
+
return z = "useActionState", D(), N(), $t(e);
|
|
12678
|
+
}, useOptimistic: function(e, n) {
|
|
12679
|
+
return z = "useOptimistic", D(), N(), of(e, n);
|
|
12680
|
+
}, useMemoCache: function(e) {
|
|
12681
|
+
return D(), Oa(e);
|
|
12682
|
+
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
12683
|
+
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
12684
|
+
}, useEffectEvent: function(e) {
|
|
12685
|
+
return z = "useEffectEvent", D(), N(), oa(e);
|
|
12686
|
+
} };
|
|
12687
|
+
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();
|
|
12688
|
+
Object.freeze(Fy);
|
|
12689
|
+
var zg = { enqueueSetState: function(e, n, o) {
|
|
12690
|
+
e = e._reactInternals;
|
|
12691
|
+
var i = Nt(e), s = zo(i);
|
|
12692
|
+
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));
|
|
12693
|
+
}, enqueueReplaceState: function(e, n, o) {
|
|
12694
|
+
e = e._reactInternals;
|
|
12695
|
+
var i = Nt(e), s = zo(i);
|
|
12696
|
+
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));
|
|
12697
|
+
}, enqueueForceUpdate: function(e, n) {
|
|
12698
|
+
e = e._reactInternals;
|
|
12699
|
+
var o = Nt(e), i = zo(o);
|
|
12700
|
+
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));
|
|
12701
|
+
} }, 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;
|
|
12702
|
+
Yy = /* @__PURE__ */ new Set();
|
|
12703
|
+
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) {
|
|
12704
|
+
var n = Ee(un), o = n.data.get(e);
|
|
12705
|
+
return o === void 0 && (o = e(), n.data.set(e, o)), o;
|
|
12706
|
+
}, cacheSignal: function() {
|
|
12707
|
+
return Ee(un).controller.signal;
|
|
12708
|
+
}, getOwner: function() {
|
|
12709
|
+
return di;
|
|
12710
|
+
} }, pm = 0, hm = 1, mm = 2, gm = 3, ym = 4;
|
|
12711
|
+
if (typeof Symbol == "function" && Symbol.for) {
|
|
12712
|
+
var bp = Symbol.for;
|
|
12713
|
+
pm = bp("selector.component"), hm = bp("selector.has_pseudo_class"), mm = bp("selector.role"), gm = bp("selector.test_id"), ym = bp("selector.text");
|
|
12714
|
+
}
|
|
12715
|
+
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;
|
|
12716
|
+
try {
|
|
12717
|
+
var o0 = Object.preventExtensions({});
|
|
12718
|
+
} catch {
|
|
12719
|
+
pb = true;
|
|
12720
|
+
}
|
|
12721
|
+
var hb = false, mb = {}, gb = null, yb = null, bb = null, vb = null, Sb = null, kb = null, wb = null, Pb = null, xb = null, zb = null;
|
|
12722
|
+
return gb = function(e, n, o, i) {
|
|
12723
|
+
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));
|
|
12724
|
+
}, yb = function(e, n, o) {
|
|
12725
|
+
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));
|
|
12726
|
+
}, bb = function(e, n, o, i) {
|
|
12727
|
+
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));
|
|
12728
|
+
}, vb = function(e, n, o) {
|
|
12729
|
+
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);
|
|
12730
|
+
}, Sb = function(e, n) {
|
|
12731
|
+
e.pendingProps = du(e.memoizedProps, n, 0), e.alternate && (e.alternate.pendingProps = e.pendingProps), n = On(e, 2), n !== null && We(n, e, 2);
|
|
12732
|
+
}, kb = function(e, n, o) {
|
|
12733
|
+
e.pendingProps = F(e.memoizedProps, n, o), e.alternate && (e.alternate.pendingProps = e.pendingProps), n = On(e, 2), n !== null && We(n, e, 2);
|
|
12734
|
+
}, wb = function(e) {
|
|
12735
|
+
var n = On(e, 2);
|
|
12736
|
+
n !== null && We(n, e, 2);
|
|
12737
|
+
}, Pb = function(e) {
|
|
12738
|
+
var n = ut(), o = On(e, n);
|
|
12739
|
+
o !== null && We(o, e, n);
|
|
12740
|
+
}, xb = function(e) {
|
|
12741
|
+
pu = e;
|
|
12742
|
+
}, zb = function(e) {
|
|
12743
|
+
fu = e;
|
|
12744
|
+
}, le.attemptContinuousHydration = function(e) {
|
|
12745
|
+
if (e.tag === 13 || e.tag === 31) {
|
|
12746
|
+
var n = On(e, 67108864);
|
|
12747
|
+
n !== null && We(n, e, 67108864), rl(e, 67108864);
|
|
12748
|
+
}
|
|
12749
|
+
}, le.attemptHydrationAtCurrentPriority = function(e) {
|
|
12750
|
+
if (e.tag === 13 || e.tag === 31) {
|
|
12751
|
+
var n = Nt(e);
|
|
12752
|
+
n = Xo(n);
|
|
12753
|
+
var o = On(e, n);
|
|
12754
|
+
o !== null && We(o, e, n), rl(e, n);
|
|
12755
|
+
}
|
|
12756
|
+
}, le.attemptSynchronousHydration = function(e) {
|
|
12757
|
+
switch (e.tag) {
|
|
12758
|
+
case 3:
|
|
12759
|
+
if (e = e.stateNode, e.current.memoizedState.isDehydrated) {
|
|
12760
|
+
var n = _t(e.pendingLanes);
|
|
12761
|
+
if (n !== 0) {
|
|
12762
|
+
for (e.pendingLanes |= 2, e.entangledLanes |= 2; n; ) {
|
|
12763
|
+
var o = 1 << 31 - vn(n);
|
|
12764
|
+
e.entanglements[1] |= o, n &= ~o;
|
|
12765
|
+
}
|
|
12766
|
+
Kn(e), (ye & (Zn | uo)) === Jn && (Pp = me() + Fg, Wa(0));
|
|
12767
|
+
}
|
|
12768
|
+
}
|
|
12769
|
+
break;
|
|
12770
|
+
case 31:
|
|
12771
|
+
case 13:
|
|
12772
|
+
n = On(e, 2), n !== null && We(n, e, 2), Ls(), rl(e, 2);
|
|
12773
|
+
}
|
|
12774
|
+
}, le.batchedUpdates = function(e, n) {
|
|
12775
|
+
return e(n);
|
|
12776
|
+
}, le.createComponentSelector = function(e) {
|
|
12777
|
+
return { $$typeof: pm, value: e };
|
|
12778
|
+
}, le.createContainer = function(e, n, o, i, s, u, f, p, g, S) {
|
|
12779
|
+
return Ka(e, n, false, null, o, i, u, null, f, p, g, S);
|
|
12780
|
+
}, le.createHasPseudoClassSelector = function(e) {
|
|
12781
|
+
return { $$typeof: hm, value: e };
|
|
12782
|
+
}, le.createHydrationContainer = function(e, n, o, i, s, u, f, p, g, S, T, _, I, O) {
|
|
12783
|
+
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;
|
|
12784
|
+
}, le.createPortal = function(e, n, o) {
|
|
12785
|
+
var i = 3 < arguments.length && arguments[3] !== void 0 ? arguments[3] : null;
|
|
12786
|
+
try {
|
|
12787
|
+
vt(i);
|
|
12788
|
+
var s = false;
|
|
12789
|
+
} catch {
|
|
12790
|
+
s = true;
|
|
12791
|
+
}
|
|
12792
|
+
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 };
|
|
12793
|
+
}, le.createRoleSelector = function(e) {
|
|
12794
|
+
return { $$typeof: mm, value: e };
|
|
12795
|
+
}, le.createTestNameSelector = function(e) {
|
|
12796
|
+
return { $$typeof: gm, value: e };
|
|
12797
|
+
}, le.createTextSelector = function(e) {
|
|
12798
|
+
return { $$typeof: ym, value: e };
|
|
12799
|
+
}, le.defaultOnCaughtError = function(e) {
|
|
12800
|
+
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") + ".");
|
|
12801
|
+
typeof e == "object" && e !== null && typeof e.environmentName == "string" ? ri("error", [`%o
|
|
12802
|
+
|
|
12803
|
+
%s
|
|
12804
|
+
|
|
12805
|
+
%s
|
|
12806
|
+
`, e, n, o], e.environmentName)() : console.error(`%o
|
|
12807
|
+
|
|
12808
|
+
%s
|
|
12809
|
+
|
|
12810
|
+
%s
|
|
12811
|
+
`, e, n, o);
|
|
12812
|
+
}, le.defaultOnRecoverableError = function(e) {
|
|
12813
|
+
qg(e);
|
|
12814
|
+
}, le.defaultOnUncaughtError = function(e) {
|
|
12815
|
+
qg(e), console.warn(`%s
|
|
12816
|
+
|
|
12817
|
+
%s
|
|
12818
|
+
`, 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.
|
|
12819
|
+
Visit https://react.dev/link/error-boundaries to learn more about error boundaries.`);
|
|
12820
|
+
}, le.deferredUpdates = function(e) {
|
|
12821
|
+
var n = x.T, o = wt();
|
|
12822
|
+
try {
|
|
12823
|
+
return an(32), x.T = null, e();
|
|
13294
12824
|
} finally {
|
|
13295
|
-
x.
|
|
12825
|
+
an(o), x.T = n;
|
|
13296
12826
|
}
|
|
13297
|
-
},
|
|
13298
|
-
|
|
13299
|
-
var i = x.H;
|
|
13300
|
-
x.H = $o;
|
|
12827
|
+
}, le.discreteUpdates = function(e, n, o, i, s) {
|
|
12828
|
+
var u = x.T, f = wt();
|
|
13301
12829
|
try {
|
|
13302
|
-
return
|
|
12830
|
+
return an(2), x.T = null, e(n, o, i, s);
|
|
13303
12831
|
} finally {
|
|
13304
|
-
x.
|
|
12832
|
+
an(f), x.T = u, ye === Jn && (Pp = me() + Fg);
|
|
13305
12833
|
}
|
|
13306
|
-
},
|
|
13307
|
-
|
|
13308
|
-
|
|
13309
|
-
|
|
13310
|
-
|
|
13311
|
-
|
|
13312
|
-
|
|
13313
|
-
|
|
13314
|
-
|
|
13315
|
-
|
|
12834
|
+
}, le.findAllNodes = kc, le.findBoundingRects = function(e, n) {
|
|
12835
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12836
|
+
n = kc(e, n), e = [];
|
|
12837
|
+
for (var o = 0; o < n.length; o++) e.push(ma(n[o]));
|
|
12838
|
+
for (n = e.length - 1; 0 < n; n--) {
|
|
12839
|
+
o = e[n];
|
|
12840
|
+
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) {
|
|
12841
|
+
var g = e[p], S = g.x, T = S + g.width, _ = g.y, I = _ + g.height;
|
|
12842
|
+
if (i >= S && u >= _ && s <= T && f <= I) {
|
|
12843
|
+
e.splice(n, 1);
|
|
12844
|
+
break;
|
|
12845
|
+
} else if (i !== S || o.width !== g.width || I < u || _ > f) {
|
|
12846
|
+
if (!(u !== _ || o.height !== g.height || T < i || S > s)) {
|
|
12847
|
+
S > i && (g.width += S - i, g.x = i), T < s && (g.width = s - S), e.splice(n, 1);
|
|
12848
|
+
break;
|
|
12849
|
+
}
|
|
12850
|
+
} else {
|
|
12851
|
+
_ > u && (g.height += _ - u, g.y = u), I < f && (g.height = f - _), e.splice(n, 1);
|
|
12852
|
+
break;
|
|
12853
|
+
}
|
|
12854
|
+
}
|
|
13316
12855
|
}
|
|
13317
|
-
|
|
13318
|
-
|
|
13319
|
-
|
|
13320
|
-
|
|
13321
|
-
|
|
13322
|
-
|
|
13323
|
-
|
|
13324
|
-
|
|
13325
|
-
|
|
13326
|
-
|
|
13327
|
-
|
|
13328
|
-
|
|
13329
|
-
|
|
13330
|
-
|
|
13331
|
-
|
|
13332
|
-
|
|
13333
|
-
}, useMemoCache: function(e) {
|
|
13334
|
-
return D(), Oa(e);
|
|
13335
|
-
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
13336
|
-
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
13337
|
-
}, useEffectEvent: function(e) {
|
|
13338
|
-
return z = "useEffectEvent", D(), N(), oa(e);
|
|
13339
|
-
} }, dm = { readContext: function(e) {
|
|
13340
|
-
return Ce(), Ee(e);
|
|
13341
|
-
}, use: function(e) {
|
|
13342
|
-
return D(), we(e);
|
|
13343
|
-
}, useCallback: function(e, n) {
|
|
13344
|
-
return z = "useCallback", D(), N(), Ma(e, n);
|
|
13345
|
-
}, useContext: function(e) {
|
|
13346
|
-
return z = "useContext", D(), N(), Ee(e);
|
|
13347
|
-
}, useEffect: function(e, n) {
|
|
13348
|
-
z = "useEffect", D(), N(), Qn(2048, Ut, e, n);
|
|
13349
|
-
}, useImperativeHandle: function(e, n, o) {
|
|
13350
|
-
return z = "useImperativeHandle", D(), N(), aa(e, n, o);
|
|
13351
|
-
}, useInsertionEffect: function(e, n) {
|
|
13352
|
-
return z = "useInsertionEffect", D(), N(), Qn(4, Wt, e, n);
|
|
13353
|
-
}, useLayoutEffect: function(e, n) {
|
|
13354
|
-
return z = "useLayoutEffect", D(), N(), Qn(4, Rr, e, n);
|
|
13355
|
-
}, useMemo: function(e, n) {
|
|
13356
|
-
z = "useMemo", D(), N();
|
|
13357
|
-
var o = x.H;
|
|
13358
|
-
x.H = $o;
|
|
13359
|
-
try {
|
|
13360
|
-
return Vi(e, n);
|
|
13361
|
-
} finally {
|
|
13362
|
-
x.H = o;
|
|
12856
|
+
return e;
|
|
12857
|
+
}, le.findHostInstance = function(e) {
|
|
12858
|
+
var n = e._reactInternals;
|
|
12859
|
+
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));
|
|
12860
|
+
return e = mu(n), e === null ? null : ot(e.stateNode);
|
|
12861
|
+
}, le.findHostInstanceWithNoPortals = function(e) {
|
|
12862
|
+
return e = Ed(e), e = e !== null ? _p(e) : null, e === null ? null : ot(e.stateNode);
|
|
12863
|
+
}, le.findHostInstanceWithWarning = function(e, n) {
|
|
12864
|
+
var o = e._reactInternals;
|
|
12865
|
+
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));
|
|
12866
|
+
if (e = mu(o), e === null) return null;
|
|
12867
|
+
if (e.mode & 8) {
|
|
12868
|
+
var i = G(o) || "Component";
|
|
12869
|
+
mb[i] || (mb[i] = true, B(e, function() {
|
|
12870
|
+
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);
|
|
12871
|
+
}));
|
|
13363
12872
|
}
|
|
13364
|
-
|
|
13365
|
-
|
|
13366
|
-
var
|
|
13367
|
-
|
|
12873
|
+
return ot(e.stateNode);
|
|
12874
|
+
}, le.flushPassiveEffects = el, le.flushSyncFromReconciler = function(e) {
|
|
12875
|
+
var n = ye;
|
|
12876
|
+
ye |= 1;
|
|
12877
|
+
var o = x.T, i = wt();
|
|
13368
12878
|
try {
|
|
13369
|
-
|
|
12879
|
+
if (an(2), x.T = null, e) return e();
|
|
13370
12880
|
} finally {
|
|
13371
|
-
x.
|
|
12881
|
+
an(i), x.T = o, ye = n, (ye & (Zn | uo)) === Jn && Wa(0);
|
|
13372
12882
|
}
|
|
13373
|
-
},
|
|
13374
|
-
|
|
13375
|
-
|
|
13376
|
-
|
|
13377
|
-
|
|
13378
|
-
|
|
13379
|
-
|
|
13380
|
-
|
|
13381
|
-
}
|
|
13382
|
-
|
|
12883
|
+
}, le.flushSyncWork = Ls, le.focusWithin = function(e, n) {
|
|
12884
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12885
|
+
for (e = Ef(e), n = hh(e, n), n = Array.from(n), e = 0; e < n.length; ) {
|
|
12886
|
+
var o = n[e++], i = o.tag;
|
|
12887
|
+
if (!Kr(o)) {
|
|
12888
|
+
if ((i === 5 || i === 26 || i === 27) && Ft(o.stateNode)) return true;
|
|
12889
|
+
for (o = o.child; o !== null; ) n.push(o), o = o.sibling;
|
|
12890
|
+
}
|
|
12891
|
+
}
|
|
12892
|
+
return false;
|
|
12893
|
+
}, le.getFindAllNodesFailureDescription = function(e, n) {
|
|
12894
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12895
|
+
var o = 0, i = [];
|
|
12896
|
+
e = [Ef(e), 0];
|
|
12897
|
+
for (var s = 0; s < e.length; ) {
|
|
12898
|
+
var u = e[s++], f = u.tag, p = e[s++], g = n[p];
|
|
12899
|
+
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;
|
|
12900
|
+
}
|
|
12901
|
+
if (o < n.length) {
|
|
12902
|
+
for (e = []; o < n.length; o++) e.push(Sc(n[o]));
|
|
12903
|
+
return `findAllNodes was able to match part of the selector:
|
|
12904
|
+
` + (i.join(" > ") + `
|
|
12905
|
+
|
|
12906
|
+
No matching component was found for:
|
|
12907
|
+
`) + e.join(" > ");
|
|
12908
|
+
}
|
|
12909
|
+
return null;
|
|
12910
|
+
}, le.getPublicRootInstance = function(e) {
|
|
12911
|
+
if (e = e.current, !e.child) return null;
|
|
12912
|
+
switch (e.child.tag) {
|
|
12913
|
+
case 27:
|
|
12914
|
+
case 5:
|
|
12915
|
+
return ot(e.child.stateNode);
|
|
12916
|
+
default:
|
|
12917
|
+
return e.child.stateNode;
|
|
12918
|
+
}
|
|
12919
|
+
}, le.injectIntoDevTools = function() {
|
|
12920
|
+
var e = { bundleType: 1, version: Jt, rendererPackageName: Zt, currentDispatcherRef: x, reconcilerVersion: "19.2.0" };
|
|
12921
|
+
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);
|
|
12922
|
+
}, le.isAlreadyRendering = Ns, le.observeVisibleRects = function(e, n, o, i) {
|
|
12923
|
+
function s() {
|
|
12924
|
+
var S = kc(e, n);
|
|
12925
|
+
u.forEach(function(T) {
|
|
12926
|
+
0 > S.indexOf(T) && g(T);
|
|
12927
|
+
}), S.forEach(function(T) {
|
|
12928
|
+
0 > u.indexOf(T) && p(T);
|
|
12929
|
+
});
|
|
12930
|
+
}
|
|
12931
|
+
if (!xr) throw Error("Test selector API is not supported by this renderer.");
|
|
12932
|
+
var u = kc(e, n);
|
|
12933
|
+
o = zr(u, o, i);
|
|
12934
|
+
var f = o.disconnect, p = o.observe, g = o.unobserve;
|
|
12935
|
+
return bm.push(s), { disconnect: function() {
|
|
12936
|
+
var S = bm.indexOf(s);
|
|
12937
|
+
0 <= S && bm.splice(S, 1), f();
|
|
12938
|
+
} };
|
|
12939
|
+
}, le.shouldError = function(e) {
|
|
12940
|
+
return pu(e);
|
|
12941
|
+
}, le.shouldSuspend = function(e) {
|
|
12942
|
+
return fu(e);
|
|
12943
|
+
}, le.startHostTransition = function(e, n, o, i) {
|
|
12944
|
+
if (e.tag !== 5) throw Error("Expected the form instance to be a HostComponent. This is a bug in React.");
|
|
12945
|
+
var s = uf(e).queue;
|
|
12946
|
+
Hp(e), nt(e, s, n, Xt, o === null ? Em : function() {
|
|
12947
|
+
x.T === null && console.error("requestFormReset was called outside a transition or action. To fix, move to an action, or wrap with startTransition.");
|
|
12948
|
+
var u = uf(e);
|
|
12949
|
+
return u.next === null && (u = e.alternate.memoizedState), qi(e, u.next.queue, {}, Nt(e)), o(i);
|
|
12950
|
+
});
|
|
12951
|
+
}, le.updateContainer = function(e, n, o, i) {
|
|
12952
|
+
var s = n.current, u = Nt(s);
|
|
12953
|
+
return As(s, u, e, n, o, i), u;
|
|
12954
|
+
}, le.updateContainerSync = Wh, le;
|
|
12955
|
+
}, Tt.exports.default = Tt.exports, Object.defineProperty(Tt.exports, "__esModule", { value: true }));
|
|
12956
|
+
})(Mg)), Mg.exports;
|
|
12957
|
+
}
|
|
12958
|
+
var Eb;
|
|
12959
|
+
function n0() {
|
|
12960
|
+
return Eb || (Eb = 1, process.env.NODE_ENV === "production" ? Rm.exports = Kb() : Rm.exports = e0()), Rm.exports;
|
|
12961
|
+
}
|
|
12962
|
+
var t0 = n0();
|
|
12963
|
+
const r0 = Xb(t0);
|
|
12964
|
+
|
|
12965
|
+
const DEFAULT_POINTER_ID = 0;
|
|
12966
|
+
const XR_POINTER_ID_START = 1e3;
|
|
12967
|
+
function getPointerState(internal, pointerId) {
|
|
12968
|
+
let state = internal.pointerMap.get(pointerId);
|
|
12969
|
+
if (!state) {
|
|
12970
|
+
state = {
|
|
12971
|
+
hovered: /* @__PURE__ */ new Map(),
|
|
12972
|
+
captured: /* @__PURE__ */ new Map(),
|
|
12973
|
+
initialClick: [0, 0],
|
|
12974
|
+
initialHits: []
|
|
12975
|
+
};
|
|
12976
|
+
internal.pointerMap.set(pointerId, state);
|
|
12977
|
+
}
|
|
12978
|
+
return state;
|
|
12979
|
+
}
|
|
12980
|
+
function getPointerId(event) {
|
|
12981
|
+
return "pointerId" in event ? event.pointerId : DEFAULT_POINTER_ID;
|
|
12982
|
+
}
|
|
12983
|
+
function makeId(event) {
|
|
12984
|
+
return (event.eventObject || event.object).uuid + "/" + event.index + event.instanceId;
|
|
12985
|
+
}
|
|
12986
|
+
function releaseInternalPointerCapture(internal, obj, pointerId) {
|
|
12987
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
12988
|
+
if (!pointerState) return;
|
|
12989
|
+
const captureData = pointerState.captured.get(obj);
|
|
12990
|
+
if (captureData) {
|
|
12991
|
+
pointerState.captured.delete(obj);
|
|
12992
|
+
try {
|
|
12993
|
+
captureData.target.releasePointerCapture?.(pointerId);
|
|
12994
|
+
} catch {
|
|
12995
|
+
}
|
|
12996
|
+
}
|
|
12997
|
+
}
|
|
12998
|
+
function swapInteractivity(store, object, newObject) {
|
|
12999
|
+
const { internal } = store.getState();
|
|
13000
|
+
for (let i = 0; i < internal.interaction.length; i++) {
|
|
13001
|
+
if (internal.interaction[i] === object) internal.interaction[i] = newObject;
|
|
13002
|
+
}
|
|
13003
|
+
for (const pointerState of internal.pointerMap.values()) {
|
|
13004
|
+
for (let i = 0; i < pointerState.initialHits.length; i++) {
|
|
13005
|
+
if (pointerState.initialHits[i] === object) pointerState.initialHits[i] = newObject;
|
|
13006
|
+
}
|
|
13007
|
+
pointerState.hovered.forEach((value, key) => {
|
|
13008
|
+
if (value.eventObject === object || value.object === object) {
|
|
13009
|
+
pointerState.hovered.delete(key);
|
|
13010
|
+
const next = {
|
|
13011
|
+
...value,
|
|
13012
|
+
eventObject: value.eventObject === object ? newObject : value.eventObject,
|
|
13013
|
+
object: value.object === object ? newObject : value.object
|
|
13014
|
+
};
|
|
13015
|
+
pointerState.hovered.set(makeId(next), next);
|
|
13016
|
+
}
|
|
13017
|
+
});
|
|
13018
|
+
const captureData = pointerState.captured.get(object);
|
|
13019
|
+
if (captureData) {
|
|
13020
|
+
pointerState.captured.delete(object);
|
|
13021
|
+
pointerState.captured.set(newObject, {
|
|
13022
|
+
...captureData,
|
|
13023
|
+
intersection: {
|
|
13024
|
+
...captureData.intersection,
|
|
13025
|
+
object: captureData.intersection.object === object ? newObject : captureData.intersection.object,
|
|
13026
|
+
eventObject: captureData.intersection.eventObject === object ? newObject : captureData.intersection.eventObject
|
|
13383
13027
|
}
|
|
13384
|
-
}
|
|
13385
|
-
|
|
13386
|
-
|
|
13387
|
-
|
|
13388
|
-
|
|
13389
|
-
|
|
13390
|
-
|
|
13391
|
-
|
|
13392
|
-
|
|
13393
|
-
|
|
13394
|
-
|
|
13395
|
-
|
|
13396
|
-
|
|
13397
|
-
return z = "useActionState", D(), N(), $t(e);
|
|
13398
|
-
}, useOptimistic: function(e, n) {
|
|
13399
|
-
return z = "useOptimistic", D(), N(), of(e, n);
|
|
13400
|
-
}, useMemoCache: function(e) {
|
|
13401
|
-
return D(), Oa(e);
|
|
13402
|
-
}, useHostTransitionStatus: ia, useCacheRefresh: function() {
|
|
13403
|
-
return z = "useCacheRefresh", N(), xe().memoizedState;
|
|
13404
|
-
}, useEffectEvent: function(e) {
|
|
13405
|
-
return z = "useEffectEvent", D(), N(), oa(e);
|
|
13406
|
-
} };
|
|
13407
|
-
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();
|
|
13408
|
-
Object.freeze(Fy);
|
|
13409
|
-
var zg = { enqueueSetState: function(e, n, o) {
|
|
13410
|
-
e = e._reactInternals;
|
|
13411
|
-
var i = Nt(e), s = zo(i);
|
|
13412
|
-
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));
|
|
13413
|
-
}, enqueueReplaceState: function(e, n, o) {
|
|
13414
|
-
e = e._reactInternals;
|
|
13415
|
-
var i = Nt(e), s = zo(i);
|
|
13416
|
-
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));
|
|
13417
|
-
}, enqueueForceUpdate: function(e, n) {
|
|
13418
|
-
e = e._reactInternals;
|
|
13419
|
-
var o = Nt(e), i = zo(o);
|
|
13420
|
-
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));
|
|
13421
|
-
} }, 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;
|
|
13422
|
-
Yy = /* @__PURE__ */ new Set();
|
|
13423
|
-
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) {
|
|
13424
|
-
var n = Ee(un), o = n.data.get(e);
|
|
13425
|
-
return o === void 0 && (o = e(), n.data.set(e, o)), o;
|
|
13426
|
-
}, cacheSignal: function() {
|
|
13427
|
-
return Ee(un).controller.signal;
|
|
13428
|
-
}, getOwner: function() {
|
|
13429
|
-
return di;
|
|
13430
|
-
} }, pm = 0, hm = 1, mm = 2, gm = 3, ym = 4;
|
|
13431
|
-
if (typeof Symbol == "function" && Symbol.for) {
|
|
13432
|
-
var bp = Symbol.for;
|
|
13433
|
-
pm = bp("selector.component"), hm = bp("selector.has_pseudo_class"), mm = bp("selector.role"), gm = bp("selector.test_id"), ym = bp("selector.text");
|
|
13028
|
+
});
|
|
13029
|
+
}
|
|
13030
|
+
}
|
|
13031
|
+
unregisterVisibility(store, object);
|
|
13032
|
+
}
|
|
13033
|
+
function removeInteractivity(store, object) {
|
|
13034
|
+
const { internal } = store.getState();
|
|
13035
|
+
internal.interaction = internal.interaction.filter((o) => o !== object);
|
|
13036
|
+
for (const [pointerId, pointerState] of internal.pointerMap) {
|
|
13037
|
+
pointerState.initialHits = pointerState.initialHits.filter((o) => o !== object);
|
|
13038
|
+
pointerState.hovered.forEach((value, key) => {
|
|
13039
|
+
if (value.eventObject === object || value.object === object) {
|
|
13040
|
+
pointerState.hovered.delete(key);
|
|
13434
13041
|
}
|
|
13435
|
-
|
|
13436
|
-
|
|
13437
|
-
|
|
13438
|
-
|
|
13439
|
-
|
|
13042
|
+
});
|
|
13043
|
+
if (pointerState.captured.has(object)) {
|
|
13044
|
+
releaseInternalPointerCapture(internal, object, pointerId);
|
|
13045
|
+
}
|
|
13046
|
+
}
|
|
13047
|
+
unregisterVisibility(store, object);
|
|
13048
|
+
}
|
|
13049
|
+
function createEvents(store) {
|
|
13050
|
+
function calculateDistance(event, pointerId) {
|
|
13051
|
+
const { internal } = store.getState();
|
|
13052
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13053
|
+
if (!pointerState) return 0;
|
|
13054
|
+
const [initialX, initialY] = pointerState.initialClick;
|
|
13055
|
+
const dx = event.offsetX - initialX;
|
|
13056
|
+
const dy = event.offsetY - initialY;
|
|
13057
|
+
return Math.round(Math.sqrt(dx * dx + dy * dy));
|
|
13058
|
+
}
|
|
13059
|
+
function filterPointerEvents(objects) {
|
|
13060
|
+
return objects.filter(
|
|
13061
|
+
(obj) => ["Move", "Over", "Enter", "Out", "Leave"].some(
|
|
13062
|
+
(name) => obj.__r3f?.handlers["onPointer" + name]
|
|
13063
|
+
) || ["OverEnter", "OverLeave", "Over"].some(
|
|
13064
|
+
(name) => obj.__r3f?.handlers["onDrag" + name]
|
|
13065
|
+
) || obj.__r3f?.handlers.onDrop
|
|
13066
|
+
);
|
|
13067
|
+
}
|
|
13068
|
+
function intersect(event, filter) {
|
|
13069
|
+
const state = store.getState();
|
|
13070
|
+
const duplicates = /* @__PURE__ */ new Set();
|
|
13071
|
+
const intersections = [];
|
|
13072
|
+
const eventsObjects = filter ? filter(state.internal.interaction) : state.internal.interaction;
|
|
13073
|
+
for (let i = 0; i < eventsObjects.length; i++) {
|
|
13074
|
+
const state2 = getRootState(eventsObjects[i]);
|
|
13075
|
+
if (state2) {
|
|
13076
|
+
state2.raycaster.camera = void 0;
|
|
13440
13077
|
}
|
|
13441
|
-
|
|
13442
|
-
|
|
13443
|
-
|
|
13444
|
-
|
|
13445
|
-
|
|
13446
|
-
|
|
13447
|
-
|
|
13448
|
-
|
|
13449
|
-
|
|
13450
|
-
|
|
13451
|
-
|
|
13452
|
-
|
|
13453
|
-
|
|
13454
|
-
|
|
13455
|
-
|
|
13456
|
-
|
|
13457
|
-
|
|
13458
|
-
|
|
13459
|
-
|
|
13460
|
-
|
|
13461
|
-
|
|
13462
|
-
|
|
13463
|
-
|
|
13464
|
-
}, le.attemptContinuousHydration = function(e) {
|
|
13465
|
-
if (e.tag === 13 || e.tag === 31) {
|
|
13466
|
-
var n = On(e, 67108864);
|
|
13467
|
-
n !== null && We(n, e, 67108864), rl(e, 67108864);
|
|
13078
|
+
}
|
|
13079
|
+
if (!state.previousRoot) {
|
|
13080
|
+
state.events.compute?.(event, state);
|
|
13081
|
+
}
|
|
13082
|
+
function handleRaycast(obj) {
|
|
13083
|
+
const state2 = getRootState(obj);
|
|
13084
|
+
if (!state2 || !state2.events.enabled || state2.raycaster.camera === null) return [];
|
|
13085
|
+
if (state2.raycaster.camera === void 0) {
|
|
13086
|
+
state2.events.compute?.(event, state2, state2.previousRoot?.getState());
|
|
13087
|
+
if (state2.raycaster.camera === void 0) state2.raycaster.camera = null;
|
|
13088
|
+
}
|
|
13089
|
+
if (!state2.raycaster.camera) return [];
|
|
13090
|
+
obj.updateWorldMatrix(true, true);
|
|
13091
|
+
return state2.raycaster.intersectObject(obj, true);
|
|
13092
|
+
}
|
|
13093
|
+
let hits = eventsObjects.flatMap(handleRaycast).sort((a, b) => {
|
|
13094
|
+
const aInteractivePriority = a.object.userData?.interactivePriority;
|
|
13095
|
+
const bInteractivePriority = b.object.userData?.interactivePriority;
|
|
13096
|
+
if (aInteractivePriority !== void 0 || bInteractivePriority !== void 0) {
|
|
13097
|
+
if (aInteractivePriority !== void 0 && bInteractivePriority === void 0) return -1;
|
|
13098
|
+
if (bInteractivePriority !== void 0 && aInteractivePriority === void 0) return 1;
|
|
13099
|
+
if (aInteractivePriority !== bInteractivePriority) {
|
|
13100
|
+
return (bInteractivePriority ?? 0) - (aInteractivePriority ?? 0);
|
|
13468
13101
|
}
|
|
13469
|
-
}
|
|
13470
|
-
|
|
13471
|
-
|
|
13472
|
-
|
|
13473
|
-
|
|
13474
|
-
|
|
13102
|
+
}
|
|
13103
|
+
const aState = getRootState(a.object);
|
|
13104
|
+
const bState = getRootState(b.object);
|
|
13105
|
+
const aPriority = aState?.events?.priority ?? 1;
|
|
13106
|
+
const bPriority = bState?.events?.priority ?? 1;
|
|
13107
|
+
return bPriority - aPriority || a.distance - b.distance;
|
|
13108
|
+
}).filter((item) => {
|
|
13109
|
+
const id = makeId(item);
|
|
13110
|
+
if (duplicates.has(id)) return false;
|
|
13111
|
+
duplicates.add(id);
|
|
13112
|
+
return true;
|
|
13113
|
+
});
|
|
13114
|
+
if (state.events.filter) hits = state.events.filter(hits, state);
|
|
13115
|
+
for (const hit of hits) {
|
|
13116
|
+
let eventObject = hit.object;
|
|
13117
|
+
while (eventObject) {
|
|
13118
|
+
if (eventObject.__r3f?.eventCount) {
|
|
13119
|
+
intersections.push({ ...hit, eventObject });
|
|
13475
13120
|
}
|
|
13476
|
-
|
|
13477
|
-
|
|
13478
|
-
|
|
13479
|
-
|
|
13480
|
-
|
|
13481
|
-
|
|
13482
|
-
|
|
13483
|
-
|
|
13484
|
-
|
|
13121
|
+
eventObject = eventObject.parent;
|
|
13122
|
+
}
|
|
13123
|
+
}
|
|
13124
|
+
if ("pointerId" in event) {
|
|
13125
|
+
const pointerId = event.pointerId;
|
|
13126
|
+
const pointerState = state.internal.pointerMap.get(pointerId);
|
|
13127
|
+
if (pointerState?.captured.size) {
|
|
13128
|
+
for (const captureData of pointerState.captured.values()) {
|
|
13129
|
+
if (!duplicates.has(makeId(captureData.intersection))) intersections.push(captureData.intersection);
|
|
13130
|
+
}
|
|
13131
|
+
}
|
|
13132
|
+
}
|
|
13133
|
+
return intersections;
|
|
13134
|
+
}
|
|
13135
|
+
function handleIntersects(intersections, event, delta, callback) {
|
|
13136
|
+
if (intersections.length) {
|
|
13137
|
+
const localState = { stopped: false };
|
|
13138
|
+
for (const hit of intersections) {
|
|
13139
|
+
const state = getRootState(hit.object);
|
|
13140
|
+
if (state) {
|
|
13141
|
+
const { raycaster, pointer, camera, internal } = state;
|
|
13142
|
+
const unprojectedPoint = new Vector3(pointer.x, pointer.y, 0).unproject(camera);
|
|
13143
|
+
const hasPointerCapture = (id) => {
|
|
13144
|
+
const pointerState = internal.pointerMap.get(id);
|
|
13145
|
+
return pointerState?.captured.has(hit.eventObject) ?? false;
|
|
13146
|
+
};
|
|
13147
|
+
const setPointerCapture = (id) => {
|
|
13148
|
+
const captureData = { intersection: hit, target: event.target };
|
|
13149
|
+
const pointerState = getPointerState(internal, id);
|
|
13150
|
+
pointerState.captured.set(hit.eventObject, captureData);
|
|
13151
|
+
event.target.setPointerCapture(id);
|
|
13152
|
+
};
|
|
13153
|
+
const releasePointerCapture = (id) => {
|
|
13154
|
+
releaseInternalPointerCapture(internal, hit.eventObject, id);
|
|
13155
|
+
};
|
|
13156
|
+
const extractEventProps = {};
|
|
13157
|
+
for (const prop in event) {
|
|
13158
|
+
const property = event[prop];
|
|
13159
|
+
if (typeof property !== "function") extractEventProps[prop] = property;
|
|
13160
|
+
}
|
|
13161
|
+
const eventPointerId = "pointerId" in event ? event.pointerId : void 0;
|
|
13162
|
+
const raycastEvent = {
|
|
13163
|
+
...hit,
|
|
13164
|
+
...extractEventProps,
|
|
13165
|
+
pointer,
|
|
13166
|
+
intersections,
|
|
13167
|
+
stopped: localState.stopped,
|
|
13168
|
+
delta,
|
|
13169
|
+
unprojectedPoint,
|
|
13170
|
+
ray: raycaster.ray,
|
|
13171
|
+
camera,
|
|
13172
|
+
pointerId: eventPointerId,
|
|
13173
|
+
// Hijack stopPropagation, which just sets a flag
|
|
13174
|
+
stopPropagation() {
|
|
13175
|
+
const pointerState = eventPointerId !== void 0 ? internal.pointerMap.get(eventPointerId) : void 0;
|
|
13176
|
+
if (
|
|
13177
|
+
// ...if this pointer hasn't been captured
|
|
13178
|
+
!pointerState?.captured.size || // ... or if the hit object is capturing the pointer
|
|
13179
|
+
pointerState.captured.has(hit.eventObject)
|
|
13180
|
+
) {
|
|
13181
|
+
raycastEvent.stopped = localState.stopped = true;
|
|
13182
|
+
if (pointerState?.hovered.size && Array.from(pointerState.hovered.values()).find((i) => i.eventObject === hit.eventObject)) {
|
|
13183
|
+
const higher = intersections.slice(0, intersections.indexOf(hit));
|
|
13184
|
+
cancelPointer([...higher, hit], eventPointerId);
|
|
13485
13185
|
}
|
|
13486
|
-
Kn(e), (ye & (Zn | uo)) === Jn && (Pp = me() + Fg, Wa(0));
|
|
13487
13186
|
}
|
|
13488
|
-
}
|
|
13489
|
-
|
|
13490
|
-
|
|
13491
|
-
|
|
13492
|
-
|
|
13187
|
+
},
|
|
13188
|
+
// there should be a distinction between target and currentTarget
|
|
13189
|
+
target: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
13190
|
+
currentTarget: { hasPointerCapture, setPointerCapture, releasePointerCapture },
|
|
13191
|
+
nativeEvent: event
|
|
13192
|
+
};
|
|
13193
|
+
callback(raycastEvent);
|
|
13194
|
+
if (localState.stopped === true) break;
|
|
13493
13195
|
}
|
|
13494
|
-
}
|
|
13495
|
-
|
|
13496
|
-
|
|
13497
|
-
|
|
13498
|
-
|
|
13499
|
-
|
|
13500
|
-
|
|
13501
|
-
|
|
13502
|
-
|
|
13503
|
-
|
|
13504
|
-
|
|
13505
|
-
|
|
13506
|
-
|
|
13507
|
-
|
|
13508
|
-
|
|
13509
|
-
|
|
13510
|
-
|
|
13196
|
+
}
|
|
13197
|
+
}
|
|
13198
|
+
return intersections;
|
|
13199
|
+
}
|
|
13200
|
+
function cancelPointer(intersections, pointerId) {
|
|
13201
|
+
const { internal } = store.getState();
|
|
13202
|
+
const pid = pointerId ?? DEFAULT_POINTER_ID;
|
|
13203
|
+
const pointerState = internal.pointerMap.get(pid);
|
|
13204
|
+
if (!pointerState) return;
|
|
13205
|
+
for (const [hoveredId, hoveredObj] of pointerState.hovered) {
|
|
13206
|
+
if (!intersections.length || !intersections.find(
|
|
13207
|
+
(hit) => hit.object === hoveredObj.object && hit.index === hoveredObj.index && hit.instanceId === hoveredObj.instanceId
|
|
13208
|
+
)) {
|
|
13209
|
+
const eventObject = hoveredObj.eventObject;
|
|
13210
|
+
const instance = eventObject.__r3f;
|
|
13211
|
+
pointerState.hovered.delete(hoveredId);
|
|
13212
|
+
if (instance?.eventCount) {
|
|
13213
|
+
const handlers = instance.handlers;
|
|
13214
|
+
const data = { ...hoveredObj, intersections };
|
|
13215
|
+
handlers.onPointerOut?.(data);
|
|
13216
|
+
handlers.onPointerLeave?.(data);
|
|
13217
|
+
handlers.onDragOverLeave?.(data);
|
|
13511
13218
|
}
|
|
13512
|
-
|
|
13513
|
-
|
|
13514
|
-
|
|
13515
|
-
|
|
13516
|
-
|
|
13517
|
-
|
|
13518
|
-
|
|
13519
|
-
|
|
13520
|
-
|
|
13521
|
-
|
|
13522
|
-
|
|
13523
|
-
|
|
13524
|
-
|
|
13525
|
-
|
|
13526
|
-
|
|
13527
|
-
|
|
13528
|
-
|
|
13529
|
-
|
|
13530
|
-
|
|
13531
|
-
|
|
13532
|
-
|
|
13533
|
-
|
|
13534
|
-
|
|
13535
|
-
|
|
13536
|
-
|
|
13537
|
-
|
|
13538
|
-
|
|
13539
|
-
|
|
13540
|
-
|
|
13541
|
-
|
|
13542
|
-
|
|
13543
|
-
|
|
13544
|
-
|
|
13545
|
-
an(o), x.T = n;
|
|
13219
|
+
}
|
|
13220
|
+
}
|
|
13221
|
+
}
|
|
13222
|
+
function pointerMissed(event, objects) {
|
|
13223
|
+
for (let i = 0; i < objects.length; i++) {
|
|
13224
|
+
const instance = objects[i].__r3f;
|
|
13225
|
+
instance?.handlers.onPointerMissed?.(event);
|
|
13226
|
+
}
|
|
13227
|
+
}
|
|
13228
|
+
function dragOverMissed(event, objects) {
|
|
13229
|
+
for (let i = 0; i < objects.length; i++) {
|
|
13230
|
+
const instance = objects[i].__r3f;
|
|
13231
|
+
instance?.handlers.onDragOverMissed?.(event);
|
|
13232
|
+
}
|
|
13233
|
+
}
|
|
13234
|
+
function dropMissed(event, objects) {
|
|
13235
|
+
for (let i = 0; i < objects.length; i++) {
|
|
13236
|
+
const instance = objects[i].__r3f;
|
|
13237
|
+
instance?.handlers.onDropMissed?.(event);
|
|
13238
|
+
}
|
|
13239
|
+
}
|
|
13240
|
+
function cleanupPointer(pointerId) {
|
|
13241
|
+
const { internal } = store.getState();
|
|
13242
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13243
|
+
if (pointerState) {
|
|
13244
|
+
for (const [, hoveredObj] of pointerState.hovered) {
|
|
13245
|
+
const eventObject = hoveredObj.eventObject;
|
|
13246
|
+
const instance = eventObject.__r3f;
|
|
13247
|
+
if (instance?.eventCount) {
|
|
13248
|
+
const handlers = instance.handlers;
|
|
13249
|
+
const data = { ...hoveredObj, intersections: [] };
|
|
13250
|
+
handlers.onPointerOut?.(data);
|
|
13251
|
+
handlers.onPointerLeave?.(data);
|
|
13546
13252
|
}
|
|
13547
|
-
}
|
|
13548
|
-
|
|
13549
|
-
|
|
13550
|
-
|
|
13551
|
-
|
|
13552
|
-
|
|
13253
|
+
}
|
|
13254
|
+
internal.pointerMap.delete(pointerId);
|
|
13255
|
+
}
|
|
13256
|
+
internal.pointerDirty.delete(pointerId);
|
|
13257
|
+
}
|
|
13258
|
+
function processDeferredPointer(event, pointerId) {
|
|
13259
|
+
const state = store.getState();
|
|
13260
|
+
const { internal } = state;
|
|
13261
|
+
if (!state.events.enabled) return;
|
|
13262
|
+
const filter = filterPointerEvents;
|
|
13263
|
+
const hits = intersect(event, filter);
|
|
13264
|
+
cancelPointer(hits, pointerId);
|
|
13265
|
+
function onIntersect(data) {
|
|
13266
|
+
const eventObject = data.eventObject;
|
|
13267
|
+
const instance = eventObject.__r3f;
|
|
13268
|
+
if (!instance?.eventCount) return;
|
|
13269
|
+
const handlers = instance.handlers;
|
|
13270
|
+
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
13271
|
+
const id = makeId(data);
|
|
13272
|
+
const pointerState = getPointerState(internal, pointerId);
|
|
13273
|
+
const hoveredItem = pointerState.hovered.get(id);
|
|
13274
|
+
if (!hoveredItem) {
|
|
13275
|
+
pointerState.hovered.set(id, data);
|
|
13276
|
+
handlers.onPointerOver?.(data);
|
|
13277
|
+
handlers.onPointerEnter?.(data);
|
|
13278
|
+
} else if (hoveredItem.stopped) {
|
|
13279
|
+
data.stopPropagation();
|
|
13553
13280
|
}
|
|
13554
|
-
}
|
|
13555
|
-
|
|
13556
|
-
|
|
13557
|
-
|
|
13558
|
-
|
|
13559
|
-
|
|
13560
|
-
|
|
13561
|
-
|
|
13562
|
-
|
|
13563
|
-
|
|
13564
|
-
|
|
13565
|
-
|
|
13566
|
-
|
|
13567
|
-
|
|
13568
|
-
|
|
13281
|
+
}
|
|
13282
|
+
handlers.onPointerMove?.(data);
|
|
13283
|
+
}
|
|
13284
|
+
handleIntersects(hits, event, 0, onIntersect);
|
|
13285
|
+
}
|
|
13286
|
+
function handlePointer(name) {
|
|
13287
|
+
switch (name) {
|
|
13288
|
+
case "onPointerLeave":
|
|
13289
|
+
case "onDragLeave":
|
|
13290
|
+
return () => cancelPointer([]);
|
|
13291
|
+
// Global cancel of these events
|
|
13292
|
+
case "onPointerCancel":
|
|
13293
|
+
return (event) => {
|
|
13294
|
+
const pointerId = getPointerId(event);
|
|
13295
|
+
cleanupPointer(pointerId);
|
|
13296
|
+
};
|
|
13297
|
+
case "onLostPointerCapture":
|
|
13298
|
+
return (event) => {
|
|
13299
|
+
const { internal } = store.getState();
|
|
13300
|
+
const pointerId = getPointerId(event);
|
|
13301
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13302
|
+
if (pointerState?.captured.size) {
|
|
13303
|
+
requestAnimationFrame(() => {
|
|
13304
|
+
const pointerState2 = internal.pointerMap.get(pointerId);
|
|
13305
|
+
if (pointerState2?.captured.size) {
|
|
13306
|
+
pointerState2.captured.clear();
|
|
13569
13307
|
}
|
|
13570
|
-
|
|
13571
|
-
|
|
13572
|
-
|
|
13308
|
+
cancelPointer([], pointerId);
|
|
13309
|
+
});
|
|
13310
|
+
}
|
|
13311
|
+
};
|
|
13312
|
+
}
|
|
13313
|
+
return function handleEvent(event) {
|
|
13314
|
+
const state = store.getState();
|
|
13315
|
+
const { onPointerMissed, onDragOverMissed, onDropMissed, internal, events } = state;
|
|
13316
|
+
const pointerId = getPointerId(event);
|
|
13317
|
+
internal.lastEvent.current = event;
|
|
13318
|
+
if (!events.enabled) return;
|
|
13319
|
+
const isPointerMove = name === "onPointerMove";
|
|
13320
|
+
const isDragOver = name === "onDragOver";
|
|
13321
|
+
const isDrop = name === "onDrop";
|
|
13322
|
+
const isClickEvent = name === "onClick" || name === "onContextMenu" || name === "onDoubleClick";
|
|
13323
|
+
const isPointerDown = name === "onPointerDown";
|
|
13324
|
+
const isPointerUp = name === "onPointerUp";
|
|
13325
|
+
const isWheel = name === "onWheel";
|
|
13326
|
+
const canDeferRaycasts = events.frameTimedRaycasts && state.frameloop === "always";
|
|
13327
|
+
if (isPointerMove && canDeferRaycasts) {
|
|
13328
|
+
events.compute?.(event, state);
|
|
13329
|
+
internal.pointerDirty.set(pointerId, event);
|
|
13330
|
+
return;
|
|
13331
|
+
}
|
|
13332
|
+
if (isWheel && canDeferRaycasts && !events.alwaysFireOnScroll) {
|
|
13333
|
+
events.compute?.(event, state);
|
|
13334
|
+
internal.pointerDirty.set(pointerId, event);
|
|
13335
|
+
return;
|
|
13336
|
+
}
|
|
13337
|
+
if ((isClickEvent || isPointerDown || isPointerUp) && internal.pointerDirty.has(pointerId)) {
|
|
13338
|
+
const deferredEvent = internal.pointerDirty.get(pointerId);
|
|
13339
|
+
internal.pointerDirty.delete(pointerId);
|
|
13340
|
+
processDeferredPointer(deferredEvent, pointerId);
|
|
13341
|
+
}
|
|
13342
|
+
const filter = isPointerMove || isDragOver || isDrop ? filterPointerEvents : void 0;
|
|
13343
|
+
const hits = intersect(event, filter);
|
|
13344
|
+
const delta = isClickEvent ? calculateDistance(event, pointerId) : 0;
|
|
13345
|
+
if (isPointerDown) {
|
|
13346
|
+
const pointerState2 = getPointerState(internal, pointerId);
|
|
13347
|
+
pointerState2.initialClick = [event.offsetX, event.offsetY];
|
|
13348
|
+
pointerState2.initialHits = hits.map((hit) => hit.eventObject);
|
|
13349
|
+
}
|
|
13350
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13351
|
+
const initialHits = pointerState?.initialHits ?? [];
|
|
13352
|
+
if (isClickEvent && !hits.length) {
|
|
13353
|
+
if (delta <= 2) {
|
|
13354
|
+
pointerMissed(event, internal.interaction);
|
|
13355
|
+
if (onPointerMissed) onPointerMissed(event);
|
|
13356
|
+
}
|
|
13357
|
+
}
|
|
13358
|
+
if (isDragOver && !hits.length) {
|
|
13359
|
+
dragOverMissed(event, internal.interaction);
|
|
13360
|
+
if (onDragOverMissed) onDragOverMissed(event);
|
|
13361
|
+
}
|
|
13362
|
+
if (isDrop && !hits.length) {
|
|
13363
|
+
dropMissed(event, internal.interaction);
|
|
13364
|
+
if (onDropMissed) onDropMissed(event);
|
|
13365
|
+
}
|
|
13366
|
+
if (isPointerMove || isDragOver) {
|
|
13367
|
+
cancelPointer(hits, pointerId);
|
|
13368
|
+
}
|
|
13369
|
+
function onIntersect(data) {
|
|
13370
|
+
const eventObject = data.eventObject;
|
|
13371
|
+
const instance = eventObject.__r3f;
|
|
13372
|
+
if (!instance?.eventCount) return;
|
|
13373
|
+
const handlers = instance.handlers;
|
|
13374
|
+
if (isPointerMove) {
|
|
13375
|
+
if (handlers.onPointerOver || handlers.onPointerEnter || handlers.onPointerOut || handlers.onPointerLeave) {
|
|
13376
|
+
const id = makeId(data);
|
|
13377
|
+
const pointerState2 = getPointerState(internal, pointerId);
|
|
13378
|
+
const hoveredItem = pointerState2.hovered.get(id);
|
|
13379
|
+
if (!hoveredItem) {
|
|
13380
|
+
pointerState2.hovered.set(id, data);
|
|
13381
|
+
handlers.onPointerOver?.(data);
|
|
13382
|
+
handlers.onPointerEnter?.(data);
|
|
13383
|
+
} else if (hoveredItem.stopped) {
|
|
13384
|
+
data.stopPropagation();
|
|
13573
13385
|
}
|
|
13574
13386
|
}
|
|
13575
|
-
|
|
13576
|
-
|
|
13577
|
-
|
|
13578
|
-
|
|
13579
|
-
|
|
13580
|
-
|
|
13581
|
-
|
|
13582
|
-
|
|
13583
|
-
|
|
13584
|
-
|
|
13585
|
-
|
|
13586
|
-
|
|
13587
|
-
if (
|
|
13588
|
-
|
|
13589
|
-
|
|
13590
|
-
|
|
13591
|
-
|
|
13592
|
-
|
|
13593
|
-
|
|
13594
|
-
|
|
13595
|
-
|
|
13596
|
-
|
|
13597
|
-
|
|
13598
|
-
|
|
13599
|
-
|
|
13600
|
-
|
|
13601
|
-
|
|
13602
|
-
|
|
13603
|
-
|
|
13604
|
-
|
|
13605
|
-
|
|
13606
|
-
var o = n[e++], i = o.tag;
|
|
13607
|
-
if (!Kr(o)) {
|
|
13608
|
-
if ((i === 5 || i === 26 || i === 27) && Ft(o.stateNode)) return true;
|
|
13609
|
-
for (o = o.child; o !== null; ) n.push(o), o = o.sibling;
|
|
13387
|
+
handlers.onPointerMove?.(data);
|
|
13388
|
+
} else if (isDragOver) {
|
|
13389
|
+
const id = makeId(data);
|
|
13390
|
+
const pointerState2 = getPointerState(internal, pointerId);
|
|
13391
|
+
const hoveredItem = pointerState2.hovered.get(id);
|
|
13392
|
+
if (!hoveredItem) {
|
|
13393
|
+
pointerState2.hovered.set(id, data);
|
|
13394
|
+
handlers.onDragOverEnter?.(data);
|
|
13395
|
+
} else if (hoveredItem.stopped) {
|
|
13396
|
+
data.stopPropagation();
|
|
13397
|
+
}
|
|
13398
|
+
handlers.onDragOver?.(data);
|
|
13399
|
+
} else if (isDrop) {
|
|
13400
|
+
handlers.onDrop?.(data);
|
|
13401
|
+
} else {
|
|
13402
|
+
const handler = handlers[name];
|
|
13403
|
+
if (handler) {
|
|
13404
|
+
if (!isClickEvent || initialHits.includes(eventObject)) {
|
|
13405
|
+
pointerMissed(
|
|
13406
|
+
event,
|
|
13407
|
+
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
13408
|
+
);
|
|
13409
|
+
handler(data);
|
|
13410
|
+
}
|
|
13411
|
+
} else {
|
|
13412
|
+
if (isClickEvent && initialHits.includes(eventObject)) {
|
|
13413
|
+
pointerMissed(
|
|
13414
|
+
event,
|
|
13415
|
+
internal.interaction.filter((object) => !initialHits.includes(object))
|
|
13416
|
+
);
|
|
13417
|
+
}
|
|
13610
13418
|
}
|
|
13611
13419
|
}
|
|
13612
|
-
|
|
13613
|
-
|
|
13614
|
-
|
|
13615
|
-
|
|
13616
|
-
|
|
13617
|
-
|
|
13618
|
-
|
|
13619
|
-
|
|
13420
|
+
}
|
|
13421
|
+
handleIntersects(hits, event, delta, onIntersect);
|
|
13422
|
+
};
|
|
13423
|
+
}
|
|
13424
|
+
function flushDeferredPointers() {
|
|
13425
|
+
const { internal, events } = store.getState();
|
|
13426
|
+
if (!events.frameTimedRaycasts) return;
|
|
13427
|
+
for (const [pointerId, event] of internal.pointerDirty) {
|
|
13428
|
+
processDeferredPointer(event, pointerId);
|
|
13429
|
+
}
|
|
13430
|
+
internal.pointerDirty.clear();
|
|
13431
|
+
}
|
|
13432
|
+
return { handlePointer, flushDeferredPointers, processDeferredPointer };
|
|
13433
|
+
}
|
|
13434
|
+
const DOM_EVENTS = {
|
|
13435
|
+
onClick: ["click", false],
|
|
13436
|
+
onContextMenu: ["contextmenu", false],
|
|
13437
|
+
onDoubleClick: ["dblclick", false],
|
|
13438
|
+
onDragEnter: ["dragenter", false],
|
|
13439
|
+
onDragLeave: ["dragleave", false],
|
|
13440
|
+
onDragOver: ["dragover", false],
|
|
13441
|
+
onDrop: ["drop", false],
|
|
13442
|
+
onWheel: ["wheel", true],
|
|
13443
|
+
onPointerDown: ["pointerdown", true],
|
|
13444
|
+
onPointerUp: ["pointerup", true],
|
|
13445
|
+
onPointerLeave: ["pointerleave", true],
|
|
13446
|
+
onPointerMove: ["pointermove", true],
|
|
13447
|
+
onPointerCancel: ["pointercancel", true],
|
|
13448
|
+
onLostPointerCapture: ["lostpointercapture", true]
|
|
13449
|
+
};
|
|
13450
|
+
function createPointerEvents(store) {
|
|
13451
|
+
const { handlePointer, flushDeferredPointers, processDeferredPointer } = createEvents(store);
|
|
13452
|
+
let nextXRPointerId = XR_POINTER_ID_START;
|
|
13453
|
+
const xrPointers = /* @__PURE__ */ new Map();
|
|
13454
|
+
return {
|
|
13455
|
+
priority: 1,
|
|
13456
|
+
enabled: true,
|
|
13457
|
+
frameTimedRaycasts: true,
|
|
13458
|
+
alwaysFireOnScroll: true,
|
|
13459
|
+
updateOnFrame: false,
|
|
13460
|
+
compute(event, state) {
|
|
13461
|
+
state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
|
|
13462
|
+
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
13463
|
+
},
|
|
13464
|
+
connected: void 0,
|
|
13465
|
+
handlers: Object.keys(DOM_EVENTS).reduce(
|
|
13466
|
+
(acc, key) => ({ ...acc, [key]: handlePointer(key) }),
|
|
13467
|
+
{}
|
|
13468
|
+
),
|
|
13469
|
+
update: (pointerId) => {
|
|
13470
|
+
const { events, internal } = store.getState();
|
|
13471
|
+
if (!events.handlers) return;
|
|
13472
|
+
if (pointerId !== void 0) {
|
|
13473
|
+
const event = internal.pointerDirty.get(pointerId);
|
|
13474
|
+
if (event) {
|
|
13475
|
+
internal.pointerDirty.delete(pointerId);
|
|
13476
|
+
processDeferredPointer(event, pointerId);
|
|
13477
|
+
} else if (internal.lastEvent?.current) {
|
|
13478
|
+
processDeferredPointer(internal.lastEvent.current, pointerId);
|
|
13620
13479
|
}
|
|
13621
|
-
|
|
13622
|
-
|
|
13623
|
-
|
|
13624
|
-
|
|
13625
|
-
|
|
13626
|
-
No matching component was found for:
|
|
13627
|
-
`) + e.join(" > ");
|
|
13480
|
+
} else {
|
|
13481
|
+
flushDeferredPointers();
|
|
13482
|
+
if (internal.lastEvent?.current) {
|
|
13483
|
+
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
13628
13484
|
}
|
|
13629
|
-
|
|
13630
|
-
|
|
13631
|
-
|
|
13632
|
-
|
|
13633
|
-
|
|
13634
|
-
|
|
13635
|
-
|
|
13636
|
-
|
|
13637
|
-
|
|
13485
|
+
}
|
|
13486
|
+
},
|
|
13487
|
+
flush: () => {
|
|
13488
|
+
const { events, internal } = store.getState();
|
|
13489
|
+
flushDeferredPointers();
|
|
13490
|
+
if (events.updateOnFrame && internal.lastEvent?.current && events.handlers) {
|
|
13491
|
+
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
13492
|
+
}
|
|
13493
|
+
},
|
|
13494
|
+
connect: (target) => {
|
|
13495
|
+
if (!target) return;
|
|
13496
|
+
const { set, events } = store.getState();
|
|
13497
|
+
events.disconnect?.();
|
|
13498
|
+
set((state) => ({ events: { ...state.events, connected: target } }));
|
|
13499
|
+
if (events.handlers) {
|
|
13500
|
+
for (const name in events.handlers) {
|
|
13501
|
+
const event = events.handlers[name];
|
|
13502
|
+
const [eventName, passive] = DOM_EVENTS[name];
|
|
13503
|
+
target.addEventListener(eventName, event, { passive });
|
|
13638
13504
|
}
|
|
13639
|
-
}
|
|
13640
|
-
|
|
13641
|
-
|
|
13642
|
-
|
|
13643
|
-
|
|
13644
|
-
|
|
13645
|
-
|
|
13646
|
-
|
|
13647
|
-
|
|
13648
|
-
|
|
13649
|
-
}
|
|
13505
|
+
}
|
|
13506
|
+
},
|
|
13507
|
+
disconnect: () => {
|
|
13508
|
+
const { set, events } = store.getState();
|
|
13509
|
+
if (events.connected) {
|
|
13510
|
+
if (events.handlers) {
|
|
13511
|
+
for (const name in events.handlers) {
|
|
13512
|
+
const event = events.handlers[name];
|
|
13513
|
+
const [eventName] = DOM_EVENTS[name];
|
|
13514
|
+
events.connected.removeEventListener(eventName, event);
|
|
13515
|
+
}
|
|
13650
13516
|
}
|
|
13651
|
-
|
|
13652
|
-
|
|
13653
|
-
|
|
13654
|
-
|
|
13655
|
-
|
|
13656
|
-
|
|
13657
|
-
|
|
13658
|
-
|
|
13659
|
-
|
|
13660
|
-
|
|
13661
|
-
|
|
13662
|
-
|
|
13663
|
-
|
|
13664
|
-
|
|
13665
|
-
|
|
13666
|
-
|
|
13667
|
-
|
|
13668
|
-
|
|
13669
|
-
|
|
13670
|
-
|
|
13671
|
-
|
|
13672
|
-
|
|
13673
|
-
|
|
13674
|
-
|
|
13675
|
-
|
|
13676
|
-
|
|
13677
|
-
|
|
13678
|
-
|
|
13679
|
-
|
|
13680
|
-
|
|
13517
|
+
set((state) => ({ events: { ...state.events, connected: void 0 } }));
|
|
13518
|
+
}
|
|
13519
|
+
},
|
|
13520
|
+
// PREVIEW (A8): the XR pointer registration API may change before stable.
|
|
13521
|
+
registerPointer: (config) => {
|
|
13522
|
+
const pointerId = nextXRPointerId++;
|
|
13523
|
+
xrPointers.set(pointerId, config);
|
|
13524
|
+
const { internal } = store.getState();
|
|
13525
|
+
getPointerState(internal, pointerId);
|
|
13526
|
+
return pointerId;
|
|
13527
|
+
},
|
|
13528
|
+
unregisterPointer: (pointerId) => {
|
|
13529
|
+
xrPointers.delete(pointerId);
|
|
13530
|
+
const { internal } = store.getState();
|
|
13531
|
+
const pointerState = internal.pointerMap.get(pointerId);
|
|
13532
|
+
if (pointerState) {
|
|
13533
|
+
for (const [, hoveredObj] of pointerState.hovered) {
|
|
13534
|
+
const eventObject = hoveredObj.eventObject;
|
|
13535
|
+
const instance = eventObject.__r3f;
|
|
13536
|
+
if (instance?.eventCount) {
|
|
13537
|
+
const handlers = instance.handlers;
|
|
13538
|
+
const data = { ...hoveredObj, intersections: [] };
|
|
13539
|
+
handlers.onPointerOut?.(data);
|
|
13540
|
+
handlers.onPointerLeave?.(data);
|
|
13541
|
+
}
|
|
13542
|
+
}
|
|
13543
|
+
internal.pointerMap.delete(pointerId);
|
|
13544
|
+
}
|
|
13545
|
+
internal.pointerDirty.delete(pointerId);
|
|
13546
|
+
}
|
|
13547
|
+
};
|
|
13681
13548
|
}
|
|
13682
|
-
var t0 = n0();
|
|
13683
|
-
const r0 = Xb(t0);
|
|
13684
|
-
|
|
13685
|
-
const t = 1, o = 8, r = 32, e = 2;
|
|
13686
13549
|
|
|
13687
13550
|
function createReconciler(config) {
|
|
13688
13551
|
const reconciler2 = r0(config);
|
|
@@ -13702,7 +13565,10 @@ function extend(objects) {
|
|
|
13702
13565
|
catalogue[Component] = objects;
|
|
13703
13566
|
return Component;
|
|
13704
13567
|
} else {
|
|
13705
|
-
|
|
13568
|
+
for (const name in objects) {
|
|
13569
|
+
const object = objects[name];
|
|
13570
|
+
if (isConstructor(object)) catalogue[name] = object;
|
|
13571
|
+
}
|
|
13706
13572
|
}
|
|
13707
13573
|
}
|
|
13708
13574
|
function validateInstance(type, props) {
|
|
@@ -13847,7 +13713,15 @@ function setFiberRef(fiber, publicInstance) {
|
|
|
13847
13713
|
}
|
|
13848
13714
|
}
|
|
13849
13715
|
const reconstructed = [];
|
|
13850
|
-
function
|
|
13716
|
+
function flushReconstructedInstances() {
|
|
13717
|
+
if (reconstructed.length === 0) return;
|
|
13718
|
+
try {
|
|
13719
|
+
swapReconstructedInstances();
|
|
13720
|
+
} finally {
|
|
13721
|
+
reconstructed.length = 0;
|
|
13722
|
+
}
|
|
13723
|
+
}
|
|
13724
|
+
function swapReconstructedInstances() {
|
|
13851
13725
|
for (const [instance] of reconstructed) {
|
|
13852
13726
|
const parent = instance.parent;
|
|
13853
13727
|
if (parent) {
|
|
@@ -13865,7 +13739,9 @@ function swapInstances() {
|
|
|
13865
13739
|
}
|
|
13866
13740
|
}
|
|
13867
13741
|
if (instance.isHidden) unhideInstance(instance);
|
|
13868
|
-
if (isObject3D(instance.object)
|
|
13742
|
+
if (isObject3D(instance.object) && !instance.parent) {
|
|
13743
|
+
removeInteractivity(findInitialRoot(instance), instance.object);
|
|
13744
|
+
}
|
|
13869
13745
|
if (instance.object.__r3f) delete instance.object.__r3f;
|
|
13870
13746
|
if (instance.type !== "primitive") disposeOnIdle(instance.object);
|
|
13871
13747
|
}
|
|
@@ -13874,9 +13750,13 @@ function swapInstances() {
|
|
|
13874
13750
|
const parent = instance.parent;
|
|
13875
13751
|
if (parent) {
|
|
13876
13752
|
const target = catalogue[toPascalCase(instance.type)];
|
|
13753
|
+
const prevObject = instance.object;
|
|
13877
13754
|
instance.object = instance.props.object ?? new target(...instance.props.args ?? []);
|
|
13878
13755
|
instance.object.__r3f = instance;
|
|
13879
13756
|
setFiberRef(fiber, instance.object);
|
|
13757
|
+
if (isObject3D(prevObject) && isObject3D(instance.object)) {
|
|
13758
|
+
swapInteractivity(findInitialRoot(instance), prevObject, instance.object);
|
|
13759
|
+
}
|
|
13880
13760
|
delete instance.appliedOnce;
|
|
13881
13761
|
instance.eventCount = 0;
|
|
13882
13762
|
instance.handlers = {};
|
|
@@ -13896,14 +13776,114 @@ function swapInstances() {
|
|
|
13896
13776
|
invalidateInstance(instance);
|
|
13897
13777
|
}
|
|
13898
13778
|
}
|
|
13899
|
-
reconstructed.length = 0;
|
|
13900
13779
|
}
|
|
13901
13780
|
const handleTextInstance = () => {
|
|
13902
13781
|
};
|
|
13903
13782
|
const NO_CONTEXT = {};
|
|
13904
13783
|
let currentUpdatePriority = NoEventPriority;
|
|
13905
|
-
|
|
13906
|
-
|
|
13784
|
+
function getEventPriority(type) {
|
|
13785
|
+
switch (type) {
|
|
13786
|
+
case "beforetoggle":
|
|
13787
|
+
case "cancel":
|
|
13788
|
+
case "click":
|
|
13789
|
+
case "close":
|
|
13790
|
+
case "contextmenu":
|
|
13791
|
+
case "copy":
|
|
13792
|
+
case "cut":
|
|
13793
|
+
case "auxclick":
|
|
13794
|
+
case "dblclick":
|
|
13795
|
+
case "dragend":
|
|
13796
|
+
case "dragstart":
|
|
13797
|
+
case "drop":
|
|
13798
|
+
case "focusin":
|
|
13799
|
+
case "focusout":
|
|
13800
|
+
case "input":
|
|
13801
|
+
case "invalid":
|
|
13802
|
+
case "keydown":
|
|
13803
|
+
case "keypress":
|
|
13804
|
+
case "keyup":
|
|
13805
|
+
case "mousedown":
|
|
13806
|
+
case "mouseup":
|
|
13807
|
+
case "paste":
|
|
13808
|
+
case "pause":
|
|
13809
|
+
case "play":
|
|
13810
|
+
case "pointercancel":
|
|
13811
|
+
case "pointerdown":
|
|
13812
|
+
case "pointerup":
|
|
13813
|
+
case "ratechange":
|
|
13814
|
+
case "reset":
|
|
13815
|
+
case "resize":
|
|
13816
|
+
case "seeked":
|
|
13817
|
+
case "submit":
|
|
13818
|
+
case "touchcancel":
|
|
13819
|
+
case "touchend":
|
|
13820
|
+
case "touchstart":
|
|
13821
|
+
case "volumechange":
|
|
13822
|
+
case "change":
|
|
13823
|
+
case "selectionchange":
|
|
13824
|
+
case "compositionstart":
|
|
13825
|
+
case "compositionend":
|
|
13826
|
+
case "compositionupdate":
|
|
13827
|
+
case "beforeinput":
|
|
13828
|
+
case "blur":
|
|
13829
|
+
case "fullscreenchange":
|
|
13830
|
+
case "focus":
|
|
13831
|
+
case "hashchange":
|
|
13832
|
+
case "popstate":
|
|
13833
|
+
case "select":
|
|
13834
|
+
case "selectstart":
|
|
13835
|
+
return e;
|
|
13836
|
+
case "drag":
|
|
13837
|
+
case "dragenter":
|
|
13838
|
+
case "dragexit":
|
|
13839
|
+
case "dragleave":
|
|
13840
|
+
case "dragover":
|
|
13841
|
+
case "mousemove":
|
|
13842
|
+
case "mouseout":
|
|
13843
|
+
case "mouseover":
|
|
13844
|
+
case "pointermove":
|
|
13845
|
+
case "pointerout":
|
|
13846
|
+
case "pointerover":
|
|
13847
|
+
case "scroll":
|
|
13848
|
+
case "touchmove":
|
|
13849
|
+
case "wheel":
|
|
13850
|
+
case "mouseenter":
|
|
13851
|
+
case "mouseleave":
|
|
13852
|
+
case "pointerenter":
|
|
13853
|
+
case "pointerleave":
|
|
13854
|
+
return o;
|
|
13855
|
+
case "message": {
|
|
13856
|
+
switch (unstable_getCurrentPriorityLevel()) {
|
|
13857
|
+
case unstable_ImmediatePriority:
|
|
13858
|
+
return e;
|
|
13859
|
+
case unstable_UserBlockingPriority:
|
|
13860
|
+
return o;
|
|
13861
|
+
case unstable_NormalPriority:
|
|
13862
|
+
case unstable_LowPriority:
|
|
13863
|
+
return r;
|
|
13864
|
+
case unstable_IdlePriority:
|
|
13865
|
+
return i$1;
|
|
13866
|
+
default:
|
|
13867
|
+
return r;
|
|
13868
|
+
}
|
|
13869
|
+
}
|
|
13870
|
+
default:
|
|
13871
|
+
return r;
|
|
13872
|
+
}
|
|
13873
|
+
}
|
|
13874
|
+
function scheduleMicrotask(callback) {
|
|
13875
|
+
if (typeof queueMicrotask === "function") {
|
|
13876
|
+
queueMicrotask(callback);
|
|
13877
|
+
} else if (typeof Promise !== "undefined") {
|
|
13878
|
+
Promise.resolve().then(callback).catch((error) => {
|
|
13879
|
+
setTimeout(() => {
|
|
13880
|
+
throw error;
|
|
13881
|
+
});
|
|
13882
|
+
});
|
|
13883
|
+
} else {
|
|
13884
|
+
setTimeout(callback);
|
|
13885
|
+
}
|
|
13886
|
+
}
|
|
13907
13887
|
const reconciler = /* @__PURE__ */ createReconciler({
|
|
13908
13888
|
isPrimaryRenderer: false,
|
|
13909
13889
|
warnsIfNotActing: false,
|
|
@@ -13936,22 +13916,21 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13936
13916
|
getRootHostContext: () => NO_CONTEXT,
|
|
13937
13917
|
getChildHostContext: () => NO_CONTEXT,
|
|
13938
13918
|
commitUpdate(instance, type, oldProps, newProps, fiber) {
|
|
13939
|
-
validateInstance(type, newProps);
|
|
13919
|
+
validateInstance(instance.type, newProps);
|
|
13940
13920
|
let reconstruct = false;
|
|
13941
13921
|
if (instance.type === "primitive" && oldProps.object !== newProps.object) reconstruct = true;
|
|
13942
13922
|
else if (newProps.args?.length !== oldProps.args?.length) reconstruct = true;
|
|
13943
13923
|
else if (newProps.args?.some((value, index) => value !== oldProps.args?.[index])) reconstruct = true;
|
|
13944
13924
|
if (reconstruct) {
|
|
13945
|
-
reconstructed.push([instance,
|
|
13925
|
+
reconstructed.push([instance, getInstanceProps(newProps), fiber]);
|
|
13946
13926
|
} else {
|
|
13947
13927
|
const changedProps = diffProps(instance, newProps);
|
|
13948
|
-
|
|
13949
|
-
|
|
13950
|
-
|
|
13951
|
-
|
|
13928
|
+
const attach2 = instance.props.attach;
|
|
13929
|
+
instance.props = getInstanceProps(newProps);
|
|
13930
|
+
if (attach2 !== void 0) instance.props.attach = attach2;
|
|
13931
|
+
else delete instance.props.attach;
|
|
13932
|
+
if (Object.keys(changedProps).length) applyProps(instance.object, changedProps);
|
|
13952
13933
|
}
|
|
13953
|
-
const isTailSibling = fiber.sibling === null || (fiber.flags & Update) === NoFlags;
|
|
13954
|
-
if (isTailSibling) swapInstances();
|
|
13955
13934
|
},
|
|
13956
13935
|
finalizeInitialChildren: (instance) => {
|
|
13957
13936
|
for (const prop in instance.props) {
|
|
@@ -13964,8 +13943,8 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13964
13943
|
for (const prop in instance.props) {
|
|
13965
13944
|
const value = instance.props[prop];
|
|
13966
13945
|
if (isFromRef(value)) {
|
|
13967
|
-
const ref = value
|
|
13968
|
-
if (ref.current != null) resolved[prop] = ref.current;
|
|
13946
|
+
const { [FROM_REF]: ref, transform } = value;
|
|
13947
|
+
if (ref.current != null) resolved[prop] = transform ? transform(ref.current) : ref.current;
|
|
13969
13948
|
}
|
|
13970
13949
|
}
|
|
13971
13950
|
if (Object.keys(resolved).length) applyProps(instance.object, resolved);
|
|
@@ -13976,8 +13955,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13976
13955
|
const target = container.getState().internal.container ?? container.getState().scene;
|
|
13977
13956
|
return prepare(target, container, "", {});
|
|
13978
13957
|
},
|
|
13979
|
-
|
|
13980
|
-
|
|
13958
|
+
// Reconstructed instances are swapped once all mutations are committed,
|
|
13959
|
+
// before layout effects run so refs point to the new objects
|
|
13960
|
+
resetAfterCommit: flushReconstructedInstances,
|
|
13981
13961
|
shouldSetTextContent: () => false,
|
|
13982
13962
|
clearContainer: () => false,
|
|
13983
13963
|
hideInstance,
|
|
@@ -13985,6 +13965,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
13985
13965
|
createTextInstance: handleTextInstance,
|
|
13986
13966
|
hideTextInstance: handleTextInstance,
|
|
13987
13967
|
unhideTextInstance: handleTextInstance,
|
|
13968
|
+
// Mirrors react-dom, which flushes discrete work in microtasks
|
|
13969
|
+
supportsMicrotasks: true,
|
|
13970
|
+
scheduleMicrotask,
|
|
13988
13971
|
scheduleTimeout: typeof setTimeout === "function" ? setTimeout : void 0,
|
|
13989
13972
|
cancelTimeout: typeof clearTimeout === "function" ? clearTimeout : void 0,
|
|
13990
13973
|
noTimeout: -1,
|
|
@@ -14025,28 +14008,9 @@ const reconciler = /* @__PURE__ */ createReconciler({
|
|
|
14025
14008
|
},
|
|
14026
14009
|
resolveUpdatePriority() {
|
|
14027
14010
|
if (currentUpdatePriority !== NoEventPriority) return currentUpdatePriority;
|
|
14028
|
-
|
|
14029
|
-
|
|
14030
|
-
|
|
14031
|
-
case "dblclick":
|
|
14032
|
-
case "dragenter":
|
|
14033
|
-
case "dragleave":
|
|
14034
|
-
case "drop":
|
|
14035
|
-
case "pointercancel":
|
|
14036
|
-
case "pointerdown":
|
|
14037
|
-
case "pointerup":
|
|
14038
|
-
return e;
|
|
14039
|
-
case "dragover":
|
|
14040
|
-
case "pointermove":
|
|
14041
|
-
case "pointerout":
|
|
14042
|
-
case "pointerover":
|
|
14043
|
-
case "pointerenter":
|
|
14044
|
-
case "pointerleave":
|
|
14045
|
-
case "wheel":
|
|
14046
|
-
return o;
|
|
14047
|
-
default:
|
|
14048
|
-
return r;
|
|
14049
|
-
}
|
|
14011
|
+
const eventType = typeof window !== "undefined" ? window.event?.type : void 0;
|
|
14012
|
+
if (eventType === void 0) return r;
|
|
14013
|
+
return getEventPriority(eventType);
|
|
14050
14014
|
},
|
|
14051
14015
|
resetFormInstance() {
|
|
14052
14016
|
},
|
|
@@ -14357,7 +14321,7 @@ function createRoot(canvas) {
|
|
|
14357
14321
|
const handleXRFrame = (timestamp, _frame) => {
|
|
14358
14322
|
const state2 = store.getState();
|
|
14359
14323
|
if (state2.frameloop === "never") return;
|
|
14360
|
-
advance(timestamp);
|
|
14324
|
+
advance(timestamp, true, state2);
|
|
14361
14325
|
};
|
|
14362
14326
|
const actualRenderer = state.internal.actualRenderer;
|
|
14363
14327
|
const handleSessionChange = () => {
|
|
@@ -14365,7 +14329,7 @@ function createRoot(canvas) {
|
|
|
14365
14329
|
const renderer2 = state2.internal.actualRenderer;
|
|
14366
14330
|
actualRenderer.xr.enabled = actualRenderer.xr.isPresenting;
|
|
14367
14331
|
renderer2.xr.setAnimationLoop(renderer2.xr.isPresenting ? handleXRFrame : null);
|
|
14368
|
-
if (!renderer2.xr.isPresenting) invalidate();
|
|
14332
|
+
if (!renderer2.xr.isPresenting) invalidate(state2);
|
|
14369
14333
|
};
|
|
14370
14334
|
const xr = {
|
|
14371
14335
|
connect() {
|
|
@@ -14447,14 +14411,23 @@ function createRoot(canvas) {
|
|
|
14447
14411
|
const newRootId = canvasId || scheduler.generateRootId();
|
|
14448
14412
|
const unregisterRoot = scheduler.registerRoot(newRootId, {
|
|
14449
14413
|
getState: () => store.getState(),
|
|
14450
|
-
onError: (err) => store.getState().setError(err)
|
|
14414
|
+
onError: (err) => store.getState().setError(err),
|
|
14415
|
+
frameloop: store.getState().frameloop,
|
|
14416
|
+
before: schedulerConfig?.before,
|
|
14417
|
+
after: schedulerConfig?.after,
|
|
14418
|
+
order: schedulerConfig?.order
|
|
14451
14419
|
});
|
|
14452
14420
|
const unregisterCanvasTarget = scheduler.register(
|
|
14453
14421
|
() => {
|
|
14454
14422
|
const state2 = store.getState();
|
|
14455
|
-
|
|
14423
|
+
const canvasTarget = state2.internal.canvasTarget;
|
|
14424
|
+
if (canvasTarget) {
|
|
14456
14425
|
const renderer2 = state2.internal.actualRenderer;
|
|
14457
|
-
renderer2.setCanvasTarget(
|
|
14426
|
+
if (renderer2.getCanvasTarget() !== canvasTarget) renderer2.setCanvasTarget(canvasTarget);
|
|
14427
|
+
if (state2.internal.canvasTargetSizeDirty) {
|
|
14428
|
+
state2.internal.canvasTargetSizeDirty = false;
|
|
14429
|
+
renderer2.backend?.updateSize?.();
|
|
14430
|
+
}
|
|
14458
14431
|
}
|
|
14459
14432
|
},
|
|
14460
14433
|
{
|
|
@@ -14523,8 +14496,7 @@ function createRoot(canvas) {
|
|
|
14523
14496
|
phase: "render",
|
|
14524
14497
|
system: true,
|
|
14525
14498
|
// Internal flag: this is a system job, not user-controlled
|
|
14526
|
-
//
|
|
14527
|
-
...schedulerConfig?.after && { after: schedulerConfig.after },
|
|
14499
|
+
// FPS throttles only the default render job; Canvas ordering belongs to the root.
|
|
14528
14500
|
...schedulerConfig?.fps && { fps: schedulerConfig.fps }
|
|
14529
14501
|
}
|
|
14530
14502
|
);
|
|
@@ -14543,8 +14515,21 @@ function createRoot(canvas) {
|
|
|
14543
14515
|
scheduler
|
|
14544
14516
|
}
|
|
14545
14517
|
}));
|
|
14518
|
+
} else {
|
|
14519
|
+
const constraintsChanged = !is.equ(schedulerConfig?.before, lastConfiguredProps.schedulerBefore, shallowLoose) || !is.equ(schedulerConfig?.after, lastConfiguredProps.schedulerAfter, shallowLoose);
|
|
14520
|
+
if (constraintsChanged) {
|
|
14521
|
+
scheduler.setRootConstraints(rootId, {
|
|
14522
|
+
before: schedulerConfig?.before,
|
|
14523
|
+
after: schedulerConfig?.after
|
|
14524
|
+
});
|
|
14525
|
+
}
|
|
14526
|
+
if (schedulerConfig?.order !== lastConfiguredProps.schedulerOrder) {
|
|
14527
|
+
scheduler.setRootOrder(rootId, schedulerConfig?.order ?? 0);
|
|
14528
|
+
}
|
|
14546
14529
|
}
|
|
14547
|
-
|
|
14530
|
+
lastConfiguredProps.schedulerBefore = schedulerConfig?.before;
|
|
14531
|
+
lastConfiguredProps.schedulerAfter = schedulerConfig?.after;
|
|
14532
|
+
lastConfiguredProps.schedulerOrder = schedulerConfig?.order;
|
|
14548
14533
|
onCreated = onCreatedCallback;
|
|
14549
14534
|
configured = true;
|
|
14550
14535
|
resolve();
|
|
@@ -14586,18 +14571,23 @@ function unmountComponentAtNode(canvas, callback) {
|
|
|
14586
14571
|
const fiber = root?.fiber;
|
|
14587
14572
|
if (fiber) {
|
|
14588
14573
|
const state = root?.store.getState();
|
|
14589
|
-
if (state)
|
|
14574
|
+
if (state) {
|
|
14575
|
+
state.internal.active = false;
|
|
14576
|
+
const unregisterRoot = state.internal.unregisterRoot;
|
|
14577
|
+
if (unregisterRoot) {
|
|
14578
|
+
unregisterRoot();
|
|
14579
|
+
state.internal.unregisterRoot = void 0;
|
|
14580
|
+
}
|
|
14581
|
+
}
|
|
14590
14582
|
reconciler.updateContainer(null, fiber, null, () => {
|
|
14591
14583
|
if (state) {
|
|
14592
14584
|
setTimeout(() => {
|
|
14593
14585
|
try {
|
|
14594
14586
|
const renderer = state.internal.actualRenderer;
|
|
14595
|
-
const unregisterRoot = state.internal.unregisterRoot;
|
|
14596
|
-
if (unregisterRoot) unregisterRoot();
|
|
14597
14587
|
const unregisterPrimary = state.internal.unregisterPrimary;
|
|
14598
14588
|
if (unregisterPrimary) unregisterPrimary();
|
|
14599
14589
|
const canvasTarget = state.internal.canvasTarget;
|
|
14600
|
-
if (canvasTarget?.dispose) canvasTarget.dispose();
|
|
14590
|
+
if (state.internal.isSecondary && canvasTarget?.dispose) canvasTarget.dispose();
|
|
14601
14591
|
state.events.disconnect?.();
|
|
14602
14592
|
cleanupHelperGroup(root.store);
|
|
14603
14593
|
if (state.isLegacy && renderer) {
|
|
@@ -14723,6 +14713,207 @@ function flushSync(fn) {
|
|
|
14723
14713
|
return reconciler.flushSyncFromReconciler(fn);
|
|
14724
14714
|
}
|
|
14725
14715
|
|
|
14716
|
+
const isRef = (obj) => obj.current && obj.current.isScene;
|
|
14717
|
+
const resolveScene = (scene) => isRef(scene) ? scene.current : scene;
|
|
14718
|
+
function setEnvProps(background, scene, defaultScene, texture, sceneProps = {}) {
|
|
14719
|
+
sceneProps = {
|
|
14720
|
+
backgroundBlurriness: 0,
|
|
14721
|
+
backgroundIntensity: 1,
|
|
14722
|
+
backgroundRotation: [0, 0, 0],
|
|
14723
|
+
environmentIntensity: 1,
|
|
14724
|
+
environmentRotation: [0, 0, 0],
|
|
14725
|
+
...sceneProps
|
|
14726
|
+
};
|
|
14727
|
+
const target = resolveScene(scene || defaultScene);
|
|
14728
|
+
const oldbg = target.background;
|
|
14729
|
+
const oldenv = target.environment;
|
|
14730
|
+
const oldSceneProps = {
|
|
14731
|
+
backgroundBlurriness: target.backgroundBlurriness,
|
|
14732
|
+
backgroundIntensity: target.backgroundIntensity,
|
|
14733
|
+
backgroundRotation: target.backgroundRotation.clone(),
|
|
14734
|
+
environmentIntensity: target.environmentIntensity,
|
|
14735
|
+
environmentRotation: target.environmentRotation.clone()
|
|
14736
|
+
};
|
|
14737
|
+
if (background !== "only") target.environment = texture;
|
|
14738
|
+
if (background) target.background = texture;
|
|
14739
|
+
applyProps(target, sceneProps);
|
|
14740
|
+
return () => {
|
|
14741
|
+
if (background !== "only") target.environment = oldenv;
|
|
14742
|
+
if (background) target.background = oldbg;
|
|
14743
|
+
applyProps(target, oldSceneProps);
|
|
14744
|
+
};
|
|
14745
|
+
}
|
|
14746
|
+
function EnvironmentMap({ scene, background = false, map, ...config }) {
|
|
14747
|
+
const defaultScene = useThree$1((state) => state.scene);
|
|
14748
|
+
React.useLayoutEffect(() => {
|
|
14749
|
+
if (map) return setEnvProps(background, scene, defaultScene, map, config);
|
|
14750
|
+
});
|
|
14751
|
+
return null;
|
|
14752
|
+
}
|
|
14753
|
+
function EnvironmentCube({
|
|
14754
|
+
background = false,
|
|
14755
|
+
scene,
|
|
14756
|
+
blur,
|
|
14757
|
+
backgroundBlurriness,
|
|
14758
|
+
backgroundIntensity,
|
|
14759
|
+
backgroundRotation,
|
|
14760
|
+
environmentIntensity,
|
|
14761
|
+
environmentRotation,
|
|
14762
|
+
...rest
|
|
14763
|
+
}) {
|
|
14764
|
+
const texture = useEnvironment(rest);
|
|
14765
|
+
const defaultScene = useThree$1((state) => state.scene);
|
|
14766
|
+
React.useLayoutEffect(() => {
|
|
14767
|
+
return setEnvProps(background, scene, defaultScene, texture, {
|
|
14768
|
+
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
14769
|
+
backgroundIntensity,
|
|
14770
|
+
backgroundRotation,
|
|
14771
|
+
environmentIntensity,
|
|
14772
|
+
environmentRotation
|
|
14773
|
+
});
|
|
14774
|
+
});
|
|
14775
|
+
React.useEffect(() => {
|
|
14776
|
+
return () => {
|
|
14777
|
+
texture.dispose();
|
|
14778
|
+
};
|
|
14779
|
+
}, [texture]);
|
|
14780
|
+
return null;
|
|
14781
|
+
}
|
|
14782
|
+
function EnvironmentPortal({
|
|
14783
|
+
children,
|
|
14784
|
+
near = 0.1,
|
|
14785
|
+
far = 1e3,
|
|
14786
|
+
resolution = 256,
|
|
14787
|
+
frames = 1,
|
|
14788
|
+
map,
|
|
14789
|
+
background = false,
|
|
14790
|
+
blur,
|
|
14791
|
+
backgroundBlurriness,
|
|
14792
|
+
backgroundIntensity,
|
|
14793
|
+
backgroundRotation,
|
|
14794
|
+
environmentIntensity,
|
|
14795
|
+
environmentRotation,
|
|
14796
|
+
scene,
|
|
14797
|
+
files,
|
|
14798
|
+
path,
|
|
14799
|
+
preset = void 0,
|
|
14800
|
+
extensions
|
|
14801
|
+
}) {
|
|
14802
|
+
const renderer = useThree$1((state) => state.renderer);
|
|
14803
|
+
const isLegacy = useThree$1((state) => state.isLegacy);
|
|
14804
|
+
const defaultScene = useThree$1((state) => state.scene);
|
|
14805
|
+
const camera = React.useRef(null);
|
|
14806
|
+
const [virtualScene] = React.useState(() => new Scene());
|
|
14807
|
+
const fbo = React.useMemo(() => {
|
|
14808
|
+
const fbo2 = isLegacy ? new WebGLCubeRenderTarget(resolution) : new CubeRenderTarget(resolution);
|
|
14809
|
+
fbo2.texture.type = HalfFloatType;
|
|
14810
|
+
return fbo2;
|
|
14811
|
+
}, [resolution, isLegacy]);
|
|
14812
|
+
React.useEffect(() => {
|
|
14813
|
+
return () => {
|
|
14814
|
+
fbo.dispose();
|
|
14815
|
+
};
|
|
14816
|
+
}, [fbo]);
|
|
14817
|
+
React.useLayoutEffect(() => {
|
|
14818
|
+
if (frames === 1) {
|
|
14819
|
+
const autoClear = renderer.autoClear;
|
|
14820
|
+
renderer.autoClear = true;
|
|
14821
|
+
camera.current.update(renderer, virtualScene);
|
|
14822
|
+
renderer.autoClear = autoClear;
|
|
14823
|
+
}
|
|
14824
|
+
return setEnvProps(background, scene, defaultScene, fbo.texture, {
|
|
14825
|
+
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
14826
|
+
backgroundIntensity,
|
|
14827
|
+
backgroundRotation,
|
|
14828
|
+
environmentIntensity,
|
|
14829
|
+
environmentRotation
|
|
14830
|
+
});
|
|
14831
|
+
}, [
|
|
14832
|
+
children,
|
|
14833
|
+
virtualScene,
|
|
14834
|
+
fbo.texture,
|
|
14835
|
+
scene,
|
|
14836
|
+
defaultScene,
|
|
14837
|
+
background,
|
|
14838
|
+
frames,
|
|
14839
|
+
renderer,
|
|
14840
|
+
blur,
|
|
14841
|
+
backgroundBlurriness,
|
|
14842
|
+
backgroundIntensity,
|
|
14843
|
+
backgroundRotation,
|
|
14844
|
+
environmentIntensity,
|
|
14845
|
+
environmentRotation
|
|
14846
|
+
]);
|
|
14847
|
+
let count = 1;
|
|
14848
|
+
useFrame$1(() => {
|
|
14849
|
+
if (frames === Infinity || count < frames) {
|
|
14850
|
+
const autoClear = renderer.autoClear;
|
|
14851
|
+
renderer.autoClear = true;
|
|
14852
|
+
camera.current.update(renderer, virtualScene);
|
|
14853
|
+
renderer.autoClear = autoClear;
|
|
14854
|
+
count++;
|
|
14855
|
+
}
|
|
14856
|
+
});
|
|
14857
|
+
return /* @__PURE__ */ jsx(Fragment, { children: createPortal(
|
|
14858
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
14859
|
+
children,
|
|
14860
|
+
/* @__PURE__ */ jsx("cubeCamera", { ref: camera, args: [near, far, fbo] }),
|
|
14861
|
+
files || preset ? /* @__PURE__ */ jsx(EnvironmentCube, { background: true, files, preset, path, extensions }) : map ? /* @__PURE__ */ jsx(EnvironmentMap, { background: true, map, extensions }) : null
|
|
14862
|
+
] }),
|
|
14863
|
+
virtualScene
|
|
14864
|
+
) });
|
|
14865
|
+
}
|
|
14866
|
+
function EnvironmentGround(props) {
|
|
14867
|
+
const textureDefault = useEnvironment(props);
|
|
14868
|
+
const texture = props.map || textureDefault;
|
|
14869
|
+
React.useMemo(() => extend({ GroundProjectedEnvImpl: GroundedSkybox }), []);
|
|
14870
|
+
React.useEffect(() => {
|
|
14871
|
+
return () => {
|
|
14872
|
+
textureDefault.dispose();
|
|
14873
|
+
};
|
|
14874
|
+
}, [textureDefault]);
|
|
14875
|
+
const height = props.ground?.height ?? 15;
|
|
14876
|
+
const radius = props.ground?.radius ?? 60;
|
|
14877
|
+
const scale = props.ground?.scale ?? 1e3;
|
|
14878
|
+
const args = React.useMemo(
|
|
14879
|
+
() => [texture, height, radius],
|
|
14880
|
+
[texture, height, radius]
|
|
14881
|
+
);
|
|
14882
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
14883
|
+
/* @__PURE__ */ jsx(EnvironmentMap, { ...props, map: texture }),
|
|
14884
|
+
/* @__PURE__ */ jsx("groundProjectedEnvImpl", { args, scale })
|
|
14885
|
+
] });
|
|
14886
|
+
}
|
|
14887
|
+
function EnvironmentColor({ color, scene }) {
|
|
14888
|
+
const defaultScene = useThree$1((state) => state.scene);
|
|
14889
|
+
React.useLayoutEffect(() => {
|
|
14890
|
+
if (color === void 0) return;
|
|
14891
|
+
const target = resolveScene(scene || defaultScene);
|
|
14892
|
+
const oldBg = target.background;
|
|
14893
|
+
target.background = new Color(color);
|
|
14894
|
+
return () => {
|
|
14895
|
+
target.background = oldBg;
|
|
14896
|
+
};
|
|
14897
|
+
});
|
|
14898
|
+
return null;
|
|
14899
|
+
}
|
|
14900
|
+
function EnvironmentDualSource(props) {
|
|
14901
|
+
const { backgroundFiles, ...envProps } = props;
|
|
14902
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
14903
|
+
/* @__PURE__ */ jsx(EnvironmentCube, { ...envProps, background: false }),
|
|
14904
|
+
/* @__PURE__ */ jsx(EnvironmentCube, { ...props, files: backgroundFiles, background: "only" })
|
|
14905
|
+
] });
|
|
14906
|
+
}
|
|
14907
|
+
function Environment(props) {
|
|
14908
|
+
if (props.color && !props.files && !props.preset && !props.map) {
|
|
14909
|
+
return /* @__PURE__ */ jsx(EnvironmentColor, { ...props });
|
|
14910
|
+
}
|
|
14911
|
+
if (props.backgroundFiles && props.backgroundFiles !== props.files) {
|
|
14912
|
+
return /* @__PURE__ */ jsx(EnvironmentDualSource, { ...props });
|
|
14913
|
+
}
|
|
14914
|
+
return props.ground ? /* @__PURE__ */ jsx(EnvironmentGround, { ...props }) : props.map ? /* @__PURE__ */ jsx(EnvironmentMap, { ...props }) : props.children ? /* @__PURE__ */ jsx(EnvironmentPortal, { ...props }) : /* @__PURE__ */ jsx(EnvironmentCube, { ...props });
|
|
14915
|
+
}
|
|
14916
|
+
|
|
14726
14917
|
function parseBackground(background) {
|
|
14727
14918
|
if (!background) return null;
|
|
14728
14919
|
if (typeof background === "object" && !background.isColor) {
|
|
@@ -14766,14 +14957,36 @@ function parseRendererConfig(rendererProp) {
|
|
|
14766
14957
|
return { primaryCanvas: void 0, scheduler: void 0, renderer: rendererProp };
|
|
14767
14958
|
}
|
|
14768
14959
|
|
|
14960
|
+
const RESOURCE_KINDS = ["nodes", "uniforms", "buffers", "gpuStorage"];
|
|
14961
|
+
const registries = /* @__PURE__ */ new WeakMap();
|
|
14962
|
+
function getKindRegistry(store, kind) {
|
|
14963
|
+
let registry = registries.get(store);
|
|
14964
|
+
if (!registry) {
|
|
14965
|
+
registry = {
|
|
14966
|
+
nodes: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() },
|
|
14967
|
+
uniforms: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() },
|
|
14968
|
+
buffers: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() },
|
|
14969
|
+
gpuStorage: { valid: /* @__PURE__ */ new Set(), staged: /* @__PURE__ */ new Map() }
|
|
14970
|
+
};
|
|
14971
|
+
registries.set(store, registry);
|
|
14972
|
+
}
|
|
14973
|
+
return registry[kind];
|
|
14974
|
+
}
|
|
14975
|
+
function invalidateResource(store, kind, scopeKey) {
|
|
14976
|
+
const registry = getKindRegistry(store, kind);
|
|
14977
|
+
{
|
|
14978
|
+
registry.valid.clear();
|
|
14979
|
+
registry.staged.clear();
|
|
14980
|
+
}
|
|
14981
|
+
}
|
|
14982
|
+
function invalidateAllResources(store) {
|
|
14983
|
+
for (const kind of RESOURCE_KINDS) invalidateResource(store, kind);
|
|
14984
|
+
}
|
|
14985
|
+
|
|
14769
14986
|
function clearHmrCaches(store) {
|
|
14770
|
-
store.
|
|
14771
|
-
|
|
14772
|
-
|
|
14773
|
-
buffers: {},
|
|
14774
|
-
gpuStorage: {},
|
|
14775
|
-
_hmrVersion: state._hmrVersion + 1
|
|
14776
|
-
}));
|
|
14987
|
+
const primary = store.getState().primaryStore ?? store;
|
|
14988
|
+
invalidateAllResources(primary);
|
|
14989
|
+
primary.setState((state) => ({ _hmrVersion: state._hmrVersion + 1 }));
|
|
14777
14990
|
}
|
|
14778
14991
|
|
|
14779
14992
|
function CanvasImpl({
|
|
@@ -14813,9 +15026,9 @@ function CanvasImpl({
|
|
|
14813
15026
|
React.useMemo(() => extend(THREE), []);
|
|
14814
15027
|
const Bridge = useBridge();
|
|
14815
15028
|
const backgroundProps = React.useMemo(() => parseBackground(background), [background]);
|
|
14816
|
-
const
|
|
15029
|
+
const [hasInitialSize, setHasInitialSize] = React.useState(false);
|
|
14817
15030
|
const measureConfig = React.useMemo(() => {
|
|
14818
|
-
if (!
|
|
15031
|
+
if (!hasInitialSize) {
|
|
14819
15032
|
return {
|
|
14820
15033
|
...resize,
|
|
14821
15034
|
scroll: resize?.scroll ?? true,
|
|
@@ -14827,7 +15040,7 @@ function CanvasImpl({
|
|
|
14827
15040
|
debounce: { scroll: 50, resize: 0 },
|
|
14828
15041
|
...resize
|
|
14829
15042
|
};
|
|
14830
|
-
}, [
|
|
15043
|
+
}, [hasInitialSize, resize]);
|
|
14831
15044
|
const [containerRef, containerRect] = useMeasure(measureConfig);
|
|
14832
15045
|
const effectiveSize = React.useMemo(() => {
|
|
14833
15046
|
let w = width ?? containerRect.width;
|
|
@@ -14843,9 +15056,7 @@ function CanvasImpl({
|
|
|
14843
15056
|
left: containerRect.left
|
|
14844
15057
|
};
|
|
14845
15058
|
}, [width, height, containerRect, forceEven]);
|
|
14846
|
-
if (!
|
|
14847
|
-
hasInitialSizeRef.current = true;
|
|
14848
|
-
}
|
|
15059
|
+
if (!hasInitialSize && effectiveSize.width > 0 && effectiveSize.height > 0) setHasInitialSize(true);
|
|
14849
15060
|
const canvasRef = React.useRef(null);
|
|
14850
15061
|
const divRef = React.useRef(null);
|
|
14851
15062
|
React.useImperativeHandle(ref, () => canvasRef.current);
|
|
@@ -14910,7 +15121,7 @@ function CanvasImpl({
|
|
|
14910
15121
|
onDropMissed: (...args) => handleDropMissed.current?.(...args),
|
|
14911
15122
|
onCreated: (state) => {
|
|
14912
15123
|
state.events.connect?.(
|
|
14913
|
-
eventSource ? isRef(eventSource) ? eventSource.current : eventSource : divRef.current
|
|
15124
|
+
eventSource ? isRef$1(eventSource) ? eventSource.current : eventSource : divRef.current
|
|
14914
15125
|
);
|
|
14915
15126
|
if (eventPrefix) {
|
|
14916
15127
|
state.setEvents({
|
|
@@ -14959,6 +15170,7 @@ function CanvasImpl({
|
|
|
14959
15170
|
const canvas = canvasRef.current;
|
|
14960
15171
|
if (canvas) {
|
|
14961
15172
|
return () => {
|
|
15173
|
+
if (canvas.isConnected) return;
|
|
14962
15174
|
unmountComponentAtNode(canvas);
|
|
14963
15175
|
root.current = null;
|
|
14964
15176
|
};
|
|
@@ -15017,10 +15229,13 @@ function CanvasImpl({
|
|
|
15017
15229
|
}
|
|
15018
15230
|
);
|
|
15019
15231
|
}
|
|
15020
|
-
function Canvas(props) {
|
|
15232
|
+
function Canvas$1(props) {
|
|
15021
15233
|
return /* @__PURE__ */ jsx(FiberProvider, { children: /* @__PURE__ */ jsx(CanvasImpl, { ...props }) });
|
|
15022
15234
|
}
|
|
15023
15235
|
|
|
15024
15236
|
extend(THREE);
|
|
15237
|
+
const useThree = useThree$1;
|
|
15238
|
+
const useFrame = useFrame$1;
|
|
15239
|
+
const Canvas = Canvas$1;
|
|
15025
15240
|
|
|
15026
|
-
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,
|
|
15241
|
+
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 };
|