@realsee/vreo 2.6.4-alpha.1 → 2.6.4-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/lib/PlayController/createHTMLAudioElement.js +10 -14
  2. package/lib/PlayController/index.js +63 -73
  3. package/lib/Player/App.js +2 -2
  4. package/lib/Player/Controller.d.ts +7 -1
  5. package/lib/Player/Controller.js +112 -75
  6. package/lib/Player/PlaybackLifecycle.d.ts +25 -0
  7. package/lib/Player/PlaybackLifecycle.js +117 -0
  8. package/lib/Player/custom/SpatialScenePanel/index.js +34 -11
  9. package/lib/Player/index.d.ts +7 -2
  10. package/lib/Player/index.js +198 -126
  11. package/lib/Player/modules/Drawer/index.js +1 -2
  12. package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +13 -1
  13. package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +209 -204
  14. package/lib/Player/modules/VideoAgent/VideoAgentScene.d.ts +1 -0
  15. package/lib/Player/modules/VideoAgent/VideoAgentScene.js +6 -2
  16. package/lib/Player/modules/VideoAgent/index.js +10 -2
  17. package/lib/Player/modules/keyframes/BgMusic/index.js +50 -74
  18. package/lib/Player/modules/keyframes/CameraMovement/index.js +43 -45
  19. package/lib/Player/modules/keyframes/InfoPanel/index.js +45 -35
  20. package/lib/Player/modules/keyframes/ModelVideo/index.js +95 -57
  21. package/lib/Player/modules/keyframes/PanoTag/index.js +4 -2
  22. package/lib/Player/modules/keyframes/PanoTextLabel/index.js +3 -3
  23. package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +3 -3
  24. package/lib/Player/modules/keyframes/VideoEffect/index.js +93 -79
  25. package/lib/Player/playback-types.d.ts +21 -0
  26. package/lib/Player/playback-types.js +1 -0
  27. package/lib/Player/typings.d.ts +3 -0
  28. package/lib/fivePlugins/CSS3DRenderPlugin/index.js +6 -6
  29. package/lib/fivePlugins/CameraMovementPlugin/index.js +173 -180
  30. package/lib/fivePlugins/CameraMovementPlugin/typings.js +6 -6
  31. package/lib/fivePlugins/ModelTVVideoPlugin/index.d.ts +3 -0
  32. package/lib/fivePlugins/ModelTVVideoPlugin/index.js +182 -75
  33. package/lib/index.d.ts +1 -0
  34. package/lib/react/index.js +1 -1
  35. package/lib/shared-utils/Audio.js +55 -57
  36. package/lib/shared-utils/AudioLike.js +12 -14
  37. package/lib/shared-utils/animationFrame/BetterTween.js +13 -15
  38. package/lib/shared-utils/animationFrame/tween.js +1 -3
  39. package/lib/shared-utils/getMediaInfo.js +0 -1
  40. package/lib/typings/VreoUnit.js +134 -27
  41. package/package.json +6 -4
  42. package/docs/.nojekyll +0 -1
  43. package/docs/assets/custom.css +0 -78
  44. package/docs/assets/hierarchy.js +0 -1
  45. package/docs/assets/highlight.css +0 -127
  46. package/docs/assets/icons.js +0 -18
  47. package/docs/assets/icons.svg +0 -1
  48. package/docs/assets/main.js +0 -60
  49. package/docs/assets/navigation.js +0 -1
  50. package/docs/assets/search.js +0 -1
  51. package/docs/assets/style.css +0 -1640
  52. package/docs/classes/Player.AudioLike.html +0 -15
  53. package/docs/classes/Player.Controller.html +0 -87
  54. package/docs/classes/Player.Player.html +0 -54
  55. package/docs/classes/Player.VideoAgentMesh.html +0 -72
  56. package/docs/classes/Player.VideoAgentScene.html +0 -9
  57. package/docs/demo/assets/AppReact-CkuqZtcS.js +0 -1
  58. package/docs/demo/assets/default-BQGCQRLt.css +0 -1
  59. package/docs/demo/assets/default-CVvVdmSW.js +0 -5540
  60. package/docs/demo/assets/dynamic-CO5wq52h.js +0 -1
  61. package/docs/demo/assets/examples-BCLzFApO.css +0 -1
  62. package/docs/demo/assets/examples-DfiAz2fR.js +0 -25
  63. package/docs/demo/assets/index-CBBSwaYT.js +0 -1
  64. package/docs/demo/assets/index-CmEXi2sK.css +0 -1
  65. package/docs/demo/assets/main-BF1tvUg-.js +0 -25
  66. package/docs/demo/assets/react-BnzBLum3.css +0 -1
  67. package/docs/demo/assets/react-C4h9qndP.js +0 -25
  68. package/docs/demo/examples.html +0 -16
  69. package/docs/demo/index-react-dynamic.html +0 -18
  70. package/docs/demo/index-react.html +0 -19
  71. package/docs/demo/index.html +0 -19
  72. package/docs/enums/Player.InfoPanelStyleEnum.html +0 -3
  73. package/docs/enums/Player.InfoPanelTypeEnum.html +0 -4
  74. package/docs/enums/Player.PanoEffectEnum.html +0 -4
  75. package/docs/enums/Player.PanoTagEnum.html +0 -4
  76. package/docs/enums/Player.PanoTagStyleEnum.html +0 -6
  77. package/docs/enums/Player.VreoKeyframeEnum.html +0 -25
  78. package/docs/enums/fivePlugins.CameraMovementEffect.html +0 -3
  79. package/docs/enums/fivePlugins.Rotation.html +0 -4
  80. package/docs/functions/custom.SpatialScenePanel.html +0 -2
  81. package/docs/functions/react.useVreoAction.html +0 -8
  82. package/docs/functions/react.useVreoEventCallback.html +0 -10
  83. package/docs/functions/react.useVreoPausedState.html +0 -8
  84. package/docs/hierarchy.html +0 -1
  85. package/docs/index.html +0 -160
  86. package/docs/interfaces/Player.Appearance.html +0 -2
  87. package/docs/interfaces/Player.CustomVreoKeyframeProps.html +0 -3
  88. package/docs/interfaces/Player.PlayerConfigs.html +0 -20
  89. package/docs/interfaces/Player.Vertex.html +0 -5
  90. package/docs/interfaces/Player.VideoAgentMeshOptions.html +0 -9
  91. package/docs/interfaces/Player.VreoKeyframe.html +0 -8
  92. package/docs/interfaces/Player.VreoUnit.html +0 -9
  93. package/docs/interfaces/Player.VreoVideo.html +0 -7
  94. package/docs/interfaces/fivePlugins.CSS3DRenderPluginExportType.html +0 -8
  95. package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +0 -3
  96. package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +0 -5
  97. package/docs/interfaces/fivePlugins.CameraMovementPluginParameterType.html +0 -1
  98. package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +0 -5
  99. package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +0 -4
  100. package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +0 -2
  101. package/docs/interfaces/fivePlugins.Vector3Position.html +0 -5
  102. package/docs/interfaces/react.VreoActionCallbacks.html +0 -18
  103. package/docs/interfaces/react.VreoProviderProps.html +0 -6
  104. package/docs/modules/Player.html +0 -1
  105. package/docs/modules/custom.html +0 -1
  106. package/docs/modules/fivePlugins.html +0 -1
  107. package/docs/modules/react.html +0 -1
  108. package/docs/modules.html +0 -1
  109. package/docs/types/Player.AppSize.html +0 -1
  110. package/docs/types/Player.AudioLikeEvent.html +0 -6
  111. package/docs/types/Player.CameraMovementData.html +0 -2
  112. package/docs/types/Player.CustomData.html +0 -2
  113. package/docs/types/Player.InfoPanelData.html +0 -7
  114. package/docs/types/Player.ModelVideoData.html +0 -9
  115. package/docs/types/Player.PanoEffectData.html +0 -4
  116. package/docs/types/Player.PanoTagData.html +0 -6
  117. package/docs/types/Player.PanoTextLabelData.html +0 -7
  118. package/docs/types/Player.PrompterData.html +0 -3
  119. package/docs/types/Player.QuadrangleVertexs.html +0 -2
  120. package/docs/types/Player.Quaternion.html +0 -6
  121. package/docs/types/Player.UpdateVRPanoramaData.html +0 -7
  122. package/docs/types/Player.Vertexs.html +0 -2
  123. package/docs/types/Player.VideoEffectData.html +0 -7
  124. package/docs/types/Player.VreoKeyframeEvent.html +0 -2
  125. package/docs/types/Player.VreoKeyframeMap.html +0 -6
  126. package/docs/types/Player.VreoSubscribe.html +0 -1
  127. package/docs/types/Player.WaveAppearance.html +0 -1
  128. package/docs/types/fivePlugins.CSS3DRenderPluginParameterType.html +0 -1
  129. package/docs/types/fivePlugins.MoveArgs.html +0 -1
  130. package/docs/types/fivePlugins.MoveOpts.html +0 -1
  131. package/docs/types/fivePlugins.RotateArgs.html +0 -1
  132. package/docs/types/fivePlugins.RotateOpts.html +0 -1
  133. package/docs/variables/fivePlugins.CSS3DRenderPlugin.html +0 -3
  134. package/docs/variables/fivePlugins.CameraMovementPlugin.html +0 -2
  135. package/docs/variables/fivePlugins.ModelTVVideoPlugin.html +0 -1
  136. package/docs/variables/react.VreoProvider.html +0 -9
