@realsee/vreo 2.4.2 → 2.4.5

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.
Files changed (40) hide show
  1. package/lib/PlayController/createHTMLAudioElement.js +11 -9
  2. package/lib/PlayController/index.js +61 -52
  3. package/lib/Player/App.js +1 -1
  4. package/lib/Player/Controller.js +28 -23
  5. package/lib/Player/custom/SpatialScenePanel/index.js +10 -10
  6. package/lib/Player/index.js +94 -90
  7. package/lib/Player/modules/Drawer/index.js +1 -1
  8. package/lib/Player/modules/PopUp/index.js +1 -1
  9. package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +143 -134
  10. package/lib/Player/modules/VideoAgent/VideoAgentScene.js +2 -2
  11. package/lib/Player/modules/VideoAgent/index.js +2 -2
  12. package/lib/Player/modules/Wave/index.js +1 -1
  13. package/lib/Player/modules/keyframes/BgMusic/index.js +41 -39
  14. package/lib/Player/modules/keyframes/CameraMovement/index.js +43 -41
  15. package/lib/Player/modules/keyframes/InfoPanel/index.js +6 -6
  16. package/lib/Player/modules/keyframes/ModelVideo/index.js +53 -51
  17. package/lib/Player/modules/keyframes/PanoEffect/index.js +1 -1
  18. package/lib/Player/modules/keyframes/PanoEffect/lineAnime.js +1 -1
  19. package/lib/Player/modules/keyframes/PanoTag/index.js +2 -2
  20. package/lib/Player/modules/keyframes/PanoTextLabel/index.js +3 -3
  21. package/lib/Player/modules/keyframes/Prompter/index.js +1 -1
  22. package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +5 -5
  23. package/lib/Player/modules/keyframes/VideoEffect/index.js +44 -42
  24. package/lib/Player/typings.d.ts +1 -4
  25. package/lib/fivePlugins/CSS3DRenderPlugin/index.js +7 -7
  26. package/lib/fivePlugins/CameraMovementPlugin/index.js +171 -167
  27. package/lib/fivePlugins/CameraMovementPlugin/typings.js +6 -6
  28. package/lib/fivePlugins/ModelTVVideoPlugin/index.js +30 -28
  29. package/lib/react/index.d.ts +1 -1
  30. package/lib/react/index.js +2 -2
  31. package/lib/shared-utils/Audio.d.ts +8 -0
  32. package/lib/shared-utils/Audio.js +62 -46
  33. package/lib/shared-utils/AudioLike.js +13 -10
  34. package/lib/shared-utils/animationFrame/BetterTween.d.ts +4 -2
  35. package/lib/shared-utils/animationFrame/BetterTween.js +19 -15
  36. package/lib/shared-utils/animationFrame/tween.d.ts +4 -2
  37. package/lib/shared-utils/animationFrame/tween.js +12 -1
  38. package/lib/shared-utils/createTransMatrix.js +1 -1
  39. package/lib/typings/VreoUnit.js +26 -69
  40. package/package.json +20 -24
@@ -10,9 +10,9 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
10
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
11
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
12
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
14
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
14
15
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
16
16
  var React = _interopRequireWildcard(require("react"));
17
17
  var ReactDOM = _interopRequireWildcard(require("react-dom"));
18
18
  var _five = require("@realsee/five");
@@ -24,18 +24,20 @@ var _Drawer = require("./modules/Drawer");
24
24
  var _PopUp = require("./modules/PopUp");
25
25
  var _Audio = require("../shared-utils/Audio");
26
26
  var _location$search$matc, _location$search$matc2; // 下面这一行不能删
27
- 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); }
28
- function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
27
+ 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); }
28
+ function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = (0, _getPrototypeOf2["default"])(t); if (r) { var s = (0, _getPrototypeOf2["default"])(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return (0, _possibleConstructorReturn2["default"])(this, e); }; }
29
29
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
30
30
  var DefaultAudioCacheLength = 3;
31
31
  var id = "vreo-app-dhjskadhksahdjskahdjksa";
