@realsee/vreo 1.0.0-alpha.5 → 1.0.0-alpha.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 +6 -11
- package/lib/PlayController/index.js +15 -80
- package/lib/Player/App.js +0 -24
- package/lib/Player/Controller.js +17 -93
- package/lib/Player/custom/SpatialScenePanel/index.js +42 -68
- package/lib/Player/hooks.js +0 -10
- package/lib/Player/index.js +24 -84
- 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 -111
- 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 +0 -11
- package/lib/Player/modules/keyframes/BgMusic/index.js +2 -15
- package/lib/Player/modules/keyframes/CameraMovement/index.js +3 -27
- package/lib/Player/modules/keyframes/InfoPanel/index.js +8 -25
- 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 +6 -23
- 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 -75
- 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/AduioLike.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 -15
- 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/resources/Player/modules/keyframes/PanoTag/index.tsx +1 -2
package/lib/Player/Controller.js
CHANGED
|
@@ -1,112 +1,66 @@
|
|
|
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 _setElementDataset = _interopRequireDefault(require("../shared-utils/setElementDataset"));
|
|
19
|
-
|
|
20
13
|
var _getMediaInfo = require("../shared-utils/getMediaInfo");
|
|
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
|
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; }
|
|
41
|
-
|
|
42
24
|
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; }
|
|
43
|
-
|
|
44
25
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
45
|
-
|
|
46
26
|
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); } }
|
|
47
|
-
|
|
48
27
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
49
|
-
|
|
50
28
|
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); }
|
|
51
|
-
|
|
52
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
53
|
-
|
|
29
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
54
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); }; }
|
|
55
|
-
|
|
56
31
|
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); }
|
|
57
|
-
|
|
58
32
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
59
|
-
|
|
60
33
|
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; } }
|
|
61
|
-
|
|
62
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
63
|
-
|
|
34
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
64
35
|
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; }
|
|
65
|
-
|
|
66
36
|
/**
|
|
67
37
|
* 逻辑控制器:内部状态。
|
|
68
38
|
*/
|
|
69
39
|
var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
70
40
|
_inherits(Controller, _Subscribe);
|
|
71
|
-
|
|
72
41
|
var _super = _createSuper(Controller);
|
|
73
|
-
|
|
74
42
|
function Controller(_ref) {
|
|
75
43
|
var _this;
|
|
76
|
-
|
|
77
44
|
var five = _ref.five,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
45
|
+
container = _ref.container,
|
|
46
|
+
configs = _ref.configs;
|
|
81
47
|
_classCallCheck(this, Controller);
|
|
82
|
-
|
|
83
48
|
_this = _super.call(this);
|
|
84
|
-
|
|
85
49
|
_defineProperty(_assertThisInitialized(_this), "playing", false);
|
|
86
|
-
|
|
87
50
|
_defineProperty(_assertThisInitialized(_this), "ended", false);
|
|
88
|
-
|
|
89
51
|
_defineProperty(_assertThisInitialized(_this), "loading", false);
|
|
90
|
-
|
|
91
52
|
_defineProperty(_assertThisInitialized(_this), "containerSize", {
|
|
92
53
|
width: 0,
|
|
93
54
|
height: 0
|
|
94
55
|
});
|
|
95
|
-
|
|
96
56
|
_defineProperty(_assertThisInitialized(_this), "waveAppearance", null);
|
|
97
|
-
|
|
98
57
|
_defineProperty(_assertThisInitialized(_this), "appearance", {
|
|
99
58
|
waveStyle: 'solid'
|
|
100
59
|
});
|
|
101
|
-
|
|
102
60
|
_defineProperty(_assertThisInitialized(_this), "avatar", {});
|
|
103
|
-
|
|
104
61
|
_defineProperty(_assertThisInitialized(_this), "visible", false);
|
|
105
|
-
|
|
106
62
|
_defineProperty(_assertThisInitialized(_this), "popUp", null);
|
|
107
|
-
|
|
108
63
|
_defineProperty(_assertThisInitialized(_this), "drawerConfig", null);
|
|
109
|
-
|
|
110
64
|
_this.configs = configs;
|
|
111
65
|
_this.container = container;
|
|
112
66
|
_this.five = five;
|
|
@@ -138,20 +92,17 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
138
92
|
return [_this.appearance.waveStyle, _this.loading];
|
|
139
93
|
}, function (_ref2) {
|
|
140
94
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
95
|
+
waveStyle = _ref3[0],
|
|
96
|
+
loading = _ref3[1];
|
|
144
97
|
if (loading === null) {
|
|
145
98
|
_this.waveAppearance = null;
|
|
146
99
|
return;
|
|
147
100
|
}
|
|
148
|
-
|
|
149
101
|
if (waveStyle === 'wave') {
|
|
150
102
|
switch (loading) {
|
|
151
103
|
case true:
|
|
152
104
|
_this.waveAppearance = 'double';
|
|
153
105
|
break;
|
|
154
|
-
|
|
155
106
|
case false:
|
|
156
107
|
_this.waveAppearance = 'solid';
|
|
157
108
|
break;
|
|
@@ -161,7 +112,6 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
161
112
|
case true:
|
|
162
113
|
_this.waveAppearance = 'swap';
|
|
163
114
|
break;
|
|
164
|
-
|
|
165
115
|
case false:
|
|
166
116
|
_this.waveAppearance = 'expand';
|
|
167
117
|
break;
|
|
@@ -170,7 +120,6 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
170
120
|
}, {
|
|
171
121
|
fireImmediately: true
|
|
172
122
|
});
|
|
173
|
-
|
|
174
123
|
if (!_this.appSize) {
|
|
175
124
|
(0, _mobx.reaction)(function () {
|
|
176
125
|
return _this.containerSize;
|
|
@@ -178,19 +127,16 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
178
127
|
if (!(containerSize !== null && containerSize !== void 0 && containerSize.width)) return;
|
|
179
128
|
var width = containerSize.width;
|
|
180
129
|
var height = containerSize.height;
|
|
181
|
-
|
|
182
130
|
var size = function () {
|
|
183
131
|
if (width <= 500) return 'S';
|
|
184
132
|
if (width <= 1024) return 'M';
|
|
185
133
|
if (width <= 2048) return 'L';
|
|
186
134
|
return 'XL';
|
|
187
135
|
}();
|
|
188
|
-
|
|
189
136
|
var orientation = function () {
|
|
190
137
|
if (height > width) return 'portrait';
|
|
191
138
|
return 'landscape';
|
|
192
139
|
}();
|
|
193
|
-
|
|
194
140
|
(0, _setElementDataset["default"])(_this.container, {
|
|
195
141
|
size: size
|
|
196
142
|
});
|
|
@@ -204,9 +150,9 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
204
150
|
(0, _setElementDataset["default"])(_this.container, {
|
|
205
151
|
size: _this.appSize
|
|
206
152
|
});
|
|
207
|
-
}
|
|
208
|
-
|
|
153
|
+
}
|
|
209
154
|
|
|
155
|
+
// 监听播放情况:抛出触发时机
|
|
210
156
|
(0, _mobx.reaction)(function () {
|
|
211
157
|
return _this.ended;
|
|
212
158
|
}, function (ended) {
|
|
@@ -223,13 +169,13 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
223
169
|
});
|
|
224
170
|
return _this;
|
|
225
171
|
}
|
|
226
|
-
|
|
227
172
|
_createClass(Controller, [{
|
|
228
173
|
key: "agentType",
|
|
229
|
-
get:
|
|
174
|
+
get:
|
|
175
|
+
// null 表示加载失败
|
|
176
|
+
|
|
230
177
|
function get() {
|
|
231
178
|
var _this$videoAgentScene, _this$avatar;
|
|
232
|
-
|
|
233
179
|
var type = (0, _getMediaInfo.getMediaType)((_this$videoAgentScene = this.videoAgentScene) === null || _this$videoAgentScene === void 0 ? void 0 : _this$videoAgentScene.videoAgentMesh.videoUrl);
|
|
234
180
|
if ((_this$avatar = this.avatar) !== null && _this$avatar !== void 0 && _this$avatar.force) return 'avatar';
|
|
235
181
|
if (type === 'video') return 'video';
|
|
@@ -242,7 +188,6 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
242
188
|
this.popUp = null;
|
|
243
189
|
return;
|
|
244
190
|
}
|
|
245
|
-
|
|
246
191
|
this.popUp = popUp;
|
|
247
192
|
}
|
|
248
193
|
}, {
|
|
@@ -288,14 +233,12 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
288
233
|
value: function openDrawer(drawerConfig) {
|
|
289
234
|
if (!drawerConfig) {
|
|
290
235
|
var _this$drawerConfig;
|
|
291
|
-
|
|
292
236
|
this.drawerConfig = {
|
|
293
237
|
content: '',
|
|
294
238
|
height: (_this$drawerConfig = this.drawerConfig) === null || _this$drawerConfig === void 0 ? void 0 : _this$drawerConfig.height
|
|
295
239
|
};
|
|
296
240
|
return;
|
|
297
241
|
}
|
|
298
|
-
|
|
299
242
|
this.drawerConfig = drawerConfig;
|
|
300
243
|
}
|
|
301
244
|
}, {
|
|
@@ -307,17 +250,15 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
307
250
|
key: "currentTime",
|
|
308
251
|
get: function get() {
|
|
309
252
|
var _this$videoAgentScene2;
|
|
310
|
-
|
|
311
253
|
return ((_this$videoAgentScene2 = this.videoAgentScene) === null || _this$videoAgentScene2 === void 0 ? void 0 : _this$videoAgentScene2.videoAgentMesh.currentTime) || 0;
|
|
312
254
|
}
|
|
313
255
|
}, {
|
|
314
256
|
key: "currentKeyframes",
|
|
315
257
|
get: function get() {
|
|
316
258
|
var _this2 = this;
|
|
317
|
-
|
|
318
259
|
if (!this.vreoUnit) return [];
|
|
319
|
-
var keyframes = this.vreoUnit.keyframes;
|
|
320
|
-
|
|
260
|
+
var keyframes = this.vreoUnit.keyframes;
|
|
261
|
+
// 没有被解析过且开始时间低于当前时间戳 100ms
|
|
321
262
|
return keyframes.filter(function (keyframe) {
|
|
322
263
|
if (keyframe.parsed) return false;
|
|
323
264
|
var dur = _this2.currentTime - keyframe.start;
|
|
@@ -328,50 +269,40 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
328
269
|
key: "mediaInstance",
|
|
329
270
|
get: function get() {
|
|
330
271
|
var _this$videoAgentScene3;
|
|
331
|
-
|
|
332
272
|
return (_this$videoAgentScene3 = this.videoAgentScene) === null || _this$videoAgentScene3 === void 0 ? void 0 : _this$videoAgentScene3.videoAgentMesh.mediaInstance;
|
|
333
273
|
}
|
|
274
|
+
|
|
334
275
|
/**
|
|
335
276
|
* 逐帧任务
|
|
336
277
|
*/
|
|
337
|
-
|
|
338
278
|
}, {
|
|
339
279
|
key: "requestAnimationFrameLoop",
|
|
340
280
|
value: function requestAnimationFrameLoop(callback) {
|
|
341
281
|
var _this$mediaInstance,
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
282
|
+
_this$mediaInstance4,
|
|
283
|
+
_this3 = this;
|
|
345
284
|
if ((_this$mediaInstance = this.mediaInstance) !== null && _this$mediaInstance !== void 0 && _this$mediaInstance.ended) {
|
|
346
285
|
this.setEnded(true);
|
|
347
286
|
this.setPlaying(false);
|
|
348
287
|
this.mediaInstance.pause();
|
|
349
288
|
return;
|
|
350
289
|
}
|
|
351
|
-
|
|
352
290
|
if (!this.playing) {
|
|
353
291
|
var _this$mediaInstance2;
|
|
354
|
-
|
|
355
292
|
if (!((_this$mediaInstance2 = this.mediaInstance) !== null && _this$mediaInstance2 !== void 0 && _this$mediaInstance2.paused)) {
|
|
356
293
|
var _this$mediaInstance3;
|
|
357
|
-
|
|
358
294
|
(_this$mediaInstance3 = this.mediaInstance) === null || _this$mediaInstance3 === void 0 ? void 0 : _this$mediaInstance3.pause();
|
|
359
295
|
}
|
|
360
|
-
|
|
361
296
|
return;
|
|
362
297
|
}
|
|
363
|
-
|
|
364
298
|
if ((_this$mediaInstance4 = this.mediaInstance) !== null && _this$mediaInstance4 !== void 0 && _this$mediaInstance4.paused && this.playing) {
|
|
365
299
|
this.mediaInstance.play();
|
|
366
300
|
}
|
|
367
|
-
|
|
368
301
|
var currentKeyframes = this.currentKeyframes;
|
|
369
302
|
currentKeyframes.forEach(function (keyframe) {
|
|
370
303
|
if (keyframe.parsed) return;
|
|
371
304
|
keyframe.parsed = true;
|
|
372
|
-
|
|
373
305
|
_this3.emit(keyframe.type, keyframe);
|
|
374
|
-
|
|
375
306
|
if (callback) {
|
|
376
307
|
callback(keyframe.type, keyframe);
|
|
377
308
|
}
|
|
@@ -381,7 +312,6 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
381
312
|
key: "run",
|
|
382
313
|
value: function run(callback) {
|
|
383
314
|
var _this4 = this;
|
|
384
|
-
|
|
385
315
|
if (this.stopInterval) return;
|
|
386
316
|
this.stopInterval = (0, _animationFrame.requestAnimationFrameInterval)(function () {
|
|
387
317
|
return _this4.requestAnimationFrameLoop(callback);
|
|
@@ -391,33 +321,27 @@ var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
391
321
|
key: "dispose",
|
|
392
322
|
value: function dispose() {
|
|
393
323
|
this.setPlaying(false);
|
|
394
|
-
|
|
395
324
|
if (this.currentKeyframes) {
|
|
396
325
|
this.currentKeyframes.forEach(function (keyframe) {
|
|
397
326
|
return keyframe.parsed = false;
|
|
398
327
|
});
|
|
399
328
|
}
|
|
329
|
+
|
|
400
330
|
/**
|
|
401
331
|
* 清理掉数据
|
|
402
332
|
*/
|
|
403
|
-
|
|
404
|
-
|
|
405
333
|
this.vreoUnit = undefined;
|
|
406
|
-
|
|
407
334
|
if (this.mediaInstance) {
|
|
408
335
|
this.mediaInstance.currentTime = 0;
|
|
409
336
|
}
|
|
410
|
-
|
|
411
337
|
if (this.stopInterval) {
|
|
412
338
|
this.stopInterval();
|
|
413
339
|
this.stopInterval = undefined;
|
|
414
340
|
}
|
|
415
341
|
}
|
|
416
342
|
}]);
|
|
417
|
-
|
|
418
343
|
return Controller;
|
|
419
344
|
}(_five.Subscribe);
|
|
420
|
-
|
|
421
345
|
exports.Controller = Controller;
|
|
422
346
|
var ControllerContext = /*#__PURE__*/React.createContext(null);
|
|
423
347
|
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) {
|