@realsee/vreo 1.0.0-alpha.17 → 1.0.0-alpha.19

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 (73) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/docs/demo/assets/{AppReact.a3fc45d3.js → AppReact.20163f9a.js} +1 -1
  3. package/docs/demo/assets/default.5069891b.js +3988 -0
  4. package/docs/demo/assets/{dynamic.714b9eb8.js → dynamic.c8118cc9.js} +1 -1
  5. package/docs/demo/assets/{examples.1a6f5a2c.js → examples.5391fc1f.js} +1 -1
  6. package/docs/demo/assets/{index.0ca9e9d3.js → index.2272a9ef.js} +1 -1
  7. package/docs/demo/assets/main.b335b989.js +1 -0
  8. package/docs/demo/assets/{react.fca6a967.js → react.efea3f3f.js} +1 -1
  9. package/docs/demo/examples.html +2 -2
  10. package/docs/demo/index-react-dynamic.html +4 -4
  11. package/docs/demo/index-react.html +4 -4
  12. package/docs/demo/index.html +3 -3
  13. package/lib/PlayController/createHTMLAudioElement.js +11 -6
  14. package/lib/PlayController/index.js +81 -16
  15. package/lib/Player/App.js +24 -0
  16. package/lib/Player/Controller.d.ts +2 -2
  17. package/lib/Player/Controller.js +95 -19
  18. package/lib/Player/custom/SpatialScenePanel/index.js +68 -42
  19. package/lib/Player/hooks.js +10 -0
  20. package/lib/Player/index.js +85 -25
  21. package/lib/Player/modules/Drawer/index.js +17 -0
  22. package/lib/Player/modules/PopUp/index.js +10 -0
  23. package/lib/Player/modules/ResizeObserver/index.js +8 -0
  24. package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +2 -2
  25. package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +114 -20
  26. package/lib/Player/modules/VideoAgent/VideoAgentScene.js +24 -2
  27. package/lib/Player/modules/VideoAgent/index.js +17 -0
  28. package/lib/Player/modules/Wave/index.js +32 -7
  29. package/lib/Player/modules/keyframes/BgMusic/index.js +44 -14
  30. package/lib/Player/modules/keyframes/CameraMovement/index.js +27 -3
  31. package/lib/Player/modules/keyframes/InfoPanel/index.js +25 -8
  32. package/lib/Player/modules/keyframes/ModelVideo/index.js +29 -3
  33. package/lib/Player/modules/keyframes/PanoEffect/index.js +43 -15
  34. package/lib/Player/modules/keyframes/PanoEffect/lineAnime.js +7 -0
  35. package/lib/Player/modules/keyframes/PanoTag/index.js +21 -4
  36. package/lib/Player/modules/keyframes/PanoTextLabel/index.js +47 -22
  37. package/lib/Player/modules/keyframes/Prompter/index.js +32 -10
  38. package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +25 -18
  39. package/lib/Player/modules/keyframes/VideoEffect/index.js +47 -12
  40. package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.js +2 -0
  41. package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.js +1 -0
  42. package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.js +1 -0
  43. package/lib/fivePlugins/CSS3DRenderPlugin/index.js +60 -19
  44. package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.js +5 -2
  45. package/lib/fivePlugins/CameraMovementPlugin/index.js +75 -28
  46. package/lib/fivePlugins/CameraMovementPlugin/typings.js +4 -0
  47. package/lib/fivePlugins/ModelTVVideoPlugin/index.js +60 -11
  48. package/lib/index.js +1 -0
  49. package/lib/react/index.js +34 -7
  50. package/lib/shared-utils/{AduioLike.d.ts → AudioLike.d.ts} +0 -0
  51. package/lib/shared-utils/{AduioLike.js → AudioLike.js} +43 -11
  52. package/lib/shared-utils/Preloader.js +7 -0
  53. package/lib/shared-utils/addResizeListener.js +5 -0
  54. package/lib/shared-utils/animationFrame/BetterTween.js +38 -2
  55. package/lib/shared-utils/animationFrame/index.js +10 -2
  56. package/lib/shared-utils/animationFrame/tween.js +15 -2
  57. package/lib/shared-utils/createTransMatrix.js +17 -2
  58. package/lib/shared-utils/getFileExpandedName.js +1 -0
  59. package/lib/shared-utils/getMediaInfo.js +9 -0
  60. package/lib/shared-utils/setElementDataset.js +2 -0
  61. package/lib/typings/VreoUnit.d.ts +5 -5
  62. package/lib/typings/VreoUnit.js +15 -0
  63. package/package.json +1 -1
  64. package/resources/PlayController/index.ts +1 -1
  65. package/resources/Player/Controller.ts +3 -3
  66. package/resources/Player/index.tsx +1 -1
  67. package/resources/Player/modules/VideoAgent/VideoAgentMesh.ts +2 -2
  68. package/resources/Player/modules/keyframes/BgMusic/index.tsx +23 -14
  69. package/resources/Player/modules/keyframes/PanoTag/index.tsx +1 -0
  70. package/resources/shared-utils/{AduioLike.ts → AudioLike.ts} +4 -6
  71. package/resources/typings/VreoUnit.ts +5 -5
  72. package/docs/demo/assets/default.9985006b.js +0 -3988
  73. package/docs/demo/assets/main.7963f418.js +0 -1
