@realsee/vreo 2.4.7 → 2.5.0-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/README.md +1 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/Player.AudioLike.html +2 -2
- package/docs/classes/Player.Controller.html +52 -4
- package/docs/classes/Player.Player.html +43 -2
- package/docs/classes/Player.VideoAgentMesh.html +61 -4
- package/docs/classes/Player.VideoAgentScene.html +2 -2
- package/docs/demo/assets/{examples-5qw3pq5z.js → examples-DfiAz2fR.js} +1 -1
- package/docs/demo/assets/react-BnzBLum3.css +1 -0
- package/docs/demo/examples.html +1 -1
- package/docs/demo/index-react.html +2 -2
- package/docs/demo/index.html +1 -1
- package/docs/enums/Player.InfoPanelStyleEnum.html +2 -2
- package/docs/enums/Player.InfoPanelTypeEnum.html +2 -2
- package/docs/enums/Player.PanoEffectEnum.html +2 -2
- package/docs/enums/Player.PanoTagEnum.html +2 -2
- package/docs/enums/Player.PanoTagStyleEnum.html +3 -3
- package/docs/enums/Player.VreoKeyframeEnum.html +13 -13
- package/docs/enums/fivePlugins.CameraMovementEffect.html +2 -2
- package/docs/enums/fivePlugins.Rotation.html +2 -2
- package/docs/functions/custom.SpatialScenePanel.html +1 -1
- package/docs/functions/react.useVreoAction.html +8 -1
- package/docs/functions/react.useVreoEventCallback.html +10 -1
- package/docs/functions/react.useVreoPausedState.html +8 -1
- package/docs/index.html +1 -1
- package/docs/interfaces/Player.Appearance.html +2 -0
- package/docs/interfaces/Player.CustomVreoKeyframeProps.html +2 -2
- package/docs/interfaces/Player.PlayerConfigs.html +6 -6
- package/docs/interfaces/Player.Vertex.html +2 -2
- package/docs/interfaces/Player.VideoAgentMeshOptions.html +5 -4
- package/docs/interfaces/Player.VreoKeyframe.html +2 -2
- package/docs/interfaces/Player.VreoUnit.html +2 -2
- package/docs/interfaces/Player.VreoVideo.html +2 -2
- package/docs/interfaces/fivePlugins.CSS3DRenderPluginExportType.html +7 -5
- package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +2 -2
- package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +3 -3
- package/docs/interfaces/fivePlugins.CameraMovementPluginParameterType.html +1 -1
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +2 -2
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +2 -2
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +2 -2
- package/docs/interfaces/fivePlugins.Vector3Position.html +2 -2
- package/docs/interfaces/react.VreoActionCallbacks.html +7 -7
- package/docs/interfaces/react.VreoProviderProps.html +5 -2
- package/docs/modules/Player.html +1 -1
- package/docs/modules/fivePlugins.html +1 -1
- package/docs/types/Player.AppSize.html +1 -0
- package/docs/types/Player.AudioLikeEvent.html +2 -2
- package/docs/types/Player.CameraMovementData.html +1 -1
- package/docs/types/Player.CustomData.html +1 -1
- package/docs/types/Player.InfoPanelData.html +2 -2
- package/docs/types/Player.ModelVideoData.html +5 -5
- package/docs/types/Player.PanoEffectData.html +2 -2
- package/docs/types/Player.PanoTagData.html +2 -2
- package/docs/types/Player.PanoTextLabelData.html +2 -2
- package/docs/types/Player.PrompterData.html +2 -2
- package/docs/types/Player.QuadrangleVertexs.html +1 -1
- package/docs/types/Player.Quaternion.html +2 -2
- package/docs/types/Player.UpdateVRPanoramaData.html +2 -2
- package/docs/types/Player.Vertexs.html +1 -1
- package/docs/types/Player.VideoEffectData.html +2 -2
- package/docs/types/Player.VreoKeyframeEvent.html +1 -1
- package/docs/types/Player.VreoKeyframeMap.html +2 -2
- package/docs/types/Player.VreoSubscribe.html +1 -1
- package/docs/types/Player.WaveAppearance.html +1 -0
- package/docs/types/fivePlugins.CSS3DRenderPluginParameterType.html +1 -0
- package/docs/types/fivePlugins.MoveArgs.html +1 -1
- package/docs/types/fivePlugins.MoveOpts.html +1 -1
- package/docs/types/fivePlugins.RotateArgs.html +1 -1
- package/docs/types/fivePlugins.RotateOpts.html +1 -1
- package/docs/variables/fivePlugins.CSS3DRenderPlugin.html +2 -2
- package/docs/variables/fivePlugins.CameraMovementPlugin.html +1 -1
- package/docs/variables/fivePlugins.ModelTVVideoPlugin.html +1 -1
- package/docs/variables/react.VreoProvider.html +9 -1
- package/lib/PlayController/createHTMLAudioElement.js +5 -12
- package/lib/PlayController/index.js +27 -34
- package/lib/Player/App.js +25 -34
- package/lib/Player/Controller.d.ts +106 -2
- package/lib/Player/Controller.js +190 -78
- package/lib/Player/custom/SpatialScenePanel/index.js +20 -31
- package/lib/Player/hooks.js +6 -15
- package/lib/Player/index.d.ts +103 -0
- package/lib/Player/index.js +153 -45
- package/lib/Player/modules/Drawer/index.js +8 -17
- package/lib/Player/modules/PopUp/index.js +8 -17
- package/lib/Player/modules/ResizeObserver/index.js +10 -17
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +108 -7
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +157 -52
- package/lib/Player/modules/VideoAgent/VideoAgentScene.js +16 -25
- package/lib/Player/modules/VideoAgent/index.js +8 -17
- package/lib/Player/modules/Wave/index.js +24 -33
- package/lib/Player/modules/keyframes/BgMusic/index.js +13 -22
- package/lib/Player/modules/keyframes/CameraMovement/index.js +17 -26
- package/lib/Player/modules/keyframes/InfoPanel/index.js +13 -21
- package/lib/Player/modules/keyframes/ModelVideo/index.js +17 -26
- package/lib/Player/modules/keyframes/PanoEffect/index.js +21 -30
- package/lib/Player/modules/keyframes/PanoEffect/lineAnime.js +6 -14
- package/lib/Player/modules/keyframes/PanoTag/index.js +10 -18
- package/lib/Player/modules/keyframes/PanoTextLabel/index.js +19 -28
- package/lib/Player/modules/keyframes/Prompter/index.js +13 -22
- package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +16 -24
- package/lib/Player/modules/keyframes/VideoEffect/index.js +18 -28
- package/lib/Player/typings.js +1 -5
- package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.js +3 -9
- package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.js +1 -7
- package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.js +1 -7
- package/lib/fivePlugins/CSS3DRenderPlugin/index.d.ts +6 -12
- package/lib/fivePlugins/CSS3DRenderPlugin/index.js +27 -37
- package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.js +3 -9
- package/lib/fivePlugins/CameraMovementPlugin/index.js +15 -22
- package/lib/fivePlugins/CameraMovementPlugin/typings.js +6 -10
- package/lib/fivePlugins/ModelTVVideoPlugin/index.js +9 -18
- package/lib/index.js +1 -12
- package/lib/react/index.d.ts +111 -0
- package/lib/react/index.js +148 -24
- package/lib/shared-utils/Audio.js +27 -37
- package/lib/shared-utils/AudioLike.js +22 -29
- package/lib/shared-utils/Preloader.js +1 -7
- package/lib/shared-utils/addResizeListener.js +4 -11
- package/lib/shared-utils/animationFrame/BetterTween.js +23 -33
- package/lib/shared-utils/animationFrame/index.js +4 -13
- package/lib/shared-utils/animationFrame/tween.js +9 -17
- package/lib/shared-utils/createTransMatrix.js +5 -14
- package/lib/shared-utils/getFileExpandedName.js +1 -7
- package/lib/shared-utils/getMediaInfo.js +8 -19
- package/lib/shared-utils/setElementDataset.js +1 -7
- package/lib/typings/VreoUnit.js +15 -17
- package/package.json +58 -5
- package/stylesheets/custom/SpatialScenePanel.css +7 -7
- package/stylesheets/default.css +1 -1
- package/docs/demo/assets/react-dPVEotm3.css +0 -1
- /package/docs/demo/assets/{react-BLZb_LNZ.js → react-C4h9qndP.js} +0 -0
package/lib/Player/Controller.js
CHANGED
|
@@ -1,91 +1,110 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
13
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
14
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
15
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
16
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
|
-
var _five = require("@realsee/five");
|
|
18
|
-
var _mobx = require("mobx");
|
|
19
|
-
var React = _interopRequireWildcard(require("react"));
|
|
20
|
-
var _animationFrame = require("../shared-utils/animationFrame");
|
|
21
|
-
var _VreoUnit = require("../typings/VreoUnit");
|
|
22
|
-
var _setElementDataset = _interopRequireDefault(require("../shared-utils/setElementDataset"));
|
|
23
|
-
var _getMediaInfo = require("../shared-utils/getMediaInfo");
|
|
24
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) { "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); } return f; })(e, t); }
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
+
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
7
|
+
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
8
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
25
9
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
26
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (
|
|
27
|
-
function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = (
|
|
10
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
+
function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
|
|
28
12
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
13
|
+
import { Subscribe } from '@realsee/five';
|
|
14
|
+
import { action, makeObservable, observable, reaction } from 'mobx';
|
|
15
|
+
import * as React from 'react';
|
|
16
|
+
import { requestAnimationFrameInterval } from "../shared-utils/animationFrame/index.js";
|
|
17
|
+
import { VreoKeyframeEnum } from "../typings/VreoUnit.js";
|
|
18
|
+
import setElementDataset from "../shared-utils/setElementDataset.js";
|
|
19
|
+
import { getMediaType } from "../shared-utils/getMediaInfo.js";
|
|
29
20
|
/**
|
|
30
|
-
*
|
|
21
|
+
* Vreo 播放器逻辑控制器
|
|
22
|
+
*
|
|
23
|
+
* 负责管理播放器的内部状态、事件处理、UI 控制和剧本执行。
|
|
24
|
+
* 提供播放控制、外观设置、弹窗管理、抽屉控制等功能。
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const controller = new Controller({
|
|
29
|
+
* five: fiveInstance,
|
|
30
|
+
* container: document.getElementById('container'),
|
|
31
|
+
* configs: playerConfigs
|
|
32
|
+
* })
|
|
33
|
+
*
|
|
34
|
+
* // 设置播放状态
|
|
35
|
+
* controller.setPlaying(true)
|
|
36
|
+
*
|
|
37
|
+
* // 打开弹窗
|
|
38
|
+
* controller.openPopUp('弹窗内容')
|
|
39
|
+
*
|
|
40
|
+
* // 打开抽屉
|
|
41
|
+
* controller.openDrawer({ content: '抽屉内容', height: 300 })
|
|
42
|
+
* ```
|
|
31
43
|
*/
|
|
32
|
-
var Controller =
|
|
33
|
-
(
|
|
44
|
+
export var Controller = /*#__PURE__*/function (_Subscribe) {
|
|
45
|
+
_inherits(Controller, _Subscribe);
|
|
34
46
|
var _super = _createSuper(Controller);
|
|
47
|
+
/**
|
|
48
|
+
* 创建 Controller 实例
|
|
49
|
+
* @param params - 构造参数对象
|
|
50
|
+
* @param params.five - Five 渲染引擎实例
|
|
51
|
+
* @param params.container - DOM 容器元素
|
|
52
|
+
* @param params.configs - 播放器配置
|
|
53
|
+
*/
|
|
35
54
|
function Controller(_ref) {
|
|
36
55
|
var _this;
|
|
37
56
|
var five = _ref.five,
|
|
38
57
|
container = _ref.container,
|
|
39
58
|
configs = _ref.configs;
|
|
40
|
-
(
|
|
59
|
+
_classCallCheck(this, Controller);
|
|
41
60
|
_this = _super.call(this);
|
|
42
|
-
(
|
|
43
|
-
(
|
|
44
|
-
(
|
|
45
|
-
(
|
|
61
|
+
_defineProperty(_assertThisInitialized(_this), "playing", false);
|
|
62
|
+
_defineProperty(_assertThisInitialized(_this), "ended", false);
|
|
63
|
+
_defineProperty(_assertThisInitialized(_this), "loading", false);
|
|
64
|
+
_defineProperty(_assertThisInitialized(_this), "containerSize", {
|
|
46
65
|
width: 0,
|
|
47
66
|
height: 0
|
|
48
67
|
});
|
|
49
|
-
(
|
|
50
|
-
(
|
|
68
|
+
_defineProperty(_assertThisInitialized(_this), "waveAppearance", null);
|
|
69
|
+
_defineProperty(_assertThisInitialized(_this), "appearance", {
|
|
51
70
|
waveStyle: 'wave'
|
|
52
71
|
});
|
|
53
|
-
(
|
|
54
|
-
(
|
|
55
|
-
(
|
|
56
|
-
(
|
|
72
|
+
_defineProperty(_assertThisInitialized(_this), "avatar", {});
|
|
73
|
+
_defineProperty(_assertThisInitialized(_this), "visible", false);
|
|
74
|
+
_defineProperty(_assertThisInitialized(_this), "popUp", null);
|
|
75
|
+
_defineProperty(_assertThisInitialized(_this), "drawerConfig", null);
|
|
57
76
|
_this.configs = configs;
|
|
58
77
|
_this.container = container;
|
|
59
78
|
_this.five = five;
|
|
60
79
|
_this.appSize = configs.appSize;
|
|
61
80
|
_this.appearance = _objectSpread(_objectSpread({}, _this.appearance), configs.appearance);
|
|
62
|
-
|
|
63
|
-
visible:
|
|
64
|
-
setVisible:
|
|
65
|
-
playing:
|
|
66
|
-
setPlaying:
|
|
67
|
-
loading:
|
|
81
|
+
makeObservable(_assertThisInitialized(_this), {
|
|
82
|
+
visible: observable,
|
|
83
|
+
setVisible: action,
|
|
84
|
+
playing: observable,
|
|
85
|
+
setPlaying: action,
|
|
86
|
+
loading: observable,
|
|
68
87
|
// videoAgentScene: observable.ref,
|
|
69
|
-
setLoading:
|
|
70
|
-
popUp:
|
|
71
|
-
openPopUp:
|
|
72
|
-
drawerConfig:
|
|
73
|
-
openDrawer:
|
|
74
|
-
ended:
|
|
75
|
-
waveAppearance:
|
|
76
|
-
avatar:
|
|
77
|
-
containerSize:
|
|
78
|
-
setContainerSize:
|
|
79
|
-
appearance:
|
|
80
|
-
setAppearance:
|
|
81
|
-
configs:
|
|
82
|
-
setEnded:
|
|
83
|
-
setAvatar:
|
|
88
|
+
setLoading: action,
|
|
89
|
+
popUp: observable.ref,
|
|
90
|
+
openPopUp: action,
|
|
91
|
+
drawerConfig: observable.ref,
|
|
92
|
+
openDrawer: action,
|
|
93
|
+
ended: observable,
|
|
94
|
+
waveAppearance: observable,
|
|
95
|
+
avatar: observable,
|
|
96
|
+
containerSize: observable,
|
|
97
|
+
setContainerSize: action,
|
|
98
|
+
appearance: observable,
|
|
99
|
+
setAppearance: action,
|
|
100
|
+
configs: observable.ref,
|
|
101
|
+
setEnded: action,
|
|
102
|
+
setAvatar: action
|
|
84
103
|
});
|
|
85
|
-
|
|
104
|
+
reaction(function () {
|
|
86
105
|
return [_this.appearance.waveStyle, _this.loading];
|
|
87
106
|
}, function (_ref2) {
|
|
88
|
-
var _ref3 = (
|
|
107
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
89
108
|
waveStyle = _ref3[0],
|
|
90
109
|
loading = _ref3[1];
|
|
91
110
|
if (loading === null) {
|
|
@@ -115,7 +134,7 @@ var Controller = exports.Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
115
134
|
fireImmediately: true
|
|
116
135
|
});
|
|
117
136
|
if (!_this.appSize) {
|
|
118
|
-
|
|
137
|
+
reaction(function () {
|
|
119
138
|
return _this.containerSize;
|
|
120
139
|
}, function (containerSize) {
|
|
121
140
|
if (!(containerSize !== null && containerSize !== void 0 && containerSize.width)) return;
|
|
@@ -131,30 +150,30 @@ var Controller = exports.Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
131
150
|
if (height > width) return 'portrait';
|
|
132
151
|
return 'landscape';
|
|
133
152
|
}();
|
|
134
|
-
(
|
|
153
|
+
setElementDataset(_this.container, {
|
|
135
154
|
size: size
|
|
136
155
|
});
|
|
137
|
-
(
|
|
156
|
+
setElementDataset(_this.container, {
|
|
138
157
|
orientation: orientation
|
|
139
158
|
});
|
|
140
159
|
}, {
|
|
141
160
|
fireImmediately: true
|
|
142
161
|
});
|
|
143
162
|
} else {
|
|
144
|
-
(
|
|
163
|
+
setElementDataset(_this.container, {
|
|
145
164
|
size: _this.appSize
|
|
146
165
|
});
|
|
147
166
|
}
|
|
148
167
|
|
|
149
168
|
// 监听播放情况:抛出触发时机
|
|
150
|
-
|
|
169
|
+
reaction(function () {
|
|
151
170
|
return _this.ended;
|
|
152
171
|
}, function (ended) {
|
|
153
172
|
if (ended) {
|
|
154
173
|
_this.emit('paused', true);
|
|
155
174
|
}
|
|
156
175
|
});
|
|
157
|
-
|
|
176
|
+
reaction(function () {
|
|
158
177
|
return _this.playing;
|
|
159
178
|
}, function (playing) {
|
|
160
179
|
if (!_this.ended) {
|
|
@@ -163,27 +182,46 @@ var Controller = exports.Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
163
182
|
});
|
|
164
183
|
return _this;
|
|
165
184
|
}
|
|
166
|
-
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* 获取播放器是否准备就绪
|
|
188
|
+
* @returns 是否有可用的视频代理场景
|
|
189
|
+
*/
|
|
190
|
+
_createClass(Controller, [{
|
|
167
191
|
key: "agentType",
|
|
168
192
|
get:
|
|
169
193
|
// null 表示加载失败
|
|
170
194
|
|
|
195
|
+
/**
|
|
196
|
+
* 获取当前播放媒体的类型
|
|
197
|
+
* @returns 'video' | 'avatar' | 'none' - 媒体类型
|
|
198
|
+
*/
|
|
171
199
|
function get() {
|
|
172
200
|
var _this$videoAgentScene, _this$avatar;
|
|
173
|
-
var type =
|
|
201
|
+
var type = getMediaType((_this$videoAgentScene = this.videoAgentScene) === null || _this$videoAgentScene === void 0 ? void 0 : _this$videoAgentScene.videoAgentMesh.videoUrl);
|
|
174
202
|
if ((_this$avatar = this.avatar) !== null && _this$avatar !== void 0 && _this$avatar.force) return 'avatar';
|
|
175
203
|
if (type === 'video') return 'video';
|
|
176
204
|
return 'none';
|
|
177
205
|
}
|
|
178
206
|
}, {
|
|
179
207
|
key: "openPopUp",
|
|
180
|
-
value:
|
|
208
|
+
value:
|
|
209
|
+
/**
|
|
210
|
+
* 打开或关闭弹窗
|
|
211
|
+
* @param popUp - 弹窗内容,可以是字符串、JSX元素或false(关闭弹窗)
|
|
212
|
+
*/
|
|
213
|
+
function openPopUp(popUp) {
|
|
181
214
|
if (!popUp) {
|
|
182
215
|
this.popUp = null;
|
|
183
216
|
return;
|
|
184
217
|
}
|
|
185
218
|
this.popUp = popUp;
|
|
186
219
|
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* 设置加载状态
|
|
223
|
+
* @param loading - 加载状态:true(加载中)、false(加载完成)、null(加载失败)
|
|
224
|
+
*/
|
|
187
225
|
}, {
|
|
188
226
|
key: "setLoading",
|
|
189
227
|
value: function setLoading(loading) {
|
|
@@ -191,9 +229,20 @@ var Controller = exports.Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
191
229
|
}
|
|
192
230
|
}, {
|
|
193
231
|
key: "setAvatar",
|
|
194
|
-
value:
|
|
232
|
+
value:
|
|
233
|
+
/**
|
|
234
|
+
* 设置虚拟形象配置
|
|
235
|
+
* @param avatar - 虚拟形象配置对象
|
|
236
|
+
*/
|
|
237
|
+
function setAvatar(avatar) {
|
|
195
238
|
this.avatar = avatar;
|
|
196
239
|
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* 设置容器尺寸
|
|
243
|
+
* @param width - 容器宽度
|
|
244
|
+
* @param height - 容器高度
|
|
245
|
+
*/
|
|
197
246
|
}, {
|
|
198
247
|
key: "setContainerSize",
|
|
199
248
|
value: function setContainerSize(width, height) {
|
|
@@ -202,26 +251,51 @@ var Controller = exports.Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
202
251
|
height: height
|
|
203
252
|
};
|
|
204
253
|
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* 设置播放器可见性
|
|
257
|
+
* @param v - 是否可见
|
|
258
|
+
*/
|
|
205
259
|
}, {
|
|
206
260
|
key: "setVisible",
|
|
207
261
|
value: function setVisible(v) {
|
|
208
262
|
this.visible = v;
|
|
209
263
|
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* 设置播放状态
|
|
267
|
+
* @param playing - 是否正在播放
|
|
268
|
+
*/
|
|
210
269
|
}, {
|
|
211
270
|
key: "setPlaying",
|
|
212
271
|
value: function setPlaying(playing) {
|
|
213
272
|
this.playing = playing;
|
|
214
273
|
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* 设置结束状态
|
|
277
|
+
* @param ended - 是否已结束
|
|
278
|
+
*/
|
|
215
279
|
}, {
|
|
216
280
|
key: "setEnded",
|
|
217
281
|
value: function setEnded(ended) {
|
|
218
282
|
this.ended = ended;
|
|
219
283
|
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* 设置播放器外观
|
|
287
|
+
* @param appearance - 外观配置对象
|
|
288
|
+
*/
|
|
220
289
|
}, {
|
|
221
290
|
key: "setAppearance",
|
|
222
291
|
value: function setAppearance(appearance) {
|
|
223
292
|
this.appearance = _objectSpread(_objectSpread({}, this.appearance), appearance);
|
|
224
293
|
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* 打开或关闭抽屉
|
|
297
|
+
* @param drawerConfig - 抽屉配置对象,false表示关闭抽屉
|
|
298
|
+
*/
|
|
225
299
|
}, {
|
|
226
300
|
key: "openDrawer",
|
|
227
301
|
value: function openDrawer(drawerConfig) {
|
|
@@ -240,12 +314,22 @@ var Controller = exports.Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
240
314
|
get: function get() {
|
|
241
315
|
return !!this.videoAgentScene;
|
|
242
316
|
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* 获取当前播放时间(毫秒)
|
|
320
|
+
* @returns 当前播放时间戳
|
|
321
|
+
*/
|
|
243
322
|
}, {
|
|
244
323
|
key: "currentTime",
|
|
245
324
|
get: function get() {
|
|
246
325
|
var _this$videoAgentScene2;
|
|
247
326
|
return ((_this$videoAgentScene2 = this.videoAgentScene) === null || _this$videoAgentScene2 === void 0 ? void 0 : _this$videoAgentScene2.videoAgentMesh.currentTime) || 0;
|
|
248
327
|
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* 获取当前时间点应该触发的关键帧
|
|
331
|
+
* @returns 当前应该执行的关键帧数组
|
|
332
|
+
*/
|
|
249
333
|
}, {
|
|
250
334
|
key: "currentKeyframes",
|
|
251
335
|
get: function get() {
|
|
@@ -259,12 +343,17 @@ var Controller = exports.Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
259
343
|
if (keyframe.end < _this2.currentTime) return false;
|
|
260
344
|
// 检测开始时间
|
|
261
345
|
if (keyframe.start > _this2.currentTime) return false;
|
|
262
|
-
if (keyframe.type ===
|
|
346
|
+
if (keyframe.type === VreoKeyframeEnum.BgMusic) return true;
|
|
263
347
|
// 开始时间低于当前时间戳 100ms
|
|
264
348
|
var dur = _this2.currentTime - keyframe.start;
|
|
265
349
|
return dur <= 100 && dur >= 0;
|
|
266
350
|
});
|
|
267
351
|
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* 获取当前媒体实例(音频或视频元素)
|
|
355
|
+
* @returns HTML媒体元素实例
|
|
356
|
+
*/
|
|
268
357
|
}, {
|
|
269
358
|
key: "mediaInstance",
|
|
270
359
|
get: function get() {
|
|
@@ -273,7 +362,10 @@ var Controller = exports.Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
273
362
|
}
|
|
274
363
|
|
|
275
364
|
/**
|
|
276
|
-
*
|
|
365
|
+
* 逐帧任务循环处理
|
|
366
|
+
*
|
|
367
|
+
* 在每个动画帧中检查播放状态、处理关键帧触发等
|
|
368
|
+
* @param callback - 关键帧触发时的回调函数
|
|
277
369
|
*/
|
|
278
370
|
}, {
|
|
279
371
|
key: "requestAnimationFrameLoop",
|
|
@@ -314,15 +406,28 @@ var Controller = exports.Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
314
406
|
}
|
|
315
407
|
});
|
|
316
408
|
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* 开始运行播放器逻辑循环
|
|
412
|
+
*
|
|
413
|
+
* 启动帧循环,持续监听并处理关键帧事件
|
|
414
|
+
* @param callback - 关键帧触发时的回调函数
|
|
415
|
+
*/
|
|
317
416
|
}, {
|
|
318
417
|
key: "run",
|
|
319
418
|
value: function run(callback) {
|
|
320
419
|
var _this4 = this;
|
|
321
420
|
if (this.stopInterval) return;
|
|
322
|
-
this.stopInterval =
|
|
421
|
+
this.stopInterval = requestAnimationFrameInterval(function () {
|
|
323
422
|
return _this4.requestAnimationFrameLoop(callback);
|
|
324
423
|
});
|
|
325
424
|
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* 清理播放器状态
|
|
428
|
+
*
|
|
429
|
+
* 停止播放、重置关键帧状态、清理数据和定时器
|
|
430
|
+
*/
|
|
326
431
|
}, {
|
|
327
432
|
key: "clear",
|
|
328
433
|
value: function clear() {
|
|
@@ -343,6 +448,12 @@ var Controller = exports.Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
343
448
|
(_this$stopInterval = this.stopInterval) === null || _this$stopInterval === void 0 ? void 0 : _this$stopInterval.call(this);
|
|
344
449
|
this.stopInterval = undefined;
|
|
345
450
|
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* 销毁控制器实例
|
|
454
|
+
*
|
|
455
|
+
* 清理所有状态和资源,释放内存
|
|
456
|
+
*/
|
|
346
457
|
}, {
|
|
347
458
|
key: "dispose",
|
|
348
459
|
value: function dispose() {
|
|
@@ -350,5 +461,6 @@ var Controller = exports.Controller = /*#__PURE__*/function (_Subscribe) {
|
|
|
350
461
|
}
|
|
351
462
|
}]);
|
|
352
463
|
return Controller;
|
|
353
|
-
}(
|
|
354
|
-
var ControllerContext =
|
|
464
|
+
}(Subscribe);
|
|
465
|
+
var ControllerContext = /*#__PURE__*/React.createContext(null);
|
|
466
|
+
export { ControllerContext };
|
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
exports.SpatialScenePanel = SpatialScenePanel;
|
|
9
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
-
var React = _interopRequireWildcard(require("react"));
|
|
11
|
-
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
12
|
-
var _three = require("three");
|
|
13
|
-
var _BetterTween = require("../../../shared-utils/animationFrame/BetterTween");
|
|
14
|
-
var _CSS3DRenderPlugin = require("../../../fivePlugins/CSS3DRenderPlugin");
|
|
15
|
-
var _VreoUnit = require("../../../typings/VreoUnit");
|
|
16
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) { "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); } return f; })(e, t); }
|
|
17
|
-
// __debug__
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import ReactDOM from 'react-dom';
|
|
4
|
+
import { Raycaster, Vector3 } from 'three';
|
|
5
|
+
import { tweenProgress } from "../../../shared-utils/animationFrame/BetterTween.js";
|
|
6
|
+
import { CSS3DRenderPlugin } from "../../../fivePlugins/CSS3DRenderPlugin/index.js";
|
|
7
|
+
import { VreoKeyframeEnum } from "../../../typings/VreoUnit.js"; // __debug__
|
|
18
8
|
// const mockData: SpatialScenePanelData = {
|
|
19
9
|
// customType: 'SpatialScenePanel',
|
|
20
10
|
// "stateList": [
|
|
@@ -38,7 +28,6 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
38
28
|
// "temperature": "27",
|
|
39
29
|
// "title": "沉浸式回家"
|
|
40
30
|
// }
|
|
41
|
-
|
|
42
31
|
// const getSphere = (position: Vector3, color = 0xffff00) => {
|
|
43
32
|
// const geometry = new SphereGeometry(0.05, 32, 16)
|
|
44
33
|
// const material = new MeshBasicMaterial({ color })
|
|
@@ -50,11 +39,11 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
50
39
|
var searchV1 = function searchV1(_ref) {
|
|
51
40
|
var five = _ref.five,
|
|
52
41
|
dom = _ref.dom;
|
|
53
|
-
var cameraDirection = new
|
|
42
|
+
var cameraDirection = new Vector3();
|
|
54
43
|
five.camera.getWorldDirection(cameraDirection);
|
|
55
44
|
var cameraPosition = five.camera.position;
|
|
56
|
-
var _five$model$intersect = five.model.intersectRaycaster(new
|
|
57
|
-
_five$model$intersect2 = (
|
|
45
|
+
var _five$model$intersect = five.model.intersectRaycaster(new Raycaster(cameraPosition, cameraDirection)),
|
|
46
|
+
_five$model$intersect2 = _slicedToArray(_five$model$intersect, 1),
|
|
58
47
|
intersect = _five$model$intersect2[0];
|
|
59
48
|
var point = five.project2d(intersect.point);
|
|
60
49
|
var widescreen = window.innerWidth > 560 ? true : false;
|
|
@@ -67,10 +56,10 @@ var searchV1 = function searchV1(_ref) {
|
|
|
67
56
|
top = rect.top,
|
|
68
57
|
bottom = rect.bottom,
|
|
69
58
|
right = rect.right;
|
|
70
|
-
var leftBottom = new
|
|
71
|
-
var leftTop = new
|
|
72
|
-
var rightTop = new
|
|
73
|
-
var rightBottom = new
|
|
59
|
+
var leftBottom = new Vector3(left, bottom);
|
|
60
|
+
var leftTop = new Vector3(left, top);
|
|
61
|
+
var rightTop = new Vector3(right, top);
|
|
62
|
+
var rightBottom = new Vector3(right, bottom);
|
|
74
63
|
var points = [leftBottom, rightBottom, rightTop, leftTop].map(function (point) {
|
|
75
64
|
point.setX(point.x / window.innerWidth * 2 - (widescreen ? 1.25 : 1.75));
|
|
76
65
|
point.setY(-(point.y / window.innerHeight) * 2 + (widescreen ? 1.35 : 1.125));
|
|
@@ -94,11 +83,11 @@ var searchV1 = function searchV1(_ref) {
|
|
|
94
83
|
* 空间场景面板
|
|
95
84
|
* @returns
|
|
96
85
|
*/
|
|
97
|
-
function SpatialScenePanel(props) {
|
|
86
|
+
export function SpatialScenePanel(props) {
|
|
98
87
|
var timeoutRef = React.useRef(null);
|
|
99
88
|
var ref = React.useRef(null);
|
|
100
89
|
var panelRef = React.useRef(null);
|
|
101
|
-
var rendererRef = React.useRef(
|
|
90
|
+
var rendererRef = React.useRef(CSS3DRenderPlugin(props.five));
|
|
102
91
|
React.useEffect(function () {
|
|
103
92
|
if (!ref.current) {
|
|
104
93
|
return;
|
|
@@ -128,7 +117,7 @@ function SpatialScenePanel(props) {
|
|
|
128
117
|
$css3DObject: css3DObject
|
|
129
118
|
});
|
|
130
119
|
if (!container) return;
|
|
131
|
-
|
|
120
|
+
ReactDOM.render(/*#__PURE__*/React.createElement(Panel, {
|
|
132
121
|
ref: function ref(_ref3) {
|
|
133
122
|
return panelRef.current = _ref3;
|
|
134
123
|
},
|
|
@@ -136,7 +125,7 @@ function SpatialScenePanel(props) {
|
|
|
136
125
|
}), container);
|
|
137
126
|
var startRotateY = -(Math.PI * 2) / 9;
|
|
138
127
|
var lastRotateY = 0;
|
|
139
|
-
|
|
128
|
+
tweenProgress(1000).onUpdate(function (_ref4) {
|
|
140
129
|
var progress = _ref4.progress;
|
|
141
130
|
var needRotateY = Math.PI / 90 * 11 * progress;
|
|
142
131
|
var rotateY = needRotateY - lastRotateY;
|
|
@@ -172,9 +161,9 @@ function SpatialScenePanel(props) {
|
|
|
172
161
|
});
|
|
173
162
|
|
|
174
163
|
// setTimeout(() => {callback()}, 8000)
|
|
175
|
-
props.subscribe.on(
|
|
164
|
+
props.subscribe.on(VreoKeyframeEnum.Custom, callback);
|
|
176
165
|
return function () {
|
|
177
|
-
props.subscribe.off(
|
|
166
|
+
props.subscribe.off(VreoKeyframeEnum.Custom, callback);
|
|
178
167
|
if (timeoutRef.current) {
|
|
179
168
|
clearTimeout(timeoutRef.current);
|
|
180
169
|
}
|
package/lib/Player/hooks.js
CHANGED
|
@@ -1,29 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.useController = useController;
|
|
8
|
-
exports.useFiveInstance = useFiveInstance;
|
|
9
|
-
exports.useFiveProject2d = useFiveProject2d;
|
|
10
|
-
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
var _Controller = require("./Controller");
|
|
12
|
-
function useController() {
|
|
13
|
-
var controller = _react["default"].useContext(_Controller.ControllerContext);
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ControllerContext } from "./Controller.js";
|
|
3
|
+
export function useController() {
|
|
4
|
+
var controller = React.useContext(ControllerContext);
|
|
14
5
|
if (!controller) {
|
|
15
6
|
throw new Error('没有找到 "ControllerContext"');
|
|
16
7
|
}
|
|
17
8
|
return controller;
|
|
18
9
|
}
|
|
19
|
-
function useFiveInstance() {
|
|
10
|
+
export function useFiveInstance() {
|
|
20
11
|
var controller = useController();
|
|
21
12
|
if (!controller.five) {
|
|
22
13
|
throw new Error('没有找到 "five" 实例');
|
|
23
14
|
}
|
|
24
15
|
return controller.five;
|
|
25
16
|
}
|
|
26
|
-
function useFiveProject2d() {
|
|
17
|
+
export function useFiveProject2d() {
|
|
27
18
|
var five = useFiveInstance();
|
|
28
19
|
return function (vector) {
|
|
29
20
|
return five.project2d(vector, false);
|