@realsee/vreo 0.2.0-alpha.1 → 0.2.0-alpha.12

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 (97) hide show
  1. package/README.md +104 -17
  2. package/docs/assets/custom.css +4 -4
  3. package/docs/assets/search.js +1 -1
  4. package/docs/classes/Player.Controller.html +54 -0
  5. package/docs/classes/Player.Player-1.html +9 -9
  6. package/docs/classes/Player.VideoAgentMesh.html +142 -0
  7. package/docs/classes/Player.VideoAgentScene.html +1 -0
  8. package/docs/enums/Player.InfoPanelStyleEnum.html +1 -0
  9. package/docs/enums/Player.InfoPanelTypeEnum.html +1 -1
  10. package/docs/enums/Player.PanoEffectEnum.html +2 -2
  11. package/docs/enums/Player.PanoTagEnum.html +1 -1
  12. package/docs/enums/Player.PanoTagStyleEnum.html +7 -0
  13. package/docs/enums/Player.VreoKeyframeEnum.html +13 -13
  14. package/docs/enums/fivePlugins.CameraMovementEffect.html +1 -1
  15. package/docs/enums/fivePlugins.Rotation.html +1 -1
  16. package/docs/index.html +53 -20
  17. package/docs/interfaces/Player.CustomVreoKeyframeProps.html +1 -0
  18. package/docs/interfaces/Player.PlayerConfigs.html +3 -3
  19. package/docs/interfaces/Player.Vertex.html +1 -1
  20. package/docs/interfaces/Player.VideoAgentMeshOptions.html +1 -0
  21. package/docs/interfaces/Player.VreoKeyframe.html +1 -1
  22. package/docs/interfaces/Player.VreoUnit.html +1 -1
  23. package/docs/interfaces/Player.VreoVideo.html +1 -1
  24. package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +1 -1
  25. package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +3 -3
  26. package/docs/interfaces/fivePlugins.CameraMovementPluginParameterType.html +1 -1
  27. package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +1 -1
  28. package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +1 -1
  29. package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +1 -1
  30. package/docs/interfaces/react.VreoActionCallbacks.html +15 -7
  31. package/docs/interfaces/react.VreoProviderProps.html +1 -0
  32. package/docs/modules/Player.html +17 -15
  33. package/docs/modules/custom.html +3 -0
  34. package/docs/modules/fivePlugins.html +2 -2
  35. package/docs/modules/react.html +1 -1
  36. package/docs/modules.html +1 -1
  37. package/lib/PlayController/createHTMLAudioElement.d.ts +1 -0
  38. package/lib/PlayController/createHTMLAudioElement.js +47 -0
  39. package/lib/PlayController/index.d.ts +38 -0
  40. package/lib/PlayController/index.js +300 -0
  41. package/lib/Player/App.js +4 -3
  42. package/lib/Player/Controller.d.ts +2 -0
  43. package/lib/Player/Controller.js +14 -0
  44. package/lib/Player/custom/SpatialScenePanel/index.d.ts +22 -0
  45. package/lib/Player/custom/SpatialScenePanel/index.js +279 -0
  46. package/lib/Player/index.d.ts +2 -2
  47. package/lib/Player/index.js +102 -12
  48. package/lib/Player/modules/PopUp/index.d.ts +2 -0
  49. package/lib/Player/modules/PopUp/index.js +43 -0
  50. package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +2 -1
  51. package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +26 -20
  52. package/lib/Player/modules/VideoAgent/VideoAgentScene.d.ts +4 -1
  53. package/lib/Player/modules/VideoAgent/VideoAgentScene.js +2 -1
  54. package/lib/Player/modules/VideoAgent/index.d.ts +2 -0
  55. package/lib/Player/modules/VideoAgent/index.js +1 -1
  56. package/lib/Player/modules/keyframes/CameraMovement/index.js +41 -5
  57. package/lib/Player/modules/keyframes/InfoPanel/index.js +84 -36
  58. package/lib/Player/modules/keyframes/ModelVideo/index.js +45 -8
  59. package/lib/Player/modules/keyframes/PanoTag/index.js +19 -6
  60. package/lib/Player/modules/keyframes/PanoTextLabel/index.js +4 -12
  61. package/lib/Player/modules/keyframes/Prompter/index.js +4 -18
  62. package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +30 -18
  63. package/lib/Player/typings.d.ts +15 -2
  64. package/lib/fivePlugins/CameraMovementPlugin/index.js +104 -90
  65. package/lib/fivePlugins/CameraMovementPlugin/typings.d.ts +1 -0
  66. package/lib/react/index.d.ts +12 -4
  67. package/lib/react/index.js +3 -3
  68. package/lib/shared-utils/createTransMatrix.d.ts +1 -0
  69. package/lib/shared-utils/createTransMatrix.js +43 -0
  70. package/lib/typings/VreoUnit.d.ts +32 -6
  71. package/lib/typings/VreoUnit.js +26 -6
  72. package/package.json +6 -6
  73. package/resources/PlayController/createHTMLAudioElement.ts +53 -0
  74. package/resources/PlayController/index.ts +167 -0
  75. package/resources/Player/App.tsx +3 -1
  76. package/resources/Player/Controller.ts +12 -0
  77. package/resources/Player/custom/SpatialScenePanel/index.tsx +264 -0
  78. package/resources/Player/index.tsx +59 -4
  79. package/resources/Player/modules/PopUp/index.tsx +26 -0
  80. package/resources/Player/modules/VideoAgent/VideoAgentMesh.ts +7 -6
  81. package/resources/Player/modules/VideoAgent/VideoAgentScene.ts +2 -2
  82. package/resources/Player/modules/VideoAgent/index.tsx +3 -2
  83. package/resources/Player/modules/keyframes/CameraMovement/index.tsx +7 -3
  84. package/resources/Player/modules/keyframes/InfoPanel/index.tsx +90 -23
  85. package/resources/Player/modules/keyframes/ModelVideo/index.tsx +36 -3
  86. package/resources/Player/modules/keyframes/PanoTag/index.tsx +31 -12
  87. package/resources/Player/modules/keyframes/PanoTextLabel/index.tsx +2 -2
  88. package/resources/Player/modules/keyframes/Prompter/index.tsx +5 -15
  89. package/resources/Player/modules/keyframes/UpdateVRPanorama/index.tsx +25 -16
  90. package/resources/Player/typings.ts +17 -2
  91. package/resources/fivePlugins/CameraMovementPlugin/index.ts +59 -48
  92. package/resources/fivePlugins/CameraMovementPlugin/typings.ts +2 -1
  93. package/resources/react/index.tsx +14 -5
  94. package/resources/shared-utils/createTransMatrix.ts +12 -0
  95. package/resources/typings/VreoUnit.ts +42 -7
  96. package/stylesheets/custom/SpatialScenePanel.css +309 -0
  97. package/stylesheets/default.css +116 -10