@@ -1,66 +1,112 @@
1
1
  "use strict";
2
2
 
3
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
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.ControllerContext = exports.Controller = void 0;
9
+
8
10
  var _five = require("@realsee/five");
11
+
9
12
  var _mobx = require("mobx");
13
+
10
14
  var React = _interopRequireWildcard(require("react"));
15
+
11
16
  var _animationFrame = require("../shared-utils/animationFrame");
17
+
12
18
  var _setElementDataset = _interopRequireDefault(require("../shared-utils/setElementDataset"));
19
+
13
20
  var _getMediaInfo = require("../shared-utils/getMediaInfo");
21
+
14
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
+
15
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); }
25
+
16
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; }
27
+
17
28
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
29
+
18
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
+
19
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
+
20
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
+
21
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
+
22
38
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
39
+
23
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
+
24
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
+
25
44
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
45
+
26
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); } }
47
+
27
48
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
49
+
28
50
  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); }
29
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
51
+
52
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
53
+
30
54
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
55
+
31
56
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
57
+
32
58
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
59
+
33
60
  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; } }
34
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
61
+
62
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
63
+
35
64
  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; }
65
+
36
66
  /**
37
67
  * 逻辑控制器:内部状态。
38
68
  */
39
69
  var Controller = /*#__PURE__*/function (_Subscribe) {
40
70
  _inherits(Controller, _Subscribe);
71
+
41
72
  var _super = _createSuper(Controller);
73
+
42
74
  function Controller(_ref) {
43
75
  var _this;
76
+
44
77
  var five = _ref.five,
45
- container = _ref.container,
46
- configs = _ref.configs;
78
+ container = _ref.container,
79
+ configs = _ref.configs;
80
+
47
81
  _classCallCheck(this, Controller);
82
+
48
83
  _this = _super.call(this);
84
+
49
85
  _defineProperty(_assertThisInitialized(_this), "playing", false);
86
+
50
87
  _defineProperty(_assertThisInitialized(_this), "ended", false);
88
+
51
89
  _defineProperty(_assertThisInitialized(_this), "loading", false);
90
+
52
91
  _defineProperty(_assertThisInitialized(_this), "containerSize", {
53
92
  width: 0,
54
93
  height: 0
55
94
  });
95
+
56
96
  _defineProperty(_assertThisInitialized(_this), "waveAppearance", null);
97
+
57
98
  _defineProperty(_assertThisInitialized(_this), "appearance", {
58
99
  waveStyle: 'wave'
59
100
  });
101
+
60
102
  _defineProperty(_assertThisInitialized(_this), "avatar", {});
103
+
61
104
  _defineProperty(_assertThisInitialized(_this), "visible", false);
105
+
62
106
  _defineProperty(_assertThisInitialized(_this), "popUp", null);
107
+
63
108
  _defineProperty(_assertThisInitialized(_this), "drawerConfig", null);
109
+
64
110
  _this.configs = configs;
65
111
  _this.container = container;
66
112
  _this.five = five;
@@ -93,17 +139,20 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
93
139
  return [_this.appearance.waveStyle, _this.loading];
94
140
  }, function (_ref2) {
95
141
  var _ref3 = _slicedToArray(_ref2, 2),
96
- waveStyle = _ref3[0],
97
- loading = _ref3[1];
142
+ waveStyle = _ref3[0],
143
+ loading = _ref3[1];
144
+
98
145
  if (loading === null) {
99
146
  _this.waveAppearance = null;
100
147
  return;
101
148
  }
149
+
102
150
  if (waveStyle === 'wave') {
103
151
  switch (loading) {
104
152
  case true:
105
153
  _this.waveAppearance = 'double';
106
154
  break;
155
+
107
156
  case false:
108
157
  _this.waveAppearance = 'solid';
109
158
  break;
@@ -113,6 +162,7 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
113
162
  case true:
114
163
  _this.waveAppearance = 'swap';
115
164
  break;
165
+
116
166
  case false:
117
167
  _this.waveAppearance = 'expand';
118
168
  break;
@@ -121,6 +171,7 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
121
171
  }, {
122
172
  fireImmediately: true
123
173
  });
174
+
124
175
  if (!_this.appSize) {
125
176
  (0, _mobx.reaction)(function () {
126
177
  return _this.containerSize;
@@ -128,16 +179,19 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
128
179
  if (!(containerSize !== null && containerSize !== void 0 && containerSize.width)) return;
129
180
  var width = containerSize.width;
130
181
  var height = containerSize.height;
182
+
131
183
  var size = function () {
132
184
  if (width <= 500) return 'S';
133
185
  if (width <= 1024) return 'M';
134
186
  if (width <= 2048) return 'L';
135
187
  return 'XL';
136
188
  }();
189
+
137
190
  var orientation = function () {
138
191
  if (height > width) return 'portrait';
139
192
  return 'landscape';
140
193
  }();
194
+
141
195
  (0, _setElementDataset["default"])(_this.container, {
142
196
  size: size
143
197
  });
@@ -151,9 +205,9 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
151
205
  (0, _setElementDataset["default"])(_this.container, {
152
206
  size: _this.appSize
153
207
  });
154
- }
208
+ } // 监听播放情况:抛出触发时机
209
+
155
210
 
156
- // 监听播放情况:抛出触发时机
157
211
  (0, _mobx.reaction)(function () {
158
212
  return _this.ended;
159
213
  }, function (ended) {
@@ -170,13 +224,13 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
170
224
  });
171
225
  return _this;
172
226
  }
227
+
173
228
  _createClass(Controller, [{
174
229
  key: "agentType",
175
- get:
176
- // null 表示加载失败
177
-
230
+ get: // null 表示加载失败
178
231
  function get() {
179
232
  var _this$videoAgentScene, _this$avatar;
233
+
180
234
  var type = (0, _getMediaInfo.getMediaType)((_this$videoAgentScene = this.videoAgentScene) === null || _this$videoAgentScene === void 0 ? void 0 : _this$videoAgentScene.videoAgentMesh.videoUrl);
181
235
  if ((_this$avatar = this.avatar) !== null && _this$avatar !== void 0 && _this$avatar.force) return 'avatar';
182
236
  if (type === 'video') return 'video';
@@ -189,6 +243,7 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
189
243
  this.popUp = null;
190
244
  return;
191
245
  }
246
+
192
247
  this.popUp = popUp;
193
248
  }
194
249
  }, {
@@ -234,12 +289,14 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
234
289
  value: function openDrawer(drawerConfig) {
235
290
  if (!drawerConfig) {
236
291
  var _this$drawerConfig;
292
+
237
293
  this.drawerConfig = {
238
294
  content: '',
239
295
  height: (_this$drawerConfig = this.drawerConfig) === null || _this$drawerConfig === void 0 ? void 0 : _this$drawerConfig.height
240
296
  };
241
297
  return;
242
298
  }
299
+
243
300
  this.drawerConfig = drawerConfig;
244
301
  }
245
302
  }, {
@@ -251,15 +308,17 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
251
308
  key: "currentTime",
252
309
  get: function get() {
253
310
  var _this$videoAgentScene2;
311
+
254
312
  return ((_this$videoAgentScene2 = this.videoAgentScene) === null || _this$videoAgentScene2 === void 0 ? void 0 : _this$videoAgentScene2.videoAgentMesh.currentTime) || 0;
255
313
  }
256
314
  }, {
257
315
  key: "currentKeyframes",
258
316
  get: function get() {
259
317
  var _this2 = this;
318
+
260
319
  if (!this.vreoUnit) return [];
261
- var keyframes = this.vreoUnit.keyframes;
262
- // 没有被解析过且开始时间低于当前时间戳 100ms
320
+ var keyframes = this.vreoUnit.keyframes; // 没有被解析过且开始时间低于当前时间戳 100ms
321
+
263
322
  return keyframes.filter(function (keyframe) {
264
323
  if (keyframe.parsed) return false;
265
324
  var dur = _this2.currentTime - keyframe.start;
@@ -270,42 +329,52 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
270
329
  key: "mediaInstance",
271
330
  get: function get() {
272
331
  var _this$videoAgentScene3;
332
+
273
333
  return (_this$videoAgentScene3 = this.videoAgentScene) === null || _this$videoAgentScene3 === void 0 ? void 0 : _this$videoAgentScene3.videoAgentMesh.mediaInstance;
274
334
  }
275
-
276
335
  /**
277
336
  * 逐帧任务
278
337
  */
338
+
279
339
  }, {
280
340
  key: "requestAnimationFrameLoop",
281
341
  value: function requestAnimationFrameLoop(callback) {
282
342
  var _this$mediaInstance,
283
- _this$mediaInstance4,
284
- _this3 = this;
343
+ _this$mediaInstance4,
344
+ _this3 = this;
345
+
285
346
  if ((_this$mediaInstance = this.mediaInstance) !== null && _this$mediaInstance !== void 0 && _this$mediaInstance.ended) {
286
347
  this.setEnded(true);
287
348
  this.setPlaying(false);
288
349
  this.mediaInstance.pause();
289
350
  return;
290
351
  }
352
+
291
353
  if (!this.playing) {
292
354
  var _this$mediaInstance2;
355
+
293
356
  if (!((_this$mediaInstance2 = this.mediaInstance) !== null && _this$mediaInstance2 !== void 0 && _this$mediaInstance2.paused)) {
294
357
  var _this$mediaInstance3;
358
+
295
359
  (_this$mediaInstance3 = this.mediaInstance) === null || _this$mediaInstance3 === void 0 ? void 0 : _this$mediaInstance3.pause();
296
360
  }
361
+
297
362
  return;
298
363
  }
364
+
299
365
  if ((_this$mediaInstance4 = this.mediaInstance) !== null && _this$mediaInstance4 !== void 0 && _this$mediaInstance4.paused && this.playing) {
300
366
  this.mediaInstance.play();
301
367
  }
368
+
302
369
  var currentKeyframes = this.currentKeyframes;
303
370
  currentKeyframes.forEach(function (keyframe) {
304
371
  if (keyframe.parsed) return;
305
372
  keyframe.parsed = true;
306
- _this3.emit(keyframe.type, keyframe);
373
+
374
+ _this3.emit(keyframe.type, keyframe, _this3.currentTime);
375
+
307
376
  if (callback) {
308
- callback(keyframe.type, keyframe);
377
+ callback(keyframe.type, keyframe, _this3.currentTime);
309
378
  }
310
379
  });
311
380
  }
@@ -313,6 +382,7 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
313
382
  key: "run",
314
383
  value: function run(callback) {
315
384
  var _this4 = this;
385
+
316
386
  if (this.stopInterval) return;
317
387
  this.stopInterval = (0, _animationFrame.requestAnimationFrameInterval)(function () {
318
388
  return _this4.requestAnimationFrameLoop(callback);
@@ -322,27 +392,33 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
322
392
  key: "dispose",
323
393
  value: function dispose() {
324
394
  this.setPlaying(false);
395
+
325
396
  if (this.currentKeyframes) {
326
397
  this.currentKeyframes.forEach(function (keyframe) {
327
398
  return keyframe.parsed = false;
328
399
  });
329
400
  }
330
-
331
401
  /**
332
402
  * 清理掉数据
333
403
  */
404
+
405
+
334
406
  this.vreoUnit = undefined;
407
+
335
408
  if (this.mediaInstance) {
336
409
  this.mediaInstance.currentTime = 0;
337
410
  }
411
+
338
412
  if (this.stopInterval) {
339
413
  this.stopInterval();
340
414
  this.stopInterval = undefined;
341
415
  }
342
416
  }
343
417
  }]);
418
+
344
419
  return Controller;
345
420
  }(_five.Subscribe);
421
+
346
422
  exports.Controller = Controller;
347
423
  var ControllerContext = /*#__PURE__*/React.createContext(null);
348
424
  exports.ControllerContext = ControllerContext;
@@ -1,25 +1,42 @@
1
1
  "use strict";
2
2
 
3
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
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.SpatialScenePanel = SpatialScenePanel;
9
+
8
10
  var React = _interopRequireWildcard(require("react"));
11
+
9
12
  var _reactDom = _interopRequireDefault(require("react-dom"));
13
+
10
14
  var _three = require("three");
15
+
11
16
  var _BetterTween = require("../../../shared-utils/animationFrame/BetterTween");
17
+
12
18
  var _CSS3DRenderPlugin = require("../../../fivePlugins/CSS3DRenderPlugin");
19
+
13
20
  var _VreoUnit = require("../../../typings/VreoUnit");
21
+
14
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
+
15
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); }
25
+
16
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; }
27
+
17
28
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
29
+
18
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
+
19
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
+
20
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
+
21
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
+
22
38
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
39
+
23
40
  // const getSphere = (position: Vector3, color = 0xffff00) => {
24
41
  // const geometry = new SphereGeometry(0.05, 32, 16)
25
42
  // const material = new MeshBasicMaterial({ color })
@@ -27,27 +44,28 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
27
44
  // sphere.position.copy(position)
28
45
  // return sphere
29
46
  // }
30
-
31
47
  var searchV1 = function searchV1(_ref) {
32
48
  var five = _ref.five,
33
- dom = _ref.dom;
49
+ dom = _ref.dom;
34
50
  var cameraDirection = new _three.Vector3();
35
51
  five.camera.getWorldDirection(cameraDirection);
36
52
  var cameraPosition = five.camera.position;
53
+
37
54
  var _five$model$intersect = five.model.intersectRaycaster(new _three.Raycaster(cameraPosition, cameraDirection)),
38
- _five$model$intersect2 = _slicedToArray(_five$model$intersect, 1),
39
- intersect = _five$model$intersect2[0];
55
+ _five$model$intersect2 = _slicedToArray(_five$model$intersect, 1),
56
+ intersect = _five$model$intersect2[0];
57
+
40
58
  var point = five.project2d(intersect.point);
41
- var widescreen = window.innerWidth > 560 ? true : false;
42
- // const width = dom!.clientWidth
59
+ var widescreen = window.innerWidth > 560 ? true : false; // const width = dom!.clientWidth
60
+
43
61
  var height = dom.clientHeight;
44
62
  dom.style.left = point.x + 'px';
45
63
  dom.style.top = point.y - height / 2 + 'px';
46
64
  var rect = dom.getBoundingClientRect();
47
65
  var left = rect.left,
48
- top = rect.top,
49
- bottom = rect.bottom,
50
- right = rect.right;
66
+ top = rect.top,
67
+ bottom = rect.bottom,
68
+ right = rect.right;
51
69
  var leftBottom = new _three.Vector3(left, bottom);
52
70
  var leftTop = new _three.Vector3(left, top);
53
71
  var rightTop = new _three.Vector3(right, top);
@@ -57,24 +75,23 @@ var searchV1 = function searchV1(_ref) {
57
75
  point.setY(-(point.y / window.innerHeight) * 2 + (widescreen ? 1.35 : 1.125));
58
76
  point.setZ(0.5);
59
77
  return point.unproject(five.camera).addScaledVector(cameraDirection, 0.2);
60
- });
61
-
62
- // __debug__
78
+ }); // __debug__
63
79
  // const colors = [0xdc143c, 0xffff00, 0x0000ff, 0x008000]
64
80
  // points.forEach((p, index) => five.scene.add(getSphere(p, colors[index])))
65
-
66
81
  // 判断是手机 150
82
+
67
83
  var ratio = leftBottom.distanceTo(rightBottom) / (widescreen ? 150 : 120);
68
84
  return {
69
85
  points: points,
70
86
  ratio: ratio
71
87
  };
72
88
  };
