@realsee/vreo 1.2.1-alpha.1 → 1.2.1-alpha.2

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.
Files changed (48) hide show
  1. package/lib/PlayController/createHTMLAudioElement.js +6 -11
  2. package/lib/PlayController/index.js +15 -80
  3. package/lib/Player/App.js +0 -26
  4. package/lib/Player/Controller.js +23 -100
  5. package/lib/Player/custom/SpatialScenePanel/index.js +42 -68
  6. package/lib/Player/hooks.js +0 -10
  7. package/lib/Player/index.js +24 -86
  8. package/lib/Player/modules/Drawer/index.js +0 -17
  9. package/lib/Player/modules/PopUp/index.js +0 -10
  10. package/lib/Player/modules/ResizeObserver/index.js +0 -8
  11. package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +17 -108
  12. package/lib/Player/modules/VideoAgent/VideoAgentScene.js +2 -24
  13. package/lib/Player/modules/VideoAgent/index.js +0 -17
  14. package/lib/Player/modules/Wave/index.js +7 -32
  15. package/lib/Player/modules/keyframes/BgMusic/index.js +7 -23
  16. package/lib/Player/modules/keyframes/CameraMovement/index.js +3 -27
  17. package/lib/Player/modules/keyframes/InfoPanel/index.js +8 -29
  18. package/lib/Player/modules/keyframes/ModelVideo/index.js +3 -29
  19. package/lib/Player/modules/keyframes/PanoEffect/index.js +15 -43
  20. package/lib/Player/modules/keyframes/PanoEffect/lineAnime.js +0 -7
  21. package/lib/Player/modules/keyframes/PanoTag/index.js +5 -22
  22. package/lib/Player/modules/keyframes/PanoTextLabel/index.js +22 -47
  23. package/lib/Player/modules/keyframes/Prompter/index.js +10 -32
  24. package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +18 -25
  25. package/lib/Player/modules/keyframes/VideoEffect/index.js +12 -47
  26. package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.js +0 -2
  27. package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.js +0 -1
  28. package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.js +0 -1
  29. package/lib/fivePlugins/CSS3DRenderPlugin/index.js +19 -60
  30. package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.js +2 -5
  31. package/lib/fivePlugins/CameraMovementPlugin/index.js +28 -76
  32. package/lib/fivePlugins/CameraMovementPlugin/typings.js +0 -4
  33. package/lib/fivePlugins/ModelTVVideoPlugin/index.js +11 -60
  34. package/lib/index.js +0 -1
  35. package/lib/react/index.js +7 -34
  36. package/lib/shared-utils/Audio.js +15 -69
  37. package/lib/shared-utils/AudioLike.js +5 -39
  38. package/lib/shared-utils/Preloader.js +0 -7
  39. package/lib/shared-utils/addResizeListener.js +0 -5
  40. package/lib/shared-utils/animationFrame/BetterTween.js +2 -38
  41. package/lib/shared-utils/animationFrame/index.js +2 -10
  42. package/lib/shared-utils/animationFrame/tween.js +2 -11
  43. package/lib/shared-utils/createTransMatrix.js +2 -17
  44. package/lib/shared-utils/getFileExpandedName.js +0 -1
  45. package/lib/shared-utils/getMediaInfo.js +0 -9
  46. package/lib/shared-utils/setElementDataset.js +0 -2
  47. package/lib/typings/VreoUnit.js +0 -15
  48. package/package.json +2 -2
@@ -1,30 +1,19 @@
1
1
  "use strict";
2
2
 
3
3
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports["default"] = exports.CSS3DRenderPlugin = void 0;
9
-
10
8
  var THREE = _interopRequireWildcard(require("three"));
11
-
12
9
  var _CSS3DRenderer = require("three/examples/jsm/renderers/CSS3DRenderer");
13
-
14
10
  var _evenNumber = _interopRequireDefault(require("./evenNumber"));
15
-
16
11
  var _centerPoint = _interopRequireDefault(require("./centerPoint"));
17
-
18
12
  var _transformPositionToVector = _interopRequireDefault(require("./transformPositionToVector3"));
