Commit 5b05e4f 1 parent 919a961 commit 5b05e4f Copy full SHA for 5b05e4f
File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,12 @@ export function SceneNodeThreeObject(props: {
113
113
false ;
114
114
const [ obj , setRef ] = React . useState < THREE . Object3D | null > ( null ) ;
115
115
116
+ const dragInfo = React . useRef ( {
117
+ dragging : false ,
118
+ startClientX : 0 ,
119
+ startClientY : 0 ,
120
+ } ) ;
121
+
116
122
// Create object + children.
117
123
//
118
124
// For not-fully-understood reasons, wrapping makeObject with useMemo() fixes
@@ -219,11 +225,20 @@ export function SceneNodeThreeObject(props: {
219
225
onPointerDown = { ( e ) => {
220
226
if ( ! isDisplayed ( ) ) return ;
221
227
e . stopPropagation ( ) ;
228
+ const state = dragInfo . current ;
229
+ state . startClientX = e . clientX ;
230
+ state . startClientY = e . clientY ;
222
231
setDragged ( false ) ;
223
232
} }
224
233
onPointerMove = { ( e ) => {
225
234
if ( ! isDisplayed ( ) ) return ;
226
235
e . stopPropagation ( ) ;
236
+ const state = dragInfo . current ;
237
+ const deltaX = e . clientX - state . startClientX ;
238
+ const deltaY = e . clientY - state . startClientY ;
239
+ // Minimum motion.
240
+ console . log ( deltaX , deltaY ) ;
241
+ if ( Math . abs ( deltaX ) <= 3 && Math . abs ( deltaY ) <= 3 ) return ;
227
242
setDragged ( true ) ;
228
243
} }
229
244
onPointerUp = { ( e ) => {
You can’t perform that action at this time.
0 commit comments