@realsee/vreo 0.2.0-alpha.9 → 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 (156) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +16 -5
  3. package/docs/assets/highlight.css +1 -1
  4. package/docs/assets/main.js +2 -2
  5. package/docs/assets/search.js +1 -1
  6. package/docs/assets/style.css +28 -2
  7. package/docs/classes/Player.AudioLike.html +52 -0
  8. package/docs/classes/Player.Controller.html +13 -13
  9. package/docs/classes/Player.Player-1.html +11 -11
  10. package/docs/classes/Player.VideoAgentMesh.html +53 -53
  11. package/docs/classes/Player.VideoAgentScene.html +1 -1
  12. package/docs/demo/assets/AppReact.d0ee843a.js +1 -0
  13. package/docs/demo/assets/default.63925584.js +3984 -0
  14. package/docs/demo/assets/default.f3f3ca8c.css +1 -0
  15. package/docs/demo/assets/dynamic.76506c2c.js +1 -0
  16. package/docs/demo/assets/examples.3d8323db.js +25 -0
  17. package/docs/demo/assets/examples.dac4a6fe.css +1 -0
  18. package/docs/demo/assets/index.7e31122c.js +1 -0
  19. package/docs/demo/assets/index.9331038f.css +1 -0
  20. package/docs/demo/assets/main.79b11b9d.js +1 -0
  21. package/docs/demo/assets/react.2ee8565f.css +1 -0
  22. package/docs/demo/assets/react.c1c07c14.js +25 -0
  23. package/docs/demo/assets/znRoyv06SZQeqA7m.0057e8ae.js +1 -0
  24. package/docs/demo/examples.html +17 -0
  25. package/docs/demo/index-react-dynamic.html +20 -0
  26. package/docs/demo/index-react.html +20 -0
  27. package/docs/demo/index.html +19 -0
  28. package/docs/enums/Player.InfoPanelStyleEnum.html +1 -1
  29. package/docs/enums/Player.InfoPanelTypeEnum.html +2 -2
  30. package/docs/enums/Player.PanoEffectEnum.html +2 -2
  31. package/docs/enums/Player.PanoTagEnum.html +2 -2
  32. package/docs/enums/Player.PanoTagStyleEnum.html +7 -0
  33. package/docs/enums/Player.VreoKeyframeEnum.html +12 -12
  34. package/docs/enums/fivePlugins.CameraMovementEffect.html +1 -1
  35. package/docs/enums/fivePlugins.Rotation.html +1 -1
  36. package/docs/index.html +13 -6
  37. package/docs/interfaces/Player.CustomVreoKeyframeProps.html +1 -1
  38. package/docs/interfaces/Player.PlayerConfigs.html +4 -3
  39. package/docs/interfaces/Player.Vertex.html +2 -2
  40. package/docs/interfaces/Player.VideoAgentMeshOptions.html +8 -1
  41. package/docs/interfaces/Player.VreoKeyframe.html +2 -2
  42. package/docs/interfaces/Player.VreoUnit.html +2 -2
  43. package/docs/interfaces/Player.VreoVideo.html +2 -2
  44. package/docs/interfaces/fivePlugins.CSS3DRenderPluginExportType.html +4 -0
  45. package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +1 -1
  46. package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +2 -2
  47. package/docs/interfaces/fivePlugins.CameraMovementPluginParameterType.html +1 -1
  48. package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +1 -1
  49. package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +1 -1
  50. package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +1 -1
  51. package/docs/interfaces/fivePlugins.Vector3Position.html +3 -0
  52. package/docs/interfaces/react.VreoActionCallbacks.html +15 -7
  53. package/docs/interfaces/react.VreoProviderProps.html +1 -1
  54. package/docs/modules/Player.html +21 -15
  55. package/docs/modules/custom.html +1 -1
  56. package/docs/modules/fivePlugins.html +5 -2
  57. package/docs/modules/react.html +1 -1
  58. package/docs/modules.html +1 -1
  59. package/lib/PlayController/index.js +4 -5
  60. package/lib/Player/App.js +9 -7
  61. package/lib/Player/Controller.d.ts +29 -8
  62. package/lib/Player/Controller.js +193 -27
  63. package/lib/Player/custom/SpatialScenePanel/index.js +5 -4
  64. package/lib/Player/hooks.js +2 -2
  65. package/lib/Player/index.d.ts +5 -3
  66. package/lib/Player/index.js +97 -53
  67. package/lib/Player/modules/Drawer/index.js +1 -1
  68. package/lib/Player/modules/PopUp/index.js +1 -1
  69. package/lib/Player/modules/ResizeObserver/index.d.ts +2 -0
  70. package/lib/Player/modules/ResizeObserver/index.js +37 -0
  71. package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +16 -2
  72. package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +132 -59
  73. package/lib/Player/modules/VideoAgent/VideoAgentScene.d.ts +3 -6
  74. package/lib/Player/modules/VideoAgent/VideoAgentScene.js +31 -36
  75. package/lib/Player/modules/VideoAgent/index.js +53 -12
  76. package/lib/Player/modules/Wave/index.d.ts +5 -0
  77. package/lib/Player/modules/Wave/index.js +51 -0
  78. package/lib/Player/modules/keyframes/BgMusic/index.js +1 -1
  79. package/lib/Player/modules/keyframes/CameraMovement/index.js +1 -1
  80. package/lib/Player/modules/keyframes/InfoPanel/index.js +22 -10
  81. package/lib/Player/modules/keyframes/ModelVideo/index.js +46 -9
  82. package/lib/Player/modules/keyframes/PanoEffect/index.js +1 -1
  83. package/lib/Player/modules/keyframes/PanoEffect/lineAnime.js +1 -1
  84. package/lib/Player/modules/keyframes/PanoTag/index.d.ts +1 -2
  85. package/lib/Player/modules/keyframes/PanoTag/index.js +79 -119
  86. package/lib/Player/modules/keyframes/PanoTextLabel/index.d.ts +3 -0
  87. package/lib/Player/modules/keyframes/PanoTextLabel/index.js +96 -44
  88. package/lib/Player/modules/keyframes/Prompter/index.js +10 -23
  89. package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +10 -6
  90. package/lib/Player/modules/keyframes/VideoEffect/index.js +1 -1
  91. package/lib/Player/typings.d.ts +12 -1
  92. package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.d.ts +2 -0
  93. package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.js +12 -0
  94. package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.d.ts +7 -0
  95. package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.js +32 -0
  96. package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.d.ts +3 -0
  97. package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.js +11 -0
  98. package/lib/fivePlugins/CSS3DRenderPlugin/index.d.ts +56 -0
  99. package/lib/fivePlugins/CSS3DRenderPlugin/index.js +275 -0
  100. package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.d.ts +7 -0
  101. package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.js +18 -0
  102. package/lib/fivePlugins/CameraMovementPlugin/index.js +13 -12
  103. package/lib/fivePlugins/ModelTVVideoPlugin/index.js +1 -1
  104. package/lib/react/index.d.ts +8 -4
  105. package/lib/react/index.js +3 -3
  106. package/lib/shared-utils/AduioLike.d.ts +37 -0
  107. package/lib/shared-utils/AduioLike.js +166 -0
  108. package/lib/shared-utils/addResizeListener.d.ts +4 -0
  109. package/lib/shared-utils/addResizeListener.js +51 -0
  110. package/lib/shared-utils/animationFrame/BetterTween.js +7 -3
  111. package/lib/shared-utils/animationFrame/tween.js +1 -1
  112. package/lib/shared-utils/createTransMatrix.d.ts +1 -0
  113. package/lib/shared-utils/createTransMatrix.js +43 -0
  114. package/lib/shared-utils/getFileExpandedName.d.ts +1 -0
  115. package/lib/shared-utils/getFileExpandedName.js +13 -0
  116. package/lib/shared-utils/getMediaInfo.d.ts +9 -0
  117. package/lib/shared-utils/getMediaInfo.js +75 -0
  118. package/lib/shared-utils/setElementDataset.d.ts +1 -0
  119. package/lib/shared-utils/setElementDataset.js +24 -0
  120. package/lib/typings/VreoUnit.d.ts +37 -2
  121. package/lib/typings/VreoUnit.js +13 -1
  122. package/package.json +10 -10
  123. package/resources/PlayController/index.ts +0 -13
  124. package/resources/Player/App.tsx +5 -4
  125. package/resources/Player/Controller.ts +277 -146
  126. package/resources/Player/custom/SpatialScenePanel/index.tsx +5 -5
  127. package/resources/Player/hooks.ts +3 -5
  128. package/resources/Player/index.tsx +189 -141
  129. package/resources/Player/modules/ResizeObserver/index.tsx +23 -0
  130. package/resources/Player/modules/VideoAgent/VideoAgentMesh.ts +87 -31
  131. package/resources/Player/modules/VideoAgent/VideoAgentScene.ts +27 -24
  132. package/resources/Player/modules/VideoAgent/index.tsx +28 -12
  133. package/resources/Player/modules/Wave/index.tsx +18 -0
  134. package/resources/Player/modules/keyframes/InfoPanel/index.tsx +26 -11
  135. package/resources/Player/modules/keyframes/ModelVideo/index.tsx +36 -3
  136. package/resources/Player/modules/keyframes/PanoTag/index.tsx +53 -97
  137. package/resources/Player/modules/keyframes/PanoTextLabel/index.tsx +86 -34
  138. package/resources/Player/modules/keyframes/Prompter/index.tsx +6 -16
  139. package/resources/Player/modules/keyframes/UpdateVRPanorama/index.tsx +6 -2
  140. package/resources/Player/typings.ts +15 -1
  141. package/resources/fivePlugins/CSS3DRenderPlugin/centerPoint.ts +5 -0
  142. package/resources/fivePlugins/CSS3DRenderPlugin/createResizeObserver.ts +17 -0
  143. package/resources/fivePlugins/CSS3DRenderPlugin/evenNumber.ts +4 -0
  144. package/resources/fivePlugins/CSS3DRenderPlugin/index.ts +254 -0
  145. package/resources/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.ts +5 -0
  146. package/resources/fivePlugins/CameraMovementPlugin/index.ts +19 -12
  147. package/resources/react/index.tsx +7 -3
  148. package/resources/shared-utils/AduioLike.ts +109 -0
  149. package/resources/shared-utils/addResizeListener.ts +46 -0
  150. package/resources/shared-utils/createTransMatrix.ts +12 -0
  151. package/resources/shared-utils/getFileExpandedName.ts +6 -0
  152. package/resources/shared-utils/getMediaInfo.ts +52 -0
  153. package/resources/shared-utils/setElementDataset.ts +18 -0
  154. package/resources/typings/VreoUnit.ts +41 -3
  155. package/stylesheets/custom/SpatialScenePanel.css +2 -1
  156. package/stylesheets/default.css +348 -84
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
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); }
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -13,6 +13,12 @@ var _Preloader = require("../../../shared-utils/Preloader");
13
13
 
