Browse Source

Refine GPS trace cleanup and marker rendering

zhangyan 2 weeks ago
parent
commit
71ad6c6535

+ 31 - 1
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,

+ 0 - 5
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)

+ 7 - 1
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() {

+ 3 - 0
miniprogram/pages/map/map.wxml

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