@react-three/drei 9.83.9 → 9.84.0

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 +70 -2
  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 +114 -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
package/core/Sparkles.js CHANGED
@@ -37,18 +37,13 @@ const SparklesImplMaterial = shaderMaterial({
37
37
  #include <tonemapping_fragment>
38
38
  #include <${parseInt(THREE.REVISION.replace(/\D+/g, '')) >= 154 ? 'colorspace_fragment' : 'encodings_fragment'}>
39
39
  }`);
40
-
41
40
  const isFloat32Array = def => def && def.constructor === Float32Array;
42
-
43
41
  const expandColor = v => [v.r, v.g, v.b];
44
-
45
42
  const isVector = v => v instanceof THREE.Vector2 || v instanceof THREE.Vector3 || v instanceof THREE.Vector4;
46
-
47
43
  const normalizeVector = v => {
48
44
  if (Array.isArray(v)) return v;else if (isVector(v)) return v.toArray();
49
45
  return [v, v, v];
50
46
  };
51
-
52
47
  function usePropAsIsOrAsAttribute(count, prop, setDefault) {
53
48
  return React.useMemo(() => {
54
49
  if (prop !== undefined) {
@@ -66,19 +61,16 @@ function usePropAsIsOrAsAttribute(count, prop, setDefault) {
66
61
  }, () => normalizeVector(prop)).flat();
67
62
  return Float32Array.from(a);
68
63
  }
69
-
70
64
  return Float32Array.from({
71
65
  length: count
72
66
  }, () => prop);
73
67
  }
74
68
  }
75
-
76
69
  return Float32Array.from({
77
70
  length: count
78
71
  }, setDefault);
79
72
  }, [prop]);
80
73
  }
81
-
82
74
  const Sparkles = /*#__PURE__*/React.forwardRef(({
83
75
  noise = 1,
84
76
  count = 100,
@@ -95,9 +87,7 @@ const Sparkles = /*#__PURE__*/React.forwardRef(({
95
87
  }), []);
96
88
  const ref = React.useRef(null);
97
89
  const dpr = useThree(state => state.viewport.dpr);
98
-
99
90
  const _scale = normalizeVector(scale);
100
-
101
91
  const positions = React.useMemo(() => Float32Array.from(Array.from({
102
92
  length: count
103
93
  }, () => _scale.map(THREE.MathUtils.randFloatSpread)).flat()), [count, ..._scale]);
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { DepthTexture, SpotLight as SpotLightImpl, Texture } from 'three';
3
3
  import { ForwardRefComponent } from '../helpers/ts-utils';
4
- declare type SpotLightProps = JSX.IntrinsicElements['spotLight'] & {
4
+ type SpotLightProps = JSX.IntrinsicElements['spotLight'] & {
5
5
  depthBuffer?: DepthTexture;
6
6
  attenuation?: number;
7
7
  anglePower?: number;
@@ -21,6 +21,6 @@ interface ShadowMeshProps {
21
21
  width?: number;
22
22
  height?: number;
23
23
  }
24
- export declare function SpotLightShadow(props: React.PropsWithChildren<ShadowMeshProps>): JSX.Element;
24
+ export declare function SpotLightShadow(props: React.PropsWithChildren<ShadowMeshProps>): React.JSX.Element;
25
25
  declare const SpotLight: ForwardRefComponent<React.PropsWithChildren<SpotLightProps>, SpotLightImpl>;
26
26
  export { SpotLight };
package/core/SpotLight.js CHANGED
@@ -10,7 +10,6 @@ import SpotlightShadowShader from '../helpers/glsl/DefaultSpotlightShadowShadows
10
10
  const isSpotLight = child => {
11
11
  return child == null ? void 0 : child.isSpotLight;
12
12
  };
13
-
14
13
  function VolumetricMesh({
15
14
  opacity = 1,
16
15
  radiusTop,
@@ -57,7 +56,6 @@ function VolumetricMesh({
57
56
  "uniforms-resolution-value": depthBuffer ? [size.width * dpr, size.height * dpr] : [0, 0]
58
57
  })));
59
58
  }
60
-
61
59
  function useCommon(spotlight, mesh, width, height, distance) {
62
60
  const [[pos, dir]] = React.useState(() => [new Vector3(), new Vector3()]);
63
61
  React.useLayoutEffect(() => {
@@ -80,7 +78,6 @@ function useCommon(spotlight, mesh, width, height, distance) {
80
78
  mesh.current.lookAt(spotlight.current.target.position);
81
79
  });
82
80
  }
83
-
84
81
  function SpotlightShadowWithShader({
85
82
  distance = 0.4,
86
83
  alphaTest = 0.5,
@@ -99,8 +96,8 @@ function SpotlightShadowWithShader({
99
96
  const renderTarget = React.useMemo(() => new WebGLRenderTarget(width, height, {
100
97
  format: RGBAFormat,
101
98
  encoding: LinearEncoding,
102
- stencilBuffer: false // depthTexture: null!
103
-
99
+ stencilBuffer: false
100
+ // depthTexture: null!
104
101
  }), [width, height]);
105
102
  const uniforms = React.useRef({
106
103
  uShadowMap: {
@@ -113,9 +110,7 @@ function SpotlightShadowWithShader({
113
110
  React.useEffect(() => void (uniforms.current.uShadowMap.value = map), [map]);
114
111
  const fsQuad = React.useMemo(() => new FullScreenQuad(new ShaderMaterial({
115
112
  uniforms: uniforms.current,
116
- vertexShader:
117
- /* glsl */
118
- `
113
+ vertexShader: /* glsl */`
119
114
  varying vec2 vUv;
120
115
 
121
116
  void main() {
@@ -152,7 +147,6 @@ function SpotlightShadowWithShader({
152
147
  opacity: debug ? 1 : 0
153
148
  }, children)));
154
149
  }
155
-
156
150
  function SpotlightShadowWithoutShader({
157
151
  distance = 0.4,
158
152
  alphaTest = 0.5,
@@ -181,7 +175,6 @@ function SpotlightShadowWithoutShader({
181
175
  opacity: debug ? 1 : 0
182
176
  }, children)));
183
177
  }
184
-
185
178
  function SpotLightShadow(props) {
186
179
  if (props.shader) return /*#__PURE__*/React.createElement(SpotlightShadowWithShader, props);
187
180
  return /*#__PURE__*/React.createElement(SpotlightShadowWithoutShader, props);
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- export declare type SpriteAnimatorProps = {
2
+ export type SpriteAnimatorProps = {
3
3
  startFrame?: number;
4
4
  endFrame?: number;
5
5
  fps?: number;
@@ -41,7 +41,6 @@ const SpriteAnimator = ({
41
41
  const [aspect, setAspect] = React.useState([1, 1, 1]);
42
42
  const flipOffset = flipX ? -1 : 1;
43
43
  const [displayAsSprite, setDisplayAsSprite] = React.useState(asSprite !== null && asSprite !== void 0 ? asSprite : true);
44
-
45
44
  function loadJsonAndTextureAndExecuteCallback(jsonUrl, textureUrl, callback) {
46
45
  const textureLoader = new THREE.TextureLoader();
47
46
  const jsonPromise = fetch(jsonUrl).then(response => response.json());
@@ -52,14 +51,13 @@ const SpriteAnimator = ({
52
51
  callback(response[0], response[1]);
53
52
  });
54
53
  }
55
-
56
54
  const calculateAspectRatio = (width, height) => {
57
55
  const aspectRatio = height / width;
58
56
  spriteRef.current.scale.set(1, aspectRatio, 1);
59
57
  return [1, aspectRatio, 1];
60
- }; // initial loads
61
-
58
+ };
62
59
 
60
+ // initial loads
63
61
  React.useEffect(() => {
64
62
  if (textureDataURL && textureImageURL) {
65
63
  loadJsonAndTextureAndExecuteCallback(textureDataURL, textureImageURL, parseSpriteData);
@@ -88,7 +86,6 @@ const SpriteAnimator = ({
88
86
  hasEnded.current = false;
89
87
  }
90
88
  }, [frameName]);
91
-
92
89
  const parseSpriteData = (json, _spriteTexture) => {
93
90
  // sprite only case
94
91
  if (json === null) {
@@ -111,7 +108,6 @@ const SpriteAnimator = ({
111
108
  scale: '1'
112
109
  }
113
110
  };
114
-
115
111
  if (parseInt(frameWidth.toString(), 10) === frameWidth) {
116
112
  // if it fits
117
113
  for (let i = 0; i < numberOfFrames; i++) {
@@ -149,26 +145,22 @@ const SpriteAnimator = ({
149
145
  } = getFirstItem(json.frames).sourceSize;
150
146
  const aspect = calculateAspectRatio(w, h);
151
147
  setAspect(aspect);
152
-
153
148
  if (matRef.current) {
154
149
  matRef.current.map = _spriteTexture;
155
150
  }
156
151
  }
157
-
158
152
  _spriteTexture.premultiplyAlpha = false;
159
153
  setSpriteTexture(_spriteTexture);
160
- }; // for frame based JSON Hash sprite data
161
-
154
+ };
162
155
 
156
+ // for frame based JSON Hash sprite data
163
157
  const parseFrames = () => {
164
158
  const sprites = {};
165
159
  const data = spriteData.current;
166
160
  const delimiters = animationNames;
167
-
168
161
  if (delimiters) {
169
162
  for (let i = 0; i < delimiters.length; i++) {
170
163
  sprites[delimiters[i]] = [];
171
-
172
164
  for (let innerKey in data['frames']) {
173
165
  const value = data['frames'][innerKey];
174
166
  const frameData = value['frame'];
@@ -178,7 +170,6 @@ const SpriteAnimator = ({
178
170
  const height = frameData['h'];
179
171
  const sourceWidth = value['sourceSize']['w'];
180
172
  const sourceHeight = value['sourceSize']['h'];
181
-
182
173
  if (typeof innerKey === 'string' && innerKey.toLowerCase().indexOf(delimiters[i].toLowerCase()) !== -1) {
183
174
  sprites[delimiters[i]].push({
184
175
  x: x,
@@ -195,11 +186,10 @@ const SpriteAnimator = ({
195
186
  }
196
187
  }
197
188
  }
198
-
199
189
  return sprites;
200
- }; // modify the sprite material after json is parsed and state updated
201
-
190
+ };
202
191
 
192
+ // modify the sprite material after json is parsed and state updated
203
193
  const modifySpritePosition = () => {
204
194
  if (!spriteData.current) return;
205
195
  const {
@@ -220,21 +210,21 @@ const SpriteAnimator = ({
220
210
  };
221
211
  matRef.current.map.wrapS = matRef.current.map.wrapT = THREE.RepeatWrapping;
222
212
  matRef.current.map.center.set(0, 0);
223
- matRef.current.map.repeat.set(1 * flipOffset / (metaInfo.w / frameW), 1 / (metaInfo.h / frameH)); //const framesH = (metaInfo.w - 1) / frameW
213
+ matRef.current.map.repeat.set(1 * flipOffset / (metaInfo.w / frameW), 1 / (metaInfo.h / frameH));
224
214
 
215
+ //const framesH = (metaInfo.w - 1) / frameW
225
216
  const framesV = (metaInfo.h - 1) / frameH;
226
217
  const frameOffsetY = 1 / framesV;
227
218
  matRef.current.map.offset.x = 0.0; //-matRef.current.map.repeat.x
228
-
229
219
  matRef.current.map.offset.y = 1 - frameOffsetY;
230
220
  setJsonReady(true);
231
221
  if (onStart) onStart({
232
222
  currentFrameName: frameName,
233
223
  currentFrame: currentFrame.current
234
224
  });
235
- }; // run the animation on each frame
236
-
225
+ };
237
226
 
227
+ // run the animation on each frame
238
228
  const runAnimation = () => {
239
229
  //if (!frameName) return
240
230
  const now = window.performance.now();
@@ -252,28 +242,23 @@ const SpriteAnimator = ({
252
242
  const spriteFrames = Array.isArray(frames) ? frames : frameName ? frames[frameName] : [];
253
243
  let finalValX = 0;
254
244
  let finalValY = 0;
255
-
256
245
  const _endFrame = endFrame || spriteFrames.length - 1;
257
-
258
246
  if (currentFrame.current > _endFrame) {
259
247
  currentFrame.current = loop ? startFrame !== null && startFrame !== void 0 ? startFrame : 0 : 0;
260
-
261
248
  if (loop) {
262
- onLoopEnd == null ? void 0 : onLoopEnd({
249
+ onLoopEnd == null || onLoopEnd({
263
250
  currentFrameName: frameName,
264
251
  currentFrame: currentFrame.current
265
252
  });
266
253
  } else {
267
- onEnd == null ? void 0 : onEnd({
254
+ onEnd == null || onEnd({
268
255
  currentFrameName: frameName,
269
256
  currentFrame: currentFrame.current
270
257
  });
271
258
  hasEnded.current = true;
272
259
  }
273
-
274
260
  if (!loop) return;
275
261
  }
276
-
277
262
  if (diff <= fpsInterval) return;
278
263
  timerOffset.current = now - diff % fpsInterval;
279
264
  calculateAspectRatio(frameW, frameH);
@@ -296,20 +281,17 @@ const SpriteAnimator = ({
296
281
  matRef.current.map.offset.x = finalValX;
297
282
  matRef.current.map.offset.y = finalValY;
298
283
  currentFrame.current += 1;
299
- }; // *** Warning! It runs on every frame! ***
300
-
284
+ };
301
285
 
286
+ // *** Warning! It runs on every frame! ***
302
287
  useFrame((state, delta) => {
303
288
  var _spriteData$current, _matRef$current;
304
-
305
289
  if (!((_spriteData$current = spriteData.current) != null && _spriteData$current.frames) || !((_matRef$current = matRef.current) != null && _matRef$current.map)) {
306
290
  return;
307
291
  }
308
-
309
292
  if (pause) {
310
293
  return;
311
294
  }
312
-
313
295
  if (!hasEnded.current && (autoPlay || play)) {
314
296
  runAnimation();
315
297
  onFrame && onFrame({
@@ -317,8 +299,9 @@ const SpriteAnimator = ({
317
299
  currentFrame: currentFrame.current
318
300
  });
319
301
  }
320
- }); // utils
302
+ });
321
303
 
304
+ // utils
322
305
  const getFirstItem = param => {
323
306
  if (Array.isArray(param)) {
324
307
  return param[0];
@@ -332,7 +315,6 @@ const SpriteAnimator = ({
332
315
  };
333
316
  }
334
317
  };
335
-
336
318
  return /*#__PURE__*/React.createElement("group", props, /*#__PURE__*/React.createElement(React.Suspense, {
337
319
  fallback: null
338
320
  }, displayAsSprite && /*#__PURE__*/React.createElement("sprite", {
package/core/Stage.d.ts CHANGED
@@ -1,17 +1,17 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  import { EnvironmentProps } from './Environment';
3
3
  import { ContactShadowsProps } from './ContactShadows';
4
4
  import { CenterProps } from './Center';
5
5
  import { AccumulativeShadowsProps, RandomizedLightProps } from './AccumulativeShadows';
6
6
  import { PresetsType } from '../helpers/environment-assets';
7
- declare type StageShadows = Partial<AccumulativeShadowsProps> & Partial<RandomizedLightProps> & Partial<ContactShadowsProps> & {
7
+ type StageShadows = Partial<AccumulativeShadowsProps> & Partial<RandomizedLightProps> & Partial<ContactShadowsProps> & {
8
8
  type: 'contact' | 'accumulative';
9
9
  offset?: number;
10
10
  bias?: number;
11
11
  normalBias?: number;
12
12
  size?: number;
13
13
  };
14
- declare type StageProps = {
14
+ type StageProps = {
15
15
  preset?: 'rembrandt' | 'portrait' | 'upfront' | 'soft' | {
16
16
  main: [x: number, y: number, z: number];
17
17
  fill: [x: number, y: number, z: number];
@@ -22,5 +22,5 @@ declare type StageProps = {
22
22
  intensity?: number;
23
23
  center?: Partial<CenterProps>;
24
24
  };
25
- export declare function Stage({ children, center, adjustCamera, intensity, shadows, environment, preset, ...props }: JSX.IntrinsicElements['group'] & StageProps): JSX.Element;
25
+ export declare function Stage({ children, center, adjustCamera, intensity, shadows, environment, preset, ...props }: JSX.IntrinsicElements['group'] & StageProps): React.JSX.Element;
26
26
  export {};
package/core/Stage.js CHANGED
@@ -24,7 +24,6 @@ const presets = {
24
24
  fill: [-1, 0.5, -1.5]
25
25
  }
26
26
  };
27
-
28
27
  function Refit({
29
28
  radius,
30
29
  adjustCamera
@@ -35,7 +34,6 @@ function Refit({
35
34
  }, [radius, adjustCamera]);
36
35
  return null;
37
36
  }
38
-
39
37
  function Stage({
40
38
  children,
41
39
  center,
@@ -47,7 +45,6 @@ function Stage({
47
45
  ...props
48
46
  }) {
49
47
  var _bias, _normalBias, _size, _offset, _amount, _radius, _ambient, _intensity;
50
-
51
48
  const config = typeof preset === 'string' ? presets[preset] : preset;
52
49
  const [{
53
50
  radius,
@@ -64,7 +61,8 @@ function Stage({
64
61
  const shadowOffset = (_offset = shadows == null ? void 0 : shadows.offset) !== null && _offset !== void 0 ? _offset : 0;
65
62
  const contactShadow = shadows === 'contact' || (shadows == null ? void 0 : shadows.type) === 'contact';
66
63
  const accumulativeShadow = shadows === 'accumulative' || (shadows == null ? void 0 : shadows.type) === 'accumulative';
67
- const shadowSpread = { ...(typeof shadows === 'object' ? shadows : {})
64
+ const shadowSpread = {
65
+ ...(typeof shadows === 'object' ? shadows : {})
68
66
  };
69
67
  const environmentProps = !environment ? null : typeof environment === 'string' ? {
70
68
  preset: environment
package/core/Stars.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ReactThreeFiber } from '@react-three/fiber';
2
2
  import { Points, ShaderMaterial } from 'three';
3
3
  import { ForwardRefComponent } from '../helpers/ts-utils';
4
- declare type Props = {
4
+ type Props = {
5
5
  radius?: number;
6
6
  depth?: number;
7
7
  count?: number;
package/core/Stars.js CHANGED
@@ -14,9 +14,7 @@ class StarfieldMaterial extends ShaderMaterial {
14
14
  value: 1.0
15
15
  }
16
16
  },
17
- vertexShader:
18
- /* glsl */
19
- `
17
+ vertexShader: /* glsl */`
20
18
  uniform float time;
21
19
  attribute float size;
22
20
  varying vec3 vColor;
@@ -26,9 +24,7 @@ class StarfieldMaterial extends ShaderMaterial {
26
24
  gl_PointSize = size * (30.0 / -mvPosition.z) * (3.0 + sin(time + 100.0));
27
25
  gl_Position = projectionMatrix * mvPosition;
28
26
  }`,
29
- fragmentShader:
30
- /* glsl */
31
- `
27
+ fragmentShader: /* glsl */`
32
28
  uniform sampler2D pointTexture;
33
29
  uniform float fade;
34
30
  varying vec3 vColor;
@@ -45,13 +41,10 @@ class StarfieldMaterial extends ShaderMaterial {
45
41
  }`
46
42
  });
47
43
  }
48
-
49
44
  }
50
-
51
45
  const genStar = r => {
52
46
  return new Vector3().setFromSpherical(new Spherical(r, Math.acos(1 - Math.random() * 2), Math.random() * 2 * Math.PI));
53
47
  };
54
-
55
48
  const Stars = /*#__PURE__*/React.forwardRef(({
56
49
  radius = 100,
57
50
  depth = 50,
@@ -71,14 +64,12 @@ const Stars = /*#__PURE__*/React.forwardRef(({
71
64
  const color = new Color();
72
65
  let r = radius + depth;
73
66
  const increment = depth / count;
74
-
75
67
  for (let i = 0; i < count; i++) {
76
68
  r -= increment * Math.random();
77
69
  positions.push(...genStar(r).toArray());
78
70
  color.setHSL(i / count, saturation, 0.9);
79
71
  colors.push(color.r, color.g, color.b);
80
72
  }
81
-
82
73
  return [new Float32Array(positions), new Float32Array(colors), new Float32Array(sizes)];
83
74
  }, [count, depth, factor, radius, saturation]);
84
75
  useFrame(state => material.current && (material.current.uniforms.time.value = state.clock.getElapsedTime() * speed));
package/core/Stats.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- declare type Props = {
2
+ type Props = {
3
3
  showPanel?: number;
4
4
  className?: string;
5
5
  parent?: React.RefObject<HTMLElement>;
package/core/Stats.js CHANGED
@@ -13,12 +13,12 @@ function Stats({
13
13
  if (stats) {
14
14
  const node = parent && parent.current || document.body;
15
15
  stats.showPanel(showPanel);
16
- node == null ? void 0 : node.appendChild(stats.dom);
16
+ node == null || node.appendChild(stats.dom);
17
17
  if (className) stats.dom.classList.add(...className.split(' ').filter(cls => cls));
18
18
  const begin = addEffect(() => stats.begin());
19
19
  const end = addAfterEffect(() => stats.end());
20
20
  return () => {
21
- node == null ? void 0 : node.removeChild(stats.dom);
21
+ node == null || node.removeChild(stats.dom);
22
22
  begin();
23
23
  end();
24
24
  };
package/core/StatsGl.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import Stats from 'stats-gl';
3
- declare type Props = Partial<Stats> & {
3
+ type Props = Partial<Stats> & {
4
4
  showPanel?: number;
5
5
  className?: string;
6
6
  parent?: React.RefObject<HTMLElement>;
package/core/StatsGl.js CHANGED
@@ -9,7 +9,8 @@ function StatsGl({
9
9
  }) {
10
10
  const gl = useThree(state => state.gl);
11
11
  const stats = React.useMemo(() => {
12
- const stats = new Stats({ ...props
12
+ const stats = new Stats({
13
+ ...props
13
14
  });
14
15
  stats.init(gl.domElement);
15
16
  return stats;
@@ -17,12 +18,12 @@ function StatsGl({
17
18
  React.useEffect(() => {
18
19
  if (stats) {
19
20
  const node = parent && parent.current || document.body;
20
- node == null ? void 0 : node.appendChild(stats.container);
21
+ node == null || node.appendChild(stats.container);
21
22
  if (className) stats.container.classList.add(...className.split(' ').filter(cls => cls));
22
23
  const begin = addEffect(() => stats.begin());
23
24
  const end = addAfterEffect(() => stats.end());
24
25
  return () => {
25
- node == null ? void 0 : node.removeChild(stats.container);
26
+ node == null || node.removeChild(stats.container);
26
27
  begin();
27
28
  end();
28
29
  };
package/core/Svg.js CHANGED
@@ -18,7 +18,6 @@ const Svg = /*#__PURE__*/forwardRef(function R3FSvg({
18
18
  const svg = useLoader(SVGLoader, !src.startsWith('<svg') ? src : `data:image/svg+xml;utf8,${src}`);
19
19
  const strokeGeometries = useMemo(() => skipStrokes ? [] : svg.paths.map(path => {
20
20
  var _path$userData;
21
-
22
21
  return ((_path$userData = path.userData) == null ? void 0 : _path$userData.style.stroke) === undefined || path.userData.style.stroke === 'none' ? null : path.subPaths.map(subPath => SVGLoader.pointsToStroke(subPath.getPoints(), path.userData.style));
23
22
  }), [svg, skipStrokes]);
24
23
  useEffect(() => {
@@ -30,7 +29,6 @@ const Svg = /*#__PURE__*/forwardRef(function R3FSvg({
30
29
  scale: [1, -1, 1]
31
30
  }, svg.paths.map((path, p) => {
32
31
  var _path$userData2, _path$userData3;
33
-
34
32
  return /*#__PURE__*/React.createElement(Fragment, {
35
33
  key: p
36
34
  }, !skipFill && ((_path$userData2 = path.userData) == null ? void 0 : _path$userData2.style.fill) !== undefined && path.userData.style.fill !== 'none' && SVGLoader.createShapes(path).map((shape, s) => /*#__PURE__*/React.createElement("mesh", _extends({
package/core/Text.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { ReactThreeFiber } from '@react-three/fiber';
3
3
  import { ForwardRefComponent } from '../helpers/ts-utils';
4
- declare type Props = JSX.IntrinsicElements['mesh'] & {
4
+ type Props = JSX.IntrinsicElements['mesh'] & {
5
5
  children: React.ReactNode;
6
6
  characters?: string;
7
7
  color?: ReactThreeFiber.Color;
package/core/Text3D.d.ts CHANGED
@@ -11,7 +11,7 @@ declare global {
11
11
  }
12
12
  }
13
13
  }
14
- declare type Text3DProps = {
14
+ type Text3DProps = {
15
15
  font: FontData | string;
16
16
  bevelSegments?: number;
17
17
  smooth?: number;
package/core/Text3D.js CHANGED
@@ -6,7 +6,6 @@ import { TextGeometry, mergeVertices } from 'three-stdlib';
6
6
  import { useFont } from './useFont.js';
7
7
 
8
8
  const types = ['string', 'number'];
9
-
10
9
  const getTextFromChildren = children => {
11
10
  let label = '';
12
11
  const rest = [];
@@ -15,7 +14,6 @@ const getTextFromChildren = children => {
15
14
  });
16
15
  return [label, ...rest];
17
16
  };
18
-
19
17
  const Text3D = /*#__PURE__*/React.forwardRef(({
20
18
  font: _font,
21
19
  letterSpacing = 0,
@@ -52,11 +50,11 @@ const Text3D = /*#__PURE__*/React.forwardRef(({
52
50
  lineHeight
53
51
  };
54
52
  }, [font, size, height, bevelThickness, bevelSize, bevelEnabled, bevelSegments, bevelOffset, curveSegments, letterSpacing, lineHeight]);
53
+
55
54
  /**
56
55
  * We need the `children` in the deps because we
57
56
  * need to be able to do `<Text3d>{state}</Text3d>`.
58
57
  */
59
-
60
58
  const [label, ...rest] = useMemo(() => getTextFromChildren(children), [children]);
61
59
  const args = React.useMemo(() => [label, opts], [label, opts]);
62
60
  React.useLayoutEffect(() => {
@@ -2,7 +2,7 @@ import { ReactThreeFiber } from '@react-three/fiber';
2
2
  import * as THREE from 'three';
3
3
  import { TrackballControls as TrackballControlsImpl } from 'three-stdlib';
4
4
  import { ForwardRefComponent } from '../helpers/ts-utils';
5
- export declare type TrackballControlsProps = ReactThreeFiber.Overwrite<ReactThreeFiber.Object3DNode<TrackballControlsImpl, typeof TrackballControlsImpl>, {
5
+ export type TrackballControlsProps = ReactThreeFiber.Overwrite<ReactThreeFiber.Object3DNode<TrackballControlsImpl, typeof TrackballControlsImpl>, {
6
6
  target?: ReactThreeFiber.Vector3;
7
7
  camera?: THREE.Camera;
8
8
  domElement?: HTMLElement;
@@ -39,7 +39,6 @@ const TrackballControls = /*#__PURE__*/React.forwardRef(({
39
39
  if (regress) performance.regress();
40
40
  if (onChange) onChange(e);
41
41
  };
42
-
43
42
  controls.addEventListener('change', callback);
44
43
  if (onStart) controls.addEventListener('start', onStart);
45
44
  if (onEnd) controls.addEventListener('end', onEnd);
package/core/Trail.d.ts CHANGED
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { ColorRepresentation, Object3D } from 'three';
3
3
  import { MeshLineGeometry as MeshLineGeometryImpl } from 'meshline';
4
4
  import { ForwardRefComponent } from '../helpers/ts-utils';
5
- declare type Settings = {
5
+ type Settings = {
6
6
  width: number;
7
7
  length: number;
8
8
  decay: number;
@@ -10,12 +10,12 @@ declare type Settings = {
10
10
  stride: number;
11
11
  interval: number;
12
12
  };
13
- declare type TrailProps = {
13
+ type TrailProps = {
14
14
  color?: ColorRepresentation;
15
15
  attenuation?: (width: number) => number;
16
16
  target?: React.MutableRefObject<Object3D>;
17
17
  } & Partial<Settings>;
18
18
  export declare function useTrail(target: Object3D, settings: Partial<Settings>): React.MutableRefObject<Float32Array | undefined>;
19
- export declare type MeshLineGeometry = THREE.Mesh & MeshLineGeometryImpl;
19
+ export type MeshLineGeometry = THREE.Mesh & MeshLineGeometryImpl;
20
20
  export declare const Trail: ForwardRefComponent<React.PropsWithChildren<TrailProps>, MeshLineGeometry>;
21
21
  export {};