19
-
20
13
  var _createResizeObserver = _interopRequireDefault(require("./createResizeObserver"));
21
-
22
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
-
24
15
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
25
-
26
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
27
-
28
17
  /**
29
18
  * **CSS3DRenderPlugin** 提供矩形区域(三维空间四个坐标点),你可以在此矩形区域中渲染 DOM 内容。
30
19
  * 实现原理参考[CSS3DRenderer](https://threejs.org/docs/index.html?q=CSS3D#examples/en/renderers/CSS3DRenderer)。
@@ -35,14 +24,11 @@ var CSS3DRenderPlugin = function CSS3DRenderPlugin(five) {
35
24
  var state = {
36
25
  disposeCallbacks: []
37
26
  };
38
-
39
27
  var create3DDomContainer = function create3DDomContainer() {
40
28
  var _five$model, _five$model2, _config$autoRender;
41
-
42
29
  for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
43
30
  params[_key] = arguments[_key];
44
31
  }
45
-
46
32
  var points = params[0].map(function (point) {
47
33
  return point instanceof THREE.Vector3 ? point : (0, _transformPositionToVector["default"])(point);
48
34
  });
@@ -59,43 +45,40 @@ var CSS3DRenderPlugin = function CSS3DRenderPlugin(five) {
59
45
  var autoRender = (_config$autoRender = config === null || config === void 0 ? void 0 : config.autoRender) !== null && _config$autoRender !== void 0 ? _config$autoRender : true;
60
46
  var behindFiveContainer = (config === null || config === void 0 ? void 0 : config.behindFiveContainer) || fiveElement.parentElement || document.body;
61
47
  var container = (config === null || config === void 0 ? void 0 : config.container) || document.createElement('div');
62
- container.classList.add('__Vreo-plugin--CSS3DRenderPlugin'); // 获取css3DObject, 如果mode为behind的话,一起获取mesh
48
+ container.classList.add('__Vreo-plugin--CSS3DRenderPlugin');
63
49
 
50
+ // 获取css3DObject, 如果mode为behind的话,一起获取mesh
64
51
  var _createObject = createObject(points, {
65
- ratio: ratio,
66
- dpr: dpr,
67
- container: container,
68
- mode: mode
69
- }),
70
- css3DObject = _createObject.css3DObject,
71
- mesh = _createObject.mesh; // ======= INIT START =======
72
-
73
-
52
+ ratio: ratio,
53
+ dpr: dpr,
54
+ container: container,
55
+ mode: mode
56
+ }),
57
+ css3DObject = _createObject.css3DObject,
58
+ mesh = _createObject.mesh;
59
+
60
+ // ======= INIT START =======
74
61
  var resizeObserver;
75
62
  var frontModeUnInited = mode === 'front' && !state.frontMode;
76
63
  var behindModeUnInited = mode === 'behind' && !state.behindMode;
77
64
  var inited = !(frontModeUnInited || behindModeUnInited);
78
65
  var stopRenderFlag = false;
79
66
  var requestAnimationFrameId = null;
80
-
81
67
  if (behindModeUnInited) {
82
68
  state.behindMode = {
83
69
  scene: new THREE.Scene(),
84
70
  css3DRenderer: new _CSS3DRenderer.CSS3DRenderer()
85
71
  };
86
72
  }
87
-
88
73
  if (frontModeUnInited) {
89
74
  state.frontMode = {
90
75
  scene: new THREE.Scene(),
91
76
  css3DRenderer: new _CSS3DRenderer.CSS3DRenderer()
92
77
  };
93
78
  }
94
-
95
79
  var _ref = mode === 'behind' ? state.behindMode : state.frontMode,
96
- scene = _ref.scene,
97
- css3DRenderer = _ref.css3DRenderer;
98
-
80
+ scene = _ref.scene,
81
+ css3DRenderer = _ref.css3DRenderer;
99
82
  var render = function () {
100
83
  if (!inited) {
101
84
  var css3DRendererSetSize = function css3DRendererSetSize() {
@@ -109,27 +92,22 @@ var CSS3DRenderPlugin = function CSS3DRenderPlugin(five) {
109
92
  });
110
93
  css3DRenderer.setSize(rendererWidth, rendererHeight);
111
94
  };
112
-
113
95
  css3DRendererSetSize();
114
96
  resizeObserver = (0, _createResizeObserver["default"])(css3DRendererSetSize, fiveElement);
115
97
  css3DRenderer.domElement.style.position = 'absolute';
116
98
  css3DRenderer.domElement.style.top = '0';
117
99
  css3DRenderer.domElement.style.userSelect = 'none';
118
100
  css3DRenderer.domElement.style.pointerEvents = 'none';
119
-
120
101
  var renderEveryFrame = function renderEveryFrame() {
121
102
  if (stopRenderFlag) return;
122
103
  requestAnimationFrameId = requestAnimationFrame(renderEveryFrame);
123
104
  css3DRenderer.render(scene, five.camera);
124
105
  };
125
-
126
106
  return function () {
127
107
  var _resizeObserver, _resizeObserver$obser;
128
-
129
108
  scene.add(css3DObject);
130
109
  (_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 ? void 0 : (_resizeObserver$obser = _resizeObserver.observe) === null || _resizeObserver$obser === void 0 ? void 0 : _resizeObserver$obser.call(_resizeObserver);
131
110
  renderEveryFrame();
132
-
133
111
  if (mode === 'behind' && mesh) {
134
112
  five.scene.add(mesh);
135
113
  disposers.push(function () {
@@ -143,18 +121,15 @@ var CSS3DRenderPlugin = function CSS3DRenderPlugin(five) {
143
121
  };
144
122
  }
145
123
  }();
146
-
147
124
  if (frontModeUnInited) {
148
125
  var wrapper = fiveElement.parentElement || document.body;
149
126
  wrapper.appendChild(css3DRenderer.domElement);
150
127
  }
151
-
152
128
  if (behindModeUnInited) {
153
129
  var _wrapper = behindFiveContainer;
154
-
155
130
  _wrapper.appendChild(css3DRenderer.domElement);
156
- } // ======= INIT END =======
157
-
131
+ }
132
+ // ======= INIT END =======
158
133
 
159
134
  var dispose = function dispose() {
160
135
  stopRenderFlag = true;
@@ -163,32 +138,25 @@ var CSS3DRenderPlugin = function CSS3DRenderPlugin(five) {
163
138
  });
164
139
  scene.remove(css3DObject);
165
140
  if (typeof requestAnimationFrameId === 'number') cancelAnimationFrame(requestAnimationFrameId);
166
-
167
141
  if (scene.children.length === 0) {
168
142
  css3DRenderer.domElement.remove();
169
143
  if (mode === 'front') state.frontMode = undefined;
170
144
  if (mode === 'behind') state.behindMode = undefined;
171
-
172
145
  if (!state.behindMode && !state.frontMode) {
173
146
  var _resizeObserver2, _resizeObserver2$unob;
174
-
175
147
  (_resizeObserver2 = resizeObserver) === null || _resizeObserver2 === void 0 ? void 0 : (_resizeObserver2$unob = _resizeObserver2.unobserve) === null || _resizeObserver2$unob === void 0 ? void 0 : _resizeObserver2$unob.call(_resizeObserver2);
176
148
  }
177
149
  }
178
-
179
150
  return true;
180
151
  };
181
-
182
152
  var idx = state.disposeCallbacks.findIndex(function (item) {
183
153
  return item === dispose;
184
154
  });
185
-
186
155
  if (idx !== -1) {
187
156
  state.disposeCallbacks.splice(idx, 1);
188
157
  } else {
189
158
  state.disposeCallbacks.push(dispose);
190
159
  }
191
-
192
160
  if (autoRender) render();
193
161
  return {
194
162
  container: container,
@@ -197,12 +165,11 @@ var CSS3DRenderPlugin = function CSS3DRenderPlugin(five) {
197
165
  render: autoRender ? undefined : render
198
166
  };
199
167
  };
200
-
201
168
  var createObject = function createObject(points, config) {
202
169
  var ratio = config.ratio,
203
- dpr = config.dpr,
204
- element = config.container,
205
- mode = config.mode;
170
+ dpr = config.dpr,
171
+ element = config.container,
172
+ mode = config.mode;
206
173
  var planeWidth = points[0].distanceTo(points[1]);
207
174
  var planeHeight = points[1].distanceTo(points[2]);
208
175
  var domWidthPx = (0, _evenNumber["default"])(planeWidth / ratio * dpr);
@@ -214,10 +181,9 @@ var CSS3DRenderPlugin = function CSS3DRenderPlugin(five) {
214
181
  element.style.pointerEvents = 'none';
215
182
  var centerPosition = (0, _centerPoint["default"])(points[0], points[2]);
216
183
  var vector01 = points[1].clone().sub(points[0]); // 点0 -> 点1 的向量
217
-
218
184
  var vector12 = points[2].clone().sub(points[1]); // 点1 -> 点2 的向量
219
- // 旋转
220
185
 
186
+ // 旋转
221
187
  var rotateXAngle = new THREE.Vector3(0, 1, 0).angleTo(new THREE.Vector3(0, vector12.y, vector12.z));
222
188
  var rotateYAngle = new THREE.Vector3(1, 0, 0).angleTo(new THREE.Vector3(vector01.x, 0, vector01.z));
223
189
  var rotateZAngle = vector01.angleTo(new THREE.Vector3(vector01.x, 0, vector01.z));
@@ -226,19 +192,15 @@ var CSS3DRenderPlugin = function CSS3DRenderPlugin(five) {
226
192
  * [0,0,1] => [0,1,0] 为rolate Worldy正方向
227
193
  * [0,1,1] => [-1,0,0] 为rolate Worldz正方向
228
194
  */
