@realsee/vreo 1.0.0-alpha.1 → 1.0.0-alpha.2

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 (70) hide show
  1. package/docs/assets/search.js +1 -1
  2. package/docs/classes/Player.AudioLike.html +6 -6
  3. package/docs/classes/Player.Controller.html +12 -12
  4. package/docs/classes/Player.Player-1.html +11 -11
  5. package/docs/classes/Player.VideoAgentMesh.html +12 -12
  6. package/docs/classes/Player.VideoAgentScene.html +1 -1
  7. package/docs/enums/Player.InfoPanelStyleEnum.html +1 -1
  8. package/docs/enums/Player.InfoPanelTypeEnum.html +1 -1
  9. package/docs/enums/Player.PanoEffectEnum.html +1 -1
  10. package/docs/enums/Player.PanoTagEnum.html +1 -1
  11. package/docs/enums/Player.PanoTagStyleEnum.html +2 -2
  12. package/docs/enums/Player.VreoKeyframeEnum.html +12 -12
  13. package/docs/enums/fivePlugins.CameraMovementEffect.html +1 -1
  14. package/docs/enums/fivePlugins.Rotation.html +1 -1
  15. package/docs/interfaces/Player.CustomVreoKeyframeProps.html +1 -1
  16. package/docs/interfaces/Player.PlayerConfigs.html +4 -3
  17. package/docs/interfaces/Player.Vertex.html +1 -1
  18. package/docs/interfaces/Player.VideoAgentMeshOptions.html +3 -3
  19. package/docs/interfaces/Player.VreoKeyframe.html +1 -1
  20. package/docs/interfaces/Player.VreoUnit.html +1 -1
  21. package/docs/interfaces/Player.VreoVideo.html +1 -1
  22. package/docs/interfaces/fivePlugins.CSS3DRenderPluginExportType.html +2 -2
  23. package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +1 -1
  24. package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +2 -2
  25. package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +1 -1
  26. package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +1 -1
  27. package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +1 -1
  28. package/docs/interfaces/fivePlugins.Vector3Position.html +1 -1
  29. package/docs/interfaces/react.VreoActionCallbacks.html +6 -6
  30. package/docs/interfaces/react.VreoProviderProps.html +1 -1
  31. package/docs/modules/Player.html +16 -16
  32. package/docs/modules/custom.html +1 -1
  33. package/docs/modules/fivePlugins.html +3 -3
  34. package/docs/modules/react.html +1 -1
  35. package/lib/PlayController/index.js +1 -2
  36. package/lib/Player/App.js +8 -6
  37. package/lib/Player/Controller.d.ts +27 -8
  38. package/lib/Player/Controller.js +170 -23
  39. package/lib/Player/custom/SpatialScenePanel/index.js +2 -1
  40. package/lib/Player/hooks.js +2 -2
  41. package/lib/Player/index.d.ts +2 -1
  42. package/lib/Player/index.js +42 -29
  43. package/lib/Player/modules/ResizeObserver/index.d.ts +2 -0
  44. package/lib/Player/modules/ResizeObserver/index.js +37 -0
  45. package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +1 -1
  46. package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +44 -43
  47. package/lib/Player/modules/VideoAgent/VideoAgentScene.d.ts +3 -7
  48. package/lib/Player/modules/VideoAgent/VideoAgentScene.js +25 -34
  49. package/lib/Player/modules/VideoAgent/index.js +52 -11
  50. package/lib/Player/modules/Wave/index.d.ts +5 -0
  51. package/lib/Player/modules/Wave/index.js +51 -0
  52. package/lib/Player/modules/keyframes/InfoPanel/index.js +20 -8
  53. package/lib/Player/modules/keyframes/PanoTag/index.d.ts +1 -2
  54. package/lib/Player/modules/keyframes/PanoTag/index.js +78 -131
  55. package/lib/Player/modules/keyframes/PanoTextLabel/index.js +0 -1
  56. package/lib/Player/modules/keyframes/Prompter/index.js +5 -4
  57. package/lib/Player/typings.d.ts +9 -2
  58. package/lib/fivePlugins/CameraMovementPlugin/index.js +2 -5
  59. package/lib/react/index.d.ts +2 -2
  60. package/lib/shared-utils/AduioLike.js +8 -7
  61. package/lib/shared-utils/addResizeListener.d.ts +4 -0
  62. package/lib/shared-utils/addResizeListener.js +51 -0
  63. package/lib/shared-utils/getFileExpandedName.d.ts +1 -0
  64. package/lib/shared-utils/getFileExpandedName.js +13 -0
  65. package/lib/shared-utils/getMediaInfo.d.ts +9 -0
  66. package/lib/shared-utils/getMediaInfo.js +75 -0
  67. package/lib/shared-utils/setElementDataset.d.ts +1 -0
  68. package/lib/shared-utils/setElementDataset.js +24 -0
  69. package/lib/typings/VreoUnit.d.ts +4 -0
  70. package/package.json +1 -1
