@realsee/vreo 2.3.8 → 2.3.9-alpha.1

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