Refine GPS trace cleanup and marker rendering

This commit is contained in:
2026-03-24 14:40:34 +08:00
parent 2cf0bb76b4
commit 71ad6c6535
4 changed files with 41 additions and 7 deletions

View File

@@ -552,6 +552,7 @@ export class MapEngine {
currentGpsTrack: LonLatPoint[] currentGpsTrack: LonLatPoint[]
currentGpsAccuracyMeters: number | null currentGpsAccuracyMeters: number | null
courseData: OrienteeringCourseData | null courseData: OrienteeringCourseData | null
courseOverlayVisible: boolean
cpRadiusMeters: number cpRadiusMeters: number
gameRuntime: GameRuntime gameRuntime: GameRuntime
telemetryRuntime: TelemetryRuntime telemetryRuntime: TelemetryRuntime
@@ -674,6 +675,7 @@ export class MapEngine {
this.currentGpsTrack = [] this.currentGpsTrack = []
this.currentGpsAccuracyMeters = null this.currentGpsAccuracyMeters = null
this.courseData = null this.courseData = null
this.courseOverlayVisible = false
this.cpRadiusMeters = 5 this.cpRadiusMeters = 5
this.gameRuntime = new GameRuntime() this.gameRuntime = new GameRuntime()
this.telemetryRuntime = new TelemetryRuntime() this.telemetryRuntime = new TelemetryRuntime()
@@ -851,10 +853,30 @@ export class MapEngine {
this.gameRuntime.clear() this.gameRuntime.clear()
this.telemetryRuntime.reset() this.telemetryRuntime.reset()
this.gamePresentation = EMPTY_GAME_PRESENTATION_STATE this.gamePresentation = EMPTY_GAME_PRESENTATION_STATE
this.courseOverlayVisible = !!this.courseData
this.clearSessionTimerInterval() this.clearSessionTimerInterval()
this.setCourseHeading(null) this.setCourseHeading(null)
} }
clearFinishedTestOverlay(): void {
this.currentGpsPoint = null
this.currentGpsTrack = []
this.currentGpsAccuracyMeters = null
this.courseOverlayVisible = false
this.setCourseHeading(null)
}
handleClearMapTestArtifacts(): void {
this.clearFinishedTestOverlay()
this.setState({
gpsTracking: false,
gpsTrackingText: '测试痕迹已清空',
gpsCoordText: '--',
statusText: `已清空地图点位与轨迹 (${this.buildVersion})`,
}, true)
this.syncRenderer()
}
getHudTargetControlId(): string | null { getHudTargetControlId(): string | null {
return this.gamePresentation.hud.hudTargetControlId return this.gamePresentation.hud.hudTargetControlId
} }
@@ -894,6 +916,7 @@ export class MapEngine {
const result = this.gameRuntime.loadDefinition(definition) const result = this.gameRuntime.loadDefinition(definition)
this.telemetryRuntime.loadDefinition(definition) this.telemetryRuntime.loadDefinition(definition)
this.gamePresentation = result.presentation this.gamePresentation = result.presentation
this.courseOverlayVisible = true
this.telemetryRuntime.syncGameState(this.gameRuntime.definition, result.nextState, this.getHudTargetControlId()) this.telemetryRuntime.syncGameState(this.gameRuntime.definition, result.nextState, this.getHudTargetControlId())
this.refreshCourseHeadingFromPresentation() this.refreshCourseHeadingFromPresentation()
this.updateSessionTimerLoop() this.updateSessionTimerLoop()
@@ -1172,6 +1195,12 @@ export class MapEngine {
applyGameEffects(effects: GameEffect[]): string | null { applyGameEffects(effects: GameEffect[]): string | null {
this.feedbackDirector.handleEffects(effects) this.feedbackDirector.handleEffects(effects)
if (effects.some((effect) => effect.type === 'session_finished')) {
this.setState({
gpsTracking: false,
gpsTrackingText: '测试结束,定位已停止',
}, true)
}
this.telemetryRuntime.syncGameState(this.gameRuntime.definition, this.gameRuntime.state, this.getHudTargetControlId()) this.telemetryRuntime.syncGameState(this.gameRuntime.definition, this.gameRuntime.state, this.getHudTargetControlId())
this.updateSessionTimerLoop() this.updateSessionTimerLoop()
return this.resolveGameStatusText(effects) return this.resolveGameStatusText(effects)
@@ -1206,6 +1235,7 @@ export class MapEngine {
} }
this.gamePresentation = this.gameRuntime.getPresentation() this.gamePresentation = this.gameRuntime.getPresentation()
this.courseOverlayVisible = true
this.refreshCourseHeadingFromPresentation() this.refreshCourseHeadingFromPresentation()
const defaultStatusText = this.currentGpsPoint const defaultStatusText = this.currentGpsPoint
? `顺序打点已开始 (${this.buildVersion})` ? `顺序打点已开始 (${this.buildVersion})`
@@ -2250,7 +2280,7 @@ export class MapEngine {
gpsPoint: this.currentGpsPoint, gpsPoint: this.currentGpsPoint,
gpsCalibration: GPS_MAP_CALIBRATION, gpsCalibration: GPS_MAP_CALIBRATION,
gpsCalibrationOrigin: worldTileToLonLat({ x: this.defaultCenterTileX, y: this.defaultCenterTileY }, this.defaultZoom), gpsCalibrationOrigin: worldTileToLonLat({ x: this.defaultCenterTileX, y: this.defaultCenterTileY }, this.defaultZoom),
course: this.courseData, course: this.courseOverlayVisible ? this.courseData : null,
cpRadiusMeters: this.cpRadiusMeters, cpRadiusMeters: this.cpRadiusMeters,
controlVisualMode: this.gamePresentation.map.controlVisualMode, controlVisualMode: this.gamePresentation.map.controlVisualMode,
showCourseLegs: this.gamePresentation.map.showCourseLegs, showCourseLegs: this.gamePresentation.map.showCourseLegs,

View File

@@ -170,11 +170,6 @@ export class WebGLVectorRenderer {
this.pushSegment(positions, colors, trackPoints[index - 1], trackPoints[index], 6, [0.09, 0.43, 0.36, 0.96], scene) this.pushSegment(positions, colors, trackPoints[index - 1], trackPoints[index], 6, [0.09, 0.43, 0.36, 0.96], scene)
} }
for (const point of trackPoints) {
this.pushCircle(positions, colors, point.x, point.y, 10, [0.09, 0.43, 0.36, 1], scene)
this.pushCircle(positions, colors, point.x, point.y, 6.5, [0.97, 0.98, 0.95, 1], scene)
}
if (gpsPoint) { if (gpsPoint) {
this.pushCircle(positions, colors, gpsPoint.x, gpsPoint.y, this.gpsLayer.getPulseRadius(pulseFrame), [0.13, 0.62, 0.74, 0.22], scene) this.pushCircle(positions, colors, gpsPoint.x, gpsPoint.y, this.gpsLayer.getPulseRadius(pulseFrame), [0.13, 0.62, 0.74, 0.22], scene)
this.pushCircle(positions, colors, gpsPoint.x, gpsPoint.y, 13, [1, 1, 1, 0.95], scene) this.pushCircle(positions, colors, gpsPoint.x, gpsPoint.y, 13, [1, 1, 1, 0.95], scene)

View File

@@ -31,7 +31,7 @@ type MapPageData = MapEngineViewState & {
showRightButtonGroups: boolean showRightButtonGroups: boolean
showBottomDebugButton: boolean showBottomDebugButton: boolean
} }
const INTERNAL_BUILD_VERSION = 'map-build-172' const INTERNAL_BUILD_VERSION = 'map-build-175'
const REMOTE_GAME_CONFIG_URL = 'https://oss-mbh5.colormaprun.com/wxmini/test/game.json' const REMOTE_GAME_CONFIG_URL = 'https://oss-mbh5.colormaprun.com/wxmini/test/game.json'
let mapEngine: MapEngine | null = null let mapEngine: MapEngine | null = null
function buildSideButtonVisibility(mode: SideButtonMode) { function buildSideButtonVisibility(mode: SideButtonMode) {
@@ -525,6 +525,12 @@ Page({
} }
}, },
handleClearMapTestArtifacts() {
if (mapEngine) {
mapEngine.handleClearMapTestArtifacts()
}
},
handleOverlayTouch() {}, handleOverlayTouch() {},
handlePunchAction() { handlePunchAction() {

View File

@@ -274,6 +274,9 @@
<view class="control-chip control-chip--primary" bindtap="handleRecenter">回到首屏</view> <view class="control-chip control-chip--primary" bindtap="handleRecenter">回到首屏</view>
<view class="control-chip control-chip--secondary" bindtap="handleRotationReset">旋转归零</view> <view class="control-chip control-chip--secondary" bindtap="handleRotationReset">旋转归零</view>
</view> </view>
<view class="control-row">
<view class="control-chip control-chip--secondary" bindtap="handleClearMapTestArtifacts">清空测试痕迹</view>
</view>
</view> </view>
<view class="debug-section"> <view class="debug-section">