229
-
230
195
  var rotateX = (vector12.z > 0 ? -1 : 1) * rotateXAngle;
231
196
  var rotateY = (vector01.z < 0 ? 1 : -1) * rotateYAngle;
232
197
  var rotateZ = (vector01.x > 0 && vector01.y < 0 || vector01.x < 0 && vector01.y > 0 ? -1 : 1) * rotateZAngle;
233
198
  css3DObject.rotateOnWorldAxis(new THREE.Vector3(1, 0, 0), rotateX); // x
234
-
235
199
  css3DObject.rotateOnWorldAxis(new THREE.Vector3(0, 1, 0), rotateY); // y
236
-
237
200
  css3DObject.rotateOnWorldAxis(new THREE.Vector3(0, 0, 1), rotateZ); // z
238
201
 
239
202
  css3DObject.position.set(centerPosition.x, centerPosition.y, centerPosition.z);
240
203
  var mesh;
241
-
242
204
  if (mode === 'behind') {
243
205
  var material = new THREE.MeshBasicMaterial({
244
206
  opacity: 0,
@@ -252,13 +214,11 @@ var CSS3DRenderPlugin = function CSS3DRenderPlugin(five) {
252
214
  mesh.rotation.copy(css3DObject.rotation);
253
215
  mesh.scale.copy(css3DObject.scale);
254
216
  }
255
-
256
217
  return {
257
218
  css3DObject: css3DObject,
258
219
  mesh: mesh
259
220
  };
260
221
  };
261
-
262
222
  return {
263
223
  create3DDomContainer: create3DDomContainer,
264
224
  disposeAll: function disposeAll() {
@@ -269,7 +229,6 @@ var CSS3DRenderPlugin = function CSS3DRenderPlugin(five) {
269
229
  }
270
230
  };
271
231
  };
272
-
273
232
  exports.CSS3DRenderPlugin = CSS3DRenderPlugin;
274
233
  var _default = CSS3DRenderPlugin;
275
234
  exports["default"] = _default;
@@ -4,15 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
-
8
7
  var _three = require("three");
9
-
10
8
  var transformPositionToVector3 = function transformPositionToVector3(_ref) {
11
9
  var x = _ref.x,
12
- y = _ref.y,
13
- z = _ref.z;
10
+ y = _ref.y,
11
+ z = _ref.z;
14
12
  return new _three.Vector3(x, y, z);
15
13
  };
16
-
17
14
  var _default = transformPositionToVector3;
18
15
  exports["default"] = _default;
@@ -1,39 +1,36 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.CameraMovementPlugin = void 0;
7
-
8
8
  var _five = require("@realsee/five");
9
-
10
9
  var _tween = require("@tweenjs/tween.js");
11
-
12
10
  var _typings = require("./typings");
13
-
14
11
  var _tween2 = require("../../shared-utils/animationFrame/tween");
15
-
12
+ 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 exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
16
13
  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); } }
