@realsee/vreo 0.2.0-alpha.7 → 0.2.0-alpha.8
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.
- package/README.md +27 -0
- package/docs/assets/search.js +1 -1
- package/docs/classes/Player.Controller.html +3 -3
- package/docs/classes/Player.Player-1.html +3 -3
- package/docs/classes/Player.VideoAgentMesh.html +11 -11
- package/docs/classes/Player.VideoAgentScene.html +1 -1
- package/docs/enums/Player.InfoPanelStyleEnum.html +1 -1
- package/docs/enums/Player.InfoPanelTypeEnum.html +1 -1
- package/docs/enums/Player.PanoEffectEnum.html +1 -1
- package/docs/enums/Player.PanoTagEnum.html +1 -1
- package/docs/enums/Player.VreoKeyframeEnum.html +12 -12
- package/docs/enums/fivePlugins.CameraMovementEffect.html +1 -1
- package/docs/enums/fivePlugins.Rotation.html +1 -1
- package/docs/index.html +20 -0
- package/docs/interfaces/Player.CustomVreoKeyframeProps.html +1 -1
- package/docs/interfaces/Player.PlayerConfigs.html +3 -3
- package/docs/interfaces/Player.Vertex.html +1 -1
- package/docs/interfaces/Player.VideoAgentMeshOptions.html +1 -1
- package/docs/interfaces/Player.VreoKeyframe.html +1 -1
- package/docs/interfaces/Player.VreoUnit.html +1 -1
- package/docs/interfaces/Player.VreoVideo.html +1 -1
- package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +1 -1
- package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +2 -2
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +1 -1
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +1 -1
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +1 -1
- package/docs/interfaces/react.VreoActionCallbacks.html +6 -6
- package/docs/interfaces/react.VreoProviderProps.html +1 -1
- package/docs/modules/Player.html +13 -13
- package/docs/modules/custom.html +1 -1
- package/docs/modules/fivePlugins.html +2 -2
- package/docs/modules/react.html +1 -1
- package/lib/PlayController/createHTMLAudioElement.d.ts +1 -0
- package/lib/PlayController/createHTMLAudioElement.js +47 -0
- package/lib/PlayController/index.d.ts +38 -0
- package/lib/PlayController/index.js +300 -0
- package/lib/Player/custom/SpatialScenePanel/index.js +0 -1
- package/lib/Player/index.d.ts +1 -1
- package/lib/Player/index.js +68 -9
- package/lib/Player/modules/keyframes/CameraMovement/index.js +41 -5
- package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +23 -15
- package/lib/Player/typings.d.ts +4 -0
- package/lib/fivePlugins/CameraMovementPlugin/index.js +101 -90
- package/lib/fivePlugins/CameraMovementPlugin/typings.d.ts +3 -2
- package/lib/typings/VreoUnit.d.ts +4 -3
- package/package.json +1 -1
- package/resources/PlayController/createHTMLAudioElement.ts +53 -0
- package/resources/PlayController/index.ts +167 -0
- package/resources/Player/custom/SpatialScenePanel/index.tsx +0 -1
- package/resources/Player/index.tsx +34 -2
- package/resources/Player/modules/keyframes/CameraMovement/index.tsx +7 -3
- package/resources/Player/modules/keyframes/UpdateVRPanorama/index.tsx +20 -15
- package/resources/Player/typings.ts +2 -0
- package/resources/fivePlugins/CameraMovementPlugin/index.ts +55 -47
- package/resources/fivePlugins/CameraMovementPlugin/typings.ts +2 -1
- package/resources/typings/VreoUnit.ts +5 -4
|
@@ -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");
|
|
@@ -201,7 +201,6 @@ function SpatialScenePanelBg() {
|
|
|
201
201
|
var listener = function listener() {
|
|
202
202
|
var _ref$current;
|
|
203
203
|
|
|
204
|
-
console.log('listener');
|
|
205
204
|
(_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.setAttribute('class', 'SpatialScenePanel-bg');
|
|
206
205
|
timeoutRef.current = setTimeout(function () {
|
|
207
206
|
var _ref$current2;
|
package/lib/Player/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ 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): Promise<boolean>;
|
|
10
10
|
get paused(): boolean;
|
|
11
11
|
play(): boolean;
|
|
12
12
|
pause(): void;
|
package/lib/Player/index.js
CHANGED
|
@@ -17,6 +17,8 @@ var _App = require("./App");
|
|
|
17
17
|
|
|
18
18
|
var _Controller = require("./Controller");
|
|
19
19
|
|
|
20
|
+
var _VreoUnit = require("../typings/VreoUnit");
|
|
21
|
+
|
|
20
22
|
var _mobx = require("mobx");
|
|
21
23
|
|
|
22
24
|
var _Drawer = require("./modules/Drawer");
|
|
@@ -112,9 +114,14 @@ var Player = /*#__PURE__*/function (_Subscribe) {
|
|
|
112
114
|
value: function () {
|
|
113
115
|
var _load = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(vreoUnit) {
|
|
114
116
|
var _this$controller$vide,
|
|
117
|
+
_this$configs$imageOp,
|
|
115
118
|
_this2 = this;
|
|
116
119
|
|
|
117
120
|
var currentTime,
|
|
121
|
+
preload,
|
|
122
|
+
panoIndexMap,
|
|
123
|
+
panoIndexs,
|
|
124
|
+
i,
|
|
118
125
|
_this$controller$vide2,
|
|
119
126
|
_this$controller$vide3,
|
|
120
127
|
_args = arguments;
|
|
@@ -124,34 +131,86 @@ var Player = /*#__PURE__*/function (_Subscribe) {
|
|
|
124
131
|
switch (_context.prev = _context.next) {
|
|
125
132
|
case 0:
|
|
126
133
|
currentTime = _args.length > 1 && _args[1] !== undefined ? _args[1] : 0;
|
|
134
|
+
preload = _args.length > 2 && _args[2] !== undefined ? _args[2] : false;
|
|
127
135
|
|
|
128
136
|
if (this.controller.visible) {
|
|
129
|
-
_context.next =
|
|
137
|
+
_context.next = 6;
|
|
130
138
|
break;
|
|
131
139
|
}
|
|
132
140
|
|
|
133
141
|
this.controller.setVisible(true); // 延迟 500ms 规避跟 DOM 动画冲突
|
|
134
142
|
|
|
135
|
-
_context.next =
|
|
143
|
+
_context.next = 6;
|
|
136
144
|
return new Promise(function (resolve) {
|
|
137
145
|
setTimeout(function () {
|
|
138
146
|
return resolve(true);
|
|
139
147
|
}, 500);
|
|
140
148
|
});
|
|
141
149
|
|
|
142
|
-
case
|
|
150
|
+
case 6:
|
|
143
151
|
if (this.controller.stopInterval) {
|
|
144
152
|
this.controller.stopInterval();
|
|
145
153
|
this.controller.stopInterval = undefined;
|
|
146
154
|
}
|
|
147
155
|
|
|
148
156
|
this.controller.vreoUnit = vreoUnit;
|
|
149
|
-
(_this$controller$vide = this.controller.videoInstance) === null || _this$controller$vide === void 0 ? void 0 : _this$controller$vide.pause(); //
|
|
157
|
+
(_this$controller$vide = this.controller.videoInstance) === null || _this$controller$vide === void 0 ? void 0 : _this$controller$vide.pause(); // 预载逻辑
|
|
158
|
+
// 是否降低图片分辨率
|
|
159
|
+
|
|
160
|
+
if (this.$five.imageOptions.size && (_this$configs$imageOp = this.configs.imageOptions) !== null && _this$configs$imageOp !== void 0 && _this$configs$imageOp.size && this.$five.imageOptions.size > this.configs.imageOptions.size) {
|
|
161
|
+
this.$five.imageOptions.size = this.configs.imageOptions.size;
|
|
162
|
+
} // 预载数据中的点位
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
if (!(preload || preload === undefined && this.configs.autoPreload)) {
|
|
166
|
+
_context.next = 20;
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
panoIndexMap = vreoUnit.keyframes.filter(function (vreoKeyframe) {
|
|
171
|
+
if (vreoKeyframe.type !== _VreoUnit.VreoKeyframeEnum.CameraMovement) {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
var data = vreoKeyframe.data;
|
|
176
|
+
|
|
177
|
+
if (data.panoIndex === undefined) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return true;
|
|
182
|
+
}).reduce(function (accu, curr) {
|
|
183
|
+
var panoIndex = curr.data.panoIndex;
|
|
150
184
|
|
|
185
|
+
if (!accu[panoIndex]) {
|
|
186
|
+
accu[panoIndex] = true;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return accu;
|
|
190
|
+
}, {});
|
|
191
|
+
panoIndexs = Object.keys(panoIndexMap);
|
|
192
|
+
i = 0;
|
|
193
|
+
|
|
194
|
+
case 14:
|
|
195
|
+
if (!(i < panoIndexs.length)) {
|
|
196
|
+
_context.next = 20;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
_context.next = 17;
|
|
201
|
+
return this.$five.preloadPano(Number(panoIndexs[i]));
|
|
202
|
+
|
|
203
|
+
case 17:
|
|
204
|
+
i++;
|
|
205
|
+
_context.next = 14;
|
|
206
|
+
break;
|
|
207
|
+
|
|
208
|
+
case 20:
|
|
209
|
+
// 新数据载入就绪
|
|
151
210
|
this.emit('loaded', vreoUnit);
|
|
152
211
|
|
|
153
212
|
if (!vreoUnit.video.url) {
|
|
154
|
-
_context.next =
|
|
213
|
+
_context.next = 26;
|
|
155
214
|
break;
|
|
156
215
|
}
|
|
157
216
|
|
|
@@ -159,19 +218,19 @@ var Player = /*#__PURE__*/function (_Subscribe) {
|
|
|
159
218
|
this.controller.videoAgentScene.videoAgentMesh.videoInstance.currentTime = currentTime / 1000;
|
|
160
219
|
}
|
|
161
220
|
|
|
162
|
-
_context.next =
|
|
221
|
+
_context.next = 25;
|
|
163
222
|
return (_this$controller$vide3 = this.controller.videoAgentScene) === null || _this$controller$vide3 === void 0 ? void 0 : _this$controller$vide3.videoAgentMesh.play(vreoUnit.video.url);
|
|
164
223
|
|
|
165
|
-
case
|
|
224
|
+
case 25:
|
|
166
225
|
this.play();
|
|
167
226
|
|
|
168
|
-
case
|
|
227
|
+
case 26:
|
|
169
228
|
this.controller.run(function (type, keyframe) {
|
|
170
229
|
return _this2.emit(type, keyframe);
|
|
171
230
|
});
|
|
172
231
|
return _context.abrupt("return", true);
|
|
173
232
|
|
|
174
|
-
case
|
|
233
|
+
case 28:
|
|
175
234
|
case "end":
|
|
176
235
|
return _context.stop();
|
|
177
236
|
}
|
|
@@ -45,13 +45,49 @@ function CameraMovement() {
|
|
|
45
45
|
cameraMovementData = data;
|
|
46
46
|
effect = cameraMovementData.effect;
|
|
47
47
|
|
|
48
|
-
if (effect === _typings.CameraMovementEffect.Rotate) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
ref.current.move(data, end - start);
|
|
48
|
+
if (!(effect === _typings.CameraMovementEffect.Rotate)) {
|
|
49
|
+
_context.next = 9;
|
|
50
|
+
break;
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
|
|
53
|
+
_context.next = 7;
|
|
54
|
+
return ref.current.rotate(data, end - start);
|
|
55
|
+
|
|
56
|
+
case 7:
|
|
57
|
+
_context.next = 21;
|
|
58
|
+
break;
|
|
59
|
+
|
|
60
|
+
case 9:
|
|
61
|
+
if (!(effect === _typings.CameraMovementEffect.Move)) {
|
|
62
|
+
_context.next = 14;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
_context.next = 12;
|
|
67
|
+
return ref.current.move(data, end - start);
|
|
68
|
+
|
|
69
|
+
case 12:
|
|
70
|
+
_context.next = 21;
|
|
71
|
+
break;
|
|
72
|
+
|
|
73
|
+
case 14:
|
|
74
|
+
if (!(cameraMovementData.panoIndex !== undefined && cameraMovementData.panoIndex !== five.panoIndex)) {
|
|
75
|
+
_context.next = 19;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
_context.next = 17;
|
|
80
|
+
return ref.current.move(data, end - start);
|
|
81
|
+
|
|
82
|
+
case 17:
|
|
83
|
+
_context.next = 21;
|
|
84
|
+
break;
|
|
85
|
+
|
|
86
|
+
case 19:
|
|
87
|
+
_context.next = 21;
|
|
88
|
+
return ref.current.rotate(data, end - start);
|
|
89
|
+
|
|
90
|
+
case 21:
|
|
55
91
|
case "end":
|
|
56
92
|
return _context.stop();
|
|
57
93
|
}
|
|
@@ -22,42 +22,45 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
22
22
|
function UpdateVRPanorama() {
|
|
23
23
|
var controller = (0, _hooks.useController)();
|
|
24
24
|
var five = (0, _hooks.useFiveInstance)();
|
|
25
|
-
var
|
|
26
|
-
var
|
|
25
|
+
var deafultWorkRef = React.useRef(null);
|
|
26
|
+
var updateWorkRef = React.useRef(null);
|
|
27
27
|
var restoreCallback = React.useCallback(function () {
|
|
28
|
-
if (
|
|
29
|
-
var work = (0, _five.parseWork)(
|
|
28
|
+
if (deafultWorkRef.current) {
|
|
29
|
+
var work = (0, _five.parseWork)(deafultWorkRef.current);
|
|
30
30
|
five.load(work);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
updateWorkRef.current = null;
|
|
34
34
|
}, []);
|
|
35
35
|
var pausedCallback = React.useCallback(function () {
|
|
36
|
-
if (
|
|
37
|
-
var work = (0, _five.parseWork)(
|
|
36
|
+
if (deafultWorkRef.current) {
|
|
37
|
+
var work = (0, _five.parseWork)(deafultWorkRef.current);
|
|
38
|
+
Object.assign(window, {
|
|
39
|
+
$rawWork: work
|
|
40
|
+
});
|
|
38
41
|
five.load(work);
|
|
39
42
|
}
|
|
40
43
|
}, []);
|
|
41
44
|
var playingCallback = React.useCallback(function () {
|
|
42
|
-
if (!
|
|
45
|
+
if (!updateWorkRef.current) {
|
|
43
46
|
return;
|
|
44
47
|
}
|
|
45
48
|
|
|
46
|
-
five.load(
|
|
49
|
+
five.load(updateWorkRef.current);
|
|
47
50
|
}, []);
|
|
48
51
|
React.useEffect(function () {
|
|
49
52
|
var callback = function callback(keyframe) {
|
|
50
53
|
var _five$work;
|
|
51
54
|
|
|
52
|
-
if (!
|
|
53
|
-
|
|
55
|
+
if (!deafultWorkRef.current) {
|
|
56
|
+
deafultWorkRef.current = five.work.raw.works;
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
var data = keyframe.data; // 如果数据中有新 work 数据,则直接载入
|
|
57
60
|
|
|
58
61
|
if (data.work) {
|
|
59
|
-
|
|
60
|
-
five.load(
|
|
62
|
+
updateWorkRef.current = (0, _five.parseWork)(data.work);
|
|
63
|
+
five.load(updateWorkRef.current);
|
|
61
64
|
return;
|
|
62
65
|
}
|
|
63
66
|
|
|
@@ -72,8 +75,13 @@ function UpdateVRPanorama() {
|
|
|
72
75
|
delete data.dynamic_scene;
|
|
73
76
|
}
|
|
74
77
|
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
Object.assign(window, {
|
|
79
|
+
$work1: JSON.parse(lastRawWork),
|
|
80
|
+
$work2: data,
|
|
81
|
+
parseWork: _five.parseWork
|
|
82
|
+
});
|
|
83
|
+
updateWorkRef.current = (0, _five.parseWork)([lastRawWork, data]);
|
|
84
|
+
five.load(updateWorkRef.current);
|
|
77
85
|
};
|
|
78
86
|
|
|
79
87
|
controller.on(_VreoUnit.VreoKeyframeEnum.UpdateVRPanorama, callback); // 离开 将之前的内容清空
|
package/lib/Player/typings.d.ts
CHANGED
|
@@ -18,6 +18,10 @@ export interface PlayerConfigs {
|
|
|
18
18
|
*/
|
|
19
19
|
customPanelChildren?: ReactNode;
|
|
20
20
|
customKeyframes?: React.FC<CustomVreoKeyframeProps>[];
|
|
21
|
+
imageOptions?: {
|
|
22
|
+
size: number;
|
|
23
|
+
};
|
|
24
|
+
autoPreload?: boolean;
|
|
21
25
|
}
|
|
22
26
|
export declare type VreoSubscribe = Pick<Subscribe<VreoKeyframeEvent>, 'on' | 'once' | 'off'>;
|
|
23
27
|
export interface CustomVreoKeyframeProps {
|