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