73
-
74
89
  /**
75
90
  * 空间场景面板
76
91
  * @returns
77
92
  */
93
+
94
+
78
95
  function SpatialScenePanel(props) {
79
96
  var timeoutRef = React.useRef(null);
80
97
  var ref = React.useRef(null);
@@ -84,63 +101,68 @@ function SpatialScenePanel(props) {
84
101
  if (!ref.current) {
85
102
  return;
86
103
  }
104
+
87
105
  var callback = function callback(keyframe) {
88
106
  if (keyframe.data.customType !== 'SpatialScenePanel') {
89
107
  return;
90
108
  }
91
- var data = keyframe.data;
92
109
 
93
- // const data = mockData
110
+ var data = keyframe.data; // const data = mockData
111
+
94
112
  var _searchV = searchV1({
95
- five: props.five,
96
- dom: ref.current
97
- }),
98
- points = _searchV.points,
99
- ratio = _searchV.ratio;
113
+ five: props.five,
114
+ dom: ref.current
115
+ }),
116
+ points = _searchV.points,
117
+ ratio = _searchV.ratio;
118
+
100
119
  var _ref2 = rendererRef.current.create3DDomContainer(points, {
101
- ratio: ratio,
102
- autoRender: false
103
- }) || {},
104
- container = _ref2.container,
105
- dispose = _ref2.dispose,
106
- css3DObject = _ref2.css3DObject,
107
- render = _ref2.render;
120
+ ratio: ratio,
121
+ autoRender: false
122
+ }) || {},
123
+ container = _ref2.container,
124
+ dispose = _ref2.dispose,
125
+ css3DObject = _ref2.css3DObject,
126
+ render = _ref2.render;
127
+
108
128
  Object.assign(window, {
109
129
  $css3DObject: css3DObject
110
130
  });
