@realsee/vreo 0.1.6-alpha.5 → 0.2.0-alpha.10
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 +103 -16
- package/docs/assets/custom.css +4 -4
- package/docs/assets/search.js +1 -1
- package/docs/classes/Player.Controller.html +54 -0
- package/docs/classes/Player.Player-1.html +11 -11
- package/docs/classes/Player.VideoAgentMesh.html +142 -0
- package/docs/classes/Player.VideoAgentScene.html +1 -0
- package/docs/enums/Player.InfoPanelStyleEnum.html +1 -0
- package/docs/enums/Player.InfoPanelTypeEnum.html +1 -1
- package/docs/enums/Player.PanoEffectEnum.html +2 -2
- package/docs/enums/Player.PanoTagEnum.html +1 -1
- package/docs/enums/Player.VreoKeyframeEnum.html +14 -12
- package/docs/enums/fivePlugins.CameraMovementEffect.html +1 -1
- package/docs/enums/fivePlugins.Rotation.html +1 -1
- package/docs/index.html +52 -19
- package/docs/interfaces/Player.CustomVreoKeyframeProps.html +1 -0
- package/docs/interfaces/Player.PlayerConfigs.html +4 -2
- package/docs/interfaces/Player.Vertex.html +1 -1
- package/docs/interfaces/Player.VideoAgentMeshOptions.html +1 -0
- package/docs/interfaces/Player.VreoKeyframe.html +1 -1
- package/docs/interfaces/Player.VreoUnit.html +1 -1
- package/docs/interfaces/Player.VreoVideo.html +1 -1
- package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +1 -1
- package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +3 -3
- package/docs/interfaces/fivePlugins.CameraMovementPluginParameterType.html +1 -1
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +1 -1
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +1 -1
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +1 -1
- package/docs/interfaces/react.VreoActionCallbacks.html +15 -7
- package/docs/interfaces/react.VreoProviderProps.html +1 -0
- package/docs/modules/Player.html +17 -15
- package/docs/modules/custom.html +3 -0
- package/docs/modules/fivePlugins.html +2 -2
- package/docs/modules/react.html +1 -1
- package/docs/modules.html +1 -1
- package/lib/PlayController/createHTMLAudioElement.d.ts +1 -0
- package/lib/PlayController/createHTMLAudioElement.js +47 -0
- package/lib/PlayController/index.d.ts +38 -0
- package/lib/PlayController/index.js +300 -0
- package/lib/Player/App.js +8 -3
- package/lib/Player/Controller.d.ts +2 -0
- package/lib/Player/Controller.js +14 -0
- package/lib/Player/custom/SpatialScenePanel/index.d.ts +22 -0
- package/lib/Player/custom/SpatialScenePanel/index.js +279 -0
- package/lib/Player/index.d.ts +1 -1
- package/lib/Player/index.js +98 -11
- package/lib/Player/modules/Drawer/index.js +1 -1
- package/lib/Player/modules/PopUp/index.d.ts +2 -0
- package/lib/Player/modules/PopUp/index.js +43 -0
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +1 -0
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +5 -1
- package/lib/Player/modules/VideoAgent/VideoAgentScene.d.ts +4 -1
- package/lib/Player/modules/VideoAgent/VideoAgentScene.js +2 -1
- package/lib/Player/modules/VideoAgent/index.d.ts +2 -0
- package/lib/Player/modules/VideoAgent/index.js +1 -1
- package/lib/Player/modules/keyframes/BgMusic/index.d.ts +2 -0
- package/lib/Player/modules/keyframes/BgMusic/index.js +76 -0
- package/lib/Player/modules/keyframes/CameraMovement/index.js +41 -5
- package/lib/Player/modules/keyframes/InfoPanel/index.js +105 -23
- package/lib/Player/modules/keyframes/ModelVideo/index.js +43 -6
- package/lib/Player/modules/keyframes/PanoTextLabel/index.js +4 -12
- package/lib/Player/modules/keyframes/Prompter/index.js +2 -15
- package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +68 -17
- package/lib/Player/typings.d.ts +19 -1
- package/lib/fivePlugins/CameraMovementPlugin/index.js +104 -90
- package/lib/fivePlugins/CameraMovementPlugin/typings.d.ts +1 -0
- package/lib/react/index.d.ts +10 -2
- package/lib/react/index.js +1 -1
- package/lib/shared-utils/createTransMatrix.d.ts +1 -0
- package/lib/shared-utils/createTransMatrix.js +43 -0
- package/lib/typings/VreoUnit.d.ts +47 -8
- package/lib/typings/VreoUnit.js +15 -6
- package/package.json +6 -6
- package/resources/PlayController/createHTMLAudioElement.ts +53 -0
- package/resources/PlayController/index.ts +167 -0
- package/resources/Player/App.tsx +6 -1
- package/resources/Player/Controller.ts +12 -0
- package/resources/Player/custom/SpatialScenePanel/index.tsx +264 -0
- package/resources/Player/index.tsx +56 -2
- package/resources/Player/modules/Drawer/index.tsx +1 -1
- package/resources/Player/modules/PopUp/index.tsx +26 -0
- package/resources/Player/modules/VideoAgent/VideoAgentMesh.ts +4 -3
- package/resources/Player/modules/VideoAgent/VideoAgentScene.ts +2 -2
- package/resources/Player/modules/VideoAgent/index.tsx +3 -2
- package/resources/Player/modules/keyframes/BgMusic/index.tsx +66 -0
- package/resources/Player/modules/keyframes/CameraMovement/index.tsx +7 -3
- package/resources/Player/modules/keyframes/InfoPanel/index.tsx +109 -11
- package/resources/Player/modules/keyframes/ModelVideo/index.tsx +35 -2
- package/resources/Player/modules/keyframes/PanoTextLabel/index.tsx +2 -2
- package/resources/Player/modules/keyframes/Prompter/index.tsx +3 -14
- package/resources/Player/modules/keyframes/UpdateVRPanorama/index.tsx +72 -15
- package/resources/Player/typings.ts +21 -1
- package/resources/fivePlugins/CameraMovementPlugin/index.ts +59 -48
- package/resources/fivePlugins/CameraMovementPlugin/typings.ts +2 -1
- package/resources/react/index.tsx +12 -3
- package/resources/shared-utils/createTransMatrix.ts +12 -0
- package/resources/typings/VreoUnit.ts +56 -8
- package/stylesheets/custom/SpatialScenePanel.css +309 -0
- package/stylesheets/default.css +127 -9
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@realsee/vreo)
|
|
4
4
|
|
|
5
|
-
Vreo (VR Video 缩写) 是基于如视三维渲染引擎 [Five](https://unpkg.com/@realsee/five/docs/index.html) 和 用户界面构建库 [React](https://reactjs.org/) 实现的如视 3D 空间剧本播放器。
|
|
5
|
+
**Vreo** (VR Video 缩写) 是基于如视三维渲染引擎 [Five](https://unpkg.com/@realsee/five/docs/index.html) 和 用户界面构建库 [React](https://reactjs.org/) 实现的如视 3D 空间剧本播放器。
|
|
6
6
|
|
|
7
7
|
## 特性
|
|
8
8
|
|
|
@@ -59,7 +59,7 @@ vreoplayer.pause()
|
|
|
59
59
|
|
|
60
60
|
## React Context & Hooks 模式使用
|
|
61
61
|
|
|
62
|
-
Vreo 支持 [React Context](https://reactjs.org/docs/context.html) 与 [Hooks](https://reactjs.org/docs/hooks-intro.html) 相配合的模式使用,简单样例如下:
|
|
62
|
+
**Vreo** 支持 [React Context](https://reactjs.org/docs/context.html) 与 [Hooks](https://reactjs.org/docs/hooks-intro.html) 相配合的模式使用,简单样例如下:
|
|
63
63
|
|
|
64
64
|
```jsx
|
|
65
65
|
import * as React from 'react'
|
|
@@ -114,7 +114,7 @@ ReactDOM.render(<App></App>, document.getElementById('app'))
|
|
|
114
114
|
|
|
115
115
|
### 结构描述
|
|
116
116
|
|
|
117
|
-
**VreoUnit**
|
|
117
|
+
**VreoUnit** 是剧本数据结构的最小单元,用以描述音视频、剧本帧序列等信息。
|
|
118
118
|
|
|
119
119
|
**VreoUnit** 数据结构样例如下:
|
|
120
120
|
|
|
@@ -233,25 +233,25 @@ ReactDOM.render(<App></App>, document.getElementById('app'))
|
|
|
233
233
|
|
|
234
234
|
> 注意事项:**视频素材必须是绿幕背景**。
|
|
235
235
|
|
|
236
|
-
- `keyframes
|
|
236
|
+
- `keyframes`:剧本帧集合。
|
|
237
237
|
|
|
238
|
-
- `uuid`:
|
|
239
|
-
- `type`:
|
|
238
|
+
- `uuid`: 剧本帧 `uuid`。
|
|
239
|
+
- `type`: 剧本帧类别枚举,详见下文 **剧本关键帧** 部分。
|
|
240
240
|
- `start`: 触发时间戳。
|
|
241
241
|
- `end`: 结束时间戳。
|
|
242
242
|
- `parsed`: 解析状态。
|
|
243
|
-
- `data`:
|
|
243
|
+
- `data`: 当前剧本帧类别数据依赖。
|
|
244
244
|
|
|
245
245
|
> **如何获取剧本数据?**
|
|
246
|
-
>
|
|
246
|
+
> 剧本服务及剧本编辑器公开版本尚在开发中,敬请期待。
|
|
247
247
|
|
|
248
|
-
###
|
|
248
|
+
### 剧本帧说明
|
|
249
249
|
|
|
250
|
-
Vreo
|
|
250
|
+
**Vreo** 剧本行为是按照剧本关键帧来执行的,即根据音视频播放的时间序列命中剧本帧后,按照剧本帧的类型执行相机运镜、全景标签、模型特效等动作。
|
|
251
251
|
|
|
252
|
-
>
|
|
252
|
+
> 目前支持多种类型剧本关键帧(详见:[Player.VreoKeyframeEnum](https://realsee-developer.github.io/vreo/enums/Player.VreoKeyframeEnum.html)),后续会不断完善及添加新的剧本关键帧行为。
|
|
253
253
|
|
|
254
|
-
Vreo 内置了每一个剧本关键帧的 UI 动作行为,通过 `vreoplayer.on()` 可监听到相应的剧本关键帧的命中时机,并按需添加业务逻辑。
|
|
254
|
+
**Vreo** 内置了每一个剧本关键帧的 UI 动作行为,通过 `vreoplayer.on()` 可监听到相应的剧本关键帧的命中时机,并按需添加业务逻辑。
|
|
255
255
|
|
|
256
256
|
### 剧本关键帧
|
|
257
257
|
|
|
@@ -353,8 +353,23 @@ type PanoEffectData = {
|
|
|
353
353
|
|
|
354
354
|
```ts
|
|
355
355
|
export type UpdateVRPanoramaData = {
|
|
356
|
-
|
|
357
|
-
|
|
356
|
+
_signature: string // 签名字段
|
|
357
|
+
allow_hosts: string[] // 域名白名单
|
|
358
|
+
certificate: string // 签名值
|
|
359
|
+
expire_at: string // 过期时间
|
|
360
|
+
// 动态场景
|
|
361
|
+
dynamic_scene?: {
|
|
362
|
+
images: { // 切换全景的图片
|
|
363
|
+
index: number // 对应的全景点位
|
|
364
|
+
right: string
|
|
365
|
+
left: string
|
|
366
|
+
up: string
|
|
367
|
+
down: string
|
|
368
|
+
front: string
|
|
369
|
+
back: string
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
[key: string]: any
|
|
358
373
|
}
|
|
359
374
|
```
|
|
360
375
|
|
|
@@ -393,9 +408,9 @@ type VideoEffectData = {
|
|
|
393
408
|
}
|
|
394
409
|
```
|
|
395
410
|
|
|
396
|
-
###
|
|
411
|
+
### 自定义剧本帧行为
|
|
397
412
|
|
|
398
|
-
Vreo
|
|
413
|
+
**Vreo** 中的剧本帧行为是内置的,但如果您有强烈的诸如统一 UI 风格类的诉求,不想使用内置剧本逻辑,也可以通过 `new Player(five, {keyframeMap: {PanoTag: false}})` 来禁用内置剧本帧解析,然后通过监听剧本帧触发事件来补充您自己的剧本 UI 行为。
|
|
399
414
|
|
|
400
415
|
比如,禁用全景标签的解析:
|
|
401
416
|
|
|
@@ -417,8 +432,33 @@ vreoplayer.off(VreoKeyframeEnum.PanoTag, callback)
|
|
|
417
432
|
|
|
418
433
|
目前仅 DOM 相关的剧本关键帧支持自定义,与 3D 空间模型相关的内容(如:运镜、特效等)尚不支持用户自定义,请采用内置方案。
|
|
419
434
|
|
|
435
|
+
### 自定义剧本帧
|
|
436
|
+
|
|
437
|
+
除了默认内置的剧本帧之外,**Vreo** 支持自定义剧本帧。你可以将剧本帧类型设定为 `VreoKeyframeEnum.Custom`,然后通过监听 `vreoplayer.on(VreoKeyframeEnum.Custom, callback)` 剧本事件去解析你自己定义的剧本行为。
|
|
438
|
+
|
|
439
|
+
此外,你也可以实现个 `React` 组件,例如:
|
|
440
|
+
|
|
441
|
+
```ts
|
|
442
|
+
export function YourCustomKeyframe(props: CustomVreoKeyframeProps) {
|
|
443
|
+
|
|
444
|
+
React.useEffect(() => {
|
|
445
|
+
props.subscribe.on(VreoKeyframeEnum.Custom, callback)
|
|
446
|
+
|
|
447
|
+
return () => {
|
|
448
|
+
props.subscribe.off(VreoKeyframeEnum.Custom, callback)
|
|
449
|
+
}
|
|
450
|
+
}, [])
|
|
451
|
+
|
|
452
|
+
return <>...</>
|
|
453
|
+
}
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
然后通过 `new Player(five, {customKeyframes: [YourCustomKeyframe]})` 配置参数添加进去即可。
|
|
457
|
+
|
|
420
458
|
## 注意事项
|
|
421
459
|
|
|
460
|
+
### 兼容性
|
|
461
|
+
|
|
422
462
|
浏览器对视频自动播放有严格的限制(播放行为必须由用户触发),`@realsee/vreo` 内部已经最大限度规避了浏览器对视频自动播放的限制。
|
|
423
463
|
|
|
424
464
|
但是规避 [微信浏览器中音视频自动播放限制](https://developers.weixin.qq.com/community/develop/doc/000e640d77cfa001132a6cb8456c01) 需要调用 [微信 JS-SDK](https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html) 触发`WeixinJSBridgeReady`事件后才能实现。
|
|
@@ -437,9 +477,23 @@ const creatVideo = (): HTMLVideoElement => {
|
|
|
437
477
|
return video
|
|
438
478
|
}
|
|
439
479
|
|
|
480
|
+
const creatAudio = (): HTMLVideoElement => {
|
|
481
|
+
const audio = document.createElement('audio')
|
|
482
|
+
|
|
483
|
+
audio.setAttribute('autoplay', 'true')
|
|
484
|
+
|
|
485
|
+
return audio
|
|
486
|
+
}
|
|
487
|
+
|
|
440
488
|
// 提前创建 Video
|
|
489
|
+
// 视频特效
|
|
441
490
|
const videoEffect = creatVideo()
|
|
491
|
+
// 视频广告
|
|
442
492
|
const modelTVVideo = creatVideo()
|
|
493
|
+
// 视频数字人形象
|
|
494
|
+
const videoInstance = creatVideo()
|
|
495
|
+
// 无数字人,仅音频
|
|
496
|
+
const audioInstance = createAudio()
|
|
443
497
|
|
|
444
498
|
// 微信限制:需在 WeixinJSBridgeReady 回调中触发一次
|
|
445
499
|
document.addEventListener(
|
|
@@ -447,6 +501,8 @@ document.addEventListener(
|
|
|
447
501
|
() => {
|
|
448
502
|
videoEffect.play()
|
|
449
503
|
modelTVVideo.play()
|
|
504
|
+
videoInstance.play()
|
|
505
|
+
audioInstance.play
|
|
450
506
|
},
|
|
451
507
|
false
|
|
452
508
|
)
|
|
@@ -457,11 +513,42 @@ const vreoplayer = new Player(five, {
|
|
|
457
513
|
videoEffect, // 视频特效 时依赖的 HTMLVideoElement
|
|
458
514
|
modelTVVideo, // 视频广告 时依赖的 HTMLVideoElement
|
|
459
515
|
},
|
|
516
|
+
videoAgentMeshOptions: {
|
|
517
|
+
videoInstance,
|
|
518
|
+
audioInstance,
|
|
519
|
+
}
|
|
460
520
|
})
|
|
461
521
|
```
|
|
462
522
|
|
|
463
523
|
这样,在微信浏览器或微信小程序 `WebView` 中也能正常使用自动播效果。
|
|
464
524
|
|
|
525
|
+
### 性能优化
|
|
526
|
+
|
|
527
|
+
提高播放性能目前有两个策略:降低贴图分辨率和提前预载。
|
|
528
|
+
|
|
529
|
+
#### 降低图片分辨率
|
|
530
|
+
|
|
531
|
+
可以设置 `five.imageOptions.size` 来降低渲染引擎的贴图尺寸,这样下载速度会变快且内存占用也会降低。
|
|
532
|
+
你也可以配置 **Vreo** 参数来达到类似的效果:
|
|
533
|
+
|
|
534
|
+
```ts
|
|
535
|
+
const vreoplayer = new Player(five, { imageOptions: { size: 1024 } })
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
#### 自动预载
|
|
539
|
+
|
|
540
|
+
如果网络不稳定,可以提前预载静态资源,这样播放过程中不会卡顿:
|
|
541
|
+
|
|
542
|
+
```ts
|
|
543
|
+
// 全局预载
|
|
544
|
+
const vreoplayer = new Player(five, { autoPreload: true })
|
|
545
|
+
|
|
546
|
+
// 针对某一份剧本数据预载
|
|
547
|
+
vreoplayer.load(vreoUnit, 0, true)
|
|
548
|
+
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
|
|
465
552
|
## API 文档
|
|
466
553
|
|
|
467
554
|
详细的 API 文档请参考:[Vreo API](https://realsee-developer.github.io/vreo/index.html) 。
|
package/docs/assets/custom.css
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
body {
|
|
2
2
|
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
|
|
3
|
-
font-size:
|
|
3
|
+
font-size: 16px;
|
|
4
4
|
color: #2e2e2e;
|
|
5
5
|
}
|
|
6
6
|
|
|
@@ -19,7 +19,7 @@ blockquote p {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
.tsd-typography {
|
|
22
|
-
font-size:
|
|
22
|
+
font-size: 16px;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
.tsd-typography h4 {
|
|
@@ -29,10 +29,10 @@ blockquote p {
|
|
|
29
29
|
.hljs {
|
|
30
30
|
background-color: transparent;
|
|
31
31
|
font-family: monospace;
|
|
32
|
-
font-size: 0.
|
|
32
|
+
font-size: 0.85rem;
|
|
33
33
|
}
|
|
34
34
|
code {
|
|
35
|
-
font-size:
|
|
35
|
+
font-size: 14px;
|
|
36
36
|
background-color: rgb(96 125 139 / 10%);
|
|
37
37
|
}
|
|
38
38
|
|