@realsee/vreo 2.6.4-alpha.5 → 3.0.0-webgpu-react18.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +6 -6
  3. package/lib/PlayController/createHTMLAudioElement.d.ts +1 -0
  4. package/lib/PlayController/createHTMLAudioElement.d.ts.map +1 -0
  5. package/lib/PlayController/index.d.ts +14 -24
  6. package/lib/PlayController/index.d.ts.map +1 -0
  7. package/lib/PlayController/index.js +74 -210
  8. package/lib/PlayController/index.js.map +1 -0
  9. package/lib/Player/App.d.ts +2 -2
  10. package/lib/Player/App.d.ts.map +1 -0
  11. package/lib/Player/Controller.d.ts +11 -6
  12. package/lib/Player/Controller.d.ts.map +1 -0
  13. package/lib/Player/PlaybackLifecycle.d.ts +1 -0
  14. package/lib/Player/PlaybackLifecycle.d.ts.map +1 -0
  15. package/lib/Player/custom/SpatialScenePanel/index.d.ts +2 -2
  16. package/lib/Player/custom/SpatialScenePanel/index.d.ts.map +1 -0
  17. package/lib/Player/hooks.d.ts +3 -2
  18. package/lib/Player/hooks.d.ts.map +1 -0
  19. package/lib/Player/index.d.ts +3 -2
  20. package/lib/Player/index.d.ts.map +1 -0
  21. package/lib/Player/index.js +1769 -430
  22. package/lib/Player/index.js.map +1 -0
  23. package/lib/Player/modules/Drawer/index.d.ts +2 -2
  24. package/lib/Player/modules/Drawer/index.d.ts.map +1 -0
  25. package/lib/Player/modules/PopUp/index.d.ts +2 -2
  26. package/lib/Player/modules/PopUp/index.d.ts.map +1 -0
  27. package/lib/Player/modules/ResizeObserver/index.d.ts +2 -2
  28. package/lib/Player/modules/ResizeObserver/index.d.ts.map +1 -0
  29. package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +5 -2
  30. package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts.map +1 -0
  31. package/lib/Player/modules/VideoAgent/VideoAgentScene.d.ts +8 -5
  32. package/lib/Player/modules/VideoAgent/VideoAgentScene.d.ts.map +1 -0
  33. package/lib/Player/modules/VideoAgent/index.d.ts +11 -2
  34. package/lib/Player/modules/VideoAgent/index.d.ts.map +1 -0
  35. package/lib/Player/modules/Wave/index.d.ts +2 -2
  36. package/lib/Player/modules/Wave/index.d.ts.map +1 -0
  37. package/lib/Player/modules/keyframes/BgMusic/index.d.ts +2 -2
  38. package/lib/Player/modules/keyframes/BgMusic/index.d.ts.map +1 -0
  39. package/lib/Player/modules/keyframes/CameraMovement/index.d.ts +2 -2
  40. package/lib/Player/modules/keyframes/CameraMovement/index.d.ts.map +1 -0
  41. package/lib/Player/modules/keyframes/InfoPanel/index.d.ts +2 -2
  42. package/lib/Player/modules/keyframes/InfoPanel/index.d.ts.map +1 -0
  43. package/lib/Player/modules/keyframes/ModelVideo/index.d.ts +2 -2
  44. package/lib/Player/modules/keyframes/ModelVideo/index.d.ts.map +1 -0
  45. package/lib/Player/modules/keyframes/PanoEffect/index.d.ts +2 -2
  46. package/lib/Player/modules/keyframes/PanoEffect/index.d.ts.map +1 -0
  47. package/lib/Player/modules/keyframes/PanoEffect/lineAnime.d.ts +3 -2
  48. package/lib/Player/modules/keyframes/PanoEffect/lineAnime.d.ts.map +1 -0
  49. package/lib/Player/modules/keyframes/PanoTag/index.d.ts +1 -0
  50. package/lib/Player/modules/keyframes/PanoTag/index.d.ts.map +1 -0
  51. package/lib/Player/modules/keyframes/PanoTextLabel/index.d.ts +2 -2
  52. package/lib/Player/modules/keyframes/PanoTextLabel/index.d.ts.map +1 -0
  53. package/lib/Player/modules/keyframes/Prompter/index.d.ts +2 -2
  54. package/lib/Player/modules/keyframes/Prompter/index.d.ts.map +1 -0
  55. package/lib/Player/modules/keyframes/UpdateVRPanorama/index.d.ts +2 -2
  56. package/lib/Player/modules/keyframes/UpdateVRPanorama/index.d.ts.map +1 -0
  57. package/lib/Player/modules/keyframes/VideoEffect/index.d.ts +2 -2
  58. package/lib/Player/modules/keyframes/VideoEffect/index.d.ts.map +1 -0
  59. package/lib/Player/playback-types.d.ts +1 -0
  60. package/lib/Player/playback-types.d.ts.map +1 -0
  61. package/lib/Player/typings.d.ts +2 -1
  62. package/lib/Player/typings.d.ts.map +1 -0
  63. package/lib/chunks/index-BgPSzRSs.js +93 -0
  64. package/lib/chunks/index-BgPSzRSs.js.map +1 -0
  65. package/lib/chunks/index-CunyJn6H.js +51 -0
  66. package/lib/chunks/index-CunyJn6H.js.map +1 -0
  67. package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.d.ts +2 -1
  68. package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.d.ts.map +1 -0
  69. package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.d.ts +5 -6
  70. package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.d.ts.map +1 -0
  71. package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.d.ts +1 -0
  72. package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.d.ts.map +1 -0
  73. package/lib/fivePlugins/CSS3DRenderPlugin/index.d.ts +5 -22
  74. package/lib/fivePlugins/CSS3DRenderPlugin/index.d.ts.map +1 -0
  75. package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.d.ts +2 -1
  76. package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.d.ts.map +1 -0
  77. package/lib/fivePlugins/CameraMovementPlugin/index.d.ts +2 -1
  78. package/lib/fivePlugins/CameraMovementPlugin/index.d.ts.map +1 -0
  79. package/lib/fivePlugins/CameraMovementPlugin/typings.d.ts +2 -1
  80. package/lib/fivePlugins/CameraMovementPlugin/typings.d.ts.map +1 -0
  81. package/lib/fivePlugins/ModelTVVideoPlugin/index.d.ts +2 -1
  82. package/lib/fivePlugins/ModelTVVideoPlugin/index.d.ts.map +1 -0
  83. package/lib/index.d.ts +3 -0
  84. package/lib/index.d.ts.map +1 -0
  85. package/lib/index.js +12 -1
  86. package/lib/index.js.map +1 -0
  87. package/lib/plugins/CSS3DRenderPlugin.js +115 -0
  88. package/lib/plugins/CSS3DRenderPlugin.js.map +1 -0
  89. package/lib/plugins/CameraMovementPlugin.js +6 -0
  90. package/lib/plugins/CameraMovementPlugin.js.map +1 -0
  91. package/lib/plugins/ModelTVVideoPlugin.js +162 -0
  92. package/lib/plugins/ModelTVVideoPlugin.js.map +1 -0
  93. package/lib/react/index.d.ts +5 -4
  94. package/lib/react/index.d.ts.map +1 -0
  95. package/lib/react/index.js +39 -226
  96. package/lib/react/index.js.map +1 -0
  97. package/lib/shared-utils/Audio.d.ts +3 -1
  98. package/lib/shared-utils/Audio.d.ts.map +1 -0
  99. package/lib/shared-utils/AudioLike.d.ts +2 -1
  100. package/lib/shared-utils/AudioLike.d.ts.map +1 -0
  101. package/lib/shared-utils/Preloader.d.ts +1 -0
  102. package/lib/shared-utils/Preloader.d.ts.map +1 -0
  103. package/lib/shared-utils/addResizeListener.d.ts +2 -1
  104. package/lib/shared-utils/addResizeListener.d.ts.map +1 -0
  105. package/lib/shared-utils/animationFrame/BetterTween.d.ts +1 -0
  106. package/lib/shared-utils/animationFrame/BetterTween.d.ts.map +1 -0
  107. package/lib/shared-utils/animationFrame/index.d.ts +5 -14
  108. package/lib/shared-utils/animationFrame/index.d.ts.map +1 -0
  109. package/lib/shared-utils/animationFrame/tween.d.ts +1 -0
  110. package/lib/shared-utils/animationFrame/tween.d.ts.map +1 -0
  111. package/lib/shared-utils/createTransMatrix.d.ts +3 -1
  112. package/lib/shared-utils/createTransMatrix.d.ts.map +1 -0
  113. package/lib/shared-utils/getFileExpandedName.d.ts +1 -0
  114. package/lib/shared-utils/getFileExpandedName.d.ts.map +1 -0
  115. package/lib/shared-utils/getMediaInfo.d.ts +1 -0
  116. package/lib/shared-utils/getMediaInfo.d.ts.map +1 -0
  117. package/lib/shared-utils/setElementDataset.d.ts +1 -0
  118. package/lib/shared-utils/setElementDataset.d.ts.map +1 -0
  119. package/lib/timeline/index.d.ts +18 -0
  120. package/lib/timeline/index.d.ts.map +1 -0
  121. package/lib/types/index.js +10 -0
  122. package/lib/types/index.js.map +1 -0
  123. package/lib/typings/VreoUnit.d.ts +2 -1
  124. package/lib/typings/VreoUnit.d.ts.map +1 -0
  125. package/lib/typings/index.d.ts +1 -0
  126. package/lib/typings/index.d.ts.map +1 -0
  127. package/package.json +51 -71
  128. package/lib/PlayController/createHTMLAudioElement.js +0 -30
  129. package/lib/Player/App.js +0 -52
  130. package/lib/Player/Controller.js +0 -530
  131. package/lib/Player/PlaybackLifecycle.js +0 -117
  132. package/lib/Player/custom/SpatialScenePanel/index.js +0 -263
  133. package/lib/Player/hooks.js +0 -22
  134. package/lib/Player/modules/Drawer/index.js +0 -39
  135. package/lib/Player/modules/PopUp/index.js +0 -23
  136. package/lib/Player/modules/ResizeObserver/index.js +0 -22
  137. package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +0 -445
  138. package/lib/Player/modules/VideoAgent/VideoAgentScene.js +0 -53
  139. package/lib/Player/modules/VideoAgent/index.js +0 -72
  140. package/lib/Player/modules/Wave/index.js +0 -171
  141. package/lib/Player/modules/keyframes/BgMusic/index.js +0 -65
  142. package/lib/Player/modules/keyframes/CameraMovement/index.js +0 -73
  143. package/lib/Player/modules/keyframes/InfoPanel/index.js +0 -170
  144. package/lib/Player/modules/keyframes/ModelVideo/index.js +0 -126
  145. package/lib/Player/modules/keyframes/PanoEffect/index.js +0 -99
  146. package/lib/Player/modules/keyframes/PanoEffect/lineAnime.js +0 -30
  147. package/lib/Player/modules/keyframes/PanoTag/index.js +0 -110
  148. package/lib/Player/modules/keyframes/PanoTextLabel/index.js +0 -122
  149. package/lib/Player/modules/keyframes/Prompter/index.js +0 -56
  150. package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +0 -98
  151. package/lib/Player/modules/keyframes/VideoEffect/index.js +0 -152
  152. package/lib/Player/playback-types.js +0 -1
  153. package/lib/Player/typings.js +0 -1
  154. package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.js +0 -4
  155. package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.js +0 -25
  156. package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.js +0 -4
  157. package/lib/fivePlugins/CSS3DRenderPlugin/index.js +0 -226
  158. package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.js +0 -8
  159. package/lib/fivePlugins/CameraMovementPlugin/index.js +0 -238
  160. package/lib/fivePlugins/CameraMovementPlugin/typings.js +0 -15
  161. package/lib/fivePlugins/ModelTVVideoPlugin/index.js +0 -347
  162. package/lib/shared-utils/Audio.js +0 -147
  163. package/lib/shared-utils/AudioLike.js +0 -120
  164. package/lib/shared-utils/Preloader.js +0 -37
  165. package/lib/shared-utils/addResizeListener.js +0 -39
  166. package/lib/shared-utils/animationFrame/BetterTween.js +0 -56
  167. package/lib/shared-utils/animationFrame/index.js +0 -52
  168. package/lib/shared-utils/animationFrame/tween.js +0 -56
  169. package/lib/shared-utils/createTransMatrix.js +0 -12
  170. package/lib/shared-utils/getFileExpandedName.js +0 -6
  171. package/lib/shared-utils/getMediaInfo.js +0 -54
  172. package/lib/shared-utils/setElementDataset.js +0 -16
  173. package/lib/typings/VreoUnit.js +0 -171
  174. package/lib/typings/index.js +0 -1
