@react-three/drei 9.83.9 → 9.84.1
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 +116 -5
- package/core/AccumulativeShadows.d.ts +3 -3
- package/core/AccumulativeShadows.js +30 -36
- package/core/AdaptiveDpr.js +4 -4
- package/core/ArcballControls.d.ts +1 -1
- package/core/ArcballControls.js +0 -1
- package/core/AsciiRenderer.d.ts +3 -3
- package/core/AsciiRenderer.js +12 -6
- package/core/BBAnchor.cjs.js +1 -1
- package/core/BBAnchor.d.ts +2 -2
- package/core/BBAnchor.js +5 -5
- package/core/Backdrop.d.ts +2 -2
- package/core/Backdrop.js +0 -3
- package/core/Billboard.d.ts +1 -1
- package/core/Billboard.js +6 -3
- package/core/Bounds.d.ts +5 -5
- package/core/Bounds.js +5 -32
- package/core/CameraControls.d.ts +2 -2
- package/core/CameraControls.js +0 -3
- package/core/CameraShake.js +0 -4
- package/core/CatmullRomLine.d.ts +1 -1
- package/core/CatmullRomLine.js +0 -2
- package/core/Caustics.d.ts +1 -1
- package/core/Caustics.js +31 -32
- package/core/Center.d.ts +2 -2
- package/core/Center.js +2 -1
- package/core/Clone.d.ts +1 -1
- package/core/Clone.js +10 -13
- package/core/Cloud.cjs.js +1 -1
- package/core/Cloud.d.ts +2 -2
- package/core/Cloud.js +1 -2
- package/core/ComputedAttribute.d.ts +2 -2
- package/core/ComputedAttribute.js +0 -1
- package/core/ContactShadows.d.ts +1 -1
- package/core/ContactShadows.js +6 -7
- package/core/CubeCamera.cjs.js +1 -1
- package/core/CubeCamera.d.ts +2 -2
- package/core/CubeCamera.js +1 -1
- package/core/CubicBezierLine.d.ts +1 -1
- package/core/CurveModifier.d.ts +1 -1
- package/core/CurveModifier.js +2 -4
- package/core/Decal.d.ts +1 -1
- package/core/Decal.js +8 -15
- package/core/Detailed.d.ts +1 -1
- package/core/Detailed.js +0 -1
- package/core/DeviceOrientationControls.d.ts +1 -1
- package/core/DeviceOrientationControls.js +3 -4
- package/core/Edges.d.ts +1 -1
- package/core/Edges.js +0 -2
- package/core/Effects.d.ts +1 -1
- package/core/Effects.js +5 -7
- package/core/Environment.d.ts +3 -3
- package/core/Environment.js +6 -12
- package/core/Example.d.ts +3 -3
- package/core/Example.js +2 -1
- package/core/FaceControls.cjs.js +1 -1
- package/core/FaceControls.d.ts +5 -5
- package/core/FaceControls.js +42 -39
- package/core/FaceLandmarker.d.ts +3 -2
- package/core/FaceLandmarker.js +1 -1
- package/core/Facemesh.d.ts +6 -6
- package/core/Facemesh.js +47 -53
- package/core/FirstPersonControls.d.ts +1 -1
- package/core/Float.d.ts +1 -1
- package/core/Float.js +0 -1
- package/core/FlyControls.d.ts +1 -1
- package/core/FlyControls.js +1 -2
- package/core/GizmoHelper.cjs.js +1 -1
- package/core/GizmoHelper.d.ts +2 -2
- package/core/GizmoHelper.js +18 -19
- package/core/GizmoViewcube.d.ts +3 -3
- package/core/GizmoViewcube.js +0 -14
- package/core/GizmoViewport.d.ts +3 -3
- package/core/GizmoViewport.js +0 -7
- package/core/Gltf.d.ts +1 -1
- package/core/GradientTexture.d.ts +3 -3
- package/core/GradientTexture.js +2 -5
- package/core/Grid.d.ts +2 -2
- package/core/Grid.js +2 -6
- package/core/Hud.d.ts +2 -2
- package/core/Hud.js +6 -9
- package/core/Image.d.ts +2 -2
- package/core/Image.js +4 -6
- package/core/Instances.d.ts +6 -6
- package/core/Instances.js +20 -35
- package/core/Lightformer.d.ts +1 -1
- package/core/Lightformer.js +4 -2
- package/core/Line.d.ts +1 -1
- package/core/Line.js +0 -3
- package/core/MapControls.d.ts +1 -1
- package/core/MapControls.js +0 -2
- package/core/MarchingCubes.d.ts +3 -3
- package/core/Mask.d.ts +1 -1
- package/core/MeshDistortMaterial.d.ts +2 -2
- package/core/MeshDistortMaterial.js +0 -9
- package/core/MeshPortalMaterial.d.ts +4 -4
- package/core/MeshPortalMaterial.js +22 -61
- package/core/MeshReflectorMaterial.d.ts +1 -1
- package/core/MeshReflectorMaterial.js +12 -14
- package/core/MeshRefractionMaterial.cjs.js +1 -1
- package/core/MeshRefractionMaterial.d.ts +3 -3
- package/core/MeshRefractionMaterial.js +9 -14
- package/core/MeshTransmissionMaterial.d.ts +2 -2
- package/core/MeshTransmissionMaterial.js +32 -33
- package/core/MeshWobbleMaterial.d.ts +2 -2
- package/core/MeshWobbleMaterial.js +0 -7
- package/core/MotionPathControls.cjs.js +1 -0
- package/core/MotionPathControls.d.ts +15 -0
- package/core/MotionPathControls.js +113 -0
- package/core/OrbitControls.d.ts +2 -2
- package/core/OrbitControls.js +0 -4
- package/core/OrthographicCamera.d.ts +1 -1
- package/core/OrthographicCamera.js +2 -3
- package/core/Outlines.cjs.js +1 -1
- package/core/Outlines.d.ts +3 -3
- package/core/Outlines.js +2 -7
- package/core/PerformanceMonitor.d.ts +4 -4
- package/core/PerformanceMonitor.js +8 -12
- package/core/PerspectiveCamera.d.ts +1 -1
- package/core/PerspectiveCamera.js +2 -3
- package/core/PointMaterial.d.ts +1 -1
- package/core/PointMaterial.js +0 -2
- package/core/PointerLockControls.d.ts +1 -1
- package/core/PointerLockControls.js +4 -6
- package/core/Points.d.ts +2 -2
- package/core/Points.js +6 -23
- package/core/PositionalAudio.d.ts +1 -1
- package/core/PositionalAudio.js +0 -5
- package/core/Preload.d.ts +1 -1
- package/core/Preload.js +8 -9
- package/core/QuadraticBezierLine.d.ts +2 -2
- package/core/QuadraticBezierLine.js +0 -2
- package/core/Reflector.d.ts +1 -1
- package/core/Reflector.js +11 -12
- package/core/RenderTexture.d.ts +1 -1
- package/core/RenderTexture.js +9 -11
- package/core/Resize.d.ts +2 -2
- package/core/RoundedBox.cjs.js +1 -1
- package/core/RoundedBox.d.ts +1 -1
- package/core/RoundedBox.js +1 -3
- package/core/Sampler.d.ts +5 -5
- package/core/Sampler.js +0 -10
- package/core/ScreenQuad.d.ts +1 -1
- package/core/ScreenQuad.js +0 -1
- package/core/ScreenSpace.d.ts +1 -1
- package/core/Segments.d.ts +2 -2
- package/core/Segments.js +0 -6
- package/core/Shadow.d.ts +1 -1
- package/core/Sky.d.ts +1 -1
- package/core/Sparkles.js +0 -10
- package/core/SpotLight.d.ts +2 -2
- package/core/SpotLight.js +3 -10
- package/core/SpriteAnimator.d.ts +1 -1
- package/core/SpriteAnimator.js +16 -34
- package/core/Stage.d.ts +4 -4
- package/core/Stage.js +2 -4
- package/core/Stars.d.ts +1 -1
- package/core/Stars.js +2 -11
- package/core/Stats.d.ts +1 -1
- package/core/Stats.js +2 -2
- package/core/StatsGl.d.ts +1 -1
- package/core/StatsGl.js +4 -3
- package/core/Svg.js +0 -2
- package/core/Text.d.ts +1 -1
- package/core/Text3D.d.ts +1 -1
- package/core/Text3D.js +1 -3
- package/core/TrackballControls.d.ts +1 -1
- package/core/TrackballControls.js +0 -1
- package/core/Trail.d.ts +3 -3
- package/core/Trail.js +6 -17
- package/core/TransformControls.d.ts +1 -1
- package/core/TransformControls.js +3 -9
- package/core/Wireframe.d.ts +1 -1
- package/core/Wireframe.js +0 -28
- package/core/index.cjs.js +1 -1
- package/core/index.d.ts +1 -0
- package/core/index.js +1 -0
- package/core/meshBounds.js +4 -14
- package/core/shaderMaterial.js +10 -9
- package/core/shapes.d.ts +2 -2
- package/core/shapes.js +3 -6
- package/core/softShadows.d.ts +1 -1
- package/core/softShadows.js +1 -4
- package/core/useAnimations.d.ts +1 -1
- package/core/useAnimations.js +2 -4
- package/core/useBVH.d.ts +1 -1
- package/core/useBVH.js +3 -4
- package/core/useBoxProjectedEnv.js +15 -22
- package/core/useCamera.js +0 -1
- package/core/useContextBridge.js +1 -2
- package/core/useCubeCamera.d.ts +1 -1
- package/core/useCubeTexture.d.ts +1 -1
- package/core/useCubeTexture.js +4 -3
- package/core/useEnvironment.cjs.js +1 -1
- package/core/useEnvironment.d.ts +2 -2
- package/core/useEnvironment.js +9 -11
- package/core/useFBO.d.ts +1 -1
- package/core/useFBO.js +3 -12
- package/core/useFBX.js +0 -2
- package/core/useFont.d.ts +2 -2
- package/core/useFont.js +0 -4
- package/core/useGLTF.d.ts +2 -2
- package/core/useGLTF.js +0 -8
- package/core/useHelper.d.ts +3 -3
- package/core/useHelper.js +2 -5
- package/core/useIntersect.js +5 -8
- package/core/useKTX2.js +3 -5
- package/core/useMatcapTexture.js +0 -6
- package/core/useNormalTexture.d.ts +1 -1
- package/core/useProgress.d.ts +1 -1
- package/core/useProgress.js +0 -5
- package/core/useTexture.js +4 -6
- package/core/useTrailTexture.d.ts +1 -1
- package/core/useTrailTexture.js +10 -21
- package/helpers/environment-assets.d.ts +1 -1
- package/helpers/ts-utils.d.ts +2 -2
- package/helpers/useEffectfulState.d.ts +1 -1
- package/helpers/useEffectfulState.js +0 -1
- package/index.cjs.js +1 -1
- package/index.js +1 -0
- package/materials/BlurPass.js +2 -5
- package/materials/ConvolutionMaterial.js +0 -3
- package/materials/MeshReflectorMaterial.d.ts +1 -1
- package/materials/MeshReflectorMaterial.js +0 -34
- package/materials/MeshRefractionMaterial.js +2 -6
- package/materials/SpotLightMaterial.js +2 -7
- package/materials/WireframeMaterial.js +7 -25
- package/native/index.cjs.js +1 -1
- package/native/index.js +1 -0
- package/package.json +2 -2
- package/react-three-drei-0.0.0-semantic-release.tgz +0 -0
- package/web/CycleRaycast.d.ts +1 -1
- package/web/CycleRaycast.js +20 -24
- package/web/Html.d.ts +2 -2
- package/web/Html.js +6 -50
- package/web/KeyboardControls.d.ts +10 -10
- package/web/KeyboardControls.js +9 -6
- package/web/Loader.d.ts +2 -2
- package/web/Loader.js +8 -5
- package/web/PresentationControls.d.ts +2 -2
- package/web/PresentationControls.js +2 -1
- package/web/ScrollControls.d.ts +4 -4
- package/web/ScrollControls.js +5 -16
- package/web/Select.d.ts +3 -3
- package/web/Select.js +6 -17
- package/web/View.d.ts +5 -5
- package/web/View.js +7 -20
- package/web/index.cjs.js +1 -1
- package/web/index.js +1 -0
- package/web/pivotControls/AxisArrow.js +6 -15
- package/web/pivotControls/AxisRotator.js +8 -23
- package/web/pivotControls/PlaneSlider.js +6 -16
- package/web/pivotControls/context.d.ts +2 -2
- package/web/pivotControls/index.d.ts +1 -1
- package/web/pivotControls/index.js +2 -9
package/README.md
CHANGED
|
@@ -53,6 +53,7 @@ The `native` route of the library **does not** export `Html` or `Loader`. The de
|
|
|
53
53
|
<li><a href="#presentationcontrols">PresentationControls</a></li>
|
|
54
54
|
<li><a href="#keyboardcontrols">KeyboardControls</a></li>
|
|
55
55
|
<li><a href="#FaceControls">FaceControls</a></li>
|
|
56
|
+
<li><a href="#motionpathcontrols">MotionPathControls</a></li>
|
|
56
57
|
</ul>
|
|
57
58
|
<li><a href="#gizmos">Gizmos</a></li>
|
|
58
59
|
<ul>
|
|
@@ -750,6 +751,118 @@ useFrame((_, delta) => {
|
|
|
750
751
|
})
|
|
751
752
|
```
|
|
752
753
|
|
|
754
|
+
#### MotionPathControls
|
|
755
|
+
|
|
756
|
+
<p>
|
|
757
|
+
<a href="https://codesandbox.io/s/2y73c6"><img width="20%" src="https://codesandbox.io/api/v1/sandboxes/2y73c6/screenshot.png" alt="Demo"/></a>
|
|
758
|
+
</p>
|
|
759
|
+
|
|
760
|
+
Motion path controls, it takes a path of bezier curves or catmull-rom curves as input and animates the passed `object` along that path. It can be configured to look upon an external object for staging or presentation purposes by adding a `focusObject` property (ref).
|
|
761
|
+
|
|
762
|
+
```tsx
|
|
763
|
+
type MotionPathProps = JSX.IntrinsicElements['group'] & {
|
|
764
|
+
/** An optional array of THREE curves */
|
|
765
|
+
curves?: THREE.Curve<THREE.Vector3>[]
|
|
766
|
+
/** Show debug helpers */
|
|
767
|
+
debug?: boolean
|
|
768
|
+
/** The target object that is moved, default: null (the default camera) */
|
|
769
|
+
object?: React.MutableRefObject<THREE.Object3D>
|
|
770
|
+
/** An object where the target looks towards, can also be a vector, default: null */
|
|
771
|
+
focus?: [x: number, y: number, z: number] | React.MutableRefObject<THREE.Object3D>
|
|
772
|
+
/** Position between 0 (start) and end (1), if this is not set useMotion().current must be used, default: null */
|
|
773
|
+
offset?: number
|
|
774
|
+
/** Optionally smooth the curve, default: false */
|
|
775
|
+
smooth?: boolean | number
|
|
776
|
+
/** Damping tolerance, default: 0.00001 */
|
|
777
|
+
eps?: number
|
|
778
|
+
/** Damping factor for movement along the curve, default: 0.1 */
|
|
779
|
+
damping?: number
|
|
780
|
+
/** Damping factor for lookAt, default: 0.1 */
|
|
781
|
+
focusDamping?: number
|
|
782
|
+
/** Damping maximum speed, default: Infinity */
|
|
783
|
+
maxSpeed?: number
|
|
784
|
+
}
|
|
785
|
+
```
|
|
786
|
+
|
|
787
|
+
You can use MotionPathControls with declarative curves.
|
|
788
|
+
|
|
789
|
+
```jsx
|
|
790
|
+
function App() {
|
|
791
|
+
const poi = useRef()
|
|
792
|
+
return (
|
|
793
|
+
<group>
|
|
794
|
+
<MotionPathControls offset={0} focus={poi} damping={0.2}>
|
|
795
|
+
<cubicBezierCurve3 v0={[-5, -5, 0]} v1={[-10, 0, 0]} v2={[0, 3, 0]} v3={[6, 3, 0]} />
|
|
796
|
+
<cubicBezierCurve3 v0={[6, 3, 0]} v1={[10, 5, 5]} v2={[5, 5, 5]} v3={[5, 5, 5]} />
|
|
797
|
+
</MotionPathControls>
|
|
798
|
+
<Box args={[1, 1, 1]} ref={poi}/>
|
|
799
|
+
```
|
|
800
|
+
|
|
801
|
+
Or with imperative curves.
|
|
802
|
+
|
|
803
|
+
```jsx
|
|
804
|
+
<MotionPathControls
|
|
805
|
+
offset={0}
|
|
806
|
+
focus={poi}
|
|
807
|
+
damping={0.2}
|
|
808
|
+
curves={[
|
|
809
|
+
new THREE.CubicBezierCurve3(
|
|
810
|
+
new THREE.Vector3(-5, -5, 0),
|
|
811
|
+
new THREE.Vector3(-10, 0, 0),
|
|
812
|
+
new THREE.Vector3(0, 3, 0),
|
|
813
|
+
new THREE.Vector3(6, 3, 0)
|
|
814
|
+
),
|
|
815
|
+
new THREE.CubicBezierCurve3(
|
|
816
|
+
new THREE.Vector3(6, 3, 0),
|
|
817
|
+
new THREE.Vector3(10, 5, 5),
|
|
818
|
+
new THREE.Vector3(5, 3, 5),
|
|
819
|
+
new THREE.Vector3(5, 5, 5)
|
|
820
|
+
),
|
|
821
|
+
]}
|
|
822
|
+
/>
|
|
823
|
+
```
|
|
824
|
+
|
|
825
|
+
You can exert full control with the `useMotion` hook, it allows you to define the current position along the path for instance, or define your own lookAt. Keep in mind that MotionPathControls will still these values unless you set damping and focusDamping to 0. Then you can also employ your own easing.
|
|
826
|
+
|
|
827
|
+
```tsx
|
|
828
|
+
type MotionState = {
|
|
829
|
+
/** The user-defined, mutable, current goal position along the curve, it may be >1 or <0 */
|
|
830
|
+
current: number
|
|
831
|
+
/** The combined curve */
|
|
832
|
+
path: THREE.CurvePath<THREE.Vector3>
|
|
833
|
+
/** The focus object */
|
|
834
|
+
focus: React.MutableRefObject<THREE.Object3D<THREE.Event>> | [x: number, y: number, z: number] | undefined
|
|
835
|
+
/** The target object that is moved along the curve */
|
|
836
|
+
object: React.MutableRefObject<THREE.Object3D<THREE.Event>>
|
|
837
|
+
/** The automated, 0-1 normalised and damped current goal position along curve */
|
|
838
|
+
offset: number
|
|
839
|
+
/** The current point on the curve */
|
|
840
|
+
point: THREE.Vector3
|
|
841
|
+
/** The current tangent on the curve */
|
|
842
|
+
tangent: THREE.Vector3
|
|
843
|
+
/** The next point on the curve */
|
|
844
|
+
next: THREE.Vector3
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
const state: MotionState = useMotion()
|
|
848
|
+
```
|
|
849
|
+
|
|
850
|
+
```jsx
|
|
851
|
+
function Loop() {
|
|
852
|
+
const motion = useMotion()
|
|
853
|
+
useFrame((state, delta) => {
|
|
854
|
+
// Set the current position along the curve, you can increment indiscriminately for a loop
|
|
855
|
+
motion.current += delta
|
|
856
|
+
// Look ahead on the curve
|
|
857
|
+
motion.object.lookAt(motion.next)
|
|
858
|
+
})
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
<MotionPathControls>
|
|
862
|
+
<cubicBezierCurve3 v0={[-5, -5, 0]} v1={[-10, 0, 0]} v2={[0, 3, 0]} v3={[6, 3, 0]} />
|
|
863
|
+
<Loop />
|
|
864
|
+
```
|
|
865
|
+
|
|
753
866
|
# Gizmos
|
|
754
867
|
|
|
755
868
|
#### GizmoHelper
|
|
@@ -1135,13 +1248,13 @@ export type FacemeshProps = {
|
|
|
1135
1248
|
/** a landmark index (to get the position from) or a vec3 to be the origin of the mesh. default: undefined (ie. the bbox center) */
|
|
1136
1249
|
origin?: number | THREE.Vector3
|
|
1137
1250
|
/** A facial transformation matrix, as returned by FaceLandmarkerResult.facialTransformationMatrixes (see: https://developers.google.com/mediapipe/solutions/vision/face_landmarker/web_js#handle_and_display_results) */
|
|
1138
|
-
facialTransformationMatrix?: typeof FacemeshDatas.SAMPLE_FACELANDMARKER_RESULT.facialTransformationMatrixes[0]
|
|
1251
|
+
facialTransformationMatrix?: (typeof FacemeshDatas.SAMPLE_FACELANDMARKER_RESULT.facialTransformationMatrixes)[0]
|
|
1139
1252
|
/** Apply position offset extracted from `facialTransformationMatrix` */
|
|
1140
1253
|
offset?: boolean
|
|
1141
1254
|
/** Offset sensitivity factor, less is more sensible */
|
|
1142
1255
|
offsetScalar?: number
|
|
1143
1256
|
/** Fface blendshapes, as returned by FaceLandmarkerResult.faceBlendshapes (see: https://developers.google.com/mediapipe/solutions/vision/face_landmarker/web_js#handle_and_display_results) */
|
|
1144
|
-
faceBlendshapes?: typeof FacemeshDatas.SAMPLE_FACELANDMARKER_RESULT.faceBlendshapes[0]
|
|
1257
|
+
faceBlendshapes?: (typeof FacemeshDatas.SAMPLE_FACELANDMARKER_RESULT.faceBlendshapes)[0]
|
|
1145
1258
|
/** whether to enable eyes (nb. `faceBlendshapes` is required for), default: true */
|
|
1146
1259
|
eyes?: boolean
|
|
1147
1260
|
/** Force `origin` to be the middle of the 2 eyes (nb. `eyes` is required for), default: false */
|
|
@@ -2802,8 +2915,6 @@ useGLTF.preload(url)
|
|
|
2802
2915
|
|
|
2803
2916
|
If you want to use your own draco decoder globally, you can pass it through `useGLTF.setDecoderPath(path)`:
|
|
2804
2917
|
|
|
2805
|
-
````jsx
|
|
2806
|
-
|
|
2807
2918
|
> **Note** <br>If you are using the CDN loaded draco binaries, you can get a small speedup in loading time by prefetching them.
|
|
2808
2919
|
>
|
|
2809
2920
|
> You can accomplish this by adding two `<link>` tags to your `<head>` tag, as below. The version in those URLs must exactly match what [useGLTF](src/core/useGLTF.tsx#L18) uses for this to work. If you're using create-react-app, `public/index.html` file contains the `<head>` tag.
|
|
@@ -2836,7 +2947,7 @@ function SuzanneFBX() {
|
|
|
2836
2947
|
let fbx = useFBX('suzanne/suzanne.fbx')
|
|
2837
2948
|
return <primitive object={fbx} />
|
|
2838
2949
|
}
|
|
2839
|
-
|
|
2950
|
+
```
|
|
2840
2951
|
|
|
2841
2952
|
#### useTexture
|
|
2842
2953
|
|
|
@@ -2,7 +2,7 @@ import * as THREE from 'three';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { ReactThreeFiber } from '@react-three/fiber';
|
|
4
4
|
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
5
|
-
export
|
|
5
|
+
export type AccumulativeShadowsProps = {
|
|
6
6
|
frames?: number;
|
|
7
7
|
blend?: number;
|
|
8
8
|
limit?: number;
|
|
@@ -28,7 +28,7 @@ interface AccumulativeContext {
|
|
|
28
28
|
interface AccumulativeLightContext {
|
|
29
29
|
update: () => void;
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
type SoftShadowMaterialProps = {
|
|
32
32
|
map: THREE.Texture;
|
|
33
33
|
color?: ReactThreeFiber.Color;
|
|
34
34
|
alphaTest?: number;
|
|
@@ -43,7 +43,7 @@ declare global {
|
|
|
43
43
|
}
|
|
44
44
|
export declare const accumulativeContext: React.Context<AccumulativeContext>;
|
|
45
45
|
export declare const AccumulativeShadows: ForwardRefComponent<JSX.IntrinsicElements['group'] & AccumulativeShadowsProps, AccumulativeContext>;
|
|
46
|
-
export
|
|
46
|
+
export type RandomizedLightProps = {
|
|
47
47
|
frames?: number;
|
|
48
48
|
position?: [x: number, y: number, z: number];
|
|
49
49
|
radius?: number;
|
|
@@ -8,11 +8,9 @@ import { DiscardMaterial } from '../materials/DiscardMaterial.js';
|
|
|
8
8
|
function isLight(object) {
|
|
9
9
|
return object.isLight;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
11
|
function isGeometry(object) {
|
|
13
12
|
return !!object.geometry;
|
|
14
13
|
}
|
|
15
|
-
|
|
16
14
|
const accumulativeContext = /*#__PURE__*/React.createContext(null);
|
|
17
15
|
const SoftShadowMaterial = shaderMaterial({
|
|
18
16
|
color: new THREE.Color(),
|
|
@@ -82,38 +80,38 @@ const AccumulativeShadows = /*#__PURE__*/React.forwardRef(({
|
|
|
82
80
|
update: (frames = 1) => {
|
|
83
81
|
// Adapt the opacity-blend ratio to the number of frames
|
|
84
82
|
const material = gPlane.current.material;
|
|
85
|
-
|
|
86
83
|
if (!api.temporal) {
|
|
87
84
|
material.opacity = opacity;
|
|
88
85
|
material.alphaTest = alphaTest;
|
|
89
86
|
} else {
|
|
90
87
|
material.opacity = Math.min(opacity, material.opacity + opacity / api.blend);
|
|
91
88
|
material.alphaTest = Math.min(alphaTest, material.alphaTest + alphaTest / api.blend);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
gLights.current.visible = true; // Collect scene lights and meshes
|
|
89
|
+
}
|
|
96
90
|
|
|
97
|
-
|
|
91
|
+
// Switch accumulative lights on
|
|
92
|
+
gLights.current.visible = true;
|
|
93
|
+
// Collect scene lights and meshes
|
|
94
|
+
plm.prepare();
|
|
98
95
|
|
|
96
|
+
// Update the lightmap and the accumulative lights
|
|
99
97
|
for (let i = 0; i < frames; i++) {
|
|
100
98
|
api.lights.forEach(light => light.update());
|
|
101
99
|
plm.update(camera, api.blend);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
100
|
+
}
|
|
101
|
+
// Switch lights off
|
|
102
|
+
gLights.current.visible = false;
|
|
103
|
+
// Restore lights and meshes
|
|
107
104
|
plm.finish();
|
|
108
105
|
}
|
|
109
106
|
}), [plm, camera, scene, temporal, frames, blend, opacity, alphaTest]);
|
|
110
107
|
React.useLayoutEffect(() => {
|
|
111
108
|
// Reset internals, buffers, ...
|
|
112
|
-
api.reset();
|
|
113
|
-
|
|
109
|
+
api.reset();
|
|
110
|
+
// Update lightmap
|
|
114
111
|
if (!api.temporal && api.frames !== Infinity) api.update(api.blend);
|
|
115
|
-
});
|
|
112
|
+
});
|
|
116
113
|
|
|
114
|
+
// Expose api, allow children to set itself as the main light source
|
|
117
115
|
React.useImperativeHandle(forwardRef, () => api, [api]);
|
|
118
116
|
useFrame(() => {
|
|
119
117
|
if ((api.temporal || api.frames === Infinity) && api.count < api.frames && api.count < limit) {
|
|
@@ -161,11 +159,9 @@ const RandomizedLight = /*#__PURE__*/React.forwardRef(({
|
|
|
161
159
|
const parent = React.useContext(accumulativeContext);
|
|
162
160
|
const update = React.useCallback(() => {
|
|
163
161
|
let light;
|
|
164
|
-
|
|
165
162
|
if (gLights.current) {
|
|
166
163
|
for (let l = 0; l < gLights.current.children.length; l++) {
|
|
167
164
|
light = gLights.current.children[l];
|
|
168
|
-
|
|
169
165
|
if (Math.random() > ambient) {
|
|
170
166
|
light.position.set(position[0] + THREE.MathUtils.randFloatSpread(radius), position[1] + THREE.MathUtils.randFloatSpread(radius), position[2] + THREE.MathUtils.randFloatSpread(radius));
|
|
171
167
|
} else {
|
|
@@ -199,8 +195,9 @@ const RandomizedLight = /*#__PURE__*/React.forwardRef(({
|
|
|
199
195
|
attach: "shadow-camera",
|
|
200
196
|
args: [-size, size, size, -size, near, far]
|
|
201
197
|
}))));
|
|
202
|
-
});
|
|
198
|
+
});
|
|
203
199
|
|
|
200
|
+
// Based on "Progressive Light Map Accumulator", by [zalo](https://github.com/zalo/)
|
|
204
201
|
class ProgressiveLightMap {
|
|
205
202
|
constructor(renderer, scene, res = 1024) {
|
|
206
203
|
this.renderer = renderer;
|
|
@@ -211,16 +208,18 @@ class ProgressiveLightMap {
|
|
|
211
208
|
this.meshes = [];
|
|
212
209
|
this.object = null;
|
|
213
210
|
this.clearColor = new THREE.Color();
|
|
214
|
-
this.clearAlpha = 0;
|
|
211
|
+
this.clearAlpha = 0;
|
|
215
212
|
|
|
213
|
+
// Create the Progressive LightMap Texture
|
|
216
214
|
const textureParams = {
|
|
217
215
|
type: THREE.HalfFloatType,
|
|
218
216
|
magFilter: THREE.NearestFilter,
|
|
219
217
|
minFilter: THREE.NearestFilter
|
|
220
218
|
};
|
|
221
219
|
this.progressiveLightMap1 = new THREE.WebGLRenderTarget(this.res, this.res, textureParams);
|
|
222
|
-
this.progressiveLightMap2 = new THREE.WebGLRenderTarget(this.res, this.res, textureParams);
|
|
220
|
+
this.progressiveLightMap2 = new THREE.WebGLRenderTarget(this.res, this.res, textureParams);
|
|
223
221
|
|
|
222
|
+
// Inject some spicy new logic into a standard phong material
|
|
224
223
|
this.discardMat = new DiscardMaterial();
|
|
225
224
|
this.targetMat = new THREE.MeshLambertMaterial({
|
|
226
225
|
fog: false
|
|
@@ -231,21 +230,21 @@ class ProgressiveLightMap {
|
|
|
231
230
|
this.averagingWindow = {
|
|
232
231
|
value: 100
|
|
233
232
|
};
|
|
234
|
-
|
|
235
233
|
this.targetMat.onBeforeCompile = shader => {
|
|
236
234
|
// Vertex Shader: Set Vertex Positions to the Unwrapped UV Positions
|
|
237
|
-
shader.vertexShader = 'varying vec2 vUv;\n' + shader.vertexShader.slice(0, -1) + 'vUv = uv; gl_Position = vec4((uv - 0.5) * 2.0, 1.0, 1.0); }';
|
|
235
|
+
shader.vertexShader = 'varying vec2 vUv;\n' + shader.vertexShader.slice(0, -1) + 'vUv = uv; gl_Position = vec4((uv - 0.5) * 2.0, 1.0, 1.0); }';
|
|
238
236
|
|
|
237
|
+
// Fragment Shader: Set Pixels to average in the Previous frame's Shadows
|
|
239
238
|
const bodyStart = shader.fragmentShader.indexOf('void main() {');
|
|
240
239
|
shader.fragmentShader = 'varying vec2 vUv;\n' + shader.fragmentShader.slice(0, bodyStart) + 'uniform sampler2D previousShadowMap;\n uniform float averagingWindow;\n' + shader.fragmentShader.slice(bodyStart - 1, -1) + `\nvec3 texelOld = texture2D(previousShadowMap, vUv).rgb;
|
|
241
240
|
gl_FragColor.rgb = mix(texelOld, gl_FragColor.rgb, 1.0/ averagingWindow);
|
|
242
|
-
}`;
|
|
241
|
+
}`;
|
|
243
242
|
|
|
243
|
+
// Set the Previous Frame's Texture Buffer and Averaging Window
|
|
244
244
|
shader.uniforms.previousShadowMap = this.previousShadowMap;
|
|
245
245
|
shader.uniforms.averagingWindow = this.averagingWindow;
|
|
246
246
|
};
|
|
247
247
|
}
|
|
248
|
-
|
|
249
248
|
clear() {
|
|
250
249
|
this.renderer.getClearColor(this.clearColor);
|
|
251
250
|
this.clearAlpha = this.renderer.getClearAlpha();
|
|
@@ -272,30 +271,26 @@ class ProgressiveLightMap {
|
|
|
272
271
|
}
|
|
273
272
|
});
|
|
274
273
|
}
|
|
275
|
-
|
|
276
274
|
prepare() {
|
|
277
275
|
this.lights.forEach(light => light.object.intensity = 0);
|
|
278
276
|
this.meshes.forEach(mesh => mesh.object.material = this.discardMat);
|
|
279
277
|
}
|
|
280
|
-
|
|
281
278
|
finish() {
|
|
282
279
|
this.lights.forEach(light => light.object.intensity = light.intensity);
|
|
283
280
|
this.meshes.forEach(mesh => mesh.object.material = mesh.material);
|
|
284
281
|
}
|
|
285
|
-
|
|
286
282
|
configure(object) {
|
|
287
283
|
this.object = object;
|
|
288
284
|
}
|
|
289
|
-
|
|
290
285
|
update(camera, blendWindow = 100) {
|
|
291
|
-
if (!this.object) return;
|
|
292
|
-
|
|
286
|
+
if (!this.object) return;
|
|
287
|
+
// Set each object's material to the UV Unwrapped Surface Mapping Version
|
|
293
288
|
this.averagingWindow.value = blendWindow;
|
|
294
|
-
this.object.material = this.targetMat;
|
|
295
|
-
|
|
289
|
+
this.object.material = this.targetMat;
|
|
290
|
+
// Ping-pong two surface buffers for reading/writing
|
|
296
291
|
const activeMap = this.buffer1Active ? this.progressiveLightMap1 : this.progressiveLightMap2;
|
|
297
|
-
const inactiveMap = this.buffer1Active ? this.progressiveLightMap2 : this.progressiveLightMap1;
|
|
298
|
-
|
|
292
|
+
const inactiveMap = this.buffer1Active ? this.progressiveLightMap2 : this.progressiveLightMap1;
|
|
293
|
+
// Render the object's surface maps
|
|
299
294
|
const oldBg = this.scene.background;
|
|
300
295
|
this.scene.background = null;
|
|
301
296
|
this.renderer.setRenderTarget(activeMap);
|
|
@@ -305,7 +300,6 @@ class ProgressiveLightMap {
|
|
|
305
300
|
this.renderer.setRenderTarget(null);
|
|
306
301
|
this.scene.background = oldBg;
|
|
307
302
|
}
|
|
308
|
-
|
|
309
303
|
}
|
|
310
304
|
|
|
311
305
|
export { AccumulativeShadows, RandomizedLight, accumulativeContext };
|
package/core/AdaptiveDpr.js
CHANGED
|
@@ -8,16 +8,16 @@ function AdaptiveDpr({
|
|
|
8
8
|
const active = useThree(state => state.internal.active);
|
|
9
9
|
const current = useThree(state => state.performance.current);
|
|
10
10
|
const initialDpr = useThree(state => state.viewport.initialDpr);
|
|
11
|
-
const setDpr = useThree(state => state.setDpr);
|
|
12
|
-
|
|
11
|
+
const setDpr = useThree(state => state.setDpr);
|
|
12
|
+
// Restore initial pixelratio on unmount
|
|
13
13
|
React.useEffect(() => {
|
|
14
14
|
const domElement = gl.domElement;
|
|
15
15
|
return () => {
|
|
16
16
|
if (active) setDpr(initialDpr);
|
|
17
17
|
if (pixelated && domElement) domElement.style.imageRendering = 'auto';
|
|
18
18
|
};
|
|
19
|
-
}, []);
|
|
20
|
-
|
|
19
|
+
}, []);
|
|
20
|
+
// Set adaptive pixelratio
|
|
21
21
|
React.useEffect(() => {
|
|
22
22
|
setDpr(current * initialDpr);
|
|
23
23
|
if (pixelated && gl.domElement) gl.domElement.style.imageRendering = current === 1 ? 'auto' : 'pixelated';
|
|
@@ -2,7 +2,7 @@ import { ReactThreeFiber } from '@react-three/fiber';
|
|
|
2
2
|
import { ArcballControls as ArcballControlsImpl } from 'three-stdlib';
|
|
3
3
|
import type { Event, OrthographicCamera, PerspectiveCamera } from 'three';
|
|
4
4
|
import { ForwardRefComponent } from '../helpers/ts-utils';
|
|
5
|
-
export
|
|
5
|
+
export type ArcballControlsProps = Omit<ReactThreeFiber.Overwrite<ReactThreeFiber.Object3DNode<ArcballControlsImpl, typeof ArcballControlsImpl>, {
|
|
6
6
|
target?: ReactThreeFiber.Vector3;
|
|
7
7
|
camera?: OrthographicCamera | PerspectiveCamera;
|
|
8
8
|
domElement?: HTMLElement;
|
package/core/ArcballControls.js
CHANGED
|
@@ -37,7 +37,6 @@ const ArcballControls = /*#__PURE__*/forwardRef(({
|
|
|
37
37
|
if (regress) performance.regress();
|
|
38
38
|
if (onChange) onChange(e);
|
|
39
39
|
};
|
|
40
|
-
|
|
41
40
|
controls.addEventListener('change', callback);
|
|
42
41
|
if (onStart) controls.addEventListener('start', onStart);
|
|
43
42
|
if (onEnd) controls.addEventListener('end', onEnd);
|
package/core/AsciiRenderer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
type AsciiRendererProps = {
|
|
3
3
|
renderIndex?: number;
|
|
4
4
|
bgColor?: string;
|
|
5
5
|
fgColor?: string;
|
|
@@ -8,5 +8,5 @@ declare type AsciiRendererProps = {
|
|
|
8
8
|
color?: boolean;
|
|
9
9
|
resolution?: number;
|
|
10
10
|
};
|
|
11
|
-
export declare function AsciiRenderer({ renderIndex, bgColor, fgColor, characters, invert, color, resolution, }: AsciiRendererProps): JSX.Element;
|
|
11
|
+
export declare function AsciiRenderer({ renderIndex, bgColor, fgColor, characters, invert, color, resolution, }: AsciiRendererProps): React.JSX.Element;
|
|
12
12
|
export {};
|
package/core/AsciiRenderer.js
CHANGED
|
@@ -17,8 +17,9 @@ function AsciiRenderer({
|
|
|
17
17
|
gl,
|
|
18
18
|
scene,
|
|
19
19
|
camera
|
|
20
|
-
} = useThree();
|
|
20
|
+
} = useThree();
|
|
21
21
|
|
|
22
|
+
// Create effect
|
|
22
23
|
const effect = React.useMemo(() => {
|
|
23
24
|
const effect = new AsciiEffect(gl, characters, {
|
|
24
25
|
invert,
|
|
@@ -30,13 +31,15 @@ function AsciiRenderer({
|
|
|
30
31
|
effect.domElement.style.left = '0px';
|
|
31
32
|
effect.domElement.style.pointerEvents = 'none';
|
|
32
33
|
return effect;
|
|
33
|
-
}, [characters, invert, color, resolution]);
|
|
34
|
+
}, [characters, invert, color, resolution]);
|
|
34
35
|
|
|
36
|
+
// Styling
|
|
35
37
|
React.useLayoutEffect(() => {
|
|
36
38
|
effect.domElement.style.color = fgColor;
|
|
37
39
|
effect.domElement.style.backgroundColor = bgColor;
|
|
38
|
-
}, [fgColor, bgColor]);
|
|
40
|
+
}, [fgColor, bgColor]);
|
|
39
41
|
|
|
42
|
+
// Append on mount, remove on unmount
|
|
40
43
|
React.useEffect(() => {
|
|
41
44
|
gl.domElement.style.opacity = '0';
|
|
42
45
|
gl.domElement.parentNode.appendChild(effect.domElement);
|
|
@@ -44,16 +47,19 @@ function AsciiRenderer({
|
|
|
44
47
|
gl.domElement.style.opacity = '1';
|
|
45
48
|
gl.domElement.parentNode.removeChild(effect.domElement);
|
|
46
49
|
};
|
|
47
|
-
}, [effect]);
|
|
50
|
+
}, [effect]);
|
|
48
51
|
|
|
52
|
+
// Set size
|
|
49
53
|
React.useEffect(() => {
|
|
50
54
|
effect.setSize(size.width, size.height);
|
|
51
|
-
}, [effect, size]);
|
|
55
|
+
}, [effect, size]);
|
|
52
56
|
|
|
57
|
+
// Take over render-loop (that is what the index is for)
|
|
53
58
|
useFrame(state => {
|
|
54
59
|
effect.render(scene, camera);
|
|
55
|
-
}, renderIndex);
|
|
60
|
+
}, renderIndex);
|
|
56
61
|
|
|
62
|
+
// return something to not break type signatures
|
|
57
63
|
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
58
64
|
}
|
|
59
65
|
|
package/core/BBAnchor.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),r=require("react"),t=require("three"),n=require("@react-three/fiber");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function c(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 a=u(e),o=c(r),i=c(t);const s=new i.Box3,f=new i.Vector3;exports.BBAnchor=({anchor:e,...r})=>{const t=o.useRef(null),u=o.useRef(null);return o.useEffect((()=>{var e
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),r=require("react"),t=require("three"),n=require("@react-three/fiber");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function c(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 a=u(e),o=c(r),i=c(t);const s=new i.Box3,f=new i.Vector3;exports.BBAnchor=({anchor:e,...r})=>{const t=o.useRef(null),u=o.useRef(null);return o.useEffect((()=>{var e;null!=(e=t.current)&&null!=(e=e.parent)&&e.parent&&(u.current=t.current.parent,t.current.parent.parent.add(t.current))}),[]),n.useFrame((()=>{u.current&&(s.setFromObject(u.current),s.getSize(f),t.current.position.set(u.current.position.x+f.x*(Array.isArray(e)?e[0]:e.x)/2,u.current.position.y+f.y*(Array.isArray(e)?e[1]:e.y)/2,u.current.position.z+f.z*(Array.isArray(e)?e[2]:e.z)/2))})),o.createElement("group",a.default({ref:t},r))};
|
package/core/BBAnchor.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import * as THREE from 'three';
|
|
3
3
|
import { GroupProps } from '@react-three/fiber';
|
|
4
4
|
export interface BBAnchorProps extends GroupProps {
|
|
5
5
|
anchor: THREE.Vector3 | [number, number, number];
|
|
6
6
|
}
|
|
7
|
-
export declare const BBAnchor: ({ anchor, ...props }: BBAnchorProps) => JSX.Element;
|
|
7
|
+
export declare const BBAnchor: ({ anchor, ...props }: BBAnchorProps) => React.JSX.Element;
|
package/core/BBAnchor.js
CHANGED
|
@@ -10,14 +10,14 @@ const BBAnchor = ({
|
|
|
10
10
|
...props
|
|
11
11
|
}) => {
|
|
12
12
|
const ref = React.useRef(null);
|
|
13
|
-
const parentRef = React.useRef(null);
|
|
13
|
+
const parentRef = React.useRef(null);
|
|
14
|
+
|
|
15
|
+
// Reattach group created by this component to the parent's parent,
|
|
14
16
|
// so it becomes a sibling of its initial parent.
|
|
15
17
|
// We do that so the children have no impact on a bounding box of a parent.
|
|
16
|
-
|
|
17
18
|
React.useEffect(() => {
|
|
18
|
-
var _ref$current
|
|
19
|
-
|
|
20
|
-
if ((_ref$current = ref.current) != null && (_ref$current$parent = _ref$current.parent) != null && _ref$current$parent.parent) {
|
|
19
|
+
var _ref$current;
|
|
20
|
+
if ((_ref$current = ref.current) != null && (_ref$current = _ref$current.parent) != null && _ref$current.parent) {
|
|
21
21
|
parentRef.current = ref.current.parent;
|
|
22
22
|
ref.current.parent.parent.add(ref.current);
|
|
23
23
|
}
|
package/core/Backdrop.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
export
|
|
2
|
+
export type BackdropProps = JSX.IntrinsicElements['group'] & {
|
|
3
3
|
floor?: number;
|
|
4
4
|
segments?: number;
|
|
5
5
|
receiveShadow?: boolean;
|
|
@@ -11,4 +11,4 @@ export declare function Backdrop({ children, floor, segments, receiveShadow, ...
|
|
|
11
11
|
floor?: number | undefined;
|
|
12
12
|
segments?: number | undefined;
|
|
13
13
|
receiveShadow: any;
|
|
14
|
-
}): JSX.Element;
|
|
14
|
+
}): React.JSX.Element;
|
package/core/Backdrop.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
3
|
const easeInExpo = x => x === 0 ? 0 : Math.pow(2, 10 * x - 10);
|
|
4
|
-
|
|
5
4
|
function Backdrop({
|
|
6
5
|
children,
|
|
7
6
|
floor = 0.25,
|
|
@@ -14,13 +13,11 @@ function Backdrop({
|
|
|
14
13
|
let i = 0;
|
|
15
14
|
const offset = segments / segments / 2;
|
|
16
15
|
const position = ref.current.attributes.position;
|
|
17
|
-
|
|
18
16
|
for (let x = 0; x < segments + 1; x++) {
|
|
19
17
|
for (let y = 0; y < segments + 1; y++) {
|
|
20
18
|
position.setXYZ(i++, x / segments - offset + (x === 0 ? -floor : 0), y / segments - offset, easeInExpo(x / segments));
|
|
21
19
|
}
|
|
22
20
|
}
|
|
23
|
-
|
|
24
21
|
position.needsUpdate = true;
|
|
25
22
|
ref.current.computeVertexNormals();
|
|
26
23
|
}, [segments, floor]);
|
package/core/Billboard.d.ts
CHANGED
package/core/Billboard.js
CHANGED
|
@@ -23,12 +23,15 @@ const Billboard = /*#__PURE__*/React.forwardRef(function Billboard({
|
|
|
23
23
|
useFrame(({
|
|
24
24
|
camera
|
|
25
25
|
}) => {
|
|
26
|
-
if (!follow || !localRef.current) return;
|
|
26
|
+
if (!follow || !localRef.current) return;
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
// save previous rotation in case we're locking an axis
|
|
29
|
+
const prevRotation = localRef.current.rotation.clone();
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
// always face the camera
|
|
32
|
+
camera.getWorldQuaternion(localRef.current.quaternion);
|
|
31
33
|
|
|
34
|
+
// readjust any axis that is locked
|
|
32
35
|
if (lockX) localRef.current.rotation.x = prevRotation.x;
|
|
33
36
|
if (lockY) localRef.current.rotation.y = prevRotation.y;
|
|
34
37
|
if (lockZ) localRef.current.rotation.z = prevRotation.z;
|
package/core/Bounds.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import * as THREE from 'three';
|
|
3
|
-
export
|
|
3
|
+
export type SizeProps = {
|
|
4
4
|
box: THREE.Box3;
|
|
5
5
|
size: THREE.Vector3;
|
|
6
6
|
center: THREE.Vector3;
|
|
7
7
|
distance: number;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type BoundsApi = {
|
|
10
10
|
getSize: () => SizeProps;
|
|
11
11
|
refresh(object?: THREE.Object3D | THREE.Box3): any;
|
|
12
12
|
clip(): any;
|
|
@@ -16,7 +16,7 @@ export declare type BoundsApi = {
|
|
|
16
16
|
target?: [number, number, number];
|
|
17
17
|
}) => any;
|
|
18
18
|
};
|
|
19
|
-
export
|
|
19
|
+
export type BoundsProps = JSX.IntrinsicElements['group'] & {
|
|
20
20
|
damping?: number;
|
|
21
21
|
fit?: boolean;
|
|
22
22
|
clip?: boolean;
|
|
@@ -25,5 +25,5 @@ export declare type BoundsProps = JSX.IntrinsicElements['group'] & {
|
|
|
25
25
|
eps?: number;
|
|
26
26
|
onFit?: (data: SizeProps) => void;
|
|
27
27
|
};
|
|
28
|
-
export declare function Bounds({ children, damping, fit, clip, observe, margin, eps, onFit }: BoundsProps): JSX.Element;
|
|
28
|
+
export declare function Bounds({ children, damping, fit, clip, observe, margin, eps, onFit }: BoundsProps): React.JSX.Element;
|
|
29
29
|
export declare function useBounds(): BoundsApi;
|