Skip to content

Commit 2b0a8a3

Browse files
committed
fix: lng lat order
1 parent 9fb4078 commit 2b0a8a3

10 files changed

Lines changed: 21 additions & 27 deletions

File tree

src/components/bar.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,11 @@ export default class Bar {
1919
draw(): THREE.Mesh {
2020
const targetVector = new THREE.Vector3(0, 0, 0)
2121

22-
const [lng, lat] = this.config.location.geometry.coordinates;
22+
const [lng, lat] = this.config.location.geometry.coordinates
2323

24-
if(!lng || !lat) throw Error("Invalid coordinates");
24+
if (!lng || !lat) throw Error('Invalid coordinates')
2525

26-
const position = calculateVec3FromLatLon(
27-
lng, lat,
28-
600,
29-
)
26+
const position = calculateVec3FromLatLon(lng, lat, 600)
3027

3128
const geometry = new THREE.CylinderGeometry(
3229
this.config.radiusTop!,

src/components/marker.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,11 @@ export default class Marker {
3636
depthTest: false,
3737
})
3838

39-
const [lng, lat] = this.config.location.geometry.coordinates;
39+
const [lng, lat] = this.config.location.geometry.coordinates
4040

41-
if(!lng || !lat) throw Error("Invalid coordinates.");
41+
if (!lng || !lat) throw Error('Invalid coordinates.')
4242

43-
const position = calculateVec3FromLatLon(
44-
lng,
45-
lat,
46-
600,
47-
)
43+
const position = calculateVec3FromLatLon(lng, lat, 600)
4844

4945
const mesh = new THREE.Mesh(geometry, material)
5046

src/components/scene.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ export default class GlobeScene {
1717

1818
#renderer: THREE.WebGLRenderer
1919

20-
#markerMeshes: THREE.Mesh<THREE.PlaneGeometry,THREE.ShaderMaterial>[] = []
20+
#markerMeshes: THREE.Mesh<THREE.PlaneGeometry, THREE.ShaderMaterial>[] = []
2121
#barMeshes: THREE.Mesh[] = []
2222
#dotSphereMesh: THREE.Mesh<THREE.BufferGeometry, THREE.ShaderMaterial> | null = null
23-
#atmosphere: THREE.Mesh<THREE.IcosahedronGeometry,THREE.ShaderMaterial> | undefined
23+
#atmosphere: THREE.Mesh<THREE.IcosahedronGeometry, THREE.ShaderMaterial> | undefined
2424

2525
readonly globeConfig: GlobeConfig
2626
readonly container: HTMLCanvasElement
@@ -126,7 +126,8 @@ export default class GlobeScene {
126126
private animate(): void {
127127
const delta = this.#clock.getDelta()
128128

129-
if (!this.#atmosphere || !this.#atmosphere.material.uniforms.viewVector) throw Error('No atmosphere.')
129+
if (!this.#atmosphere || !this.#atmosphere.material.uniforms.viewVector)
130+
throw Error('No atmosphere.')
130131

131132
this.#atmosphere.material.uniforms.viewVector.value = this.#camera.position
132133

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ import Arc from './components/arc'
33
import Marker from './components/marker'
44
import Bar from './components/bar'
55

6-
76
export { GlobeScene, Arc, Bar, Marker }

src/types/arc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Vector3 } from 'three'
2-
import type { Feature, Point } from 'geojson';
2+
import type { Feature, Point } from 'geojson'
33

44
export interface ArcConfig {
55
startLocation: Feature<Point>

src/types/bar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Feature, Point } from 'geojson';
1+
import type { Feature, Point } from 'geojson'
22

33
export interface BarConfig {
44
location: Feature<Point>

src/types/marker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Feature, Point } from 'geojson';
1+
import type { Feature, Point } from 'geojson'
22

33
export interface MarkerConfig {
44
location: Feature<Point>

src/utils/arc-controlpoints.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ export default function calculateArcControlPoints(config: ArcConfig): ControlPoi
1313
lat: config.endLocation.geometry.coordinates[1],
1414
}
1515

16-
if(!startCoords.lat || !startCoords.lon || !endCoords.lat || !endCoords.lon) throw Error("Invalid coordinates")
16+
if (!startCoords.lat || !startCoords.lon || !endCoords.lat || !endCoords.lon)
17+
throw Error('Invalid coordinates')
1718

18-
const startVec3 = calculateVec3FromLatLon(startCoords.lat, startCoords.lon, 600)
19-
const endVec3 = calculateVec3FromLatLon(endCoords.lat, endCoords.lon, 600)
19+
const startVec3 = calculateVec3FromLatLon(startCoords.lon, startCoords.lat, 600)
20+
const endVec3 = calculateVec3FromLatLon(endCoords.lon, endCoords.lat, 600)
2021
const arcHeight = startVec3.distanceTo(endVec3) * config.height! + 600
2122

2223
const interpolate = geoInterpolate(
@@ -29,8 +30,8 @@ export default function calculateArcControlPoints(config: ArcConfig): ControlPoi
2930
end: interpolate(0.75),
3031
}
3132

32-
const midStartVec3 = calculateVec3FromLatLon(midCoords.start[1], midCoords.start[0], arcHeight)
33-
const midEndVec3 = calculateVec3FromLatLon(midCoords.end[1], midCoords.end[0], arcHeight)
33+
const midStartVec3 = calculateVec3FromLatLon(midCoords.start[0], midCoords.start[1], arcHeight)
34+
const midEndVec3 = calculateVec3FromLatLon(midCoords.end[0], midCoords.end[1], arcHeight)
3435

3536
return {
3637
start: startVec3,

src/utils/threejs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function degreesToRadians(degrees: number): number {
88
return degrees * (Math.PI / 180)
99
}
1010

11-
export const calculateVec3FromLatLon = (lat: number, lon: number, radius: number): Vector3 => {
11+
export const calculateVec3FromLatLon = (lng: number, lat: number, radius: number): Vector3 => {
1212
const phi = degreesToRadians(90 - lat)
1313
const theta = degreesToRadians(lon + 90)
1414
const rho = radius

vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default defineConfig({
1515
},
1616
rollupOptions: {
1717
external: [...Object.keys(peerDependencies), '@vue/devtools-kit'],
18-
}
18+
},
1919
},
2020
server: {
2121
host: '0.0.0.0',

0 commit comments

Comments
 (0)