@realsee/vreo 2.3.7 → 2.3.8
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.
- package/lib/PlayController/createHTMLAudioElement.js +7 -13
- package/lib/PlayController/index.js +27 -95
- package/lib/Player/App.js +2 -28
- package/lib/Player/Controller.js +48 -132
- package/lib/Player/custom/SpatialScenePanel/index.js +45 -76
- package/lib/Player/hooks.js +1 -11
- package/lib/Player/index.js +34 -101
- package/lib/Player/modules/Drawer/index.js +2 -19
- package/lib/Player/modules/PopUp/index.js +2 -12
- package/lib/Player/modules/ResizeObserver/index.js +1 -9
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +29 -123
- package/lib/Player/modules/VideoAgent/VideoAgentScene.js +15 -37
- package/lib/Player/modules/VideoAgent/index.js +2 -19
- package/lib/Player/modules/Wave/index.js +14 -43
- package/lib/Player/modules/keyframes/BgMusic/index.js +10 -28
- package/lib/Player/modules/keyframes/CameraMovement/index.js +6 -30
- package/lib/Player/modules/keyframes/InfoPanel/index.js +9 -39
- package/lib/Player/modules/keyframes/ModelVideo/index.js +6 -32
- package/lib/Player/modules/keyframes/PanoEffect/index.js +19 -52
- package/lib/Player/modules/keyframes/PanoEffect/lineAnime.js +1 -8
- package/lib/Player/modules/keyframes/PanoTag/index.js +5 -23
- package/lib/Player/modules/keyframes/PanoTextLabel/index.js +27 -57
- package/lib/Player/modules/keyframes/Prompter/index.js +15 -42
- package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +19 -26
- package/lib/Player/modules/keyframes/VideoEffect/index.js +18 -59
- package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.js +0 -2
- package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.js +0 -1
- package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.js +0 -1
- package/lib/fivePlugins/CSS3DRenderPlugin/index.js +21 -62
- package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.js +2 -5
- package/lib/fivePlugins/CameraMovementPlugin/index.js +20 -74
- package/lib/fivePlugins/CameraMovementPlugin/typings.js +0 -4
- package/lib/fivePlugins/ModelTVVideoPlugin/index.js +15 -69
- package/lib/index.js +0 -1
- package/lib/react/index.js +10 -41
- package/lib/shared-utils/Audio.js +35 -96
- package/lib/shared-utils/AudioLike.js +20 -56
- package/lib/shared-utils/Preloader.js +0 -7
- package/lib/shared-utils/addResizeListener.js +0 -5
- package/lib/shared-utils/animationFrame/BetterTween.js +19 -58
- package/lib/shared-utils/animationFrame/index.js +2 -10
- package/lib/shared-utils/animationFrame/tween.js +2 -11
- package/lib/shared-utils/createTransMatrix.js +5 -26
- package/lib/shared-utils/getFileExpandedName.js +0 -1
- package/lib/shared-utils/getMediaInfo.js +1 -10
- package/lib/shared-utils/setElementDataset.js +0 -2
- package/lib/typings/VreoUnit.js +0 -15
- package/package.json +2 -1
|
@@ -1,30 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = exports.CSS3DRenderPlugin = void 0;
|
|
9
|
-
|
|
10
9
|
var THREE = _interopRequireWildcard(require("three"));
|
|
11
|
-
|
|
12
10
|
var _CSS3DRenderer = require("three/examples/jsm/renderers/CSS3DRenderer");
|
|
13
|
-
|
|
14
11
|
var _evenNumber = _interopRequireDefault(require("./evenNumber"));
|
|
15
|
-
|
|
16
12
|
var _centerPoint = _interopRequireDefault(require("./centerPoint"));
|
|
17
|
-
|
|
18
13
|
var _transformPositionToVector = _interopRequireDefault(require("./transformPositionToVector3"));
|
|
19
|
-
|
|
20
14
|
var _createResizeObserver = _interopRequireDefault(require("./createResizeObserver"));
|
|
21
|
-
|
|
22
|
-
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');
|
|
48
|
+
container.classList.add('__Vreo-plugin--CSS3DRenderPlugin');
|
|
63
49
|
|
|
50
|
+
// 获取css3DObject, 如果mode为behind的话,一起获取mesh
|
|
64
51
|
var _createObject = createObject(points, {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
97
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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
|
-
|
|
13
|
-
|
|
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,26 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.CameraMovementPlugin = void 0;
|
|
7
|
-
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
10
|
var _five = require("@realsee/five");
|
|
9
|
-
|
|
10
11
|
var _typings = require("./typings");
|
|
11
|
-
|
|
12
|
-
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); } }
|
|
13
|
-
|
|
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); }); }; }
|
|
15
|
-
|
|
16
12
|
var PI = Math.PI;
|
|
17
13
|
var PI_2 = PI * 2;
|
|
18
|
-
|
|
19
14
|
function progressNumber(from, to, pst) {
|
|
20
15
|
if (from === to) return from;
|
|
21
16
|
return from + (to - from) * pst;
|
|
22
17
|
}
|
|
23
|
-
|
|
24
18
|
function progressLongitude(fromLongitude, toLongitude, rotation, progress) {
|
|
25
19
|
var clockwise = rotation === _typings.Rotation.Clockwise;
|
|
26
20
|
var delta = clockwise ? fromLongitude - toLongitude : toLongitude - fromLongitude;
|
|
@@ -30,87 +24,69 @@ function progressLongitude(fromLongitude, toLongitude, rotation, progress) {
|
|
|
30
24
|
var progressLongitude = fromLongitude + deltaMod3 * progress;
|
|
31
25
|
return progressLongitude % PI_2;
|
|
32
26
|
}
|
|
27
|
+
|
|
33
28
|
/**
|
|
34
29
|
* **运镜插件** 模拟类似于电影运镜效果。
|
|
35
30
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
31
|
var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
39
32
|
var move = function move(args, duration) {
|
|
40
33
|
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
41
34
|
preload: true
|
|
42
35
|
};
|
|
43
36
|
return new Promise( /*#__PURE__*/function () {
|
|
44
|
-
var _ref =
|
|
37
|
+
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(resolve, reject) {
|
|
45
38
|
var _opts$asyncEndCallbac;
|
|
46
|
-
|
|
47
39
|
var panoIndex, start, movePanoOptions;
|
|
48
|
-
return
|
|
40
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
49
41
|
while (1) {
|
|
50
42
|
switch (_context.prev = _context.next) {
|
|
51
43
|
case 0:
|
|
52
44
|
if (opts.asyncStartCallback) {
|
|
53
45
|
opts.asyncStartCallback();
|
|
54
46
|
}
|
|
55
|
-
|
|
56
47
|
if (!(five.panoIndex === undefined)) {
|
|
57
48
|
_context.next = 3;
|
|
58
49
|
break;
|
|
59
50
|
}
|
|
60
|
-
|
|
61
51
|
return _context.abrupt("return", reject(false));
|
|
62
|
-
|
|
63
52
|
case 3:
|
|
64
53
|
if (!(args.mode && args.mode !== five.currentMode)) {
|
|
65
54
|
_context.next = 7;
|
|
66
55
|
break;
|
|
67
56
|
}
|
|
68
|
-
|
|
69
57
|
_context.next = 6;
|
|
70
58
|
return five.changeMode(args.mode, args, duration);
|
|
71
|
-
|
|
72
59
|
case 6:
|
|
73
60
|
return _context.abrupt("return", resolve(true));
|
|
74
|
-
|
|
75
61
|
case 7:
|
|
76
62
|
if (!(args.mode === _five.Five.Mode.Floorplan)) {
|
|
77
63
|
_context.next = 9;
|
|
78
64
|
break;
|
|
79
65
|
}
|
|
80
|
-
|
|
81
66
|
return _context.abrupt("return", resolve(true));
|
|
82
|
-
|
|
83
67
|
case 9:
|
|
84
68
|
if (!(opts.preload && args.panoIndex !== undefined && args.panoIndex !== five.panoIndex)) {
|
|
85
69
|
_context.next = 12;
|
|
86
70
|
break;
|
|
87
71
|
}
|
|
88
|
-
|
|
89
72
|
_context.next = 12;
|
|
90
73
|
return five.preloadPano(args.panoIndex);
|
|
91
|
-
|
|
92
74
|
case 12:
|
|
93
75
|
(_opts$asyncEndCallbac = opts.asyncEndCallback) === null || _opts$asyncEndCallbac === void 0 ? void 0 : _opts$asyncEndCallbac.call(opts);
|
|
94
|
-
|
|
95
76
|
if (!(args.panoIndex === undefined && args.fov === undefined && args.latitude === undefined && args.longitude === undefined)) {
|
|
96
77
|
_context.next = 15;
|
|
97
78
|
break;
|
|
98
79
|
}
|
|
99
|
-
|
|
100
80
|
return _context.abrupt("return", resolve(true));
|
|
101
|
-
|
|
102
81
|
case 15:
|
|
103
82
|
panoIndex = args.panoIndex !== undefined ? args.panoIndex : five.panoIndex;
|
|
104
|
-
|
|
105
83
|
if (!(panoIndex !== undefined)) {
|
|
106
84
|
_context.next = 25;
|
|
107
85
|
break;
|
|
108
86
|
}
|
|
109
|
-
|
|
110
87
|
start = performance.now();
|
|
111
88
|
_context.next = 20;
|
|
112
89
|
return five.ready();
|
|
113
|
-
|
|
114
90
|
case 20:
|
|
115
91
|
movePanoOptions = Object.assign({}, args, {
|
|
116
92
|
duration: duration - (performance.now() - start),
|
|
@@ -127,14 +103,11 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
127
103
|
});
|
|
128
104
|
_context.next = 23;
|
|
129
105
|
return five.moveToPano(panoIndex, movePanoOptions);
|
|
130
|
-
|
|
131
106
|
case 23:
|
|
132
107
|
_context.next = 26;
|
|
133
108
|
break;
|
|
134
|
-
|
|
135
109
|
case 25:
|
|
136
110
|
reject(false);
|
|
137
|
-
|
|
138
111
|
case 26:
|
|
139
112
|
case "end":
|
|
140
113
|
return _context.stop();
|
|
@@ -142,56 +115,49 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
142
115
|
}
|
|
143
116
|
}, _callee);
|
|
144
117
|
}));
|
|
145
|
-
|
|
146
118
|
return function (_x, _x2) {
|
|
147
119
|
return _ref.apply(this, arguments);
|
|
148
120
|
};
|
|
149
121
|
}());
|
|
150
122
|
};
|
|
151
|
-
|
|
152
123
|
var rotate = /*#__PURE__*/function () {
|
|
153
|
-
var _ref2 =
|
|
124
|
+
var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(args, duration) {
|
|
154
125
|
var _opts$asyncStartCallb, _opts$asyncEndCallbac2;
|
|
155
|
-
|
|
156
126
|
var opts,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return
|
|
127
|
+
from,
|
|
128
|
+
to,
|
|
129
|
+
timeEnd,
|
|
130
|
+
start,
|
|
131
|
+
animeDuration,
|
|
132
|
+
onFiveRenderFrame,
|
|
133
|
+
_args2 = arguments;
|
|
134
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
165
135
|
while (1) {
|
|
166
136
|
switch (_context2.prev = _context2.next) {
|
|
167
137
|
case 0:
|
|
168
138
|
opts = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {};
|
|
169
|
-
(_opts$asyncStartCallb = opts.asyncStartCallback) === null || _opts$asyncStartCallb === void 0 ? void 0 : _opts$asyncStartCallb.call(opts);
|
|
139
|
+
(_opts$asyncStartCallb = opts.asyncStartCallback) === null || _opts$asyncStartCallb === void 0 ? void 0 : _opts$asyncStartCallb.call(opts);
|
|
170
140
|
|
|
141
|
+
// 先切换模型再出旋转效果
|
|
171
142
|
if (!(args.mode && five.currentMode !== args.mode)) {
|
|
172
143
|
_context2.next = 5;
|
|
173
144
|
break;
|
|
174
145
|
}
|
|
175
|
-
|
|
176
146
|
_context2.next = 5;
|
|
177
147
|
return five.changeMode(args.mode, args.mode === _five.Five.Mode.Panorama ? {
|
|
178
148
|
latitude: 0
|
|
179
149
|
} : undefined);
|
|
180
|
-
|
|
181
150
|
case 5:
|
|
182
151
|
if (!(args.mode === _five.Five.Mode.Panorama && five.currentMode === _five.Five.Mode.Panorama && args.panoIndex !== undefined && args.panoIndex !== five.panoIndex)) {
|
|
183
152
|
_context2.next = 11;
|
|
184
153
|
break;
|
|
185
154
|
}
|
|
186
|
-
|
|
187
155
|
if (!opts.preload) {
|
|
188
156
|
_context2.next = 9;
|
|
189
157
|
break;
|
|
190
158
|
}
|
|
191
|
-
|
|
192
159
|
_context2.next = 9;
|
|
193
160
|
return five.preloadPano(args.panoIndex);
|
|
194
|
-
|
|
195
161
|
case 9:
|
|
196
162
|
_context2.next = 11;
|
|
197
163
|
return new Promise(function (resolve, reject) {
|
|
@@ -207,38 +173,30 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
207
173
|
effect: 'fade'
|
|
208
174
|
});
|
|
209
175
|
});
|
|
210
|
-
|
|
211
176
|
case 11:
|
|
212
177
|
_context2.next = 13;
|
|
213
178
|
return five.ready();
|
|
214
|
-
|
|
215
179
|
case 13:
|
|
216
|
-
(_opts$asyncEndCallbac2 = opts.asyncEndCallback) === null || _opts$asyncEndCallbac2 === void 0 ? void 0 : _opts$asyncEndCallbac2.call(opts);
|
|
180
|
+
(_opts$asyncEndCallbac2 = opts.asyncEndCallback) === null || _opts$asyncEndCallbac2 === void 0 ? void 0 : _opts$asyncEndCallbac2.call(opts);
|
|
217
181
|
|
|
182
|
+
// 计算to
|
|
218
183
|
from = five.getCurrentState();
|
|
219
|
-
|
|
220
184
|
to = function () {
|
|
221
185
|
return args;
|
|
222
186
|
}();
|
|
223
|
-
|
|
224
187
|
timeEnd = false; // 开始时间
|
|
225
|
-
|
|
226
188
|
start = performance.now();
|
|
227
189
|
animeDuration = duration;
|
|
228
|
-
|
|
229
190
|
if (args.rotation === _typings.Rotation.Loop) {
|
|
230
191
|
animeDuration = args.rotateSpeed ? Math.ceil(Math.abs(to.longitude - from.longitude) / args.rotateSpeed * 1000) : duration;
|
|
231
192
|
animeDuration = Math.min(duration, animeDuration);
|
|
232
193
|
}
|
|
233
|
-
|
|
234
194
|
onFiveRenderFrame = function onFiveRenderFrame() {
|
|
235
195
|
if (timeEnd) {
|
|
236
196
|
five.off('renderFrame', onFiveRenderFrame);
|
|
237
197
|
return;
|
|
238
198
|
}
|
|
239
|
-
|
|
240
199
|
var targetState = {};
|
|
241
|
-
|
|
242
200
|
if (args.rotation !== _typings.Rotation.Loop) {
|
|
243
201
|
var progress = (performance.now() - start) / duration;
|
|
244
202
|
targetState = {
|
|
@@ -248,13 +206,9 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
248
206
|
};
|
|
249
207
|
} else {
|
|
250
208
|
var _progress = (performance.now() - start) / animeDuration; // 可能大于1
|
|
251
|
-
|
|
252
|
-
|
|
253
209
|
var times = Math.floor(_progress);
|
|
254
210
|
var progress2 = _progress - times; // 一定小于1
|
|
255
|
-
|
|
256
211
|
var isNegative = times % 2 === 1; // 是否为反向旋转, 0: 正, 1: 反, 2: 正, 3: 反 以此类推
|
|
257
|
-
|
|
258
212
|
var resultProgress = isNegative ? 1 - progress2 : progress2;
|
|
259
213
|
targetState = {
|
|
260
214
|
fov: progressNumber(from.fov, to.fov, resultProgress),
|
|
@@ -262,25 +216,20 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
262
216
|
longitude: progressNumber(from.longitude, to.longitude, resultProgress)
|
|
263
217
|
};
|
|
264
218
|
}
|
|
265
|
-
|
|
266
219
|
five.setState(targetState, true);
|
|
267
220
|
};
|
|
268
|
-
|
|
269
221
|
five.on('renderFrame', onFiveRenderFrame);
|
|
270
222
|
_context2.next = 24;
|
|
271
223
|
return new Promise(function (resolve) {
|
|
272
224
|
setTimeout(function () {
|
|
273
225
|
timeEnd = true;
|
|
274
|
-
five.off('renderFrame', onFiveRenderFrame);
|
|
275
|
-
|
|
226
|
+
five.off('renderFrame', onFiveRenderFrame);
|
|
276
227
|
// 总时间到了之后强制结束,同时也是 Loop 模式的结束方式
|
|
277
228
|
resolve(true);
|
|
278
229
|
}, duration);
|
|
279
230
|
});
|
|
280
|
-
|
|
281
231
|
case 24:
|
|
282
232
|
return _context2.abrupt("return", _context2.sent);
|
|
283
|
-
|
|
284
233
|
case 25:
|
|
285
234
|
case "end":
|
|
286
235
|
return _context2.stop();
|
|
@@ -288,16 +237,13 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
288
237
|
}
|
|
289
238
|
}, _callee2);
|
|
290
239
|
}));
|
|
291
|
-
|
|
292
240
|
return function rotate(_x3, _x4) {
|
|
293
241
|
return _ref2.apply(this, arguments);
|
|
294
242
|
};
|
|
295
243
|
}();
|
|
296
|
-
|
|
297
244
|
return {
|
|
298
245
|
move: move,
|
|
299
246
|
rotate: rotate
|
|
300
247
|
};
|
|
301
248
|
};
|
|
302
|
-
|
|
303
249
|
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";
|