修改光照分析切换日期 进度条bug 和 修改速度 进度条bug
This commit is contained in:
@ -53,17 +53,25 @@ export default class TimeLine {
|
|||||||
|
|
||||||
document.getElementById('timePause').addEventListener('click', function () {
|
document.getElementById('timePause').addEventListener('click', function () {
|
||||||
that.pauseed = !that.pauseed;
|
that.pauseed = !that.pauseed;
|
||||||
if (that.pauseed) {
|
if (that.pauseed) {//暂停
|
||||||
document.getElementById('timePause').textContent = '播放';
|
document.getElementById('timePause').textContent = '播放';
|
||||||
that.animationId && cancelAnimationFrame(that.animationId);
|
that.animationId && cancelAnimationFrame(that.animationId);
|
||||||
that.pausedTime = Date.now(); // 记录暂停时刻
|
that.pausedTime = Date.now(); // 记录暂停时刻
|
||||||
that.sdk.viewer.clock.shouldAnimate = false
|
that.sdk.viewer.clock.shouldAnimate = false
|
||||||
} else {
|
} else {//播放
|
||||||
document.getElementById('timePause').textContent = '暂停';
|
document.getElementById('timePause').textContent = '暂停';
|
||||||
that.manualPosition = null
|
that.manualPosition = null
|
||||||
|
|
||||||
const pausedDuration = Date.now() - that.pausedTime;
|
const pausedDuration = Date.now() - that.pausedTime;
|
||||||
that.startTime += pausedDuration; // 补偿暂停期间的时间差
|
that.startTime += pausedDuration; // 补偿暂停期间的时间差
|
||||||
|
|
||||||
|
if (that.changeDate) {//切换日期后让时间从0开始
|
||||||
|
if (that.changeDateGrag) {
|
||||||
|
that.changeDateGrag = undefined
|
||||||
|
} else {
|
||||||
|
that.startTime = Date.now()
|
||||||
|
}
|
||||||
|
that.changeDate = undefined
|
||||||
|
}
|
||||||
that.sdk.viewer.clock.shouldAnimate = true
|
that.sdk.viewer.clock.shouldAnimate = true
|
||||||
that.update(); // 重启动画循环
|
that.update(); // 重启动画循环
|
||||||
}
|
}
|
||||||
@ -77,7 +85,7 @@ export default class TimeLine {
|
|||||||
// that.sdk.viewer.clock.shouldAnimate = true
|
// that.sdk.viewer.clock.shouldAnimate = true
|
||||||
that.startTime = Date.now() - (that.manualPosition * 86400 * 1000 / that.speed);
|
that.startTime = Date.now() - (that.manualPosition * 86400 * 1000 / that.speed);
|
||||||
that.manualPosition = null;
|
that.manualPosition = null;
|
||||||
|
that.changeDate && (that.changeDateGrag = true)
|
||||||
if (!that.pauseed) {
|
if (!that.pauseed) {
|
||||||
that.update()
|
that.update()
|
||||||
func(that.time)
|
func(that.time)
|
||||||
@ -98,30 +106,55 @@ export default class TimeLine {
|
|||||||
|
|
||||||
update() {
|
update() {
|
||||||
if (this.manualPosition !== null) return;
|
if (this.manualPosition !== null) return;
|
||||||
|
if (this.changeDate) {//切换日期后让时间从0开始
|
||||||
const elapsed = (Date.now() - this.startTime) * this.speed;
|
this.startTime = Date.now()
|
||||||
const totalSeconds = elapsed / 1000;
|
}
|
||||||
const daySeconds = totalSeconds % 86400;
|
let elapsed = (Date.now() - this.startTime) * this.speed;
|
||||||
|
// if (this.elapsed) {
|
||||||
|
// elapsed = elapsed + this.elapsed
|
||||||
|
// this.elapsed = undefined
|
||||||
|
// }
|
||||||
|
const totalSeconds = elapsed / 1000;//秒
|
||||||
|
const daySeconds = totalSeconds % 86400;//天
|
||||||
const percentage = daySeconds / 86400;
|
const percentage = daySeconds / 86400;
|
||||||
|
|
||||||
this.progress.style.width = `${percentage * 100}%`;
|
this.progress.style.width = `${percentage * 100}%`;
|
||||||
this.time = this.formatTime(daySeconds)
|
this.time = this.formatTime(daySeconds)
|
||||||
this.currentTime.textContent = this.time;
|
this.currentTime.textContent = this.time;
|
||||||
this.animationId = requestAnimationFrame(this.update);
|
if (!this.pauseed) {
|
||||||
|
this.animationId && cancelAnimationFrame(this.animationId);
|
||||||
|
this.animationId = requestAnimationFrame(this.update);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setSpeed(v) {
|
setSpeed(v) {
|
||||||
const currentProgress = this.manualPosition ??
|
if (!this.pauseed) {
|
||||||
(Date.now() - this.startTime) * this.speed / (86400 * 1000);
|
const currentProgress = this.manualPosition ??
|
||||||
|
(Date.now() - this.startTime) * this.speed / (86400 * 1000);
|
||||||
|
this.speed = v;
|
||||||
|
this.startTime = Date.now() - (currentProgress * 86400 * 1000 / this.speed);
|
||||||
|
|
||||||
this.speed = v;
|
} else {
|
||||||
this.startTime = Date.now() - (currentProgress * 86400 * 1000 / this.speed);
|
let pausedDuration = Date.now() - this.pausedTime;
|
||||||
|
this.startTime += pausedDuration; // 补偿暂停期间的时间差
|
||||||
|
|
||||||
|
const currentProgress = this.manualPosition ??
|
||||||
|
(Date.now() - this.startTime) * this.speed / (86400 * 1000);
|
||||||
|
this.speed = v;
|
||||||
|
this.startTime = Date.now() - (currentProgress * 86400 * 1000 / this.speed);
|
||||||
|
|
||||||
|
this.pausedTime = Date.now(); // 记录切换speed暂停时刻
|
||||||
|
this.speed = v;
|
||||||
|
}
|
||||||
this.manualPosition = null;
|
this.manualPosition = null;
|
||||||
this.update();
|
|
||||||
|
// this.update();
|
||||||
|
|
||||||
}
|
}
|
||||||
updateTime() {
|
updateTime() {
|
||||||
this.startTime = Date.now() - (this.manualPosition * 86400 * 1000 / this.speed);
|
|
||||||
this.manualPosition = null;
|
this.manualPosition = null;
|
||||||
|
this.startTime = Date.now() - ((this.manualPosition || 0) * 86400 * 1000 / this.speed);
|
||||||
|
this.pauseed && (this.changeDate = true)
|
||||||
|
this.changeDateGrag = undefined
|
||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
clear() {
|
clear() {
|
||||||
|
Reference in New Issue
Block a user