@realsee/vreo 2.4.6 → 2.5.0
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/.nojekyll +1 -0
- package/docs/assets/custom.css +78 -0
- package/docs/assets/hierarchy.js +1 -0
- package/docs/assets/highlight.css +127 -0
- package/docs/assets/icons.js +18 -0
- package/docs/assets/icons.svg +1 -0
- package/docs/assets/main.js +60 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1640 -0
- package/docs/classes/Player.AudioLike.html +15 -0
- package/docs/classes/Player.Controller.html +87 -0
- package/docs/classes/Player.Player.html +54 -0
- package/docs/classes/Player.VideoAgentMesh.html +72 -0
- package/docs/classes/Player.VideoAgentScene.html +9 -0
- package/docs/demo/assets/AppReact-CkuqZtcS.js +1 -0
- package/docs/demo/assets/default-BQGCQRLt.css +1 -0
- package/docs/demo/assets/default-CVvVdmSW.js +5540 -0
- package/docs/demo/assets/dynamic-CO5wq52h.js +1 -0
- package/docs/demo/assets/examples-BCLzFApO.css +1 -0
- package/docs/demo/assets/examples-DfiAz2fR.js +25 -0
- package/docs/demo/assets/index-CBBSwaYT.js +1 -0
- package/docs/demo/assets/index-CmEXi2sK.css +1 -0
- package/docs/demo/assets/main-BF1tvUg-.js +25 -0
- package/docs/demo/assets/react-BnzBLum3.css +1 -0
- package/docs/demo/assets/react-C4h9qndP.js +25 -0
- package/docs/demo/examples.html +16 -0
- package/docs/demo/index-react-dynamic.html +18 -0
- package/docs/demo/index-react.html +19 -0
- package/docs/demo/index.html +19 -0
- package/docs/enums/Player.InfoPanelStyleEnum.html +3 -0
- package/docs/enums/Player.InfoPanelTypeEnum.html +4 -0
- package/docs/enums/Player.PanoEffectEnum.html +4 -0
- package/docs/enums/Player.PanoTagEnum.html +4 -0
- package/docs/enums/Player.PanoTagStyleEnum.html +6 -0
- package/docs/enums/Player.VreoKeyframeEnum.html +25 -0
- package/docs/enums/fivePlugins.CameraMovementEffect.html +3 -0
- package/docs/enums/fivePlugins.Rotation.html +4 -0
- package/docs/functions/custom.SpatialScenePanel.html +2 -0
- package/docs/functions/react.useVreoAction.html +8 -0
- package/docs/functions/react.useVreoEventCallback.html +10 -0
- package/docs/functions/react.useVreoPausedState.html +8 -0
- package/docs/hierarchy.html +1 -0
- package/docs/index.html +160 -0
- package/docs/interfaces/Player.Appearance.html +2 -0
- package/docs/interfaces/Player.CustomVreoKeyframeProps.html +3 -0
- package/docs/interfaces/Player.PlayerConfigs.html +20 -0
- package/docs/interfaces/Player.Vertex.html +5 -0
- package/docs/interfaces/Player.VideoAgentMeshOptions.html +9 -0
- package/docs/interfaces/Player.VreoKeyframe.html +8 -0
- package/docs/interfaces/Player.VreoUnit.html +9 -0
- package/docs/interfaces/Player.VreoVideo.html +7 -0
- package/docs/interfaces/fivePlugins.CSS3DRenderPluginExportType.html +8 -0
- package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +3 -0
- package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +5 -0
- package/docs/interfaces/fivePlugins.CameraMovementPluginParameterType.html +1 -0
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +5 -0
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +4 -0
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +2 -0
- package/docs/interfaces/fivePlugins.Vector3Position.html +5 -0
- package/docs/interfaces/react.VreoActionCallbacks.html +18 -0
- package/docs/interfaces/react.VreoProviderProps.html +6 -0
- package/docs/modules/Player.html +1 -0
- package/docs/modules/custom.html +1 -0
- package/docs/modules/fivePlugins.html +1 -0
- package/docs/modules/react.html +1 -0
- package/docs/modules.html +1 -0
- package/docs/types/Player.AppSize.html +1 -0
- package/docs/types/Player.AudioLikeEvent.html +6 -0
- package/docs/types/Player.CameraMovementData.html +2 -0
- package/docs/types/Player.CustomData.html +2 -0
- package/docs/types/Player.InfoPanelData.html +7 -0
- package/docs/types/Player.ModelVideoData.html +9 -0
- package/docs/types/Player.PanoEffectData.html +4 -0
- package/docs/types/Player.PanoTagData.html +6 -0
- package/docs/types/Player.PanoTextLabelData.html +7 -0
- package/docs/types/Player.PrompterData.html +3 -0
- package/docs/types/Player.QuadrangleVertexs.html +2 -0
- package/docs/types/Player.Quaternion.html +6 -0
- package/docs/types/Player.UpdateVRPanoramaData.html +7 -0
- package/docs/types/Player.Vertexs.html +2 -0
- package/docs/types/Player.VideoEffectData.html +7 -0
- package/docs/types/Player.VreoKeyframeEvent.html +2 -0
- package/docs/types/Player.VreoKeyframeMap.html +6 -0
- package/docs/types/Player.VreoSubscribe.html +1 -0
- package/docs/types/Player.WaveAppearance.html +1 -0
- package/docs/types/fivePlugins.CSS3DRenderPluginParameterType.html +1 -0
- package/docs/types/fivePlugins.MoveArgs.html +1 -0
- package/docs/types/fivePlugins.MoveOpts.html +1 -0
- package/docs/types/fivePlugins.RotateArgs.html +1 -0
- package/docs/types/fivePlugins.RotateOpts.html +1 -0
- package/docs/variables/fivePlugins.CSS3DRenderPlugin.html +3 -0
- package/docs/variables/fivePlugins.CameraMovementPlugin.html +2 -0
- package/docs/variables/fivePlugins.ModelTVVideoPlugin.html +1 -0
- package/docs/variables/react.VreoProvider.html +9 -0
- package/lib/Player/Controller.d.ts +106 -2
- package/lib/Player/Controller.js +124 -4
- package/lib/Player/index.d.ts +103 -0
- package/lib/Player/index.js +117 -1
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +108 -7
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +124 -11
- package/lib/Player/modules/keyframes/VideoEffect/index.js +1 -1
- package/lib/fivePlugins/CSS3DRenderPlugin/index.d.ts +6 -12
- package/lib/react/index.d.ts +111 -0
- package/lib/react/index.js +136 -0
- package/package.json +3 -2
- package/stylesheets/custom/SpatialScenePanel.css +7 -7
- package/stylesheets/default.css +1 -1
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import AudioLike from '../../../shared-utils/AudioLike';
|
|
3
|
+
/**
|
|
4
|
+
* 视频经纪人贴片的配置选项
|
|
5
|
+
*/
|
|
3
6
|
export interface VideoAgentMeshOptions {
|
|
4
7
|
/**
|
|
5
8
|
* 自定义视频实例。
|
|
@@ -17,31 +20,129 @@ export interface VideoAgentMeshOptions {
|
|
|
17
20
|
preload?: boolean;
|
|
18
21
|
}
|
|
19
22
|
/**
|
|
20
|
-
*
|
|
23
|
+
* 视频经纪人贴片类
|
|
24
|
+
*
|
|
25
|
+
* 基于 THREE.js 的网格对象,作为 VR 视频播放的核心媒体管理组件。
|
|
26
|
+
* 负责视频和音频的播放控制、时间同步、绿幕抠图渲染等功能。
|
|
27
|
+
*
|
|
28
|
+
* 主要特性:
|
|
29
|
+
* - 支持绿幕抠图渲染(ChromaKey)
|
|
30
|
+
* - 音视频同步播放管理
|
|
31
|
+
* - 媒体预载优化策略
|
|
32
|
+
* - 跨平台播放兼容性
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const videoMesh = new VideoAgentMesh(1920, 1080, 32, 18, {
|
|
37
|
+
* preload: true,
|
|
38
|
+
* videoInstance: customVideoElement
|
|
39
|
+
* })
|
|
40
|
+
*
|
|
41
|
+
* // 播放视频
|
|
42
|
+
* await videoMesh.play('https://example.com/video.mp4', 0, 60)
|
|
43
|
+
*
|
|
44
|
+
* // 获取当前时间
|
|
45
|
+
* console.log(videoMesh.currentTime)
|
|
46
|
+
*
|
|
47
|
+
* // 销毁资源
|
|
48
|
+
* videoMesh.dispose()
|
|
49
|
+
* ```
|
|
21
50
|
*/
|
|
22
51
|
export declare class VideoAgentMesh extends THREE.Mesh {
|
|
52
|
+
/** 配置选项 */
|
|
23
53
|
options: VideoAgentMeshOptions;
|
|
54
|
+
/** 当前视频URL */
|
|
24
55
|
videoUrl?: string;
|
|
56
|
+
/** 是否冻结状态 */
|
|
25
57
|
freeze: boolean;
|
|
58
|
+
/** 是否暂停状态 */
|
|
26
59
|
paused: boolean;
|
|
60
|
+
/** 音频实例 */
|
|
27
61
|
audioInstance: HTMLAudioElement;
|
|
62
|
+
/** AudioLike 实例 */
|
|
28
63
|
audioLikeInstance: AudioLike;
|
|
64
|
+
/** 移除事件监听器的函数 */
|
|
29
65
|
$removeEventListener: () => void;
|
|
66
|
+
/**
|
|
67
|
+
* 获取当前的媒体实例
|
|
68
|
+
*
|
|
69
|
+
* 根据媒体类型自动返回对应的播放实例:
|
|
70
|
+
* - 无媒体时返回 AudioLike 实例
|
|
71
|
+
* - 音频文件返回 HTMLAudioElement
|
|
72
|
+
* - 视频文件返回 HTMLVideoElement
|
|
73
|
+
*
|
|
74
|
+
* @returns 当前活跃的媒体播放实例
|
|
75
|
+
*/
|
|
30
76
|
get mediaInstance(): HTMLAudioElement | HTMLVideoElement | AudioLike;
|
|
31
77
|
/**
|
|
78
|
+
* 创建视频经纪人贴片实例
|
|
32
79
|
*
|
|
33
|
-
* @param width
|
|
34
|
-
* @param height
|
|
35
|
-
* @param widthSegments
|
|
36
|
-
* @param heightSegments
|
|
37
|
-
* @param options
|
|
80
|
+
* @param width - 网格宽度
|
|
81
|
+
* @param height - 网格高度
|
|
82
|
+
* @param widthSegments - 宽度方向分段数
|
|
83
|
+
* @param heightSegments - 高度方向分段数
|
|
84
|
+
* @param options - 配置选项
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const mesh = new VideoAgentMesh(1920, 1080, 32, 18, {
|
|
89
|
+
* preload: true,
|
|
90
|
+
* videoInstance: document.getElementById('video')
|
|
91
|
+
* })
|
|
92
|
+
* ```
|
|
38
93
|
*/
|
|
39
94
|
constructor(width: number, height: number, widthSegments: number, heightSegments: number, options?: VideoAgentMeshOptions);
|
|
95
|
+
/**
|
|
96
|
+
* 更新媒体资源
|
|
97
|
+
*
|
|
98
|
+
* 内部方法,负责加载新的视频/音频资源,处理预载逻辑和着色器设置
|
|
99
|
+
* @param videoUrl - 媒体文件URL
|
|
100
|
+
* @private
|
|
101
|
+
*/
|
|
40
102
|
private update;
|
|
103
|
+
/**
|
|
104
|
+
* 播放媒体内容
|
|
105
|
+
*
|
|
106
|
+
* 支持多种播放模式:
|
|
107
|
+
* - 播放指定视频/音频文件
|
|
108
|
+
* - 仅设置时长(无媒体文件)
|
|
109
|
+
* - 继续播放当前媒体
|
|
110
|
+
*
|
|
111
|
+
* @param videoUrl - 媒体文件URL,默认为空字符串
|
|
112
|
+
* @param currentTime - 播放起始时间(秒),默认为 0
|
|
113
|
+
* @param duration - 媒体总时长(秒),可选
|
|
114
|
+
* @returns Promise<boolean> 播放是否成功
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* // 播放视频文件
|
|
119
|
+
* await mesh.play('video.mp4', 10, 120)
|
|
120
|
+
*
|
|
121
|
+
* // 仅设置时长(音频跟踪)
|
|
122
|
+
* await mesh.play('', 0, 60)
|
|
123
|
+
*
|
|
124
|
+
* // 继续播放当前媒体
|
|
125
|
+
* await mesh.play()
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
41
128
|
play(videoUrl?: string, currentTime?: number, duration?: number): Promise<unknown>;
|
|
42
129
|
/**
|
|
43
|
-
*
|
|
130
|
+
* 获取当前播放时间(毫秒)
|
|
131
|
+
*
|
|
132
|
+
* 将媒体实例的秒级时间转换为毫秒,提供更高精度的时间控制
|
|
133
|
+
* @returns 当前播放时间戳(毫秒)
|
|
44
134
|
*/
|
|
45
135
|
get currentTime(): number;
|
|
136
|
+
/**
|
|
137
|
+
* 销毁视频经纪人贴片实例
|
|
138
|
+
*
|
|
139
|
+
* 清理所有事件监听器、DOM元素和缓存实例,释放内存资源
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* // 在组件卸载时调用
|
|
144
|
+
* videoMesh.dispose()
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
46
147
|
dispose(): void;
|
|
47
148
|
}
|
|
@@ -27,19 +27,58 @@ var fragmentShaderTpl = function fragmentShaderTpl() {
|
|
|
27
27
|
return "\nuniform int enable;\nuniform sampler2D map;\nvarying vec2 vUv;\nvarying vec2 vColorUv;\nvarying vec2 vMaskUv;\n\nvec3 hsv2rgb(vec3 c) {\n const vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n}\n\nvec3 rgb2hsv(vec3 c) {\n const vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n\n float d = q.x - min(q.w, q.y);\n return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + 0.001)), d / (q.x + 0.001), q.x);\n}\n\nvoid main(void) {\n vec3 color = texture2D(map, vUv).xyz;\n float amask = 1.0;\n\n float ref = color.r;\n if (ref < color.b) ref = color.b;\n amask = color.g - ref + 0.1;\n amask = smoothstep(0.1, 0.3, amask);\n amask = 1.0 - amask;\n\n vec3 target = rgb2hsv(vec3(0.0 / 255.0, 255.0 / 255.0, 0.0 / 255.0));\n vec3 hsv = rgb2hsv(color);\n float distance = abs(hsv.x - target.x);\n if (distance < 0.15) {\n hsv.y = 0.0;\n }\n color = hsv2rgb(hsv);\n\n gl_FragColor = vec4(color.rgb, amask * float(enable));\n}\n";
|
|
28
28
|
};
|
|
29
29
|
var cacheInstance = {};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 视频经纪人贴片的配置选项
|
|
33
|
+
*/
|
|
30
34
|
/**
|
|
31
|
-
*
|
|
35
|
+
* 视频经纪人贴片类
|
|
36
|
+
*
|
|
37
|
+
* 基于 THREE.js 的网格对象,作为 VR 视频播放的核心媒体管理组件。
|
|
38
|
+
* 负责视频和音频的播放控制、时间同步、绿幕抠图渲染等功能。
|
|
39
|
+
*
|
|
40
|
+
* 主要特性:
|
|
41
|
+
* - 支持绿幕抠图渲染(ChromaKey)
|
|
42
|
+
* - 音视频同步播放管理
|
|
43
|
+
* - 媒体预载优化策略
|
|
44
|
+
* - 跨平台播放兼容性
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const videoMesh = new VideoAgentMesh(1920, 1080, 32, 18, {
|
|
49
|
+
* preload: true,
|
|
50
|
+
* videoInstance: customVideoElement
|
|
51
|
+
* })
|
|
52
|
+
*
|
|
53
|
+
* // 播放视频
|
|
54
|
+
* await videoMesh.play('https://example.com/video.mp4', 0, 60)
|
|
55
|
+
*
|
|
56
|
+
* // 获取当前时间
|
|
57
|
+
* console.log(videoMesh.currentTime)
|
|
58
|
+
*
|
|
59
|
+
* // 销毁资源
|
|
60
|
+
* videoMesh.dispose()
|
|
61
|
+
* ```
|
|
32
62
|
*/
|
|
33
63
|
var VideoAgentMesh = exports.VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh) {
|
|
34
64
|
(0, _inherits2["default"])(VideoAgentMesh, _THREE$Mesh);
|
|
35
65
|
var _super = _createSuper(VideoAgentMesh);
|
|
36
66
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* @param
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
67
|
+
* 创建视频经纪人贴片实例
|
|
68
|
+
*
|
|
69
|
+
* @param width - 网格宽度
|
|
70
|
+
* @param height - 网格高度
|
|
71
|
+
* @param widthSegments - 宽度方向分段数
|
|
72
|
+
* @param heightSegments - 高度方向分段数
|
|
73
|
+
* @param options - 配置选项
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* const mesh = new VideoAgentMesh(1920, 1080, 32, 18, {
|
|
78
|
+
* preload: true,
|
|
79
|
+
* videoInstance: document.getElementById('video')
|
|
80
|
+
* })
|
|
81
|
+
* ```
|
|
43
82
|
*/
|
|
44
83
|
function VideoAgentMesh(width, height, widthSegments, heightSegments) {
|
|
45
84
|
var _this$options$videoIn, _this$options$videoIn2;
|
|
@@ -131,9 +170,41 @@ var VideoAgentMesh = exports.VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh
|
|
|
131
170
|
};
|
|
132
171
|
return _this;
|
|
133
172
|
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 更新媒体资源
|
|
176
|
+
*
|
|
177
|
+
* 内部方法,负责加载新的视频/音频资源,处理预载逻辑和着色器设置
|
|
178
|
+
* @param videoUrl - 媒体文件URL
|
|
179
|
+
* @private
|
|
180
|
+
*/
|
|
134
181
|
(0, _createClass2["default"])(VideoAgentMesh, [{
|
|
135
182
|
key: "mediaInstance",
|
|
136
|
-
get:
|
|
183
|
+
get: /** 配置选项 */
|
|
184
|
+
|
|
185
|
+
/** 当前视频URL */
|
|
186
|
+
|
|
187
|
+
/** 是否冻结状态 */
|
|
188
|
+
|
|
189
|
+
/** 是否暂停状态 */
|
|
190
|
+
|
|
191
|
+
/** 音频实例 */
|
|
192
|
+
|
|
193
|
+
/** AudioLike 实例 */
|
|
194
|
+
|
|
195
|
+
/** 移除事件监听器的函数 */
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* 获取当前的媒体实例
|
|
199
|
+
*
|
|
200
|
+
* 根据媒体类型自动返回对应的播放实例:
|
|
201
|
+
* - 无媒体时返回 AudioLike 实例
|
|
202
|
+
* - 音频文件返回 HTMLAudioElement
|
|
203
|
+
* - 视频文件返回 HTMLVideoElement
|
|
204
|
+
*
|
|
205
|
+
* @returns 当前活跃的媒体播放实例
|
|
206
|
+
*/
|
|
207
|
+
function get() {
|
|
137
208
|
if (!this.videoUrl) {
|
|
138
209
|
return this.audioLikeInstance;
|
|
139
210
|
}
|
|
@@ -146,7 +217,7 @@ var VideoAgentMesh = exports.VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh
|
|
|
146
217
|
}
|
|
147
218
|
}, {
|
|
148
219
|
key: "update",
|
|
149
|
-
value: function () {
|
|
220
|
+
value: (function () {
|
|
150
221
|
var _update = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(videoUrl) {
|
|
151
222
|
var _this2 = this;
|
|
152
223
|
var uniforms, onStart;
|
|
@@ -215,9 +286,35 @@ var VideoAgentMesh = exports.VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh
|
|
|
215
286
|
}
|
|
216
287
|
return update;
|
|
217
288
|
}()
|
|
289
|
+
/**
|
|
290
|
+
* 播放媒体内容
|
|
291
|
+
*
|
|
292
|
+
* 支持多种播放模式:
|
|
293
|
+
* - 播放指定视频/音频文件
|
|
294
|
+
* - 仅设置时长(无媒体文件)
|
|
295
|
+
* - 继续播放当前媒体
|
|
296
|
+
*
|
|
297
|
+
* @param videoUrl - 媒体文件URL,默认为空字符串
|
|
298
|
+
* @param currentTime - 播放起始时间(秒),默认为 0
|
|
299
|
+
* @param duration - 媒体总时长(秒),可选
|
|
300
|
+
* @returns Promise<boolean> 播放是否成功
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```typescript
|
|
304
|
+
* // 播放视频文件
|
|
305
|
+
* await mesh.play('video.mp4', 10, 120)
|
|
306
|
+
*
|
|
307
|
+
* // 仅设置时长(音频跟踪)
|
|
308
|
+
* await mesh.play('', 0, 60)
|
|
309
|
+
*
|
|
310
|
+
* // 继续播放当前媒体
|
|
311
|
+
* await mesh.play()
|
|
312
|
+
* ```
|
|
313
|
+
*/
|
|
314
|
+
)
|
|
218
315
|
}, {
|
|
219
316
|
key: "play",
|
|
220
|
-
value: function () {
|
|
317
|
+
value: (function () {
|
|
221
318
|
var _play = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
222
319
|
var _this3 = this;
|
|
223
320
|
var videoUrl,
|
|
@@ -311,13 +408,29 @@ var VideoAgentMesh = exports.VideoAgentMesh = /*#__PURE__*/function (_THREE$Mesh
|
|
|
311
408
|
return play;
|
|
312
409
|
}()
|
|
313
410
|
/**
|
|
314
|
-
*
|
|
411
|
+
* 获取当前播放时间(毫秒)
|
|
412
|
+
*
|
|
413
|
+
* 将媒体实例的秒级时间转换为毫秒,提供更高精度的时间控制
|
|
414
|
+
* @returns 当前播放时间戳(毫秒)
|
|
315
415
|
*/
|
|
416
|
+
)
|
|
316
417
|
}, {
|
|
317
418
|
key: "currentTime",
|
|
318
419
|
get: function get() {
|
|
319
420
|
return this.mediaInstance.currentTime * 1000;
|
|
320
421
|
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* 销毁视频经纪人贴片实例
|
|
425
|
+
*
|
|
426
|
+
* 清理所有事件监听器、DOM元素和缓存实例,释放内存资源
|
|
427
|
+
*
|
|
428
|
+
* @example
|
|
429
|
+
* ```typescript
|
|
430
|
+
* // 在组件卸载时调用
|
|
431
|
+
* videoMesh.dispose()
|
|
432
|
+
* ```
|
|
433
|
+
*/
|
|
321
434
|
}, {
|
|
322
435
|
key: "dispose",
|
|
323
436
|
value: function dispose() {
|
|
@@ -28,7 +28,7 @@ var inlinePlay = function inlinePlay(videoInstance) {
|
|
|
28
28
|
videoInstance.load();
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
// const emptyVideo = '//
|
|
31
|
+
// const emptyVideo = '//vr-static.realsee-cdn.cn/release/web/leisure.69fd3522.mov'
|
|
32
32
|
var PI = Math.PI;
|
|
33
33
|
var PI_2 = PI * 2;
|
|
34
34
|
function VideoEffect() {
|
|
@@ -12,16 +12,11 @@ export interface Vector3Position {
|
|
|
12
12
|
export type CSS3DRenderPluginParameterType = undefined;
|
|
13
13
|
export interface CSS3DRenderPluginExportType {
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @param
|
|
18
|
-
* @param
|
|
19
|
-
* @
|
|
20
|
-
* @param {HTMLElement} config.container: HTMLElement
|
|
21
|
-
* @param {number} config.autoRender: 默认为true,如果需要手动render则传false
|
|
22
|
-
* @param {'front' | 'behind'} config.mode: 两种模式
|
|
23
|
-
* @param {HTMLElement} config.behindFiveContainer: 如果config.mode为'behind',需要传入容器,并确保此容器位five下方,且中间没有其他dom元素遮挡
|
|
24
|
-
* @return {{ container: HTMLElement; dispose: () => void }}: container: dom容器, dispose: 清理函数
|
|
15
|
+
* 根据传入的四个点位创建一个3d dom容器,可以通过ReactDom.render()的方式将react组件放到容器中
|
|
16
|
+
*
|
|
17
|
+
* @param points - 矩形四个点坐标
|
|
18
|
+
* @param config - 配置项,包含ratio(像素比例)、dpr(设备像素比)、container(容器)、autoRender(自动渲染)、mode(渲染模式)等
|
|
19
|
+
* @returns 返回包含容器、销毁函数、CSS3D对象和可选渲染函数的对象
|
|
25
20
|
*/
|
|
26
21
|
create3DDomContainer: (points: Vector3[] | Vector3Position[], config?: {
|
|
27
22
|
ratio?: number;
|
|
@@ -41,8 +36,7 @@ export interface CSS3DRenderPluginExportType {
|
|
|
41
36
|
render?: () => void;
|
|
42
37
|
} | void;
|
|
43
38
|
/**
|
|
44
|
-
*
|
|
45
|
-
* @return {void}
|
|
39
|
+
* 销毁所有的渲染内容
|
|
46
40
|
*/
|
|
47
41
|
disposeAll: () => void;
|
|
48
42
|
}
|
package/lib/react/index.d.ts
CHANGED
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { PlayerConfigs } from '../Player/typings';
|
|
3
3
|
import { VreoKeyframeEvent, VreoUnit } from '../typings/VreoUnit';
|
|
4
|
+
/**
|
|
5
|
+
* VreoProvider 组件的属性接口
|
|
6
|
+
*/
|
|
4
7
|
export interface VreoProviderProps {
|
|
8
|
+
/** 播放器配置选项 */
|
|
5
9
|
configs?: Partial<PlayerConfigs>;
|
|
10
|
+
/** 子组件 */
|
|
6
11
|
children?: React.ReactNode;
|
|
7
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Vreo 播放器 Provider 组件
|
|
15
|
+
*
|
|
16
|
+
* 为子组件提供 Vreo 播放器实例的 React Context Provider。
|
|
17
|
+
* 必须在 Five Provider 内部使用。
|
|
18
|
+
*
|
|
19
|
+
* @param props - 组件属性
|
|
20
|
+
* @returns React.FC 组件
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* <FiveProvider>
|
|
25
|
+
* <VreoProvider configs={{ autoPreload: true }}>
|
|
26
|
+
* <YourComponent />
|
|
27
|
+
* </VreoProvider>
|
|
28
|
+
* </FiveProvider>
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
8
31
|
export declare const VreoProvider: React.FC<VreoProviderProps>;
|
|
9
32
|
/**
|
|
10
33
|
* VreoPlayer 命令集合。
|
|
@@ -39,6 +62,35 @@ export interface VreoActionCallbacks {
|
|
|
39
62
|
*/
|
|
40
63
|
dispose: () => void;
|
|
41
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* 获取 Vreo 播放器操作函数集合
|
|
67
|
+
*
|
|
68
|
+
* 返回一组经过优化的播放器操作函数,这些函数已经绑定了当前播放器实例。
|
|
69
|
+
* 使用 useCallback 进行性能优化,避免不必要的重新渲染。
|
|
70
|
+
*
|
|
71
|
+
* @returns VreoActionCallbacks 操作函数集合
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```tsx
|
|
75
|
+
* function PlayerControls() {
|
|
76
|
+
* const { load, play, pause, show, hide, dispose } = useVreoAction()
|
|
77
|
+
*
|
|
78
|
+
* const handleLoadScript = async () => {
|
|
79
|
+
* await load(vreoUnit, 0)
|
|
80
|
+
* play()
|
|
81
|
+
* }
|
|
82
|
+
*
|
|
83
|
+
* return (
|
|
84
|
+
* <div>
|
|
85
|
+
* <button onClick={handleLoadScript}>加载并播放</button>
|
|
86
|
+
* <button onClick={pause}>暂停</button>
|
|
87
|
+
* <button onClick={() => show()}>显示</button>
|
|
88
|
+
* <button onClick={() => hide()}>隐藏</button>
|
|
89
|
+
* </div>
|
|
90
|
+
* )
|
|
91
|
+
* }
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
42
94
|
export declare function useVreoAction(): {
|
|
43
95
|
load: (vreoUnit: VreoUnit, currentTime?: number) => Promise<boolean>;
|
|
44
96
|
pause: () => void;
|
|
@@ -47,5 +99,64 @@ export declare function useVreoAction(): {
|
|
|
47
99
|
hide: () => void;
|
|
48
100
|
dispose: () => void;
|
|
49
101
|
};
|
|
102
|
+
/**
|
|
103
|
+
* 监听 Vreo 播放器事件
|
|
104
|
+
*
|
|
105
|
+
* 用于注册和清理 Vreo 播放器事件监听器的 React Hook。
|
|
106
|
+
* 当组件卸载或依赖项变化时自动清理事件监听器。
|
|
107
|
+
*
|
|
108
|
+
* @param name - 事件名称
|
|
109
|
+
* @param callback - 事件回调函数
|
|
110
|
+
* @param deps - 依赖项数组(可选)
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```tsx
|
|
114
|
+
* function EventListener() {
|
|
115
|
+
* const [keyframes, setKeyframes] = React.useState([])
|
|
116
|
+
*
|
|
117
|
+
* // 监听关键帧事件
|
|
118
|
+
* useVreoEventCallback('CameraMovement', (keyframe) => {
|
|
119
|
+
* console.log('相机运镜:', keyframe)
|
|
120
|
+
* })
|
|
121
|
+
*
|
|
122
|
+
* // 监听播放状态变化
|
|
123
|
+
* useVreoEventCallback('playing', () => {
|
|
124
|
+
* console.log('开始播放')
|
|
125
|
+
* }, [])
|
|
126
|
+
*
|
|
127
|
+
* return <div>事件监听组件</div>
|
|
128
|
+
* }
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
50
131
|
export declare function useVreoEventCallback<T extends keyof VreoKeyframeEvent>(name: T, callback: VreoKeyframeEvent[T], deps?: React.DependencyList | undefined): void;
|
|
132
|
+
/**
|
|
133
|
+
* 获取播放器暂停状态
|
|
134
|
+
*
|
|
135
|
+
* 返回当前播放器的暂停状态,并自动响应播放状态变化。
|
|
136
|
+
* 当播放器开始播放或暂停时,状态会自动更新。
|
|
137
|
+
*
|
|
138
|
+
* @returns boolean 是否处于暂停状态
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```tsx
|
|
142
|
+
* function PlayButton() {
|
|
143
|
+
* const isPaused = useVreoPausedState()
|
|
144
|
+
* const { play, pause } = useVreoAction()
|
|
145
|
+
*
|
|
146
|
+
* const handleToggle = () => {
|
|
147
|
+
* if (isPaused) {
|
|
148
|
+
* play()
|
|
149
|
+
* } else {
|
|
150
|
+
* pause()
|
|
151
|
+
* }
|
|
152
|
+
* }
|
|
153
|
+
*
|
|
154
|
+
* return (
|
|
155
|
+
* <button onClick={handleToggle}>
|
|
156
|
+
* {isPaused ? '播放' : '暂停'}
|
|
157
|
+
* </button>
|
|
158
|
+
* )
|
|
159
|
+
* }
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
51
162
|
export declare function useVreoPausedState(): boolean;
|
package/lib/react/index.js
CHANGED
|
@@ -15,6 +15,29 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
15
15
|
var _Player = require("../Player");
|
|
16
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
17
|
var VreoContext = /*#__PURE__*/React.createContext(null);
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* VreoProvider 组件的属性接口
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Vreo 播放器 Provider 组件
|
|
25
|
+
*
|
|
26
|
+
* 为子组件提供 Vreo 播放器实例的 React Context Provider。
|
|
27
|
+
* 必须在 Five Provider 内部使用。
|
|
28
|
+
*
|
|
29
|
+
* @param props - 组件属性
|
|
30
|
+
* @returns React.FC 组件
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* <FiveProvider>
|
|
35
|
+
* <VreoProvider configs={{ autoPreload: true }}>
|
|
36
|
+
* <YourComponent />
|
|
37
|
+
* </VreoProvider>
|
|
38
|
+
* </FiveProvider>
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
18
41
|
var VreoProvider = exports.VreoProvider = function VreoProvider(props) {
|
|
19
42
|
var five = (0, _react.unsafe__useFiveInstance)();
|
|
20
43
|
var _React$useState = React.useState(null),
|
|
@@ -35,6 +58,29 @@ var VreoProvider = exports.VreoProvider = function VreoProvider(props) {
|
|
|
35
58
|
value: player
|
|
36
59
|
}, props.children);
|
|
37
60
|
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 获取 Vreo 播放器实例
|
|
64
|
+
*
|
|
65
|
+
* 从 React Context 中获取当前的 Vreo 播放器实例。
|
|
66
|
+
* 必须在 VreoProvider 内部使用。
|
|
67
|
+
*
|
|
68
|
+
* @returns Player 播放器实例
|
|
69
|
+
* @throws 如果未找到 VreoProvider 则抛出错误
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```tsx
|
|
73
|
+
* function MyComponent() {
|
|
74
|
+
* const player = useVreoInstance()
|
|
75
|
+
*
|
|
76
|
+
* const handleLoad = () => {
|
|
77
|
+
* player.load(vreoUnit)
|
|
78
|
+
* }
|
|
79
|
+
*
|
|
80
|
+
* return <button onClick={handleLoad}>Load Script</button>
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
38
84
|
function useVreoInstance() {
|
|
39
85
|
var context = React.useContext(VreoContext);
|
|
40
86
|
if (!context) {
|
|
@@ -47,6 +93,35 @@ function useVreoInstance() {
|
|
|
47
93
|
* VreoPlayer 命令集合。
|
|
48
94
|
*/
|
|
49
95
|
|
|
96
|
+
/**
|
|
97
|
+
* 获取 Vreo 播放器操作函数集合
|
|
98
|
+
*
|
|
99
|
+
* 返回一组经过优化的播放器操作函数,这些函数已经绑定了当前播放器实例。
|
|
100
|
+
* 使用 useCallback 进行性能优化,避免不必要的重新渲染。
|
|
101
|
+
*
|
|
102
|
+
* @returns VreoActionCallbacks 操作函数集合
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```tsx
|
|
106
|
+
* function PlayerControls() {
|
|
107
|
+
* const { load, play, pause, show, hide, dispose } = useVreoAction()
|
|
108
|
+
*
|
|
109
|
+
* const handleLoadScript = async () => {
|
|
110
|
+
* await load(vreoUnit, 0)
|
|
111
|
+
* play()
|
|
112
|
+
* }
|
|
113
|
+
*
|
|
114
|
+
* return (
|
|
115
|
+
* <div>
|
|
116
|
+
* <button onClick={handleLoadScript}>加载并播放</button>
|
|
117
|
+
* <button onClick={pause}>暂停</button>
|
|
118
|
+
* <button onClick={() => show()}>显示</button>
|
|
119
|
+
* <button onClick={() => hide()}>隐藏</button>
|
|
120
|
+
* </div>
|
|
121
|
+
* )
|
|
122
|
+
* }
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
50
125
|
function useVreoAction() {
|
|
51
126
|
var player = useVreoInstance();
|
|
52
127
|
var load = React.useCallback(function (vreoUnit, currentTime) {
|
|
@@ -76,6 +151,36 @@ function useVreoAction() {
|
|
|
76
151
|
dispose: dispose
|
|
77
152
|
};
|
|
78
153
|
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* 监听 Vreo 播放器事件
|
|
157
|
+
*
|
|
158
|
+
* 用于注册和清理 Vreo 播放器事件监听器的 React Hook。
|
|
159
|
+
* 当组件卸载或依赖项变化时自动清理事件监听器。
|
|
160
|
+
*
|
|
161
|
+
* @param name - 事件名称
|
|
162
|
+
* @param callback - 事件回调函数
|
|
163
|
+
* @param deps - 依赖项数组(可选)
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```tsx
|
|
167
|
+
* function EventListener() {
|
|
168
|
+
* const [keyframes, setKeyframes] = React.useState([])
|
|
169
|
+
*
|
|
170
|
+
* // 监听关键帧事件
|
|
171
|
+
* useVreoEventCallback('CameraMovement', (keyframe) => {
|
|
172
|
+
* console.log('相机运镜:', keyframe)
|
|
173
|
+
* })
|
|
174
|
+
*
|
|
175
|
+
* // 监听播放状态变化
|
|
176
|
+
* useVreoEventCallback('playing', () => {
|
|
177
|
+
* console.log('开始播放')
|
|
178
|
+
* }, [])
|
|
179
|
+
*
|
|
180
|
+
* return <div>事件监听组件</div>
|
|
181
|
+
* }
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
79
184
|
function useVreoEventCallback(name, callback, deps) {
|
|
80
185
|
var player = useVreoInstance();
|
|
81
186
|
var dependencyList = [player, name];
|
|
@@ -91,6 +196,37 @@ function useVreoEventCallback(name, callback, deps) {
|
|
|
91
196
|
};
|
|
92
197
|
}, dependencyList);
|
|
93
198
|
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* 获取播放器暂停状态
|
|
202
|
+
*
|
|
203
|
+
* 返回当前播放器的暂停状态,并自动响应播放状态变化。
|
|
204
|
+
* 当播放器开始播放或暂停时,状态会自动更新。
|
|
205
|
+
*
|
|
206
|
+
* @returns boolean 是否处于暂停状态
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```tsx
|
|
210
|
+
* function PlayButton() {
|
|
211
|
+
* const isPaused = useVreoPausedState()
|
|
212
|
+
* const { play, pause } = useVreoAction()
|
|
213
|
+
*
|
|
214
|
+
* const handleToggle = () => {
|
|
215
|
+
* if (isPaused) {
|
|
216
|
+
* play()
|
|
217
|
+
* } else {
|
|
218
|
+
* pause()
|
|
219
|
+
* }
|
|
220
|
+
* }
|
|
221
|
+
*
|
|
222
|
+
* return (
|
|
223
|
+
* <button onClick={handleToggle}>
|
|
224
|
+
* {isPaused ? '播放' : '暂停'}
|
|
225
|
+
* </button>
|
|
226
|
+
* )
|
|
227
|
+
* }
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
94
230
|
function useVreoPausedState() {
|
|
95
231
|
var player = useVreoInstance();
|
|
96
232
|
var _React$useState3 = React.useState(player.paused),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@realsee/vreo",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "Vreo (VR Video 缩写) 是基于如视三维渲染引擎 Five 和 用户界面构建库 React 实现的如视 3D 空间剧本播放器。",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"realsee",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"lib",
|
|
15
15
|
"stylesheets",
|
|
16
16
|
"LICENSE",
|
|
17
|
-
"CHANGELOG.md"
|
|
17
|
+
"CHANGELOG.md",
|
|
18
|
+
"docs"
|
|
18
19
|
],
|
|
19
20
|
"scripts": {
|
|
20
21
|
"dev": "vite --port=3088 --host 0.0.0.0",
|