光照分析联动
This commit is contained in:
@ -245,7 +245,6 @@ onMounted(() => {
|
|||||||
weatherData.currWeather = false
|
weatherData.currWeather = false
|
||||||
sunshine.timeBar = item
|
sunshine.timeBar = item
|
||||||
})
|
})
|
||||||
console.log(timeline, 'klklkl')
|
|
||||||
// timeline.updateTime()
|
// timeline.updateTime()
|
||||||
// timeline.setCurrBar()
|
// timeline.setCurrBar()
|
||||||
})
|
})
|
||||||
@ -254,15 +253,39 @@ onBeforeUnmount(() => {
|
|||||||
sunshine && sunshine.remove()
|
sunshine && sunshine.remove()
|
||||||
timeline && timeline.clear()
|
timeline && timeline.clear()
|
||||||
})
|
})
|
||||||
|
let currWeatherData = false
|
||||||
var weatherChange = () => {
|
var weatherChange = () => {
|
||||||
|
currWeatherData = true
|
||||||
if (weatherData.currWeather) {
|
if (weatherData.currWeather) {
|
||||||
let ss = getCurrentTime()
|
let ss = getCurrentTime()
|
||||||
sunshine.timeBar = ss
|
sunshine && (sunshine.timeBar = ss)
|
||||||
weatherData.speed = 1
|
weatherData.speed = 1
|
||||||
sunshine && (sunshine.speed = weatherData.speed)
|
sunshine && (sunshine.speed = weatherData.speed)
|
||||||
|
|
||||||
|
timeline.setCurrBar()
|
||||||
|
|
||||||
timeline.setSpeed(weatherData.speed)
|
timeline.setSpeed(weatherData.speed)
|
||||||
|
|
||||||
|
//让日期回到当前时间
|
||||||
|
|
||||||
|
weatherData.time = getDateTimeString()
|
||||||
|
timeline.closeChangeDate()
|
||||||
|
|
||||||
|
// sunshine && (sunshine.time = weatherData.time)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var getDateTimeString = () => {
|
||||||
|
// 创建一个表示当前时间的 Date 对象
|
||||||
|
const now = new Date()
|
||||||
|
// 获取年份
|
||||||
|
const year = now.getFullYear()
|
||||||
|
// 获取月份(从 0 开始,所以要加 1),并将其转换为两位字符串,不足两位在前面补零
|
||||||
|
const month = String(now.getMonth() + 1).padStart(2, '0')
|
||||||
|
// 获取日期,并将其转换为两位字符串,不足两位在前面补零
|
||||||
|
const day = String(now.getDate()).padStart(2, '0')
|
||||||
|
// 获取小时,并将其转换为两位字符串,不足两位在前面补零
|
||||||
|
return `${year}-${month}-${day}`
|
||||||
|
}
|
||||||
watch(
|
watch(
|
||||||
() => weatherData.darkness,
|
() => weatherData.darkness,
|
||||||
(newValue) => {
|
(newValue) => {
|
||||||
@ -287,7 +310,11 @@ var decrementValue = () => {
|
|||||||
watch(
|
watch(
|
||||||
() => weatherData.speed,
|
() => weatherData.speed,
|
||||||
(newValue) => {
|
(newValue) => {
|
||||||
|
if (!currWeatherData) {
|
||||||
weatherData.currWeather = false
|
weatherData.currWeather = false
|
||||||
|
} else {
|
||||||
|
currWeatherData = false
|
||||||
|
}
|
||||||
sunshine && (sunshine.speed = newValue)
|
sunshine && (sunshine.speed = newValue)
|
||||||
timeline.setSpeed(newValue)
|
timeline.setSpeed(newValue)
|
||||||
}
|
}
|
||||||
@ -322,8 +349,8 @@ var switchFunc = () => {
|
|||||||
//关闭
|
//关闭
|
||||||
sunshine && sunshine.remove()
|
sunshine && sunshine.remove()
|
||||||
sunshine = null
|
sunshine = null
|
||||||
let timeData = now.setHours(0, 0, 0, 0) // 设置为当天0点
|
// let timeData = now.setHours(0, 0, 0, 0) // 设置为当天0点
|
||||||
timeline.updateTime(timeData)
|
// timeline.updateTime(timeData)
|
||||||
timeline.setSunShine(false)
|
timeline.setSunShine(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -360,7 +387,6 @@ var clickIcon = (item: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var changDarkness = () => {
|
var changDarkness = () => {
|
||||||
console.log('changDarkness')
|
|
||||||
sunshine && (sunshine.darkness = weatherData.darkness)
|
sunshine && (sunshine.darkness = weatherData.darkness)
|
||||||
}
|
}
|
||||||
var changSpeed = () => {
|
var changSpeed = () => {
|
||||||
@ -373,6 +399,7 @@ var weatherTimeChange = () => {
|
|||||||
let timeData = now.setHours(0, 0, 0, 0) // 设置为当天0点
|
let timeData = now.setHours(0, 0, 0, 0) // 设置为当天0点
|
||||||
timeline.updateTime(timeData)
|
timeline.updateTime(timeData)
|
||||||
sunshine && (sunshine.time = weatherData.time)
|
sunshine && (sunshine.time = weatherData.time)
|
||||||
|
weatherData.currWeather = false
|
||||||
}
|
}
|
||||||
|
|
||||||
var onClose = () => {}
|
var onClose = () => {}
|
||||||
|
|||||||
@ -179,7 +179,6 @@ export default class TimeLine {
|
|||||||
if (this.changeDate) {//切换日期后让时间从0开始
|
if (this.changeDate) {//切换日期后让时间从0开始
|
||||||
this.startTime = performance.now()
|
this.startTime = performance.now()
|
||||||
}
|
}
|
||||||
|
|
||||||
let elapsed = (performance.now() - this.startTime) * this.speed;
|
let elapsed = (performance.now() - this.startTime) * this.speed;
|
||||||
// if (this.elapsed) {
|
// if (this.elapsed) {
|
||||||
// elapsed = elapsed + this.elapsed
|
// elapsed = elapsed + this.elapsed
|
||||||
@ -217,10 +216,12 @@ export default class TimeLine {
|
|||||||
// this.speed = v;
|
// this.speed = v;
|
||||||
}
|
}
|
||||||
this.manualPosition = null;
|
this.manualPosition = null;
|
||||||
|
|
||||||
// this.update();
|
// this.update();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
closeChangeDate() {
|
||||||
|
this.changeDate && (this.changeDate = false)
|
||||||
|
}
|
||||||
updateTime() {
|
updateTime() {
|
||||||
this.manualPosition = null;
|
this.manualPosition = null;
|
||||||
this.startTime = performance.now() - ((this.manualPosition || 0) * 86400 * 1000 / this.speed);
|
this.startTime = performance.now() - ((this.manualPosition || 0) * 86400 * 1000 / this.speed);
|
||||||
|
|||||||
Reference in New Issue
Block a user