@@ -0,0 +1,300 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.PlayController = void 0;
9
+
10
+ var _five = require("@realsee/five");
11
+
12
+ var _animationFrame = require("../shared-utils/animationFrame");
13
+
14
+ var _createHTMLAudioElement = require("./createHTMLAudioElement");
15
+
16
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
17
+
18
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
19
+
20
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
21
+
22
+ 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); } }
23
+
24
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
25
+
26
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
27
+
28
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
29
+
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); }; }
31
+
32
+ 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); }
33
+
34
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
35
+
36
+ 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; } }
37
+
38
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
39
+
40
+ 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; }
41
+
42
+ var closures = {};
43
+
44
+ var PlayController = /*#__PURE__*/function (_Subscribe) {
45
+ _inherits(PlayController, _Subscribe);
46
+
47
+ var _super = _createSuper(PlayController);
48
+
49
+ function PlayController() {
50
+ var _this;
51
+
52
+ var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
53
+
54
+ _classCallCheck(this, PlayController);
55
+
56
+ _this = _super.call(this);
57
+
58
+ _defineProperty(_assertThisInitialized(_this), "config", {});
59
+
60
+ if (!config.audio) {
61
+ config.audio = (0, _createHTMLAudioElement.createHTMLAudioElement)();
62
+ }
63
+
64
+ _this.config = Object.assign(_this.config, config);
65
+
66
+ closures.onPlaying = function () {
67
+ return _this.emit('playing');
68
+ };
69
+
70
+ closures.onPaused = function () {
71
+ return _this.emit('paused');
72
+ };
73
+
74
+ closures.onEnded = function () {
75
+ return _this.emit('paused', true);
76
+ };
77
+
78
+ _this.audioInstance.addEventListener('play', closures.onPlaying);
79
+
80
+ _this.audioInstance.addEventListener('pause', closures.onPaused);
81
+
82
+ _this.audioInstance.addEventListener('ended', closures.onEnded);
83
+
84
+ _this.stopInterval = (0, _animationFrame.requestAnimationFrameInterval)(function () {
85
+ if (_this.audioInstance.paused) {
86
+ return;
87
+ }
88
+
89
+ if (!_this.vreoUnit) {
90
+ return;
91
+ }
92
+
93
+ var keyframes = _this.vreoUnit.keyframes;
94
+ var currentTime = _this.currentTime; // 没有被解析过且开始时间低于当前时间戳 100ms
95
+
96
+ var currentKeyframes = keyframes.filter(function (keyframe) {
97
+ if (keyframe.parsed) return false;
98
+ var dur = currentTime - keyframe.start;
99
+ return dur <= 60 && dur >= 0;
100
+ });
101
+ currentKeyframes.forEach(function (keyframe) {
102
+ if (keyframe.parsed) return;
103
+ keyframe.parsed = true;
104
+
105
+ _this.emit(keyframe.type, keyframe);
106
+ });
107
+ });
108
+ return _this;
109
+ }
110
+ /**
111
+ * 载入数据
112
+ */
113
+
114
+
115
+ _createClass(PlayController, [{
116
+ key: "paused",
117
+ get: function get() {
118
+ return this.audioInstance.paused;
119
+ }
120
+ }, {
121
+ key: "audioInstance",
122
+ get: function get() {
123
+ return this.config.audio;
124
+ }
125
+ }, {
126
+ key: "currentTime",
127
+ get: function get() {
128
+ return this.audioInstance.currentTime * 1000;
129
+ }
130
+ }, {
131
+ key: "currentKeyframes",
132
+ get: function get() {
133
+ var _this2 = this;
134
+
135
+ if (!this.vreoUnit) return [];
136
+ var keyframes = this.vreoUnit.keyframes; // 没有被解析过且开始时间低于当前时间戳 100ms
137
+
138
+ return keyframes.filter(function (keyframe) {
139
+ if (keyframe.parsed) return false;
140
+ var dur = _this2.currentTime - keyframe.start;
141
+ return dur <= 100 && dur >= 0;
142
+ });
143
+ }
144
+ /**
145
+ * 音频时长 不一定能获取得到,建议以 VreoUnit 配置的时长为准。
146
+ */
147
+
148
+ }, {
149
+ key: "duration",
150
+ get: function get() {
151
+ return this.audioInstance.duration * 1000;
152
+ }
153
+ }, {
154
+ key: "load",
155
+ value: function () {
156
+ var _load = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(vreoUnit) {
157
+ var _this3 = this;
158
+
159
+ return regeneratorRuntime.wrap(function _callee$(_context) {
160
+ while (1) {
161
+ switch (_context.prev = _context.next) {
162
+ case 0:
163
+ this.vreoUnit = vreoUnit;
164
+ _context.next = 3;
165
+ return this.pause();
166
+
167
+ case 3:
168
+ _context.next = 5;
169
+ return new Promise(function (resolve, reject) {
170
+ if (vreoUnit.video.url === _this3.audioInstance.src) {
171
+ return resolve(true);
172
+ }
173
+
174
+ _this3.audioInstance.src = vreoUnit.video.url;
175
+
176
+ var canplaythrough = function canplaythrough() {
177
+ resolve(true);
178
+
179
+ _this3.audioInstance.removeEventListener('canplaythrough', canplaythrough);
180
+ };
181
+
182
+ var error = function error(err) {
183
+ reject(err);
184
+
185
+ _this3.audioInstance.removeEventListener('error', error);
186
+ };
187
+
188
+ _this3.audioInstance.addEventListener('canplaythrough', canplaythrough);
189
+
190
+ _this3.audioInstance.addEventListener('error', error);
191
+ });
192
+
193
+ case 5:
194
+ return _context.abrupt("return", _context.sent);
195
+
196
+ case 6:
197
+ case "end":
198
+ return _context.stop();
199
+ }
200
+ }
201
+ }, _callee, this);
202
+ }));
203
+
204
+ function load(_x) {
205
+ return _load.apply(this, arguments);
206
+ }
207
+
208
+ return load;
209
+ }()
210
+ /**
211
+ * 播放
212
+ */
213
+
214
+ }, {
215
+ key: "play",
216
+ value: function () {
217
+ var _play = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
218
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
219
+ while (1) {
220
+ switch (_context2.prev = _context2.next) {
221
+ case 0:
222
+ closures.playPromise = this.audioInstance.play();
223
+
224
+ case 1:
225
+ case "end":
226
+ return _context2.stop();
227
+ }
228
+ }
229
+ }, _callee2, this);
230
+ }));
231
+
232
+ function play() {
233
+ return _play.apply(this, arguments);
234
+ }
235
+
236
+ return play;
237
+ }()
238
+ /**
239
+ * 暂停
240
+ */
241
+
242
+ }, {
243
+ key: "pause",
244
+ value: function () {
245
+ var _pause = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
246
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
247
+ while (1) {
248
+ switch (_context3.prev = _context3.next) {
249
+ case 0:
250
+ if (!closures.playPromise) {
251
+ _context3.next = 3;
252
+ break;
253
+ }
254
+
255
+ _context3.next = 3;
256
+ return closures.playPromise;
257
+
258
+ case 3:
259
+ this.audioInstance.pause();
260
+
261
+ case 4:
262
+ case "end":
263
+ return _context3.stop();
264
+ }
265
+ }
266
+ }, _callee3, this);
267
+ }));
268
+
269
+ function pause() {
270
+ return _pause.apply(this, arguments);
271
+ }
272
+
273
+ return pause;
274
+ }()
275
+ /**
276
+ * 销毁资源
277
+ * @notice 一旦销毁,创建的实例将不可用:需重新创建实例。
278
+ *
279
+ * @deprecated **慎重执行**
280
+ */
281
+
282
+ }, {
283
+ key: "dispose",
284
+ value: function dispose() {
285
+ // 清理事件监听
286
+ this.audioInstance.removeEventListener('play', closures.onPlaying);
287
+ this.audioInstance.removeEventListener('pasue', closures.onPaused);
288
+ this.audioInstance.removeEventListener('ended', closures.onEnded);
289
+
290
+ if (this.stopInterval) {
291
+ this.stopInterval();
292
+ }
293
+ }
294
+ }]);
295
+
296
+ return PlayController;
297
+ }(_five.Subscribe);
298
+
299
+ exports.PlayController = PlayController;
300
+ console.log("\n\n\u250F\u2501\u2501\u2501\u2513\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u250F\u2513\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\u2503\u250F\u2501\u2513\u2503\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2503\u2503\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\u2503\u2517\u2501\u251B\u2503\u250F\u2501\u2501\u2513\u250F\u2501\u2501\u2513\u2501\u2503\u2503\u2501\u250F\u2501\u2501\u2513\u250F\u2501\u2501\u2513\u250F\u2501\u2501\u2513\n\u2503\u250F\u2513\u250F\u251B\u2503\u250F\u2513\u2503\u2517\u2501\u2513\u2503\u2501\u2503\u2503\u2501\u2503\u2501\u2501\u252B\u2503\u250F\u2513\u2503\u2503\u250F\u2513\u2503\n\u2503\u2503\u2503\u2517\u2513\u2503\u2503\u2501\u252B\u2503\u2517\u251B\u2517\u2513\u2503\u2517\u2513\u2523\u2501\u2501\u2503\u2503\u2503\u2501\u252B\u2503\u2503\u2501\u252B\n\u2517\u251B\u2517\u2501\u251B\u2517\u2501\u2501\u251B\u2517\u2501\u2501\u2501\u251B\u2517\u2501\u251B\u2517\u2501\u2501\u251B\u2517\u2501\u2501\u251B\u2517\u2501\u2501\u251B\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 \n\n");
package/lib/Player/App.js CHANGED
@@ -44,7 +44,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
44
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
45
 
