11import type { Lane } from 'opendrive-parser'
2- import type { Vector3 } from 'three'
2+ import type { BufferGeometry , Vector3 } from 'three'
33import type { Level , Source } from './types'
44import type { RoadMesh } from './viewer'
55import 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 ( {
0 commit comments