@realsee/vreo 1.1.0-dev.2 → 1.2.1-alpha.0

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