46
46
  var AppView = (0, _mobxReact.observer)(function (_ref) {
47
- var _controller$configs;
47
+ var _controller$configs, _controller$configs2;
48
48
 
49
49
  var controller = _ref.controller;
50
50
  return /*#__PURE__*/React.createElement("div", {
@@ -64,8 +64,9 @@ var AppView = (0, _mobxReact.observer)(function (_ref) {
64
64
  } else {
65
65
  controller.setPlaying(true);
66
66
  }
67
- }
68
- }), /*#__PURE__*/React.createElement(_Prompter.Prompter, null), (_controller$configs = controller.configs) === null || _controller$configs === void 0 ? void 0 : _controller$configs.customPanelChildren));
67
+ },
68
+ options: ((_controller$configs = controller.configs) === null || _controller$configs === void 0 ? void 0 : _controller$configs.videoAgentMeshOptions) || {}
69
+ }), /*#__PURE__*/React.createElement(_Prompter.Prompter, null), (_controller$configs2 = controller.configs) === null || _controller$configs2 === void 0 ? void 0 : _controller$configs2.customPanelChildren));
69
70
  });
70
71
 
71
72
  function App() {
@@ -15,6 +15,8 @@ export declare class Controller extends Subscribe<VreoKeyframeEvent> {
15
15
  playing: boolean;
16
16
  visible: boolean;
17
17
  get isAudio(): boolean;
18
+ popUp: string | JSX.Element | null;
19
+ openPopUp(popUp: string | JSX.Element | false): void;
18
20
  drawerConfig: {
19
21
  content: string | JSX.Element;
20
22
  height?: number | string;
@@ -60,6 +60,8 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
60
60
 
61
61
  _defineProperty(_assertThisInitialized(_this), "visible", false);
62
62
 
63
+ _defineProperty(_assertThisInitialized(_this), "popUp", null);
64
+
63
65
  _defineProperty(_assertThisInitialized(_this), "drawerConfig", null);
64
66
 
65
67
  (0, _mobx.makeObservable)(_assertThisInitialized(_this), {
@@ -67,6 +69,8 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
67
69
  setVisible: _mobx.action,
68
70
  playing: _mobx.observable,
69
71
  setPlaying: _mobx.action,
72
+ popUp: _mobx.observable.ref,
73
+ openPopUp: _mobx.action,
70
74
  drawerConfig: _mobx.observable.ref,
71
75
  openDrawer: _mobx.action
72
76
  }); // 监听播放情况:抛出触发时机
@@ -86,6 +90,16 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
86
90
 
87
91
  return !((_this$videoAgentScene = this.videoAgentScene) !== null && _this$videoAgentScene !== void 0 && (_this$videoAgentScene2 = _this$videoAgentScene.videoAgentMesh.videoUrl) !== null && _this$videoAgentScene2 !== void 0 && _this$videoAgentScene2.endsWith('.mp4'));
88
92
  }
93
+ }, {
94
+ key: "openPopUp",
95
+ value: function openPopUp(popUp) {
96
+ if (!popUp) {
97
+ this.popUp = null;
98
+ return;
99
+ }
100
+
101
+ this.popUp = popUp;
102
+ }
89
103
  }, {
90
104
  key: "setVisible",
91
105
  value: function setVisible(v) {
@@ -0,0 +1,22 @@
1
+ /// <reference types="react" />
2
+ import { CustomVreoKeyframeProps } from '../../typings';
3
+ export interface SpatialScenePanelData {
4
+ customType: 'SpatialScenePanel';
5
+ title: string;
6
+ temperature: string;
7
+ stateList: {
8
+ text: string;
9
+ icon: string;
10
+ }[];
11
+ position?: {
12
+ x: number;
13
+ y: number;
14
+ z: number;
15
+ };
16
+ quaternion?: [number, number, number, number];
17
+ }
18
+ /**
19
+ * 空间场景面板
20
+ * @returns
21
+ */
22
+ export declare function SpatialScenePanel(props: CustomVreoKeyframeProps): JSX.Element;
@@ -0,0 +1,279 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.SpatialScenePanel = SpatialScenePanel;
9
+
10
+ var React = _interopRequireWildcard(require("react"));
11
+
12
+ var _reactDom = _interopRequireDefault(require("react-dom"));
13
+
14
+ var _three = require("three");
15
+
16
+ var _BetterTween = require("@realsee/dnalogel/shared-utils/animationFrame/BetterTween");
17
+
18
+ var _CSS3DRenderPlugin = require("@realsee/dnalogel/plugins/CSS3DRenderPlugin");
19
+
20
+ var _VreoUnit = require("../../../typings/VreoUnit");
21
+
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
+
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
+
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
+
28
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
29
+
30
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
31
+
32
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
33
+
34
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
35
+
36
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
37
+
38
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
39
+
40
+ // const getSphere = (position: Vector3, color = 0xffff00) => {
41
+ // const geometry = new SphereGeometry(0.05, 32, 16)
42
+ // const material = new MeshBasicMaterial({ color })
43
+ // const sphere = new Mesh(geometry, material)
44
+ // sphere.position.copy(position)
45
+ // return sphere
46
+ // }
47
+ var searchV1 = function searchV1(_ref) {
48
+ var five = _ref.five,
49
+ dom = _ref.dom;
50
+ var cameraDirection = new _three.Vector3();
51
+ five.camera.getWorldDirection(cameraDirection);
52
+ var cameraPosition = five.camera.position;
53
+
54
+ 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
+
58
+ var point = five.project2d(intersect.point);
59
+ var widescreen = window.innerWidth > 560 ? true : false; // const width = dom!.clientWidth
60
+
61
+ var height = dom.clientHeight;
62
+ dom.style.left = point.x + 'px';
63
+ dom.style.top = point.y - height / 2 + 'px';
64
+ var rect = dom.getBoundingClientRect();
65
+ var left = rect.left,
66
+ top = rect.top,
67
+ bottom = rect.bottom,
68
+ right = rect.right;
69
+ var leftBottom = new _three.Vector3(left, bottom);
70
+ var leftTop = new _three.Vector3(left, top);
71
+ var rightTop = new _three.Vector3(right, top);
72
+ var rightBottom = new _three.Vector3(right, bottom);
73
+ var points = [leftBottom, rightBottom, rightTop, leftTop].map(function (point) {
74
+ point.setX(point.x / window.innerWidth * 2 - (widescreen ? 1.25 : 1.75));
75
+ point.setY(-(point.y / window.innerHeight) * 2 + (widescreen ? 1.35 : 1.125));
76
+ point.setZ(0.5);
77
+ return point.unproject(five.camera).addScaledVector(cameraDirection, 0.2);
78
+ }); // __debug__
79
+ // const colors = [0xdc143c, 0xffff00, 0x0000ff, 0x008000]
80
+ // points.forEach((p, index) => five.scene.add(getSphere(p, colors[index])))
81
+ // 判断是手机 150
82
+
83
+ var ratio = leftBottom.distanceTo(rightBottom) / (widescreen ? 150 : 120);
84
+ return {
85
+ points: points,
86
+ ratio: ratio
87
+ };
88
+ };
89
+ /**
90
+ * 空间场景面板
91
+ * @returns
92
+ */
93
+
94
+
95
+ function SpatialScenePanel(props) {
96
+ var timeoutRef = React.useRef(null);
97
+ var ref = React.useRef(null);
98
+ var panelRef = React.useRef(null);
99
+ var rendererRef = React.useRef((0, _CSS3DRenderPlugin.CSS3DRenderPlugin)(props.five));
100
+ React.useEffect(function () {
101
+ if (!ref.current) {
102
+ return;
103
+ }
104
+
105
+ var callback = function callback(keyframe) {
106
+ if (keyframe.data.customType !== 'SpatialScenePanel') {
107
+ return;
108
+ }
109
+
110
+ var data = keyframe.data; // const data = mockData
111
+
112
+ var _searchV = searchV1({
113
+ five: props.five,
114
+ dom: ref.current
115
+ }),
116
+ points = _searchV.points,
117
+ ratio = _searchV.ratio;
118
+
119
+ 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
+
128
+ Object.assign(window, {
129
+ $css3DObject: css3DObject
130
+ });
131
+ if (!container) return;
132
+
133
+ _reactDom["default"].render( /*#__PURE__*/React.createElement(Panel, {
134
+ ref: function ref(_ref3) {
135
+ return panelRef.current = _ref3;
136
+ },
137
+ data: data
138
+ }), container);
139
+
140
+ var startRotateY = -(Math.PI * 2) / 9;
141
+ var lastRotateY = 0;
142
+ (0, _BetterTween.tweenProgress)(1000).onUpdate(function (_ref4) {
143
+ var progress = _ref4.progress;
144
+ var needRotateY = Math.PI / 90 * 11 * progress;
145
+ var rotateY = needRotateY - lastRotateY;
146
+ css3DObject === null || css3DObject === void 0 ? void 0 : css3DObject.rotateY(rotateY); // css3DObject?.rotateZ
147
+
148
+ lastRotateY = needRotateY;
149
+ }).onStart(function () {
150
+ css3DObject === null || css3DObject === void 0 ? void 0 : css3DObject.rotateY(startRotateY);
151
+ render();
152
+ }).onDispose(function () {
153
+ var _panelRef$current;
154
+
155
+ (_panelRef$current = panelRef.current) === null || _panelRef$current === void 0 ? void 0 : _panelRef$current.classList.add('show');
156
+ }).play(); // Object.assign(window, { $dispose: () => {
157
+ // panelRef.current?.classList.add('hide')
158
+ // setTimeout(() => dispose?.(), 1500)
159
+ // } })
160
+
161
+ var start = keyframe.start,
162
+ end = keyframe.end;
163
+ timeoutRef.current = setTimeout(function () {
164
+ var _panelRef$current2;
165
+
166
+ (_panelRef$current2 = panelRef.current) === null || _panelRef$current2 === void 0 ? void 0 : _panelRef$current2.classList.add('hide');
167
+ timeoutRef.current = setTimeout(function () {
168
+ dispose === null || dispose === void 0 ? void 0 : dispose();
169
+ timeoutRef.current = null;
170
+ }, 1500);
171
+ }, end - start);
172
+ };
173
+
174
+ Object.assign(window, {
175
+ $callback: callback
176
+ }); // setTimeout(() => {callback()}, 8000)
177
+
178
+ props.subscribe.on(_VreoUnit.VreoKeyframeEnum.Custom, callback);
179
+ return function () {
180
+ props.subscribe.off(_VreoUnit.VreoKeyframeEnum.Custom, callback);
181
+
182
+ if (timeoutRef.current) {
183
+ clearTimeout(timeoutRef.current);
184
+ }
185
+ };
186
+ }, []);
187
+ return /*#__PURE__*/React.createElement("div", {
188
+ className: "vreo-SpatialScenePanel",
189
+ ref: ref
190
+ });
191
+ }
192
+ /** 背景动画:控制延迟 */
193
+
194
+
195
+ function SpatialScenePanelBg() {
196
+ var ref = React.useRef(null);
197
+ var timeoutRef = React.useRef(null);
198
+ React.useEffect(function () {
199
+ if (!ref.current) return;
200
+
201
+ var listener = function listener() {
202
+ var _ref$current;
203
+
204
+ (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.setAttribute('class', 'SpatialScenePanel-bg');
205
+ timeoutRef.current = setTimeout(function () {
206
+ var _ref$current2;
207
+
208
+ (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.setAttribute('class', 'SpatialScenePanel-bg SpatialScenePanel-bg--animation');
209
+ timeoutRef.current = null;
210
+ }, 3000);
211
+ };
212
+
213
+ ref.current.addEventListener('animationend', listener);
214
+ return function () {
215
+ if (ref.current) ref.current.removeEventListener('animationend', listener);
216
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
217
+ };
218
+ }, []);
219
+ return /*#__PURE__*/React.createElement("div", {
220
+ ref: ref,
221
+ className: "SpatialScenePanel-bg SpatialScenePanel-bg--animation"
222
+ });
223
+ }
224
+
225
+ var Panel = /*#__PURE__*/React.forwardRef(function (props, myRef) {
226
+ var _props$data, _props$data2, _props$data3, _props$data3$stateLis;
227
+
228
+ return /*#__PURE__*/React.createElement("div", {
229
+ className: "SpatialScenePanel",
230
+ ref: myRef
231
+ }, /*#__PURE__*/React.createElement("div", {
232
+ className: "SpatialScenePanel-show-area"
233
+ }, /*#__PURE__*/React.createElement(SpatialScenePanelBg, null), /*#__PURE__*/React.createElement("div", {
234
+ className: "SpatialScenePanel-header"
235
+ }, /*#__PURE__*/React.createElement("div", {
236
+ className: "SpatialScenePanel-title"
237
+ }, (_props$data = props.data) === null || _props$data === void 0 ? void 0 : _props$data.title), /*#__PURE__*/React.createElement("div", {
238
+ className: "SpatialScenePanel-temperature"
239
+ }, (_props$data2 = props.data) === null || _props$data2 === void 0 ? void 0 : _props$data2.temperature, "\u2103")), /*#__PURE__*/React.createElement("div", {
240
+ className: "SpatialScenePanel-body"
241
+ }, (_props$data3 = props.data) === null || _props$data3 === void 0 ? void 0 : (_props$data3$stateLis = _props$data3.stateList) === null || _props$data3$stateLis === void 0 ? void 0 : _props$data3$stateLis.map(function (state, index) {
242
+ return /*#__PURE__*/React.createElement("div", {
243
+ key: "scene-".concat(state.text),
244
+ className: "SpatialScenePanel-item index_".concat(index)
245
+ }, /*#__PURE__*/React.createElement("img", {
246
+ className: "SpatialScenePanel-icon",
247
+ src: state.icon
248
+ }), /*#__PURE__*/React.createElement("div", {
249
+ className: "SpatialScenePanel-text"
250
+ }, state.text), /*#__PURE__*/React.createElement("div", {
251
+ className: "SpatialScenePanel-dot"
252
+ }));
253
+ }))), /*#__PURE__*/React.createElement("div", {
254
+ className: "SpatialScenePanel-disappear-area"
255
+ }));
256
+ }); // export function SpatialScenePanel() {
257
+ // // const data = mockData
258
+ // return (
259
+ // <div className="SpatialScenePanel" >
260
+ // <div className="SpatialScenePanel-show-area">
261
+ // <SpatialScenePanelBg />
262
+ // <div className="SpatialScenePanel-header">
263
+ // <div className="SpatialScenePanel-title">{data?.title}</div>
264
+ // <div className="SpatialScenePanel-temperature">{data?.temperature}℃</div>
265
+ // </div>
266
+ // <div className="SpatialScenePanel-body">
267
+ // {data?.stateList?.map((state, index) => (
268
+ // <div key={`scene-${state.text}`} className={`SpatialScenePanel-item index_${index}`}>
269
+ // <img className="SpatialScenePanel-icon" src={state.icon}></img>
270
+ // <div className="SpatialScenePanel-text">{state.text}</div>
271
+ // <div className="SpatialScenePanel-dot"></div>
272
+ // </div>
273
+ // ))}
274
+ // </div>
275
+ // </div>
276
+ // <div className="SpatialScenePanel-disappear-area"></div>
277
+ // </div>
278
+ // )
279
+ // }
@@ -6,9 +6,9 @@ export declare class Player extends Subscribe<VreoKeyframeEvent> {
6
6
  private controller;
7
7
  configs: Readonly<PlayerConfigs>;
8
8
  constructor(five: Five, configs?: Partial<PlayerConfigs>);
9
- load(vreoUnit: VreoUnit, currentTime?: number): Promise<boolean>;
9
+ load(vreoUnit: VreoUnit, currentTime?: number, preload?: boolean, force?: boolean): Promise<boolean>;
10
10
  get paused(): boolean;
11
- play(): boolean;
11
+ play(currentTime?: number): boolean;
12
12
  pause(): void;
13
13
  show(): void;
14
14
  hide(): void;