@realsee/vreo 2.6.4-alpha.5 → 2.6.4

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 (31) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/lib/PlayController/createHTMLAudioElement.js +14 -10
  3. package/lib/PlayController/index.js +73 -63
  4. package/lib/Player/Controller.js +56 -50
  5. package/lib/Player/PlaybackLifecycle.js +7 -6
  6. package/lib/Player/custom/SpatialScenePanel/index.js +11 -34
  7. package/lib/Player/index.js +166 -160
  8. package/lib/Player/modules/Drawer/index.js +2 -1
  9. package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +157 -146
  10. package/lib/Player/modules/VideoAgent/VideoAgentScene.js +1 -1
  11. package/lib/Player/modules/VideoAgent/index.js +3 -3
  12. package/lib/Player/modules/keyframes/BgMusic/index.js +12 -12
  13. package/lib/Player/modules/keyframes/CameraMovement/index.js +45 -43
  14. package/lib/Player/modules/keyframes/InfoPanel/index.js +8 -8
  15. package/lib/Player/modules/keyframes/ModelVideo/index.js +83 -81
  16. package/lib/Player/modules/keyframes/PanoTag/index.js +1 -1
  17. package/lib/Player/modules/keyframes/PanoTextLabel/index.js +3 -3
  18. package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +3 -3
  19. package/lib/Player/modules/keyframes/VideoEffect/index.js +71 -69
  20. package/lib/fivePlugins/CSS3DRenderPlugin/index.js +6 -6
  21. package/lib/fivePlugins/CameraMovementPlugin/index.js +180 -173
  22. package/lib/fivePlugins/CameraMovementPlugin/typings.js +6 -6
  23. package/lib/fivePlugins/ModelTVVideoPlugin/index.js +59 -57
  24. package/lib/react/index.js +1 -1
  25. package/lib/shared-utils/Audio.js +56 -52
  26. package/lib/shared-utils/AudioLike.js +14 -11
  27. package/lib/shared-utils/animationFrame/BetterTween.js +15 -13
  28. package/lib/shared-utils/animationFrame/tween.js +3 -1
  29. package/lib/shared-utils/getMediaInfo.js +1 -0
  30. package/lib/typings/VreoUnit.js +27 -134
  31. package/package.json +3 -3