32
32
  var audioCacheLength = Number((_location$search$matc = (_location$search$matc2 = location.search.match(/audio_cache=(\d+)/)) === null || _location$search$matc2 === void 0 ? void 0 : _location$search$matc2[1]) !== null && _location$search$matc !== void 0 ? _location$search$matc : DefaultAudioCacheLength);
33
33
  var Player = exports.Player = /*#__PURE__*/function (_Subscribe) {
34
+ (0, _inherits2["default"])(Player, _Subscribe);
35
+ var _super = _createSuper(Player);
34
36
  function Player(five) {
35
37
  var _this;
36
38
  var configs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
37
39
  (0, _classCallCheck2["default"])(this, Player);
38
- _this = _callSuper(this, Player);
40
+ _this = _super.call(this);
39
41
  _this.$five = five;
40
42
  (0, _Audio.generateBlankAudio)(audioCacheLength);
41
43
  if (!configs.container) {
@@ -104,8 +106,7 @@ var Player = exports.Player = /*#__PURE__*/function (_Subscribe) {
104
106
  });
105
107
  return _this;
106
108
  }
107
- (0, _inherits2["default"])(Player, _Subscribe);
108
- return (0, _createClass2["default"])(Player, [{
109
+ (0, _createClass2["default"])(Player, [{
109
110
  key: "load",
110
111
  value: function () {
111
112
  var _load = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(vreoUnit) {
@@ -122,95 +123,97 @@ var Player = exports.Player = /*#__PURE__*/function (_Subscribe) {
122
123
  i,
123
124
  _args = arguments;
124
125
  return _regenerator["default"].wrap(function _callee$(_context) {
125
- while (1) switch (_context.prev = _context.next) {
126
- case 0:
127
- currentTime = _args.length > 1 && _args[1] !== undefined ? _args[1] : 0;
128
- preload = _args.length > 2 && _args[2] !== undefined ? _args[2] : false;
129
- force = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
130
- this.controller.clear();
131
- this.controller.setLoading(true);
132
- if (force) {
133
- vreoUnit = JSON.parse(JSON.stringify(vreoUnit));
134
- }
135
- // if (!this.controller.visible) {
136
- // this.controller.setVisible(true)
137
- // // 延迟 500ms 规避跟 DOM 动画冲突
138
- // await new Promise((resolve) => {
139
- // setTimeout(() => resolve(true), 500)
140
- // })
141
- // }
142
-
143
- if (this.controller.stopInterval) {
144
- this.controller.stopInterval();
145
- this.controller.stopInterval = undefined;
146
- }
147
- this.controller.vreoUnit = vreoUnit;
148
- (_this$controller$medi = this.controller.mediaInstance) === null || _this$controller$medi === void 0 || _this$controller$medi.pause();
126
+ while (1) {
127
+ switch (_context.prev = _context.next) {
128
+ case 0:
129
+ currentTime = _args.length > 1 && _args[1] !== undefined ? _args[1] : 0;
130
+ preload = _args.length > 2 && _args[2] !== undefined ? _args[2] : false;
131
+ force = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
132
+ this.controller.clear();
133
+ this.controller.setLoading(true);
134
+ if (force) {
135
+ vreoUnit = JSON.parse(JSON.stringify(vreoUnit));
136
+ }
137
+ // if (!this.controller.visible) {
138
+ // this.controller.setVisible(true)
139
+ // // 延迟 500ms 规避跟 DOM 动画冲突
140
+ // await new Promise((resolve) => {
141
+ // setTimeout(() => resolve(true), 500)
142
+ // })
143
+ // }
149
144
 
150
- // 预载逻辑
151
- // 是否降低图片分辨率
152
- if (this.$five.imageOptions.size && (_this$configs$imageOp = this.configs.imageOptions) !== null && _this$configs$imageOp !== void 0 && _this$configs$imageOp.size && this.$five.imageOptions.size > this.configs.imageOptions.size) {
153
- this.$five.imageOptions.size = this.configs.imageOptions.size;
154
- }
145
+ if (this.controller.stopInterval) {
146
+ this.controller.stopInterval();
147
+ this.controller.stopInterval = undefined;
148
+ }
149
+ this.controller.vreoUnit = vreoUnit;
150
+ (_this$controller$medi = this.controller.mediaInstance) === null || _this$controller$medi === void 0 ? void 0 : _this$controller$medi.pause();
155
151
 
156
- // 预载数据中的点位
157
- if (!(preload || preload === undefined && this.configs.autoPreload)) {
158
- _context.next = 20;
159
- break;
160
- }
161
- panoIndexMap = vreoUnit.keyframes.filter(function (vreoKeyframe) {
162
- if (vreoKeyframe.type !== _VreoUnit.VreoKeyframeEnum.CameraMovement) {
163
- return false;
152
+ // 预载逻辑
153
+ // 是否降低图片分辨率
154
+ if (this.$five.imageOptions.size && (_this$configs$imageOp = this.configs.imageOptions) !== null && _this$configs$imageOp !== void 0 && _this$configs$imageOp.size && this.$five.imageOptions.size > this.configs.imageOptions.size) {
155
+ this.$five.imageOptions.size = this.configs.imageOptions.size;
164
156
  }
165
- var data = vreoKeyframe.data;
166
- if (data.panoIndex === undefined) {
167
- return false;
157
+
158
+ // 预载数据中的点位
159
+ if (!(preload || preload === undefined && this.configs.autoPreload)) {
160
+ _context.next = 20;
161
+ break;
168
162
  }
169
- return true;
170
- }).reduce(function (accu, curr) {
171
- var panoIndex = curr.data.panoIndex;
172
- if (!accu[panoIndex]) {
173
- accu[panoIndex] = true;
163
+ panoIndexMap = vreoUnit.keyframes.filter(function (vreoKeyframe) {
164
+ if (vreoKeyframe.type !== _VreoUnit.VreoKeyframeEnum.CameraMovement) {
165
+ return false;
166
+ }
167
+ var data = vreoKeyframe.data;
168
+ if (data.panoIndex === undefined) {
169
+ return false;
170
+ }
171
+ return true;
172
+ }).reduce(function (accu, curr) {
173
+ var panoIndex = curr.data.panoIndex;
174
+ if (!accu[panoIndex]) {
175
+ accu[panoIndex] = true;
176
+ }
177
+ return accu;
178
+ }, {});
179
+ panoIndexes = Object.keys(panoIndexMap);
180
+ i = 0;
181
+ case 14:
182
+ if (!(i < panoIndexes.length)) {
183
+ _context.next = 20;
184
+ break;
174
185
  }
175
- return accu;
176
- }, {});
177
- panoIndexes = Object.keys(panoIndexMap);
178
- i = 0;
179
- case 14:
180
- if (!(i < panoIndexes.length)) {
181
- _context.next = 20;
186
+ _context.next = 17;
187
+ return this.$five.preloadPano(Number(panoIndexes[i]));
188
+ case 17:
189
+ i++;
190
+ _context.next = 14;
182
191
  break;
183
- }
184
- _context.next = 17;
185
- return this.$five.preloadPano(Number(panoIndexes[i]));
186
- case 17:
187
- i++;
188
- _context.next = 14;
189
- break;
190
- case 20:
191
- // 新数据载入就绪
192
- this.emit('loaded', vreoUnit);
193
- this.controller.emit('loaded', vreoUnit);
194
- if ((_this$controller$vide = this.controller.videoAgentScene) !== null && _this$controller$vide !== void 0 && _this$controller$vide.videoAgentMesh.mediaInstance) {
195
- this.controller.videoAgentScene.videoAgentMesh.mediaInstance.currentTime = currentTime / 1000;
196
- }
197
- this.controller.setAvatar(vreoUnit.video.avatar);
198
- _context.next = 26;
199
- return (0, _Audio.waitForBlankAudioGenerated)();
200
- case 26:
201
- _context.next = 28;
202
- return (_this$controller$vide2 = this.controller.videoAgentScene) === null || _this$controller$vide2 === void 0 ? void 0 : _this$controller$vide2.videoAgentMesh.play(vreoUnit.video.url, currentTime / 1000, vreoUnit.video.duration);
203
- case 28:
204
- this.controller.setEnded(false);
205
- this.play();
206
- this.controller.run(function (type, keyframe) {
207
- return _this2.emit(type, keyframe, _this2.controller.currentTime);
208
- });
209
- this.controller.setLoading(false);
210
- return _context.abrupt("return", true);
211
- case 33:
212
- case "end":
213
- return _context.stop();
192
+ case 20:
193
+ // 新数据载入就绪
194
+ this.emit('loaded', vreoUnit);
195
+ this.controller.emit('loaded', vreoUnit);
196
+ if ((_this$controller$vide = this.controller.videoAgentScene) !== null && _this$controller$vide !== void 0 && _this$controller$vide.videoAgentMesh.mediaInstance) {
197
+ this.controller.videoAgentScene.videoAgentMesh.mediaInstance.currentTime = currentTime / 1000;
198
+ }
199
+ this.controller.setAvatar(vreoUnit.video.avatar);
200
+ _context.next = 26;
201
+ return (0, _Audio.waitForBlankAudioGenerated)();
202
+ case 26:
203
+ _context.next = 28;
204
+ return (_this$controller$vide2 = this.controller.videoAgentScene) === null || _this$controller$vide2 === void 0 ? void 0 : _this$controller$vide2.videoAgentMesh.play(vreoUnit.video.url, currentTime / 1000, vreoUnit.video.duration);
205
+ case 28:
206
+ this.controller.setEnded(false);
207
+ this.play();
208
+ this.controller.run(function (type, keyframe) {
209
+ return _this2.emit(type, keyframe, _this2.controller.currentTime);
210
+ });
211
+ this.controller.setLoading(false);
212
+ return _context.abrupt("return", true);
213
+ case 33:
214
+ case "end":
215
+ return _context.stop();
216
+ }
214
217
  }
215
218
  }, _callee, this);
216
219
  }));
@@ -237,7 +240,7 @@ var Player = exports.Player = /*#__PURE__*/function (_Subscribe) {
237
240
  });
238
241
  this.controller.setEnded(false);
239
242
  this.controller.setPlaying(true);
240
- (_this$controller$vreo = this.controller.vreoUnit) === null || _this$controller$vreo === void 0 || _this$controller$vreo.keyframes.forEach(function (keyframe) {
243
+ (_this$controller$vreo = this.controller.vreoUnit) === null || _this$controller$vreo === void 0 ? void 0 : _this$controller$vreo.keyframes.forEach(function (keyframe) {
241
244
  if (keyframe.type === _VreoUnit.VreoKeyframeEnum.BgMusic) {
242
245
  keyframe.parsed = false;
243
246
  }
@@ -278,5 +281,6 @@ var Player = exports.Player = /*#__PURE__*/function (_Subscribe) {
278
281
  }
279
282
  }
280
283
  }]);
284
+ return Player;
281
285
  }(_five.Subscribe);
282
286
  console.log("\n \u250F\u2501\u2501\u2501\u2513\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u250F\u2513\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n \u2503\u250F\u2501\u2513\u2503\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2503\u2503\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n \u2503\u2517\u2501\u251B\u2503\u250F\u2501\u2501\u2513\u250F\u2501\u2501\u2513\u2501\u2503\u2503\u2501\u250F\u2501\u2501\u2513\u250F\u2501\u2501\u2513\u250F\u2501\u2501\u2513\n \u2503\u250F\u2513\u250F\u251B\u2503\u250F\u2513\u2503\u2517\u2501\u2513\u2503\u2501\u2503\u2503\u2501\u2503\u2501\u2501\u252B\u2503\u250F\u2513\u2503\u2503\u250F\u2513\u2503\n \u2503\u2503\u2503\u2517\u2513\u2503\u2503\u2501\u252B\u2503\u2517\u251B\u2517\u2513\u2503\u2517\u2513\u2523\u2501\u2501\u2503\u2503\u2503\u2501\u252B\u2503\u2503\u2501\u252B\n \u2517\u251B\u2517\u2501\u251B\u2517\u2501\u2501\u251B\u2517\u2501\u2501\u2501\u251B\u2517\u2501\u251B\u2517\u2501\u2501\u251B\u2517\u2501\u2501\u251B\u2517\u2501\u2501\u251B\n \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n");
@@ -10,7 +10,7 @@ var React = _interopRequireWildcard(require("react"));
10
10
  var _classnames = _interopRequireDefault(require("classnames"));
11
11
  var _mobxReact = require("mobx-react");
12
12
  var _hooks = require("../../hooks");
13
- 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); }
13
+ 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); }
14
14
  var DrawerView = (0, _mobxReact.observer)(function (_ref) {
15
15
  var _controller$drawerCon2;
16
16
  var controller = _ref.controller;
@@ -10,7 +10,7 @@ var React = _interopRequireWildcard(require("react"));
10
10
  var _classnames = _interopRequireDefault(require("classnames"));
11
11
  var _mobxReact = require("mobx-react");
12
12
  var _hooks = require("../../hooks");
13
- 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); }
13
+ 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); }
14
14
  var PopUpView = (0, _mobxReact.observer)(function (_ref) {
15
15
  var controller = _ref.controller;
16
16
  return /*#__PURE__*/React.createElement("div", {
@@ -10,16 +10,17 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
10
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
11
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
12
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
14
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
15
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
14
16
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
16
17
  var THREE = _interopRequireWildcard(require("three"));
17
18
  var _Preloader = require("../../../shared-utils/Preloader");
18
19
  var _mobx = require("mobx");
19
20
  var _AudioLike = _interopRequireDefault(require("../../../shared-utils/AudioLike"));
20
21
  var _getMediaInfo = require("../../../shared-utils/getMediaInfo");
21
- 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); }
22
- function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
22
+ 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); }
23
+ function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = (0, _getPrototypeOf2["default"])(t); if (r) { var s = (0, _getPrototypeOf2["default"])(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return (0, _possibleConstructorReturn2["default"])(this, e); }; }
23
24
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
24
25
  var vertexShader = "\nvarying vec2 vUv;\nvarying vec2 vColorUv;\nvarying vec2 vMaskUv;\nvoid main(){\n vUv = uv;\n vColorUv = vec2(uv.x / 2.0, uv.y);\n vMaskUv = vec2(0.5 + uv.x / 2.0, uv.y);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n";
25
26
  var fragmentShaderTpl = function fragmentShaderTpl() {
@@ -30,6 +31,8 @@ var cacheInstance = {};
30
31
  * 视频经纪人MESH
31
32
  */
32
33
  var VideoAgentMesh = exports.VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
34
+ (0, _inherits2["default"])(VideoAgentMesh, _THREE$Mesh);
35
+ var _super = _createSuper(VideoAgentMesh);
33
36
  /**
34
37
  *
35
38
  * @param width
@@ -75,7 +78,7 @@ var VideoAgentMesh = exports.VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh
75
78
  fragmentShader: fragmentShaderTpl(),
76
79
  transparent: true
77
80
  });
78
- _this = _callSuper(this, VideoAgentMesh, [geometry, material]);
81
+ _this = _super.call(this, geometry, material);
79
82
  _this.options = options;
80
83
  _this.freeze = false;
81
84
  _this.paused = true;
@@ -97,7 +100,7 @@ var VideoAgentMesh = exports.VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh
97
100
  _this.audioInstance = options.audioInstance;
98
101
  }
99
102
  _this.audioLikeInstance = new _AudioLike["default"]();
100
- (0, _mobx.makeObservable)(_this, {
103
+ (0, _mobx.makeObservable)((0, _assertThisInitialized2["default"])(_this), {
101
104
  paused: _mobx.observable
102
105
  });
103
106
  var updatePaused = function updatePaused(paused) {
@@ -113,23 +116,22 @@ var VideoAgentMesh = exports.VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh
113
116
  };
114
117
  _this.audioInstance.addEventListener('pause', onPause);
115
118
  _this.audioInstance.addEventListener('play', onPlay);
116
- (_this$options$videoIn = _this.options.videoInstance) === null || _this$options$videoIn === void 0 || _this$options$videoIn.addEventListener('pause', onPause);
117
- (_this$options$videoIn2 = _this.options.videoInstance) === null || _this$options$videoIn2 === void 0 || _this$options$videoIn2.addEventListener('play', onPlay);
119
+ (_this$options$videoIn = _this.options.videoInstance) === null || _this$options$videoIn === void 0 ? void 0 : _this$options$videoIn.addEventListener('pause', onPause);
120
+ (_this$options$videoIn2 = _this.options.videoInstance) === null || _this$options$videoIn2 === void 0 ? void 0 : _this$options$videoIn2.addEventListener('play', onPlay);
118
121
  _this.audioLikeInstance.addEventListener('pause', onPause);
119
122
  _this.audioLikeInstance.addEventListener('play', onPlay);
120
123
  _this.$removeEventListener = function () {
121
124
  var _this$options$videoIn3, _this$options$videoIn4;
122
125
  _this.audioInstance.removeEventListener('pause', onPause);
123
126
  _this.audioInstance.removeEventListener('play', onPlay);
124
- (_this$options$videoIn3 = _this.options.videoInstance) === null || _this$options$videoIn3 === void 0 || _this$options$videoIn3.removeEventListener('pause', onPause);
125
- (_this$options$videoIn4 = _this.options.videoInstance) === null || _this$options$videoIn4 === void 0 || _this$options$videoIn4.removeEventListener('play', onPlay);
127
+ (_this$options$videoIn3 = _this.options.videoInstance) === null || _this$options$videoIn3 === void 0 ? void 0 : _this$options$videoIn3.removeEventListener('pause', onPause);
128
+ (_this$options$videoIn4 = _this.options.videoInstance) === null || _this$options$videoIn4 === void 0 ? void 0 : _this$options$videoIn4.removeEventListener('play', onPlay);
126
129
  _this.audioLikeInstance.removeEventListener('pause', onPause);
127
130
  _this.audioLikeInstance.removeEventListener('play', onPlay);
128
131
  };
129
132
  return _this;
130
133
  }
131
- (0, _inherits2["default"])(VideoAgentMesh, _THREE$Mesh);
132
- return (0, _createClass2["default"])(VideoAgentMesh, [{
134
+ (0, _createClass2["default"])(VideoAgentMesh, [{
133
135
  key: "mediaInstance",
134
136
  get: function get() {
135
137
  if (!this.videoUrl) {
@@ -147,62 +149,64 @@ var VideoAgentMesh = exports.VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh
147
149
  value: function () {
148
150
  var _update = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(videoUrl) {
149
151
  var _this2 = this;
150
- var uniforms, _onStart;
152
+ var uniforms, onStart;
151
153
  return _regenerator["default"].wrap(function _callee$(_context) {
152
- while (1) switch (_context.prev = _context.next) {
153
- case 0:
154
- if (!(this.videoUrl === videoUrl)) {
155
- _context.next = 2;
156
- break;
157
- }
158
- return _context.abrupt("return");
159
- case 2:
160
- this.videoUrl = videoUrl;
154
+ while (1) {
155
+ switch (_context.prev = _context.next) {
156
+ case 0:
157
+ if (!(this.videoUrl === videoUrl)) {
158
+ _context.next = 2;
159
+ break;
160
+ }
161
+ return _context.abrupt("return");
162
+ case 2:
163
+ this.videoUrl = videoUrl;
161
164
 
162
- // // 兼容非视频场景
163
- // if (this.mediaInstance instanceof HTMLAudioElement) {
164
- // this.mediaInstance.style.display = 'none'
165
- // } else if (this.mediaInstance instanceof HTMLVideoElement) {
166
- // this.mediaInstance.style.display = 'block'
167
- // }
165
+ // // 兼容非视频场景
166
+ // if (this.mediaInstance instanceof HTMLAudioElement) {
167
+ // this.mediaInstance.style.display = 'none'
168
+ // } else if (this.mediaInstance instanceof HTMLVideoElement) {
169
+ // this.mediaInstance.style.display = 'block'
170
+ // }
168
171
 
169
- this.freeze = true;
170
- _context.next = 6;
171
- return this.mediaInstance.pause();
172
- case 6:
173
- uniforms = this.material.uniforms;
174
- this.mediaInstance.muted = true;
175
- if (!(this.options.preload || this.options.preload === undefined || (0, _getMediaInfo.getMediaType)(this.videoUrl) === 'video')) {
176
- _context.next = 18;
172
+ this.freeze = true;
173
+ _context.next = 6;
174
+ return this.mediaInstance.pause();
175
+ case 6:
176
+ uniforms = this.material.uniforms;
177
+ this.mediaInstance.muted = true;
178
+ if (!(this.options.preload || this.options.preload === undefined || (0, _getMediaInfo.getMediaType)(this.videoUrl) === 'video')) {
179
+ _context.next = 18;
180
+ break;
181
+ }
182
+ _context.t1 = URL;
183
+ _context.next = 12;
184
+ return _Preloader.Preloader.blob(this.videoUrl);
185
+ case 12:
186
+ _context.t2 = _context.sent;
187
+ _context.next = 15;
188
+ return _context.t1.createObjectURL.call(_context.t1, _context.t2);
189
+ case 15:
190
+ _context.t0 = _context.sent;
191
+ _context.next = 19;
177
192
  break;
178
- }
179
- _context.t1 = URL;
180
- _context.next = 12;
181
- return _Preloader.Preloader.blob(this.videoUrl);
182
- case 12:
183
- _context.t2 = _context.sent;
184
- _context.next = 15;
185
- return _context.t1.createObjectURL.call(_context.t1, _context.t2);
186
- case 15:
187
- _context.t0 = _context.sent;
188
- _context.next = 19;
189
- break;
190
- case 18:
191
- _context.t0 = this.videoUrl;
192
- case 19:
193
- this.mediaInstance.src = _context.t0;
194
- this.mediaInstance.setAttribute('data-src', this.videoUrl);
195
- _onStart = function onStart() {
196
- if (_this2.mediaInstance.currentTime === 0) return;
197
- _this2.freeze = false;
198
- _this2.mediaInstance.muted = false;
199
- uniforms.enable.value = (0, _getMediaInfo.getMediaType)(_this2.videoUrl) ? 1 : 0;
200
- _this2.mediaInstance.removeEventListener('timeupdate', _onStart, false);
201
- };
202
- this.mediaInstance.addEventListener('timeupdate', _onStart, false);
203
- case 23:
204
- case "end":
205
- return _context.stop();
193
+ case 18:
194
+ _context.t0 = this.videoUrl;
195
+ case 19:
196
+ this.mediaInstance.src = _context.t0;
197
+ this.mediaInstance.setAttribute('data-src', this.videoUrl);
198
+ onStart = function onStart() {
199
+ if (_this2.mediaInstance.currentTime === 0) return;
200
+ _this2.freeze = false;
201
+ _this2.mediaInstance.muted = false;
202
+ uniforms.enable.value = (0, _getMediaInfo.getMediaType)(_this2.videoUrl) ? 1 : 0;
203
+ _this2.mediaInstance.removeEventListener('timeupdate', onStart, false);
204
+ };
205
+ this.mediaInstance.addEventListener('timeupdate', onStart, false);
206
+ case 23:
207
+ case "end":
208
+ return _context.stop();
209
+ }
206
210
  }
207
211
  }, _callee, this);
208
212
  }));
@@ -221,79 +225,83 @@ var VideoAgentMesh = exports.VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh
221
225
  duration,
222
226
  _args3 = arguments;
223
227
  return _regenerator["default"].wrap(function _callee3$(_context3) {
224
- while (1) switch (_context3.prev = _context3.next) {
225
- case 0:
226
- videoUrl = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : '';
227
- currentTime = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : 0;
228
- duration = _args3.length > 2 ? _args3[2] : undefined;
229
- videoUrl = videoUrl || '';
230
- if (!(duration && !videoUrl)) {
231
- _context3.next = 10;
228
+ while (1) {
229
+ switch (_context3.prev = _context3.next) {
230
+ case 0:
231
+ videoUrl = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : '';
232
+ currentTime = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : 0;
233
+ duration = _args3.length > 2 ? _args3[2] : undefined;
234
+ videoUrl = videoUrl || '';
235
+ if (!(duration && !videoUrl)) {
236
+ _context3.next = 10;
237
+ break;
238
+ }
239
+ if (this.currentTime) {
240
+ this.mediaInstance.currentTime = currentTime;
241
+ }
242
+ this.mediaInstance.duration = duration;
243
+ this.videoUrl = '';
244
+ this.mediaInstance.play();
245
+ return _context3.abrupt("return", true);
246
+ case 10:
247
+ if (videoUrl) {
248
+ _context3.next = 18;
249
+ break;
250
+ }
251
+ if (!this.videoUrl) {
252
+ _context3.next = 16;
253
+ break;
254
+ }
255
+ _context3.next = 14;
256
+ return this.mediaInstance.play();
257
+ case 14:
258
+ _context3.next = 17;
232
259
  break;
233
- }
234
- if (this.currentTime) {
260
+ case 16:
261
+ console.warn('警告:视频资源未初始化。');
262
+ case 17:
263
+ return _context3.abrupt("return", true);
264
+ case 18:
265
+ if (!(videoUrl === this.videoUrl)) {
266
+ _context3.next = 23;
267
+ break;
268
+ }
235
269
  this.mediaInstance.currentTime = currentTime;
236
- }
237
- this.mediaInstance.duration = duration;
238
- this.videoUrl = '';
239
- this.mediaInstance.play();
240
- return _context3.abrupt("return", true);
241
- case 10:
242
- if (videoUrl) {
243
- _context3.next = 18;
244
- break;
245
- }
246
- if (!this.videoUrl) {
247
- _context3.next = 16;
248
- break;
249
- }
250
- _context3.next = 14;
251
- return this.mediaInstance.play();
252
- case 14:
253
- _context3.next = 17;
254
- break;
255
- case 16:
256
- console.warn('警告:视频资源未初始化。');
257
- case 17:
258
- return _context3.abrupt("return", true);
259
- case 18:
260
- if (!(videoUrl === this.videoUrl)) {
261
- _context3.next = 23;
262
- break;
263
- }
264
- this.mediaInstance.currentTime = currentTime;
265
- _context3.next = 22;
266
- return this.mediaInstance.play();
267
- case 22:
268
- return _context3.abrupt("return", true);
269
- case 23:
270
- _context3.next = 25;
271
- return this.update(videoUrl);
272
- case 25:
273
- this.mediaInstance.pause();
274
- _context3.next = 28;
275
- return new Promise(function (resolve) {
276
- return setTimeout(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2() {
277
- return _regenerator["default"].wrap(function _callee2$(_context2) {
278
- while (1) switch (_context2.prev = _context2.next) {
279
- case 0:
280
- _this3.mediaInstance.currentTime = currentTime;
281
- _context2.next = 3;
282
- return _this3.mediaInstance.play();
283
- case 3:
284
- resolve(true);
285
- case 4:
286
- case "end":
287
- return _context2.stop();
288
- }
289
- }, _callee2);
290
- })), 20);
291
- });
292
- case 28:
293
- return _context3.abrupt("return", _context3.sent);
294
- case 29:
295
- case "end":
296
- return _context3.stop();
270
+ _context3.next = 22;
271
+ return this.mediaInstance.play();
272
+ case 22:
273
+ return _context3.abrupt("return", true);
274
+ case 23:
275
+ _context3.next = 25;
276
+ return this.update(videoUrl);
277
+ case 25:
278
+ this.mediaInstance.pause();
279
+ _context3.next = 28;
280
+ return new Promise(function (resolve) {
281
+ return setTimeout(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2() {
282
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
283
+ while (1) {
284
+ switch (_context2.prev = _context2.next) {
285
+ case 0:
286
+ _this3.mediaInstance.currentTime = currentTime;
287
+ _context2.next = 3;
288
+ return _this3.mediaInstance.play();
289
+ case 3:
290
+ resolve(true);
291
+ case 4:
292
+ case "end":
293
+ return _context2.stop();
294
+ }
295
+ }
296
+ }, _callee2);
297
+ })), 20);
298
+ });
299
+ case 28:
300
+ return _context3.abrupt("return", _context3.sent);
301
+ case 29:
302
+ case "end":
303
+ return _context3.stop();
304
+ }
297
305
  }
298
306
  }, _callee3, this);
299
307
  }));
@@ -325,4 +333,5 @@ var VideoAgentMesh = exports.VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh
325
333
  }
326
334
  }
327
335
  }]);
336
+ return VideoAgentMesh;
328
337
  }(THREE.Mesh);