@@ -15,10 +15,32 @@ var React = _interopRequireWildcard(require("react"));
15
15
 
16
16
  var _animationFrame = require("../shared-utils/animationFrame");
17
17
 
18
+ var _setElementDataset = _interopRequireDefault(require("../shared-utils/setElementDataset"));
19
+
20
+ var _getMediaInfo = require("../shared-utils/getMediaInfo");
21
+
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
+
18
24
  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); }
19
25
 
20
26
  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; }
21
27
 
28
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
29
+
30
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
31
+
32
+ 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); }
33
+
34
+ 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; }
35
+
36
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
37
+
38
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
39
+
40
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
41
+
42
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
43
+
22
44
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
23
45
 
24
46
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
@@ -49,9 +71,13 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
49
71
 
50
72
  var _super = _createSuper(Controller);
51
73
 
52
- function Controller() {
74
+ function Controller(_ref) {
53
75
  var _this;
54
76
 
77
+ var five = _ref.five,
78
+ container = _ref.container,
79
+ configs = _ref.configs;
80
+
55
81
  _classCallCheck(this, Controller);
56
82
 
57
83
  _this = _super.call(this);
@@ -60,24 +86,119 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
60
86
 
61
87
  _defineProperty(_assertThisInitialized(_this), "ended", false);
62
88
 
89
+ _defineProperty(_assertThisInitialized(_this), "loading", false);
90
+
91
+ _defineProperty(_assertThisInitialized(_this), "waveAppearance", null);
92
+
93
+ _defineProperty(_assertThisInitialized(_this), "appearance", {
94
+ waveStyle: 'solid'
95
+ });
96
+
63
97
  _defineProperty(_assertThisInitialized(_this), "visible", false);
64
98
 
65
99
  _defineProperty(_assertThisInitialized(_this), "popUp", null);
66
100
 
67
101
  _defineProperty(_assertThisInitialized(_this), "drawerConfig", null);
68
102
 
103
+ _this.configs = configs;
104
+ _this.container = container;
105
+ _this.five = five;
106
+ _this.appSize = configs.appSize;
107
+ _this.appearance = _objectSpread(_objectSpread({}, _this.appearance), configs.appearance);
69
108
  (0, _mobx.makeObservable)(_assertThisInitialized(_this), {
70
109
  visible: _mobx.observable,
71
110
  setVisible: _mobx.action,
72
111
  playing: _mobx.observable,
73
112
  setPlaying: _mobx.action,
113
+ loading: _mobx.observable,
114
+ setLoading: _mobx.action,
74
115
  popUp: _mobx.observable.ref,
75
116
  openPopUp: _mobx.action,
76
117
  drawerConfig: _mobx.observable.ref,
77
118
  openDrawer: _mobx.action,
78
119
  ended: _mobx.observable,
79
- setEnded: _mobx.action
80
- }); // 监听播放情况:抛出触发时机
120
+ waveAppearance: _mobx.observable,
121
+ avatar: _mobx.observable,
122
+ containerSize: _mobx.observable,
123
+ setContainerSize: _mobx.action,
124
+ appearance: _mobx.observable,
125
+ setAppearance: _mobx.action,
126
+ configs: _mobx.observable.ref,
127
+ setEnded: _mobx.action,
128
+ setAvatar: _mobx.action
129
+ });
130
+ (0, _mobx.reaction)(function () {
131
+ return [_this.appearance.waveStyle, _this.loading];
132
+ }, function (_ref2) {
133
+ var _ref3 = _slicedToArray(_ref2, 2),
134
+ waveStyle = _ref3[0],
135
+ loading = _ref3[1];
136
+
137
+ if (loading === null) {
138
+ _this.waveAppearance = null;
139
+ return;
140
+ }
141
+
142
+ if (waveStyle === 'wave') {
143
+ switch (loading) {
144
+ case true:
145
+ _this.waveAppearance = 'double';
146
+ break;
147
+
148
+ case false:
149
+ _this.waveAppearance = 'solid';
150
+ break;
151
+ }
152
+ } else if (waveStyle === 'solid') {
153
+ switch (loading) {
154
+ case true:
155
+ _this.waveAppearance = 'swap';
156
+ break;
157
+
158
+ case false:
159
+ _this.waveAppearance = 'expand';
160
+ break;
161
+ }
162
+ }
163
+ }, {
164
+ fireImmediately: true
165
+ });
166
+
167
+ if (!_this.appSize) {
168
+ (0, _mobx.reaction)(function () {
169
+ return _this.containerSize;
170
+ }, function (containerSize) {
171
+ if (!containerSize) return;
172
+ var width = containerSize.width;
173
+ var height = containerSize.height;
174
+
175
+ var size = function () {
176
+ if (width <= 500) return 'S';
177
+ if (width <= 1024) return 'M';
178
+ if (width <= 2048) return 'L';
179
+ return 'XL';
180
+ }();
181
+
182
+ var orientation = function () {
183
+ if (height > width) return 'portrait';
184
+ return 'landscape';
185
+ }();
186
+
187
+ (0, _setElementDataset["default"])(_this.container, {
188
+ size: size
189
+ });
190
+ (0, _setElementDataset["default"])(_this.container, {
191
+ orientation: orientation
192
+ });
193
+ }, {
194
+ fireImmediately: true
195
+ });
196
+ } else {
197
+ (0, _setElementDataset["default"])(_this.container, {
198
+ size: _this.appSize
199
+ });
200
+ } // 监听播放情况:抛出触发时机
201
+
81
202
 
