@realsee/vreo 2.6.2 → 2.6.4-alpha.2
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 -14
- package/lib/PlayController/index.js +63 -73
- package/lib/Player/App.js +2 -2
- package/lib/Player/AudioFocus.d.ts +36 -0
- package/lib/Player/AudioFocus.js +139 -0
- package/lib/Player/Controller.d.ts +16 -0
- package/lib/Player/Controller.js +119 -61
- package/lib/Player/custom/SpatialScenePanel/index.js +34 -11
- package/lib/Player/index.d.ts +8 -2
- package/lib/Player/index.js +182 -123
- package/lib/Player/modules/Drawer/index.js +1 -2
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +8 -1
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +173 -203
- package/lib/Player/modules/VideoAgent/VideoAgentScene.d.ts +1 -0
- package/lib/Player/modules/VideoAgent/VideoAgentScene.js +6 -2
- package/lib/Player/modules/VideoAgent/index.js +10 -2
- package/lib/Player/modules/keyframes/BgMusic/index.js +46 -54
- package/lib/Player/modules/keyframes/CameraMovement/index.js +43 -45
- package/lib/Player/modules/keyframes/InfoPanel/index.js +37 -32
- package/lib/Player/modules/keyframes/ModelVideo/index.js +98 -57
- package/lib/Player/modules/keyframes/PanoTag/index.js +1 -1
- package/lib/Player/modules/keyframes/PanoTextLabel/index.js +3 -3
- package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +3 -3
- package/lib/Player/modules/keyframes/VideoEffect/index.js +87 -74
- package/lib/Player/typings.d.ts +10 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/index.js +6 -6
- package/lib/fivePlugins/CameraMovementPlugin/index.js +173 -180
- package/lib/fivePlugins/CameraMovementPlugin/typings.js +6 -6
- package/lib/fivePlugins/ModelTVVideoPlugin/index.d.ts +2 -0
- package/lib/fivePlugins/ModelTVVideoPlugin/index.js +87 -43
- package/lib/index.d.ts +1 -0
- package/lib/react/index.js +1 -1
- package/lib/shared-utils/Audio.js +53 -56
- package/lib/shared-utils/AudioLike.js +12 -14
- package/lib/shared-utils/animationFrame/BetterTween.js +13 -15
- package/lib/shared-utils/animationFrame/tween.js +1 -3
- package/lib/shared-utils/getMediaInfo.js +0 -1
- package/lib/typings/VreoUnit.js +134 -27
- package/package.json +6 -4
- package/docs/.nojekyll +0 -1
- package/docs/assets/custom.css +0 -78
- package/docs/assets/hierarchy.js +0 -1
- package/docs/assets/highlight.css +0 -127
- package/docs/assets/icons.js +0 -18
- package/docs/assets/icons.svg +0 -1
- package/docs/assets/main.js +0 -60
- package/docs/assets/navigation.js +0 -1
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1640
- package/docs/classes/Player.AudioLike.html +0 -15
- package/docs/classes/Player.Controller.html +0 -87
- package/docs/classes/Player.Player.html +0 -54
- package/docs/classes/Player.VideoAgentMesh.html +0 -72
- package/docs/classes/Player.VideoAgentScene.html +0 -9
- package/docs/demo/assets/AppReact-CkuqZtcS.js +0 -1
- package/docs/demo/assets/default-BQGCQRLt.css +0 -1
- package/docs/demo/assets/default-CVvVdmSW.js +0 -5540
- package/docs/demo/assets/dynamic-CO5wq52h.js +0 -1
- package/docs/demo/assets/examples-BCLzFApO.css +0 -1
- package/docs/demo/assets/examples-DfiAz2fR.js +0 -25
- package/docs/demo/assets/index-CBBSwaYT.js +0 -1
- package/docs/demo/assets/index-CmEXi2sK.css +0 -1
- package/docs/demo/assets/main-BF1tvUg-.js +0 -25
- package/docs/demo/assets/react-BnzBLum3.css +0 -1
- package/docs/demo/assets/react-C4h9qndP.js +0 -25
- package/docs/demo/examples.html +0 -16
- package/docs/demo/index-react-dynamic.html +0 -18
- package/docs/demo/index-react.html +0 -19
- package/docs/demo/index.html +0 -19
- package/docs/enums/Player.InfoPanelStyleEnum.html +0 -3
- package/docs/enums/Player.InfoPanelTypeEnum.html +0 -4
- package/docs/enums/Player.PanoEffectEnum.html +0 -4
- package/docs/enums/Player.PanoTagEnum.html +0 -4
- package/docs/enums/Player.PanoTagStyleEnum.html +0 -6
- package/docs/enums/Player.VreoKeyframeEnum.html +0 -25
- package/docs/enums/fivePlugins.CameraMovementEffect.html +0 -3
- package/docs/enums/fivePlugins.Rotation.html +0 -4
- package/docs/functions/custom.SpatialScenePanel.html +0 -2
- package/docs/functions/react.useVreoAction.html +0 -8
- package/docs/functions/react.useVreoEventCallback.html +0 -10
- package/docs/functions/react.useVreoPausedState.html +0 -8
- package/docs/hierarchy.html +0 -1
- package/docs/index.html +0 -160
- package/docs/interfaces/Player.Appearance.html +0 -2
- package/docs/interfaces/Player.CustomVreoKeyframeProps.html +0 -3
- package/docs/interfaces/Player.PlayerConfigs.html +0 -20
- package/docs/interfaces/Player.Vertex.html +0 -5
- package/docs/interfaces/Player.VideoAgentMeshOptions.html +0 -9
- package/docs/interfaces/Player.VreoKeyframe.html +0 -8
- package/docs/interfaces/Player.VreoUnit.html +0 -9
- package/docs/interfaces/Player.VreoVideo.html +0 -7
- package/docs/interfaces/fivePlugins.CSS3DRenderPluginExportType.html +0 -8
- package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +0 -3
- package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +0 -5
- package/docs/interfaces/fivePlugins.CameraMovementPluginParameterType.html +0 -1
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +0 -5
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +0 -4
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +0 -2
- package/docs/interfaces/fivePlugins.Vector3Position.html +0 -5
- package/docs/interfaces/react.VreoActionCallbacks.html +0 -18
- package/docs/interfaces/react.VreoProviderProps.html +0 -6
- package/docs/modules/Player.html +0 -1
- package/docs/modules/custom.html +0 -1
- package/docs/modules/fivePlugins.html +0 -1
- package/docs/modules/react.html +0 -1
- package/docs/modules.html +0 -1
- package/docs/types/Player.AppSize.html +0 -1
- package/docs/types/Player.AudioLikeEvent.html +0 -6
- package/docs/types/Player.CameraMovementData.html +0 -2
- package/docs/types/Player.CustomData.html +0 -2
- package/docs/types/Player.InfoPanelData.html +0 -7
- package/docs/types/Player.ModelVideoData.html +0 -9
- package/docs/types/Player.PanoEffectData.html +0 -4
- package/docs/types/Player.PanoTagData.html +0 -6
- package/docs/types/Player.PanoTextLabelData.html +0 -7
- package/docs/types/Player.PrompterData.html +0 -3
- package/docs/types/Player.QuadrangleVertexs.html +0 -2
- package/docs/types/Player.Quaternion.html +0 -6
- package/docs/types/Player.UpdateVRPanoramaData.html +0 -7
- package/docs/types/Player.Vertexs.html +0 -2
- package/docs/types/Player.VideoEffectData.html +0 -7
- package/docs/types/Player.VreoKeyframeEvent.html +0 -2
- package/docs/types/Player.VreoKeyframeMap.html +0 -6
- package/docs/types/Player.VreoSubscribe.html +0 -1
- package/docs/types/Player.WaveAppearance.html +0 -1
- package/docs/types/fivePlugins.CSS3DRenderPluginParameterType.html +0 -1
- package/docs/types/fivePlugins.MoveArgs.html +0 -1
- package/docs/types/fivePlugins.MoveOpts.html +0 -1
- package/docs/types/fivePlugins.RotateArgs.html +0 -1
- package/docs/types/fivePlugins.RotateOpts.html +0 -1
- package/docs/variables/fivePlugins.CSS3DRenderPlugin.html +0 -3
- package/docs/variables/fivePlugins.CameraMovementPlugin.html +0 -2
- package/docs/variables/fivePlugins.ModelTVVideoPlugin.html +0 -1
- package/docs/variables/react.VreoProvider.html +0 -9
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
-
|
|
2
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
3
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
3
4
|
import { Five } from '@realsee/five';
|
|
4
5
|
import { Rotation } from "./typings.js";
|
|
5
6
|
var PI = Math.PI;
|
|
@@ -28,86 +29,83 @@ export var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
28
29
|
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
29
30
|
preload: true
|
|
30
31
|
};
|
|
31
|
-
return new Promise(
|
|
32
|
-
var _ref = _asyncToGenerator(
|
|
32
|
+
return new Promise(/*#__PURE__*/function () {
|
|
33
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(resolve, reject) {
|
|
33
34
|
var _opts$asyncEndCallbac;
|
|
34
35
|
var panoIndex, start, movePanoOptions;
|
|
35
|
-
return
|
|
36
|
-
while (1) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
_context.next = 4;
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
return _context.abrupt("return", reject(false));
|
|
48
|
-
case 4:
|
|
49
|
-
if (!(args.mode && args.mode !== five.currentMode)) {
|
|
50
|
-
_context.next = 8;
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
_context.next = 7;
|
|
54
|
-
return five.changeMode(args.mode, args, duration);
|
|
55
|
-
case 7:
|
|
56
|
-
return _context.abrupt("return", resolve(true));
|
|
57
|
-
case 8:
|
|
58
|
-
if (!(args.mode === Five.Mode.Floorplan)) {
|
|
59
|
-
_context.next = 10;
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
return _context.abrupt("return", resolve(true));
|
|
63
|
-
case 10:
|
|
64
|
-
if (!(opts.preload && args.panoIndex !== undefined && args.panoIndex !== five.panoIndex)) {
|
|
65
|
-
_context.next = 13;
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
_context.next = 13;
|
|
69
|
-
return five.preloadPano(args.panoIndex);
|
|
70
|
-
case 13:
|
|
71
|
-
(_opts$asyncEndCallbac = opts.asyncEndCallback) === null || _opts$asyncEndCallbac === void 0 ? void 0 : _opts$asyncEndCallbac.call(opts);
|
|
72
|
-
if (!(args.panoIndex === undefined && args.fov === undefined && args.latitude === undefined && args.longitude === undefined)) {
|
|
73
|
-
_context.next = 16;
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
return _context.abrupt("return", resolve(true));
|
|
77
|
-
case 16:
|
|
78
|
-
panoIndex = args.panoIndex !== undefined ? args.panoIndex : five.panoIndex;
|
|
79
|
-
if (!(panoIndex !== undefined)) {
|
|
80
|
-
_context.next = 26;
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
start = performance.now();
|
|
84
|
-
_context.next = 21;
|
|
85
|
-
return five.ready();
|
|
86
|
-
case 21:
|
|
87
|
-
movePanoOptions = Object.assign({}, args, {
|
|
88
|
-
duration: duration - (performance.now() - start),
|
|
89
|
-
// 移动耗时
|
|
90
|
-
moveEndCallback: function moveEndCallback() {
|
|
91
|
-
return resolve(true);
|
|
92
|
-
},
|
|
93
|
-
// 移动结束
|
|
94
|
-
moveCancelCallback: function moveCancelCallback() {
|
|
95
|
-
resolve(true);
|
|
96
|
-
},
|
|
97
|
-
// 移动开始
|
|
98
|
-
effect: args.transEffect || 'fly'
|
|
99
|
-
});
|
|
100
|
-
_context.next = 24;
|
|
101
|
-
return five.moveToPano(panoIndex, movePanoOptions);
|
|
102
|
-
case 24:
|
|
103
|
-
_context.next = 27;
|
|
36
|
+
return _regenerator().w(function (_context) {
|
|
37
|
+
while (1) switch (_context.n) {
|
|
38
|
+
case 0:
|
|
39
|
+
moving = true;
|
|
40
|
+
if (opts.asyncStartCallback) {
|
|
41
|
+
opts.asyncStartCallback();
|
|
42
|
+
}
|
|
43
|
+
if (!(five.panoIndex === undefined)) {
|
|
44
|
+
_context.n = 1;
|
|
104
45
|
break;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
46
|
+
}
|
|
47
|
+
return _context.a(2, reject(false));
|
|
48
|
+
case 1:
|
|
49
|
+
if (!(args.mode && args.mode !== five.currentMode)) {
|
|
50
|
+
_context.n = 3;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
_context.n = 2;
|
|
54
|
+
return five.changeMode(args.mode, args, duration);
|
|
55
|
+
case 2:
|
|
56
|
+
return _context.a(2, resolve(true));
|
|
57
|
+
case 3:
|
|
58
|
+
if (!(args.mode === Five.Mode.Floorplan)) {
|
|
59
|
+
_context.n = 4;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
return _context.a(2, resolve(true));
|
|
63
|
+
case 4:
|
|
64
|
+
if (!(opts.preload && args.panoIndex !== undefined && args.panoIndex !== five.panoIndex)) {
|
|
65
|
+
_context.n = 5;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
_context.n = 5;
|
|
69
|
+
return five.preloadPano(args.panoIndex);
|
|
70
|
+
case 5:
|
|
71
|
+
(_opts$asyncEndCallbac = opts.asyncEndCallback) === null || _opts$asyncEndCallbac === void 0 || _opts$asyncEndCallbac.call(opts);
|
|
72
|
+
if (!(args.panoIndex === undefined && args.fov === undefined && args.latitude === undefined && args.longitude === undefined)) {
|
|
73
|
+
_context.n = 6;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
return _context.a(2, resolve(true));
|
|
77
|
+
case 6:
|
|
78
|
+
panoIndex = args.panoIndex !== undefined ? args.panoIndex : five.panoIndex;
|
|
79
|
+
if (!(panoIndex !== undefined)) {
|
|
80
|
+
_context.n = 9;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
start = performance.now();
|
|
84
|
+
_context.n = 7;
|
|
85
|
+
return five.ready();
|
|
86
|
+
case 7:
|
|
87
|
+
movePanoOptions = Object.assign({}, args, {
|
|
88
|
+
duration: duration - (performance.now() - start),
|
|
89
|
+
// 移动耗时
|
|
90
|
+
moveEndCallback: function moveEndCallback() {
|
|
91
|
+
return resolve(true);
|
|
92
|
+
},
|
|
93
|
+
// 移动结束
|
|
94
|
+
moveCancelCallback: function moveCancelCallback() {
|
|
95
|
+
resolve(true);
|
|
96
|
+
},
|
|
97
|
+
// 移动开始
|
|
98
|
+
effect: args.transEffect || 'fly'
|
|
99
|
+
});
|
|
100
|
+
_context.n = 8;
|
|
101
|
+
return five.moveToPano(panoIndex, movePanoOptions);
|
|
102
|
+
case 8:
|
|
103
|
+
_context.n = 10;
|
|
104
|
+
break;
|
|
105
|
+
case 9:
|
|
106
|
+
reject(false);
|
|
107
|
+
case 10:
|
|
108
|
+
return _context.a(2);
|
|
111
109
|
}
|
|
112
110
|
}, _callee);
|
|
113
111
|
}));
|
|
@@ -117,7 +115,7 @@ export var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
117
115
|
}());
|
|
118
116
|
};
|
|
119
117
|
var rotate = /*#__PURE__*/function () {
|
|
120
|
-
var _ref2 = _asyncToGenerator(
|
|
118
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(args, duration) {
|
|
121
119
|
var _opts$asyncStartCallb, _opts$asyncEndCallbac2;
|
|
122
120
|
var opts,
|
|
123
121
|
from,
|
|
@@ -125,112 +123,107 @@ export var CameraMovementPlugin = function CameraMovementPlugin(five) {
|
|
|
125
123
|
timeEnd,
|
|
126
124
|
start,
|
|
127
125
|
animeDuration,
|
|
128
|
-
|
|
126
|
+
_onFiveRenderFrame,
|
|
129
127
|
_args2 = arguments;
|
|
130
|
-
return
|
|
131
|
-
while (1) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
(_opts$asyncStartCallb = opts.asyncStartCallback) === null || _opts$asyncStartCallb === void 0 ? void 0 : _opts$asyncStartCallb.call(opts);
|
|
128
|
+
return _regenerator().w(function (_context2) {
|
|
129
|
+
while (1) switch (_context2.n) {
|
|
130
|
+
case 0:
|
|
131
|
+
opts = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {};
|
|
132
|
+
moving = false;
|
|
133
|
+
(_opts$asyncStartCallb = opts.asyncStartCallback) === null || _opts$asyncStartCallb === void 0 || _opts$asyncStartCallb.call(opts);
|
|
137
134
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
});
|
|
135
|
+
// 先切换模型再出旋转效果
|
|
136
|
+
if (!(args.mode && five.currentMode !== args.mode)) {
|
|
137
|
+
_context2.n = 1;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
_context2.n = 1;
|
|
141
|
+
return five.changeMode(args.mode, args.mode === Five.Mode.Panorama ? {
|
|
142
|
+
latitude: 0
|
|
143
|
+
} : undefined);
|
|
144
|
+
case 1:
|
|
145
|
+
if (!(args.mode === Five.Mode.Panorama && five.currentMode === Five.Mode.Panorama && args.panoIndex !== undefined && args.panoIndex !== five.panoIndex)) {
|
|
146
|
+
_context2.n = 3;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
if (!opts.preload) {
|
|
150
|
+
_context2.n = 2;
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
_context2.n = 2;
|
|
154
|
+
return five.preloadPano(args.panoIndex);
|
|
155
|
+
case 2:
|
|
156
|
+
_context2.n = 3;
|
|
157
|
+
return new Promise(function (resolve, reject) {
|
|
158
|
+
five.moveToPano(args.panoIndex, {
|
|
159
|
+
moveEndCallback: function moveEndCallback() {
|
|
160
|
+
return resolve(true);
|
|
161
|
+
},
|
|
162
|
+
// 移动结束
|
|
163
|
+
moveCancelCallback: function moveCancelCallback() {
|
|
164
|
+
return reject(false);
|
|
165
|
+
},
|
|
166
|
+
// 移动开始
|
|
167
|
+
effect: 'fade'
|
|
172
168
|
});
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
169
|
+
});
|
|
170
|
+
case 3:
|
|
171
|
+
_context2.n = 4;
|
|
172
|
+
return five.ready();
|
|
173
|
+
case 4:
|
|
174
|
+
(_opts$asyncEndCallbac2 = opts.asyncEndCallback) === null || _opts$asyncEndCallbac2 === void 0 || _opts$asyncEndCallbac2.call(opts);
|
|
178
175
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
176
|
+
// 计算to
|
|
177
|
+
from = five.getCurrentState();
|
|
178
|
+
to = function () {
|
|
179
|
+
return args;
|
|
180
|
+
}();
|
|
181
|
+
timeEnd = false; // 开始时间
|
|
182
|
+
start = performance.now();
|
|
183
|
+
animeDuration = duration;
|
|
184
|
+
if (args.rotation === Rotation.Loop) {
|
|
185
|
+
animeDuration = args.rotateSpeed ? Math.ceil(Math.abs(to.longitude - from.longitude) / args.rotateSpeed * 1000) : duration;
|
|
186
|
+
animeDuration = Math.min(duration, animeDuration);
|
|
187
|
+
}
|
|
188
|
+
_onFiveRenderFrame = function onFiveRenderFrame() {
|
|
189
|
+
if (timeEnd || moving) {
|
|
190
|
+
five.off('renderFrame', _onFiveRenderFrame);
|
|
191
|
+
return;
|
|
190
192
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
resolve(true);
|
|
226
|
-
}, duration);
|
|
227
|
-
});
|
|
228
|
-
case 25:
|
|
229
|
-
return _context2.abrupt("return", _context2.sent);
|
|
230
|
-
case 26:
|
|
231
|
-
case "end":
|
|
232
|
-
return _context2.stop();
|
|
233
|
-
}
|
|
193
|
+
var targetState = {};
|
|
194
|
+
if (args.rotation !== Rotation.Loop) {
|
|
195
|
+
var progress = (performance.now() - start) / duration;
|
|
196
|
+
targetState = {
|
|
197
|
+
fov: progressNumber(from.fov, to.fov, progress),
|
|
198
|
+
latitude: progressNumber(from.latitude, to.latitude, progress),
|
|
199
|
+
longitude: progressLongitude(from.longitude, to.longitude, args.rotation, progress)
|
|
200
|
+
};
|
|
201
|
+
} else {
|
|
202
|
+
var _progress = (performance.now() - start) / animeDuration; // 可能大于1
|
|
203
|
+
var times = Math.floor(_progress);
|
|
204
|
+
var progress2 = _progress - times; // 一定小于1
|
|
205
|
+
var isNegative = times % 2 === 1; // 是否为反向旋转, 0: 正, 1: 反, 2: 正, 3: 反 以此类推
|
|
206
|
+
var resultProgress = isNegative ? 1 - progress2 : progress2;
|
|
207
|
+
targetState = {
|
|
208
|
+
fov: progressNumber(from.fov, to.fov, resultProgress),
|
|
209
|
+
latitude: progressNumber(from.latitude, to.latitude, resultProgress),
|
|
210
|
+
longitude: progressNumber(from.longitude, to.longitude, resultProgress)
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
five.setState(targetState, true);
|
|
214
|
+
};
|
|
215
|
+
five.on('renderFrame', _onFiveRenderFrame);
|
|
216
|
+
_context2.n = 5;
|
|
217
|
+
return new Promise(function (resolve) {
|
|
218
|
+
setTimeout(function () {
|
|
219
|
+
timeEnd = true;
|
|
220
|
+
five.off('renderFrame', _onFiveRenderFrame);
|
|
221
|
+
// 总时间到了之后强制结束,同时也是 Loop 模式的结束方式
|
|
222
|
+
resolve(true);
|
|
223
|
+
}, duration);
|
|
224
|
+
});
|
|
225
|
+
case 5:
|
|
226
|
+
return _context2.a(2, _context2.v);
|
|
234
227
|
}
|
|
235
228
|
}, _callee2);
|
|
236
229
|
}));
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
4
4
|
|
|
5
|
-
export var CameraMovementEffect
|
|
6
|
-
(function (CameraMovementEffect) {
|
|
5
|
+
export var CameraMovementEffect = /*#__PURE__*/function (CameraMovementEffect) {
|
|
7
6
|
CameraMovementEffect["Move"] = "Move";
|
|
8
7
|
CameraMovementEffect["Rotate"] = "Rotate";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
return CameraMovementEffect;
|
|
9
|
+
}({});
|
|
10
|
+
export var Rotation = /*#__PURE__*/function (Rotation) {
|
|
12
11
|
Rotation["Clockwise"] = "Clockwise";
|
|
13
12
|
Rotation["Anticlockwise"] = "Anticlockwise";
|
|
14
13
|
Rotation["Loop"] = "Loop";
|
|
15
|
-
|
|
14
|
+
return Rotation;
|
|
15
|
+
}({});
|
|
@@ -11,10 +11,12 @@ export interface ModelTVVideoPluginData {
|
|
|
11
11
|
}
|
|
12
12
|
export interface ModelTVVideoPluginParameterType {
|
|
13
13
|
videoElement?: HTMLVideoElement;
|
|
14
|
+
canPlay?: () => boolean;
|
|
14
15
|
}
|
|
15
16
|
export interface ModelTVVideoPluginExportType {
|
|
16
17
|
enable: () => void;
|
|
17
18
|
disable: () => void;
|
|
19
|
+
dispose: () => void;
|
|
18
20
|
load: (data: ModelTVVideoPluginData, videoElement?: HTMLVideoElement) => Promise<void>;
|
|
19
21
|
}
|
|
20
22
|
export declare const ModelTVVideoPlugin: FivePlugin<ModelTVVideoPluginParameterType, ModelTVVideoPluginExportType>;
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
-
|
|
3
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
4
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
4
5
|
import * as THREE from 'three';
|
|
5
6
|
export var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
6
|
-
var videoElement = _ref.videoElement
|
|
7
|
+
var videoElement = _ref.videoElement,
|
|
8
|
+
canPlay = _ref.canPlay;
|
|
9
|
+
var listeners = [];
|
|
10
|
+
var on = function on(name, callback) {
|
|
11
|
+
listeners.push(function () {
|
|
12
|
+
five.off(name, callback);
|
|
13
|
+
});
|
|
14
|
+
return five.on(name, callback);
|
|
15
|
+
};
|
|
16
|
+
var generation = 0;
|
|
17
|
+
var disposed = false;
|
|
7
18
|
var state = {
|
|
8
19
|
videoMeshes: [],
|
|
9
20
|
videoTextureEnabled: false,
|
|
@@ -14,15 +25,16 @@ export var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
14
25
|
};
|
|
15
26
|
var setMuted = function setMuted(muted) {
|
|
16
27
|
if (state.videoTexture) {
|
|
28
|
+
if (!muted && canPlay && !canPlay()) return;
|
|
17
29
|
state.videoTexture.image.muted = muted;
|
|
18
|
-
state.videoTexture.image.play();
|
|
30
|
+
if (state.enabled && (!canPlay || canPlay())) void state.videoTexture.image.play();
|
|
19
31
|
}
|
|
20
32
|
};
|
|
21
33
|
var getMuted = function getMuted() {
|
|
22
34
|
if (state.videoTexture) return state.videoTexture.image.muted;else return true;
|
|
23
35
|
};
|
|
24
36
|
var enable = function enable() {
|
|
25
|
-
if (state.enabled) return;
|
|
37
|
+
if (disposed || state.enabled || canPlay && !canPlay()) return;
|
|
26
38
|
if (!state.videoTexture) return;
|
|
27
39
|
state.enabled = true;
|
|
28
40
|
state.videoMeshes = createPanoVideoMeshes();
|
|
@@ -30,18 +42,18 @@ export var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
30
42
|
return five.scene.add(mesh);
|
|
31
43
|
});
|
|
32
44
|
var play = function play() {
|
|
33
|
-
if (!state.videoTexture) return;
|
|
34
|
-
var
|
|
45
|
+
if (!state.videoTexture || !state.enabled || canPlay && !canPlay()) return;
|
|
46
|
+
var _timeupdate = function timeupdate() {
|
|
35
47
|
var _state$videoTexture;
|
|
36
48
|
if (!state.videoTexture) return;
|
|
37
|
-
(_state$videoTexture = state.videoTexture) === null || _state$videoTexture === void 0
|
|
49
|
+
(_state$videoTexture = state.videoTexture) === null || _state$videoTexture === void 0 || _state$videoTexture.image.removeEventListener('timeupdate', _timeupdate);
|
|
38
50
|
state.videoTextureEnabled = true;
|
|
39
51
|
state.videoMeshes.forEach(function (mesh) {
|
|
40
52
|
if (mesh.material.map !== state.videoTexture) mesh.material.map = state.videoTexture;
|
|
41
53
|
});
|
|
42
54
|
five.needsRender = true;
|
|
43
55
|
};
|
|
44
|
-
state.videoTexture.image.addEventListener('timeupdate',
|
|
56
|
+
state.videoTexture.image.addEventListener('timeupdate', _timeupdate);
|
|
45
57
|
if (state.videoTexture && state.videoMeshes.length) {
|
|
46
58
|
state.videoTexture.image.play();
|
|
47
59
|
}
|
|
@@ -53,6 +65,10 @@ export var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
53
65
|
}
|
|
54
66
|
};
|
|
55
67
|
var disable = function disable() {
|
|
68
|
+
if (state.videoTexture) {
|
|
69
|
+
state.videoTexture.image.muted = true;
|
|
70
|
+
state.videoTexture.image.pause();
|
|
71
|
+
}
|
|
56
72
|
if (!state.enabled) return;
|
|
57
73
|
state.enabled = false;
|
|
58
74
|
state.videoMeshes.forEach(function (mesh) {
|
|
@@ -149,36 +165,49 @@ export var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
149
165
|
});
|
|
150
166
|
};
|
|
151
167
|
var load = /*#__PURE__*/function () {
|
|
152
|
-
var _ref2 = _asyncToGenerator(
|
|
153
|
-
var video_src, video_poster_src, points;
|
|
154
|
-
return
|
|
155
|
-
while (1) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
});
|
|
168
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(data, videoElement) {
|
|
169
|
+
var current, video_src, video_poster_src, points, texture;
|
|
170
|
+
return _regenerator().w(function (_context) {
|
|
171
|
+
while (1) switch (_context.n) {
|
|
172
|
+
case 0:
|
|
173
|
+
current = ++generation;
|
|
174
|
+
video_src = data.video_src, video_poster_src = data.video_poster_src, points = data.points;
|
|
175
|
+
state.videoSource = video_src;
|
|
176
|
+
state.rectPoints = points.map(function (items) {
|
|
177
|
+
return items.map(function (_ref3) {
|
|
178
|
+
var x = _ref3.x,
|
|
179
|
+
y = _ref3.y,
|
|
180
|
+
z = _ref3.z;
|
|
181
|
+
return new THREE.Vector3(x, y, z);
|
|
167
182
|
});
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
183
|
+
});
|
|
184
|
+
state.imageTexture = getImageTexture(video_poster_src);
|
|
185
|
+
if (videoElement) {
|
|
186
|
+
state.videoElement = videoElement;
|
|
187
|
+
}
|
|
188
|
+
_context.n = 1;
|
|
189
|
+
return getVideoTexture(state.videoSource, state.videoElement);
|
|
190
|
+
case 1:
|
|
191
|
+
texture = _context.v;
|
|
192
|
+
if (!(disposed || current !== generation)) {
|
|
193
|
+
_context.n = 2;
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
texture.image.muted = true;
|
|
197
|
+
texture.image.pause();
|
|
198
|
+
URL.revokeObjectURL(texture.image.src);
|
|
199
|
+
texture.dispose();
|
|
200
|
+
return _context.a(2);
|
|
201
|
+
case 2:
|
|
202
|
+
if (state.videoTexture) {
|
|
203
|
+
state.videoTexture.image.pause();
|
|
204
|
+
URL.revokeObjectURL(state.videoTexture.image.src);
|
|
205
|
+
state.videoTexture.dispose();
|
|
206
|
+
}
|
|
207
|
+
state.videoTexture = texture;
|
|
208
|
+
if (data.enable) enable();
|
|
209
|
+
case 3:
|
|
210
|
+
return _context.a(2);
|
|
182
211
|
}
|
|
183
212
|
}, _callee);
|
|
184
213
|
}));
|
|
@@ -186,10 +215,10 @@ export var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
186
215
|
return _ref2.apply(this, arguments);
|
|
187
216
|
};
|
|
188
217
|
}();
|
|
189
|
-
|
|
218
|
+
on('modeChange', function () {
|
|
190
219
|
return setMuted(true);
|
|
191
220
|
});
|
|
192
|
-
|
|
221
|
+
on('wantsTapGesture', function (raycaster) {
|
|
193
222
|
if (!state.enabled) return;
|
|
194
223
|
var _raycaster$intersectO = raycaster.intersectObjects(five.scene.children, true),
|
|
195
224
|
_raycaster$intersectO2 = _slicedToArray(_raycaster$intersectO, 1),
|
|
@@ -199,7 +228,7 @@ export var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
199
228
|
return false;
|
|
200
229
|
}
|
|
201
230
|
});
|
|
202
|
-
|
|
231
|
+
on('panoArrived', function () {
|
|
203
232
|
if (!state.enabled) return;
|
|
204
233
|
if (getMuted()) return;
|
|
205
234
|
var cameraPosition = five.camera.position;
|
|
@@ -220,21 +249,36 @@ export var ModelTVVideoPlugin = function ModelTVVideoPlugin(five, _ref) {
|
|
|
220
249
|
});
|
|
221
250
|
if (!visible) setMuted(true);
|
|
222
251
|
});
|
|
223
|
-
|
|
252
|
+
on('renderFrame', function () {
|
|
224
253
|
state.videoMeshes.forEach(function (meshes) {
|
|
225
254
|
if (meshes)
|
|
226
255
|
//@ts-ignore
|
|
227
256
|
meshes.needsRender = true;
|
|
228
257
|
});
|
|
229
258
|
});
|
|
230
|
-
|
|
259
|
+
on('load', function (input) {
|
|
231
260
|
if (input.modelTVVideoData) {
|
|
232
261
|
load(input.modelTVVideoData);
|
|
233
262
|
}
|
|
234
263
|
});
|
|
264
|
+
var dispose = function dispose() {
|
|
265
|
+
var _state$imageTexture;
|
|
266
|
+
disposed = true;
|
|
267
|
+
++generation;
|
|
268
|
+
disable();
|
|
269
|
+
listeners.splice(0).forEach(function (remove) {
|
|
270
|
+
return remove();
|
|
271
|
+
});
|
|
272
|
+
(_state$imageTexture = state.imageTexture) === null || _state$imageTexture === void 0 || _state$imageTexture.dispose();
|
|
273
|
+
if (state.videoTexture) {
|
|
274
|
+
URL.revokeObjectURL(state.videoTexture.image.src);
|
|
275
|
+
state.videoTexture.dispose();
|
|
276
|
+
}
|
|
277
|
+
};
|
|
235
278
|
return {
|
|
236
279
|
enable: enable,
|
|
237
280
|
disable: disable,
|
|
238
|
-
load: load
|
|
281
|
+
load: load,
|
|
282
|
+
dispose: dispose
|
|
239
283
|
};
|
|
240
284
|
};
|
package/lib/index.d.ts
CHANGED