@realsee/vreo 1.0.0-alpha.22 → 1.0.0-alpha.24

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