111
131
  if (!container) return;
132
+
112
133
  _reactDom["default"].render( /*#__PURE__*/React.createElement(Panel, {
113
134
  ref: function ref(_ref3) {
114
135
  return panelRef.current = _ref3;
115
136
  },
116
137
  data: data
117
138
  }), container);
139
+
118
140
  var startRotateY = -(Math.PI * 2) / 9;
119
141
  var lastRotateY = 0;
120
142
  (0, _BetterTween.tweenProgress)(1000).onUpdate(function (_ref4) {
121
143
  var progress = _ref4.progress;
122
144
  var needRotateY = Math.PI / 90 * 11 * progress;
123
145
  var rotateY = needRotateY - lastRotateY;
124
- css3DObject === null || css3DObject === void 0 ? void 0 : css3DObject.rotateY(rotateY);
125
- // css3DObject?.rotateZ
146
+ css3DObject === null || css3DObject === void 0 ? void 0 : css3DObject.rotateY(rotateY); // css3DObject?.rotateZ
147
+
126
148
  lastRotateY = needRotateY;
127
149
  }).onStart(function () {
128
150
  css3DObject === null || css3DObject === void 0 ? void 0 : css3DObject.rotateY(startRotateY);
129
151
  render();
130
152
  }).onDispose(function () {
131
153
  var _panelRef$current;
132
- (_panelRef$current = panelRef.current) === null || _panelRef$current === void 0 ? void 0 : _panelRef$current.classList.add('show');
133
- }).play();
134
154
 
