@react-three/drei 9.83.9 → 9.84.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.
Files changed (255) hide show
  1. package/README.md +116 -5
  2. package/core/AccumulativeShadows.d.ts +3 -3
  3. package/core/AccumulativeShadows.js +30 -36
  4. package/core/AdaptiveDpr.js +4 -4
  5. package/core/ArcballControls.d.ts +1 -1
  6. package/core/ArcballControls.js +0 -1
  7. package/core/AsciiRenderer.d.ts +3 -3
  8. package/core/AsciiRenderer.js +12 -6
  9. package/core/BBAnchor.cjs.js +1 -1
  10. package/core/BBAnchor.d.ts +2 -2
  11. package/core/BBAnchor.js +5 -5
  12. package/core/Backdrop.d.ts +2 -2
  13. package/core/Backdrop.js +0 -3
  14. package/core/Billboard.d.ts +1 -1
  15. package/core/Billboard.js +6 -3
  16. package/core/Bounds.d.ts +5 -5
  17. package/core/Bounds.js +5 -32
  18. package/core/CameraControls.d.ts +2 -2
  19. package/core/CameraControls.js +0 -3
  20. package/core/CameraShake.js +0 -4
  21. package/core/CatmullRomLine.d.ts +1 -1
  22. package/core/CatmullRomLine.js +0 -2
  23. package/core/Caustics.d.ts +1 -1
  24. package/core/Caustics.js +31 -32
  25. package/core/Center.d.ts +2 -2
  26. package/core/Center.js +2 -1
  27. package/core/Clone.d.ts +1 -1
  28. package/core/Clone.js +10 -13
  29. package/core/Cloud.cjs.js +1 -1
  30. package/core/Cloud.d.ts +2 -2
  31. package/core/Cloud.js +1 -2
  32. package/core/ComputedAttribute.d.ts +2 -2
  33. package/core/ComputedAttribute.js +0 -1
  34. package/core/ContactShadows.d.ts +1 -1
  35. package/core/ContactShadows.js +6 -7
  36. package/core/CubeCamera.cjs.js +1 -1
  37. package/core/CubeCamera.d.ts +2 -2
  38. package/core/CubeCamera.js +1 -1
  39. package/core/CubicBezierLine.d.ts +1 -1
  40. package/core/CurveModifier.d.ts +1 -1
  41. package/core/CurveModifier.js +2 -4
  42. package/core/Decal.d.ts +1 -1
  43. package/core/Decal.js +8 -15
  44. package/core/Detailed.d.ts +1 -1
  45. package/core/Detailed.js +0 -1
  46. package/core/DeviceOrientationControls.d.ts +1 -1
  47. package/core/DeviceOrientationControls.js +3 -4
  48. package/core/Edges.d.ts +1 -1
  49. package/core/Edges.js +0 -2
  50. package/core/Effects.d.ts +1 -1
  51. package/core/Effects.js +5 -7
  52. package/core/Environment.d.ts +3 -3
  53. package/core/Environment.js +6 -12
  54. package/core/Example.d.ts +3 -3
  55. package/core/Example.js +2 -1
  56. package/core/FaceControls.cjs.js +1 -1
  57. package/core/FaceControls.d.ts +5 -5
  58. package/core/FaceControls.js +42 -39
  59. package/core/FaceLandmarker.d.ts +3 -2
  60. package/core/FaceLandmarker.js +1 -1
  61. package/core/Facemesh.d.ts +6 -6
  62. package/core/Facemesh.js +47 -53
  63. package/core/FirstPersonControls.d.ts +1 -1
  64. package/core/Float.d.ts +1 -1
  65. package/core/Float.js +0 -1
  66. package/core/FlyControls.d.ts +1 -1
  67. package/core/FlyControls.js +1 -2
  68. package/core/GizmoHelper.cjs.js +1 -1
  69. package/core/GizmoHelper.d.ts +2 -2
  70. package/core/GizmoHelper.js +18 -19
  71. package/core/GizmoViewcube.d.ts +3 -3
  72. package/core/GizmoViewcube.js +0 -14
  73. package/core/GizmoViewport.d.ts +3 -3
  74. package/core/GizmoViewport.js +0 -7
  75. package/core/Gltf.d.ts +1 -1
  76. package/core/GradientTexture.d.ts +3 -3
  77. package/core/GradientTexture.js +2 -5
  78. package/core/Grid.d.ts +2 -2
  79. package/core/Grid.js +2 -6
  80. package/core/Hud.d.ts +2 -2
  81. package/core/Hud.js +6 -9
  82. package/core/Image.d.ts +2 -2
  83. package/core/Image.js +4 -6
  84. package/core/Instances.d.ts +6 -6
  85. package/core/Instances.js +20 -35
  86. package/core/Lightformer.d.ts +1 -1
  87. package/core/Lightformer.js +4 -2
  88. package/core/Line.d.ts +1 -1
  89. package/core/Line.js +0 -3
  90. package/core/MapControls.d.ts +1 -1
  91. package/core/MapControls.js +0 -2
  92. package/core/MarchingCubes.d.ts +3 -3
  93. package/core/Mask.d.ts +1 -1
  94. package/core/MeshDistortMaterial.d.ts +2 -2
  95. package/core/MeshDistortMaterial.js +0 -9
  96. package/core/MeshPortalMaterial.d.ts +4 -4
  97. package/core/MeshPortalMaterial.js +22 -61
  98. package/core/MeshReflectorMaterial.d.ts +1 -1
  99. package/core/MeshReflectorMaterial.js +12 -14
  100. package/core/MeshRefractionMaterial.cjs.js +1 -1
  101. package/core/MeshRefractionMaterial.d.ts +3 -3
  102. package/core/MeshRefractionMaterial.js +9 -14
  103. package/core/MeshTransmissionMaterial.d.ts +2 -2
  104. package/core/MeshTransmissionMaterial.js +32 -33
  105. package/core/MeshWobbleMaterial.d.ts +2 -2
  106. package/core/MeshWobbleMaterial.js +0 -7
  107. package/core/MotionPathControls.cjs.js +1 -0
  108. package/core/MotionPathControls.d.ts +15 -0
  109. package/core/MotionPathControls.js +113 -0
  110. package/core/OrbitControls.d.ts +2 -2
  111. package/core/OrbitControls.js +0 -4
  112. package/core/OrthographicCamera.d.ts +1 -1
  113. package/core/OrthographicCamera.js +2 -3
  114. package/core/Outlines.cjs.js +1 -1
  115. package/core/Outlines.d.ts +3 -3
  116. package/core/Outlines.js +2 -7
  117. package/core/PerformanceMonitor.d.ts +4 -4
  118. package/core/PerformanceMonitor.js +8 -12
  119. package/core/PerspectiveCamera.d.ts +1 -1
  120. package/core/PerspectiveCamera.js +2 -3
  121. package/core/PointMaterial.d.ts +1 -1
  122. package/core/PointMaterial.js +0 -2
  123. package/core/PointerLockControls.d.ts +1 -1
  124. package/core/PointerLockControls.js +4 -6
  125. package/core/Points.d.ts +2 -2
  126. package/core/Points.js +6 -23
  127. package/core/PositionalAudio.d.ts +1 -1
  128. package/core/PositionalAudio.js +0 -5
  129. package/core/Preload.d.ts +1 -1
  130. package/core/Preload.js +8 -9
  131. package/core/QuadraticBezierLine.d.ts +2 -2
  132. package/core/QuadraticBezierLine.js +0 -2
  133. package/core/Reflector.d.ts +1 -1
  134. package/core/Reflector.js +11 -12
  135. package/core/RenderTexture.d.ts +1 -1
  136. package/core/RenderTexture.js +9 -11
  137. package/core/Resize.d.ts +2 -2
  138. package/core/RoundedBox.cjs.js +1 -1
  139. package/core/RoundedBox.d.ts +1 -1
  140. package/core/RoundedBox.js +1 -3
  141. package/core/Sampler.d.ts +5 -5
  142. package/core/Sampler.js +0 -10
  143. package/core/ScreenQuad.d.ts +1 -1
  144. package/core/ScreenQuad.js +0 -1
  145. package/core/ScreenSpace.d.ts +1 -1
  146. package/core/Segments.d.ts +2 -2
  147. package/core/Segments.js +0 -6
  148. package/core/Shadow.d.ts +1 -1
  149. package/core/Sky.d.ts +1 -1
  150. package/core/Sparkles.js +0 -10
  151. package/core/SpotLight.d.ts +2 -2
  152. package/core/SpotLight.js +3 -10
  153. package/core/SpriteAnimator.d.ts +1 -1
  154. package/core/SpriteAnimator.js +16 -34
  155. package/core/Stage.d.ts +4 -4
  156. package/core/Stage.js +2 -4
  157. package/core/Stars.d.ts +1 -1
  158. package/core/Stars.js +2 -11
  159. package/core/Stats.d.ts +1 -1
  160. package/core/Stats.js +2 -2
  161. package/core/StatsGl.d.ts +1 -1
  162. package/core/StatsGl.js +4 -3
  163. package/core/Svg.js +0 -2
  164. package/core/Text.d.ts +1 -1
  165. package/core/Text3D.d.ts +1 -1
  166. package/core/Text3D.js +1 -3
  167. package/core/TrackballControls.d.ts +1 -1
  168. package/core/TrackballControls.js +0 -1
  169. package/core/Trail.d.ts +3 -3
  170. package/core/Trail.js +6 -17
  171. package/core/TransformControls.d.ts +1 -1
  172. package/core/TransformControls.js +3 -9
  173. package/core/Wireframe.d.ts +1 -1
  174. package/core/Wireframe.js +0 -28
  175. package/core/index.cjs.js +1 -1
  176. package/core/index.d.ts +1 -0
  177. package/core/index.js +1 -0
  178. package/core/meshBounds.js +4 -14
  179. package/core/shaderMaterial.js +10 -9
  180. package/core/shapes.d.ts +2 -2
  181. package/core/shapes.js +3 -6
  182. package/core/softShadows.d.ts +1 -1
  183. package/core/softShadows.js +1 -4
  184. package/core/useAnimations.d.ts +1 -1
  185. package/core/useAnimations.js +2 -4
  186. package/core/useBVH.d.ts +1 -1
  187. package/core/useBVH.js +3 -4
  188. package/core/useBoxProjectedEnv.js +15 -22
  189. package/core/useCamera.js +0 -1
  190. package/core/useContextBridge.js +1 -2
  191. package/core/useCubeCamera.d.ts +1 -1
  192. package/core/useCubeTexture.d.ts +1 -1
  193. package/core/useCubeTexture.js +4 -3
  194. package/core/useEnvironment.cjs.js +1 -1
  195. package/core/useEnvironment.d.ts +2 -2
  196. package/core/useEnvironment.js +9 -11
  197. package/core/useFBO.d.ts +1 -1
  198. package/core/useFBO.js +3 -12
  199. package/core/useFBX.js +0 -2
  200. package/core/useFont.d.ts +2 -2
  201. package/core/useFont.js +0 -4
  202. package/core/useGLTF.d.ts +2 -2
  203. package/core/useGLTF.js +0 -8
  204. package/core/useHelper.d.ts +3 -3
  205. package/core/useHelper.js +2 -5
  206. package/core/useIntersect.js +5 -8
  207. package/core/useKTX2.js +3 -5
  208. package/core/useMatcapTexture.js +0 -6
  209. package/core/useNormalTexture.d.ts +1 -1
  210. package/core/useProgress.d.ts +1 -1
  211. package/core/useProgress.js +0 -5
  212. package/core/useTexture.js +4 -6
  213. package/core/useTrailTexture.d.ts +1 -1
  214. package/core/useTrailTexture.js +10 -21
  215. package/helpers/environment-assets.d.ts +1 -1
  216. package/helpers/ts-utils.d.ts +2 -2
  217. package/helpers/useEffectfulState.d.ts +1 -1
  218. package/helpers/useEffectfulState.js +0 -1
  219. package/index.cjs.js +1 -1
  220. package/index.js +1 -0
  221. package/materials/BlurPass.js +2 -5
  222. package/materials/ConvolutionMaterial.js +0 -3
  223. package/materials/MeshReflectorMaterial.d.ts +1 -1
  224. package/materials/MeshReflectorMaterial.js +0 -34
  225. package/materials/MeshRefractionMaterial.js +2 -6
  226. package/materials/SpotLightMaterial.js +2 -7
  227. package/materials/WireframeMaterial.js +7 -25
  228. package/native/index.cjs.js +1 -1
  229. package/native/index.js +1 -0
  230. package/package.json +2 -2
  231. package/react-three-drei-0.0.0-semantic-release.tgz +0 -0
  232. package/web/CycleRaycast.d.ts +1 -1
  233. package/web/CycleRaycast.js +20 -24
  234. package/web/Html.d.ts +2 -2
  235. package/web/Html.js +6 -50
  236. package/web/KeyboardControls.d.ts +10 -10
  237. package/web/KeyboardControls.js +9 -6
  238. package/web/Loader.d.ts +2 -2
  239. package/web/Loader.js +8 -5
  240. package/web/PresentationControls.d.ts +2 -2
  241. package/web/PresentationControls.js +2 -1
  242. package/web/ScrollControls.d.ts +4 -4
  243. package/web/ScrollControls.js +5 -16
  244. package/web/Select.d.ts +3 -3
  245. package/web/Select.js +6 -17
  246. package/web/View.d.ts +5 -5
  247. package/web/View.js +7 -20
  248. package/web/index.cjs.js +1 -1
  249. package/web/index.js +1 -0
  250. package/web/pivotControls/AxisArrow.js +6 -15
  251. package/web/pivotControls/AxisRotator.js +8 -23
  252. package/web/pivotControls/PlaneSlider.js +6 -16
  253. package/web/pivotControls/context.d.ts +2 -2
  254. package/web/pivotControls/index.d.ts +1 -1
  255. package/web/pivotControls/index.js +2 -9
