@react-three/drei 9.121.5 → 9.121.6-rc.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 (201) hide show
  1. package/core/AccumulativeShadows.d.ts +8 -10
  2. package/core/ArcballControls.d.ts +4 -4
  3. package/core/AsciiRenderer.d.ts +1 -2
  4. package/core/BBAnchor.d.ts +3 -3
  5. package/core/Backdrop.d.ts +2 -1
  6. package/core/Billboard.cjs.js +1 -1
  7. package/core/Billboard.d.ts +3 -2
  8. package/core/Billboard.js +1 -1
  9. package/core/Bounds.d.ts +2 -1
  10. package/core/Bvh.d.ts +3 -2
  11. package/core/CameraControls.d.ts +4 -4
  12. package/core/CatmullRomLine.d.ts +2 -3
  13. package/core/Caustics.d.ts +14 -17
  14. package/core/Center.d.ts +3 -2
  15. package/core/Clone.d.ts +4 -4
  16. package/core/Cloud.cjs.js +1 -1
  17. package/core/Cloud.d.ts +50 -12
  18. package/core/Cloud.js +3 -3
  19. package/core/ComputedAttribute.cjs.js +1 -1
  20. package/core/ComputedAttribute.d.ts +3 -4
  21. package/core/ComputedAttribute.js +1 -1
  22. package/core/ContactShadows.d.ts +3 -2
  23. package/core/CubeCamera.d.ts +3 -3
  24. package/core/CubeTexture.d.ts +5 -6
  25. package/core/CubeTexture.js +2 -7
  26. package/core/CubicBezierLine.d.ts +2 -3
  27. package/core/CurveModifier.d.ts +2 -1
  28. package/core/Decal.d.ts +2 -2
  29. package/core/Detailed.d.ts +3 -3
  30. package/core/DetectGPU.d.ts +1 -2
  31. package/core/DeviceOrientationControls.d.ts +2 -2
  32. package/core/Edges.cjs.js +1 -1
  33. package/core/Edges.d.ts +2 -2
  34. package/core/Edges.js +2 -2
  35. package/core/Effects.cjs.js +1 -1
  36. package/core/Effects.d.ts +9 -13
  37. package/core/Effects.js +3 -3
  38. package/core/Environment.cjs.js +1 -1
  39. package/core/Environment.d.ts +5 -7
  40. package/core/Fbo.d.ts +1 -4
  41. package/core/Fbo.js +0 -2
  42. package/core/Fbx.d.ts +1 -1
  43. package/core/FirstPersonControls.d.ts +2 -2
  44. package/core/Fisheye.d.ts +2 -1
  45. package/core/Float.d.ts +2 -1
  46. package/core/FlyControls.d.ts +2 -2
  47. package/core/GizmoHelper.d.ts +2 -1
  48. package/core/GizmoViewport.d.ts +2 -2
  49. package/core/Gltf.d.ts +9 -5
  50. package/core/GradientTexture.d.ts +4 -4
  51. package/core/GradientTexture.js +0 -2
  52. package/core/Grid.d.ts +6 -7
  53. package/core/Helper.cjs.js +1 -1
  54. package/core/Helper.d.ts +1 -1
  55. package/core/Helper.js +1 -1
  56. package/core/Hud.d.ts +1 -2
  57. package/core/Image.d.ts +6 -8
  58. package/core/Instances.cjs.js +1 -1
  59. package/core/Instances.d.ts +27 -35
  60. package/core/Instances.js +35 -30
  61. package/core/Ktx2.d.ts +1 -1
  62. package/core/Lightformer.d.ts +3 -3
  63. package/core/Line.d.ts +4 -4
  64. package/core/MapControls.d.ts +4 -4
  65. package/core/MarchingCubes.d.ts +6 -6
  66. package/core/Mask.d.ts +3 -3
  67. package/core/MeshDiscardMaterial.d.ts +6 -7
  68. package/core/MeshDistortMaterial.d.ts +15 -17
  69. package/core/MeshPortalMaterial.cjs.js +1 -1
  70. package/core/MeshPortalMaterial.d.ts +14 -17
  71. package/core/MeshPortalMaterial.js +2 -2
  72. package/core/MeshReflectorMaterial.cjs.js +1 -1
  73. package/core/MeshReflectorMaterial.d.ts +9 -22
  74. package/core/MeshReflectorMaterial.js +2 -4
  75. package/core/MeshRefractionMaterial.cjs.js +1 -1
  76. package/core/MeshRefractionMaterial.d.ts +5 -8
  77. package/core/MeshRefractionMaterial.js +2 -2
  78. package/core/MeshTransmissionMaterial.cjs.js +1 -1
  79. package/core/MeshTransmissionMaterial.d.ts +7 -8
  80. package/core/MeshTransmissionMaterial.js +2 -1
  81. package/core/MeshWobbleMaterial.d.ts +15 -17
  82. package/core/MotionPathControls.cjs.js +1 -1
  83. package/core/MotionPathControls.d.ts +18 -6
  84. package/core/MotionPathControls.js +2 -3
  85. package/core/MultiMaterial.cjs.js +1 -1
  86. package/core/MultiMaterial.d.ts +3 -1
  87. package/core/MultiMaterial.js +2 -3
  88. package/core/OrbitControls.d.ts +4 -4
  89. package/core/OrthographicCamera.d.ts +3 -3
  90. package/core/Outlines.cjs.js +1 -1
  91. package/core/Outlines.d.ts +2 -3
  92. package/core/Outlines.js +2 -2
  93. package/core/PerformanceMonitor.d.ts +2 -2
  94. package/core/PerspectiveCamera.d.ts +3 -3
  95. package/core/PointMaterial.d.ts +3 -11
  96. package/core/PointerLockControls.d.ts +2 -2
  97. package/core/Points.cjs.js +1 -1
  98. package/core/Points.d.ts +10 -13
  99. package/core/Points.js +6 -16
  100. package/core/PositionalAudio.d.ts +3 -3
  101. package/core/Preload.d.ts +2 -3
  102. package/core/QuadraticBezierLine.d.ts +5 -7
  103. package/core/RenderCubeTexture.d.ts +2 -2
  104. package/core/RenderTexture.cjs.js +1 -1
  105. package/core/RenderTexture.d.ts +3 -3
  106. package/core/RenderTexture.js +3 -2
  107. package/core/Resize.d.ts +9 -2
  108. package/core/RoundedBox.d.ts +4 -4
  109. package/core/Sampler.d.ts +4 -4
  110. package/core/ScreenQuad.d.ts +3 -3
  111. package/core/ScreenSizer.d.ts +3 -3
  112. package/core/ScreenSpace.d.ts +3 -2
  113. package/core/Segments.d.ts +6 -8
  114. package/core/Shadow.d.ts +3 -3
  115. package/core/ShadowAlpha.cjs.js +1 -1
  116. package/core/ShadowAlpha.d.ts +1 -2
  117. package/core/ShadowAlpha.js +1 -1
  118. package/core/Sky.d.ts +2 -3
  119. package/core/Sparkles.d.ts +14 -16
  120. package/core/Splat.d.ts +6 -8
  121. package/core/SpotLight.d.ts +2 -1
  122. package/core/SpriteAnimator.cjs.js +1 -1
  123. package/core/SpriteAnimator.d.ts +36 -3
  124. package/core/Stage.cjs.js +1 -1
  125. package/core/Stage.d.ts +3 -2
  126. package/core/Stars.cjs.js +1 -1
  127. package/core/Stars.d.ts +6 -8
  128. package/core/Stars.js +1 -1
  129. package/core/Stats.d.ts +2 -3
  130. package/core/StatsGl.d.ts +2 -2
  131. package/core/Svg.d.ts +6 -6
  132. package/core/Text.d.ts +3 -4
  133. package/core/Text3D.d.ts +7 -10
  134. package/core/Texture.d.ts +1 -1
  135. package/core/TrackballControls.d.ts +4 -4
  136. package/core/Trail.cjs.js +1 -1
  137. package/core/Trail.d.ts +3 -3
  138. package/core/Trail.js +3 -3
  139. package/core/TrailTexture.d.ts +3 -2
  140. package/core/TransformControls.cjs.js +1 -1
  141. package/core/TransformControls.d.ts +3 -3
  142. package/core/TransformControls.js +4 -5
  143. package/core/VideoTexture.cjs.js +1 -1
  144. package/core/VideoTexture.js +1 -1
  145. package/core/Wireframe.d.ts +5 -7
  146. package/core/index.cjs.js +1 -1
  147. package/core/index.d.ts +0 -1
  148. package/core/index.js +1 -3
  149. package/core/shapes.d.ts +21 -20
  150. package/core/softShadows.d.ts +1 -2
  151. package/core/useAnimations.cjs.js +1 -1
  152. package/core/useAnimations.d.ts +2 -2
  153. package/core/useAnimations.js +1 -1
  154. package/core/useBoxProjectedEnv.d.ts +1 -1
  155. package/core/useCamera.cjs.js +1 -1
  156. package/core/useCamera.d.ts +1 -1
  157. package/core/useCamera.js +1 -8
  158. package/core/useContextBridge.d.ts +1 -1
  159. package/core/useEnvironment.cjs.js +1 -1
  160. package/core/useEnvironment.d.ts +3 -4
  161. package/core/useEnvironment.js +11 -19
  162. package/core/useIntersect.d.ts +1 -1
  163. package/core/useSpriteLoader.d.ts +1 -1
  164. package/helpers/deprecated.cjs.js +1 -1
  165. package/helpers/deprecated.d.ts +1 -4
  166. package/helpers/deprecated.js +2 -14
  167. package/helpers/ts-utils.d.ts +4 -0
  168. package/helpers/useEffectfulState.d.ts +1 -1
  169. package/index.cjs.js +1 -1
  170. package/index.js +0 -1
  171. package/materials/BlurPass.js +0 -1
  172. package/materials/MeshReflectorMaterial.d.ts +0 -16
  173. package/native/index.cjs.js +1 -1
  174. package/native/index.js +1 -3
  175. package/package.json +7 -8
  176. package/web/CycleRaycast.d.ts +1 -1
  177. package/web/FaceLandmarker.d.ts +1 -2
  178. package/web/Facemesh.d.ts +3 -2
  179. package/web/Html.cjs.js +1 -1
  180. package/web/Html.d.ts +4 -4
  181. package/web/Html.js +1 -1
  182. package/web/KeyboardControls.d.ts +1 -1
  183. package/web/PresentationControls.cjs.js +1 -1
  184. package/web/PresentationControls.d.ts +3 -4
  185. package/web/PresentationControls.js +20 -28
  186. package/web/ScrollControls.d.ts +1 -1
  187. package/web/Select.d.ts +3 -3
  188. package/web/Select.js +6 -2
  189. package/web/View.cjs.js +1 -1
  190. package/web/View.d.ts +8 -10
  191. package/web/View.js +4 -34
  192. package/web/index.cjs.js +1 -1
  193. package/web/index.js +0 -3
  194. package/web/pivotControls/AxisArrow.js +0 -2
  195. package/web/pivotControls/AxisRotator.js +0 -2
  196. package/web/pivotControls/PlaneSlider.js +0 -2
  197. package/web/pivotControls/ScalingSphere.js +0 -1
  198. package/web/pivotControls/index.d.ts +1 -2
  199. package/core/Reflector.cjs.js +0 -1
  200. package/core/Reflector.d.ts +0 -30
  201. package/core/Reflector.js +0 -180
