chbim-time-axis-v2 0.0.19 → 0.0.192
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -12922,7 +12922,21 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
12922
12922
|
const handleRowMouseLeave = () => {
|
|
12923
12923
|
hoveredTaskId.value = null;
|
|
12924
12924
|
};
|
|
12925
|
-
const
|
|
12925
|
+
const getInitialTime = () => {
|
|
12926
|
+
var _a;
|
|
12927
|
+
const clock = props.clock || ((_a = props.viewer) == null ? void 0 : _a.clock);
|
|
12928
|
+
const Cesium2 = window.Cesium;
|
|
12929
|
+
if (clock && Cesium2) {
|
|
12930
|
+
try {
|
|
12931
|
+
const now = Cesium2.JulianDate.toDate(clock.currentTime);
|
|
12932
|
+
return dayjs(now).toISOString();
|
|
12933
|
+
} catch (e) {
|
|
12934
|
+
console.warn("Failed to init time from clock", e);
|
|
12935
|
+
}
|
|
12936
|
+
}
|
|
12937
|
+
return dayjs().toISOString();
|
|
12938
|
+
};
|
|
12939
|
+
const currentTime = ref(getInitialTime());
|
|
12926
12940
|
const viewStartTime = ref(dayjs().subtract(1, "month").valueOf());
|
|
12927
12941
|
const viewEndTime = ref(dayjs().add(1, "month").valueOf());
|
|
12928
12942
|
const scale = ref(DEFAULT_SCALE);
|
|
@@ -13634,10 +13648,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
13634
13648
|
};
|
|
13635
13649
|
}
|
|
13636
13650
|
});
|
|
13637
|
-
const
|
|
13638
|
-
const CesiumGantt = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
13651
|
+
const CesiumGantt_vue_vue_type_style_index_0_scoped_87a98505_lang = "";
|
|
13652
|
+
const CesiumGantt = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-87a98505"]]);
|
|
13639
13653
|
class ViewportRoam {
|
|
13640
|
-
constructor(viewer, data) {
|
|
13654
|
+
constructor(viewer, data, intervals) {
|
|
13641
13655
|
__publicField(this, "viewer");
|
|
13642
13656
|
__publicField(this, "positionProperty");
|
|
13643
13657
|
__publicField(this, "headingProperty");
|
|
@@ -13645,38 +13659,146 @@ class ViewportRoam {
|
|
|
13645
13659
|
__publicField(this, "rollProperty");
|
|
13646
13660
|
__publicField(this, "_onTick");
|
|
13647
13661
|
__publicField(this, "_isPlaying", false);
|
|
13662
|
+
__publicField(this, "validIntervals");
|
|
13648
13663
|
this.viewer = viewer;
|
|
13664
|
+
this.validIntervals = new Cesium.TimeIntervalCollection([]);
|
|
13649
13665
|
this.positionProperty = new Cesium.SampledPositionProperty();
|
|
13650
13666
|
this.headingProperty = new Cesium.SampledProperty(Number);
|
|
13651
13667
|
this.pitchProperty = new Cesium.SampledProperty(Number);
|
|
13652
13668
|
this.rollProperty = new Cesium.SampledProperty(Number);
|
|
13653
|
-
|
|
13654
|
-
interpolationDegree: 1,
|
|
13655
|
-
interpolationAlgorithm: Cesium.LinearApproximation
|
|
13656
|
-
});
|
|
13657
|
-
this.headingProperty.setInterpolationOptions({
|
|
13658
|
-
interpolationDegree: 1,
|
|
13659
|
-
interpolationAlgorithm: Cesium.LinearApproximation
|
|
13660
|
-
});
|
|
13661
|
-
this.pitchProperty.setInterpolationOptions({
|
|
13669
|
+
const interpolationOptions = {
|
|
13662
13670
|
interpolationDegree: 1,
|
|
13663
13671
|
interpolationAlgorithm: Cesium.LinearApproximation
|
|
13664
|
-
}
|
|
13665
|
-
this.
|
|
13666
|
-
|
|
13667
|
-
|
|
13668
|
-
|
|
13669
|
-
this.initData(data);
|
|
13672
|
+
};
|
|
13673
|
+
this.positionProperty.setInterpolationOptions(interpolationOptions);
|
|
13674
|
+
this.headingProperty.setInterpolationOptions(interpolationOptions);
|
|
13675
|
+
this.pitchProperty.setInterpolationOptions(interpolationOptions);
|
|
13676
|
+
this.rollProperty.setInterpolationOptions(interpolationOptions);
|
|
13670
13677
|
this._onTick = (clock) => {
|
|
13671
13678
|
const time = clock.currentTime;
|
|
13672
13679
|
this.updateCamera(time);
|
|
13673
13680
|
};
|
|
13681
|
+
if (data) {
|
|
13682
|
+
this.updateData(data, intervals);
|
|
13683
|
+
}
|
|
13684
|
+
}
|
|
13685
|
+
/**
|
|
13686
|
+
* 更新漫游数据
|
|
13687
|
+
* @param data 漫游点列表或任务列表
|
|
13688
|
+
* @param intervals 有效时间区间(仅当data为点列表时有效)
|
|
13689
|
+
*/
|
|
13690
|
+
updateData(data, intervals) {
|
|
13691
|
+
this.positionProperty = new Cesium.SampledPositionProperty();
|
|
13692
|
+
this.headingProperty = new Cesium.SampledProperty(Number);
|
|
13693
|
+
this.pitchProperty = new Cesium.SampledProperty(Number);
|
|
13694
|
+
this.rollProperty = new Cesium.SampledProperty(Number);
|
|
13695
|
+
const interpolationOptions = {
|
|
13696
|
+
interpolationDegree: 1,
|
|
13697
|
+
interpolationAlgorithm: Cesium.LinearApproximation
|
|
13698
|
+
};
|
|
13699
|
+
this.positionProperty.setInterpolationOptions(interpolationOptions);
|
|
13700
|
+
this.headingProperty.setInterpolationOptions(interpolationOptions);
|
|
13701
|
+
this.pitchProperty.setInterpolationOptions(interpolationOptions);
|
|
13702
|
+
this.rollProperty.setInterpolationOptions(interpolationOptions);
|
|
13703
|
+
this.validIntervals = new Cesium.TimeIntervalCollection([]);
|
|
13704
|
+
if (this.isRoamPointArray(data)) {
|
|
13705
|
+
this.initData(data);
|
|
13706
|
+
if (intervals) {
|
|
13707
|
+
intervals.forEach(
|
|
13708
|
+
(interval) => this.validIntervals.addInterval(interval)
|
|
13709
|
+
);
|
|
13710
|
+
}
|
|
13711
|
+
} else {
|
|
13712
|
+
const { points, intervals: taskIntervals } = this.parseTasks(data);
|
|
13713
|
+
this.initData(points);
|
|
13714
|
+
taskIntervals.forEach(
|
|
13715
|
+
(interval) => this.validIntervals.addInterval(interval)
|
|
13716
|
+
);
|
|
13717
|
+
}
|
|
13718
|
+
}
|
|
13719
|
+
isRoamPointArray(data) {
|
|
13720
|
+
return data.length > 0 && "lat" in data[0] && "lng" in data[0];
|
|
13721
|
+
}
|
|
13722
|
+
/**
|
|
13723
|
+
* 解析任务列表,提取漫游点和时间区间
|
|
13724
|
+
*/
|
|
13725
|
+
parseTasks(tasks) {
|
|
13726
|
+
const points = [];
|
|
13727
|
+
const intervals = [];
|
|
13728
|
+
const processRoamData = (roamData, startTime, endTime) => {
|
|
13729
|
+
if (!roamData || roamData.length === 0)
|
|
13730
|
+
return;
|
|
13731
|
+
const start = dayjs(startTime).valueOf();
|
|
13732
|
+
const end = dayjs(endTime).valueOf();
|
|
13733
|
+
const totalDuration = end - start;
|
|
13734
|
+
const hasSelfTime = roamData.every((item) => item.time);
|
|
13735
|
+
if (!hasSelfTime) {
|
|
13736
|
+
if (roamData.length === 1) {
|
|
13737
|
+
if (!roamData[0].time) {
|
|
13738
|
+
roamData[0].time = startTime;
|
|
13739
|
+
}
|
|
13740
|
+
} else {
|
|
13741
|
+
roamData.forEach((item, index) => {
|
|
13742
|
+
const progress = index / (roamData.length - 1);
|
|
13743
|
+
const time = start + totalDuration * progress;
|
|
13744
|
+
item.time = dayjs(time).toISOString();
|
|
13745
|
+
});
|
|
13746
|
+
}
|
|
13747
|
+
}
|
|
13748
|
+
points.push(...roamData);
|
|
13749
|
+
if (hasSelfTime && roamData.length > 0) {
|
|
13750
|
+
const firstTime = roamData[0].time;
|
|
13751
|
+
const lastTime = roamData[roamData.length - 1].time;
|
|
13752
|
+
intervals.push(
|
|
13753
|
+
new Cesium.TimeInterval({
|
|
13754
|
+
start: Cesium.JulianDate.fromIso8601(firstTime),
|
|
13755
|
+
stop: Cesium.JulianDate.fromIso8601(lastTime)
|
|
13756
|
+
})
|
|
13757
|
+
);
|
|
13758
|
+
} else {
|
|
13759
|
+
intervals.push(
|
|
13760
|
+
new Cesium.TimeInterval({
|
|
13761
|
+
start: Cesium.JulianDate.fromIso8601(startTime),
|
|
13762
|
+
stop: Cesium.JulianDate.fromIso8601(endTime)
|
|
13763
|
+
})
|
|
13764
|
+
);
|
|
13765
|
+
}
|
|
13766
|
+
};
|
|
13767
|
+
const traverse = (list) => {
|
|
13768
|
+
list.forEach((item) => {
|
|
13769
|
+
var _a;
|
|
13770
|
+
if (item.type === "group" && item.children) {
|
|
13771
|
+
traverse(item.children);
|
|
13772
|
+
} else {
|
|
13773
|
+
if (((_a = item.attr) == null ? void 0 : _a.roamData) && item.startTime && item.endTime) {
|
|
13774
|
+
processRoamData(item.attr.roamData, item.startTime, item.endTime);
|
|
13775
|
+
}
|
|
13776
|
+
if (item.blocks) {
|
|
13777
|
+
item.blocks.forEach((block) => {
|
|
13778
|
+
var _a2;
|
|
13779
|
+
if (((_a2 = block.attr) == null ? void 0 : _a2.roamData) && block.startTime && block.endTime) {
|
|
13780
|
+
processRoamData(
|
|
13781
|
+
block.attr.roamData,
|
|
13782
|
+
block.startTime,
|
|
13783
|
+
block.endTime
|
|
13784
|
+
);
|
|
13785
|
+
}
|
|
13786
|
+
});
|
|
13787
|
+
}
|
|
13788
|
+
}
|
|
13789
|
+
});
|
|
13790
|
+
};
|
|
13791
|
+
traverse(tasks);
|
|
13792
|
+
return { points, intervals };
|
|
13674
13793
|
}
|
|
13675
13794
|
initData(data) {
|
|
13676
13795
|
const sortedData = [...data].sort(
|
|
13677
13796
|
(a, b) => dayjs(a.time).valueOf() - dayjs(b.time).valueOf()
|
|
13678
13797
|
);
|
|
13798
|
+
let lastHeading;
|
|
13679
13799
|
sortedData.forEach((item) => {
|
|
13800
|
+
if (!item.time)
|
|
13801
|
+
return;
|
|
13680
13802
|
const time = Cesium.JulianDate.fromIso8601(item.time);
|
|
13681
13803
|
const position = Cesium.Cartesian3.fromDegrees(
|
|
13682
13804
|
item.lng,
|
|
@@ -13684,7 +13806,23 @@ class ViewportRoam {
|
|
|
13684
13806
|
item.alt
|
|
13685
13807
|
);
|
|
13686
13808
|
this.positionProperty.addSample(time, position);
|
|
13687
|
-
|
|
13809
|
+
let currentHeading = item.heading;
|
|
13810
|
+
if (lastHeading !== void 0) {
|
|
13811
|
+
let diff = currentHeading - lastHeading;
|
|
13812
|
+
while (diff > 180) {
|
|
13813
|
+
currentHeading -= 360;
|
|
13814
|
+
diff -= 360;
|
|
13815
|
+
}
|
|
13816
|
+
while (diff < -180) {
|
|
13817
|
+
currentHeading += 360;
|
|
13818
|
+
diff += 360;
|
|
13819
|
+
}
|
|
13820
|
+
}
|
|
13821
|
+
lastHeading = currentHeading;
|
|
13822
|
+
this.headingProperty.addSample(
|
|
13823
|
+
time,
|
|
13824
|
+
Cesium.Math.toRadians(currentHeading)
|
|
13825
|
+
);
|
|
13688
13826
|
this.pitchProperty.addSample(time, Cesium.Math.toRadians(item.pitch));
|
|
13689
13827
|
this.rollProperty.addSample(time, Cesium.Math.toRadians(item.roll || 0));
|
|
13690
13828
|
});
|
|
@@ -13712,6 +13850,9 @@ class ViewportRoam {
|
|
|
13712
13850
|
* @param time
|
|
13713
13851
|
*/
|
|
13714
13852
|
updateCamera(time) {
|
|
13853
|
+
if (this.validIntervals.length > 0 && !this.validIntervals.contains(time)) {
|
|
13854
|
+
return;
|
|
13855
|
+
}
|
|
13715
13856
|
const position = this.positionProperty.getValue(time);
|
|
13716
13857
|
const heading = this.headingProperty.getValue(time);
|
|
13717
13858
|
const pitch = this.pitchProperty.getValue(time);
|