14
14
  var _mobx = require("mobx");
15
15
 
16
+ var _AduioLike = _interopRequireDefault(require("../../../shared-utils/AduioLike"));
17
+
18
+ var _getMediaInfo = require("../../../shared-utils/getMediaInfo");
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
+
16
22
  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); }
17
23
 
18
24
  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; }
@@ -25,9 +31,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
25
31
 
26
32
  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); } }
27
33
 
28
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
34
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
29
35
 
30
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
36
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
31
37
 
32
38
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
33
39
 
@@ -66,9 +72,13 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
66
72
  * @param options
67
73
  */
68
74
  function VideoAgentMesh(width, height, widthSegments, heightSegments) {
75
+ var _this$options$videoIn, _this$options$videoIn2, _this$options$videoIn3;
76
+
69
77
  var _this;
70
78
 
71
- var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
79
+ var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
80
+ preload: true
81
+ };
72
82
 
73
83
  _classCallCheck(this, VideoAgentMesh);
74
84
 
@@ -78,6 +88,7 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
78
88
  } else {
79
89
  var videoInstance = document.createElement('video');
80
90
  videoInstance.style.opacity = '0';
91
+ videoInstance.style.pointerEvents = 'none';
81
92
  videoInstance.style.display = 'none';
82
93
  document.body.append(videoInstance);
83
94
  options.videoInstance = videoInstance;
@@ -115,10 +126,8 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
115
126
  audioInstance.crossOrigin = ''; // videoInstance.muted = true
116
127
 
117
128
  audioInstance.muted = false;
118
- audioInstance.setAttribute('playsinline', 'true');
119
- audioInstance.setAttribute('webkit-playsinline', 'true');
120
- audioInstance.setAttribute('autoplay', 'false');
121
- audioInstance.setAttribute('style', 'display: none;');
129
+ audioInstance.autoplay = false;
130
+ audioInstance.style.display = 'none';
122
131
  document.body.appendChild(audioInstance);
123
132
  _this.audioInstance = audioInstance;
124
133
  cacheInstance.audioInstance = audioInstance;
@@ -127,6 +136,7 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
127
136
  _this.audioInstance = options.audioInstance;
128
137
  }
