Skip to content

Commit

Permalink
Merge pull request #187 from Drangeer/track
Browse files Browse the repository at this point in the history
Track
  • Loading branch information
cavencj authored Jun 6, 2024
2 parents 74f0655 + 99a9dfd commit 595d62f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/modules/history-track/Track.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ class Track {
)
this._state = State.INITIALIZED
}
get currentDistance() {
return distance(Parse.parsePositions(this._pathPositions))
}
get currentPosition() {
const [pos] = this._pathPositions.slice(-1)
return Parse.parsePosition(pos)
}
get allDistance() {
return distance(this._positions)
}

get trackId() {
return this._id
Expand Down Expand Up @@ -217,12 +227,27 @@ class Track {
this._positionIndex + 1 === this._positions.length
)
this._positionIndex++
// 无限循环
if (
this._options.loop &&
this._positionIndex === this._positions.length
) {
this._restart()
}
}
}
}
this._setCameraView(viewer, viewOption)
}

/**
* 重头开始播放动画
*/
_restart() {
this._startTime = Cesium.JulianDate.now()
this._resetTimeLine({})
}

/**
* Sets camera position
* @param viewer
Expand Down
2 changes: 2 additions & 0 deletions src/modules/history-track/TrackController.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ class TrackController {
this._activedTrack && (this._activedTrack.viewed = false)
this._activedTrack = undefined
this._viewer.off(SceneEventType.POST_RENDER, this._onPostRender, this)
this._viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY)
this._viewer.delegate.trackedEntity = undefined
return this
}
}
Expand Down

0 comments on commit 595d62f

Please sign in to comment.