@react-three/drei 9.74.13 → 9.74.15
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/CatmullRomLine.js +0 -2
- package/core/Cloud.js +0 -3
- package/core/CubeCamera.js +0 -1
- package/core/CubicBezierLine.js +0 -2
- package/core/Environment.js +0 -1
- package/core/Example.js +0 -6
- package/core/FaceControls.cjs.js +1 -1
- package/core/FaceControls.js +0 -2
- package/core/FaceLandmarker.cjs.js +1 -1
- package/core/FaceLandmarker.js +3 -4
- package/core/Facemesh.js +0 -2
- package/core/GizmoHelper.js +0 -3
- package/core/GizmoViewcube.js +0 -4
- package/core/GizmoViewport.js +0 -4
- package/core/Gltf.js +0 -4
- package/core/MeshDiscardMaterial.js +0 -2
- package/core/MeshDistortMaterial.js +1 -2
- package/core/MeshReflectorMaterial.js +0 -1
- package/core/MeshRefractionMaterial.js +0 -2
- package/core/MeshTransmissionMaterial.js +0 -1
- package/core/OrthographicCamera.js +0 -1
- package/core/PerspectiveCamera.js +0 -1
- package/core/QuadraticBezierLine.js +0 -2
- package/core/Reflector.js +0 -1
- package/core/SpotLight.js +1 -2
- package/core/Stage.js +0 -7
- package/core/Text3D.js +0 -1
- package/core/Wireframe.js +0 -1
- package/core/index.cjs.js +1 -1
- package/core/index.js +1 -0
- package/core/useKTX2.js +0 -1
- package/core/useMatcapTexture.js +0 -2
- package/core/useNormalTexture.js +0 -1
- package/index.cjs.js +1 -1
- package/materials/DiscardMaterial.js +0 -1
- package/materials/MeshRefractionMaterial.js +1 -1
- package/native/index.cjs.js +1 -1
- package/native/index.js +1 -0
- package/package.json +2 -2
- package/web/Loader.js +0 -2
- package/web/index.cjs.js +1 -1
- package/web/index.js +1 -0
- package/web/pivotControls/AxisArrow.js +0 -3
- package/web/pivotControls/AxisRotator.js +0 -3
- package/web/pivotControls/PlaneSlider.js +0 -3
- package/web/pivotControls/index.js +0 -5
- package/src/core/AccumulativeShadows.js +0 -311
- package/src/core/AdaptiveDpr.js +0 -28
- package/src/core/AdaptiveEvents.js +0 -20
- package/src/core/ArcballControls.js +0 -67
- package/src/core/AsciiRenderer.js +0 -60
- package/src/core/BBAnchor.js +0 -37
- package/src/core/Backdrop.js +0 -36
- package/src/core/BakeShadows.js +0 -16
- package/src/core/Billboard.js +0 -41
- package/src/core/Bounds.js +0 -245
- package/src/core/CameraControls.js +0 -92
- package/src/core/CameraShake.js +0 -61
- package/src/core/CatmullRomLine.js +0 -44
- package/src/core/Caustics.js +0 -375
- package/src/core/Center.js +0 -66
- package/src/core/Clone.js +0 -102
- package/src/core/Cloud.js +0 -59
- package/src/core/ComputedAttribute.js +0 -34
- package/src/core/ContactShadows.js +0 -114
- package/src/core/CubeCamera.js +0 -43
- package/src/core/CubicBezierLine.js +0 -28
- package/src/core/CurveModifier.js +0 -34
- package/src/core/Decal.js +0 -92
- package/src/core/Detailed.js +0 -34
- package/src/core/DeviceOrientationControls.js +0 -51
- package/src/core/Edges.js +0 -36
- package/src/core/Effects.js +0 -93
- package/src/core/Environment.js +0 -132
- package/src/core/Example.js +0 -42
- package/src/core/FaceControls.js +0 -315
- package/src/core/FaceLandmarker.js +0 -43
- package/src/core/Facemesh.js +0 -4545
- package/src/core/FirstPersonControls.js +0 -38
- package/src/core/Float.js +0 -36
- package/src/core/FlyControls.js +0 -55
- package/src/core/GizmoHelper.js +0 -111
- package/src/core/GizmoViewcube.js +0 -152
- package/src/core/GizmoViewport.js +0 -152
- package/src/core/Gltf.js +0 -20
- package/src/core/GradientTexture.js +0 -33
- package/src/core/Grid.js +0 -112
- package/src/core/Hud.js +0 -58
- package/src/core/Image.js +0 -119
- package/src/core/Instances.js +0 -215
- package/src/core/Lightformer.js +0 -51
- package/src/core/Line.js +0 -68
- package/src/core/MapControls.js +0 -64
- package/src/core/MarchingCubes.js +0 -76
- package/src/core/Mask.js +0 -42
- package/src/core/MeshDiscardMaterial.js +0 -15
- package/src/core/MeshDistortMaterial.js +0 -79
- package/src/core/MeshPortalMaterial.js +0 -381
- package/src/core/MeshReflectorMaterial.js +0 -182
- package/src/core/MeshRefractionMaterial.js +0 -79
- package/src/core/MeshTransmissionMaterial.js +0 -395
- package/src/core/MeshWobbleMaterial.js +0 -65
- package/src/core/OrbitControls.js +0 -82
- package/src/core/OrthographicCamera.js +0 -77
- package/src/core/PerformanceMonitor.js +0 -121
- package/src/core/PerspectiveCamera.js +0 -73
- package/src/core/PointMaterial.js +0 -36
- package/src/core/PointerLockControls.js +0 -90
- package/src/core/Points.js +0 -227
- package/src/core/PositionalAudio.js +0 -51
- package/src/core/Preload.js +0 -45
- package/src/core/QuadraticBezierLine.js +0 -44
- package/src/core/Reflector.js +0 -182
- package/src/core/RenderTexture.js +0 -96
- package/src/core/Resize.js +0 -39
- package/src/core/RoundedBox.js +0 -52
- package/src/core/Sampler.js +0 -85
- package/src/core/ScreenQuad.js +0 -24
- package/src/core/ScreenSpace.js +0 -25
- package/src/core/Segments.js +0 -102
- package/src/core/Shadow.js +0 -42
- package/src/core/Sky.js +0 -39
- package/src/core/Sparkles.js +0 -139
- package/src/core/SpotLight.js +0 -231
- package/src/core/SpriteAnimator.js +0 -342
- package/src/core/Stage.js +0 -135
- package/src/core/Stars.js +0 -108
- package/src/core/Stats.js +0 -30
- package/src/core/Svg.js +0 -59
- package/src/core/Text.js +0 -58
- package/src/core/Text3D.js +0 -76
- package/src/core/TrackballControls.js +0 -72
- package/src/core/Trail.js +0 -161
- package/src/core/TransformControls.js +0 -106
- package/src/core/Wireframe.js +0 -185
- package/src/core/meshBounds.js +0 -38
- package/src/core/shaderMaterial.js +0 -39
- package/src/core/shapes.js +0 -68
- package/src/core/softShadows.js +0 -161
- package/src/core/useAnimations.js +0 -56
- package/src/core/useAspect.js +0 -10
- package/src/core/useBVH.js +0 -90
- package/src/core/useBoxProjectedEnv.js +0 -98
- package/src/core/useCamera.js +0 -27
- package/src/core/useContextBridge.js +0 -21
- package/src/core/useCubeCamera.js +0 -49
- package/src/core/useCubeTexture.js +0 -18
- package/src/core/useDepthBuffer.js +0 -38
- package/src/core/useDetectGPU.js +0 -6
- package/src/core/useEnvironment.js +0 -48
- package/src/core/useFBO.js +0 -53
- package/src/core/useFBX.js +0 -12
- package/src/core/useFont.js +0 -20
- package/src/core/useGLTF.js +0 -37
- package/src/core/useHelper.js +0 -31
- package/src/core/useIntersect.js +0 -39
- package/src/core/useKTX2.js +0 -38
- package/src/core/useMatcapTexture.js +0 -45
- package/src/core/useNormalTexture.js +0 -30
- package/src/core/useProgress.js +0 -50
- package/src/core/useTexture.js +0 -35
- package/src/core/useTrailTexture.js +0 -164
- package/src/core/useVideoTexture.js +0 -41
- package/src/helpers/environment-assets.js +0 -14
- package/src/helpers/useEffectfulState.js +0 -18
- package/src/materials/BlurPass.js +0 -75
- package/src/materials/ConvolutionMaterial.js +0 -99
- package/src/materials/DiscardMaterial.js +0 -5
- package/src/materials/MeshReflectorMaterial.js +0 -290
- package/src/materials/MeshRefractionMaterial.js +0 -171
- package/src/materials/SpotLightMaterial.js +0 -111
- package/src/materials/WireframeMaterial.js +0 -235
- package/src/web/CycleRaycast.js +0 -97
- package/src/web/Html.js +0 -417
- package/src/web/KeyboardControls.js +0 -101
- package/src/web/Loader.js +0 -98
- package/src/web/PresentationControls.js +0 -86
- package/src/web/ScrollControls.js +0 -246
- package/src/web/Select.js +0 -175
- package/src/web/View.js +0 -206
- package/src/web/pivotControls/AxisArrow.js +0 -202
- package/src/web/pivotControls/AxisRotator.js +0 -235
- package/src/web/pivotControls/PlaneSlider.js +0 -211
- package/src/web/pivotControls/context.js +0 -5
- package/src/web/pivotControls/index.js +0 -223
- package/src/web/useCursor.js +0 -12
- /package/{src/helpers → helpers}/glsl/DefaultSpotlightShadowShadows.glsl.js +0 -0
- /package/{src/helpers → helpers}/glsl/distort.vert.glsl.js +0 -0
- /package/{src/index.js → index.js} +0 -0
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
-
import * as THREE from 'three';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { useThree, useFrame } from '@react-three/fiber';
|
|
5
|
-
import { AxisArrow } from './AxisArrow.js';
|
|
6
|
-
import { PlaneSlider } from './PlaneSlider.js';
|
|
7
|
-
import { AxisRotator } from './AxisRotator.js';
|
|
8
|
-
import { context } from './context.js';
|
|
9
|
-
|
|
10
|
-
const tV0 = new THREE.Vector3();
|
|
11
|
-
const tV1 = new THREE.Vector3();
|
|
12
|
-
const tV2 = new THREE.Vector3();
|
|
13
|
-
|
|
14
|
-
const getPoint2 = (point3, camera, size) => {
|
|
15
|
-
const widthHalf = size.width / 2;
|
|
16
|
-
const heightHalf = size.height / 2;
|
|
17
|
-
camera.updateMatrixWorld(false);
|
|
18
|
-
const vector = point3.project(camera);
|
|
19
|
-
vector.x = vector.x * widthHalf + widthHalf;
|
|
20
|
-
vector.y = -(vector.y * heightHalf) + heightHalf;
|
|
21
|
-
return vector;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const getPoint3 = (point2, camera, size, zValue = 1) => {
|
|
25
|
-
const vector = tV0.set(point2.x / size.width * 2 - 1, -(point2.y / size.height) * 2 + 1, zValue);
|
|
26
|
-
vector.unproject(camera);
|
|
27
|
-
return vector;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const calculateScaleFactor = (point3, radiusPx, camera, size) => {
|
|
31
|
-
const point2 = getPoint2(tV2.copy(point3), camera, size);
|
|
32
|
-
let scale = 0;
|
|
33
|
-
|
|
34
|
-
for (let i = 0; i < 2; ++i) {
|
|
35
|
-
const point2off = tV1.copy(point2).setComponent(i, point2.getComponent(i) + radiusPx);
|
|
36
|
-
const point3off = getPoint3(point2off, camera, size, point2off.z);
|
|
37
|
-
scale = Math.max(scale, point3.distanceTo(point3off));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return scale;
|
|
41
|
-
};
|
|
42
|
-
const mL0 = new THREE.Matrix4();
|
|
43
|
-
const mW0 = new THREE.Matrix4();
|
|
44
|
-
const mP = new THREE.Matrix4();
|
|
45
|
-
const mPInv = new THREE.Matrix4();
|
|
46
|
-
const mW = new THREE.Matrix4();
|
|
47
|
-
const mL = new THREE.Matrix4();
|
|
48
|
-
const mL0Inv = new THREE.Matrix4();
|
|
49
|
-
const mdL = new THREE.Matrix4();
|
|
50
|
-
const bb = new THREE.Box3();
|
|
51
|
-
const bbObj = new THREE.Box3();
|
|
52
|
-
const vCenter = new THREE.Vector3();
|
|
53
|
-
const vSize = new THREE.Vector3();
|
|
54
|
-
const vAnchorOffset = new THREE.Vector3();
|
|
55
|
-
const vPosition = new THREE.Vector3();
|
|
56
|
-
const xDir = new THREE.Vector3(1, 0, 0);
|
|
57
|
-
const yDir = new THREE.Vector3(0, 1, 0);
|
|
58
|
-
const zDir = new THREE.Vector3(0, 0, 1);
|
|
59
|
-
const PivotControls = /*#__PURE__*/React.forwardRef(({
|
|
60
|
-
matrix,
|
|
61
|
-
onDragStart,
|
|
62
|
-
onDrag,
|
|
63
|
-
onDragEnd,
|
|
64
|
-
autoTransform = true,
|
|
65
|
-
anchor,
|
|
66
|
-
disableAxes = false,
|
|
67
|
-
disableSliders = false,
|
|
68
|
-
disableRotations = false,
|
|
69
|
-
activeAxes = [true, true, true],
|
|
70
|
-
offset = [0, 0, 0],
|
|
71
|
-
rotation = [0, 0, 0],
|
|
72
|
-
scale = 1,
|
|
73
|
-
lineWidth = 4,
|
|
74
|
-
fixed = false,
|
|
75
|
-
translationLimits,
|
|
76
|
-
rotationLimits,
|
|
77
|
-
depthTest = true,
|
|
78
|
-
axisColors = ['#ff2060', '#20df80', '#2080ff'],
|
|
79
|
-
hoveredColor = '#ffff40',
|
|
80
|
-
annotations = false,
|
|
81
|
-
annotationsClass,
|
|
82
|
-
opacity = 1,
|
|
83
|
-
visible = true,
|
|
84
|
-
userData,
|
|
85
|
-
children,
|
|
86
|
-
...props
|
|
87
|
-
}, fRef) => {
|
|
88
|
-
const invalidate = useThree(state => state.invalidate);
|
|
89
|
-
const parentRef = React.useRef(null);
|
|
90
|
-
const ref = React.useRef(null);
|
|
91
|
-
const gizmoRef = React.useRef(null);
|
|
92
|
-
const childrenRef = React.useRef(null);
|
|
93
|
-
const translation = React.useRef([0, 0, 0]);
|
|
94
|
-
React.useLayoutEffect(() => {
|
|
95
|
-
if (!anchor) return;
|
|
96
|
-
childrenRef.current.updateWorldMatrix(true, true);
|
|
97
|
-
mPInv.copy(childrenRef.current.matrixWorld).invert();
|
|
98
|
-
bb.makeEmpty();
|
|
99
|
-
childrenRef.current.traverse(obj => {
|
|
100
|
-
if (!obj.geometry) return;
|
|
101
|
-
if (!obj.geometry.boundingBox) obj.geometry.computeBoundingBox();
|
|
102
|
-
mL.copy(obj.matrixWorld).premultiply(mPInv);
|
|
103
|
-
bbObj.copy(obj.geometry.boundingBox);
|
|
104
|
-
bbObj.applyMatrix4(mL);
|
|
105
|
-
bb.union(bbObj);
|
|
106
|
-
});
|
|
107
|
-
vCenter.copy(bb.max).add(bb.min).multiplyScalar(0.5);
|
|
108
|
-
vSize.copy(bb.max).sub(bb.min).multiplyScalar(0.5);
|
|
109
|
-
vAnchorOffset.copy(vSize).multiply(new THREE.Vector3(...anchor)).add(vCenter);
|
|
110
|
-
vPosition.set(...offset).add(vAnchorOffset);
|
|
111
|
-
gizmoRef.current.position.copy(vPosition);
|
|
112
|
-
invalidate();
|
|
113
|
-
});
|
|
114
|
-
const config = React.useMemo(() => ({
|
|
115
|
-
onDragStart: props => {
|
|
116
|
-
mL0.copy(ref.current.matrix);
|
|
117
|
-
mW0.copy(ref.current.matrixWorld);
|
|
118
|
-
onDragStart && onDragStart(props);
|
|
119
|
-
invalidate();
|
|
120
|
-
},
|
|
121
|
-
onDrag: mdW => {
|
|
122
|
-
mP.copy(parentRef.current.matrixWorld);
|
|
123
|
-
mPInv.copy(mP).invert(); // After applying the delta
|
|
124
|
-
|
|
125
|
-
mW.copy(mW0).premultiply(mdW);
|
|
126
|
-
mL.copy(mW).premultiply(mPInv);
|
|
127
|
-
mL0Inv.copy(mL0).invert();
|
|
128
|
-
mdL.copy(mL).multiply(mL0Inv);
|
|
129
|
-
if (autoTransform) ref.current.matrix.copy(mL);
|
|
130
|
-
onDrag && onDrag(mL, mdL, mW, mdW);
|
|
131
|
-
invalidate();
|
|
132
|
-
},
|
|
133
|
-
onDragEnd: () => {
|
|
134
|
-
if (onDragEnd) onDragEnd();
|
|
135
|
-
invalidate();
|
|
136
|
-
},
|
|
137
|
-
translation,
|
|
138
|
-
translationLimits,
|
|
139
|
-
rotationLimits,
|
|
140
|
-
axisColors,
|
|
141
|
-
hoveredColor,
|
|
142
|
-
opacity,
|
|
143
|
-
scale,
|
|
144
|
-
lineWidth,
|
|
145
|
-
fixed,
|
|
146
|
-
depthTest,
|
|
147
|
-
userData,
|
|
148
|
-
annotations,
|
|
149
|
-
annotationsClass
|
|
150
|
-
}), [onDragStart, onDrag, onDragEnd, translation, translationLimits, rotationLimits, depthTest, scale, lineWidth, fixed, ...axisColors, hoveredColor, opacity, userData, autoTransform, annotations, annotationsClass]);
|
|
151
|
-
const vec = new THREE.Vector3();
|
|
152
|
-
useFrame(state => {
|
|
153
|
-
if (fixed) {
|
|
154
|
-
const sf = calculateScaleFactor(gizmoRef.current.getWorldPosition(vec), scale, state.camera, state.size);
|
|
155
|
-
|
|
156
|
-
if (gizmoRef.current) {
|
|
157
|
-
var _gizmoRef$current, _gizmoRef$current2, _gizmoRef$current3;
|
|
158
|
-
|
|
159
|
-
if (((_gizmoRef$current = gizmoRef.current) == null ? void 0 : _gizmoRef$current.scale.x) !== sf || ((_gizmoRef$current2 = gizmoRef.current) == null ? void 0 : _gizmoRef$current2.scale.y) !== sf || ((_gizmoRef$current3 = gizmoRef.current) == null ? void 0 : _gizmoRef$current3.scale.z) !== sf) {
|
|
160
|
-
gizmoRef.current.scale.setScalar(sf);
|
|
161
|
-
state.invalidate();
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
React.useImperativeHandle(fRef, () => ref.current, []);
|
|
167
|
-
React.useLayoutEffect(() => {
|
|
168
|
-
// If the matrix is a real matrix4 it means that the user wants to control the gizmo
|
|
169
|
-
// In that case it should just be set, as a bare prop update would merely copy it
|
|
170
|
-
if (matrix && matrix instanceof THREE.Matrix4) ref.current.matrix = matrix;
|
|
171
|
-
}, [matrix]);
|
|
172
|
-
return /*#__PURE__*/React.createElement(context.Provider, {
|
|
173
|
-
value: config
|
|
174
|
-
}, /*#__PURE__*/React.createElement("group", {
|
|
175
|
-
ref: parentRef
|
|
176
|
-
}, /*#__PURE__*/React.createElement("group", _extends({
|
|
177
|
-
ref: ref,
|
|
178
|
-
matrix: matrix,
|
|
179
|
-
matrixAutoUpdate: false
|
|
180
|
-
}, props), /*#__PURE__*/React.createElement("group", {
|
|
181
|
-
visible: visible,
|
|
182
|
-
ref: gizmoRef,
|
|
183
|
-
position: offset,
|
|
184
|
-
rotation: rotation
|
|
185
|
-
}, !disableAxes && activeAxes[0] && /*#__PURE__*/React.createElement(AxisArrow, {
|
|
186
|
-
axis: 0,
|
|
187
|
-
direction: xDir
|
|
188
|
-
}), !disableAxes && activeAxes[1] && /*#__PURE__*/React.createElement(AxisArrow, {
|
|
189
|
-
axis: 1,
|
|
190
|
-
direction: yDir
|
|
191
|
-
}), !disableAxes && activeAxes[2] && /*#__PURE__*/React.createElement(AxisArrow, {
|
|
192
|
-
axis: 2,
|
|
193
|
-
direction: zDir
|
|
194
|
-
}), !disableSliders && activeAxes[0] && activeAxes[1] && /*#__PURE__*/React.createElement(PlaneSlider, {
|
|
195
|
-
axis: 2,
|
|
196
|
-
dir1: xDir,
|
|
197
|
-
dir2: yDir
|
|
198
|
-
}), !disableSliders && activeAxes[0] && activeAxes[2] && /*#__PURE__*/React.createElement(PlaneSlider, {
|
|
199
|
-
axis: 1,
|
|
200
|
-
dir1: zDir,
|
|
201
|
-
dir2: xDir
|
|
202
|
-
}), !disableSliders && activeAxes[2] && activeAxes[1] && /*#__PURE__*/React.createElement(PlaneSlider, {
|
|
203
|
-
axis: 0,
|
|
204
|
-
dir1: yDir,
|
|
205
|
-
dir2: zDir
|
|
206
|
-
}), !disableRotations && activeAxes[0] && activeAxes[1] && /*#__PURE__*/React.createElement(AxisRotator, {
|
|
207
|
-
axis: 2,
|
|
208
|
-
dir1: xDir,
|
|
209
|
-
dir2: yDir
|
|
210
|
-
}), !disableRotations && activeAxes[0] && activeAxes[2] && /*#__PURE__*/React.createElement(AxisRotator, {
|
|
211
|
-
axis: 1,
|
|
212
|
-
dir1: zDir,
|
|
213
|
-
dir2: xDir
|
|
214
|
-
}), !disableRotations && activeAxes[2] && activeAxes[1] && /*#__PURE__*/React.createElement(AxisRotator, {
|
|
215
|
-
axis: 0,
|
|
216
|
-
dir1: yDir,
|
|
217
|
-
dir2: zDir
|
|
218
|
-
})), /*#__PURE__*/React.createElement("group", {
|
|
219
|
-
ref: childrenRef
|
|
220
|
-
}, children))));
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
export { PivotControls, calculateScaleFactor };
|
package/src/web/useCursor.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
function useCursor(hovered, onPointerOver = 'pointer', onPointerOut = 'auto') {
|
|
4
|
-
React.useEffect(() => {
|
|
5
|
-
if (hovered) {
|
|
6
|
-
document.body.style.cursor = onPointerOver;
|
|
7
|
-
return () => void (document.body.style.cursor = onPointerOut);
|
|
8
|
-
}
|
|
9
|
-
}, [hovered]);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export { useCursor };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|