@@ -1,142 +1,1666 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/esm/createClass";
4
- import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
5
- import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
6
- import _inherits from "@babel/runtime/helpers/esm/inherits";
7
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
8
- var _location$search$matc, _location$search$matc2;
9
- 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 }; })(); }
10
- 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); }
11
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
12
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
13
- // 下面这一行不能删
14
- import * as React from 'react';
15
- import { createRoot } from 'react-dom/client';
16
- import { Subscribe } from '@realsee/five';
17
- import { App } from "./App.js";
18
- import { Controller, ControllerContext } from "./Controller.js";
19
- import { VreoKeyframeEnum } from "../typings/VreoUnit.js";
20
- import { reaction } from 'mobx';
21
- import { Drawer } from "./modules/Drawer/index.js";
22
- import { PopUp } from "./modules/PopUp/index.js";
23
- import { generateBlankAudio, waitForBlankAudioGenerated } from "../shared-utils/Audio.js";
24
- var DefaultAudioCacheLength = 3;
25
- var id = "vreo-app-dhjskadhksahdjskahdjksa";
26
- 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);
27
-
28
- /**
29
- * Vreo 播放器核心类
30
- *
31
- * 提供 VR 视频播放、剧本执行、相机运镜等功能的主要接口。
32
- * 基于 Five 渲染引擎和 React 构建的 3D 空间剧本播放器。
33
- *
34
- * @example
35
- * ```typescript
36
- * import { Five } from '@realsee/five'
37
- * import { Player } from '@realsee/vreo'
38
- *
39
- * const five = new Five({
40
- * // Five 配置选项
41
- * })
42
- * const player = new Player(five, {
43
- * autoPreload: true,
44
- * imageOptions: { size: 1024 }
45
- * })
46
- *
47
- * await player.load(vreoUnit)
48
- * player.play()
49
- * ```
50
- */
51
- export var Player = /*#__PURE__*/function (_Subscribe) {
1
+ var Se = Object.defineProperty;
2
+ var Te = (t, i, e) => i in t ? Se(t, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[i] = e;
3
+ var u = (t, i, e) => Te(t, typeof i != "symbol" ? i + "" : i, e);
4
+ import { jsx as d, Fragment as C, jsxs as L } from "react/jsx-runtime";
5
+ import { createRoot as oe } from "react-dom/client";
6
+ import { Subscribe as ce, parseWork as J } from "@realsee/five-webgpu";
7
+ import D from "classnames";
8
+ import { observer as ne } from "mobx-react-lite";
9
+ import * as A from "react";
10
+ import X, { useRef as Le, useState as de, useEffect as Ie, useCallback as ue } from "react";
11
+ import { makeObservable as be, action as R, observable as N, observableRef as Q, reaction as j, runInAction as Z } from "mobx";
12
+ import { T as Ce, r as le } from "../chunks/index-CunyJn6H.js";
13
+ import { C as Re, a as Ve } from "../chunks/index-BgPSzRSs.js";
14
+ import { VreoKeyframeEnum as P, InfoPanelStyleEnum as Ne, InfoPanelTypeEnum as ee } from "../types/index.js";
15
+ import * as M from "three/webgpu";
16
+ import { Vector3 as q, Quaternion as qe, Scene as ze, OrthographicCamera as Be, WebGPURenderer as Ue, Raycaster as Oe } from "three/webgpu";
17
+ import { ModelTVVideoPlugin as $e } from "../plugins/ModelTVVideoPlugin.js";
18
+ import { Line2 as We } from "three/addons/lines/webgpu/Line2.js";
19
+ import { LineGeometry as Fe } from "three/addons/lines/LineGeometry.js";
20
+ import * as se from "@tweenjs/tween.js";
21
+ import { PanoTagPlugin as De } from "@realsee/dnalogel/plugins/pano-tag";
22
+ import { CSS3DRenderPlugin as we } from "../plugins/CSS3DRenderPlugin.js";
23
+ import { uniform as je, texture as Ge, uv as He, float as Ke, smoothstep as Je, max as Qe } from "three/tsl";
24
+ class Ye {
25
+ constructor(i, e) {
26
+ u(this, "controller");
27
+ u(this, "run");
28
+ u(this, "generation", 0);
29
+ u(this, "disposed", !1);
30
+ u(this, "members", /* @__PURE__ */ new Set());
31
+ this.onStop = e, this.controller = i == null ? void 0 : i.createController({ label: "vreo", onCancel: () => this.stop() });
32
+ }
33
+ get active() {
34
+ var i;
35
+ return !!((i = this.run) != null && i.valid());
36
+ }
37
+ capture() {
38
+ return this.run;
39
+ }
40
+ begin(i) {
41
+ var s;
42
+ if (this.disposed) return !1;
43
+ if (this.active) return !0;
44
+ const e = ((s = this.controller) == null ? void 0 : s.begin({ userAction: i, audible: !0 })) ?? void 0;
45
+ if (this.controller && !e) return !1;
46
+ const n = ++this.generation, r = e == null ? void 0 : e.mediaManager;
47
+ return this.run = {
48
+ session: e,
49
+ mediaManager: r,
50
+ valid: () => n === this.generation && !this.disposed && !(e != null && e.signal.aborted),
51
+ bind: (a) => e ? e.bind(a) : a
52
+ }, !0;
53
+ }
54
+ add(i) {
55
+ return this.members.add(i), () => {
56
+ this.members.delete(i);
57
+ };
58
+ }
59
+ stop() {
60
+ ++this.generation, this.run = void 0;
61
+ const i = [];
62
+ try {
63
+ this.onStop();
64
+ } catch (e) {
65
+ i.push(e);
66
+ }
67
+ for (const e of [...this.members])
68
+ try {
69
+ e();
70
+ } catch (n) {
71
+ i.push(n);
72
+ }
73
+ if (i.length) throw i[0];
74
+ }
75
+ cancel() {
76
+ var e;
77
+ const i = this.generation;
78
+ (e = this.controller) == null || e.cancel(), i === this.generation && this.stop();
79
+ }
80
+ finish() {
81
+ var e;
82
+ const i = (e = this.run) == null ? void 0 : e.session;
83
+ this.stop(), i == null || i.finish();
84
+ }
85
+ dispose() {
86
+ var e;
87
+ if (this.disposed) return;
88
+ this.disposed = !0;
89
+ const i = this.generation;
90
+ (e = this.controller) == null || e.dispose(), i === this.generation && this.stop(), this.members.clear();
91
+ }
92
+ }
93
+ function ie(t, i) {
94
+ t && Object.keys(i).forEach((e) => {
95
+ const n = i[e].toString();
96
+ t instanceof Element ? t.setAttribute(`data-${e}`, n) : t instanceof Document ? t.documentElement.setAttribute(`data-${e}`, n) : t instanceof HTMLElement ? t.dataset[e] = n : t.setAttribute(`data-${e}`, n);
97
+ });
98
+ }
99
+ function Ze(t) {
100
+ if (!t) return "";
101
+ const i = t.lastIndexOf(".");
102
+ return t.substring(i + 1).toLowerCase();
103
+ }
104
+ function Y(t) {
105
+ const i = Ze(t);
106
+ return _e(i);
107
+ }
108
+ function _e(t) {
109
+ return t ? /jpg|jpeg|png$/.test(t) ? "image" : /mp3|wav$/.test(t) ? "audio" : /avi|wmv|mpeg|mp4|m4v|mov|asf|flv|f4v|rmvb|rm|3gp|vob$/.test(t) ? "video" : "unknown" : "unknown";
110
+ }
111
+ class Xe extends ce {
112
+ constructor({ five: e, container: n, configs: r }) {
113
+ super();
114
+ u(this, "five");
115
+ u(this, "configs");
116
+ u(this, "videoAgentScene");
117
+ u(this, "vreoUnit");
118
+ u(this, "stopInterval");
119
+ u(this, "playing", !1);
120
+ u(this, "ended", !1);
121
+ u(this, "loading", !1);
122
+ // null 表示加载失败
123
+ u(this, "containerSize", { width: 0, height: 0 });
124
+ u(this, "appSize");
125
+ u(this, "container");
126
+ u(this, "waveAppearance", null);
127
+ u(this, "appearance", {
128
+ waveStyle: "wave"
129
+ });
130
+ u(this, "avatar", {});
131
+ /**
132
+ * 是否正在等待背景音乐加载
133
+ * 当此状态为 true 时,播放流程会暂停,等待音频加载完成
134
+ */
135
+ u(this, "waitingForBgMusic", !1);
136
+ u(this, "visible", !1);
137
+ u(this, "popUp", null);
138
+ u(this, "drawerConfig", null);
139
+ /**
140
+ * 创建 Controller 实例
141
+ * @param params - 构造参数对象
142
+ * @param params.five - Five 渲染引擎实例
143
+ * @param params.container - DOM 容器元素
144
+ * @param params.configs - 播放器配置
145
+ */
146
+ u(this, "resumeGeneration", 0);
147
+ u(this, "resuming");
148
+ u(this, "disposers", []);
149
+ u(this, "playback");
150
+ u(this, "timeline", new Ce());
151
+ this.playback = new Ye(r.mediaManager, () => {
152
+ var s;
153
+ this.resuming = void 0, ++this.resumeGeneration, this.setPlaying(!1), (s = this.videoAgentScene) == null || s.videoAgentMesh.stop(), this.setWaitingForBgMusic(!1);
154
+ }), this.configs = r, this.container = n, this.five = e, this.appSize = r.appSize, this.appearance = { ...this.appearance, ...r.appearance }, be(this, {
155
+ visible: N,
156
+ setVisible: R,
157
+ playing: N,
158
+ setPlaying: R,
159
+ loading: N,
160
+ videoAgentScene: Q,
161
+ setLoading: R,
162
+ popUp: Q,
163
+ openPopUp: R,
164
+ drawerConfig: Q,
165
+ openDrawer: R,
166
+ ended: N,
167
+ waveAppearance: N,
168
+ avatar: N,
169
+ containerSize: N,
170
+ setContainerSize: R,
171
+ appearance: N,
172
+ setAppearance: R,
173
+ configs: Q,
174
+ setEnded: R,
175
+ setAvatar: R,
176
+ waitingForBgMusic: N,
177
+ setWaitingForBgMusic: R
178
+ }), this.disposers.push(j(
179
+ () => [this.appearance.waveStyle, this.loading],
180
+ ([s, a]) => {
181
+ if (a === null) {
182
+ this.waveAppearance = null;
183
+ return;
184
+ }
185
+ if (s === "wave")
186
+ switch (a) {
187
+ case !0:
188
+ this.waveAppearance = "double";
189
+ break;
190
+ case !1:
191
+ this.waveAppearance = "solid";
192
+ break;
193
+ }
194
+ else if (s === "solid")
195
+ switch (a) {
196
+ case !0:
197
+ this.waveAppearance = "swap";
198
+ break;
199
+ case !1:
200
+ this.waveAppearance = "expand";
201
+ break;
202
+ }
203
+ },
204
+ { fireImmediately: !0 }
205
+ )), this.appSize ? ie(this.container, { size: this.appSize }) : this.disposers.push(j(
206
+ () => this.containerSize,
207
+ (s) => {
208
+ if (!(s != null && s.width)) return;
209
+ const a = s.width, o = s.height, l = a <= 500 ? "S" : a <= 1024 ? "M" : a <= 2048 ? "L" : "XL", c = o > a ? "portrait" : "landscape";
210
+ ie(this.container, { size: l }), ie(this.container, { orientation: c });
211
+ },
212
+ { fireImmediately: !0 }
213
+ )), this.disposers.push(j(
214
+ () => this.ended,
215
+ (s) => {
216
+ s && this.emit("paused", !0);
217
+ }
218
+ )), this.disposers.push(j(
219
+ () => this.playing,
220
+ (s) => {
221
+ this.ended || this.emit(s ? "playing" : "paused");
222
+ }
223
+ ));
224
+ }
225
+ /**
226
+ * 获取当前播放媒体的类型
227
+ * @returns 'video' | 'avatar' | 'none' - 媒体类型
228
+ */
229
+ get agentType() {
230
+ var n, r;
231
+ const e = Y((n = this.videoAgentScene) == null ? void 0 : n.videoAgentMesh.videoUrl);
232
+ return (r = this.avatar) != null && r.force ? "avatar" : e === "video" ? "video" : "none";
233
+ }
234
+ /**
235
+ * 打开或关闭弹窗
236
+ * @param popUp - 弹窗内容,可以是字符串、JSX元素或false(关闭弹窗)
237
+ */
238
+ openPopUp(e) {
239
+ if (!e) {
240
+ this.popUp = null;
241
+ return;
242
+ }
243
+ this.popUp = e;
244
+ }
245
+ /**
246
+ * 设置加载状态
247
+ * @param loading - 加载状态:true(加载中)、false(加载完成)、null(加载失败)
248
+ */
249
+ setLoading(e) {
250
+ this.loading = e;
251
+ }
252
+ /**
253
+ * 设置虚拟形象配置
254
+ * @param avatar - 虚拟形象配置对象
255
+ */
256
+ setAvatar(e) {
257
+ this.avatar = e;
258
+ }
259
+ /**
260
+ * 设置容器尺寸
261
+ * @param width - 容器宽度
262
+ * @param height - 容器高度
263
+ */
264
+ setContainerSize(e, n) {
265
+ this.containerSize = { width: e, height: n };
266
+ }
267
+ /**
268
+ * 设置播放器可见性
269
+ * @param v - 是否可见
270
+ */
271
+ setVisible(e) {
272
+ this.visible = e;
273
+ }
274
+ /**
275
+ * 设置播放状态
276
+ * @param playing - 是否正在播放
277
+ */
278
+ setPlaying(e) {
279
+ e && !this.playback.active || (this.playing = e, e && this.resumeMedia());
280
+ }
281
+ /**
282
+ * 设置结束状态
283
+ * @param ended - 是否已结束
284
+ */
285
+ setEnded(e) {
286
+ this.ended = e;
287
+ }
288
+ /**
289
+ * 设置是否正在等待背景音乐加载
290
+ * @param waiting - 是否正在等待
291
+ */
292
+ setWaitingForBgMusic(e) {
293
+ this.waitingForBgMusic = e;
294
+ }
295
+ /**
296
+ * 设置播放器外观
297
+ * @param appearance - 外观配置对象
298
+ */
299
+ setAppearance(e) {
300
+ this.appearance = { ...this.appearance, ...e };
301
+ }
302
+ /**
303
+ * 打开或关闭抽屉
304
+ * @param drawerConfig - 抽屉配置对象,false表示关闭抽屉
305
+ */
306
+ openDrawer(e) {
307
+ var n;
308
+ if (!e) {
309
+ this.drawerConfig = {
310
+ content: "",
311
+ height: (n = this.drawerConfig) == null ? void 0 : n.height
312
+ };
313
+ return;
314
+ }
315
+ this.drawerConfig = e;
316
+ }
317
+ /**
318
+ * 获取播放器是否准备就绪
319
+ * @returns 是否有可用的视频代理场景
320
+ */
321
+ get ready() {
322
+ return !!this.videoAgentScene;
323
+ }
324
+ /**
325
+ * 获取当前播放时间(毫秒)
326
+ * @returns 当前播放时间戳
327
+ */
328
+ get currentTime() {
329
+ var e;
330
+ return ((e = this.videoAgentScene) == null ? void 0 : e.videoAgentMesh.currentTime) || 0;
331
+ }
332
+ /**
333
+ * 获取当前时间点应该触发的关键帧
334
+ * @returns 当前应该执行的关键帧数组
335
+ */
336
+ loadTimeline(e) {
337
+ this.timeline.load(e);
338
+ }
339
+ seekTimeline(e) {
340
+ this.timeline.seek(e);
341
+ }
342
+ resetTimeline(e) {
343
+ this.timeline.reset(e);
344
+ }
345
+ get currentKeyframes() {
346
+ return this.timeline.pendingAt(this.currentTime);
347
+ }
348
+ /**
349
+ * 获取当前媒体实例(音频或视频元素)
350
+ * @returns HTML媒体元素实例
351
+ */
352
+ get mediaInstance() {
353
+ var e;
354
+ return (e = this.videoAgentScene) == null ? void 0 : e.videoAgentMesh.mediaInstance;
355
+ }
356
+ /**
357
+ * 逐帧任务循环处理
358
+ *
359
+ * 在每个动画帧中检查播放状态、处理关键帧触发等
360
+ * @param callback - 关键帧触发时的回调函数
361
+ */
362
+ requestAnimationFrameLoop(e) {
363
+ var s, a, o, l, c, V, f, h;
364
+ if (this.waitingForBgMusic) {
365
+ (s = this.mediaInstance) != null && s.paused || (o = (a = this.videoAgentScene) == null ? void 0 : a.videoAgentMesh.mediaOperations) == null || o.pause();
366
+ return;
367
+ }
368
+ if ((l = this.mediaInstance) != null && l.ended && this.mediaInstance.currentTime !== 0) {
369
+ if (this.ended) return;
370
+ this.timeline.reset();
371
+ const p = (c = this.videoAgentScene) == null ? void 0 : c.videoAgentMesh.mediaOperations;
372
+ p == null || p.pause(), p && (p.currentTime = 0), this.playback.finish(), this.setEnded(!0), this.setPlaying(!1);
373
+ return;
374
+ }
375
+ if (!this.playing) {
376
+ (V = this.mediaInstance) != null && V.paused || (h = (f = this.videoAgentScene) == null ? void 0 : f.videoAgentMesh.mediaOperations) == null || h.pause();
377
+ return;
378
+ }
379
+ this.resumeMedia();
380
+ const n = this.playback.capture();
381
+ if (!(n != null && n.valid())) return;
382
+ const r = this.currentTime;
383
+ this.timeline.take(r).forEach((p) => {
384
+ this.emit(p.type, p, r), n.valid() && e(p.type, p, r);
385
+ });
386
+ }
387
+ resumeMedia() {
388
+ var e, n;
389
+ if (!this.waitingForBgMusic && (e = this.mediaInstance) != null && e.paused && this.playing && !this.resuming) {
390
+ const r = ++this.resumeGeneration;
391
+ this.resuming = r;
392
+ const s = this.playback.capture(), a = () => !!(s != null && s.valid());
393
+ (n = this.videoAgentScene) == null || n.videoAgentMesh.play().catch((o) => {
394
+ a() && (this.playback.cancel(), console.error(o));
395
+ }).finally(() => {
396
+ this.resuming === r && (this.resuming = void 0);
397
+ });
398
+ }
399
+ }
400
+ /**
401
+ * 开始运行播放器逻辑循环
402
+ *
403
+ * 启动帧循环,持续监听并处理关键帧事件
404
+ * @param callback - 关键帧触发时的回调函数
405
+ */
406
+ run(e) {
407
+ this.stopInterval || (this.stopInterval = le(() => this.requestAnimationFrameLoop(e)));
408
+ }
409
+ /**
410
+ * 清理播放器状态
411
+ *
412
+ * 停止播放、重置关键帧状态、清理数据和定时器
413
+ */
414
+ clear() {
415
+ var e, n, r, s;
416
+ this.setPlaying(!1), this.timeline.reset(), this.vreoUnit = void 0, this.timeline.clear(), this.mediaInstance && ((n = (e = this.videoAgentScene) == null ? void 0 : e.videoAgentMesh.mediaOperations) == null || n.pause(), (r = this.videoAgentScene) != null && r.videoAgentMesh.mediaOperations && (this.videoAgentScene.videoAgentMesh.mediaOperations.currentTime = 0)), (s = this.stopInterval) == null || s.call(this), this.stopInterval = void 0;
417
+ }
418
+ /**
419
+ * 销毁控制器实例
420
+ *
421
+ * 清理所有状态和资源,释放内存
422
+ */
423
+ dispose() {
424
+ this.disposers.splice(0).forEach((e) => e()), this.playback.dispose(), this.clear();
425
+ }
426
+ }
427
+ const ye = A.createContext(null);
428
+ function T() {
429
+ const t = X.useContext(ye);
430
+ if (!t)
431
+ throw new Error('没有找到 "ControllerContext"');
432
+ return t;
433
+ }
434
+ function U() {
435
+ const t = T();
436
+ if (!t.five)
437
+ throw new Error('没有找到 "five" 实例');
438
+ return t.five;
439
+ }
440
+ function et() {
441
+ const t = U();
442
+ return (i) => t.project2d(i, !1);
443
+ }
444
+ function tt() {
445
+ const t = T(), i = U(), e = A.useRef(void 0);
446
+ return A.useEffect(() => {
447
+ const n = async (r) => {
448
+ e.current || (e.current = Re(i));
449
+ const { start: s, end: a, data: o } = r, l = o, c = l.effect;
450
+ c === Ve.Rotate ? await e.current.rotate(o, a - s) : c === Ve.Move ? await e.current.move(o, a - s) : l.panoIndex !== void 0 && l.panoIndex !== i.panoIndex ? await e.current.move(o, a - s) : await e.current.rotate(o, a - s);
451
+ };
452
+ return t.on(P.CameraMovement, n), () => {
453
+ t.off(P.CameraMovement, n);
454
+ };
455
+ }, [t]), /* @__PURE__ */ d(C, {});
456
+ }
457
+ const G = /* @__PURE__ */ new Map();
458
+ function fe(t) {
459
+ G.set(t, (G.get(t) ?? 0) + 1);
460
+ }
461
+ function he(t) {
462
+ const i = (G.get(t) ?? 1) - 1;
463
+ i > 0 ? G.set(t, i) : G.delete(t);
464
+ }
465
+ function xe(t, i, e = !0) {
466
+ if (!t) return () => {
467
+ };
468
+ e && i(t.clientWidth, t.clientHeight);
469
+ let n = !1;
470
+ if (typeof ResizeObserver < "u") {
471
+ const o = new ResizeObserver(() => i(t.clientWidth, t.clientHeight));
472
+ return o.observe(t), fe(t), () => {
473
+ n || (n = !0, o.disconnect(), he(t));
474
+ };
475
+ }
476
+ const r = document.createElement("iframe");
477
+ r.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;opacity:0;visibility:hidden;margin:0;border:0;padding:0;z-index:-1;", r.classList.add("resize-sensor-iframe"), t.appendChild(r);
478
+ const s = r.contentWindow;
479
+ if (!s)
480
+ return r.remove(), () => {
481
+ };
482
+ const a = () => i(r.clientWidth, r.clientHeight);
483
+ return s.addEventListener("resize", a), fe(t), () => {
484
+ n || (n = !0, s.removeEventListener("resize", a), r.remove(), he(t));
485
+ };
486
+ }
487
+ function nt(t) {
488
+ return !!t && (G.get(t) ?? 0) > 0;
489
+ }
490
+ function it() {
491
+ const t = X.useRef(null), i = T();
492
+ return X.useEffect(() => {
493
+ if (!t.current) return;
494
+ const e = i.container.parentElement;
495
+ if (nt(e)) return;
496
+ const n = xe(e, (r, s) => {
497
+ i.setContainerSize(r, s);
498
+ });
499
+ return () => {
500
+ n();
501
+ };
502
+ }, []), /* @__PURE__ */ d("div", { className: "resizeObserver-element", ref: t });
503
+ }
504
+ function pe({ url: t, children: i }) {
505
+ return /* @__PURE__ */ d("div", { className: "vreo-infoPanel-container", children: /* @__PURE__ */ L("div", { className: "vreo-infoPanel", children: [
506
+ i,
507
+ /* @__PURE__ */ d("img", { src: t })
508
+ ] }) });
509
+ }
510
+ function Ae({ url: t, children: i }) {
511
+ const e = A.useRef(null), n = T();
512
+ return A.useEffect(() => {
513
+ var h, p;
514
+ const r = ((p = (h = n.configs) == null ? void 0 : h.videos) == null ? void 0 : p.videoPanel) || document.createElement("video"), s = n.playback.capture(), a = () => !!(s != null && s.valid());
515
+ if (!(s != null && s.valid())) return;
516
+ const o = s.bind(r);
517
+ let l = !1;
518
+ r.playsInline = !0, o.muted = !0;
519
+ const c = () => {
520
+ l = !0, o.muted = !0, o.pause(), r.removeEventListener("canplaythrough", f);
521
+ };
522
+ if (!e.current) return;
523
+ const V = n.playback.add(c);
524
+ o.src = t, e.current.contains(r) || e.current.appendChild(r);
525
+ const f = () => {
526
+ r.removeEventListener("canplaythrough", f), !(l || !a()) && (o.muted = !1, o.play().catch((w) => {
527
+ a() && !l && (c(), n.playback.cancel(), console.error(w));
528
+ }));
529
+ };
530
+ return r.addEventListener("canplaythrough", f), o.load(), () => {
531
+ var w;
532
+ c(), V(), (w = e.current) != null && w.contains(r) && e.current.removeChild(r);
533
+ };
534
+ }, [n, t]), /* @__PURE__ */ d("div", { className: "vreo-infoPanel-container", children: /* @__PURE__ */ L("div", { className: "vreo-infoPanel", children: [
535
+ i,
536
+ /* @__PURE__ */ d("div", { className: "vreo-infoPanel-inner", ref: e })
537
+ ] }) });
538
+ }
539
+ const te = (t) => !t.title && !t.subTitle ? null : /* @__PURE__ */ d(C, { children: /* @__PURE__ */ L("div", { className: "vreo-infoPanel-title", children: [
540
+ /* @__PURE__ */ d("div", { className: "vreo-infoPanel-t1", children: t.title }),
541
+ /* @__PURE__ */ d("div", { className: "vreo-infoPanel-t2", children: t.subTitle })
542
+ ] }) });
543
+ function rt() {
544
+ const t = A.useRef(null), i = T();
545
+ return A.useEffect(() => {
546
+ var s;
547
+ if (((s = i.configs) == null ? void 0 : s.keyframeMap.InfoPanel) === !1)
548
+ return;
549
+ const e = (a) => {
550
+ const { start: o, end: l, data: c } = a, V = c, { title: f, subTitle: h, style: p } = V;
551
+ do {
552
+ if (p === Ne.PopUp) {
553
+ V.type === ee.Image ? i.openPopUp(
554
+ /* @__PURE__ */ d(pe, { url: V.url, children: /* @__PURE__ */ d(te, { title: f, subTitle: h }) })
555
+ ) : V.type === ee.Video && i.openPopUp(
556
+ /* @__PURE__ */ d(Ae, { url: V.url, children: /* @__PURE__ */ d(te, { title: f, subTitle: h }) })
557
+ );
558
+ break;
559
+ }
560
+ V.type === ee.Image ? i.openDrawer({
561
+ content: /* @__PURE__ */ d(pe, { url: V.url, children: /* @__PURE__ */ d(te, { title: f, subTitle: h }) }),
562
+ height: "60vh"
563
+ }) : V.type === ee.Video && i.openDrawer({
564
+ content: /* @__PURE__ */ d(Ae, { url: V.url, children: /* @__PURE__ */ d(te, { title: f, subTitle: h }) }),
565
+ height: "60vh"
566
+ });
567
+ } while (!1);
568
+ t.current = setTimeout(() => {
569
+ i.openDrawer(!1), i.openPopUp(!1);
570
+ }, l - o);
571
+ };
572
+ i.on(P.InfoPanel, e);
573
+ const n = () => {
574
+ t.current && clearTimeout(t.current), i.openDrawer(!1), i.openPopUp(!1);
575
+ }, r = i.playback.add(n);
576
+ return () => {
577
+ r(), n(), i.off(P.InfoPanel, e), t.current && clearTimeout(t.current);
578
+ };
579
+ }, [i]), /* @__PURE__ */ d(C, {});
580
+ }
581
+ function st(t) {
582
+ const i = new M.Matrix4();
583
+ return i.fromArray(t), (e) => {
584
+ const n = new M.Vector3(...e);
585
+ return n.applyMatrix4(i), n.toArray();
586
+ };
587
+ }
588
+ function at() {
589
+ const t = T(), i = U(), e = A.useRef(void 0), n = A.useRef(null);
590
+ return A.useEffect(() => {
591
+ let r = 0;
592
+ const s = () => {
593
+ var l;
594
+ ++r, n.current && clearTimeout(n.current), (l = e.current) == null || l.dispose(), e.current = void 0;
595
+ }, a = t.playback.add(s), o = async (l) => {
596
+ var x, I;
597
+ s();
598
+ const c = r, V = t.playback.capture(), f = () => !!(V != null && V.valid());
599
+ if (!f()) return;
600
+ const h = e.current = $e(i, { mediaManager: V == null ? void 0 : V.mediaManager }), { start: p, end: w } = l, { videoSrc: y, videoPosterSrc: v, vertexs: m, matrixWorld: k } = l.data, b = (() => {
601
+ if (m.length < 4)
602
+ throw new Error("ModelVideo: 顶点数据集合不够,无法组成矩形 ....");
603
+ if (m.length === 4)
604
+ return m;
605
+ const E = new M.Box3();
606
+ return m.forEach((S) => E.expandByPoint(new M.Vector3(S.x, S.y, S.z))), [
607
+ new M.Vector3(E.min.x, E.max.y, E.max.z),
608
+ new M.Vector3(E.min.x, E.min.y, E.max.z),
609
+ new M.Vector3(E.max.x, E.min.y, E.max.z),
610
+ new M.Vector3(E.max.x, E.max.y, E.max.z)
611
+ ];
612
+ })(), g = (() => {
613
+ if (k) {
614
+ const E = st(k);
615
+ return [
616
+ b.map((S) => {
617
+ const z = E([S.x, S.y, S.z]);
618
+ return { x: z[0], y: z[1], z: z[2] };
619
+ })
620
+ ];
621
+ }
622
+ return [b];
623
+ })();
624
+ h.disable();
625
+ try {
626
+ await h.load(
627
+ {
628
+ video_src: y,
629
+ video_poster_src: v,
630
+ points: g
631
+ },
632
+ (I = (x = t.configs) == null ? void 0 : x.videos) == null ? void 0 : I.modelTVVideo
633
+ );
634
+ } catch (E) {
635
+ c === r && f() && (t.playback.cancel(), console.error(E));
636
+ return;
637
+ }
638
+ c !== r || !f() || (h.enable(), n.current = setTimeout(s, w - p));
639
+ };
640
+ return t.on(P.ModelVideo, o), () => {
641
+ var l;
642
+ s(), a(), (l = e.current) == null || l.dispose(), e.current = void 0, t.off(P.ModelVideo, o), n.current && clearTimeout(n.current);
643
+ };
644
+ }, [t]), /* @__PURE__ */ d(C, {});
645
+ }
646
+ class ot extends se.Tween {
647
+ constructor() {
648
+ super(...arguments);
649
+ u(this, "disposeMethods", []);
650
+ u(this, "animationFrameDisposer");
651
+ u(this, "onDispose", (e) => (this.disposeMethods.push(e), this));
652
+ u(this, "play", () => (this.start(), this.animationFrameDisposer = le(() => this.update()), this));
653
+ u(this, "dispose", () => {
654
+ var e;
655
+ this.stop(), (e = this.animationFrameDisposer) == null || e.call(this), this.disposeMethods.forEach((n) => n()), this.disposeMethods = [], se.remove(this);
656
+ });
657
+ }
658
+ }
659
+ function ke(t, i = se.Easing.Linear.None) {
660
+ const e = new ot({ progress: 0 }).to({ progress: 1 });
661
+ return t !== void 0 && e.duration(t), i !== void 0 && e.easing(i), e;
662
+ }
663
+ function ct(t, i, e) {
664
+ const r = new M.TextureLoader().load("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgBAMAAACBVGfHAAAAIVBMVEUAAAD////////////////////////////////////////PIev5AAAACnRSTlMAG/Py2baba05un7UgfgAAAHJJREFUKM9joBpgLHVSCRdA4metAoJlCJHmVWBgAeNzroKCCVCBLpjACqgJVjCBxRBT2FbBQQJYQAohsBAsUIUQWA4WiEIILAULeCEEloAFtBACizAEMLRgGIphLabDMJ2O6TlM72MGECIIMQIZIxqoBQCPvpJ/e9FaAAAAAABJRU5ErkJggg=="), s = new Fe(), a = new M.Line2NodeMaterial({ color: 16777215, linewidth: 2, depthTest: !1 }), o = new We(s, a), l = new M.BufferGeometry(), c = new M.PointsNodeMaterial({ color: 16777215, map: r, transparent: !0 }), V = new M.Points(l, c), f = new M.Group();
665
+ f.add(o, V);
666
+ const h = (p, w) => {
667
+ const y = [...p.toArray(), ...w.toArray()];
668
+ s.setPositions(y), l.setAttribute("position", new M.Float32BufferAttribute(y, 3));
669
+ };
670
+ return h(i, e), ke().onUpdate(({ progress: p }) => {
671
+ h(i.clone().lerp(e, 0.5 - p / 2), i.clone().lerp(e, 0.5 + p / 2)), t.needsRender = !0;
672
+ }).onStart(() => t.scene.add(f)).onDispose(() => {
673
+ t.scene.remove(f), s.dispose(), a.dispose(), l.dispose(), c.dispose(), r.dispose(), t.needsRender = !0;
674
+ });
675
+ }
676
+ function lt() {
677
+ const [t, i] = A.useState(null), e = U(), n = A.useRef(null), [r, s] = A.useState(null), a = A.useRef(null), o = T(), l = et(), c = () => {
678
+ n.current && n.current.dispose();
679
+ };
680
+ return A.useEffect(() => {
681
+ const V = (f) => {
682
+ const { start: h, end: p, data: w } = f, y = w, [v, m] = y.twoVertexs, k = new q(v.x, v.y, v.z), b = new q(m.x, m.y, m.z);
683
+ n.current = ct(e, k.clone(), b.clone()), n.current.play();
684
+ const g = k.lerp(b, 0.5), x = k.distanceTo(b), I = l(g);
685
+ if (!I) return;
686
+ const { x: E, y: S } = I;
687
+ i({ center: g, distance: x }), s({ left: E, top: S }), a.current = setTimeout(() => {
688
+ i(null), s(null), c();
689
+ }, p - h);
690
+ };
691
+ return o.on(P.PanoEffect, V), () => {
692
+ o.off(P.PanoEffect, V), a.current && clearTimeout(a.current), c();
693
+ };
694
+ }, [o]), A.useEffect(() => {
695
+ const V = () => {
696
+ if (!(t != null && t.center)) return;
697
+ const { x: f, y: h, z: p } = t.center, w = l(new q(f, h, p));
698
+ if (!w) return;
699
+ const { x: y, y: v } = w;
700
+ s({ left: y, top: v });
701
+ };
702
+ return e.on("currentStateChange", V), () => {
703
+ e.off("currentStateChange", V);
704
+ };
705
+ }, [t == null ? void 0 : t.center]), /* @__PURE__ */ d(C, { children: /* @__PURE__ */ d(
706
+ "div",
707
+ {
708
+ className: D("PanoEffect", {
709
+ "PanoEffect--notHidden": t
710
+ }),
711
+ style: {
712
+ left: ((r == null ? void 0 : r.left) || 0) + "px",
713
+ top: ((r == null ? void 0 : r.top) || 0) + "px"
714
+ },
715
+ children: (t == null ? void 0 : t.distance.toFixed(4)) + "m"
716
+ }
717
+ ) });
718
+ }
719
+ function dt() {
720
+ const t = T(), i = U();
721
+ return A.useEffect(() => {
722
+ var V;
723
+ if (((V = t.configs) == null ? void 0 : V.keyframeMap.PanoTag) === !1)
724
+ return;
725
+ const e = De(i, {
726
+ config: {
727
+ globalConfig: {
728
+ visibleConfig: { keep: "visible" },
729
+ unfoldedConfig: { autoUnfold: !1, unfoldDistance: { max: 100 } }
730
+ }
731
+ }
732
+ });
733
+ let n, r = !1, s = 0;
734
+ const a = (f) => {
735
+ f.released || (f.released = !0, f.timer !== void 0 && clearTimeout(f.timer), n === f && (n = void 0), e.destroyTagById(f.id));
736
+ }, o = () => {
737
+ n && a(n);
738
+ }, l = t.playback.add(o), c = (f, h = f.start) => {
739
+ const p = t.playback.capture();
740
+ if (r || !(p != null && p.valid())) return;
741
+ o();
742
+ const { end: w, data: y } = f, v = y;
743
+ s = Math.max(Date.now(), s + 1);
744
+ const m = s.toString(), k = [v.vertex.x, v.vertex.y, v.vertex.z], b = v.imgUrl ? { id: m, position: k, contentType: "ImageText", stickType: "2DPoint", data: { title: v.text, mediaData: [{ type: "Image", url: v.imgUrl }] } } : { id: m, position: k, contentType: "Text", stickType: "2DPoint", data: { title: v.text } }, g = { id: m, released: !1, expired: !1 };
745
+ n = g, g.timer = setTimeout(() => {
746
+ var x;
747
+ if (!g.released) {
748
+ if (r || !p.valid()) return a(g);
749
+ g.expired = !0, (x = e.getTagById(m)) == null || x.fold(), g.timer = setTimeout(() => a(g), 1500);
750
+ }
751
+ }, Math.max(0, w - h)), e.load({ tagList: [b] }).then(() => {
752
+ if (r || g.released || g.expired || n !== g || !p.valid()) {
753
+ a(g);
754
+ return;
755
+ }
756
+ const x = e.getTagById(m);
757
+ if (!x) return a(g);
758
+ x.setMediaManager(p.mediaManager), x.unfold();
759
+ }).catch((x) => {
760
+ a(g), console.error("Vreo PanoTag failed to load", x);
761
+ });
762
+ };
763
+ return t.on(P.PanoTag, c), () => {
764
+ r = !0, t.off(P.PanoTag, c), l(), o(), e.dispose();
765
+ };
766
+ }, [t]), null;
767
+ }
768
+ const ut = (t, i, e, n) => {
769
+ const r = e / 375, s = n / 375, a = new M.PlaneGeometry(r, s);
770
+ if (i) {
771
+ const c = new M.Vector3(i.x + t.x, i.y + t.y, i.z + t.z);
772
+ a.lookAt(c);
773
+ }
774
+ const o = a.getAttribute("position"), l = (c) => t.clone().add(
775
+ new M.Vector3().fromBufferAttribute(o, c)
776
+ );
777
+ return [l(2), l(3), l(1), l(0)];
778
+ };
779
+ function Vt() {
780
+ const t = T(), i = U(), e = A.useRef(void 0);
781
+ return A.useEffect(() => {
782
+ var o;
783
+ if (((o = t.configs) == null ? void 0 : o.keyframeMap.PanoTextLabel) === !1)
784
+ return;
785
+ const n = /* @__PURE__ */ new Set(), r = () => {
786
+ for (const l of [...n]) l();
787
+ }, s = t.playback.add(r), a = (l, c = l.start) => {
788
+ var $, B, K;
789
+ const { end: V, data: f } = l, h = f;
790
+ if (f.text === "") return;
791
+ const { x: p, y: w, z: y } = h.vertex, v = new q(p, w, y), m = new q(($ = h.normal) == null ? void 0 : $.x, (B = h.normal) == null ? void 0 : B.y, (K = h.normal) == null ? void 0 : K.z), g = ut(v, h.normal && m, 200, 30);
792
+ e.current || (e.current = we(i));
793
+ const x = e.current.create3DDomContainer(g), I = x == null ? void 0 : x.css3DObject;
794
+ if (f.quaternion) {
795
+ const W = new qe(f.quaternion.x, f.quaternion.y, f.quaternion.z, f.quaternion.w);
796
+ I == null || I.quaternion.copy(W);
797
+ }
798
+ if (!(x != null && x.container)) return;
799
+ const E = oe(x.container);
800
+ let S, z = !1;
801
+ const O = () => {
802
+ z || (z = !0, S !== void 0 && clearTimeout(S), n.delete(O), x.dispose(), queueMicrotask(() => E.unmount()));
803
+ };
804
+ n.add(O), E.render(
805
+ /* @__PURE__ */ d("div", { className: "PanoTextLabel PanoTextLabel--notHidden", children: /* @__PURE__ */ d("div", { className: "PanoTextLabel-wrapper", children: /* @__PURE__ */ d("div", { style: { fontSize: `${f.fontSize || 16}px` }, className: "PanoText-innerText", children: f.text || "" }) }) })
806
+ ), S = setTimeout(O, Math.max(0, V - c));
807
+ };
808
+ return t.on(P.PanoTextLabel, a), () => {
809
+ t.off(P.PanoTextLabel, a), s(), r(), e.current = void 0;
810
+ };
811
+ }, [t]), /* @__PURE__ */ d(C, {});
812
+ }
813
+ function ft() {
814
+ const [t, i] = A.useState(""), [e, n] = A.useState(!0), r = A.useRef(null), s = T();
815
+ return A.useEffect(() => {
816
+ var c;
817
+ if (((c = s.configs) == null ? void 0 : c.keyframeMap.Prompter) === !1)
818
+ return;
819
+ const a = () => {
820
+ r.current !== null && clearTimeout(r.current), r.current = null, n(!0), i("");
821
+ }, o = s.playback.add(a), l = (V, f = V.start) => {
822
+ const { end: h, data: p } = V;
823
+ i(p.text), n(!1), r.current && (clearTimeout(r.current), r.current = null), r.current = setTimeout(a, Math.max(0, h - f));
824
+ };
825
+ return s.on(P.Prompter, l), () => {
826
+ s.off(P.Prompter, l), o(), a();
827
+ };
828
+ }, [s]), /* @__PURE__ */ d(
829
+ "div",
830
+ {
831
+ className: D("vreo-prompter", {
832
+ "vreo-prompter--hidden": e,
833
+ [`vreo-prompter-left--${s.agentType}`]: !0
834
+ }),
835
+ children: /* @__PURE__ */ d("div", { className: "vreo-prompter-text", children: /* @__PURE__ */ d("div", { className: "vreo-prompter-innerText", children: t }) })
836
+ }
837
+ );
838
+ }
839
+ function ht() {
840
+ const t = T(), i = U(), e = A.useRef(null), n = A.useRef(null), r = A.useCallback(() => {
841
+ if (n.current = null, e.current) {
842
+ const o = J(e.current);
843
+ i.load(o);
844
+ }
845
+ }, []), s = A.useCallback(() => {
846
+ if (e.current) {
847
+ const o = J(e.current);
848
+ Object.assign(window, { $rawWork: o }), i.load(o);
849
+ }
850
+ }, []), a = A.useCallback(() => {
851
+ n.current && i.load(n.current);
852
+ }, []);
853
+ return A.useEffect(() => {
854
+ const o = (l) => {
855
+ var f, h, p, w, y;
856
+ !e.current && ((h = (f = i.work) == null ? void 0 : f.raw) != null && h.works) && (e.current = i.work.raw.works);
857
+ const c = l.data;
858
+ if (c.work) {
859
+ n.current = J(c.work), i.load(n.current);
860
+ return;
861
+ }
862
+ const V = (y = (w = (p = i.work) == null ? void 0 : p.raw) == null ? void 0 : w.works) == null ? void 0 : y[0];
863
+ if (!V) {
864
+ console.warn("UpdateVRPanorama: 没有可用的 work 数据");
865
+ return;
866
+ }
867
+ if (c.dynamic_scene && !c.panorama) {
868
+ const m = JSON.parse(V).panorama, k = c.dynamic_scene.images.index;
869
+ m.list[k] = c.dynamic_scene.images, c.panorama = m, delete c.dynamic_scene;
870
+ }
871
+ Object.assign(window, { $work1: JSON.parse(V), $work2: c, parseWork: J }), n.current = J([V, c]), i.load(n.current);
872
+ };
873
+ return t.on(P.UpdateVRPanorama, o), t.on(P.Exit, r), t.on("loaded", r), t.on("paused", s), t.on("playing", a), () => {
874
+ t.off(P.UpdateVRPanorama, o), t.off(P.Exit, r), t.off("loaded", r), t.off("paused", s), t.off("playing", a);
875
+ };
876
+ }, []), /* @__PURE__ */ d(C, {});
877
+ }
878
+ const pt = Math.PI, re = pt * 2;
879
+ function At() {
880
+ const t = A.useRef(null), i = A.useRef(null), e = T(), n = A.useRef(null), [r, s] = A.useState(!1), a = U();
881
+ return A.useEffect(() => {
882
+ let o, l = 0, c;
883
+ const V = async (p) => {
884
+ const { start: w, end: y } = p, { videoSrc: v, fov: m, direction: k, panoIndex: b, vector: g } = p.data, [x, I] = (() => {
885
+ if (g)
886
+ return [g.longitude, g.latitude];
887
+ if (!k)
888
+ return [0, 0];
889
+ let W = -Math.atan2(k.x, -k.z);
890
+ W = (W % re + re) % re;
891
+ const Me = -Math.asin(k.y / 1);
892
+ return [W, Me];
893
+ })();
894
+ f();
895
+ const E = l;
896
+ a.setState({ fov: m, panoIndex: b, longitude: x, latitude: I }, !0), c == null || c();
897
+ const S = e.playback.capture(), z = () => !!(S != null && S.valid()), O = () => E === l && z(), $ = i.current;
898
+ if (!$ || !O()) return;
899
+ const B = o = S.bind($);
900
+ B.muted = !0, B.src = v;
901
+ const K = () => {
902
+ c == null || c(), O() && (B.muted = !1, B.play().catch((W) => {
903
+ O() && (e.playback.cancel(), console.error(W));
904
+ }));
905
+ };
906
+ c = () => $.removeEventListener("canplaythrough", K), $.addEventListener("canplaythrough", K), B.load(), s(!0), n.current = setTimeout(f, Math.max(0, y - w));
907
+ };
908
+ e.on(P.VideoEffect, V);
909
+ const f = () => {
910
+ ++l, n.current && clearTimeout(n.current), c == null || c(), o && (o.muted = !0, o.pause(), o.src = ""), o = void 0, s(!1);
911
+ }, h = e.playback.add(f);
912
+ return () => {
913
+ f(), h(), e.off(P.VideoEffect, V), n.current && clearTimeout(n.current);
914
+ };
915
+ }, [e]), A.useEffect(() => {
916
+ var l, c;
917
+ if (!t.current) return;
918
+ const o = ((c = (l = e.configs) == null ? void 0 : l.videos) == null ? void 0 : c.videoEffect) || document.createElement("video");
919
+ return o.setAttribute("playsinline", "true"), o.setAttribute("webkit-playsinline", "true"), o.autoplay = !1, o.muted = !0, o.setAttribute("key", "VideoEffect-video"), o.setAttribute("class", "VideoEffect-video"), i.current = o, t.current.append(i.current), () => {
920
+ o.muted = !0, o.pause(), o.remove();
921
+ };
922
+ }, []), /* @__PURE__ */ d(
923
+ "div",
924
+ {
925
+ ref: t,
926
+ className: D("VideoEffect", {
927
+ "VideoEffect--visible": r
928
+ })
929
+ }
930
+ );
931
+ }
932
+ const mt = {
933
+ blob: (t) => {
934
+ const i = () => null;
935
+ return new Promise((e, n) => {
936
+ const r = new XMLHttpRequest(), s = () => {
937
+ r.ontimeout = i, r.onreadystatechange = i, r.onprogress = i, r.onabort = i;
938
+ };
939
+ r.ontimeout = () => {
940
+ n(new Error("timeout")), s();
941
+ }, r.onreadystatechange = () => {
942
+ r.readyState === 4 && (r.status === 0 && !r.response || (r.status === 200 || r.status === 0 ? (e(r.response), s()) : (n(new Error("status:" + r.status)), s())));
943
+ }, r.open("GET", t, !0), r.responseType = "blob", r.send(null);
944
+ });
945
+ }
946
+ };
947
+ class vt extends ce {
948
+ constructor({ duration: e } = {}) {
949
+ super();
950
+ u(this, "$timestamp", null);
951
+ u(this, "$currentTime", 0);
952
+ u(this, "$duration", 0);
953
+ u(this, "stopInterval");
954
+ u(this, "muted", !1);
955
+ u(this, "src", "");
956
+ e && (this.$duration = e);
957
+ }
958
+ setAttribute(e, n) {
959
+ }
960
+ play() {
961
+ this.stopInterval || (this.$currentTime === this.$duration && (this.$currentTime = 0), this.$timestamp === null && (this.$timestamp = performance.now()), this.stopInterval = le(() => this.requestAnimationFrameLoop()), this.emit("play"));
962
+ }
963
+ pause() {
964
+ this.stopInterval && (this.stopInterval(), this.emit("pause"), this.stopInterval = void 0), this.$timestamp = null;
965
+ }
966
+ requestAnimationFrameLoop() {
967
+ if (this.$timestamp === null) return;
968
+ const e = performance.now();
969
+ this.$currentTime += e - this.$timestamp, this.$timestamp = e, this.emit("timeupdate"), this.$currentTime >= this.$duration - 10 && (this.$currentTime = this.$duration, this.pause(), this.emit("ended"));
970
+ }
971
+ get currentTime() {
972
+ return this.$currentTime / 1e3;
973
+ }
974
+ set currentTime(e) {
975
+ this.$currentTime = e * 1e3;
976
+ }
977
+ get duration() {
978
+ return this.$duration;
979
+ }
980
+ set duration(e) {
981
+ this.$duration = e;
982
+ }
983
+ get ended() {
984
+ return this.$currentTime === this.$duration;
985
+ }
986
+ get paused() {
987
+ return !this.stopInterval;
988
+ }
989
+ addEventListener(e, n, r = !1) {
990
+ this.on(e, n);
991
+ }
992
+ removeEventListener(e, n, r = !1) {
993
+ this.off(e, n);
994
+ }
995
+ }
996
+ class gt extends M.Mesh {
997
+ /**
998
+ * 创建视频经纪人贴片实例
999
+ *
1000
+ * @param width - 网格宽度
1001
+ * @param height - 网格高度
1002
+ * @param widthSegments - 宽度方向分段数
1003
+ * @param heightSegments - 高度方向分段数
1004
+ * @param options - 配置选项
1005
+ *
1006
+ * @example
1007
+ * ```typescript
1008
+ * const mesh = new VideoAgentMesh(1920, 1080, 32, 18, {
1009
+ * preload: true,
1010
+ * videoInstance: document.getElementById('video')
1011
+ * })
1012
+ * ```
1013
+ */
1014
+ constructor(e, n, r, s, a = {
1015
+ preload: !0
1016
+ }) {
1017
+ var k, b;
1018
+ const o = !a.videoInstance;
1019
+ if (!a.videoInstance) {
1020
+ const g = document.createElement("video");
1021
+ g.style.display = "none", g.playsInline = !0, g.muted = !0, document.body.append(g), a.videoInstance = g;
1022
+ }
1023
+ const l = new M.PlaneGeometry(e, n, r, s), c = new M.VideoTexture(a.videoInstance);
1024
+ c.colorSpace = M.SRGBColorSpace;
1025
+ const V = je(0), h = Ge(c).sample(He()), p = Ke(1).sub(
1026
+ Je(0.1, 0.3, h.g.sub(Qe(h.r, h.b)).add(0.1))
1027
+ ), w = new M.MeshBasicNodeMaterial({ transparent: !0 });
1028
+ w.colorNode = h.rgb, w.opacityNode = p.mul(V);
1029
+ super(l, w);
1030
+ u(this, "videoTexture");
1031
+ u(this, "enableNode");
1032
+ /** 配置选项 */
1033
+ u(this, "options");
1034
+ /** 当前视频URL */
1035
+ u(this, "videoUrl");
1036
+ /** 是否冻结状态 */
1037
+ u(this, "freeze");
1038
+ /** 是否暂停状态 */
1039
+ u(this, "paused");
1040
+ /** 音频实例 */
1041
+ u(this, "outputs", /* @__PURE__ */ new Map());
1042
+ u(this, "ownsVideo", !1);
1043
+ u(this, "ownsAudio", !1);
1044
+ u(this, "generation", 0);
1045
+ u(this, "removeStart");
1046
+ u(this, "objectURL");
1047
+ u(this, "audioInstance");
1048
+ /** AudioLike 实例 */
1049
+ u(this, "audioLikeInstance");
1050
+ /** 移除事件监听器的函数 */
1051
+ u(this, "$removeEventListener");
1052
+ this.videoTexture = c, this.enableNode = V, this.ownsVideo = o, this.ownsAudio = !a.audioInstance, this.options = a, this.freeze = !1, this.paused = !0, a.audioInstance ? this.audioInstance = a.audioInstance : (this.audioInstance = document.createElement("audio"), this.audioInstance.crossOrigin = "", this.audioInstance.muted = !0, this.audioInstance.autoplay = !1), this.audioLikeInstance = new vt(), be(this, { paused: N, videoUrl: Q });
1053
+ const y = (g) => Z(() => this.paused = g), v = () => y(!0), m = () => y(!1);
1054
+ this.audioInstance.addEventListener("pause", v), this.audioInstance.addEventListener("play", m), (k = this.options.videoInstance) == null || k.addEventListener("pause", v), (b = this.options.videoInstance) == null || b.addEventListener("play", m), this.audioLikeInstance.addEventListener("pause", v), this.audioLikeInstance.addEventListener("play", m), this.$removeEventListener = () => {
1055
+ var g, x;
1056
+ this.audioInstance.removeEventListener("pause", v), this.audioInstance.removeEventListener("play", m), (g = this.options.videoInstance) == null || g.removeEventListener("pause", v), (x = this.options.videoInstance) == null || x.removeEventListener("play", m), this.audioLikeInstance.removeEventListener("pause", v), this.audioLikeInstance.removeEventListener("play", m);
1057
+ };
1058
+ }
1059
+ operations(e, n) {
1060
+ const r = e ? e.bind(n) : n;
1061
+ return this.outputs.set(n, r), r;
1062
+ }
1063
+ /**
1064
+ * 获取当前的媒体实例
1065
+ *
1066
+ * 根据媒体类型自动返回对应的播放实例:
1067
+ * - 无媒体时返回 AudioLike 实例
1068
+ * - 音频文件返回 HTMLAudioElement
1069
+ * - 视频文件返回 HTMLVideoElement
1070
+ *
1071
+ * @returns 当前活跃的媒体播放实例
1072
+ */
1073
+ get mediaInstance() {
1074
+ return this.videoUrl ? Y(this.videoUrl) === "audio" ? this.audioInstance : this.videoTexture.image : this.audioLikeInstance;
1075
+ }
1076
+ /**
1077
+ * 更新媒体资源
1078
+ *
1079
+ * 内部方法,负责加载新的视频/音频资源,处理预载逻辑和着色器设置
1080
+ * @param videoUrl - 媒体文件URL
1081
+ * @private
1082
+ */
1083
+ async update(e, n, r) {
1084
+ if (this.videoUrl === e) return;
1085
+ this.stop(), this.freeze = !0;
1086
+ const s = Y(e) === "audio" ? this.audioInstance : this.options.videoInstance, a = this.operations(r, s);
1087
+ a.muted = !0;
1088
+ const o = this.options.preload !== !1 || Y(e) === "video" ? URL.createObjectURL(await mt.blob(e)) : e;
1089
+ if (!n()) {
1090
+ o !== e && URL.revokeObjectURL(o);
1091
+ return;
1092
+ }
1093
+ Z(() => {
1094
+ this.videoUrl = e;
1095
+ }), this.objectURL && URL.revokeObjectURL(this.objectURL), this.objectURL = o !== e ? o : void 0, a.src = o, s.setAttribute("data-src", e);
1096
+ const l = () => {
1097
+ var c;
1098
+ !n() || a.currentTime === 0 || (this.freeze = !1, a.muted = !1, this.enableNode.value = Y(e) ? 1 : 0, (c = this.removeStart) == null || c.call(this));
1099
+ };
1100
+ this.removeStart = () => s.removeEventListener("timeupdate", l), s.addEventListener("timeupdate", l);
1101
+ }
1102
+ /**
1103
+ * 播放媒体内容
1104
+ *
1105
+ * 支持多种播放模式:
1106
+ * - 播放指定视频/音频文件
1107
+ * - 仅设置时长(无媒体文件)
1108
+ * - 继续播放当前媒体
1109
+ *
1110
+ * @param videoUrl - 媒体文件URL,默认为空字符串
1111
+ * @param currentTime - 播放起始时间(秒),默认为 0
1112
+ * @param duration - 媒体总时长(秒),可选
1113
+ * @returns Promise<boolean> 播放是否成功
1114
+ *
1115
+ * @example
1116
+ * ```typescript
1117
+ * // 播放视频文件
1118
+ * await mesh.play('video.mp4', 10, 120)
1119
+ *
1120
+ * // 仅设置时长(音频跟踪)
1121
+ * await mesh.play('', 0, 60)
1122
+ *
1123
+ * // 继续播放当前媒体
1124
+ * await mesh.play()
1125
+ * ```
1126
+ */
1127
+ async play(e = "", n = 0, r) {
1128
+ var c, V;
1129
+ const s = (V = (c = this.options).getPlayback) == null ? void 0 : V.call(c);
1130
+ if (this.options.getPlayback && !(s != null && s.valid())) return !1;
1131
+ e && e !== this.videoUrl && this.stop();
1132
+ let a = this.generation;
1133
+ const o = () => a === this.generation && (!this.options.getPlayback || !!(s != null && s.valid()));
1134
+ if (e && e !== this.videoUrl && (a++, await this.update(e, o, s)), !o()) return !1;
1135
+ r && !e && (Z(() => {
1136
+ this.videoUrl = "";
1137
+ }), this.audioLikeInstance.duration = r);
1138
+ const l = this.videoUrl ? this.operations(s, this.mediaInstance) : this.audioLikeInstance;
1139
+ return (e || r) && (l.currentTime = n), l.muted = !0, await l.play(), o() ? (l.muted = !1, !0) : !1;
1140
+ }
1141
+ get mediaOperations() {
1142
+ var n, r;
1143
+ const e = (r = (n = this.options).getPlayback) == null ? void 0 : r.call(n);
1144
+ if (!(this.options.getPlayback && !(e != null && e.valid())))
1145
+ return this.videoUrl ? this.operations(e, this.mediaInstance) : this.audioLikeInstance;
1146
+ }
1147
+ stop() {
1148
+ var e;
1149
+ ++this.generation, (e = this.removeStart) == null || e.call(this), this.removeStart = void 0;
1150
+ for (const n of this.outputs.values())
1151
+ n.muted = !0, n.pause();
1152
+ this.outputs.clear(), this.audioLikeInstance.pause();
1153
+ }
1154
+ /**
1155
+ * 获取当前播放时间(毫秒)
1156
+ *
1157
+ * 将媒体实例的秒级时间转换为毫秒,提供更高精度的时间控制
1158
+ * @returns 当前播放时间戳(毫秒)
1159
+ */
1160
+ get currentTime() {
1161
+ return this.mediaInstance.currentTime * 1e3;
1162
+ }
1163
+ /**
1164
+ * 销毁视频经纪人贴片实例
1165
+ *
1166
+ * 清理所有事件监听器、DOM元素和缓存实例,释放内存资源
1167
+ *
1168
+ * @example
1169
+ * ```typescript
1170
+ * // 在组件卸载时调用
1171
+ * videoMesh.dispose()
1172
+ * ```
1173
+ */
1174
+ dispose() {
1175
+ var e;
1176
+ this.stop(), this.$removeEventListener(), this.ownsVideo && ((e = this.options.videoInstance) == null || e.remove()), this.ownsAudio && this.audioInstance.remove(), this.objectURL && URL.revokeObjectURL(this.objectURL), this.geometry.dispose(), this.videoTexture.dispose(), this.material.dispose();
1177
+ }
1178
+ }
1179
+ class bt {
1180
+ constructor(i, e, n = !1) {
1181
+ u(this, "videoAgentMesh");
1182
+ u(this, "scene", new ze());
1183
+ u(this, "camera", new Be(-240, 240, 135, -135));
1184
+ u(this, "renderer");
1185
+ u(this, "frame");
1186
+ u(this, "disposed", !1);
1187
+ u(this, "disposers", []);
1188
+ u(this, "fail", (i) => {
1189
+ this.disposed || (this.dispose(), console.error("VideoAgent renderer initialization failed", i));
1190
+ });
1191
+ u(this, "run", () => {
1192
+ this.disposed || (!(this.videoAgentMesh.paused || this.videoAgentMesh.freeze) && this.videoAgentMesh.currentTime > 1e3 && this.renderer.render(this.scene, this.camera), this.frame = requestAnimationFrame(this.run));
1193
+ });
1194
+ u(this, "dispose", () => {
1195
+ this.disposed || (this.disposed = !0, this.frame !== void 0 && cancelAnimationFrame(this.frame), this.frame = void 0, this.disposers.splice(0).forEach((i) => i()), this.videoAgentMesh.dispose(), this.renderer.dispose(), this.renderer.domElement.remove());
1196
+ });
1197
+ if (this.renderer = new Ue({ alpha: !0, forceWebGL: n }), this.videoAgentMesh = new gt(480, 270, 1, 1, e), !i) return;
1198
+ this.camera.position.set(0, 0, 10), this.camera.lookAt(0, 0, 0);
1199
+ const r = this.renderer.domElement;
1200
+ r.classList.add("VideoAgent-canvas");
1201
+ const s = xe(i, (a, o) => {
1202
+ this.renderer.setPixelRatio(window.devicePixelRatio), this.renderer.setSize(a, o, !1), r.style.width = `${a}px`, r.style.height = `${o}px`;
1203
+ });
1204
+ this.disposers.push(s), i.append(r), this.scene.add(this.videoAgentMesh), this.renderer.init().then(() => {
1205
+ if (this.disposed) return;
1206
+ const a = this.renderer.backend;
1207
+ if (!a.isWebGPUBackend && !a.isWebGLBackend)
1208
+ throw new Error("VideoAgent renderer initialized with an unsupported backend");
1209
+ this.run();
1210
+ }).catch(this.fail);
1211
+ }
1212
+ }
1213
+ const wt = ne(function(i) {
1214
+ var a, o, l;
1215
+ const e = A.useRef(null), n = T(), r = ((a = n.avatar) == null ? void 0 : a.url) && n.avatar.force === !0, s = !r && ((o = n.videoAgentScene) == null ? void 0 : o.videoAgentMesh.mediaInstance) instanceof HTMLVideoElement;
1216
+ return A.useEffect(() => {
1217
+ var f, h;
1218
+ if (!e.current) throw new Error("React 渲染异常,请稍后重试 ...");
1219
+ if (n.videoAgentScene) {
1220
+ console.warn('VideoAgentScene" 重复初始化,已被过滤');
1221
+ return;
1222
+ }
1223
+ const c = ((h = (f = n.five.renderer) == null ? void 0 : f.backend) == null ? void 0 : h.isWebGLBackend) === !0, V = new bt(e.current, { ...i.options, getPlayback: () => n.playback.capture() }, c);
1224
+ return Z(() => {
1225
+ n.videoAgentScene = V;
1226
+ }), () => {
1227
+ V.dispose(), n.videoAgentScene === V && Z(() => {
1228
+ n.videoAgentScene = void 0;
1229
+ });
1230
+ };
1231
+ }, [n]), /* @__PURE__ */ L(C, { children: [
1232
+ /* @__PURE__ */ d("div", { className: "Avatar", style: { display: r ? "block" : "none" }, children: /* @__PURE__ */ d("div", { className: "Avatar-wrapper ratio-1-1", children: /* @__PURE__ */ d("img", { className: "Avatar-img", src: (l = n.avatar) == null ? void 0 : l.url, onClick: () => {
1233
+ var c;
1234
+ return (c = i.onClick) == null ? void 0 : c.call(i);
1235
+ } }) }) }),
1236
+ /* @__PURE__ */ d("div", { className: D("VideoAgent", { hide: !s }), children: /* @__PURE__ */ d("div", { className: "VideoAgent-container", children: /* @__PURE__ */ d("div", { className: "VideoAgent-wrapper ratio-16-9", children: /* @__PURE__ */ d("div", { className: "VideoAgent-inner", ref: e, children: /* @__PURE__ */ d("div", { className: "VideoAgent-play", onClick: () => {
1237
+ var c;
1238
+ return (c = i.onClick) == null ? void 0 : c.call(i);
1239
+ } }) }) }) }) })
1240
+ ] });
1241
+ }), F = "data:audio/mpeg;base64,//uQxAAAAAAAAAAAAAAAAAAAAAAASW5mbwAAAA8AAAADAAAGhgBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVWqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr///////////////////////////////////////////8AAAA5TEFNRTMuOThyAc0AAAAAAAAAABSAJAiqQgAAgAAABobxtI73AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//uQxAACFEII9ACZ/sJZwWEoEb8w/////N//////JcxjHjf+7/v/H2PzCCFAiDtGeyBCIx7bJJ1mmEEMy6g8mm2c8nrGABB4h2Mkmn//4z/73u773R5qHHu/j/w7Kxkzh5lWRWdsifCkNAnY9Zc1HvDAhjhSHdFkHFzLmabt/AQxSg2wwzLhHIJOBnAWwVY4zrhIYhhc2kvhYDfQ4hDi2Gmh5KyFn8EcGIrHAngNgIwVIEMf5bzbAiTRoAD///8z/KVhkkWEle6IX+d/z4fvH3BShK1e5kmjkCMoxVmXhd4ROlTKo3iipasvTilY21q19ta30/v/0/idPX1v8PNxJL6ramnOVsdvMv2akO0iSYIzdJFirtzWXCZicS9vHqvSKyqm5XJBdqBwPxyfJdykhWTZ0G0ZyTZGpLKxsNwwoRhsx3tZfhwmeOBVISm3impAC/IT/8hP/EKEM1KMdVdVKM2rHV4x7HVXZvbVVKN/qq8CiV9VL9jjH/6l6qf7MBCjZmOqsAibjcP+qqqv0oxqpa/NVW286hPo1nz2L/h8+jXt//uSxCmDU2IK/ECN98KKtE5IYzNoCfbw+u9i5r8PoadUMFPKqWL4LK3T/LCraMSHGkW4bpLXR/E6LlHOVQxmslKVJ8IULktMN06N0FKCpHCoYsjC4F+Z0NVqdNFoGSTjSiyjzLdnZ2fNqTi2eHKONONKLMPMKLONKLMPQRJGlFxZRoKcJFAYEeIFiRQkUWUeYfef//Ko04soswso40UJAgMw8wosososy0EalnZyjQUGBRQGIFggOWUacWUeYmuadrZziQKKEgQsQLAhQkUJAgMQDghltLO1onp0cpkNInSFMqlYeSEJ5AHsqFdOwy1DA2sRmRJKxdKRfLhfLw5BzUxBTUUzLjk4LjJVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUxBTUUzLjk4LjJVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7ksRRA8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVU=", H = [], yt = typeof Audio > "u" ? class {
1242
+ } : Audio;
1243
+ function xt(t) {
1244
+ let i = H.find((e) => !e.realSrc || e.realSrc === F);
1245
+ return i || (i = new Pe(F), H.push(i)), i;
1246
+ }
1247
+ async function kt(t = 100, i = 2e3) {
1248
+ console.log("waitForBlankAudioGenerated, needGenerate: ", H.some((r) => !r.ended && r.src === F));
1249
+ const e = Date.now();
1250
+ let n = !1;
1251
+ for (; H.some((r) => !r.ended && r.src === F) && !n; ) {
1252
+ if (Date.now() - e > i)
1253
+ return n = !0, Promise.resolve();
1254
+ await new Promise((r) => setTimeout(r, t));
1255
+ }
1256
+ }
1257
+ function Pt(t) {
1258
+ const i = t - H.length;
1259
+ if (!(i <= 0))
1260
+ for (let e = 0; e < i; e++)
1261
+ H.push(new Pe(F));
1262
+ }
1263
+ function Et(t) {
1264
+ t.inited || (t.src && (t.inited = !0, t.removeDocumentEventListener()), t.src === F && t.play());
1265
+ }
1266
+ class Pe extends yt {
1267
+ constructor(e) {
1268
+ super(e);
1269
+ u(this, "preload", "auto");
1270
+ u(this, "realSrc", "");
1271
+ u(this, "inited", !1);
1272
+ u(this, "removeDocumentEventListener");
1273
+ this.realSrc = e ?? "", this.muted = !0, super.addEventListener("ended", () => {
1274
+ this.src === F && (this.src = "");
1275
+ });
1276
+ const n = () => Et(this);
1277
+ document.addEventListener("click", n), document.addEventListener("touchend", n), this.removeDocumentEventListener = () => {
1278
+ document.removeEventListener("click", n), document.removeEventListener("touchend", n);
1279
+ };
1280
+ }
1281
+ /**
1282
+ * 获取音频源 URL
1283
+ * @returns {string} 当前音频源 URL
1284
+ */
1285
+ get src() {
1286
+ return this.getAttribute("src") || "";
1287
+ }
1288
+ /**
1289
+ * 设置音频源 URL
1290
+ * @param paramsSrc - 音频源 URL
1291
+ */
1292
+ set src(e) {
1293
+ if (this.muted = !0, e === "") {
1294
+ this.removeAttribute("src"), this.realSrc = "", this.load();
1295
+ return;
1296
+ }
1297
+ this.setAttribute("src", e), this.realSrc = e;
1298
+ }
1299
+ }
1300
+ function Mt() {
1301
+ const t = T();
1302
+ return A.useEffect(() => {
1303
+ const i = /* @__PURE__ */ new Set(), e = (n, r) => {
1304
+ const s = t.playback.capture(), a = () => !!(s != null && s.valid());
1305
+ if (!a()) return;
1306
+ const o = xt(), l = s.bind(o);
1307
+ let c = !1;
1308
+ const V = () => {
1309
+ c || (c = !0, o.removeEventListener("canplay", h), o.removeEventListener("ended", V), l.muted = !0, l.pause(), l.src = "", f(), i.delete(V), t.setWaitingForBgMusic(!1));
1310
+ }, f = t.playback.add(V);
1311
+ i.add(V);
1312
+ const h = () => {
1313
+ o.removeEventListener("canplay", h), !(!a() || c) && (l.muted = !1, l.play().catch((p) => {
1314
+ a() && !c && (V(), t.playback.cancel(), console.error(p));
1315
+ }), t.setWaitingForBgMusic(!1));
1316
+ };
1317
+ l.muted = !0, l.src = n.data.url, l.currentTime = Math.max(0, (r - n.start) / 1e3), o.addEventListener("ended", V), t.configs.waitForBgMusicLoaded && o.readyState < 3 ? (t.setWaitingForBgMusic(!0), o.addEventListener("canplay", h)) : h();
1318
+ };
1319
+ return t.on(P.BgMusic, e), () => {
1320
+ t.off(P.BgMusic, e);
1321
+ for (const n of [...i]) n();
1322
+ };
1323
+ }, [t]), /* @__PURE__ */ d(C, {});
1324
+ }
1325
+ const Ee = "https://vr-public.realsee-cdn.cn/release/static/image/release/", St = {
1326
+ single: {
1327
+ width: 766,
1328
+ height: 60,
1329
+ frames: 20,
1330
+ hevc: "vapor/static/wave-single.140d197f4838c130b69e87dfd0705479.mov",
1331
+ vp9: "vapor/static/wave-single.eda65de390a830193fff40d1f1255555.webm",
1332
+ png: "vapor/static/wave-single.f51aade2a6e1c59211698a1a24e6135f.png"
1333
+ },
1334
+ double: {
1335
+ width: 766,
1336
+ height: 60,
1337
+ frames: 16,
1338
+ hevc: "vapor/static/wave-double.3e6d73050ee6958cc3060b107ebe5f39.mov",
1339
+ vp9: "/vapor/static/wave-double.77dfe8548ebcb3f3d336785d4fe9c7b2.webm",
1340
+ png: "/vapor/static/wave-double.ab4fe7d8a70395109ca4f759af7bd53f.png"
1341
+ },
1342
+ solid: {
1343
+ width: 1126,
1344
+ height: 90,
1345
+ frames: 48,
1346
+ hevc: "vapor/static/wave-solid.cf68912a93275d07aa6b5097ea11fdda.mov",
1347
+ vp9: "vapor/static/wave-solid.64438b63cbb346906d066bb7b8dc3e20.webm",
1348
+ png: "vapor/static/wave-solid.6969d7f3f2f44f7ac1ade30e65660cb1.png"
1349
+ },
1350
+ swap: {
1351
+ width: 2250,
1352
+ height: 180,
1353
+ frames: 41,
1354
+ hevc: "vapor/static/wave-swap.b38f22e2cf84ee21e9be35f7f56c9cfc.mov",
1355
+ vp9: "vapor/static/wave-swap.c02e4b94cf05aecf6e7a0023bc7bb90f.webm",
1356
+ png: "vapor/static/wave-swap.772ba526a7210dcc01567062c6319545.png"
1357
+ },
1358
+ expand: {
1359
+ width: 2250,
1360
+ height: 180,
1361
+ frames: 45,
1362
+ hevc: "vapor/static/wave-expand.9529956c5954740cd4c9d07d51e32822.mov",
1363
+ vp9: "vapor/static/wave-expand.a0d2a0074001cd3d4fea56818c6d3c38.webm",
1364
+ png: "vapor/static/wave-expand.62fcf27b445533e6eb1b17bab5eafa0d.png"
1365
+ }
1366
+ }, _ = typeof navigator < "u" ? navigator.userAgent : "", Tt = /(iPhone|iPad|iPod)/i.test(_), Lt = /safari/i.test(_) && !/chrome/i.test(_) && /version/i.test(_), It = /microMessenger/i.test(_), Ct = Tt || Lt, Rt = typeof MediaSource < "u" && MediaSource.isTypeSupported("video/webm; codecs=vp9");
1367
+ function Nt(t) {
1368
+ const i = X.useMemo(() => {
1369
+ const r = (t == null ? void 0 : t.appearance) ?? "solid";
1370
+ return St[r];
1371
+ }, [t == null ? void 0 : t.appearance]), e = X.useMemo(() => i.height / i.width, [i]);
1372
+ let n = null;
1373
+ return It ? n = /* @__PURE__ */ d(ae, { wave: i, prefix: t == null ? void 0 : t.staticPrefix }) : Ct ? n = /* @__PURE__ */ d(me, { format: "hevc", wave: i, prefix: t == null ? void 0 : t.staticPrefix }) : Rt ? n = /* @__PURE__ */ d(me, { format: "vp9", wave: i, prefix: t == null ? void 0 : t.staticPrefix }) : n = /* @__PURE__ */ d(ae, { wave: i, prefix: t == null ? void 0 : t.staticPrefix }), /* @__PURE__ */ d("div", { className: "vreo-wave", onClick: t == null ? void 0 : t.onClick, children: /* @__PURE__ */ d("div", { style: { position: "relative", width: "100%", paddingTop: `${e * 100}%` }, children: /* @__PURE__ */ d("div", { style: { position: "absolute", width: "100%", height: "100%", left: 0, top: 0 }, children: n }) }) });
1374
+ }
1375
+ const me = ({
1376
+ wave: t,
1377
+ format: i,
1378
+ prefix: e = Ee
1379
+ }) => {
1380
+ const n = Le(null), [r, s] = de(!1), [a, o] = de(!1), l = e + t[i];
1381
+ Ie(() => {
1382
+ s(!1);
1383
+ }, [l]);
1384
+ const c = ue(() => {
1385
+ n.current && n.current.play(), s(!0);
1386
+ }, []), V = ue(() => {
1387
+ o(!0);
1388
+ }, []);
1389
+ return a ? /* @__PURE__ */ d(ae, { wave: t, prefix: e }) : /* @__PURE__ */ d(
1390
+ "video",
1391
+ {
1392
+ style: { opacity: r ? 1 : 0 },
1393
+ preload: "auto",
1394
+ ref: n,
1395
+ width: "100%",
1396
+ height: "100%",
1397
+ playsInline: !0,
1398
+ autoPlay: !0,
1399
+ onCanPlay: c,
1400
+ onError: V,
1401
+ muted: !0,
1402
+ loop: !0,
1403
+ src: l
1404
+ }
1405
+ );
1406
+ }, ae = ({
1407
+ wave: t,
1408
+ prefix: i = Ee
1409
+ }) => {
1410
+ const e = i + t.png;
1411
+ return /* @__PURE__ */ d(
1412
+ "div",
1413
+ {
1414
+ style: {
1415
+ width: "100%",
1416
+ height: "100%",
1417
+ backgroundImage: `url(${e})`,
1418
+ backgroundSize: "100%",
1419
+ animationName: "vreo-wave-keyframes",
1420
+ animationTimingFunction: `steps(${t.frames - 1})`,
1421
+ animationDuration: `${t.frames / 25}s`,
1422
+ animationIterationCount: "infinite"
1423
+ }
1424
+ }
1425
+ );
1426
+ }, qt = ne(({ controller: t }) => {
1427
+ var i, e, n;
1428
+ return /* @__PURE__ */ d(
1429
+ "div",
1430
+ {
1431
+ className: D("vreo-panel", {
1432
+ "vreo-panel--hidden": !t.visible
1433
+ }),
1434
+ children: /* @__PURE__ */ L("div", { className: "vreo-panel-inner", children: [
1435
+ /* @__PURE__ */ d(Nt, { onClick: (i = t.configs) == null ? void 0 : i.onWaveClick, appearance: t.waveAppearance ?? "single", staticPrefix: t.configs.waveStaticPrefix }),
1436
+ /* @__PURE__ */ d(
1437
+ wt,
1438
+ {
1439
+ onClick: () => {
1440
+ var r;
1441
+ if ((r = t.configs) != null && r.onAvatarClick) {
1442
+ t.configs.onAvatarClick();
1443
+ return;
1444
+ }
1445
+ t.playing ? t.playback.cancel() : t.playback.begin(!0) && t.setPlaying(!0);
1446
+ },
1447
+ options: ((e = t.configs) == null ? void 0 : e.videoAgentMeshOptions) || {}
1448
+ }
1449
+ ),
1450
+ /* @__PURE__ */ d(ft, {}),
1451
+ (n = t.configs) == null ? void 0 : n.customPanelChildren
1452
+ ] })
1453
+ }
1454
+ );
1455
+ });
1456
+ function zt() {
1457
+ const t = T();
1458
+ return /* @__PURE__ */ L(C, { children: [
1459
+ /* @__PURE__ */ L(C, { children: [
1460
+ /* @__PURE__ */ d(it, {}),
1461
+ /* @__PURE__ */ d(tt, {}),
1462
+ /* @__PURE__ */ d(at, {}),
1463
+ /* @__PURE__ */ d(ht, {}),
1464
+ /* @__PURE__ */ d(At, {}),
1465
+ /* @__PURE__ */ d(dt, {}),
1466
+ /* @__PURE__ */ d(Vt, {}),
1467
+ /* @__PURE__ */ d(rt, {}),
1468
+ /* @__PURE__ */ d(lt, {}),
1469
+ /* @__PURE__ */ d(Mt, {})
1470
+ ] }),
1471
+ /* @__PURE__ */ d(qt, { controller: t })
1472
+ ] });
1473
+ }
1474
+ const Bt = ne(({ controller: t }) => {
1475
+ var n;
1476
+ const i = "400px", e = (() => {
1477
+ var s;
1478
+ const r = (s = t.drawerConfig) == null ? void 0 : s.height;
1479
+ return r ? typeof r == "number" ? r + "px" : r : "max-content";
1480
+ })();
1481
+ return /* @__PURE__ */ d(
1482
+ "div",
1483
+ {
1484
+ className: D("vreo-drawer", {
1485
+ "vreo-drawer-visible": t.drawerConfig && t.drawerConfig.content
1486
+ }),
1487
+ onClick: () => t.openDrawer(!1),
1488
+ children: /* @__PURE__ */ d("div", { className: "vreo-drawer-inner", style: { height: e, maxHeight: i }, children: ((n = t.drawerConfig) == null ? void 0 : n.content) || "" })
1489
+ }
1490
+ );
1491
+ });
1492
+ function Ut() {
1493
+ const t = T();
1494
+ return /* @__PURE__ */ d(Bt, { controller: t });
1495
+ }
1496
+ const Ot = ne(({ controller: t }) => /* @__PURE__ */ d(
1497
+ "div",
1498
+ {
1499
+ className: D("vreo-PopUp", {
1500
+ "vreo-PopUp-visible": t.popUp
1501
+ }),
1502
+ onClick: () => t.openPopUp(!1),
1503
+ children: /* @__PURE__ */ d("div", { className: "vreo-PopUp-inner", children: t.popUp || "" })
1504
+ }
1505
+ ));
1506
+ function $t() {
1507
+ const t = T();
1508
+ return /* @__PURE__ */ d(Ot, { controller: t });
1509
+ }
1510
+ const Wt = ({ five: t, dom: i }) => {
1511
+ const e = new q();
1512
+ t.camera.getWorldDirection(e);
1513
+ const n = t.camera.position, [r] = t.model.intersectRaycaster(new Oe(n, e)), s = t.project2d(r.point), a = window.innerWidth > 560, o = i.clientHeight;
1514
+ i.style.left = s.x + "px", i.style.top = s.y - o / 2 + "px";
1515
+ const l = i.getBoundingClientRect(), { left: c, top: V, bottom: f, right: h } = l, p = new q(c, f), w = new q(c, V), y = new q(h, V), v = new q(h, f), m = [p, v, y, w].map((b) => (b.setX(b.x / window.innerWidth * 2 - (a ? 1.25 : 1.75)), b.setY(-(b.y / window.innerHeight) * 2 + (a ? 1.35 : 1.125)), b.setZ(0.5), b.unproject(t.camera).addScaledVector(e, 0.2))), k = p.distanceTo(v) / (a ? 150 : 120);
1516
+ return { points: m, ratio: k };
1517
+ };
1518
+ function dn(t) {
1519
+ const i = A.useRef(null), e = A.useRef(null), n = A.useRef(null), r = A.useRef(we(t.five));
1520
+ return A.useEffect(() => {
1521
+ if (!e.current)
1522
+ return;
1523
+ const s = (a) => {
1524
+ if (a.data.customType !== "SpatialScenePanel")
1525
+ return;
1526
+ const o = a.data, { points: l, ratio: c } = Wt({
1527
+ five: t.five,
1528
+ dom: e.current
1529
+ }), { container: V, dispose: f, css3DObject: h, render: p } = r.current.create3DDomContainer(l, { ratio: c, autoRender: !1 }) || {};
1530
+ if (Object.assign(window, { $css3DObject: h }), !V) return;
1531
+ oe(V).render(/* @__PURE__ */ d(Dt, { ref: (b) => {
1532
+ n.current = b;
1533
+ }, data: o }));
1534
+ const y = -(Math.PI * 2) / 9;
1535
+ let v = 0;
1536
+ ke(1e3).onUpdate(({ progress: b }) => {
1537
+ const g = Math.PI / 90 * 11 * b, x = g - v;
1538
+ h == null || h.rotateY(x), v = g;
1539
+ }).onStart(() => {
1540
+ h == null || h.rotateY(y), p();
1541
+ }).onDispose(() => {
1542
+ var b;
1543
+ (b = n.current) == null || b.classList.add("show");
1544
+ }).play();
1545
+ const { start: m, end: k } = a;
1546
+ i.current = setTimeout(() => {
1547
+ var b;
1548
+ (b = n.current) == null || b.classList.add("hide"), i.current = setTimeout(() => {
1549
+ f == null || f(), i.current = null;
1550
+ }, 1500);
1551
+ }, k - m);
1552
+ };
1553
+ return Object.assign(window, { $callback: s }), t.subscribe.on(P.Custom, s), () => {
1554
+ t.subscribe.off(P.Custom, s), i.current && clearTimeout(i.current);
1555
+ };
1556
+ }, []), /* @__PURE__ */ d("div", { className: "vreo-SpatialScenePanel", ref: e });
1557
+ }
1558
+ function Ft() {
1559
+ const t = A.useRef(null), i = A.useRef(null);
1560
+ return A.useEffect(() => {
1561
+ if (!t.current) return;
1562
+ const e = () => {
1563
+ var n;
1564
+ (n = t.current) == null || n.setAttribute("class", "SpatialScenePanel-bg"), i.current = setTimeout(() => {
1565
+ var r;
1566
+ (r = t.current) == null || r.setAttribute("class", "SpatialScenePanel-bg SpatialScenePanel-bg--animation"), i.current = null;
1567
+ }, 3e3);
1568
+ };
1569
+ return t.current.addEventListener("animationend", e), () => {
1570
+ t.current && t.current.removeEventListener("animationend", e), i.current && clearTimeout(i.current);
1571
+ };
1572
+ }, []), /* @__PURE__ */ d("div", { ref: t, className: "SpatialScenePanel-bg SpatialScenePanel-bg--animation" });
1573
+ }
1574
+ const Dt = A.forwardRef(
1575
+ (t, i) => {
1576
+ var e, n, r, s;
1577
+ return /* @__PURE__ */ L("div", { className: "SpatialScenePanel", ref: i, children: [
1578
+ /* @__PURE__ */ L("div", { className: "SpatialScenePanel-show-area", children: [
1579
+ /* @__PURE__ */ d(Ft, {}),
1580
+ /* @__PURE__ */ L("div", { className: "SpatialScenePanel-header", children: [
1581
+ /* @__PURE__ */ d("div", { className: "SpatialScenePanel-title", children: (e = t.data) == null ? void 0 : e.title }),
1582
+ /* @__PURE__ */ L("div", { className: "SpatialScenePanel-temperature", children: [
1583
+ (n = t.data) == null ? void 0 : n.temperature,
1584
+ "℃"
1585
+ ] })
1586
+ ] }),
1587
+ /* @__PURE__ */ d("div", { className: "SpatialScenePanel-body", children: (s = (r = t.data) == null ? void 0 : r.stateList) == null ? void 0 : s.map((a, o) => /* @__PURE__ */ L("div", { className: `SpatialScenePanel-item index_${o}`, children: [
1588
+ /* @__PURE__ */ d("img", { className: "SpatialScenePanel-icon", src: a.icon, alt: `${a.text}` }),
1589
+ /* @__PURE__ */ d("div", { className: "SpatialScenePanel-text", children: a.text }),
1590
+ /* @__PURE__ */ d("div", { className: "SpatialScenePanel-dot" })
1591
+ ] }, `scene-${a.text}`)) })
1592
+ ] }),
1593
+ /* @__PURE__ */ d("div", { className: "SpatialScenePanel-disappear-area" })
1594
+ ] });
1595
+ }
1596
+ ), ve = 3, ge = "vreo-app-dhjskadhksahdjskahdjksa";
1597
+ function jt() {
1598
+ var t;
1599
+ return typeof location > "u" ? ve : Number(((t = location.search.match(/audio_cache=(\d+)/)) == null ? void 0 : t[1]) ?? ve);
1600
+ }
1601
+ class un extends ce {
52
1602
  /**
53
1603
  * 创建 Vreo 播放器实例
54
1604
  *
55
1605
  * @param five - Five 渲染引擎实例
56
1606
  * @param configs - 播放器配置选项
57
1607
  */
58
- function Player(five) {
59
- var _this;
60
- var configs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
61
- _classCallCheck(this, Player);
62
- _this = _callSuper(this, Player);
1608
+ constructor(e, n = {}) {
1609
+ var r;
1610
+ super();
63
1611
  /** Five 渲染引擎实例 */
1612
+ u(this, "$five");
64
1613
  /** 内部控制器 */
65
- _defineProperty(_this, "disposers", []);
66
- _defineProperty(_this, "loadGeneration", 0);
67
- _defineProperty(_this, "disposed", false);
68
- _this.$five = five;
69
- generateBlankAudio(audioCacheLength);
70
- if (!configs.container) {
71
- configs.container = configs.containter;
72
- }
73
- if (!configs.container) {
74
- var _five$getElement;
75
- var oldElement = document.getElementById(id);
76
- if (oldElement) {
77
- oldElement.remove();
78
- }
79
- var container = document.createElement('div');
80
- container.id = id;
81
- configs.container = container;
82
- var fiveCanvasDomParent = (_five$getElement = five.getElement()) === null || _five$getElement === void 0 ? void 0 : _five$getElement.parentNode;
83
- if (fiveCanvasDomParent) {
84
- fiveCanvasDomParent.append(container);
85
- } else {
86
- document.body.append(container);
87
- }
1614
+ u(this, "controller");
1615
+ u(this, "root");
1616
+ u(this, "disposers", []);
1617
+ u(this, "loadGeneration", 0);
1618
+ u(this, "disposed", !1);
1619
+ /** 播放器配置(只读) */
1620
+ u(this, "configs");
1621
+ if (this.$five = e, Pt(jt()), n.container || (n.container = n.containter), !n.container) {
1622
+ const s = document.getElementById(ge);
1623
+ s && s.remove();
1624
+ const a = document.createElement("div");
1625
+ a.id = ge, n.container = a;
1626
+ const o = (r = e.getElement()) == null ? void 0 : r.parentNode;
1627
+ o ? o.append(a) : document.body.append(a);
88
1628
  }
89
- if (!configs.container.classList.contains('vreo-app')) configs.container.classList.add('vreo-app');
90
- _this.configs = Object.freeze(Object.assign({
91
- keyframeMap: {}
92
- }, configs));
93
- _this.controller = new Controller({
94
- five: five,
95
- container: configs.container,
96
- configs: _this.configs
97
- });
98
- _this.root = createRoot(configs.container);
99
- _this.root.render(/*#__PURE__*/React.createElement(ControllerContext.Provider, {
100
- value: _this.controller
101
- }, /*#__PURE__*/React.createElement(App, null), /*#__PURE__*/React.createElement(Drawer, null), /*#__PURE__*/React.createElement(PopUp, null), _this.configs.customKeyframes && _this.configs.customKeyframes.map(function (CustomCmpt, key) {
102
- return /*#__PURE__*/React.createElement(CustomCmpt, {
103
- key: key,
104
- subscribe: {
105
- on: function on(name, callback) {
106
- return _this.on(name, callback);
1629
+ n.container.classList.contains("vreo-app") || n.container.classList.add("vreo-app"), this.configs = Object.freeze(Object.assign({ keyframeMap: {} }, n)), this.controller = new Xe({ five: e, container: n.container, configs: this.configs }), this.root = oe(n.container), this.root.render(
1630
+ /* @__PURE__ */ L(ye.Provider, { value: this.controller, children: [
1631
+ /* @__PURE__ */ d(zt, {}),
1632
+ /* @__PURE__ */ d(Ut, {}),
1633
+ /* @__PURE__ */ d($t, {}),
1634
+ this.configs.customKeyframes && this.configs.customKeyframes.map((s, a) => /* @__PURE__ */ d(
1635
+ s,
1636
+ {
1637
+ subscribe: {
1638
+ on: (o, l) => this.on(o, l),
1639
+ once: (o, l) => this.once(o, l),
1640
+ off: (o, l) => this.off(o, l)
1641
+ },
1642
+ five: e,
1643
+ getMediaManager: () => this.getMediaManager()
107
1644
  },
108
- once: function once(name, callback) {
109
- return _this.once(name, callback);
110
- },
111
- off: function off(name, callback) {
112
- return _this.off(name, callback);
113
- }
114
- },
115
- five: five,
116
- getMediaManager: function getMediaManager() {
117
- return _this.getMediaManager();
118
- }
119
- });
120
- })));
121
-
122
- // 监听播放情况:抛出触发时机
123
- _this.disposers.push(reaction(function () {
124
- return _this.controller.ended;
125
- }, function (ended) {
126
- if (ended) {
127
- _this.emit('paused', true);
1645
+ a
1646
+ ))
1647
+ ] })
1648
+ ), this.disposers.push(j(
1649
+ () => this.controller.ended,
1650
+ (s) => {
1651
+ s && this.emit("paused", !0);
128
1652
  }
129
- }));
130
- _this.disposers.push(reaction(function () {
131
- return _this.controller.playing;
132
- }, function (playing) {
133
- if (!_this.controller.ended) {
134
- _this.emit(playing ? 'playing' : 'paused');
1653
+ )), this.disposers.push(j(
1654
+ () => this.controller.playing,
1655
+ (s) => {
1656
+ this.controller.ended || this.emit(s ? "playing" : "paused");
135
1657
  }
136
- }));
137
- return _this;
1658
+ ));
1659
+ }
1660
+ getMediaManager() {
1661
+ var e;
1662
+ return (e = this.controller.playback.capture()) == null ? void 0 : e.mediaManager;
138
1663
  }
139
-
140
1664
  /**
141
1665
  * 加载剧本数据
142
1666
  *
@@ -160,310 +1684,125 @@ export var Player = /*#__PURE__*/function (_Subscribe) {
160
1684
  * await player.load(vreoUnit, 0, false, true)
161
1685
  * ```
162
1686
  */
163
- _inherits(Player, _Subscribe);
164
- return _createClass(Player, [{
165
- key: "getMediaManager",
166
- value: function getMediaManager() {
167
- var _this$controller$play;
168
- return (_this$controller$play = this.controller.playback.capture()) === null || _this$controller$play === void 0 ? void 0 : _this$controller$play.mediaManager;
169
- }
170
- /** 播放器配置(只读) */
171
- }, {
172
- key: "load",
173
- value: (function () {
174
- var _load = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(vreoUnit) {
175
- var _this2 = this;
176
- var currentTime,
177
- preload,
178
- force,
179
- userAction,
180
- generation,
181
- run,
182
- valid,
183
- _this$controller$vide,
184
- _this$configs$imageOp,
185
- _this$controller$vide2,
186
- _this$controller$vide3,
187
- panoIndexMap,
188
- panoIndexes,
189
- i,
190
- _args = arguments,
191
- _t;
192
- return _regenerator().w(function (_context) {
193
- while (1) switch (_context.p = _context.n) {
194
- case 0:
195
- currentTime = _args.length > 1 && _args[1] !== undefined ? _args[1] : 0;
196
- preload = _args.length > 2 && _args[2] !== undefined ? _args[2] : false;
197
- force = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
198
- userAction = _args.length > 4 && _args[4] !== undefined ? _args[4] : false;
199
- generation = ++this.loadGeneration;
200
- this.controller.playback.cancel();
201
- if (!(this.disposed || !this.controller.playback.begin(userAction))) {
202
- _context.n = 1;
203
- break;
204
- }
205
- return _context.a(2, false);
206
- case 1:
207
- run = this.controller.playback.capture();
208
- valid = function valid() {
209
- return run.valid();
210
- };
211
- _context.p = 2;
212
- this.controller.clear();
213
- this.controller.setLoading(true);
214
- if (force) {
215
- vreoUnit = JSON.parse(JSON.stringify(vreoUnit));
216
- }
217
- // if (!this.controller.visible) {
218
- // this.controller.setVisible(true)
219
- // // 延迟 500ms 规避跟 DOM 动画冲突
220
- // await new Promise((resolve) => {
221
- // setTimeout(() => resolve(true), 500)
222
- // })
223
- // }
224
-
225
- if (this.controller.stopInterval) {
226
- this.controller.stopInterval();
227
- this.controller.stopInterval = undefined;
228
- }
229
- this.controller.vreoUnit = vreoUnit;
230
- (_this$controller$vide = this.controller.videoAgentScene) === null || _this$controller$vide === void 0 || (_this$controller$vide = _this$controller$vide.videoAgentMesh.mediaOperations) === null || _this$controller$vide === void 0 || _this$controller$vide.pause();
231
-
232
- // 预载逻辑
233
- // 是否降低图片分辨率
234
- 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) {
235
- this.$five.imageOptions.size = this.configs.imageOptions.size;
236
- }
237
-
238
- // 预载数据中的点位
239
- if (!(preload || preload === undefined && this.configs.autoPreload)) {
240
- _context.n = 6;
241
- break;
242
- }
243
- panoIndexMap = vreoUnit.keyframes.filter(function (vreoKeyframe) {
244
- if (vreoKeyframe.type !== VreoKeyframeEnum.CameraMovement) {
245
- return false;
246
- }
247
- var data = vreoKeyframe.data;
248
- if (data.panoIndex === undefined) {
249
- return false;
250
- }
251
- return true;
252
- }).reduce(function (accu, curr) {
253
- var panoIndex = curr.data.panoIndex;
254
- if (!accu[panoIndex]) {
255
- accu[panoIndex] = true;
256
- }
257
- return accu;
258
- }, {});
259
- panoIndexes = Object.keys(panoIndexMap);
260
- i = 0;
261
- case 3:
262
- if (!(i < panoIndexes.length)) {
263
- _context.n = 6;
264
- break;
265
- }
266
- _context.n = 4;
267
- return this.$five.preloadPano(Number(panoIndexes[i]));
268
- case 4:
269
- if (!(!valid() || generation !== this.loadGeneration)) {
270
- _context.n = 5;
271
- break;
272
- }
273
- return _context.a(2, false);
274
- case 5:
275
- i++;
276
- _context.n = 3;
277
- break;
278
- case 6:
279
- // 新数据载入就绪
280
- this.emit('loaded', vreoUnit);
281
- this.controller.emit('loaded', vreoUnit);
282
- if (!(!valid() || generation !== this.loadGeneration)) {
283
- _context.n = 7;
284
- break;
285
- }
286
- return _context.a(2, false);
287
- case 7:
288
- if ((_this$controller$vide2 = this.controller.videoAgentScene) !== null && _this$controller$vide2 !== void 0 && _this$controller$vide2.videoAgentMesh.mediaOperations) {
289
- this.controller.videoAgentScene.videoAgentMesh.mediaOperations.currentTime = currentTime / 1000;
290
- }
291
- this.controller.setAvatar(vreoUnit.video.avatar);
292
- _context.n = 8;
293
- return waitForBlankAudioGenerated();
294
- case 8:
295
- if (!(!valid() || generation !== this.loadGeneration)) {
296
- _context.n = 9;
297
- break;
298
- }
299
- return _context.a(2, false);
300
- case 9:
301
- _context.n = 10;
302
- return (_this$controller$vide3 = this.controller.videoAgentScene) === null || _this$controller$vide3 === void 0 ? void 0 : _this$controller$vide3.videoAgentMesh.play(vreoUnit.video.url, currentTime / 1000, vreoUnit.video.duration);
303
- case 10:
304
- if (!(!valid() || generation !== this.loadGeneration)) {
305
- _context.n = 11;
306
- break;
307
- }
308
- return _context.a(2, false);
309
- case 11:
310
- this.controller.setEnded(false);
311
- this.play(undefined, userAction);
312
- this.controller.run(function (type, keyframe) {
313
- return _this2.emit(type, keyframe, _this2.controller.currentTime);
314
- });
315
- this.controller.setLoading(false);
316
- return _context.a(2, true);
317
- case 12:
318
- _context.p = 12;
319
- _t = _context.v;
320
- if (valid()) {
321
- _context.n = 13;
322
- break;
323
- }
324
- return _context.a(2, false);
325
- case 13:
326
- this.controller.playback.cancel();
327
- throw _t;
328
- case 14:
329
- _context.p = 14;
330
- if (generation === this.loadGeneration) this.controller.setLoading(false);
331
- return _context.f(14);
332
- case 15:
333
- return _context.a(2);
334
- }
335
- }, _callee, this, [[2, 12, 14, 15]]);
336
- }));
337
- function load(_x) {
338
- return _load.apply(this, arguments);
1687
+ async load(e, n = 0, r = !1, s = !1, a = !1) {
1688
+ var V, f, h, p, w;
1689
+ const o = ++this.loadGeneration;
1690
+ if (this.controller.playback.cancel(), this.disposed || !this.controller.playback.begin(a)) return !1;
1691
+ const l = this.controller.playback.capture(), c = () => l.valid();
1692
+ try {
1693
+ if (this.controller.clear(), this.controller.setLoading(!0), s && (e = JSON.parse(JSON.stringify(e))), this.controller.stopInterval && (this.controller.stopInterval(), this.controller.stopInterval = void 0), this.controller.vreoUnit = e, this.controller.loadTimeline(e.keyframes), (f = (V = this.controller.videoAgentScene) == null ? void 0 : V.videoAgentMesh.mediaOperations) == null || f.pause(), this.$five.imageOptions.size && ((h = this.configs.imageOptions) != null && h.size) && this.$five.imageOptions.size > this.configs.imageOptions.size && (this.$five.imageOptions.size = this.configs.imageOptions.size), r || r === void 0 && this.configs.autoPreload) {
1694
+ const y = e.keyframes.filter((m) => !(m.type !== P.CameraMovement || m.data.panoIndex === void 0)).reduce((m, k) => {
1695
+ const b = k.data.panoIndex;
1696
+ return m[b] || (m[b] = !0), m;
1697
+ }, {}), v = Object.keys(y);
1698
+ for (let m = 0; m < v.length; m++)
1699
+ if (await this.$five.preloadPano(Number(v[m])), !c() || o !== this.loadGeneration) return !1;
339
1700
  }
340
- return load;
341
- }()
342
- /**
343
- * 获取播放器是否处于暂停状态
344
- * @returns 是否暂停中
345
- */
346
- )
347
- }, {
348
- key: "paused",
349
- get: function get() {
350
- return !this.controller.playing;
351
- }
352
-
353
- /**
354
- * 开始播放
355
- *
356
- * @param currentTime - 可选的播放起始时间(毫秒)
357
- * @returns 是否开始播放成功
358
- *
359
- * @example
360
- * ```typescript
361
- * // 从当前位置播放
362
- * player.play()
363
- *
364
- * // 从指定时间开始播放
365
- * player.play(10000) // 从10秒处开始
366
- * ```
367
- */
368
- }, {
369
- key: "play",
370
- value: function play(currentTime) {
371
- var _this$controller$vide4, _this$controller$vreo;
372
- var userAction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
373
- if (this.disposed || !this.controller.playback.begin(userAction)) return false;
374
- if (this.controller.playing) return true;
375
- if (currentTime && (_this$controller$vide4 = this.controller.videoAgentScene) !== null && _this$controller$vide4 !== void 0 && _this$controller$vide4.videoAgentMesh.mediaOperations) {
376
- this.controller.videoAgentScene.videoAgentMesh.mediaOperations.currentTime = currentTime / 1000;
377
- }
378
- Object.assign(window, {
379
- $vreoController: this.controller
380
- });
381
- this.controller.setEnded(false);
382
- this.controller.setPlaying(true);
383
- (_this$controller$vreo = this.controller.vreoUnit) === null || _this$controller$vreo === void 0 || _this$controller$vreo.keyframes.forEach(function (keyframe) {
384
- if (keyframe.type === VreoKeyframeEnum.BgMusic) {
385
- keyframe.parsed = false;
386
- }
387
- });
388
- return true;
389
- }
390
-
391
- /**
392
- * 设置播放器外观
393
- * @param appearance - 外观配置对象
394
- *
395
- * @example
396
- * ```typescript
397
- * player.setAppearance({
398
- * waveStyle: 'solid'
399
- * })
400
- * ```
401
- */
402
- }, {
403
- key: "setAppearance",
404
- value: function setAppearance(appearance) {
405
- this.controller.setAppearance(appearance);
406
- }
407
-
408
- /**
409
- * 暂停播放
410
- */
411
- }, {
412
- key: "pause",
413
- value: function pause() {
414
- ++this.loadGeneration;
415
- this.controller.playback.cancel();
416
- this.controller.setLoading(false);
417
- }
418
-
419
- /**
420
- * 显示播放器界面
421
- */
422
- }, {
423
- key: "show",
424
- value: function show() {
425
- this.controller.setVisible(true);
1701
+ return this.emit("loaded", e), this.controller.emit("loaded", e), !c() || o !== this.loadGeneration || ((p = this.controller.videoAgentScene) != null && p.videoAgentMesh.mediaOperations && (this.controller.videoAgentScene.videoAgentMesh.mediaOperations.currentTime = n / 1e3), this.controller.setAvatar(e.video.avatar), await kt(), !c() || o !== this.loadGeneration) || (await ((w = this.controller.videoAgentScene) == null ? void 0 : w.videoAgentMesh.play(
1702
+ e.video.url,
1703
+ n / 1e3,
1704
+ e.video.duration
1705
+ )), !c() || o !== this.loadGeneration) ? !1 : (this.controller.setEnded(!1), this.play(void 0, a), this.controller.run((y, v) => this.emit(y, v, this.controller.currentTime)), this.controller.setLoading(!1), !0);
1706
+ } catch (y) {
1707
+ if (!c()) return !1;
1708
+ throw this.controller.playback.cancel(), y;
1709
+ } finally {
1710
+ o === this.loadGeneration && this.controller.setLoading(!1);
426
1711
  }
427
-
428
- /**
429
- * 隐藏播放器界面
430
- */
431
- }, {
432
- key: "hide",
433
- value: function hide() {
434
- this.controller.setVisible(false);
435
- }
436
-
437
- /**
438
- * 获取当前播放时间
439
- * @returns 当前播放时间(毫秒)
440
- */
441
- }, {
442
- key: "getCurrentTime",
443
- value: function getCurrentTime() {
444
- return this.controller.currentTime;
445
- }
446
-
447
- /**
448
- * 销毁播放器实例
449
- *
450
- * 清理所有资源、事件监听器和DOM元素
451
- */
452
- }, {
453
- key: "dispose",
454
- value: function dispose() {
455
- if (this.disposed) return;
456
- this.disposed = true;
457
- ++this.loadGeneration;
458
- this.disposers.forEach(function (dispose) {
459
- return dispose();
460
- });
461
- this.controller.dispose();
462
- this.root.unmount();
1712
+ }
1713
+ /**
1714
+ * 获取播放器是否处于暂停状态
1715
+ * @returns 是否暂停中
1716
+ */
1717
+ get paused() {
1718
+ return !this.controller.playing;
1719
+ }
1720
+ /**
1721
+ * 开始播放
1722
+ *
1723
+ * @param currentTime - 可选的播放起始时间(毫秒)
1724
+ * @returns 是否开始播放成功
1725
+ *
1726
+ * @example
1727
+ * ```typescript
1728
+ * // 从当前位置播放
1729
+ * player.play()
1730
+ *
1731
+ * // 从指定时间开始播放
1732
+ * player.play(10000) // 从10秒处开始
1733
+ * ```
1734
+ */
1735
+ play(e, n = !1) {
1736
+ var r, s;
1737
+ if (this.disposed || !this.controller.playback.begin(n)) return !1;
1738
+ if (e !== void 0) {
1739
+ const a = (r = this.controller.videoAgentScene) == null ? void 0 : r.videoAgentMesh.mediaOperations;
1740
+ a && (a.currentTime = e / 1e3), this.controller.seekTimeline(e);
463
1741
  }
464
- }]);
465
- }(Subscribe);
466
-
467
- // 导出自定义组件
468
- export { SpatialScenePanel } from "./custom/SpatialScenePanel/index.js";
469
- 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");
1742
+ return this.controller.playing || (typeof window < "u" && Object.assign(window, { $vreoController: this.controller }), this.controller.setEnded(!1), this.controller.setPlaying(!0), (s = this.controller.vreoUnit) == null || s.keyframes.forEach((a) => {
1743
+ a.type === P.BgMusic && this.controller.resetTimeline(P.BgMusic);
1744
+ })), !0;
1745
+ }
1746
+ /**
1747
+ * 设置播放器外观
1748
+ * @param appearance - 外观配置对象
1749
+ *
1750
+ * @example
1751
+ * ```typescript
1752
+ * player.setAppearance({
1753
+ * waveStyle: 'solid'
1754
+ * })
1755
+ * ```
1756
+ */
1757
+ setAppearance(e) {
1758
+ this.controller.setAppearance(e);
1759
+ }
1760
+ /**
1761
+ * 暂停播放
1762
+ */
1763
+ pause() {
1764
+ ++this.loadGeneration, this.controller.playback.cancel(), this.controller.setLoading(!1);
1765
+ }
1766
+ /**
1767
+ * 显示播放器界面
1768
+ */
1769
+ show() {
1770
+ this.controller.setVisible(!0);
1771
+ }
1772
+ /**
1773
+ * 隐藏播放器界面
1774
+ */
1775
+ hide() {
1776
+ this.controller.setVisible(!1);
1777
+ }
1778
+ /**
1779
+ * 获取当前播放时间
1780
+ * @returns 当前播放时间(毫秒)
1781
+ */
1782
+ getCurrentTime() {
1783
+ return this.controller.currentTime;
1784
+ }
1785
+ /**
1786
+ * 销毁播放器实例
1787
+ *
1788
+ * 清理所有资源、事件监听器和DOM元素
1789
+ */
1790
+ dispose() {
1791
+ this.disposed || (this.disposed = !0, ++this.loadGeneration, this.disposers.splice(0).forEach((e) => e()), this.controller.dispose(), queueMicrotask(() => this.root.unmount()));
1792
+ }
1793
+ }
1794
+ console.log(`
1795
+ ┏━━━┓━━━━━━━━━┏┓━━━━━━━━━━━━━
1796
+ ┃┏━┓┃━━━━━━━━━┃┃━━━━━━━━━━━━━
1797
+ ┃┗━┛┃┏━━┓┏━━┓━┃┃━┏━━┓┏━━┓┏━━┓
1798
+ ┃┏┓┏┛┃┏┓┃┗━┓┃━┃┃━┃━━┫┃┏┓┃┃┏┓┃
1799
+ ┃┃┃┗┓┃┃━┫┃┗┛┗┓┃┗┓┣━━┃┃┃━┫┃┃━┫
1800
+ ┗┛┗━┛┗━━┛┗━━━┛┗━┛┗━━┛┗━━┛┗━━┛
1801
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1802
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1803
+ `);
1804
+ export {
1805
+ un as Player,
1806
+ dn as SpatialScenePanel
1807
+ };
1808
+ //# sourceMappingURL=index.js.map