@react-three/drei 9.98.0 → 9.99.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/README.md CHANGED
@@ -59,6 +59,7 @@ The `native` route of the library **does not** export `Html` or `Loader`. The de
59
59
  <ul>
60
60
  <li><a href="#gizmohelper">GizmoHelper</a></li>
61
61
  <li><a href="#pivotcontrols">PivotControls</a></li>
62
+ <li><a href="#dragcontrols">DragControls</a></li>
62
63
  <li><a href="#transformcontrols">TransformControls</a></li>
63
64
  <li><a href="#grid">Grid</a></li>
64
65
  <li><a href="#usehelper">useHelper</a></li>
@@ -965,6 +966,57 @@ return (
965
966
  onDrag={({ matrix: matrix_ }) => matrix.copy(matrix_)}
966
967
  ```
967
968
 
969
+ #### DragControls
970
+
971
+ [![storybook](https://img.shields.io/badge/-storybook-%23ff69b4)](https://drei.vercel.app/?path=/story/gizmos-dragcontrols--drag-controls-story) ![Dom only](https://img.shields.io/badge/-Dom%20only-red)
972
+
973
+ You can use DragControls to make objects draggable in your scene. It supports locking the drag to specific axes, setting drag limits, and custom drag start, drag, and drag end events.
974
+
975
+ ```tsx
976
+ type DragControlsProps = {
977
+ /** If autoTransform is true, automatically apply the local transform on drag, true */
978
+ autoTransform?: boolean
979
+ /** The matrix to control */
980
+ matrix?: THREE.Matrix4
981
+ /** Lock the drag to a specific axis */
982
+ axisLock?: 'x' | 'y' | 'z'
983
+ /** Limits */
984
+ dragLimits?: [[number, number] | undefined, [number, number] | undefined, [number, number] | undefined]
985
+ /** Hover event */
986
+ onHover?: (hovering: boolean) => void
987
+ /** Drag start event */
988
+ onDragStart?: (origin: THREE.Vector3) => void
989
+ /** Drag event */
990
+ onDrag?: (
991
+ localMatrix: THREE.Matrix4,
992
+ deltaLocalMatrix: THREE.Matrix4,
993
+ worldMatrix: THREE.Matrix4,
994
+ deltaWorldMatrix: THREE.Matrix4
995
+ ) => void
996
+ /** Drag end event */
997
+ onDragEnd?: () => void
998
+ children: React.ReactNode
999
+ }
1000
+ ```
1001
+
1002
+ ```jsx
1003
+ <DragControls>
1004
+ <mesh />
1005
+ </DragControls>
1006
+ ```
1007
+
1008
+ You can utilize DragControls as a controlled component by toggling `autoTransform` off, which then requires you to manage the matrix transformation manually. Alternatively, keeping `autoTransform` enabled allows you to apply the matrix to external objects, enabling DragControls to manage objects that are not directly parented within it.
1009
+
1010
+ ```jsx
1011
+ const matrix = new THREE.Matrix4()
1012
+ return (
1013
+ <DragControls
1014
+ ref={ref}
1015
+ matrix={matrix}
1016
+ autoTransform={false}
1017
+ onDrag={(localMatrix) => matrix.copy(localMatrix)}
1018
+ ```
1019
+
968
1020
  #### TransformControls
969
1021
 
970
1022
  [![](https://img.shields.io/badge/-storybook-%23ff69b4)](https://drei.vercel.app/?path=/story/gizmos-transformcontrols--transform-controls-story)
@@ -2619,7 +2671,7 @@ Notes:
2619
2671
  ScrollControls example
2620
2672
 
2621
2673
  ```jsx
2622
- <ScrollControls damping={0.2} maxSpeed={0.5} pages={2}>
2674
+ ;<ScrollControls damping={0.2} maxSpeed={0.5} pages={2}>
2623
2675
  <SpriteAnimator
2624
2676
  position={[0.0, -1.5, -1.5]}
2625
2677
  startFrame={0}
@@ -3306,7 +3358,6 @@ const { spriteObj } = useSpriteLoader(
3306
3358
  />
3307
3359
  ```
3308
3360
 
3309
-
3310
3361
  # Performance
3311
3362
 
3312
3363
  #### Instances
@@ -2,6 +2,6 @@ import { Object3DProps } from '@react-three/fiber';
2
2
  import { Object3D } from 'three';
3
3
  import { ForwardRefComponent } from '../helpers/ts-utils';
4
4
  export interface ScreenSizerProps extends Object3DProps {
5
- scale: number;
5
+ scale?: number;
6
6
  }
7
7
  export declare const ScreenSizer: ForwardRefComponent<ScreenSizerProps, Object3D>;