129
138
 
139
+ _this.audioLikeInstance = new _AduioLike["default"]();
130
140
  (0, _mobx.makeObservable)(_assertThisInitialized(_this), {
131
141
  paused: _mobx.observable
132
142
  });
@@ -145,25 +155,51 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
145
155
  return updatePaused(false);
146
156
  };
147
157
 
148
- _this.videoInstance.addEventListener('pause', onPause);
158
+ var onEnded = function onEnded() {
159
+ return console.log('vreo: video 播放结束');
160
+ };
161
+
162
+ _this.audioInstance.addEventListener('pause', onPause);
149
163
 
150
- _this.videoInstance.addEventListener('play', onPlay);
164
+ _this.audioInstance.addEventListener('play', onPlay);
165
+
166
+ (_this$options$videoIn = _this.options.videoInstance) === null || _this$options$videoIn === void 0 ? void 0 : _this$options$videoIn.addEventListener('pause', onPause);
167
+ (_this$options$videoIn2 = _this.options.videoInstance) === null || _this$options$videoIn2 === void 0 ? void 0 : _this$options$videoIn2.addEventListener('play', onPlay);
168
+
169
+ _this.audioLikeInstance.addEventListener('pause', onPause);
170
+
171
+ _this.audioLikeInstance.addEventListener('play', onPlay);
172
+
173
+ (_this$options$videoIn3 = _this.options.videoInstance) === null || _this$options$videoIn3 === void 0 ? void 0 : _this$options$videoIn3.addEventListener('ended', onEnded);
151
174
 
