Skip to content

Commit 4fae830

Browse files
committed
Fix types
1 parent 05b3780 commit 4fae830

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

storybook/src/helpers/useApplyLocation.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import type { OrbitControls } from '@react-three/drei'
12
import { useThree } from '@react-three/fiber'
2-
import { useEffect, useRef, type RefObject } from 'react'
3+
import { useEffect, useRef, type ComponentRef, type RefObject } from 'react'
34
import { Quaternion, Vector3, type Camera } from 'three'
4-
import type { OrbitControls } from 'three/addons/controls/OrbitControls.js'
55

66
import {
77
Ellipsoid,
@@ -18,7 +18,7 @@ const rotation = new Quaternion()
1818

1919
function 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

3840
export 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

Comments
 (0)