@realsee/vreo 0.1.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.
Files changed (126) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +465 -0
  3. package/docs/.nojekyll +1 -0
  4. package/docs/assets/custom.css +52 -0
  5. package/docs/assets/highlight.css +127 -0
  6. package/docs/assets/icons.css +1043 -0
  7. package/docs/assets/icons.png +0 -0
  8. package/docs/assets/icons@2x.png +0 -0
  9. package/docs/assets/main.js +52 -0
  10. package/docs/assets/search.js +1 -0
  11. package/docs/assets/style.css +1388 -0
  12. package/docs/assets/widgets.png +0 -0
  13. package/docs/assets/widgets@2x.png +0 -0
  14. package/docs/classes/Player.Player-1.html +50 -0
  15. package/docs/enums/Player.InfoPanelTypeEnum.html +3 -0
  16. package/docs/enums/Player.PanoEffectEnum.html +5 -0
  17. package/docs/enums/Player.PanoTagEnum.html +3 -0
  18. package/docs/enums/Player.VreoKeyframeEnum.html +388 -0
  19. package/docs/enums/fivePlugins.CameraMovementEffect.html +1 -0
  20. package/docs/enums/fivePlugins.Rotation.html +1 -0
  21. package/docs/index.html +204 -0
  22. package/docs/interfaces/Player.PlayerConfigs.html +4 -0
  23. package/docs/interfaces/Player.Vertex.html +3 -0
  24. package/docs/interfaces/Player.VreoKeyframe.html +3 -0
  25. package/docs/interfaces/Player.VreoUnit.html +3 -0
  26. package/docs/interfaces/Player.VreoVideo.html +3 -0
  27. package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +1 -0
  28. package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +7 -0
  29. package/docs/interfaces/fivePlugins.CameraMovementPluginParameterType.html +1 -0
  30. package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +1 -0
  31. package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +1 -0
  32. package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +1 -0
  33. package/docs/interfaces/react.VreoActionCallbacks.html +15 -0
  34. package/docs/modules/Player.html +29 -0
  35. package/docs/modules/fivePlugins.html +3 -0
  36. package/docs/modules/react.html +1 -0
  37. package/docs/modules.html +1 -0
  38. package/lib/Player/App.d.ts +2 -0
  39. package/lib/Player/App.js +68 -0
  40. package/lib/Player/Controller.d.ts +39 -0
  41. package/lib/Player/Controller.js +226 -0
  42. package/lib/Player/hooks.d.ts +4 -0
  43. package/lib/Player/hooks.js +41 -0
  44. package/lib/Player/index.d.ts +15 -0
  45. package/lib/Player/index.js +191 -0
  46. package/lib/Player/modules/Drawer/index.d.ts +2 -0
  47. package/lib/Player/modules/Drawer/index.js +67 -0
  48. package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +30 -0
  49. package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +324 -0
  50. package/lib/Player/modules/VideoAgent/VideoAgentScene.d.ts +10 -0
  51. package/lib/Player/modules/VideoAgent/VideoAgentScene.js +65 -0
  52. package/lib/Player/modules/VideoAgent/index.d.ts +4 -0
  53. package/lib/Player/modules/VideoAgent/index.js +44 -0
  54. package/lib/Player/modules/keyframes/CameraMovement/index.d.ts +2 -0
  55. package/lib/Player/modules/keyframes/CameraMovement/index.js +73 -0
  56. package/lib/Player/modules/keyframes/InfoPanel/index.d.ts +2 -0
  57. package/lib/Player/modules/keyframes/InfoPanel/index.js +89 -0
  58. package/lib/Player/modules/keyframes/ModelVideo/index.d.ts +2 -0
  59. package/lib/Player/modules/keyframes/ModelVideo/index.js +87 -0
  60. package/lib/Player/modules/keyframes/PanoEffect/index.d.ts +2 -0
  61. package/lib/Player/modules/keyframes/PanoEffect/index.js +142 -0
  62. package/lib/Player/modules/keyframes/PanoEffect/lineAnime.d.ts +5 -0
  63. package/lib/Player/modules/keyframes/PanoEffect/lineAnime.js +46 -0
  64. package/lib/Player/modules/keyframes/PanoTag/index.d.ts +2 -0
  65. package/lib/Player/modules/keyframes/PanoTag/index.js +168 -0
  66. package/lib/Player/modules/keyframes/PanoTextLabel/index.d.ts +2 -0
  67. package/lib/Player/modules/keyframes/PanoTextLabel/index.js +113 -0
  68. package/lib/Player/modules/keyframes/Prompter/index.d.ts +2 -0
  69. package/lib/Player/modules/keyframes/Prompter/index.js +105 -0
  70. package/lib/Player/modules/keyframes/UpdateVRPanorama/index.d.ts +2 -0
  71. package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +51 -0
  72. package/lib/Player/modules/keyframes/VideoEffect/index.d.ts +2 -0
  73. package/lib/Player/modules/keyframes/VideoEffect/index.js +176 -0
  74. package/lib/Player/typings.d.ts +14 -0
  75. package/lib/Player/typings.js +5 -0
  76. package/lib/fivePlugins/CameraMovementPlugin/index.d.ts +6 -0
  77. package/lib/fivePlugins/CameraMovementPlugin/index.js +307 -0
  78. package/lib/fivePlugins/CameraMovementPlugin/typings.d.ts +48 -0
  79. package/lib/fivePlugins/CameraMovementPlugin/typings.js +25 -0
  80. package/lib/fivePlugins/ModelTVVideoPlugin/index.d.ts +20 -0
  81. package/lib/fivePlugins/ModelTVVideoPlugin/index.js +305 -0
  82. package/lib/index.d.ts +1 -0
  83. package/lib/index.js +13 -0
  84. package/lib/react/index.d.ts +42 -0
  85. package/lib/react/index.js +120 -0
  86. package/lib/shared-utils/Preloader.d.ts +6 -0
  87. package/lib/shared-utils/Preloader.js +51 -0
  88. package/lib/shared-utils/animationFrame/BetterTween.d.ts +11 -0
  89. package/lib/shared-utils/animationFrame/BetterTween.js +102 -0
  90. package/lib/shared-utils/animationFrame/index.d.ts +15 -0
  91. package/lib/shared-utils/animationFrame/index.js +68 -0
  92. package/lib/shared-utils/animationFrame/tween.d.ts +75 -0
  93. package/lib/shared-utils/animationFrame/tween.js +76 -0
  94. package/lib/typings/VreoUnit.d.ts +204 -0
  95. package/lib/typings/VreoUnit.js +65 -0
  96. package/package.json +55 -0
  97. package/resources/Player/App.tsx +57 -0
  98. package/resources/Player/Controller.ts +154 -0
  99. package/resources/Player/hooks.ts +28 -0
  100. package/resources/Player/index.tsx +115 -0
  101. package/resources/Player/modules/Drawer/index.tsx +40 -0
  102. package/resources/Player/modules/VideoAgent/VideoAgentMesh.ts +202 -0
  103. package/resources/Player/modules/VideoAgent/VideoAgentScene.ts +38 -0
  104. package/resources/Player/modules/VideoAgent/index.tsx +31 -0
  105. package/resources/Player/modules/keyframes/CameraMovement/index.tsx +33 -0
  106. package/resources/Player/modules/keyframes/InfoPanel/index.tsx +52 -0
  107. package/resources/Player/modules/keyframes/ModelVideo/index.tsx +44 -0
  108. package/resources/Player/modules/keyframes/PanoEffect/index.tsx +99 -0
  109. package/resources/Player/modules/keyframes/PanoEffect/lineAnime.ts +31 -0
  110. package/resources/Player/modules/keyframes/PanoTag/index.tsx +127 -0
  111. package/resources/Player/modules/keyframes/PanoTextLabel/index.tsx +65 -0
  112. package/resources/Player/modules/keyframes/Prompter/index.tsx +65 -0
  113. package/resources/Player/modules/keyframes/UpdateVRPanorama/index.tsx +36 -0
  114. package/resources/Player/modules/keyframes/VideoEffect/index.tsx +115 -0
  115. package/resources/Player/typings.ts +15 -0
  116. package/resources/fivePlugins/CameraMovementPlugin/index.ts +203 -0
  117. package/resources/fivePlugins/CameraMovementPlugin/typings.ts +57 -0
  118. package/resources/fivePlugins/ModelTVVideoPlugin/index.ts +278 -0
  119. package/resources/index.ts +1 -0
  120. package/resources/react/index.tsx +95 -0
  121. package/resources/shared-utils/Preloader.ts +35 -0
  122. package/resources/shared-utils/animationFrame/BetterTween.ts +33 -0
  123. package/resources/shared-utils/animationFrame/index.ts +48 -0
  124. package/resources/shared-utils/animationFrame/tween.ts +51 -0
  125. package/resources/typings/VreoUnit.ts +225 -0
  126. package/stylesheets/default.css +497 -0