17
-
18
14
  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); }); }; }
19
-
20
15
  var PI = Math.PI;
21
16
  var PI_2 = PI * 2;
22
-
23
17
  function formatLatitude(rad) {
24
18
  return rad % PI_2;
25
19
  }
26
-
27
20
  function formatLongitude(rad) {
28
21
  return rad % PI_2;
29
22
  }
30
-
31
23
  var getLongitudeParams = function getLongitudeParams(from, to, rotation) {
32
24
  from = formatLongitude(from);
33
- to = formatLongitude(to); // 逆时针旋转,初始值必须是较大的值
25
+ to = formatLongitude(to);
26
+
27
+ // 逆时针旋转,初始值必须是较大的值
28
+ if (rotation === _typings.Rotation.Anticlockwise && from > to) to += PI_2;
29
+
30
+ // 顺时针旋转,结束值必须是较大值
31
+ else if (rotation === _typings.Rotation.Clockwise && to > from) from += PI_2;
34
32
 
35
- if (rotation === _typings.Rotation.Anticlockwise && from > to) to += PI_2; // 顺时针旋转,结束值必须是较大值
36
- else if (rotation === _typings.Rotation.Clockwise && to > from) from += PI_2; // Loop 旋转,找锐角旋转
33
+ // Loop 旋转,找锐角旋转
37
34
  // 如果 to 比 from 大 180°,逆时针转
38
35
  // 如果 from 比 to 大 180°,顺时针转
39
36
  else if (rotation !== _typings.Rotation.Anticlockwise && rotation !== _typings.Rotation.Clockwise && to - from > PI) return getLongitudeParams(from, to, _typings.Rotation.Clockwise);else if (rotation !== _typings.Rotation.Anticlockwise && rotation !== _typings.Rotation.Clockwise && from - to > PI) return getLongitudeParams(from, to, _typings.Rotation.Anticlockwise);
@@ -42,44 +39,38 @@ var getLongitudeParams = function getLongitudeParams(from, to, rotation) {
42
39
  to: to
43
40
  };
44
41
  };