152
175
  _this.$removeEventListener = function () {
153
- _this.videoInstance.removeEventListener('pause', onPause);
176
+ var _this$options$videoIn4, _this$options$videoIn5, _this$options$videoIn6;
177
+
178
+ _this.audioInstance.removeEventListener('pause', onPause);
179
+
180
+ _this.audioInstance.removeEventListener('play', onPlay);
154
181
 
155
- _this.videoInstance.removeEventListener('play', onPlay);
182
+ (_this$options$videoIn4 = _this.options.videoInstance) === null || _this$options$videoIn4 === void 0 ? void 0 : _this$options$videoIn4.removeEventListener('pause', onPause);
183
+ (_this$options$videoIn5 = _this.options.videoInstance) === null || _this$options$videoIn5 === void 0 ? void 0 : _this$options$videoIn5.removeEventListener('play', onPlay);
184
+
185
+ _this.audioLikeInstance.removeEventListener('pause', onPause);
186
+
187
+ _this.audioLikeInstance.removeEventListener('play', onPlay);
188
+
189
+ (_this$options$videoIn6 = _this.options.videoInstance) === null || _this$options$videoIn6 === void 0 ? void 0 : _this$options$videoIn6.removeEventListener('ended', onEnded);
156
190
  };
157
191
 
158
192
  return _this;
159
193
  }
160
194
 