135
- // Object.assign(window, { $dispose: () => {
155
+ (_panelRef$current = panelRef.current) === null || _panelRef$current === void 0 ? void 0 : _panelRef$current.classList.add('show');
156
+ }).play(); // Object.assign(window, { $dispose: () => {
136
157
  // panelRef.current?.classList.add('hide')
137
158
  // setTimeout(() => dispose?.(), 1500)
138
159
  // } })
139
160
 
140
161
  var start = keyframe.start,
141
- end = keyframe.end;
162
+ end = keyframe.end;
142
163
  timeoutRef.current = setTimeout(function () {
143
164
  var _panelRef$current2;
165
+
144
166
  (_panelRef$current2 = panelRef.current) === null || _panelRef$current2 === void 0 ? void 0 : _panelRef$current2.classList.add('hide');
145
167
  timeoutRef.current = setTimeout(function () {
146
168
  dispose === null || dispose === void 0 ? void 0 : dispose();
@@ -148,14 +170,15 @@ function SpatialScenePanel(props) {
148
170
  }, 1500);
149
171
  }, end - start);
150
172
  };
173
+
151
174
  Object.assign(window, {
152
175
  $callback: callback
153
- });
176
+ }); // setTimeout(() => {callback()}, 8000)
154
177
 
155
- // setTimeout(() => {callback()}, 8000)
156
178
  props.subscribe.on(_VreoUnit.VreoKeyframeEnum.Custom, callback);