45
-
46
42
  function progressNumber(from, to, pst) {
47
43
  return from + (to - from) * pst;
48
44
  }
45
+
49
46
  /**
50
47
  * **运镜插件** 模拟类似于电影运镜效果。
51
48
  */
52
-
53
-
54
49
  var CameraMovementPlugin = function CameraMovementPlugin(five) {
55
50
  var move = function move(args, duration) {
56
51
  var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
57
52
  preload: true
58
53
  };
59
54
  return new Promise( /*#__PURE__*/function () {
60
- var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(resolve, reject) {
55
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resolve, reject) {
61
56
  var panoIndex, movePanoOptions;
62
- return regeneratorRuntime.wrap(function _callee$(_context) {
57
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
63
58
  while (1) {
64
59
  switch (_context.prev = _context.next) {
65
60
  case 0:
66
61
  if (opts.asyncStartCallback) {
67
62
  opts.asyncStartCallback();
68
63
  }
69
-
70
64
  if (!(five.panoIndex === undefined)) {
71
65
  _context.next = 3;
72
66
  break;
73
67
  }
74
-
75
68
  return _context.abrupt("return", reject(false));
76
-
77
69
  case 3:
78
70
  if (!(args.mode && args.mode !== five.currentMode)) {
79
71
  _context.next = 6;
80
72
  break;
81
73
  }
82
-
83
74
  _context.next = 6;
84
75
  return new Promise(function (resolve) {
85
76
  if (!args.mode) return;
@@ -97,44 +88,34 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
97
88
  panoIndex: args.panoIndex || undefined
98
89
  });
99
90
  });
100
-
101
91
  case 6:
102
92
  if (!(args.mode === _five.Five.Mode.Floorplan)) {
103
93
  _context.next = 8;
104
94
  break;
105
95
  }
106
-
107
96
  return _context.abrupt("return", resolve(true));
108
-
109
97
  case 8:
110
98
  if (!(opts.preload && args.panoIndex !== undefined && args.panoIndex !== five.panoIndex)) {
111
99
  _context.next = 11;
112
100
  break;
113
101
  }
114
-
115
102
  _context.next = 11;
116
103
  return five.preloadPano(args.panoIndex);
117
-
118
104
  case 11:
119
105
  if (opts.asyncEndCallback) {
120
106
  opts.asyncEndCallback();
121
107
  }
122
-
123
108
  if (!(args.panoIndex === undefined && args.fov === undefined && args.latitude === undefined && args.longitude === undefined)) {
124
109
  _context.next = 14;
125
110
  break;
126
111
  }
127
-
128
112
  return _context.abrupt("return", resolve(true));
129
-
130
113
  case 14:
131
114
  panoIndex = args.panoIndex !== undefined ? args.panoIndex : five.panoIndex;
132
-
133
115
  if (!(panoIndex !== undefined)) {
134
116
  _context.next = 21;
135
117
  break;
136
118
  }
137
-
138
119
  movePanoOptions = Object.assign(args, {
139
120
  duration: duration,
140
121
  // 移动耗时
@@ -146,18 +127,14 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
146
127
  resolve(true);
147
128
  } // 移动开始
148
129
  // effect: args.transEffect || 'fade',
149
-
150
130
  });
151
131
  _context.next = 19;
152
132
  return five.moveToPano(panoIndex, movePanoOptions);
153
-
154
133
  case 19:
155
134
  _context.next = 22;
156
135
  break;
157
-
158
136
  case 21:
159
137
  reject(false);
160
-
161
138
  case 22:
162
139
  case "end":
163
140
  return _context.stop();
@@ -165,24 +142,21 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
165
142
  }
166
143
  }, _callee);
167
144
  }));
