@react-three/drei 10.7.1 → 10.7.3

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": "10.7.1",
3
+ "version": "10.7.3",
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("react"),t=require("three"),r=require("@react-three/fiber"),n=require("../../core/Line.cjs.js"),o=require("../Html.cjs.js"),a=require("./context.cjs.js");function i(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)}require("@babel/runtime/helpers/extends"),require("three-stdlib"),require("react-dom/client");var c=i(e),l=i(t);const s=new l.Vector3,u=new l.Vector3,d=(e,t,r,n)=>{const o=t.dot(t),a=t.dot(e)-t.dot(r),i=t.dot(n);if(0===i)return-a/o;s.copy(n).multiplyScalar(o/i).sub(t),u.copy(n).multiplyScalar(a/i).add(r).sub(e);return-s.dot(u)/s.dot(s)},p=new l.Vector3(0,1,0),m=new l.Matrix4;exports.AxisArrow=({direction:e,axis:t})=>{const{translation:i,translationLimits:s,annotations:u,annotationsClass:f,depthTest:x,scale:y,lineWidth:g,fixed:h,axisColors:b,hoveredColor:P,opacity:w,onDragStart:O,onDrag:v,onDragEnd:j,userData:E}=c.useContext(a.context),M=r.useThree((e=>e.controls)),k=c.useRef(null),C=c.useRef(null),q=c.useRef(null),L=c.useRef(0),[D,F]=c.useState(!1),R=c.useCallback((r=>{u&&(k.current.innerText=`${i.current[t].toFixed(2)}`,k.current.style.display="block"),r.stopPropagation();const n=(new l.Matrix4).extractRotation(C.current.matrixWorld),o=r.point.clone(),a=(new l.Vector3).setFromMatrixPosition(C.current.matrixWorld),c=e.clone().applyMatrix4(n).normalize();q.current={clickPoint:o,dir:c},L.current=i.current[t],O({component:"Arrow",axis:t,origin:a,directions:[c]}),M&&(M.enabled=!1),r.target.setPointerCapture(r.pointerId)}),[u,e,M,O,i,t]),T=c.useCallback((e=>{if(e.stopPropagation(),D||F(!0),q.current){const{clickPoint:r,dir:n}=q.current,[o,a]=(null==s?void 0:s[t])||[void 0,void 0];let c=d(r,n,e.ray.origin,e.ray.direction);void 0!==o&&(c=Math.max(c,o-L.current)),void 0!==a&&(c=Math.min(c,a-L.current)),i.current[t]=L.current+c,u&&(k.current.innerText=`${i.current[t].toFixed(2)}`),m.makeTranslation(n.x*c,n.y*c,n.z*c),v(m)}}),[u,v,D,i,s,t]),S=c.useCallback((e=>{u&&(k.current.style.display="none"),e.stopPropagation(),q.current=null,j(),M&&(M.enabled=!0),e.target.releasePointerCapture(e.pointerId)}),[u,M,j]),W=c.useCallback((e=>{e.stopPropagation(),F(!1)}),[]),{cylinderLength:V,coneWidth:z,coneLength:A,matrixL:_}=c.useMemo((()=>{const t=h?g/y*1.6:y/20,r=h?.2:y/5,n=h?1-r:y-r,o=(new l.Quaternion).setFromUnitVectors(p,e.clone().normalize());return{cylinderLength:n,coneWidth:t,coneLength:r,matrixL:(new l.Matrix4).makeRotationFromQuaternion(o)}}),[e,y,g,h]),U=D?P:b[t];return c.createElement("group",{ref:C},c.createElement("group",{matrix:_,matrixAutoUpdate:!1,onPointerDown:R,onPointerMove:T,onPointerUp:S,onPointerOut:W},u&&c.createElement(o.Html,{position:[0,-A,0]},c.createElement("div",{style:{display:"none",background:"#151520",color:"white",padding:"6px 8px",borderRadius:7,whiteSpace:"nowrap"},className:f,ref:k})),c.createElement("mesh",{visible:!1,position:[0,(V+A)/2,0],userData:E},c.createElement("cylinderGeometry",{args:[1.4*z,1.4*z,V+A,8,1]})),c.createElement(n.Line,{transparent:!0,raycast:()=>null,depthTest:x,points:[0,0,0,0,V,0],lineWidth:g,side:l.DoubleSide,color:U,opacity:w,polygonOffset:!0,renderOrder:1,polygonOffsetFactor:-10,fog:!1}),c.createElement("mesh",{raycast:()=>null,position:[0,V+A/2,0],renderOrder:500},c.createElement("coneGeometry",{args:[z,A,24,1]}),c.createElement("meshBasicMaterial",{transparent:!0,depthTest:x,color:U,opacity:w,polygonOffset:!0,polygonOffsetFactor:-10,fog:!1}))))},exports.calculateOffset=d;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("three"),r=require("@react-three/fiber"),n=require("../../core/Line.cjs.js"),o=require("../Html.cjs.js"),a=require("./context.cjs.js");function i(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)}require("@babel/runtime/helpers/extends"),require("three-stdlib"),require("react-dom/client");var c=i(e),l=i(t);const s=new l.Vector3,u=new l.Vector3,d=(e,t,r,n)=>{const o=t.dot(t),a=t.dot(e)-t.dot(r),i=t.dot(n);if(0===i)return-a/o;s.copy(n).multiplyScalar(o/i).sub(t),u.copy(n).multiplyScalar(a/i).add(r).sub(e);return-s.dot(u)/s.dot(s)},p=new l.Vector3(0,1,0),m=new l.Matrix4;exports.AxisArrow=({direction:e,axis:t})=>{const{translation:i,translationLimits:s,annotations:u,annotationsClass:f,depthTest:x,scale:y,lineWidth:g,fixed:h,axisColors:b,hoveredColor:O,opacity:P,renderOrder:w,onDragStart:v,onDrag:j,onDragEnd:E,userData:M}=c.useContext(a.context),k=r.useThree((e=>e.controls)),C=c.useRef(null),q=c.useRef(null),L=c.useRef(null),D=c.useRef(0),[F,R]=c.useState(!1),T=c.useCallback((r=>{u&&(C.current.innerText=`${i.current[t].toFixed(2)}`,C.current.style.display="block"),r.stopPropagation();const n=(new l.Matrix4).extractRotation(q.current.matrixWorld),o=r.point.clone(),a=(new l.Vector3).setFromMatrixPosition(q.current.matrixWorld),c=e.clone().applyMatrix4(n).normalize();L.current={clickPoint:o,dir:c},D.current=i.current[t],v({component:"Arrow",axis:t,origin:a,directions:[c]}),k&&(k.enabled=!1),r.target.setPointerCapture(r.pointerId)}),[u,e,k,v,i,t]),S=c.useCallback((e=>{if(e.stopPropagation(),F||R(!0),L.current){const{clickPoint:r,dir:n}=L.current,[o,a]=(null==s?void 0:s[t])||[void 0,void 0];let c=d(r,n,e.ray.origin,e.ray.direction);void 0!==o&&(c=Math.max(c,o-D.current)),void 0!==a&&(c=Math.min(c,a-D.current)),i.current[t]=D.current+c,u&&(C.current.innerText=`${i.current[t].toFixed(2)}`),m.makeTranslation(n.x*c,n.y*c,n.z*c),j(m)}}),[u,j,F,i,s,t]),W=c.useCallback((e=>{u&&(C.current.style.display="none"),e.stopPropagation(),L.current=null,E(),k&&(k.enabled=!0),e.target.releasePointerCapture(e.pointerId)}),[u,k,E]),V=c.useCallback((e=>{e.stopPropagation(),R(!1)}),[]),{cylinderLength:z,coneWidth:A,coneLength:_,matrixL:U}=c.useMemo((()=>{const t=h?g/y*1.6:y/20,r=h?.2:y/5,n=h?1-r:y-r,o=(new l.Quaternion).setFromUnitVectors(p,e.clone().normalize());return{cylinderLength:n,coneWidth:t,coneLength:r,matrixL:(new l.Matrix4).makeRotationFromQuaternion(o)}}),[e,y,g,h]),G=F?O:b[t];return c.createElement("group",{ref:q},c.createElement("group",{matrix:U,matrixAutoUpdate:!1,onPointerDown:T,onPointerMove:S,onPointerUp:W,onPointerOut:V},u&&c.createElement(o.Html,{position:[0,-_,0]},c.createElement("div",{style:{display:"none",background:"#151520",color:"white",padding:"6px 8px",borderRadius:7,whiteSpace:"nowrap"},className:f,ref:C})),c.createElement("mesh",{visible:!1,position:[0,(z+_)/2,0],userData:M},c.createElement("cylinderGeometry",{args:[1.4*A,1.4*A,z+_,8,1]})),c.createElement(n.Line,{transparent:!0,raycast:()=>null,depthTest:x,points:[0,0,0,0,z,0],lineWidth:g,side:l.DoubleSide,color:G,opacity:P,polygonOffset:!0,renderOrder:1,polygonOffsetFactor:-10,fog:!1}),c.createElement("mesh",{raycast:()=>null,position:[0,z+_/2,0],renderOrder:w},c.createElement("coneGeometry",{args:[A,_,24,1]}),c.createElement("meshBasicMaterial",{transparent:!0,depthTest:x,color:G,opacity:P,polygonOffset:!0,polygonOffsetFactor:-10,fog:!1}))))},exports.calculateOffset=d;
@@ -37,6 +37,7 @@ const AxisArrow = ({
37
37
  axisColors,
38
38
  hoveredColor,
39
39
  opacity,
40
+ renderOrder,
40
41
  onDragStart,
41
42
  onDrag,
42
43
  onDragEnd,
@@ -175,7 +176,7 @@ const AxisArrow = ({
175
176
  }), /*#__PURE__*/React.createElement("mesh", {
176
177
  raycast: () => null,
177
178
  position: [0, cylinderLength + coneLength / 2.0, 0],
178
- renderOrder: 500
179
+ renderOrder: renderOrder
179
180
  }, /*#__PURE__*/React.createElement("coneGeometry", {
180
181
  args: [coneWidth, coneLength, 24, 1]
181
182
  }), /*#__PURE__*/React.createElement("meshBasicMaterial", {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("three"),r=require("@react-three/fiber"),n=require("../../core/Line.cjs.js"),o=require("../Html.cjs.js"),a=require("./context.cjs.js");function i(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)}require("@babel/runtime/helpers/extends"),require("three-stdlib"),require("react-dom/client");var c=i(e),s=i(t);const l=new s.Vector3,u=new s.Vector3,d=e=>180*e/Math.PI,p=e=>{let t=((e,t)=>{let r=Math.floor(e/t);return r=r<0?r+1:r,e-r*t})(e,2*Math.PI);return Math.abs(t)<1e-6?0:(t<0&&(t+=2*Math.PI),t)},m=new s.Matrix4,h=new s.Vector3,x=new s.Ray,P=new s.Vector3;exports.AxisRotator=({dir1:e,dir2:t,axis:i})=>{const{rotationLimits:M,annotations:f,annotationsClass:b,depthTest:g,scale:y,lineWidth:w,fixed:v,axisColors:C,hoveredColor:j,opacity:I,onDragStart:k,onDrag:O,onDragEnd:R,userData:q}=c.useContext(a.context),V=r.useThree((e=>e.controls)),D=c.useRef(null),F=c.useRef(null),E=c.useRef(0),W=c.useRef(0),z=c.useRef(null),[T,A]=c.useState(!1),L=c.useCallback((e=>{f&&(D.current.innerText=`${d(W.current).toFixed(0)}º`,D.current.style.display="block"),e.stopPropagation();const t=e.point.clone(),r=(new s.Vector3).setFromMatrixPosition(F.current.matrixWorld),n=(new s.Vector3).setFromMatrixColumn(F.current.matrixWorld,0).normalize(),o=(new s.Vector3).setFromMatrixColumn(F.current.matrixWorld,1).normalize(),a=(new s.Vector3).setFromMatrixColumn(F.current.matrixWorld,2).normalize(),c=(new s.Plane).setFromNormalAndCoplanarPoint(a,r);z.current={clickPoint:t,origin:r,e1:n,e2:o,normal:a,plane:c},k({component:"Rotator",axis:i,origin:r,directions:[n,o,a]}),V&&(V.enabled=!1),e.target.setPointerCapture(e.pointerId)}),[f,V,k,i]),S=c.useCallback((e=>{if(e.stopPropagation(),T||A(!0),z.current){const{clickPoint:t,origin:r,e1:n,e2:o,normal:a,plane:c}=z.current,[b,g]=(null==M?void 0:M[i])||[void 0,void 0];x.copy(e.ray),x.intersectPlane(c,P),x.direction.negate(),x.intersectPlane(c,P);let y=((e,t,r,n,o)=>{l.copy(e).sub(r),u.copy(t).sub(r);const a=n.dot(n),i=o.dot(o),c=l.dot(n)/a,s=l.dot(o)/i,d=u.dot(n)/a,p=u.dot(o)/i,m=Math.atan2(s,c);return Math.atan2(p,d)-m})(t,P,r,n,o),w=d(y);e.shiftKey&&(w=10*Math.round(w/10),y=(e=>e*Math.PI/180)(w)),void 0!==b&&void 0!==g&&g-b<2*Math.PI?(y=p(y),y=y>Math.PI?y-2*Math.PI:y,y=s.MathUtils.clamp(y,b-E.current,g-E.current),W.current=E.current+y):(W.current=p(E.current+y),W.current=W.current>Math.PI?W.current-2*Math.PI:W.current),f&&(w=d(W.current),D.current.innerText=`${w.toFixed(0)}º`),m.makeRotationAxis(a,y),h.copy(r).applyMatrix4(m).sub(r).negate(),m.setPosition(h),O(m)}}),[f,O,T,M,i]),_=c.useCallback((e=>{f&&(D.current.style.display="none"),e.stopPropagation(),E.current=W.current,z.current=null,R(),V&&(V.enabled=!0),e.target.releasePointerCapture(e.pointerId)}),[f,V,R]),U=c.useCallback((e=>{e.stopPropagation(),A(!1)}),[]),H=c.useMemo((()=>{const r=e.clone().normalize(),n=t.clone().normalize();return(new s.Matrix4).makeBasis(r,n,r.clone().cross(n))}),[e,t]),N=v?.65:.65*y,$=c.useMemo((()=>{const e=[];for(let t=0;t<=32;t++){const r=t*(Math.PI/2)/32;e.push(new s.Vector3(Math.cos(r)*N,Math.sin(r)*N,0))}return e}),[N]);return c.createElement("group",{ref:F,onPointerDown:L,onPointerMove:S,onPointerUp:_,onPointerOut:U,matrix:H,matrixAutoUpdate:!1},f&&c.createElement(o.Html,{position:[N,N,0]},c.createElement("div",{style:{display:"none",background:"#151520",color:"white",padding:"6px 8px",borderRadius:7,whiteSpace:"nowrap"},className:b,ref:D})),c.createElement(n.Line,{points:$,lineWidth:4*w,visible:!1,userData:q}),c.createElement(n.Line,{transparent:!0,raycast:()=>null,depthTest:g,points:$,lineWidth:w,side:s.DoubleSide,color:T?j:C[i],opacity:I,polygonOffset:!0,polygonOffsetFactor:-10,fog:!1}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("three"),r=require("@react-three/fiber"),n=require("../../core/Line.cjs.js"),o=require("../Html.cjs.js"),a=require("./context.cjs.js");function i(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)}require("@babel/runtime/helpers/extends"),require("three-stdlib"),require("react-dom/client");var c=i(e),s=i(t);const l=new s.Vector3,u=new s.Vector3,d=e=>180*e/Math.PI,p=e=>{let t=((e,t)=>{let r=Math.floor(e/t);return r=r<0?r+1:r,e-r*t})(e,2*Math.PI);return Math.abs(t)<1e-6?0:(t<0&&(t+=2*Math.PI),t)},m=new s.Matrix4,h=new s.Vector3,x=new s.Ray,P=new s.Vector3;exports.AxisRotator=({dir1:e,dir2:t,axis:i})=>{const{rotationLimits:M,annotations:f,annotationsClass:b,depthTest:g,scale:y,lineWidth:w,fixed:v,axisColors:C,hoveredColor:j,renderOrder:I,opacity:O,onDragStart:k,onDrag:R,onDragEnd:q,userData:V}=c.useContext(a.context),D=r.useThree((e=>e.controls)),F=c.useRef(null),E=c.useRef(null),W=c.useRef(0),z=c.useRef(0),T=c.useRef(null),[A,L]=c.useState(!1),S=c.useCallback((e=>{f&&(F.current.innerText=`${d(z.current).toFixed(0)}º`,F.current.style.display="block"),e.stopPropagation();const t=e.point.clone(),r=(new s.Vector3).setFromMatrixPosition(E.current.matrixWorld),n=(new s.Vector3).setFromMatrixColumn(E.current.matrixWorld,0).normalize(),o=(new s.Vector3).setFromMatrixColumn(E.current.matrixWorld,1).normalize(),a=(new s.Vector3).setFromMatrixColumn(E.current.matrixWorld,2).normalize(),c=(new s.Plane).setFromNormalAndCoplanarPoint(a,r);T.current={clickPoint:t,origin:r,e1:n,e2:o,normal:a,plane:c},k({component:"Rotator",axis:i,origin:r,directions:[n,o,a]}),D&&(D.enabled=!1),e.target.setPointerCapture(e.pointerId)}),[f,D,k,i]),_=c.useCallback((e=>{if(e.stopPropagation(),A||L(!0),T.current){const{clickPoint:t,origin:r,e1:n,e2:o,normal:a,plane:c}=T.current,[b,g]=(null==M?void 0:M[i])||[void 0,void 0];x.copy(e.ray),x.intersectPlane(c,P),x.direction.negate(),x.intersectPlane(c,P);let y=((e,t,r,n,o)=>{l.copy(e).sub(r),u.copy(t).sub(r);const a=n.dot(n),i=o.dot(o),c=l.dot(n)/a,s=l.dot(o)/i,d=u.dot(n)/a,p=u.dot(o)/i,m=Math.atan2(s,c);return Math.atan2(p,d)-m})(t,P,r,n,o),w=d(y);e.shiftKey&&(w=10*Math.round(w/10),y=(e=>e*Math.PI/180)(w)),void 0!==b&&void 0!==g&&g-b<2*Math.PI?(y=p(y),y=y>Math.PI?y-2*Math.PI:y,y=s.MathUtils.clamp(y,b-W.current,g-W.current),z.current=W.current+y):(z.current=p(W.current+y),z.current=z.current>Math.PI?z.current-2*Math.PI:z.current),f&&(w=d(z.current),F.current.innerText=`${w.toFixed(0)}º`),m.makeRotationAxis(a,y),h.copy(r).applyMatrix4(m).sub(r).negate(),m.setPosition(h),R(m)}}),[f,R,A,M,i]),U=c.useCallback((e=>{f&&(F.current.style.display="none"),e.stopPropagation(),W.current=z.current,T.current=null,q(),D&&(D.enabled=!0),e.target.releasePointerCapture(e.pointerId)}),[f,D,q]),H=c.useCallback((e=>{e.stopPropagation(),L(!1)}),[]),N=c.useMemo((()=>{const r=e.clone().normalize(),n=t.clone().normalize();return(new s.Matrix4).makeBasis(r,n,r.clone().cross(n))}),[e,t]),$=v?.65:.65*y,B=c.useMemo((()=>{const e=[];for(let t=0;t<=32;t++){const r=t*(Math.PI/2)/32;e.push(new s.Vector3(Math.cos(r)*$,Math.sin(r)*$,0))}return e}),[$]);return c.createElement("group",{ref:E,onPointerDown:S,onPointerMove:_,onPointerUp:U,onPointerOut:H,matrix:N,matrixAutoUpdate:!1},f&&c.createElement(o.Html,{position:[$,$,0]},c.createElement("div",{style:{display:"none",background:"#151520",color:"white",padding:"6px 8px",borderRadius:7,whiteSpace:"nowrap"},className:b,ref:F})),c.createElement(n.Line,{points:B,lineWidth:4*w,visible:!1,userData:V}),c.createElement(n.Line,{transparent:!0,raycast:()=>null,depthTest:g,points:B,lineWidth:w,side:s.DoubleSide,color:A?j:C[i],opacity:O,polygonOffset:!0,polygonOffsetFactor:-10,renderOrder:I,fog:!1}))};
@@ -56,6 +56,7 @@ const AxisRotator = ({
56
56
  fixed,
57
57
  axisColors,
58
58
  hoveredColor,
59
+ renderOrder,
59
60
  opacity,
60
61
  onDragStart,
61
62
  onDrag,
@@ -211,6 +212,7 @@ const AxisRotator = ({
211
212
  opacity: opacity,
212
213
  polygonOffset: true,
213
214
  polygonOffsetFactor: -10,
215
+ renderOrder: renderOrder,
214
216
  fog: false
215
217
  }));
216
218
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("three"),r=require("@react-three/fiber"),n=require("../Html.cjs.js"),o=require("./context.cjs.js"),a=require("../../core/calculateScaleFactor.cjs.js");function i(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)}require("@babel/runtime/helpers/extends"),require("react-dom/client");var c=i(e),l=i(t);const s=new l.Vector3,u=new l.Vector3,p=(e,t,r,n)=>{const o=t.dot(t),a=t.dot(e)-t.dot(r),i=t.dot(n);if(0===i)return-a/o;s.copy(n).multiplyScalar(o/i).sub(t),u.copy(n).multiplyScalar(a/i).add(r).sub(e);return-s.dot(u)/s.dot(s)},d=new l.Vector3(0,1,0),m=new l.Vector3,f=new l.Matrix4;exports.ScalingSphere=({direction:e,axis:t})=>{const{scaleLimits:i,annotations:u,annotationsClass:x,depthTest:y,scale:g,lineWidth:h,fixed:b,axisColors:P,hoveredColor:M,opacity:w,onDragStart:v,onDrag:j,onDragEnd:O,userData:k}=c.useContext(o.context),C=r.useThree((e=>e.size)),S=r.useThree((e=>e.controls)),E=c.useRef(null),R=c.useRef(null),q=c.useRef(null),F=c.useRef(1),D=c.useRef(1),L=c.useRef(null),[T,V]=c.useState(!1),z=b?1.2:1.2*g,G=c.useCallback((r=>{u&&(E.current.innerText=`${D.current.toFixed(2)}`,E.current.style.display="block"),r.stopPropagation();const n=(new l.Matrix4).extractRotation(R.current.matrixWorld),o=r.point.clone(),i=(new l.Vector3).setFromMatrixPosition(R.current.matrixWorld),c=e.clone().applyMatrix4(n).normalize(),p=R.current.matrixWorld.clone(),d=p.clone().invert(),m=b?1/a.calculateScaleFactor(R.current.getWorldPosition(s),g,r.camera,C):1;L.current={clickPoint:o,dir:c,mPLG:p,mPLGInv:d,offsetMultiplier:m},v({component:"Sphere",axis:t,origin:i,directions:[c]}),S&&(S.enabled=!1),r.target.setPointerCapture(r.pointerId)}),[u,S,e,v,t,b,g,C]),W=c.useCallback((e=>{if(e.stopPropagation(),T||V(!0),L.current){const{clickPoint:r,dir:n,mPLG:o,mPLGInv:a,offsetMultiplier:c}=L.current,[l,s]=(null==i?void 0:i[t])||[1e-5,void 0],d=p(r,n,e.ray.origin,e.ray.direction)*c,x=b?d:d/g;let y=Math.pow(2,.2*x);e.shiftKey&&(y=Math.round(10*y)/10),y=Math.max(y,l/F.current),void 0!==s&&(y=Math.min(y,s/F.current)),D.current=F.current*y,q.current.position.set(0,z+d,0),u&&(E.current.innerText=`${D.current.toFixed(2)}`),m.set(1,1,1),m.setComponent(t,y),f.makeScale(m.x,m.y,m.z).premultiply(o).multiply(a),j(f)}}),[u,z,j,T,i,t]),I=c.useCallback((e=>{u&&(E.current.style.display="none"),e.stopPropagation(),F.current=D.current,L.current=null,q.current.position.set(0,z,0),O(),S&&(S.enabled=!0),e.target.releasePointerCapture(e.pointerId)}),[u,S,O,z]),_=c.useCallback((e=>{e.stopPropagation(),V(!1)}),[]),{radius:U,matrixL:H}=c.useMemo((()=>{const t=b?h/g*1.8:g/22.5,r=(new l.Quaternion).setFromUnitVectors(d,e.clone().normalize());return{radius:t,matrixL:(new l.Matrix4).makeRotationFromQuaternion(r)}}),[e,g,h,b]),Q=T?M:P[t];return c.createElement("group",{ref:R},c.createElement("group",{matrix:H,matrixAutoUpdate:!1,onPointerDown:G,onPointerMove:W,onPointerUp:I,onPointerOut:_},u&&c.createElement(n.Html,{position:[0,z/2,0]},c.createElement("div",{style:{display:"none",background:"#151520",color:"white",padding:"6px 8px",borderRadius:7,whiteSpace:"nowrap"},className:x,ref:E})),c.createElement("mesh",{ref:q,position:[0,z,0],renderOrder:500,userData:k},c.createElement("sphereGeometry",{args:[U,12,12]}),c.createElement("meshBasicMaterial",{transparent:!0,depthTest:y,color:Q,opacity:w,polygonOffset:!0,polygonOffsetFactor:-10}))))},exports.calculateOffset=p;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("three"),r=require("@react-three/fiber"),n=require("../Html.cjs.js"),o=require("./context.cjs.js"),a=require("../../core/calculateScaleFactor.cjs.js");function i(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)}require("@babel/runtime/helpers/extends"),require("react-dom/client");var c=i(e),l=i(t);const s=new l.Vector3,u=new l.Vector3,p=(e,t,r,n)=>{const o=t.dot(t),a=t.dot(e)-t.dot(r),i=t.dot(n);if(0===i)return-a/o;s.copy(n).multiplyScalar(o/i).sub(t),u.copy(n).multiplyScalar(a/i).add(r).sub(e);return-s.dot(u)/s.dot(s)},d=new l.Vector3(0,1,0),m=new l.Vector3,f=new l.Matrix4;exports.ScalingSphere=({direction:e,axis:t})=>{const{scaleLimits:i,annotations:u,annotationsClass:x,depthTest:y,scale:g,lineWidth:h,fixed:b,axisColors:P,hoveredColor:M,opacity:w,renderOrder:v,onDragStart:O,onDrag:j,onDragEnd:k,userData:C}=c.useContext(o.context),S=r.useThree((e=>e.size)),E=r.useThree((e=>e.controls)),R=c.useRef(null),q=c.useRef(null),F=c.useRef(null),D=c.useRef(1),L=c.useRef(1),T=c.useRef(null),[V,z]=c.useState(!1),G=b?1.2:1.2*g,W=c.useCallback((r=>{u&&(R.current.innerText=`${L.current.toFixed(2)}`,R.current.style.display="block"),r.stopPropagation();const n=(new l.Matrix4).extractRotation(q.current.matrixWorld),o=r.point.clone(),i=(new l.Vector3).setFromMatrixPosition(q.current.matrixWorld),c=e.clone().applyMatrix4(n).normalize(),p=q.current.matrixWorld.clone(),d=p.clone().invert(),m=b?1/a.calculateScaleFactor(q.current.getWorldPosition(s),g,r.camera,S):1;T.current={clickPoint:o,dir:c,mPLG:p,mPLGInv:d,offsetMultiplier:m},O({component:"Sphere",axis:t,origin:i,directions:[c]}),E&&(E.enabled=!1),r.target.setPointerCapture(r.pointerId)}),[u,E,e,O,t,b,g,S]),I=c.useCallback((e=>{if(e.stopPropagation(),V||z(!0),T.current){const{clickPoint:r,dir:n,mPLG:o,mPLGInv:a,offsetMultiplier:c}=T.current,[l,s]=(null==i?void 0:i[t])||[1e-5,void 0],d=p(r,n,e.ray.origin,e.ray.direction)*c,x=b?d:d/g;let y=Math.pow(2,.2*x);e.shiftKey&&(y=Math.round(10*y)/10),y=Math.max(y,l/D.current),void 0!==s&&(y=Math.min(y,s/D.current)),L.current=D.current*y,F.current.position.set(0,G+d,0),u&&(R.current.innerText=`${L.current.toFixed(2)}`),m.set(1,1,1),m.setComponent(t,y),f.makeScale(m.x,m.y,m.z).premultiply(o).multiply(a),j(f)}}),[u,G,j,V,i,t]),_=c.useCallback((e=>{u&&(R.current.style.display="none"),e.stopPropagation(),D.current=L.current,T.current=null,F.current.position.set(0,G,0),k(),E&&(E.enabled=!0),e.target.releasePointerCapture(e.pointerId)}),[u,E,k,G]),U=c.useCallback((e=>{e.stopPropagation(),z(!1)}),[]),{radius:H,matrixL:Q}=c.useMemo((()=>{const t=b?h/g*1.8:g/22.5,r=(new l.Quaternion).setFromUnitVectors(d,e.clone().normalize());return{radius:t,matrixL:(new l.Matrix4).makeRotationFromQuaternion(r)}}),[e,g,h,b]),$=V?M:P[t];return c.createElement("group",{ref:q},c.createElement("group",{matrix:Q,matrixAutoUpdate:!1,onPointerDown:W,onPointerMove:I,onPointerUp:_,onPointerOut:U},u&&c.createElement(n.Html,{position:[0,G/2,0]},c.createElement("div",{style:{display:"none",background:"#151520",color:"white",padding:"6px 8px",borderRadius:7,whiteSpace:"nowrap"},className:x,ref:R})),c.createElement("mesh",{ref:F,position:[0,G,0],renderOrder:v,userData:C},c.createElement("sphereGeometry",{args:[H,12,12]}),c.createElement("meshBasicMaterial",{transparent:!0,depthTest:y,color:$,opacity:w,polygonOffset:!0,polygonOffsetFactor:-10}))))},exports.calculateOffset=p;
@@ -37,6 +37,7 @@ const ScalingSphere = ({
37
37
  axisColors,
38
38
  hoveredColor,
39
39
  opacity,
40
+ renderOrder,
40
41
  onDragStart,
41
42
  onDrag,
42
43
  onDragEnd,
@@ -174,7 +175,7 @@ const ScalingSphere = ({
174
175
  })), /*#__PURE__*/React.createElement("mesh", {
175
176
  ref: meshRef,
176
177
  position: [0, position, 0],
177
- renderOrder: 500,
178
+ renderOrder: renderOrder,
178
179
  userData: userData
179
180
  }, /*#__PURE__*/React.createElement("sphereGeometry", {
180
181
  args: [radius, 12, 12]
@@ -23,6 +23,7 @@ export type PivotContext = {
23
23
  lineWidth: number;
24
24
  fixed: boolean;
25
25
  depthTest: boolean;
26
+ renderOrder: number;
26
27
  userData?: {
27
28
  [key: string]: any;
28
29
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),r=require("@react-three/fiber"),t=require("react"),i=require("three"),a=require("./AxisArrow.cjs.js"),n=require("./AxisRotator.cjs.js"),o=require("./PlaneSlider.cjs.js"),c=require("./ScalingSphere.cjs.js"),l=require("./context.cjs.js"),s=require("../../core/calculateScaleFactor.cjs.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function d(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,i.get?i:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}require("../../core/Line.cjs.js"),require("three-stdlib"),require("../Html.cjs.js"),require("react-dom/client");var m=u(e),x=d(t),p=d(i);const f=new p.Matrix4,y=new p.Matrix4,w=new p.Matrix4,g=new p.Matrix4,b=new p.Matrix4,E=new p.Matrix4,j=new p.Matrix4,S=new p.Matrix4,h=new p.Matrix4,v=new p.Box3,M=new p.Box3,A=new p.Vector3,q=new p.Vector3,R=new p.Vector3,V=new p.Vector3,P=new p.Vector3,W=new p.Vector3(1,0,0),D=new p.Vector3(0,1,0),C=new p.Vector3(0,0,1),L=x.forwardRef((({enabled:e=!0,matrix:t,onDragStart:i,onDrag:u,onDragEnd:d,autoTransform:L=!0,anchor:O,disableAxes:B=!1,disableSliders:F=!1,disableRotations:z=!1,disableScaling:T=!1,activeAxes:_=[!0,!0,!0],offset:k=[0,0,0],rotation:H=[0,0,0],scale:I=1,lineWidth:U=4,fixed:G=!1,translationLimits:J,rotationLimits:K,scaleLimits:N,depthTest:Q=!0,axisColors:X=["#ff2060","#20df80","#2080ff"],hoveredColor:Y="#ffff40",annotations:Z=!1,annotationsClass:$,opacity:ee=1,visible:re=!0,userData:te,children:ie,...ae},ne)=>{const oe=r.useThree((e=>e.invalidate)),ce=x.useRef(null),le=x.useRef(null),se=x.useRef(null),ue=x.useRef(null),de=x.useRef([0,0,0]),me=x.useRef(new p.Vector3(1,1,1)),xe=x.useRef(new p.Vector3(1,1,1));x.useLayoutEffect((()=>{O&&(ue.current.updateWorldMatrix(!0,!0),g.copy(ue.current.matrixWorld).invert(),v.makeEmpty(),ue.current.traverse((e=>{e.geometry&&(e.geometry.boundingBox||e.geometry.computeBoundingBox(),E.copy(e.matrixWorld).premultiply(g),M.copy(e.geometry.boundingBox),M.applyMatrix4(E),v.union(M))})),A.copy(v.max).add(v.min).multiplyScalar(.5),q.copy(v.max).sub(v.min).multiplyScalar(.5),R.copy(q).multiply(new p.Vector3(...O)).add(A),V.set(...k).add(R),se.current.position.copy(V),oe())}));const pe=x.useMemo((()=>({onDragStart:e=>{f.copy(le.current.matrix),y.copy(le.current.matrixWorld),i&&i(e),oe()},onDrag:e=>{w.copy(ce.current.matrixWorld),g.copy(w).invert(),b.copy(y).premultiply(e),E.copy(b).premultiply(g),j.copy(f).invert(),S.copy(E).multiply(j),L&&le.current.matrix.copy(E),u&&u(E,S,b,e),oe()},onDragEnd:()=>{d&&d(),oe()},translation:de,translationLimits:J,rotationLimits:K,axisColors:X,hoveredColor:Y,opacity:ee,scale:I,lineWidth:U,fixed:G,depthTest:Q,userData:te,annotations:Z,annotationsClass:$})),[i,u,d,de,J,K,N,Q,I,U,G,...X,Y,ee,te,L,Z,$]),fe=new p.Vector3;return r.useFrame((e=>{if(G){const r=s.calculateScaleFactor(se.current.getWorldPosition(fe),I,e.camera,e.size);me.current.setScalar(r)}t&&t instanceof p.Matrix4&&(le.current.matrix=t),le.current.updateWorldMatrix(!0,!0),h.makeRotationFromEuler(se.current.rotation).setPosition(se.current.position).premultiply(le.current.matrixWorld),xe.current.setFromMatrixScale(h),P.copy(me.current).divide(xe.current),(Math.abs(se.current.scale.x-P.x)>1e-4||Math.abs(se.current.scale.y-P.y)>1e-4||Math.abs(se.current.scale.z-P.z)>1e-4)&&(se.current.scale.copy(P),e.invalidate())})),x.useImperativeHandle(ne,(()=>le.current),[]),x.createElement(l.context.Provider,{value:pe},x.createElement("group",{ref:ce},x.createElement("group",m.default({ref:le,matrix:t,matrixAutoUpdate:!1},ae),x.createElement("group",{visible:re,ref:se,position:k,rotation:H},e&&x.createElement(x.Fragment,null,!B&&_[0]&&x.createElement(a.AxisArrow,{axis:0,direction:W}),!B&&_[1]&&x.createElement(a.AxisArrow,{axis:1,direction:D}),!B&&_[2]&&x.createElement(a.AxisArrow,{axis:2,direction:C}),!F&&_[0]&&_[1]&&x.createElement(o.PlaneSlider,{axis:2,dir1:W,dir2:D}),!F&&_[0]&&_[2]&&x.createElement(o.PlaneSlider,{axis:1,dir1:C,dir2:W}),!F&&_[2]&&_[1]&&x.createElement(o.PlaneSlider,{axis:0,dir1:D,dir2:C}),!z&&_[0]&&_[1]&&x.createElement(n.AxisRotator,{axis:2,dir1:W,dir2:D}),!z&&_[0]&&_[2]&&x.createElement(n.AxisRotator,{axis:1,dir1:C,dir2:W}),!z&&_[2]&&_[1]&&x.createElement(n.AxisRotator,{axis:0,dir1:D,dir2:C}),!T&&_[0]&&x.createElement(c.ScalingSphere,{axis:0,direction:W}),!T&&_[1]&&x.createElement(c.ScalingSphere,{axis:1,direction:D}),!T&&_[2]&&x.createElement(c.ScalingSphere,{axis:2,direction:C}))),x.createElement("group",{ref:ue},ie))))}));exports.PivotControls=L;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),r=require("@react-three/fiber"),t=require("react"),i=require("three"),a=require("./AxisArrow.cjs.js"),n=require("./AxisRotator.cjs.js"),o=require("./PlaneSlider.cjs.js"),c=require("./ScalingSphere.cjs.js"),l=require("./context.cjs.js"),s=require("../../core/calculateScaleFactor.cjs.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function d(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,i.get?i:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}require("../../core/Line.cjs.js"),require("three-stdlib"),require("../Html.cjs.js"),require("react-dom/client");var m=u(e),x=d(t),p=d(i);const f=new p.Matrix4,y=new p.Matrix4,w=new p.Matrix4,g=new p.Matrix4,b=new p.Matrix4,E=new p.Matrix4,j=new p.Matrix4,S=new p.Matrix4,h=new p.Matrix4,v=new p.Box3,M=new p.Box3,A=new p.Vector3,q=new p.Vector3,R=new p.Vector3,V=new p.Vector3,P=new p.Vector3,W=new p.Vector3(1,0,0),D=new p.Vector3(0,1,0),O=new p.Vector3(0,0,1),C=x.forwardRef((({enabled:e=!0,matrix:t,onDragStart:i,onDrag:u,onDragEnd:d,autoTransform:C=!0,anchor:L,disableAxes:B=!1,disableSliders:F=!1,disableRotations:z=!1,disableScaling:T=!1,activeAxes:_=[!0,!0,!0],offset:k=[0,0,0],rotation:H=[0,0,0],scale:I=1,lineWidth:U=4,fixed:G=!1,translationLimits:J,rotationLimits:K,scaleLimits:N,depthTest:Q=!0,renderOrder:X=500,axisColors:Y=["#ff2060","#20df80","#2080ff"],hoveredColor:Z="#ffff40",annotations:$=!1,annotationsClass:ee,opacity:re=1,visible:te=!0,userData:ie,children:ae,...ne},oe)=>{const ce=r.useThree((e=>e.invalidate)),le=x.useRef(null),se=x.useRef(null),ue=x.useRef(null),de=x.useRef(null),me=x.useRef([0,0,0]),xe=x.useRef(new p.Vector3(1,1,1)),pe=x.useRef(new p.Vector3(1,1,1));x.useLayoutEffect((()=>{L&&(de.current.updateWorldMatrix(!0,!0),g.copy(de.current.matrixWorld).invert(),v.makeEmpty(),de.current.traverse((e=>{e.geometry&&(e.geometry.boundingBox||e.geometry.computeBoundingBox(),E.copy(e.matrixWorld).premultiply(g),M.copy(e.geometry.boundingBox),M.applyMatrix4(E),v.union(M))})),A.copy(v.max).add(v.min).multiplyScalar(.5),q.copy(v.max).sub(v.min).multiplyScalar(.5),R.copy(q).multiply(new p.Vector3(...L)).add(A),V.set(...k).add(R),ue.current.position.copy(V),ce())}));const fe=x.useMemo((()=>({onDragStart:e=>{f.copy(se.current.matrix),y.copy(se.current.matrixWorld),i&&i(e),ce()},onDrag:e=>{w.copy(le.current.matrixWorld),g.copy(w).invert(),b.copy(y).premultiply(e),E.copy(b).premultiply(g),j.copy(f).invert(),S.copy(E).multiply(j),C&&se.current.matrix.copy(E),u&&u(E,S,b,e),ce()},onDragEnd:()=>{d&&d(),ce()},translation:me,translationLimits:J,rotationLimits:K,axisColors:Y,hoveredColor:Z,opacity:re,scale:I,lineWidth:U,fixed:G,depthTest:Q,renderOrder:X,userData:ie,annotations:$,annotationsClass:ee})),[i,u,d,me,J,K,N,Q,I,U,G,...Y,Z,re,ie,C,$,ee]),ye=new p.Vector3;return r.useFrame((e=>{if(G){const r=s.calculateScaleFactor(ue.current.getWorldPosition(ye),I,e.camera,e.size);xe.current.setScalar(r)}t&&t instanceof p.Matrix4&&(se.current.matrix=t),se.current.updateWorldMatrix(!0,!0),h.makeRotationFromEuler(ue.current.rotation).setPosition(ue.current.position).premultiply(se.current.matrixWorld),pe.current.setFromMatrixScale(h),P.copy(xe.current).divide(pe.current),(Math.abs(ue.current.scale.x-P.x)>1e-4||Math.abs(ue.current.scale.y-P.y)>1e-4||Math.abs(ue.current.scale.z-P.z)>1e-4)&&(ue.current.scale.copy(P),e.invalidate())})),x.useImperativeHandle(oe,(()=>se.current),[]),x.createElement(l.context.Provider,{value:fe},x.createElement("group",{ref:le},x.createElement("group",m.default({ref:se,matrix:t,matrixAutoUpdate:!1},ne),x.createElement("group",{visible:te,ref:ue,position:k,rotation:H},e&&x.createElement(x.Fragment,null,!B&&_[0]&&x.createElement(a.AxisArrow,{axis:0,direction:W}),!B&&_[1]&&x.createElement(a.AxisArrow,{axis:1,direction:D}),!B&&_[2]&&x.createElement(a.AxisArrow,{axis:2,direction:O}),!F&&_[0]&&_[1]&&x.createElement(o.PlaneSlider,{axis:2,dir1:W,dir2:D}),!F&&_[0]&&_[2]&&x.createElement(o.PlaneSlider,{axis:1,dir1:O,dir2:W}),!F&&_[2]&&_[1]&&x.createElement(o.PlaneSlider,{axis:0,dir1:D,dir2:O}),!z&&_[0]&&_[1]&&x.createElement(n.AxisRotator,{axis:2,dir1:W,dir2:D}),!z&&_[0]&&_[2]&&x.createElement(n.AxisRotator,{axis:1,dir1:O,dir2:W}),!z&&_[2]&&_[1]&&x.createElement(n.AxisRotator,{axis:0,dir1:D,dir2:O}),!T&&_[0]&&x.createElement(c.ScalingSphere,{axis:0,direction:W}),!T&&_[1]&&x.createElement(c.ScalingSphere,{axis:1,direction:D}),!T&&_[2]&&x.createElement(c.ScalingSphere,{axis:2,direction:O}))),x.createElement("group",{ref:de},ae))))}));exports.PivotControls=C;
@@ -28,6 +28,7 @@ export type PivotControlsProps = {
28
28
  onDrag?: (l: THREE.Matrix4, deltaL: THREE.Matrix4, w: THREE.Matrix4, deltaW: THREE.Matrix4) => void;
29
29
  onDragEnd?: () => void;
30
30
  depthTest?: boolean;
31
+ renderOrder?: number;
31
32
  opacity?: number;
32
33
  visible?: boolean;
33
34
  userData?: {
@@ -50,6 +50,7 @@ const PivotControls = /* @__PURE__ */React.forwardRef(({
50
50
  rotationLimits,
51
51
  scaleLimits,
52
52
  depthTest = true,
53
+ renderOrder = 500,
53
54
  axisColors = ['#ff2060', '#20df80', '#2080ff'],
54
55
  hoveredColor = '#ffff40',
55
56
  annotations = false,
@@ -123,6 +124,7 @@ const PivotControls = /* @__PURE__ */React.forwardRef(({
123
124
  lineWidth,
124
125
  fixed,
125
126
  depthTest,
127
+ renderOrder,
126
128
  userData,
127
129
  annotations,
128
130
  annotationsClass