完善样式系统与调试链路底座
This commit is contained in:
@@ -7,6 +7,7 @@ import { type MapRenderer, type MapRendererStats, type MapScene } from './mapRen
|
||||
import { WebGLTileRenderer } from './webglTileRenderer'
|
||||
import { WebGLVectorRenderer } from './webglVectorRenderer'
|
||||
import { CourseLabelRenderer } from './courseLabelRenderer'
|
||||
import { type MockSimulatorDebugLogLevel } from '../debug/mockSimulatorDebugLogger'
|
||||
|
||||
const RENDER_FRAME_MS = 16
|
||||
const ANIMATION_FRAME_MS = 33
|
||||
@@ -29,12 +30,32 @@ export class WebGLMapRenderer implements MapRenderer {
|
||||
animationPaused: boolean
|
||||
pulseFrame: number
|
||||
lastStats: MapRendererStats
|
||||
lastGpsLogoDebugInfo: { status: string; url: string; resolvedSrc: string }
|
||||
onStats?: (stats: MapRendererStats) => void
|
||||
onTileError?: (message: string) => void
|
||||
onGpsLogoDebug?: (info: { status: string; url: string; resolvedSrc: string }) => void
|
||||
onDebugLog?: (
|
||||
scope: string,
|
||||
level: MockSimulatorDebugLogLevel,
|
||||
message: string,
|
||||
payload?: Record<string, unknown>,
|
||||
) => void
|
||||
|
||||
constructor(onStats?: (stats: MapRendererStats) => void, onTileError?: (message: string) => void) {
|
||||
constructor(
|
||||
onStats?: (stats: MapRendererStats) => void,
|
||||
onTileError?: (message: string) => void,
|
||||
onGpsLogoDebug?: (info: { status: string; url: string; resolvedSrc: string }) => void,
|
||||
onDebugLog?: (
|
||||
scope: string,
|
||||
level: MockSimulatorDebugLogLevel,
|
||||
message: string,
|
||||
payload?: Record<string, unknown>,
|
||||
) => void,
|
||||
) {
|
||||
this.onStats = onStats
|
||||
this.onTileError = onTileError
|
||||
this.onGpsLogoDebug = onGpsLogoDebug
|
||||
this.onDebugLog = onDebugLog
|
||||
this.tileStore = new TileStore({
|
||||
onTileReady: () => {
|
||||
this.scheduleRender()
|
||||
@@ -61,7 +82,7 @@ export class WebGLMapRenderer implements MapRenderer {
|
||||
this.gpsLayer = new GpsLayer()
|
||||
this.tileRenderer = new WebGLTileRenderer(this.tileLayer, this.tileStore, this.osmTileLayer, this.osmTileStore)
|
||||
this.vectorRenderer = new WebGLVectorRenderer(this.courseLayer, this.trackLayer, this.gpsLayer)
|
||||
this.labelRenderer = new CourseLabelRenderer(this.courseLayer)
|
||||
this.labelRenderer = new CourseLabelRenderer(this.courseLayer, onDebugLog)
|
||||
this.scene = null
|
||||
this.renderTimer = 0
|
||||
this.animationTimer = 0
|
||||
@@ -77,6 +98,11 @@ export class WebGLMapRenderer implements MapRenderer {
|
||||
diskHitCount: 0,
|
||||
networkFetchCount: 0,
|
||||
}
|
||||
this.lastGpsLogoDebugInfo = {
|
||||
status: 'idle',
|
||||
url: '',
|
||||
resolvedSrc: '',
|
||||
}
|
||||
}
|
||||
|
||||
attachCanvas(canvasNode: any, width: number, height: number, dpr: number, labelCanvasNode?: any): void {
|
||||
@@ -164,9 +190,14 @@ export class WebGLMapRenderer implements MapRenderer {
|
||||
this.tileRenderer.render(this.scene)
|
||||
this.vectorRenderer.render(this.scene, this.pulseFrame)
|
||||
this.labelRenderer.render(this.scene)
|
||||
this.emitGpsLogoDebug(this.labelRenderer.getGpsLogoDebugInfo())
|
||||
this.emitStats(this.tileStore.getStats(this.tileLayer.lastVisibleTileCount, this.tileLayer.lastReadyTileCount))
|
||||
}
|
||||
|
||||
getGpsLogoDebugInfo(): { status: string; url: string; resolvedSrc: string } {
|
||||
return this.labelRenderer.getGpsLogoDebugInfo()
|
||||
}
|
||||
|
||||
emitStats(stats: MapRendererStats): void {
|
||||
if (
|
||||
stats.visibleTileCount === this.lastStats.visibleTileCount
|
||||
@@ -185,4 +216,19 @@ export class WebGLMapRenderer implements MapRenderer {
|
||||
this.onStats(stats)
|
||||
}
|
||||
}
|
||||
|
||||
emitGpsLogoDebug(info: { status: string; url: string; resolvedSrc: string }): void {
|
||||
if (
|
||||
info.status === this.lastGpsLogoDebugInfo.status
|
||||
&& info.url === this.lastGpsLogoDebugInfo.url
|
||||
&& info.resolvedSrc === this.lastGpsLogoDebugInfo.resolvedSrc
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
this.lastGpsLogoDebugInfo = info
|
||||
if (this.onGpsLogoDebug) {
|
||||
this.onGpsLogoDebug(info)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user