@realsee/vreo 0.2.0-alpha.1 → 0.2.0-alpha.12

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 (97) hide show
  1. package/README.md +104 -17
  2. package/docs/assets/custom.css +4 -4
  3. package/docs/assets/search.js +1 -1
  4. package/docs/classes/Player.Controller.html +54 -0
  5. package/docs/classes/Player.Player-1.html +9 -9
  6. package/docs/classes/Player.VideoAgentMesh.html +142 -0
  7. package/docs/classes/Player.VideoAgentScene.html +1 -0
  8. package/docs/enums/Player.InfoPanelStyleEnum.html +1 -0
  9. package/docs/enums/Player.InfoPanelTypeEnum.html +1 -1
  10. package/docs/enums/Player.PanoEffectEnum.html +2 -2
  11. package/docs/enums/Player.PanoTagEnum.html +1 -1
  12. package/docs/enums/Player.PanoTagStyleEnum.html +7 -0
  13. package/docs/enums/Player.VreoKeyframeEnum.html +13 -13
  14. package/docs/enums/fivePlugins.CameraMovementEffect.html +1 -1
  15. package/docs/enums/fivePlugins.Rotation.html +1 -1
  16. package/docs/index.html +53 -20
  17. package/docs/interfaces/Player.CustomVreoKeyframeProps.html +1 -0
  18. package/docs/interfaces/Player.PlayerConfigs.html +3 -3
  19. package/docs/interfaces/Player.Vertex.html +1 -1
  20. package/docs/interfaces/Player.VideoAgentMeshOptions.html +1 -0
  21. package/docs/interfaces/Player.VreoKeyframe.html +1 -1
  22. package/docs/interfaces/Player.VreoUnit.html +1 -1
  23. package/docs/interfaces/Player.VreoVideo.html +1 -1
  24. package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +1 -1
  25. package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +3 -3
  26. package/docs/interfaces/fivePlugins.CameraMovementPluginParameterType.html +1 -1
  27. package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +1 -1
  28. package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +1 -1
  29. package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +1 -1
  30. package/docs/interfaces/react.VreoActionCallbacks.html +15 -7
  31. package/docs/interfaces/react.VreoProviderProps.html +1 -0
  32. package/docs/modules/Player.html +17 -15
  33. package/docs/modules/custom.html +3 -0
  34. package/docs/modules/fivePlugins.html +2 -2
  35. package/docs/modules/react.html +1 -1
  36. package/docs/modules.html +1 -1
  37. package/lib/PlayController/createHTMLAudioElement.d.ts +1 -0
  38. package/lib/PlayController/createHTMLAudioElement.js +47 -0
  39. package/lib/PlayController/index.d.ts +38 -0
  40. package/lib/PlayController/index.js +300 -0
  41. package/lib/Player/App.js +4 -3
  42. package/lib/Player/Controller.d.ts +2 -0
  43. package/lib/Player/Controller.js +14 -0
  44. package/lib/Player/custom/SpatialScenePanel/index.d.ts +22 -0
  45. package/lib/Player/custom/SpatialScenePanel/index.js +279 -0
  46. package/lib/Player/index.d.ts +2 -2
  47. package/lib/Player/index.js +102 -12
  48. package/lib/Player/modules/PopUp/index.d.ts +2 -0
  49. package/lib/Player/modules/PopUp/index.js +43 -0
  50. package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +2 -1
  51. package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +26 -20
  52. package/lib/Player/modules/VideoAgent/VideoAgentScene.d.ts +4 -1
  53. package/lib/Player/modules/VideoAgent/VideoAgentScene.js +2 -1
  54. package/lib/Player/modules/VideoAgent/index.d.ts +2 -0
  55. package/lib/Player/modules/VideoAgent/index.js +1 -1
  56. package/lib/Player/modules/keyframes/CameraMovement/index.js +41 -5
  57. package/lib/Player/modules/keyframes/InfoPanel/index.js +84 -36
  58. package/lib/Player/modules/keyframes/ModelVideo/index.js +45 -8
  59. package/lib/Player/modules/keyframes/PanoTag/index.js +19 -6
  60. package/lib/Player/modules/keyframes/PanoTextLabel/index.js +4 -12
  61. package/lib/Player/modules/keyframes/Prompter/index.js +4 -18
  62. package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +30 -18
  63. package/lib/Player/typings.d.ts +15 -2
  64. package/lib/fivePlugins/CameraMovementPlugin/index.js +104 -90
  65. package/lib/fivePlugins/CameraMovementPlugin/typings.d.ts +1 -0
  66. package/lib/react/index.d.ts +12 -4
  67. package/lib/react/index.js +3 -3
  68. package/lib/shared-utils/createTransMatrix.d.ts +1 -0
  69. package/lib/shared-utils/createTransMatrix.js +43 -0
  70. package/lib/typings/VreoUnit.d.ts +32 -6
  71. package/lib/typings/VreoUnit.js +26 -6
  72. package/package.json +6 -6
  73. package/resources/PlayController/createHTMLAudioElement.ts +53 -0
  74. package/resources/PlayController/index.ts +167 -0
  75. package/resources/Player/App.tsx +3 -1
  76. package/resources/Player/Controller.ts +12 -0
  77. package/resources/Player/custom/SpatialScenePanel/index.tsx +264 -0
  78. package/resources/Player/index.tsx +59 -4
  79. package/resources/Player/modules/PopUp/index.tsx +26 -0
  80. package/resources/Player/modules/VideoAgent/VideoAgentMesh.ts +7 -6
  81. package/resources/Player/modules/VideoAgent/VideoAgentScene.ts +2 -2
  82. package/resources/Player/modules/VideoAgent/index.tsx +3 -2
  83. package/resources/Player/modules/keyframes/CameraMovement/index.tsx +7 -3
  84. package/resources/Player/modules/keyframes/InfoPanel/index.tsx +90 -23
  85. package/resources/Player/modules/keyframes/ModelVideo/index.tsx +36 -3
  86. package/resources/Player/modules/keyframes/PanoTag/index.tsx +31 -12
  87. package/resources/Player/modules/keyframes/PanoTextLabel/index.tsx +2 -2
  88. package/resources/Player/modules/keyframes/Prompter/index.tsx +5 -15
  89. package/resources/Player/modules/keyframes/UpdateVRPanorama/index.tsx +25 -16
  90. package/resources/Player/typings.ts +17 -2
  91. package/resources/fivePlugins/CameraMovementPlugin/index.ts +59 -48
  92. package/resources/fivePlugins/CameraMovementPlugin/typings.ts +2 -1
  93. package/resources/react/index.tsx +14 -5
  94. package/resources/shared-utils/createTransMatrix.ts +12 -0
  95. package/resources/typings/VreoUnit.ts +42 -7
  96. package/stylesheets/custom/SpatialScenePanel.css +309 -0
  97. package/stylesheets/default.css +116 -10
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createTransMatrix = createTransMatrix;
9
+
10
+ var THREE = _interopRequireWildcard(require("three"));
11
+
12
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
+
14
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
+
16
+ function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
17
+
18
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
19
+
20
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
21
+
22
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
23
+
24
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
25
+
26
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
27
+
28
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
29
+
30
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
31
+
32
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
33
+
34
+ function createTransMatrix(arr1) {
35
+ var matrix4 = new THREE.Matrix4();
36
+ matrix4.fromArray(arr1);
37
+ return function (arr2) {
38
+ var vector3 = _construct(THREE.Vector3, _toConsumableArray(arr2));
39
+
40
+ vector3.applyMatrix4(matrix4);
41
+ return vector3.toArray();
42
+ };
43
+ }
@@ -61,7 +61,7 @@ export declare type VreoKeyframeConfigMap = {
61
61
  * 剧本关键帧
62
62
  */
63
63
  export interface VreoKeyframe {
64
- uuid: string;
64
+ uuid?: string;
65
65
  type: VreoKeyframeEnum;
66
66
  start: number;
67
67
  end: number;
@@ -95,14 +95,16 @@ export declare type VreoKeyframeEvent = {
95
95
  [key in VreoKeyframeEnum]: (keyframe: VreoKeyframe) => void;
96
96
  } & {
97
97
  loaded: (vreoUnit: VreoUnit) => void;
98
- paused: () => void;
98
+ paused: (ended?: boolean) => void;
99
99
  playing: () => void;
100
+ unknownKeyframeType: (keyframe: Record<string, any>) => void;
100
101
  };
101
102
  /**
102
103
  * 相机运动
103
104
  */
104
105
  export declare type CameraMovementData = {
105
- effect: CameraMovementEffect;
106
+ effect?: CameraMovementEffect;
107
+ transEffect?: "fly" | "fade" | "instant";
106
108
  mode: Mode;
107
109
  panoIndex: number;
108
110
  loop?: boolean;
@@ -145,9 +147,13 @@ export interface Vertex {
145
147
  z: number;
146
148
  }
147
149
  /**
148
- * 四个顶点元组
150
+ * 矩形顶点
149
151
  */
150
152
  export declare type QuadrangleVertexs = [Vertex, Vertex, Vertex, Vertex];
153
+ /**
154
+ * 顶点数组
155
+ */
156
+ export declare type Vertexs = Vertex[];
151
157
  /**
152
158
  * 视频广告
153
159
  */
@@ -163,7 +169,8 @@ export declare type ModelVideoData = {
163
169
  /**
164
170
  * 视频映射在模型中的顶点
165
171
  */
166
- vertexs: QuadrangleVertexs;
172
+ vertexs: QuadrangleVertexs | Vertexs;
173
+ matrixWorld?: number[];
167
174
  };
168
175
  /**
169
176
  * 全景文本标签
@@ -180,8 +187,22 @@ export declare enum PanoTagEnum {
180
187
  Text = "Text",
181
188
  Image = "Image"
182
189
  }
190
+ /**
191
+ * 标签样式种类
192
+ */
193
+ export declare enum PanoTagStyleEnum {
194
+ /**
195
+ * 生长动画:默认值
196
+ */
197
+ Growth = "Growth",
198
+ /**
199
+ * 展开动画
200
+ */
201
+ Expand = "Expand"
202
+ }
183
203
  export declare type PanoTagData = {
184
204
  type: PanoTagEnum;
205
+ style: PanoTagStyleEnum;
185
206
  text: string;
186
207
  vertex: Vertex;
187
208
  imgUrl?: string;
@@ -209,13 +230,18 @@ export declare enum InfoPanelTypeEnum {
209
230
  Image = "Image",
210
231
  Video = "Video"
211
232
  }
233
+ export declare enum InfoPanelStyleEnum {
234
+ Drawer = "Drawer",
235
+ PopUp = "PopUp"
236
+ }
212
237
  /**
213
238
  * 信息面板
214
239
  */
215
240
  export declare type InfoPanelData = {
216
241
  type: InfoPanelTypeEnum;
242
+ style?: InfoPanelStyleEnum;
217
243
  url: string;
218
- tilte?: string;
244
+ title?: string;
219
245
  subTitle?: string;
220
246
  };
221
247
  /**
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.VreoKeyframeEnum = exports.PanoTagEnum = exports.PanoEffectEnum = exports.InfoPanelTypeEnum = void 0;
6
+ exports.VreoKeyframeEnum = exports.PanoTagStyleEnum = exports.PanoTagEnum = exports.PanoEffectEnum = exports.InfoPanelTypeEnum = exports.InfoPanelStyleEnum = void 0;
7
7
  var VreoKeyframeEnum;
8
8
  /**
9
9
  * 支持自定义剧本关键帧配置项
@@ -30,6 +30,10 @@ exports.VreoKeyframeEnum = VreoKeyframeEnum;
30
30
  * 全景标签枚举
31
31
  */
32
32
  var PanoTagEnum;
33
+ /**
34
+ * 标签样式种类
35
+ */
36
+
33
37
  exports.PanoTagEnum = PanoTagEnum;
34
38
 
35
39
  (function (PanoTagEnum) {
@@ -37,6 +41,14 @@ exports.PanoTagEnum = PanoTagEnum;
37
41
  PanoTagEnum["Image"] = "Image";
38
42
  })(PanoTagEnum || (exports.PanoTagEnum = PanoTagEnum = {}));
39
43
 
44
+ var PanoTagStyleEnum;
45
+ exports.PanoTagStyleEnum = PanoTagStyleEnum;
46
+
47
+ (function (PanoTagStyleEnum) {
48
+ PanoTagStyleEnum["Growth"] = "Growth";
49
+ PanoTagStyleEnum["Expand"] = "Expand";
50
+ })(PanoTagStyleEnum || (exports.PanoTagStyleEnum = PanoTagStyleEnum = {}));
51
+
40
52
  /**
41
53
  * 全景特效枚举
42
54
  */
@@ -55,13 +67,21 @@ exports.PanoEffectEnum = PanoEffectEnum;
55
67
  * 信息面板类型枚举
56
68
  */
57
69
  var InfoPanelTypeEnum;
58
- /**
59
- * 信息面板
60
- */
61
-
62
70
  exports.InfoPanelTypeEnum = InfoPanelTypeEnum;
63
71
 
64
72
  (function (InfoPanelTypeEnum) {
65
73
  InfoPanelTypeEnum["Image"] = "Image";
66
74
  InfoPanelTypeEnum["Video"] = "Video";
67
- })(InfoPanelTypeEnum || (exports.InfoPanelTypeEnum = InfoPanelTypeEnum = {}));
75
+ })(InfoPanelTypeEnum || (exports.InfoPanelTypeEnum = InfoPanelTypeEnum = {}));
76
+
77
+ var InfoPanelStyleEnum;
78
+ /**
79
+ * 信息面板
80
+ */
81
+
82
+ exports.InfoPanelStyleEnum = InfoPanelStyleEnum;
83
+
84
+ (function (InfoPanelStyleEnum) {
85
+ InfoPanelStyleEnum["Drawer"] = "Drawer";
86
+ InfoPanelStyleEnum["PopUp"] = "PopUp";
87
+ })(InfoPanelStyleEnum || (exports.InfoPanelStyleEnum = InfoPanelStyleEnum = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@realsee/vreo",
3
- "version": "0.2.0-alpha.1",
3
+ "version": "0.2.0-alpha.12",
4
4
  "description": "Vreo (VR Video 缩写) 是基于如视三维渲染引擎 Five 和 用户界面构建库 React 实现的如视 3D 空间剧本播放器。",
5
5
  "keywords": [
6
6
  "realsee",
@@ -18,7 +18,7 @@
18
18
  "LICENSE"
19
19
  ],
20
20
  "scripts": {
21
- "dev": "vite --port=3088",
21
+ "dev": "vite --port=3088 --host 0.0.0.0",
22
22
  "build": "tsc && vite build",
23
23
  "preview": "vite preview",
24
24
  "docs": "npx typedoc",
@@ -26,8 +26,8 @@
26
26
  },
27
27
  "peerDependencies": {
28
28
  "@realsee/five": "^5.0.0-alpha.103",
29
- "react": "^16.0.0",
30
- "react-dom": "^16.0.0"
29
+ "react": "^17.0.0",
30
+ "react-dom": "^17.0.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@babel/cli": "^7.16.0",
@@ -35,6 +35,7 @@
35
35
  "@babel/preset-env": "^7.16.4",
36
36
  "@babel/preset-react": "^7.16.0",
37
37
  "@babel/preset-typescript": "^7.16.0",
38
+ "@realsee/dnalogel": "^0.1.7-alpha.10",
38
39
  "@realsee/five": "^5.0.0-alpha.103",
39
40
  "@types/offscreencanvas": "^2019.6.4",
40
41
  "@types/react": "^17.0.37",
@@ -53,7 +54,6 @@
53
54
  "@tweenjs/tween.js": "18.6.4",
54
55
  "classnames": "^2.3.1",
55
56
  "mobx": "^6.3.7",
56
- "mobx-react": "^7.2.1",
57
- "react-transition-group": "^4.4.2"
57
+ "mobx-react": "^7.2.1"
58
58
  }
59
59
  }
@@ -0,0 +1,53 @@
1
+
2
+ const BLANK_AUDIO = ''
3
+ + 'data:audio/mpeg;base64,'
4
+ + '//uQxAAAAAAAAAAAAAAAAAAAAAAASW5mbwAAAA8AAAADAAAGhgBVVVVVVVVVVVVVVVVVVVVVVVV'
5
+ + 'VVVVVVVVVVVVVVVVVVVWqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr///////////'
6
+ + '////////////////////////////////8AAAA5TEFNRTMuOThyAc0AAAAAAAAAABSAJAiqQgAAg'
7
+ + 'AAABobxtI73AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
8
+ + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
9
+ + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
10
+ + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
11
+ + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//uQxAACFEII9ACZ/sJZwWEoEb8w/////N//////Jcxj'
12
+ + 'Hjf+7/v/H2PzCCFAiDtGeyBCIx7bJJ1mmEEMy6g8mm2c8nrGABB4h2Mkmn//4z/73u773R5qHHu'
13
+ + '/j/w7Kxkzh5lWRWdsifCkNAnY9Zc1HvDAhjhSHdFkHFzLmabt/AQxSg2wwzLhHIJOBnAWwVY4zr'
14
+ + 'hIYhhc2kvhYDfQ4hDi2Gmh5KyFn8EcGIrHAngNgIwVIEMf5bzbAiTRoAD///8z/KVhkkWEle6IX'
15
+ + '+d/z4fvH3BShK1e5kmjkCMoxVmXhd4ROlTKo3iipasvTilY21q19ta30/v/0/idPX1v8PNxJL6r'
16
+ + 'amnOVsdvMv2akO0iSYIzdJFirtzWXCZicS9vHqvSKyqm5XJBdqBwPxyfJdykhWTZ0G0ZyTZGpLK'
17
+ + 'xsNwwoRhsx3tZfhwmeOBVISm3impAC/IT/8hP/EKEM1KMdVdVKM2rHV4x7HVXZvbVVKN/qq8CiV'
18
+ + '9VL9jjH/6l6qf7MBCjZmOqsAibjcP+qqqv0oxqpa/NVW286hPo1nz2L/h8+jXt//uSxCmDU2IK/'
19
+ + 'ECN98KKtE5IYzNoCfbw+u9i5r8PoadUMFPKqWL4LK3T/LCraMSHGkW4bpLXR/E6LlHOVQxmslKV'
20
+ + 'J8IULktMN06N0FKCpHCoYsjC4F+Z0NVqdNFoGSTjSiyjzLdnZ2fNqTi2eHKONONKLMPMKLONKLM'
21
+ + 'PQRJGlFxZRoKcJFAYEeIFiRQkUWUeYfef//Ko04soswso40UJAgMw8wosososy0EalnZyjQUGBR'
22
+ + 'QGIFggOWUacWUeYmuadrZziQKKEgQsQLAhQkUJAgMQDghltLO1onp0cpkNInSFMqlYeSEJ5AHsq'
23
+ + 'FdOwy1DA2sRmRJKxdKRfLhfLw5BzUxBTUUzLjk4LjJVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV'
24
+ + 'VVVVVVVVVVVVVVVVVUxBTUUzLjk4LjJVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV'
25
+ + 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV'
26
+ + 'VVVVVVVVVVVVVVVVVVVf/7ksRRA8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVV'
27
+ + 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV'
28
+ + 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV'
29
+ + 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV'
30
+ + 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV'
31
+ + 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV'
32
+ + 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV'
33
+ + 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVU=';
34
+
35
+
36
+ export function createHTMLAudioElement(): HTMLAudioElement {
37
+ const ndAudio = document.querySelector('#vreo-playController-audio')
38
+ if (ndAudio) {
39
+ return ndAudio as HTMLAudioElement
40
+ }
41
+
42
+ const audio = document.createElement('audio')
43
+ audio.style.display = 'none'
44
+ audio.setAttribute('id', 'vreo-playController-audio')
45
+ audio.controls = false
46
+ document.body.appendChild(audio)
47
+ audio.src = BLANK_AUDIO
48
+
49
+ // 触发一次播放
50
+ Promise.resolve(async () => await audio.play())
51
+
52
+ return audio
53
+ }
@@ -0,0 +1,167 @@
1
+ import { Subscribe } from '@realsee/five'
2
+ import { requestAnimationFrameInterval } from '../shared-utils/animationFrame'
3
+ import { VreoKeyframe, VreoKeyframeEvent, VreoUnit } from '../typings/VreoUnit'
4
+ import { createHTMLAudioElement } from './createHTMLAudioElement'
5
+
6
+ export interface PlayControllerConfig {
7
+ audio?: HTMLAudioElement
8
+ }
9
+
10
+ const closures: Record<string, any> = {}
11
+
12
+ export class PlayController extends Subscribe<VreoKeyframeEvent> {
13
+
14
+ vreoUnit?: VreoUnit
15
+
16
+ config: PlayControllerConfig = {}
17
+ stopInterval: () => void
18
+
19
+ get paused() {
20
+ return this.audioInstance.paused
21
+ }
22
+
23
+ get audioInstance() {
24
+ return this.config.audio!
25
+ }
26
+
27
+ get currentTime() {
28
+ return this.audioInstance.currentTime * 1000
29
+ }
30
+
31
+ get currentKeyframes() {
32
+ if (!this.vreoUnit) return []
33
+ const keyframes = this.vreoUnit.keyframes
34
+ // 没有被解析过且开始时间低于当前时间戳 100ms
35
+ return keyframes.filter((keyframe: VreoKeyframe) => {
36
+ if (keyframe.parsed) return false
37
+ const dur = this.currentTime - keyframe.start
38
+ return dur <= 100 && dur >= 0
39
+ })
40
+ }
41
+
42
+ /**
43
+ * 音频时长 不一定能获取得到,建议以 VreoUnit 配置的时长为准。
44
+ */
45
+ get duration() {
46
+ return this.audioInstance.duration * 1000
47
+ }
48
+
49
+ constructor(config: PlayControllerConfig = {}) {
50
+ super()
51
+
52
+ if (!config.audio) {
53
+ config.audio = createHTMLAudioElement()
54
+ }
55
+
56
+ this.config = Object.assign(this.config, config)
57
+
58
+ closures.onPlaying = () => this.emit('playing')
59
+ closures.onPaused = () => this.emit('paused')
60
+ closures.onEnded = () => this.emit('paused', true)
61
+
62
+ this.audioInstance.addEventListener('play', closures.onPlaying)
63
+ this.audioInstance.addEventListener('pause', closures.onPaused)
64
+ this.audioInstance.addEventListener('ended', closures.onEnded)
65
+
66
+ this.stopInterval = requestAnimationFrameInterval(() => {
67
+ if (this.audioInstance.paused) {
68
+ return
69
+ }
70
+
71
+ if (!this.vreoUnit) {
72
+ return
73
+ }
74
+
75
+ const keyframes = this.vreoUnit.keyframes
76
+ const currentTime = this.currentTime
77
+ // 没有被解析过且开始时间低于当前时间戳 100ms
78
+ const currentKeyframes = keyframes.filter((keyframe: VreoKeyframe) => {
79
+ if (keyframe.parsed) return false
80
+
81
+ const dur = currentTime - keyframe.start
82
+ return dur <= 60 && dur >= 0
83
+ })
84
+
85
+ currentKeyframes.forEach((keyframe) => {
86
+ if (keyframe.parsed) return
87
+ keyframe.parsed = true
88
+ this.emit(keyframe.type, keyframe)
89
+ })
90
+ })
91
+
92
+ }
93
+
94
+
95
+
96
+ /**
97
+ * 载入数据
98
+ */
99
+ async load(vreoUnit: VreoUnit): Promise<boolean> {
100
+ this.vreoUnit = vreoUnit
101
+
102
+ await this.pause()
103
+ return await new Promise((resolve, reject) => {
104
+ if (vreoUnit.video.url === this.audioInstance.src) {
105
+ return resolve(true)
106
+ }
107
+
108
+ this.audioInstance.src = vreoUnit.video.url
109
+ const canplaythrough = () => {
110
+ resolve(true)
111
+ this.audioInstance.removeEventListener('canplaythrough', canplaythrough)
112
+ }
113
+ const error = (err: any) => {
114
+ reject(err)
115
+ this.audioInstance.removeEventListener('error', error)
116
+ }
117
+ this.audioInstance.addEventListener('canplaythrough', canplaythrough)
118
+ this.audioInstance.addEventListener('error', error)
119
+ })
120
+ }
121
+
122
+ /**
123
+ * 播放
124
+ */
125
+ async play() {
126
+ closures.playPromise = this.audioInstance.play()
127
+ }
128
+
129
+ /**
130
+ * 暂停
131
+ */
132
+ async pause() {
133
+ if (closures.playPromise) {
134
+ await closures.playPromise
135
+ }
136
+ this.audioInstance.pause()
137
+ }
138
+
139
+ /**
140
+ * 销毁资源
141
+ * @notice 一旦销毁,创建的实例将不可用:需重新创建实例。
142
+ *
143
+ * @deprecated **慎重执行**
144
+ */
145
+ dispose() {
146
+ // 清理事件监听
147
+ this.audioInstance.removeEventListener('play', closures.onPlaying)
148
+ this.audioInstance.removeEventListener('pasue', closures.onPaused)
149
+ this.audioInstance.removeEventListener('ended', closures.onEnded)
150
+ if (this.stopInterval) {
151
+ this.stopInterval()
152
+ }
153
+ }
154
+ }
155
+
156
+ console.log(`
157
+
158
+ ┏━━━┓━━━━━━━━━┏┓━━━━━━━━━━━━━
159
+ ┃┏━┓┃━━━━━━━━━┃┃━━━━━━━━━━━━━
160
+ ┃┗━┛┃┏━━┓┏━━┓━┃┃━┏━━┓┏━━┓┏━━┓
161
+ ┃┏┓┏┛┃┏┓┃┗━┓┃━┃┃━┃━━┫┃┏┓┃┃┏┓┃
162
+ ┃┃┃┗┓┃┃━┫┃┗┛┗┓┃┗┓┣━━┃┃┃━┫┃┃━┫
163
+ ┗┛┗━┛┗━━┛┗━━━┛┗━┛┗━━┛┗━━┛┗━━┛
164
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
165
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
166
+
167
+ `)
@@ -2,7 +2,7 @@ import * as React from 'react'
2
2
  import classNames from 'classnames'
3
3
  import { observer } from 'mobx-react'
4
4
  import { Controller } from './Controller'
5
- import { useController } from './hooks'
5
+ import { useController, useFiveInstance } from './hooks'
6
6
  import { CameraMovement } from './modules/keyframes/CameraMovement'
7
7
  import { InfoPanel } from './modules/keyframes/InfoPanel'
8
8
  import { ModelVideo } from './modules/keyframes/ModelVideo'
@@ -16,6 +16,7 @@ import { VideoAgent } from './modules/VideoAgent'
16
16
  import { BgMusic } from './modules/keyframes/BgMusic'
17
17
 
18
18
  const AppView = observer(({ controller }: { controller: Controller }) => {
19
+
19
20
  return (
20
21
  <div
21
22
  className={classNames('vreo-panel', {
@@ -34,6 +35,7 @@ const AppView = observer(({ controller }: { controller: Controller }) => {
34
35
  controller.setPlaying(true)
35
36
  }
36
37
  }}
38
+ options={controller.configs?.videoAgentMeshOptions || {}}
37
39
  />
38
40
  <Prompter />
39
41
  {controller.configs?.customPanelChildren}
@@ -24,6 +24,16 @@ export class Controller extends Subscribe<VreoKeyframeEvent> {
24
24
  return !this.videoAgentScene?.videoAgentMesh.videoUrl?.endsWith('.mp4')
25
25
  }
26
26
 
27
+ popUp: string | JSX.Element | null = null
28
+
29
+ openPopUp(popUp: string | JSX.Element | false) {
30
+ if (!popUp) {
31
+ this.popUp = null
32
+ return
33
+ }
34
+ this.popUp = popUp
35
+ }
36
+
27
37
  drawerConfig: {
28
38
  content: string | JSX.Element
29
39
  height?: number | string
@@ -57,6 +67,8 @@ export class Controller extends Subscribe<VreoKeyframeEvent> {
57
67
  setVisible: action,
58
68
  playing: observable,
59
69
  setPlaying: action,
70
+ popUp: observable.ref,
71
+ openPopUp: action,
60
72
  drawerConfig: observable.ref,
61
73
  openDrawer: action,
62
74
  })