1+ import type { OrbitControls } from '@react-three/drei'
12import { useThree } from '@react-three/fiber'
2- import { useEffect , useRef , type RefObject } from 'react'
3+ import { useEffect , useRef , type ComponentRef , type RefObject } from 'react'
34import { Quaternion , Vector3 , type Camera } from 'three'
4- import type { OrbitControls } from 'three/addons/controls/OrbitControls.js'
55
66import {
77 Ellipsoid ,
@@ -18,7 +18,7 @@ const rotation = new Quaternion()
1818
1919function applyLocation (
2020 camera : Camera ,
21- controls : OrbitControls ,
21+ controls : ComponentRef < typeof OrbitControls > ,
2222 { longitude, latitude, height } : GeodeticLike
2323) : void {
2424 geodetic . set ( radians ( longitude ) , radians ( latitude ) , height )
@@ -33,13 +33,15 @@ function applyLocation(
3333 controls . target . copy ( position )
3434}
3535
36- export type UseApplyLocationResult = RefObject < OrbitControls | null >
36+ export type UseApplyLocationResult = RefObject < ComponentRef <
37+ typeof OrbitControls
38+ > | null >
3739
3840export function useApplyLocation (
3941 { longitude, latitude, height } : GeodeticLike ,
4042 callback ?: ( position : Vector3 ) => void
4143) : UseApplyLocationResult {
42- const ref = useRef < OrbitControls > ( null )
44+ const ref = useRef < ComponentRef < typeof OrbitControls > > ( null )
4345 const camera = useThree ( ( { camera } ) => camera )
4446 const callbackRef = useRef ( callback )
4547 callbackRef . current = callback
0 commit comments