@realsee/vreo 2.3.7 → 2.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/PlayController/createHTMLAudioElement.js +7 -13
- package/lib/PlayController/index.js +27 -95
- package/lib/Player/App.js +2 -28
- package/lib/Player/Controller.js +48 -132
- package/lib/Player/custom/SpatialScenePanel/index.js +45 -76
- package/lib/Player/hooks.js +1 -11
- package/lib/Player/index.js +34 -101
- package/lib/Player/modules/Drawer/index.js +2 -19
- package/lib/Player/modules/PopUp/index.js +2 -12
- package/lib/Player/modules/ResizeObserver/index.js +1 -9
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +29 -123
- package/lib/Player/modules/VideoAgent/VideoAgentScene.js +15 -37
- package/lib/Player/modules/VideoAgent/index.js +2 -19
- package/lib/Player/modules/Wave/index.js +14 -43
- package/lib/Player/modules/keyframes/BgMusic/index.js +10 -28
- package/lib/Player/modules/keyframes/CameraMovement/index.js +6 -30
- package/lib/Player/modules/keyframes/InfoPanel/index.js +9 -39
- package/lib/Player/modules/keyframes/ModelVideo/index.js +6 -32
- package/lib/Player/modules/keyframes/PanoEffect/index.js +19 -52
- package/lib/Player/modules/keyframes/PanoEffect/lineAnime.js +1 -8
- package/lib/Player/modules/keyframes/PanoTag/index.js +5 -23
- package/lib/Player/modules/keyframes/PanoTextLabel/index.js +27 -57
- package/lib/Player/modules/keyframes/Prompter/index.js +15 -42
- package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +19 -26
- package/lib/Player/modules/keyframes/VideoEffect/index.js +18 -59
- package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.js +0 -2
- package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.js +0 -1
- package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.js +0 -1
- package/lib/fivePlugins/CSS3DRenderPlugin/index.js +21 -62
- package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.js +2 -5
- package/lib/fivePlugins/CameraMovementPlugin/index.js +20 -74
- package/lib/fivePlugins/CameraMovementPlugin/typings.js +0 -4
- package/lib/fivePlugins/ModelTVVideoPlugin/index.js +15 -69
- package/lib/index.js +0 -1
- package/lib/react/index.js +10 -41
- package/lib/shared-utils/Audio.js +35 -96
- package/lib/shared-utils/AudioLike.js +20 -56
- package/lib/shared-utils/Preloader.js +0 -7
- package/lib/shared-utils/addResizeListener.js +0 -5
- package/lib/shared-utils/animationFrame/BetterTween.js +19 -58
- package/lib/shared-utils/animationFrame/index.js +2 -10
- package/lib/shared-utils/animationFrame/tween.js +2 -11
- package/lib/shared-utils/createTransMatrix.js +5 -26
- package/lib/shared-utils/getFileExpandedName.js +0 -1
- package/lib/shared-utils/getMediaInfo.js +1 -10
- package/lib/shared-utils/setElementDataset.js +0 -2
- package/lib/typings/VreoUnit.js +0 -15
- package/package.json +2 -1
package/lib/Player/Controller.js
CHANGED
|
@@ -1,120 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.ControllerContext = exports.Controller = void 0;
|
|
9
|
-
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
13
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
14
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
15
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
16
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
17
|
var _five = require("@realsee/five");
|
|
11
|
-
|
|
12
18
|
var _mobx = require("mobx");
|
|
13
|
-
|
|
14
19
|
var React = _interopRequireWildcard(require("react"));
|
|
15
|
-
|
|
16
20
|
var _animationFrame = require("../shared-utils/animationFrame");
|
|
17
|
-
|
|
18
21
|
var _VreoUnit = require("../typings/VreoUnit");
|
|
19
|
-
|
|
20
22
|
var _setElementDataset = _interopRequireDefault(require("../shared-utils/setElementDataset"));
|
|
21
|
-
|
|
22
23
|
var _getMediaInfo = require("../shared-utils/getMediaInfo");
|
|
23
|
-
|
|
24
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
|
-
|
|
26
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); }
|
|
27
|
-
|
|
28
25
|
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; }
|
|
29
|
-
|
|
30
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
31
|
-
|
|
32
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
33
|
-
|
|
34
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
35
|
-
|
|
36
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
37
|
-
|
|
38
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
39
|
-
|
|
40
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
41
|
-
|
|
42
26
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
43
|
-
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
47
|
-
|
|
48
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
49
|
-
|
|
50
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
51
|
-
|
|
52
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
53
|
-
|
|
54
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
55
|
-
|
|
56
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
57
|
-
|
|
58
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
59
|
-
|
|
60
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
61
|
-
|
|
27
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
28
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
62
29
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
63
|
-
|
|
64
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
65
|
-
|
|
66
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
67
|
-
|
|
68
30
|
/**
|
|
69
31
|
* 逻辑控制器:内部状态。
|
|
70
32
|
*/
|
|
71
33
|
var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
72
|
-
|
|
73
|
-
|
|
34
|
+
(0, _inherits2["default"])(Controller, _Subscribe);
|
|
74
35
|
var _super = _createSuper(Controller);
|
|
75
|
-
|
|
76
36
|
function Controller(_ref) {
|
|
77
37
|
var _this;
|
|
78
|
-
|
|
79
38
|
var five = _ref.five,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
_classCallCheck(this, Controller);
|
|
84
|
-
|
|
39
|
+
container = _ref.container,
|
|
40
|
+
configs = _ref.configs;
|
|
41
|
+
(0, _classCallCheck2["default"])(this, Controller);
|
|
85
42
|
_this = _super.call(this);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
_defineProperty(_assertThisInitialized(_this), "loading", false);
|
|
92
|
-
|
|
93
|
-
_defineProperty(_assertThisInitialized(_this), "containerSize", {
|
|
43
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "playing", false);
|
|
44
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "ended", false);
|
|
45
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "loading", false);
|
|
46
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "containerSize", {
|
|
94
47
|
width: 0,
|
|
95
48
|
height: 0
|
|
96
49
|
});
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
_defineProperty(_assertThisInitialized(_this), "appearance", {
|
|
50
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "waveAppearance", null);
|
|
51
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "appearance", {
|
|
101
52
|
waveStyle: 'wave'
|
|
102
53
|
});
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
_defineProperty(_assertThisInitialized(_this), "popUp", null);
|
|
109
|
-
|
|
110
|
-
_defineProperty(_assertThisInitialized(_this), "drawerConfig", null);
|
|
111
|
-
|
|
54
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "avatar", {});
|
|
55
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "visible", false);
|
|
56
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "popUp", null);
|
|
57
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "drawerConfig", null);
|
|
112
58
|
_this.configs = configs;
|
|
113
59
|
_this.container = container;
|
|
114
60
|
_this.five = five;
|
|
115
61
|
_this.appSize = configs.appSize;
|
|
116
62
|
_this.appearance = _objectSpread(_objectSpread({}, _this.appearance), configs.appearance);
|
|
117
|
-
(0, _mobx.makeObservable)(
|
|
63
|
+
(0, _mobx.makeObservable)((0, _assertThisInitialized2["default"])(_this), {
|
|
118
64
|
visible: _mobx.observable,
|
|
119
65
|
setVisible: _mobx.action,
|
|
120
66
|
playing: _mobx.observable,
|
|
@@ -140,21 +86,18 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
140
86
|
(0, _mobx.reaction)(function () {
|
|
141
87
|
return [_this.appearance.waveStyle, _this.loading];
|
|
142
88
|
}, function (_ref2) {
|
|
143
|
-
var _ref3 =
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
89
|
+
var _ref3 = (0, _slicedToArray2["default"])(_ref2, 2),
|
|
90
|
+
waveStyle = _ref3[0],
|
|
91
|
+
loading = _ref3[1];
|
|
147
92
|
if (loading === null) {
|
|
148
93
|
_this.waveAppearance = null;
|
|
149
94
|
return;
|
|
150
95
|
}
|
|
151
|
-
|
|
152
96
|
if (waveStyle === 'wave') {
|
|
153
97
|
switch (loading) {
|
|
154
98
|
case true:
|
|
155
99
|
_this.waveAppearance = 'double';
|
|
156
100
|
break;
|
|
157
|
-
|
|
158
101
|
case false:
|
|
159
102
|
_this.waveAppearance = 'solid';
|
|
160
103
|
break;
|
|
@@ -164,7 +107,6 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
164
107
|
case true:
|
|
165
108
|
_this.waveAppearance = 'swap';
|
|
166
109
|
break;
|
|
167
|
-
|
|
168
110
|
case false:
|
|
169
111
|
_this.waveAppearance = 'expand';
|
|
170
112
|
break;
|
|
@@ -173,7 +115,6 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
173
115
|
}, {
|
|
174
116
|
fireImmediately: true
|
|
175
117
|
});
|
|
176
|
-
|
|
177
118
|
if (!_this.appSize) {
|
|
178
119
|
(0, _mobx.reaction)(function () {
|
|
179
120
|
return _this.containerSize;
|
|
@@ -181,19 +122,16 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
181
122
|
if (!(containerSize !== null && containerSize !== void 0 && containerSize.width)) return;
|
|
182
123
|
var width = containerSize.width;
|
|
183
124
|
var height = containerSize.height;
|
|
184
|
-
|
|
185
125
|
var size = function () {
|
|
186
126
|
if (width <= 500) return 'S';
|
|
187
127
|
if (width <= 1024) return 'M';
|
|
188
128
|
if (width <= 2048) return 'L';
|
|
189
129
|
return 'XL';
|
|
190
130
|
}();
|
|
191
|
-
|
|
192
131
|
var orientation = function () {
|
|
193
132
|
if (height > width) return 'portrait';
|
|
194
133
|
return 'landscape';
|
|
195
134
|
}();
|
|
196
|
-
|
|
197
135
|
(0, _setElementDataset["default"])(_this.container, {
|
|
198
136
|
size: size
|
|
199
137
|
});
|
|
@@ -207,9 +145,9 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
207
145
|
(0, _setElementDataset["default"])(_this.container, {
|
|
208
146
|
size: _this.appSize
|
|
209
147
|
});
|
|
210
|
-
}
|
|
211
|
-
|
|
148
|
+
}
|
|
212
149
|
|
|
150
|
+
// 监听播放情况:抛出触发时机
|
|
213
151
|
(0, _mobx.reaction)(function () {
|
|
214
152
|
return _this.ended;
|
|
215
153
|
}, function (ended) {
|
|
@@ -226,13 +164,13 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
226
164
|
});
|
|
227
165
|
return _this;
|
|
228
166
|
}
|
|
229
|
-
|
|
230
|
-
_createClass(Controller, [{
|
|
167
|
+
(0, _createClass2["default"])(Controller, [{
|
|
231
168
|
key: "agentType",
|
|
232
|
-
get:
|
|
169
|
+
get:
|
|
170
|
+
// null 表示加载失败
|
|
171
|
+
|
|
233
172
|
function get() {
|
|
234
173
|
var _this$videoAgentScene, _this$avatar;
|
|
235
|
-
|
|
236
174
|
var type = (0, _getMediaInfo.getMediaType)((_this$videoAgentScene = this.videoAgentScene) === null || _this$videoAgentScene === void 0 ? void 0 : _this$videoAgentScene.videoAgentMesh.videoUrl);
|
|
237
175
|
if ((_this$avatar = this.avatar) !== null && _this$avatar !== void 0 && _this$avatar.force) return 'avatar';
|
|
238
176
|
if (type === 'video') return 'video';
|
|
@@ -245,7 +183,6 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
245
183
|
this.popUp = null;
|
|
246
184
|
return;
|
|
247
185
|
}
|
|
248
|
-
|
|
249
186
|
this.popUp = popUp;
|
|
250
187
|
}
|
|
251
188
|
}, {
|
|
@@ -291,14 +228,12 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
291
228
|
value: function openDrawer(drawerConfig) {
|
|
292
229
|
if (!drawerConfig) {
|
|
293
230
|
var _this$drawerConfig;
|
|
294
|
-
|
|
295
231
|
this.drawerConfig = {
|
|
296
232
|
content: '',
|
|
297
233
|
height: (_this$drawerConfig = this.drawerConfig) === null || _this$drawerConfig === void 0 ? void 0 : _this$drawerConfig.height
|
|
298
234
|
};
|
|
299
235
|
return;
|
|
300
236
|
}
|
|
301
|
-
|
|
302
237
|
this.drawerConfig = drawerConfig;
|
|
303
238
|
}
|
|
304
239
|
}, {
|
|
@@ -310,25 +245,23 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
310
245
|
key: "currentTime",
|
|
311
246
|
get: function get() {
|
|
312
247
|
var _this$videoAgentScene2;
|
|
313
|
-
|
|
314
248
|
return ((_this$videoAgentScene2 = this.videoAgentScene) === null || _this$videoAgentScene2 === void 0 ? void 0 : _this$videoAgentScene2.videoAgentMesh.currentTime) || 0;
|
|
315
249
|
}
|
|
316
250
|
}, {
|
|
317
251
|
key: "currentKeyframes",
|
|
318
252
|
get: function get() {
|
|
319
253
|
var _this2 = this;
|
|
320
|
-
|
|
321
254
|
if (!this.vreoUnit) return [];
|
|
322
|
-
var keyframes = this.vreoUnit.keyframes;
|
|
323
|
-
|
|
255
|
+
var keyframes = this.vreoUnit.keyframes;
|
|
256
|
+
// 没有被解析过且开始时间低于当前时间戳 100ms
|
|
324
257
|
return keyframes.filter(function (keyframe) {
|
|
325
|
-
if (keyframe.parsed) return false;
|
|
326
|
-
|
|
327
|
-
if (keyframe.end < _this2.currentTime) return false;
|
|
328
|
-
|
|
258
|
+
if (keyframe.parsed) return false;
|
|
259
|
+
// 检测结束时间
|
|
260
|
+
if (keyframe.end < _this2.currentTime) return false;
|
|
261
|
+
// 检测开始时间
|
|
329
262
|
if (keyframe.start > _this2.currentTime) return false;
|
|
330
|
-
if (keyframe.type === _VreoUnit.VreoKeyframeEnum.BgMusic) return true;
|
|
331
|
-
|
|
263
|
+
if (keyframe.type === _VreoUnit.VreoKeyframeEnum.BgMusic) return true;
|
|
264
|
+
// 开始时间低于当前时间戳 100ms
|
|
332
265
|
var dur = _this2.currentTime - keyframe.start;
|
|
333
266
|
return dur <= 100 && dur >= 0;
|
|
334
267
|
});
|
|
@@ -337,23 +270,20 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
337
270
|
key: "mediaInstance",
|
|
338
271
|
get: function get() {
|
|
339
272
|
var _this$videoAgentScene3;
|
|
340
|
-
|
|
341
273
|
return (_this$videoAgentScene3 = this.videoAgentScene) === null || _this$videoAgentScene3 === void 0 ? void 0 : _this$videoAgentScene3.videoAgentMesh.mediaInstance;
|
|
342
274
|
}
|
|
275
|
+
|
|
343
276
|
/**
|
|
344
277
|
* 逐帧任务
|
|
345
278
|
*/
|
|
346
|
-
|
|
347
279
|
}, {
|
|
348
280
|
key: "requestAnimationFrameLoop",
|
|
349
281
|
value: function requestAnimationFrameLoop(callback) {
|
|
350
282
|
var _this$mediaInstance,
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
283
|
+
_this$mediaInstance4,
|
|
284
|
+
_this3 = this;
|
|
354
285
|
if ((_this$mediaInstance = this.mediaInstance) !== null && _this$mediaInstance !== void 0 && _this$mediaInstance.ended && this.mediaInstance.currentTime !== 0) {
|
|
355
286
|
var _this$vreoUnit;
|
|
356
|
-
|
|
357
287
|
if (this.ended) return;
|
|
358
288
|
(_this$vreoUnit = this.vreoUnit) === null || _this$vreoUnit === void 0 ? void 0 : _this$vreoUnit.keyframes.forEach(function (keyframe) {
|
|
359
289
|
return keyframe.parsed = false;
|
|
@@ -364,30 +294,22 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
364
294
|
this.mediaInstance.currentTime = 0;
|
|
365
295
|
return;
|
|
366
296
|
}
|
|
367
|
-
|
|
368
297
|
if (!this.playing) {
|
|
369
298
|
var _this$mediaInstance2;
|
|
370
|
-
|
|
371
299
|
if (!((_this$mediaInstance2 = this.mediaInstance) !== null && _this$mediaInstance2 !== void 0 && _this$mediaInstance2.paused)) {
|
|
372
300
|
var _this$mediaInstance3;
|
|
373
|
-
|
|
374
301
|
(_this$mediaInstance3 = this.mediaInstance) === null || _this$mediaInstance3 === void 0 ? void 0 : _this$mediaInstance3.pause();
|
|
375
302
|
}
|
|
376
|
-
|
|
377
303
|
return;
|
|
378
304
|
}
|
|
379
|
-
|
|
380
305
|
if ((_this$mediaInstance4 = this.mediaInstance) !== null && _this$mediaInstance4 !== void 0 && _this$mediaInstance4.paused && this.playing) {
|
|
381
306
|
this.mediaInstance.play();
|
|
382
307
|
}
|
|
383
|
-
|
|
384
308
|
var currentKeyframes = this.currentKeyframes;
|
|
385
309
|
currentKeyframes.forEach(function (keyframe) {
|
|
386
310
|
if (keyframe.parsed) return;
|
|
387
311
|
keyframe.parsed = true;
|
|
388
|
-
|
|
389
312
|
_this3.emit(keyframe.type, keyframe, _this3.currentTime);
|
|
390
|
-
|
|
391
313
|
if (callback) {
|
|
392
314
|
callback(keyframe.type, keyframe, _this3.currentTime);
|
|
393
315
|
}
|
|
@@ -397,7 +319,6 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
397
319
|
key: "run",
|
|
398
320
|
value: function run(callback) {
|
|
399
321
|
var _this4 = this;
|
|
400
|
-
|
|
401
322
|
if (this.stopInterval) return;
|
|
402
323
|
this.stopInterval = (0, _animationFrame.requestAnimationFrameInterval)(function () {
|
|
403
324
|
return _this4.requestAnimationFrameLoop(callback);
|
|
@@ -407,22 +328,19 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
407
328
|
key: "clear",
|
|
408
329
|
value: function clear() {
|
|
409
330
|
var _this$vreoUnit2, _this$stopInterval;
|
|
410
|
-
|
|
411
331
|
this.setPlaying(false);
|
|
412
332
|
(_this$vreoUnit2 = this.vreoUnit) === null || _this$vreoUnit2 === void 0 ? void 0 : _this$vreoUnit2.keyframes.forEach(function (keyframe) {
|
|
413
333
|
return keyframe.parsed = false;
|
|
414
334
|
});
|
|
335
|
+
|
|
415
336
|
/**
|
|
416
337
|
* 清理掉数据
|
|
417
338
|
*/
|
|
418
|
-
|
|
419
339
|
this.vreoUnit = undefined;
|
|
420
|
-
|
|
421
340
|
if (this.mediaInstance) {
|
|
422
341
|
this.mediaInstance.pause();
|
|
423
342
|
this.mediaInstance.currentTime = 0;
|
|
424
343
|
}
|
|
425
|
-
|
|
426
344
|
(_this$stopInterval = this.stopInterval) === null || _this$stopInterval === void 0 ? void 0 : _this$stopInterval.call(this);
|
|
427
345
|
this.stopInterval = undefined;
|
|
428
346
|
}
|
|
@@ -432,10 +350,8 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
432
350
|
this.clear();
|
|
433
351
|
}
|
|
434
352
|
}]);
|
|
435
|
-
|
|
436
353
|
return Controller;
|
|
437
354
|
}(_five.Subscribe);
|
|
438
|
-
|
|
439
355
|
exports.Controller = Controller;
|
|
440
356
|
var ControllerContext = /*#__PURE__*/React.createContext(null);
|
|
441
357
|
exports.ControllerContext = ControllerContext;
|