This commit is contained in:
zh
2025-07-17 17:47:43 +08:00
5 changed files with 290 additions and 32 deletions

View File

@ -61,6 +61,10 @@ export default class Sunshine {
set darkness(v) {
this.options.darkness = v
this.viewer.shadowMap.darkness = 1.0 - this.options.darkness
this._elms.darkness &&
this._elms.darkness.forEach(item => {
item.value = v
})
}
get speed() {
@ -101,14 +105,14 @@ export default class Sunshine {
let _this = this
this._DialogObject = await new Dialog(this.sdk, this.originalOptions, {
title: '光照属性', left: '180px', top: '100px',
confirmCallBack: (options) => {
this.originalOptions = tools.deepCopyObj(this.options)
this._DialogObject.close()
this.Dialog.confirmCallBack && this.Dialog.confirmCallBack(this.originalOptions)
syncData(this.sdk, this.options.id)
syncSplitData(this.sdk, this.options.id)
this.remove()
},
// confirmCallBack: (options) => {
// this.originalOptions = tools.deepCopyObj(this.options)
// this._DialogObject.close()
// this.Dialog.confirmCallBack && this.Dialog.confirmCallBack(this.originalOptions)
// syncData(this.sdk, this.options.id)
// syncSplitData(this.sdk, this.options.id)
// this.remove()
// },
resetCallBack: () => {
this.reset()
this.Dialog.resetCallBack && this.Dialog.resetCallBack()

View File

@ -3,7 +3,8 @@ export default class TimeLine {
this.sdk = { ...sdk };
this.progress = document.getElementById('progress');
this.handle = document.getElementById('handle');
this.timeline = document.getElementById('timeline');
// this.timeline = document.getElementById('timeline');
this.timeline = document.getElementsByClassName('timeline-container')[0];
this.currentTime = document.getElementById('currentTime');
this.timelineCon = document.getElementsByClassName('timeline-container')[0];
this.speed = speed;
@ -53,17 +54,25 @@ export default class TimeLine {
document.getElementById('timePause').addEventListener('click', function () {
that.pauseed = !that.pauseed;
if (that.pauseed) {
if (that.pauseed) {//暂停
document.getElementById('timePause').textContent = '播放';
that.animationId && cancelAnimationFrame(that.animationId);
that.pausedTime = Date.now(); // 记录暂停时刻
that.sdk.viewer.clock.shouldAnimate = false
} else {
} else {//播放
document.getElementById('timePause').textContent = '暂停';
that.manualPosition = null
const pausedDuration = Date.now() - that.pausedTime;
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.update(); // 重启动画循环
}
@ -77,7 +86,7 @@ export default class TimeLine {
// that.sdk.viewer.clock.shouldAnimate = true
that.startTime = Date.now() - (that.manualPosition * 86400 * 1000 / that.speed);
that.manualPosition = null;
that.changeDate && (that.changeDateGrag = true)
if (!that.pauseed) {
that.update()
func(that.time)
@ -98,30 +107,55 @@ export default class TimeLine {
update() {
if (this.manualPosition !== null) return;
const elapsed = (Date.now() - this.startTime) * this.speed;
const totalSeconds = elapsed / 1000;
const daySeconds = totalSeconds % 86400;
if (this.changeDate) {//切换日期后让时间从0开始
this.startTime = Date.now()
}
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;
this.progress.style.width = `${percentage * 100}%`;
this.time = this.formatTime(daySeconds)
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) {
const currentProgress = this.manualPosition ??
(Date.now() - this.startTime) * this.speed / (86400 * 1000);
if (!this.pauseed) {
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;
this.startTime = Date.now() - (currentProgress * 86400 * 1000 / this.speed);
} else {
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.update();
// this.update();
}
updateTime() {
this.startTime = Date.now() - (this.manualPosition * 86400 * 1000 / this.speed);
this.manualPosition = null;
this.startTime = Date.now() - ((this.manualPosition || 0) * 86400 * 1000 / this.speed);
this.pauseed && (this.changeDate = true)
this.changeDateGrag = undefined
this.update();
}
clear() {

View File

@ -89,6 +89,7 @@ class FlowLine extends Base {
const minLat = Math.min(...lats), maxLat = Math.max(...lats);
const points = [];
let that = this
while (points.length < count) {
const lon = minLon + Math.random() * (maxLon - minLon);
const lat = minLat + Math.random() * (maxLat - minLat);
@ -100,9 +101,14 @@ class FlowLine extends Base {
const isInside = turf.booleanPointInPolygon(point, polygon);
if (isInside) {
let posi = Cesium.Cartesian3.fromDegrees(lon, lat);
const cartographic = that.viewer.scene.globe.ellipsoid.cartesianToCartographic(posi);
const height = cartographic.height;
points.push([
lon,
lat
lat,
height
]);
}
}
@ -126,15 +132,16 @@ class FlowLine extends Base {
positions.forEach((item, index) => {
let point = item
//根据点设置起始点位置
let start = Cesium.Cartesian3.fromDegrees(point[0], point[1], 0)
// let start = Cesium.Cartesian3.fromDegrees(point[0], point[1], 0)
let start = Cesium.Cartesian3.fromDegrees(point[0], point[1], point[2])
//根据点设置结束点位置
let end = Cesium.Cartesian3.fromDegrees(point[0], point[1], that.options.height + Math.random() * that.options.heightDifference)
let end = Cesium.Cartesian3.fromDegrees(point[0], point[1], point[2] + that.options.height + Math.random() * that.options.heightDifference)
//创建线
that.viewer.entities.add({
parent: celiangEntity,
polyline: {
positions: [start, end],
width: 2,
width: that.options.width,
// material:Cesium.Color.RED
material: new Cesium.FlowLineMaterialProperty({
color: that.options.color,
@ -425,7 +432,7 @@ class FlowLine extends Base {
let a = Cesium.Cartesian3.fromDegrees(
this.positions[i][0],
this.positions[i][1],
this.options.height + this.options.heightDifference / 2
this.positions[i][2] + this.options.height + this.options.heightDifference / 2
)
positionArray.push(a.x, a.y, a.z)
}

View File

@ -61,7 +61,7 @@ class EventBinding {
if ((e.target.min) && value < Number(e.target.min)) {
value = Number(e.target.min)
}
if((e.target.dataset.min) && value<Number(e.target.dataset.min)) {
if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) {
value = Number(e.target.dataset.min)
}
}
@ -121,4 +121,4 @@ class EventBinding {
}
}
export default EventBinding;
export default EventBinding;