Skip to content

Commit

Permalink
fix: GizmoHelper's incorrect snapping with TrackballControls
Browse files Browse the repository at this point in the history
  • Loading branch information
FarazzShaikh committed Jul 10, 2022
1 parent a2dfb04 commit c7fa011
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/core/GizmoHelper.tsx
Expand Up @@ -37,7 +37,16 @@ const targetPosition = new Vector3()
type ControlsProto = { update(): void; target: THREE.Vector3 }

export type GizmoHelperProps = JSX.IntrinsicElements['group'] & {
alignment?: 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left' | 'bottom-center' | 'center-right' | 'center-left' | 'center-center' | 'top-center'
alignment?:
| 'top-left'
| 'top-right'
| 'bottom-right'
| 'bottom-left'
| 'bottom-center'
| 'center-right'
| 'center-left'
| 'center-center'
| 'top-center'
margin?: [number, number]
renderPriority?: number
autoClear?: boolean
Expand Down Expand Up @@ -74,6 +83,10 @@ export const GizmoHelper = ({
const focusPoint = React.useRef(new Vector3(0, 0, 0))
const defaultUp = React.useRef(new Vector3(0, 0, 0))

React.useEffect(() => {
defaultUp.current.copy(mainCamera.up)
}, [mainCamera])

const tweenCamera = React.useCallback(
(direction: Vector3) => {
animating.current = true
Expand All @@ -88,8 +101,6 @@ export const GizmoHelper = ({
dummy.lookAt(targetPosition)
q2.copy(dummy.quaternion)

defaultUp.current.copy(mainCamera.up)

invalidate()
},
[defaultControls, mainCamera, onTarget, invalidate]
Expand Down

1 comment on commit c7fa011

@vercel
Copy link

@vercel vercel bot commented on c7fa011 Jul 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.