@react-three/drei 10.0.5 → 10.0.6

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("react"),r=require("three"),a=require("@react-three/fiber"),n=require("../materials/BlurPass.cjs.js"),o=require("../materials/MeshReflectorMaterial.cjs.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}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 a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}require("../materials/ConvolutionMaterial.cjs.js"),require("../helpers/constants.cjs.js");var l=s(e),u=i(t);const d=u.forwardRef((({mixBlur:e=0,mixStrength:t=1,resolution:s=256,blur:i=[0,0],minDepthThreshold:d=.9,maxDepthThreshold:c=1,depthScale:p=0,depthToBlurRatioBias:m=.25,mirror:h=0,distortion:f=1,mixContrast:x=1,distortionMap:M,reflectorOffset:T=0,...S},y)=>{a.extend({MeshReflectorMaterialImpl:o.MeshReflectorMaterial});const b=a.useThree((({gl:e})=>e)),w=a.useThree((({camera:e})=>e)),j=a.useThree((({scene:e})=>e)),R=(i=Array.isArray(i)?i:[i,i])[0]+i[1]>0,v=u.useRef(null);u.useImperativeHandle(y,(()=>v.current),[]);const[g]=u.useState((()=>new r.Plane)),[D]=u.useState((()=>new r.Vector3)),[B]=u.useState((()=>new r.Vector3)),[_]=u.useState((()=>new r.Vector3)),[O]=u.useState((()=>new r.Matrix4)),[P]=u.useState((()=>new r.Vector3(0,0,-1))),[U]=u.useState((()=>new r.Vector4)),[V]=u.useState((()=>new r.Vector3)),[E]=u.useState((()=>new r.Vector3)),[F]=u.useState((()=>new r.Vector4)),[W]=u.useState((()=>new r.Matrix4)),[I]=u.useState((()=>new r.PerspectiveCamera)),q=u.useCallback((()=>{var e;const t=v.current.parent||(null==(e=v.current)||null==(e=e.__r3f.parent)?void 0:e.object);if(!t)return;if(B.setFromMatrixPosition(t.matrixWorld),_.setFromMatrixPosition(w.matrixWorld),O.extractRotation(t.matrixWorld),D.set(0,0,1),D.applyMatrix4(O),B.addScaledVector(D,T),V.subVectors(B,_),V.dot(D)>0)return;V.reflect(D).negate(),V.add(B),O.extractRotation(w.matrixWorld),P.set(0,0,-1),P.applyMatrix4(O),P.add(_),E.subVectors(B,P),E.reflect(D).negate(),E.add(B),I.position.copy(V),I.up.set(0,1,0),I.up.applyMatrix4(O),I.up.reflect(D),I.lookAt(E),I.far=w.far,I.updateMatrixWorld(),I.projectionMatrix.copy(w.projectionMatrix),W.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),W.multiply(I.projectionMatrix),W.multiply(I.matrixWorldInverse),W.multiply(t.matrixWorld),g.setFromNormalAndCoplanarPoint(D,B),g.applyMatrix4(I.matrixWorldInverse),U.set(g.normal.x,g.normal.y,g.normal.z,g.constant);const r=I.projectionMatrix;F.x=(Math.sign(U.x)+r.elements[8])/r.elements[0],F.y=(Math.sign(U.y)+r.elements[9])/r.elements[5],F.z=-1,F.w=(1+r.elements[10])/r.elements[14],U.multiplyScalar(2/U.dot(F)),r.elements[2]=U.x,r.elements[6]=U.y,r.elements[10]=U.z+1,r.elements[14]=U.w}),[w,T]),[C,k,L,z]=u.useMemo((()=>{const a={minFilter:r.LinearFilter,magFilter:r.LinearFilter,type:r.HalfFloatType},o=new r.WebGLRenderTarget(s,s,a);o.depthBuffer=!0,o.depthTexture=new r.DepthTexture(s,s),o.depthTexture.format=r.DepthFormat,o.depthTexture.type=r.UnsignedShortType;const l=new r.WebGLRenderTarget(s,s,a);return[o,l,new n.BlurPass({gl:b,resolution:s,width:i[0],height:i[1],minDepthThreshold:d,maxDepthThreshold:c,depthScale:p,depthToBlurRatioBias:m}),{mirror:h,textureMatrix:W,mixBlur:e,tDiffuse:o.texture,tDepth:o.depthTexture,tDiffuseBlur:l.texture,hasBlur:R,mixStrength:t,minDepthThreshold:d,maxDepthThreshold:c,depthScale:p,depthToBlurRatioBias:m,distortion:f,distortionMap:M,mixContrast:x,"defines-USE_BLUR":R?"":void 0,"defines-USE_DEPTH":p>0?"":void 0,"defines-USE_DISTORTION":M?"":void 0}]}),[b,i,W,s,h,R,e,t,d,c,p,m,f,M,x]);return a.useFrame((()=>{var e;const t=v.current.parent||(null==(e=v.current)||null==(e=e.__r3f.parent)?void 0:e.object);if(!t)return;t.visible=!1;const r=b.xr.enabled,a=b.shadowMap.autoUpdate;q(),b.xr.enabled=!1,b.shadowMap.autoUpdate=!1,b.setRenderTarget(C),b.state.buffers.depth.setMask(!0),b.autoClear||b.clear(),b.render(j,I),R&&L.render(b,C,k),b.xr.enabled=r,b.shadowMap.autoUpdate=a,t.visible=!0,b.setRenderTarget(null)})),u.createElement("meshReflectorMaterialImpl",l.default({attach:"material",key:"key"+z["defines-USE_BLUR"]+z["defines-USE_DEPTH"]+z["defines-USE_DISTORTION"],ref:v},z,S))}));exports.MeshReflectorMaterial=d;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("react"),r=require("three"),a=require("@react-three/fiber"),n=require("../materials/BlurPass.cjs.js"),o=require("../materials/MeshReflectorMaterial.cjs.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}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 a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}require("../materials/ConvolutionMaterial.cjs.js"),require("../helpers/constants.cjs.js");var l=s(e),u=i(t);const d=u.forwardRef((({mixBlur:e=0,mixStrength:t=1,resolution:s=256,blur:i=[0,0],minDepthThreshold:d=.9,maxDepthThreshold:c=1,depthScale:p=0,depthToBlurRatioBias:m=.25,mirror:h=0,distortion:f=1,mixContrast:x=1,distortionMap:M,reflectorOffset:T=0,...S},y)=>{a.extend({MeshReflectorMaterialImpl:o.MeshReflectorMaterial});const b=a.useThree((({gl:e})=>e)),w=a.useThree((({camera:e})=>e)),j=a.useThree((({scene:e})=>e)),R=(i=Array.isArray(i)?i:[i,i])[0]+i[1]>0,v=i[0],g=i[1],D=u.useRef(null);u.useImperativeHandle(y,(()=>D.current),[]);const[B]=u.useState((()=>new r.Plane)),[_]=u.useState((()=>new r.Vector3)),[O]=u.useState((()=>new r.Vector3)),[P]=u.useState((()=>new r.Vector3)),[U]=u.useState((()=>new r.Matrix4)),[V]=u.useState((()=>new r.Vector3(0,0,-1))),[E]=u.useState((()=>new r.Vector4)),[F]=u.useState((()=>new r.Vector3)),[W]=u.useState((()=>new r.Vector3)),[I]=u.useState((()=>new r.Vector4)),[q]=u.useState((()=>new r.Matrix4)),[C]=u.useState((()=>new r.PerspectiveCamera)),k=u.useCallback((()=>{var e;const t=D.current.parent||(null==(e=D.current)||null==(e=e.__r3f.parent)?void 0:e.object);if(!t)return;if(O.setFromMatrixPosition(t.matrixWorld),P.setFromMatrixPosition(w.matrixWorld),U.extractRotation(t.matrixWorld),_.set(0,0,1),_.applyMatrix4(U),O.addScaledVector(_,T),F.subVectors(O,P),F.dot(_)>0)return;F.reflect(_).negate(),F.add(O),U.extractRotation(w.matrixWorld),V.set(0,0,-1),V.applyMatrix4(U),V.add(P),W.subVectors(O,V),W.reflect(_).negate(),W.add(O),C.position.copy(F),C.up.set(0,1,0),C.up.applyMatrix4(U),C.up.reflect(_),C.lookAt(W),C.far=w.far,C.updateMatrixWorld(),C.projectionMatrix.copy(w.projectionMatrix),q.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),q.multiply(C.projectionMatrix),q.multiply(C.matrixWorldInverse),q.multiply(t.matrixWorld),B.setFromNormalAndCoplanarPoint(_,O),B.applyMatrix4(C.matrixWorldInverse),E.set(B.normal.x,B.normal.y,B.normal.z,B.constant);const r=C.projectionMatrix;I.x=(Math.sign(E.x)+r.elements[8])/r.elements[0],I.y=(Math.sign(E.y)+r.elements[9])/r.elements[5],I.z=-1,I.w=(1+r.elements[10])/r.elements[14],E.multiplyScalar(2/E.dot(I)),r.elements[2]=E.x,r.elements[6]=E.y,r.elements[10]=E.z+1,r.elements[14]=E.w}),[w,T]),[L,z,A,H]=u.useMemo((()=>{const a={minFilter:r.LinearFilter,magFilter:r.LinearFilter,type:r.HalfFloatType},o=new r.WebGLRenderTarget(s,s,a);o.depthBuffer=!0,o.depthTexture=new r.DepthTexture(s,s),o.depthTexture.format=r.DepthFormat,o.depthTexture.type=r.UnsignedShortType;const i=new r.WebGLRenderTarget(s,s,a);return[o,i,new n.BlurPass({gl:b,resolution:s,width:v,height:g,minDepthThreshold:d,maxDepthThreshold:c,depthScale:p,depthToBlurRatioBias:m}),{mirror:h,textureMatrix:q,mixBlur:e,tDiffuse:o.texture,tDepth:o.depthTexture,tDiffuseBlur:i.texture,hasBlur:R,mixStrength:t,minDepthThreshold:d,maxDepthThreshold:c,depthScale:p,depthToBlurRatioBias:m,distortion:f,distortionMap:M,mixContrast:x,"defines-USE_BLUR":R?"":void 0,"defines-USE_DEPTH":p>0?"":void 0,"defines-USE_DISTORTION":M?"":void 0}]}),[b,v,g,q,s,h,R,e,t,d,c,p,m,f,M,x]);return a.useFrame((()=>{var e;const t=D.current.parent||(null==(e=D.current)||null==(e=e.__r3f.parent)?void 0:e.object);if(!t)return;t.visible=!1;const r=b.xr.enabled,a=b.shadowMap.autoUpdate;k(),b.xr.enabled=!1,b.shadowMap.autoUpdate=!1,b.setRenderTarget(L),b.state.buffers.depth.setMask(!0),b.autoClear||b.clear(),b.render(j,C),R&&A.render(b,L,z),b.xr.enabled=r,b.shadowMap.autoUpdate=a,t.visible=!0,b.setRenderTarget(null)})),u.createElement("meshReflectorMaterialImpl",l.default({attach:"material",key:"key"+H["defines-USE_BLUR"]+H["defines-USE_DEPTH"]+H["defines-USE_DISTORTION"],ref:D},H,S))}));exports.MeshReflectorMaterial=d;
@@ -35,6 +35,8 @@ const MeshReflectorMaterial = /* @__PURE__ */React.forwardRef(({
35
35
  }) => scene);