168
-
169
145
  return function (_x, _x2) {
170
146
  return _ref.apply(this, arguments);
171
147
  };
172
148
  }());
173
149
  };
174
-
175
150
  var getAnimeParams = function getAnimeParams(args) {
176
- var currentFiveState = five.state; // latitude
177
-
151
+ var currentFiveState = five.state;
152
+ // latitude
178
153
  var fromLatitude = formatLatitude(currentFiveState.latitude);
179
- var toLatitude = formatLatitude(args.latitude); // longitude
180
-
154
+ var toLatitude = formatLatitude(args.latitude);
155
+ // longitude
181
156
  var _getLongitudeParams = getLongitudeParams(currentFiveState.longitude, args.longitude, args.rotation || _typings.Rotation.Loop),
182
- fromLongitude = _getLongitudeParams.from,
183
- toLongitude = _getLongitudeParams.to; // fov
184
-
185
-
157
+ fromLongitude = _getLongitudeParams.from,
158
+ toLongitude = _getLongitudeParams.to;
159
+ // fov
186
160
  var fromFov = currentFiveState.fov;
187
161
  var toFov = args.fov;
188
162
  return {
@@ -198,48 +172,40 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
198
172
  }
199
173
  };
200
174
  };
201
-
202
175
  var rotate = /*#__PURE__*/function () {
203
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(args, duration) {
176
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(args, duration) {
204
177
  var opts,
205
- _getAnimeParams,
206
- from,
207
- to,
208
- _args2 = arguments;
209
-
210
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
178
+ _getAnimeParams,
179
+ from,
180
+ to,
181
+ _args2 = arguments;
182
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
211
183
  while (1) {
212
184
  switch (_context2.prev = _context2.next) {
213
185
  case 0:
214
186
  opts = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {};
215
-
216
187
  if (opts.asyncStartCallback) {
217
188
  opts.asyncStartCallback();
218
- } // 先切换模型再出旋转效果
219
-
189
+ }
220
190
 
191
+ // 先切换模型再出旋转效果
221
192
  if (!(args.mode && five.currentMode !== args.mode)) {
222
193
  _context2.next = 5;
223
194
  break;
224
195
  }
225
-
226
196
  _context2.next = 5;
227
197
  return five.changeMode(args.mode);
228
-
229
198
  case 5:
230
199
  if (!(args.mode === _five.Five.Mode.Panorama && five.currentMode === _five.Five.Mode.Panorama && args.panoIndex !== undefined && args.panoIndex !== five.panoIndex)) {
231
200
  _context2.next = 11;
232
201
  break;
233
202
  }
234
-
235
203
  if (!opts.preload) {
236
204
  _context2.next = 9;
237
205
  break;
238
206
  }
239
-
240
207
  _context2.next = 9;
241
208
  return five.preloadPano(args.panoIndex);
242
-
243
209
  case 9:
244
210
  _context2.next = 11;
245
211
  return new Promise(function (resolve, reject) {
@@ -255,12 +221,10 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
255
221
  effect: 'fade'
256
222
  });
257
223
  });
258
-
259
224
  case 11:
260
225
  if (opts.asyncEndCallback) {
261
226
  opts.asyncEndCallback();
262
227
  }
263
-
264
228
  _getAnimeParams = getAnimeParams(args), from = _getAnimeParams.from, to = _getAnimeParams.to;
265
229
  _context2.next = 15;
266
230
  return new Promise(function (resolve, reject) {
@@ -272,37 +236,28 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
272
236
  state.fov = progressNumber(from.fov, to.fov, progress);
273
237
  five.setState(state, true);
274
238
  };
275
-
276
239
  var onComplete = function onComplete() {
277
240
  resolve(true);
278
241
  };
279
-
280
242
  var onDestroy = function onDestroy() {
281
243
  resolve(false);
282
244
  };
283
-
284
245
  var animeDuration = duration;
285
-
286
246
  if (args.rotation === _typings.Rotation.Loop) {
287
247
  animeDuration = args.rotateSpeed ? Math.ceil(Math.abs(to.longitude - from.longitude) / args.rotateSpeed * 1000) : duration;
288
248
  }
289
-
290
249
  var tween = (0, _tween2.tweenProgress)(animeDuration, _tween.Easing.Linear.None).onUpdate(onUpdate).onComplete(onComplete).onDestroy(onDestroy);
291
-
292
250
  if (args.rotation === _typings.Rotation.Loop) {
293
251
  tween.repeat(Infinity).yoyo(true);
294
252
  }
295
-
296
253
  setTimeout(function () {
297
254
  // 总时间到了之后强制结束,同时也是 Loop 模式的结束方式
298
255
  tween.destroy();
299
256
  resolve(true);
300
257
  }, duration);
301
258
  });
302
-
303
259
  case 15:
304
260
  return _context2.abrupt("return", _context2.sent);
305
-
306
261
  case 16:
307
262
  case "end":
308
263
  return _context2.stop();
@@ -310,16 +265,13 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
310
265
  }
311
266
  }, _callee2);
312
267
  }));
313
-
314
268
  return function rotate(_x3, _x4) {
315
269
  return _ref2.apply(this, arguments);
316
270
  };
317
271
  }();
318
-
319
272
  return {
320
273
  move: move,
321
274
  rotate: rotate
322
275
  };
323
276
  };
324
-
325
277
  exports.CameraMovementPlugin = CameraMovementPlugin;
@@ -4,20 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Rotation = exports.CameraMovementEffect = void 0;
7
-
8
7
  /* eslint-disable prettier/prettier */
9
8
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
10
9
  var CameraMovementEffect;
11
10
  exports.CameraMovementEffect = CameraMovementEffect;
12
-
13
11
  (function (CameraMovementEffect) {
14
12
  CameraMovementEffect["Move"] = "Move";
15
13
  CameraMovementEffect["Rotate"] = "Rotate";
16
14
  })(CameraMovementEffect || (exports.CameraMovementEffect = CameraMovementEffect = {}));
17
-
18
15
  var Rotation;
19
16
  exports.Rotation = Rotation;
20
-
21
17
  (function (Rotation) {
22
18
  Rotation["Clockwise"] = "Clockwise";
23
19
  Rotation["Anticlockwise"] = "Anticlockwise";