@react-three/drei 9.120.5 → 9.120.7

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": "9.120.5",
3
+ "version": "9.120.7",
4
4
  "private": false,
5
5
  "description": "useful add-ons for react-three-fiber",
6
6
  "keywords": [
@@ -47,7 +47,7 @@
47
47
  "stats.js": "^0.17.0",
48
48
  "suspend-react": "^0.1.3",
49
49
  "three-mesh-bvh": "^0.7.8",
50
- "three-stdlib": "^2.34.0",
50
+ "three-stdlib": "^2.35.6",
51
51
  "troika-three-text": "^0.52.0",
52
52
  "tunnel-rat": "^0.1.2",
53
53
  "utility-types": "^3.11.0",
@@ -4,12 +4,12 @@ import * as THREE from 'three';
4
4
  import { useThree } from '@react-three/fiber';
5
5
  import { useGesture } from '@use-gesture/react';
6
6
 
7
- const initialModelPosition = new THREE.Vector3();
8
- const mousePosition2D = new THREE.Vector2();
9
- const mousePosition3D = new THREE.Vector3();
10
- const dragOffset = new THREE.Vector3();
11
- const dragPlaneNormal = new THREE.Vector3();
12
- const dragPlane = new THREE.Plane();
7
+ const initialModelPosition = /* @__PURE__ */new THREE.Vector3();
8
+ const mousePosition2D = /* @__PURE__ */new THREE.Vector2();
9
+ const mousePosition3D = /* @__PURE__ */new THREE.Vector3();
10
+ const dragOffset = /* @__PURE__ */new THREE.Vector3();
11
+ const dragPlaneNormal = /* @__PURE__ */new THREE.Vector3();
12
+ const dragPlane = /* @__PURE__ */new THREE.Plane();
13
13
  const DragControls = /*#__PURE__*/React.forwardRef(({
14
14
  autoTransform = true,
15
15
  matrix,
package/web/View.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("react"),r=require("three"),n=require("@react-three/fiber"),c=require("tunnel-rat");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function a(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var o=i(e),s=a(t),l=a(r),u=i(c);const f=new l.Color,d=u.default();function m(e){return"top"in e}function h(e,t){const{right:r,top:n,left:c,bottom:i,width:a,height:o}=t,s=t.bottom<0||n>e.height||r<0||t.left>e.width;if(m(e)){const t=e.top+e.height-i;return{position:{width:a,height:o,left:c-e.left,top:n,bottom:t,right:r},isOffscreen:s}}return{position:{width:a,height:o,top:n,left:c,bottom:e.height-i,right:r},isOffscreen:s}}function g(e,{left:t,bottom:r,width:n,height:c}){let i;const a=n/c;var o;return(o=e.camera)&&o.isOrthographicCamera?e.camera.left===n/-2&&e.camera.right===n/2&&e.camera.top===c/2&&e.camera.bottom===c/-2||(Object.assign(e.camera,{left:n/-2,right:n/2,top:c/2,bottom:c/-2}),e.camera.updateProjectionMatrix()):e.camera.aspect!==a&&(e.camera.aspect=a,e.camera.updateProjectionMatrix()),i=e.gl.autoClear,e.gl.autoClear=!1,e.gl.setViewport(t,r,n,c),e.gl.setScissor(t,r,n,c),e.gl.setScissorTest(!0),i}function p(e,t){e.gl.setScissorTest(!1),e.gl.autoClear=t}function v(e){e.gl.getClearColor(f),e.gl.setClearColor(f,e.gl.getClearAlpha()),e.gl.clear(!0,!0)}function b({visible:e=!0,canvasSize:t,scene:r,index:c,children:i,frames:a,rect:o,track:l}){const u=n.useThree(),[f,d]=s.useState(!1);let b=0;return n.useFrame((n=>{var c;(a===1/0||b<=a)&&(l&&(o.current=null==(c=l.current)?void 0:c.getBoundingClientRect()),b++);if(o.current){const{position:c,isOffscreen:a}=h(t,o.current);if(f!==a&&d(a),e&&!f&&o.current){const e=g(n,c);n.gl.render(i?n.scene:r,n.camera),p(n,e)}}}),c),s.useLayoutEffect((()=>{const r=o.current;if(r&&(!e||!f)){const{position:e}=h(t,r),n=g(u,e);v(u),p(u,n)}}),[e,f]),s.useEffect((()=>{if(!l)return;const e=o.current,r=u.get().events.connected;return u.setEvents({connected:l.current}),()=>{if(e){const{position:r}=h(t,e),n=g(u,r);v(u),p(u,n)}u.setEvents({connected:r})}}),[l]),s.useEffect((()=>{m(t)||console.warn("Detected @react-three/fiber canvas size does not include position information. <View /> may not work as expected. Upgrade to @react-three/fiber ^8.1.0 for support.\n See https://github.com/pmndrs/drei/issues/944")}),[]),s.createElement(s.Fragment,null,i,s.createElement("group",{onPointerOver:()=>null}))}const w=s.forwardRef((({track:e,visible:t=!0,index:r=1,id:c,style:i,className:a,frames:u=1/0,children:f,...d},m)=>{var h,g,p,v;const w=s.useRef(null),{size:E,scene:C}=n.useThree(),[O]=s.useState((()=>new l.Scene)),[x,y]=s.useReducer((()=>!0),!1),j=s.useCallback(((t,r)=>{if(w.current&&e&&e.current&&t.target===e.current){const{width:e,height:n,left:c,top:i}=w.current,a=t.clientX-c,o=t.clientY-i;r.pointer.set(a/e*2-1,-o/n*2+1),r.raycaster.setFromCamera(r.pointer,r.camera)}}),[w,e]);return s.useEffect((()=>{var t;e&&(w.current=null==(t=e.current)?void 0:t.getBoundingClientRect()),y()}),[e]),s.createElement("group",o.default({ref:m},d),x&&n.createPortal(s.createElement(b,{visible:t,canvasSize:E,frames:u,scene:C,track:e,rect:w,index:r},f),O,{events:{compute:j,priority:r},size:{width:null==(h=w.current)?void 0:h.width,height:null==(g=w.current)?void 0:g.height,top:null==(p=w.current)?void 0:p.top,left:null==(v=w.current)?void 0:v.left}}))})),E=s.forwardRef((({as:e="div",id:t,visible:r,className:n,style:c,index:i=1,track:a,frames:l=1/0,children:u,...f},m)=>{const h=s.useId(),g=s.useRef(null);return s.useImperativeHandle(m,(()=>g.current)),s.createElement(s.Fragment,null,s.createElement(e,o.default({ref:g,id:t,className:n,style:c},f)),s.createElement(d.In,null,s.createElement(w,{visible:r,key:h,track:g,frames:l,index:i},u)))})),C=s.forwardRef(((e,t)=>s.useContext(n.context)?s.createElement(w,o.default({ref:t},e)):s.createElement(E,o.default({ref:t},e))));C.Port=()=>s.createElement(d.Out,null),exports.View=C;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("react"),r=require("three"),n=require("@react-three/fiber"),c=require("tunnel-rat");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function a(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var o=i(e),s=a(t),l=a(r),u=i(c);const f=new l.Color,d=u.default();function m(e){return"top"in e}function h(e,t){const{right:r,top:n,left:c,bottom:i,width:a,height:o}=t,s=t.bottom<0||n>e.height||r<0||t.left>e.width;if(m(e)){const t=e.top+e.height-i;return{position:{width:a,height:o,left:c-e.left,top:n,bottom:t,right:r},isOffscreen:s}}return{position:{width:a,height:o,top:n,left:c,bottom:e.height-i,right:r},isOffscreen:s}}function g(e,{left:t,bottom:r,width:n,height:c}){let i;const a=n/c;var o;return(o=e.camera)&&o.isOrthographicCamera?e.camera.left===n/-2&&e.camera.right===n/2&&e.camera.top===c/2&&e.camera.bottom===c/-2||(Object.assign(e.camera,{left:n/-2,right:n/2,top:c/2,bottom:c/-2}),e.camera.updateProjectionMatrix()):e.camera.aspect!==a&&(e.camera.aspect=a,e.camera.updateProjectionMatrix()),i=e.gl.autoClear,e.gl.autoClear=!1,e.gl.setViewport(t,r,n,c),e.gl.setScissor(t,r,n,c),e.gl.setScissorTest(!0),i}function p(e,t){e.gl.setScissorTest(!1),e.gl.autoClear=t}function v(e){e.gl.getClearColor(f),e.gl.setClearColor(f,e.gl.getClearAlpha()),e.gl.clear(!0,!0)}function b({visible:e=!0,canvasSize:t,scene:r,index:c,children:i,frames:a,rect:o,track:l}){const u=n.useThree(),[f,d]=s.useState(!1);let b=0;return n.useFrame((n=>{var c;(a===1/0||b<=a)&&(l&&(o.current=null==(c=l.current)?void 0:c.getBoundingClientRect()),b++);if(o.current){const{position:c,isOffscreen:a}=h(t,o.current);if(f!==a&&d(a),e&&!f&&o.current){const e=g(n,c);n.gl.render(i?n.scene:r,n.camera),p(n,e)}}}),c),s.useLayoutEffect((()=>{const r=o.current;if(r&&(!e||!f)){const{position:e}=h(t,r),n=g(u,e);v(u),p(u,n)}}),[e,f]),s.useEffect((()=>{if(!l)return;const e=o.current,r=u.get().events.connected;return u.setEvents({connected:l.current}),()=>{if(e){const{position:r}=h(t,e),n=g(u,r);v(u),p(u,n)}u.setEvents({connected:r})}}),[l]),s.useEffect((()=>{m(t)||console.warn("Detected @react-three/fiber canvas size does not include position information. <View /> may not work as expected. Upgrade to @react-three/fiber ^8.1.0 for support.\n See https://github.com/pmndrs/drei/issues/944")}),[]),s.createElement(s.Fragment,null,i,s.createElement("group",{onPointerOver:()=>null}))}const w=s.forwardRef((({track:e,visible:t=!0,index:r=1,id:c,style:i,className:a,frames:u=1/0,children:f,...d},m)=>{var h,g,p,v;const w=s.useRef(null),{size:E,scene:C}=n.useThree(),[O]=s.useState((()=>new l.Scene)),[x,y]=s.useReducer((()=>!0),!1),j=s.useCallback(((t,r)=>{if(w.current&&e&&e.current&&t.target===e.current){const{width:e,height:n,left:c,top:i}=w.current,a=t.clientX-c,o=t.clientY-i;r.pointer.set(a/e*2-1,-o/n*2+1),r.raycaster.setFromCamera(r.pointer,r.camera)}}),[w,e]);return s.useEffect((()=>{var t;e&&(w.current=null==(t=e.current)?void 0:t.getBoundingClientRect()),y()}),[e]),s.createElement("group",o.default({ref:m},d),x&&n.createPortal(s.createElement(b,{visible:t,canvasSize:E,frames:u,scene:C,track:e,rect:w,index:r},f),O,{events:{compute:j,priority:r},size:{width:null==(h=w.current)?void 0:h.width,height:null==(g=w.current)?void 0:g.height,top:null==(p=w.current)?void 0:p.top,left:null==(v=w.current)?void 0:v.left}}))})),E=s.forwardRef((({as:e="div",id:t,visible:r,className:n,style:c,index:i=1,track:a,frames:l=1/0,children:u,...f},m)=>{const h=s.useId(),g=s.useRef(null);return s.useImperativeHandle(m,(()=>g.current)),s.createElement(s.Fragment,null,s.createElement(e,o.default({ref:g,id:t,className:n,style:c},f)),s.createElement(d.In,null,s.createElement(w,{visible:r,key:h,track:g,frames:l,index:i},u)))})),C=(()=>{const e=s.forwardRef(((e,t)=>s.useContext(n.context)?s.createElement(w,o.default({ref:t},e)):s.createElement(E,o.default({ref:t},e))));return e.Port=()=>s.createElement(d.Out,null),e})();exports.View=C;
package/web/View.js CHANGED
@@ -5,8 +5,8 @@ import { context, useThree, createPortal, useFrame } from '@react-three/fiber';
5
5
  import tunnel from 'tunnel-rat';
6
6
 
7
7
  const isOrthographicCamera = def => def && def.isOrthographicCamera;
8
- const col = new THREE.Color();
9
- const tracked = tunnel();
8
+ const col = /* @__PURE__ */new THREE.Color();
9
+ const tracked = /* @__PURE__ */tunnel();
10
10
 
11
11
  /**
12
12
  * In `@react-three/fiber` after `v8.0.0` but prior to `v8.1.0`, `state.size` contained only dimension
@@ -172,7 +172,7 @@ function Container({
172
172
  onPointerOver: () => null
173
173
  }));
174
174
  }
175
- const CanvasView = /*#__PURE__*/React.forwardRef(({
175
+ const CanvasView = /* @__PURE__ */React.forwardRef(({
176
176
  track,
177
177
  visible = true,
178
178
  index = 1,
@@ -237,7 +237,7 @@ const CanvasView = /*#__PURE__*/React.forwardRef(({
237
237
  }
238
238
  }));
239
239
  });
240
- const HtmlView = /*#__PURE__*/React.forwardRef(({
240
+ const HtmlView = /* @__PURE__ */React.forwardRef(({
241
241
  as: El = 'div',
242
242
  id,
243
243
  visible,
@@ -265,18 +265,21 @@ const HtmlView = /*#__PURE__*/React.forwardRef(({
265
265
  index: index
266
266
  }, children)));
267
267
  });
268
- const View = /*#__PURE__*/React.forwardRef((props, fref) => {
269
- // If we're inside a canvas we should be able to access the context store
270
- const store = React.useContext(context);
271
- // If that's not the case we render a tunnel
272
- if (!store) return /*#__PURE__*/React.createElement(HtmlView, _extends({
273
- ref: fref
274
- }, props));
275
- // Otherwise a plain canvas-view
276
- else return /*#__PURE__*/React.createElement(CanvasView, _extends({
277
- ref: fref
278
- }, props));
279
- });
280
- View.Port = () => /*#__PURE__*/React.createElement(tracked.Out, null);
268
+ const View = /* @__PURE__ */(() => {
269
+ const _View = /*#__PURE__*/React.forwardRef((props, fref) => {
270
+ // If we're inside a canvas we should be able to access the context store
271
+ const store = React.useContext(context);
272
+ // If that's not the case we render a tunnel
273
+ if (!store) return /*#__PURE__*/React.createElement(HtmlView, _extends({
274
+ ref: fref
275
+ }, props));
276
+ // Otherwise a plain canvas-view
277
+ else return /*#__PURE__*/React.createElement(CanvasView, _extends({
278
+ ref: fref
279
+ }, props));
280
+ });
281
+ _View.Port = () => /*#__PURE__*/React.createElement(tracked.Out, null);
282
+ return _View;
283
+ })();
281
284
 
282
285
  export { View };