chbim-time-axis-v2 0.0.18 → 0.0.19

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 Cesium = window.Cesium;
13141
- if (!Cesium)
13141
+ const Cesium2 = window.Cesium;
13142
+ if (!Cesium2)
13142
13143
  return;
13143
- const now = Cesium.JulianDate.toDate(clock.currentTime);
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 Cesium = window.Cesium;
13409
- if (clock && Cesium) {
13410
- clock.currentTime = Cesium.JulianDate.fromIso8601(newTime);
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,109 @@ 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) {
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
+ this.viewer = viewer;
13649
+ this.positionProperty = new Cesium.SampledPositionProperty();
13650
+ this.headingProperty = new Cesium.SampledProperty(Number);
13651
+ this.pitchProperty = new Cesium.SampledProperty(Number);
13652
+ this.rollProperty = new Cesium.SampledProperty(Number);
13653
+ this.positionProperty.setInterpolationOptions({
13654
+ interpolationDegree: 1,
13655
+ interpolationAlgorithm: Cesium.LinearApproximation
13656
+ });
13657
+ this.headingProperty.setInterpolationOptions({
13658
+ interpolationDegree: 1,
13659
+ interpolationAlgorithm: Cesium.LinearApproximation
13660
+ });
13661
+ this.pitchProperty.setInterpolationOptions({
13662
+ interpolationDegree: 1,
13663
+ interpolationAlgorithm: Cesium.LinearApproximation
13664
+ });
13665
+ this.rollProperty.setInterpolationOptions({
13666
+ interpolationDegree: 1,
13667
+ interpolationAlgorithm: Cesium.LinearApproximation
13668
+ });
13669
+ this.initData(data);
13670
+ this._onTick = (clock) => {
13671
+ const time = clock.currentTime;
13672
+ this.updateCamera(time);
13673
+ };
13674
+ }
13675
+ initData(data) {
13676
+ const sortedData = [...data].sort(
13677
+ (a, b) => dayjs(a.time).valueOf() - dayjs(b.time).valueOf()
13678
+ );
13679
+ sortedData.forEach((item) => {
13680
+ const time = Cesium.JulianDate.fromIso8601(item.time);
13681
+ const position = Cesium.Cartesian3.fromDegrees(
13682
+ item.lng,
13683
+ item.lat,
13684
+ item.alt
13685
+ );
13686
+ this.positionProperty.addSample(time, position);
13687
+ this.headingProperty.addSample(time, Cesium.Math.toRadians(item.heading));
13688
+ this.pitchProperty.addSample(time, Cesium.Math.toRadians(item.pitch));
13689
+ this.rollProperty.addSample(time, Cesium.Math.toRadians(item.roll || 0));
13690
+ });
13691
+ }
13692
+ /**
13693
+ * 开始跟随时间轴播放漫游
13694
+ */
13695
+ start() {
13696
+ if (this._isPlaying)
13697
+ return;
13698
+ this.viewer.clock.onTick.addEventListener(this._onTick);
13699
+ this._isPlaying = true;
13700
+ }
13701
+ /**
13702
+ * 停止漫游
13703
+ */
13704
+ stop() {
13705
+ if (!this._isPlaying)
13706
+ return;
13707
+ this.viewer.clock.onTick.removeEventListener(this._onTick);
13708
+ this._isPlaying = false;
13709
+ }
13710
+ /**
13711
+ * 根据当前时间更新相机
13712
+ * @param time
13713
+ */
13714
+ updateCamera(time) {
13715
+ const position = this.positionProperty.getValue(time);
13716
+ const heading = this.headingProperty.getValue(time);
13717
+ const pitch = this.pitchProperty.getValue(time);
13718
+ const roll = this.rollProperty.getValue(time);
13719
+ if (position && heading !== void 0 && pitch !== void 0) {
13720
+ this.viewer.camera.setView({
13721
+ destination: position,
13722
+ orientation: {
13723
+ heading,
13724
+ pitch,
13725
+ roll: roll || 0
13726
+ }
13727
+ });
13728
+ }
13729
+ }
13730
+ /**
13731
+ * 销毁实例
13732
+ */
13733
+ destroy() {
13734
+ this.stop();
13735
+ }
13736
+ }
13638
13737
  CesiumGantt.install = (app) => {
13639
13738
  app.component("CesiumGantt", CesiumGantt);
13640
13739
  };
13641
13740
  export {
13642
13741
  CesiumGantt,
13742
+ ViewportRoam,
13643
13743
  CesiumGantt as default
13644
13744
  };