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