161
195
  _createClass(VideoAgentMesh, [{
162
- key: "videoInstance",
196
+ key: "mediaInstance",
163
197
  get: function get() {
164
- var _this$videoUrl;
198
+ if (!this.videoUrl) {
199
+ return this.audioLikeInstance;
200
+ }
165
201
 
166
- if ((_this$videoUrl = this.videoUrl) !== null && _this$videoUrl !== void 0 && _this$videoUrl.endsWith('mp3')) {
202
+ if ((0, _getMediaInfo.getMediaType)(this.videoUrl) === 'audio') {
167
203
  return this.audioInstance;
168
204
  }
169
205
 
@@ -190,41 +226,59 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
190
226
  return _context.abrupt("return");
191
227
 
192
228
  case 2:
193
- this.videoUrl = videoUrl;
229
+ this.videoUrl = videoUrl; // // 兼容非视频场景
230
+ // if (this.mediaInstance instanceof HTMLAudioElement) {
231
+ // this.mediaInstance.style.display = 'none'
232
+ // } else if (this.mediaInstance instanceof HTMLVideoElement) {
233
+ // this.mediaInstance.style.display = 'block'
234
+ // }
235
+
194
236
  this.freeze = true;
195
237
  _context.next = 6;
196
- return this.videoInstance.pause();
238
+ return this.mediaInstance.pause();
197
239
 
198
240
  case 6:
199
241
  uniforms = this.material.uniforms;
200
- this.videoInstance.muted = true;
201
- _context.t0 = URL;
202
- _context.next = 11;
242
+ this.mediaInstance.muted = true;
243
+
244
+ if (!(this.options.preload || this.options.preload === undefined || (0, _getMediaInfo.getMediaType)(this.videoUrl) === 'video')) {
245
+ _context.next = 18;
246
+ break;
247
+ }
248
+
249
+ _context.t1 = URL;
250
+ _context.next = 12;
203
251
  return _Preloader.Preloader.blob(this.videoUrl);
204
252
 
205
- case 11:
206
- _context.t1 = _context.sent;
207
- _context.next = 14;
208
- return _context.t0.createObjectURL.call(_context.t0, _context.t1);
253
+ case 12:
254
+ _context.t2 = _context.sent;
255
+ _context.next = 15;
256
+ return _context.t1.createObjectURL.call(_context.t1, _context.t2);
209
257
 
210
- case 14:
211
- this.videoInstance.src = _context.sent;
212
- this.videoInstance.setAttribute('data-src', this.videoUrl);
258
+ case 15:
259
+ _context.t0 = _context.sent;
260
+ _context.next = 19;
261
+ break;
213
262
 
214
- onStart = function onStart() {
215
- var _this2$videoUrl;
263
+ case 18:
264
+ _context.t0 = this.videoUrl;
265
+
266
+ case 19:
267
+ this.mediaInstance.src = _context.t0;
268
+ this.mediaInstance.setAttribute('data-src', this.videoUrl);
216
269
 
217
- if (_this2.videoInstance.currentTime === 0) return;
270
+ onStart = function onStart() {
271
+ if (_this2.mediaInstance.currentTime === 0) return;
218
272
  _this2.freeze = false;
219
- _this2.videoInstance.muted = false;
220
- uniforms.enable.value = (_this2$videoUrl = _this2.videoUrl) !== null && _this2$videoUrl !== void 0 && _this2$videoUrl.endsWith('.mp4') ? 1 : 0;
273
+ _this2.mediaInstance.muted = false;
274
+ uniforms.enable.value = (0, _getMediaInfo.getMediaType)(_this2.videoUrl) ? 1 : 0;
221
275
 
222
- _this2.videoInstance.removeEventListener('timeupdate', onStart, false);
276
+ _this2.mediaInstance.removeEventListener('timeupdate', onStart, false);
223
277
  };
224
278
 
225
- this.videoInstance.addEventListener('timeupdate', onStart, false);
279
+ this.mediaInstance.addEventListener('timeupdate', onStart, false);
226
280
 
227
- case 18:
281
+ case 23:
228
282
  case "end":
229
283
  return _context.stop();
230
284
  }
@@ -245,66 +299,85 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
245
299
  var _this3 = this;
246
300
 
247
301
  var videoUrl,
302
+ currentTime,
303
+ duration,
248
304
  _args3 = arguments;
249
305
  return regeneratorRuntime.wrap(function _callee3$(_context3) {
250
306
  while (1) {
251
307
  switch (_context3.prev = _context3.next) {
252
308
  case 0:
253
309
  videoUrl = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : '';
310
+ currentTime = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : 0;
311
+ duration = _args3.length > 2 ? _args3[2] : undefined;
254
312
  videoUrl = videoUrl || '';
255
313
 
256
- if (videoUrl) {
314
+ if (!(duration && !videoUrl)) {
257
315
  _context3.next = 10;
258
316
  break;
259
317
  }
260
318
 
319
+ if (this.currentTime) {
320
+ this.mediaInstance.currentTime = currentTime;
321
+ }
322
+
323
+ this.mediaInstance.duration = duration;
324
+ this.videoUrl = '';
325
+ this.mediaInstance.play();
326
+ return _context3.abrupt("return", true);
327
+
328
+ case 10:
329
+ if (videoUrl) {
330
+ _context3.next = 18;
331
+ break;
332
+ }
333
+
261
334
  if (!this.videoUrl) {
262
- _context3.next = 8;
335
+ _context3.next = 16;
263
336
  break;
264
337
  }
265
338
 
266
- _context3.next = 6;
267
- return this.videoInstance.play();
339
+ _context3.next = 14;
340
+ return this.mediaInstance.play();
268
341
 
269
- case 6:
270
- _context3.next = 9;
342
+ case 14:
343
+ _context3.next = 17;
271
344
  break;
272
345
 
273
- case 8:
346
+ case 16:
274
347
  console.warn('警告:视频资源未初始化。');
275
348
 
276
- case 9:
349
+ case 17:
277
350
  return _context3.abrupt("return", true);
278
351
 
279
- case 10:
352
+ case 18:
280
353
  if (!(videoUrl === this.videoUrl)) {
281
- _context3.next = 15;
354
+ _context3.next = 23;
282
355
  break;
283
356
  }
284
357
 
285
- this.videoInstance.currentTime = 0;
286
- _context3.next = 14;
287
- return this.videoInstance.play();
358
+ this.mediaInstance.currentTime = currentTime;
359
+ _context3.next = 22;
360
+ return this.mediaInstance.play();
288
361
 
289
- case 14:
362
+ case 22:
290
363
  return _context3.abrupt("return", true);
291
364
 
292
- case 15:
293
- _context3.next = 17;
365
+ case 23:
366
+ _context3.next = 25;
294
367
  return this.update(videoUrl);
295
368
 
296
- case 17:
297
- this.videoInstance.pause();
298
- _context3.next = 20;
369
+ case 25:
370
+ this.mediaInstance.pause();
371
+ _context3.next = 28;
299
372
  return new Promise(function (resolve) {
300
373
  return setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
301
374
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
302
375
  while (1) {
303
376
  switch (_context2.prev = _context2.next) {
304
377
  case 0:
305
- _this3.videoInstance.currentTime = 0;
378
+ _this3.mediaInstance.currentTime = currentTime;
306
379
  _context2.next = 3;
307
- return _this3.videoInstance.play();
380
+ return _this3.mediaInstance.play();
308
381
 
309
382
  case 3:
310
383
  resolve(true);
@@ -318,10 +391,10 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
318
391
  })), 20);
319
392
  });
320
393
 
321
- case 20:
394
+ case 28:
322
395
  return _context3.abrupt("return", _context3.sent);
323
396
 
324
- case 21:
397
+ case 29:
325
398
  case "end":
326
399
  return _context3.stop();
327
400
  }
@@ -342,7 +415,7 @@ var VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
342
415
  }, {
343
416
  key: "currentTime",
344
417
  get: function get() {
345
- return this.videoInstance.currentTime * 1000;
418
+ return this.mediaInstance.currentTime * 1000;
346
419
  }
347
420
  }, {
348
421
  key: "dispose",
@@ -1,15 +1,12 @@
1
1
  import * as THREE from 'three';
2
- import { VideoAgentMesh } from './VideoAgentMesh';
2
+ import { VideoAgentMesh, VideoAgentMeshOptions } from './VideoAgentMesh';
3
3
  export declare class VideoAgentScene {
4
4
  videoAgentMesh: VideoAgentMesh;
5
5
  scene: THREE.Scene;
6
6
  camera: THREE.OrthographicCamera;
7
7
  renderer: THREE.WebGLRenderer;
8
- container: HTMLElement;
9
- constructor(container: HTMLElement, needRender?: boolean, options?: {
10
- videoInstance?: HTMLVideoElement;
11
- audioInstance?: HTMLAudioElement;
12
- });
8
+ disposers: (() => void)[];
9
+ constructor(container?: HTMLElement, options?: VideoAgentMeshOptions);
13
10
  run: () => void;
14
11
  dispose: () => void;
15
12
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
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); }
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -9,22 +9,25 @@ exports.VideoAgentScene = void 0;
9
9
 
10
10
  var THREE = _interopRequireWildcard(require("three"));
11
11
 
12
+ var _addResizeListener = require("../../../shared-utils/addResizeListener");
13
+
12
14
  var _VideoAgentMesh = require("./VideoAgentMesh");
13
15
 
14
16
  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); }
15
17
 
16
18
  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; }
17
19
 
20
+ 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); } }
21
+
22
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
23
+
18
24
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19
25
 
