Skip to content

Commit bfb0e99

Browse files
committed
chore: lint styles and add deploy configurations
1 parent e4727c8 commit bfb0e99

24 files changed

Lines changed: 211 additions & 290 deletions

apps/viewer/netlify.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Netlify configuration file inside apps/viewer
2+
# Reference: https://docs.netlify.com/configure-builds/file-based-configuration/
3+
4+
[build]
5+
# Build command to run. Since Netlify handles workspace dependency resolution,
6+
# we specify our specific app target build filter.
7+
command = "pnpm --filter hdmap-viewer... build"
8+
9+
# Directory containing the static site assets to be published.
10+
publish = "apps/viewer/dist"
11+
12+
# Single Page Application (SPA) redirect rule
13+
# Redirects all requests to index.html for client-side routing
14+
[[redirects]]
15+
from = "/*"
16+
to = "/index.html"
17+
status = 200

apps/viewer/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
"name": "hdmap-viewer",
33
"type": "module",
44
"version": "0.0.5",
5+
"private": true,
56
"repository": {
67
"type": "github",
78
"url": "https://github.com/42arch/hdmap-viewer"
89
},
9-
"private": true,
1010
"scripts": {
1111
"dev": "vite",
12+
"lint": "eslint",
13+
"lint:fix": "eslint --fix",
1214
"build": "vue-tsc -b && vite build",
1315
"preview": "vite preview"
1416
},

