chbim-time-axis-v2 0.0.18 → 0.0.191
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.
|
@@ -5,6 +5,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
7
|
import { watch, toValue as toValue$1, computed, unref, reactive, shallowRef, ref, getCurrentScope, onScopeDispose, shallowReadonly, defineComponent, mergeDefaults, useSlots, useTemplateRef, openBlock, createBlock, createSlots, renderList, withCtx, renderSlot, normalizeProps, guardReactiveProps, provide, readonly, toRef, onMounted, nextTick, onUnmounted, createElementBlock, normalizeClass, createVNode, Teleport, createElementVNode, normalizeStyle, Transition, createCommentVNode, inject, withModifiers, Fragment, toDisplayString, resolveDynamicComponent, h, mergeProps, createTextVNode, onBeforeUpdate, withDirectives, vShow, withKeys, createStaticVNode } from "vue";
|
|
8
|
+
import * as Cesium from "cesium";
|
|
8
9
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
9
10
|
function getDefaultExportFromCjs(x) {
|
|
10
11
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
@@ -13137,10 +13138,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
13137
13138
|
if (clock) {
|
|
13138
13139
|
isPlaying.value = clock.shouldAnimate;
|
|
13139
13140
|
const onTick = () => {
|
|
13140
|
-
const
|
|
13141
|
-
if (!
|
|
13141
|
+
const Cesium2 = window.Cesium;
|
|
13142
|
+
if (!Cesium2)
|
|
13142
13143
|
return;
|
|
13143
|
-
const now =
|
|
13144
|
+
const now = Cesium2.JulianDate.toDate(clock.currentTime);
|
|
13144
13145
|
currentTime.value = dayjs(now).toISOString();
|
|
13145
13146
|
if (isPlaying.value !== clock.shouldAnimate) {
|
|
13146
13147
|
isPlaying.value = clock.shouldAnimate;
|
|
@@ -13405,9 +13406,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
13405
13406
|
const handleTimeUpdate = (newTime) => {
|
|
13406
13407
|
currentTime.value = newTime;
|
|
13407
13408
|
const clock = targetClock.value;
|
|
13408
|
-
const
|
|
13409
|
-
if (clock &&
|
|
13410
|
-
clock.currentTime =
|
|
13409
|
+
const Cesium2 = window.Cesium;
|
|
13410
|
+
if (clock && Cesium2) {
|
|
13411
|
+
clock.currentTime = Cesium2.JulianDate.fromIso8601(newTime);
|
|
13411
13412
|
}
|
|
13412
13413
|
};
|
|
13413
13414
|
const toggleMaximize = () => {
|
|
@@ -13635,10 +13636,236 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
13635
13636
|
});
|
|
13636
13637
|
const CesiumGantt_vue_vue_type_style_index_0_scoped_bc47a9ac_lang = "";
|
|
13637
13638
|
const CesiumGantt = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-bc47a9ac"]]);
|
|
13639
|
+
class ViewportRoam {
|
|
13640
|
+
constructor(viewer, data, intervals) {
|
|
13641
|
+
__publicField(this, "viewer");
|
|
13642
|
+
__publicField(this, "positionProperty");
|
|
13643
|
+
__publicField(this, "headingProperty");
|
|
13644
|
+
__publicField(this, "pitchProperty");
|
|
13645
|
+
__publicField(this, "rollProperty");
|
|
13646
|
+
__publicField(this, "_onTick");
|
|
13647
|
+
__publicField(this, "_isPlaying", false);
|
|
13648
|
+
__publicField(this, "validIntervals");
|
|
13649
|
+
this.viewer = viewer;
|
|
13650
|
+
this.validIntervals = new Cesium.TimeIntervalCollection([]);
|
|
13651
|
+
this.positionProperty = new Cesium.SampledPositionProperty();
|
|
13652
|
+
this.headingProperty = new Cesium.SampledProperty(Number);
|
|
13653
|
+
this.pitchProperty = new Cesium.SampledProperty(Number);
|
|
13654
|
+
this.rollProperty = new Cesium.SampledProperty(Number);
|
|
13655
|
+
const interpolationOptions = {
|
|
13656
|
+
interpolationDegree: 1,
|
|
13657
|
+
interpolationAlgorithm: Cesium.LinearApproximation
|
|
13658
|
+
};
|
|
13659
|
+
this.positionProperty.setInterpolationOptions(interpolationOptions);
|
|
13660
|
+
this.headingProperty.setInterpolationOptions(interpolationOptions);
|
|
13661
|
+
this.pitchProperty.setInterpolationOptions(interpolationOptions);
|
|
13662
|
+
this.rollProperty.setInterpolationOptions(interpolationOptions);
|
|
13663
|
+
this._onTick = (clock) => {
|
|
13664
|
+
const time = clock.currentTime;
|
|
13665
|
+
this.updateCamera(time);
|
|
13666
|
+
};
|
|
13667
|
+
if (data) {
|
|
13668
|
+
this.updateData(data, intervals);
|
|
13669
|
+
}
|
|
13670
|
+
}
|
|
13671
|
+
/**
|
|
13672
|
+
* 更新漫游数据
|
|
13673
|
+
* @param data 漫游点列表或任务列表
|
|
13674
|
+
* @param intervals 有效时间区间(仅当data为点列表时有效)
|
|
13675
|
+
*/
|
|
13676
|
+
updateData(data, intervals) {
|
|
13677
|
+
this.positionProperty = new Cesium.SampledPositionProperty();
|
|
13678
|
+
this.headingProperty = new Cesium.SampledProperty(Number);
|
|
13679
|
+
this.pitchProperty = new Cesium.SampledProperty(Number);
|
|
13680
|
+
this.rollProperty = new Cesium.SampledProperty(Number);
|
|
13681
|
+
const interpolationOptions = {
|
|
13682
|
+
interpolationDegree: 1,
|
|
13683
|
+
interpolationAlgorithm: Cesium.LinearApproximation
|
|
13684
|
+
};
|
|
13685
|
+
this.positionProperty.setInterpolationOptions(interpolationOptions);
|
|
13686
|
+
this.headingProperty.setInterpolationOptions(interpolationOptions);
|
|
13687
|
+
this.pitchProperty.setInterpolationOptions(interpolationOptions);
|
|
13688
|
+
this.rollProperty.setInterpolationOptions(interpolationOptions);
|
|
13689
|
+
this.validIntervals = new Cesium.TimeIntervalCollection([]);
|
|
13690
|
+
if (this.isRoamPointArray(data)) {
|
|
13691
|
+
this.initData(data);
|
|
13692
|
+
if (intervals) {
|
|
13693
|
+
intervals.forEach(
|
|
13694
|
+
(interval) => this.validIntervals.addInterval(interval)
|
|
13695
|
+
);
|
|
13696
|
+
}
|
|
13697
|
+
} else {
|
|
13698
|
+
const { points, intervals: taskIntervals } = this.parseTasks(data);
|
|
13699
|
+
this.initData(points);
|
|
13700
|
+
taskIntervals.forEach(
|
|
13701
|
+
(interval) => this.validIntervals.addInterval(interval)
|
|
13702
|
+
);
|
|
13703
|
+
}
|
|
13704
|
+
}
|
|
13705
|
+
isRoamPointArray(data) {
|
|
13706
|
+
return data.length > 0 && "lat" in data[0] && "lng" in data[0];
|
|
13707
|
+
}
|
|
13708
|
+
/**
|
|
13709
|
+
* 解析任务列表,提取漫游点和时间区间
|
|
13710
|
+
*/
|
|
13711
|
+
parseTasks(tasks) {
|
|
13712
|
+
const points = [];
|
|
13713
|
+
const intervals = [];
|
|
13714
|
+
const processRoamData = (roamData, startTime, endTime) => {
|
|
13715
|
+
if (!roamData || roamData.length === 0)
|
|
13716
|
+
return;
|
|
13717
|
+
const start = dayjs(startTime).valueOf();
|
|
13718
|
+
const end = dayjs(endTime).valueOf();
|
|
13719
|
+
const totalDuration = end - start;
|
|
13720
|
+
const hasSelfTime = roamData.every((item) => item.time);
|
|
13721
|
+
if (!hasSelfTime) {
|
|
13722
|
+
if (roamData.length === 1) {
|
|
13723
|
+
if (!roamData[0].time) {
|
|
13724
|
+
roamData[0].time = startTime;
|
|
13725
|
+
}
|
|
13726
|
+
} else {
|
|
13727
|
+
roamData.forEach((item, index) => {
|
|
13728
|
+
const progress = index / (roamData.length - 1);
|
|
13729
|
+
const time = start + totalDuration * progress;
|
|
13730
|
+
item.time = dayjs(time).toISOString();
|
|
13731
|
+
});
|
|
13732
|
+
}
|
|
13733
|
+
}
|
|
13734
|
+
points.push(...roamData);
|
|
13735
|
+
if (hasSelfTime && roamData.length > 0) {
|
|
13736
|
+
const firstTime = roamData[0].time;
|
|
13737
|
+
const lastTime = roamData[roamData.length - 1].time;
|
|
13738
|
+
intervals.push(
|
|
13739
|
+
new Cesium.TimeInterval({
|
|
13740
|
+
start: Cesium.JulianDate.fromIso8601(firstTime),
|
|
13741
|
+
stop: Cesium.JulianDate.fromIso8601(lastTime)
|
|
13742
|
+
})
|
|
13743
|
+
);
|
|
13744
|
+
} else {
|
|
13745
|
+
intervals.push(
|
|
13746
|
+
new Cesium.TimeInterval({
|
|
13747
|
+
start: Cesium.JulianDate.fromIso8601(startTime),
|
|
13748
|
+
stop: Cesium.JulianDate.fromIso8601(endTime)
|
|
13749
|
+
})
|
|
13750
|
+
);
|
|
13751
|
+
}
|
|
13752
|
+
};
|
|
13753
|
+
const traverse = (list) => {
|
|
13754
|
+
list.forEach((item) => {
|
|
13755
|
+
var _a;
|
|
13756
|
+
if (item.type === "group" && item.children) {
|
|
13757
|
+
traverse(item.children);
|
|
13758
|
+
} else {
|
|
13759
|
+
if (((_a = item.attr) == null ? void 0 : _a.roamData) && item.startTime && item.endTime) {
|
|
13760
|
+
processRoamData(item.attr.roamData, item.startTime, item.endTime);
|
|
13761
|
+
}
|
|
13762
|
+
if (item.blocks) {
|
|
13763
|
+
item.blocks.forEach((block) => {
|
|
13764
|
+
var _a2;
|
|
13765
|
+
if (((_a2 = block.attr) == null ? void 0 : _a2.roamData) && block.startTime && block.endTime) {
|
|
13766
|
+
processRoamData(
|
|
13767
|
+
block.attr.roamData,
|
|
13768
|
+
block.startTime,
|
|
13769
|
+
block.endTime
|
|
13770
|
+
);
|
|
13771
|
+
}
|
|
13772
|
+
});
|
|
13773
|
+
}
|
|
13774
|
+
}
|
|
13775
|
+
});
|
|
13776
|
+
};
|
|
13777
|
+
traverse(tasks);
|
|
13778
|
+
return { points, intervals };
|
|
13779
|
+
}
|
|
13780
|
+
initData(data) {
|
|
13781
|
+
const sortedData = [...data].sort(
|
|
13782
|
+
(a, b) => dayjs(a.time).valueOf() - dayjs(b.time).valueOf()
|
|
13783
|
+
);
|
|
13784
|
+
let lastHeading;
|
|
13785
|
+
sortedData.forEach((item) => {
|
|
13786
|
+
if (!item.time)
|
|
13787
|
+
return;
|
|
13788
|
+
const time = Cesium.JulianDate.fromIso8601(item.time);
|
|
13789
|
+
const position = Cesium.Cartesian3.fromDegrees(
|
|
13790
|
+
item.lng,
|
|
13791
|
+
item.lat,
|
|
13792
|
+
item.alt
|
|
13793
|
+
);
|
|
13794
|
+
this.positionProperty.addSample(time, position);
|
|
13795
|
+
let currentHeading = item.heading;
|
|
13796
|
+
if (lastHeading !== void 0) {
|
|
13797
|
+
let diff = currentHeading - lastHeading;
|
|
13798
|
+
while (diff > 180) {
|
|
13799
|
+
currentHeading -= 360;
|
|
13800
|
+
diff -= 360;
|
|
13801
|
+
}
|
|
13802
|
+
while (diff < -180) {
|
|
13803
|
+
currentHeading += 360;
|
|
13804
|
+
diff += 360;
|
|
13805
|
+
}
|
|
13806
|
+
}
|
|
13807
|
+
lastHeading = currentHeading;
|
|
13808
|
+
this.headingProperty.addSample(
|
|
13809
|
+
time,
|
|
13810
|
+
Cesium.Math.toRadians(currentHeading)
|
|
13811
|
+
);
|
|
13812
|
+
this.pitchProperty.addSample(time, Cesium.Math.toRadians(item.pitch));
|
|
13813
|
+
this.rollProperty.addSample(time, Cesium.Math.toRadians(item.roll || 0));
|
|
13814
|
+
});
|
|
13815
|
+
}
|
|
13816
|
+
/**
|
|
13817
|
+
* 开始跟随时间轴播放漫游
|
|
13818
|
+
*/
|
|
13819
|
+
start() {
|
|
13820
|
+
if (this._isPlaying)
|
|
13821
|
+
return;
|
|
13822
|
+
this.viewer.clock.onTick.addEventListener(this._onTick);
|
|
13823
|
+
this._isPlaying = true;
|
|
13824
|
+
}
|
|
13825
|
+
/**
|
|
13826
|
+
* 停止漫游
|
|
13827
|
+
*/
|
|
13828
|
+
stop() {
|
|
13829
|
+
if (!this._isPlaying)
|
|
13830
|
+
return;
|
|
13831
|
+
this.viewer.clock.onTick.removeEventListener(this._onTick);
|
|
13832
|
+
this._isPlaying = false;
|
|
13833
|
+
}
|
|
13834
|
+
/**
|
|
13835
|
+
* 根据当前时间更新相机
|
|
13836
|
+
* @param time
|
|
13837
|
+
*/
|
|
13838
|
+
updateCamera(time) {
|
|
13839
|
+
if (this.validIntervals.length > 0 && !this.validIntervals.contains(time)) {
|
|
13840
|
+
return;
|
|
13841
|
+
}
|
|
13842
|
+
const position = this.positionProperty.getValue(time);
|
|
13843
|
+
const heading = this.headingProperty.getValue(time);
|
|
13844
|
+
const pitch = this.pitchProperty.getValue(time);
|
|
13845
|
+
const roll = this.rollProperty.getValue(time);
|
|
13846
|
+
if (position && heading !== void 0 && pitch !== void 0) {
|
|
13847
|
+
this.viewer.camera.setView({
|
|
13848
|
+
destination: position,
|
|
13849
|
+
orientation: {
|
|
13850
|
+
heading,
|
|
13851
|
+
pitch,
|
|
13852
|
+
roll: roll || 0
|
|
13853
|
+
}
|
|
13854
|
+
});
|
|
13855
|
+
}
|
|
13856
|
+
}
|
|
13857
|
+
/**
|
|
13858
|
+
* 销毁实例
|
|
13859
|
+
*/
|
|
13860
|
+
destroy() {
|
|
13861
|
+
this.stop();
|
|
13862
|
+
}
|
|
13863
|
+
}
|
|
13638
13864
|
CesiumGantt.install = (app) => {
|
|
13639
13865
|
app.component("CesiumGantt", CesiumGantt);
|
|
13640
13866
|
};
|
|
13641
13867
|
export {
|
|
13642
13868
|
CesiumGantt,
|
|
13869
|
+
ViewportRoam,
|
|
13643
13870
|
CesiumGantt as default
|
|
13644
13871
|
};
|