@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.
Files changed (189) hide show
  1. package/core/CatmullRomLine.js +0 -2
  2. package/core/Cloud.js +0 -3
  3. package/core/CubeCamera.js +0 -1
  4. package/core/CubicBezierLine.js +0 -2
  5. package/core/Environment.js +0 -1
  6. package/core/Example.js +0 -6
  7. package/core/FaceControls.cjs.js +1 -1
  8. package/core/FaceControls.js +0 -2
  9. package/core/FaceLandmarker.cjs.js +1 -1
  10. package/core/FaceLandmarker.js +3 -4
  11. package/core/Facemesh.js +0 -2
  12. package/core/GizmoHelper.js +0 -3
  13. package/core/GizmoViewcube.js +0 -4
  14. package/core/GizmoViewport.js +0 -4
  15. package/core/Gltf.js +0 -4
  16. package/core/MeshDiscardMaterial.js +0 -2
  17. package/core/MeshDistortMaterial.js +1 -2
  18. package/core/MeshReflectorMaterial.js +0 -1
  19. package/core/MeshRefractionMaterial.js +0 -2
  20. package/core/MeshTransmissionMaterial.js +0 -1
  21. package/core/OrthographicCamera.js +0 -1
  22. package/core/PerspectiveCamera.js +0 -1
  23. package/core/QuadraticBezierLine.js +0 -2
  24. package/core/Reflector.js +0 -1
  25. package/core/SpotLight.js +1 -2
  26. package/core/Stage.js +0 -7
  27. package/core/Text3D.js +0 -1
  28. package/core/Wireframe.js +0 -1
  29. package/core/index.cjs.js +1 -1
  30. package/core/index.js +1 -0
  31. package/core/useKTX2.js +0 -1
  32. package/core/useMatcapTexture.js +0 -2
  33. package/core/useNormalTexture.js +0 -1
  34. package/index.cjs.js +1 -1
  35. package/materials/DiscardMaterial.js +0 -1
  36. package/materials/MeshRefractionMaterial.js +1 -1
  37. package/native/index.cjs.js +1 -1
  38. package/native/index.js +1 -0
  39. package/package.json +2 -2
  40. package/web/Loader.js +0 -2
  41. package/web/index.cjs.js +1 -1
  42. package/web/index.js +1 -0
  43. package/web/pivotControls/AxisArrow.js +0 -3
  44. package/web/pivotControls/AxisRotator.js +0 -3
  45. package/web/pivotControls/PlaneSlider.js +0 -3
  46. package/web/pivotControls/index.js +0 -5
  47. package/src/core/AccumulativeShadows.js +0 -311
  48. package/src/core/AdaptiveDpr.js +0 -28
  49. package/src/core/AdaptiveEvents.js +0 -20
  50. package/src/core/ArcballControls.js +0 -67
  51. package/src/core/AsciiRenderer.js +0 -60
  52. package/src/core/BBAnchor.js +0 -37
  53. package/src/core/Backdrop.js +0 -36
  54. package/src/core/BakeShadows.js +0 -16
  55. package/src/core/Billboard.js +0 -41
  56. package/src/core/Bounds.js +0 -245
  57. package/src/core/CameraControls.js +0 -92
  58. package/src/core/CameraShake.js +0 -61
  59. package/src/core/CatmullRomLine.js +0 -44
  60. package/src/core/Caustics.js +0 -375
  61. package/src/core/Center.js +0 -66
  62. package/src/core/Clone.js +0 -102
  63. package/src/core/Cloud.js +0 -59
  64. package/src/core/ComputedAttribute.js +0 -34
  65. package/src/core/ContactShadows.js +0 -114
  66. package/src/core/CubeCamera.js +0 -43
  67. package/src/core/CubicBezierLine.js +0 -28
  68. package/src/core/CurveModifier.js +0 -34
  69. package/src/core/Decal.js +0 -92
  70. package/src/core/Detailed.js +0 -34
  71. package/src/core/DeviceOrientationControls.js +0 -51
  72. package/src/core/Edges.js +0 -36
  73. package/src/core/Effects.js +0 -93
  74. package/src/core/Environment.js +0 -132
  75. package/src/core/Example.js +0 -42
  76. package/src/core/FaceControls.js +0 -315
  77. package/src/core/FaceLandmarker.js +0 -43
  78. package/src/core/Facemesh.js +0 -4545
  79. package/src/core/FirstPersonControls.js +0 -38
  80. package/src/core/Float.js +0 -36
  81. package/src/core/FlyControls.js +0 -55
  82. package/src/core/GizmoHelper.js +0 -111
  83. package/src/core/GizmoViewcube.js +0 -152
  84. package/src/core/GizmoViewport.js +0 -152
  85. package/src/core/Gltf.js +0 -20
  86. package/src/core/GradientTexture.js +0 -33
  87. package/src/core/Grid.js +0 -112
  88. package/src/core/Hud.js +0 -58
  89. package/src/core/Image.js +0 -119
  90. package/src/core/Instances.js +0 -215
  91. package/src/core/Lightformer.js +0 -51
  92. package/src/core/Line.js +0 -68
  93. package/src/core/MapControls.js +0 -64
  94. package/src/core/MarchingCubes.js +0 -76
  95. package/src/core/Mask.js +0 -42
  96. package/src/core/MeshDiscardMaterial.js +0 -15
  97. package/src/core/MeshDistortMaterial.js +0 -79
  98. package/src/core/MeshPortalMaterial.js +0 -381
  99. package/src/core/MeshReflectorMaterial.js +0 -182
  100. package/src/core/MeshRefractionMaterial.js +0 -79
  101. package/src/core/MeshTransmissionMaterial.js +0 -395
  102. package/src/core/MeshWobbleMaterial.js +0 -65
  103. package/src/core/OrbitControls.js +0 -82
  104. package/src/core/OrthographicCamera.js +0 -77
  105. package/src/core/PerformanceMonitor.js +0 -121
  106. package/src/core/PerspectiveCamera.js +0 -73
  107. package/src/core/PointMaterial.js +0 -36
  108. package/src/core/PointerLockControls.js +0 -90
  109. package/src/core/Points.js +0 -227
  110. package/src/core/PositionalAudio.js +0 -51
  111. package/src/core/Preload.js +0 -45
  112. package/src/core/QuadraticBezierLine.js +0 -44
  113. package/src/core/Reflector.js +0 -182
  114. package/src/core/RenderTexture.js +0 -96
  115. package/src/core/Resize.js +0 -39
  116. package/src/core/RoundedBox.js +0 -52
  117. package/src/core/Sampler.js +0 -85
  118. package/src/core/ScreenQuad.js +0 -24
  119. package/src/core/ScreenSpace.js +0 -25
  120. package/src/core/Segments.js +0 -102
  121. package/src/core/Shadow.js +0 -42
  122. package/src/core/Sky.js +0 -39
  123. package/src/core/Sparkles.js +0 -139
  124. package/src/core/SpotLight.js +0 -231
  125. package/src/core/SpriteAnimator.js +0 -342
  126. package/src/core/Stage.js +0 -135
  127. package/src/core/Stars.js +0 -108
  128. package/src/core/Stats.js +0 -30
  129. package/src/core/Svg.js +0 -59
  130. package/src/core/Text.js +0 -58
  131. package/src/core/Text3D.js +0 -76
  132. package/src/core/TrackballControls.js +0 -72
  133. package/src/core/Trail.js +0 -161
  134. package/src/core/TransformControls.js +0 -106
  135. package/src/core/Wireframe.js +0 -185
  136. package/src/core/meshBounds.js +0 -38
  137. package/src/core/shaderMaterial.js +0 -39
  138. package/src/core/shapes.js +0 -68
  139. package/src/core/softShadows.js +0 -161
  140. package/src/core/useAnimations.js +0 -56
  141. package/src/core/useAspect.js +0 -10
  142. package/src/core/useBVH.js +0 -90
  143. package/src/core/useBoxProjectedEnv.js +0 -98
  144. package/src/core/useCamera.js +0 -27
  145. package/src/core/useContextBridge.js +0 -21
  146. package/src/core/useCubeCamera.js +0 -49
  147. package/src/core/useCubeTexture.js +0 -18
  148. package/src/core/useDepthBuffer.js +0 -38
  149. package/src/core/useDetectGPU.js +0 -6
  150. package/src/core/useEnvironment.js +0 -48
  151. package/src/core/useFBO.js +0 -53
  152. package/src/core/useFBX.js +0 -12
  153. package/src/core/useFont.js +0 -20
  154. package/src/core/useGLTF.js +0 -37
  155. package/src/core/useHelper.js +0 -31
  156. package/src/core/useIntersect.js +0 -39
  157. package/src/core/useKTX2.js +0 -38
  158. package/src/core/useMatcapTexture.js +0 -45
  159. package/src/core/useNormalTexture.js +0 -30
  160. package/src/core/useProgress.js +0 -50
  161. package/src/core/useTexture.js +0 -35
  162. package/src/core/useTrailTexture.js +0 -164
  163. package/src/core/useVideoTexture.js +0 -41
  164. package/src/helpers/environment-assets.js +0 -14
  165. package/src/helpers/useEffectfulState.js +0 -18
  166. package/src/materials/BlurPass.js +0 -75
  167. package/src/materials/ConvolutionMaterial.js +0 -99
  168. package/src/materials/DiscardMaterial.js +0 -5
  169. package/src/materials/MeshReflectorMaterial.js +0 -290
  170. package/src/materials/MeshRefractionMaterial.js +0 -171
  171. package/src/materials/SpotLightMaterial.js +0 -111
  172. package/src/materials/WireframeMaterial.js +0 -235
  173. package/src/web/CycleRaycast.js +0 -97
  174. package/src/web/Html.js +0 -417
  175. package/src/web/KeyboardControls.js +0 -101
  176. package/src/web/Loader.js +0 -98
  177. package/src/web/PresentationControls.js +0 -86
  178. package/src/web/ScrollControls.js +0 -246
  179. package/src/web/Select.js +0 -175
  180. package/src/web/View.js +0 -206
  181. package/src/web/pivotControls/AxisArrow.js +0 -202
  182. package/src/web/pivotControls/AxisRotator.js +0 -235
  183. package/src/web/pivotControls/PlaneSlider.js +0 -211
  184. package/src/web/pivotControls/context.js +0 -5
  185. package/src/web/pivotControls/index.js +0 -223
  186. package/src/web/useCursor.js +0 -12
  187. /package/{src/helpers → helpers}/glsl/DefaultSpotlightShadowShadows.glsl.js +0 -0
  188. /package/{src/helpers → helpers}/glsl/distort.vert.glsl.js +0 -0
  189. /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 };
@@ -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