20
26
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
27
 
22
- var VideoAgentScene = function VideoAgentScene(container) {
28
+ var VideoAgentScene = /*#__PURE__*/_createClass(function VideoAgentScene(container, options) {
23
29
  var _this = this;
24
30
 
25
- var needRender = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
26
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
27
-
28
31
  _classCallCheck(this, VideoAgentScene);
29
32
 
30
33
  _defineProperty(this, "scene", new THREE.Scene());
@@ -35,20 +38,12 @@ var VideoAgentScene = function VideoAgentScene(container) {
35
38
  alpha: true
36
39
  }));
37
40
 
38
- _defineProperty(this, "run", function () {
39
- var _this$videoAgentMesh$;
40
-
41
- var domElement = _this.renderer.domElement; // 视频开始 1s 不渲染:规避某些设备黑屏闪烁问题。视频前 2s 是最好是静默的。
41
+ _defineProperty(this, "disposers", []);
42
42
 
43
+ _defineProperty(this, "run", function () {
44
+ // 视频开始 1s 不渲染:规避某些设备黑屏闪烁问题。视频前 2s 是最好是静默的。
43
45
  if (!(_this.videoAgentMesh.paused || _this.videoAgentMesh.freeze) && _this.videoAgentMesh.currentTime > 1000) {
44
46
  _this.renderer.render(_this.scene, _this.camera);
45
- } // 兼容非视频场景
46
-
47
-
48
- if (!((_this$videoAgentMesh$ = _this.videoAgentMesh.videoUrl) !== null && _this$videoAgentMesh$ !== void 0 && _this$videoAgentMesh$.endsWith('.mp4'))) {
49
- if (domElement.style.display !== 'none') domElement.style.display = 'none';
50
- } else {
51
- if (domElement.style.display !== 'block') domElement.style.display = 'block';
52
47
  }
53
48
 
54
49
  requestAnimationFrame(_this.run);
@@ -58,30 +53,30 @@ var VideoAgentScene = function VideoAgentScene(container) {
58
53
  var _this$videoAgentMesh;
59
54
 
60
55
  (_this$videoAgentMesh = _this.videoAgentMesh) === null || _this$videoAgentMesh === void 0 ? void 0 : _this$videoAgentMesh.dispose();
61
- });
62
-
63
- this.container = container;
64
- this.camera.position.set(0, 0, 10);
65
- this.camera.lookAt(0, 0, 0);
66
- var state = {
67
- width: container.offsetWidth,
68
- height: container.offsetHeight
69
- };
70
- var _domElement = this.renderer.domElement;
71
-
72
- _domElement.classList.add('VideoAgent-canvas');
73
56
 
74
- this.renderer.setSize(state.width * window.devicePixelRatio, state.height * window.devicePixelRatio);
75
-
76
- _domElement.setAttribute('style', "width: ".concat(state.width, "px;height: ").concat(state.height, "px;"));
77
-
78
- this.videoAgentMesh = new _VideoAgentMesh.VideoAgentMesh(480, 270, 1, 1, options);
57
+ _this.disposers.forEach(function (disposer) {
58
+ return disposer === null || disposer === void 0 ? void 0 : disposer();
59
+ });
60
+ });
79
61
 
80
- if (needRender) {
81
- container.append(_domElement);
62
+ this.videoAgentMesh = new _VideoAgentMesh.VideoAgentMesh(480, 270, 1, 1, options); // const needRender = getMediaType(this.videoAgentMesh.videoUrl) === 'video'
63
+
64
+ if (container) {
65
+ this.camera.position.set(0, 0, 10);
66
+ this.camera.lookAt(0, 0, 0);
67
+ var domElement = this.renderer.domElement;
68
+ domElement.classList.add('VideoAgent-canvas');
69
+ var dispose = (0, _addResizeListener.addResizeListener)(container, function (width, height) {
70
+ _this.renderer.setSize(width * window.devicePixelRatio, height * window.devicePixelRatio);
71
+
72
+ domElement.style.width = "".concat(width, "px");
73
+ domElement.style.height = "".concat(height, "px");
74
+ });
75
+ this.disposers.push(dispose);
76
+ container.append(domElement);
82
77
  this.scene.add(this.videoAgentMesh);
83
78
  this.run();
84
79
  }
85
- };
80
+ });
86
81
 