157
179
  return function () {
158
180
  props.subscribe.off(_VreoUnit.VreoKeyframeEnum.Custom, callback);
181
+
159
182
  if (timeoutRef.current) {
160
183
  clearTimeout(timeoutRef.current);
161
184
  }
@@ -166,22 +189,27 @@ function SpatialScenePanel(props) {
166
189
  ref: ref
167
190
  });
168
191
  }
169
-
170
192
  /** 背景动画:控制延迟 */
193
+
194
+
171
195
  function SpatialScenePanelBg() {
172
196
  var ref = React.useRef(null);
173
197
  var timeoutRef = React.useRef(null);
174
198
  React.useEffect(function () {
175
199
  if (!ref.current) return;
200
+
176
201
  var listener = function listener() {
177
202
  var _ref$current;
203
+
178
204
  (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.setAttribute('class', 'SpatialScenePanel-bg');
179
205
  timeoutRef.current = setTimeout(function () {
180
206
  var _ref$current2;
207
+
181
208
  (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.setAttribute('class', 'SpatialScenePanel-bg SpatialScenePanel-bg--animation');
182
209
  timeoutRef.current = null;
183
210
  }, 3000);
184
211
  };
212
+
185
213
  ref.current.addEventListener('animationend', listener);
186
214
  return function () {
187
215
  if (ref.current) ref.current.removeEventListener('animationend', listener);
@@ -193,8 +221,10 @@ function SpatialScenePanelBg() {
193
221
  className: "SpatialScenePanel-bg SpatialScenePanel-bg--animation"
194
222
  });
195
223
  }
224
+
196
225
  var Panel = /*#__PURE__*/React.forwardRef(function (props, myRef) {
197
226
  var _props$data, _props$data2, _props$data3, _props$data3$stateLis;
227
+
198
228
  return /*#__PURE__*/React.createElement("div", {
199
229
  className: "SpatialScenePanel",
200
230
  ref: myRef
@@ -224,11 +254,8 @@ var Panel = /*#__PURE__*/React.forwardRef(function (props, myRef) {
224
254
  }))), /*#__PURE__*/React.createElement("div", {
225
255
  className: "SpatialScenePanel-disappear-area"
226
256
  }));
227
- });
228
-
229
- // export function SpatialScenePanel() {
257
+ }); // export function SpatialScenePanel() {
230
258
  // // const data = mockData
231
-
232
259
  // return (
233
260
  // <div className="SpatialScenePanel" >
234
261
  // <div className="SpatialScenePanel-show-area">
@@ -247,7 +274,6 @@ var Panel = /*#__PURE__*/React.forwardRef(function (props, myRef) {
247
274
  // ))}
248
275
  // </div>
249
276
  // </div>
250
-
251
277
  // <div className="SpatialScenePanel-disappear-area"></div>
252
278
  // </div>
253
279
  // )
@@ -6,23 +6,33 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.useController = useController;
7
7
  exports.useFiveInstance = useFiveInstance;
8
8
  exports.useFiveProject2d = useFiveProject2d;
9
+
9
10
  var _react = _interopRequireDefault(require("react"));
11
+
10
12
  var _Controller = require("./Controller");
13
+
11
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
+
12
16
  function useController() {
13
17
  var controller = _react["default"].useContext(_Controller.ControllerContext);
18
+
14
19
  if (!controller) {
15
20
  throw new Error('没有找到 "ControllerContext"');
16
21
  }
22
+
17
23
  return controller;
18
24
  }
25
+
19
26
  function useFiveInstance() {
20
27
  var controller = useController();
28
+
21
29
  if (!controller.five) {
22
30
  throw new Error('没有找到 "five" 实例');
23
31
  }
32
+
24
33
  return controller.five;
25
34
  }
35
+
26
36
  function useFiveProject2d() {
27
37
  var five = useFiveInstance();
28
38
  return function (vector) {