@@ -1,5 +1,4 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
- import _regeneratorRuntime from "@babel/runtime/regenerator";
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
2
  import * as React from 'react';
4
3
  import { getAudio } from "../../../../shared-utils/Audio.js";
5
4
  import { VreoKeyframeEnum } from "../../../../typings/VreoUnit.js";
@@ -7,83 +6,60 @@ import { useController } from "../../../hooks.js";
7
6
  export function BgMusic() {
8
7
  var controller = useController();
9
8
  React.useEffect(function () {
10
- var callback = /*#__PURE__*/function () {
11
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(keyframe, currentTime) {
12
- var _controller$configs$w, _controller$configs;
13
- var start, end, _currentTime, audio, waitForLoaded, cleanAudio, play, playOnCanPlay;
14
- return _regeneratorRuntime.wrap(function _callee$(_context) {
15
- while (1) {
16
- switch (_context.prev = _context.next) {
17
- case 0:
18
- start = keyframe.start, end = keyframe.end;
19
- _currentTime = (currentTime - start) / 1000;
20
- if (!(_currentTime < 0 || _currentTime >= keyframe.end - keyframe.start)) {
21
- _context.next = 4;
22
- break;
23
- }
24
- return _context.abrupt("return");
25
- case 4:
26
- audio = getAudio(keyframe.data.url);
27
- audio.currentTime = Math.max(0, _currentTime);
28
- waitForLoaded = (_controller$configs$w = (_controller$configs = controller.configs) === null || _controller$configs === void 0 ? void 0 : _controller$configs.waitForBgMusicLoaded) !== null && _controller$configs$w !== void 0 ? _controller$configs$w : false;
29
- cleanAudio = function cleanAudio() {
30
- audio.removeEventListener('canplay', playOnCanPlay);
31
- audio.removeEventListener('pause', play);
32
- audio.pause();
33
- audio.src = '';
34
- };
35
- play = function play() {
36
- if (audio.realSrc === keyframe.data.url) {
37
- // 有可能会被其他音轨打断
38
- audio.play();
39
- }
40
- }; // canplay 事件比 canplaythrough 更早触发,表示可以开始播放了
41
- playOnCanPlay = function playOnCanPlay() {
42
- audio.removeEventListener('canplay', playOnCanPlay);
43
- audio.play();
44
- // 解除等待状态,恢复主时间线播放
45
- controller.setWaitingForBgMusic(false);
46
- };
47
- if (waitForLoaded) {
48
- // 等待音频加载完成后再播放
49
- // readyState: 0=HAVE_NOTHING, 1=HAVE_METADATA, 2=HAVE_CURRENT_DATA, 3=HAVE_FUTURE_DATA, 4=HAVE_ENOUGH_DATA
50
- if (audio.readyState >= 3) {
51
- // readyState >= 3 表示有足够数据开始播放
52
- audio.play();
53
- } else {
54
- // 设置等待状态,阻塞整个播放流程
55
- controller.setWaitingForBgMusic(true);
56
- // 监听 canplay 事件(可以开始播放)
57
- audio.addEventListener('canplay', playOnCanPlay);
58
- }
59
- } else {
60
- // 默认行为:立即播放,边加载边播放
61
- audio.play();
62
- }
63
- audio.addEventListener('ended', function () {
64
- cleanAudio();
65
- });
66
- audio.addEventListener('pause', play);
67
- controller.once('paused', function () {
68
- // 如果播放器暂停,也要解除等待状态
69
- controller.setWaitingForBgMusic(false);
70
- cleanAudio();
71
- });
72
- case 14:
73
- case "end":
74
- return _context.stop();
75
- }
9
+ var tracks = new Set();
10
+ var callback = function callback(keyframe, currentTime) {
11
+ var run = controller.playback.capture();
12
+ var valid = function valid() {
13
+ return !!(run !== null && run !== void 0 && run.valid());
14
+ };
15
+ if (!valid()) return;
16
+ var element = getAudio();
17
+ var audio = run.bind(element);
18
+ var cleaned = false;
19
+ var _clean = function clean() {
20
+ if (cleaned) return;
21
+ cleaned = true;
22
+ element.removeEventListener('canplay', _play);
23
+ element.removeEventListener('ended', _clean);
24
+ audio.muted = true;
25
+ audio.pause();
26
+ audio.src = '';
27
+ remove();
28
+ tracks.delete(_clean);
29
+ controller.setWaitingForBgMusic(false);
30
+ };
31
+ var remove = controller.playback.add(_clean);
32
+ tracks.add(_clean);
33
+ var _play = function play() {
34
+ element.removeEventListener('canplay', _play);
35
+ if (!valid() || cleaned) return;
36
+ audio.muted = false;
37
+ void audio.play().catch(function (error) {
38
+ if (valid() && !cleaned) {
39
+ _clean();
40
+ controller.playback.cancel();
41
+ console.error(error);
76
42
  }
77
- }, _callee);
78
- }));
79
- return function callback(_x, _x2) {
80
- return _ref.apply(this, arguments);
43
+ });
44
+ controller.setWaitingForBgMusic(false);
81
45
  };
82
- }();
46
+ audio.muted = true;
47
+ audio.src = keyframe.data.url;
48
+ audio.currentTime = Math.max(0, (currentTime - keyframe.start) / 1000);
49
+ element.addEventListener('ended', _clean);
50
+ if (controller.configs.waitForBgMusicLoaded && element.readyState < 3) {
51
+ controller.setWaitingForBgMusic(true);
52
+ element.addEventListener('canplay', _play);
53
+ } else _play();
54
+ };
83
55
  controller.on(VreoKeyframeEnum.BgMusic, callback);
84
56
  return function () {
85
57
  controller.off(VreoKeyframeEnum.BgMusic, callback);
58
+ for (var _i = 0, _arr = _toConsumableArray(tracks); _i < _arr.length; _i++) {
59
+ var clean = _arr[_i];
60
+ clean();
61
+ }
86
62
  };
87
- });
63
+ }, [controller]);
88
64
  return /*#__PURE__*/React.createElement(React.Fragment, null);
