@react-three/drei 10.8.0-alpha.1 → 11.0.0-alpha.1
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/core/_chunks/libs/tunnel-rat.mjs +11 -11
- package/core/_chunks/libs/zustand.mjs +3 -3
- package/core/core/index.d.mts +150 -150
- package/core/core/index.mjs +646 -646
- package/index.d.mts +5 -5
- package/native/_chunks/libs/tunnel-rat.mjs +11 -11
- package/native/_chunks/libs/zustand.mjs +3 -3
- package/native/native/index.d.mts +164 -164
- package/native/native/index.mjs +765 -765
- package/package.json +1 -1
- package/webgpu/webgpu/index.d.mts +1 -1
package/native/native/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import { t as require_stats_min } from "../_chunks/libs/stats.js.mjs";
|
|
|
10
10
|
import { t as Stats$1 } from "../_chunks/libs/stats-gl.mjs";
|
|
11
11
|
import { t as require_index_cjs$1 } from "../_chunks/libs/tunnel-rat.mjs";
|
|
12
12
|
import { n as HDRJPGLoader, t as GainMapLoader } from "../_chunks/libs/@monogrid/gainmap-js.mjs";
|
|
13
|
-
import * as React
|
|
13
|
+
import * as React from "react";
|
|
14
14
|
import { Fragment, createContext, forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
15
15
|
import { addAfterEffect, addEffect, applyProps, context, createPortal, extend, useFrame, useInstanceHandle, useLoader, useThree } from "@react-three/fiber";
|
|
16
16
|
import * as THREE from "three/webgpu";
|
|
@@ -142,14 +142,14 @@ var BlurNodeMaterial = class extends MeshBasicNodeMaterial {
|
|
|
142
142
|
* <ContactShadows frames={1} />
|
|
143
143
|
* ```
|
|
144
144
|
*/
|
|
145
|
-
const ContactShadows = /* @__PURE__ */ React
|
|
146
|
-
const ref = React
|
|
145
|
+
const ContactShadows = /* @__PURE__ */ React.forwardRef(({ scale: scale$2 = 10, frames = Infinity, opacity = 1, width = 1, height = 1, blur = 1, near = 0, far = 10, resolution = 512, smooth = true, color = "#000000", depthWrite = false, renderOrder, ...props }, fref) => {
|
|
146
|
+
const ref = React.useRef(null);
|
|
147
147
|
const scene = useThree((state) => state.scene);
|
|
148
148
|
const gl = useThree((state) => state.gl);
|
|
149
|
-
const shadowCamera = React
|
|
149
|
+
const shadowCamera = React.useRef(null);
|
|
150
150
|
const actualWidth = width * (Array.isArray(scale$2) ? scale$2[0] : scale$2 || 1);
|
|
151
151
|
const actualHeight = height * (Array.isArray(scale$2) ? scale$2[1] : scale$2 || 1);
|
|
152
|
-
const [renderTarget, planeGeometry, depthMaterial, blurPlane, horizontalBlurMaterial, verticalBlurMaterial, renderTargetBlur] = React
|
|
152
|
+
const [renderTarget, planeGeometry, depthMaterial, blurPlane, horizontalBlurMaterial, verticalBlurMaterial, renderTargetBlur] = React.useMemo(() => {
|
|
153
153
|
const renderTarget$1 = new THREE.RenderTarget(resolution, resolution, {
|
|
154
154
|
format: THREE.RGBAFormat,
|
|
155
155
|
type: THREE.HalfFloatType
|
|
@@ -179,7 +179,7 @@ const ContactShadows = /* @__PURE__ */ React$1.forwardRef(({ scale: scale$2 = 10
|
|
|
179
179
|
near,
|
|
180
180
|
far
|
|
181
181
|
]);
|
|
182
|
-
const blurShadows = React
|
|
182
|
+
const blurShadows = React.useCallback((blurAmount) => {
|
|
183
183
|
blurPlane.visible = true;
|
|
184
184
|
blurPlane.material = horizontalBlurMaterial;
|
|
185
185
|
horizontalBlurMaterial.inputTexture = renderTarget.texture;
|
|
@@ -223,11 +223,11 @@ const ContactShadows = /* @__PURE__ */ React$1.forwardRef(({ scale: scale$2 = 10
|
|
|
223
223
|
scene.background = initialBackground;
|
|
224
224
|
}
|
|
225
225
|
});
|
|
226
|
-
React
|
|
227
|
-
React
|
|
226
|
+
React.useImperativeHandle(fref, () => ref.current, []);
|
|
227
|
+
React.useEffect(() => {
|
|
228
228
|
depthMaterial.shadowOpacity = opacity;
|
|
229
229
|
}, [opacity, depthMaterial]);
|
|
230
|
-
React
|
|
230
|
+
React.useEffect(() => {
|
|
231
231
|
return () => {
|
|
232
232
|
renderTarget.dispose();
|
|
233
233
|
renderTargetBlur.dispose();
|
|
@@ -346,7 +346,7 @@ function isLight(object) {
|
|
|
346
346
|
function isGeometry$1(object) {
|
|
347
347
|
return !!object.geometry;
|
|
348
348
|
}
|
|
349
|
-
const accumulativeContext = /* @__PURE__ */ React
|
|
349
|
+
const accumulativeContext = /* @__PURE__ */ React.createContext(null);
|
|
350
350
|
const SoftShadowMaterial = /* @__PURE__ */ shaderMaterial({
|
|
351
351
|
color: /* @__PURE__ */ new Color$2(),
|
|
352
352
|
blend: 2,
|
|
@@ -369,19 +369,19 @@ const SoftShadowMaterial = /* @__PURE__ */ shaderMaterial({
|
|
|
369
369
|
#include <tonemapping_fragment>
|
|
370
370
|
#include <${version >= 154 ? "colorspace_fragment" : "encodings_fragment"}>
|
|
371
371
|
}`);
|
|
372
|
-
const AccumulativeShadows = /* @__PURE__ */ React
|
|
372
|
+
const AccumulativeShadows = /* @__PURE__ */ React.forwardRef(({ children, temporal, frames = 40, limit = Infinity, blend = 20, scale: scale$2 = 10, opacity = 1, alphaTest = .75, color = "black", colorBlend = 2, resolution = 1024, toneMapped = true, ...props }, forwardRef$1) => {
|
|
373
373
|
extend({ SoftShadowMaterial });
|
|
374
374
|
const gl = useThree((state) => state.gl);
|
|
375
375
|
const scene = useThree((state) => state.scene);
|
|
376
376
|
const camera = useThree((state) => state.camera);
|
|
377
377
|
const invalidate = useThree((state) => state.invalidate);
|
|
378
|
-
const gPlane = React
|
|
379
|
-
const gLights = React
|
|
380
|
-
const [plm] = React
|
|
381
|
-
React
|
|
378
|
+
const gPlane = React.useRef(null);
|
|
379
|
+
const gLights = React.useRef(null);
|
|
380
|
+
const [plm] = React.useState(() => new ProgressiveLightMap(gl, scene, resolution));
|
|
381
|
+
React.useLayoutEffect(() => {
|
|
382
382
|
plm.configure(gPlane.current);
|
|
383
383
|
}, []);
|
|
384
|
-
const api = React
|
|
384
|
+
const api = React.useMemo(() => ({
|
|
385
385
|
lights: /* @__PURE__ */ new Map(),
|
|
386
386
|
temporal: !!temporal,
|
|
387
387
|
frames: Math.max(2, frames),
|
|
@@ -423,11 +423,11 @@ const AccumulativeShadows = /* @__PURE__ */ React$1.forwardRef(({ children, temp
|
|
|
423
423
|
opacity,
|
|
424
424
|
alphaTest
|
|
425
425
|
]);
|
|
426
|
-
React
|
|
426
|
+
React.useLayoutEffect(() => {
|
|
427
427
|
api.reset();
|
|
428
428
|
if (!api.temporal && api.frames !== Infinity) api.update(api.blend);
|
|
429
429
|
});
|
|
430
|
-
React
|
|
430
|
+
React.useImperativeHandle(forwardRef$1, () => api, [api]);
|
|
431
431
|
useFrame(() => {
|
|
432
432
|
if ((api.temporal || api.frames === Infinity) && api.count < api.frames && api.count < limit) {
|
|
433
433
|
invalidate();
|
|
@@ -464,15 +464,15 @@ const AccumulativeShadows = /* @__PURE__ */ React$1.forwardRef(({ children, temp
|
|
|
464
464
|
})]
|
|
465
465
|
});
|
|
466
466
|
});
|
|
467
|
-
const RandomizedLight = /* @__PURE__ */ React
|
|
467
|
+
const RandomizedLight = /* @__PURE__ */ React.forwardRef(({ castShadow = true, bias = .001, mapSize = 512, size = 5, near = .5, far = 500, frames = 1, position: position$1 = [
|
|
468
468
|
0,
|
|
469
469
|
0,
|
|
470
470
|
0
|
|
471
471
|
], radius = 1, amount = 8, intensity = version >= 155 ? Math.PI : 1, ambient = .5, ...props }, forwardRef$1) => {
|
|
472
|
-
const gLights = React
|
|
472
|
+
const gLights = React.useRef(null);
|
|
473
473
|
const length$1 = new Vector3$2(...position$1).length();
|
|
474
|
-
const parent = React
|
|
475
|
-
const update = React
|
|
474
|
+
const parent = React.useContext(accumulativeContext);
|
|
475
|
+
const update = React.useCallback(() => {
|
|
476
476
|
let light;
|
|
477
477
|
if (gLights.current) for (let l = 0; l < gLights.current.children.length; l++) {
|
|
478
478
|
light = gLights.current.children[l];
|
|
@@ -489,9 +489,9 @@ const RandomizedLight = /* @__PURE__ */ React$1.forwardRef(({ castShadow = true,
|
|
|
489
489
|
length$1,
|
|
490
490
|
...position$1
|
|
491
491
|
]);
|
|
492
|
-
const api = React
|
|
493
|
-
React
|
|
494
|
-
React
|
|
492
|
+
const api = React.useMemo(() => ({ update }), [update]);
|
|
493
|
+
React.useImperativeHandle(forwardRef$1, () => api, [api]);
|
|
494
|
+
React.useLayoutEffect(() => {
|
|
495
495
|
const group = gLights.current;
|
|
496
496
|
if (parent) parent.lights?.set(group.uuid, api);
|
|
497
497
|
return () => void parent?.lights?.delete(group.uuid);
|
|
@@ -640,7 +640,7 @@ function useFBO(width, height, settings) {
|
|
|
640
640
|
const _settings = (typeof width === "number" ? settings : width) || {};
|
|
641
641
|
const { samples = 0, depth, ...targetSettings } = _settings;
|
|
642
642
|
const depthBuffer = depth ?? _settings.depthBuffer;
|
|
643
|
-
const target$1 = React
|
|
643
|
+
const target$1 = React.useMemo(() => {
|
|
644
644
|
const target$2 = new RenderTarget(_width, _height, {
|
|
645
645
|
minFilter: LinearFilter,
|
|
646
646
|
magFilter: LinearFilter,
|
|
@@ -651,7 +651,7 @@ function useFBO(width, height, settings) {
|
|
|
651
651
|
target$2.samples = samples;
|
|
652
652
|
return target$2;
|
|
653
653
|
}, []);
|
|
654
|
-
React
|
|
654
|
+
React.useLayoutEffect(() => {
|
|
655
655
|
target$1.setSize(_width, _height);
|
|
656
656
|
if (samples) target$1.samples = samples;
|
|
657
657
|
}, [
|
|
@@ -660,7 +660,7 @@ function useFBO(width, height, settings) {
|
|
|
660
660
|
_width,
|
|
661
661
|
_height
|
|
662
662
|
]);
|
|
663
|
-
React
|
|
663
|
+
React.useEffect(() => {
|
|
664
664
|
return () => target$1.dispose();
|
|
665
665
|
}, []);
|
|
666
666
|
return target$1;
|
|
@@ -704,9 +704,9 @@ const Fbo = /* @__PURE__ */ forwardRef(({ children, width, height, ...settings }
|
|
|
704
704
|
* ```
|
|
705
705
|
*/
|
|
706
706
|
function useHelper(object3D, helperConstructor, ...args) {
|
|
707
|
-
const helper = React
|
|
707
|
+
const helper = React.useRef(null);
|
|
708
708
|
const scene = useThree((state) => state.scene);
|
|
709
|
-
React
|
|
709
|
+
React.useLayoutEffect(() => {
|
|
710
710
|
let currentHelper = void 0;
|
|
711
711
|
if (object3D && object3D?.current && helperConstructor) helper.current = currentHelper = new helperConstructor(object3D.current, ...args);
|
|
712
712
|
if (currentHelper) {
|
|
@@ -739,9 +739,9 @@ function useHelper(object3D, helperConstructor, ...args) {
|
|
|
739
739
|
* ```
|
|
740
740
|
*/
|
|
741
741
|
const Helper = ({ type: helperConstructor, args = [] }) => {
|
|
742
|
-
const thisRef = React
|
|
743
|
-
const parentRef = React
|
|
744
|
-
React
|
|
742
|
+
const thisRef = React.useRef(null);
|
|
743
|
+
const parentRef = React.useRef(null);
|
|
744
|
+
React.useLayoutEffect(() => {
|
|
745
745
|
parentRef.current = thisRef.current.parent;
|
|
746
746
|
});
|
|
747
747
|
useHelper(parentRef, helperConstructor, ...args);
|
|
@@ -770,11 +770,11 @@ const Helper = ({ type: helperConstructor, args = [] }) => {
|
|
|
770
770
|
* </mesh>
|
|
771
771
|
* ```
|
|
772
772
|
*/
|
|
773
|
-
const Edges = /* @__PURE__ */ React
|
|
773
|
+
const Edges = /* @__PURE__ */ React.forwardRef(({ threshold = 15, geometry: explicitGeometry, LineComponent, ...props }, fref) => {
|
|
774
774
|
const LineComp = LineComponent ?? Line;
|
|
775
|
-
const ref = React
|
|
776
|
-
React
|
|
777
|
-
const tmpPoints = React
|
|
775
|
+
const ref = React.useRef(null);
|
|
776
|
+
React.useImperativeHandle(fref, () => ref.current, []);
|
|
777
|
+
const tmpPoints = React.useMemo(() => [
|
|
778
778
|
0,
|
|
779
779
|
0,
|
|
780
780
|
0,
|
|
@@ -782,9 +782,9 @@ const Edges = /* @__PURE__ */ React$1.forwardRef(({ threshold = 15, geometry: ex
|
|
|
782
782
|
0,
|
|
783
783
|
0
|
|
784
784
|
], []);
|
|
785
|
-
const memoizedGeometry = React
|
|
786
|
-
const memoizedThreshold = React
|
|
787
|
-
React
|
|
785
|
+
const memoizedGeometry = React.useRef(null);
|
|
786
|
+
const memoizedThreshold = React.useRef(null);
|
|
787
|
+
React.useLayoutEffect(() => {
|
|
788
788
|
const parent = ref.current.parent;
|
|
789
789
|
const geometry$1 = explicitGeometry ?? parent?.geometry;
|
|
790
790
|
if (!geometry$1) return;
|
|
@@ -1342,10 +1342,10 @@ var MeshTransmissionMaterialImpl = class extends MeshPhysicalNodeMaterial {
|
|
|
1342
1342
|
this._attenuationColor.value = v$1;
|
|
1343
1343
|
}
|
|
1344
1344
|
};
|
|
1345
|
-
const MeshTransmissionMaterial = /* @__PURE__ */ React
|
|
1345
|
+
const MeshTransmissionMaterial = /* @__PURE__ */ React.forwardRef(({ buffer, transmissionSampler = false, backside = false, side = THREE.FrontSide, transmission = 1, thickness = 0, backsideThickness = 0, backsideEnvMapIntensity = 1, samples = 10, resolution, backsideResolution, background, anisotropy, anisotropicBlur, ...props }, fref) => {
|
|
1346
1346
|
extend({ MeshTransmissionMaterial: MeshTransmissionMaterialImpl });
|
|
1347
|
-
const ref = React
|
|
1348
|
-
const [discardMaterial] = React
|
|
1347
|
+
const ref = React.useRef(null);
|
|
1348
|
+
const [discardMaterial] = React.useState(() => DiscardMaterial);
|
|
1349
1349
|
const fboBack = useFBO(backsideResolution || resolution);
|
|
1350
1350
|
const fboMain = useFBO(resolution);
|
|
1351
1351
|
let oldBg;
|
|
@@ -1385,7 +1385,7 @@ const MeshTransmissionMaterial = /* @__PURE__ */ React$1.forwardRef(({ buffer, t
|
|
|
1385
1385
|
}
|
|
1386
1386
|
}
|
|
1387
1387
|
});
|
|
1388
|
-
React
|
|
1388
|
+
React.useImperativeHandle(fref, () => ref.current, []);
|
|
1389
1389
|
return /* @__PURE__ */ jsx("meshTransmissionMaterial", {
|
|
1390
1390
|
args: [samples, transmissionSampler],
|
|
1391
1391
|
ref,
|
|
@@ -1546,12 +1546,12 @@ var MeshReflectorMaterial$1 = class extends THREE.MeshStandardNodeMaterial {
|
|
|
1546
1546
|
* </mesh>
|
|
1547
1547
|
* ```
|
|
1548
1548
|
*/
|
|
1549
|
-
const MeshReflectorMaterial = /* @__PURE__ */ React
|
|
1549
|
+
const MeshReflectorMaterial = /* @__PURE__ */ React.forwardRef(({ mixBlur = 0, mixStrength = 1, resolution = 256, blur = [0, 0], minDepthThreshold = .9, maxDepthThreshold = 1, depthScale = 0, depthToBlurRatioBias = .25, mirror = 0, distortion = 1, mixContrast = 1, reflectorOffset = 0, ...props }, ref) => {
|
|
1550
1550
|
const scene = useThree(({ scene: scene$1 }) => scene$1);
|
|
1551
1551
|
const blurArray = Array.isArray(blur) ? blur : [blur, blur];
|
|
1552
1552
|
blurArray[0] + blurArray[1];
|
|
1553
1553
|
const blurRadius = Math.min(1, (blurArray[0] + blurArray[1]) / 1e3);
|
|
1554
|
-
const [material] = React
|
|
1554
|
+
const [material] = React.useState(() => new MeshReflectorMaterial$1({
|
|
1555
1555
|
resolution,
|
|
1556
1556
|
mixBlur,
|
|
1557
1557
|
mixStrength,
|
|
@@ -1564,9 +1564,9 @@ const MeshReflectorMaterial = /* @__PURE__ */ React$1.forwardRef(({ mixBlur = 0,
|
|
|
1564
1564
|
mixContrast,
|
|
1565
1565
|
reflectorOffset
|
|
1566
1566
|
}, props));
|
|
1567
|
-
React
|
|
1568
|
-
const parentMeshRef = React
|
|
1569
|
-
React
|
|
1567
|
+
React.useImperativeHandle(ref, () => material, [material]);
|
|
1568
|
+
const parentMeshRef = React.useRef(null);
|
|
1569
|
+
React.useEffect(() => {
|
|
1570
1570
|
const target$1 = material.reflectorTarget;
|
|
1571
1571
|
if (target$1) scene.add(target$1);
|
|
1572
1572
|
return () => {
|
|
@@ -1592,7 +1592,7 @@ const MeshReflectorMaterial = /* @__PURE__ */ React$1.forwardRef(({ mixBlur = 0,
|
|
|
1592
1592
|
target$1.matrix.copy(parentMesh.matrixWorld);
|
|
1593
1593
|
}
|
|
1594
1594
|
});
|
|
1595
|
-
React
|
|
1595
|
+
React.useEffect(() => {
|
|
1596
1596
|
material.mirror = mirror;
|
|
1597
1597
|
material.mixBlur = mixBlur;
|
|
1598
1598
|
material.mixStrength = mixStrength;
|
|
@@ -1781,17 +1781,17 @@ var MeshRefractionMaterialImpl = class extends MeshPhysicalNodeMaterial {
|
|
|
1781
1781
|
this._thickness.value = v$1;
|
|
1782
1782
|
}
|
|
1783
1783
|
};
|
|
1784
|
-
const MeshRefractionMaterial = /* @__PURE__ */ React
|
|
1784
|
+
const MeshRefractionMaterial = /* @__PURE__ */ React.forwardRef(({ envMap, bounces = 3, ior = 2.4, fresnel = 0, aberrationStrength = .01, fastChroma = true, tintColor = "white", opacity = 1, ...props }, fref) => {
|
|
1785
1785
|
extend({ MeshRefractionMaterial: MeshRefractionMaterialImpl });
|
|
1786
|
-
const ref = React
|
|
1786
|
+
const ref = React.useRef(null);
|
|
1787
1787
|
const size = useThree((state) => state.size);
|
|
1788
|
-
React
|
|
1788
|
+
React.useEffect(() => {
|
|
1789
1789
|
if (ref.current) ref.current.resolution = new THREE.Vector2(size.width, size.height);
|
|
1790
1790
|
}, [size]);
|
|
1791
|
-
React
|
|
1791
|
+
React.useEffect(() => {
|
|
1792
1792
|
if (ref.current && envMap) ref.current.envMap = envMap;
|
|
1793
1793
|
}, [envMap]);
|
|
1794
|
-
React
|
|
1794
|
+
React.useImperativeHandle(fref, () => ref.current, []);
|
|
1795
1795
|
return /* @__PURE__ */ jsx("meshRefractionMaterial", {
|
|
1796
1796
|
args: [fastChroma],
|
|
1797
1797
|
ref,
|
|
@@ -1819,17 +1819,17 @@ const MeshRefractionMaterial = /* @__PURE__ */ React$1.forwardRef(({ envMap, bou
|
|
|
1819
1819
|
*/
|
|
1820
1820
|
function useIntersect(onChange) {
|
|
1821
1821
|
const { isLegacy } = useThree();
|
|
1822
|
-
const ref = React
|
|
1823
|
-
const currentStatus = React
|
|
1824
|
-
const previousStatus = React
|
|
1825
|
-
const callback = React
|
|
1826
|
-
const { frustum, projScreenMatrix } = React
|
|
1822
|
+
const ref = React.useRef(null);
|
|
1823
|
+
const currentStatus = React.useRef(false);
|
|
1824
|
+
const previousStatus = React.useRef(false);
|
|
1825
|
+
const callback = React.useRef(onChange);
|
|
1826
|
+
const { frustum, projScreenMatrix } = React.useMemo(() => {
|
|
1827
1827
|
return {
|
|
1828
1828
|
frustum: new Frustum(),
|
|
1829
1829
|
projScreenMatrix: new Matrix4()
|
|
1830
1830
|
};
|
|
1831
1831
|
}, []);
|
|
1832
|
-
React
|
|
1832
|
+
React.useLayoutEffect(() => void (callback.current = onChange), [onChange]);
|
|
1833
1833
|
useFrame(() => {
|
|
1834
1834
|
if (ref.current) currentStatus.current = false;
|
|
1835
1835
|
}, { phase: "start" });
|
|
@@ -1847,7 +1847,7 @@ function useIntersect(onChange) {
|
|
|
1847
1847
|
previousStatus.current = visibleNow;
|
|
1848
1848
|
callback.current?.(visibleNow);
|
|
1849
1849
|
}, { phase: "end" });
|
|
1850
|
-
React
|
|
1850
|
+
React.useEffect(() => {
|
|
1851
1851
|
const obj = ref.current;
|
|
1852
1852
|
if (obj && isLegacy) {
|
|
1853
1853
|
const oldOnRender = obj.onBeforeRender;
|
|
@@ -1862,11 +1862,11 @@ function useIntersect(onChange) {
|
|
|
1862
1862
|
|
|
1863
1863
|
//#endregion
|
|
1864
1864
|
//#region src/core/Portal/RenderTexture/RenderTexture.tsx
|
|
1865
|
-
const RenderTexture = /* @__PURE__ */ React
|
|
1865
|
+
const RenderTexture = /* @__PURE__ */ React.forwardRef(({ children, compute, width, height, samples = 4, renderPriority = 0, eventPriority = 0, frames = Infinity, stencilBuffer = false, depthBuffer = true, generateMipmaps = false, ...props }, forwardRef$1) => {
|
|
1866
1866
|
const { size, viewport, isLegacy } = useThree();
|
|
1867
1867
|
const fboWidth = (width || size.width) * viewport.dpr;
|
|
1868
1868
|
const fboHeight = (height || size.height) * viewport.dpr;
|
|
1869
|
-
const fboRef = React
|
|
1869
|
+
const fboRef = React.useRef(null);
|
|
1870
1870
|
if (!fboRef.current) {
|
|
1871
1871
|
const settings = {
|
|
1872
1872
|
minFilter: LinearFilter,
|
|
@@ -1884,7 +1884,7 @@ const RenderTexture = /* @__PURE__ */ React$1.forwardRef(({ children, compute, w
|
|
|
1884
1884
|
}
|
|
1885
1885
|
const fboA = fboRef.current.a;
|
|
1886
1886
|
const fboB = fboRef.current.b;
|
|
1887
|
-
React
|
|
1887
|
+
React.useLayoutEffect(() => {
|
|
1888
1888
|
const needsFlip = !isLegacy;
|
|
1889
1889
|
fboA.texture.flipY = !needsFlip;
|
|
1890
1890
|
fboB.texture.flipY = !needsFlip;
|
|
@@ -1893,7 +1893,7 @@ const RenderTexture = /* @__PURE__ */ React$1.forwardRef(({ children, compute, w
|
|
|
1893
1893
|
fboB,
|
|
1894
1894
|
isLegacy
|
|
1895
1895
|
]);
|
|
1896
|
-
React
|
|
1896
|
+
React.useLayoutEffect(() => {
|
|
1897
1897
|
fboA.setSize(fboWidth, fboHeight);
|
|
1898
1898
|
fboB.setSize(fboWidth, fboHeight);
|
|
1899
1899
|
}, [
|
|
@@ -1902,7 +1902,7 @@ const RenderTexture = /* @__PURE__ */ React$1.forwardRef(({ children, compute, w
|
|
|
1902
1902
|
fboWidth,
|
|
1903
1903
|
fboHeight
|
|
1904
1904
|
]);
|
|
1905
|
-
React
|
|
1905
|
+
React.useEffect(() => {
|
|
1906
1906
|
return () => {
|
|
1907
1907
|
if (fboRef.current) {
|
|
1908
1908
|
fboRef.current.a.dispose();
|
|
@@ -1911,10 +1911,10 @@ const RenderTexture = /* @__PURE__ */ React$1.forwardRef(({ children, compute, w
|
|
|
1911
1911
|
}
|
|
1912
1912
|
};
|
|
1913
1913
|
}, []);
|
|
1914
|
-
const readBufferIndex = React
|
|
1915
|
-
const displayTextureRef = React
|
|
1916
|
-
const [vScene] = React
|
|
1917
|
-
const uvCompute = React
|
|
1914
|
+
const readBufferIndex = React.useRef(0);
|
|
1915
|
+
const displayTextureRef = React.useRef(fboA.texture);
|
|
1916
|
+
const [vScene] = React.useState(() => new Scene());
|
|
1917
|
+
const uvCompute = React.useCallback((event, state, previous) => {
|
|
1918
1918
|
let parent = fboA.texture?.__r3f?.parent?.object;
|
|
1919
1919
|
while (parent && !(parent instanceof Object3D$1)) parent = parent.__r3f?.parent?.object;
|
|
1920
1920
|
if (!parent) return false;
|
|
@@ -1925,7 +1925,7 @@ const RenderTexture = /* @__PURE__ */ React$1.forwardRef(({ children, compute, w
|
|
|
1925
1925
|
if (!uv$1) return false;
|
|
1926
1926
|
state.raycaster.setFromCamera(state.pointer.set(uv$1.x * 2 - 1, uv$1.y * 2 - 1), state.camera);
|
|
1927
1927
|
}, [fboA]);
|
|
1928
|
-
React
|
|
1928
|
+
React.useImperativeHandle(forwardRef$1, () => displayTextureRef.current, []);
|
|
1929
1929
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [createPortal(/* @__PURE__ */ jsxs(Container$2, {
|
|
1930
1930
|
renderPriority,
|
|
1931
1931
|
frames,
|
|
@@ -2330,25 +2330,25 @@ const makeSDFGenerator = (clientWidth, clientHeight, renderer) => {
|
|
|
2330
2330
|
return finalTarget;
|
|
2331
2331
|
};
|
|
2332
2332
|
};
|
|
2333
|
-
const MeshPortalMaterial = /* @__PURE__ */ React
|
|
2333
|
+
const MeshPortalMaterial = /* @__PURE__ */ React.forwardRef(({ children, events = void 0, blur = 0, eventPriority = 0, renderPriority = 0, worldUnits = false, resolution = 512, ...props }, fref) => {
|
|
2334
2334
|
extend({ PortalMaterialImpl });
|
|
2335
|
-
const ref = React
|
|
2335
|
+
const ref = React.useRef(null);
|
|
2336
2336
|
const { scene, gl, size, viewport, setEvents } = useThree();
|
|
2337
2337
|
const maskRenderTarget = useFBO(resolution, resolution);
|
|
2338
|
-
const [priority, setPriority] = React
|
|
2338
|
+
const [priority, setPriority] = React.useState(0);
|
|
2339
2339
|
useFrame(() => {
|
|
2340
2340
|
const p = ref.current.blend > 0 ? Math.max(1, renderPriority) : 0;
|
|
2341
2341
|
if (priority !== p) setPriority(p);
|
|
2342
2342
|
});
|
|
2343
|
-
React
|
|
2343
|
+
React.useEffect(() => {
|
|
2344
2344
|
if (events !== void 0) setEvents({ enabled: !events });
|
|
2345
2345
|
}, [events]);
|
|
2346
|
-
const [visible, setVisible] = React
|
|
2346
|
+
const [visible, setVisible] = React.useState(true);
|
|
2347
2347
|
const parent = useIntersect(setVisible);
|
|
2348
|
-
React
|
|
2348
|
+
React.useLayoutEffect(() => {
|
|
2349
2349
|
parent.current = ref.current?.__r3f?.parent?.object;
|
|
2350
2350
|
}, []);
|
|
2351
|
-
React
|
|
2351
|
+
React.useLayoutEffect(() => {
|
|
2352
2352
|
if (!parent.current) return;
|
|
2353
2353
|
if (blur && ref.current.sdf === null) {
|
|
2354
2354
|
const tempMesh = new THREE.Mesh(parent.current.geometry, new THREE.MeshBasicMaterial());
|
|
@@ -2369,8 +2369,8 @@ const MeshPortalMaterial = /* @__PURE__ */ React$1.forwardRef(({ children, event
|
|
|
2369
2369
|
gl.setRenderTarget(null);
|
|
2370
2370
|
}
|
|
2371
2371
|
}, [resolution, blur]);
|
|
2372
|
-
React
|
|
2373
|
-
const compute = React
|
|
2372
|
+
React.useImperativeHandle(fref, () => ref.current);
|
|
2373
|
+
const compute = React.useCallback((event, state, _previous) => {
|
|
2374
2374
|
if (!parent.current) return false;
|
|
2375
2375
|
state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
|
|
2376
2376
|
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
@@ -2410,13 +2410,13 @@ function ManagePortalScene({ events = void 0, rootScene, material, priority, wor
|
|
|
2410
2410
|
const setEvents = useThree((state) => state.setEvents);
|
|
2411
2411
|
const buffer1 = useFBO();
|
|
2412
2412
|
const buffer2 = useFBO();
|
|
2413
|
-
React
|
|
2413
|
+
React.useLayoutEffect(() => {
|
|
2414
2414
|
scene.matrixAutoUpdate = false;
|
|
2415
2415
|
}, []);
|
|
2416
|
-
React
|
|
2416
|
+
React.useEffect(() => {
|
|
2417
2417
|
if (events !== void 0) setEvents({ enabled: events });
|
|
2418
2418
|
}, [events]);
|
|
2419
|
-
const [quad, blendMat] = React
|
|
2419
|
+
const [quad, blendMat] = React.useMemo(() => {
|
|
2420
2420
|
const mat = new BlendMaterial();
|
|
2421
2421
|
mat.textureA = buffer1.texture;
|
|
2422
2422
|
mat.textureB = buffer2.texture;
|
|
@@ -2495,8 +2495,8 @@ var DistortMaterialImplWebGPU = class extends THREE.MeshPhysicalNodeMaterial {
|
|
|
2495
2495
|
* </mesh>
|
|
2496
2496
|
* ```
|
|
2497
2497
|
*/
|
|
2498
|
-
const MeshDistortMaterial = /* @__PURE__ */ React
|
|
2499
|
-
const [material] = React
|
|
2498
|
+
const MeshDistortMaterial = /* @__PURE__ */ React.forwardRef(({ speed = 1, ...props }, ref) => {
|
|
2499
|
+
const [material] = React.useState(() => new DistortMaterialImplWebGPU());
|
|
2500
2500
|
useFrame(({ elapsed }) => material && (material.time = elapsed * speed));
|
|
2501
2501
|
return /* @__PURE__ */ jsx("primitive", {
|
|
2502
2502
|
object: material,
|
|
@@ -2547,8 +2547,8 @@ var WobbleMaterialImpl = class extends THREE.MeshStandardNodeMaterial {
|
|
|
2547
2547
|
this.factorUniform.value = v$1;
|
|
2548
2548
|
}
|
|
2549
2549
|
};
|
|
2550
|
-
const MeshWobbleMaterial = /* @__PURE__ */ React
|
|
2551
|
-
const [material] = React
|
|
2550
|
+
const MeshWobbleMaterial = /* @__PURE__ */ React.forwardRef(({ speed = 1, ...props }, ref) => {
|
|
2551
|
+
const [material] = React.useState(() => new WobbleMaterialImpl());
|
|
2552
2552
|
useFrame((state) => material && (material.time = state.elapsed * speed));
|
|
2553
2553
|
return /* @__PURE__ */ jsx("primitive", {
|
|
2554
2554
|
object: material,
|
|
@@ -2647,14 +2647,14 @@ var OutlinesMaterial = class extends MeshBasicNodeMaterial {
|
|
|
2647
2647
|
}
|
|
2648
2648
|
};
|
|
2649
2649
|
function Outlines({ color = "black", opacity = 1, transparent = false, screenspace = false, toneMapped = true, polygonOffset = false, polygonOffsetFactor = 0, renderOrder = 0, thickness = .05, angle = Math.PI, clippingPlanes, ...props }) {
|
|
2650
|
-
const ref = React
|
|
2651
|
-
const [material] = React
|
|
2650
|
+
const ref = React.useRef(null);
|
|
2651
|
+
const [material] = React.useState(() => new OutlinesMaterial());
|
|
2652
2652
|
const { gl } = useThree();
|
|
2653
2653
|
const contextSize = gl.getDrawingBufferSize(new THREE.Vector2());
|
|
2654
|
-
React
|
|
2655
|
-
const oldAngle = React
|
|
2656
|
-
const oldGeometry = React
|
|
2657
|
-
React
|
|
2654
|
+
React.useMemo(() => extend({ OutlinesMaterial }), []);
|
|
2655
|
+
const oldAngle = React.useRef(0);
|
|
2656
|
+
const oldGeometry = React.useRef(null);
|
|
2657
|
+
React.useLayoutEffect(() => {
|
|
2658
2658
|
const group = ref.current;
|
|
2659
2659
|
if (!group) return;
|
|
2660
2660
|
const parent = group.parent;
|
|
@@ -2687,7 +2687,7 @@ function Outlines({ color = "black", opacity = 1, transparent = false, screenspa
|
|
|
2687
2687
|
}
|
|
2688
2688
|
}
|
|
2689
2689
|
});
|
|
2690
|
-
React
|
|
2690
|
+
React.useLayoutEffect(() => {
|
|
2691
2691
|
const group = ref.current;
|
|
2692
2692
|
if (!group) return;
|
|
2693
2693
|
const mesh = group.children[0];
|
|
@@ -2713,7 +2713,7 @@ function Outlines({ color = "black", opacity = 1, transparent = false, screenspa
|
|
|
2713
2713
|
});
|
|
2714
2714
|
}
|
|
2715
2715
|
});
|
|
2716
|
-
React
|
|
2716
|
+
React.useEffect(() => {
|
|
2717
2717
|
return () => {
|
|
2718
2718
|
const group = ref.current;
|
|
2719
2719
|
if (!group) return;
|
|
@@ -2748,11 +2748,11 @@ function Outlines({ color = "black", opacity = 1, transparent = false, screenspa
|
|
|
2748
2748
|
* </mesh>
|
|
2749
2749
|
* ```
|
|
2750
2750
|
*/
|
|
2751
|
-
const RenderCubeTexture = /* @__PURE__ */ React
|
|
2751
|
+
const RenderCubeTexture = /* @__PURE__ */ React.forwardRef(({ children, compute, renderPriority = -1, eventPriority = 0, frames = Infinity, stencilBuffer = false, depthBuffer = true, generateMipmaps = false, resolution = 896, near = .1, far = 1e3, flip = false, position: position$1, rotation: rotation$2, scale: scale$2, quaternion, matrix: matrix$1, matrixAutoUpdate, ...props }, forwardRef$1) => {
|
|
2752
2752
|
const { size, viewport } = useThree();
|
|
2753
2753
|
const fboSize = Math.max((resolution || size.width) * viewport.dpr, (resolution || size.height) * viewport.dpr);
|
|
2754
|
-
const fboRef = React
|
|
2755
|
-
const cameraRef = React
|
|
2754
|
+
const fboRef = React.useRef(null);
|
|
2755
|
+
const cameraRef = React.useRef(null);
|
|
2756
2756
|
if (!fboRef.current) {
|
|
2757
2757
|
const settings = {
|
|
2758
2758
|
stencilBuffer,
|
|
@@ -2776,9 +2776,9 @@ const RenderCubeTexture = /* @__PURE__ */ React$1.forwardRef(({ children, comput
|
|
|
2776
2776
|
const fboA = fboRef.current.a;
|
|
2777
2777
|
const fboB = fboRef.current.b;
|
|
2778
2778
|
const camera = cameraRef.current;
|
|
2779
|
-
const readBufferIndex = React
|
|
2780
|
-
const displayTextureRef = React
|
|
2781
|
-
React
|
|
2779
|
+
const readBufferIndex = React.useRef(0);
|
|
2780
|
+
const displayTextureRef = React.useRef(fboA.texture);
|
|
2781
|
+
React.useLayoutEffect(() => {
|
|
2782
2782
|
if (position$1) {
|
|
2783
2783
|
if (Array.isArray(position$1)) camera.position.set(...position$1);
|
|
2784
2784
|
else if (position$1 instanceof Vector3$2) camera.position.copy(position$1);
|
|
@@ -2807,7 +2807,7 @@ const RenderCubeTexture = /* @__PURE__ */ React$1.forwardRef(({ children, comput
|
|
|
2807
2807
|
matrix$1,
|
|
2808
2808
|
matrixAutoUpdate
|
|
2809
2809
|
]);
|
|
2810
|
-
React
|
|
2810
|
+
React.useEffect(() => {
|
|
2811
2811
|
return () => {
|
|
2812
2812
|
if (fboRef.current) {
|
|
2813
2813
|
fboRef.current.a.dispose();
|
|
@@ -2817,8 +2817,8 @@ const RenderCubeTexture = /* @__PURE__ */ React$1.forwardRef(({ children, comput
|
|
|
2817
2817
|
cameraRef.current = null;
|
|
2818
2818
|
};
|
|
2819
2819
|
}, []);
|
|
2820
|
-
const [vScene] = React
|
|
2821
|
-
React
|
|
2820
|
+
const [vScene] = React.useState(() => new Scene());
|
|
2821
|
+
React.useImperativeHandle(forwardRef$1, () => ({
|
|
2822
2822
|
scene: vScene,
|
|
2823
2823
|
get fbo() {
|
|
2824
2824
|
return readBufferIndex.current === 0 ? fboA : fboB;
|
|
@@ -2851,9 +2851,9 @@ const RenderCubeTexture = /* @__PURE__ */ React$1.forwardRef(({ children, comput
|
|
|
2851
2851
|
})] });
|
|
2852
2852
|
});
|
|
2853
2853
|
function DynamicTexture({ displayTextureRef, fboA, fboB, readBufferIndex, ...props }) {
|
|
2854
|
-
const materialRef = React
|
|
2854
|
+
const materialRef = React.useRef(null);
|
|
2855
2855
|
const attachKey = typeof props.attach === "string" ? props.attach : "envMap";
|
|
2856
|
-
const customAttach = React
|
|
2856
|
+
const customAttach = React.useCallback((parent, self) => {
|
|
2857
2857
|
const material = parent?.isMaterial ? parent : parent?.object;
|
|
2858
2858
|
if (!material) {
|
|
2859
2859
|
console.warn("RenderCubeTexture: Could not find parent material for attach");
|
|
@@ -2941,7 +2941,7 @@ function RenderHud({ defaultScene, defaultCamera, renderPriority = 1 }) {
|
|
|
2941
2941
|
*/
|
|
2942
2942
|
function Hud({ children, renderPriority = 1 }) {
|
|
2943
2943
|
const { scene: defaultScene, camera: defaultCamera } = useThree();
|
|
2944
|
-
const [hudScene] = React
|
|
2944
|
+
const [hudScene] = React.useState(() => new Scene());
|
|
2945
2945
|
return /* @__PURE__ */ jsx(Fragment$1, { children: createPortal(/* @__PURE__ */ jsxs(Fragment$1, { children: [children, /* @__PURE__ */ jsx(RenderHud, {
|
|
2946
2946
|
defaultScene,
|
|
2947
2947
|
defaultCamera,
|
|
@@ -2967,12 +2967,12 @@ function Hud({ children, renderPriority = 1 }) {
|
|
|
2967
2967
|
* />
|
|
2968
2968
|
* ```
|
|
2969
2969
|
*/
|
|
2970
|
-
const Line = /* @__PURE__ */ React
|
|
2970
|
+
const Line = /* @__PURE__ */ React.forwardRef(function Line$1({ points, color = 16777215, vertexColors, linewidth, lineWidth, segments, dashed, ...rest }, ref) {
|
|
2971
2971
|
const size = useThree((state) => state.size);
|
|
2972
|
-
const line2 = React
|
|
2973
|
-
const lineMaterial = React
|
|
2972
|
+
const line2 = React.useMemo(() => segments ? new LineSegments2() : new Line2(), [segments]);
|
|
2973
|
+
const lineMaterial = React.useMemo(() => new Line2NodeMaterial({ vertexColors: Boolean(vertexColors) }), [Boolean(vertexColors)]);
|
|
2974
2974
|
const itemSize = (vertexColors?.[0])?.length === 4 ? 4 : 3;
|
|
2975
|
-
const lineGeom = React
|
|
2975
|
+
const lineGeom = React.useMemo(() => {
|
|
2976
2976
|
const geom = segments ? new LineSegmentsGeometry() : new LineGeometry();
|
|
2977
2977
|
const pValues = points.map((p) => {
|
|
2978
2978
|
const isArray$1 = Array.isArray(p);
|
|
@@ -3020,10 +3020,10 @@ const Line = /* @__PURE__ */ React$1.forwardRef(function Line$1({ points, color
|
|
|
3020
3020
|
vertexColors,
|
|
3021
3021
|
itemSize
|
|
3022
3022
|
]);
|
|
3023
|
-
React
|
|
3023
|
+
React.useLayoutEffect(() => {
|
|
3024
3024
|
line2.computeLineDistances();
|
|
3025
3025
|
}, [points, line2]);
|
|
3026
|
-
React
|
|
3026
|
+
React.useLayoutEffect(() => {
|
|
3027
3027
|
if (dashed) lineMaterial.dashed = true;
|
|
3028
3028
|
else lineMaterial.dashed = false;
|
|
3029
3029
|
lineMaterial.needsUpdate = true;
|
|
@@ -3050,7 +3050,7 @@ const Line = /* @__PURE__ */ React$1.forwardRef(function Line$1({ points, color
|
|
|
3050
3050
|
|
|
3051
3051
|
//#endregion
|
|
3052
3052
|
//#region src/webgpu/Geometry/Segments/Segments.tsx
|
|
3053
|
-
const context$10 = /* @__PURE__ */ React
|
|
3053
|
+
const context$10 = /* @__PURE__ */ React.createContext(null);
|
|
3054
3054
|
/**
|
|
3055
3055
|
* High-performance line segments renderer.
|
|
3056
3056
|
* WebGPU version using Line2NodeMaterial.
|
|
@@ -3063,23 +3063,23 @@ const context$10 = /* @__PURE__ */ React$1.createContext(null);
|
|
|
3063
3063
|
* </Segments>
|
|
3064
3064
|
* ```
|
|
3065
3065
|
*/
|
|
3066
|
-
const Segments = /* @__PURE__ */ React
|
|
3067
|
-
React
|
|
3066
|
+
const Segments = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
|
|
3067
|
+
React.useMemo(() => extend({ SegmentObject }), []);
|
|
3068
3068
|
const { limit = 1e3, lineWidth = 1, children, ...rest } = props;
|
|
3069
|
-
const [segments, setSegments] = React
|
|
3070
|
-
const line = React
|
|
3071
|
-
const [geometry$1] = React
|
|
3072
|
-
const [resolution] = React
|
|
3073
|
-
const [positions] = React
|
|
3074
|
-
const [colors$1] = React
|
|
3075
|
-
const material = React
|
|
3069
|
+
const [segments, setSegments] = React.useState([]);
|
|
3070
|
+
const line = React.useMemo(() => new LineSegments2(), []);
|
|
3071
|
+
const [geometry$1] = React.useState(() => new LineSegmentsGeometry());
|
|
3072
|
+
const [resolution] = React.useState(() => new THREE.Vector2(512, 512));
|
|
3073
|
+
const [positions] = React.useState(() => Array(limit * 6).fill(0));
|
|
3074
|
+
const [colors$1] = React.useState(() => Array(limit * 6).fill(0));
|
|
3075
|
+
const material = React.useMemo(() => new THREE.Line2NodeMaterial({
|
|
3076
3076
|
color: 16777215,
|
|
3077
3077
|
linewidth: 1,
|
|
3078
3078
|
worldUnits: false,
|
|
3079
3079
|
vertexColors: true,
|
|
3080
3080
|
alphaToCoverage: true
|
|
3081
3081
|
}), []);
|
|
3082
|
-
const api = React
|
|
3082
|
+
const api = React.useMemo(() => ({ subscribe: (ref) => {
|
|
3083
3083
|
setSegments((segments$1) => [...segments$1, ref]);
|
|
3084
3084
|
return () => setSegments((segments$1) => segments$1.filter((item) => item.current !== ref.current));
|
|
3085
3085
|
} }), []);
|
|
@@ -3143,12 +3143,12 @@ const normPos = (pos) => pos instanceof THREE.Vector3 ? pos : new THREE.Vector3(
|
|
|
3143
3143
|
pos,
|
|
3144
3144
|
pos
|
|
3145
3145
|
] : pos);
|
|
3146
|
-
const Segment = /* @__PURE__ */ React
|
|
3147
|
-
const api = React
|
|
3146
|
+
const Segment = /* @__PURE__ */ React.forwardRef(({ color, start, end }, forwardedRef) => {
|
|
3147
|
+
const api = React.useContext(context$10);
|
|
3148
3148
|
if (!api) throw "Segment must used inside Segments component.";
|
|
3149
|
-
const ref = React
|
|
3150
|
-
React
|
|
3151
|
-
React
|
|
3149
|
+
const ref = React.useRef(null);
|
|
3150
|
+
React.useImperativeHandle(forwardedRef, () => ref.current, []);
|
|
3151
|
+
React.useLayoutEffect(() => api.subscribe(ref), []);
|
|
3152
3152
|
return /* @__PURE__ */ jsx("segmentObject", {
|
|
3153
3153
|
ref,
|
|
3154
3154
|
color,
|
|
@@ -3185,16 +3185,16 @@ function useTrail(target$1, settings, pointCount) {
|
|
|
3185
3185
|
...defaults,
|
|
3186
3186
|
...settings
|
|
3187
3187
|
};
|
|
3188
|
-
const points = React
|
|
3189
|
-
const [worldPosition] = React
|
|
3190
|
-
React
|
|
3188
|
+
const points = React.useRef(null);
|
|
3189
|
+
const [worldPosition] = React.useState(() => new Vector3$1());
|
|
3190
|
+
React.useLayoutEffect(() => {
|
|
3191
3191
|
if (target$1) {
|
|
3192
3192
|
const pos = target$1.position;
|
|
3193
3193
|
points.current = Float32Array.from({ length: pointCount * 3 }, (_, i$1) => pos.getComponent(i$1 % 3));
|
|
3194
3194
|
}
|
|
3195
3195
|
}, [pointCount, target$1]);
|
|
3196
|
-
const prevPosition = React
|
|
3197
|
-
const frameCount = React
|
|
3196
|
+
const prevPosition = React.useRef(new Vector3$1());
|
|
3197
|
+
const frameCount = React.useRef(0);
|
|
3198
3198
|
useFrame(() => {
|
|
3199
3199
|
if (!target$1) return;
|
|
3200
3200
|
if (!points.current) return;
|
|
@@ -3222,7 +3222,7 @@ function useTrail(target$1, settings, pointCount) {
|
|
|
3222
3222
|
* A declarative trail effect using Line2.
|
|
3223
3223
|
* WebGPU version using Line2NodeMaterial.
|
|
3224
3224
|
*/
|
|
3225
|
-
const Trail = /* @__PURE__ */ React
|
|
3225
|
+
const Trail = /* @__PURE__ */ React.forwardRef((props, forwardRef$1) => {
|
|
3226
3226
|
const { children } = props;
|
|
3227
3227
|
const { width, length: length$1, decay, local, stride, interval } = {
|
|
3228
3228
|
...defaults,
|
|
@@ -3231,8 +3231,8 @@ const Trail = /* @__PURE__ */ React$1.forwardRef((props, forwardRef$1) => {
|
|
|
3231
3231
|
const { color = "hotpink", attenuation, target: target$1 } = props;
|
|
3232
3232
|
const size = useThree((s) => s.size);
|
|
3233
3233
|
const scene = useThree((s) => s.scene);
|
|
3234
|
-
const ref = React
|
|
3235
|
-
const [anchor, setAnchor] = React
|
|
3234
|
+
const ref = React.useRef(null);
|
|
3235
|
+
const [anchor, setAnchor] = React.useState(null);
|
|
3236
3236
|
const pointCount = length$1 * 10;
|
|
3237
3237
|
const points = useTrail(anchor, {
|
|
3238
3238
|
decay,
|
|
@@ -3240,12 +3240,12 @@ const Trail = /* @__PURE__ */ React$1.forwardRef((props, forwardRef$1) => {
|
|
|
3240
3240
|
stride,
|
|
3241
3241
|
interval
|
|
3242
3242
|
}, pointCount);
|
|
3243
|
-
React
|
|
3243
|
+
React.useEffect(() => {
|
|
3244
3244
|
const t = target$1?.current || ref.current.children.find((o) => o instanceof Object3D);
|
|
3245
3245
|
if (t) setAnchor(t);
|
|
3246
3246
|
}, [points, target$1]);
|
|
3247
|
-
const line = React
|
|
3248
|
-
const geo = React
|
|
3247
|
+
const line = React.useMemo(() => new Line2(), []);
|
|
3248
|
+
const geo = React.useMemo(() => {
|
|
3249
3249
|
const geometry$1 = new LineGeometry();
|
|
3250
3250
|
const initialPositions = new Float32Array(pointCount * 3).fill(0);
|
|
3251
3251
|
const initialColors = new Float32Array(pointCount * 3).fill(1);
|
|
@@ -3253,10 +3253,10 @@ const Trail = /* @__PURE__ */ React$1.forwardRef((props, forwardRef$1) => {
|
|
|
3253
3253
|
geometry$1.setColors(initialColors);
|
|
3254
3254
|
return geometry$1;
|
|
3255
3255
|
}, [pointCount]);
|
|
3256
|
-
const [resolution] = React
|
|
3257
|
-
const colorsRef = React
|
|
3258
|
-
const baseColor = React
|
|
3259
|
-
const mat = React
|
|
3256
|
+
const [resolution] = React.useState(() => new Vector2$1(size.width, size.height));
|
|
3257
|
+
const colorsRef = React.useRef(new Float32Array(pointCount * 3));
|
|
3258
|
+
const baseColor = React.useMemo(() => new THREE.Color(color), [color]);
|
|
3259
|
+
const mat = React.useMemo(() => new Line2NodeMaterial({
|
|
3260
3260
|
color: 16777215,
|
|
3261
3261
|
linewidth: width,
|
|
3262
3262
|
worldUnits: false,
|
|
@@ -3264,7 +3264,7 @@ const Trail = /* @__PURE__ */ React$1.forwardRef((props, forwardRef$1) => {
|
|
|
3264
3264
|
transparent: true,
|
|
3265
3265
|
alphaToCoverage: true
|
|
3266
3266
|
}), [width]);
|
|
3267
|
-
React
|
|
3267
|
+
React.useEffect(() => {
|
|
3268
3268
|
resolution.set(size.width, size.height);
|
|
3269
3269
|
if ("resolution" in mat && mat.resolution?.set) mat.resolution.set(size.width, size.height);
|
|
3270
3270
|
}, [
|
|
@@ -3287,7 +3287,7 @@ const Trail = /* @__PURE__ */ React$1.forwardRef((props, forwardRef$1) => {
|
|
|
3287
3287
|
geo.setColors(colors$1);
|
|
3288
3288
|
line.computeLineDistances();
|
|
3289
3289
|
});
|
|
3290
|
-
React
|
|
3290
|
+
React.useLayoutEffect(() => {
|
|
3291
3291
|
line.geometry = geo;
|
|
3292
3292
|
line.material = mat;
|
|
3293
3293
|
}, [
|
|
@@ -3435,21 +3435,21 @@ const isFunction$1 = (node) => typeof node === "function";
|
|
|
3435
3435
|
* </OrthographicCamera>
|
|
3436
3436
|
* ```
|
|
3437
3437
|
*/
|
|
3438
|
-
const OrthographicCamera = /* @__PURE__ */ React
|
|
3438
|
+
const OrthographicCamera = /* @__PURE__ */ React.forwardRef(({ envMap, resolution = 256, frames = Infinity, children, makeDefault, ...props }, ref) => {
|
|
3439
3439
|
const set = useThree(({ set: set$1 }) => set$1);
|
|
3440
3440
|
const camera = useThree(({ camera: camera$1 }) => camera$1);
|
|
3441
3441
|
const size = useThree(({ size: size$1 }) => size$1);
|
|
3442
|
-
const cameraRef = React
|
|
3443
|
-
React
|
|
3444
|
-
const groupRef = React
|
|
3442
|
+
const cameraRef = React.useRef(null);
|
|
3443
|
+
React.useImperativeHandle(ref, () => cameraRef.current, []);
|
|
3444
|
+
const groupRef = React.useRef(null);
|
|
3445
3445
|
const fbo = useFBO(resolution);
|
|
3446
|
-
React
|
|
3446
|
+
React.useLayoutEffect(() => {
|
|
3447
3447
|
if (!props.manual) cameraRef.current.updateProjectionMatrix();
|
|
3448
3448
|
}, [size, props]);
|
|
3449
|
-
React
|
|
3449
|
+
React.useLayoutEffect(() => {
|
|
3450
3450
|
cameraRef.current.updateProjectionMatrix();
|
|
3451
3451
|
});
|
|
3452
|
-
React
|
|
3452
|
+
React.useLayoutEffect(() => {
|
|
3453
3453
|
if (makeDefault) {
|
|
3454
3454
|
const oldCam = camera;
|
|
3455
3455
|
set(() => ({ camera: cameraRef.current }));
|
|
@@ -3521,18 +3521,18 @@ const isFunction = (node) => typeof node === "function";
|
|
|
3521
3521
|
* </PerspectiveCamera>
|
|
3522
3522
|
* ```
|
|
3523
3523
|
*/
|
|
3524
|
-
const PerspectiveCamera = /* @__PURE__ */ React
|
|
3524
|
+
const PerspectiveCamera = /* @__PURE__ */ React.forwardRef(({ envMap, resolution = 256, frames = Infinity, makeDefault, children, ...props }, ref) => {
|
|
3525
3525
|
const set = useThree(({ set: set$1 }) => set$1);
|
|
3526
3526
|
const camera = useThree(({ camera: camera$1 }) => camera$1);
|
|
3527
3527
|
const size = useThree(({ size: size$1 }) => size$1);
|
|
3528
|
-
const cameraRef = React
|
|
3529
|
-
React
|
|
3530
|
-
const groupRef = React
|
|
3528
|
+
const cameraRef = React.useRef(null);
|
|
3529
|
+
React.useImperativeHandle(ref, () => cameraRef.current, []);
|
|
3530
|
+
const groupRef = React.useRef(null);
|
|
3531
3531
|
const fbo = useFBO(resolution);
|
|
3532
|
-
React
|
|
3532
|
+
React.useLayoutEffect(() => {
|
|
3533
3533
|
if (!props.manual) cameraRef.current.aspect = size.width / size.height;
|
|
3534
3534
|
}, [size, props]);
|
|
3535
|
-
React
|
|
3535
|
+
React.useLayoutEffect(() => {
|
|
3536
3536
|
cameraRef.current.updateProjectionMatrix();
|
|
3537
3537
|
});
|
|
3538
3538
|
let count = 0;
|
|
@@ -3551,7 +3551,7 @@ const PerspectiveCamera = /* @__PURE__ */ React$1.forwardRef(({ envMap, resoluti
|
|
|
3551
3551
|
count++;
|
|
3552
3552
|
}
|
|
3553
3553
|
});
|
|
3554
|
-
React
|
|
3554
|
+
React.useLayoutEffect(() => {
|
|
3555
3555
|
if (makeDefault) {
|
|
3556
3556
|
const oldCam = camera;
|
|
3557
3557
|
set(() => ({ camera: cameraRef.current }));
|
|
@@ -3650,15 +3650,15 @@ const ArcballControls = /* @__PURE__ */ forwardRef(({ camera, makeDefault, regre
|
|
|
3650
3650
|
* <DeviceOrientationControls />
|
|
3651
3651
|
* ```
|
|
3652
3652
|
*/
|
|
3653
|
-
const DeviceOrientationControls = /* @__PURE__ */ React
|
|
3653
|
+
const DeviceOrientationControls = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
3654
3654
|
const { camera, onChange, makeDefault, ...rest } = props;
|
|
3655
3655
|
const defaultCamera = useThree((state) => state.camera);
|
|
3656
3656
|
const invalidate = useThree((state) => state.invalidate);
|
|
3657
3657
|
const get = useThree((state) => state.get);
|
|
3658
3658
|
const set = useThree((state) => state.set);
|
|
3659
3659
|
const explCamera = camera || defaultCamera;
|
|
3660
|
-
const controls = React
|
|
3661
|
-
React
|
|
3660
|
+
const controls = React.useMemo(() => new DeviceOrientationControls$1(explCamera), [explCamera]);
|
|
3661
|
+
React.useEffect(() => {
|
|
3662
3662
|
const callback = (e) => {
|
|
3663
3663
|
invalidate();
|
|
3664
3664
|
if (onChange) onChange(e);
|
|
@@ -3671,12 +3671,12 @@ const DeviceOrientationControls = /* @__PURE__ */ React$1.forwardRef((props, ref
|
|
|
3671
3671
|
invalidate
|
|
3672
3672
|
]);
|
|
3673
3673
|
useFrame(() => controls?.update(), -1);
|
|
3674
|
-
React
|
|
3674
|
+
React.useEffect(() => {
|
|
3675
3675
|
const current = controls;
|
|
3676
3676
|
current?.connect();
|
|
3677
3677
|
return () => current?.dispose();
|
|
3678
3678
|
}, [controls]);
|
|
3679
|
-
React
|
|
3679
|
+
React.useEffect(() => {
|
|
3680
3680
|
if (makeDefault) {
|
|
3681
3681
|
const old = get().controls;
|
|
3682
3682
|
set({ controls });
|
|
@@ -3720,10 +3720,10 @@ const dragPlane = /* @__PURE__ */ new Plane$1();
|
|
|
3720
3720
|
* />
|
|
3721
3721
|
* ```
|
|
3722
3722
|
*/
|
|
3723
|
-
const DragControls = React
|
|
3723
|
+
const DragControls = React.forwardRef(({ autoTransform = true, matrix: matrix$1, axisLock, dragLimits, onHover, onDragStart, onDrag, onDragEnd, children, dragConfig, ...props }, fRef) => {
|
|
3724
3724
|
const defaultControls = useThree((state) => state.controls);
|
|
3725
3725
|
const { camera, size, raycaster, invalidate } = useThree();
|
|
3726
|
-
const ref = React
|
|
3726
|
+
const ref = React.useRef(null);
|
|
3727
3727
|
const bind = (0, import_use_gesture_react_cjs.useGesture)({
|
|
3728
3728
|
onHover: ({ hovering }) => onHover && onHover(hovering ?? false),
|
|
3729
3729
|
onDragStart: ({ event }) => {
|
|
@@ -3787,8 +3787,8 @@ const DragControls = React$1.forwardRef(({ autoTransform = true, matrix: matrix$
|
|
|
3787
3787
|
threshold: 1,
|
|
3788
3788
|
...typeof dragConfig === "object" ? dragConfig : {}
|
|
3789
3789
|
} });
|
|
3790
|
-
React
|
|
3791
|
-
React
|
|
3790
|
+
React.useImperativeHandle(fRef, () => ref.current, []);
|
|
3791
|
+
React.useLayoutEffect(() => {
|
|
3792
3792
|
if (!matrix$1) return;
|
|
3793
3793
|
ref.current.matrix = matrix$1;
|
|
3794
3794
|
}, [matrix$1]);
|
|
@@ -3813,15 +3813,15 @@ const DragControls = React$1.forwardRef(({ autoTransform = true, matrix: matrix$
|
|
|
3813
3813
|
* <FirstPersonControls />
|
|
3814
3814
|
* ```
|
|
3815
3815
|
*/
|
|
3816
|
-
const FirstPersonControls = /* @__PURE__ */ React
|
|
3816
|
+
const FirstPersonControls = /* @__PURE__ */ React.forwardRef(({ domElement, makeDefault, ...props }, ref) => {
|
|
3817
3817
|
const camera = useThree((state) => state.camera);
|
|
3818
3818
|
const gl = useThree((state) => state.gl);
|
|
3819
3819
|
const events = useThree((state) => state.events);
|
|
3820
3820
|
const get = useThree((state) => state.get);
|
|
3821
3821
|
const set = useThree((state) => state.set);
|
|
3822
3822
|
const explDomElement = domElement || events.connected || gl.domElement;
|
|
3823
|
-
const [controls] = React
|
|
3824
|
-
React
|
|
3823
|
+
const [controls] = React.useState(() => new FirstPersonControls$1(camera, explDomElement));
|
|
3824
|
+
React.useEffect(() => {
|
|
3825
3825
|
if (makeDefault) {
|
|
3826
3826
|
const old = get().controls;
|
|
3827
3827
|
set({ controls });
|
|
@@ -3849,7 +3849,7 @@ const FirstPersonControls = /* @__PURE__ */ React$1.forwardRef(({ domElement, ma
|
|
|
3849
3849
|
* <FlyControls movementSpeed={2} rollSpeed={Math.PI / 6} />
|
|
3850
3850
|
* ```
|
|
3851
3851
|
*/
|
|
3852
|
-
const FlyControls = /* @__PURE__ */ React
|
|
3852
|
+
const FlyControls = /* @__PURE__ */ React.forwardRef(({ domElement, ...props }, fref) => {
|
|
3853
3853
|
const { onChange, makeDefault, ...rest } = props;
|
|
3854
3854
|
const invalidate = useThree((state) => state.invalidate);
|
|
3855
3855
|
const camera = useThree((state) => state.camera);
|
|
@@ -3858,8 +3858,8 @@ const FlyControls = /* @__PURE__ */ React$1.forwardRef(({ domElement, ...props }
|
|
|
3858
3858
|
const get = useThree((state) => state.get);
|
|
3859
3859
|
const set = useThree((state) => state.set);
|
|
3860
3860
|
const explDomElement = domElement || events.connected || gl.domElement;
|
|
3861
|
-
const controls = React
|
|
3862
|
-
React
|
|
3861
|
+
const controls = React.useMemo(() => new FlyControls$1(camera), [camera]);
|
|
3862
|
+
React.useEffect(() => {
|
|
3863
3863
|
controls.connect(explDomElement);
|
|
3864
3864
|
return () => void controls.dispose();
|
|
3865
3865
|
}, [
|
|
@@ -3867,7 +3867,7 @@ const FlyControls = /* @__PURE__ */ React$1.forwardRef(({ domElement, ...props }
|
|
|
3867
3867
|
controls,
|
|
3868
3868
|
invalidate
|
|
3869
3869
|
]);
|
|
3870
|
-
React
|
|
3870
|
+
React.useEffect(() => {
|
|
3871
3871
|
const callback = (e) => {
|
|
3872
3872
|
invalidate();
|
|
3873
3873
|
if (onChange) onChange(e);
|
|
@@ -3875,7 +3875,7 @@ const FlyControls = /* @__PURE__ */ React$1.forwardRef(({ domElement, ...props }
|
|
|
3875
3875
|
controls.addEventListener?.("change", callback);
|
|
3876
3876
|
return () => controls.removeEventListener?.("change", callback);
|
|
3877
3877
|
}, [onChange, invalidate]);
|
|
3878
|
-
React
|
|
3878
|
+
React.useEffect(() => {
|
|
3879
3879
|
if (makeDefault) {
|
|
3880
3880
|
const old = get().controls;
|
|
3881
3881
|
set({ controls });
|
|
@@ -3893,7 +3893,7 @@ const FlyControls = /* @__PURE__ */ React$1.forwardRef(({ domElement, ...props }
|
|
|
3893
3893
|
|
|
3894
3894
|
//#endregion
|
|
3895
3895
|
//#region src/core/Controls/KeyboardControls/KeyboardControls.tsx
|
|
3896
|
-
const context$9 = /* @__PURE__ */ React
|
|
3896
|
+
const context$9 = /* @__PURE__ */ React.createContext(null);
|
|
3897
3897
|
/**
|
|
3898
3898
|
* A rudimentary keyboard controller which distributes your defined data-model
|
|
3899
3899
|
* to the `useKeyboardControls` hook. It's a rather simple way to get started with keyboard input.
|
|
@@ -3934,19 +3934,19 @@ const context$9 = /* @__PURE__ */ React$1.createContext(null);
|
|
|
3934
3934
|
*/
|
|
3935
3935
|
function KeyboardControls({ map, children, onChange, domElement }) {
|
|
3936
3936
|
const key = map.map((item) => item.name + item.keys).join("-");
|
|
3937
|
-
const useControls = React
|
|
3937
|
+
const useControls = React.useMemo(() => {
|
|
3938
3938
|
return create$1(subscribeWithSelector(() => map.reduce((prev, cur) => ({
|
|
3939
3939
|
...prev,
|
|
3940
3940
|
[cur.name]: false
|
|
3941
3941
|
}), {})));
|
|
3942
3942
|
}, [key]);
|
|
3943
|
-
const api = React
|
|
3943
|
+
const api = React.useMemo(() => [
|
|
3944
3944
|
useControls.subscribe,
|
|
3945
3945
|
useControls.getState,
|
|
3946
3946
|
useControls
|
|
3947
3947
|
], [key]);
|
|
3948
3948
|
const set = useControls.setState;
|
|
3949
|
-
React
|
|
3949
|
+
React.useEffect(() => {
|
|
3950
3950
|
const keyMap = map.map(({ name, keys, up }) => ({
|
|
3951
3951
|
keys,
|
|
3952
3952
|
up,
|
|
@@ -3990,7 +3990,7 @@ function KeyboardControls({ map, children, onChange, domElement }) {
|
|
|
3990
3990
|
});
|
|
3991
3991
|
}
|
|
3992
3992
|
function useKeyboardControls(sel) {
|
|
3993
|
-
const [sub$1, get, store] = React
|
|
3993
|
+
const [sub$1, get, store] = React.useContext(context$9);
|
|
3994
3994
|
if (sel) return store(sel);
|
|
3995
3995
|
else return [sub$1, get];
|
|
3996
3996
|
}
|
|
@@ -4006,7 +4006,7 @@ function useKeyboardControls(sel) {
|
|
|
4006
4006
|
* <MapControls enableDamping dampingFactor={0.05} />
|
|
4007
4007
|
* ```
|
|
4008
4008
|
*/
|
|
4009
|
-
const MapControls = /* @__PURE__ */ React
|
|
4009
|
+
const MapControls = /* @__PURE__ */ React.forwardRef((props = { enableDamping: true }, ref) => {
|
|
4010
4010
|
const { domElement, camera, makeDefault, onChange, onStart, onEnd, ...rest } = props;
|
|
4011
4011
|
const invalidate = useThree((state) => state.invalidate);
|
|
4012
4012
|
const defaultCamera = useThree((state) => state.camera);
|
|
@@ -4016,8 +4016,8 @@ const MapControls = /* @__PURE__ */ React$1.forwardRef((props = { enableDamping:
|
|
|
4016
4016
|
const get = useThree((state) => state.get);
|
|
4017
4017
|
const explDomElement = domElement || events.connected || gl.domElement;
|
|
4018
4018
|
const explCamera = camera || defaultCamera;
|
|
4019
|
-
const controls = React
|
|
4020
|
-
React
|
|
4019
|
+
const controls = React.useMemo(() => new MapControls$1(explCamera), [explCamera]);
|
|
4020
|
+
React.useEffect(() => {
|
|
4021
4021
|
controls.connect(explDomElement);
|
|
4022
4022
|
const callback = (e) => {
|
|
4023
4023
|
invalidate();
|
|
@@ -4040,7 +4040,7 @@ const MapControls = /* @__PURE__ */ React$1.forwardRef((props = { enableDamping:
|
|
|
4040
4040
|
invalidate,
|
|
4041
4041
|
explDomElement
|
|
4042
4042
|
]);
|
|
4043
|
-
React
|
|
4043
|
+
React.useEffect(() => {
|
|
4044
4044
|
if (makeDefault) {
|
|
4045
4045
|
const old = get().controls;
|
|
4046
4046
|
set({ controls });
|
|
@@ -4060,19 +4060,19 @@ const MapControls = /* @__PURE__ */ React$1.forwardRef((props = { enableDamping:
|
|
|
4060
4060
|
//#region src/core/Controls/MotionPathControls/MotionPathControls.tsx
|
|
4061
4061
|
var import_maath_cjs = require_maath_cjs();
|
|
4062
4062
|
const isObject3DRef = (ref) => ref?.current instanceof Object3D$1;
|
|
4063
|
-
const MotionContext = /* @__PURE__ */ React
|
|
4063
|
+
const MotionContext = /* @__PURE__ */ React.createContext(null);
|
|
4064
4064
|
function useMotion() {
|
|
4065
|
-
const context$11 = React
|
|
4065
|
+
const context$11 = React.useContext(MotionContext);
|
|
4066
4066
|
if (!context$11) throw new Error("useMotion hook must be used in a MotionPathControls component.");
|
|
4067
4067
|
return context$11;
|
|
4068
4068
|
}
|
|
4069
4069
|
function Debug({ points = 50, color = "black" }) {
|
|
4070
4070
|
const { path } = useMotion();
|
|
4071
|
-
const [dots, setDots] = React
|
|
4072
|
-
const material = React
|
|
4073
|
-
const geometry$1 = React
|
|
4074
|
-
const last = React
|
|
4075
|
-
React
|
|
4071
|
+
const [dots, setDots] = React.useState([]);
|
|
4072
|
+
const material = React.useMemo(() => new MeshBasicMaterial({ color }), [color]);
|
|
4073
|
+
const geometry$1 = React.useMemo(() => new SphereGeometry(.025, 16, 16), []);
|
|
4074
|
+
const last = React.useRef([]);
|
|
4075
|
+
React.useEffect(() => {
|
|
4076
4076
|
if (path.curves !== last.current) {
|
|
4077
4077
|
setDots(path.getPoints(points));
|
|
4078
4078
|
last.current = path.curves;
|
|
@@ -4115,12 +4115,12 @@ function Debug({ points = 50, color = "black" }) {
|
|
|
4115
4115
|
* }
|
|
4116
4116
|
* ```
|
|
4117
4117
|
*/
|
|
4118
|
-
const MotionPathControls = /* @__PURE__ */ React
|
|
4118
|
+
const MotionPathControls = /* @__PURE__ */ React.forwardRef(({ children, curves = [], debug = false, debugColor = "black", object, focus, loop = true, offset = void 0, smooth = false, eps: eps$1 = 1e-5, damping = .1, focusDamping = .1, maxSpeed = Infinity, ...props }, fref) => {
|
|
4119
4119
|
const { camera } = useThree();
|
|
4120
|
-
const ref = React
|
|
4121
|
-
const pos = React
|
|
4122
|
-
const path = React
|
|
4123
|
-
const state = React
|
|
4120
|
+
const ref = React.useRef(null);
|
|
4121
|
+
const pos = React.useRef(offset ?? 0);
|
|
4122
|
+
const path = React.useMemo(() => new CurvePath(), []);
|
|
4123
|
+
const state = React.useMemo(() => ({
|
|
4124
4124
|
focus,
|
|
4125
4125
|
object: object?.current instanceof Object3D$1 ? object : { current: camera },
|
|
4126
4126
|
path,
|
|
@@ -4131,7 +4131,7 @@ const MotionPathControls = /* @__PURE__ */ React$1.forwardRef(({ children, curve
|
|
|
4131
4131
|
next: new Vector3$2()
|
|
4132
4132
|
}), [focus, object]);
|
|
4133
4133
|
const instanceRef = useInstanceHandle(ref);
|
|
4134
|
-
React
|
|
4134
|
+
React.useLayoutEffect(() => {
|
|
4135
4135
|
const instance = instanceRef.current;
|
|
4136
4136
|
path.curves = [];
|
|
4137
4137
|
const _curves = curves.length > 0 ? curves : instance.children.map((instance$1) => instance$1.object);
|
|
@@ -4142,11 +4142,11 @@ const MotionPathControls = /* @__PURE__ */ React$1.forwardRef(({ children, curve
|
|
|
4142
4142
|
}
|
|
4143
4143
|
path.updateArcLengths();
|
|
4144
4144
|
});
|
|
4145
|
-
React
|
|
4146
|
-
React
|
|
4145
|
+
React.useImperativeHandle(fref, () => Object.assign(ref.current, { motion: state }), [state]);
|
|
4146
|
+
React.useLayoutEffect(() => {
|
|
4147
4147
|
pos.current = import_maath_cjs.misc.repeat(pos.current, 1);
|
|
4148
4148
|
}, [offset]);
|
|
4149
|
-
const vec = React
|
|
4149
|
+
const vec = React.useMemo(() => new Vector3$2(), []);
|
|
4150
4150
|
useFrame((_state, delta) => {
|
|
4151
4151
|
const lastOffset = state.offset;
|
|
4152
4152
|
import_maath_cjs.easing.damp(pos, "current", offset !== void 0 ? offset : state.current, damping, delta, maxSpeed, void 0, eps$1);
|
|
@@ -4186,7 +4186,7 @@ const MotionPathControls = /* @__PURE__ */ React$1.forwardRef(({ children, curve
|
|
|
4186
4186
|
* <OrbitControls makeDefault enableDamping dampingFactor={0.05} />
|
|
4187
4187
|
* ```
|
|
4188
4188
|
*/
|
|
4189
|
-
const OrbitControls = /* @__PURE__ */ React
|
|
4189
|
+
const OrbitControls = /* @__PURE__ */ React.forwardRef(({ makeDefault, camera, regress, domElement, enableDamping = true, keyEvents = false, onChange, onStart, onEnd, ...restProps }, ref) => {
|
|
4190
4190
|
const invalidate = useThree((state) => state.invalidate);
|
|
4191
4191
|
const defaultCamera = useThree((state) => state.camera);
|
|
4192
4192
|
const gl = useThree((state) => state.gl);
|
|
@@ -4197,11 +4197,11 @@ const OrbitControls = /* @__PURE__ */ React$1.forwardRef(({ makeDefault, camera,
|
|
|
4197
4197
|
const performance$1 = useThree((state) => state.performance);
|
|
4198
4198
|
const explCamera = camera || defaultCamera;
|
|
4199
4199
|
const explDomElement = domElement || events.connected || gl.domElement;
|
|
4200
|
-
const controls = React
|
|
4200
|
+
const controls = React.useMemo(() => new OrbitControls$1(explCamera), [explCamera]);
|
|
4201
4201
|
useFrame(() => {
|
|
4202
4202
|
if (controls.enabled) controls.update();
|
|
4203
4203
|
}, -1);
|
|
4204
|
-
React
|
|
4204
|
+
React.useEffect(() => {
|
|
4205
4205
|
if (keyEvents) controls.connect(keyEvents === true ? explDomElement : keyEvents);
|
|
4206
4206
|
controls.connect(explDomElement);
|
|
4207
4207
|
return () => void controls.dispose();
|
|
@@ -4212,7 +4212,7 @@ const OrbitControls = /* @__PURE__ */ React$1.forwardRef(({ makeDefault, camera,
|
|
|
4212
4212
|
controls,
|
|
4213
4213
|
invalidate
|
|
4214
4214
|
]);
|
|
4215
|
-
React
|
|
4215
|
+
React.useEffect(() => {
|
|
4216
4216
|
const callback = (e) => {
|
|
4217
4217
|
invalidate();
|
|
4218
4218
|
if (regress) performance$1.regress();
|
|
@@ -4240,7 +4240,7 @@ const OrbitControls = /* @__PURE__ */ React$1.forwardRef(({ makeDefault, camera,
|
|
|
4240
4240
|
invalidate,
|
|
4241
4241
|
setEvents
|
|
4242
4242
|
]);
|
|
4243
|
-
React
|
|
4243
|
+
React.useEffect(() => {
|
|
4244
4244
|
if (makeDefault) {
|
|
4245
4245
|
const old = get().controls;
|
|
4246
4246
|
set({ controls });
|
|
@@ -4266,7 +4266,7 @@ const OrbitControls = /* @__PURE__ */ React$1.forwardRef(({ makeDefault, camera,
|
|
|
4266
4266
|
* <PointerLockControls selector="#button" />
|
|
4267
4267
|
* ```
|
|
4268
4268
|
*/
|
|
4269
|
-
const PointerLockControls = /* @__PURE__ */ React
|
|
4269
|
+
const PointerLockControls = /* @__PURE__ */ React.forwardRef(({ domElement, selector, onChange, onLock, onUnlock, enabled = true, makeDefault, ...props }, ref) => {
|
|
4270
4270
|
const { camera, ...rest } = props;
|
|
4271
4271
|
const setEvents = useThree((state) => state.setEvents);
|
|
4272
4272
|
const gl = useThree((state) => state.gl);
|
|
@@ -4277,8 +4277,8 @@ const PointerLockControls = /* @__PURE__ */ React$1.forwardRef(({ domElement, se
|
|
|
4277
4277
|
const set = useThree((state) => state.set);
|
|
4278
4278
|
const explCamera = camera || defaultCamera;
|
|
4279
4279
|
const explDomElement = domElement || events.connected || gl.domElement;
|
|
4280
|
-
const controls = React
|
|
4281
|
-
React
|
|
4280
|
+
const controls = React.useMemo(() => new PointerLockControls$1(explCamera), [explCamera]);
|
|
4281
|
+
React.useEffect(() => {
|
|
4282
4282
|
if (enabled) {
|
|
4283
4283
|
controls.connect(explDomElement);
|
|
4284
4284
|
const oldComputeOffsets = get().events.compute;
|
|
@@ -4294,7 +4294,7 @@ const PointerLockControls = /* @__PURE__ */ React$1.forwardRef(({ domElement, se
|
|
|
4294
4294
|
};
|
|
4295
4295
|
}
|
|
4296
4296
|
}, [enabled, controls]);
|
|
4297
|
-
React
|
|
4297
|
+
React.useEffect(() => {
|
|
4298
4298
|
const callback = (e) => {
|
|
4299
4299
|
invalidate();
|
|
4300
4300
|
if (onChange) onChange(e);
|
|
@@ -4319,7 +4319,7 @@ const PointerLockControls = /* @__PURE__ */ React$1.forwardRef(({ domElement, se
|
|
|
4319
4319
|
controls,
|
|
4320
4320
|
invalidate
|
|
4321
4321
|
]);
|
|
4322
|
-
React
|
|
4322
|
+
React.useEffect(() => {
|
|
4323
4323
|
if (makeDefault) {
|
|
4324
4324
|
const old = get().controls;
|
|
4325
4325
|
set({ controls });
|
|
@@ -4367,17 +4367,17 @@ function PresentationControls({ enabled = true, snap, global, domElement, cursor
|
|
|
4367
4367
|
const gl = useThree((state) => state.gl);
|
|
4368
4368
|
const explDomElement = domElement || events.connected || gl.domElement;
|
|
4369
4369
|
const { size } = useThree();
|
|
4370
|
-
const rPolar = React
|
|
4370
|
+
const rPolar = React.useMemo(() => [rotation$2[0] + polar[0], rotation$2[0] + polar[1]], [
|
|
4371
4371
|
rotation$2[0],
|
|
4372
4372
|
polar[0],
|
|
4373
4373
|
polar[1]
|
|
4374
4374
|
]);
|
|
4375
|
-
const rAzimuth = React
|
|
4375
|
+
const rAzimuth = React.useMemo(() => [rotation$2[1] + azimuth[0], rotation$2[1] + azimuth[1]], [
|
|
4376
4376
|
rotation$2[1],
|
|
4377
4377
|
azimuth[0],
|
|
4378
4378
|
azimuth[1]
|
|
4379
4379
|
]);
|
|
4380
|
-
const rInitial = React
|
|
4380
|
+
const rInitial = React.useMemo(() => [
|
|
4381
4381
|
MathUtils.clamp(rotation$2[0], ...rPolar),
|
|
4382
4382
|
MathUtils.clamp(rotation$2[1], ...rAzimuth),
|
|
4383
4383
|
rotation$2[2]
|
|
@@ -4388,7 +4388,7 @@ function PresentationControls({ enabled = true, snap, global, domElement, cursor
|
|
|
4388
4388
|
rPolar,
|
|
4389
4389
|
rAzimuth
|
|
4390
4390
|
]);
|
|
4391
|
-
React
|
|
4391
|
+
React.useEffect(() => {
|
|
4392
4392
|
if (global && cursor && enabled) {
|
|
4393
4393
|
explDomElement.style.cursor = "grab";
|
|
4394
4394
|
gl.domElement.style.cursor = "";
|
|
@@ -4403,12 +4403,12 @@ function PresentationControls({ enabled = true, snap, global, domElement, cursor
|
|
|
4403
4403
|
explDomElement,
|
|
4404
4404
|
enabled
|
|
4405
4405
|
]);
|
|
4406
|
-
const [animation] = React
|
|
4406
|
+
const [animation] = React.useState({
|
|
4407
4407
|
scale: 1,
|
|
4408
4408
|
rotation: rInitial,
|
|
4409
4409
|
damping
|
|
4410
4410
|
});
|
|
4411
|
-
const ref = React
|
|
4411
|
+
const ref = React.useRef(null);
|
|
4412
4412
|
useFrame((state, delta) => {
|
|
4413
4413
|
import_maath_cjs.easing.damp3(ref.current.scale, animation.scale, animation.damping, delta);
|
|
4414
4414
|
import_maath_cjs.easing.dampE(ref.current.rotation, animation.rotation, animation.damping, delta);
|
|
@@ -4440,12 +4440,12 @@ function PresentationControls({ enabled = true, snap, global, domElement, cursor
|
|
|
4440
4440
|
|
|
4441
4441
|
//#endregion
|
|
4442
4442
|
//#region src/core/Controls/ScrollControls/ScrollControls.tsx
|
|
4443
|
-
const context$8 = /* @__PURE__ */ React
|
|
4443
|
+
const context$8 = /* @__PURE__ */ React.createContext(null);
|
|
4444
4444
|
/**
|
|
4445
4445
|
* Hook to access scroll state: offset (0-1), delta, range(), curve(), visible().
|
|
4446
4446
|
*/
|
|
4447
4447
|
function useScroll() {
|
|
4448
|
-
return React
|
|
4448
|
+
return React.useContext(context$8);
|
|
4449
4449
|
}
|
|
4450
4450
|
/**
|
|
4451
4451
|
* Scroll controls create an HTML scroll container in front of the canvas.
|
|
@@ -4472,12 +4472,12 @@ function useScroll() {
|
|
|
4472
4472
|
*/
|
|
4473
4473
|
function ScrollControls({ eps: eps$1 = 1e-5, enabled = true, infinite, horizontal, pages = 1, distance: distance$1 = 1, damping = .25, maxSpeed = Infinity, prepend = false, style = {}, children }) {
|
|
4474
4474
|
const { get, setEvents, gl, size, invalidate, events } = useThree();
|
|
4475
|
-
const [el] = React
|
|
4476
|
-
const [fill] = React
|
|
4477
|
-
const [fixed] = React
|
|
4475
|
+
const [el] = React.useState(() => document.createElement("div"));
|
|
4476
|
+
const [fill] = React.useState(() => document.createElement("div"));
|
|
4477
|
+
const [fixed] = React.useState(() => document.createElement("div"));
|
|
4478
4478
|
const target$1 = gl.domElement.parentNode;
|
|
4479
|
-
const scroll = React
|
|
4480
|
-
const state = React
|
|
4479
|
+
const scroll = React.useRef(0);
|
|
4480
|
+
const state = React.useMemo(() => {
|
|
4481
4481
|
return {
|
|
4482
4482
|
el,
|
|
4483
4483
|
eps: eps$1,
|
|
@@ -4509,7 +4509,7 @@ function ScrollControls({ eps: eps$1 = 1e-5, enabled = true, infinite, horizonta
|
|
|
4509
4509
|
horizontal,
|
|
4510
4510
|
pages
|
|
4511
4511
|
]);
|
|
4512
|
-
React
|
|
4512
|
+
React.useEffect(() => {
|
|
4513
4513
|
el.style.position = "absolute";
|
|
4514
4514
|
el.style.width = "100%";
|
|
4515
4515
|
el.style.height = "100%";
|
|
@@ -4556,7 +4556,7 @@ function ScrollControls({ eps: eps$1 = 1e-5, enabled = true, infinite, horizonta
|
|
|
4556
4556
|
fixed,
|
|
4557
4557
|
target$1
|
|
4558
4558
|
]);
|
|
4559
|
-
React
|
|
4559
|
+
React.useEffect(() => {
|
|
4560
4560
|
if (events.connected === el) {
|
|
4561
4561
|
const containerLength = size[horizontal ? "width" : "height"];
|
|
4562
4562
|
const scrollLength = el[horizontal ? "scrollWidth" : "scrollHeight"];
|
|
@@ -4617,9 +4617,9 @@ function ScrollControls({ eps: eps$1 = 1e-5, enabled = true, infinite, horizonta
|
|
|
4617
4617
|
children
|
|
4618
4618
|
});
|
|
4619
4619
|
}
|
|
4620
|
-
const ScrollCanvas = /* @__PURE__ */ React
|
|
4621
|
-
const group = React
|
|
4622
|
-
React
|
|
4620
|
+
const ScrollCanvas = /* @__PURE__ */ React.forwardRef(({ children }, ref) => {
|
|
4621
|
+
const group = React.useRef(null);
|
|
4622
|
+
React.useImperativeHandle(ref, () => group.current, []);
|
|
4623
4623
|
const state = useScroll();
|
|
4624
4624
|
const { width, height } = useThree((state$1) => state$1.viewport);
|
|
4625
4625
|
useFrame(() => {
|
|
@@ -4631,13 +4631,13 @@ const ScrollCanvas = /* @__PURE__ */ React$1.forwardRef(({ children }, ref) => {
|
|
|
4631
4631
|
children
|
|
4632
4632
|
});
|
|
4633
4633
|
});
|
|
4634
|
-
const ScrollHtml = React
|
|
4634
|
+
const ScrollHtml = React.forwardRef(({ children, style, ...props }, ref) => {
|
|
4635
4635
|
const state = useScroll();
|
|
4636
|
-
const group = React
|
|
4637
|
-
React
|
|
4636
|
+
const group = React.useRef(null);
|
|
4637
|
+
React.useImperativeHandle(ref, () => group.current, []);
|
|
4638
4638
|
const { width, height } = useThree((state$1) => state$1.size);
|
|
4639
|
-
const fiberState = React
|
|
4640
|
-
const root = React
|
|
4639
|
+
const fiberState = React.useContext(context);
|
|
4640
|
+
const root = React.useMemo(() => ReactDOM.createRoot(state.fixed), [state.fixed]);
|
|
4641
4641
|
useFrame(() => {
|
|
4642
4642
|
if (state.delta > state.eps) group.current.style.transform = `translate3d(${state.horizontal ? -width * (state.pages - 1) * state.offset : 0}px,${state.horizontal ? 0 : height * (state.pages - 1) * -state.offset}px,0)`;
|
|
4643
4643
|
});
|
|
@@ -4661,7 +4661,7 @@ const ScrollHtml = React$1.forwardRef(({ children, style, ...props }, ref) => {
|
|
|
4661
4661
|
}));
|
|
4662
4662
|
return null;
|
|
4663
4663
|
});
|
|
4664
|
-
const Scroll = /* @__PURE__ */ React
|
|
4664
|
+
const Scroll = /* @__PURE__ */ React.forwardRef(({ html, ...props }, ref) => {
|
|
4665
4665
|
return /* @__PURE__ */ jsx(html ? ScrollHtml : ScrollCanvas, {
|
|
4666
4666
|
ref,
|
|
4667
4667
|
...props
|
|
@@ -4679,15 +4679,15 @@ const Scroll = /* @__PURE__ */ React$1.forwardRef(({ html, ...props }, ref) => {
|
|
|
4679
4679
|
* <TrackballControls />
|
|
4680
4680
|
* ```
|
|
4681
4681
|
*/
|
|
4682
|
-
const TrackballControls = /* @__PURE__ */ React
|
|
4682
|
+
const TrackballControls = /* @__PURE__ */ React.forwardRef(({ makeDefault, camera, domElement, regress, onChange, onStart, onEnd, ...restProps }, ref) => {
|
|
4683
4683
|
const { invalidate, camera: defaultCamera, gl, events, set, get, performance: performance$1, viewport } = useThree();
|
|
4684
4684
|
const explCamera = camera || defaultCamera;
|
|
4685
4685
|
const explDomElement = domElement || events.connected || gl.domElement;
|
|
4686
|
-
const controls = React
|
|
4686
|
+
const controls = React.useMemo(() => new TrackballControls$1(explCamera), [explCamera]);
|
|
4687
4687
|
useFrame(() => {
|
|
4688
4688
|
if (controls.enabled) controls.update();
|
|
4689
4689
|
}, -1);
|
|
4690
|
-
React
|
|
4690
|
+
React.useEffect(() => {
|
|
4691
4691
|
controls.connect(explDomElement);
|
|
4692
4692
|
return () => void controls.dispose();
|
|
4693
4693
|
}, [
|
|
@@ -4696,7 +4696,7 @@ const TrackballControls = /* @__PURE__ */ React$1.forwardRef(({ makeDefault, cam
|
|
|
4696
4696
|
controls,
|
|
4697
4697
|
invalidate
|
|
4698
4698
|
]);
|
|
4699
|
-
React
|
|
4699
|
+
React.useEffect(() => {
|
|
4700
4700
|
const callback = (e) => {
|
|
4701
4701
|
invalidate();
|
|
4702
4702
|
if (regress) performance$1.regress();
|
|
@@ -4717,10 +4717,10 @@ const TrackballControls = /* @__PURE__ */ React$1.forwardRef(({ makeDefault, cam
|
|
|
4717
4717
|
controls,
|
|
4718
4718
|
invalidate
|
|
4719
4719
|
]);
|
|
4720
|
-
React
|
|
4720
|
+
React.useEffect(() => {
|
|
4721
4721
|
controls.handleResize();
|
|
4722
4722
|
}, [viewport]);
|
|
4723
|
-
React
|
|
4723
|
+
React.useEffect(() => {
|
|
4724
4724
|
if (makeDefault) {
|
|
4725
4725
|
const old = get().controls;
|
|
4726
4726
|
set({ controls });
|
|
@@ -4755,25 +4755,25 @@ const TrackballControls = /* @__PURE__ */ React$1.forwardRef(({ makeDefault, cam
|
|
|
4755
4755
|
* <CameraShake ref={shakeRef} decay decayRate={0.65} intensity={0} />
|
|
4756
4756
|
* ```
|
|
4757
4757
|
*/
|
|
4758
|
-
const CameraShake = /* @__PURE__ */ React
|
|
4758
|
+
const CameraShake = /* @__PURE__ */ React.forwardRef(({ intensity = 1, decay, decayRate = .65, maxYaw = .1, maxPitch = .1, maxRoll = .1, yawFrequency = .1, pitchFrequency = .1, rollFrequency = .1 }, ref) => {
|
|
4759
4759
|
const camera = useThree((state) => state.camera);
|
|
4760
4760
|
const defaultControls = useThree((state) => state.controls);
|
|
4761
|
-
const intensityRef = React
|
|
4762
|
-
const initialRotation = React
|
|
4763
|
-
const [yawNoise] = React
|
|
4764
|
-
const [pitchNoise] = React
|
|
4765
|
-
const [rollNoise] = React
|
|
4761
|
+
const intensityRef = React.useRef(intensity);
|
|
4762
|
+
const initialRotation = React.useRef(camera.rotation.clone());
|
|
4763
|
+
const [yawNoise] = React.useState(() => new SimplexNoise());
|
|
4764
|
+
const [pitchNoise] = React.useState(() => new SimplexNoise());
|
|
4765
|
+
const [rollNoise] = React.useState(() => new SimplexNoise());
|
|
4766
4766
|
const constrainIntensity = () => {
|
|
4767
4767
|
if (intensityRef.current < 0 || intensityRef.current > 1) intensityRef.current = intensityRef.current < 0 ? 0 : 1;
|
|
4768
4768
|
};
|
|
4769
|
-
React
|
|
4769
|
+
React.useImperativeHandle(ref, () => ({
|
|
4770
4770
|
getIntensity: () => intensityRef.current,
|
|
4771
4771
|
setIntensity: (val) => {
|
|
4772
4772
|
intensityRef.current = val;
|
|
4773
4773
|
constrainIntensity();
|
|
4774
4774
|
}
|
|
4775
4775
|
}), []);
|
|
4776
|
-
React
|
|
4776
|
+
React.useEffect(() => {
|
|
4777
4777
|
if (defaultControls) {
|
|
4778
4778
|
const callback = () => void (initialRotation.current = camera.rotation.clone());
|
|
4779
4779
|
defaultControls.addEventListener("change", callback);
|
|
@@ -4862,7 +4862,7 @@ const rotation$1 = /* @__PURE__ */ new Quaternion();
|
|
|
4862
4862
|
const cpos = /* @__PURE__ */ new Vector3$2();
|
|
4863
4863
|
const cquat = /* @__PURE__ */ new Quaternion();
|
|
4864
4864
|
const scale$1 = /* @__PURE__ */ new Vector3$2();
|
|
4865
|
-
const context$7 = /* @__PURE__ */ React
|
|
4865
|
+
const context$7 = /* @__PURE__ */ React.createContext(null);
|
|
4866
4866
|
/**
|
|
4867
4867
|
* Provider component that groups all Cloud children into a single instanced draw call.
|
|
4868
4868
|
* Wrap your Cloud components with this for better performance.
|
|
@@ -4875,18 +4875,18 @@ const context$7 = /* @__PURE__ */ React$1.createContext(null);
|
|
|
4875
4875
|
* </Clouds>
|
|
4876
4876
|
* ```
|
|
4877
4877
|
*/
|
|
4878
|
-
const Clouds = /* @__PURE__ */ React
|
|
4879
|
-
const instance = React
|
|
4880
|
-
const clouds = React
|
|
4881
|
-
const opacities = React
|
|
4882
|
-
const colors$1 = React
|
|
4878
|
+
const Clouds = /* @__PURE__ */ React.forwardRef(({ children, material = MeshLambertMaterial, materialFactory, texture: texture$1 = CLOUD_URL, range, limit = 200, frustumCulled, ...props }, fref) => {
|
|
4879
|
+
const instance = React.useRef(null);
|
|
4880
|
+
const clouds = React.useRef([]);
|
|
4881
|
+
const opacities = React.useMemo(() => new Float32Array(Array.from({ length: limit }, () => 1)), [limit]);
|
|
4882
|
+
const colors$1 = React.useMemo(() => new Float32Array(Array.from({ length: limit }, () => [
|
|
4883
4883
|
1,
|
|
4884
4884
|
1,
|
|
4885
4885
|
1
|
|
4886
4886
|
]).flat()), [limit]);
|
|
4887
4887
|
const cloudTexture = useTexture(texture$1);
|
|
4888
4888
|
const MaterialFn = materialFactory ?? FakeCloudMaterial;
|
|
4889
|
-
const cloudMaterial = React
|
|
4889
|
+
const cloudMaterial = React.useMemo(() => {
|
|
4890
4890
|
const cloudMat = MaterialFn(material);
|
|
4891
4891
|
cloudMat.map = cloudTexture;
|
|
4892
4892
|
cloudMat.transparent = true;
|
|
@@ -4927,7 +4927,7 @@ const Clouds = /* @__PURE__ */ React$1.forwardRef(({ children, material = MeshLa
|
|
|
4927
4927
|
instance.current.instanceMatrix.needsUpdate = true;
|
|
4928
4928
|
if (instance.current.instanceColor) instance.current.instanceColor.needsUpdate = true;
|
|
4929
4929
|
});
|
|
4930
|
-
React
|
|
4930
|
+
React.useLayoutEffect(() => {
|
|
4931
4931
|
const count = Math.min(limit, range !== void 0 ? range : limit, clouds.current.length);
|
|
4932
4932
|
instance.current.count = count;
|
|
4933
4933
|
setUpdateRange(instance.current.instanceMatrix, {
|
|
@@ -4978,7 +4978,7 @@ const Clouds = /* @__PURE__ */ React$1.forwardRef(({ children, material = MeshLa
|
|
|
4978
4978
|
})
|
|
4979
4979
|
});
|
|
4980
4980
|
});
|
|
4981
|
-
const CloudInstance = /* @__PURE__ */ React
|
|
4981
|
+
const CloudInstance = /* @__PURE__ */ React.forwardRef(({ opacity = 1, speed = 0, bounds = [
|
|
4982
4982
|
5,
|
|
4983
4983
|
1,
|
|
4984
4984
|
1
|
|
@@ -4987,10 +4987,10 @@ const CloudInstance = /* @__PURE__ */ React$1.forwardRef(({ opacity = 1, speed =
|
|
|
4987
4987
|
const x = Math.sin(seed++) * 1e4;
|
|
4988
4988
|
return x - Math.floor(x);
|
|
4989
4989
|
}
|
|
4990
|
-
const parent = React
|
|
4991
|
-
const ref = React
|
|
4992
|
-
const uuid = React
|
|
4993
|
-
const clouds = React
|
|
4990
|
+
const parent = React.useContext(context$7);
|
|
4991
|
+
const ref = React.useRef(null);
|
|
4992
|
+
const uuid = React.useId();
|
|
4993
|
+
const clouds = React.useMemo(() => {
|
|
4994
4994
|
return [...new Array(segments)].map((_, index) => ({
|
|
4995
4995
|
segments,
|
|
4996
4996
|
bounds: new Vector3$2(1, 1, 1),
|
|
@@ -5004,7 +5004,7 @@ const CloudInstance = /* @__PURE__ */ React$1.forwardRef(({ opacity = 1, speed =
|
|
|
5004
5004
|
rotation: index * (Math.PI / segments)
|
|
5005
5005
|
}));
|
|
5006
5006
|
}, [segments, uuid]);
|
|
5007
|
-
React
|
|
5007
|
+
React.useLayoutEffect(() => {
|
|
5008
5008
|
clouds.forEach((cloud, index) => {
|
|
5009
5009
|
applyProps(cloud, {
|
|
5010
5010
|
volume,
|
|
@@ -5045,14 +5045,14 @@ const CloudInstance = /* @__PURE__ */ React$1.forwardRef(({ opacity = 1, speed =
|
|
|
5045
5045
|
segments,
|
|
5046
5046
|
speed
|
|
5047
5047
|
]);
|
|
5048
|
-
React
|
|
5048
|
+
React.useLayoutEffect(() => {
|
|
5049
5049
|
const temp = clouds;
|
|
5050
5050
|
parent.current = [...parent.current, ...temp];
|
|
5051
5051
|
return () => {
|
|
5052
5052
|
parent.current = parent.current.filter((item) => item.uuid !== uuid);
|
|
5053
5053
|
};
|
|
5054
5054
|
}, [clouds]);
|
|
5055
|
-
React
|
|
5055
|
+
React.useImperativeHandle(fref, () => ref.current, []);
|
|
5056
5056
|
return /* @__PURE__ */ jsx("group", {
|
|
5057
5057
|
ref,
|
|
5058
5058
|
...props
|
|
@@ -5069,8 +5069,8 @@ const CloudInstance = /* @__PURE__ */ React$1.forwardRef(({ opacity = 1, speed =
|
|
|
5069
5069
|
* <Cloud segments={40} bounds={[10, 2, 2]} volume={10} color="white" />
|
|
5070
5070
|
* ```
|
|
5071
5071
|
*/
|
|
5072
|
-
const Cloud = /* @__PURE__ */ React
|
|
5073
|
-
if (React
|
|
5072
|
+
const Cloud = /* @__PURE__ */ React.forwardRef((props, fref) => {
|
|
5073
|
+
if (React.useContext(context$7)) return /* @__PURE__ */ jsx(CloudInstance, {
|
|
5074
5074
|
ref: fref,
|
|
5075
5075
|
...props
|
|
5076
5076
|
});
|
|
@@ -5097,9 +5097,9 @@ const Cloud = /* @__PURE__ */ React$1.forwardRef((props, fref) => {
|
|
|
5097
5097
|
* />
|
|
5098
5098
|
* ```
|
|
5099
5099
|
*/
|
|
5100
|
-
const CatmullRomLine = /* @__PURE__ */ React
|
|
5100
|
+
const CatmullRomLine = /* @__PURE__ */ React.forwardRef(function CatmullRomLine$1({ points, closed = false, curveType = "centripetal", tension = .5, segments = 20, vertexColors, LineComponent, ...rest }, ref) {
|
|
5101
5101
|
const LineComp = LineComponent ?? Line;
|
|
5102
|
-
const curve = React
|
|
5102
|
+
const curve = React.useMemo(() => {
|
|
5103
5103
|
return new CatmullRomCurve3(points.map((pt) => pt instanceof Vector3$2 ? pt : new Vector3$2(...pt)), closed, curveType, tension);
|
|
5104
5104
|
}, [
|
|
5105
5105
|
points,
|
|
@@ -5109,8 +5109,8 @@ const CatmullRomLine = /* @__PURE__ */ React$1.forwardRef(function CatmullRomLin
|
|
|
5109
5109
|
]);
|
|
5110
5110
|
return /* @__PURE__ */ jsx(LineComp, {
|
|
5111
5111
|
ref,
|
|
5112
|
-
points: React
|
|
5113
|
-
vertexColors: React
|
|
5112
|
+
points: React.useMemo(() => curve.getPoints(segments), [curve, segments]),
|
|
5113
|
+
vertexColors: React.useMemo(() => {
|
|
5114
5114
|
if (!vertexColors || vertexColors.length < 2) return void 0;
|
|
5115
5115
|
if (vertexColors.length === segments + 1) return vertexColors;
|
|
5116
5116
|
const mappedColors = vertexColors.map((color) => color instanceof Color$2 ? color : new Color$2(...color));
|
|
@@ -5145,10 +5145,10 @@ const CatmullRomLine = /* @__PURE__ */ React$1.forwardRef(function CatmullRomLin
|
|
|
5145
5145
|
* />
|
|
5146
5146
|
* ```
|
|
5147
5147
|
*/
|
|
5148
|
-
const CubicBezierLine = /* @__PURE__ */ React
|
|
5148
|
+
const CubicBezierLine = /* @__PURE__ */ React.forwardRef(function CubicBezierLine$1({ start, end, midA, midB, segments = 20, LineComponent, ...rest }, ref) {
|
|
5149
5149
|
return /* @__PURE__ */ jsx(LineComponent ?? Line, {
|
|
5150
5150
|
ref,
|
|
5151
|
-
points: React
|
|
5151
|
+
points: React.useMemo(() => {
|
|
5152
5152
|
const startV = start instanceof Vector3$2 ? start : new Vector3$2(...start);
|
|
5153
5153
|
const endV = end instanceof Vector3$2 ? end : new Vector3$2(...end);
|
|
5154
5154
|
return new CubicBezierCurve3(startV, midA instanceof Vector3$2 ? midA : new Vector3$2(...midA), midB instanceof Vector3$2 ? midB : new Vector3$2(...midB), endV).getPoints(segments);
|
|
@@ -5197,18 +5197,18 @@ const CubicBezierLine = /* @__PURE__ */ React$1.forwardRef(function CubicBezierL
|
|
|
5197
5197
|
* </CurveModifier>
|
|
5198
5198
|
* ```
|
|
5199
5199
|
*/
|
|
5200
|
-
const CurveModifier = /* @__PURE__ */ React
|
|
5201
|
-
const [scene] = React
|
|
5202
|
-
const [obj, set] = React
|
|
5203
|
-
const modifier = React
|
|
5204
|
-
React
|
|
5200
|
+
const CurveModifier = /* @__PURE__ */ React.forwardRef(({ children, curve }, ref) => {
|
|
5201
|
+
const [scene] = React.useState(() => new Scene());
|
|
5202
|
+
const [obj, set] = React.useState();
|
|
5203
|
+
const modifier = React.useRef(null);
|
|
5204
|
+
React.useLayoutEffect(() => {
|
|
5205
5205
|
modifier.current = new Flow(scene.children[0]);
|
|
5206
5206
|
set(modifier.current.object3D);
|
|
5207
5207
|
}, [children]);
|
|
5208
|
-
React
|
|
5208
|
+
React.useEffect(() => {
|
|
5209
5209
|
if (curve) modifier.current?.updateCurve(0, curve);
|
|
5210
5210
|
}, [curve]);
|
|
5211
|
-
React
|
|
5211
|
+
React.useImperativeHandle(ref, () => modifier.current);
|
|
5212
5212
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [createPortal(children, scene), obj && /* @__PURE__ */ jsx("primitive", { object: obj })] });
|
|
5213
5213
|
});
|
|
5214
5214
|
|
|
@@ -5269,16 +5269,16 @@ function vecToArray(vec = [
|
|
|
5269
5269
|
* </Decal>
|
|
5270
5270
|
* ```
|
|
5271
5271
|
*/
|
|
5272
|
-
const Decal = /* @__PURE__ */ React
|
|
5273
|
-
const ref = React
|
|
5274
|
-
React
|
|
5275
|
-
const helper = React
|
|
5276
|
-
const state = React
|
|
5272
|
+
const Decal = /* @__PURE__ */ React.forwardRef(function Decal$1({ debug, depthTest = false, polygonOffsetFactor = -10, map, mesh, children, position: position$1, rotation: rotation$2, scale: scale$2, ...props }, forwardRef$1) {
|
|
5273
|
+
const ref = React.useRef(null);
|
|
5274
|
+
React.useImperativeHandle(forwardRef$1, () => ref.current);
|
|
5275
|
+
const helper = React.useRef(null);
|
|
5276
|
+
const state = React.useRef({
|
|
5277
5277
|
position: new Vector3$2(),
|
|
5278
5278
|
rotation: new Euler$1(),
|
|
5279
5279
|
scale: new Vector3$2(1, 1, 1)
|
|
5280
5280
|
});
|
|
5281
|
-
React
|
|
5281
|
+
React.useLayoutEffect(() => {
|
|
5282
5282
|
const parent = mesh?.current || ref.current.parent;
|
|
5283
5283
|
const target$1 = ref.current;
|
|
5284
5284
|
if (!(parent instanceof Mesh)) throw new Error("Decal must have a Mesh as parent or specify its \"mesh\" prop");
|
|
@@ -5335,7 +5335,7 @@ const Decal = /* @__PURE__ */ React$1.forwardRef(function Decal$1({ debug, depth
|
|
|
5335
5335
|
...vecToArray(scale$2),
|
|
5336
5336
|
...vecToArray(rotation$2)
|
|
5337
5337
|
]);
|
|
5338
|
-
React
|
|
5338
|
+
React.useLayoutEffect(() => {
|
|
5339
5339
|
if (helper.current) helper.current.traverse((child) => child.raycast = () => null);
|
|
5340
5340
|
}, [debug]);
|
|
5341
5341
|
return /* @__PURE__ */ jsxs("mesh", {
|
|
@@ -5372,10 +5372,10 @@ const Decal = /* @__PURE__ */ React$1.forwardRef(function Decal$1({ debug, depth
|
|
|
5372
5372
|
* </Detailed>
|
|
5373
5373
|
* ```
|
|
5374
5374
|
*/
|
|
5375
|
-
const Detailed = /* @__PURE__ */ React
|
|
5376
|
-
const lodRef = React
|
|
5377
|
-
React
|
|
5378
|
-
React
|
|
5375
|
+
const Detailed = /* @__PURE__ */ React.forwardRef(({ children, hysteresis = 0, distances, ...props }, ref) => {
|
|
5376
|
+
const lodRef = React.useRef(null);
|
|
5377
|
+
React.useImperativeHandle(ref, () => lodRef.current, []);
|
|
5378
|
+
React.useLayoutEffect(() => {
|
|
5379
5379
|
const { current: lod } = lodRef;
|
|
5380
5380
|
lod.levels.length = 0;
|
|
5381
5381
|
lod.children.forEach((object, index) => lod.levels.push({
|
|
@@ -5445,22 +5445,22 @@ var PositionPoint = class extends Group {
|
|
|
5445
5445
|
}
|
|
5446
5446
|
};
|
|
5447
5447
|
let i, positionRef;
|
|
5448
|
-
const context$6 = /* @__PURE__ */ React
|
|
5448
|
+
const context$6 = /* @__PURE__ */ React.createContext(null);
|
|
5449
5449
|
const parentMatrix$1 = /* @__PURE__ */ new Matrix4();
|
|
5450
5450
|
const position = /* @__PURE__ */ new Vector3$2();
|
|
5451
5451
|
/**
|
|
5452
5452
|
* Instance implementation, relies on react + context to update the attributes based on the children of this component
|
|
5453
5453
|
*/
|
|
5454
|
-
const PointsInstances = /* @__PURE__ */ React
|
|
5455
|
-
const parentRef = React
|
|
5456
|
-
React
|
|
5457
|
-
const [refs, setRefs] = React
|
|
5458
|
-
const [[positions, colors$1, sizes]] = React
|
|
5454
|
+
const PointsInstances = /* @__PURE__ */ React.forwardRef(({ children, range, limit = 1e3, ...props }, ref) => {
|
|
5455
|
+
const parentRef = React.useRef(null);
|
|
5456
|
+
React.useImperativeHandle(ref, () => parentRef.current, []);
|
|
5457
|
+
const [refs, setRefs] = React.useState([]);
|
|
5458
|
+
const [[positions, colors$1, sizes]] = React.useState(() => [
|
|
5459
5459
|
new Float32Array(limit * 3),
|
|
5460
5460
|
Float32Array.from({ length: limit * 3 }, () => 1),
|
|
5461
5461
|
Float32Array.from({ length: limit }, () => 1)
|
|
5462
5462
|
]);
|
|
5463
|
-
React
|
|
5463
|
+
React.useEffect(() => {
|
|
5464
5464
|
parentRef.current.geometry.attributes.position.needsUpdate = true;
|
|
5465
5465
|
});
|
|
5466
5466
|
useFrame(() => {
|
|
@@ -5480,7 +5480,7 @@ const PointsInstances = /* @__PURE__ */ React$1.forwardRef(({ children, range, l
|
|
|
5480
5480
|
parentRef.current.geometry.attributes.size.needsUpdate = true;
|
|
5481
5481
|
}
|
|
5482
5482
|
});
|
|
5483
|
-
const api = React
|
|
5483
|
+
const api = React.useMemo(() => ({
|
|
5484
5484
|
getParent: () => parentRef,
|
|
5485
5485
|
subscribe: (ref$1) => {
|
|
5486
5486
|
setRefs((refs$1) => [...refs$1, ref$1]);
|
|
@@ -5526,12 +5526,12 @@ const PointsInstances = /* @__PURE__ */ React$1.forwardRef(({ children, range, l
|
|
|
5526
5526
|
* </Points>
|
|
5527
5527
|
* ```
|
|
5528
5528
|
*/
|
|
5529
|
-
const Point = /* @__PURE__ */ React
|
|
5530
|
-
React
|
|
5531
|
-
const group = React
|
|
5532
|
-
React
|
|
5533
|
-
const { subscribe, getParent } = React
|
|
5534
|
-
React
|
|
5529
|
+
const Point = /* @__PURE__ */ React.forwardRef(({ children, ...props }, ref) => {
|
|
5530
|
+
React.useMemo(() => extend({ PositionPoint }), []);
|
|
5531
|
+
const group = React.useRef(null);
|
|
5532
|
+
React.useImperativeHandle(ref, () => group.current, []);
|
|
5533
|
+
const { subscribe, getParent } = React.useContext(context$6);
|
|
5534
|
+
React.useLayoutEffect(() => subscribe(group), []);
|
|
5535
5535
|
return /* @__PURE__ */ jsx("positionPoint", {
|
|
5536
5536
|
instance: getParent(),
|
|
5537
5537
|
instanceKey: group,
|
|
@@ -5540,9 +5540,9 @@ const Point = /* @__PURE__ */ React$1.forwardRef(({ children, ...props }, ref) =
|
|
|
5540
5540
|
children
|
|
5541
5541
|
});
|
|
5542
5542
|
});
|
|
5543
|
-
const PointsBuffer = /* @__PURE__ */ React
|
|
5544
|
-
const pointsRef = React
|
|
5545
|
-
React
|
|
5543
|
+
const PointsBuffer = /* @__PURE__ */ React.forwardRef(({ children, positions, colors: colors$1, sizes, stride = 3, ...props }, forwardedRef) => {
|
|
5544
|
+
const pointsRef = React.useRef(null);
|
|
5545
|
+
React.useImperativeHandle(forwardedRef, () => pointsRef.current, []);
|
|
5546
5546
|
useFrame(() => {
|
|
5547
5547
|
const attr = pointsRef.current.geometry.attributes;
|
|
5548
5548
|
attr.position.needsUpdate = true;
|
|
@@ -5589,7 +5589,7 @@ const PointsBuffer = /* @__PURE__ */ React$1.forwardRef(({ children, positions,
|
|
|
5589
5589
|
* </Points>
|
|
5590
5590
|
* ```
|
|
5591
5591
|
*/
|
|
5592
|
-
const Points = /* @__PURE__ */ React
|
|
5592
|
+
const Points = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
|
|
5593
5593
|
if (props.positions instanceof Float32Array) return /* @__PURE__ */ jsx(PointsBuffer, {
|
|
5594
5594
|
...props,
|
|
5595
5595
|
ref: forwardedRef
|
|
@@ -5616,7 +5616,7 @@ const v = /* @__PURE__ */ new Vector3$2();
|
|
|
5616
5616
|
* />
|
|
5617
5617
|
* ```
|
|
5618
5618
|
*/
|
|
5619
|
-
const QuadraticBezierLine = /* @__PURE__ */ React
|
|
5619
|
+
const QuadraticBezierLine = /* @__PURE__ */ React.forwardRef(function QuadraticBezierLine$1({ start = [
|
|
5620
5620
|
0,
|
|
5621
5621
|
0,
|
|
5622
5622
|
0
|
|
@@ -5626,10 +5626,10 @@ const QuadraticBezierLine = /* @__PURE__ */ React$1.forwardRef(function Quadrati
|
|
|
5626
5626
|
0
|
|
5627
5627
|
], mid, segments = 20, LineComponent, ...rest }, forwardref) {
|
|
5628
5628
|
const LineComp = LineComponent ?? Line;
|
|
5629
|
-
const ref = React
|
|
5630
|
-
React
|
|
5631
|
-
const [curve] = React
|
|
5632
|
-
const getPoints = React
|
|
5629
|
+
const ref = React.useRef(null);
|
|
5630
|
+
React.useImperativeHandle(forwardref, () => ref.current);
|
|
5631
|
+
const [curve] = React.useState(() => new QuadraticBezierCurve3(void 0, void 0, void 0));
|
|
5632
|
+
const getPoints = React.useCallback((start$1, end$1, mid$1, segments$1 = 20) => {
|
|
5633
5633
|
if (start$1 instanceof Vector3$2) curve.v0.copy(start$1);
|
|
5634
5634
|
else curve.v0.set(...start$1);
|
|
5635
5635
|
if (end$1 instanceof Vector3$2) curve.v2.copy(end$1);
|
|
@@ -5639,7 +5639,7 @@ const QuadraticBezierLine = /* @__PURE__ */ React$1.forwardRef(function Quadrati
|
|
|
5639
5639
|
else curve.v1.copy(curve.v0.clone().add(curve.v2.clone().sub(curve.v0)).add(v.set(0, curve.v0.y - curve.v2.y, 0)));
|
|
5640
5640
|
return curve.getPoints(segments$1);
|
|
5641
5641
|
}, []);
|
|
5642
|
-
React
|
|
5642
|
+
React.useLayoutEffect(() => {
|
|
5643
5643
|
ref.current.setPoints = (start$1, end$1, mid$1) => {
|
|
5644
5644
|
const points = getPoints(start$1, end$1, mid$1);
|
|
5645
5645
|
if (ref.current.geometry) ref.current.geometry.setPositions(points.map((p) => p.toArray()).flat());
|
|
@@ -5647,7 +5647,7 @@ const QuadraticBezierLine = /* @__PURE__ */ React$1.forwardRef(function Quadrati
|
|
|
5647
5647
|
}, []);
|
|
5648
5648
|
return /* @__PURE__ */ jsx(LineComp, {
|
|
5649
5649
|
ref,
|
|
5650
|
-
points: React
|
|
5650
|
+
points: React.useMemo(() => getPoints(start, end, mid, segments), [
|
|
5651
5651
|
start,
|
|
5652
5652
|
end,
|
|
5653
5653
|
mid,
|
|
@@ -5691,7 +5691,7 @@ function createShape(width, height, radius0) {
|
|
|
5691
5691
|
* </RoundedBox>
|
|
5692
5692
|
* ```
|
|
5693
5693
|
*/
|
|
5694
|
-
const RoundedBox = /* @__PURE__ */ React
|
|
5694
|
+
const RoundedBox = /* @__PURE__ */ React.forwardRef(function RoundedBox$1({ args: [width = 1, height = 1, depth = 1] = [], radius = .05, steps = 1, smoothness = 4, bevelSegments = 4, creaseAngle = .4, children, ...rest }, ref) {
|
|
5695
5695
|
return /* @__PURE__ */ jsxs("mesh", {
|
|
5696
5696
|
ref,
|
|
5697
5697
|
...rest,
|
|
@@ -5709,13 +5709,13 @@ const RoundedBox = /* @__PURE__ */ React$1.forwardRef(function RoundedBox$1({ ar
|
|
|
5709
5709
|
}), children]
|
|
5710
5710
|
});
|
|
5711
5711
|
});
|
|
5712
|
-
const RoundedBoxGeometry = /* @__PURE__ */ React
|
|
5713
|
-
const shape = React
|
|
5712
|
+
const RoundedBoxGeometry = /* @__PURE__ */ React.forwardRef(function RoundedBoxGeometry$1({ args: [width = 1, height = 1, depth = 1] = [], radius = .05, steps = 1, smoothness = 4, bevelSegments = 4, creaseAngle = .4, ...rest }, ref) {
|
|
5713
|
+
const shape = React.useMemo(() => createShape(width, height, radius), [
|
|
5714
5714
|
width,
|
|
5715
5715
|
height,
|
|
5716
5716
|
radius
|
|
5717
5717
|
]);
|
|
5718
|
-
const params = React
|
|
5718
|
+
const params = React.useMemo(() => ({
|
|
5719
5719
|
depth: depth - radius * 2,
|
|
5720
5720
|
bevelEnabled: true,
|
|
5721
5721
|
bevelSegments: bevelSegments * 2,
|
|
@@ -5730,8 +5730,8 @@ const RoundedBoxGeometry = /* @__PURE__ */ React$1.forwardRef(function RoundedBo
|
|
|
5730
5730
|
bevelSegments,
|
|
5731
5731
|
steps
|
|
5732
5732
|
]);
|
|
5733
|
-
const geomRef = React
|
|
5734
|
-
React
|
|
5733
|
+
const geomRef = React.useRef(null);
|
|
5734
|
+
React.useLayoutEffect(() => {
|
|
5735
5735
|
if (geomRef.current) {
|
|
5736
5736
|
geomRef.current.center();
|
|
5737
5737
|
toCreasedNormals(geomRef.current, creaseAngle);
|
|
@@ -5741,7 +5741,7 @@ const RoundedBoxGeometry = /* @__PURE__ */ React$1.forwardRef(function RoundedBo
|
|
|
5741
5741
|
params,
|
|
5742
5742
|
creaseAngle
|
|
5743
5743
|
]);
|
|
5744
|
-
React
|
|
5744
|
+
React.useImperativeHandle(ref, () => geomRef.current);
|
|
5745
5745
|
return /* @__PURE__ */ jsx("extrudeGeometry", {
|
|
5746
5746
|
ref: geomRef,
|
|
5747
5747
|
args: [shape, params],
|
|
@@ -5776,10 +5776,10 @@ function createScreenQuadGeometry() {
|
|
|
5776
5776
|
* </ScreenQuad>
|
|
5777
5777
|
* ```
|
|
5778
5778
|
*/
|
|
5779
|
-
const ScreenQuad = /* @__PURE__ */ React
|
|
5779
|
+
const ScreenQuad = /* @__PURE__ */ React.forwardRef(function ScreenQuad$1({ children, ...restProps }, ref) {
|
|
5780
5780
|
return /* @__PURE__ */ jsx("mesh", {
|
|
5781
5781
|
ref,
|
|
5782
|
-
geometry: React
|
|
5782
|
+
geometry: React.useMemo(createScreenQuadGeometry, []),
|
|
5783
5783
|
frustumCulled: false,
|
|
5784
5784
|
...restProps,
|
|
5785
5785
|
children
|
|
@@ -5800,10 +5800,10 @@ const ScreenQuad = /* @__PURE__ */ React$1.forwardRef(function ScreenQuad$1({ ch
|
|
|
5800
5800
|
*/
|
|
5801
5801
|
function create(type, effect) {
|
|
5802
5802
|
const El = type + "Geometry";
|
|
5803
|
-
return React
|
|
5804
|
-
const ref = React
|
|
5805
|
-
React
|
|
5806
|
-
React
|
|
5803
|
+
return React.forwardRef(({ args, children, ...props }, fref) => {
|
|
5804
|
+
const ref = React.useRef(null);
|
|
5805
|
+
React.useImperativeHandle(fref, () => ref.current);
|
|
5806
|
+
React.useLayoutEffect(() => void effect?.(ref.current));
|
|
5807
5807
|
return /* @__PURE__ */ jsxs("mesh", {
|
|
5808
5808
|
ref,
|
|
5809
5809
|
...props,
|
|
@@ -5883,7 +5883,7 @@ const types = ["string", "number"];
|
|
|
5883
5883
|
const getTextFromChildren = (children) => {
|
|
5884
5884
|
let label = "";
|
|
5885
5885
|
const rest = [];
|
|
5886
|
-
React
|
|
5886
|
+
React.Children.forEach(children, (child) => {
|
|
5887
5887
|
if (types.includes(typeof child)) label += child + "";
|
|
5888
5888
|
else rest.push(child);
|
|
5889
5889
|
});
|
|
@@ -5922,9 +5922,9 @@ const getTextFromChildren = (children) => {
|
|
|
5922
5922
|
* <Text3D smooth={1} lineHeight={0.5} letterSpacing={-0.025}>{`hello\nworld`}</Text3D>
|
|
5923
5923
|
* ```
|
|
5924
5924
|
*/
|
|
5925
|
-
const Text3D = /* @__PURE__ */ React
|
|
5926
|
-
React
|
|
5927
|
-
const ref = React
|
|
5925
|
+
const Text3D = /* @__PURE__ */ React.forwardRef(({ font: _font, letterSpacing = 0, lineHeight = 1, size = 1, height = .2, bevelThickness = .1, bevelSize = .01, bevelEnabled = false, bevelOffset = 0, bevelSegments = 4, curveSegments = 8, smooth, children, ...props }, fref) => {
|
|
5926
|
+
React.useMemo(() => extend({ RenamedTextGeometry: TextGeometry }), []);
|
|
5927
|
+
const ref = React.useRef(null);
|
|
5928
5928
|
const font = useFont(_font);
|
|
5929
5929
|
const opts = useMemo(() => {
|
|
5930
5930
|
return {
|
|
@@ -5958,14 +5958,14 @@ const Text3D = /* @__PURE__ */ React$1.forwardRef(({ font: _font, letterSpacing
|
|
|
5958
5958
|
* need to be able to do `<Text3d>{state}</Text3d>`.
|
|
5959
5959
|
*/
|
|
5960
5960
|
const [label, ...rest] = useMemo(() => getTextFromChildren(children), [children]);
|
|
5961
|
-
const args = React
|
|
5962
|
-
React
|
|
5961
|
+
const args = React.useMemo(() => [label, opts], [label, opts]);
|
|
5962
|
+
React.useLayoutEffect(() => {
|
|
5963
5963
|
if (smooth) {
|
|
5964
5964
|
ref.current.geometry = mergeVertices(ref.current.geometry, smooth);
|
|
5965
5965
|
ref.current.geometry.computeVertexNormals();
|
|
5966
5966
|
}
|
|
5967
5967
|
}, [args, smooth]);
|
|
5968
|
-
React
|
|
5968
|
+
React.useImperativeHandle(fref, () => ref.current, []);
|
|
5969
5969
|
return /* @__PURE__ */ jsxs("mesh", {
|
|
5970
5970
|
...props,
|
|
5971
5971
|
ref,
|
|
@@ -6146,21 +6146,21 @@ function setWireframeOverride$1(material, uniforms) {
|
|
|
6146
6146
|
material.transparent = true;
|
|
6147
6147
|
}
|
|
6148
6148
|
function useWireframeUniforms$1(uniforms, props) {
|
|
6149
|
-
React
|
|
6150
|
-
React
|
|
6151
|
-
React
|
|
6152
|
-
React
|
|
6153
|
-
React
|
|
6154
|
-
React
|
|
6155
|
-
React
|
|
6156
|
-
React
|
|
6157
|
-
React
|
|
6158
|
-
React
|
|
6159
|
-
React
|
|
6160
|
-
React
|
|
6161
|
-
React
|
|
6162
|
-
React
|
|
6163
|
-
React
|
|
6149
|
+
React.useEffect(() => void (uniforms.fillOpacity.value = props.fillOpacity ?? uniforms.fillOpacity.value), [props.fillOpacity]);
|
|
6150
|
+
React.useEffect(() => void (uniforms.fillMix.value = props.fillMix ?? uniforms.fillMix.value), [props.fillMix]);
|
|
6151
|
+
React.useEffect(() => void (uniforms.strokeOpacity.value = props.strokeOpacity ?? uniforms.strokeOpacity.value), [props.strokeOpacity]);
|
|
6152
|
+
React.useEffect(() => void (uniforms.thickness.value = props.thickness ?? uniforms.thickness.value), [props.thickness]);
|
|
6153
|
+
React.useEffect(() => void (uniforms.colorBackfaces.value = !!props.colorBackfaces), [props.colorBackfaces]);
|
|
6154
|
+
React.useEffect(() => void (uniforms.dash.value = !!props.dash), [props.dash]);
|
|
6155
|
+
React.useEffect(() => void (uniforms.dashInvert.value = !!props.dashInvert), [props.dashInvert]);
|
|
6156
|
+
React.useEffect(() => void (uniforms.dashRepeats.value = props.dashRepeats ?? uniforms.dashRepeats.value), [props.dashRepeats]);
|
|
6157
|
+
React.useEffect(() => void (uniforms.dashLength.value = props.dashLength ?? uniforms.dashLength.value), [props.dashLength]);
|
|
6158
|
+
React.useEffect(() => void (uniforms.squeeze.value = !!props.squeeze), [props.squeeze]);
|
|
6159
|
+
React.useEffect(() => void (uniforms.squeezeMin.value = props.squeezeMin ?? uniforms.squeezeMin.value), [props.squeezeMin]);
|
|
6160
|
+
React.useEffect(() => void (uniforms.squeezeMax.value = props.squeezeMax ?? uniforms.squeezeMax.value), [props.squeezeMax]);
|
|
6161
|
+
React.useEffect(() => void (uniforms.stroke.value = props.stroke ? new Color$2(props.stroke) : uniforms.stroke.value), [props.stroke]);
|
|
6162
|
+
React.useEffect(() => void (uniforms.fill.value = props.fill ? new Color$2(props.fill) : uniforms.fill.value), [props.fill]);
|
|
6163
|
+
React.useEffect(() => void (uniforms.backfaceStroke.value = props.backfaceStroke ? new Color$2(props.backfaceStroke) : uniforms.backfaceStroke.value), [props.backfaceStroke]);
|
|
6164
6164
|
}
|
|
6165
6165
|
|
|
6166
6166
|
//#endregion
|
|
@@ -6219,8 +6219,8 @@ function setBarycentricCoordinates$1(geometry$1, simplify) {
|
|
|
6219
6219
|
}
|
|
6220
6220
|
function WireframeWithCustomGeo({ geometry: customGeometry, simplify = false, ...props }) {
|
|
6221
6221
|
extend({ MeshWireframeMaterial: WireframeMaterial$1 });
|
|
6222
|
-
const [geometry$1, setGeometry] = React
|
|
6223
|
-
React
|
|
6222
|
+
const [geometry$1, setGeometry] = React.useState(null);
|
|
6223
|
+
React.useLayoutEffect(() => {
|
|
6224
6224
|
const geom = getInputGeometry(customGeometry);
|
|
6225
6225
|
if (!geom) throw new Error("Wireframe: geometry prop must be a BufferGeometry or a ref to a BufferGeometry.");
|
|
6226
6226
|
setBarycentricCoordinates$1(geom, simplify);
|
|
@@ -6240,10 +6240,10 @@ function WireframeWithCustomGeo({ geometry: customGeometry, simplify = false, ..
|
|
|
6240
6240
|
}) });
|
|
6241
6241
|
}
|
|
6242
6242
|
function WireframeWithoutCustomGeo({ simplify = false, ...props }) {
|
|
6243
|
-
const objectRef = React
|
|
6244
|
-
const uniforms = React
|
|
6243
|
+
const objectRef = React.useRef(null);
|
|
6244
|
+
const uniforms = React.useMemo(() => getUniforms(), [WireframeMaterialShaders$1.uniforms]);
|
|
6245
6245
|
useWireframeUniforms$1(uniforms, props);
|
|
6246
|
-
React
|
|
6246
|
+
React.useLayoutEffect(() => {
|
|
6247
6247
|
const geom = getInputGeometry(objectRef);
|
|
6248
6248
|
if (!geom) throw new Error("Wireframe: Must be a child of a Mesh, Line or Points object or specify a geometry prop.");
|
|
6249
6249
|
const og = geom.clone();
|
|
@@ -6253,7 +6253,7 @@ function WireframeWithoutCustomGeo({ simplify = false, ...props }) {
|
|
|
6253
6253
|
og.dispose();
|
|
6254
6254
|
};
|
|
6255
6255
|
}, [simplify]);
|
|
6256
|
-
React
|
|
6256
|
+
React.useLayoutEffect(() => {
|
|
6257
6257
|
const parentMesh = objectRef.current.parent;
|
|
6258
6258
|
const og = parentMesh.material.clone();
|
|
6259
6259
|
setWireframeOverride$1(parentMesh.material, uniforms);
|
|
@@ -6286,13 +6286,13 @@ function Wireframe({ geometry: customGeometry, ...props }) {
|
|
|
6286
6286
|
|
|
6287
6287
|
//#endregion
|
|
6288
6288
|
//#region src/core/Gizmos/gizmo/GizmoHelper.tsx
|
|
6289
|
-
const Context = /* @__PURE__ */ React
|
|
6289
|
+
const Context = /* @__PURE__ */ React.createContext({});
|
|
6290
6290
|
/**
|
|
6291
6291
|
* Hook to access the GizmoHelper context for creating custom gizmos.
|
|
6292
6292
|
* Provides `tweenCamera(direction)` to animate camera rotation.
|
|
6293
6293
|
*/
|
|
6294
6294
|
const useGizmoContext = () => {
|
|
6295
|
-
return React
|
|
6295
|
+
return React.useContext(Context);
|
|
6296
6296
|
};
|
|
6297
6297
|
const turnRate = 2 * Math.PI;
|
|
6298
6298
|
const dummy = /* @__PURE__ */ new Object3D$1();
|
|
@@ -6323,17 +6323,17 @@ const GizmoHelper = ({ alignment = "bottom-right", margin = [80, 80], renderPrio
|
|
|
6323
6323
|
const mainCamera = useThree((state) => state.camera);
|
|
6324
6324
|
const defaultControls = useThree((state) => state.controls);
|
|
6325
6325
|
const invalidate = useThree((state) => state.invalidate);
|
|
6326
|
-
const gizmoRef = React
|
|
6327
|
-
const virtualCam = React
|
|
6328
|
-
const animating = React
|
|
6329
|
-
const radius = React
|
|
6330
|
-
const focusPoint = React
|
|
6331
|
-
const defaultUp = React
|
|
6332
|
-
React
|
|
6326
|
+
const gizmoRef = React.useRef(null);
|
|
6327
|
+
const virtualCam = React.useRef(null);
|
|
6328
|
+
const animating = React.useRef(false);
|
|
6329
|
+
const radius = React.useRef(0);
|
|
6330
|
+
const focusPoint = React.useRef(new Vector3$2(0, 0, 0));
|
|
6331
|
+
const defaultUp = React.useRef(new Vector3$2(0, 0, 0));
|
|
6332
|
+
React.useEffect(() => {
|
|
6333
6333
|
defaultUp.current.copy(mainCamera.up);
|
|
6334
6334
|
dummy.up.copy(mainCamera.up);
|
|
6335
6335
|
}, [mainCamera]);
|
|
6336
|
-
const tweenCamera = React
|
|
6336
|
+
const tweenCamera = React.useCallback((direction) => {
|
|
6337
6337
|
animating.current = true;
|
|
6338
6338
|
if (defaultControls || onTarget) focusPoint.current = onTarget?.() || (isCameraControls(defaultControls) ? defaultControls.getTarget(focusPoint.current) : defaultControls?.target);
|
|
6339
6339
|
radius.current = mainCamera.position.distanceTo(target);
|
|
@@ -6368,7 +6368,7 @@ const GizmoHelper = ({ alignment = "bottom-right", margin = [80, 80], renderPrio
|
|
|
6368
6368
|
gizmoRef.current?.quaternion.setFromRotationMatrix(matrix);
|
|
6369
6369
|
}
|
|
6370
6370
|
});
|
|
6371
|
-
const gizmoHelperContext = React
|
|
6371
|
+
const gizmoHelperContext = React.useMemo(() => ({ tweenCamera }), [tweenCamera]);
|
|
6372
6372
|
const [marginX, marginY] = margin;
|
|
6373
6373
|
const x = alignment.endsWith("-center") ? 0 : alignment.endsWith("-left") ? -size.width / 2 + marginX : size.width / 2 - marginX;
|
|
6374
6374
|
const y = alignment.startsWith("center-") ? 0 : alignment.startsWith("top-") ? size.height / 2 - marginY : -size.height / 2 + marginY;
|
|
@@ -6527,7 +6527,7 @@ const edgeDimensions = /* @__PURE__ */ edges.map((edge) => edge.toArray().map((a
|
|
|
6527
6527
|
const FaceMaterial = ({ hover, index, font = "20px Inter var, Arial, sans-serif", faces = defaultFaces, color = colors.bg, hoverColor = colors.hover, textColor = colors.text, strokeColor = colors.stroke, opacity = 1 }) => {
|
|
6528
6528
|
const renderer = useThree((state) => state.renderer);
|
|
6529
6529
|
return /* @__PURE__ */ jsx("meshBasicMaterial", {
|
|
6530
|
-
map: React
|
|
6530
|
+
map: React.useMemo(() => {
|
|
6531
6531
|
const canvas = document.createElement("canvas");
|
|
6532
6532
|
canvas.width = 128;
|
|
6533
6533
|
canvas.height = 128;
|
|
@@ -6558,7 +6558,7 @@ const FaceMaterial = ({ hover, index, font = "20px Inter var, Arial, sans-serif"
|
|
|
6558
6558
|
};
|
|
6559
6559
|
const FaceCube = (props) => {
|
|
6560
6560
|
const { tweenCamera } = useGizmoContext();
|
|
6561
|
-
const [hover, setHover] = React
|
|
6561
|
+
const [hover, setHover] = React.useState(null);
|
|
6562
6562
|
const handlePointerOut = (e) => {
|
|
6563
6563
|
e.stopPropagation();
|
|
6564
6564
|
setHover(null);
|
|
@@ -6584,7 +6584,7 @@ const FaceCube = (props) => {
|
|
|
6584
6584
|
};
|
|
6585
6585
|
const EdgeCube = ({ onClick, dimensions, position: position$1, hoverColor = colors.hover }) => {
|
|
6586
6586
|
const { tweenCamera } = useGizmoContext();
|
|
6587
|
-
const [hover, setHover] = React
|
|
6587
|
+
const [hover, setHover] = React.useState(false);
|
|
6588
6588
|
const handlePointerOut = (e) => {
|
|
6589
6589
|
e.stopPropagation();
|
|
6590
6590
|
setHover(false);
|
|
@@ -6669,7 +6669,7 @@ function Axis({ scale: scale$2 = [
|
|
|
6669
6669
|
}
|
|
6670
6670
|
function AxisHead({ onClick, font, disabled, arcStyle, label, labelColor, axisHeadScale = 1, ...props }) {
|
|
6671
6671
|
const renderer = useThree((state) => state.renderer);
|
|
6672
|
-
const texture$1 = React
|
|
6672
|
+
const texture$1 = React.useMemo(() => {
|
|
6673
6673
|
const canvas = document.createElement("canvas");
|
|
6674
6674
|
canvas.width = 64;
|
|
6675
6675
|
canvas.height = 64;
|
|
@@ -6692,7 +6692,7 @@ function AxisHead({ onClick, font, disabled, arcStyle, label, labelColor, axisHe
|
|
|
6692
6692
|
labelColor,
|
|
6693
6693
|
font
|
|
6694
6694
|
]);
|
|
6695
|
-
const [active, setActive] = React
|
|
6695
|
+
const [active, setActive] = React.useState(false);
|
|
6696
6696
|
const scale$2 = (label ? 1 : .75) * (active ? 1.2 : 1) * axisHeadScale;
|
|
6697
6697
|
const handlePointerOver = (e) => {
|
|
6698
6698
|
e.stopPropagation();
|
|
@@ -6965,22 +6965,22 @@ function isRefObject(ref) {
|
|
|
6965
6965
|
* </Html>
|
|
6966
6966
|
* ```
|
|
6967
6967
|
*/
|
|
6968
|
-
const Html$1 = /* @__PURE__ */ React
|
|
6968
|
+
const Html$1 = /* @__PURE__ */ React.forwardRef(({ children, eps: eps$1 = .001, style, className, prepend, center, fullscreen, portal, distanceFactor, sprite = false, transform = false, occlude, onOcclude, castShadow, receiveShadow, material, geometry: geometry$1, zIndexRange = [16777271, 0], calculatePosition = defaultCalculatePosition, as = "div", wrapperClass, pointerEvents = "auto", ...props }, ref) => {
|
|
6969
6969
|
const { gl, camera, scene, size, raycaster, events, viewport } = useThree();
|
|
6970
|
-
const [el] = React
|
|
6971
|
-
const root = React
|
|
6972
|
-
const group = React
|
|
6973
|
-
const oldZoom = React
|
|
6974
|
-
const oldPosition = React
|
|
6975
|
-
const transformOuterRef = React
|
|
6976
|
-
const transformInnerRef = React
|
|
6970
|
+
const [el] = React.useState(() => document.createElement(as));
|
|
6971
|
+
const root = React.useRef(null);
|
|
6972
|
+
const group = React.useRef(null);
|
|
6973
|
+
const oldZoom = React.useRef(0);
|
|
6974
|
+
const oldPosition = React.useRef([0, 0]);
|
|
6975
|
+
const transformOuterRef = React.useRef(null);
|
|
6976
|
+
const transformInnerRef = React.useRef(null);
|
|
6977
6977
|
const target$1 = portal?.current || events.connected || gl.domElement.parentNode;
|
|
6978
|
-
const occlusionMeshRef = React
|
|
6979
|
-
const isMeshSizeSet = React
|
|
6980
|
-
const isRayCastOcclusion = React
|
|
6978
|
+
const occlusionMeshRef = React.useRef(null);
|
|
6979
|
+
const isMeshSizeSet = React.useRef(false);
|
|
6980
|
+
const isRayCastOcclusion = React.useMemo(() => {
|
|
6981
6981
|
return occlude && occlude !== "blending" || Array.isArray(occlude) && occlude.length && isRefObject(occlude[0]);
|
|
6982
6982
|
}, [occlude]);
|
|
6983
|
-
React
|
|
6983
|
+
React.useLayoutEffect(() => {
|
|
6984
6984
|
const el$1 = gl.domElement;
|
|
6985
6985
|
if (occlude && occlude === "blending") {
|
|
6986
6986
|
el$1.style.zIndex = `${Math.floor(zIndexRange[0] / 2)}`;
|
|
@@ -6992,7 +6992,7 @@ const Html$1 = /* @__PURE__ */ React$1.forwardRef(({ children, eps: eps$1 = .001
|
|
|
6992
6992
|
el$1.style.pointerEvents = null;
|
|
6993
6993
|
}
|
|
6994
6994
|
}, [occlude]);
|
|
6995
|
-
React
|
|
6995
|
+
React.useLayoutEffect(() => {
|
|
6996
6996
|
if (group.current) {
|
|
6997
6997
|
const currentRoot = root.current = ReactDOM.createRoot(el);
|
|
6998
6998
|
scene.updateMatrixWorld();
|
|
@@ -7009,10 +7009,10 @@ const Html$1 = /* @__PURE__ */ React$1.forwardRef(({ children, eps: eps$1 = .001
|
|
|
7009
7009
|
};
|
|
7010
7010
|
}
|
|
7011
7011
|
}, [target$1, transform]);
|
|
7012
|
-
React
|
|
7012
|
+
React.useLayoutEffect(() => {
|
|
7013
7013
|
if (wrapperClass) el.className = wrapperClass;
|
|
7014
7014
|
}, [wrapperClass]);
|
|
7015
|
-
const styles$1 = React
|
|
7015
|
+
const styles$1 = React.useMemo(() => {
|
|
7016
7016
|
if (transform) return {
|
|
7017
7017
|
position: "absolute",
|
|
7018
7018
|
top: 0,
|
|
@@ -7040,11 +7040,11 @@ const Html$1 = /* @__PURE__ */ React$1.forwardRef(({ children, eps: eps$1 = .001
|
|
|
7040
7040
|
size,
|
|
7041
7041
|
transform
|
|
7042
7042
|
]);
|
|
7043
|
-
const transformInnerStyles = React
|
|
7043
|
+
const transformInnerStyles = React.useMemo(() => ({
|
|
7044
7044
|
position: "absolute",
|
|
7045
7045
|
pointerEvents
|
|
7046
7046
|
}), [pointerEvents]);
|
|
7047
|
-
React
|
|
7047
|
+
React.useLayoutEffect(() => {
|
|
7048
7048
|
isMeshSizeSet.current = false;
|
|
7049
7049
|
if (transform) root.current?.render(/* @__PURE__ */ jsx("div", {
|
|
7050
7050
|
ref: transformOuterRef,
|
|
@@ -7067,7 +7067,7 @@ const Html$1 = /* @__PURE__ */ React$1.forwardRef(({ children, eps: eps$1 = .001
|
|
|
7067
7067
|
children
|
|
7068
7068
|
}));
|
|
7069
7069
|
});
|
|
7070
|
-
const visible = React
|
|
7070
|
+
const visible = React.useRef(true);
|
|
7071
7071
|
useFrame((gl$1) => {
|
|
7072
7072
|
if (group.current) {
|
|
7073
7073
|
camera.updateMatrixWorld();
|
|
@@ -7145,7 +7145,7 @@ const Html$1 = /* @__PURE__ */ React$1.forwardRef(({ children, eps: eps$1 = .001
|
|
|
7145
7145
|
occlusionMeshRef.current.lookAt(gl$1.camera.position);
|
|
7146
7146
|
}
|
|
7147
7147
|
});
|
|
7148
|
-
const shaders = React
|
|
7148
|
+
const shaders = React.useMemo(() => ({
|
|
7149
7149
|
vertexShader: !transform ? `
|
|
7150
7150
|
/*
|
|
7151
7151
|
This shader is from the THREE's SpriteMaterial.
|
|
@@ -7204,7 +7204,7 @@ const Html$1 = /* @__PURE__ */ React$1.forwardRef(({ children, eps: eps$1 = .001
|
|
|
7204
7204
|
|
|
7205
7205
|
//#endregion
|
|
7206
7206
|
//#region src/core/Gizmos/PivotControls/context.ts
|
|
7207
|
-
const context$5 = /* @__PURE__ */ React
|
|
7207
|
+
const context$5 = /* @__PURE__ */ React.createContext(null);
|
|
7208
7208
|
|
|
7209
7209
|
//#endregion
|
|
7210
7210
|
//#region src/core/Gizmos/PivotControls/AxisArrow.tsx
|
|
@@ -7222,14 +7222,14 @@ const calculateOffset$1 = (clickPoint, normal, rayStart, rayDir) => {
|
|
|
7222
7222
|
const upV$1 = /* @__PURE__ */ new Vector3$2(0, 1, 0);
|
|
7223
7223
|
const offsetMatrix$1 = /* @__PURE__ */ new Matrix4();
|
|
7224
7224
|
const AxisArrow = ({ direction, axis }) => {
|
|
7225
|
-
const { translation: translation$2, translationLimits, annotations, annotationsClass, depthTest, scale: scale$2, lineWidth, fixed, axisColors, hoveredColor, opacity, renderOrder, onDragStart, onDrag, onDragEnd, userData, LineComponent: Line$1 } = React
|
|
7225
|
+
const { translation: translation$2, translationLimits, annotations, annotationsClass, depthTest, scale: scale$2, lineWidth, fixed, axisColors, hoveredColor, opacity, renderOrder, onDragStart, onDrag, onDragEnd, userData, LineComponent: Line$1 } = React.useContext(context$5);
|
|
7226
7226
|
const camControls = useThree((state) => state.controls);
|
|
7227
|
-
const divRef = React
|
|
7228
|
-
const objRef = React
|
|
7229
|
-
const clickInfo = React
|
|
7230
|
-
const offset0 = React
|
|
7231
|
-
const [isHovered, setIsHovered] = React
|
|
7232
|
-
const onPointerDown = React
|
|
7227
|
+
const divRef = React.useRef(null);
|
|
7228
|
+
const objRef = React.useRef(null);
|
|
7229
|
+
const clickInfo = React.useRef(null);
|
|
7230
|
+
const offset0 = React.useRef(0);
|
|
7231
|
+
const [isHovered, setIsHovered] = React.useState(false);
|
|
7232
|
+
const onPointerDown = React.useCallback((e) => {
|
|
7233
7233
|
if (annotations) {
|
|
7234
7234
|
divRef.current.innerText = `${translation$2.current[axis].toFixed(2)}`;
|
|
7235
7235
|
divRef.current.style.display = "block";
|
|
@@ -7260,7 +7260,7 @@ const AxisArrow = ({ direction, axis }) => {
|
|
|
7260
7260
|
translation$2,
|
|
7261
7261
|
axis
|
|
7262
7262
|
]);
|
|
7263
|
-
const onPointerMove = React
|
|
7263
|
+
const onPointerMove = React.useCallback((e) => {
|
|
7264
7264
|
e.stopPropagation();
|
|
7265
7265
|
if (!isHovered) setIsHovered(true);
|
|
7266
7266
|
if (clickInfo.current) {
|
|
@@ -7282,7 +7282,7 @@ const AxisArrow = ({ direction, axis }) => {
|
|
|
7282
7282
|
translationLimits,
|
|
7283
7283
|
axis
|
|
7284
7284
|
]);
|
|
7285
|
-
const onPointerUp = React
|
|
7285
|
+
const onPointerUp = React.useCallback((e) => {
|
|
7286
7286
|
if (annotations) divRef.current.style.display = "none";
|
|
7287
7287
|
e.stopPropagation();
|
|
7288
7288
|
clickInfo.current = null;
|
|
@@ -7294,11 +7294,11 @@ const AxisArrow = ({ direction, axis }) => {
|
|
|
7294
7294
|
camControls,
|
|
7295
7295
|
onDragEnd
|
|
7296
7296
|
]);
|
|
7297
|
-
const onPointerOut = React
|
|
7297
|
+
const onPointerOut = React.useCallback((e) => {
|
|
7298
7298
|
e.stopPropagation();
|
|
7299
7299
|
setIsHovered(false);
|
|
7300
7300
|
}, []);
|
|
7301
|
-
const { cylinderLength, coneWidth, coneLength, matrixL } = React
|
|
7301
|
+
const { cylinderLength, coneWidth, coneLength, matrixL } = React.useMemo(() => {
|
|
7302
7302
|
const coneWidth$1 = fixed ? lineWidth / scale$2 * 1.6 : scale$2 / 20;
|
|
7303
7303
|
const coneLength$1 = fixed ? .2 : scale$2 / 5;
|
|
7304
7304
|
const cylinderLength$1 = fixed ? 1 - coneLength$1 : scale$2 - coneLength$1;
|
|
@@ -7444,15 +7444,15 @@ const posNew = /* @__PURE__ */ new Vector3$2();
|
|
|
7444
7444
|
const ray$1 = /* @__PURE__ */ new Ray();
|
|
7445
7445
|
const intersection$1 = /* @__PURE__ */ new Vector3$2();
|
|
7446
7446
|
const AxisRotator = ({ dir1, dir2, axis }) => {
|
|
7447
|
-
const { rotationLimits, annotations, annotationsClass, depthTest, scale: scale$2, lineWidth, fixed, axisColors, hoveredColor, renderOrder, opacity, onDragStart, onDrag, onDragEnd, userData, LineComponent: Line$1 } = React
|
|
7447
|
+
const { rotationLimits, annotations, annotationsClass, depthTest, scale: scale$2, lineWidth, fixed, axisColors, hoveredColor, renderOrder, opacity, onDragStart, onDrag, onDragEnd, userData, LineComponent: Line$1 } = React.useContext(context$5);
|
|
7448
7448
|
const camControls = useThree((state) => state.controls);
|
|
7449
|
-
const divRef = React
|
|
7450
|
-
const objRef = React
|
|
7451
|
-
const angle0 = React
|
|
7452
|
-
const angle = React
|
|
7453
|
-
const clickInfo = React
|
|
7454
|
-
const [isHovered, setIsHovered] = React
|
|
7455
|
-
const onPointerDown = React
|
|
7449
|
+
const divRef = React.useRef(null);
|
|
7450
|
+
const objRef = React.useRef(null);
|
|
7451
|
+
const angle0 = React.useRef(0);
|
|
7452
|
+
const angle = React.useRef(0);
|
|
7453
|
+
const clickInfo = React.useRef(null);
|
|
7454
|
+
const [isHovered, setIsHovered] = React.useState(false);
|
|
7455
|
+
const onPointerDown = React.useCallback((e) => {
|
|
7456
7456
|
if (annotations) {
|
|
7457
7457
|
divRef.current.innerText = `${toDegrees(angle.current).toFixed(0)}º`;
|
|
7458
7458
|
divRef.current.style.display = "block";
|
|
@@ -7489,7 +7489,7 @@ const AxisRotator = ({ dir1, dir2, axis }) => {
|
|
|
7489
7489
|
onDragStart,
|
|
7490
7490
|
axis
|
|
7491
7491
|
]);
|
|
7492
|
-
const onPointerMove = React
|
|
7492
|
+
const onPointerMove = React.useCallback((e) => {
|
|
7493
7493
|
e.stopPropagation();
|
|
7494
7494
|
if (!isHovered) setIsHovered(true);
|
|
7495
7495
|
if (clickInfo.current) {
|
|
@@ -7530,7 +7530,7 @@ const AxisRotator = ({ dir1, dir2, axis }) => {
|
|
|
7530
7530
|
rotationLimits,
|
|
7531
7531
|
axis
|
|
7532
7532
|
]);
|
|
7533
|
-
const onPointerUp = React
|
|
7533
|
+
const onPointerUp = React.useCallback((e) => {
|
|
7534
7534
|
if (annotations) divRef.current.style.display = "none";
|
|
7535
7535
|
e.stopPropagation();
|
|
7536
7536
|
angle0.current = angle.current;
|
|
@@ -7543,17 +7543,17 @@ const AxisRotator = ({ dir1, dir2, axis }) => {
|
|
|
7543
7543
|
camControls,
|
|
7544
7544
|
onDragEnd
|
|
7545
7545
|
]);
|
|
7546
|
-
const onPointerOut = React
|
|
7546
|
+
const onPointerOut = React.useCallback((e) => {
|
|
7547
7547
|
e.stopPropagation();
|
|
7548
7548
|
setIsHovered(false);
|
|
7549
7549
|
}, []);
|
|
7550
|
-
const matrixL = React
|
|
7550
|
+
const matrixL = React.useMemo(() => {
|
|
7551
7551
|
const dir1N = dir1.clone().normalize();
|
|
7552
7552
|
const dir2N = dir2.clone().normalize();
|
|
7553
7553
|
return new Matrix4().makeBasis(dir1N, dir2N, dir1N.clone().cross(dir2N));
|
|
7554
7554
|
}, [dir1, dir2]);
|
|
7555
7555
|
const r = fixed ? .65 : scale$2 * .65;
|
|
7556
|
-
const arc = React
|
|
7556
|
+
const arc = React.useMemo(() => {
|
|
7557
7557
|
const segments = 32;
|
|
7558
7558
|
const points = [];
|
|
7559
7559
|
for (let j = 0; j <= segments; j++) {
|
|
@@ -7636,15 +7636,15 @@ const ray = /* @__PURE__ */ new Ray();
|
|
|
7636
7636
|
const intersection = /* @__PURE__ */ new Vector3$2();
|
|
7637
7637
|
const offsetMatrix = /* @__PURE__ */ new Matrix4();
|
|
7638
7638
|
const PlaneSlider = ({ dir1, dir2, axis }) => {
|
|
7639
|
-
const { translation: translation$2, translationLimits, annotations, annotationsClass, depthTest, scale: scale$2, lineWidth, fixed, axisColors, hoveredColor, opacity, renderOrder, onDragStart, onDrag, onDragEnd, userData, LineComponent: Line$1 } = React
|
|
7639
|
+
const { translation: translation$2, translationLimits, annotations, annotationsClass, depthTest, scale: scale$2, lineWidth, fixed, axisColors, hoveredColor, opacity, renderOrder, onDragStart, onDrag, onDragEnd, userData, LineComponent: Line$1 } = React.useContext(context$5);
|
|
7640
7640
|
const camControls = useThree((state) => state.controls);
|
|
7641
|
-
const divRef = React
|
|
7642
|
-
const objRef = React
|
|
7643
|
-
const clickInfo = React
|
|
7644
|
-
const offsetX0 = React
|
|
7645
|
-
const offsetY0 = React
|
|
7646
|
-
const [isHovered, setIsHovered] = React
|
|
7647
|
-
const onPointerDown = React
|
|
7641
|
+
const divRef = React.useRef(null);
|
|
7642
|
+
const objRef = React.useRef(null);
|
|
7643
|
+
const clickInfo = React.useRef(null);
|
|
7644
|
+
const offsetX0 = React.useRef(0);
|
|
7645
|
+
const offsetY0 = React.useRef(0);
|
|
7646
|
+
const [isHovered, setIsHovered] = React.useState(false);
|
|
7647
|
+
const onPointerDown = React.useCallback((e) => {
|
|
7648
7648
|
if (annotations) {
|
|
7649
7649
|
divRef.current.innerText = `${translation$2.current[(axis + 1) % 3].toFixed(2)}, ${translation$2.current[(axis + 2) % 3].toFixed(2)}`;
|
|
7650
7650
|
divRef.current.style.display = "block";
|
|
@@ -7681,7 +7681,7 @@ const PlaneSlider = ({ dir1, dir2, axis }) => {
|
|
|
7681
7681
|
onDragStart,
|
|
7682
7682
|
axis
|
|
7683
7683
|
]);
|
|
7684
|
-
const onPointerMove = React
|
|
7684
|
+
const onPointerMove = React.useCallback((e) => {
|
|
7685
7685
|
e.stopPropagation();
|
|
7686
7686
|
if (!isHovered) setIsHovered(true);
|
|
7687
7687
|
if (clickInfo.current) {
|
|
@@ -7712,7 +7712,7 @@ const PlaneSlider = ({ dir1, dir2, axis }) => {
|
|
|
7712
7712
|
translationLimits,
|
|
7713
7713
|
axis
|
|
7714
7714
|
]);
|
|
7715
|
-
const onPointerUp = React
|
|
7715
|
+
const onPointerUp = React.useCallback((e) => {
|
|
7716
7716
|
if (annotations) divRef.current.style.display = "none";
|
|
7717
7717
|
e.stopPropagation();
|
|
7718
7718
|
clickInfo.current = null;
|
|
@@ -7724,11 +7724,11 @@ const PlaneSlider = ({ dir1, dir2, axis }) => {
|
|
|
7724
7724
|
camControls,
|
|
7725
7725
|
onDragEnd
|
|
7726
7726
|
]);
|
|
7727
|
-
const onPointerOut = React
|
|
7727
|
+
const onPointerOut = React.useCallback((e) => {
|
|
7728
7728
|
e.stopPropagation();
|
|
7729
7729
|
setIsHovered(false);
|
|
7730
7730
|
}, []);
|
|
7731
|
-
const matrixL = React
|
|
7731
|
+
const matrixL = React.useMemo(() => {
|
|
7732
7732
|
const dir1N = dir1.clone().normalize();
|
|
7733
7733
|
const dir2N = dir2.clone().normalize();
|
|
7734
7734
|
return new Matrix4().makeBasis(dir1N, dir2N, dir1N.clone().cross(dir2N));
|
|
@@ -7736,7 +7736,7 @@ const PlaneSlider = ({ dir1, dir2, axis }) => {
|
|
|
7736
7736
|
const pos1 = fixed ? 1 / 7 : scale$2 / 7;
|
|
7737
7737
|
const length$1 = fixed ? .225 : scale$2 * .225;
|
|
7738
7738
|
const color = isHovered ? hoveredColor : axisColors[axis];
|
|
7739
|
-
const points = React
|
|
7739
|
+
const points = React.useMemo(() => [
|
|
7740
7740
|
new Vector3$2(0, 0, 0),
|
|
7741
7741
|
new Vector3$2(0, length$1, 0),
|
|
7742
7742
|
new Vector3$2(length$1, length$1, 0),
|
|
@@ -7858,18 +7858,18 @@ const upV = /* @__PURE__ */ new Vector3$2(0, 1, 0);
|
|
|
7858
7858
|
const scaleV = /* @__PURE__ */ new Vector3$2();
|
|
7859
7859
|
const scaleMatrix = /* @__PURE__ */ new Matrix4();
|
|
7860
7860
|
const ScalingSphere = ({ direction, axis }) => {
|
|
7861
|
-
const { scaleLimits, annotations, annotationsClass, depthTest, scale: scale$2, lineWidth, fixed, axisColors, hoveredColor, opacity, renderOrder, onDragStart, onDrag, onDragEnd, userData } = React
|
|
7861
|
+
const { scaleLimits, annotations, annotationsClass, depthTest, scale: scale$2, lineWidth, fixed, axisColors, hoveredColor, opacity, renderOrder, onDragStart, onDrag, onDragEnd, userData } = React.useContext(context$5);
|
|
7862
7862
|
const size = useThree((state) => state.size);
|
|
7863
7863
|
const camControls = useThree((state) => state.controls);
|
|
7864
|
-
const divRef = React
|
|
7865
|
-
const objRef = React
|
|
7866
|
-
const meshRef = React
|
|
7867
|
-
const scale0 = React
|
|
7868
|
-
const scaleCur = React
|
|
7869
|
-
const clickInfo = React
|
|
7870
|
-
const [isHovered, setIsHovered] = React
|
|
7864
|
+
const divRef = React.useRef(null);
|
|
7865
|
+
const objRef = React.useRef(null);
|
|
7866
|
+
const meshRef = React.useRef(null);
|
|
7867
|
+
const scale0 = React.useRef(1);
|
|
7868
|
+
const scaleCur = React.useRef(1);
|
|
7869
|
+
const clickInfo = React.useRef(null);
|
|
7870
|
+
const [isHovered, setIsHovered] = React.useState(false);
|
|
7871
7871
|
const position$1 = fixed ? 1.2 : 1.2 * scale$2;
|
|
7872
|
-
const onPointerDown = React
|
|
7872
|
+
const onPointerDown = React.useCallback((e) => {
|
|
7873
7873
|
if (annotations) {
|
|
7874
7874
|
divRef.current.innerText = `${scaleCur.current.toFixed(2)}`;
|
|
7875
7875
|
divRef.current.style.display = "block";
|
|
@@ -7905,7 +7905,7 @@ const ScalingSphere = ({ direction, axis }) => {
|
|
|
7905
7905
|
scale$2,
|
|
7906
7906
|
size
|
|
7907
7907
|
]);
|
|
7908
|
-
const onPointerMove = React
|
|
7908
|
+
const onPointerMove = React.useCallback((e) => {
|
|
7909
7909
|
e.stopPropagation();
|
|
7910
7910
|
if (!isHovered) setIsHovered(true);
|
|
7911
7911
|
if (clickInfo.current) {
|
|
@@ -7933,7 +7933,7 @@ const ScalingSphere = ({ direction, axis }) => {
|
|
|
7933
7933
|
scaleLimits,
|
|
7934
7934
|
axis
|
|
7935
7935
|
]);
|
|
7936
|
-
const onPointerUp = React
|
|
7936
|
+
const onPointerUp = React.useCallback((e) => {
|
|
7937
7937
|
if (annotations) divRef.current.style.display = "none";
|
|
7938
7938
|
e.stopPropagation();
|
|
7939
7939
|
scale0.current = scaleCur.current;
|
|
@@ -7948,11 +7948,11 @@ const ScalingSphere = ({ direction, axis }) => {
|
|
|
7948
7948
|
onDragEnd,
|
|
7949
7949
|
position$1
|
|
7950
7950
|
]);
|
|
7951
|
-
const onPointerOut = React
|
|
7951
|
+
const onPointerOut = React.useCallback((e) => {
|
|
7952
7952
|
e.stopPropagation();
|
|
7953
7953
|
setIsHovered(false);
|
|
7954
7954
|
}, []);
|
|
7955
|
-
const { radius, matrixL } = React
|
|
7955
|
+
const { radius, matrixL } = React.useMemo(() => {
|
|
7956
7956
|
const radius$1 = fixed ? lineWidth / scale$2 * 1.8 : scale$2 / 22.5;
|
|
7957
7957
|
const quaternion = new Quaternion().setFromUnitVectors(upV, direction.clone().normalize());
|
|
7958
7958
|
return {
|
|
@@ -8062,7 +8062,7 @@ const zDir = /* @__PURE__ */ new Vector3$2(0, 0, 1);
|
|
|
8062
8062
|
* />
|
|
8063
8063
|
* ```
|
|
8064
8064
|
*/
|
|
8065
|
-
const PivotControls = /* @__PURE__ */ React
|
|
8065
|
+
const PivotControls = /* @__PURE__ */ React.forwardRef(({ enabled = true, matrix: matrix$1, onDragStart, onDrag, onDragEnd, autoTransform = true, anchor, disableAxes = false, disableSliders = false, disableRotations = false, disableScaling = false, activeAxes = [
|
|
8066
8066
|
true,
|
|
8067
8067
|
true,
|
|
8068
8068
|
true
|
|
@@ -8081,18 +8081,18 @@ const PivotControls = /* @__PURE__ */ React$1.forwardRef(({ enabled = true, matr
|
|
|
8081
8081
|
], hoveredColor = "#ffff40", annotations = false, annotationsClass, opacity = 1, visible = true, userData, children, LineComponent, ...props }, fRef) => {
|
|
8082
8082
|
const LineComp = LineComponent ?? Line;
|
|
8083
8083
|
const invalidate = useThree((state) => state.invalidate);
|
|
8084
|
-
const parentRef = React
|
|
8085
|
-
const ref = React
|
|
8086
|
-
const gizmoRef = React
|
|
8087
|
-
const childrenRef = React
|
|
8088
|
-
const translation$2 = React
|
|
8084
|
+
const parentRef = React.useRef(null);
|
|
8085
|
+
const ref = React.useRef(null);
|
|
8086
|
+
const gizmoRef = React.useRef(null);
|
|
8087
|
+
const childrenRef = React.useRef(null);
|
|
8088
|
+
const translation$2 = React.useRef([
|
|
8089
8089
|
0,
|
|
8090
8090
|
0,
|
|
8091
8091
|
0
|
|
8092
8092
|
]);
|
|
8093
|
-
const cameraScale = React
|
|
8094
|
-
const gizmoScale = React
|
|
8095
|
-
React
|
|
8093
|
+
const cameraScale = React.useRef(new Vector3$2(1, 1, 1));
|
|
8094
|
+
const gizmoScale = React.useRef(new Vector3$2(1, 1, 1));
|
|
8095
|
+
React.useLayoutEffect(() => {
|
|
8096
8096
|
if (!anchor) return;
|
|
8097
8097
|
childrenRef.current.updateWorldMatrix(true, true);
|
|
8098
8098
|
mPInv.copy(childrenRef.current.matrixWorld).invert();
|
|
@@ -8112,7 +8112,7 @@ const PivotControls = /* @__PURE__ */ React$1.forwardRef(({ enabled = true, matr
|
|
|
8112
8112
|
gizmoRef.current.position.copy(vPosition);
|
|
8113
8113
|
invalidate();
|
|
8114
8114
|
});
|
|
8115
|
-
const config = React
|
|
8115
|
+
const config = React.useMemo(() => ({
|
|
8116
8116
|
onDragStart: (props$1) => {
|
|
8117
8117
|
mL0.copy(ref.current.matrix);
|
|
8118
8118
|
mW0.copy(ref.current.matrixWorld);
|
|
@@ -8186,7 +8186,7 @@ const PivotControls = /* @__PURE__ */ React$1.forwardRef(({ enabled = true, matr
|
|
|
8186
8186
|
state.invalidate();
|
|
8187
8187
|
}
|
|
8188
8188
|
});
|
|
8189
|
-
React
|
|
8189
|
+
React.useImperativeHandle(fRef, () => ref.current, []);
|
|
8190
8190
|
return /* @__PURE__ */ jsx(context$5.Provider, {
|
|
8191
8191
|
value: config,
|
|
8192
8192
|
children: /* @__PURE__ */ jsx("group", {
|
|
@@ -8286,7 +8286,7 @@ const PivotControls = /* @__PURE__ */ React$1.forwardRef(({ enabled = true, matr
|
|
|
8286
8286
|
* <mesh ref={meshRef} />
|
|
8287
8287
|
* ```
|
|
8288
8288
|
*/
|
|
8289
|
-
const TransformControls = /* @__PURE__ */ React
|
|
8289
|
+
const TransformControls = /* @__PURE__ */ React.forwardRef(({ children, domElement, onChange, onMouseDown, onMouseUp, onObjectChange, object, makeDefault, camera, enabled, axis, mode, translationSnap, rotationSnap, scaleSnap, space, size, showX, showY, showZ, ...props }, ref) => {
|
|
8290
8290
|
const defaultControls = useThree((state) => state.controls);
|
|
8291
8291
|
const gl = useThree((state) => state.gl);
|
|
8292
8292
|
const events = useThree((state) => state.events);
|
|
@@ -8296,9 +8296,9 @@ const TransformControls = /* @__PURE__ */ React$1.forwardRef(({ children, domEle
|
|
|
8296
8296
|
const set = useThree((state) => state.set);
|
|
8297
8297
|
const explCamera = camera || defaultCamera;
|
|
8298
8298
|
const explDomElement = domElement || events.connected || gl.domElement;
|
|
8299
|
-
const controls = React
|
|
8300
|
-
const group = React
|
|
8301
|
-
React
|
|
8299
|
+
const controls = React.useMemo(() => new TransformControls$1(explCamera, explDomElement), [explCamera, explDomElement]);
|
|
8300
|
+
const group = React.useRef(null);
|
|
8301
|
+
React.useLayoutEffect(() => {
|
|
8302
8302
|
if (object) controls.attach(object instanceof Object3D$1 ? object : object.current);
|
|
8303
8303
|
else if (group.current instanceof Object3D$1) controls.attach(group.current);
|
|
8304
8304
|
return () => void controls.detach();
|
|
@@ -8307,22 +8307,22 @@ const TransformControls = /* @__PURE__ */ React$1.forwardRef(({ children, domEle
|
|
|
8307
8307
|
children,
|
|
8308
8308
|
controls
|
|
8309
8309
|
]);
|
|
8310
|
-
React
|
|
8310
|
+
React.useEffect(() => {
|
|
8311
8311
|
if (defaultControls) {
|
|
8312
8312
|
const callback = (event) => defaultControls.enabled = !event.value;
|
|
8313
8313
|
controls.addEventListener("dragging-changed", callback);
|
|
8314
8314
|
return () => controls.removeEventListener("dragging-changed", callback);
|
|
8315
8315
|
}
|
|
8316
8316
|
}, [controls, defaultControls]);
|
|
8317
|
-
const onChangeRef = React
|
|
8318
|
-
const onMouseDownRef = React
|
|
8319
|
-
const onMouseUpRef = React
|
|
8320
|
-
const onObjectChangeRef = React
|
|
8321
|
-
React
|
|
8322
|
-
React
|
|
8323
|
-
React
|
|
8324
|
-
React
|
|
8325
|
-
React
|
|
8317
|
+
const onChangeRef = React.useRef(void 0);
|
|
8318
|
+
const onMouseDownRef = React.useRef(void 0);
|
|
8319
|
+
const onMouseUpRef = React.useRef(void 0);
|
|
8320
|
+
const onObjectChangeRef = React.useRef(void 0);
|
|
8321
|
+
React.useLayoutEffect(() => void (onChangeRef.current = onChange), [onChange]);
|
|
8322
|
+
React.useLayoutEffect(() => void (onMouseDownRef.current = onMouseDown), [onMouseDown]);
|
|
8323
|
+
React.useLayoutEffect(() => void (onMouseUpRef.current = onMouseUp), [onMouseUp]);
|
|
8324
|
+
React.useLayoutEffect(() => void (onObjectChangeRef.current = onObjectChange), [onObjectChange]);
|
|
8325
|
+
React.useEffect(() => {
|
|
8326
8326
|
const onChange$1 = (e) => {
|
|
8327
8327
|
invalidate();
|
|
8328
8328
|
onChangeRef.current?.(e);
|
|
@@ -8341,7 +8341,7 @@ const TransformControls = /* @__PURE__ */ React$1.forwardRef(({ children, domEle
|
|
|
8341
8341
|
controls.removeEventListener("objectChange", onObjectChange$1);
|
|
8342
8342
|
};
|
|
8343
8343
|
}, [invalidate, controls]);
|
|
8344
|
-
React
|
|
8344
|
+
React.useEffect(() => {
|
|
8345
8345
|
if (makeDefault) {
|
|
8346
8346
|
const old = get().controls;
|
|
8347
8347
|
set({ controls });
|
|
@@ -8402,8 +8402,8 @@ var PointMaterialImpl = class extends PointsMaterial {
|
|
|
8402
8402
|
* </points>
|
|
8403
8403
|
* ```
|
|
8404
8404
|
*/
|
|
8405
|
-
const PointMaterial = /* @__PURE__ */ React
|
|
8406
|
-
const [material] = React
|
|
8405
|
+
const PointMaterial = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
8406
|
+
const [material] = React.useState(() => new PointMaterialImpl(null));
|
|
8407
8407
|
return /* @__PURE__ */ jsx("primitive", {
|
|
8408
8408
|
...props,
|
|
8409
8409
|
object: material,
|
|
@@ -8428,13 +8428,13 @@ const PointMaterial = /* @__PURE__ */ React$1.forwardRef((props, ref) => {
|
|
|
8428
8428
|
* />
|
|
8429
8429
|
* ```
|
|
8430
8430
|
*/
|
|
8431
|
-
const PositionalAudio = /* @__PURE__ */ React
|
|
8432
|
-
const sound = React
|
|
8433
|
-
React
|
|
8431
|
+
const PositionalAudio = /* @__PURE__ */ React.forwardRef(({ url, distance: distance$1 = 1, loop = true, autoplay, ...props }, ref) => {
|
|
8432
|
+
const sound = React.useRef(null);
|
|
8433
|
+
React.useImperativeHandle(ref, () => sound.current, []);
|
|
8434
8434
|
const camera = useThree(({ camera: camera$1 }) => camera$1);
|
|
8435
|
-
const [listener] = React
|
|
8435
|
+
const [listener] = React.useState(() => new AudioListener());
|
|
8436
8436
|
const buffer = useLoader(AudioLoader, url);
|
|
8437
|
-
React
|
|
8437
|
+
React.useEffect(() => {
|
|
8438
8438
|
const _sound = sound.current;
|
|
8439
8439
|
if (_sound) {
|
|
8440
8440
|
_sound.setBuffer(Array.isArray(buffer) ? buffer[0] : buffer);
|
|
@@ -8448,7 +8448,7 @@ const PositionalAudio = /* @__PURE__ */ React$1.forwardRef(({ url, distance: dis
|
|
|
8448
8448
|
distance$1,
|
|
8449
8449
|
loop
|
|
8450
8450
|
]);
|
|
8451
|
-
React
|
|
8451
|
+
React.useEffect(() => {
|
|
8452
8452
|
const _sound = sound.current;
|
|
8453
8453
|
camera.add(listener);
|
|
8454
8454
|
return () => {
|
|
@@ -8511,7 +8511,7 @@ var PositionMesh = class extends Group {
|
|
|
8511
8511
|
_instanceIntersects.length = 0;
|
|
8512
8512
|
}
|
|
8513
8513
|
};
|
|
8514
|
-
const globalContext = /* @__PURE__ */ React
|
|
8514
|
+
const globalContext = /* @__PURE__ */ React.createContext(null);
|
|
8515
8515
|
const parentMatrix = /* @__PURE__ */ new Matrix4();
|
|
8516
8516
|
const instanceMatrix = /* @__PURE__ */ new Matrix4();
|
|
8517
8517
|
const tempMatrix = /* @__PURE__ */ new Matrix4();
|
|
@@ -8523,12 +8523,12 @@ const isInstancedBufferAttribute = (attr) => attr.isInstancedBufferAttribute;
|
|
|
8523
8523
|
* A single instance within an Instances container.
|
|
8524
8524
|
* Supports transform props, colors, and events.
|
|
8525
8525
|
*/
|
|
8526
|
-
const Instance = /* @__PURE__ */ React
|
|
8527
|
-
React
|
|
8528
|
-
const group = React
|
|
8529
|
-
React
|
|
8530
|
-
const { subscribe, getParent } = React
|
|
8531
|
-
React
|
|
8526
|
+
const Instance = /* @__PURE__ */ React.forwardRef(({ context: context$11, children, ...props }, ref) => {
|
|
8527
|
+
React.useMemo(() => extend({ PositionMesh }), []);
|
|
8528
|
+
const group = React.useRef(null);
|
|
8529
|
+
React.useImperativeHandle(ref, () => group.current, []);
|
|
8530
|
+
const { subscribe, getParent } = React.useContext(context$11 || globalContext);
|
|
8531
|
+
React.useLayoutEffect(() => subscribe(group), []);
|
|
8532
8532
|
return /* @__PURE__ */ jsx("positionMesh", {
|
|
8533
8533
|
instance: getParent(),
|
|
8534
8534
|
instanceKey: group,
|
|
@@ -8551,33 +8551,33 @@ const Instance = /* @__PURE__ */ React$1.forwardRef(({ context: context$11, chil
|
|
|
8551
8551
|
* </Instances>
|
|
8552
8552
|
* ```
|
|
8553
8553
|
*/
|
|
8554
|
-
const Instances = /* @__PURE__ */ React
|
|
8555
|
-
const [{ localContext, instance }] = React
|
|
8556
|
-
const localContext$1 = React
|
|
8554
|
+
const Instances = /* @__PURE__ */ React.forwardRef(({ context: context$11, children, range, limit = 1e3, frames = Infinity, ...props }, ref) => {
|
|
8555
|
+
const [{ localContext, instance }] = React.useState(() => {
|
|
8556
|
+
const localContext$1 = React.createContext(null);
|
|
8557
8557
|
return {
|
|
8558
8558
|
localContext: localContext$1,
|
|
8559
|
-
instance: React
|
|
8559
|
+
instance: React.forwardRef((props$1, ref$1) => /* @__PURE__ */ jsx(Instance, {
|
|
8560
8560
|
context: localContext$1,
|
|
8561
8561
|
...props$1,
|
|
8562
8562
|
ref: ref$1
|
|
8563
8563
|
}))
|
|
8564
8564
|
};
|
|
8565
8565
|
});
|
|
8566
|
-
const parentRef = React
|
|
8567
|
-
React
|
|
8568
|
-
const [instances, setInstances] = React
|
|
8569
|
-
const [[matrices, colors$1]] = React
|
|
8566
|
+
const parentRef = React.useRef(null);
|
|
8567
|
+
React.useImperativeHandle(ref, () => parentRef.current, []);
|
|
8568
|
+
const [instances, setInstances] = React.useState([]);
|
|
8569
|
+
const [[matrices, colors$1]] = React.useState(() => {
|
|
8570
8570
|
const mArray = new Float32Array(limit * 16);
|
|
8571
8571
|
for (let i$1 = 0; i$1 < limit; i$1++) tempMatrix.identity().toArray(mArray, i$1 * 16);
|
|
8572
8572
|
return [mArray, new Float32Array([...new Array(limit * 3)].map(() => 1))];
|
|
8573
8573
|
});
|
|
8574
|
-
React
|
|
8574
|
+
React.useEffect(() => {
|
|
8575
8575
|
parentRef.current.instanceMatrix.needsUpdate = true;
|
|
8576
8576
|
});
|
|
8577
8577
|
let iterations = 0;
|
|
8578
8578
|
let count = 0;
|
|
8579
|
-
const attributes = React
|
|
8580
|
-
React
|
|
8579
|
+
const attributes = React.useRef([]);
|
|
8580
|
+
React.useLayoutEffect(() => {
|
|
8581
8581
|
attributes.current = Object.entries(parentRef.current.geometry.attributes).filter(([_name, value]) => isInstancedBufferAttribute(value));
|
|
8582
8582
|
});
|
|
8583
8583
|
useFrame(() => {
|
|
@@ -8608,7 +8608,7 @@ const Instances = /* @__PURE__ */ React$1.forwardRef(({ context: context$11, chi
|
|
|
8608
8608
|
iterations++;
|
|
8609
8609
|
}
|
|
8610
8610
|
});
|
|
8611
|
-
const api = React
|
|
8611
|
+
const api = React.useMemo(() => ({
|
|
8612
8612
|
getParent: () => parentRef,
|
|
8613
8613
|
subscribe: (ref$1) => {
|
|
8614
8614
|
setInstances((instances$1) => [...instances$1, ref$1]);
|
|
@@ -8654,7 +8654,7 @@ const Instances = /* @__PURE__ */ React$1.forwardRef(({ context: context$11, chi
|
|
|
8654
8654
|
]
|
|
8655
8655
|
});
|
|
8656
8656
|
});
|
|
8657
|
-
const Merged = /* @__PURE__ */ React
|
|
8657
|
+
const Merged = /* @__PURE__ */ React.forwardRef(function Merged$1({ meshes, children, ...props }, ref) {
|
|
8658
8658
|
const isArray$1 = Array.isArray(meshes);
|
|
8659
8659
|
if (!isArray$1) {
|
|
8660
8660
|
for (const key of Object.keys(meshes)) if (!meshes[key].isMesh) delete meshes[key];
|
|
@@ -8680,7 +8680,7 @@ function renderRecursive(render, components, results = []) {
|
|
|
8680
8680
|
return typeof components[0] === "function" ? components[0]({
|
|
8681
8681
|
results,
|
|
8682
8682
|
render: nextRender
|
|
8683
|
-
}) : React
|
|
8683
|
+
}) : React.cloneElement(components[0], { children: nextRender });
|
|
8684
8684
|
}
|
|
8685
8685
|
/** Idea and implementation for global instances and instanced attributes by
|
|
8686
8686
|
/* Matias Gonzalez Fernandez https://x.com/matiNotFound
|
|
@@ -8703,12 +8703,12 @@ function renderRecursive(render, components, results = []) {
|
|
|
8703
8703
|
* ```
|
|
8704
8704
|
*/
|
|
8705
8705
|
function createInstances() {
|
|
8706
|
-
const context$11 = React
|
|
8707
|
-
return [React
|
|
8706
|
+
const context$11 = React.createContext(null);
|
|
8707
|
+
return [React.forwardRef((props, fref) => /* @__PURE__ */ jsx(Instances, {
|
|
8708
8708
|
ref: fref,
|
|
8709
8709
|
context: context$11,
|
|
8710
8710
|
...props
|
|
8711
|
-
})), React
|
|
8711
|
+
})), React.forwardRef((props, fref) => /* @__PURE__ */ jsx(Instance, {
|
|
8712
8712
|
ref: fref,
|
|
8713
8713
|
context: context$11,
|
|
8714
8714
|
...props
|
|
@@ -8728,10 +8728,10 @@ function createInstances() {
|
|
|
8728
8728
|
* </Instances>
|
|
8729
8729
|
* ```
|
|
8730
8730
|
*/
|
|
8731
|
-
const InstancedAttribute = React
|
|
8732
|
-
const ref = React
|
|
8733
|
-
React
|
|
8734
|
-
React
|
|
8731
|
+
const InstancedAttribute = React.forwardRef(({ name, defaultValue, normalized, usage = DynamicDrawUsage }, fref) => {
|
|
8732
|
+
const ref = React.useRef(null);
|
|
8733
|
+
React.useImperativeHandle(fref, () => ref.current, []);
|
|
8734
|
+
React.useLayoutEffect(() => {
|
|
8735
8735
|
const parent = ref.current.__r3f.parent.object;
|
|
8736
8736
|
parent.geometry.attributes[name] = ref.current;
|
|
8737
8737
|
const value = Array.isArray(defaultValue) ? defaultValue : [defaultValue];
|
|
@@ -8794,9 +8794,9 @@ const InstancedAttribute = React$1.forwardRef(({ name, defaultValue, normalized,
|
|
|
8794
8794
|
* </group>
|
|
8795
8795
|
* ```
|
|
8796
8796
|
*/
|
|
8797
|
-
const Billboard = /* @__PURE__ */ React
|
|
8798
|
-
const inner = React
|
|
8799
|
-
const localRef = React
|
|
8797
|
+
const Billboard = /* @__PURE__ */ React.forwardRef(function Billboard$1({ children, follow = true, lockX = false, lockY = false, lockZ = false, ...props }, fref) {
|
|
8798
|
+
const inner = React.useRef(null);
|
|
8799
|
+
const localRef = React.useRef(null);
|
|
8800
8800
|
const q = new Quaternion();
|
|
8801
8801
|
useFrame(({ camera }) => {
|
|
8802
8802
|
if (!follow || !localRef.current) return;
|
|
@@ -8809,7 +8809,7 @@ const Billboard = /* @__PURE__ */ React$1.forwardRef(function Billboard$1({ chil
|
|
|
8809
8809
|
if (lockY) inner.current.rotation.y = prevRotation.y;
|
|
8810
8810
|
if (lockZ) inner.current.rotation.z = prevRotation.z;
|
|
8811
8811
|
});
|
|
8812
|
-
React
|
|
8812
|
+
React.useImperativeHandle(fref, () => localRef.current, []);
|
|
8813
8813
|
return /* @__PURE__ */ jsx("group", {
|
|
8814
8814
|
ref: localRef,
|
|
8815
8815
|
...props,
|
|
@@ -8839,18 +8839,18 @@ const checkIfFrameIsEmpty = (frameData) => {
|
|
|
8839
8839
|
* ```
|
|
8840
8840
|
*/
|
|
8841
8841
|
function useSpriteLoader(input, json, animationNames, numberOfFrames, onLoad, canvasRenderingContext2DSettings) {
|
|
8842
|
-
const viewportRef = React
|
|
8843
|
-
const spriteDataRef = React
|
|
8844
|
-
const totalFrames = React
|
|
8842
|
+
const viewportRef = React.useRef(useThree((state) => state.viewport));
|
|
8843
|
+
const spriteDataRef = React.useRef(null);
|
|
8844
|
+
const totalFrames = React.useRef(0);
|
|
8845
8845
|
const aspectFactor = .1;
|
|
8846
|
-
const inputRef = React
|
|
8847
|
-
const jsonRef = React
|
|
8848
|
-
const animationFramesRef = React
|
|
8846
|
+
const inputRef = React.useRef(input);
|
|
8847
|
+
const jsonRef = React.useRef(json);
|
|
8848
|
+
const animationFramesRef = React.useRef(animationNames);
|
|
8849
8849
|
const [spriteData, setSpriteData] = useState(null);
|
|
8850
|
-
const [spriteTexture, setSpriteTexture] = React
|
|
8851
|
-
const textureLoader = React
|
|
8850
|
+
const [spriteTexture, setSpriteTexture] = React.useState(new Texture$1());
|
|
8851
|
+
const textureLoader = React.useMemo(() => new TextureLoader(), []);
|
|
8852
8852
|
const [spriteObj, setSpriteObj] = useState(null);
|
|
8853
|
-
const calculateAspectRatio = React
|
|
8853
|
+
const calculateAspectRatio = React.useCallback((width, height, factor) => {
|
|
8854
8854
|
const adaptedHeight = height * (viewportRef.current.aspect > width / height ? viewportRef.current.width / width : viewportRef.current.height / height);
|
|
8855
8855
|
const scaleX = width * (viewportRef.current.aspect > width / height ? viewportRef.current.width / width : viewportRef.current.height / height) * factor;
|
|
8856
8856
|
const scaleY = adaptedHeight * factor;
|
|
@@ -8863,7 +8863,7 @@ function useSpriteLoader(input, json, animationNames, numberOfFrames, onLoad, ca
|
|
|
8863
8863
|
}
|
|
8864
8864
|
return new Vector3$2(finalMaxScaleW, finalMaxScaleH, 1);
|
|
8865
8865
|
}, []);
|
|
8866
|
-
const getRowsAndColumns = React
|
|
8866
|
+
const getRowsAndColumns = React.useCallback((texture$1, totalFrames$1) => {
|
|
8867
8867
|
if (texture$1.image) {
|
|
8868
8868
|
const canvas = document.createElement("canvas");
|
|
8869
8869
|
const ctx = canvas.getContext("2d", canvasRenderingContext2DSettings);
|
|
@@ -8908,7 +8908,7 @@ function useSpriteLoader(input, json, animationNames, numberOfFrames, onLoad, ca
|
|
|
8908
8908
|
emptyFrames: []
|
|
8909
8909
|
};
|
|
8910
8910
|
}, [canvasRenderingContext2DSettings]);
|
|
8911
|
-
const calculateScaleRatio = React
|
|
8911
|
+
const calculateScaleRatio = React.useCallback((frames) => {
|
|
8912
8912
|
const processFrameArray = (frameArray) => {
|
|
8913
8913
|
let largestFrame = null;
|
|
8914
8914
|
for (const frame of frameArray) {
|
|
@@ -8937,7 +8937,7 @@ function useSpriteLoader(input, json, animationNames, numberOfFrames, onLoad, ca
|
|
|
8937
8937
|
return result;
|
|
8938
8938
|
}
|
|
8939
8939
|
}, []);
|
|
8940
|
-
const parseFrames = React
|
|
8940
|
+
const parseFrames = React.useCallback(() => {
|
|
8941
8941
|
const sprites = {};
|
|
8942
8942
|
const data = spriteDataRef.current;
|
|
8943
8943
|
const delimiters = animationFramesRef.current;
|
|
@@ -9006,7 +9006,7 @@ function useSpriteLoader(input, json, animationNames, numberOfFrames, onLoad, ca
|
|
|
9006
9006
|
}
|
|
9007
9007
|
return [];
|
|
9008
9008
|
}, [calculateScaleRatio, spriteDataRef]);
|
|
9009
|
-
const parseSpriteData = React
|
|
9009
|
+
const parseSpriteData = React.useCallback((json$1, _spriteTexture) => {
|
|
9010
9010
|
let aspect$1 = new Vector3$2(1, 1, 1);
|
|
9011
9011
|
if (json$1 === null) {
|
|
9012
9012
|
if (_spriteTexture && numberOfFrames) {
|
|
@@ -9084,7 +9084,7 @@ function useSpriteLoader(input, json, animationNames, numberOfFrames, onLoad, ca
|
|
|
9084
9084
|
/**
|
|
9085
9085
|
*
|
|
9086
9086
|
*/
|
|
9087
|
-
const loadJsonAndTextureAndExecuteCallback = React
|
|
9087
|
+
const loadJsonAndTextureAndExecuteCallback = React.useCallback((jsonUrl, textureUrl, callback) => {
|
|
9088
9088
|
const jsonPromise = fetch(jsonUrl).then((response) => response.json());
|
|
9089
9089
|
const texturePromise = new Promise((resolve) => {
|
|
9090
9090
|
textureLoader.load(textureUrl, resolve);
|
|
@@ -9093,13 +9093,13 @@ function useSpriteLoader(input, json, animationNames, numberOfFrames, onLoad, ca
|
|
|
9093
9093
|
callback(response[0], response[1]);
|
|
9094
9094
|
});
|
|
9095
9095
|
}, [textureLoader]);
|
|
9096
|
-
const loadStandaloneSprite = React
|
|
9096
|
+
const loadStandaloneSprite = React.useCallback((textureUrl) => {
|
|
9097
9097
|
if (!textureUrl && !inputRef.current) throw new Error("Either textureUrl or input must be provided");
|
|
9098
9098
|
const validUrl = textureUrl ?? inputRef.current;
|
|
9099
9099
|
if (!validUrl) throw new Error("A valid texture URL must be provided");
|
|
9100
9100
|
textureLoader.load(validUrl, (texture$1) => parseSpriteData(null, texture$1));
|
|
9101
9101
|
}, [textureLoader, parseSpriteData]);
|
|
9102
|
-
const loadJsonAndTexture = React
|
|
9102
|
+
const loadJsonAndTexture = React.useCallback((textureUrl, jsonUrl) => {
|
|
9103
9103
|
if (jsonUrl && textureUrl) loadJsonAndTextureAndExecuteCallback(jsonUrl, textureUrl, parseSpriteData);
|
|
9104
9104
|
else loadStandaloneSprite(textureUrl);
|
|
9105
9105
|
}, [
|
|
@@ -9107,7 +9107,7 @@ function useSpriteLoader(input, json, animationNames, numberOfFrames, onLoad, ca
|
|
|
9107
9107
|
loadStandaloneSprite,
|
|
9108
9108
|
parseSpriteData
|
|
9109
9109
|
]);
|
|
9110
|
-
React
|
|
9110
|
+
React.useLayoutEffect(() => {
|
|
9111
9111
|
if (jsonRef.current && inputRef.current) loadJsonAndTextureAndExecuteCallback(jsonRef.current, inputRef.current, parseSpriteData);
|
|
9112
9112
|
else if (inputRef.current) loadStandaloneSprite();
|
|
9113
9113
|
const _inputRef = inputRef.current;
|
|
@@ -9119,7 +9119,7 @@ function useSpriteLoader(input, json, animationNames, numberOfFrames, onLoad, ca
|
|
|
9119
9119
|
loadStandaloneSprite,
|
|
9120
9120
|
parseSpriteData
|
|
9121
9121
|
]);
|
|
9122
|
-
React
|
|
9122
|
+
React.useLayoutEffect(() => {
|
|
9123
9123
|
onLoad?.(spriteTexture, spriteData ?? null);
|
|
9124
9124
|
}, [
|
|
9125
9125
|
spriteTexture,
|
|
@@ -9136,9 +9136,9 @@ useSpriteLoader.clear = (input) => useLoader.clear(TextureLoader, input);
|
|
|
9136
9136
|
|
|
9137
9137
|
//#endregion
|
|
9138
9138
|
//#region src/core/Helpers/SpriteAnimator/SpriteAnimator.tsx
|
|
9139
|
-
const context$4 = React
|
|
9139
|
+
const context$4 = React.createContext(null);
|
|
9140
9140
|
function useSpriteAnimator() {
|
|
9141
|
-
return React
|
|
9141
|
+
return React.useContext(context$4);
|
|
9142
9142
|
}
|
|
9143
9143
|
function isSpriteData(data) {
|
|
9144
9144
|
return data !== null && "meta" in data && "frames" in data;
|
|
@@ -9159,29 +9159,29 @@ const geometry = /* @__PURE__ */ new PlaneGeometry(1, 1);
|
|
|
9159
9159
|
* />
|
|
9160
9160
|
* ```
|
|
9161
9161
|
*/
|
|
9162
|
-
const SpriteAnimator = /* @__PURE__ */ React
|
|
9162
|
+
const SpriteAnimator = /* @__PURE__ */ React.forwardRef(({ startFrame = 0, endFrame, fps = 30, frameName = "", textureDataURL, textureImageURL, loop = false, numberOfFrames = 1, autoPlay = true, animationNames, onStart, onEnd, onLoopEnd, onFrame, play, pause = false, flipX = false, alphaTest = 0, children, asSprite = false, offset, playBackwards = false, resetOnEnd = false, maxItems = 1, instanceItems = [[
|
|
9163
9163
|
0,
|
|
9164
9164
|
0,
|
|
9165
9165
|
0
|
|
9166
9166
|
]], spriteDataset, canvasRenderingContext2DSettings, roundFramePosition = false, meshProps = {}, ...props }, fref) => {
|
|
9167
|
-
const ref = React
|
|
9168
|
-
const spriteData = React
|
|
9169
|
-
const matRef = React
|
|
9170
|
-
const spriteRef = React
|
|
9171
|
-
const timerOffset = React
|
|
9172
|
-
const currentFrame = React
|
|
9173
|
-
const currentFrameName = React
|
|
9167
|
+
const ref = React.useRef(new Group());
|
|
9168
|
+
const spriteData = React.useRef(null);
|
|
9169
|
+
const matRef = React.useRef(null);
|
|
9170
|
+
const spriteRef = React.useRef(null);
|
|
9171
|
+
const timerOffset = React.useRef(window.performance.now());
|
|
9172
|
+
const currentFrame = React.useRef(startFrame);
|
|
9173
|
+
const currentFrameName = React.useRef(frameName);
|
|
9174
9174
|
const fpsInterval = fps > 0 ? 1e3 / fps : 0;
|
|
9175
|
-
const [spriteTexture, setSpriteTexture] = React
|
|
9176
|
-
const totalFrames = React
|
|
9177
|
-
const [aspect$1, setAspect] = React
|
|
9175
|
+
const [spriteTexture, setSpriteTexture] = React.useState(new Texture$1());
|
|
9176
|
+
const totalFrames = React.useRef(0);
|
|
9177
|
+
const [aspect$1, setAspect] = React.useState(new Vector3$2(1, 1, 1));
|
|
9178
9178
|
const flipOffset = flipX ? -1 : 1;
|
|
9179
|
-
const pauseRef = React
|
|
9180
|
-
const pos = React
|
|
9181
|
-
const softEnd = React
|
|
9179
|
+
const pauseRef = React.useRef(pause);
|
|
9180
|
+
const pos = React.useRef(offset);
|
|
9181
|
+
const softEnd = React.useRef(false);
|
|
9182
9182
|
const { spriteObj, loadJsonAndTexture } = useSpriteLoader(null, null, animationNames, numberOfFrames, void 0, canvasRenderingContext2DSettings);
|
|
9183
|
-
const frameNameRef = React
|
|
9184
|
-
const parseSpriteDataLite = React
|
|
9183
|
+
const frameNameRef = React.useRef(frameName);
|
|
9184
|
+
const parseSpriteDataLite = React.useCallback((textureData, data) => {
|
|
9185
9185
|
if (data === null) {
|
|
9186
9186
|
if (numberOfFrames) {
|
|
9187
9187
|
totalFrames.current = numberOfFrames;
|
|
@@ -9200,7 +9200,7 @@ const SpriteAnimator = /* @__PURE__ */ React$1.forwardRef(({ startFrame = 0, end
|
|
|
9200
9200
|
}
|
|
9201
9201
|
setSpriteTexture(textureData);
|
|
9202
9202
|
}, [numberOfFrames, playBackwards]);
|
|
9203
|
-
const modifySpritePosition = React
|
|
9203
|
+
const modifySpritePosition = React.useCallback(() => {
|
|
9204
9204
|
if (!spriteData.current) return;
|
|
9205
9205
|
const { meta: { size: metaInfo }, frames } = spriteData.current;
|
|
9206
9206
|
const { w: frameW, h: frameH } = Array.isArray(frames) ? frames[0].sourceSize : frameName ? frames[frameName] ? frames[frameName][0].sourceSize : {
|
|
@@ -9229,15 +9229,15 @@ const SpriteAnimator = /* @__PURE__ */ React$1.forwardRef(({ startFrame = 0, end
|
|
|
9229
9229
|
frameName,
|
|
9230
9230
|
onStart
|
|
9231
9231
|
]);
|
|
9232
|
-
const state = React
|
|
9232
|
+
const state = React.useMemo(() => ({
|
|
9233
9233
|
current: pos.current,
|
|
9234
9234
|
offset: pos.current,
|
|
9235
9235
|
imageUrl: textureImageURL,
|
|
9236
9236
|
hasEnded: false,
|
|
9237
9237
|
ref: fref
|
|
9238
9238
|
}), [textureImageURL, fref]);
|
|
9239
|
-
React
|
|
9240
|
-
React
|
|
9239
|
+
React.useImperativeHandle(fref, () => ref.current, []);
|
|
9240
|
+
React.useLayoutEffect(() => {
|
|
9241
9241
|
pos.current = offset;
|
|
9242
9242
|
}, [offset]);
|
|
9243
9243
|
const calculateAspectRatio = (width, height) => {
|
|
@@ -9247,7 +9247,7 @@ const SpriteAnimator = /* @__PURE__ */ React$1.forwardRef(({ startFrame = 0, end
|
|
|
9247
9247
|
spriteRef.current?.scale.copy(ret);
|
|
9248
9248
|
return ret;
|
|
9249
9249
|
};
|
|
9250
|
-
React
|
|
9250
|
+
React.useEffect(() => {
|
|
9251
9251
|
if (spriteDataset) parseSpriteDataLite(spriteDataset?.spriteTexture?.clone(), spriteDataset.spriteData);
|
|
9252
9252
|
else if (textureImageURL && textureDataURL) loadJsonAndTexture(textureImageURL, textureDataURL);
|
|
9253
9253
|
}, [
|
|
@@ -9257,25 +9257,25 @@ const SpriteAnimator = /* @__PURE__ */ React$1.forwardRef(({ startFrame = 0, end
|
|
|
9257
9257
|
textureImageURL,
|
|
9258
9258
|
parseSpriteDataLite
|
|
9259
9259
|
]);
|
|
9260
|
-
React
|
|
9260
|
+
React.useEffect(() => {
|
|
9261
9261
|
if (spriteObj) parseSpriteDataLite(spriteObj?.spriteTexture?.clone(), spriteObj?.spriteData);
|
|
9262
9262
|
}, [spriteObj, parseSpriteDataLite]);
|
|
9263
|
-
React
|
|
9263
|
+
React.useEffect(() => {
|
|
9264
9264
|
state.hasEnded = false;
|
|
9265
9265
|
if (spriteData.current && playBackwards === true) currentFrame.current = (spriteData.current.frames.length ?? 0) - 1;
|
|
9266
9266
|
else currentFrame.current = 0;
|
|
9267
9267
|
}, [playBackwards, state]);
|
|
9268
|
-
React
|
|
9268
|
+
React.useLayoutEffect(() => {
|
|
9269
9269
|
modifySpritePosition();
|
|
9270
9270
|
}, [
|
|
9271
9271
|
spriteTexture,
|
|
9272
9272
|
flipX,
|
|
9273
9273
|
modifySpritePosition
|
|
9274
9274
|
]);
|
|
9275
|
-
React
|
|
9275
|
+
React.useEffect(() => {
|
|
9276
9276
|
if (autoPlay) pauseRef.current = false;
|
|
9277
9277
|
}, [autoPlay]);
|
|
9278
|
-
React
|
|
9278
|
+
React.useLayoutEffect(() => {
|
|
9279
9279
|
if (currentFrameName.current !== frameName && frameName) {
|
|
9280
9280
|
currentFrame.current = 0;
|
|
9281
9281
|
currentFrameName.current = frameName;
|
|
@@ -9456,15 +9456,15 @@ const SpriteAnimator = /* @__PURE__ */ React$1.forwardRef(({ startFrame = 0, end
|
|
|
9456
9456
|
* ```
|
|
9457
9457
|
*/
|
|
9458
9458
|
function useAnimations(clips, root) {
|
|
9459
|
-
const ref = React
|
|
9460
|
-
const [actualRef] = React
|
|
9461
|
-
const [mixer] = React
|
|
9462
|
-
React
|
|
9459
|
+
const ref = React.useRef(null);
|
|
9460
|
+
const [actualRef] = React.useState(() => root ? root instanceof Object3D$1 ? { current: root } : root : ref);
|
|
9461
|
+
const [mixer] = React.useState(() => new AnimationMixer(void 0));
|
|
9462
|
+
React.useLayoutEffect(() => {
|
|
9463
9463
|
if (root) actualRef.current = root instanceof Object3D$1 ? root : root.current;
|
|
9464
9464
|
mixer._root = actualRef.current;
|
|
9465
9465
|
});
|
|
9466
|
-
const lazyActions = React
|
|
9467
|
-
const api = React
|
|
9466
|
+
const lazyActions = React.useRef({});
|
|
9467
|
+
const api = React.useMemo(() => {
|
|
9468
9468
|
const actions = {};
|
|
9469
9469
|
clips.forEach((clip) => Object.defineProperty(actions, clip.name, {
|
|
9470
9470
|
enumerable: true,
|
|
@@ -9482,7 +9482,7 @@ function useAnimations(clips, root) {
|
|
|
9482
9482
|
};
|
|
9483
9483
|
}, [clips]);
|
|
9484
9484
|
useFrame((state, delta) => mixer.update(delta));
|
|
9485
|
-
React
|
|
9485
|
+
React.useEffect(() => {
|
|
9486
9486
|
const currentRoot = actualRef.current;
|
|
9487
9487
|
return () => {
|
|
9488
9488
|
lazyActions.current = {};
|
|
@@ -9515,9 +9515,9 @@ function useAnimations(clips, root) {
|
|
|
9515
9515
|
* ```
|
|
9516
9516
|
*/
|
|
9517
9517
|
function useContextBridge(...contexts) {
|
|
9518
|
-
const cRef = React
|
|
9519
|
-
cRef.current = contexts.map((context$11) => React
|
|
9520
|
-
return React
|
|
9518
|
+
const cRef = React.useRef([]);
|
|
9519
|
+
cRef.current = contexts.map((context$11) => React.useContext(context$11));
|
|
9520
|
+
return React.useMemo(() => ({ children }) => contexts.reduceRight((acc, Context$1, i$1) => /* @__PURE__ */ jsx(Context$1.Provider, {
|
|
9521
9521
|
value: cRef.current[i$1],
|
|
9522
9522
|
children: acc
|
|
9523
9523
|
}), children), []);
|
|
@@ -9563,7 +9563,7 @@ function createSpread(child, { keys = [
|
|
|
9563
9563
|
...spread,
|
|
9564
9564
|
children: inject(child)
|
|
9565
9565
|
};
|
|
9566
|
-
else if (React
|
|
9566
|
+
else if (React.isValidElement(inject)) spread = {
|
|
9567
9567
|
...spread,
|
|
9568
9568
|
children: inject
|
|
9569
9569
|
};
|
|
@@ -9606,7 +9606,7 @@ function createSpread(child, { keys = [
|
|
|
9606
9606
|
* } />
|
|
9607
9607
|
* ```
|
|
9608
9608
|
*/
|
|
9609
|
-
const Clone = /* @__PURE__ */ React
|
|
9609
|
+
const Clone = /* @__PURE__ */ React.forwardRef(({ isChild = false, object, children, deep, castShadow, receiveShadow, inject, keys, ...props }, forwardRef$1) => {
|
|
9610
9610
|
const config = {
|
|
9611
9611
|
keys,
|
|
9612
9612
|
deep,
|
|
@@ -9614,7 +9614,7 @@ const Clone = /* @__PURE__ */ React$1.forwardRef(({ isChild = false, object, chi
|
|
|
9614
9614
|
castShadow,
|
|
9615
9615
|
receiveShadow
|
|
9616
9616
|
};
|
|
9617
|
-
object = React
|
|
9617
|
+
object = React.useMemo(() => {
|
|
9618
9618
|
if (isChild === false && !Array.isArray(object)) {
|
|
9619
9619
|
let isSkinned = false;
|
|
9620
9620
|
object.traverse((object$1) => {
|
|
@@ -9676,9 +9676,9 @@ const Clone = /* @__PURE__ */ React$1.forwardRef(({ isChild = false, object, chi
|
|
|
9676
9676
|
* ```
|
|
9677
9677
|
*/
|
|
9678
9678
|
const ComputedAttribute = ({ compute, name, ...props }) => {
|
|
9679
|
-
const [bufferAttribute] = React
|
|
9680
|
-
const primitive = React
|
|
9681
|
-
React
|
|
9679
|
+
const [bufferAttribute] = React.useState(() => new BufferAttribute(new Float32Array(0), 1));
|
|
9680
|
+
const primitive = React.useRef(null);
|
|
9681
|
+
React.useLayoutEffect(() => {
|
|
9682
9682
|
if (primitive.current) {
|
|
9683
9683
|
const prim = primitive.current;
|
|
9684
9684
|
const attr = compute(prim.parent ?? prim.__r3f?.parent?.object);
|
|
@@ -9713,14 +9713,14 @@ const ComputedAttribute = ({ compute, name, ...props }) => {
|
|
|
9713
9713
|
* </Center>
|
|
9714
9714
|
* ```
|
|
9715
9715
|
*/
|
|
9716
|
-
const Center = /* @__PURE__ */ React
|
|
9717
|
-
const ref = React
|
|
9718
|
-
const outer = React
|
|
9719
|
-
const inner = React
|
|
9720
|
-
const [box3] = React
|
|
9721
|
-
const [center] = React
|
|
9722
|
-
const [sphere] = React
|
|
9723
|
-
React
|
|
9716
|
+
const Center = /* @__PURE__ */ React.forwardRef(function Center$1({ children, object, disable, disableX, disableY, disableZ, left, right, top, bottom, front, back, onCentered, precise = true, cacheKey = 0, ...props }, fRef) {
|
|
9717
|
+
const ref = React.useRef(null);
|
|
9718
|
+
const outer = React.useRef(null);
|
|
9719
|
+
const inner = React.useRef(null);
|
|
9720
|
+
const [box3] = React.useState(() => new Box3());
|
|
9721
|
+
const [center] = React.useState(() => new Vector3$2());
|
|
9722
|
+
const [sphere] = React.useState(() => new Sphere$1());
|
|
9723
|
+
React.useLayoutEffect(() => {
|
|
9724
9724
|
outer.current.matrixWorld.identity();
|
|
9725
9725
|
box3.setFromObject(object ?? inner.current, precise);
|
|
9726
9726
|
const width = box3.max.x - box3.min.x;
|
|
@@ -9764,7 +9764,7 @@ const Center = /* @__PURE__ */ React$1.forwardRef(function Center$1({ children,
|
|
|
9764
9764
|
center,
|
|
9765
9765
|
sphere
|
|
9766
9766
|
]);
|
|
9767
|
-
React
|
|
9767
|
+
React.useImperativeHandle(fRef, () => ref.current, []);
|
|
9768
9768
|
return /* @__PURE__ */ jsx("group", {
|
|
9769
9769
|
ref,
|
|
9770
9770
|
...props,
|
|
@@ -9783,18 +9783,18 @@ const Center = /* @__PURE__ */ React$1.forwardRef(function Center$1({ children,
|
|
|
9783
9783
|
/**
|
|
9784
9784
|
* A simple counter example component. Click to increment, meta-click to decrement.
|
|
9785
9785
|
*/
|
|
9786
|
-
const Example = /* @__PURE__ */ React
|
|
9787
|
-
const [counter, setCounter] = React
|
|
9788
|
-
const incr = React
|
|
9789
|
-
const decr = React
|
|
9790
|
-
const api = React
|
|
9786
|
+
const Example = /* @__PURE__ */ React.forwardRef(({ font, color = "#cbcbcb", bevelSize = .04, debug = false, children, ...props }, fref) => {
|
|
9787
|
+
const [counter, setCounter] = React.useState(0);
|
|
9788
|
+
const incr = React.useCallback((x = 1) => setCounter(counter + x), [counter]);
|
|
9789
|
+
const decr = React.useCallback((x = 1) => setCounter(counter - x), [counter]);
|
|
9790
|
+
const api = React.useMemo(() => ({
|
|
9791
9791
|
incr,
|
|
9792
9792
|
decr
|
|
9793
9793
|
}), [incr, decr]);
|
|
9794
|
-
React
|
|
9794
|
+
React.useImperativeHandle(fref, () => api, [api]);
|
|
9795
9795
|
return /* @__PURE__ */ jsxs("group", {
|
|
9796
9796
|
...props,
|
|
9797
|
-
children: [/* @__PURE__ */ jsx(React
|
|
9797
|
+
children: [/* @__PURE__ */ jsx(React.Suspense, {
|
|
9798
9798
|
fallback: null,
|
|
9799
9799
|
children: /* @__PURE__ */ jsx(Center, {
|
|
9800
9800
|
top: true,
|
|
@@ -9816,7 +9816,7 @@ const Example = /* @__PURE__ */ React$1.forwardRef(({ font, color = "#cbcbcb", b
|
|
|
9816
9816
|
//#endregion
|
|
9817
9817
|
//#region src/core/Helpers/Sampler/Sampler.tsx
|
|
9818
9818
|
function useSurfaceSampler(mesh, count = 16, transform, weight, instanceMesh) {
|
|
9819
|
-
const [buffer, setBuffer] = React
|
|
9819
|
+
const [buffer, setBuffer] = React.useState(() => {
|
|
9820
9820
|
const arr = Array.from({ length: count }, () => [
|
|
9821
9821
|
1,
|
|
9822
9822
|
0,
|
|
@@ -9837,7 +9837,7 @@ function useSurfaceSampler(mesh, count = 16, transform, weight, instanceMesh) {
|
|
|
9837
9837
|
]).flat();
|
|
9838
9838
|
return new InstancedBufferAttribute(Float32Array.from(arr), 16);
|
|
9839
9839
|
});
|
|
9840
|
-
React
|
|
9840
|
+
React.useLayoutEffect(() => {
|
|
9841
9841
|
if (typeof mesh.current === "undefined") return;
|
|
9842
9842
|
const sampler = new MeshSurfaceSampler(mesh.current);
|
|
9843
9843
|
if (weight) sampler.setWeightAttribute(weight);
|
|
@@ -9910,10 +9910,10 @@ function useSurfaceSampler(mesh, count = 16, transform, weight, instanceMesh) {
|
|
|
9910
9910
|
* ```
|
|
9911
9911
|
*/
|
|
9912
9912
|
function Sampler({ children, weight, transform, instances, mesh, count = 16, ...props }) {
|
|
9913
|
-
const group = React
|
|
9914
|
-
const instancedRef = React
|
|
9915
|
-
const meshToSampleRef = React
|
|
9916
|
-
React
|
|
9913
|
+
const group = React.useRef(null);
|
|
9914
|
+
const instancedRef = React.useRef(null);
|
|
9915
|
+
const meshToSampleRef = React.useRef(null);
|
|
9916
|
+
React.useLayoutEffect(() => {
|
|
9917
9917
|
instancedRef.current = instances?.current ?? group.current.children.find((c) => c.hasOwnProperty("instanceMatrix"));
|
|
9918
9918
|
meshToSampleRef.current = mesh?.current ?? group.current.children.find((c) => c.type === "Mesh");
|
|
9919
9919
|
}, [
|
|
@@ -9991,7 +9991,7 @@ function useDepthBuffer({ size = 256, frames = Infinity } = {}) {
|
|
|
9991
9991
|
const { width, height } = useThree((state) => state.size);
|
|
9992
9992
|
const w = size || width * dpr;
|
|
9993
9993
|
const h = size || height * dpr;
|
|
9994
|
-
const depthConfig = React
|
|
9994
|
+
const depthConfig = React.useMemo(() => {
|
|
9995
9995
|
const depthTexture = new DepthTexture(w, h);
|
|
9996
9996
|
depthTexture.format = DepthFormat;
|
|
9997
9997
|
depthTexture.type = UnsignedShortType;
|
|
@@ -10097,23 +10097,23 @@ const defaultDataInterpolation = (p) => `Loading ${p.toFixed(2)}%`;
|
|
|
10097
10097
|
*/
|
|
10098
10098
|
function Loader({ containerStyles, innerStyles, barStyles, dataStyles, dataInterpolation = defaultDataInterpolation, initialState = (active$1) => active$1 }) {
|
|
10099
10099
|
const { active, progress } = useProgress();
|
|
10100
|
-
const progressRef = React
|
|
10101
|
-
const rafRef = React
|
|
10102
|
-
const progressSpanRef = React
|
|
10103
|
-
const [shown, setShown] = React
|
|
10104
|
-
React
|
|
10100
|
+
const progressRef = React.useRef(0);
|
|
10101
|
+
const rafRef = React.useRef(0);
|
|
10102
|
+
const progressSpanRef = React.useRef(null);
|
|
10103
|
+
const [shown, setShown] = React.useState(initialState(active));
|
|
10104
|
+
React.useEffect(() => {
|
|
10105
10105
|
let t;
|
|
10106
10106
|
if (active !== shown) t = setTimeout(() => setShown(active), 300);
|
|
10107
10107
|
return () => clearTimeout(t);
|
|
10108
10108
|
}, [shown, active]);
|
|
10109
|
-
const updateProgress = React
|
|
10109
|
+
const updateProgress = React.useCallback(() => {
|
|
10110
10110
|
if (!progressSpanRef.current) return;
|
|
10111
10111
|
progressRef.current += (progress - progressRef.current) / 2;
|
|
10112
10112
|
if (progressRef.current > .95 * progress || progress === 100) progressRef.current = progress;
|
|
10113
10113
|
progressSpanRef.current.innerText = dataInterpolation(progressRef.current);
|
|
10114
10114
|
if (progressRef.current < progress) rafRef.current = requestAnimationFrame(updateProgress);
|
|
10115
10115
|
}, [dataInterpolation, progress]);
|
|
10116
|
-
React
|
|
10116
|
+
React.useEffect(() => {
|
|
10117
10117
|
updateProgress();
|
|
10118
10118
|
return () => cancelAnimationFrame(rafRef.current);
|
|
10119
10119
|
}, [updateProgress]);
|
|
@@ -10199,7 +10199,7 @@ function Preload({ all, scene, camera }) {
|
|
|
10199
10199
|
const gl = useThree(({ gl: gl$1 }) => gl$1);
|
|
10200
10200
|
const dCamera = useThree(({ camera: camera$1 }) => camera$1);
|
|
10201
10201
|
const dScene = useThree(({ scene: scene$1 }) => scene$1);
|
|
10202
|
-
React
|
|
10202
|
+
React.useLayoutEffect(() => {
|
|
10203
10203
|
const invisible = [];
|
|
10204
10204
|
if (all) (scene || dScene).traverse((object) => {
|
|
10205
10205
|
if (object.visible === false) {
|
|
@@ -10568,7 +10568,7 @@ useGLTF.setDecoderPath = (path) => {
|
|
|
10568
10568
|
* <Gltf src="/model.glb" />
|
|
10569
10569
|
* ```
|
|
10570
10570
|
*/
|
|
10571
|
-
const Gltf = /* @__PURE__ */ React
|
|
10571
|
+
const Gltf = /* @__PURE__ */ React.forwardRef(({ src, useDraco, useMeshOpt, extendLoader, ...props }, ref) => {
|
|
10572
10572
|
const { scene } = useGLTF(src, useDraco, useMeshOpt, extendLoader);
|
|
10573
10573
|
return /* @__PURE__ */ jsx(Clone, {
|
|
10574
10574
|
ref,
|
|
@@ -10673,14 +10673,14 @@ function AdaptiveDpr({ pixelated }) {
|
|
|
10673
10673
|
const current = useThree((state) => state.performance.current);
|
|
10674
10674
|
const initialDpr = useThree((state) => state.viewport.initialDpr);
|
|
10675
10675
|
const setDpr = useThree((state) => state.setDpr);
|
|
10676
|
-
React
|
|
10676
|
+
React.useEffect(() => {
|
|
10677
10677
|
const domElement = gl.domElement;
|
|
10678
10678
|
return () => {
|
|
10679
10679
|
if (active) setDpr(initialDpr);
|
|
10680
10680
|
if (pixelated && domElement) domElement.style.imageRendering = "auto";
|
|
10681
10681
|
};
|
|
10682
10682
|
}, []);
|
|
10683
|
-
React
|
|
10683
|
+
React.useEffect(() => {
|
|
10684
10684
|
setDpr(current * initialDpr);
|
|
10685
10685
|
if (pixelated && gl.domElement) gl.domElement.style.imageRendering = current === 1 ? "auto" : "pixelated";
|
|
10686
10686
|
}, [current]);
|
|
@@ -10702,11 +10702,11 @@ function AdaptiveEvents() {
|
|
|
10702
10702
|
const get = useThree((state) => state.get);
|
|
10703
10703
|
const setEvents = useThree((state) => state.setEvents);
|
|
10704
10704
|
const current = useThree((state) => state.performance.current);
|
|
10705
|
-
React
|
|
10705
|
+
React.useEffect(() => {
|
|
10706
10706
|
const enabled = get().events.enabled;
|
|
10707
10707
|
return () => setEvents({ enabled });
|
|
10708
10708
|
}, []);
|
|
10709
|
-
React
|
|
10709
|
+
React.useEffect(() => setEvents({ enabled: current === 1 }), [current]);
|
|
10710
10710
|
return null;
|
|
10711
10711
|
}
|
|
10712
10712
|
|
|
@@ -10882,8 +10882,8 @@ function call(ref, value) {
|
|
|
10882
10882
|
else if (ref != null) ref.current = value;
|
|
10883
10883
|
}
|
|
10884
10884
|
function useEffectfulState(fn, deps = [], cb) {
|
|
10885
|
-
const [state, set] = React
|
|
10886
|
-
React
|
|
10885
|
+
const [state, set] = React.useState();
|
|
10886
|
+
React.useLayoutEffect(() => {
|
|
10887
10887
|
const value = fn();
|
|
10888
10888
|
set(value);
|
|
10889
10889
|
call(cb, value);
|
|
@@ -10905,7 +10905,7 @@ var import_stats_min = /* @__PURE__ */ __toESM(require_stats_min());
|
|
|
10905
10905
|
*/
|
|
10906
10906
|
function Stats({ showPanel = 0, className, parent }) {
|
|
10907
10907
|
const stats = useEffectfulState(() => new import_stats_min.default(), []);
|
|
10908
|
-
React
|
|
10908
|
+
React.useEffect(() => {
|
|
10909
10909
|
if (stats) {
|
|
10910
10910
|
const node = parent && parent.current || document.body;
|
|
10911
10911
|
stats.showPanel(showPanel);
|
|
@@ -10940,13 +10940,13 @@ function Stats({ showPanel = 0, className, parent }) {
|
|
|
10940
10940
|
* <Canvas><StatsGl /></Canvas>
|
|
10941
10941
|
* ```
|
|
10942
10942
|
*/
|
|
10943
|
-
const StatsGl = /* @__PURE__ */ React
|
|
10943
|
+
const StatsGl = /* @__PURE__ */ React.forwardRef(function StatsGl$1({ className, parent, id, clearStatsGlStyle, ...props }, fref) {
|
|
10944
10944
|
const { renderer } = useThree();
|
|
10945
|
-
const stats = React
|
|
10945
|
+
const stats = React.useMemo(() => {
|
|
10946
10946
|
return new Stats$1({ ...props });
|
|
10947
10947
|
}, [renderer]);
|
|
10948
|
-
React
|
|
10949
|
-
React
|
|
10948
|
+
React.useImperativeHandle(fref, () => stats.domElement, [stats]);
|
|
10949
|
+
React.useEffect(() => {
|
|
10950
10950
|
if (stats) {
|
|
10951
10951
|
const node = parent && parent.current || document.body;
|
|
10952
10952
|
node?.appendChild(stats.domElement);
|
|
@@ -11004,11 +11004,11 @@ const StatsGl = /* @__PURE__ */ React$1.forwardRef(function StatsGl$1({ classNam
|
|
|
11004
11004
|
* ```
|
|
11005
11005
|
*/
|
|
11006
11006
|
function Fisheye({ renderPriority = 1, zoom = 0, segments = 64, children, resolution = 896, ...props }) {
|
|
11007
|
-
const sphere = React
|
|
11008
|
-
const cubeApi = React
|
|
11007
|
+
const sphere = React.useRef(null);
|
|
11008
|
+
const cubeApi = React.useRef(null);
|
|
11009
11009
|
const { width, height } = useThree((state) => state.size);
|
|
11010
|
-
const [orthoC] = React
|
|
11011
|
-
React
|
|
11010
|
+
const [orthoC] = React.useState(() => new OrthographicCamera$1());
|
|
11011
|
+
React.useLayoutEffect(() => {
|
|
11012
11012
|
orthoC.position.set(0, 0, 100);
|
|
11013
11013
|
orthoC.zoom = 100;
|
|
11014
11014
|
orthoC.left = width / -2;
|
|
@@ -11021,7 +11021,7 @@ function Fisheye({ renderPriority = 1, zoom = 0, segments = 64, children, resolu
|
|
|
11021
11021
|
const normal = new Vector3$2();
|
|
11022
11022
|
const sph = new Sphere$1(new Vector3$2(), radius);
|
|
11023
11023
|
const normalMatrix = new Matrix3();
|
|
11024
|
-
const compute = React
|
|
11024
|
+
const compute = React.useCallback((event, state, prev) => {
|
|
11025
11025
|
state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
|
|
11026
11026
|
state.raycaster.setFromCamera(state.pointer, orthoC);
|
|
11027
11027
|
if (!state.raycaster.ray.intersectSphere(sph, normal)) return;
|
|
@@ -11092,13 +11092,13 @@ function UpdateCubeCamera({ api }) {
|
|
|
11092
11092
|
* <Mask id={1} position={[1, 0, 0]}><circleGeometry /></Mask>
|
|
11093
11093
|
* ```
|
|
11094
11094
|
*/
|
|
11095
|
-
const Mask = /* @__PURE__ */ React
|
|
11096
|
-
const ref = React
|
|
11095
|
+
const Mask = /* @__PURE__ */ React.forwardRef(({ id = 1, colorWrite = false, depthWrite = false, children, ...props }, fref) => {
|
|
11096
|
+
const ref = React.useRef(null);
|
|
11097
11097
|
const renderer = useThree((state) => state.renderer);
|
|
11098
|
-
const stencilReady = React
|
|
11099
|
-
const [ready, setReady] = React
|
|
11100
|
-
React
|
|
11101
|
-
React
|
|
11098
|
+
const stencilReady = React.useRef(false);
|
|
11099
|
+
const [ready, setReady] = React.useState(false);
|
|
11100
|
+
React.useImperativeHandle(fref, () => ref.current, []);
|
|
11101
|
+
React.useLayoutEffect(() => {
|
|
11102
11102
|
if (stencilReady.current) return;
|
|
11103
11103
|
if ("backend" in renderer) {
|
|
11104
11104
|
renderer.stencil = true;
|
|
@@ -11175,7 +11175,7 @@ function useMask(id, inverse = false) {
|
|
|
11175
11175
|
*/
|
|
11176
11176
|
function useCustomRaycast(camera, props) {
|
|
11177
11177
|
const pointer = useThree((state) => state.pointer);
|
|
11178
|
-
const [raycast] = React
|
|
11178
|
+
const [raycast] = React.useState(() => {
|
|
11179
11179
|
const raycaster = new Raycaster();
|
|
11180
11180
|
if (props) applyProps(raycaster, props);
|
|
11181
11181
|
return function(_, intersects) {
|
|
@@ -11244,9 +11244,9 @@ function clear(renderer) {
|
|
|
11244
11244
|
}
|
|
11245
11245
|
function Container({ visible = true, canvasSize, scene, index, children, frames, rect, track }) {
|
|
11246
11246
|
const { scene: portalScene, camera: portalCamera, renderer, get, setEvents } = useThree();
|
|
11247
|
-
const [isOffscreen, setOffscreen] = React
|
|
11248
|
-
const mountedRef = React
|
|
11249
|
-
React
|
|
11247
|
+
const [isOffscreen, setOffscreen] = React.useState(false);
|
|
11248
|
+
const mountedRef = React.useRef(true);
|
|
11249
|
+
React.useEffect(() => {
|
|
11250
11250
|
mountedRef.current = true;
|
|
11251
11251
|
return () => {
|
|
11252
11252
|
mountedRef.current = false;
|
|
@@ -11278,7 +11278,7 @@ function Container({ visible = true, canvasSize, scene, index, children, frames,
|
|
|
11278
11278
|
after: "render",
|
|
11279
11279
|
priority: index
|
|
11280
11280
|
});
|
|
11281
|
-
React
|
|
11281
|
+
React.useLayoutEffect(() => {
|
|
11282
11282
|
const curRect = rect.current;
|
|
11283
11283
|
if (curRect && (!visible || !isOffscreen)) {
|
|
11284
11284
|
const { position: position$1, isOffscreen: _isOffscreen } = computeContainerPosition(canvasSize, curRect);
|
|
@@ -11295,7 +11295,7 @@ function Container({ visible = true, canvasSize, scene, index, children, frames,
|
|
|
11295
11295
|
portalCamera,
|
|
11296
11296
|
canvasSize
|
|
11297
11297
|
]);
|
|
11298
|
-
React
|
|
11298
|
+
React.useEffect(() => {
|
|
11299
11299
|
if (!track) return;
|
|
11300
11300
|
const curRect = rect.current;
|
|
11301
11301
|
const old = get().events.connected;
|
|
@@ -11321,12 +11321,12 @@ function Container({ visible = true, canvasSize, scene, index, children, frames,
|
|
|
11321
11321
|
]);
|
|
11322
11322
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [children, /* @__PURE__ */ jsx("group", { onPointerOver: () => null })] });
|
|
11323
11323
|
}
|
|
11324
|
-
const CanvasView = /* @__PURE__ */ React
|
|
11325
|
-
const rect = React
|
|
11324
|
+
const CanvasView = /* @__PURE__ */ React.forwardRef(({ track, visible = true, index = 1, id, style, className, frames = Infinity, children, ...props }, fref) => {
|
|
11325
|
+
const rect = React.useRef(null);
|
|
11326
11326
|
const { size, scene } = useThree();
|
|
11327
|
-
const [virtualScene] = React
|
|
11328
|
-
const [ready, toggle] = React
|
|
11329
|
-
const compute = React
|
|
11327
|
+
const [virtualScene] = React.useState(() => new Scene());
|
|
11328
|
+
const [ready, toggle] = React.useReducer(() => true, false);
|
|
11329
|
+
const compute = React.useCallback((event, state) => {
|
|
11330
11330
|
if (rect.current && track && track.current && event.target === track.current) {
|
|
11331
11331
|
const { width, height, left, top } = rect.current;
|
|
11332
11332
|
const x = event.clientX - left;
|
|
@@ -11335,7 +11335,7 @@ const CanvasView = /* @__PURE__ */ React$1.forwardRef(({ track, visible = true,
|
|
|
11335
11335
|
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
11336
11336
|
}
|
|
11337
11337
|
}, [rect, track]);
|
|
11338
|
-
React
|
|
11338
|
+
React.useEffect(() => {
|
|
11339
11339
|
if (track) rect.current = track.current?.getBoundingClientRect();
|
|
11340
11340
|
toggle();
|
|
11341
11341
|
}, [track]);
|
|
@@ -11365,10 +11365,10 @@ const CanvasView = /* @__PURE__ */ React$1.forwardRef(({ track, visible = true,
|
|
|
11365
11365
|
})
|
|
11366
11366
|
});
|
|
11367
11367
|
});
|
|
11368
|
-
const HtmlView = /* @__PURE__ */ React
|
|
11369
|
-
const uuid = React
|
|
11370
|
-
const ref = React
|
|
11371
|
-
React
|
|
11368
|
+
const HtmlView = /* @__PURE__ */ React.forwardRef(({ as: El = "div", id, visible, className, style, index = 1, track, frames = Infinity, children, ...props }, fref) => {
|
|
11369
|
+
const uuid = React.useId();
|
|
11370
|
+
const ref = React.useRef(null);
|
|
11371
|
+
React.useImperativeHandle(fref, () => ref.current);
|
|
11372
11372
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(El, {
|
|
11373
11373
|
ref,
|
|
11374
11374
|
id,
|
|
@@ -11404,8 +11404,8 @@ const HtmlView = /* @__PURE__ */ React$1.forwardRef(({ as: El = "div", id, visib
|
|
|
11404
11404
|
* ```
|
|
11405
11405
|
*/
|
|
11406
11406
|
const View = /* @__PURE__ */ (() => {
|
|
11407
|
-
const _View = React
|
|
11408
|
-
if (!React
|
|
11407
|
+
const _View = React.forwardRef((props, fref) => {
|
|
11408
|
+
if (!React.useContext(context)) return /* @__PURE__ */ jsx(HtmlView, {
|
|
11409
11409
|
ref: fref,
|
|
11410
11410
|
...props
|
|
11411
11411
|
});
|
|
@@ -11432,8 +11432,8 @@ const easeInExpo = (x) => x === 0 ? 0 : Math.pow(2, 10 * x - 10);
|
|
|
11432
11432
|
* ```
|
|
11433
11433
|
*/
|
|
11434
11434
|
function Backdrop({ children, floor = .25, segments = 20, receiveShadow, ...props }) {
|
|
11435
|
-
const ref = React
|
|
11436
|
-
React
|
|
11435
|
+
const ref = React.useRef(null);
|
|
11436
|
+
React.useLayoutEffect(() => {
|
|
11437
11437
|
let i$1 = 0;
|
|
11438
11438
|
const offset = segments / segments / 2;
|
|
11439
11439
|
const position$1 = ref.current.attributes.position;
|
|
@@ -11481,9 +11481,9 @@ const boundingBoxSize = /* @__PURE__ */ new Vector3$2();
|
|
|
11481
11481
|
* ```
|
|
11482
11482
|
*/
|
|
11483
11483
|
const BBAnchor = ({ anchor, ...props }) => {
|
|
11484
|
-
const ref = React
|
|
11485
|
-
const parentRef = React
|
|
11486
|
-
React
|
|
11484
|
+
const ref = React.useRef(null);
|
|
11485
|
+
const parentRef = React.useRef(null);
|
|
11486
|
+
React.useEffect(() => {
|
|
11487
11487
|
if (ref.current?.parent?.parent) {
|
|
11488
11488
|
parentRef.current = ref.current.parent;
|
|
11489
11489
|
ref.current.parent.parent.add(ref.current);
|
|
@@ -11515,7 +11515,7 @@ const isBox3 = (def) => def && def.isBox3;
|
|
|
11515
11515
|
const interpolateFuncDefault = (t) => {
|
|
11516
11516
|
return 1 - Math.exp(-5 * t) + .007 * t;
|
|
11517
11517
|
};
|
|
11518
|
-
const context$2 = React
|
|
11518
|
+
const context$2 = React.createContext(null);
|
|
11519
11519
|
/**
|
|
11520
11520
|
* Calculates and provides the bounding box of children.
|
|
11521
11521
|
* Useful for camera framing and object positioning.
|
|
@@ -11528,27 +11528,27 @@ const context$2 = React$1.createContext(null);
|
|
|
11528
11528
|
* ```
|
|
11529
11529
|
*/
|
|
11530
11530
|
function Bounds({ children, maxDuration = 1, margin = 1.2, observe, fit, clip, interpolateFunc = interpolateFuncDefault, onFit }) {
|
|
11531
|
-
const ref = React
|
|
11531
|
+
const ref = React.useRef(null);
|
|
11532
11532
|
const { camera, size, invalidate } = useThree();
|
|
11533
11533
|
const controls = useThree((state) => state.controls);
|
|
11534
|
-
const onFitRef = React
|
|
11534
|
+
const onFitRef = React.useRef(onFit);
|
|
11535
11535
|
onFitRef.current = onFit;
|
|
11536
|
-
const origin = React
|
|
11536
|
+
const origin = React.useRef({
|
|
11537
11537
|
camPos: new Vector3$2(),
|
|
11538
11538
|
camRot: new Quaternion(),
|
|
11539
11539
|
camZoom: 1
|
|
11540
11540
|
});
|
|
11541
|
-
const goal = React
|
|
11541
|
+
const goal = React.useRef({
|
|
11542
11542
|
camPos: void 0,
|
|
11543
11543
|
camRot: void 0,
|
|
11544
11544
|
camZoom: void 0,
|
|
11545
11545
|
camUp: void 0,
|
|
11546
11546
|
target: void 0
|
|
11547
11547
|
});
|
|
11548
|
-
const animationState = React
|
|
11549
|
-
const t = React
|
|
11550
|
-
const [box] = React
|
|
11551
|
-
const api = React
|
|
11548
|
+
const animationState = React.useRef(AnimationState.NONE);
|
|
11549
|
+
const t = React.useRef(0);
|
|
11550
|
+
const [box] = React.useState(() => new Box3());
|
|
11551
|
+
const api = React.useMemo(() => {
|
|
11552
11552
|
function getSize() {
|
|
11553
11553
|
const boxSize = box.getSize(new Vector3$2());
|
|
11554
11554
|
const center = box.getCenter(new Vector3$2());
|
|
@@ -11670,7 +11670,7 @@ function Bounds({ children, maxDuration = 1, margin = 1.2, observe, fit, clip, i
|
|
|
11670
11670
|
margin,
|
|
11671
11671
|
invalidate
|
|
11672
11672
|
]);
|
|
11673
|
-
React
|
|
11673
|
+
React.useLayoutEffect(() => {
|
|
11674
11674
|
if (controls) {
|
|
11675
11675
|
const callback = () => {
|
|
11676
11676
|
if (controls && goal.current.target && animationState.current !== AnimationState.NONE) {
|
|
@@ -11687,8 +11687,8 @@ function Bounds({ children, maxDuration = 1, margin = 1.2, observe, fit, clip, i
|
|
|
11687
11687
|
return () => controls.removeEventListener("start", callback);
|
|
11688
11688
|
}
|
|
11689
11689
|
}, [controls]);
|
|
11690
|
-
const count = React
|
|
11691
|
-
React
|
|
11690
|
+
const count = React.useRef(0);
|
|
11691
|
+
React.useLayoutEffect(() => {
|
|
11692
11692
|
if (observe || count.current++ === 0) {
|
|
11693
11693
|
api.refresh();
|
|
11694
11694
|
if (fit) api.reset().fit();
|
|
@@ -11741,7 +11741,7 @@ function Bounds({ children, maxDuration = 1, margin = 1.2, observe, fit, clip, i
|
|
|
11741
11741
|
});
|
|
11742
11742
|
}
|
|
11743
11743
|
function useBounds() {
|
|
11744
|
-
return React
|
|
11744
|
+
return React.useContext(context$2);
|
|
11745
11745
|
}
|
|
11746
11746
|
|
|
11747
11747
|
//#endregion
|
|
@@ -11950,7 +11950,7 @@ function setEnvProps(background, scene, defaultScene, texture$1, sceneProps = {}
|
|
|
11950
11950
|
*/
|
|
11951
11951
|
function EnvironmentMap({ scene, background = false, map, ...config }) {
|
|
11952
11952
|
const defaultScene = useThree((state) => state.scene);
|
|
11953
|
-
React
|
|
11953
|
+
React.useLayoutEffect(() => {
|
|
11954
11954
|
if (map) return setEnvProps(background, scene, defaultScene, map, config);
|
|
11955
11955
|
});
|
|
11956
11956
|
return null;
|
|
@@ -11983,7 +11983,7 @@ function EnvironmentMap({ scene, background = false, map, ...config }) {
|
|
|
11983
11983
|
function EnvironmentCube({ background = false, scene, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, ...rest }) {
|
|
11984
11984
|
const texture$1 = useEnvironment(rest);
|
|
11985
11985
|
const defaultScene = useThree((state) => state.scene);
|
|
11986
|
-
React
|
|
11986
|
+
React.useLayoutEffect(() => {
|
|
11987
11987
|
return setEnvProps(background, scene, defaultScene, texture$1, {
|
|
11988
11988
|
backgroundBlurriness: blur ?? backgroundBlurriness,
|
|
11989
11989
|
backgroundIntensity,
|
|
@@ -11992,7 +11992,7 @@ function EnvironmentCube({ background = false, scene, blur, backgroundBlurriness
|
|
|
11992
11992
|
environmentRotation
|
|
11993
11993
|
});
|
|
11994
11994
|
});
|
|
11995
|
-
React
|
|
11995
|
+
React.useEffect(() => {
|
|
11996
11996
|
return () => {
|
|
11997
11997
|
texture$1.dispose();
|
|
11998
11998
|
};
|
|
@@ -12033,19 +12033,19 @@ function EnvironmentCube({ background = false, scene, blur, backgroundBlurriness
|
|
|
12033
12033
|
function EnvironmentPortal({ children, near = .1, far = 1e3, resolution = 256, frames = 1, map, background = false, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, scene, files, path, preset = void 0, extensions: extensions$1 }) {
|
|
12034
12034
|
const gl = useThree((state) => state.gl);
|
|
12035
12035
|
const defaultScene = useThree((state) => state.scene);
|
|
12036
|
-
const camera = React
|
|
12037
|
-
const [virtualScene] = React
|
|
12038
|
-
const fbo = React
|
|
12036
|
+
const camera = React.useRef(null);
|
|
12037
|
+
const [virtualScene] = React.useState(() => new Scene());
|
|
12038
|
+
const fbo = React.useMemo(() => {
|
|
12039
12039
|
const fbo$1 = new WebGLCubeRenderTarget(resolution);
|
|
12040
12040
|
fbo$1.texture.type = HalfFloatType;
|
|
12041
12041
|
return fbo$1;
|
|
12042
12042
|
}, [resolution]);
|
|
12043
|
-
React
|
|
12043
|
+
React.useEffect(() => {
|
|
12044
12044
|
return () => {
|
|
12045
12045
|
fbo.dispose();
|
|
12046
12046
|
};
|
|
12047
12047
|
}, [fbo]);
|
|
12048
|
-
React
|
|
12048
|
+
React.useLayoutEffect(() => {
|
|
12049
12049
|
if (frames === 1) {
|
|
12050
12050
|
const autoClear = gl.autoClear;
|
|
12051
12051
|
gl.autoClear = true;
|
|
@@ -12126,8 +12126,8 @@ function EnvironmentPortal({ children, near = .1, far = 1e3, resolution = 256, f
|
|
|
12126
12126
|
function EnvironmentGround(props) {
|
|
12127
12127
|
const textureDefault = useEnvironment(props);
|
|
12128
12128
|
const texture$1 = props.map || textureDefault;
|
|
12129
|
-
React
|
|
12130
|
-
React
|
|
12129
|
+
React.useMemo(() => extend({ GroundProjectedEnvImpl: GroundedSkybox }), []);
|
|
12130
|
+
React.useEffect(() => {
|
|
12131
12131
|
return () => {
|
|
12132
12132
|
textureDefault.dispose();
|
|
12133
12133
|
};
|
|
@@ -12135,7 +12135,7 @@ function EnvironmentGround(props) {
|
|
|
12135
12135
|
const height = props.ground?.height ?? 15;
|
|
12136
12136
|
const radius = props.ground?.radius ?? 60;
|
|
12137
12137
|
const scale$2 = props.ground?.scale ?? 1e3;
|
|
12138
|
-
const args = React
|
|
12138
|
+
const args = React.useMemo(() => [
|
|
12139
12139
|
texture$1,
|
|
12140
12140
|
height,
|
|
12141
12141
|
radius
|
|
@@ -12263,10 +12263,10 @@ function Environment(props) {
|
|
|
12263
12263
|
* </Float>
|
|
12264
12264
|
* ```
|
|
12265
12265
|
*/
|
|
12266
|
-
const Float = /* @__PURE__ */ React
|
|
12267
|
-
const ref = React
|
|
12268
|
-
React
|
|
12269
|
-
const offset = React
|
|
12266
|
+
const Float = /* @__PURE__ */ React.forwardRef(({ children, enabled = true, speed = 1, rotationIntensity = 1, floatIntensity = 1, floatingRange = [-.1, .1], autoInvalidate = false, ...props }, forwardRef$1) => {
|
|
12267
|
+
const ref = React.useRef(null);
|
|
12268
|
+
React.useImperativeHandle(forwardRef$1, () => ref.current, []);
|
|
12269
|
+
const offset = React.useRef(Math.random() * 1e4);
|
|
12270
12270
|
useFrame((state) => {
|
|
12271
12271
|
if (!enabled || speed === 0) return;
|
|
12272
12272
|
if (autoInvalidate) state.invalidate();
|
|
@@ -12300,14 +12300,14 @@ const Float = /* @__PURE__ */ React$1.forwardRef(({ children, enabled = true, sp
|
|
|
12300
12300
|
* <Lightformer form="circle" intensity={2} position={[0, 5, -2]} />
|
|
12301
12301
|
* ```
|
|
12302
12302
|
*/
|
|
12303
|
-
const Lightformer = /* @__PURE__ */ React
|
|
12303
|
+
const Lightformer = /* @__PURE__ */ React.forwardRef(({ light, args, map, toneMapped = false, color = "white", form: Form = "rect", intensity = 1, scale: scale$2 = 1, target: target$1 = [
|
|
12304
12304
|
0,
|
|
12305
12305
|
0,
|
|
12306
12306
|
0
|
|
12307
12307
|
], children, ...props }, forwardRef$1) => {
|
|
12308
|
-
const ref = React
|
|
12309
|
-
React
|
|
12310
|
-
React
|
|
12308
|
+
const ref = React.useRef(null);
|
|
12309
|
+
React.useImperativeHandle(forwardRef$1, () => ref.current, []);
|
|
12310
|
+
React.useLayoutEffect(() => {
|
|
12311
12311
|
if (!children && !props.material) {
|
|
12312
12312
|
applyProps(ref.current.material, { color });
|
|
12313
12313
|
ref.current.material.color.multiplyScalar(intensity);
|
|
@@ -12318,7 +12318,7 @@ const Lightformer = /* @__PURE__ */ React$1.forwardRef(({ light, args, map, tone
|
|
|
12318
12318
|
children,
|
|
12319
12319
|
props.material
|
|
12320
12320
|
]);
|
|
12321
|
-
React
|
|
12321
|
+
React.useLayoutEffect(() => {
|
|
12322
12322
|
if (!props.rotation) ref.current.quaternion.identity();
|
|
12323
12323
|
if (target$1 && !props.rotation) "boolean" === typeof target$1 ? ref.current.lookAt(0, 0, 0) : ref.current.lookAt(Array.isArray(target$1) ? new Vector3$2(...target$1) : target$1);
|
|
12324
12324
|
}, [target$1, props.rotation]);
|
|
@@ -12370,11 +12370,11 @@ const Lightformer = /* @__PURE__ */ React$1.forwardRef(({ light, args, map, tone
|
|
|
12370
12370
|
* </Resize>
|
|
12371
12371
|
* ```
|
|
12372
12372
|
*/
|
|
12373
|
-
const Resize = /* @__PURE__ */ React
|
|
12374
|
-
const ref = React
|
|
12375
|
-
const outer = React
|
|
12376
|
-
const inner = React
|
|
12377
|
-
React
|
|
12373
|
+
const Resize = /* @__PURE__ */ React.forwardRef(({ children, width, height, depth, box3, precise = true, ...props }, fRef) => {
|
|
12374
|
+
const ref = React.useRef(null);
|
|
12375
|
+
const outer = React.useRef(null);
|
|
12376
|
+
const inner = React.useRef(null);
|
|
12377
|
+
React.useLayoutEffect(() => {
|
|
12378
12378
|
outer.current.matrixWorld.identity();
|
|
12379
12379
|
let box = box3 || new Box3().setFromObject(inner.current, precise);
|
|
12380
12380
|
const w = box.max.x - box.min.x;
|
|
@@ -12392,7 +12392,7 @@ const Resize = /* @__PURE__ */ React$1.forwardRef(({ children, width, height, de
|
|
|
12392
12392
|
box3,
|
|
12393
12393
|
precise
|
|
12394
12394
|
]);
|
|
12395
|
-
React
|
|
12395
|
+
React.useImperativeHandle(fRef, () => ref.current, []);
|
|
12396
12396
|
return /* @__PURE__ */ jsx("group", {
|
|
12397
12397
|
ref,
|
|
12398
12398
|
...props,
|
|
@@ -12421,7 +12421,7 @@ const worldPos = /* @__PURE__ */ new Vector3$2();
|
|
|
12421
12421
|
*/
|
|
12422
12422
|
const ScreenSizer = /* @__PURE__ */ forwardRef(({ scale: scale$2 = 1, ...props }, ref) => {
|
|
12423
12423
|
const container = useRef(null);
|
|
12424
|
-
React
|
|
12424
|
+
React.useImperativeHandle(ref, () => container.current, []);
|
|
12425
12425
|
useFrame((state) => {
|
|
12426
12426
|
const obj = container.current;
|
|
12427
12427
|
if (!obj) return;
|
|
@@ -12444,8 +12444,8 @@ const ScreenSizer = /* @__PURE__ */ forwardRef(({ scale: scale$2 = 1, ...props }
|
|
|
12444
12444
|
* <Shadow color="black" opacity={0.5} position={[0, 0, 0]} />
|
|
12445
12445
|
* ```
|
|
12446
12446
|
*/
|
|
12447
|
-
const Shadow = /* @__PURE__ */ React
|
|
12448
|
-
const canvas = React
|
|
12447
|
+
const Shadow = /* @__PURE__ */ React.forwardRef(({ fog = false, renderOrder, depthWrite = false, colorStop = 0, color = "black", opacity = .5, ...props }, ref) => {
|
|
12448
|
+
const canvas = React.useMemo(() => {
|
|
12449
12449
|
const canvas$1 = document.createElement("canvas");
|
|
12450
12450
|
canvas$1.width = 128;
|
|
12451
12451
|
canvas$1.height = 128;
|
|
@@ -12500,9 +12500,9 @@ function toVector3(value) {
|
|
|
12500
12500
|
* <Sky sunPosition={[0, 1, 0]} />
|
|
12501
12501
|
* ```
|
|
12502
12502
|
*/
|
|
12503
|
-
const Sky = /* @__PURE__ */ React
|
|
12503
|
+
const Sky = /* @__PURE__ */ React.forwardRef(({ inclination = .6, azimuth = .1, distance: distance$1 = 1e3, mieCoefficient = .005, mieDirectionalG = .8, rayleigh = .5, turbidity = 10, sunPosition = calcPosFromAngles(inclination, azimuth), ...props }, ref) => {
|
|
12504
12504
|
const { isLegacy } = useThree();
|
|
12505
|
-
const sky = React
|
|
12505
|
+
const sky = React.useMemo(() => {
|
|
12506
12506
|
if (isLegacy) {
|
|
12507
12507
|
const skyInstance = new Sky$1();
|
|
12508
12508
|
skyInstance.scale.setScalar(distance$1);
|
|
@@ -12513,10 +12513,10 @@ const Sky = /* @__PURE__ */ React$1.forwardRef(({ inclination = .6, azimuth = .1
|
|
|
12513
12513
|
return skyInstance;
|
|
12514
12514
|
}
|
|
12515
12515
|
}, [isLegacy, distance$1]);
|
|
12516
|
-
React
|
|
12516
|
+
React.useLayoutEffect(() => {
|
|
12517
12517
|
sky.scale.setScalar(distance$1);
|
|
12518
12518
|
}, [sky, distance$1]);
|
|
12519
|
-
React
|
|
12519
|
+
React.useLayoutEffect(() => {
|
|
12520
12520
|
if (!sky) return;
|
|
12521
12521
|
if (isLegacy) applyProps(sky.material, {
|
|
12522
12522
|
mieCoefficient,
|
|
@@ -12614,7 +12614,7 @@ const presets = {
|
|
|
12614
12614
|
};
|
|
12615
12615
|
function Refit({ radius, adjustCamera }) {
|
|
12616
12616
|
const api = useBounds();
|
|
12617
|
-
React
|
|
12617
|
+
React.useEffect(() => {
|
|
12618
12618
|
if (adjustCamera) api.refresh().clip().fit();
|
|
12619
12619
|
}, [radius, adjustCamera]);
|
|
12620
12620
|
return null;
|
|
@@ -12632,7 +12632,7 @@ function Refit({ radius, adjustCamera }) {
|
|
|
12632
12632
|
*/
|
|
12633
12633
|
function Stage({ children, center, adjustCamera = true, intensity = .5, shadows = "contact", environment = "city", preset = "rembrandt", ...props }) {
|
|
12634
12634
|
const config = typeof preset === "string" ? presets[preset] : preset;
|
|
12635
|
-
const [{ radius, height }, set] = React
|
|
12635
|
+
const [{ radius, height }, set] = React.useState({
|
|
12636
12636
|
radius: 0,
|
|
12637
12637
|
width: 0,
|
|
12638
12638
|
height: 0,
|
|
@@ -12646,7 +12646,7 @@ function Stage({ children, center, adjustCamera = true, intensity = .5, shadows
|
|
|
12646
12646
|
const accumulativeShadow = shadows === "accumulative" || shadows?.type === "accumulative";
|
|
12647
12647
|
const shadowSpread = { ...typeof shadows === "object" ? shadows : {} };
|
|
12648
12648
|
const environmentProps = !environment ? null : typeof environment === "string" ? { preset: environment } : environment;
|
|
12649
|
-
const onCentered = React
|
|
12649
|
+
const onCentered = React.useCallback((props$1) => {
|
|
12650
12650
|
const { width, height: height$1, depth, boundingSphere } = props$1;
|
|
12651
12651
|
set({
|
|
12652
12652
|
radius: boundingSphere.radius,
|
|
@@ -12753,8 +12753,8 @@ const MATCAP_ROOT = "https://rawcdn.githack.com/emmelleppi/matcaps/9b36ccaaf0a24
|
|
|
12753
12753
|
function useMatcapTexture(id = 0, format = 1024, onLoad) {
|
|
12754
12754
|
const matcapList = (0, import_index_cjs$1.suspend)(() => fetch(LIST_URL$1).then((res) => res.json()), ["matcapList"]);
|
|
12755
12755
|
const DEFAULT_MATCAP = matcapList[0];
|
|
12756
|
-
const numTot = React
|
|
12757
|
-
const url = `${MATCAP_ROOT}/${format}/${`${React
|
|
12756
|
+
const numTot = React.useMemo(() => Object.keys(matcapList).length, []);
|
|
12757
|
+
const url = `${MATCAP_ROOT}/${format}/${`${React.useMemo(() => {
|
|
12758
12758
|
if (typeof id === "string") return id;
|
|
12759
12759
|
else if (typeof id === "number") return matcapList[id];
|
|
12760
12760
|
return null;
|
|
@@ -12787,11 +12787,11 @@ const LIST_URL = "https://cdn.jsdelivr.net/gh/pmndrs/drei-assets@master/normals/
|
|
|
12787
12787
|
function useNormalTexture(id = 0, settings = {}, onLoad) {
|
|
12788
12788
|
const { repeat = [1, 1], anisotropy = 1, offset = [0, 0] } = settings;
|
|
12789
12789
|
const normalsList = (0, import_index_cjs$1.suspend)(() => fetch(LIST_URL).then((res) => res.json()), ["normalsList"]);
|
|
12790
|
-
const numTot = React
|
|
12790
|
+
const numTot = React.useMemo(() => Object.keys(normalsList).length, []);
|
|
12791
12791
|
const DEFAULT_NORMAL = normalsList[0];
|
|
12792
12792
|
const url = `${NORMAL_ROOT}/normals/${normalsList[id] || DEFAULT_NORMAL}`;
|
|
12793
12793
|
const normalTexture = useTexture(url, onLoad);
|
|
12794
|
-
React
|
|
12794
|
+
React.useLayoutEffect(() => {
|
|
12795
12795
|
if (!normalTexture) return;
|
|
12796
12796
|
normalTexture.wrapS = normalTexture.wrapT = RepeatWrapping;
|
|
12797
12797
|
normalTexture.repeat = new Vector2$2(repeat[0], repeat[1]);
|
|
@@ -12836,11 +12836,11 @@ const NormalTexture = ({ children, id, onLoad, ...settings }) => {
|
|
|
12836
12836
|
* ```
|
|
12837
12837
|
*/
|
|
12838
12838
|
function CycleRaycast({ onChanged, portal, preventDefault = true, scroll = true, keyCode = 9 }) {
|
|
12839
|
-
const cycle = React
|
|
12839
|
+
const cycle = React.useRef(0);
|
|
12840
12840
|
const setEvents = useThree((state) => state.setEvents);
|
|
12841
12841
|
const get = useThree((state) => state.get);
|
|
12842
12842
|
const gl = useThree((state) => state.gl);
|
|
12843
|
-
React
|
|
12843
|
+
React.useEffect(() => {
|
|
12844
12844
|
let hits = [];
|
|
12845
12845
|
let lastEvent = void 0;
|
|
12846
12846
|
const prev = get().events.filter;
|
|
@@ -12935,7 +12935,7 @@ function useAspect(width, height, factor = 1) {
|
|
|
12935
12935
|
* ```
|
|
12936
12936
|
*/
|
|
12937
12937
|
function useCursor(hovered, onPointerOver = "pointer", onPointerOut = "auto", container = document.body) {
|
|
12938
|
-
React
|
|
12938
|
+
React.useEffect(() => {
|
|
12939
12939
|
if (hovered) {
|
|
12940
12940
|
container.style.cursor = onPointerOver;
|
|
12941
12941
|
return () => void (container.style.cursor = onPointerOut);
|
|
@@ -12955,9 +12955,9 @@ function useCursor(hovered, onPointerOver = "pointer", onPointerOut = "auto", co
|
|
|
12955
12955
|
* </ScreenSpace>
|
|
12956
12956
|
* ```
|
|
12957
12957
|
*/
|
|
12958
|
-
const ScreenSpace = /* @__PURE__ */ React
|
|
12959
|
-
const localRef = React
|
|
12960
|
-
React
|
|
12958
|
+
const ScreenSpace = /* @__PURE__ */ React.forwardRef(({ children, depth = -1, ...rest }, ref) => {
|
|
12959
|
+
const localRef = React.useRef(null);
|
|
12960
|
+
React.useImperativeHandle(ref, () => localRef.current, []);
|
|
12961
12961
|
useFrame(({ camera }) => {
|
|
12962
12962
|
localRef.current.quaternion.copy(camera.quaternion);
|
|
12963
12963
|
localRef.current.position.copy(camera.position);
|
|
@@ -12974,7 +12974,7 @@ const ScreenSpace = /* @__PURE__ */ React$1.forwardRef(({ children, depth = -1,
|
|
|
12974
12974
|
|
|
12975
12975
|
//#endregion
|
|
12976
12976
|
//#region src/core/UI/Select/Select.tsx
|
|
12977
|
-
const context$1 = /* @__PURE__ */ React
|
|
12977
|
+
const context$1 = /* @__PURE__ */ React.createContext([]);
|
|
12978
12978
|
/**
|
|
12979
12979
|
* Allows selecting/unselecting objects by clicking on them.
|
|
12980
12980
|
* Supports multi-select (shift key) and box selection.
|
|
@@ -12992,30 +12992,30 @@ const context$1 = /* @__PURE__ */ React$1.createContext([]);
|
|
|
12992
12992
|
* ```
|
|
12993
12993
|
*/
|
|
12994
12994
|
function Select({ box, multiple, children, onChange, onChangePointerUp, border = "1px solid #55aaff", backgroundColor = "rgba(75, 160, 255, 0.1)", filter: customFilter = (item) => item, ...props }) {
|
|
12995
|
-
const [downed, down] = React
|
|
12995
|
+
const [downed, down] = React.useState(false);
|
|
12996
12996
|
const { setEvents, camera, raycaster, gl, controls, size, get } = useThree();
|
|
12997
|
-
const [hovered, hover] = React
|
|
12998
|
-
const [active, dispatch] = React
|
|
12997
|
+
const [hovered, hover] = React.useState(false);
|
|
12998
|
+
const [active, dispatch] = React.useReducer((state, { object, shift }) => {
|
|
12999
12999
|
if (object === void 0) return [];
|
|
13000
13000
|
else if (Array.isArray(object)) return object;
|
|
13001
13001
|
else if (!shift) return state[0] === object ? [] : [object];
|
|
13002
13002
|
else if (state.includes(object)) return state.filter((o) => o !== object);
|
|
13003
13003
|
else return [object, ...state];
|
|
13004
13004
|
}, []);
|
|
13005
|
-
React
|
|
13005
|
+
React.useEffect(() => {
|
|
13006
13006
|
if (downed) onChange?.(active);
|
|
13007
13007
|
else onChangePointerUp?.(active);
|
|
13008
13008
|
}, [active, downed]);
|
|
13009
|
-
const onClick = React
|
|
13009
|
+
const onClick = React.useCallback((e) => {
|
|
13010
13010
|
e.stopPropagation();
|
|
13011
13011
|
dispatch({
|
|
13012
13012
|
object: customFilter([e.object])[0],
|
|
13013
13013
|
shift: multiple && e.shiftKey
|
|
13014
13014
|
});
|
|
13015
13015
|
}, []);
|
|
13016
|
-
const onPointerMissed = React
|
|
13017
|
-
const ref = React
|
|
13018
|
-
React
|
|
13016
|
+
const onPointerMissed = React.useCallback((e) => !hovered && dispatch({}), [hovered]);
|
|
13017
|
+
const ref = React.useRef(null);
|
|
13018
|
+
React.useEffect(() => {
|
|
13019
13019
|
if (!box || !multiple) return;
|
|
13020
13020
|
const selBox = new SelectionBox(camera, ref.current);
|
|
13021
13021
|
const element = document.createElement("div");
|
|
@@ -13118,7 +13118,7 @@ function Select({ box, multiple, children, onChange, onChangePointerUp, border =
|
|
|
13118
13118
|
});
|
|
13119
13119
|
}
|
|
13120
13120
|
function useSelect() {
|
|
13121
|
-
return React
|
|
13121
|
+
return React.useContext(context$1);
|
|
13122
13122
|
}
|
|
13123
13123
|
|
|
13124
13124
|
//#endregion
|
|
@@ -13519,7 +13519,7 @@ let GradientType = /* @__PURE__ */ function(GradientType$1) {
|
|
|
13519
13519
|
}({});
|
|
13520
13520
|
function GradientTexture({ stops, colors: colors$1, size = 1024, width = 16, type = GradientType.Linear, innerCircleRadius = 0, outerCircleRadius = "auto", ...props }) {
|
|
13521
13521
|
const gl = useThree((state) => state.gl);
|
|
13522
|
-
const canvas = React
|
|
13522
|
+
const canvas = React.useMemo(() => {
|
|
13523
13523
|
const canvas$1 = document.createElement("canvas");
|
|
13524
13524
|
const context$11 = canvas$1.getContext("2d");
|
|
13525
13525
|
canvas$1.width = width;
|
|
@@ -13561,7 +13561,7 @@ const udRoundBox = /* @__PURE__ */ Fn(({ p, b, r }) => {
|
|
|
13561
13561
|
return length(max(abs(p).sub(b).add(r), float(0))).sub(r);
|
|
13562
13562
|
});
|
|
13563
13563
|
function useImageMaterial(tex, options) {
|
|
13564
|
-
const uniforms = React
|
|
13564
|
+
const uniforms = React.useMemo(() => ({
|
|
13565
13565
|
color: uniform(new THREE.Color("white")),
|
|
13566
13566
|
scale: uniform(new THREE.Vector2(1, 1)),
|
|
13567
13567
|
imageBounds: uniform(new THREE.Vector2(1, 1)),
|
|
@@ -13571,7 +13571,7 @@ function useImageMaterial(tex, options) {
|
|
|
13571
13571
|
grayscale: uniform(0),
|
|
13572
13572
|
opacity: uniform(1)
|
|
13573
13573
|
}), []);
|
|
13574
|
-
const material = React
|
|
13574
|
+
const material = React.useMemo(() => {
|
|
13575
13575
|
const mat = new THREE.MeshBasicNodeMaterial();
|
|
13576
13576
|
mat.colorNode = Fn(() => {
|
|
13577
13577
|
const uvCoord = uv();
|
|
@@ -13600,7 +13600,7 @@ function useImageMaterial(tex, options) {
|
|
|
13600
13600
|
})();
|
|
13601
13601
|
return mat;
|
|
13602
13602
|
}, [tex, uniforms]);
|
|
13603
|
-
React
|
|
13603
|
+
React.useLayoutEffect(() => {
|
|
13604
13604
|
uniforms.color.value.set(options.color);
|
|
13605
13605
|
uniforms.scale.value.set(options.scale[0], options.scale[1]);
|
|
13606
13606
|
uniforms.imageBounds.value.set(options.imageBounds[0], options.imageBounds[1]);
|
|
@@ -13622,7 +13622,7 @@ function useImageMaterial(tex, options) {
|
|
|
13622
13622
|
options.grayscale,
|
|
13623
13623
|
options.opacity
|
|
13624
13624
|
]);
|
|
13625
|
-
React
|
|
13625
|
+
React.useLayoutEffect(() => {
|
|
13626
13626
|
material.toneMapped = options.toneMapped ?? true;
|
|
13627
13627
|
material.transparent = options.transparent ?? false;
|
|
13628
13628
|
if (options.side !== void 0) material.side = options.side;
|
|
@@ -13635,8 +13635,8 @@ function useImageMaterial(tex, options) {
|
|
|
13635
13635
|
]);
|
|
13636
13636
|
return material;
|
|
13637
13637
|
}
|
|
13638
|
-
const ImageBase = /* @__PURE__ */ React
|
|
13639
|
-
const ref = React
|
|
13638
|
+
const ImageBase = /* @__PURE__ */ React.forwardRef(({ children, color = "white", segments = 1, scale: scale$2 = 1, zoom = 1, grayscale = 0, opacity = 1, radius = 0, texture: texture$1, toneMapped, transparent, side, ...props }, fref) => {
|
|
13639
|
+
const ref = React.useRef(null);
|
|
13640
13640
|
const size = useThree((state) => state.size);
|
|
13641
13641
|
const planeBounds = Array.isArray(scale$2) ? [scale$2[0], scale$2[1]] : [scale$2, scale$2];
|
|
13642
13642
|
const img = texture$1.image;
|
|
@@ -13653,7 +13653,7 @@ const ImageBase = /* @__PURE__ */ React$1.forwardRef(({ children, color = "white
|
|
|
13653
13653
|
transparent,
|
|
13654
13654
|
side
|
|
13655
13655
|
});
|
|
13656
|
-
React
|
|
13656
|
+
React.useImperativeHandle(fref, () => ref.current, []);
|
|
13657
13657
|
return /* @__PURE__ */ jsxs("mesh", {
|
|
13658
13658
|
ref,
|
|
13659
13659
|
scale: Array.isArray(scale$2) ? [...scale$2, 1] : scale$2,
|
|
@@ -13673,7 +13673,7 @@ const ImageBase = /* @__PURE__ */ React$1.forwardRef(({ children, color = "white
|
|
|
13673
13673
|
]
|
|
13674
13674
|
});
|
|
13675
13675
|
});
|
|
13676
|
-
const ImageWithUrl = /* @__PURE__ */ React
|
|
13676
|
+
const ImageWithUrl = /* @__PURE__ */ React.forwardRef(({ url, ...props }, ref) => {
|
|
13677
13677
|
const texture$1 = useTexture(url);
|
|
13678
13678
|
return /* @__PURE__ */ jsx(ImageBase, {
|
|
13679
13679
|
...props,
|
|
@@ -13681,13 +13681,13 @@ const ImageWithUrl = /* @__PURE__ */ React$1.forwardRef(({ url, ...props }, ref)
|
|
|
13681
13681
|
ref
|
|
13682
13682
|
});
|
|
13683
13683
|
});
|
|
13684
|
-
const ImageWithTexture = /* @__PURE__ */ React
|
|
13684
|
+
const ImageWithTexture = /* @__PURE__ */ React.forwardRef(({ url: _url, ...props }, ref) => {
|
|
13685
13685
|
return /* @__PURE__ */ jsx(ImageBase, {
|
|
13686
13686
|
...props,
|
|
13687
13687
|
ref
|
|
13688
13688
|
});
|
|
13689
13689
|
});
|
|
13690
|
-
const Image = /* @__PURE__ */ React
|
|
13690
|
+
const Image = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
13691
13691
|
if (props.url) return /* @__PURE__ */ jsx(ImageWithUrl, {
|
|
13692
13692
|
...props,
|
|
13693
13693
|
ref
|
|
@@ -13816,7 +13816,7 @@ function SoftShadows({ focus = 0, samples = 10, size = 25 }) {
|
|
|
13816
13816
|
const gl = useThree((state) => state.gl);
|
|
13817
13817
|
const scene = useThree((state) => state.scene);
|
|
13818
13818
|
const camera = useThree((state) => state.camera);
|
|
13819
|
-
React
|
|
13819
|
+
React.useEffect(() => {
|
|
13820
13820
|
const original = (void 0).shadowmap_pars_fragment;
|
|
13821
13821
|
(void 0).shadowmap_pars_fragment = (void 0).shadowmap_pars_fragment.replace("#ifdef USE_SHADOWMAP", "#ifdef USE_SHADOWMAP\n" + pcss({
|
|
13822
13822
|
size,
|
|
@@ -14178,10 +14178,10 @@ function setBarycentricCoordinates(geometry$1) {
|
|
|
14178
14178
|
geometry$1.setAttribute("barycentric", new THREE.BufferAttribute(barycentricArray, 3));
|
|
14179
14179
|
return geometry$1;
|
|
14180
14180
|
}
|
|
14181
|
-
const WireframeMaterial = /* @__PURE__ */ React
|
|
14181
|
+
const WireframeMaterial = /* @__PURE__ */ React.forwardRef(({ fillOpacity = .25, fillMix = 0, strokeOpacity = 1, thickness = .05, colorBackfaces = false, dashInvert = true, dash = false, dashRepeats = 4, dashLength = .5, squeeze = false, squeezeMin = .2, squeezeMax = 1, stroke = "#ff0000", backfaceStroke = "#0000ff", fill = "#00ff00", ...props }, fref) => {
|
|
14182
14182
|
extend({ WireframeMaterial: WireframeMaterialImpl });
|
|
14183
|
-
const ref = React
|
|
14184
|
-
React
|
|
14183
|
+
const ref = React.useRef(null);
|
|
14184
|
+
React.useImperativeHandle(fref, () => ref.current, []);
|
|
14185
14185
|
return /* @__PURE__ */ jsx("wireframeMaterial", {
|
|
14186
14186
|
ref,
|
|
14187
14187
|
...props,
|
|
@@ -14544,15 +14544,15 @@ var GridMaterialImpl = class extends MeshBasicNodeMaterial {
|
|
|
14544
14544
|
* />
|
|
14545
14545
|
* ```
|
|
14546
14546
|
*/
|
|
14547
|
-
const Grid = /* @__PURE__ */ React
|
|
14547
|
+
const Grid = /* @__PURE__ */ React.forwardRef(({ args, cellColor = "#000000", sectionColor = "#2080ff", cellSize = .5, sectionSize = 1, followCamera = false, infiniteGrid = false, fadeDistance = 100, fadeStrength = 1, fadeFrom = 1, cellThickness = .5, sectionThickness = 1, side = THREE.BackSide, ...props }, fRef) => {
|
|
14548
14548
|
extend({ GridMaterial: GridMaterialImpl });
|
|
14549
|
-
const ref = React
|
|
14550
|
-
const materialRef = React
|
|
14551
|
-
React
|
|
14552
|
-
const plane = React
|
|
14553
|
-
const upVector = React
|
|
14554
|
-
const zeroVector = React
|
|
14555
|
-
const tempVec = React
|
|
14549
|
+
const ref = React.useRef(null);
|
|
14550
|
+
const materialRef = React.useRef(null);
|
|
14551
|
+
React.useImperativeHandle(fRef, () => ref.current, []);
|
|
14552
|
+
const plane = React.useMemo(() => new THREE.Plane(), []);
|
|
14553
|
+
const upVector = React.useMemo(() => new THREE.Vector3(0, 1, 0), []);
|
|
14554
|
+
const zeroVector = React.useMemo(() => new THREE.Vector3(0, 0, 0), []);
|
|
14555
|
+
const tempVec = React.useMemo(() => new THREE.Vector3(), []);
|
|
14556
14556
|
useFrame((state) => {
|
|
14557
14557
|
if (!materialRef.current) return;
|
|
14558
14558
|
plane.setFromNormalAndCoplanarPoint(upVector, zeroVector).applyMatrix4(ref.current.matrixWorld);
|
|
@@ -14588,16 +14588,16 @@ const Grid = /* @__PURE__ */ React$1.forwardRef(({ args, cellColor = "#000000",
|
|
|
14588
14588
|
let spotlightIdCounter = 0;
|
|
14589
14589
|
const generateSpotlightId = () => `spotlight_${spotlightIdCounter++}`;
|
|
14590
14590
|
function VolumetricMesh({ opacity = 1, radiusTop, radiusBottom, depthBuffer, color = "white", distance: distance$1 = 5, angle = .15, attenuation = 5, anglePower = 5 }) {
|
|
14591
|
-
const mesh = React
|
|
14591
|
+
const mesh = React.useRef(null);
|
|
14592
14592
|
const size = useThree((state) => state.size);
|
|
14593
14593
|
const camera = useThree((state) => state.camera);
|
|
14594
14594
|
const dpr = useThree((state) => state.viewport.dpr);
|
|
14595
|
-
const [material] = React
|
|
14596
|
-
const [tempVec] = React
|
|
14597
|
-
const [instanceId] = React
|
|
14595
|
+
const [material] = React.useState(() => new SpotLightMaterial());
|
|
14596
|
+
const [tempVec] = React.useState(() => new Vector3$2());
|
|
14597
|
+
const [instanceId] = React.useState(() => generateSpotlightId());
|
|
14598
14598
|
radiusTop = radiusTop === void 0 ? .1 : radiusTop;
|
|
14599
14599
|
radiusBottom = radiusBottom === void 0 ? angle * 7 : radiusBottom;
|
|
14600
|
-
React
|
|
14600
|
+
React.useLayoutEffect(() => {
|
|
14601
14601
|
material.lightColor = typeof color === "string" || typeof color === "number" ? new Color$2(color) : color;
|
|
14602
14602
|
material.opacity = opacity;
|
|
14603
14603
|
material.attenuation = attenuation;
|
|
@@ -14647,7 +14647,7 @@ function VolumetricMesh({ opacity = 1, radiusTop, radiusBottom, depthBuffer, col
|
|
|
14647
14647
|
});
|
|
14648
14648
|
return /* @__PURE__ */ jsx("mesh", {
|
|
14649
14649
|
ref: mesh,
|
|
14650
|
-
geometry: React
|
|
14650
|
+
geometry: React.useMemo(() => {
|
|
14651
14651
|
const geometry$1 = new CylinderGeometry(radiusTop, radiusBottom, distance$1, 128, 64, true);
|
|
14652
14652
|
geometry$1.applyMatrix4(new Matrix4().makeTranslation(0, -distance$1 / 2, 0));
|
|
14653
14653
|
geometry$1.applyMatrix4(new Matrix4().makeRotationX(-Math.PI / 2));
|
|
@@ -14661,9 +14661,9 @@ function VolumetricMesh({ opacity = 1, radiusTop, radiusBottom, depthBuffer, col
|
|
|
14661
14661
|
raycast: () => null
|
|
14662
14662
|
});
|
|
14663
14663
|
}
|
|
14664
|
-
const SpotLight = /* @__PURE__ */ React
|
|
14665
|
-
const spotlight = React
|
|
14666
|
-
React
|
|
14664
|
+
const SpotLight = /* @__PURE__ */ React.forwardRef(({ opacity = 1, radiusTop, radiusBottom, depthBuffer, color = "white", distance: distance$1 = 5, angle = .15, attenuation = 5, anglePower = 5, volumetric = true, debug = false, children, ...props }, ref) => {
|
|
14665
|
+
const spotlight = React.useRef(null);
|
|
14666
|
+
React.useImperativeHandle(ref, () => spotlight.current, []);
|
|
14667
14667
|
return /* @__PURE__ */ jsxs("group", { children: [
|
|
14668
14668
|
debug && spotlight.current && /* @__PURE__ */ jsx("spotLightHelper", { args: [spotlight.current] }),
|
|
14669
14669
|
/* @__PURE__ */ jsx("spotLight", {
|
|
@@ -14703,10 +14703,10 @@ const genStar = (r) => {
|
|
|
14703
14703
|
* <Stars radius={100} depth={50} count={5000} factor={4} fade />
|
|
14704
14704
|
* ```
|
|
14705
14705
|
*/
|
|
14706
|
-
const Stars = /* @__PURE__ */ React
|
|
14707
|
-
React
|
|
14708
|
-
const ref = React
|
|
14709
|
-
const { positions, colors: colors$1, sizes } = React
|
|
14706
|
+
const Stars = /* @__PURE__ */ React.forwardRef(({ radius = 100, depth = 50, count = 5e3, saturation = 0, factor = 4, fade = false, speed = 1, children, ...props }, forwardRef$1) => {
|
|
14707
|
+
React.useMemo(() => extend({ WebgpuStarfieldMaterial: StarfieldMaterial }), []);
|
|
14708
|
+
const ref = React.useRef(null);
|
|
14709
|
+
const { positions, colors: colors$1, sizes } = React.useMemo(() => {
|
|
14710
14710
|
const positions$1 = new Float32Array(count * 3);
|
|
14711
14711
|
const colors$2 = new Float32Array(count * 3);
|
|
14712
14712
|
const sizes$1 = new Float32Array(count);
|
|
@@ -14737,7 +14737,7 @@ const Stars = /* @__PURE__ */ React$1.forwardRef(({ radius = 100, depth = 50, co
|
|
|
14737
14737
|
radius,
|
|
14738
14738
|
saturation
|
|
14739
14739
|
]);
|
|
14740
|
-
const geometry$1 = React
|
|
14740
|
+
const geometry$1 = React.useMemo(() => {
|
|
14741
14741
|
const geo = new PlaneGeometry(1, 1);
|
|
14742
14742
|
geo.deleteAttribute("normal");
|
|
14743
14743
|
geo.setAttribute("particlePosition", new InstancedBufferAttribute(positions, 3));
|
|
@@ -14753,10 +14753,10 @@ const Stars = /* @__PURE__ */ React$1.forwardRef(({ radius = 100, depth = 50, co
|
|
|
14753
14753
|
useFrame((state) => {
|
|
14754
14754
|
if (ref.current?.material) ref.current.material.setTime(state.elapsed * speed);
|
|
14755
14755
|
});
|
|
14756
|
-
React
|
|
14756
|
+
React.useEffect(() => {
|
|
14757
14757
|
if (ref.current?.material) ref.current.material.setFade(fade ? 1 : 0);
|
|
14758
14758
|
}, [fade]);
|
|
14759
|
-
React
|
|
14759
|
+
React.useImperativeHandle(forwardRef$1, () => ref.current, []);
|
|
14760
14760
|
return /* @__PURE__ */ jsx("instancedMesh", {
|
|
14761
14761
|
ref,
|
|
14762
14762
|
args: [
|
|
@@ -14788,7 +14788,7 @@ const normalizeVector = (v$1) => {
|
|
|
14788
14788
|
];
|
|
14789
14789
|
};
|
|
14790
14790
|
function usePropAsIsOrAsAttribute(count, prop, setDefault) {
|
|
14791
|
-
return React
|
|
14791
|
+
return React.useMemo(() => {
|
|
14792
14792
|
if (prop !== void 0) if (isFloat32Array(prop)) return prop;
|
|
14793
14793
|
else {
|
|
14794
14794
|
if (prop instanceof Color$2) {
|
|
@@ -14803,18 +14803,18 @@ function usePropAsIsOrAsAttribute(count, prop, setDefault) {
|
|
|
14803
14803
|
return Float32Array.from({ length: count }, setDefault);
|
|
14804
14804
|
}, [prop]);
|
|
14805
14805
|
}
|
|
14806
|
-
const Sparkles = /* @__PURE__ */ React
|
|
14807
|
-
React
|
|
14808
|
-
const ref = React
|
|
14806
|
+
const Sparkles = /* @__PURE__ */ React.forwardRef(({ noise = 1, count = 100, speed = 1, opacity = 1, scale: scale$2 = 1, size, color, children, ...props }, forwardRef$1) => {
|
|
14807
|
+
React.useMemo(() => extend({ WebgpuSparklesMaterial: SparklesMaterial }), []);
|
|
14808
|
+
const ref = React.useRef(null);
|
|
14809
14809
|
const dpr = useThree((state) => state.viewport.dpr);
|
|
14810
14810
|
const _scale = normalizeVector(scale$2);
|
|
14811
|
-
const positions = React
|
|
14811
|
+
const positions = React.useMemo(() => Float32Array.from(Array.from({ length: count }, () => _scale.map((s) => MathUtils.randFloatSpread(s))).flat()), [count, ..._scale]);
|
|
14812
14812
|
const sizes = usePropAsIsOrAsAttribute(count, size, Math.random);
|
|
14813
14813
|
const opacities = usePropAsIsOrAsAttribute(count, opacity);
|
|
14814
14814
|
const speeds = usePropAsIsOrAsAttribute(count, speed);
|
|
14815
14815
|
const noises = usePropAsIsOrAsAttribute(count * 3, noise);
|
|
14816
14816
|
const colors$1 = usePropAsIsOrAsAttribute(color === void 0 ? count * 3 : count, !isFloat32Array(color) ? new Color$2(color) : color, () => 1);
|
|
14817
|
-
const geometry$1 = React
|
|
14817
|
+
const geometry$1 = React.useMemo(() => {
|
|
14818
14818
|
const geo = new PlaneGeometry(1, 1);
|
|
14819
14819
|
geo.deleteAttribute("normal");
|
|
14820
14820
|
geo.setAttribute("particlePosition", new InstancedBufferAttribute(positions, 3));
|
|
@@ -14836,7 +14836,7 @@ const Sparkles = /* @__PURE__ */ React$1.forwardRef(({ noise = 1, count = 100, s
|
|
|
14836
14836
|
useFrame((state) => {
|
|
14837
14837
|
if (ref.current && ref.current.material) ref.current.material.time = state.elapsed;
|
|
14838
14838
|
});
|
|
14839
|
-
React
|
|
14839
|
+
React.useImperativeHandle(forwardRef$1, () => ref.current, []);
|
|
14840
14840
|
return /* @__PURE__ */ jsx("instancedMesh", {
|
|
14841
14841
|
ref,
|
|
14842
14842
|
args: [
|