@react-three/drei 7.27.1 → 7.27.2
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 +8 -5
- package/core/MeshReflectorMaterial.cjs.js +1 -1
- package/core/MeshReflectorMaterial.d.ts +4 -1
- package/core/MeshReflectorMaterial.js +10 -4
- package/core/Reflector.cjs.js +1 -1
- package/core/Reflector.d.ts +4 -1
- package/core/Reflector.js +9 -3
- package/index.cjs.js +1 -1
- package/materials/MeshReflectorMaterial.cjs.js +1 -1
- package/materials/MeshReflectorMaterial.d.ts +12 -0
- package/materials/MeshReflectorMaterial.js +48 -2
- package/package.json +1 -1
- package/web/PresentationControls.cjs.js +1 -1
- package/web/PresentationControls.js +1 -1
package/README.md
CHANGED
|
@@ -616,15 +616,18 @@ Easily add reflections and/or blur to any mesh. It takes surface roughness into
|
|
|
616
616
|
<planeGeometry />
|
|
617
617
|
<MeshReflectorMaterial
|
|
618
618
|
blur={[0, 0]} // Blur ground reflections (width, heigt), 0 skips blur
|
|
619
|
-
mixBlur={
|
|
620
|
-
mixStrength={
|
|
619
|
+
mixBlur={0} // How much blur mixes with surface roughness (default = 1)
|
|
620
|
+
mixStrength={1} // Strength of the reflections
|
|
621
621
|
resolution={256} // Off-buffer resolution, lower=faster, higher=better quality, slower
|
|
622
|
-
mirror={0
|
|
623
|
-
depthScale={
|
|
622
|
+
mirror={0} // Mirror environment, 0 = texture colors, 1 = pick up env colors
|
|
623
|
+
depthScale={0} // Scale the depth factor (0 = no depth, default = 0)
|
|
624
624
|
minDepthThreshold={0.9} // Lower edge for the depthTexture interpolation (default = 0)
|
|
625
625
|
maxDepthThreshold={1} // Upper edge for the depthTexture interpolation (default = 0)
|
|
626
626
|
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
|
-
|
|
627
|
+
gamma={1} // Reflection layer gamma
|
|
628
|
+
contrast={1} // Reflection layer contrast
|
|
629
|
+
brightness={0} // Reflection layer brightness
|
|
630
|
+
distortion={1} // Amount of distortion based on the distortionMap texture
|
|
628
631
|
distortionMap={distortionTexture} // The red channel of this texture is used as the distortion map. Default is null
|
|
629
632
|
debug={0} /* Depending on the assigned value, one of the following channels is shown:
|
|
630
633
|
0 = no debug
|
|
@@ -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
|
+
"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;
|
|
@@ -14,6 +14,9 @@ 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
20
|
};
|
|
18
21
|
declare global {
|
|
19
22
|
namespace JSX {
|
|
@@ -22,4 +25,4 @@ declare global {
|
|
|
22
25
|
}
|
|
23
26
|
}
|
|
24
27
|
}
|
|
25
|
-
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" | "distortionMap"> & React.RefAttributes<MeshReflectorMaterialImpl>>;
|
|
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>>;
|
|
@@ -10,17 +10,20 @@ extend({
|
|
|
10
10
|
MeshReflectorMaterialImpl: MeshReflectorMaterial$1
|
|
11
11
|
});
|
|
12
12
|
const MeshReflectorMaterial = /*#__PURE__*/React.forwardRef(({
|
|
13
|
-
mixBlur = 0
|
|
14
|
-
mixStrength =
|
|
13
|
+
mixBlur = 0,
|
|
14
|
+
mixStrength = 1,
|
|
15
15
|
resolution = 256,
|
|
16
16
|
blur = [0, 0],
|
|
17
17
|
minDepthThreshold = 0.9,
|
|
18
18
|
maxDepthThreshold = 1,
|
|
19
19
|
depthScale = 0,
|
|
20
20
|
depthToBlurRatioBias = 0.25,
|
|
21
|
-
mirror = 0
|
|
21
|
+
mirror = 0,
|
|
22
22
|
debug = 0,
|
|
23
23
|
distortion = 1,
|
|
24
|
+
gamma = 1,
|
|
25
|
+
contrast = 1,
|
|
26
|
+
brightness = 0,
|
|
24
27
|
distortionMap,
|
|
25
28
|
...props
|
|
26
29
|
}, ref) => {
|
|
@@ -143,12 +146,15 @@ const MeshReflectorMaterial = /*#__PURE__*/React.forwardRef(({
|
|
|
143
146
|
debug,
|
|
144
147
|
distortion,
|
|
145
148
|
distortionMap,
|
|
149
|
+
gamma,
|
|
150
|
+
contrast,
|
|
151
|
+
brightness,
|
|
146
152
|
'defines-USE_BLUR': hasBlur ? '' : undefined,
|
|
147
153
|
'defines-USE_DEPTH': depthScale > 0 ? '' : undefined,
|
|
148
154
|
'defines-USE_DISTORTION': distortionMap ? '' : undefined
|
|
149
155
|
};
|
|
150
156
|
return [fbo1, fbo2, blurpass, reflectorProps];
|
|
151
|
-
}, [gl, blur, textureMatrix, resolution, mirror, hasBlur, mixBlur, mixStrength, minDepthThreshold, maxDepthThreshold, depthScale, depthToBlurRatioBias, debug, distortion, distortionMap]);
|
|
157
|
+
}, [gl, blur, textureMatrix, resolution, mirror, hasBlur, mixBlur, mixStrength, minDepthThreshold, maxDepthThreshold, depthScale, depthToBlurRatioBias, debug, distortion, distortionMap, gamma, contrast, brightness]);
|
|
152
158
|
useFrame(() => {
|
|
153
159
|
var _materialRef$current2;
|
|
154
160
|
|
package/core/Reflector.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"),a=require("@react-three/fiber"),n=require("react-merge-refs"),o=require("../materials/BlurPass.cjs.js"),
|
|
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;
|
package/core/Reflector.d.ts
CHANGED
|
@@ -14,6 +14,9 @@ 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
20
|
children?: {
|
|
18
21
|
(Component: React.ElementType<JSX.IntrinsicElements['meshReflectorMaterial']>, ComponentProps: MeshReflectorMaterialProps): JSX.Element | null;
|
|
19
22
|
};
|
|
@@ -25,4 +28,4 @@ declare global {
|
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
|
-
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" | "distortionMap"> & React.RefAttributes<Mesh<import("three").BufferGeometry, import("three").Material | import("three").Material[]>>>;
|
|
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[]>>>;
|
package/core/Reflector.js
CHANGED
|
@@ -10,7 +10,7 @@ extend({
|
|
|
10
10
|
MeshReflectorMaterial
|
|
11
11
|
});
|
|
12
12
|
const Reflector = /*#__PURE__*/React.forwardRef(({
|
|
13
|
-
mixBlur = 0
|
|
13
|
+
mixBlur = 0,
|
|
14
14
|
mixStrength = 0.5,
|
|
15
15
|
resolution = 256,
|
|
16
16
|
blur = [0, 0],
|
|
@@ -19,10 +19,13 @@ const Reflector = /*#__PURE__*/React.forwardRef(({
|
|
|
19
19
|
maxDepthThreshold = 1,
|
|
20
20
|
depthScale = 0,
|
|
21
21
|
depthToBlurRatioBias = 0.25,
|
|
22
|
-
mirror,
|
|
22
|
+
mirror = 0,
|
|
23
23
|
children,
|
|
24
24
|
debug = 0,
|
|
25
25
|
distortion = 1,
|
|
26
|
+
gamma = 1,
|
|
27
|
+
contrast = 1,
|
|
28
|
+
brightness = 0,
|
|
26
29
|
distortionMap,
|
|
27
30
|
...props
|
|
28
31
|
}, ref) => {
|
|
@@ -143,12 +146,15 @@ const Reflector = /*#__PURE__*/React.forwardRef(({
|
|
|
143
146
|
debug,
|
|
144
147
|
distortion,
|
|
145
148
|
distortionMap,
|
|
149
|
+
gamma,
|
|
150
|
+
contrast,
|
|
151
|
+
brightness,
|
|
146
152
|
'defines-USE_BLUR': hasBlur ? '' : undefined,
|
|
147
153
|
'defines-USE_DEPTH': depthScale > 0 ? '' : undefined,
|
|
148
154
|
'defines-USE_DISTORTION': distortionMap ? '' : undefined
|
|
149
155
|
};
|
|
150
156
|
return [fbo1, fbo2, blurpass, reflectorProps];
|
|
151
|
-
}, [gl, blur, textureMatrix, resolution, mirror, hasBlur, mixBlur, mixStrength, minDepthThreshold, maxDepthThreshold, depthScale, depthToBlurRatioBias, debug, distortion, distortionMap]);
|
|
157
|
+
}, [gl, blur, textureMatrix, resolution, mirror, hasBlur, mixBlur, mixStrength, minDepthThreshold, maxDepthThreshold, depthScale, depthToBlurRatioBias, debug, distortion, distortionMap, gamma, contrast, brightness]);
|
|
152
158
|
useFrame(() => {
|
|
153
159
|
if (!(meshRef != null && meshRef.current)) return;
|
|
154
160
|
meshRef.current.visible = false;
|