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