@@ -3,7 +3,6 @@ import { CubeReflectionMapping, EquirectangularReflectionMapping, CubeTextureLoa
3
3
  import { RGBELoader, EXRLoader } from 'three-stdlib';
4
4
  import { HDRJPGLoader, GainMapLoader } from '@monogrid/gainmap-js';
5
5
  import { presetsObj } from '../helpers/environment-assets.js';
6
- import { sRGBEncoding, LinearEncoding } from '../helpers/deprecated.js';
7
6
  import { useLayoutEffect } from 'react';
8
7
 
9
8
  const CUBEMAP_ROOT = 'https://raw.githack.com/pmndrs/drei-assets/456060a26bbeb8fdf79326f224b6d99b8bcce736/hdri/';
@@ -13,11 +12,9 @@ function useEnvironment({
13
12
  files = defaultFiles,
14
13
  path = '',
15
14
  preset = undefined,
16
- encoding = undefined,
15
+ colorSpace = undefined,
17
16
  extensions
18
17
  } = {}) {
19
- let loader = null;
20
- let multiFile = false;
21
18
  if (preset) {
22
19
  validatePreset(preset);
23
20
  files = presetsObj[preset];
@@ -25,34 +22,32 @@ function useEnvironment({
25
22
  }
26
23
 
27
24
  // Everything else
28
- multiFile = isArray(files);
25
+ const multiFile = isArray(files);
29
26
  const {
30
27
  extension,
31
28
  isCubemap
32
29
  } = getExtension(files);
33
- loader = getLoader(extension);
30
+ const loader = getLoader(extension);
34
31
  if (!loader) throw new Error('useEnvironment: Unrecognized file extension: ' + files);
35
32
  const gl = useThree(state => state.gl);
36
33
  useLayoutEffect(() => {
37
34
  // Only required for gainmap
38
35
  if (extension !== 'webp' && extension !== 'jpg' && extension !== 'jpeg') return;
39
36
  function clearGainmapTexture() {
40
- useLoader.clear(
41
- // @ts-expect-error
42
- loader, multiFile ? [files] : files);
37
+ useLoader.clear(loader, multiFile ? [files] : files);
43
38
  }
44
39
  gl.domElement.addEventListener('webglcontextlost', clearGainmapTexture, {
45
40
  once: true
46
41
  });
47
42
  }, [files, gl.domElement]);
48
- const loaderResult = useLoader(
49
- // @ts-expect-error
50
- loader, multiFile ? [files] : files, loader => {
43
+ const loaderResult = useLoader(loader, multiFile ? [files] : files, loader => {
51
44
  // Gainmap requires a renderer
52
45
  if (extension === 'webp' || extension === 'jpg' || extension === 'jpeg') {
46
+ // @ts-expect-error
53
47
  loader.setRenderer(gl);
54
48
  }
55
49
  loader.setPath == null || loader.setPath(path);
50
+ // @ts-expect-error
56
51
  if (extensions) extensions(loader);
57
52
  });
58
53
  let texture = multiFile ?
@@ -63,7 +58,7 @@ function useEnvironment({
63
58
  texture = (_renderTarget = texture.renderTarget) == null ? void 0 : _renderTarget.texture;
64
59
  }
65
60
  texture.mapping = isCubemap ? CubeReflectionMapping : EquirectangularReflectionMapping;
66
- if ('colorSpace' in texture) texture.colorSpace = (encoding !== null && encoding !== void 0 ? encoding : isCubemap) ? 'srgb' : 'srgb-linear';else texture.encoding = (encoding !== null && encoding !== void 0 ? encoding : isCubemap) ? sRGBEncoding : LinearEncoding;
61
+ texture.colorSpace = colorSpace !== null && colorSpace !== void 0 ? colorSpace : isCubemap ? 'srgb' : 'srgb-linear';
67
62
  return texture;
68
63
  }
69
64
  const preloadDefaultOptions = {
@@ -98,10 +93,9 @@ useEnvironment.preload = preloadOptions => {
98
93
  }
99
94
  const loader = getLoader(extension);
100
95
  if (!loader) throw new Error('useEnvironment: Unrecognized file extension: ' + files);
101
- useLoader.preload(
102
- // @ts-expect-error
103
- loader, isArray(files) ? [files] : files, loader => {
96
+ useLoader.preload(loader, isArray(files) ? [files] : files, loader => {
104
97
  loader.setPath == null || loader.setPath(path);
98
+ // @ts-expect-error
105
99
  if (extensions) extensions(loader);
106
100
  });
107
101
  };
@@ -129,9 +123,7 @@ useEnvironment.clear = clearOptions => {
129
123
  } = getExtension(files);
130
124
  const loader = getLoader(extension);
131
125
  if (!loader) throw new Error('useEnvironment: Unrecognized file extension: ' + files);
132
- useLoader.clear(
133
- // @ts-expect-error
134
- loader, isArray(files) ? [files] : files);
126
+ useLoader.clear(loader, isArray(files) ? [files] : files);
135
127
  };
136
128
  function validatePreset(preset) {
137
129
  if (!(preset in presetsObj)) throw new Error('Preset must be one of: ' + Object.keys(presetsObj).join(', '));
@@ -1,3 +1,3 @@
1
1
  import * as React from 'react';
2
2
  import { Object3D } from 'three';
3
- export declare function useIntersect<T extends Object3D>(onChange: (visible: boolean) => void): React.MutableRefObject<T>;
3
+ export declare function useIntersect<T extends Object3D>(onChange: (visible: boolean) => void): React.RefObject<T>;
@@ -51,7 +51,7 @@ export declare function useSpriteLoader<Url extends string>(input: Url | null, j
51
51
  loadJsonAndTexture: (textureUrl: string, jsonUrl?: string) => void;
52
52
  };
53
53
  export declare namespace useSpriteLoader {
54
- var preload: (url: string) => undefined;
54
+ var preload: (url: string) => void;
55
55
  var clear: (input: string) => void;
56
56
  }
57
57
  export {};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.LinearEncoding=3e3,exports.sRGBEncoding=3001,exports.setUpdateRange=(e,t)=>{"updateRanges"in e?e.updateRanges[0]=t:e.updateRange=t};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.setUpdateRange=(e,t)=>{e.updateRanges[0]=t};
@@ -1,8 +1,5 @@
1
1
  import * as THREE from 'three';
2
2
  export declare const setUpdateRange: (attribute: THREE.BufferAttribute, updateRange: {
3
- offset: number;
3
+ start: number;
4
4
  count: number;
5
5
  }) => void;
6
- export declare const LinearEncoding = 3000;
7
- export declare const sRGBEncoding = 3001;
8
- export type TextureEncoding = typeof LinearEncoding | typeof sRGBEncoding;
@@ -2,19 +2,7 @@
2
2
  * Sets `BufferAttribute.updateRange` since r159.
3
3
  */
4
4
  const setUpdateRange = (attribute, updateRange) => {
5
- if ('updateRanges' in attribute) {
6
- // r159
7
- // @ts-ignore
8
- attribute.updateRanges[0] = updateRange;
9
- } else {
10
- attribute.updateRange = updateRange;
11
- }
5
+ attribute.updateRanges[0] = updateRange;
12
6
  };
13
- const LinearEncoding = 3000;
14
- const sRGBEncoding = 3001;
15
7
 
16
- /**
17
- * TextureEncoding was deprecated in r152, and removed in r162.
18
- */
19
-
20
- export { LinearEncoding, sRGBEncoding, setUpdateRange };
8
+ export { setUpdateRange };
@@ -1,3 +1,7 @@
1
1
  import { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from 'react';
2
2
  export type NamedArrayTuple<T extends (...args: any) => any> = Parameters<T>;
3
3
  export type ForwardRefComponent<P, T> = ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
4
+ export type NonFunctionKeys<T> = {
5
+ [K in keyof T]-?: T[K] extends Function ? never : K;
6
+ }[keyof T];
7
+ export type Overwrite<T, O> = Omit<T, NonFunctionKeys<O>> & O;
@@ -1,4 +1,4 @@
1
1
  import * as React from 'react';
2
- type RefType<T> = React.MutableRefObject<T> | ((state: T) => void);
2
+ type RefType<T> = React.RefObject<T> | ((state: T) => void);
3
3
  export declare function useEffectfulState<T>(fn: () => T, deps?: React.DependencyList, cb?: RefType<T>): T | undefined;
4
4
  export {};