@@ -1,9 +1,9 @@
1
1
  import { Vector3 } from 'three';
2
- declare type GizmoHelperContext = {
2
+ type GizmoHelperContext = {
3
3
  tweenCamera: (direction: Vector3) => void;
4
4
  };
5
5
  export declare const useGizmoContext: () => GizmoHelperContext;
6
- export declare type GizmoHelperProps = JSX.IntrinsicElements['group'] & {
6
+ export type GizmoHelperProps = JSX.IntrinsicElements['group'] & {
7
7
  alignment?: 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left' | 'bottom-center' | 'center-right' | 'center-left' | 'center-center' | 'top-center';
8
8
  margin?: [number, number];
9
9
  renderPriority?: number;
@@ -9,17 +9,14 @@ const useGizmoContext = () => {
9
9
  return React.useContext(Context);
10
10
  };
11
11
  const turnRate = 2 * Math.PI; // turn rate in angles per second
12
-
13
12
  const dummy = new Object3D();
14
13
  const matrix = new Matrix4();
15
14
  const [q1, q2] = [new Quaternion(), new Quaternion()];
16
15
  const target = new Vector3();
17
16
  const targetPosition = new Vector3();
18
-
19
17
  const isOrbitControls = controls => {
20
18
  return 'minPolarAngle' in controls;
21
19
  };
22
-
23
20
  const GizmoHelper = ({
24
21
  alignment = 'bottom-right',
25
22
  margin = [80, 80],
@@ -29,11 +26,11 @@ const GizmoHelper = ({
29
26
  children
30
27
  }) => {
31
28
  const size = useThree(state => state.size);
32
- const mainCamera = useThree(state => state.camera); // @ts-ignore
33
-
29
+ const mainCamera = useThree(state => state.camera);
30
+ // @ts-ignore
34
31
  const defaultControls = useThree(state => state.controls);
35
32
  const invalidate = useThree(state => state.invalidate);
36
- const gizmoRef = React.useRef();
33
+ const gizmoRef = React.useRef(null);
37
34
  const virtualCam = React.useRef(null);
38
35
  const animating = React.useRef(false);
39
36
  const radius = React.useRef(0);
@@ -45,10 +42,12 @@ const GizmoHelper = ({
45
42
  const tweenCamera = React.useCallback(direction => {
46
43
  animating.current = true;
47
44
  if (defaultControls || onTarget) focusPoint.current = (defaultControls == null ? void 0 : defaultControls.target) || (onTarget == null ? void 0 : onTarget());
48
- radius.current = mainCamera.position.distanceTo(target); // Rotate from current camera orientation
45
+ radius.current = mainCamera.position.distanceTo(target);
49
46
 
50
- q1.copy(mainCamera.quaternion); // To new current camera orientation
47
+ // Rotate from current camera orientation
48
+ q1.copy(mainCamera.quaternion);
51
49
 
50
+ // To new current camera orientation
52
51
  targetPosition.copy(direction).multiplyScalar(radius.current).add(target);
53
52
  dummy.lookAt(targetPosition);
54
53
  dummy.up.copy(mainCamera.up);
@@ -58,39 +57,39 @@ const GizmoHelper = ({
58
57
  useFrame((_, delta) => {
59
58
  if (virtualCam.current && gizmoRef.current) {
60
59
  var _gizmoRef$current;
61
-
62
60
  // Animate step
63
61
  if (animating.current) {
64
62
  if (q1.angleTo(q2) < 0.01) {
65
- animating.current = false; // Orbit controls uses UP vector as the orbit axes,
63
+ animating.current = false;
64
+ // Orbit controls uses UP vector as the orbit axes,
66
65
  // so we need to reset it after the animation is done
67
66
  // moving it around for the controls to work correctly
68
-
69
67
  if (isOrbitControls(defaultControls)) {
70
68
  mainCamera.up.copy(defaultUp.current);
71
69
  }
72
70
  } else {
73
- const step = delta * turnRate; // animate position by doing a slerp and then scaling the position on the unit sphere
74
-
75
- q1.rotateTowards(q2, step); // animate orientation
76
-
71
+ const step = delta * turnRate;
72
+ // animate position by doing a slerp and then scaling the position on the unit sphere
73
+ q1.rotateTowards(q2, step);
74
+ // animate orientation
77
75
  mainCamera.position.set(0, 0, 1).applyQuaternion(q1).multiplyScalar(radius.current).add(focusPoint.current);
78
76
  mainCamera.up.set(0, 1, 0).applyQuaternion(q1).normalize();
79
77
  mainCamera.quaternion.copy(q1);
80
78
  if (onUpdate) onUpdate();else if (defaultControls) defaultControls.update();
81
79
  invalidate();
82
80
  }
83
- } // Sync Gizmo with main camera orientation
84
-
81
+ }
85
82
 
83
+ // Sync Gizmo with main camera orientation
86
84
  matrix.copy(mainCamera.matrix).invert();
87
- (_gizmoRef$current = gizmoRef.current) == null ? void 0 : _gizmoRef$current.quaternion.setFromRotationMatrix(matrix);
85
+ (_gizmoRef$current = gizmoRef.current) == null || _gizmoRef$current.quaternion.setFromRotationMatrix(matrix);
88
86
  }
89
87
  });
90
88
  const gizmoHelperContext = React.useMemo(() => ({
91
89
  tweenCamera
92
- }), [tweenCamera]); // Position gizmo component within scene
90
+ }), [tweenCamera]);
93
91
 
92
+ // Position gizmo component within scene
94
93
  const [marginX, marginY] = margin;
95
94
  const x = alignment.endsWith('-center') ? 0 : alignment.endsWith('-left') ? -size.width / 2 + marginX : size.width / 2 - marginX;
96
95
  const y = alignment.startsWith('center-') ? 0 : alignment.startsWith('top-') ? size.height / 2 - marginY : -size.height / 2 + marginY;
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  import { ThreeEvent } from '@react-three/fiber';
3
- declare type GenericProps = {
3
+ type GenericProps = {
4
4
  font?: string;
5
5
  opacity?: number;
6
6
  color?: string;
@@ -10,5 +10,5 @@ declare type GenericProps = {
10
10
  onClick?: (e: ThreeEvent<MouseEvent>) => null;
11
11
  faces?: string[];
12
12
  };
13
- export declare const GizmoViewcube: (props: GenericProps) => JSX.Element;
13
+ export declare const GizmoViewcube: (props: GenericProps) => React.JSX.Element;
14
14
  export {};
@@ -11,14 +11,11 @@ const colors = {
11
11
  stroke: 'black'
12
12
  };
13
13
  const defaultFaces = ['Right', 'Left', 'Top', 'Bottom', 'Front', 'Back'];
14
-
15
14
  const makePositionVector = xyz => new Vector3(...xyz).multiplyScalar(0.38);
16
-
17
15
  const corners = [[1, 1, 1], [1, 1, -1], [1, -1, 1], [1, -1, -1], [-1, 1, 1], [-1, 1, -1], [-1, -1, 1], [-1, -1, -1]].map(makePositionVector);
18
16
  const cornerDimensions = [0.25, 0.25, 0.25];
19
17
  const edges = [[1, 1, 0], [1, 0, 1], [1, 0, -1], [1, -1, 0], [0, 1, 1], [0, 1, -1], [0, -1, 1], [0, -1, -1], [-1, 1, 0], [-1, 0, 1], [-1, 0, -1], [-1, -1, 0]].map(makePositionVector);
20
18
  const edgeDimensions = edges.map(edge => edge.toArray().map(axis => axis == 0 ? 0.5 : 0.25));
21
-
22
19
  const FaceMaterial = ({
23
20
  hover,
24
21
  index,
@@ -55,28 +52,23 @@ const FaceMaterial = ({
55
52
  opacity: opacity
56
53
  });
57
54
  };
58
-
59
55
  const FaceCube = props => {
60
56
  const {
61
57
  tweenCamera
62
58
  } = useGizmoContext();
63
59
  const [hover, setHover] = React.useState(null);
64
-
65
60
  const handlePointerOut = e => {
66
61
  e.stopPropagation();
67
62
  setHover(null);
68
63
  };
69
-
70
64
  const handleClick = e => {
71
65
  e.stopPropagation();
72
66
  tweenCamera(e.face.normal);
73
67
  };
74
-
75
68
  const handlePointerMove = e => {
76
69
  e.stopPropagation();
77
70
  setHover(Math.floor(e.faceIndex / 2));
78
71
  };
79
-
80
72
  return /*#__PURE__*/React.createElement("mesh", {
81
73
  onPointerOut: handlePointerOut,
82
74
  onPointerMove: handlePointerMove,
@@ -87,7 +79,6 @@ const FaceCube = props => {
87
79
  hover: hover === index
88
80
  }, props))), /*#__PURE__*/React.createElement("boxGeometry", null));
89
81
  };
90
-
91
82
  const EdgeCube = ({
92
83
  onClick,
93
84
  dimensions,
@@ -98,22 +89,18 @@ const EdgeCube = ({
98
89
  tweenCamera
99
90
  } = useGizmoContext();
100
91
  const [hover, setHover] = React.useState(false);
101
-
102
92
  const handlePointerOut = e => {
103
93
  e.stopPropagation();
104
94
  setHover(false);
105
95
  };
106
-
107
96
  const handlePointerOver = e => {
108
97
  e.stopPropagation();
109
98
  setHover(true);
110
99
  };
111
-
112
100
  const handleClick = e => {
113
101
  e.stopPropagation();
114
102
  tweenCamera(position);
115
103
  };
116
-
117
104
  return /*#__PURE__*/React.createElement("mesh", {
118
105
  scale: 1.01,
119
106
  position: position,
@@ -129,7 +116,6 @@ const EdgeCube = ({
129
116
  args: dimensions
130
117
  }));
131
118
  };
132
-
133
119
  const GizmoViewcube = props => {
134
120
  return /*#__PURE__*/React.createElement("group", {
135
121
  scale: [60, 60, 60]
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  import { ThreeEvent } from '@react-three/fiber';
3
- declare type GizmoViewportProps = JSX.IntrinsicElements['group'] & {
3
+ type GizmoViewportProps = JSX.IntrinsicElements['group'] & {
4
4
  axisColors?: [string, string, string];
5
5
  axisScale?: [number, number, number];
6
6
  labels?: [string, string, string];
@@ -12,5 +12,5 @@ declare type GizmoViewportProps = JSX.IntrinsicElements['group'] & {
12
12
  font?: string;
13
13
  onClick?: (e: ThreeEvent<MouseEvent>) => null;
14
14
  };
15
- export declare const GizmoViewport: ({ hideNegativeAxes, hideAxisHeads, disabled, font, axisColors, axisHeadScale, axisScale, labels, labelColor, onClick, ...props }: GizmoViewportProps) => JSX.Element;
15
+ export declare const GizmoViewport: ({ hideNegativeAxes, hideAxisHeads, disabled, font, axisColors, axisHeadScale, axisScale, labels, labelColor, onClick, ...props }: GizmoViewportProps) => React.JSX.Element;
16
16
  export {};
@@ -20,7 +20,6 @@ function Axis({
20
20
  toneMapped: false
21
21
  })));
22
22
  }
23
-
24
23
  function AxisHead({
25
24
  onClick,
26
25
  font,
@@ -42,29 +41,24 @@ function AxisHead({
42
41
  context.closePath();
43
42
  context.fillStyle = arcStyle;
44
43
  context.fill();
45
-
46
44
  if (label) {
47
45
  context.font = font;
48
46
  context.textAlign = 'center';
49
47
  context.fillStyle = labelColor;
50
48
  context.fillText(label, 32, 41);
51
49
  }
52
-
53
50
  return new CanvasTexture(canvas);
54
51
  }, [arcStyle, label, labelColor, font]);
55
52
  const [active, setActive] = React.useState(false);
56
53
  const scale = (label ? 1 : 0.75) * (active ? 1.2 : 1) * axisHeadScale;
57
-
58
54
  const handlePointerOver = e => {
59
55
  e.stopPropagation();
60
56
  setActive(true);
61
57
  };
62
-
63
58
  const handlePointerOut = e => {
64
59
  e.stopPropagation();
65
60
  setActive(false);
66
61
  };
67
-
68
62
  return /*#__PURE__*/React.createElement("sprite", _extends({
69
63
  scale: scale,
70
64
  onPointerOver: !disabled ? handlePointerOver : undefined,
@@ -77,7 +71,6 @@ function AxisHead({
77
71
  toneMapped: false
78
72
  }));
79
73
  }
80
-
81
74
  const GizmoViewport = ({
82
75
  hideNegativeAxes,
83
76
  hideAxisHeads,
package/core/Gltf.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as THREE from 'three';
2
2
  import { CloneProps } from './Clone';
3
3
  import { ForwardRefComponent } from '../helpers/ts-utils';
4
- declare type GltfProps = Omit<JSX.IntrinsicElements['group'], 'children'> & Omit<CloneProps, 'object'> & {
4
+ type GltfProps = Omit<JSX.IntrinsicElements['group'], 'children'> & Omit<CloneProps, 'object'> & {
5
5
  src: string;
6
6
  };
7
7
  export declare const Gltf: ForwardRefComponent<GltfProps, THREE.Object3D>;
@@ -1,9 +1,9 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  export declare enum GradientType {
3
3
  Linear = "linear",
4
4
  Radial = "radial"
5
5
  }
6
- declare type Props = {
6
+ type Props = {
7
7
  stops: Array<number>;
8
8
  colors: Array<string>;
9
9
  attach?: string;
@@ -13,5 +13,5 @@ declare type Props = {
13
13
  innerCircleRadius?: number;
14
14
  outerCircleRadius?: string | number;
15
15
  } & JSX.IntrinsicElements['texture'];
16
- export declare function GradientTexture({ stops, colors, size, width, type, innerCircleRadius, outerCircleRadius, ...props }: Props): JSX.Element;
16
+ export declare function GradientTexture({ stops, colors, size, width, type, innerCircleRadius, outerCircleRadius, ...props }: Props): React.JSX.Element;
17
17
  export {};
@@ -25,7 +25,6 @@ function GradientTexture({
25
25
  canvas.width = width;
26
26
  canvas.height = size;
27
27
  let gradient;
28
-
29
28
  if (type === GradientType.Linear) {
30
29
  gradient = context.createLinearGradient(0, 0, 0, size);
31
30
  } else {
@@ -34,20 +33,18 @@ function GradientTexture({
34
33
  const radius = outerCircleRadius !== 'auto' ? Math.abs(Number(outerCircleRadius)) : Math.sqrt(canvasCenterX ** 2 + canvasCenterY ** 2);
35
34
  gradient = context.createRadialGradient(canvasCenterX, canvasCenterY, Math.abs(innerCircleRadius), canvasCenterX, canvasCenterY, radius);
36
35
  }
37
-
38
36
  let i = stops.length;
39
-
40
37
  while (i--) {
41
38
  gradient.addColorStop(stops[i], colors[i]);
42
39
  }
43
-
44
40
  context.save();
45
41
  context.fillStyle = gradient;
46
42
  context.fillRect(0, 0, width, size);
47
43
  context.restore();
48
44
  return canvas;
49
- }, [stops]); // @ts-ignore ????
45
+ }, [stops]);
50
46
 
47
+ // @ts-ignore ????
51
48
  return /*#__PURE__*/React.createElement("canvasTexture", _extends({
52
49
  colorSpace: gl.outputColorSpace,
53
50
  args: [canvas],
package/core/Grid.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as THREE from 'three';
2
2
  import { ForwardRefComponent } from '../helpers/ts-utils';
3
- export declare type GridMaterialType = {
3
+ export type GridMaterialType = {
4
4
  cellSize?: number;
5
5
  cellThickness?: number;
6
6
  cellColor?: THREE.ColorRepresentation;
@@ -13,7 +13,7 @@ export declare type GridMaterialType = {
13
13
  fadeStrength?: number;
14
14
  side?: THREE.Side;
15
15
  };
16
- export declare type GridProps = GridMaterialType & {
16
+ export type GridProps = GridMaterialType & {
17
17
  args?: ConstructorParameters<typeof THREE.PlaneGeometry>;
18
18
  };
19
19
  declare global {
package/core/Grid.js CHANGED
@@ -18,9 +18,7 @@ const GridMaterial = shaderMaterial({
18
18
  followCamera: false,
19
19
  worldCamProjPosition: new THREE.Vector3(),
20
20
  worldPlanePosition: new THREE.Vector3()
21
- },
22
- /* glsl */
23
- `
21
+ }, /* glsl */`
24
22
  varying vec3 localPosition;
25
23
  varying vec4 worldPosition;
26
24
 
@@ -42,9 +40,7 @@ const GridMaterial = shaderMaterial({
42
40
 
43
41
  gl_Position = projectionMatrix * viewMatrix * worldPosition;
44
42
  }
45
- `,
46
- /* glsl */
47
- `
43
+ `, /* glsl */`
48
44
  varying vec3 localPosition;
49
45
  varying vec4 worldPosition;
50
46
 
package/core/Hud.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
- declare type HudProps = {
2
+ type HudProps = {
3
3
  children: React.ReactNode;
4
4
  renderPriority?: number;
5
5
  };
6
- export declare function Hud({ children, renderPriority }: HudProps): JSX.Element;
6
+ export declare function Hud({ children, renderPriority }: HudProps): React.JSX.Element;
7
7
  export {};
package/core/Hud.js CHANGED
@@ -15,26 +15,23 @@ function RenderHud({
15
15
  let oldCLear;
16
16
  useFrame(() => {
17
17
  oldCLear = gl.autoClear;
18
-
19
18
  if (renderPriority === 1) {
20
19
  // Clear scene and render the default scene
21
20
  gl.autoClear = true;
22
21
  gl.render(defaultScene, defaultCamera);
23
- } // Disable cleaning and render the portal with its own camera
24
-
25
-
22
+ }
23
+ // Disable cleaning and render the portal with its own camera
26
24
  gl.autoClear = false;
27
25
  gl.clearDepth();
28
- gl.render(scene, camera); // Restore default
29
-
26
+ gl.render(scene, camera);
27
+ // Restore default
30
28
  gl.autoClear = oldCLear;
31
- }, renderPriority); // Without an element that receives pointer events state.pointer will always be 0/0
32
-
29
+ }, renderPriority);
30
+ // Without an element that receives pointer events state.pointer will always be 0/0
33
31
  return /*#__PURE__*/React.createElement("group", {
34
32
  onPointerOver: () => null
35
33
  });
36
34
  }
37
-
38
35
  function Hud({
39
36
  children,
40
37
  renderPriority = 1
package/core/Image.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as THREE from 'three';
2
2
  import { Color } from '@react-three/fiber';
3
3
  import { ForwardRefComponent } from '../helpers/ts-utils';
4
- export declare type ImageProps = Omit<JSX.IntrinsicElements['mesh'], 'scale'> & {
4
+ export type ImageProps = Omit<JSX.IntrinsicElements['mesh'], 'scale'> & {
5
5
  segments?: number;
6
6
  scale?: number | [number, number];
7
7
  color?: Color;
@@ -17,7 +17,7 @@ export declare type ImageProps = Omit<JSX.IntrinsicElements['mesh'], 'scale'> &
17
17
  texture?: never;
18
18
  url: string;
19
19
  });
20
- declare type ImageMaterialType = JSX.IntrinsicElements['shaderMaterial'] & {
20
+ type ImageMaterialType = JSX.IntrinsicElements['shaderMaterial'] & {
21
21
  scale?: number[];
22
22
  imageBounds?: number[];
23
23
  color?: Color;
package/core/Image.js CHANGED
@@ -5,6 +5,8 @@ import { extend } from '@react-three/fiber';
5
5
  import { shaderMaterial } from './shaderMaterial.js';
6
6
  import { useTexture } from './useTexture.js';
7
7
 
8
+ // {texture: THREE.Texture} XOR {url: string}
9
+
8
10
  const ImageMaterialImpl = shaderMaterial({
9
11
  color: new THREE.Color('white'),
10
12
  scale: [1, 1],
@@ -13,17 +15,13 @@ const ImageMaterialImpl = shaderMaterial({
13
15
  zoom: 1,
14
16
  grayscale: 0,
15
17
  opacity: 1
16
- },
17
- /* glsl */
18
- `
18
+ }, /* glsl */`
19
19
  varying vec2 vUv;
20
20
  void main() {
21
21
  gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.);
22
22
  vUv = uv;
23
23
  }
24
- `,
25
- /* glsl */
26
- `
24
+ `, /* glsl */`
27
25
  // mostly from https://gist.github.com/statico/df64c5d167362ecf7b34fca0b1459a44
28
26
  varying vec2 vUv;
29
27
  uniform vec2 scale;
@@ -9,19 +9,19 @@ declare global {
9
9
  }
10
10
  }
11
11
  }
12
- declare type Api = {
12
+ type Api = {
13
13
  getParent: () => React.MutableRefObject<InstancedMesh>;
14
14
  subscribe: <T>(ref: React.MutableRefObject<T>) => void;
15
15
  };
16
- export declare type InstancesProps = JSX.IntrinsicElements['instancedMesh'] & {
16
+ export type InstancesProps = JSX.IntrinsicElements['instancedMesh'] & {
17
17
  range?: number;
18
18
  limit?: number;
19
19
  frames?: number;
20
20
  };
21
- export declare type InstanceProps = JSX.IntrinsicElements['positionMesh'] & {
21
+ export type InstanceProps = JSX.IntrinsicElements['positionMesh'] & {
22
22
  context?: React.Context<Api>;
23
23
  };
24
- declare type InstancedMesh = Omit<THREE.InstancedMesh, 'instanceMatrix' | 'instanceColor'> & {
24
+ type InstancedMesh = Omit<THREE.InstancedMesh, 'instanceMatrix' | 'instanceColor'> & {
25
25
  instanceMatrix: THREE.InstancedBufferAttribute;
26
26
  instanceColor: THREE.InstancedBufferAttribute;
27
27
  };
@@ -33,7 +33,7 @@ declare class PositionMesh extends THREE.Group {
33
33
  get geometry(): THREE.BufferGeometry | undefined;
34
34
  raycast(raycaster: THREE.Raycaster, intersects: THREE.Intersection[]): void;
35
35
  }
36
- export declare const Instance: React.ForwardRefExoticComponent<Pick<Omit<ReactThreeFiber.ExtendedColors<ReactThreeFiber.Overwrite<Partial<PositionMesh>, ReactThreeFiber.NodeProps<PositionMesh, typeof PositionMesh>>>, ReactThreeFiber.NonFunctionKeys<{
36
+ export declare const Instance: React.ForwardRefExoticComponent<Omit<Omit<ReactThreeFiber.ExtendedColors<ReactThreeFiber.Overwrite<Partial<PositionMesh>, ReactThreeFiber.NodeProps<PositionMesh, typeof PositionMesh>>>, ReactThreeFiber.NonFunctionKeys<{
37
37
  position?: ReactThreeFiber.Vector3 | undefined;
38
38
  up?: ReactThreeFiber.Vector3 | undefined;
39
39
  scale?: ReactThreeFiber.Vector3 | undefined;
@@ -53,7 +53,7 @@ export declare const Instance: React.ForwardRefExoticComponent<Pick<Omit<ReactTh
53
53
  dispose?: (() => void) | null | undefined;
54
54
  } & import("@react-three/fiber/dist/declarations/src/core/events").EventHandlers & {
55
55
  context?: React.Context<Api> | undefined;
56
- }, "visible" | "attach" | "args" | "children" | "key" | "onUpdate" | "position" | "up" | "scale" | "rotation" | "matrix" | "quaternion" | "layers" | "dispose" | "type" | "isGroup" | "id" | "uuid" | "name" | "parent" | "modelViewMatrix" | "normalMatrix" | "matrixWorld" | "matrixAutoUpdate" | "matrixWorldAutoUpdate" | "matrixWorldNeedsUpdate" | "castShadow" | "receiveShadow" | "frustumCulled" | "renderOrder" | "animations" | "userData" | "customDepthMaterial" | "customDistanceMaterial" | "isObject3D" | "onBeforeRender" | "onAfterRender" | "applyMatrix4" | "applyQuaternion" | "setRotationFromAxisAngle" | "setRotationFromEuler" | "setRotationFromMatrix" | "setRotationFromQuaternion" | "rotateOnAxis" | "rotateOnWorldAxis" | "rotateX" | "rotateY" | "rotateZ" | "translateOnAxis" | "translateX" | "translateY" | "translateZ" | "localToWorld" | "worldToLocal" | "lookAt" | "add" | "remove" | "removeFromParent" | "clear" | "getObjectById" | "getObjectByName" | "getObjectByProperty" | "getObjectsByProperty" | "getWorldPosition" | "getWorldQuaternion" | "getWorldScale" | "getWorldDirection" | "raycast" | "traverse" | "traverseVisible" | "traverseAncestors" | "updateMatrix" | "updateMatrixWorld" | "updateWorldMatrix" | "toJSON" | "clone" | "copy" | "addEventListener" | "hasEventListener" | "removeEventListener" | "dispatchEvent" | "color" | keyof import("@react-three/fiber/dist/declarations/src/core/events").EventHandlers | "geometry" | "context" | "instance" | "instanceKey"> & React.RefAttributes<unknown>>;
56
+ }, "ref"> & React.RefAttributes<unknown>>;
57
57
  export declare const Instances: ForwardRefComponent<InstancesProps, InstancedMesh>;
58
58
  export interface MergedProps extends InstancesProps {
59
59
  meshes: THREE.Mesh[];
package/core/Instances.js CHANGED
@@ -6,13 +6,9 @@ import mergeRefs from 'react-merge-refs';
6
6
  import Composer from 'react-composer';
7
7
 
8
8
  const _instanceLocalMatrix = /*@__PURE__*/new THREE.Matrix4();
9
-
10
9
  const _instanceWorldMatrix = /*@__PURE__*/new THREE.Matrix4();
11
-
12
10
  const _instanceIntersects = [];
13
-
14
11
  const _mesh = /*@__PURE__*/new THREE.Mesh();
15
-
16
12
  class PositionMesh extends THREE.Group {
17
13
  constructor() {
18
14
  super();
@@ -23,50 +19,42 @@ class PositionMesh extends THREE.Group {
23
19
  this.instanceKey = {
24
20
  current: undefined
25
21
  };
26
- } // This will allow the virtual instance have bounds
27
-
22
+ }
28
23
 
24
+ // This will allow the virtual instance have bounds
29
25
  get geometry() {
30
26
  var _this$instance$curren;
31
-
32
27
  return (_this$instance$curren = this.instance.current) == null ? void 0 : _this$instance$curren.geometry;
33
- } // And this will allow the virtual instance to receive events
34
-
28
+ }
35
29
 
30
+ // And this will allow the virtual instance to receive events
36
31
  raycast(raycaster, intersects) {
37
32
  const parent = this.instance.current;
38
33
  if (!parent) return;
39
34
  if (!parent.geometry || !parent.material) return;
40
35
  _mesh.geometry = parent.geometry;
41
36
  const matrixWorld = parent.matrixWorld;
42
- const instanceId = parent.userData.instances.indexOf(this.instanceKey); // If the instance wasn't found or exceeds the parents draw range, bail out
43
-
44
- if (instanceId === -1 || instanceId > parent.count) return; // calculate the world matrix for each instance
45
-
37
+ const instanceId = parent.userData.instances.indexOf(this.instanceKey);
38
+ // If the instance wasn't found or exceeds the parents draw range, bail out
39
+ if (instanceId === -1 || instanceId > parent.count) return;
40
+ // calculate the world matrix for each instance
46
41
  parent.getMatrixAt(instanceId, _instanceLocalMatrix);
47
-
48
- _instanceWorldMatrix.multiplyMatrices(matrixWorld, _instanceLocalMatrix); // the mesh represents this single instance
49
-
50
-
51
- _mesh.matrixWorld = _instanceWorldMatrix; // raycast side according to instance material
52
-
42
+ _instanceWorldMatrix.multiplyMatrices(matrixWorld, _instanceLocalMatrix);
43
+ // the mesh represents this single instance
44
+ _mesh.matrixWorld = _instanceWorldMatrix;
45
+ // raycast side according to instance material
53
46
  if (parent.material instanceof THREE.Material) _mesh.material.side = parent.material.side;else _mesh.material.side = parent.material[0].side;
54
-
55
- _mesh.raycast(raycaster, _instanceIntersects); // process the result of raycast
56
-
57
-
47
+ _mesh.raycast(raycaster, _instanceIntersects);
48
+ // process the result of raycast
58
49
  for (let i = 0, l = _instanceIntersects.length; i < l; i++) {
59
50
  const intersect = _instanceIntersects[i];
60
51
  intersect.instanceId = instanceId;
61
52
  intersect.object = this;
62
53
  intersects.push(intersect);
63
54
  }
64
-
65
55
  _instanceIntersects.length = 0;
66
56
  }
67
-
68
57
  }
69
-
70
58
  const globalContext = /*@__PURE__*/React.createContext(null);
71
59
  const parentMatrix = /*@__PURE__*/new THREE.Matrix4();
72
60
  const instanceMatrix = /*@__PURE__*/new THREE.Matrix4();
@@ -119,9 +107,7 @@ const Instances = /*#__PURE__*/React.forwardRef(({
119
107
  const [instances, setInstances] = React.useState([]);
120
108
  const [[matrices, colors]] = React.useState(() => {
121
109
  const mArray = new Float32Array(limit * 16);
122
-
123
110
  for (let i = 0; i < limit; i++) tempMatrix.identity().toArray(mArray, i * 16);
124
-
125
111
  return [mArray, new Float32Array([...new Array(limit * 3)].map(() => 1))];
126
112
  });
127
113
  React.useEffect(() => {
@@ -139,11 +125,10 @@ const Instances = /*#__PURE__*/React.forwardRef(({
139
125
  parentRef.current.count = updateRange;
140
126
  parentRef.current.instanceMatrix.updateRange.count = updateRange * 16;
141
127
  parentRef.current.instanceColor.updateRange.count = updateRange * 3;
142
-
143
128
  for (let i = 0; i < instances.length; i++) {
144
- const instance = instances[i].current; // Multiply the inverse of the InstancedMesh world matrix or else
129
+ const instance = instances[i].current;
130
+ // Multiply the inverse of the InstancedMesh world matrix or else
145
131
  // Instances will be double-transformed if <Instances> isn't at identity
146
-
147
132
  instance.matrixWorld.decompose(translation, rotation, scale);
148
133
  instanceMatrix.compose(translation, rotation, scale).premultiply(parentMatrix);
149
134
  instanceMatrix.toArray(matrices, i * 16);
@@ -151,7 +136,6 @@ const Instances = /*#__PURE__*/React.forwardRef(({
151
136
  instance.color.toArray(colors, i * 3);
152
137
  parentRef.current.instanceColor.needsUpdate = true;
153
138
  }
154
-
155
139
  count++;
156
140
  }
157
141
  });
@@ -193,8 +177,8 @@ const Merged = /*#__PURE__*/React.forwardRef(function Merged({
193
177
  children,
194
178
  ...props
195
179
  }, ref) {
196
- const isArray = Array.isArray(meshes); // Filter out meshes from collections, which may contain non-meshes
197
-
180
+ const isArray = Array.isArray(meshes);
181
+ // Filter out meshes from collections, which may contain non-meshes
198
182
  if (!isArray) for (const key of Object.keys(meshes)) if (!meshes[key].isMesh) delete meshes[key];
199
183
  return /*#__PURE__*/React.createElement("group", {
200
184
  ref: ref
@@ -207,7 +191,8 @@ const Merged = /*#__PURE__*/React.forwardRef(function Merged({
207
191
  geometry: geometry,
208
192
  material: material
209
193
  }, props)))
210
- }, args => isArray ? children(...args) : children(Object.keys(meshes).filter(key => meshes[key].isMesh).reduce((acc, key, i) => ({ ...acc,
194
+ }, args => isArray ? children(...args) : children(Object.keys(meshes).filter(key => meshes[key].isMesh).reduce((acc, key, i) => ({
195
+ ...acc,
211
196
  [key]: args[i]
212
197
  }), {}))));
213
198
  });
@@ -1,7 +1,7 @@
1
1
  import { ReactThreeFiber } from '@react-three/fiber';
2
2
  import * as THREE from 'three';
3
3
  import { ForwardRefComponent } from '../helpers/ts-utils';
4
- export declare type LightProps = JSX.IntrinsicElements['mesh'] & {
4
+ export type LightProps = JSX.IntrinsicElements['mesh'] & {
5
5
  args?: any[];
6
6
  map?: THREE.Texture;
7
7
  toneMapped?: boolean;