@react-three/drei 7.26.0 → 7.26.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/drei",
3
- "version": "7.26.0",
3
+ "version": "7.26.1",
4
4
  "private": false,
5
5
  "description": "useful add-ons for react-three-fiber",
6
6
  "keywords": [
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("three"),r=require("react"),o=require("@react-three/fiber"),a=require("@react-spring/three"),n=require("@use-gesture/react");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=s(e);exports.PresentationControls=function({snap:e,global:s,children:u,speed:c=1,rotation:l=[0,0,0],zoom:f=1,polar:m=[0,Math.PI/2],azimuth:d=[-1/0,1/0],config:g={mass:1,tension:170,friction:26}}){const{size:h,gl:p}=o.useThree(),b=r.useMemo((()=>[l[0]+m[0],l[0]+m[1]]),[l[0],m[0],m[1]]),M=r.useMemo((()=>[l[1]+d[0],l[1]+d[1]]),[l[1],d[0],d[1]]),y=r.useMemo((()=>[t.MathUtils.clamp(l[0],...b),t.MathUtils.clamp(l[1],...M),l[2]]),[l[0],l[1],l[2],b,M]),[q,v]=a.useSpring((()=>({scale:1,rotation:y,config:g})));r.useEffect((()=>{v.start({scale:1,rotation:y,config:g})}),[y]),r.useEffect((()=>{s&&(document.body.style.cursor="grab")}),[s]);const P=n.useGesture({onHover:({last:e})=>{s||(document.body.style.cursor=e?"auto":"grab")},onDrag:({down:r,delta:[o,a],memo:[n,s]=q.rotation.animation.to||y})=>{document.body.style.cursor=r?"grabbing":"grab",o=t.MathUtils.clamp(s+o/h.width*Math.PI*c,...M),a=t.MathUtils.clamp(n+a/h.height*Math.PI*c,...b);const i=e&&!r&&"boolean"!=typeof e?e:g;return v.start({scale:r&&a>b[1]/2?f:1,rotation:e&&!r?y:[a,o,0],config:e=>"scale"===e?{...i,friction:3*i.friction}:i}),[a,o]}},{target:s&&p.domElement});return React.createElement(a.a.group,i.default({},null==P?void 0:P(),q),u)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("react"),r=require("three"),o=require("@react-three/fiber"),n=require("@react-spring/three"),a=require("@use-gesture/react");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function s(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var u=i(e),c=s(t);exports.PresentationControls=function({snap:e,global:t,children:i,speed:s=1,rotation:l=[0,0,0],zoom:f=1,polar:d=[0,Math.PI/2],azimuth:b=[-1/0,1/0],config:g={mass:1,tension:170,friction:26}}){const{size:m,gl:p}=o.useThree(),h=c.useMemo((()=>[l[0]+d[0],l[0]+d[1]]),[l[0],d[0],d[1]]),y=c.useMemo((()=>[l[1]+b[0],l[1]+b[1]]),[l[1],b[0],b[1]]),M=c.useMemo((()=>[r.MathUtils.clamp(l[0],...h),r.MathUtils.clamp(l[1],...y),l[2]]),[l[0],l[1],l[2],h,y]),[j,v]=n.useSpring((()=>({scale:1,rotation:M,config:g})));c.useEffect((()=>{v.start({scale:1,rotation:M,config:g})}),[M]),c.useEffect((()=>{t&&(document.body.style.cursor="grab")}),[t]);const O=a.useGesture({onHover:({last:e})=>{t||(document.body.style.cursor=e?"auto":"grab")},onDrag:({down:t,delta:[o,n],memo:[a,i]=j.rotation.animation.to||M})=>{document.body.style.cursor=t?"grabbing":"grab",o=r.MathUtils.clamp(i+o/m.width*Math.PI*s,...y),n=r.MathUtils.clamp(a+n/m.height*Math.PI*s,...h);const u=e&&!t&&"boolean"!=typeof e?e:g;return v.start({scale:t&&n>h[1]/2?f:1,rotation:e&&!t?M:[n,o,0],config:e=>"scale"===e?{...u,friction:3*u.friction}:u}),[n,o]}},{target:t&&p.domElement});return c.createElement(n.a.group,u.default({},null==O?void 0:O(),j),i)};
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  declare type Props = {
3
3
  snap?: boolean;
4
4
  global?: boolean;
@@ -1,6 +1,6 @@
1
1
  import _extends from '@babel/runtime/helpers/esm/extends';
2
+ import * as React from 'react';
2
3
  import { MathUtils } from 'three';
3
- import { useMemo, useEffect } from 'react';
4
4
  import { useThree } from '@react-three/fiber';
5
5
  import { useSpring, a } from '@react-spring/three';
6
6
  import { useGesture } from '@use-gesture/react';
@@ -24,20 +24,20 @@ function PresentationControls({
24
24
  size,
25
25
  gl
26
26
  } = useThree();
27
- const rPolar = useMemo(() => [rotation[0] + polar[0], rotation[0] + polar[1]], [rotation[0], polar[0], polar[1]]);
28
- const rAzimuth = useMemo(() => [rotation[1] + azimuth[0], rotation[1] + azimuth[1]], [rotation[1], azimuth[0], azimuth[1]]);
29
- const rInitial = useMemo(() => [MathUtils.clamp(rotation[0], ...rPolar), MathUtils.clamp(rotation[1], ...rAzimuth), rotation[2]], [rotation[0], rotation[1], rotation[2], rPolar, rAzimuth]);
27
+ const rPolar = React.useMemo(() => [rotation[0] + polar[0], rotation[0] + polar[1]], [rotation[0], polar[0], polar[1]]);
28
+ const rAzimuth = React.useMemo(() => [rotation[1] + azimuth[0], rotation[1] + azimuth[1]], [rotation[1], azimuth[0], azimuth[1]]);
29
+ const rInitial = React.useMemo(() => [MathUtils.clamp(rotation[0], ...rPolar), MathUtils.clamp(rotation[1], ...rAzimuth), rotation[2]], [rotation[0], rotation[1], rotation[2], rPolar, rAzimuth]);
30
30
  const [spring, api] = useSpring(() => ({
31
31
  scale: 1,
32
32
  rotation: rInitial,
33
33
  config
34
34
  }));
35
- useEffect(() => void api.start({
35
+ React.useEffect(() => void api.start({
36
36
  scale: 1,
37
37
  rotation: rInitial,
38
38
  config
39
39
  }), [rInitial]);
40
- useEffect(() => {
40
+ React.useEffect(() => {
41
41
  if (global) document.body.style.cursor = 'grab';
42
42
  }, [global]);
43
43
  const bind = useGesture({