@react-three/drei 7.27.2 → 7.27.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/README.md CHANGED
@@ -618,15 +618,13 @@ Easily add reflections and/or blur to any mesh. It takes surface roughness into
618
618
  blur={[0, 0]} // Blur ground reflections (width, heigt), 0 skips blur
619
619
  mixBlur={0} // How much blur mixes with surface roughness (default = 1)
620
620
  mixStrength={1} // Strength of the reflections
621
+ mixContrast={1} // Contrast of the reflections
621
622
  resolution={256} // Off-buffer resolution, lower=faster, higher=better quality, slower
622
623
  mirror={0} // Mirror environment, 0 = texture colors, 1 = pick up env colors
623
624
  depthScale={0} // Scale the depth factor (0 = no depth, default = 0)
624
625
  minDepthThreshold={0.9} // Lower edge for the depthTexture interpolation (default = 0)
625
626
  maxDepthThreshold={1} // Upper edge for the depthTexture interpolation (default = 0)
626
627
  depthToBlurRatioBias={0.25} // Adds a bias factor to the depthTexture before calculating the blur amount [blurFactor = blurTexture * (depthTexture + bias)]. It accepts values between 0 and 1, default is 0.25. An amount > 0 of bias makes sure that the blurTexture is not too sharp because of the multiplication with the depthTexture
627
- gamma={1} // Reflection layer gamma
628
- contrast={1} // Reflection layer contrast
629
- brightness={0} // Reflection layer brightness
630
628
  distortion={1} // Amount of distortion based on the distortionMap texture
631
629
  distortionMap={distortionTexture} // The red channel of this texture is used as the distortion map. Default is null
