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