@@ -0,0 +1,48 @@
1
+ const _requestAnimationFrame = window.requestAnimationFrame || ((fn) => setTimeout(fn, 16))
2
+
3
+ const _cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout
4
+
5
+ export default _requestAnimationFrame
6
+
7
+ export function nextFrame(fn: FrameRequestCallback, delay = 0) {
8
+ if (delay <= 0) _requestAnimationFrame(fn)
9
+ else _requestAnimationFrame(() => nextFrame(fn, delay - 1))
10
+ }
11
+
12
+ /**
13
+ * 在每个 AnimationFrame 中调用传入的函数
14
+ * @param callback 每次 AnimationFrame 中调用的函数
15
+ * @param frame 每秒运行多少次
16
+ * @returns 返回一个函数,调用可以停止 AnimationFrameLoop
17
+ */
18
+ export function requestAnimationFrameInterval(callback?: (time: number) => any, frame = 60) {
19
+ let index = -1
20
+ let oldTime = 0
21
+ let startTime = -1
22
+ const minDeltaTime = 1000 / frame
23
+ function loop(time: number) {
24
+ startTime === -1 && (startTime = time)
25
+ index = _requestAnimationFrame(loop)
26
+ const deltaTime = time - oldTime
27
+ if (deltaTime < minDeltaTime) return
28
+ oldTime = time
29
+ callback && callback(time - startTime)
30
+ }
31
+ index = _requestAnimationFrame(loop)
32
+ return function stop() {
33
+ _cancelAnimationFrame(index)
34
+ }
35
+ }
36
+
37
+ /**
38
+ * 获取两个 AnimationFrame 间隔的时间
39
+ * @returns 返回一个 Promise,resolve 的结果是两个 AnimationFrame 间隔的时间
40
+ */
41
+ export function getFrameTime() {
42
+ const start = Date.now()
43
+ return new Promise((resolve) => {
44
+ _requestAnimationFrame(() => {
45
+ resolve(Date.now() - start)
46
+ })
47
+ })
48
+ }
@@ -0,0 +1,51 @@
1
+ import * as TWEEN from '@tweenjs/tween.js'
2
+ import { nextFrame, requestAnimationFrameInterval } from './index'
3
+
4
+ export const Easing = TWEEN.Easing
5
+
6
+ interface ITween<T> extends TWEEN.Tween<T> {
7
+ onDestroy: (fn: () => void) => TWEEN.Tween<T>
8
+ destroy: () => void
9
+ }
10
+
11
+ /**
12
+ * 对象变化的补间动画
13
+ * 1. 应用 requestAnimationFrameInterval 做 update
14
+ * 2. 在原生 tween 上新增 destroy 方法和 onDestroy 监听
15
+ * DOC: https://github.com/tweenjs/tween.js
16
+ * @param from 对象起始状态
17
+ * @param to 对象末尾状态
18
+ * @param duration 经历时间(s)
19
+ * @param easing 过程动画,默认是 Easing.Linear.None
20
+ */
21
+ export default function tween<T>(from: T, to: T, duration: number, easing = Easing.Linear.None) {
22
+ const tween = new TWEEN.Tween(from).to(to, duration).easing(easing) as ITween<T>
23
+ // 这里注意一下,因为 requestAnimationFrameInterval 给的时间是从 0 开始的,tween 动画也从 0 开始
24
+ nextFrame(() => tween.start(0))
25
+
26
+ const cancelAnimationFrame = requestAnimationFrameInterval((time) => {
27
+ if (tween.update(time) === false) cancelAnimationFrame()
28
+ })
29
+ const destroyMethods: ((...params: any) => any)[] = []
30
+ tween.onDestroy = (fn) => {
31
+ destroyMethods.push(fn)
32
+ return tween
33
+ }
34
+ tween.destroy = function () {
35
+ this.stop()
36
+ Object.assign(tween, {
37
+ _onStartCallback: null,
38
+ _onUpdateCallback: null,
39
+ _onCompleteCallback: null,
40
+ _onStopCallbackL: null,
41
+ })
42
+ let destroyMethod: undefined | ((...params: any) => any)
43
+ while ((destroyMethod = destroyMethods.shift())) destroyMethod()
44
+ cancelAnimationFrame()
45
+ }
46
+ return tween
47
+ }
48
+
49
+ export function tweenProgress(duration: number, easing: typeof Easing.Linear.None) {
50
+ return tween({ progress: 0 }, { progress: 1 }, duration, easing)
51
+ }
@@ -0,0 +1,225 @@
1
+ import { Mode, Pose, WorkCubeImage } from '@realsee/five'
2
+ import { CameraMovementEffect, Rotation } from '../fivePlugins/CameraMovementPlugin/typings'
3
+
4
+ export enum VreoKeyframeEnum {
5
+ /** 运镜 */
6
+ CameraMovement = 'CameraMovement',
7
+ /**
8
+ * 全景标签
9
+ */
10
+ PanoTag = 'PanoTag',
11
+ /**
12
+ * 全景文本标签
13
+ */
14
+ PanoTextLabel = 'PanoTextLabel',
15
+ /**
16
+ * 提词器
17
+ */
18
+ Prompter = 'Prompter',
19
+ /**
20
+ * 更新 VR 全景
21
+ */
22
+ UpdateVRPanorama = 'UpdateVRPanorama',
23
+ /**
24
+ * 视频广告
25
+ */
26
+ ModelVideo = 'ModelVideo',
27
+ /**
28
+ * 全景特效
29
+ */
30
+ PanoEffect = 'PanoEffect',
31
+ /**
32
+ * 信息面板
33
+ */
34
+ InfoPanel = 'InfoPanel',
35
+ /**
36
+ * 视频特效
37
+ */
38
+ VideoEffect = 'VideoEffect',
39
+ /**
40
+ * 结束
41
+ */
42
+ Exit = 'Exit',
43
+ }
44
+
45
+ /**
46
+ * 支持自定义剧本关键帧配置项
47
+ */
48
+ export type VreoKeyframeConfigMap = {
49
+ PanoTag?: false
50
+ PanoTextLabel?: false
51
+ Prompter?: false
52
+ InfoPanel?: false
53
+ }
54
+
55
+
56
+ /**
57
+ * 剧本关键帧
58
+ */
59
+ export interface VreoKeyframe {
60
+ type: VreoKeyframeEnum
61
+ start: number
62
+ end: number
63
+ parsed?: boolean
64
+ data: Record<string, any>
65
+ }
66
+
67
+ /**
68
+ * 虚拟视频角色
69
+ */
70
+ export interface VreoVideo {
71
+ duration: number
72
+ start: number
73
+ end: number
74
+ url: string
75
+ }
76
+
77
+ /**
78
+ * 剧本结构
79
+ */
80
+ export interface VreoUnit {
81
+ categoryId: string
82
+ categoryText: string
83
+ frontRequestId: string
84
+ index: string | number
85
+ keyframes: VreoKeyframe[]
86
+ video: VreoVideo
87
+ }
88
+
89
+
90
+
91
+ /**
92
+ * 剧本事件
93
+ */
94
+ export type VreoKeyframeEvent = { [key in VreoKeyframeEnum]: (keyframe: VreoKeyframe) => void } & {
95
+ paused: () => void
96
+ playing: () => void
97
+ }
98
+
99
+ /**
100
+ * 相机运动
101
+ */
102
+ export type CameraMovementData = {
103
+ effect: CameraMovementEffect
104
+ mode: Mode
105
+ panoIndex: number
106
+ loop?: boolean
107
+ rotateSpeed?: number
108
+ rotation?: Rotation
109
+ } & Partial<Pose>
110
+
111
+ /**
112
+ * 提词器
113
+ */
114
+ export type PrompterData = {
115
+ text: string
116
+ }
117
+
118
+ /**
119
+ * VR 全景切换
120
+ */
121
+ export type UpdateVRPanoramaData = {
122
+ panoIndex: number
123
+ images: WorkCubeImage
124
+ }
125
+
126
+ /**
127
+ * 顶点
128
+ */
129
+ export interface Vertex {
130
+ x: number
131
+ y: number
132
+ z: number
133
+ }
134
+
135
+ /**
136
+ * 四个顶点元组
137
+ */
138
+ export type QuadrangleVertexs = [Vertex, Vertex, Vertex, Vertex]
139
+
140
+ /**
141
+ * 视频广告
142
+ */
143
+ export type ModelVideoData = {
144
+ /**
145
+ * 视频素材
146
+ */
147
+ videoSrc: string
148
+ /**
149
+ * 视频封面
150
+ */
151
+ videoPosterSrc: string
152
+ /**
153
+ * 视频映射在模型中的顶点
154
+ */
155
+ vertexs: QuadrangleVertexs
156
+ }
157
+
158
+ /**
159
+ * 全景文本标签
160
+ */
161
+ export type PanoTextLabelData = {
162
+ text: string
163
+ vertex: Vertex
164
+ fontSize?: number
165
+ }
166
+
167
+ /**
168
+ * 全景标签枚举
169
+ */
170
+ export enum PanoTagEnum {
171
+ Text = 'Text',
172
+ Image = 'Image',
173
+ }
174
+
175
+ export type PanoTagData = {
176
+ type: PanoTagEnum
177
+ text: string
178
+ vertex: Vertex
179
+ imgUrl?: string
180
+ }
181
+
182
+ /**
183
+ * 全景特效枚举
184
+ */
185
+ export enum PanoEffectEnum {
186
+ /**
187
+ * 两点距离
188
+ */
189
+ Distance = 'Distance',
190
+ }
191
+
192
+ /**
193
+ * 全景特效
194
+ */
195
+ export type PanoEffectData = {
196
+ effect: PanoEffectEnum
197
+ twoVertexs: [Vertex, Vertex]
198
+ }
199
+
200
+ /**
201
+ * 信息面板类型枚举
202
+ */
203
+ export enum InfoPanelTypeEnum {
204
+ Image = 'Image',
205
+ Video = 'Video',
206
+ }
207
+
208
+ /**
209
+ * 信息面板
210
+ */
211
+ export type InfoPanelData = {
212
+ type: InfoPanelTypeEnum
213
+ url: string
214
+ }
215
+
216
+ /**
217
+ * 视频特效
218
+ */
219
+ export type VideoEffectData = {
220
+ videoSrc: string
221
+ panoIndex: number
222
+ fov: number
223
+ direction?: Vertex
224
+ vector?: Pick<Pose, 'longitude' | 'latitude'>
225
+ }