632
630
  debug={0} /* Depending on the assigned value, one of the following channels is shown:
@@ -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("react-merge-refs"),i=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 l(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");var u=s(e),d=l(t),c=s(n);a.extend({MeshReflectorMaterialImpl:o.MeshReflectorMaterial});const p=d.forwardRef((({mixBlur:e=0,mixStrength:t=1,resolution:n=256,blur:o=[0,0],minDepthThreshold:s=.9,maxDepthThreshold:l=1,depthScale:p=0,depthToBlurRatioBias:m=.25,mirror:h=0,debug:f=0,distortion:x=1,gamma:M=1,contrast:T=1,brightness:b=0,distortionMap:g,...S},y)=>{const w=a.useThree((({gl:e})=>e)),R=a.useThree((({camera:e})=>e)),v=a.useThree((({scene:e})=>e)),j=(o=Array.isArray(o)?o:[o,o])[0]+o[1]>0,B=d.useRef(null),[D]=d.useState((()=>new r.Plane)),[_]=d.useState((()=>new r.Vector3)),[P]=d.useState((()=>new r.Vector3)),[U]=d.useState((()=>new r.Vector3)),[E]=d.useState((()=>new r.Matrix4)),[O]=d.useState((()=>new r.Vector3(0,0,-1))),[F]=d.useState((()=>new r.Vector4)),[V]=d.useState((()=>new r.Vector3)),[W]=d.useState((()=>new r.Vector3)),[q]=d.useState((()=>new r.Vector4)),[I]=d.useState((()=>new r.Matrix4)),[k]=d.useState((()=>new r.PerspectiveCamera)),L=d.useCallback((()=>{var e;const t=B.current.parent||(null==(e=B.current)?void 0:e.__r3f.parent);if(!t)return;if(P.setFromMatrixPosition(t.matrixWorld),U.setFromMatrixPosition(R.matrixWorld),E.extractRotation(t.matrixWorld),_.set(0,0,1),_.applyMatrix4(E),V.subVectors(P,U),V.dot(_)>0)return;V.reflect(_).negate(),V.add(P),E.extractRotation(R.matrixWorld),O.set(0,0,-1),O.applyMatrix4(E),O.add(U),W.subVectors(P,O),W.reflect(_).negate(),W.add(P),k.position.copy(V),k.up.set(0,1,0),k.up.applyMatrix4(E),k.up.reflect(_),k.lookAt(W),k.far=R.far,k.updateMatrixWorld(),k.projectionMatrix.copy(R.projectionMatrix),I.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),I.multiply(k.projectionMatrix),I.multiply(k.matrixWorldInverse),I.multiply(t.matrixWorld),D.setFromNormalAndCoplanarPoint(_,P),D.applyMatrix4(k.matrixWorldInverse),F.set(D.normal.x,D.normal.y,D.normal.z,D.constant);const r=k.projectionMatrix;q.x=(Math.sign(F.x)+r.elements[8])/r.elements[0],q.y=(Math.sign(F.y)+r.elements[9])/r.elements[5],q.z=-1,q.w=(1+r.elements[10])/r.elements[14],F.multiplyScalar(2/F.dot(q)),r.elements[2]=F.x,r.elements[6]=F.y,r.elements[10]=F.z+1,r.elements[14]=F.w}),[]),[C,z,A,G]=d.useMemo((()=>{const a={minFilter:r.LinearFilter,magFilter:r.LinearFilter,format:r.RGBFormat,encoding:w.outputEncoding},u=new r.WebGLRenderTarget(n,n,a);u.depthBuffer=!0,u.depthTexture=new r.DepthTexture(n,n),u.depthTexture.format=r.DepthFormat,u.depthTexture.type=r.UnsignedShortType;const d=new r.WebGLRenderTarget(n,n,a);return[u,d,new i.BlurPass({gl:w,resolution:n,width:o[0],height:o[1],minDepthThreshold:s,maxDepthThreshold:l,depthScale:p,depthToBlurRatioBias:m}),{mirror:h,textureMatrix:I,mixBlur:e,tDiffuse:u.texture,tDepth:u.depthTexture,tDiffuseBlur:d.texture,hasBlur:j,mixStrength:t,minDepthThreshold:s,maxDepthThreshold:l,depthScale:p,depthToBlurRatioBias:m,transparent:!0,debug:f,distortion:x,distortionMap:g,gamma:M,contrast:T,brightness:b,"defines-USE_BLUR":j?"":void 0,"defines-USE_DEPTH":p>0?"":void 0,"defines-USE_DISTORTION":g?"":void 0}]}),[w,o,I,n,h,j,e,t,s,l,p,m,f,x,g,M,T,b]);return a.useFrame((()=>{var e;const t=B.current.parent||(null==(e=B.current)?void 0:e.__r3f.parent);if(!t)return;t.visible=!1;const r=w.xr.enabled,a=w.shadowMap.autoUpdate;L(),w.xr.enabled=!1,w.shadowMap.autoUpdate=!1,w.setRenderTarget(C),w.state.buffers.depth.setMask(!0),w.autoClear||w.clear(),w.render(v,k),j&&A.render(w,C,z),w.xr.enabled=r,w.shadowMap.autoUpdate=a,t.visible=!0,w.setRenderTarget(null)})),d.createElement("meshReflectorMaterialImpl",u.default({attach:"material",key:"key"+G["defines-USE_BLUR"]+G["defines-USE_DEPTH"]+G["defines-USE_DISTORTION"],ref:c.default([B,y])},G,S))}));exports.MeshReflectorMaterial=p;
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("react-merge-refs"),i=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 l(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");var u=s(e),d=l(t),c=s(n);a.extend({MeshReflectorMaterialImpl:o.MeshReflectorMaterial});const p=d.forwardRef((({mixBlur:e=0,mixStrength:t=1,resolution:n=256,blur:o=[0,0],minDepthThreshold:s=.9,maxDepthThreshold:l=1,depthScale:p=0,depthToBlurRatioBias:m=.25,mirror:h=0,debug:f=0,distortion:x=1,mixContrast:M=1,distortionMap:T,...S},b)=>{const y=a.useThree((({gl:e})=>e)),w=a.useThree((({camera:e})=>e)),g=a.useThree((({scene:e})=>e)),R=(o=Array.isArray(o)?o:[o,o])[0]+o[1]>0,v=d.useRef(null),[j]=d.useState((()=>new r.Plane)),[B]=d.useState((()=>new r.Vector3)),[D]=d.useState((()=>new r.Vector3)),[_]=d.useState((()=>new r.Vector3)),[P]=d.useState((()=>new r.Matrix4)),[U]=d.useState((()=>new r.Vector3(0,0,-1))),[E]=d.useState((()=>new r.Vector4)),[O]=d.useState((()=>new r.Vector3)),[F]=d.useState((()=>new r.Vector3)),[V]=d.useState((()=>new r.Vector4)),[W]=d.useState((()=>new r.Matrix4)),[q]=d.useState((()=>new r.PerspectiveCamera)),I=d.useCallback((()=>{var e;const t=v.current.parent||(null==(e=v.current)?void 0:e.__r3f.parent);if(!t)return;if(D.setFromMatrixPosition(t.matrixWorld),_.setFromMatrixPosition(w.matrixWorld),P.extractRotation(t.matrixWorld),B.set(0,0,1),B.applyMatrix4(P),O.subVectors(D,_),O.dot(B)>0)return;O.reflect(B).negate(),O.add(D),P.extractRotation(w.matrixWorld),U.set(0,0,-1),U.applyMatrix4(P),U.add(_),F.subVectors(D,U),F.reflect(B).negate(),F.add(D),q.position.copy(O),q.up.set(0,1,0),q.up.applyMatrix4(P),q.up.reflect(B),q.lookAt(F),q.far=w.far,q.updateMatrixWorld(),q.projectionMatrix.copy(w.projectionMatrix),W.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),W.multiply(q.projectionMatrix),W.multiply(q.matrixWorldInverse),W.multiply(t.matrixWorld),j.setFromNormalAndCoplanarPoint(B,D),j.applyMatrix4(q.matrixWorldInverse),E.set(j.normal.x,j.normal.y,j.normal.z,j.constant);const r=q.projectionMatrix;V.x=(Math.sign(E.x)+r.elements[8])/r.elements[0],V.y=(Math.sign(E.y)+r.elements[9])/r.elements[5],V.z=-1,V.w=(1+r.elements[10])/r.elements[14],E.multiplyScalar(2/E.dot(V)),r.elements[2]=E.x,r.elements[6]=E.y,r.elements[10]=E.z+1,r.elements[14]=E.w}),[]),[C,k,L,z]=d.useMemo((()=>{const a={minFilter:r.LinearFilter,magFilter:r.LinearFilter,format:r.RGBFormat,encoding:y.outputEncoding},u=new r.WebGLRenderTarget(n,n,a);u.depthBuffer=!0,u.depthTexture=new r.DepthTexture(n,n),u.depthTexture.format=r.DepthFormat,u.depthTexture.type=r.UnsignedShortType;const d=new r.WebGLRenderTarget(n,n,a);return[u,d,new i.BlurPass({gl:y,resolution:n,width:o[0],height:o[1],minDepthThreshold:s,maxDepthThreshold:l,depthScale:p,depthToBlurRatioBias:m}),{mirror:h,textureMatrix:W,mixBlur:e,tDiffuse:u.texture,tDepth:u.depthTexture,tDiffuseBlur:d.texture,hasBlur:R,mixStrength:t,minDepthThreshold:s,maxDepthThreshold:l,depthScale:p,depthToBlurRatioBias:m,transparent:!0,debug:f,distortion:x,distortionMap:T,mixContrast:M,"defines-USE_BLUR":R?"":void 0,"defines-USE_DEPTH":p>0?"":void 0,"defines-USE_DISTORTION":T?"":void 0}]}),[y,o,W,n,h,R,e,t,s,l,p,m,f,x,T,M]);return a.useFrame((()=>{var e;const t=v.current.parent||(null==(e=v.current)?void 0:e.__r3f.parent);if(!t)return;t.visible=!1;const r=y.xr.enabled,a=y.shadowMap.autoUpdate;I(),y.xr.enabled=!1,y.shadowMap.autoUpdate=!1,y.setRenderTarget(C),y.state.buffers.depth.setMask(!0),y.autoClear||y.clear(),y.render(g,q),R&&L.render(y,C,k),y.xr.enabled=r,y.shadowMap.autoUpdate=a,t.visible=!0,y.setRenderTarget(null)})),d.createElement("meshReflectorMaterialImpl",u.default({attach:"material",key:"key"+z["defines-USE_BLUR"]+z["defines-USE_DEPTH"]+z["defines-USE_DISTORTION"],ref:c.default([v,b])},z,S))}));exports.MeshReflectorMaterial=p;
@@ -14,9 +14,7 @@ export declare type Props = JSX.IntrinsicElements['meshStandardMaterial'] & {
14
14
  debug?: number;
15
15
  distortionMap?: Texture;
16
16
  distortion?: number;
17
- gamma?: number;
18
- contrast?: number;
19
- brightness?: number;
17
+ mixContrast?: number;
20
18
  };
21
19
  declare global {
22
20
  namespace JSX {
@@ -25,4 +23,4 @@ declare global {
25
23
  }
26
24
  }
27
25
  }
28
- export declare const MeshReflectorMaterial: React.ForwardRefExoticComponent<Pick<Props, "visible" | "attach" | "attachArray" | "attachObject" | "args" | "children" | "key" | "onUpdate" | "dispose" | "type" | "id" | "uuid" | "name" | "userData" | "toJSON" | "clone" | "copy" | "addEventListener" | "hasEventListener" | "removeEventListener" | "dispatchEvent" | "color" | "map" | "transparent" | "fog" | "blur" | "opacity" | "precision" | "alphaTest" | "alphaToCoverage" | "blendDst" | "blendDstAlpha" | "blendEquation" | "blendEquationAlpha" | "blending" | "blendSrc" | "blendSrcAlpha" | "clipIntersection" | "clippingPlanes" | "clipShadows" | "colorWrite" | "defines" | "depthFunc" | "depthTest" | "depthWrite" | "stencilWrite" | "stencilFunc" | "stencilRef" | "stencilWriteMask" | "stencilFuncMask" | "stencilFail" | "stencilZFail" | "stencilZPass" | "isMaterial" | "needsUpdate" | "polygonOffset" | "polygonOffsetFactor" | "polygonOffsetUnits" | "premultipliedAlpha" | "dithering" | "side" | "shadowSide" | "toneMapped" | "vertexColors" | "version" | "onBeforeCompile" | "customProgramCacheKey" | "setValues" | "resolution" | "wireframe" | "wireframeLinewidth" | "skinning" | "morphTargets" | "morphNormals" | "emissive" | "emissiveIntensity" | "emissiveMap" | "lightMap" | "lightMapIntensity" | "aoMap" | "aoMapIntensity" | "alphaMap" | "envMap" | "refractionRatio" | "wireframeLinecap" | "wireframeLinejoin" | "roughness" | "metalness" | "bumpMap" | "bumpScale" | "normalMap" | "normalMapType" | "normalScale" | "displacementMap" | "displacementScale" | "displacementBias" | "roughnessMap" | "metalnessMap" | "envMapIntensity" | "vertexTangents" | "flatShading" | "isMeshStandardMaterial" | "minDepthThreshold" | "maxDepthThreshold" | "depthScale" | "depthToBlurRatioBias" | "mixBlur" | "mixStrength" | "mirror" | "debug" | "distortion" | "gamma" | "contrast" | "brightness" | "distortionMap"> & React.RefAttributes<MeshReflectorMaterialImpl>>;
26
+ export declare const MeshReflectorMaterial: React.ForwardRefExoticComponent<Pick<Props, "visible" | "attach" | "attachArray" | "attachObject" | "args" | "children" | "key" | "onUpdate" | "dispose" | "type" | "id" | "uuid" | "name" | "userData" | "toJSON" | "clone" | "copy" | "addEventListener" | "hasEventListener" | "removeEventListener" | "dispatchEvent" | "color" | "map" | "transparent" | "fog" | "blur" | "opacity" | "precision" | "alphaTest" | "alphaToCoverage" | "blendDst" | "blendDstAlpha" | "blendEquation" | "blendEquationAlpha" | "blending" | "blendSrc" | "blendSrcAlpha" | "clipIntersection" | "clippingPlanes" | "clipShadows" | "colorWrite" | "defines" | "depthFunc" | "depthTest" | "depthWrite" | "stencilWrite" | "stencilFunc" | "stencilRef" | "stencilWriteMask" | "stencilFuncMask" | "stencilFail" | "stencilZFail" | "stencilZPass" | "isMaterial" | "needsUpdate" | "polygonOffset" | "polygonOffsetFactor" | "polygonOffsetUnits" | "premultipliedAlpha" | "dithering" | "side" | "shadowSide" | "toneMapped" | "vertexColors" | "version" | "onBeforeCompile" | "customProgramCacheKey" | "setValues" | "resolution" | "wireframe" | "wireframeLinewidth" | "skinning" | "morphTargets" | "morphNormals" | "emissive" | "emissiveIntensity" | "emissiveMap" | "lightMap" | "lightMapIntensity" | "aoMap" | "aoMapIntensity" | "alphaMap" | "envMap" | "refractionRatio" | "wireframeLinecap" | "wireframeLinejoin" | "roughness" | "metalness" | "bumpMap" | "bumpScale" | "normalMap" | "normalMapType" | "normalScale" | "displacementMap" | "displacementScale" | "displacementBias" | "roughnessMap" | "metalnessMap" | "envMapIntensity" | "vertexTangents" | "flatShading" | "isMeshStandardMaterial" | "minDepthThreshold" | "maxDepthThreshold" | "depthScale" | "depthToBlurRatioBias" | "mixBlur" | "mixStrength" | "mirror" | "debug" | "distortion" | "mixContrast" | "distortionMap"> & React.RefAttributes<MeshReflectorMaterialImpl>>;
@@ -21,9 +21,7 @@ const MeshReflectorMaterial = /*#__PURE__*/React.forwardRef(({
21
21
  mirror = 0,
22
22
  debug = 0,
23
23
  distortion = 1,
24
- gamma = 1,
25
- contrast = 1,
26
- brightness = 0,
24
+ mixContrast = 1,
27
25
  distortionMap,
28
26
  ...props
29
27
  }, ref) => {
@@ -146,15 +144,13 @@ const MeshReflectorMaterial = /*#__PURE__*/React.forwardRef(({
146
144
  debug,
147
145
  distortion,
148
146
  distortionMap,
149
- gamma,
150
- contrast,
151
- brightness,
147
+ mixContrast,
152
148
  'defines-USE_BLUR': hasBlur ? '' : undefined,
153
149
  'defines-USE_DEPTH': depthScale > 0 ? '' : undefined,
154
150
  'defines-USE_DISTORTION': distortionMap ? '' : undefined
155
151
  };
156
152
  return [fbo1, fbo2, blurpass, reflectorProps];
157
- }, [gl, blur, textureMatrix, resolution, mirror, hasBlur, mixBlur, mixStrength, minDepthThreshold, maxDepthThreshold, depthScale, depthToBlurRatioBias, debug, distortion, distortionMap, gamma, contrast, brightness]);
153
+ }, [gl, blur, textureMatrix, resolution, mirror, hasBlur, mixBlur, mixStrength, minDepthThreshold, maxDepthThreshold, depthScale, depthToBlurRatioBias, debug, distortion, distortionMap, mixContrast]);
158
154
  useFrame(() => {
159
155
  var _materialRef$current2;
160
156
 
@@ -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("react-merge-refs"),o=require("../materials/BlurPass.cjs.js"),s=require("../materials/MeshReflectorMaterial.cjs.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function l(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");var u=i(e),d=l(t),c=i(n);a.extend({MeshReflectorMaterial:s.MeshReflectorMaterial});const m=d.forwardRef((({mixBlur:e=0,mixStrength:t=.5,resolution:n=256,blur:s=[0,0],args:i=[1,1],minDepthThreshold:l=.9,maxDepthThreshold:m=1,depthScale:p=0,depthToBlurRatioBias:h=.25,mirror:f=0,children:x,debug:M=0,distortion:b=1,gamma:g=1,contrast:w=1,brightness:T=0,distortionMap:y,...R},S)=>{d.useEffect((()=>{console.warn("Reflector has been deprecated and will be removed next major. Replace it with <MeshReflectorMaterial />!")}),[]);const j=a.useThree((({gl:e})=>e)),B=a.useThree((({camera:e})=>e)),v=a.useThree((({scene:e})=>e)),D=(s=Array.isArray(s)?s:[s,s])[0]+s[1]>0,P=d.useRef(null),[E]=d.useState((()=>new r.Plane)),[F]=d.useState((()=>new r.Vector3)),[V]=d.useState((()=>new r.Vector3)),[W]=d.useState((()=>new r.Vector3)),[O]=d.useState((()=>new r.Matrix4)),[q]=d.useState((()=>new r.Vector3(0,0,-1))),[U]=d.useState((()=>new r.Vector4)),[_]=d.useState((()=>new r.Vector3)),[C]=d.useState((()=>new r.Vector3)),[L]=d.useState((()=>new r.Vector4)),[k]=d.useState((()=>new r.Matrix4)),[z]=d.useState((()=>new r.PerspectiveCamera)),A=d.useCallback((()=>{if(V.setFromMatrixPosition(P.current.matrixWorld),W.setFromMatrixPosition(B.matrixWorld),O.extractRotation(P.current.matrixWorld),F.set(0,0,1),F.applyMatrix4(O),_.subVectors(V,W),_.dot(F)>0)return;_.reflect(F).negate(),_.add(V),O.extractRotation(B.matrixWorld),q.set(0,0,-1),q.applyMatrix4(O),q.add(W),C.subVectors(V,q),C.reflect(F).negate(),C.add(V),z.position.copy(_),z.up.set(0,1,0),z.up.applyMatrix4(O),z.up.reflect(F),z.lookAt(C),z.far=B.far,z.updateMatrixWorld(),z.projectionMatrix.copy(B.projectionMatrix),k.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),k.multiply(z.projectionMatrix),k.multiply(z.matrixWorldInverse),k.multiply(P.current.matrixWorld),E.setFromNormalAndCoplanarPoint(F,V),E.applyMatrix4(z.matrixWorldInverse),U.set(E.normal.x,E.normal.y,E.normal.z,E.constant);const e=z.projectionMatrix;L.x=(Math.sign(U.x)+e.elements[8])/e.elements[0],L.y=(Math.sign(U.y)+e.elements[9])/e.elements[5],L.z=-1,L.w=(1+e.elements[10])/e.elements[14],U.multiplyScalar(2/U.dot(L)),e.elements[2]=U.x,e.elements[6]=U.y,e.elements[10]=U.z+1,e.elements[14]=U.w}),[]),[G,I,N,H]=d.useMemo((()=>{const a={minFilter:r.LinearFilter,magFilter:r.LinearFilter,format:r.RGBFormat,encoding:j.outputEncoding},i=new r.WebGLRenderTarget(n,n,a);i.depthBuffer=!0,i.depthTexture=new r.DepthTexture(n,n),i.depthTexture.format=r.DepthFormat,i.depthTexture.type=r.UnsignedShortType;const u=new r.WebGLRenderTarget(n,n,a);return[i,u,new o.BlurPass({gl:j,resolution:n,width:s[0],height:s[1],minDepthThreshold:l,maxDepthThreshold:m,depthScale:p,depthToBlurRatioBias:h}),{mirror:f,textureMatrix:k,mixBlur:e,tDiffuse:i.texture,tDepth:i.depthTexture,tDiffuseBlur:u.texture,hasBlur:D,mixStrength:t,minDepthThreshold:l,maxDepthThreshold:m,depthScale:p,depthToBlurRatioBias:h,transparent:!0,debug:M,distortion:b,distortionMap:y,gamma:g,contrast:w,brightness:T,"defines-USE_BLUR":D?"":void 0,"defines-USE_DEPTH":p>0?"":void 0,"defines-USE_DISTORTION":y?"":void 0}]}),[j,s,k,n,f,D,e,t,l,m,p,h,M,b,y,g,w,T]);return a.useFrame((()=>{if(null==P||!P.current)return;P.current.visible=!1;const e=j.xr.enabled,t=j.shadowMap.autoUpdate;A(),j.xr.enabled=!1,j.shadowMap.autoUpdate=!1,j.setRenderTarget(G),j.state.buffers.depth.setMask(!0),j.autoClear||j.clear(),j.render(v,z),D&&N.render(j,G,I),j.xr.enabled=e,j.shadowMap.autoUpdate=t,P.current.visible=!0,j.setRenderTarget(null)})),d.createElement("mesh",u.default({ref:c.default([P,S])},R),d.createElement("planeBufferGeometry",{args:i}),x?x("meshReflectorMaterial",H):d.createElement("meshReflectorMaterial",H))}));exports.Reflector=m;
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("react-merge-refs"),o=require("../materials/BlurPass.cjs.js"),i=require("../materials/MeshReflectorMaterial.cjs.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function l(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");var u=s(e),d=l(t),c=s(n);a.extend({MeshReflectorMaterial:i.MeshReflectorMaterial});const p=d.forwardRef((({mixBlur:e=0,mixStrength:t=.5,resolution:n=256,blur:i=[0,0],args:s=[1,1],minDepthThreshold:l=.9,maxDepthThreshold:p=1,depthScale:m=0,depthToBlurRatioBias:h=.25,mirror:f=0,children:x,debug:M=0,distortion:b=1,mixContrast:w=1,distortionMap:g,...T},y)=>{d.useEffect((()=>{console.warn("Reflector has been deprecated and will be removed next major. Replace it with <MeshReflectorMaterial />!")}),[]);const R=a.useThree((({gl:e})=>e)),S=a.useThree((({camera:e})=>e)),j=a.useThree((({scene:e})=>e)),B=(i=Array.isArray(i)?i:[i,i])[0]+i[1]>0,v=d.useRef(null),[D]=d.useState((()=>new r.Plane)),[P]=d.useState((()=>new r.Vector3)),[E]=d.useState((()=>new r.Vector3)),[F]=d.useState((()=>new r.Vector3)),[V]=d.useState((()=>new r.Matrix4)),[W]=d.useState((()=>new r.Vector3(0,0,-1))),[O]=d.useState((()=>new r.Vector4)),[q]=d.useState((()=>new r.Vector3)),[U]=d.useState((()=>new r.Vector3)),[C]=d.useState((()=>new r.Vector4)),[_]=d.useState((()=>new r.Matrix4)),[L]=d.useState((()=>new r.PerspectiveCamera)),k=d.useCallback((()=>{if(E.setFromMatrixPosition(v.current.matrixWorld),F.setFromMatrixPosition(S.matrixWorld),V.extractRotation(v.current.matrixWorld),P.set(0,0,1),P.applyMatrix4(V),q.subVectors(E,F),q.dot(P)>0)return;q.reflect(P).negate(),q.add(E),V.extractRotation(S.matrixWorld),W.set(0,0,-1),W.applyMatrix4(V),W.add(F),U.subVectors(E,W),U.reflect(P).negate(),U.add(E),L.position.copy(q),L.up.set(0,1,0),L.up.applyMatrix4(V),L.up.reflect(P),L.lookAt(U),L.far=S.far,L.updateMatrixWorld(),L.projectionMatrix.copy(S.projectionMatrix),_.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),_.multiply(L.projectionMatrix),_.multiply(L.matrixWorldInverse),_.multiply(v.current.matrixWorld),D.setFromNormalAndCoplanarPoint(P,E),D.applyMatrix4(L.matrixWorldInverse),O.set(D.normal.x,D.normal.y,D.normal.z,D.constant);const e=L.projectionMatrix;C.x=(Math.sign(O.x)+e.elements[8])/e.elements[0],C.y=(Math.sign(O.y)+e.elements[9])/e.elements[5],C.z=-1,C.w=(1+e.elements[10])/e.elements[14],O.multiplyScalar(2/O.dot(C)),e.elements[2]=O.x,e.elements[6]=O.y,e.elements[10]=O.z+1,e.elements[14]=O.w}),[]),[z,A,G,I]=d.useMemo((()=>{const a={minFilter:r.LinearFilter,magFilter:r.LinearFilter,format:r.RGBFormat,encoding:R.outputEncoding},s=new r.WebGLRenderTarget(n,n,a);s.depthBuffer=!0,s.depthTexture=new r.DepthTexture(n,n),s.depthTexture.format=r.DepthFormat,s.depthTexture.type=r.UnsignedShortType;const u=new r.WebGLRenderTarget(n,n,a);return[s,u,new o.BlurPass({gl:R,resolution:n,width:i[0],height:i[1],minDepthThreshold:l,maxDepthThreshold:p,depthScale:m,depthToBlurRatioBias:h}),{mirror:f,textureMatrix:_,mixBlur:e,tDiffuse:s.texture,tDepth:s.depthTexture,tDiffuseBlur:u.texture,hasBlur:B,mixStrength:t,minDepthThreshold:l,maxDepthThreshold:p,depthScale:m,depthToBlurRatioBias:h,transparent:!0,debug:M,distortion:b,distortionMap:g,mixContrast:w,"defines-USE_BLUR":B?"":void 0,"defines-USE_DEPTH":m>0?"":void 0,"defines-USE_DISTORTION":g?"":void 0}]}),[R,i,_,n,f,B,e,t,l,p,m,h,M,b,g,w]);return a.useFrame((()=>{if(null==v||!v.current)return;v.current.visible=!1;const e=R.xr.enabled,t=R.shadowMap.autoUpdate;k(),R.xr.enabled=!1,R.shadowMap.autoUpdate=!1,R.setRenderTarget(z),R.state.buffers.depth.setMask(!0),R.autoClear||R.clear(),R.render(j,L),B&&G.render(R,z,A),R.xr.enabled=e,R.shadowMap.autoUpdate=t,v.current.visible=!0,R.setRenderTarget(null)})),d.createElement("mesh",u.default({ref:c.default([v,y])},T),d.createElement("planeBufferGeometry",{args:s}),x?x("meshReflectorMaterial",I):d.createElement("meshReflectorMaterial",I))}));exports.Reflector=p;
@@ -14,9 +14,7 @@ export declare type ReflectorProps = Omit<JSX.IntrinsicElements['mesh'], 'args'
14
14
  debug?: number;