87
82
  exports.VideoAgentScene = VideoAgentScene;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
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); }
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -13,38 +13,79 @@ var _hooks = require("../../hooks");
13
13
 
14
14
  var _VideoAgentScene = require("./VideoAgentScene");
15
15
 
16
+ var _classnames = _interopRequireDefault(require("classnames"));
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
+
16
20
  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); }
17
21
 
18
22
  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; }
19
23
 
20
24
  function VideoAgent(props) {
25
+ var _controller$avatar2;
26
+
21
27
  var ref = React.useRef(null);
22
28
  var controller = (0, _hooks.useController)();
29
+ var showAvatar = React.useMemo(function () {
30
+ var _controller$avatar;
31
+
32
+ return ((_controller$avatar = controller.avatar) === null || _controller$avatar === void 0 ? void 0 : _controller$avatar.url) && controller.avatar.force === true;
33
+ }, [controller.avatar]);
34
+ var showVideoAgent = React.useMemo(function () {
35
+ var _controller$videoAgen;
36
+
37
+ if (showAvatar) return false;
38
+ return ((_controller$videoAgen = controller.videoAgentScene) === null || _controller$videoAgen === void 0 ? void 0 : _controller$videoAgen.videoAgentMesh.mediaInstance) instanceof HTMLVideoElement;
39
+ }, [controller.videoAgentScene]);
23
40
  React.useEffect(function () {
24
41
  if (!ref.current) throw new Error('React 渲染异常,请稍后重试 ...');
25
42
 
26
43
  if (controller.videoAgentScene) {
27
- console.warn('"VideoAgentScene" 重复初始化,已被过滤 ...');
44
+ console.warn('VideoAgentScene" 重复初始化,已被过滤');
28
45
  return;
29
46
  }
30
47
 
31
- var videoAgentScene = new _VideoAgentScene.VideoAgentScene(ref.current, true, props.options || {});
48
+ var videoAgentScene = new _VideoAgentScene.VideoAgentScene(ref.current, props.options);
32
49
  controller.videoAgentScene = videoAgentScene;
33
50
  return function () {
34
- var _controller$videoAgen;
51
+ var _controller$videoAgen2;
35
52
 
36
53
  controller.dispose();
37
- (_controller$videoAgen = controller.videoAgentScene) === null || _controller$videoAgen === void 0 ? void 0 : _controller$videoAgen.dispose();
54
+ (_controller$videoAgen2 = controller.videoAgentScene) === null || _controller$videoAgen2 === void 0 ? void 0 : _controller$videoAgen2.dispose();
38
55
  };
39
56
  }, []);
40
- return /*#__PURE__*/React.createElement("div", {
41
- className: "VideoAgent",
57
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
58
+ className: "Avatar",
59
+ style: {
60
+ display: showAvatar ? 'block' : 'none'
61
+ }
62
+ }, /*#__PURE__*/React.createElement("div", {
63
+ className: "Avatar-wrapper ratio-1-1"
64
+ }, /*#__PURE__*/React.createElement("img", {
65
+ className: "Avatar-img",
66
+ src: (_controller$avatar2 = controller.avatar) === null || _controller$avatar2 === void 0 ? void 0 : _controller$avatar2.url,
42
67
  onClick: function onClick() {
43
- if (!props.onClick) return;
44
- props.onClick();
45
- },
68
+ var _props$onClick;
69
+
70
+ return (_props$onClick = props.onClick) === null || _props$onClick === void 0 ? void 0 : _props$onClick.call(props);
71
+ }
72
+ }))), /*#__PURE__*/React.createElement("div", {
73
+ className: (0, _classnames["default"])('VideoAgent', {
74
+ hide: !showVideoAgent
75
+ })
76
+ }, /*#__PURE__*/React.createElement("div", {
77
+ className: "VideoAgent-container"
78
+ }, /*#__PURE__*/React.createElement("div", {
79
+ className: "VideoAgent-wrapper ratio-16-9"
80
+ }, /*#__PURE__*/React.createElement("div", {
81
+ className: "VideoAgent-inner",
46
82
  ref: ref
47
83
  }, /*#__PURE__*/React.createElement("div", {
48
- className: "VideoAgent-play"
49
- }));
84
+ className: "VideoAgent-play",
85
+ onClick: function onClick() {
86
+ var _props$onClick2;
87
+
88
+ return (_props$onClick2 = props.onClick) === null || _props$onClick2 === void 0 ? void 0 : _props$onClick2.call(props);
89
+ }
90
+ }))))));
50
91
  }
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { WaveAppearance } from '../../typings';
3
+ export declare function Wave(props?: {
4
+ appearance?: WaveAppearance;
5
+ }): JSX.Element;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Wave = Wave;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
+
12
+ function Wave(props) {
13
+ var waveUrl = _react["default"].useMemo(function () {
14
+ var _props$appearance;
15
+
16
+ var appearance = (_props$appearance = props === null || props === void 0 ? void 0 : props.appearance) !== null && _props$appearance !== void 0 ? _props$appearance : 'solid';
17
+
18
+ switch (appearance) {
19
+ default:
20
+ return 'https://vr-public.realsee-cdn.cn/release/static/image/release/vapor/static/wave-solid.64438b63cbb346906d066bb7b8dc3e20.webm';
21
+
22
+ case 'solid':
23
+ return 'https://vr-public.realsee-cdn.cn/release/static/image/release/vapor/static/wave-solid.64438b63cbb346906d066bb7b8dc3e20.webm';
24
+
25
+ case 'single':
26
+ return 'https://vr-public.realsee-cdn.cn/release/static/image/release/vapor/static/wave-single.eda65de390a830193fff40d1f1255555.webm';
27
+
28
+ case 'double':
29
+ return 'https://vr-public.realsee-cdn.cn/release/static/image/release/vapor/static/wave-double.77dfe8548ebcb3f3d336785d4fe9c7b2.webm';
30
+
31
+ case 'swap':
32
+ return 'https://vr-public.realsee-cdn.cn/release/static/image/release/vapor/static/wave-swap.c02e4b94cf05aecf6e7a0023bc7bb90f.webm';
33
+
34
+ case 'expand':
35
+ return 'https://vr-public.realsee-cdn.cn/release/static/image/release/vapor/static/wave-expand.a0d2a0074001cd3d4fea56818c6d3c38.webm';
36
+ }
37
+ }, [props === null || props === void 0 ? void 0 : props.appearance]);
38
+
39
+ return /*#__PURE__*/_react["default"].createElement("video", {
40
+ className: "vreo-wave",
41
+ width: "100%",
42
+ preload: "auto",
43
+ muted: true,
44
+ autoPlay: true,
45
+ loop: true,
46
+ playsInline: true,
47
+ disablePictureInPicture: true,
48
+ controls: false,
49
+ src: waveUrl
50
+ });
51
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
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); }
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true