@@ -18,9 +18,9 @@ function InfoPanelVideo(_ref2) {
18
18
  var videoWrapperRef = React.useRef(null);
19
19
  var controller = useController();
20
20
  React.useEffect(function () {
21
- var _controller$configs;
21
+ var _controller$configs, _controller$configs$v;
22
22
  // if (!isIOSorWX) return
23
- var video = ((_controller$configs = controller.configs) === null || _controller$configs === void 0 || (_controller$configs = _controller$configs.videos) === null || _controller$configs === void 0 ? void 0 : _controller$configs.videoPanel) || document.createElement('video');
23
+ var video = ((_controller$configs = controller.configs) === null || _controller$configs === void 0 ? void 0 : (_controller$configs$v = _controller$configs.videos) === null || _controller$configs$v === void 0 ? void 0 : _controller$configs$v.videoPanel) || document.createElement('video');
24
24
  var run = controller.playback.capture();
25
25
  var valid = function valid() {
26
26
  return !!(run !== null && run !== void 0 && run.valid());
@@ -34,7 +34,7 @@ function InfoPanelVideo(_ref2) {
34
34
  disposed = true;
35
35
  output.muted = true;
36
36
  output.pause();
37
- video.removeEventListener('canplaythrough', _canplaythrough);
37
+ video.removeEventListener('canplaythrough', canplaythrough);
38
38
  };
39
39
  if (!videoWrapperRef.current) return;
40
40
  var remove = controller.playback.add(stop);
@@ -42,8 +42,8 @@ function InfoPanelVideo(_ref2) {
42
42
  if (!videoWrapperRef.current.contains(video)) {
43
43
  videoWrapperRef.current.appendChild(video);
44
44
  }
45
- var _canplaythrough = function canplaythrough() {
46
- video.removeEventListener('canplaythrough', _canplaythrough);
45
+ var canplaythrough = function canplaythrough() {
46
+ video.removeEventListener('canplaythrough', canplaythrough);
47
47
  if (disposed || !valid()) return;
48
48
  output.muted = false;
49
49
  void output.play().catch(function (error) {
@@ -54,7 +54,7 @@ function InfoPanelVideo(_ref2) {
54
54
  }
55
55
  });
56
56
  };
57
- video.addEventListener('canplaythrough', _canplaythrough);
57
+ video.addEventListener('canplaythrough', canplaythrough);
58
58
  output.load();
59
59
  // output.play()
60
60
 
@@ -107,14 +107,14 @@ export function InfoPanel() {
107
107
  do {
108
108
  if (style === InfoPanelStyleEnum.PopUp) {
109
109
  if (infoPanelData.type === InfoPanelTypeEnum.Image) {
110
- controller.openPopUp(/*#__PURE__*/React.createElement(InfoPanelImg, {
110
+ controller.openPopUp( /*#__PURE__*/React.createElement(InfoPanelImg, {
111
111
  url: infoPanelData.url
112
112
  }, /*#__PURE__*/React.createElement(Title, {
113
113
  title: title,
114
114
  subTitle: subTitle
115
115
  })));
116
116
  } else if (infoPanelData.type === InfoPanelTypeEnum.Video) {
117
- controller.openPopUp(/*#__PURE__*/React.createElement(InfoPanelVideo, {
117
+ controller.openPopUp( /*#__PURE__*/React.createElement(InfoPanelVideo, {
118
118
  url: infoPanelData.url
119
119
  }, /*#__PURE__*/React.createElement(Title, {
120
120
  title: title,
@@ -1,6 +1,5 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
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); }
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
3
  import * as React from 'react';
5
4
  import * as THREE from 'three';
6
5
  import { useController, useFiveInstance } from "../../../hooks.js";
@@ -18,92 +17,95 @@ export function ModelVideo() {
18
17
  var _ref$current;
19
18
  ++generation;
20
19
  if (timeoutRef.current) clearTimeout(timeoutRef.current);
21
- (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.dispose();
20
+ (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.dispose();
22
21
  ref.current = undefined;
23
22
  };
24
23
  var remove = controller.playback.add(stop);
25
24
  var callback = /*#__PURE__*/function () {
26
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(keyframe) {
27
- var current, run, valid, plugin, start, end, _ref2, videoSrc, videoPosterSrc, vertexs, matrixWorld, position, points, _controller$configs, _t;
28
- return _regenerator().w(function (_context) {
29
- while (1) switch (_context.p = _context.n) {
30
- case 0:
31
- stop();
32
- current = generation;
33
- run = controller.playback.capture();
34
- valid = function valid() {
35
- return !!(run !== null && run !== void 0 && run.valid());
36
- };
37
- if (valid()) {
38
- _context.n = 1;
39
- break;
40
- }
41
- return _context.a(2);
42
- case 1:
43
- plugin = ref.current = ModelTVVideoPlugin(five, {
44
- mediaManager: run === null || run === void 0 ? void 0 : run.mediaManager
45
- });
46
- start = keyframe.start, end = keyframe.end;
47
- _ref2 = keyframe.data, videoSrc = _ref2.videoSrc, videoPosterSrc = _ref2.videoPosterSrc, vertexs = _ref2.vertexs, matrixWorld = _ref2.matrixWorld;
48
- position = function () {
49
- if (vertexs.length < 4) {
50
- throw new Error('ModelVideo: 顶点数据集合不够,无法组成矩形 ....');
51
- }
52
- if (vertexs.length === 4) {
53
- return vertexs;
25
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(keyframe) {
26
+ var current, run, valid, plugin, start, end, _ref2, videoSrc, videoPosterSrc, vertexs, matrixWorld, position, points, _controller$configs, _controller$configs$v;
27
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
28
+ while (1) {
29
+ switch (_context.prev = _context.next) {
30
+ case 0:
31
+ stop();
32
+ current = generation;
33
+ run = controller.playback.capture();
34
+ valid = function valid() {
35
+ return !!(run !== null && run !== void 0 && run.valid());
36
+ };
37
+ if (valid()) {
38
+ _context.next = 6;
39
+ break;
54
40
  }
55
- var box = new THREE.Box3();
56
- vertexs.forEach(function (v) {
57
- return box.expandByPoint(new THREE.Vector3(v.x, v.y, v.z));
41
+ return _context.abrupt("return");
42
+ case 6:
43
+ plugin = ref.current = ModelTVVideoPlugin(five, {
44
+ mediaManager: run === null || run === void 0 ? void 0 : run.mediaManager
58
45
  });
59
- return [new THREE.Vector3(box.min.x, box.max.y, box.max.z), new THREE.Vector3(box.min.x, box.min.y, box.max.z), new THREE.Vector3(box.max.x, box.min.y, box.max.z), new THREE.Vector3(box.max.x, box.max.y, box.max.z)];
60
- }();
61
- points = function () {
62
- if (matrixWorld) {
63
- var transMatrix = createTransMatrix(matrixWorld);
64
- return [position.map(function (p) {
65
- var res = transMatrix([p.x, p.y, p.z]);
66
- return {
67
- x: res[0],
68
- y: res[1],
69
- z: res[2]
70
- };
71
- })];
72
- }
73
- return [position];
74
- }();
75
- plugin.disable();
76
- _context.p = 2;
77
- _context.n = 3;
78
- return plugin.load({
79
- video_src: videoSrc,
80
- video_poster_src: videoPosterSrc,
81
- points: points
82
- }, (_controller$configs = controller.configs) === null || _controller$configs === void 0 || (_controller$configs = _controller$configs.videos) === null || _controller$configs === void 0 ? void 0 : _controller$configs.modelTVVideo);
83
- case 3:
84
- _context.n = 5;
85
- break;
86
- case 4:
87
- _context.p = 4;
88
- _t = _context.v;
89
- if (current === generation && valid()) {
90
- controller.playback.cancel();
91
- console.error(_t);
92
- }
93
- return _context.a(2);
94
- case 5:
95
- if (!(current !== generation || !valid())) {
96
- _context.n = 6;
46
+ start = keyframe.start, end = keyframe.end;
47
+ _ref2 = keyframe.data, videoSrc = _ref2.videoSrc, videoPosterSrc = _ref2.videoPosterSrc, vertexs = _ref2.vertexs, matrixWorld = _ref2.matrixWorld;
48
+ position = function () {
49
+ if (vertexs.length < 4) {
50
+ throw new Error('ModelVideo: 顶点数据集合不够,无法组成矩形 ....');
51
+ }
52
+ if (vertexs.length === 4) {
53
+ return vertexs;
54
+ }
55
+ var box = new THREE.Box3();
56
+ vertexs.forEach(function (v) {
57
+ return box.expandByPoint(new THREE.Vector3(v.x, v.y, v.z));
58
+ });
59
+ return [new THREE.Vector3(box.min.x, box.max.y, box.max.z), new THREE.Vector3(box.min.x, box.min.y, box.max.z), new THREE.Vector3(box.max.x, box.min.y, box.max.z), new THREE.Vector3(box.max.x, box.max.y, box.max.z)];
60
+ }();
61
+ points = function () {
62
+ if (matrixWorld) {
63
+ var transMatrix = createTransMatrix(matrixWorld);
64
+ return [position.map(function (p) {
65
+ var res = transMatrix([p.x, p.y, p.z]);
66
+ return {
67
+ x: res[0],
68
+ y: res[1],
69
+ z: res[2]
70
+ };
71
+ })];
72
+ }
73
+ return [position];
74
+ }();
75
+ plugin.disable();
76
+ _context.prev = 12;
77
+ _context.next = 15;
78
+ return plugin.load({
79
+ video_src: videoSrc,
80
+ video_poster_src: videoPosterSrc,
81
+ points: points
82
+ }, (_controller$configs = controller.configs) === null || _controller$configs === void 0 ? void 0 : (_controller$configs$v = _controller$configs.videos) === null || _controller$configs$v === void 0 ? void 0 : _controller$configs$v.modelTVVideo);
83
+ case 15:
84
+ _context.next = 21;
97
85
  break;
98
- }
99
- return _context.a(2);
100
- case 6:
101
- plugin.enable();
102
- timeoutRef.current = setTimeout(stop, end - start);
103
- case 7:
104
- return _context.a(2);
86
+ case 17:
87
+ _context.prev = 17;
88
+ _context.t0 = _context["catch"](12);
89
+ if (current === generation && valid()) {
90
+ controller.playback.cancel();
91
+ console.error(_context.t0);
92
+ }
93
+ return _context.abrupt("return");
94
+ case 21:
95
+ if (!(current !== generation || !valid())) {
96
+ _context.next = 23;
97
+ break;
98
+ }
99
+ return _context.abrupt("return");
100
+ case 23:
101
+ plugin.enable();
102
+ timeoutRef.current = setTimeout(stop, end - start);
103
+ case 25:
104
+ case "end":
105
+ return _context.stop();
106
+ }
105
107
  }
106
- }, _callee, null, [[2, 4]]);
108
+ }, _callee, null, [[12, 17]]);
107
109
  }));
108
110
  return function callback(_x) {
109
111
  return _ref.apply(this, arguments);
@@ -114,7 +116,7 @@ export function ModelVideo() {
114
116
  var _ref$current2;
115
117
  stop();
116
118
  remove();
117
- (_ref$current2 = ref.current) === null || _ref$current2 === void 0 || _ref$current2.dispose();
119
+ (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.dispose();
118
120
  ref.current = undefined;
119
121
  controller.off(VreoKeyframeEnum.ModelVideo, callback);
120
122
  if (timeoutRef.current) {
@@ -88,7 +88,7 @@ export function PanoTag() {
88
88
  tag.state.unfolded = false;
89
89
  panoTagPlugin.current.updateRenderAllTags();
90
90
  }
91
- (_tag$hooks = tag.hooks) === null || _tag$hooks === void 0 || _tag$hooks.on('folded', function () {
91
+ (_tag$hooks = tag.hooks) === null || _tag$hooks === void 0 ? void 0 : _tag$hooks.on('folded', function () {
92
92
  setTimeout(function () {
93
93
  if (tag.state) {
94
94
  tag.state.visible = false;
@@ -90,11 +90,11 @@ export function PanoTextLabel() {
90
90
  // 将获取的mesh进行旋转操作,根据欧拉角去进行mesh的变换
91
91
  if (data.quaternion) {
92
92
  var quaternion = new Quaternion(data.quaternion.x, data.quaternion.y, data.quaternion.z, data.quaternion.w);
93
- css3DObject === null || css3DObject === void 0 || css3DObject.quaternion.copy(quaternion);
93
+ css3DObject === null || css3DObject === void 0 ? void 0 : css3DObject.quaternion.copy(quaternion);
94
94
  }
95
95
  if (container !== null && container !== void 0 && container.container) {
96
96
  var root = createRoot(container.container);
97
- root.render(/*#__PURE__*/React.createElement("div", {
97
+ root.render( /*#__PURE__*/React.createElement("div", {
98
98
  className: "PanoTextLabel PanoTextLabel--notHidden"
99
99
  }, /*#__PURE__*/React.createElement("div", {
100
100
  className: "PanoTextLabel-wrapper"
@@ -107,7 +107,7 @@ export function PanoTextLabel() {
107
107
  }
108
108
  timeoutRef.current = setTimeout(function () {
109
109
  var _ref$current;
110
- (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.disposeAll();
110
+ (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.disposeAll();
111
111
  }, end - start);
112
112
  };
113
113
  controller.on(VreoKeyframeEnum.PanoTextLabel, callback);
@@ -38,8 +38,8 @@ export function UpdateVRPanorama() {
38
38
  }, []);
39
39
  React.useEffect(function () {
40
40
  var callback = function callback(keyframe) {
41
- var _five$work, _five$work2;
42
- if (!deafultWorkRef.current && (_five$work = five.work) !== null && _five$work !== void 0 && (_five$work = _five$work.raw) !== null && _five$work !== void 0 && _five$work.works) {
41
+ var _five$work, _five$work$raw, _five$work2, _five$work2$raw, _five$work2$raw$works;
42
+ if (!deafultWorkRef.current && (_five$work = five.work) !== null && _five$work !== void 0 && (_five$work$raw = _five$work.raw) !== null && _five$work$raw !== void 0 && _five$work$raw.works) {
43
43
  deafultWorkRef.current = five.work.raw.works;
44
44
  }
45
45
  var data = keyframe.data;
@@ -50,7 +50,7 @@ export function UpdateVRPanorama() {
50
50
  five.load(updateWorkRef.current);
51
51
  return;
52
52
  }
53
- var lastRawWork = (_five$work2 = five.work) === null || _five$work2 === void 0 || (_five$work2 = _five$work2.raw) === null || _five$work2 === void 0 || (_five$work2 = _five$work2.works) === null || _five$work2 === void 0 ? void 0 : _five$work2[0];
53
+ var lastRawWork = (_five$work2 = five.work) === null || _five$work2 === void 0 ? void 0 : (_five$work2$raw = _five$work2.raw) === null || _five$work2$raw === void 0 ? void 0 : (_five$work2$raw$works = _five$work2$raw.works) === null || _five$work2$raw$works === void 0 ? void 0 : _five$work2$raw$works[0];
54
54
  if (!lastRawWork) {
55
55
  console.warn('UpdateVRPanorama: 没有可用的 work 数据');
56
56
  return;
@@ -1,7 +1,6 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
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); }
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
5
4
  import classNames from 'classnames';
6
5
  import * as React from 'react';
7
6
  // import { Preloader } from '../../../../shared-utils/Preloader'
@@ -24,73 +23,76 @@ export function VideoEffect() {
24
23
  var generation = 0;
25
24
  var removeCanPlay;
26
25
  var callback = /*#__PURE__*/function () {
27
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(keyframe) {
26
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(keyframe) {
28
27
  var _removeCanPlay;
29
28
  var start, end, _ref2, videoSrc, fov, direction, panoIndex, vector, _ref3, _ref4, longitude, latitude, currentGeneration, run, active, valid, video, media, play;
30
- return _regenerator().w(function (_context) {
31
- while (1) switch (_context.n) {
32
- case 0:
33
- start = keyframe.start, end = keyframe.end;
34
- _ref2 = keyframe.data, videoSrc = _ref2.videoSrc, fov = _ref2.fov, direction = _ref2.direction, panoIndex = _ref2.panoIndex, vector = _ref2.vector;
35
- _ref3 = function () {
36
- if (vector) {
37
- return [vector.longitude, vector.latitude];
38
- }
39
- if (!direction) {
40
- return [0, 0];
41
- }
42
- var longitude = -Math.atan2(direction.x, -direction.z);
43
- longitude = (longitude % PI_2 + PI_2) % PI_2;
44
- var latitude = -Math.asin(direction.y / 1);
45
- return [longitude, latitude];
46
- }(), _ref4 = _slicedToArray(_ref3, 2), longitude = _ref4[0], latitude = _ref4[1];
47
- destroy();
48
- currentGeneration = generation;
49
- five.setState({
50
- fov: fov,
51
- panoIndex: panoIndex,
52
- longitude: longitude,
53
- latitude: latitude
54
- }, true);
55
- (_removeCanPlay = removeCanPlay) === null || _removeCanPlay === void 0 || _removeCanPlay();
56
- run = controller.playback.capture();
57
- active = function active() {
58
- return !!(run !== null && run !== void 0 && run.valid());
59
- };
60
- valid = function valid() {
61
- return currentGeneration === generation && active();
62
- };
63
- video = videoRef.current;
64
- if (!(!video || !valid())) {
65
- _context.n = 1;
66
- break;
67
- }
68
- return _context.a(2);
69
- case 1:
70
- media = output = run.bind(video);
71
- media.muted = true;
72
- media.src = videoSrc;
73
- play = function play() {
74
- var _removeCanPlay2;
75
- (_removeCanPlay2 = removeCanPlay) === null || _removeCanPlay2 === void 0 || _removeCanPlay2();
76
- if (!valid()) return;
77
- media.muted = false;
78
- void media.play().catch(function (error) {
79
- if (valid()) {
80
- controller.playback.cancel();
81
- console.error(error);
29
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
30
+ while (1) {
31
+ switch (_context.prev = _context.next) {
32
+ case 0:
33
+ start = keyframe.start, end = keyframe.end;
34
+ _ref2 = keyframe.data, videoSrc = _ref2.videoSrc, fov = _ref2.fov, direction = _ref2.direction, panoIndex = _ref2.panoIndex, vector = _ref2.vector;
35
+ _ref3 = function () {
36
+ if (vector) {
37
+ return [vector.longitude, vector.latitude];
82
38
  }
83
- });
84
- };
85
- removeCanPlay = function removeCanPlay() {
86
- return video.removeEventListener('canplaythrough', play);
87
- };
88
- video.addEventListener('canplaythrough', play);
89
- media.load();
90
- setVisible(true);
91
- timeoutRef.current = setTimeout(destroy, Math.max(0, end - start));
92
- case 2:
93
- return _context.a(2);
39
+ if (!direction) {
40
+ return [0, 0];
41
+ }
42
+ var longitude = -Math.atan2(direction.x, -direction.z);
43
+ longitude = (longitude % PI_2 + PI_2) % PI_2;
44
+ var latitude = -Math.asin(direction.y / 1);
45
+ return [longitude, latitude];
46
+ }(), _ref4 = _slicedToArray(_ref3, 2), longitude = _ref4[0], latitude = _ref4[1];
47
+ destroy();
48
+ currentGeneration = generation;
49
+ five.setState({
50
+ fov: fov,
51
+ panoIndex: panoIndex,
52
+ longitude: longitude,
53
+ latitude: latitude
54
+ }, true);
55
+ (_removeCanPlay = removeCanPlay) === null || _removeCanPlay === void 0 ? void 0 : _removeCanPlay();
56
+ run = controller.playback.capture();
57
+ active = function active() {
58
+ return !!(run !== null && run !== void 0 && run.valid());
59
+ };
60
+ valid = function valid() {
61
+ return currentGeneration === generation && active();
62
+ };
63
+ video = videoRef.current;
64
+ if (!(!video || !valid())) {
65
+ _context.next = 13;
66
+ break;
67
+ }
68
+ return _context.abrupt("return");
69
+ case 13:
70
+ media = output = run.bind(video);
71
+ media.muted = true;
72
+ media.src = videoSrc;
73
+ play = function play() {
74
+ var _removeCanPlay2;
75
+ (_removeCanPlay2 = removeCanPlay) === null || _removeCanPlay2 === void 0 ? void 0 : _removeCanPlay2();
76
+ if (!valid()) return;
77
+ media.muted = false;
78
+ void media.play().catch(function (error) {
79
+ if (valid()) {
80
+ controller.playback.cancel();
81
+ console.error(error);
82
+ }
83
+ });
84
+ };
85
+ removeCanPlay = function removeCanPlay() {
86
+ return video.removeEventListener('canplaythrough', play);
87
+ };
88
+ video.addEventListener('canplaythrough', play);
89
+ media.load();
90
+ setVisible(true);
91
+ timeoutRef.current = setTimeout(destroy, Math.max(0, end - start));
92
+ case 22:
93
+ case "end":
94
+ return _context.stop();
95
+ }
94
96
  }
95
97
  }, _callee);
96
98
  }));
@@ -105,7 +107,7 @@ export function VideoEffect() {
105
107
  if (timeoutRef.current) {
106
108
  clearTimeout(timeoutRef.current);
107
109
  }
108
- (_removeCanPlay3 = removeCanPlay) === null || _removeCanPlay3 === void 0 || _removeCanPlay3();
110
+ (_removeCanPlay3 = removeCanPlay) === null || _removeCanPlay3 === void 0 ? void 0 : _removeCanPlay3();
109
111
  if (output) {
110
112
  output.muted = true;
111
113
  output.pause();
@@ -125,9 +127,9 @@ export function VideoEffect() {
125
127
  };
126
128
  }, [controller]);
127
129
  React.useEffect(function () {
128
- var _controller$configs;
130
+ var _controller$configs, _controller$configs$v;
129
131
  if (!ref.current) return;
130
- var video = ((_controller$configs = controller.configs) === null || _controller$configs === void 0 || (_controller$configs = _controller$configs.videos) === null || _controller$configs === void 0 ? void 0 : _controller$configs.videoEffect) || document.createElement('video');
132
+ var video = ((_controller$configs = controller.configs) === null || _controller$configs === void 0 ? void 0 : (_controller$configs$v = _controller$configs.videos) === null || _controller$configs$v === void 0 ? void 0 : _controller$configs$v.videoEffect) || document.createElement('video');
131
133
  // <video playsInline key="VideoEffect-video" className="VideoEffect-video" src={blobSrc} />
132
134
  video.setAttribute('playsinline', 'true');
133
135
  video.setAttribute('webkit-playsinline', 'true');
@@ -28,7 +28,7 @@ export var CSS3DRenderPlugin = function CSS3DRenderPlugin(five) {
28
28
  });
29
29
  var config = params[1];
30
30
  if ((points === null || points === void 0 ? void 0 : points.length) < 4) return console.error('points must be equal or greater than than 4');
31
- if (!(five !== null && five !== void 0 && (_five$model = five.model) !== null && _five$model !== void 0 && _five$model.loaded)) return console.error('five.model.loaded is: ', five === null || five === void 0 || (_five$model2 = five.model) === null || _five$model2 === void 0 ? void 0 : _five$model2.loaded);
31
+ if (!(five !== null && five !== void 0 && (_five$model = five.model) !== null && _five$model !== void 0 && _five$model.loaded)) return console.error('five.model.loaded is: ', five === null || five === void 0 ? void 0 : (_five$model2 = five.model) === null || _five$model2 === void 0 ? void 0 : _five$model2.loaded);
32
32
  var fiveElement = five.getElement();
33
33
  if (!fiveElement) return console.error('five.getElement() is ' + fiveElement);
34
34
  var disposers = [];
@@ -92,16 +92,16 @@ export var CSS3DRenderPlugin = function CSS3DRenderPlugin(five) {
92
92
  css3DRenderer.domElement.style.top = '0';
93
93
  css3DRenderer.domElement.style.userSelect = 'none';
94
94
  css3DRenderer.domElement.style.pointerEvents = 'none';
95
- var _renderEveryFrame = function renderEveryFrame() {
95
+ var renderEveryFrame = function renderEveryFrame() {
96
96
  if (stopRenderFlag) return;
97
- requestAnimationFrameId = requestAnimationFrame(_renderEveryFrame);
97
+ requestAnimationFrameId = requestAnimationFrame(renderEveryFrame);
98
98
  css3DRenderer.render(scene, five.camera);
99
99
  };
100
100
  return function () {
101
101
  var _resizeObserver, _resizeObserver$obser;
102
102
  scene.add(css3DObject);
103
- (_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 || (_resizeObserver$obser = _resizeObserver.observe) === null || _resizeObserver$obser === void 0 || _resizeObserver$obser.call(_resizeObserver);
104
- _renderEveryFrame();
103
+ (_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 ? void 0 : (_resizeObserver$obser = _resizeObserver.observe) === null || _resizeObserver$obser === void 0 ? void 0 : _resizeObserver$obser.call(_resizeObserver);
104
+ renderEveryFrame();
105
105
  if (mode === 'behind' && mesh) {
106
106
  five.scene.add(mesh);
107
107
  disposers.push(function () {
@@ -138,7 +138,7 @@ export var CSS3DRenderPlugin = function CSS3DRenderPlugin(five) {
138
138
  if (mode === 'behind') state.behindMode = undefined;
139
139
  if (!state.behindMode && !state.frontMode) {
140
140
  var _resizeObserver2, _resizeObserver2$unob;
141
- (_resizeObserver2 = resizeObserver) === null || _resizeObserver2 === void 0 || (_resizeObserver2$unob = _resizeObserver2.unobserve) === null || _resizeObserver2$unob === void 0 || _resizeObserver2$unob.call(_resizeObserver2);
141
+ (_resizeObserver2 = resizeObserver) === null || _resizeObserver2 === void 0 ? void 0 : (_resizeObserver2$unob = _resizeObserver2.unobserve) === null || _resizeObserver2$unob === void 0 ? void 0 : _resizeObserver2$unob.call(_resizeObserver2);
142
142
  }
143
143
  }
144
144
  return true;