15
15
  distortionMap?: Texture;
16
16
  distortion?: number;
17
- gamma?: number;
18
- contrast?: number;
19
- brightness?: number;
17
+ mixContrast?: number;
20
18
  children?: {
21
19
  (Component: React.ElementType<JSX.IntrinsicElements['meshReflectorMaterial']>, ComponentProps: MeshReflectorMaterialProps): JSX.Element | null;
22
20
  };
@@ -28,4 +26,4 @@ declare global {
28
26
  }
29
27
  }
30
28
  }
31
- export declare const Reflector: React.ForwardRefExoticComponent<Pick<ReflectorProps, "visible" | "attach" | "attachArray" | "attachObject" | "args" | "children" | "key" | "onUpdate" | "position" | "up" | "scale" | "rotation" | "matrix" | "quaternion" | "layers" | "dispose" | "type" | "id" | "uuid" | "name" | "parent" | "modelViewMatrix" | "normalMatrix" | "matrixWorld" | "matrixAutoUpdate" | "matrixWorldNeedsUpdate" | "castShadow" | "receiveShadow" | "frustumCulled" | "renderOrder" | "animations" | "userData" | "customDepthMaterial" | "customDistanceMaterial" | "isObject3D" | "onBeforeRender" | "onAfterRender" | "applyMatrix4" | "applyQuaternion" | "setRotationFromAxisAngle" | "setRotationFromEuler" | "setRotationFromMatrix" | "setRotationFromQuaternion" | "rotateOnAxis" | "rotateOnWorldAxis" | "rotateX" | "rotateY" | "rotateZ" | "translateOnAxis" | "translateX" | "translateY" | "translateZ" | "localToWorld" | "worldToLocal" | "lookAt" | "add" | "remove" | "clear" | "getObjectById" | "getObjectByName" | "getObjectByProperty" | "getWorldPosition" | "getWorldQuaternion" | "getWorldScale" | "getWorldDirection" | "raycast" | "traverse" | "traverseVisible" | "traverseAncestors" | "updateMatrix" | "updateMatrixWorld" | "updateWorldMatrix" | "toJSON" | "clone" | "copy" | "addEventListener" | "hasEventListener" | "removeEventListener" | "dispatchEvent" | keyof import("@react-three/fiber/dist/declarations/src/core/events").EventHandlers | "material" | "blur" | "geometry" | "morphTargetInfluences" | "morphTargetDictionary" | "isMesh" | "updateMorphTargets" | "resolution" | "minDepthThreshold" | "maxDepthThreshold" | "depthScale" | "depthToBlurRatioBias" | "mixBlur" | "mixStrength" | "mirror" | "debug" | "distortion" | "gamma" | "contrast" | "brightness" | "distortionMap"> & React.RefAttributes<Mesh<import("three").BufferGeometry, import("three").Material | import("three").Material[]>>>;
29
+ export declare const Reflector: React.ForwardRefExoticComponent<Pick<ReflectorProps, "visible" | "attach" | "attachArray" | "attachObject" | "args" | "children" | "key" | "onUpdate" | "position" | "up" | "scale" | "rotation" | "matrix" | "quaternion" | "layers" | "dispose" | "type" | "id" | "uuid" | "name" | "parent" | "modelViewMatrix" | "normalMatrix" | "matrixWorld" | "matrixAutoUpdate" | "matrixWorldNeedsUpdate" | "castShadow" | "receiveShadow" | "frustumCulled" | "renderOrder" | "animations" | "userData" | "customDepthMaterial" | "customDistanceMaterial" | "isObject3D" | "onBeforeRender" | "onAfterRender" | "applyMatrix4" | "applyQuaternion" | "setRotationFromAxisAngle" | "setRotationFromEuler" | "setRotationFromMatrix" | "setRotationFromQuaternion" | "rotateOnAxis" | "rotateOnWorldAxis" | "rotateX" | "rotateY" | "rotateZ" | "translateOnAxis" | "translateX" | "translateY" | "translateZ" | "localToWorld" | "worldToLocal" | "lookAt" | "add" | "remove" | "clear" | "getObjectById" | "getObjectByName" | "getObjectByProperty" | "getWorldPosition" | "getWorldQuaternion" | "getWorldScale" | "getWorldDirection" | "raycast" | "traverse" | "traverseVisible" | "traverseAncestors" | "updateMatrix" | "updateMatrixWorld" | "updateWorldMatrix" | "toJSON" | "clone" | "copy" | "addEventListener" | "hasEventListener" | "removeEventListener" | "dispatchEvent" | keyof import("@react-three/fiber/dist/declarations/src/core/events").EventHandlers | "material" | "blur" | "geometry" | "morphTargetInfluences" | "morphTargetDictionary" | "isMesh" | "updateMorphTargets" | "resolution" | "minDepthThreshold" | "maxDepthThreshold" | "depthScale" | "depthToBlurRatioBias" | "mixBlur" | "mixStrength" | "mirror" | "debug" | "distortion" | "mixContrast" | "distortionMap"> & React.RefAttributes<Mesh<import("three").BufferGeometry, import("three").Material | import("three").Material[]>>>;
package/core/Reflector.js CHANGED
@@ -23,9 +23,7 @@ const Reflector = /*#__PURE__*/React.forwardRef(({
23
23
  children,
24
24
  debug = 0,
25
25
  distortion = 1,
26
- gamma = 1,
27
- contrast = 1,
28
- brightness = 0,
26
+ mixContrast = 1,
29
27
  distortionMap,
30
28
  ...props
31
29
  }, ref) => {
@@ -146,15 +144,13 @@ const Reflector = /*#__PURE__*/React.forwardRef(({
146
144
  debug,
147
145
  distortion,
148
146
  distortionMap,
149
- gamma,
150
- contrast,
151
- brightness,
147
+ mixContrast,
152
148
  'defines-USE_BLUR': hasBlur ? '' : undefined,
153
149
  'defines-USE_DEPTH': depthScale > 0 ? '' : undefined,
154
150
  'defines-USE_DISTORTION': distortionMap ? '' : undefined
155
151
  };
156
152
  return [fbo1, fbo2, blurpass, reflectorProps];
157
- }, [gl, blur, textureMatrix, resolution, mirror, hasBlur, mixBlur, mixStrength, minDepthThreshold, maxDepthThreshold, depthScale, depthToBlurRatioBias, debug, distortion, distortionMap, gamma, contrast, brightness]);
153
+ }, [gl, blur, textureMatrix, resolution, mirror, hasBlur, mixBlur, mixStrength, minDepthThreshold, maxDepthThreshold, depthScale, depthToBlurRatioBias, debug, distortion, distortionMap, mixContrast]);
158
154
  useFrame(() => {
159
155
  if (!(meshRef != null && meshRef.current)) return;
160
156
  meshRef.current.visible = false;