@realsee/vreo 2.4.2 → 2.4.3
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 +11 -9
- package/lib/PlayController/index.js +61 -52
- package/lib/Player/App.js +1 -1
- package/lib/Player/Controller.js +28 -23
- package/lib/Player/custom/SpatialScenePanel/index.js +10 -10
- package/lib/Player/index.js +94 -90
- package/lib/Player/modules/Drawer/index.js +1 -1
- package/lib/Player/modules/PopUp/index.js +1 -1
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +143 -134
- package/lib/Player/modules/VideoAgent/VideoAgentScene.js +2 -2
- package/lib/Player/modules/VideoAgent/index.js +2 -2
- package/lib/Player/modules/Wave/index.js +1 -1
- package/lib/Player/modules/keyframes/BgMusic/index.js +41 -39
- package/lib/Player/modules/keyframes/CameraMovement/index.js +43 -41
- package/lib/Player/modules/keyframes/InfoPanel/index.js +6 -6
- package/lib/Player/modules/keyframes/ModelVideo/index.js +53 -51
- package/lib/Player/modules/keyframes/PanoEffect/index.js +1 -1
- package/lib/Player/modules/keyframes/PanoEffect/lineAnime.js +1 -1
- package/lib/Player/modules/keyframes/PanoTag/index.js +2 -2
- package/lib/Player/modules/keyframes/PanoTextLabel/index.js +3 -3
- package/lib/Player/modules/keyframes/Prompter/index.js +1 -1
- package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +5 -5
- package/lib/Player/modules/keyframes/VideoEffect/index.js +44 -42
- package/lib/Player/typings.d.ts +1 -4
- package/lib/fivePlugins/CSS3DRenderPlugin/index.js +7 -7
- package/lib/fivePlugins/CameraMovementPlugin/index.js +171 -167
- package/lib/fivePlugins/CameraMovementPlugin/typings.js +6 -6
- package/lib/fivePlugins/ModelTVVideoPlugin/index.js +30 -28
- package/lib/react/index.d.ts +1 -1
- package/lib/react/index.js +2 -2
- package/lib/shared-utils/Audio.d.ts +8 -0
- package/lib/shared-utils/Audio.js +62 -46
- package/lib/shared-utils/AudioLike.js +13 -10
- package/lib/shared-utils/animationFrame/BetterTween.d.ts +4 -2
- package/lib/shared-utils/animationFrame/BetterTween.js +19 -15
- package/lib/shared-utils/animationFrame/tween.d.ts +4 -2
- package/lib/shared-utils/animationFrame/tween.js +12 -1
- package/lib/shared-utils/createTransMatrix.js +1 -1
- package/lib/typings/VreoUnit.js +26 -69
- package/package.json +20 -24
|
@@ -13,18 +13,18 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
13
13
|
var React = _interopRequireWildcard(require("react"));
|
|
14
14
|
var _VreoUnit = require("../../../../typings/VreoUnit");
|
|
15
15
|
var _hooks = require("../../../hooks");
|
|
16
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
16
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) { "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); } return f; })(e, t); }
|
|
17
17
|
// import { Preloader } from '../../../../shared-utils/Preloader'
|
|
18
18
|
|
|
19
19
|
var inlinePlay = function inlinePlay(videoInstance) {
|
|
20
20
|
if (!videoInstance) return;
|
|
21
|
-
var
|
|
22
|
-
videoInstance.removeEventListener('canplaythrough',
|
|
21
|
+
var canplaythrough = function canplaythrough() {
|
|
22
|
+
videoInstance.removeEventListener('canplaythrough', canplaythrough);
|
|
23
23
|
try {
|
|
24
24
|
videoInstance.play();
|
|
25
25
|
} catch (error) {}
|
|
26
26
|
};
|
|
27
|
-
videoInstance.addEventListener('canplaythrough',
|
|
27
|
+
videoInstance.addEventListener('canplaythrough', canplaythrough);
|
|
28
28
|
videoInstance.load();
|
|
29
29
|
};
|
|
30
30
|
|
|
@@ -50,40 +50,42 @@ function VideoEffect() {
|
|
|
50
50
|
var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(keyframe) {
|
|
51
51
|
var start, end, _ref2, videoSrc, fov, direction, panoIndex, vector, _ref3, _ref4, longitude, latitude;
|
|
52
52
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
53
|
-
while (1)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
53
|
+
while (1) {
|
|
54
|
+
switch (_context.prev = _context.next) {
|
|
55
|
+
case 0:
|
|
56
|
+
start = keyframe.start, end = keyframe.end;
|
|
57
|
+
_ref2 = keyframe.data, videoSrc = _ref2.videoSrc, fov = _ref2.fov, direction = _ref2.direction, panoIndex = _ref2.panoIndex, vector = _ref2.vector;
|
|
58
|
+
_ref3 = function () {
|
|
59
|
+
if (vector) {
|
|
60
|
+
return [vector.longitude, vector.latitude];
|
|
61
|
+
}
|
|
62
|
+
if (!direction) {
|
|
63
|
+
return [0, 0];
|
|
64
|
+
}
|
|
65
|
+
var longitude = -Math.atan2(direction.x, -direction.z);
|
|
66
|
+
longitude = (longitude % PI_2 + PI_2) % PI_2;
|
|
67
|
+
var latitude = -Math.asin(direction.y / 1);
|
|
68
|
+
return [longitude, latitude];
|
|
69
|
+
}(), _ref4 = (0, _slicedToArray2["default"])(_ref3, 2), longitude = _ref4[0], latitude = _ref4[1];
|
|
70
|
+
five.setState({
|
|
71
|
+
fov: fov,
|
|
72
|
+
panoIndex: panoIndex,
|
|
73
|
+
longitude: longitude,
|
|
74
|
+
latitude: latitude
|
|
75
|
+
}, true);
|
|
76
|
+
setBlobSrc(videoSrc);
|
|
77
|
+
inlinePlay(videoRef.current);
|
|
78
|
+
setVisible(true);
|
|
79
|
+
timeoutRef.current = setTimeout(function () {
|
|
80
|
+
var _videoRef$current;
|
|
81
|
+
(_videoRef$current = videoRef.current) === null || _videoRef$current === void 0 ? void 0 : _videoRef$current.pause();
|
|
82
|
+
setVisible(false);
|
|
83
|
+
setBlobSrc('');
|
|
84
|
+
}, end - start);
|
|
85
|
+
case 8:
|
|
86
|
+
case "end":
|
|
87
|
+
return _context.stop();
|
|
88
|
+
}
|
|
87
89
|
}
|
|
88
90
|
}, _callee);
|
|
89
91
|
}));
|
|
@@ -97,7 +99,7 @@ function VideoEffect() {
|
|
|
97
99
|
if (timeoutRef.current) {
|
|
98
100
|
clearTimeout(timeoutRef.current);
|
|
99
101
|
}
|
|
100
|
-
(_videoRef$current2 = videoRef.current) === null || _videoRef$current2 === void 0
|
|
102
|
+
(_videoRef$current2 = videoRef.current) === null || _videoRef$current2 === void 0 ? void 0 : _videoRef$current2.pause();
|
|
101
103
|
setVisible(false);
|
|
102
104
|
setBlobSrc('');
|
|
103
105
|
};
|
|
@@ -115,9 +117,9 @@ function VideoEffect() {
|
|
|
115
117
|
};
|
|
116
118
|
}, [controller]);
|
|
117
119
|
React.useEffect(function () {
|
|
118
|
-
var _controller$configs;
|
|
120
|
+
var _controller$configs, _controller$configs$v;
|
|
119
121
|
if (!ref.current) return;
|
|
120
|
-
var video = ((_controller$configs = controller.configs) === null || _controller$configs === void 0
|
|
122
|
+
var video = ((_controller$configs = controller.configs) === null || _controller$configs === void 0 ? void 0 : (_controller$configs$v = _controller$configs.videos) === null || _controller$configs$v === void 0 ? void 0 : _controller$configs$v.videoEffect) || document.createElement('video');
|
|
121
123
|
// <video playsInline key="VideoEffect-video" className="VideoEffect-video" src={blobSrc} />
|
|
122
124
|
video.setAttribute('playsinline', 'true');
|
|
123
125
|
video.setAttribute('webkit-playsinline', 'true');
|
|
@@ -128,7 +130,7 @@ function VideoEffect() {
|
|
|
128
130
|
ref.current.append(videoRef.current);
|
|
129
131
|
document.addEventListener('WeixinJSBridgeReady', function () {
|
|
130
132
|
var _videoRef$current3;
|
|
131
|
-
(_videoRef$current3 = videoRef.current) === null || _videoRef$current3 === void 0
|
|
133
|
+
(_videoRef$current3 = videoRef.current) === null || _videoRef$current3 === void 0 ? void 0 : _videoRef$current3.play();
|
|
132
134
|
}, false);
|
|
133
135
|
if (!ref.current) return;
|
|
134
136
|
// const asyncfunc = async () => {
|
package/lib/Player/typings.d.ts
CHANGED
|
@@ -2,9 +2,6 @@ import React, { ReactNode } from 'react';
|
|
|
2
2
|
import { Subscribe, Five } from '@realsee/five';
|
|
3
3
|
import { VreoKeyframe, VreoKeyframeConfigMap, VreoKeyframeEvent } from '../typings/VreoUnit';
|
|
4
4
|
import { VideoAgentMeshOptions } from './modules/VideoAgent/VideoAgentMesh';
|
|
5
|
-
export type VreoFunctionComponent<P = {}> = (props: P) => ReactNode;
|
|
6
|
-
/** @deprecated 请使用 VreoFunctionComponent<CustomVreoKeyframeProps> 替代 */
|
|
7
|
-
export type LegacyCustomKeyframe = React.FC<CustomVreoKeyframeProps>;
|
|
8
5
|
export interface PlayerConfigs {
|
|
9
6
|
/**
|
|
10
7
|
* @deprecated rename to container
|
|
@@ -27,7 +24,7 @@ export interface PlayerConfigs {
|
|
|
27
24
|
* 如果需要在 底部面板添加自定义内容,可以传递个 React 组件。
|
|
28
25
|
*/
|
|
29
26
|
customPanelChildren?: ReactNode;
|
|
30
|
-
customKeyframes?:
|
|
27
|
+
customKeyframes?: React.FC<CustomVreoKeyframeProps>[];
|
|
31
28
|
imageOptions?: {
|
|
32
29
|
size: number;
|
|
33
30
|
};
|
|
@@ -13,7 +13,7 @@ var _evenNumber = _interopRequireDefault(require("./evenNumber"));
|
|
|
13
13
|
var _centerPoint = _interopRequireDefault(require("./centerPoint"));
|
|
14
14
|
var _transformPositionToVector = _interopRequireDefault(require("./transformPositionToVector3"));
|
|
15
15
|
var _createResizeObserver = _interopRequireDefault(require("./createResizeObserver"));
|
|
16
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
16
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) { "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); } return f; })(e, t); }
|
|
17
17
|
/**
|
|
18
18
|
* 三维向量
|
|
19
19
|
*/
|
|
@@ -38,7 +38,7 @@ var CSS3DRenderPlugin = exports.CSS3DRenderPlugin = function CSS3DRenderPlugin(f
|
|
|
38
38
|
});
|
|
39
39
|
var config = params[1];
|
|
40
40
|
if ((points === null || points === void 0 ? void 0 : points.length) < 4) return console.error('points must be equal or greater than than 4');
|
|
41
|
-
if (!(five !== null && five !== void 0 && (_five$model = five.model) !== null && _five$model !== void 0 && _five$model.loaded)) return console.error('five.model.loaded is: ', five === null || five === void 0
|
|
41
|
+
if (!(five !== null && five !== void 0 && (_five$model = five.model) !== null && _five$model !== void 0 && _five$model.loaded)) return console.error('five.model.loaded is: ', five === null || five === void 0 ? void 0 : (_five$model2 = five.model) === null || _five$model2 === void 0 ? void 0 : _five$model2.loaded);
|
|
42
42
|
var fiveElement = five.getElement();
|
|
43
43
|
if (!fiveElement) return console.error('five.getElement() is ' + fiveElement);
|
|
44
44
|
var disposers = [];
|
|
@@ -102,16 +102,16 @@ var CSS3DRenderPlugin = exports.CSS3DRenderPlugin = function CSS3DRenderPlugin(f
|
|
|
102
102
|
css3DRenderer.domElement.style.top = '0';
|
|
103
103
|
css3DRenderer.domElement.style.userSelect = 'none';
|
|
104
104
|
css3DRenderer.domElement.style.pointerEvents = 'none';
|
|
105
|
-
var
|
|
105
|
+
var renderEveryFrame = function renderEveryFrame() {
|
|
106
106
|
if (stopRenderFlag) return;
|
|
107
|
-
requestAnimationFrameId = requestAnimationFrame(
|
|
107
|
+
requestAnimationFrameId = requestAnimationFrame(renderEveryFrame);
|
|
108
108
|
css3DRenderer.render(scene, five.camera);
|
|
109
109
|
};
|
|
110
110
|
return function () {
|
|
111
111
|
var _resizeObserver, _resizeObserver$obser;
|
|
112
112
|
scene.add(css3DObject);
|
|
113
|
-
(_resizeObserver = resizeObserver) === null || _resizeObserver === void 0
|
|
114
|
-
|
|
113
|
+
(_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 ? void 0 : (_resizeObserver$obser = _resizeObserver.observe) === null || _resizeObserver$obser === void 0 ? void 0 : _resizeObserver$obser.call(_resizeObserver);
|
|
114
|
+
renderEveryFrame();
|
|
115
115
|
if (mode === 'behind' && mesh) {
|
|
116
116
|
five.scene.add(mesh);
|
|
117
117
|
disposers.push(function () {
|
|
@@ -148,7 +148,7 @@ var CSS3DRenderPlugin = exports.CSS3DRenderPlugin = function CSS3DRenderPlugin(f
|
|
|
148
148
|
if (mode === 'behind') state.behindMode = undefined;
|
|
149
149
|
if (!state.behindMode && !state.frontMode) {
|
|
150
150
|
var _resizeObserver2, _resizeObserver2$unob;
|
|
151
|
-
(_resizeObserver2 = resizeObserver) === null || _resizeObserver2 === void 0
|
|
151
|
+
(_resizeObserver2 = resizeObserver) === null || _resizeObserver2 === void 0 ? void 0 : (_resizeObserver2$unob = _resizeObserver2.unobserve) === null || _resizeObserver2$unob === void 0 ? void 0 : _resizeObserver2$unob.call(_resizeObserver2);
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
return true;
|
|
@@ -40,79 +40,81 @@ var CameraMovementPlugin = exports.CameraMovementPlugin = function CameraMovemen
|
|
|
40
40
|
var _opts$asyncEndCallbac;
|
|
41
41
|
var panoIndex, start, movePanoOptions;
|
|
42
42
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
43
|
-
while (1)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
opts.asyncStartCallback
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
43
|
+
while (1) {
|
|
44
|
+
switch (_context.prev = _context.next) {
|
|
45
|
+
case 0:
|
|
46
|
+
moving = true;
|
|
47
|
+
if (opts.asyncStartCallback) {
|
|
48
|
+
opts.asyncStartCallback();
|
|
49
|
+
}
|
|
50
|
+
if (!(five.panoIndex === undefined)) {
|
|
51
|
+
_context.next = 4;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
return _context.abrupt("return", reject(false));
|
|
55
|
+
case 4:
|
|
56
|
+
if (!(args.mode && args.mode !== five.currentMode)) {
|
|
57
|
+
_context.next = 8;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
_context.next = 7;
|
|
61
|
+
return five.changeMode(args.mode, args, duration);
|
|
62
|
+
case 7:
|
|
63
|
+
return _context.abrupt("return", resolve(true));
|
|
64
|
+
case 8:
|
|
65
|
+
if (!(args.mode === _five.Five.Mode.Floorplan)) {
|
|
66
|
+
_context.next = 10;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
return _context.abrupt("return", resolve(true));
|
|
70
|
+
case 10:
|
|
71
|
+
if (!(opts.preload && args.panoIndex !== undefined && args.panoIndex !== five.panoIndex)) {
|
|
72
|
+
_context.next = 13;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
71
75
|
_context.next = 13;
|
|
76
|
+
return five.preloadPano(args.panoIndex);
|
|
77
|
+
case 13:
|
|
78
|
+
(_opts$asyncEndCallbac = opts.asyncEndCallback) === null || _opts$asyncEndCallbac === void 0 ? void 0 : _opts$asyncEndCallbac.call(opts);
|
|
79
|
+
if (!(args.panoIndex === undefined && args.fov === undefined && args.latitude === undefined && args.longitude === undefined)) {
|
|
80
|
+
_context.next = 16;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
return _context.abrupt("return", resolve(true));
|
|
84
|
+
case 16:
|
|
85
|
+
panoIndex = args.panoIndex !== undefined ? args.panoIndex : five.panoIndex;
|
|
86
|
+
if (!(panoIndex !== undefined)) {
|
|
87
|
+
_context.next = 26;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
start = performance.now();
|
|
91
|
+
_context.next = 21;
|
|
92
|
+
return five.ready();
|
|
93
|
+
case 21:
|
|
94
|
+
movePanoOptions = Object.assign({}, args, {
|
|
95
|
+
duration: duration - (performance.now() - start),
|
|
96
|
+
// 移动耗时
|
|
97
|
+
moveEndCallback: function moveEndCallback() {
|
|
98
|
+
return resolve(true);
|
|
99
|
+
},
|
|
100
|
+
// 移动结束
|
|
101
|
+
moveCancelCallback: function moveCancelCallback() {
|
|
102
|
+
resolve(true);
|
|
103
|
+
},
|
|
104
|
+
// 移动开始
|
|
105
|
+
effect: args.transEffect || 'fly'
|
|
106
|
+
});
|
|
107
|
+
_context.next = 24;
|
|
108
|
+
return five.moveToPano(panoIndex, movePanoOptions);
|
|
109
|
+
case 24:
|
|
110
|
+
_context.next = 27;
|
|
72
111
|
break;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
_context.next = 16;
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
return _context.abrupt("return", resolve(true));
|
|
83
|
-
case 16:
|
|
84
|
-
panoIndex = args.panoIndex !== undefined ? args.panoIndex : five.panoIndex;
|
|
85
|
-
if (!(panoIndex !== undefined)) {
|
|
86
|
-
_context.next = 26;
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
start = performance.now();
|
|
90
|
-
_context.next = 21;
|
|
91
|
-
return five.ready();
|
|
92
|
-
case 21:
|
|
93
|
-
movePanoOptions = Object.assign({}, args, {
|
|
94
|
-
duration: duration - (performance.now() - start),
|
|
95
|
-
// 移动耗时
|
|
96
|
-
moveEndCallback: function moveEndCallback() {
|
|
97
|
-
return resolve(true);
|
|
98
|
-
},
|
|
99
|
-
// 移动结束
|
|
100
|
-
moveCancelCallback: function moveCancelCallback() {
|
|
101
|
-
resolve(true);
|
|
102
|
-
},
|
|
103
|
-
// 移动开始
|
|
104
|
-
effect: args.transEffect || 'fly'
|
|
105
|
-
});
|
|
106
|
-
_context.next = 24;
|
|
107
|
-
return five.moveToPano(panoIndex, movePanoOptions);
|
|
108
|
-
case 24:
|
|
109
|
-
_context.next = 27;
|
|
110
|
-
break;
|
|
111
|
-
case 26:
|
|
112
|
-
reject(false);
|
|
113
|
-
case 27:
|
|
114
|
-
case "end":
|
|
115
|
-
return _context.stop();
|
|
112
|
+
case 26:
|
|
113
|
+
reject(false);
|
|
114
|
+
case 27:
|
|
115
|
+
case "end":
|
|
116
|
+
return _context.stop();
|
|
117
|
+
}
|
|
116
118
|
}
|
|
117
119
|
}, _callee);
|
|
118
120
|
}));
|
|
@@ -130,110 +132,112 @@ var CameraMovementPlugin = exports.CameraMovementPlugin = function CameraMovemen
|
|
|
130
132
|
timeEnd,
|
|
131
133
|
start,
|
|
132
134
|
animeDuration,
|
|
133
|
-
|
|
135
|
+
onFiveRenderFrame,
|
|
134
136
|
_args2 = arguments;
|
|
135
137
|
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
136
|
-
while (1)
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
while (1) {
|
|
139
|
+
switch (_context2.prev = _context2.next) {
|
|
140
|
+
case 0:
|
|
141
|
+
opts = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {};
|
|
142
|
+
moving = false;
|
|
143
|
+
(_opts$asyncStartCallb = opts.asyncStartCallback) === null || _opts$asyncStartCallb === void 0 ? void 0 : _opts$asyncStartCallb.call(opts);
|
|
141
144
|
|
|
142
|
-
|
|
143
|
-
|
|
145
|
+
// 先切换模型再出旋转效果
|
|
146
|
+
if (!(args.mode && five.currentMode !== args.mode)) {
|
|
147
|
+
_context2.next = 6;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
144
150
|
_context2.next = 6;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
151
|
+
return five.changeMode(args.mode, args.mode === _five.Five.Mode.Panorama ? {
|
|
152
|
+
latitude: 0
|
|
153
|
+
} : undefined);
|
|
154
|
+
case 6:
|
|
155
|
+
if (!(args.mode === _five.Five.Mode.Panorama && five.currentMode === _five.Five.Mode.Panorama && args.panoIndex !== undefined && args.panoIndex !== five.panoIndex)) {
|
|
156
|
+
_context2.next = 12;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
if (!opts.preload) {
|
|
160
|
+
_context2.next = 10;
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
157
163
|
_context2.next = 10;
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
// 移动开始
|
|
174
|
-
effect: 'fade'
|
|
164
|
+
return five.preloadPano(args.panoIndex);
|
|
165
|
+
case 10:
|
|
166
|
+
_context2.next = 12;
|
|
167
|
+
return new Promise(function (resolve, reject) {
|
|
168
|
+
five.moveToPano(args.panoIndex, {
|
|
169
|
+
moveEndCallback: function moveEndCallback() {
|
|
170
|
+
return resolve(true);
|
|
171
|
+
},
|
|
172
|
+
// 移动结束
|
|
173
|
+
moveCancelCallback: function moveCancelCallback() {
|
|
174
|
+
return reject(false);
|
|
175
|
+
},
|
|
176
|
+
// 移动开始
|
|
177
|
+
effect: 'fade'
|
|
178
|
+
});
|
|
175
179
|
});
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
(_opts$asyncEndCallbac2 = opts.asyncEndCallback) === null || _opts$asyncEndCallbac2 === void 0 || _opts$asyncEndCallbac2.call(opts);
|
|
180
|
+
case 12:
|
|
181
|
+
_context2.next = 14;
|
|
182
|
+
return five.ready();
|
|
183
|
+
case 14:
|
|
184
|
+
(_opts$asyncEndCallbac2 = opts.asyncEndCallback) === null || _opts$asyncEndCallbac2 === void 0 ? void 0 : _opts$asyncEndCallbac2.call(opts);
|
|
182
185
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
_onFiveRenderFrame = function onFiveRenderFrame() {
|
|
196
|
-
if (timeEnd || moving) {
|
|
197
|
-
five.off('renderFrame', _onFiveRenderFrame);
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
var targetState = {};
|
|
201
|
-
if (args.rotation !== _typings.Rotation.Loop) {
|
|
202
|
-
var progress = (performance.now() - start) / duration;
|
|
203
|
-
targetState = {
|
|
204
|
-
fov: progressNumber(from.fov, to.fov, progress),
|
|
205
|
-
latitude: progressNumber(from.latitude, to.latitude, progress),
|
|
206
|
-
longitude: progressLongitude(from.longitude, to.longitude, args.rotation, progress)
|
|
207
|
-
};
|
|
208
|
-
} else {
|
|
209
|
-
var _progress = (performance.now() - start) / animeDuration; // 可能大于1
|
|
210
|
-
var times = Math.floor(_progress);
|
|
211
|
-
var progress2 = _progress - times; // 一定小于1
|
|
212
|
-
var isNegative = times % 2 === 1; // 是否为反向旋转, 0: 正, 1: 反, 2: 正, 3: 反 以此类推
|
|
213
|
-
var resultProgress = isNegative ? 1 - progress2 : progress2;
|
|
214
|
-
targetState = {
|
|
215
|
-
fov: progressNumber(from.fov, to.fov, resultProgress),
|
|
216
|
-
latitude: progressNumber(from.latitude, to.latitude, resultProgress),
|
|
217
|
-
longitude: progressNumber(from.longitude, to.longitude, resultProgress)
|
|
218
|
-
};
|
|
186
|
+
// 计算to
|
|
187
|
+
from = five.getCurrentState();
|
|
188
|
+
to = function () {
|
|
189
|
+
return args;
|
|
190
|
+
}();
|
|
191
|
+
timeEnd = false; // 开始时间
|
|
192
|
+
start = performance.now();
|
|
193
|
+
animeDuration = duration;
|
|
194
|
+
if (args.rotation === _typings.Rotation.Loop) {
|
|
195
|
+
animeDuration = args.rotateSpeed ? Math.ceil(Math.abs(to.longitude - from.longitude) / args.rotateSpeed * 1000) : duration;
|
|
196
|
+
animeDuration = Math.min(duration, animeDuration);
|
|
219
197
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
198
|
+
onFiveRenderFrame = function onFiveRenderFrame() {
|
|
199
|
+
if (timeEnd || moving) {
|
|
200
|
+
five.off('renderFrame', onFiveRenderFrame);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
var targetState = {};
|
|
204
|
+
if (args.rotation !== _typings.Rotation.Loop) {
|
|
205
|
+
var progress = (performance.now() - start) / duration;
|
|
206
|
+
targetState = {
|
|
207
|
+
fov: progressNumber(from.fov, to.fov, progress),
|
|
208
|
+
latitude: progressNumber(from.latitude, to.latitude, progress),
|
|
209
|
+
longitude: progressLongitude(from.longitude, to.longitude, args.rotation, progress)
|
|
210
|
+
};
|
|
211
|
+
} else {
|
|
212
|
+
var _progress = (performance.now() - start) / animeDuration; // 可能大于1
|
|
213
|
+
var times = Math.floor(_progress);
|
|
214
|
+
var progress2 = _progress - times; // 一定小于1
|
|
215
|
+
var isNegative = times % 2 === 1; // 是否为反向旋转, 0: 正, 1: 反, 2: 正, 3: 反 以此类推
|
|
216
|
+
var resultProgress = isNegative ? 1 - progress2 : progress2;
|
|
217
|
+
targetState = {
|
|
218
|
+
fov: progressNumber(from.fov, to.fov, resultProgress),
|
|
219
|
+
latitude: progressNumber(from.latitude, to.latitude, resultProgress),
|
|
220
|
+
longitude: progressNumber(from.longitude, to.longitude, resultProgress)
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
five.setState(targetState, true);
|
|
224
|
+
};
|
|
225
|
+
five.on('renderFrame', onFiveRenderFrame);
|
|
226
|
+
_context2.next = 25;
|
|
227
|
+
return new Promise(function (resolve) {
|
|
228
|
+
setTimeout(function () {
|
|
229
|
+
timeEnd = true;
|
|
230
|
+
five.off('renderFrame', onFiveRenderFrame);
|
|
231
|
+
// 总时间到了之后强制结束,同时也是 Loop 模式的结束方式
|
|
232
|
+
resolve(true);
|
|
233
|
+
}, duration);
|
|
234
|
+
});
|
|
235
|
+
case 25:
|
|
236
|
+
return _context2.abrupt("return", _context2.sent);
|
|
237
|
+
case 26:
|
|
238
|
+
case "end":
|
|
239
|
+
return _context2.stop();
|
|
240
|
+
}
|
|
237
241
|
}
|
|
238
242
|
}, _callee2);
|
|
239
243
|
}));
|
|
@@ -6,14 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.Rotation = exports.CameraMovementEffect = void 0;
|
|
7
7
|
/* eslint-disable prettier/prettier */
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
9
|
-
var CameraMovementEffect
|
|
9
|
+
var CameraMovementEffect;
|
|
10
|
+
(function (CameraMovementEffect) {
|
|
10
11
|
CameraMovementEffect["Move"] = "Move";
|
|
11
12
|
CameraMovementEffect["Rotate"] = "Rotate";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
})(CameraMovementEffect || (exports.CameraMovementEffect = CameraMovementEffect = {}));
|
|
14
|
+
var Rotation;
|
|
15
|
+
(function (Rotation) {
|
|
15
16
|
Rotation["Clockwise"] = "Clockwise";
|
|
16
17
|
Rotation["Anticlockwise"] = "Anticlockwise";
|
|
17
18
|
Rotation["Loop"] = "Loop";
|
|
18
|
-
|
|
19
|
-
}({});
|
|
19
|
+
})(Rotation || (exports.Rotation = Rotation = {}));
|