From 71ad6c653586576f88f500017ae4d462d66921e6 Mon Sep 17 00:00:00 2001 From: zhangyan Date: Tue, 24 Mar 2026 14:40:34 +0800 Subject: [PATCH] Refine GPS trace cleanup and marker rendering --- miniprogram/engine/map/mapEngine.ts | 32 ++++++++++++++++++- .../engine/renderer/webglVectorRenderer.ts | 5 --- miniprogram/pages/map/map.ts | 8 ++++- miniprogram/pages/map/map.wxml | 3 ++ 4 files changed, 41 insertions(+), 7 deletions(-) diff --git a/miniprogram/engine/map/mapEngine.ts b/miniprogram/engine/map/mapEngine.ts index 82bc560..54dfd8c 100644 --- a/miniprogram/engine/map/mapEngine.ts +++ b/miniprogram/engine/map/mapEngine.ts @@ -552,6 +552,7 @@ export class MapEngine { currentGpsTrack: LonLatPoint[] currentGpsAccuracyMeters: number | null courseData: OrienteeringCourseData | null + courseOverlayVisible: boolean cpRadiusMeters: number gameRuntime: GameRuntime telemetryRuntime: TelemetryRuntime @@ -674,6 +675,7 @@ export class MapEngine { this.currentGpsTrack = [] this.currentGpsAccuracyMeters = null this.courseData = null + this.courseOverlayVisible = false this.cpRadiusMeters = 5 this.gameRuntime = new GameRuntime() this.telemetryRuntime = new TelemetryRuntime() @@ -851,10 +853,30 @@ export class MapEngine { this.gameRuntime.clear() this.telemetryRuntime.reset() this.gamePresentation = EMPTY_GAME_PRESENTATION_STATE + this.courseOverlayVisible = !!this.courseData this.clearSessionTimerInterval() 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 { return this.gamePresentation.hud.hudTargetControlId } @@ -894,6 +916,7 @@ export class MapEngine { const result = this.gameRuntime.loadDefinition(definition) this.telemetryRuntime.loadDefinition(definition) this.gamePresentation = result.presentation + this.courseOverlayVisible = true this.telemetryRuntime.syncGameState(this.gameRuntime.definition, result.nextState, this.getHudTargetControlId()) this.refreshCourseHeadingFromPresentation() this.updateSessionTimerLoop() @@ -1172,6 +1195,12 @@ export class MapEngine { applyGameEffects(effects: GameEffect[]): string | null { 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.updateSessionTimerLoop() return this.resolveGameStatusText(effects) @@ -1206,6 +1235,7 @@ export class MapEngine { } this.gamePresentation = this.gameRuntime.getPresentation() + this.courseOverlayVisible = true this.refreshCourseHeadingFromPresentation() const defaultStatusText = this.currentGpsPoint ? `顺序打点已开始 (${this.buildVersion})` @@ -2250,7 +2280,7 @@ export class MapEngine { gpsPoint: this.currentGpsPoint, gpsCalibration: GPS_MAP_CALIBRATION, gpsCalibrationOrigin: worldTileToLonLat({ x: this.defaultCenterTileX, y: this.defaultCenterTileY }, this.defaultZoom), - course: this.courseData, + course: this.courseOverlayVisible ? this.courseData : null, cpRadiusMeters: this.cpRadiusMeters, controlVisualMode: this.gamePresentation.map.controlVisualMode, showCourseLegs: this.gamePresentation.map.showCourseLegs, diff --git a/miniprogram/engine/renderer/webglVectorRenderer.ts b/miniprogram/engine/renderer/webglVectorRenderer.ts index bb6bc90..d77ee0a 100644 --- a/miniprogram/engine/renderer/webglVectorRenderer.ts +++ b/miniprogram/engine/renderer/webglVectorRenderer.ts @@ -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) } - 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) { 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) diff --git a/miniprogram/pages/map/map.ts b/miniprogram/pages/map/map.ts index 9d85833..d52aae0 100644 --- a/miniprogram/pages/map/map.ts +++ b/miniprogram/pages/map/map.ts @@ -31,7 +31,7 @@ type MapPageData = MapEngineViewState & { showRightButtonGroups: 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' let mapEngine: MapEngine | null = null function buildSideButtonVisibility(mode: SideButtonMode) { @@ -525,6 +525,12 @@ Page({ } }, + handleClearMapTestArtifacts() { + if (mapEngine) { + mapEngine.handleClearMapTestArtifacts() + } + }, + handleOverlayTouch() {}, handlePunchAction() { diff --git a/miniprogram/pages/map/map.wxml b/miniprogram/pages/map/map.wxml index 080b760..b860cb3 100644 --- a/miniprogram/pages/map/map.wxml +++ b/miniprogram/pages/map/map.wxml @@ -274,6 +274,9 @@ 回到首屏 旋转归零 + + 清空测试痕迹 +