deeptwins-engine-3d 0.1.67 → 0.1.68

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.
@@ -1,6 +1,9 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
2
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
6
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
4
7
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
8
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
6
9
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -20,29 +23,35 @@ var ModelRoamHistory = /*#__PURE__*/function () {
20
23
  _defineProperty(this, "polylineEntity", void 0);
21
24
  _defineProperty(this, "modelLayer", void 0);
22
25
  _defineProperty(this, "modelEntity", void 0);
23
- _defineProperty(this, "positionProperty", void 0);
24
- // 视角
26
+ _defineProperty(this, "positionProperty", null);
25
27
  _defineProperty(this, "follow", null);
26
- _defineProperty(this, "status", 'stop');
27
- _defineProperty(this, "_eventRunning", void 0);
28
- _defineProperty(this, "_eventComplete", void 0);
29
- _defineProperty(this, "_eventCancel", void 0);
30
- // 帧率更新的事件
28
+ _defineProperty(this, "status", 'initializing');
29
+ _defineProperty(this, "_eventRunning", null);
30
+ _defineProperty(this, "_eventComplete", null);
31
+ _defineProperty(this, "_eventCancel", null);
31
32
  _defineProperty(this, "_eventPreUpdate", void 0);
32
33
  _defineProperty(this, "_positions", []);
33
- _defineProperty(this, "_currentPosition", void 0);
34
- _defineProperty(this, "_heading", void 0);
35
- _defineProperty(this, "_listenRunning", void 0);
36
- // 第一人称视角设置
34
+ _defineProperty(this, "_currentPosition", null);
35
+ _defineProperty(this, "_heading", null);
36
+ _defineProperty(this, "_listenRunning", null);
37
+ _defineProperty(this, "_clockRange", Cesium.ClockRange.CLAMPED);
38
+ _defineProperty(this, "_initPromise", void 0);
39
+ _defineProperty(this, "_isReady", false);
40
+ _defineProperty(this, "_pendingStart", false);
41
+ _defineProperty(this, "_hasReachedStopTime", false);
42
+ _defineProperty(this, "_modelSourceId", null);
43
+ _defineProperty(this, "_samples", []);
37
44
  _defineProperty(this, "firstCameraSettings", {
38
45
  distance: 0,
39
46
  pitch: -45
40
47
  });
41
- // 第三人称视角设置
42
48
  _defineProperty(this, "thirdPersonSettings", {
43
49
  distance: 500,
44
50
  pitch: -45
45
51
  });
52
+ if (!(map !== null && map !== void 0 && map._mapContext)) {
53
+ throw new Error('undefined map');
54
+ }
46
55
  var _ref = options || {},
47
56
  complete = _ref.complete,
48
57
  cancel = _ref.cancel,
@@ -51,31 +60,142 @@ var ModelRoamHistory = /*#__PURE__*/function () {
51
60
  cancel && (this._eventCancel = cancel);
52
61
  onRunning && (this._eventRunning = onRunning);
53
62
  this._mapContext = map._mapContext;
54
- this._positions = positions;
55
- this._init(options);
63
+ this._positions = this._normalizePositions(positions);
64
+ this._initPromise = this._init(options);
65
+ this._initPromise.catch(function () {
66
+ return undefined;
67
+ });
56
68
  }
57
69
  _createClass(ModelRoamHistory, [{
58
70
  key: "getMap",
59
71
  value: function getMap() {
60
72
  return this._mapContext && this._mapContext.getMap();
61
73
  }
74
+ }, {
75
+ key: "isReady",
76
+ value: function isReady() {
77
+ return this._isReady;
78
+ }
79
+ }, {
80
+ key: "getStatus",
81
+ value: function getStatus() {
82
+ return this.status;
83
+ }
62
84
  }, {
63
85
  key: "_init",
64
- value: function _init(options) {
65
- var _this = this;
66
- var _ref2 = options || {},
67
- polyline = _ref2.polyline,
68
- model = _ref2.model,
69
- _ref2$multiplier = _ref2.multiplier,
70
- multiplier = _ref2$multiplier === void 0 ? 1 : _ref2$multiplier,
71
- _ref2$clockRange = _ref2.clockRange,
72
- clockRange = _ref2$clockRange === void 0 ? Cesium.ClockRange.CLAMPED : _ref2$clockRange,
73
- _ref2$flyTo = _ref2.flyTo,
74
- flyTo = _ref2$flyTo === void 0 ? false : _ref2$flyTo,
75
- _ref2$clampToGround = _ref2.clampToGround,
76
- clampToGround = _ref2$clampToGround === void 0 ? false : _ref2$clampToGround,
77
- _ref2$splitNum = _ref2.splitNum,
78
- splitNum = _ref2$splitNum === void 0 ? 50 : _ref2$splitNum;
86
+ value: function () {
87
+ var _init2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
88
+ var _this$polylineLayer;
89
+ var _ref2, polyline, _ref2$model, model, _ref2$multiplier, multiplier, _ref2$clockRange, clockRange, _ref2$flyTo, flyTo, _ref2$clampToGround, clampToGround, _ref2$splitNum, splitNum, map, start, stop, _this$polylineLayer2, _this$modelLayer, samples, modelOptions, startPosition;
90
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
91
+ while (1) switch (_context.prev = _context.next) {
92
+ case 0:
93
+ _ref2 = options || {}, polyline = _ref2.polyline, _ref2$model = _ref2.model, model = _ref2$model === void 0 ? {} : _ref2$model, _ref2$multiplier = _ref2.multiplier, multiplier = _ref2$multiplier === void 0 ? 1 : _ref2$multiplier, _ref2$clockRange = _ref2.clockRange, clockRange = _ref2$clockRange === void 0 ? Cesium.ClockRange.CLAMPED : _ref2$clockRange, _ref2$flyTo = _ref2.flyTo, flyTo = _ref2$flyTo === void 0 ? false : _ref2$flyTo, _ref2$clampToGround = _ref2.clampToGround, clampToGround = _ref2$clampToGround === void 0 ? false : _ref2$clampToGround, _ref2$splitNum = _ref2.splitNum, splitNum = _ref2$splitNum === void 0 ? 50 : _ref2$splitNum;
94
+ this._clockRange = clockRange;
95
+ map = this.getMap();
96
+ start = Cesium.JulianDate.fromDate(this._positions[0].time);
97
+ stop = Cesium.JulianDate.fromDate(this._positions[this._positions.length - 1].time);
98
+ this._createPolylineLayer(polyline, clampToGround);
99
+ this.polylineEntity = (_this$polylineLayer = this.polylineLayer) === null || _this$polylineLayer === void 0 || (_this$polylineLayer = _this$polylineLayer.layers) === null || _this$polylineLayer === void 0 || (_this$polylineLayer = _this$polylineLayer[0]) === null || _this$polylineLayer === void 0 ? void 0 : _this$polylineLayer.entity;
100
+ if (flyTo) {
101
+ (_this$polylineLayer2 = this.polylineLayer) === null || _this$polylineLayer2 === void 0 || _this$polylineLayer2.flyTo();
102
+ }
103
+ this._configureClock(start, stop, multiplier, clockRange);
104
+ this._bindSceneListener();
105
+ _context.prev = 10;
106
+ _context.next = 13;
107
+ return this._buildPositionSamples({
108
+ clampToGround: clampToGround,
109
+ splitNum: splitNum
110
+ });
111
+ case 13:
112
+ samples = _context.sent;
113
+ if (!(this.status === 'destroy')) {
114
+ _context.next = 16;
115
+ break;
116
+ }
117
+ return _context.abrupt("return");
118
+ case 16:
119
+ this.positionProperty = new Cesium.SampledPositionProperty();
120
+ this._samples = samples.slice().sort(function (a, b) {
121
+ return a.time.getTime() - b.time.getTime();
122
+ });
123
+ this._appendSamples(this._samples);
124
+ modelOptions = _objectSpread(_objectSpread({}, model || {}), clampToGround ? {
125
+ heightReference: Cesium.HeightReference.CLAMP_TO_GROUND
126
+ } : {});
127
+ this.modelEntity = new Cesium.Entity({
128
+ availability: new Cesium.TimeIntervalCollection([new Cesium.TimeInterval({
129
+ start: start,
130
+ stop: stop
131
+ })]),
132
+ orientation: new Cesium.VelocityOrientationProperty(this.positionProperty),
133
+ position: this.positionProperty,
134
+ model: ModelEntity.handleOptions(modelOptions)
135
+ });
136
+ this.modelLayer = map.addCustomSourceToGraphicLayer(this.modelEntity.position, {
137
+ type: 'model',
138
+ entity: this.modelEntity
139
+ });
140
+ this._modelSourceId = ((_this$modelLayer = this.modelLayer) === null || _this$modelLayer === void 0 ? void 0 : _this$modelLayer.sourceId) || null;
141
+ this.status = 'stop';
142
+ this._isReady = true;
143
+ startPosition = this.positionProperty.getValue(map.clock.currentTime);
144
+ if (startPosition) {
145
+ this._currentPosition = startPosition;
146
+ }
147
+ if (this._pendingStart) {
148
+ this._pendingStart = false;
149
+ this.start();
150
+ }
151
+ _context.next = 34;
152
+ break;
153
+ case 30:
154
+ _context.prev = 30;
155
+ _context.t0 = _context["catch"](10);
156
+ if (this.status !== 'destroy') {
157
+ this.status = 'error';
158
+ }
159
+ throw _context.t0;
160
+ case 34:
161
+ case "end":
162
+ return _context.stop();
163
+ }
164
+ }, _callee, this, [[10, 30]]);
165
+ }));
166
+ function _init(_x) {
167
+ return _init2.apply(this, arguments);
168
+ }
169
+ return _init;
170
+ }()
171
+ }, {
172
+ key: "_normalizePositions",
173
+ value: function _normalizePositions(positions) {
174
+ if (!Array.isArray(positions) || positions.length < 2) {
175
+ throw new Error('positions must contain at least two items');
176
+ }
177
+ var normalizedPositions = positions.map(function (item, index) {
178
+ var time = (item === null || item === void 0 ? void 0 : item.time) instanceof Date ? item.time : new Date(item === null || item === void 0 ? void 0 : item.time);
179
+ if (typeof (item === null || item === void 0 ? void 0 : item.lng) !== 'number' || typeof (item === null || item === void 0 ? void 0 : item.lat) !== 'number' || typeof (item === null || item === void 0 ? void 0 : item.alt) !== 'number' || Number.isNaN(time.getTime())) {
180
+ throw new Error("invalid position data at index ".concat(index));
181
+ }
182
+ return {
183
+ lng: item.lng,
184
+ lat: item.lat,
185
+ alt: item.alt,
186
+ time: time
187
+ };
188
+ });
189
+ for (var i = 1; i < normalizedPositions.length; i++) {
190
+ if (normalizedPositions[i].time.getTime() <= normalizedPositions[i - 1].time.getTime()) {
191
+ throw new Error('positions time must be in strictly ascending order');
192
+ }
193
+ }
194
+ return normalizedPositions;
195
+ }
196
+ }, {
197
+ key: "_createPolylineLayer",
198
+ value: function _createPolylineLayer(polyline, clampToGround) {
79
199
  var geoJson = {
80
200
  type: 'FeatureCollection',
81
201
  features: [{
@@ -90,277 +210,428 @@ var ModelRoamHistory = /*#__PURE__*/function () {
90
210
  };
91
211
  this.polylineLayer = this.getMap().addGraphicLayer(geoJson, {
92
212
  type: 'polyline',
93
- id: '_modelHistoryRoam',
94
213
  style: _objectSpread(_objectSpread({}, polyline), {}, {
95
214
  clampToGround: clampToGround
96
215
  })
97
216
  });
98
- this.polylineEntity = this.polylineLayer.layers[0].entity;
99
- if (flyTo) {
100
- this.polylineLayer.flyTo();
101
- }
102
- var start = Cesium.JulianDate.fromDate(this._positions[0].time);
103
- var stop = Cesium.JulianDate.fromDate(this._positions[this._positions.length - 1].time);
104
- this.getMap().clock.startTime = start.clone();
105
- this.getMap().clock.stopTime = stop.clone();
106
- this.getMap().clock.currentTime = start.clone();
107
- // 播放速率
108
- this.getMap().clock.multiplier = multiplier;
109
- this.getMap().clock.clockRange = clockRange;
110
- // 停止播放
111
- this.getMap().clock.shouldAnimate = false;
217
+ }
218
+ }, {
219
+ key: "_configureClock",
220
+ value: function _configureClock(start, stop, multiplier, clockRange) {
221
+ var map = this.getMap();
222
+ map.clock.startTime = start.clone();
223
+ map.clock.stopTime = stop.clone();
224
+ map.clock.currentTime = start.clone();
225
+ map.clock.multiplier = multiplier;
226
+ map.clock.clockRange = clockRange;
227
+ map.clock.shouldAnimate = false;
228
+ }
229
+ }, {
230
+ key: "_bindSceneListener",
231
+ value: function _bindSceneListener() {
232
+ var _this = this;
112
233
  this._listenRunning = function () {
113
- // 判断结束
114
- if (Cesium.JulianDate.compare(_this.getMap().clock.currentTime, _this.getMap().clock.stopTime) >= 0 && clockRange !== Cesium.ClockRange.LOOP_STOP) {
234
+ if (!_this._isReady || !_this.positionProperty || _this.status === 'destroy' || _this.status === 'error') {
235
+ return;
236
+ }
237
+ var map = _this.getMap();
238
+ var clock = map.clock;
239
+ var currentTime = clock.currentTime;
240
+ var reachedStopTime = Cesium.JulianDate.compare(currentTime, clock.stopTime) >= 0;
241
+ if (reachedStopTime && !_this._hasReachedStopTime) {
242
+ _this._hasReachedStopTime = true;
115
243
  if (_this._eventComplete && _this.status === 'running') {
116
244
  _this._eventComplete();
117
245
  }
118
- _this.status = 'stop';
119
- } else {
120
- // 监听运行状态
121
- if (_this._eventRunning && _this.getMap().clock.shouldAnimate) {
122
- // 获取当前时间
123
- var currentTime = _this.getMap().clock.currentTime;
124
- // 获取前一帧时间
125
- var beforeTime = Cesium.JulianDate.addSeconds(currentTime, -0.1, new Cesium.JulianDate());
126
- // 获取插值后的当前位置
127
- var currentPosition = _this.positionProperty.getValue(currentTime);
128
- // 获取前一帧的位置
129
- var beforePosition = _this.positionProperty.getValue(beforeTime);
130
- if (currentPosition) {
131
- _this._currentPosition = currentPosition;
132
- if (_this.modelLayer && _this._positions && beforePosition) {
133
- _this._getHeading(currentPosition, beforePosition);
134
- }
135
- _this._eventRunning(_objectSpread(_objectSpread({}, cartesian3ToLngLatAlt(currentPosition)), {}, {
136
- time: Cesium.JulianDate.toDate(currentTime)
137
- }));
138
- }
246
+ if (_this._clockRange !== Cesium.ClockRange.LOOP_STOP) {
247
+ _this.status = 'stop';
248
+ clock.shouldAnimate = false;
139
249
  }
250
+ } else if (!reachedStopTime) {
251
+ _this._hasReachedStopTime = false;
252
+ }
253
+ if (!clock.shouldAnimate) {
254
+ return;
255
+ }
256
+ var currentPosition = _this.positionProperty.getValue(currentTime);
257
+ if (!currentPosition) {
258
+ return;
259
+ }
260
+ _this._currentPosition = currentPosition;
261
+ var beforePosition = _this._getPreviousPosition(currentTime);
262
+ if (beforePosition) {
263
+ _this._updateHeading(currentPosition, beforePosition);
264
+ }
265
+ if (_this._eventRunning) {
266
+ _this._eventRunning(_objectSpread(_objectSpread({}, cartesian3ToLngLatAlt(currentPosition)), {}, {
267
+ time: Cesium.JulianDate.toDate(currentTime)
268
+ }));
140
269
  }
141
270
  };
142
- // 监听帧率
143
271
  this._eventPreUpdate = this.getMap().on(constant.SCENE_EVENT_TYPE.PRE_UPDATE, this._listenRunning);
144
- this.positionProperty = new Cesium.SampledPositionProperty();
145
- if (clampToGround) {
146
- // 贴地计算
147
- model.heightReference = Cesium.HeightReference.CLAMP_TO_GROUND;
148
- var _loop = function _loop() {
149
- var position1 = _this._positions[i];
150
- var position2 = _this._positions[i + 1];
151
- var points = lineClampToGroundSplit({
152
- map: _this.getMap(),
153
- pos1: lngLatAltToCartesian3(position1.lng, position1.lat, position1.alt),
154
- pos2: lngLatAltToCartesian3(position2.lng, position2.lat, position2.alt),
155
- splitNum: splitNum
156
- });
157
- // 分段计算
158
- var cartographicPoints = points.map(function (point) {
159
- return Cesium.Cartographic.fromCartesian(point);
160
- });
161
- // 贴地计算
162
- Cesium.sampleTerrainMostDetailed(_this.getMap().terrainProvider, cartographicPoints).then(function (updatedPoints) {
163
- var startTime = position1.time;
164
- var endTime = position2.time;
165
- var totalInterval = endTime - startTime;
166
- var segmentInterval = totalInterval / updatedPoints.length;
167
- for (var j = 0; j < updatedPoints.length; j++) {
168
- var dataPoint = updatedPoints[j];
169
- var position = Cesium.Cartesian3.fromRadians(dataPoint.longitude, dataPoint.latitude, dataPoint.height);
170
- var time = new Date(startTime.getTime() + j * segmentInterval);
171
- _this.positionProperty.addSample(Cesium.JulianDate.fromDate(time), position);
172
- }
173
- });
272
+ }
273
+ }, {
274
+ key: "_buildPositionSamples",
275
+ value: function () {
276
+ var _buildPositionSamples2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref3) {
277
+ var _this2 = this;
278
+ var clampToGround, splitNum, map, segmentTasks, segments;
279
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
280
+ while (1) switch (_context2.prev = _context2.next) {
281
+ case 0:
282
+ clampToGround = _ref3.clampToGround, splitNum = _ref3.splitNum;
283
+ if (clampToGround) {
284
+ _context2.next = 3;
285
+ break;
286
+ }
287
+ return _context2.abrupt("return", this._positions.map(function (dataPoint) {
288
+ return {
289
+ time: dataPoint.time,
290
+ position: lngLatAltToCartesian3(dataPoint.lng, dataPoint.lat, dataPoint.alt)
291
+ };
292
+ }));
293
+ case 3:
294
+ map = this.getMap();
295
+ segmentTasks = this._positions.slice(0, -1).map(function (position1, index) {
296
+ var position2 = _this2._positions[index + 1];
297
+ var points = lineClampToGroundSplit({
298
+ map: map,
299
+ pos1: lngLatAltToCartesian3(position1.lng, position1.lat, position1.alt),
300
+ pos2: lngLatAltToCartesian3(position2.lng, position2.lat, position2.alt),
301
+ splitNum: splitNum
302
+ });
303
+ if (!points.length) {
304
+ return Promise.resolve({
305
+ index: index,
306
+ samples: _this2._buildRawSegmentSamples(position1, position2)
307
+ });
308
+ }
309
+ var cartographicPoints = points.map(function (point) {
310
+ return Cesium.Cartographic.fromCartesian(point);
311
+ });
312
+ return Cesium.sampleTerrainMostDetailed(map.terrainProvider, cartographicPoints).then(function (updatedPoints) {
313
+ return {
314
+ index: index,
315
+ samples: _this2._buildTerrainSegmentSamples(position1, position2, updatedPoints)
316
+ };
317
+ });
318
+ });
319
+ _context2.next = 7;
320
+ return Promise.all(segmentTasks);
321
+ case 7:
322
+ segments = _context2.sent;
323
+ return _context2.abrupt("return", segments.sort(function (a, b) {
324
+ return a.index - b.index;
325
+ }).reduce(function (result, item) {
326
+ return result.concat(item.samples);
327
+ }, []));
328
+ case 9:
329
+ case "end":
330
+ return _context2.stop();
331
+ }
332
+ }, _callee2, this);
333
+ }));
334
+ function _buildPositionSamples(_x2) {
335
+ return _buildPositionSamples2.apply(this, arguments);
336
+ }
337
+ return _buildPositionSamples;
338
+ }()
339
+ }, {
340
+ key: "_buildRawSegmentSamples",
341
+ value: function _buildRawSegmentSamples(startPosition, endPosition) {
342
+ return [{
343
+ time: startPosition.time,
344
+ position: lngLatAltToCartesian3(startPosition.lng, startPosition.lat, startPosition.alt)
345
+ }, {
346
+ time: endPosition.time,
347
+ position: lngLatAltToCartesian3(endPosition.lng, endPosition.lat, endPosition.alt)
348
+ }];
349
+ }
350
+ }, {
351
+ key: "_buildTerrainSegmentSamples",
352
+ value: function _buildTerrainSegmentSamples(startPosition, endPosition, updatedPoints) {
353
+ if (!updatedPoints.length) {
354
+ return this._buildRawSegmentSamples(startPosition, endPosition);
355
+ }
356
+ if (updatedPoints.length === 1) {
357
+ return this._buildRawSegmentSamples(startPosition, endPosition);
358
+ }
359
+ var startTime = startPosition.time.getTime();
360
+ var endTime = endPosition.time.getTime();
361
+ var totalInterval = endTime - startTime;
362
+ var segmentInterval = totalInterval / (updatedPoints.length - 1);
363
+ return updatedPoints.map(function (dataPoint, index) {
364
+ return {
365
+ time: new Date(startTime + index * segmentInterval),
366
+ position: Cesium.Cartesian3.fromRadians(dataPoint.longitude, dataPoint.latitude, dataPoint.height)
174
367
  };
175
- for (var i = 0; i < this._positions.length - 1; i++) {
176
- _loop();
368
+ });
369
+ }
370
+ }, {
371
+ key: "_appendSamples",
372
+ value: function _appendSamples(samples) {
373
+ var _this3 = this;
374
+ if (!this.positionProperty) {
375
+ return;
376
+ }
377
+ var previousSample = null;
378
+ samples.forEach(function (sample) {
379
+ var _this3$positionProper;
380
+ if (_this3._shouldSkipSample(sample, previousSample)) {
381
+ return;
177
382
  }
178
- } else {
179
- for (var _i = 0; _i < this._positions.length; _i++) {
180
- var dataPoint = this._positions[_i];
181
- var position = lngLatAltToCartesian3(dataPoint.lng, dataPoint.lat, dataPoint.alt);
182
- this.positionProperty.addSample(Cesium.JulianDate.fromDate(dataPoint.time), position);
383
+ (_this3$positionProper = _this3.positionProperty) === null || _this3$positionProper === void 0 || _this3$positionProper.addSample(Cesium.JulianDate.fromDate(sample.time), sample.position);
384
+ previousSample = sample;
385
+ });
386
+ }
387
+ }, {
388
+ key: "_shouldSkipSample",
389
+ value: function _shouldSkipSample(sample, previousSample) {
390
+ if (!previousSample) {
391
+ return false;
392
+ }
393
+ return previousSample.time.getTime() === sample.time.getTime() && Cesium.Cartesian3.equals(previousSample.position, sample.position);
394
+ }
395
+ }, {
396
+ key: "_getPreviousPosition",
397
+ value: function _getPreviousPosition(currentTime) {
398
+ if (!this.positionProperty || !this._samples.length) {
399
+ return null;
400
+ }
401
+ var currentTimeMs = Cesium.JulianDate.toDate(currentTime).getTime();
402
+ for (var i = this._samples.length - 1; i >= 0; i--) {
403
+ var sample = this._samples[i];
404
+ if (sample.time.getTime() >= currentTimeMs) {
405
+ continue;
183
406
  }
407
+ return sample.position;
184
408
  }
185
- this.modelEntity = new Cesium.Entity({
186
- availability: new Cesium.TimeIntervalCollection([new Cesium.TimeInterval({
187
- start: start,
188
- stop: stop
189
- })]),
190
- orientation: new Cesium.VelocityOrientationProperty(this.positionProperty),
191
- position: this.positionProperty,
192
- model: ModelEntity.handleOptions(model)
193
- });
194
- this.modelLayer = this.getMap().addCustomSourceToGraphicLayer(this.modelEntity.position, {
195
- type: 'model',
196
- entity: this.modelEntity
197
- });
409
+ var fallbackTime = Cesium.JulianDate.addSeconds(currentTime, -0.01, new Cesium.JulianDate());
410
+ return this.positionProperty.getValue(fallbackTime) || null;
198
411
  }
199
-
200
- // 获取方向角
201
412
  }, {
202
- key: "_getHeading",
203
- value: function _getHeading(currentPosition, beforePosition) {
204
- // 当前位置与之前位置的 Cartographic 经纬度
413
+ key: "_updateHeading",
414
+ value: function _updateHeading(currentPosition, beforePosition) {
205
415
  var cartoNow = Cesium.Cartographic.fromCartesian(currentPosition);
206
416
  var cartoBefore = Cesium.Cartographic.fromCartesian(beforePosition);
207
-
208
- // 把它们转为 Cartesian3
209
417
  var origin = Cesium.Cartesian3.fromRadians(cartoBefore.longitude, cartoBefore.latitude, cartoBefore.height);
210
418
  var target = Cesium.Cartesian3.fromRadians(cartoNow.longitude, cartoNow.latitude, cartoNow.height);
211
-
212
- // 构造 ENU 变换矩阵(以 before 位置为原点)
213
419
  var enuTransform = Cesium.Transforms.eastNorthUpToFixedFrame(origin);
214
420
  var inverse = Cesium.Matrix4.inverse(enuTransform, new Cesium.Matrix4());
215
-
216
- // 计算从 before → now 的方向向量
217
421
  var directionWorld = Cesium.Cartesian3.subtract(target, origin, new Cesium.Cartesian3());
422
+ if (Cesium.Cartesian3.magnitudeSquared(directionWorld) <= Cesium.Math.EPSILON12) {
423
+ return;
424
+ }
218
425
  var directionENU = Cesium.Matrix4.multiplyByPointAsVector(inverse, directionWorld, new Cesium.Cartesian3());
219
-
220
- // 在 ENU 坐标中计算 heading
221
- var heading = Cesium.Math.zeroToTwoPi(Math.atan2(directionENU.x, directionENU.y)); // 东为 x,北为 y
426
+ var heading = Cesium.Math.zeroToTwoPi(Math.atan2(directionENU.x, directionENU.y));
222
427
  this._heading = heading;
428
+ this._applyFollowView(currentPosition, heading);
429
+ }
430
+ }, {
431
+ key: "_applyFollowView",
432
+ value: function _applyFollowView(position, heading) {
223
433
  if (this.follow === 'first') {
224
- this.updateFirstPersonView(currentPosition, heading);
434
+ this.updateFirstPersonView(position, heading);
225
435
  } else if (this.follow === 'third') {
226
- this.updateThirdPersonView(currentPosition, heading);
436
+ this.updateThirdPersonView(position, heading);
227
437
  }
228
438
  }
229
-
230
- // 开始播放场景
231
439
  }, {
232
440
  key: "start",
233
441
  value: function start() {
234
- if (this.status === 'destroy') return;
442
+ if (this.status === 'destroy' || this.status === 'error') return;
443
+ if (!this._isReady) {
444
+ this._pendingStart = true;
445
+ return;
446
+ }
447
+ if (Cesium.JulianDate.compare(this.getMap().clock.currentTime, this.getMap().clock.stopTime) >= 0) {
448
+ this.getMap().clock.currentTime = this.getMap().clock.startTime.clone();
449
+ }
235
450
  this.status = 'running';
451
+ this._hasReachedStopTime = false;
236
452
  this.getMap().clock.shouldAnimate = true;
237
453
  }
238
-
239
- // 暂停
240
454
  }, {
241
455
  key: "pause",
242
456
  value: function pause() {
243
- if (this.status === 'destroy') return;
457
+ if (this.status !== 'running') return;
244
458
  this.status = 'pause';
245
459
  this.getMap().clock.shouldAnimate = false;
246
- this._eventCancel && this._eventCancel();
247
460
  }
248
-
249
- // 继续
250
461
  }, {
251
462
  key: "proceed",
252
463
  value: function proceed() {
253
- if (this.status === 'destroy') return;
464
+ if (this.status === 'destroy' || this.status === 'error') return;
465
+ if (!this._isReady) {
466
+ this._pendingStart = true;
467
+ return;
468
+ }
469
+ if (this.status !== 'pause' && this.status !== 'stop' && this.status !== 'ready') {
470
+ return;
471
+ }
254
472
  this.status = 'running';
473
+ this._hasReachedStopTime = false;
255
474
  this.getMap().clock.shouldAnimate = true;
256
475
  }
257
-
258
- // 停止
259
476
  }, {
260
477
  key: "stop",
261
478
  value: function stop() {
262
- if (this.status === 'destroy') return;
479
+ if (this.status === 'destroy' || this.status === 'error') return;
480
+ this._pendingStart = false;
263
481
  this.status = 'stop';
264
482
  this.getMap().clock.shouldAnimate = false;
265
483
  this.getMap().clock.currentTime = Cesium.JulianDate.fromDate(this._positions[0].time);
484
+ if (this.positionProperty) {
485
+ var resetPosition = this.positionProperty.getValue(this.getMap().clock.currentTime);
486
+ if (resetPosition) {
487
+ this._currentPosition = resetPosition;
488
+ if (this._heading != null) {
489
+ this._applyFollowView(resetPosition, this._heading);
490
+ }
491
+ }
492
+ }
266
493
  this._eventCancel && this._eventCancel();
267
494
  }
268
-
269
- // 第一人称视角跟随
270
495
  }, {
271
496
  key: "setFollowFirst",
272
- value: function setFollowFirst(options) {
497
+ value: function setFollowFirst() {
498
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
273
499
  if (this.status === 'destroy') return;
274
500
  this.firstCameraSettings = _objectSpread(_objectSpread({}, this.firstCameraSettings), options);
275
501
  this.follow = 'first';
276
- this.updateFirstPersonView(this._currentPosition, this._heading);
502
+ if (this._currentPosition && this._heading != null) {
503
+ this.updateFirstPersonView(this._currentPosition, this._heading);
504
+ }
277
505
  }
278
-
279
- // 第三人称视角跟随
280
506
  }, {
281
507
  key: "setFollowThird",
282
- value: function setFollowThird(options) {
508
+ value: function setFollowThird() {
509
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
283
510
  if (this.status === 'destroy') return;
284
511
  this.thirdPersonSettings = _objectSpread(_objectSpread({}, this.thirdPersonSettings), options);
285
512
  this.follow = 'third';
286
- this.updateThirdPersonView(this._currentPosition, this._heading);
513
+ if (this._currentPosition && this._heading != null) {
514
+ this.updateThirdPersonView(this._currentPosition, this._heading);
515
+ }
287
516
  }
288
-
289
- // 取消跟随
290
517
  }, {
291
518
  key: "cancelFollow",
292
519
  value: function cancelFollow() {
293
520
  if (this.status === 'destroy') return;
294
521
  this.follow = null;
295
522
  }
296
-
297
- // 更新第一人称视角
298
523
  }, {
299
524
  key: "updateFirstPersonView",
300
525
  value: function updateFirstPersonView(position, heading) {
301
- if (!position || !heading) {
526
+ if (!position || heading == null) {
302
527
  return;
303
528
  }
304
- // 设置相机位置和朝向
529
+ var pitch = Cesium.Math.toRadians(this.firstCameraSettings.pitch);
530
+ var roll = 0.0;
531
+ var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
532
+ var orientationMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(position, hpr, Cesium.Ellipsoid.WGS84, Cesium.Transforms.localFrameToFixedFrameGenerator('east', 'north'));
533
+ var forwardLocal = new Cesium.Cartesian3(0, 1, 0);
534
+ var rotation = Cesium.Matrix4.getMatrix3(orientationMatrix, new Cesium.Matrix3());
535
+ var forwardWorld = Cesium.Matrix3.multiplyByVector(rotation, forwardLocal, new Cesium.Cartesian3());
536
+ var offset = Cesium.Cartesian3.multiplyByScalar(forwardWorld, -this.firstCameraSettings.distance, new Cesium.Cartesian3());
537
+ var cameraPosition = Cesium.Cartesian3.add(position, offset, new Cesium.Cartesian3());
305
538
  this.getMap().camera.setView({
306
- destination: position,
539
+ destination: cameraPosition,
307
540
  orientation: {
308
541
  heading: heading,
309
- pitch: Cesium.Math.toRadians(this.firstCameraSettings.pitch),
310
- roll: 0.0
542
+ pitch: pitch,
543
+ roll: roll
311
544
  }
312
545
  });
313
546
  }
314
-
315
- // 更新第三人称视角
316
547
  }, {
317
548
  key: "updateThirdPersonView",
318
549
  value: function updateThirdPersonView(position, heading) {
319
- if (!position || !heading) {
550
+ if (!position || heading == null) {
320
551
  return;
321
552
  }
322
- this.getMap().camera.lookAt(position, new Cesium.HeadingPitchRange(heading, Cesium.Math.toRadians(this.thirdPersonSettings.pitch), this.thirdPersonSettings.distance));
553
+ var transform = Cesium.Transforms.headingPitchRollToFixedFrame(position, new Cesium.HeadingPitchRoll(heading, 0, 0), Cesium.Ellipsoid.WGS84, Cesium.Transforms.localFrameToFixedFrameGenerator('north', 'west'));
554
+ var offset = new Cesium.Cartesian3(-this.thirdPersonSettings.distance, 0, 500);
555
+ var cameraPosition = Cesium.Matrix4.multiplyByPoint(transform, offset, new Cesium.Cartesian3());
556
+ this.getMap().camera.setView({
557
+ destination: cameraPosition,
558
+ orientation: {
559
+ heading: heading,
560
+ pitch: Cesium.Math.toRadians(this.thirdPersonSettings.pitch),
561
+ roll: 0.0
562
+ }
563
+ });
323
564
  }
324
-
325
- // 监听
326
565
  }, {
327
566
  key: "on",
328
567
  value: function on(type, event) {
329
568
  return this.getMap()._event.listenToModelRoam(type, event, this);
330
569
  }
331
-
332
- // 更新线
333
570
  }, {
334
571
  key: "updatePolyline",
335
572
  value: function updatePolyline(style) {
336
- this.polylineLayer.setStyle(style);
573
+ var _this$polylineLayer3;
574
+ (_this$polylineLayer3 = this.polylineLayer) === null || _this$polylineLayer3 === void 0 || _this$polylineLayer3.setStyle(style);
337
575
  }
338
-
339
- // 更新模型
340
576
  }, {
341
577
  key: "updateModel",
342
578
  value: function updateModel(style) {
343
- this.modelLayer.setStyle(style);
579
+ var _this$modelLayer2;
580
+ (_this$modelLayer2 = this.modelLayer) === null || _this$modelLayer2 === void 0 || _this$modelLayer2.setStyle(style);
344
581
  }
345
-
346
- // 销毁
582
+ }, {
583
+ key: "waitUntilReady",
584
+ value: function () {
585
+ var _waitUntilReady = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
586
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
587
+ while (1) switch (_context3.prev = _context3.next) {
588
+ case 0:
589
+ _context3.next = 2;
590
+ return this._initPromise;
591
+ case 2:
592
+ case "end":
593
+ return _context3.stop();
594
+ }
595
+ }, _callee3, this);
596
+ }));
597
+ function waitUntilReady() {
598
+ return _waitUntilReady.apply(this, arguments);
599
+ }
600
+ return waitUntilReady;
601
+ }()
347
602
  }, {
348
603
  key: "destroy",
349
604
  value: function destroy() {
350
- this.status = 'destroy';
351
- this.getMap().clock.shouldAnimate = false;
352
- this.getMap().clock.currentTime = Cesium.JulianDate.fromDate(new Date());
353
- this._eventPreUpdate.off();
354
- this._listenRunning = null;
355
- this.getMap().removeLayer('_modelHistoryRoam');
356
- this.getMap().removeSource('_modelHistoryRoam');
605
+ var _this$_eventPreUpdate, _this$_eventPreUpdate2, _this$polylineLayer4, _this$polylineLayer4$;
606
+ if (this.status === 'destroy') {
607
+ return;
608
+ }
609
+ var map = this.getMap();
610
+ map.clock.shouldAnimate = false;
357
611
  this.cancelFollow();
358
- this.polylineLayer.remove();
612
+ this._pendingStart = false;
613
+ (_this$_eventPreUpdate = this._eventPreUpdate) === null || _this$_eventPreUpdate === void 0 || (_this$_eventPreUpdate2 = _this$_eventPreUpdate.off) === null || _this$_eventPreUpdate2 === void 0 || _this$_eventPreUpdate2.call(_this$_eventPreUpdate);
614
+ this._eventPreUpdate = null;
615
+ this._listenRunning = null;
616
+ if (this._modelSourceId) {
617
+ map.removeGraphicSource(this._modelSourceId);
618
+ } else {
619
+ var _this$modelLayer3, _this$modelLayer3$rem;
620
+ (_this$modelLayer3 = this.modelLayer) === null || _this$modelLayer3 === void 0 || (_this$modelLayer3$rem = _this$modelLayer3.remove) === null || _this$modelLayer3$rem === void 0 || _this$modelLayer3$rem.call(_this$modelLayer3);
621
+ }
622
+ (_this$polylineLayer4 = this.polylineLayer) === null || _this$polylineLayer4 === void 0 || (_this$polylineLayer4$ = _this$polylineLayer4.remove) === null || _this$polylineLayer4$ === void 0 || _this$polylineLayer4$.call(_this$polylineLayer4);
623
+ this.polylineLayer = null;
359
624
  this.polylineEntity = null;
360
- this.modelLayer.remove();
625
+ this.modelLayer = null;
361
626
  this.modelEntity = null;
627
+ this._modelSourceId = null;
362
628
  this._positions = [];
629
+ this._samples = [];
363
630
  this.positionProperty = null;
631
+ this._currentPosition = null;
632
+ this._heading = null;
633
+ this._isReady = false;
634
+ this.status = 'destroy';
364
635
  }
365
636
  }]);
366
637
  return ModelRoamHistory;