Skip to content

Commit 4634b65

Browse files
committed
push 10 year fixes
1 parent d4fbfb8 commit 4634b65

File tree

4 files changed

+77
-10
lines changed

4 files changed

+77
-10
lines changed

app/[locale]/10years/_components/TenYearGlobe.tsx

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useTheme } from "next-themes"
55
import Globe from "react-globe.gl"
66
import { type GlobeMethods } from "react-globe.gl"
77
import * as THREE from "three"
8+
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls"
89

910
import Link from "@/components/ui/Link"
1011

@@ -29,6 +30,14 @@ type CountryFeature = {
2930
}
3031
}
3132

33+
// Extend OrbitControls type to include _sphericalDelta
34+
interface ExtendedOrbitControls extends OrbitControls {
35+
_sphericalDelta?: {
36+
theta: number
37+
phi: number
38+
}
39+
}
40+
3241
const TenYearGlobe = ({ events }: { events: EventData[] }) => {
3342
const globeRef = useRef<GlobeMethods>()
3443
const globeContainerRef = useRef<HTMLDivElement>(null)
@@ -71,10 +80,11 @@ const TenYearGlobe = ({ events }: { events: EventData[] }) => {
7180

7281
useEffect(() => {
7382
if (globeRef.current) {
74-
globeRef.current.controls().autoRotate = true
75-
globeRef.current.controls().enablePan = false
76-
globeRef.current.controls().enableZoom = false
77-
globeRef.current.controls().autoRotateSpeed = 2.0
83+
const controls = globeRef.current.controls() as ExtendedOrbitControls
84+
controls.autoRotate = true
85+
controls.enablePan = false
86+
controls.enableZoom = false
87+
controls.autoRotateSpeed = 2.0
7888
globeRef.current.pointOfView({ lat: 0, lng: 0, altitude: 1.8 })
7989

8090
const ambientLight = new THREE.AmbientLight(0xffffff, 1)
@@ -165,10 +175,10 @@ const TenYearGlobe = ({ events }: { events: EventData[] }) => {
165175
setTooltipPos(coords)
166176
}
167177
// Stop rotation immediately
168-
const controls = globeRef.current.controls()
178+
const controls = globeRef.current.controls() as ExtendedOrbitControls
169179
controls.autoRotate = false
170180
if ("autoRotateSpeed" in controls) controls.autoRotateSpeed = 0
171-
if ("_sphericalDelta" in controls && controls._sphericalDelta) {
181+
if (controls._sphericalDelta) {
172182
controls._sphericalDelta.theta = 0
173183
controls._sphericalDelta.phi = 0
174184
}
@@ -181,18 +191,19 @@ const TenYearGlobe = ({ events }: { events: EventData[] }) => {
181191
}
182192
}, 100)
183193
if (globeRef.current) {
184-
const controls = globeRef.current.controls()
194+
const controls =
195+
globeRef.current.controls() as ExtendedOrbitControls
185196
controls.autoRotate = true
186197
if ("autoRotateSpeed" in controls) controls.autoRotateSpeed = 2.0
187198
}
188199
}
189200
}}
190201
onPointClick={() => {
191202
if (globeRef.current) {
192-
const controls = globeRef.current.controls()
203+
const controls = globeRef.current.controls() as ExtendedOrbitControls
193204
controls.autoRotate = false
194205
if ("autoRotateSpeed" in controls) controls.autoRotateSpeed = 0
195-
if ("_sphericalDelta" in controls && controls._sphericalDelta) {
206+
if (controls._sphericalDelta) {
196207
controls._sphericalDelta.theta = 0
197208
controls._sphericalDelta.phi = 0
198209
}

app/[locale]/10years/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import pick from "lodash.pick"
1+
import { pick } from "lodash"
22
import {
33
getMessages,
44
getTranslations,

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"@socialgouv/matomo-next": "^1.8.0",
5252
"@tanstack/react-query": "^5.66.7",
5353
"@tanstack/react-table": "^8.19.3",
54+
"@types/three": "^0.177.0",
5455
"chart.js": "^4.4.2",
5556
"chartjs-plugin-datalabels": "^2.2.0",
5657
"class-variance-authority": "^0.7.0",
@@ -87,6 +88,7 @@
8788
"tailwind-merge": "^2.3.0",
8889
"tailwind-variants": "^0.2.1",
8990
"tailwindcss-animate": "^1.0.7",
91+
"three": "^0.177.0",
9092
"usehooks-ts": "^3.1.0",
9193
"vaul": "^1.0.0",
9294
"viem": "^2.23.3",

pnpm-lock.yaml

Lines changed: 54 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)