@realsee/vreo 2.3.8 → 2.3.9-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.
- 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 +93 -35
- 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,6 +46,7 @@ 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) {
|
|
@@ -44,49 +55,65 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
44
55
|
if (opts.asyncStartCallback) {
|
|
45
56
|
opts.asyncStartCallback();
|
|
46
57
|
}
|
|
58
|
+
|
|
47
59
|
if (!(five.panoIndex === undefined)) {
|
|
48
60
|
_context.next = 3;
|
|
49
61
|
break;
|
|
50
62
|
}
|
|
63
|
+
|
|
51
64
|
return _context.abrupt("return", reject(false));
|
|
65
|
+
|
|
52
66
|
case 3:
|
|
53
67
|
if (!(args.mode && args.mode !== five.currentMode)) {
|
|
54
68
|
_context.next = 7;
|
|
55
69
|
break;
|
|
56
70
|
}
|
|
71
|
+
|
|
57
72
|
_context.next = 6;
|
|
58
73
|
return five.changeMode(args.mode, args, duration);
|
|
74
|
+
|
|
59
75
|
case 6:
|
|
60
76
|
return _context.abrupt("return", resolve(true));
|
|
77
|
+
|
|
61
78
|
case 7:
|
|
62
79
|
if (!(args.mode === _five.Five.Mode.Floorplan)) {
|
|
63
80
|
_context.next = 9;
|
|
64
81
|
break;
|
|
65
82
|
}
|
|
83
|
+
|
|
66
84
|
return _context.abrupt("return", resolve(true));
|
|
85
|
+
|
|
67
86
|
case 9:
|
|
68
87
|
if (!(opts.preload && args.panoIndex !== undefined && args.panoIndex !== five.panoIndex)) {
|
|
69
88
|
_context.next = 12;
|
|
70
89
|
break;
|
|
71
90
|
}
|
|
91
|
+
|
|
72
92
|
_context.next = 12;
|
|
73
93
|
return five.preloadPano(args.panoIndex);
|
|
94
|
+
|
|
74
95
|
case 12:
|
|
75
96
|
(_opts$asyncEndCallbac = opts.asyncEndCallback) === null || _opts$asyncEndCallbac === void 0 ? void 0 : _opts$asyncEndCallbac.call(opts);
|
|
97
|
+
|
|
76
98
|
if (!(args.panoIndex === undefined && args.fov === undefined && args.latitude === undefined && args.longitude === undefined)) {
|
|
77
99
|
_context.next = 15;
|
|
78
100
|
break;
|
|
79
101
|
}
|
|
102
|
+
|
|
80
103
|
return _context.abrupt("return", resolve(true));
|
|
104
|
+
|
|
81
105
|
case 15:
|
|
82
106
|
panoIndex = args.panoIndex !== undefined ? args.panoIndex : five.panoIndex;
|
|
107
|
+
|
|
83
108
|
if (!(panoIndex !== undefined)) {
|
|
84
|
-
_context.next =
|
|
109
|
+
_context.next = 26;
|
|
85
110
|
break;
|
|
86
111
|
}
|
|
112
|
+
|
|
87
113
|
start = performance.now();
|
|
88
114
|
_context.next = 20;
|
|
89
115
|
return five.ready();
|
|
116
|
+
|
|
90
117
|
case 20:
|
|
91
118
|
movePanoOptions = Object.assign({}, args, {
|
|
92
119
|
duration: duration - (performance.now() - start),
|
|
@@ -101,65 +128,77 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
101
128
|
// 移动开始
|
|
102
129
|
effect: args.transEffect || 'fly'
|
|
103
130
|
});
|
|
104
|
-
|
|
131
|
+
moving = true;
|
|
132
|
+
_context.next = 24;
|
|
105
133
|
return five.moveToPano(panoIndex, movePanoOptions);
|
|
106
|
-
|
|
107
|
-
|
|
134
|
+
|
|
135
|
+
case 24:
|
|
136
|
+
_context.next = 27;
|
|
108
137
|
break;
|
|
109
|
-
|
|
110
|
-
reject(false);
|
|
138
|
+
|
|
111
139
|
case 26:
|
|
140
|
+
reject(false);
|
|
141
|
+
|
|
142
|
+
case 27:
|
|
112
143
|
case "end":
|
|
113
144
|
return _context.stop();
|
|
114
145
|
}
|
|
115
146
|
}
|
|
116
147
|
}, _callee);
|
|
117
148
|
}));
|
|
149
|
+
|
|
118
150
|
return function (_x, _x2) {
|
|
119
151
|
return _ref.apply(this, arguments);
|
|
120
152
|
};
|
|
121
153
|
}());
|
|
122
154
|
};
|
|
155
|
+
|
|
123
156
|
var rotate = /*#__PURE__*/function () {
|
|
124
157
|
var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(args, duration) {
|
|
125
158
|
var _opts$asyncStartCallb, _opts$asyncEndCallbac2;
|
|
159
|
+
|
|
126
160
|
var opts,
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
161
|
+
from,
|
|
162
|
+
to,
|
|
163
|
+
timeEnd,
|
|
164
|
+
start,
|
|
165
|
+
animeDuration,
|
|
166
|
+
onFiveRenderFrame,
|
|
167
|
+
_args2 = arguments;
|
|
134
168
|
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
135
169
|
while (1) {
|
|
136
170
|
switch (_context2.prev = _context2.next) {
|
|
137
171
|
case 0:
|
|
138
172
|
opts = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {};
|
|
139
|
-
|
|
173
|
+
moving = false;
|
|
174
|
+
(_opts$asyncStartCallb = opts.asyncStartCallback) === null || _opts$asyncStartCallb === void 0 ? void 0 : _opts$asyncStartCallb.call(opts); // 先切换模型再出旋转效果
|
|
140
175
|
|
|
141
|
-
// 先切换模型再出旋转效果
|
|
142
176
|
if (!(args.mode && five.currentMode !== args.mode)) {
|
|
143
|
-
_context2.next =
|
|
177
|
+
_context2.next = 6;
|
|
144
178
|
break;
|
|
145
179
|
}
|
|
146
|
-
|
|
180
|
+
|
|
181
|
+
_context2.next = 6;
|
|
147
182
|
return five.changeMode(args.mode, args.mode === _five.Five.Mode.Panorama ? {
|
|
148
183
|
latitude: 0
|
|
149
184
|
} : undefined);
|
|
150
|
-
|
|
185
|
+
|
|
186
|
+
case 6:
|
|
151
187
|
if (!(args.mode === _five.Five.Mode.Panorama && five.currentMode === _five.Five.Mode.Panorama && args.panoIndex !== undefined && args.panoIndex !== five.panoIndex)) {
|
|
152
|
-
_context2.next =
|
|
188
|
+
_context2.next = 12;
|
|
153
189
|
break;
|
|
154
190
|
}
|
|
191
|
+
|
|
155
192
|
if (!opts.preload) {
|
|
156
|
-
_context2.next =
|
|
193
|
+
_context2.next = 10;
|
|
157
194
|
break;
|
|
158
195
|
}
|
|
159
|
-
|
|
196
|
+
|
|
197
|
+
_context2.next = 10;
|
|
160
198
|
return five.preloadPano(args.panoIndex);
|
|
161
|
-
|
|
162
|
-
|
|
199
|
+
|
|
200
|
+
case 10:
|
|
201
|
+
_context2.next = 12;
|
|
163
202
|
return new Promise(function (resolve, reject) {
|
|
164
203
|
five.moveToPano(args.panoIndex, {
|
|
165
204
|
moveEndCallback: function moveEndCallback() {
|
|
@@ -173,30 +212,38 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
173
212
|
effect: 'fade'
|
|
174
213
|
});
|
|
175
214
|
});
|
|
176
|
-
|
|
177
|
-
|
|
215
|
+
|
|
216
|
+
case 12:
|
|
217
|
+
_context2.next = 14;
|
|
178
218
|
return five.ready();
|
|
179
|
-
case 13:
|
|
180
|
-
(_opts$asyncEndCallbac2 = opts.asyncEndCallback) === null || _opts$asyncEndCallbac2 === void 0 ? void 0 : _opts$asyncEndCallbac2.call(opts);
|
|
181
219
|
|
|
182
|
-
|
|
220
|
+
case 14:
|
|
221
|
+
(_opts$asyncEndCallbac2 = opts.asyncEndCallback) === null || _opts$asyncEndCallbac2 === void 0 ? void 0 : _opts$asyncEndCallbac2.call(opts); // 计算to
|
|
222
|
+
|
|
183
223
|
from = five.getCurrentState();
|
|
224
|
+
|
|
184
225
|
to = function () {
|
|
185
226
|
return args;
|
|
186
227
|
}();
|
|
228
|
+
|
|
187
229
|
timeEnd = false; // 开始时间
|
|
230
|
+
|
|
188
231
|
start = performance.now();
|
|
189
232
|
animeDuration = duration;
|
|
233
|
+
|
|
190
234
|
if (args.rotation === _typings.Rotation.Loop) {
|
|
191
235
|
animeDuration = args.rotateSpeed ? Math.ceil(Math.abs(to.longitude - from.longitude) / args.rotateSpeed * 1000) : duration;
|
|
192
236
|
animeDuration = Math.min(duration, animeDuration);
|
|
193
237
|
}
|
|
238
|
+
|
|
194
239
|
onFiveRenderFrame = function onFiveRenderFrame() {
|
|
195
|
-
if (timeEnd) {
|
|
240
|
+
if (timeEnd || moving) {
|
|
196
241
|
five.off('renderFrame', onFiveRenderFrame);
|
|
197
242
|
return;
|
|
198
243
|
}
|
|
244
|
+
|
|
199
245
|
var targetState = {};
|
|
246
|
+
|
|
200
247
|
if (args.rotation !== _typings.Rotation.Loop) {
|
|
201
248
|
var progress = (performance.now() - start) / duration;
|
|
202
249
|
targetState = {
|
|
@@ -206,9 +253,13 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
206
253
|
};
|
|
207
254
|
} else {
|
|
208
255
|
var _progress = (performance.now() - start) / animeDuration; // 可能大于1
|
|
256
|
+
|
|
257
|
+
|
|
209
258
|
var times = Math.floor(_progress);
|
|
210
259
|
var progress2 = _progress - times; // 一定小于1
|
|
260
|
+
|
|
211
261
|
var isNegative = times % 2 === 1; // 是否为反向旋转, 0: 正, 1: 反, 2: 正, 3: 反 以此类推
|
|
262
|
+
|
|
212
263
|
var resultProgress = isNegative ? 1 - progress2 : progress2;
|
|
213
264
|
targetState = {
|
|
214
265
|
fov: progressNumber(from.fov, to.fov, resultProgress),
|
|
@@ -216,34 +267,41 @@ var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
216
267
|
longitude: progressNumber(from.longitude, to.longitude, resultProgress)
|
|
217
268
|
};
|
|
218
269
|
}
|
|
270
|
+
|
|
219
271
|
five.setState(targetState, true);
|
|
220
272
|
};
|
|
273
|
+
|
|
221
274
|
five.on('renderFrame', onFiveRenderFrame);
|
|
222
|
-
_context2.next =
|
|
275
|
+
_context2.next = 25;
|
|
223
276
|
return new Promise(function (resolve) {
|
|
224
277
|
setTimeout(function () {
|
|
225
278
|
timeEnd = true;
|
|
226
|
-
five.off('renderFrame', onFiveRenderFrame);
|
|
227
|
-
|
|
279
|
+
five.off('renderFrame', onFiveRenderFrame); // 总时间到了之后强制结束,同时也是 Loop 模式的结束方式
|
|
280
|
+
|
|
228
281
|
resolve(true);
|
|
229
282
|
}, duration);
|
|
230
283
|
});
|
|
231
|
-
|
|
232
|
-
return _context2.abrupt("return", _context2.sent);
|
|
284
|
+
|
|
233
285
|
case 25:
|
|
286
|
+
return _context2.abrupt("return", _context2.sent);
|
|
287
|
+
|
|
288
|
+
case 26:
|
|
234
289
|
case "end":
|
|
235
290
|
return _context2.stop();
|
|
236
291
|
}
|
|
237
292
|
}
|
|
238
293
|
}, _callee2);
|
|
239
294
|
}));
|
|
295
|
+
|
|
240
296
|
return function rotate(_x3, _x4) {
|
|
241
297
|
return _ref2.apply(this, arguments);
|
|
242
298
|
};
|
|
243
299
|
}();
|
|
300
|
+
|
|
244
301
|
return {
|
|
245
302
|
move: move,
|
|
246
303
|
rotate: rotate
|
|
247
304
|
};
|
|
248
305
|
};
|
|
306
|
+
|
|
249
307
|
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";
|