apps/viewer/src/components/InfoPanel.vue

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,14 @@ interface InfoState {
3232
}
3333
3434
const store = useAppStore()
35-
const { viewer, openDrive, fileInfo } = storeToRefs(store)
35+
const { viewer, fileInfo } = storeToRefs(store)
3636
const state = reactive<InfoState>({
3737
basic: null,
3838
coordinate: null,
3939
predecessors: [],
4040
successors: [],
4141
})
4242
43-
watch(openDrive, () => {
44-
if (!openDrive.value)
45-
return
46-
47-
console.warn(9999, openDrive.value?.header)
48-
})
49-
5043
watch(viewer, () => {
5144
if (!viewer.value)
5245
return
@@ -82,7 +75,7 @@ watch(viewer, () => {
8275
</script>
8376

8477
<template>
85-
<NCard :class="['info-panel', { 'has-content': !!state.basic }]" content-style="padding: 0">
78+
<NCard class="info-panel" :class="[{ 'has-content': !!state.basic }]" content-style="padding: 0">
8679
<div class="title">
8780
<NIcon size="12">
8881
<InfoCircle />

apps/viewer/src/components/OperatePanel.vue

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ const precisionOptions = [{
2525
value: 1,
2626
}]
2727
28-
29-
3028
watch(precision, () => {
3129
if (!viewer.value)
3230
return
@@ -114,7 +112,8 @@ function nodeProps({ option }: { option: TreeOption }) {
114112
// viewer.value?.setSelectedLane(option.key as string)
115113
},
116114
onMouseover() {
117-
if (!isVisible) return
115+
if (!isVisible)
116+
return
118117
if (highlightTimer)
119118
clearTimeout(highlightTimer)
120119
highlightTimer = setTimeout(() => {
@@ -152,7 +151,7 @@ function renderSuffix({ option }: { option: TreeOption }) {
152151
},
153152
{
154153
default: () => h(NIcon, { size: 12 }, { default: () => h(Crosshairs) }),
155-
}
154+
},
156155
),
157156
h(
158157
NButton,
@@ -168,9 +167,9 @@ function renderSuffix({ option }: { option: TreeOption }) {
168167
},
169168
{
170169
default: () => h(NIcon, { size: 12 }, { default: () => h(isVisible ? Eye : EyeSlash) }),
171-
}
170+
},
172171
),
173-
]
172+
],
174173
)
175174
}
176175

apps/viewer/src/libs/highlight-manager.ts

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Lane } from 'opendrive-parser'
2-
import type { Vector3 } from 'three'
2+
import type { BufferGeometry, Vector3 } from 'three'
33
import type { Level, Source } from './types'
44
import type { RoadMesh } from './viewer'
55
import type Viewer from './viewer'
@@ -46,8 +46,9 @@ class HighlightManager {
4646

4747
private getLaneFromId(laneId: string): Lane | undefined {
4848
const parts = laneId.split('_')
49-
if (parts.length < 3) return undefined
50-
49+
if (parts.length < 3)
50+
return undefined
51+
5152
// The format is roadId_sectionS_laneId.
5253
// However, roadId might contain underscores? Assuming standard format.
5354
// Better logic: last part is laneId, second last is sectionS, rest is roadId.
@@ -56,10 +57,12 @@ class HighlightManager {
5657
const rId = parts.join('_')
5758

5859
const road = this.viewer.openDrive?.getRoadById(rId)
59-
if (!road) return undefined
60+
if (!road)
61+
return undefined
6062

6163
const section = road.getLaneSectionByS(Number(sS))
62-
if (!section) return undefined
64+
if (!section)
65+
return undefined
6366

6467
return section.getLaneById(lId)
6568
}
@@ -86,7 +89,8 @@ class HighlightManager {
8689
}
8790

8891
const geometry = this.viewer.createLaneGeometry(lane)
89-
if (!geometry) return
92+
if (!geometry)
93+
return
9094

9195
const [roadKey, sectionKey] = laneId.split('_')
9296
this.setHighlightRoad(roadKey!)
@@ -124,19 +128,22 @@ class HighlightManager {
124128
return
125129
}
126130

127-
const laneGeometries = []
131+
const laneGeometries: BufferGeometry[] = []
128132
const laneSections = road.getLaneSections()
129-
133+
130134
for (const section of laneSections) {
131-
for (const lane of section.getLanes()) {
132-
const laneId = `${roadId}_${section.s}_${lane.id}`
133-
if (!this.viewer.isLaneVisible(laneId)) continue
134-
const geom = this.viewer.createLaneGeometry(lane)
135-
if (geom) laneGeometries.push(geom)
136-
}
135+
for (const lane of section.getLanes()) {
136+
const laneId = `${roadId}_${section.s}_${lane.id}`
137+
if (!this.viewer.isLaneVisible(laneId))
138+
continue
139+
const geom = this.viewer.createLaneGeometry(lane)
140+
if (geom)
141+
laneGeometries.push(geom)
142+
}
137143
}
138144

139-
if (laneGeometries.length === 0) return
145+
if (laneGeometries.length === 0)
146+
return
140147

141148
const merged = BufferGeometryUtils.mergeGeometries(laneGeometries)
142149
const material = new MeshBasicMaterial({
@@ -179,17 +186,20 @@ class HighlightManager {
179186
if (!laneSection) {
180187
return
181188
}
182-
const laneGeometries = []
189+
const laneGeometries: BufferGeometry[] = []
183190
const lanes = laneSection.getLanes()
184191

185192
for (const lane of lanes) {
186193
const laneId = `${roadId}_${sectionS}_${lane.id}`
187-
if (!this.viewer.isLaneVisible(laneId)) continue
194+
if (!this.viewer.isLaneVisible(laneId))
195+
continue
188196
const geom = this.viewer.createLaneGeometry(lane)
189-
if (geom) laneGeometries.push(geom)
197+
if (geom)
198+
laneGeometries.push(geom)
190199
}
191200

192-
if (laneGeometries.length === 0) return
201+
if (laneGeometries.length === 0)
202+
return
193203

194204
const merged = BufferGeometryUtils.mergeGeometries(laneGeometries)
195205
const material = new MeshBasicMaterial({
@@ -208,16 +218,18 @@ class HighlightManager {
208218
const visibleLaneIds = laneIds.filter(id => this.viewer.isLaneVisible(id))
209219
if (visibleLaneIds.length === 0)
210220
return
211-
const geometries = []
221+
const geometries: BufferGeometry[] = []
212222
for (const laneId of visibleLaneIds) {
213223
const lane = this.getLaneFromId(laneId)
214224
if (lane) {
215-
const geom = this.viewer.createLaneGeometry(lane)
216-
if (geom) geometries.push(geom)
225+
const geom = this.viewer.createLaneGeometry(lane)
226+
if (geom)
227+
geometries.push(geom)
217228
}
218229
}
219230

220-
if (geometries.length === 0) return
231+
if (geometries.length === 0)
232+
return
221233

222234
const merged = BufferGeometryUtils.mergeGeometries(geometries)
223235
const material = new MeshBasicMaterial({
@@ -245,16 +257,18 @@ class HighlightManager {
245257
const visibleLaneIds = laneIds.filter(id => this.viewer.isLaneVisible(id))
246258
if (visibleLaneIds.length === 0)
247259
return
248-
const geometries = []
260+
const geometries: BufferGeometry[] = []
249261
for (const laneId of visibleLaneIds) {
250262
const lane = this.getLaneFromId(laneId)
251263
if (lane) {
252-
const geom = this.viewer.createLaneGeometry(lane)
253-
if (geom) geometries.push(geom)
264+
const geom = this.viewer.createLaneGeometry(lane)
265+
if (geom)
266+
geometries.push(geom)
254267
}
255268
}
256269

257-
if (geometries.length === 0) return
270+
if (geometries.length === 0)
271+
return
258272

259273
const merged = BufferGeometryUtils.mergeGeometries(geometries)
260274
const material = new MeshBasicMaterial({

apps/viewer/src/libs/viewer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,13 @@ class Viewer {
297297
`attribute float laneVisible;
298298
varying float vLaneVisible;
299299
void main() {
300-
vLaneVisible = laneVisible;`
300+
vLaneVisible = laneVisible;`,
301301
)
302302
shader.fragmentShader = shader.fragmentShader.replace(
303303
'void main() {',
304304
`varying float vLaneVisible;
305305
void main() {
306-
if (vLaneVisible < 0.5) discard;`
306+
if (vLaneVisible < 0.5) discard;`,
307307
)
308308
}
309309
}

apps/viewer/src/store.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ export const useAppStore = defineStore('app', () => {
4545
const roadId = parts.join('_')
4646
const sectionKey = `${roadId}_${sectionS}`
4747
return (
48-
visibilityMap.value[roadId] !== false &&
49-
visibilityMap.value[sectionKey] !== false &&
50-
visibilityMap.value[key] !== false
48+
visibilityMap.value[roadId] !== false
49+
&& visibilityMap.value[sectionKey] !== false
50+
&& visibilityMap.value[key] !== false
5151
)
5252
}
5353

@@ -58,20 +58,23 @@ export const useAppStore = defineStore('app', () => {
5858
}
5959

6060
function areAllVisible(): boolean {
61-
if (!openDrive.value) return true
61+
if (!openDrive.value)
62+
return true
6263
const roads = openDrive.value.getRoads()
6364
return roads.every(road => visibilityMap.value[road.id] !== false)
6465
}
6566

6667
function toggleAllVisibility() {
67-
if (!openDrive.value) return
68+
if (!openDrive.value)
69+
return
6870
const roads = openDrive.value.getRoads()
6971
const allVisible = areAllVisible()
7072
if (allVisible) {
71-
roads.forEach(road => {
73+
roads.forEach((road) => {
7274
visibilityMap.value[road.id] = false
7375
})
74-
} else {
76+
}
77+
else {
7578
visibilityMap.value = {}
7679
}
7780
viewer.value?.updateVisibility(visibilityMap.value)

apps/viewer/tsconfig.app.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
/* Linting */
1212
"strict": true,
1313
"noFallthroughCasesInSwitch": true,
14+
"noImplicitAny": false,
1415
"noUnusedLocals": true,
1516
"noUnusedParameters": true,
1617
"erasableSyntaxOnly": true,

apps/viewer/vercel.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "https://openapi.vercel.sh/vercel.json",
3+
"buildCommand": "pnpm --filter hdmap-viewer... build",
4+
"outputDirectory": "dist",
5+
"framework": "vite",
6+
"cleanUrls": true,
7+
"rewrites": [
8+
{
9+
"source": "/(.*)",
10+
"destination": "/index.html"
11+
}
12+
]
13+
}

docs/specs/01-architecture.md

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)