82
203
  (0, _mobx.reaction)(function () {
83
204
  return _this.ended;
@@ -97,11 +218,14 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
97
218
  }
98
219
 
99
220
  _createClass(Controller, [{
100
- key: "isAudio",
221
+ key: "agentType",
101
222
  get: function get() {
102
- var _this$videoAgentScene, _this$videoAgentScene2;
223
+ var _this$videoAgentScene, _this$avatar;
103
224
 
104
- return !((_this$videoAgentScene = this.videoAgentScene) !== null && _this$videoAgentScene !== void 0 && (_this$videoAgentScene2 = _this$videoAgentScene.videoAgentMesh.videoUrl) !== null && _this$videoAgentScene2 !== void 0 && _this$videoAgentScene2.endsWith('.mp4'));
225
+ var type = (0, _getMediaInfo.getMediaType)((_this$videoAgentScene = this.videoAgentScene) === null || _this$videoAgentScene === void 0 ? void 0 : _this$videoAgentScene.videoAgentMesh.videoUrl);
226
+ if ((_this$avatar = this.avatar) !== null && _this$avatar !== void 0 && _this$avatar.force) return 'avatar';
227
+ if (type === 'video') return 'video';
228
+ return 'none';
105
229
  }
106
230
  }, {
107
231
  key: "openPopUp",
@@ -113,6 +237,24 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
113
237
 
114
238
  this.popUp = popUp;
115
239
  }
240
+ }, {
241
+ key: "setLoading",
242
+ value: function setLoading(loading) {
243
+ this.loading = loading;
244
+ }
245
+ }, {
246
+ key: "setAvatar",
247
+ value: function setAvatar(avatar) {
248
+ this.avatar = avatar;
249
+ }
250
+ }, {
251
+ key: "setContainerSize",
252
+ value: function setContainerSize(width, height) {
253
+ this.containerSize = {
254
+ width: width,
255
+ height: height
256
+ };
257
+ }
116
258
  }, {
117
259
  key: "setVisible",
118
260
  value: function setVisible(v) {
@@ -128,6 +270,11 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
128
270
  value: function setEnded(ended) {
129
271
  this.ended = ended;
130
272
  }
273
+ }, {
274
+ key: "setAppearance",
275
+ value: function setAppearance(appearance) {
276
+ this.appearance = _objectSpread(_objectSpread({}, this.appearance), appearance);
277
+ }
131
278
  }, {
132
279
  key: "openDrawer",
133
280
  value: function openDrawer(drawerConfig) {
@@ -151,9 +298,9 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
151
298
  }, {
152
299
  key: "currentTime",
153
300
  get: function get() {
154
- var _this$videoAgentScene3;
301
+ var _this$videoAgentScene2;
155
302
 
156
- return ((_this$videoAgentScene3 = this.videoAgentScene) === null || _this$videoAgentScene3 === void 0 ? void 0 : _this$videoAgentScene3.videoAgentMesh.currentTime) || 0;
303
+ return ((_this$videoAgentScene2 = this.videoAgentScene) === null || _this$videoAgentScene2 === void 0 ? void 0 : _this$videoAgentScene2.videoAgentMesh.currentTime) || 0;
157
304
  }
158
305
  }, {
159
306
  key: "currentKeyframes",
@@ -170,11 +317,11 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
170
317
  });
171
318
  }
172
319
  }, {
173
- key: "videoInstance",
320
+ key: "mediaInstance",
174
321
  get: function get() {
175
- var _this$videoAgentScene4;
322
+ var _this$videoAgentScene3;
176
323
 
177
- return (_this$videoAgentScene4 = this.videoAgentScene) === null || _this$videoAgentScene4 === void 0 ? void 0 : _this$videoAgentScene4.videoAgentMesh.videoInstance;
324
+ return (_this$videoAgentScene3 = this.videoAgentScene) === null || _this$videoAgentScene3 === void 0 ? void 0 : _this$videoAgentScene3.videoAgentMesh.mediaInstance;
178
325
  }
179
326
  /**
180
327
  * 逐帧任务
@@ -183,31 +330,31 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
183
330
  }, {
184
331
  key: "requestAnimationFrameLoop",
185
332
  value: function requestAnimationFrameLoop(callback) {
186
- var _this$videoInstance,
187
- _this$videoInstance4,
333
+ var _this$mediaInstance,
334
+ _this$mediaInstance4,
188
335
  _this3 = this;
189
336
 
190
- if ((_this$videoInstance = this.videoInstance) !== null && _this$videoInstance !== void 0 && _this$videoInstance.ended) {
337
+ if ((_this$mediaInstance = this.mediaInstance) !== null && _this$mediaInstance !== void 0 && _this$mediaInstance.ended) {
191
338
  this.setEnded(true);
192
339
  this.setPlaying(false);
193
- this.videoInstance.pause();
340
+ this.mediaInstance.pause();
194
341
  return;
195
342
  }
196
343
 
197
344
  if (!this.playing) {
198
- var _this$videoInstance2;
345
+ var _this$mediaInstance2;
199
346
 
200
- if (!((_this$videoInstance2 = this.videoInstance) !== null && _this$videoInstance2 !== void 0 && _this$videoInstance2.paused)) {
201
- var _this$videoInstance3;
347
+ if (!((_this$mediaInstance2 = this.mediaInstance) !== null && _this$mediaInstance2 !== void 0 && _this$mediaInstance2.paused)) {
348
+ var _this$mediaInstance3;
202
349
 
203
- (_this$videoInstance3 = this.videoInstance) === null || _this$videoInstance3 === void 0 ? void 0 : _this$videoInstance3.pause();
350
+ (_this$mediaInstance3 = this.mediaInstance) === null || _this$mediaInstance3 === void 0 ? void 0 : _this$mediaInstance3.pause();
204
351
  }
205
352
 
206
353
  return;
207
354
  }
208
355
 
209
- if ((_this$videoInstance4 = this.videoInstance) !== null && _this$videoInstance4 !== void 0 && _this$videoInstance4.paused && this.playing) {
210
- this.videoInstance.play();
356
+ if ((_this$mediaInstance4 = this.mediaInstance) !== null && _this$mediaInstance4 !== void 0 && _this$mediaInstance4.paused && this.playing) {
357
+ this.mediaInstance.play();
211
358
  }
212
359
 
213
360
  var currentKeyframes = this.currentKeyframes;
@@ -249,8 +396,8 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
249
396
 
250
397
  this.vreoUnit = undefined;
251
398
 
252
- if (this.videoInstance) {
253
- this.videoInstance.currentTime = 0;
399
+ if (this.mediaInstance) {
400
+ this.mediaInstance.currentTime = 0;
254
401
  }
255
402
 
256
403
  if (this.stopInterval) {
@@ -244,7 +244,8 @@ var Panel = /*#__PURE__*/React.forwardRef(function (props, myRef) {
244
244
  className: "SpatialScenePanel-item index_".concat(index)
245
245
  }, /*#__PURE__*/React.createElement("img", {
246
246
  className: "SpatialScenePanel-icon",
247
- src: state.icon
247
+ src: state.icon,
248
+ alt: "".concat(state.text)
248
249
  }), /*#__PURE__*/React.createElement("div", {
249
250
  className: "SpatialScenePanel-text"
250
251
  }, state.text), /*#__PURE__*/React.createElement("div", {
@@ -26,11 +26,11 @@ function useController() {
26
26
  function useFiveInstance() {
27
27
  var controller = useController();
28
28
 
29
- if (!controller.$five) {
29
+ if (!controller.five) {
30
30
  throw new Error('没有找到 "five" 实例');
31
31
  }
32
32
 
33
- return controller.$five;
33
+ return controller.five;
34
34
  }
35
35
 
36
36
  function useFiveProject2d() {
@@ -1,6 +1,6 @@
1
1
  import { Five, Subscribe } from '@realsee/five';
2
2
  import { VreoKeyframeEvent, VreoUnit } from '../typings/VreoUnit';
3
- import { PlayerConfigs } from './typings';
3
+ import { Appearance, PlayerConfigs } from './typings';
4
4
  export declare class Player extends Subscribe<VreoKeyframeEvent> {
5
5
  $five: Five;
6
6
  private controller;
@@ -9,6 +9,7 @@ export declare class Player extends Subscribe<VreoKeyframeEvent> {
9
9
  load(vreoUnit: VreoUnit, currentTime?: number, preload?: boolean, force?: boolean): Promise<boolean>;
10
10
  get paused(): boolean;
11
11
  play(currentTime?: number): boolean;
12
+ setAppearance(appearance: Appearance): void;
12
13
  pause(): void;
13
14
  show(): void;
14
15
  hide(): void;
@@ -7,8 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.Player = void 0;
9
9
 
10
- var React = _interopRequireWildcard(require("react"));
11
-
12
10
  var ReactDOM = _interopRequireWildcard(require("react-dom"));
13
11
 
14
12
  var _five = require("@realsee/five");
@@ -66,8 +64,11 @@ var Player = /*#__PURE__*/function (_Subscribe) {
66
64
  _classCallCheck(this, Player);
67
65
 
68
66
  _this = _super.call(this);
69
- _this.controller = new _Controller.Controller();
70
- _this.$five = _this.controller.$five = five;
67
+ _this.$five = five;
68
+
69
+ if (!configs.container) {
70
+ configs.container = configs.containter;
71
+ }
71
72
 
72
73
  if (!configs.container) {
73
74
  var _five$getElement;
@@ -82,14 +83,18 @@ var Player = /*#__PURE__*/function (_Subscribe) {
82
83
  fiveCanvasDomParent.append(container);
83
84
  } else {
84
85
  document.body.append(container);
85
- } // document.body.append(container)
86
-
86
+ }
87
87
  }
88
88
 
89
+ if (!configs.container.classList.contains('vreo-app')) configs.container.classList.add('vreo-app');
89
90
  _this.configs = Object.freeze(Object.assign({
90
91
  keyframeMap: {}
91
92
  }, configs));
92
- _this.controller.configs = _this.configs;
93
+ _this.controller = new _Controller.Controller({
94
+ five: five,
95
+ container: configs.container,
96
+ configs: _this.configs
97
+ });
93
98
  ReactDOM.render( /*#__PURE__*/React.createElement(_Controller.ControllerContext.Provider, {
94
99
  value: _this.controller
95
100
  }, /*#__PURE__*/React.createElement(_App.App, null), /*#__PURE__*/React.createElement(_Drawer.Drawer, null), /*#__PURE__*/React.createElement(_PopUp.PopUp, null), _this.configs.customKeyframes && _this.configs.customKeyframes.map(function (CustomCmpt, key) {
@@ -131,10 +136,10 @@ var Player = /*#__PURE__*/function (_Subscribe) {
131
136
  key: "load",
132
137
  value: function () {
133
138
  var _load = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(vreoUnit) {
134
- var _this$controller$vide,
139
+ var _this$controller$medi,
135
140
  _this$configs$imageOp,
141
+ _this$controller$vide,
136
142
  _this$controller$vide2,
137
- _this$controller$vide3,
138
143
  _this2 = this;
139
144
 
140
145
  var currentTime,
@@ -151,33 +156,34 @@ var Player = /*#__PURE__*/function (_Subscribe) {
151
156
  currentTime = _args.length > 1 && _args[1] !== undefined ? _args[1] : 0;
152
157
  preload = _args.length > 2 && _args[2] !== undefined ? _args[2] : false;
153
158
  force = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
159
+ this.controller.setLoading(true);
154
160
 
155
161
  if (force) {
156
162
  vreoUnit = JSON.parse(JSON.stringify(vreoUnit));
157
163
  }
158
164
 
159
165
  if (this.controller.visible) {
160
- _context.next = 8;
166
+ _context.next = 9;
161
167
  break;
162
168
  }
163
169
 
164
170
  this.controller.setVisible(true); // 延迟 500ms 规避跟 DOM 动画冲突
165
171
 
166
- _context.next = 8;
172
+ _context.next = 9;
167
173
  return new Promise(function (resolve) {
168
174
  setTimeout(function () {
169
175
  return resolve(true);
170
176
  }, 500);
171
177
  });
172
178
 
173
- case 8:
179
+ case 9:
174
180
  if (this.controller.stopInterval) {
175
181
  this.controller.stopInterval();
176
182
  this.controller.stopInterval = undefined;
177
183
  }
178
184
 
179
185
  this.controller.vreoUnit = vreoUnit;
180
- (_this$controller$vide = this.controller.videoInstance) === null || _this$controller$vide === void 0 ? void 0 : _this$controller$vide.pause(); // 预载逻辑
186
+ (_this$controller$medi = this.controller.mediaInstance) === null || _this$controller$medi === void 0 ? void 0 : _this$controller$medi.pause(); // 预载逻辑
181
187
  // 是否降低图片分辨率
182
188
 
183
189
  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) {
@@ -186,7 +192,7 @@ var Player = /*#__PURE__*/function (_Subscribe) {
186
192
 
187
193
 
188
194
  if (!(preload || preload === undefined && this.configs.autoPreload)) {
189
- _context.next = 22;
195
+ _context.next = 23;
190
196
  break;
191
197
  }
192
198
 
@@ -214,41 +220,43 @@ var Player = /*#__PURE__*/function (_Subscribe) {
214
220
  panoIndexes = Object.keys(panoIndexMap);
215
221
  i = 0;
216
222
 
217
- case 16:
223
+ case 17:
218
224
  if (!(i < panoIndexes.length)) {
219
- _context.next = 22;
225
+ _context.next = 23;
220
226
  break;
221
227
  }
222
228
 
223
- _context.next = 19;
229
+ _context.next = 20;
224
230
  return this.$five.preloadPano(Number(panoIndexes[i]));
225
231
 
226
- case 19:
232
+ case 20:
227
233
  i++;
228
- _context.next = 16;
234
+ _context.next = 17;
229
235
  break;
230
236
 
231
- case 22:
237
+ case 23:
232
238
  // 新数据载入就绪
233
239
  this.emit('loaded', vreoUnit);
234
240
  this.controller.emit('loaded', vreoUnit);
235
241
 
236
- if ((_this$controller$vide2 = this.controller.videoAgentScene) !== null && _this$controller$vide2 !== void 0 && _this$controller$vide2.videoAgentMesh.videoInstance) {
237
- this.controller.videoAgentScene.videoAgentMesh.videoInstance.currentTime = currentTime / 1000;
242
+ if ((_this$controller$vide = this.controller.videoAgentScene) !== null && _this$controller$vide !== void 0 && _this$controller$vide.videoAgentMesh.mediaInstance) {
243
+ this.controller.videoAgentScene.videoAgentMesh.mediaInstance.currentTime = currentTime / 1000;
238
244
  }
239
245
 
240
- _context.next = 27;
241
- 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);
246
+ this.controller.setAvatar(vreoUnit.video.avatar);
247
+ _context.next = 29;
248
+ return (_this$controller$vide2 = this.controller.videoAgentScene) === null || _this$controller$vide2 === void 0 ? void 0 : _this$controller$vide2.videoAgentMesh.play(vreoUnit.video.url, currentTime / 1000, vreoUnit.video.duration);
242
249
 
243
- case 27:
250
+ case 29:
244
251
  this.controller.setEnded(false);
245
252
  this.play();
246
253
  this.controller.run(function (type, keyframe) {
247
254
  return _this2.emit(type, keyframe);
248
255
  });
256
+ this.controller.setLoading(false);
249
257
  return _context.abrupt("return", true);
250
258
 
251
- case 31:
259
+ case 34:
252
260
  case "end":
253
261
  return _context.stop();
254
262
  }
@@ -272,8 +280,8 @@ var Player = /*#__PURE__*/function (_Subscribe) {
272
280
  value: function play(currentTime) {
273
281
  if (this.controller.playing) return true;
274
282
 
275
- if (currentTime && this.controller.videoInstance) {
276
- this.controller.videoInstance.currentTime = currentTime / 1000;
283
+ if (currentTime && this.controller.mediaInstance) {
284
+ this.controller.mediaInstance.currentTime = currentTime / 1000;
277
285
  }
278
286
 
279
287
  Object.assign(window, {
@@ -282,6 +290,11 @@ var Player = /*#__PURE__*/function (_Subscribe) {
282
290
  this.controller.setPlaying(true);
283
291
  return true;
284
292
  }
293
+ }, {
294
+ key: "setAppearance",
295
+ value: function setAppearance(appearance) {
296
+ this.controller.setAppearance(appearance);
297
+ }
285
298
  }, {
286
299
  key: "pause",
287
300
  value: function pause() {
@@ -318,4 +331,4 @@ var Player = /*#__PURE__*/function (_Subscribe) {
318
331
  }(_five.Subscribe);
319
332
 
320
333
  exports.Player = Player;
321
- console.log("\n\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\n");
334
+ console.log("\n\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\n");
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function ResizeObserver(): JSX.Element;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ResizeObserver = ResizeObserver;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _addResizeListener = require("../../../shared-utils/addResizeListener");
11
+
12
+ var _hooks = require("../../hooks");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
+
16
+ function ResizeObserver() {
17
+ var ref = _react["default"].useRef(null);
18
+
19
+ var controller = (0, _hooks.useController)();
20
+
21
+ _react["default"].useEffect(function () {
22
+ if (!ref.current) return;
23
+ var resizeElement = controller.container.parentElement;
24
+ if ((0, _addResizeListener.hasResizeListener)(resizeElement)) return;
25
+ var dispose = (0, _addResizeListener.addResizeListener)(resizeElement, function (width, height) {
26
+ controller.setContainerSize(width, height);
27
+ });
28
+ return function () {
29
+ dispose();
30
+ };
31
+ }, []);
32
+
33
+ return /*#__PURE__*/_react["default"].createElement("div", {
34
+ className: "resizeObserver-element",
35
+ ref: ref
36
+ });
37
+ }
@@ -27,7 +27,7 @@ export declare class VideoAgentMesh extends THREE.Mesh {
27
27
  audioInstance: HTMLAudioElement;
28
28
  audioLikeInstance: AudioLike;
29
29
  $removeEventListener: () => void;
30
- get videoInstance(): HTMLAudioElement | AudioLike;
30
+ get mediaInstance(): HTMLAudioElement | HTMLVideoElement | AudioLike;
31
31
  /**
32
32
  *
33
33
  * @param width