@react-three/drei 9.121.6-rc.1 → 9.122.0
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/core/AccumulativeShadows.d.ts +10 -8
- package/core/ArcballControls.d.ts +4 -4
- package/core/AsciiRenderer.d.ts +2 -1
- package/core/BBAnchor.d.ts +3 -3
- package/core/Backdrop.d.ts +1 -2
- package/core/Billboard.cjs.js +1 -1
- package/core/Billboard.d.ts +2 -3
- package/core/Billboard.js +1 -1
- package/core/Bounds.d.ts +1 -2
- package/core/Bvh.d.ts +2 -3
- package/core/CameraControls.d.ts +4 -4
- package/core/CatmullRomLine.d.ts +3 -2
- package/core/Caustics.d.ts +17 -14
- package/core/Center.d.ts +2 -3
- package/core/Clone.d.ts +4 -4
- package/core/Cloud.cjs.js +1 -1
- package/core/Cloud.d.ts +12 -50
- package/core/Cloud.js +3 -3
- package/core/ComputedAttribute.cjs.js +1 -1
- package/core/ComputedAttribute.d.ts +4 -3
- package/core/ComputedAttribute.js +1 -1
- package/core/ContactShadows.d.ts +2 -3
- package/core/CubeCamera.d.ts +3 -3
- package/core/CubeTexture.d.ts +6 -5
- package/core/CubeTexture.js +7 -2
- package/core/CubicBezierLine.d.ts +3 -2
- package/core/CurveModifier.d.ts +1 -2
- package/core/Decal.d.ts +2 -2
- package/core/Detailed.d.ts +3 -3
- package/core/DetectGPU.d.ts +2 -1
- package/core/DeviceOrientationControls.d.ts +2 -2
- package/core/Edges.cjs.js +1 -1
- package/core/Edges.d.ts +2 -2
- package/core/Edges.js +2 -2
- package/core/Effects.cjs.js +1 -1
- package/core/Effects.d.ts +13 -9
- package/core/Effects.js +3 -3
- package/core/Environment.cjs.js +1 -1
- package/core/Environment.d.ts +7 -5
- package/core/Fbo.d.ts +4 -1
- package/core/Fbo.js +2 -0
- package/core/Fbx.d.ts +1 -1
- package/core/FirstPersonControls.d.ts +2 -2
- package/core/Fisheye.d.ts +1 -2
- package/core/Float.d.ts +1 -2
- package/core/FlyControls.d.ts +2 -2
- package/core/GizmoHelper.d.ts +1 -2
- package/core/GizmoViewport.d.ts +2 -2
- package/core/Gltf.d.ts +5 -9
- package/core/GradientTexture.d.ts +4 -4
- package/core/GradientTexture.js +2 -0
- package/core/Grid.d.ts +7 -6
- package/core/Helper.cjs.js +1 -1
- package/core/Helper.d.ts +1 -1
- package/core/Helper.js +1 -1
- package/core/Hud.d.ts +2 -1
- package/core/Image.d.ts +8 -6
- package/core/Instances.cjs.js +1 -1
- package/core/Instances.d.ts +35 -27
- package/core/Instances.js +30 -35
- package/core/Ktx2.d.ts +1 -1
- package/core/Lightformer.d.ts +3 -3
- package/core/Line.d.ts +4 -4
- package/core/MapControls.d.ts +4 -4
- package/core/MarchingCubes.d.ts +6 -6
- package/core/Mask.d.ts +3 -3
- package/core/MeshDiscardMaterial.d.ts +7 -6
- package/core/MeshDistortMaterial.d.ts +17 -15
- package/core/MeshPortalMaterial.cjs.js +1 -1
- package/core/MeshPortalMaterial.d.ts +17 -14
- package/core/MeshPortalMaterial.js +2 -2
- package/core/MeshReflectorMaterial.cjs.js +1 -1
- package/core/MeshReflectorMaterial.d.ts +22 -9
- package/core/MeshReflectorMaterial.js +4 -2
- package/core/MeshRefractionMaterial.cjs.js +1 -1
- package/core/MeshRefractionMaterial.d.ts +8 -5
- package/core/MeshRefractionMaterial.js +2 -2
- package/core/MeshTransmissionMaterial.cjs.js +1 -1
- package/core/MeshTransmissionMaterial.d.ts +8 -7
- package/core/MeshTransmissionMaterial.js +1 -2
- package/core/MeshWobbleMaterial.d.ts +17 -15
- package/core/MotionPathControls.cjs.js +1 -1
- package/core/MotionPathControls.d.ts +11 -18
- package/core/MotionPathControls.js +32 -24
- package/core/MultiMaterial.cjs.js +1 -1
- package/core/MultiMaterial.d.ts +1 -3
- package/core/MultiMaterial.js +3 -2
- package/core/OrbitControls.d.ts +4 -4
- package/core/OrthographicCamera.d.ts +3 -3
- package/core/Outlines.cjs.js +1 -1
- package/core/Outlines.d.ts +3 -2
- package/core/Outlines.js +2 -2
- package/core/PerformanceMonitor.d.ts +2 -2
- package/core/PerspectiveCamera.d.ts +3 -3
- package/core/PointMaterial.d.ts +11 -3
- package/core/PointerLockControls.d.ts +2 -2
- package/core/Points.cjs.js +1 -1
- package/core/Points.d.ts +13 -10
- package/core/Points.js +16 -6
- package/core/PositionalAudio.d.ts +3 -3
- package/core/Preload.d.ts +3 -2
- package/core/QuadraticBezierLine.d.ts +7 -5
- package/core/Reflector.cjs.js +1 -0
- package/core/Reflector.d.ts +30 -0
- package/core/Reflector.js +180 -0
- package/core/RenderCubeTexture.d.ts +2 -2
- package/core/RenderTexture.cjs.js +1 -1
- package/core/RenderTexture.d.ts +3 -3
- package/core/RenderTexture.js +2 -3
- package/core/Resize.d.ts +2 -9
- package/core/RoundedBox.d.ts +4 -4
- package/core/Sampler.d.ts +4 -4
- package/core/ScreenQuad.d.ts +3 -3
- package/core/ScreenSizer.d.ts +3 -3
- package/core/ScreenSpace.d.ts +2 -3
- package/core/Segments.d.ts +8 -6
- package/core/Shadow.d.ts +3 -3
- package/core/ShadowAlpha.cjs.js +1 -1
- package/core/ShadowAlpha.d.ts +2 -1
- package/core/ShadowAlpha.js +1 -1
- package/core/Sky.d.ts +3 -2
- package/core/Sparkles.d.ts +16 -14
- package/core/Splat.d.ts +8 -6
- package/core/SpotLight.d.ts +1 -2
- package/core/SpriteAnimator.cjs.js +1 -1
- package/core/SpriteAnimator.d.ts +3 -36
- package/core/Stage.cjs.js +1 -1
- package/core/Stage.d.ts +2 -3
- package/core/Stars.cjs.js +1 -1
- package/core/Stars.d.ts +8 -6
- package/core/Stars.js +1 -1
- package/core/Stats.d.ts +3 -2
- package/core/StatsGl.d.ts +2 -2
- package/core/Svg.d.ts +6 -6
- package/core/Text.d.ts +4 -3
- package/core/Text3D.d.ts +10 -7
- package/core/Texture.d.ts +1 -1
- package/core/TrackballControls.d.ts +4 -4
- package/core/Trail.cjs.js +1 -1
- package/core/Trail.d.ts +3 -3
- package/core/Trail.js +3 -3
- package/core/TrailTexture.d.ts +2 -3
- package/core/TransformControls.cjs.js +1 -1
- package/core/TransformControls.d.ts +3 -3
- package/core/TransformControls.js +5 -4
- package/core/VideoTexture.cjs.js +1 -1
- package/core/VideoTexture.js +1 -1
- package/core/Wireframe.d.ts +7 -5
- package/core/index.cjs.js +1 -1
- package/core/index.d.ts +1 -0
- package/core/index.js +3 -1
- package/core/shapes.d.ts +20 -21
- package/core/softShadows.d.ts +2 -1
- package/core/useAnimations.cjs.js +1 -1
- package/core/useAnimations.d.ts +2 -2
- package/core/useAnimations.js +1 -1
- package/core/useBoxProjectedEnv.d.ts +1 -1
- package/core/useCamera.cjs.js +1 -1
- package/core/useCamera.d.ts +1 -1
- package/core/useCamera.js +8 -1
- package/core/useContextBridge.d.ts +1 -1
- package/core/useEnvironment.cjs.js +1 -1
- package/core/useEnvironment.d.ts +4 -3
- package/core/useEnvironment.js +19 -11
- package/core/useIntersect.d.ts +1 -1
- package/core/useSpriteLoader.d.ts +1 -1
- package/helpers/deprecated.cjs.js +1 -1
- package/helpers/deprecated.d.ts +4 -1
- package/helpers/deprecated.js +14 -2
- package/helpers/ts-utils.d.ts +0 -4
- package/helpers/useEffectfulState.d.ts +1 -1
- package/index.cjs.js +1 -1
- package/index.js +1 -0
- package/materials/BlurPass.js +1 -0
- package/materials/MeshReflectorMaterial.d.ts +16 -0
- package/native/index.cjs.js +1 -1
- package/native/index.js +3 -1
- package/package.json +8 -7
- package/web/CycleRaycast.d.ts +1 -1
- package/web/FaceLandmarker.d.ts +2 -1
- package/web/Facemesh.d.ts +2 -3
- package/web/Html.cjs.js +1 -1
- package/web/Html.d.ts +4 -4
- package/web/Html.js +1 -1
- package/web/KeyboardControls.d.ts +1 -1
- package/web/PresentationControls.cjs.js +1 -1
- package/web/PresentationControls.d.ts +4 -3
- package/web/PresentationControls.js +28 -20
- package/web/ScrollControls.d.ts +1 -1
- package/web/Select.d.ts +3 -3
- package/web/Select.js +2 -6
- package/web/View.cjs.js +1 -1
- package/web/View.d.ts +10 -8
- package/web/View.js +34 -4
- package/web/index.cjs.js +1 -1
- package/web/index.js +3 -0
- package/web/pivotControls/AxisArrow.js +2 -0
- package/web/pivotControls/AxisRotator.js +2 -0
- package/web/pivotControls/PlaneSlider.js +2 -0
- package/web/pivotControls/ScalingSphere.js +1 -0
- package/web/pivotControls/index.d.ts +2 -1
package/core/Points.d.ts
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { ReactThreeFiber } from '@react-three/fiber';
|
|
4
4
|
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
5
|
-
declare
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
declare global {
|
|
6
|
+
namespace JSX {
|
|
7
|
+
interface IntrinsicElements {
|
|
8
|
+
positionPoint: ReactThreeFiber.Object3DNode<PositionPoint, typeof PositionPoint>;
|
|
9
|
+
}
|
|
8
10
|
}
|
|
9
11
|
}
|
|
10
|
-
|
|
12
|
+
type PointsInstancesProps = JSX.IntrinsicElements['points'] & {
|
|
11
13
|
range?: number;
|
|
12
14
|
limit?: number;
|
|
13
15
|
};
|
|
14
16
|
export declare class PositionPoint extends THREE.Group {
|
|
15
17
|
size: number;
|
|
16
18
|
color: THREE.Color;
|
|
17
|
-
instance: React.
|
|
18
|
-
instanceKey: React.
|
|
19
|
+
instance: React.MutableRefObject<THREE.Points | undefined>;
|
|
20
|
+
instanceKey: React.MutableRefObject<JSX.IntrinsicElements['positionPoint'] | undefined>;
|
|
19
21
|
constructor();
|
|
20
|
-
get geometry(): THREE.BufferGeometry
|
|
22
|
+
get geometry(): THREE.BufferGeometry | undefined;
|
|
21
23
|
raycast(raycaster: THREE.Raycaster, intersects: THREE.Intersection[]): void;
|
|
22
24
|
}
|
|
23
|
-
export declare const Point: ForwardRefComponent<
|
|
24
|
-
|
|
25
|
+
export declare const Point: ForwardRefComponent<JSX.IntrinsicElements['positionPoint'], PositionPoint>;
|
|
26
|
+
type PointsBuffersProps = JSX.IntrinsicElements['points'] & {
|
|
25
27
|
positions: Float32Array;
|
|
26
28
|
colors?: Float32Array;
|
|
27
29
|
sizes?: Float32Array;
|
|
@@ -29,3 +31,4 @@ export type PointsBuffersProps = ThreeElements['points'] & {
|
|
|
29
31
|
};
|
|
30
32
|
export declare const PointsBuffer: ForwardRefComponent<PointsBuffersProps, THREE.Points>;
|
|
31
33
|
export declare const Points: ForwardRefComponent<PointsBuffersProps | PointsInstancesProps, THREE.Points>;
|
|
34
|
+
export {};
|
package/core/Points.js
CHANGED
|
@@ -116,15 +116,21 @@ const PointsInstances = /* @__PURE__ */React.forwardRef(({
|
|
|
116
116
|
raycast: () => null
|
|
117
117
|
}, props), /*#__PURE__*/React.createElement("bufferGeometry", null, /*#__PURE__*/React.createElement("bufferAttribute", {
|
|
118
118
|
attach: "attributes-position",
|
|
119
|
-
|
|
119
|
+
count: positions.length / 3,
|
|
120
|
+
array: positions,
|
|
121
|
+
itemSize: 3,
|
|
120
122
|
usage: THREE.DynamicDrawUsage
|
|
121
123
|
}), /*#__PURE__*/React.createElement("bufferAttribute", {
|
|
122
124
|
attach: "attributes-color",
|
|
123
|
-
|
|
125
|
+
count: colors.length / 3,
|
|
126
|
+
array: colors,
|
|
127
|
+
itemSize: 3,
|
|
124
128
|
usage: THREE.DynamicDrawUsage
|
|
125
129
|
}), /*#__PURE__*/React.createElement("bufferAttribute", {
|
|
126
130
|
attach: "attributes-size",
|
|
127
|
-
|
|
131
|
+
count: sizes.length,
|
|
132
|
+
array: sizes,
|
|
133
|
+
itemSize: 1,
|
|
128
134
|
usage: THREE.DynamicDrawUsage
|
|
129
135
|
})), /*#__PURE__*/React.createElement(context.Provider, {
|
|
130
136
|
value: api
|
|
@@ -175,17 +181,21 @@ const PointsBuffer = /* @__PURE__ */React.forwardRef(({
|
|
|
175
181
|
ref: pointsRef
|
|
176
182
|
}, props), /*#__PURE__*/React.createElement("bufferGeometry", null, /*#__PURE__*/React.createElement("bufferAttribute", {
|
|
177
183
|
attach: "attributes-position",
|
|
178
|
-
|
|
184
|
+
count: positions.length / stride,
|
|
185
|
+
array: positions,
|
|
186
|
+
itemSize: stride,
|
|
179
187
|
usage: THREE.DynamicDrawUsage
|
|
180
188
|
}), colors && /*#__PURE__*/React.createElement("bufferAttribute", {
|
|
181
189
|
attach: "attributes-color",
|
|
182
|
-
args: [colors, stride],
|
|
183
190
|
count: colors.length / stride,
|
|
191
|
+
array: colors,
|
|
192
|
+
itemSize: 3,
|
|
184
193
|
usage: THREE.DynamicDrawUsage
|
|
185
194
|
}), sizes && /*#__PURE__*/React.createElement("bufferAttribute", {
|
|
186
195
|
attach: "attributes-size",
|
|
187
|
-
args: [sizes, 1],
|
|
188
196
|
count: sizes.length / stride,
|
|
197
|
+
array: sizes,
|
|
198
|
+
itemSize: 1,
|
|
189
199
|
usage: THREE.DynamicDrawUsage
|
|
190
200
|
})), children);
|
|
191
201
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PositionalAudio as PositionalAudioImpl } from 'three';
|
|
2
|
-
import { ThreeElements } from '@react-three/fiber';
|
|
3
2
|
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
4
|
-
|
|
3
|
+
type Props = JSX.IntrinsicElements['positionalAudio'] & {
|
|
5
4
|
url: string;
|
|
6
5
|
distance?: number;
|
|
7
6
|
loop?: boolean;
|
|
8
7
|
};
|
|
9
|
-
export declare const PositionalAudio: ForwardRefComponent<
|
|
8
|
+
export declare const PositionalAudio: ForwardRefComponent<Props, PositionalAudioImpl>;
|
|
9
|
+
export {};
|
package/core/Preload.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Object3D, Camera } from 'three';
|
|
2
|
-
|
|
2
|
+
type Props = {
|
|
3
3
|
all?: boolean;
|
|
4
4
|
scene?: Object3D;
|
|
5
5
|
camera?: Camera;
|
|
6
6
|
};
|
|
7
|
-
export declare function Preload({ all, scene, camera }:
|
|
7
|
+
export declare function Preload({ all, scene, camera }: Props): null;
|
|
8
|
+
export {};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { Vector3 } from 'three';
|
|
2
2
|
import { Line2 } from 'three-stdlib';
|
|
3
3
|
import { LineProps } from './Line';
|
|
4
|
+
import { Object3DNode } from '@react-three/fiber';
|
|
4
5
|
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
5
|
-
|
|
6
|
-
setPoints(start: Vector3 | [number, number, number], end: Vector3 | [number, number, number], mid: Vector3 | [number, number, number]): void;
|
|
7
|
-
};
|
|
8
|
-
export type QuadraticBezierLineProps = Omit<LineProps, 'points' | 'ref'> & {
|
|
6
|
+
type Props = Omit<LineProps, 'points' | 'ref'> & {
|
|
9
7
|
start: Vector3 | [number, number, number];
|
|
10
8
|
end: Vector3 | [number, number, number];
|
|
11
9
|
mid?: Vector3 | [number, number, number];
|
|
12
10
|
segments?: number;
|
|
13
11
|
};
|
|
14
|
-
export
|
|
12
|
+
export type Line2Props = Object3DNode<Line2, typeof Line2> & {
|
|
13
|
+
setPoints: (start: Vector3 | [number, number, number], end: Vector3 | [number, number, number], mid: Vector3 | [number, number, number]) => void;
|
|
14
|
+
};
|
|
15
|
+
export declare const QuadraticBezierLine: ForwardRefComponent<Props, Line2Props>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +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"),s=require("../materials/MeshReflectorMaterial.cjs.js");function o(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=o(e),u=i(t);const c=u.forwardRef((({mixBlur:e=0,mixStrength:t=.5,resolution:o=256,blur:i=[0,0],args:c=[1,1],minDepthThreshold:d=.9,maxDepthThreshold:p=1,depthScale:m=0,depthToBlurRatioBias:h=.25,mirror:x=0,children:f,debug:M=0,distortion:b=1,mixContrast:w=1,distortionMap:y,...T},S)=>{a.extend({MeshReflectorMaterial:s.MeshReflectorMaterial}),u.useEffect((()=>{console.warn("Reflector has been deprecated and will be removed next major. Replace it with <MeshReflectorMaterial />!")}),[]);const g=a.useThree((({gl:e})=>e)),R=a.useThree((({camera:e})=>e)),j=a.useThree((({scene:e})=>e)),v=(i=Array.isArray(i)?i:[i,i])[0]+i[1]>0,B=u.useRef(null);u.useImperativeHandle(S,(()=>B.current),[]);const[D]=u.useState((()=>new r.Plane)),[P]=u.useState((()=>new r.Vector3)),[F]=u.useState((()=>new r.Vector3)),[V]=u.useState((()=>new r.Vector3)),[W]=u.useState((()=>new r.Matrix4)),[E]=u.useState((()=>new r.Vector3(0,0,-1))),[O]=u.useState((()=>new r.Vector4)),[q]=u.useState((()=>new r.Vector3)),[U]=u.useState((()=>new r.Vector3)),[C]=u.useState((()=>new r.Vector4)),[_]=u.useState((()=>new r.Matrix4)),[I]=u.useState((()=>new r.PerspectiveCamera)),L=u.useCallback((()=>{if(F.setFromMatrixPosition(B.current.matrixWorld),V.setFromMatrixPosition(R.matrixWorld),W.extractRotation(B.current.matrixWorld),P.set(0,0,1),P.applyMatrix4(W),q.subVectors(F,V),q.dot(P)>0)return;q.reflect(P).negate(),q.add(F),W.extractRotation(R.matrixWorld),E.set(0,0,-1),E.applyMatrix4(W),E.add(V),U.subVectors(F,E),U.reflect(P).negate(),U.add(F),I.position.copy(q),I.up.set(0,1,0),I.up.applyMatrix4(W),I.up.reflect(P),I.lookAt(U),I.far=R.far,I.updateMatrixWorld(),I.projectionMatrix.copy(R.projectionMatrix),_.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),_.multiply(I.projectionMatrix),_.multiply(I.matrixWorldInverse),_.multiply(B.current.matrixWorld),D.setFromNormalAndCoplanarPoint(P,F),D.applyMatrix4(I.matrixWorldInverse),O.set(D.normal.x,D.normal.y,D.normal.z,D.constant);const e=I.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}),[]),[k,z,A,G]=u.useMemo((()=>{const a={type:r.HalfFloatType,minFilter:r.LinearFilter,magFilter:r.LinearFilter},s=new r.WebGLRenderTarget(o,o,a);s.depthBuffer=!0,s.depthTexture=new r.DepthTexture(o,o),s.depthTexture.format=r.DepthFormat,s.depthTexture.type=r.UnsignedShortType;const l=new r.WebGLRenderTarget(o,o,a);return[s,l,new n.BlurPass({gl:g,resolution:o,width:i[0],height:i[1],minDepthThreshold:d,maxDepthThreshold:p,depthScale:m,depthToBlurRatioBias:h}),{mirror:x,textureMatrix:_,mixBlur:e,tDiffuse:s.texture,tDepth:s.depthTexture,tDiffuseBlur:l.texture,hasBlur:v,mixStrength:t,minDepthThreshold:d,maxDepthThreshold:p,depthScale:m,depthToBlurRatioBias:h,transparent:!0,debug:M,distortion:b,distortionMap:y,mixContrast:w,"defines-USE_BLUR":v?"":void 0,"defines-USE_DEPTH":m>0?"":void 0,"defines-USE_DISTORTION":y?"":void 0}]}),[g,i,_,o,x,v,e,t,d,p,m,h,M,b,y,w]);return a.useFrame((()=>{if(null==B||!B.current)return;B.current.visible=!1;const e=g.xr.enabled,t=g.shadowMap.autoUpdate;L(),g.xr.enabled=!1,g.shadowMap.autoUpdate=!1,g.setRenderTarget(k),g.state.buffers.depth.setMask(!0),g.autoClear||g.clear(),g.render(j,I),v&&A.render(g,k,z),g.xr.enabled=e,g.shadowMap.autoUpdate=t,B.current.visible=!0,g.setRenderTarget(null)})),u.createElement("mesh",l.default({ref:B},T),u.createElement("planeGeometry",{args:c}),f?f("meshReflectorMaterial",G):u.createElement("meshReflectorMaterial",G))}));exports.Reflector=c;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Mesh, Texture } from 'three';
|
|
3
|
+
import { MeshReflectorMaterialProps } from '../materials/MeshReflectorMaterial';
|
|
4
|
+
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
5
|
+
export type ReflectorProps = Omit<JSX.IntrinsicElements['mesh'], 'args' | 'children'> & Pick<JSX.IntrinsicElements['planeGeometry'], 'args'> & {
|
|
6
|
+
resolution?: number;
|
|
7
|
+
mixBlur?: number;
|
|
8
|
+
mixStrength?: number;
|
|
9
|
+
blur?: [number, number] | number;
|
|
10
|
+
mirror: number;
|
|
11
|
+
minDepthThreshold?: number;
|
|
12
|
+
maxDepthThreshold?: number;
|
|
13
|
+
depthScale?: number;
|
|
14
|
+
depthToBlurRatioBias?: number;
|
|
15
|
+
debug?: number;
|
|
16
|
+
distortionMap?: Texture;
|
|
17
|
+
distortion?: number;
|
|
18
|
+
mixContrast?: number;
|
|
19
|
+
children?: {
|
|
20
|
+
(Component: React.ElementType<JSX.IntrinsicElements['meshReflectorMaterial']>, ComponentProps: MeshReflectorMaterialProps): JSX.Element | null;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
declare global {
|
|
24
|
+
namespace JSX {
|
|
25
|
+
interface IntrinsicElements {
|
|
26
|
+
meshReflectorMaterial: MeshReflectorMaterialProps;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export declare const Reflector: ForwardRefComponent<ReflectorProps, Mesh>;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Plane, Vector3, Matrix4, Vector4, PerspectiveCamera, WebGLRenderTarget, DepthTexture, DepthFormat, UnsignedShortType, HalfFloatType, LinearFilter } from 'three';
|
|
4
|
+
import { extend, useThree, useFrame } from '@react-three/fiber';
|
|
5
|
+
import { BlurPass } from '../materials/BlurPass.js';
|
|
6
|
+
import { MeshReflectorMaterial } from '../materials/MeshReflectorMaterial.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Use MeshReflectorMaterial instead
|
|
10
|
+
*/
|
|
11
|
+
const Reflector = /* @__PURE__ */React.forwardRef(({
|
|
12
|
+
mixBlur = 0,
|
|
13
|
+
mixStrength = 0.5,
|
|
14
|
+
resolution = 256,
|
|
15
|
+
blur = [0, 0],
|
|
16
|
+
args = [1, 1],
|
|
17
|
+
minDepthThreshold = 0.9,
|
|
18
|
+
maxDepthThreshold = 1,
|
|
19
|
+
depthScale = 0,
|
|
20
|
+
depthToBlurRatioBias = 0.25,
|
|
21
|
+
mirror = 0,
|
|
22
|
+
children,
|
|
23
|
+
debug = 0,
|
|
24
|
+
distortion = 1,
|
|
25
|
+
mixContrast = 1,
|
|
26
|
+
distortionMap,
|
|
27
|
+
...props
|
|
28
|
+
}, ref) => {
|
|
29
|
+
extend({
|
|
30
|
+
MeshReflectorMaterial
|
|
31
|
+
});
|
|
32
|
+
React.useEffect(() => {
|
|
33
|
+
console.warn('Reflector has been deprecated and will be removed next major. Replace it with <MeshReflectorMaterial />!');
|
|
34
|
+
}, []);
|
|
35
|
+
const gl = useThree(({
|
|
36
|
+
gl
|
|
37
|
+
}) => gl);
|
|
38
|
+
const camera = useThree(({
|
|
39
|
+
camera
|
|
40
|
+
}) => camera);
|
|
41
|
+
const scene = useThree(({
|
|
42
|
+
scene
|
|
43
|
+
}) => scene);
|
|
44
|
+
blur = Array.isArray(blur) ? blur : [blur, blur];
|
|
45
|
+
const hasBlur = blur[0] + blur[1] > 0;
|
|
46
|
+
const meshRef = React.useRef(null);
|
|
47
|
+
React.useImperativeHandle(ref, () => meshRef.current, []);
|
|
48
|
+
const [reflectorPlane] = React.useState(() => new Plane());
|
|
49
|
+
const [normal] = React.useState(() => new Vector3());
|
|
50
|
+
const [reflectorWorldPosition] = React.useState(() => new Vector3());
|
|
51
|
+
const [cameraWorldPosition] = React.useState(() => new Vector3());
|
|
52
|
+
const [rotationMatrix] = React.useState(() => new Matrix4());
|
|
53
|
+
const [lookAtPosition] = React.useState(() => new Vector3(0, 0, -1));
|
|
54
|
+
const [clipPlane] = React.useState(() => new Vector4());
|
|
55
|
+
const [view] = React.useState(() => new Vector3());
|
|
56
|
+
const [target] = React.useState(() => new Vector3());
|
|
57
|
+
const [q] = React.useState(() => new Vector4());
|
|
58
|
+
const [textureMatrix] = React.useState(() => new Matrix4());
|
|
59
|
+
const [virtualCamera] = React.useState(() => new PerspectiveCamera());
|
|
60
|
+
const beforeRender = React.useCallback(() => {
|
|
61
|
+
reflectorWorldPosition.setFromMatrixPosition(meshRef.current.matrixWorld);
|
|
62
|
+
cameraWorldPosition.setFromMatrixPosition(camera.matrixWorld);
|
|
63
|
+
rotationMatrix.extractRotation(meshRef.current.matrixWorld);
|
|
64
|
+
normal.set(0, 0, 1);
|
|
65
|
+
normal.applyMatrix4(rotationMatrix);
|
|
66
|
+
view.subVectors(reflectorWorldPosition, cameraWorldPosition);
|
|
67
|
+
// Avoid rendering when reflector is facing away
|
|
68
|
+
if (view.dot(normal) > 0) return;
|
|
69
|
+
view.reflect(normal).negate();
|
|
70
|
+
view.add(reflectorWorldPosition);
|
|
71
|
+
rotationMatrix.extractRotation(camera.matrixWorld);
|
|
72
|
+
lookAtPosition.set(0, 0, -1);
|
|
73
|
+
lookAtPosition.applyMatrix4(rotationMatrix);
|
|
74
|
+
lookAtPosition.add(cameraWorldPosition);
|
|
75
|
+
target.subVectors(reflectorWorldPosition, lookAtPosition);
|
|
76
|
+
target.reflect(normal).negate();
|
|
77
|
+
target.add(reflectorWorldPosition);
|
|
78
|
+
virtualCamera.position.copy(view);
|
|
79
|
+
virtualCamera.up.set(0, 1, 0);
|
|
80
|
+
virtualCamera.up.applyMatrix4(rotationMatrix);
|
|
81
|
+
virtualCamera.up.reflect(normal);
|
|
82
|
+
virtualCamera.lookAt(target);
|
|
83
|
+
virtualCamera.far = camera.far; // Used in WebGLBackground
|
|
84
|
+
virtualCamera.updateMatrixWorld();
|
|
85
|
+
virtualCamera.projectionMatrix.copy(camera.projectionMatrix);
|
|
86
|
+
// Update the texture matrix
|
|
87
|
+
textureMatrix.set(0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0);
|
|
88
|
+
textureMatrix.multiply(virtualCamera.projectionMatrix);
|
|
89
|
+
textureMatrix.multiply(virtualCamera.matrixWorldInverse);
|
|
90
|
+
textureMatrix.multiply(meshRef.current.matrixWorld);
|
|
91
|
+
// Now update projection matrix with new clip plane, implementing code from: http://www.terathon.com/code/oblique.html
|
|
92
|
+
// Paper explaining this technique: http://www.terathon.com/lengyel/Lengyel-Oblique.pdf
|
|
93
|
+
reflectorPlane.setFromNormalAndCoplanarPoint(normal, reflectorWorldPosition);
|
|
94
|
+
reflectorPlane.applyMatrix4(virtualCamera.matrixWorldInverse);
|
|
95
|
+
clipPlane.set(reflectorPlane.normal.x, reflectorPlane.normal.y, reflectorPlane.normal.z, reflectorPlane.constant);
|
|
96
|
+
const projectionMatrix = virtualCamera.projectionMatrix;
|
|
97
|
+
q.x = (Math.sign(clipPlane.x) + projectionMatrix.elements[8]) / projectionMatrix.elements[0];
|
|
98
|
+
q.y = (Math.sign(clipPlane.y) + projectionMatrix.elements[9]) / projectionMatrix.elements[5];
|
|
99
|
+
q.z = -1.0;
|
|
100
|
+
q.w = (1.0 + projectionMatrix.elements[10]) / projectionMatrix.elements[14];
|
|
101
|
+
// Calculate the scaled plane vector
|
|
102
|
+
clipPlane.multiplyScalar(2.0 / clipPlane.dot(q));
|
|
103
|
+
// Replacing the third row of the projection matrix
|
|
104
|
+
projectionMatrix.elements[2] = clipPlane.x;
|
|
105
|
+
projectionMatrix.elements[6] = clipPlane.y;
|
|
106
|
+
projectionMatrix.elements[10] = clipPlane.z + 1.0;
|
|
107
|
+
projectionMatrix.elements[14] = clipPlane.w;
|
|
108
|
+
}, []);
|
|
109
|
+
const [fbo1, fbo2, blurpass, reflectorProps] = React.useMemo(() => {
|
|
110
|
+
const parameters = {
|
|
111
|
+
type: HalfFloatType,
|
|
112
|
+
minFilter: LinearFilter,
|
|
113
|
+
magFilter: LinearFilter
|
|
114
|
+
};
|
|
115
|
+
const fbo1 = new WebGLRenderTarget(resolution, resolution, parameters);
|
|
116
|
+
fbo1.depthBuffer = true;
|
|
117
|
+
fbo1.depthTexture = new DepthTexture(resolution, resolution);
|
|
118
|
+
fbo1.depthTexture.format = DepthFormat;
|
|
119
|
+
fbo1.depthTexture.type = UnsignedShortType;
|
|
120
|
+
const fbo2 = new WebGLRenderTarget(resolution, resolution, parameters);
|
|
121
|
+
const blurpass = new BlurPass({
|
|
122
|
+
gl,
|
|
123
|
+
resolution,
|
|
124
|
+
width: blur[0],
|
|
125
|
+
height: blur[1],
|
|
126
|
+
minDepthThreshold,
|
|
127
|
+
maxDepthThreshold,
|
|
128
|
+
depthScale,
|
|
129
|
+
depthToBlurRatioBias
|
|
130
|
+
});
|
|
131
|
+
const reflectorProps = {
|
|
132
|
+
mirror,
|
|
133
|
+
textureMatrix,
|
|
134
|
+
mixBlur,
|
|
135
|
+
tDiffuse: fbo1.texture,
|
|
136
|
+
tDepth: fbo1.depthTexture,
|
|
137
|
+
tDiffuseBlur: fbo2.texture,
|
|
138
|
+
hasBlur,
|
|
139
|
+
mixStrength,
|
|
140
|
+
minDepthThreshold,
|
|
141
|
+
maxDepthThreshold,
|
|
142
|
+
depthScale,
|
|
143
|
+
depthToBlurRatioBias,
|
|
144
|
+
transparent: true,
|
|
145
|
+
debug,
|
|
146
|
+
distortion,
|
|
147
|
+
distortionMap,
|
|
148
|
+
mixContrast,
|
|
149
|
+
'defines-USE_BLUR': hasBlur ? '' : undefined,
|
|
150
|
+
'defines-USE_DEPTH': depthScale > 0 ? '' : undefined,
|
|
151
|
+
'defines-USE_DISTORTION': distortionMap ? '' : undefined
|
|
152
|
+
};
|
|
153
|
+
return [fbo1, fbo2, blurpass, reflectorProps];
|
|
154
|
+
}, [gl, blur, textureMatrix, resolution, mirror, hasBlur, mixBlur, mixStrength, minDepthThreshold, maxDepthThreshold, depthScale, depthToBlurRatioBias, debug, distortion, distortionMap, mixContrast]);
|
|
155
|
+
useFrame(() => {
|
|
156
|
+
if (!(meshRef != null && meshRef.current)) return;
|
|
157
|
+
meshRef.current.visible = false;
|
|
158
|
+
const currentXrEnabled = gl.xr.enabled;
|
|
159
|
+
const currentShadowAutoUpdate = gl.shadowMap.autoUpdate;
|
|
160
|
+
beforeRender();
|
|
161
|
+
gl.xr.enabled = false;
|
|
162
|
+
gl.shadowMap.autoUpdate = false;
|
|
163
|
+
gl.setRenderTarget(fbo1);
|
|
164
|
+
gl.state.buffers.depth.setMask(true);
|
|
165
|
+
if (!gl.autoClear) gl.clear();
|
|
166
|
+
gl.render(scene, virtualCamera);
|
|
167
|
+
if (hasBlur) blurpass.render(gl, fbo1, fbo2);
|
|
168
|
+
gl.xr.enabled = currentXrEnabled;
|
|
169
|
+
gl.shadowMap.autoUpdate = currentShadowAutoUpdate;
|
|
170
|
+
meshRef.current.visible = true;
|
|
171
|
+
gl.setRenderTarget(null);
|
|
172
|
+
});
|
|
173
|
+
return /*#__PURE__*/React.createElement("mesh", _extends({
|
|
174
|
+
ref: meshRef
|
|
175
|
+
}, props), /*#__PURE__*/React.createElement("planeGeometry", {
|
|
176
|
+
args: args
|
|
177
|
+
}), children ? children('meshReflectorMaterial', reflectorProps) : /*#__PURE__*/React.createElement("meshReflectorMaterial", reflectorProps));
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
export { Reflector };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { ComputeFunction, ReactThreeFiber
|
|
3
|
+
import { ComputeFunction, ReactThreeFiber } from '@react-three/fiber';
|
|
4
4
|
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
5
|
-
export type RenderCubeTextureProps = Omit<
|
|
5
|
+
export type RenderCubeTextureProps = Omit<JSX.IntrinsicElements['texture'], 'rotation'> & {
|
|
6
6
|
stencilBuffer?: boolean;
|
|
7
7
|
depthBuffer?: boolean;
|
|
8
8
|
generateMipmaps?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),r=require("three"),t=require("react"),n=require("@react-three/fiber"),a=require("./Fbo.cjs.js");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),r=require("three"),t=require("react"),n=require("@react-three/fiber"),a=require("./Fbo.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 r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var u=i(e),s=l(r),c=l(t);const o=c.forwardRef((({children:e,compute:r,width:t,height:i,samples:l=8,renderPriority:o=0,eventPriority:d=0,frames:g=1/0,stencilBuffer:p=!1,depthBuffer:m=!0,generateMipmaps:b=!1,...v},h)=>{const{size:x,viewport:y}=n.useThree(),j=a.useFBO((t||x.width)*y.dpr,(i||x.height)*y.dpr,{samples:l,stencilBuffer:p,depthBuffer:m,generateMipmaps:b}),[P]=c.useState((()=>new s.Scene)),O=c.useCallback(((e,r,t)=>{var n,a;let i=null==(n=j.texture)?void 0:n.__r3f.parent;for(;i&&!(i instanceof s.Object3D);)i=i.__r3f.parent;if(!i)return!1;t.raycaster.camera||t.events.compute(e,t,null==(a=t.previousRoot)?void 0:a.getState());const[l]=t.raycaster.intersectObject(i);if(!l)return!1;const u=l.uv;if(!u)return!1;r.raycaster.setFromCamera(r.pointer.set(2*u.x-1,2*u.y-1),r.camera)}),[]);return c.useImperativeHandle(h,(()=>j.texture),[j]),c.createElement(c.Fragment,null,n.createPortal(c.createElement(f,{renderPriority:o,frames:g,fbo:j},e,c.createElement("group",{onPointerOver:()=>null})),P,{events:{compute:r||O,priority:d}}),c.createElement("primitive",u.default({object:j.texture},v)))}));function f({frames:e,renderPriority:r,children:t,fbo:a}){let i,l,u,s,o=0;return n.useFrame((r=>{(e===1/0||o<e)&&(i=r.gl.autoClear,l=r.gl.xr.enabled,u=r.gl.getRenderTarget(),s=r.gl.xr.isPresenting,r.gl.autoClear=!0,r.gl.xr.enabled=!1,r.gl.xr.isPresenting=!1,r.gl.setRenderTarget(a),r.gl.render(r.scene,r.camera),r.gl.setRenderTarget(u),r.gl.autoClear=i,r.gl.xr.enabled=l,r.gl.xr.isPresenting=s,o++)}),r),c.createElement(c.Fragment,null,t)}exports.RenderTexture=o;
|
package/core/RenderTexture.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { ThreeElements } from '@react-three/fiber';
|
|
4
3
|
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
5
|
-
|
|
4
|
+
type Props = JSX.IntrinsicElements['texture'] & {
|
|
6
5
|
width?: number;
|
|
7
6
|
height?: number;
|
|
8
7
|
samples?: number;
|
|
@@ -15,4 +14,5 @@ export type RenderTextureProps = Omit<ThreeElements['texture'], 'ref' | 'args'>
|
|
|
15
14
|
compute?: (event: any, state: any, previous: any) => false | undefined;
|
|
16
15
|
children: React.ReactNode;
|
|
17
16
|
};
|
|
18
|
-
export declare const RenderTexture: ForwardRefComponent<
|
|
17
|
+
export declare const RenderTexture: ForwardRefComponent<Props, THREE.Texture>;
|
|
18
|
+
export {};
|
package/core/RenderTexture.js
CHANGED
|
@@ -34,10 +34,9 @@ const RenderTexture = /* @__PURE__ */React.forwardRef(({
|
|
|
34
34
|
// Since this is only a texture it does not have an easy way to obtain the parent, which we
|
|
35
35
|
// need to transform event coordinates to local coordinates. We use r3f internals to find the
|
|
36
36
|
// next Object3D.
|
|
37
|
-
let parent = (_fbo$texture = fbo.texture) == null
|
|
37
|
+
let parent = (_fbo$texture = fbo.texture) == null ? void 0 : _fbo$texture.__r3f.parent;
|
|
38
38
|
while (parent && !(parent instanceof THREE.Object3D)) {
|
|
39
|
-
|
|
40
|
-
parent = (_parent$__r3f$parent = parent.__r3f.parent) == null ? void 0 : _parent$__r3f$parent.object;
|
|
39
|
+
parent = parent.__r3f.parent;
|
|
41
40
|
}
|
|
42
41
|
if (!parent) return false;
|
|
43
42
|
// First we call the previous state-onion-layers compute, this is what makes it possible to nest portals
|
package/core/Resize.d.ts
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
|
|
4
|
-
export type ResizeProps = Omit<ThreeElements['group'], 'ref'> & {
|
|
3
|
+
export type ResizeProps = JSX.IntrinsicElements['group'] & {
|
|
5
4
|
width?: boolean;
|
|
6
5
|
height?: boolean;
|
|
7
6
|
depth?: boolean;
|
|
8
7
|
box3?: THREE.Box3;
|
|
9
8
|
precise?: boolean;
|
|
10
9
|
};
|
|
11
|
-
export declare const Resize: React.ForwardRefExoticComponent<Omit<
|
|
12
|
-
width?: boolean;
|
|
13
|
-
height?: boolean;
|
|
14
|
-
depth?: boolean;
|
|
15
|
-
box3?: THREE.Box3;
|
|
16
|
-
precise?: boolean;
|
|
17
|
-
} & React.RefAttributes<THREE.Group<THREE.Object3DEventMap>>>;
|
|
10
|
+
export declare const Resize: React.ForwardRefExoticComponent<Omit<ResizeProps, "ref"> & React.RefAttributes<THREE.Group>>;
|
package/core/RoundedBox.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Mesh } from 'three';
|
|
2
2
|
import { ForwardRefComponent, NamedArrayTuple } from '../helpers/ts-utils';
|
|
3
|
-
|
|
4
|
-
export type RoundedBoxProps = {
|
|
3
|
+
type Props = {
|
|
5
4
|
args?: NamedArrayTuple<(width?: number, height?: number, depth?: number) => void>;
|
|
6
5
|
radius?: number;
|
|
7
6
|
smoothness?: number;
|
|
8
7
|
bevelSegments?: number;
|
|
9
8
|
steps?: number;
|
|
10
9
|
creaseAngle?: number;
|
|
11
|
-
} & Omit<
|
|
12
|
-
export declare const RoundedBox: ForwardRefComponent<
|
|
10
|
+
} & Omit<JSX.IntrinsicElements['mesh'], 'args'>;
|
|
11
|
+
export declare const RoundedBox: ForwardRefComponent<Props, Mesh>;
|
|
12
|
+
export {};
|
package/core/Sampler.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Color, InstancedBufferAttribute, InstancedMesh, Mesh, Object3D, Vector3 } from 'three';
|
|
3
|
-
import {
|
|
3
|
+
import { GroupProps } from '@react-three/fiber';
|
|
4
4
|
type SamplePayload = {
|
|
5
5
|
position: Vector3;
|
|
6
6
|
normal: Vector3;
|
|
@@ -11,7 +11,7 @@ type TransformPayload = SamplePayload & {
|
|
|
11
11
|
dummy: Object3D;
|
|
12
12
|
sampledMesh: Mesh;
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
type Props = {
|
|
15
15
|
mesh?: React.RefObject<Mesh>;
|
|
16
16
|
instances?: React.RefObject<InstancedMesh>;
|
|
17
17
|
weight?: string;
|
|
@@ -23,6 +23,6 @@ export interface useSurfaceSamplerProps {
|
|
|
23
23
|
weight?: string;
|
|
24
24
|
count?: number;
|
|
25
25
|
}
|
|
26
|
-
export declare function useSurfaceSampler(mesh: React.
|
|
27
|
-
export declare function Sampler({ children, weight, transform, instances, mesh, count, ...props }:
|
|
26
|
+
export declare function useSurfaceSampler(mesh: React.MutableRefObject<Mesh>, count?: number, transform?: TransformFn, weight?: string, instanceMesh?: React.MutableRefObject<InstancedMesh> | null): InstancedBufferAttribute;
|
|
27
|
+
export declare function Sampler({ children, weight, transform, instances, mesh, count, ...props }: React.PropsWithChildren<Props & GroupProps>): React.JSX.Element;
|
|
28
28
|
export {};
|
package/core/ScreenQuad.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
export
|
|
3
|
+
type Props = Omit<JSX.IntrinsicElements['mesh'], 'args'>;
|
|
4
|
+
export declare const ScreenQuad: ForwardRefComponent<Props, THREE.Mesh>;
|
|
5
|
+
export {};
|
package/core/ScreenSizer.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Object3DProps } from '@react-three/fiber';
|
|
2
2
|
import { Object3D } from 'three';
|
|
3
3
|
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
4
|
-
export
|
|
4
|
+
export interface ScreenSizerProps extends Object3DProps {
|
|
5
5
|
scale?: number;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
7
|
export declare const ScreenSizer: ForwardRefComponent<ScreenSizerProps, Object3D>;
|
package/core/ScreenSpace.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Group } from 'three';
|
|
2
|
-
import { ThreeElements } from '@react-three/fiber';
|
|
3
2
|
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
4
|
-
export type ScreenSpaceProps =
|
|
3
|
+
export type ScreenSpaceProps = {
|
|
5
4
|
depth?: number;
|
|
6
|
-
};
|
|
5
|
+
} & JSX.IntrinsicElements['group'];
|
|
7
6
|
export declare const ScreenSpace: ForwardRefComponent<ScreenSpaceProps, Group>;
|
package/core/Segments.d.ts
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { ReactThreeFiber
|
|
3
|
+
import { ReactThreeFiber } from '@react-three/fiber';
|
|
4
4
|
import { Line2, LineMaterialParameters } from 'three-stdlib';
|
|
5
5
|
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
6
|
-
|
|
6
|
+
type SegmentsProps = LineMaterialParameters & {
|
|
7
7
|
limit?: number;
|
|
8
8
|
lineWidth?: number;
|
|
9
9
|
children: React.ReactNode;
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
type SegmentProps = Omit<JSX.IntrinsicElements['segmentObject'], 'start' | 'end' | 'color'> & {
|
|
12
12
|
start: ReactThreeFiber.Vector3;
|
|
13
13
|
end: ReactThreeFiber.Vector3;
|
|
14
14
|
color?: ReactThreeFiber.Color;
|
|
15
15
|
};
|
|
16
16
|
declare const Segments: ForwardRefComponent<SegmentsProps, Line2>;
|
|
17
|
-
declare
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
declare global {
|
|
18
|
+
namespace JSX {
|
|
19
|
+
interface IntrinsicElements {
|
|
20
|
+
segmentObject: ReactThreeFiber.Object3DNode<SegmentObject, typeof SegmentObject>;
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
export declare class SegmentObject {
|
package/core/Shadow.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Mesh, Color, type PlaneGeometry, type MeshBasicMaterial } from 'three';
|
|
2
2
|
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
3
|
-
|
|
4
|
-
export type ShadowProps = Omit<ThreeElements['mesh'], 'ref'> & {
|
|
3
|
+
type Props = JSX.IntrinsicElements['mesh'] & {
|
|
5
4
|
colorStop?: number;
|
|
6
5
|
fog?: boolean;
|
|
7
6
|
color?: Color | number | string;
|
|
@@ -9,4 +8,5 @@ export type ShadowProps = Omit<ThreeElements['mesh'], 'ref'> & {
|
|
|
9
8
|
depthWrite?: boolean;
|
|
10
9
|
};
|
|
11
10
|
export type ShadowType = Mesh<PlaneGeometry, MeshBasicMaterial>;
|
|
12
|
-
export declare const Shadow: ForwardRefComponent<
|
|
11
|
+
export declare const Shadow: ForwardRefComponent<Props, ShadowType>;
|
|
12
|
+
export {};
|
package/core/ShadowAlpha.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@react-three/fiber"),r=require("react"),a=require("three");function t(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(a){if("default"!==a){var t=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(r,a,t.get?t:{enumerable:!0,get:function(){return e[a]}})}})),r.default=e,Object.freeze(r)}var n=t(r),u=t(a);exports.ShadowAlpha=function({opacity:r,alphaMap:a}){const t=n.useRef(null),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@react-three/fiber"),r=require("react"),a=require("three");function t(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(a){if("default"!==a){var t=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(r,a,t.get?t:{enumerable:!0,get:function(){return e[a]}})}})),r.default=e,Object.freeze(r)}var n=t(r),u=t(a);exports.ShadowAlpha=function({opacity:r,alphaMap:a}){const t=n.useRef(null),o=n.useRef(null),c=n.useRef({value:1}),l=n.useRef({value:null}),i=n.useRef({value:!1});return n.useLayoutEffect((()=>{t.current.onBeforeCompile=o.current.onBeforeCompile=e=>{const r=e.fragmentShader.indexOf("void main");let a,t="",n=r;for(;"\n"!==a&&n<r+100;)a=e.fragmentShader.charAt(n),t+=a,n++;t=t.trim(),e.vertexShader=e.vertexShader.replace("void main() {","\n varying vec2 custom_vUv;\n\n void main() {\n custom_vUv = uv;\n \n "),e.fragmentShader=e.fragmentShader.replace(t,"\n uniform float uShadowOpacity;\n uniform sampler2D uAlphaMap;\n uniform bool uHasAlphaMap;\n\n varying vec2 custom_vUv;\n \n float bayerDither2x2( vec2 v ) {\n return mod( 3.0 * v.y + 2.0 * v.x, 4.0 );\n }\n \n float bayerDither4x4( vec2 v ) {\n vec2 P1 = mod( v, 2.0 );\n vec2 P2 = mod( floor( 0.5 * v ), 2.0 );\n return 4.0 * bayerDither2x2( P1 ) + bayerDither2x2( P2 );\n }\n \n void main() {\n float alpha = \n uHasAlphaMap ? \n uShadowOpacity * texture2D(uAlphaMap, custom_vUv).x\n : uShadowOpacity;\n\n if( ( bayerDither4x4( floor( mod( gl_FragCoord.xy, 4.0 ) ) ) ) / 16.0 >= alpha ) discard;\n \n "),e.uniforms.uShadowOpacity=c.current,e.uniforms.uAlphaMap=l.current,e.uniforms.uHasAlphaMap=i.current}}),[]),e.useFrame((()=>{var e;const n=null==(e=t.current.__r3f)?void 0:e.parent;if(n){const e=n.material;e&&(c.current.value=null!=r?r:e.opacity,!1===a?(l.current.value=null,i.current.value=!1):(l.current.value=a||e.alphaMap,i.current.value=!!l.current.value))}})),n.createElement(n.Fragment,null,n.createElement("meshDepthMaterial",{ref:t,attach:"customDepthMaterial",depthPacking:u.RGBADepthPacking}),n.createElement("meshDistanceMaterial",{ref:o,attach:"customDistanceMaterial"}))};
|
package/core/ShadowAlpha.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import * as THREE from 'three';
|
|
3
|
-
|
|
3
|
+
interface ShadowAlphaProps {
|
|
4
4
|
opacity?: number;
|
|
5
5
|
alphaMap?: THREE.Texture | boolean;
|
|
6
6
|
}
|
|
7
7
|
export declare function ShadowAlpha({ opacity, alphaMap }: ShadowAlphaProps): React.JSX.Element;
|
|
8
|
+
export {};
|
package/core/ShadowAlpha.js
CHANGED
|
@@ -80,7 +80,7 @@ function ShadowAlpha({
|
|
|
80
80
|
}, []);
|
|
81
81
|
useFrame(() => {
|
|
82
82
|
var _r3f;
|
|
83
|
-
const parent = (_r3f = depthMaterialRef.current.__r3f) == null
|
|
83
|
+
const parent = (_r3f = depthMaterialRef.current.__r3f) == null ? void 0 : _r3f.parent;
|
|
84
84
|
if (parent) {
|
|
85
85
|
const parentMainMaterial = parent.material;
|
|
86
86
|
if (parentMainMaterial) {
|
package/core/Sky.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ReactThreeFiber } from '@react-three/fiber';
|
|
|
2
2
|
import { Sky as SkyImpl } from 'three-stdlib';
|
|
3
3
|
import { Vector3 } from 'three';
|
|
4
4
|
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
5
|
-
|
|
5
|
+
type Props = {
|
|
6
6
|
distance?: number;
|
|
7
7
|
sunPosition?: ReactThreeFiber.Vector3;
|
|
8
8
|
inclination?: number;
|
|
@@ -13,4 +13,5 @@ export type SkyProps = {
|
|
|
13
13
|
turbidity?: number;
|
|
14
14
|
};
|
|
15
15
|
export declare function calcPosFromAngles(inclination: number, azimuth: number, vector?: Vector3): Vector3;
|
|
16
|
-
export declare const Sky: ForwardRefComponent<
|
|
16
|
+
export declare const Sky: ForwardRefComponent<Props, SkyImpl>;
|
|
17
|
+
export {};
|