36
36
  blur = Array.isArray(blur) ? blur : [blur, blur];
37
37
  const hasBlur = blur[0] + blur[1] > 0;
38
+ const blurX = blur[0];
39
+ const blurY = blur[1];
38
40
  const materialRef = React.useRef(null);
39
41
  React.useImperativeHandle(ref, () => materialRef.current, []);
40
42
  const [reflectorPlane] = React.useState(() => new Plane());
@@ -117,8 +119,8 @@ const MeshReflectorMaterial = /* @__PURE__ */React.forwardRef(({
117
119
  const blurpass = new BlurPass({
118
120
  gl,
119
121
  resolution,
120
- width: blur[0],
121
- height: blur[1],
122
+ width: blurX,
123
+ height: blurY,
122
124
  minDepthThreshold,
123
125
  maxDepthThreshold,
124
126
  depthScale,
@@ -145,7 +147,7 @@ const MeshReflectorMaterial = /* @__PURE__ */React.forwardRef(({
145
147
  'defines-USE_DISTORTION': distortionMap ? '' : undefined
146
148
  };
147
149
  return [fbo1, fbo2, blurpass, reflectorProps];
148
- }, [gl, blur, textureMatrix, resolution, mirror, hasBlur, mixBlur, mixStrength, minDepthThreshold, maxDepthThreshold, depthScale, depthToBlurRatioBias, distortion, distortionMap, mixContrast]);
150
+ }, [gl, blurX, blurY, textureMatrix, resolution, mirror, hasBlur, mixBlur, mixStrength, minDepthThreshold, maxDepthThreshold, depthScale, depthToBlurRatioBias, distortion, distortionMap, mixContrast]);
149
151
  useFrame(() => {
150
152
  var _materialRef$current2;
151
153
  const parent = materialRef.current.parent || ((_materialRef$current2 = materialRef.current) == null || (_materialRef$current2 = _materialRef$current2.__r3f.parent) == null ? void 0 : _materialRef$current2.object);