89
65
  }
@@ -1,5 +1,6 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
3
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
3
4
  import * as React from 'react';
4
5
  import { CameraMovementPlugin } from "../../../../fivePlugins/CameraMovementPlugin/index.js";
5
6
  import { CameraMovementEffect } from "../../../../fivePlugins/CameraMovementPlugin/typings.js";
@@ -11,54 +12,51 @@ export function CameraMovement() {
11
12
  var ref = React.useRef();
12
13
  React.useEffect(function () {
13
14
  var callback = /*#__PURE__*/function () {
14
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(keyframe) {
15
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(keyframe) {
15
16
  var start, end, data, cameraMovementData, effect;
16
- return _regeneratorRuntime.wrap(function _callee$(_context) {
17
- while (1) {
18
- switch (_context.prev = _context.next) {
19
- case 0:
20
- if (!ref.current) {
21
- ref.current = CameraMovementPlugin(five, {});
22
- }
23
- start = keyframe.start, end = keyframe.end, data = keyframe.data;
24
- cameraMovementData = data;
25
- effect = cameraMovementData.effect;
26
- if (!(effect === CameraMovementEffect.Rotate)) {
27
- _context.next = 9;
28
- break;
29
- }
30
- _context.next = 7;
31
- return ref.current.rotate(data, end - start);
32
- case 7:
33
- _context.next = 21;
17
+ return _regenerator().w(function (_context) {
18
+ while (1) switch (_context.n) {
19
+ case 0:
20
+ if (!ref.current) {
21
+ ref.current = CameraMovementPlugin(five, {});
22
+ }
23
+ start = keyframe.start, end = keyframe.end, data = keyframe.data;
24
+ cameraMovementData = data;
25
+ effect = cameraMovementData.effect;
26
+ if (!(effect === CameraMovementEffect.Rotate)) {
27
+ _context.n = 2;
34
28
  break;
35
- case 9:
36
- if (!(effect === CameraMovementEffect.Move)) {
37
- _context.next = 14;
38
- break;
39
- }
40
- _context.next = 12;
41
- return ref.current.move(data, end - start);
42
- case 12:
43
- _context.next = 21;
29
+ }
30
+ _context.n = 1;
31
+ return ref.current.rotate(data, end - start);
32
+ case 1:
33
+ _context.n = 7;
34
+ break;
35
+ case 2:
36
+ if (!(effect === CameraMovementEffect.Move)) {
37
+ _context.n = 4;
44
38
  break;
45
- case 14:
46
- if (!(cameraMovementData.panoIndex !== undefined && cameraMovementData.panoIndex !== five.panoIndex)) {
47
- _context.next = 19;
48
- break;
49
- }
50
- _context.next = 17;
51
- return ref.current.move(data, end - start);
52
- case 17:
53
- _context.next = 21;
39
+ }
40
+ _context.n = 3;
41
+ return ref.current.move(data, end - start);
42
+ case 3:
43
+ _context.n = 7;
44
+ break;
45
+ case 4:
46
+ if (!(cameraMovementData.panoIndex !== undefined && cameraMovementData.panoIndex !== five.panoIndex)) {
47
+ _context.n = 6;
54
48
  break;
55
- case 19:
56
- _context.next = 21;
57
- return ref.current.rotate(data, end - start);
58
- case 21:
59
- case "end":
60
- return _context.stop();
61
- }
49
+ }
50
+ _context.n = 5;
51
+ return ref.current.move(data, end - start);
52
+ case 5:
53
+ _context.n = 7;
54
+ break;
55
+ case 6:
56
+ _context.n = 7;
57
+ return ref.current.rotate(data, end - start);
58
+ case 7:
59
+ return _context.a(2);
62
60
  }
63
61
  }, _callee);
64
62
  }));
@@ -1,21 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { InfoPanelStyleEnum, InfoPanelTypeEnum, VreoKeyframeEnum } from "../../../../typings/VreoUnit.js";
3
3
  import { useController } from "../../../hooks.js";
4
- var isWX = navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1;
5
- var isIOS = navigator.userAgent.toLowerCase().indexOf('iphone') !== -1;
6
- var isIOSorWX = isIOS || isWX;
7
- var _videoElement = document.createElement('video');
8
- _videoElement.setAttribute('playsinline', 'true');
9
- _videoElement.setAttribute('webkit-playsinline', 'true');
10
- if (isIOSorWX) {
11
- if (_videoElement.paused) {
12
- _videoElement.addEventListener('click', function () {
13
- return _videoElement.play();
14
- }, {
15
- once: true
16
- });
17
- }
18
- }
19
4
  function InfoPanelImg(_ref) {
20
5
  var url = _ref.url,
21
6
  children = _ref.children;
@@ -33,32 +18,55 @@ function InfoPanelVideo(_ref2) {
33
18
  var videoWrapperRef = React.useRef(null);
34
19
  var controller = useController();
35
20
  React.useEffect(function () {
36
- var _controller$configs, _controller$configs$v;
21
+ var _controller$configs;
37
22
  // if (!isIOSorWX) return
38
- 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) || _videoElement;
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');
24
+ var run = controller.playback.capture();
25
+ var valid = function valid() {
26
+ return !!(run !== null && run !== void 0 && run.valid());
27
+ };
28
+ if (!(run !== null && run !== void 0 && run.valid())) return;
29
+ var output = run.bind(video);
30
+ var disposed = false;
31
+ video.playsInline = true;
32
+ output.muted = true;
33
+ var stop = function stop() {
34
+ disposed = true;
35
+ output.muted = true;
36
+ output.pause();
37
+ video.removeEventListener('canplaythrough', _canplaythrough);
38
+ };
39
39
  if (!videoWrapperRef.current) return;
40
- video.src = url;
40
+ var remove = controller.playback.add(stop);
41
+ output.src = url;
41
42
  if (!videoWrapperRef.current.contains(video)) {
42
43
  videoWrapperRef.current.appendChild(video);
43
44
  }
44
- var canplaythrough = function canplaythrough() {
45
- video.removeEventListener('canplaythrough', canplaythrough);
46
- try {
47
- video.play();
48
- } catch (error) {}
45
+ var _canplaythrough = function canplaythrough() {
46
+ video.removeEventListener('canplaythrough', _canplaythrough);
47
+ if (disposed || !valid()) return;
48
+ output.muted = false;
49
+ void output.play().catch(function (error) {
50
+ if (valid() && !disposed) {
51
+ stop();
52
+ controller.playback.cancel();
53
+ console.error(error);
54
+ }
55
+ });
49
56
  };
50
- video.addEventListener('canplaythrough', canplaythrough);
51
- video.load();
52
- // video.play()
57
+ video.addEventListener('canplaythrough', _canplaythrough);
58
+ output.load();
59
+ // output.play()
53
60
 
54
61
  return function () {
55
62
  var _videoWrapperRef$curr;
56
- video.pause();
63
+ stop();
64
+ remove();
57
65
  if ((_videoWrapperRef$curr = videoWrapperRef.current) !== null && _videoWrapperRef$curr !== void 0 && _videoWrapperRef$curr.contains(video)) {
58
66
  videoWrapperRef.current.removeChild(video);
59
67
  }
60
68
  };
61
- }, [videoWrapperRef.current]);
69
+ }, [controller, url]);
62
70
  return /*#__PURE__*/React.createElement("div", {
63
71
  className: "vreo-infoPanel-container"
64
72
  }, /*#__PURE__*/React.createElement("div", {
@@ -99,14 +107,14 @@ export function InfoPanel() {
99
107
  do {
100
108
  if (style === InfoPanelStyleEnum.PopUp) {
101
109
  if (infoPanelData.type === InfoPanelTypeEnum.Image) {
102
- controller.openPopUp( /*#__PURE__*/React.createElement(InfoPanelImg, {
110
+ controller.openPopUp(/*#__PURE__*/React.createElement(InfoPanelImg, {
103
111
  url: infoPanelData.url
104
112
  }, /*#__PURE__*/React.createElement(Title, {
105
113
  title: title,
106
114
  subTitle: subTitle
107
115
  })));
108
116
  } else if (infoPanelData.type === InfoPanelTypeEnum.Video) {
109
- controller.openPopUp( /*#__PURE__*/React.createElement(InfoPanelVideo, {
117
+ controller.openPopUp(/*#__PURE__*/React.createElement(InfoPanelVideo, {
110
118
  url: infoPanelData.url
111
119
  }, /*#__PURE__*/React.createElement(Title, {
112
120
  title: title,
@@ -143,13 +151,15 @@ export function InfoPanel() {
143
151
  }, end - start);
144
152
  };
145
153
  controller.on(VreoKeyframeEnum.InfoPanel, callback);
146
- controller.on('ended', function () {
147
- controller.openPopUp(false);
148
- });
149
- controller.on('paused', function () {
154
+ var close = function close() {
155
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
156
+ controller.openDrawer(false);
150
157
  controller.openPopUp(false);
151
- });
158
+ };
159
+ var remove = controller.playback.add(close);
152
160
  return function () {
161
+ remove();
162
+ close();
153
163
  controller.off(VreoKeyframeEnum.InfoPanel, callback);
154
164
  if (timeoutRef.current) {
155
165
  clearTimeout(timeoutRef.current);
@@ -1,5 +1,6 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
3
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
3
4
  import * as React from 'react';
4
5
  import * as THREE from 'three';
5
6
  import { useController, useFiveInstance } from "../../../hooks.js";
@@ -12,65 +13,97 @@ export function ModelVideo() {
12
13
  var ref = React.useRef();
13
14
  var timeoutRef = React.useRef();
14
15
  React.useEffect(function () {
16
+ var generation = 0;
17
+ var stop = function stop() {
18
+ var _ref$current;
19
+ ++generation;
20
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
21
+ (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.dispose();
22
+ ref.current = undefined;
23
+ };
24
+ var remove = controller.playback.add(stop);
15
25
  var callback = /*#__PURE__*/function () {
16
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(keyframe) {
17
- var _controller$configs, _controller$configs$v;
18
- var start, end, _ref2, videoSrc, videoPosterSrc, vertexs, matrixWorld, position, points;
19
- return _regeneratorRuntime.wrap(function _callee$(_context) {
20
- while (1) {
21
- switch (_context.prev = _context.next) {
22
- case 0:
23
- if (!ref.current) {
24
- ref.current = ModelTVVideoPlugin(five, {});
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;
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
+ })];
25
72
  }
26
- start = keyframe.start, end = keyframe.end;
27
- _ref2 = keyframe.data, videoSrc = _ref2.videoSrc, videoPosterSrc = _ref2.videoPosterSrc, vertexs = _ref2.vertexs, matrixWorld = _ref2.matrixWorld;
28
- position = function () {
29
- if (vertexs.length < 4) {
30
- throw new Error('ModelVideo: 顶点数据集合不够,无法组成矩形 ....');
31
- }
32
- if (vertexs.length === 4) {
33
- return vertexs;
34
- }
35
- var box = new THREE.Box3();
36
- vertexs.forEach(function (v) {
37
- return box.expandByPoint(new THREE.Vector3(v.x, v.y, v.z));
38
- });
39
- 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)];
40
- }();
41
- points = function () {
42
- if (matrixWorld) {
43
- var transMatrix = createTransMatrix(matrixWorld);
44
- return [position.map(function (p) {
45
- var res = transMatrix([p.x, p.y, p.z]);
46
- return {
47
- x: res[0],
48
- y: res[1],
49
- z: res[2]
50
- };
51
- })];
52
- }
53
- return [position];
54
- }();
55
- ref.current.disable();
56
- _context.next = 8;
57
- return ref.current.load({
58
- video_src: videoSrc,
59
- video_poster_src: videoPosterSrc,
60
- points: points
61
- }, (_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);
62
- case 8:
63
- ref.current.enable();
64
- timeoutRef.current = setTimeout(function () {
65
- var _ref$current;
66
- return (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.disable();
67
- }, end - start);
68
- case 10:
69
- case "end":
70
- return _context.stop();
71
- }
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;
97
+ 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);
72
105
  }
73
- }, _callee);
106
+ }, _callee, null, [[2, 4]]);
74
107
  }));
75
108
  return function callback(_x) {
76
109
  return _ref.apply(this, arguments);
@@ -78,6 +111,11 @@ export function ModelVideo() {
78
111
  }();
79
112
  controller.on(VreoKeyframeEnum.ModelVideo, callback);
80
113
  return function () {
114
+ var _ref$current2;
115
+ stop();
116
+ remove();
117
+ (_ref$current2 = ref.current) === null || _ref$current2 === void 0 || _ref$current2.dispose();
118
+ ref.current = undefined;
81
119
  controller.off(VreoKeyframeEnum.ModelVideo, callback);
82
120
  if (timeoutRef.current) {
83
121
  clearTimeout(timeoutRef.current);
@@ -27,7 +27,8 @@ export function PanoTag() {
27
27
  return;
28
28
  }
29
29
  var callback = function callback(keyframe) {
30
- if (!panoTagPlugin.current) return;
30
+ var run = controller.playback.capture();
31
+ if (!panoTagPlugin.current || !(run !== null && run !== void 0 && run.valid())) return;
31
32
  var start = keyframe.start,
32
33
  end = keyframe.end,
33
34
  data = keyframe.data;
@@ -74,6 +75,7 @@ export function PanoTag() {
74
75
  });
75
76
  var tagInstance = panoTagPlugin.current.getTagById(id);
76
77
  if (tagInstance) {
78
+ tagInstance.setMediaManager(run.mediaManager);
77
79
  tagInstance.state.unfolded = true;
78
80
  panoTagPlugin.current.updateRenderAllTags();
79
81
  }
@@ -86,7 +88,7 @@ export function PanoTag() {
86
88
  tag.state.unfolded = false;
87
89
  panoTagPlugin.current.updateRenderAllTags();
88
90
  }
89
- (_tag$hooks = tag.hooks) === null || _tag$hooks === void 0 ? void 0 : _tag$hooks.on('folded', function () {
91
+ (_tag$hooks = tag.hooks) === null || _tag$hooks === void 0 || _tag$hooks.on('folded', function () {
90
92
  setTimeout(function () {
91
93
  if (tag.state) {
92
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 ? void 0 : css3DObject.quaternion.copy(quaternion);
93
+ css3DObject === null || css3DObject === 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 ? void 0 : _ref$current.disposeAll();
110
+ (_ref$current = ref.current) === null || _ref$current === 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$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) {
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) {
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 ? 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];
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];
54
54
  if (!lastRawWork) {
55
55
  console.warn('UpdateVRPanorama: 没有可用的 work 数据');
56
56
  return;