@realsee/vreo 0.2.0-alpha.9 → 1.0.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.
Files changed (161) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +16 -5
  3. package/docs/assets/highlight.css +1 -1
  4. package/docs/assets/main.js +2 -2
  5. package/docs/assets/search.js +1 -1
  6. package/docs/assets/style.css +28 -2
  7. package/docs/classes/Player.AudioLike.html +52 -0
  8. package/docs/classes/Player.Controller.html +13 -13
  9. package/docs/classes/Player.Player-1.html +11 -11
  10. package/docs/classes/Player.VideoAgentMesh.html +53 -53
  11. package/docs/classes/Player.VideoAgentScene.html +1 -1
  12. package/docs/demo/assets/AppReact.ea8cbdb3.js +1 -0
  13. package/docs/demo/assets/default.1dd2b2d4.js +3988 -0
  14. package/docs/demo/assets/default.bc4c715d.css +1 -0
  15. package/docs/demo/assets/dynamic.cd7d1da6.js +1 -0
  16. package/docs/demo/assets/examples.98aaf9e2.js +25 -0
  17. package/docs/demo/assets/examples.dac4a6fe.css +1 -0
  18. package/docs/demo/assets/index.9331038f.css +1 -0
  19. package/docs/demo/assets/index.a3d7bd8a.js +1 -0
  20. package/docs/demo/assets/main.f0c47cae.js +1 -0
  21. package/docs/demo/assets/react.2ee8565f.css +1 -0
  22. package/docs/demo/assets/react.5f3bcfc5.js +25 -0
  23. package/docs/demo/assets/znRoyv06SZQeqA7m.0057e8ae.js +1 -0
  24. package/docs/demo/examples.html +17 -0
  25. package/docs/demo/index-react-dynamic.html +20 -0
  26. package/docs/demo/index-react.html +20 -0
  27. package/docs/demo/index.html +19 -0
  28. package/docs/enums/Player.InfoPanelStyleEnum.html +1 -1
  29. package/docs/enums/Player.InfoPanelTypeEnum.html +2 -2
  30. package/docs/enums/Player.PanoEffectEnum.html +2 -2
  31. package/docs/enums/Player.PanoTagEnum.html +2 -2
  32. package/docs/enums/Player.PanoTagStyleEnum.html +7 -0
  33. package/docs/enums/Player.VreoKeyframeEnum.html +12 -12
  34. package/docs/enums/fivePlugins.CameraMovementEffect.html +1 -1
  35. package/docs/enums/fivePlugins.Rotation.html +1 -1
  36. package/docs/index.html +13 -6
  37. package/docs/interfaces/Player.CustomVreoKeyframeProps.html +1 -1
  38. package/docs/interfaces/Player.PlayerConfigs.html +4 -3
  39. package/docs/interfaces/Player.Vertex.html +2 -2
  40. package/docs/interfaces/Player.VideoAgentMeshOptions.html +8 -1
  41. package/docs/interfaces/Player.VreoKeyframe.html +2 -2
  42. package/docs/interfaces/Player.VreoUnit.html +2 -2
  43. package/docs/interfaces/Player.VreoVideo.html +2 -2
  44. package/docs/interfaces/fivePlugins.CSS3DRenderPluginExportType.html +4 -0
  45. package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +1 -1
  46. package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +2 -2
  47. package/docs/interfaces/fivePlugins.CameraMovementPluginParameterType.html +1 -1
  48. package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +1 -1
  49. package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +1 -1
  50. package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +1 -1
  51. package/docs/interfaces/fivePlugins.Vector3Position.html +3 -0
  52. package/docs/interfaces/react.VreoActionCallbacks.html +15 -7
  53. package/docs/interfaces/react.VreoProviderProps.html +1 -1
  54. package/docs/modules/Player.html +21 -15
  55. package/docs/modules/custom.html +1 -1
  56. package/docs/modules/fivePlugins.html +5 -2
  57. package/docs/modules/react.html +1 -1
  58. package/docs/modules.html +1 -1
  59. package/lib/PlayController/createHTMLAudioElement.js +6 -11
  60. package/lib/PlayController/index.js +19 -85
  61. package/lib/Player/App.js +7 -29
  62. package/lib/Player/Controller.d.ts +29 -8
  63. package/lib/Player/Controller.js +185 -87
  64. package/lib/Player/custom/SpatialScenePanel/index.js +47 -72
  65. package/lib/Player/hooks.js +2 -12
  66. package/lib/Player/index.d.ts +5 -3
  67. package/lib/Player/index.js +108 -122
  68. package/lib/Player/modules/Drawer/index.js +1 -18
  69. package/lib/Player/modules/PopUp/index.js +1 -11
  70. package/lib/Player/modules/ResizeObserver/index.d.ts +2 -0
  71. package/lib/Player/modules/ResizeObserver/index.js +29 -0
  72. package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +16 -2
  73. package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +124 -145
  74. package/lib/Player/modules/VideoAgent/VideoAgentScene.d.ts +3 -6
  75. package/lib/Player/modules/VideoAgent/VideoAgentScene.js +25 -52
  76. package/lib/Player/modules/VideoAgent/index.js +46 -22
  77. package/lib/Player/modules/Wave/index.d.ts +5 -0
  78. package/lib/Player/modules/Wave/index.js +77 -0
  79. package/lib/Player/modules/keyframes/BgMusic/index.js +3 -16
  80. package/lib/Player/modules/keyframes/CameraMovement/index.js +4 -28
  81. package/lib/Player/modules/keyframes/InfoPanel/index.js +30 -35
  82. package/lib/Player/modules/keyframes/ModelVideo/index.js +40 -29
  83. package/lib/Player/modules/keyframes/PanoEffect/index.js +16 -44
  84. package/lib/Player/modules/keyframes/PanoEffect/lineAnime.js +1 -8
  85. package/lib/Player/modules/keyframes/PanoTag/index.d.ts +1 -2
  86. package/lib/Player/modules/keyframes/PanoTag/index.js +75 -132
  87. package/lib/Player/modules/keyframes/PanoTextLabel/index.d.ts +3 -0
  88. package/lib/Player/modules/keyframes/PanoTextLabel/index.js +93 -66
  89. package/lib/Player/modules/keyframes/Prompter/index.js +18 -53
  90. package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +22 -25
  91. package/lib/Player/modules/keyframes/VideoEffect/index.js +13 -48
  92. package/lib/Player/typings.d.ts +12 -1
  93. package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.d.ts +2 -0
  94. package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.js +10 -0
  95. package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.d.ts +7 -0
  96. package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.js +31 -0
  97. package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.d.ts +3 -0
  98. package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.js +10 -0
  99. package/lib/fivePlugins/CSS3DRenderPlugin/index.d.ts +56 -0
  100. package/lib/fivePlugins/CSS3DRenderPlugin/index.js +234 -0
  101. package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.d.ts +7 -0
  102. package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.js +15 -0
  103. package/lib/fivePlugins/CameraMovementPlugin/index.js +36 -82
  104. package/lib/fivePlugins/CameraMovementPlugin/typings.js +0 -4
  105. package/lib/fivePlugins/ModelTVVideoPlugin/index.js +12 -61
  106. package/lib/index.js +0 -1
  107. package/lib/react/index.d.ts +8 -4
  108. package/lib/react/index.js +10 -37
  109. package/lib/shared-utils/AduioLike.d.ts +37 -0
  110. package/lib/shared-utils/AduioLike.js +132 -0
  111. package/lib/shared-utils/Preloader.js +0 -7
  112. package/lib/shared-utils/addResizeListener.d.ts +4 -0
  113. package/lib/shared-utils/addResizeListener.js +46 -0
  114. package/lib/shared-utils/animationFrame/BetterTween.js +7 -39
  115. package/lib/shared-utils/animationFrame/index.js +2 -10
  116. package/lib/shared-utils/animationFrame/tween.js +3 -16
  117. package/lib/shared-utils/createTransMatrix.d.ts +1 -0
  118. package/lib/shared-utils/createTransMatrix.js +28 -0
  119. package/lib/shared-utils/getFileExpandedName.d.ts +1 -0
  120. package/lib/shared-utils/getFileExpandedName.js +12 -0
  121. package/lib/shared-utils/getMediaInfo.d.ts +9 -0
  122. package/lib/shared-utils/getMediaInfo.js +66 -0
  123. package/lib/shared-utils/setElementDataset.d.ts +1 -0
  124. package/lib/shared-utils/setElementDataset.js +22 -0
  125. package/lib/typings/VreoUnit.d.ts +37 -2
  126. package/lib/typings/VreoUnit.js +10 -13
  127. package/package.json +10 -10
  128. package/resources/PlayController/index.ts +0 -13
  129. package/resources/Player/App.tsx +5 -4
  130. package/resources/Player/Controller.ts +274 -146
  131. package/resources/Player/custom/SpatialScenePanel/index.tsx +5 -5
  132. package/resources/Player/hooks.ts +3 -5
  133. package/resources/Player/index.tsx +190 -140
  134. package/resources/Player/modules/ResizeObserver/index.tsx +23 -0
  135. package/resources/Player/modules/VideoAgent/VideoAgentMesh.ts +87 -31
  136. package/resources/Player/modules/VideoAgent/VideoAgentScene.ts +27 -24
  137. package/resources/Player/modules/VideoAgent/index.tsx +28 -12
  138. package/resources/Player/modules/Wave/index.tsx +64 -0
  139. package/resources/Player/modules/keyframes/InfoPanel/index.tsx +26 -11
  140. package/resources/Player/modules/keyframes/ModelVideo/index.tsx +36 -3
  141. package/resources/Player/modules/keyframes/PanoTag/index.tsx +52 -97
  142. package/resources/Player/modules/keyframes/PanoTextLabel/index.tsx +86 -34
  143. package/resources/Player/modules/keyframes/Prompter/index.tsx +6 -16
  144. package/resources/Player/modules/keyframes/UpdateVRPanorama/index.tsx +6 -2
  145. package/resources/Player/typings.ts +15 -1
  146. package/resources/fivePlugins/CSS3DRenderPlugin/centerPoint.ts +5 -0
  147. package/resources/fivePlugins/CSS3DRenderPlugin/createResizeObserver.ts +17 -0
  148. package/resources/fivePlugins/CSS3DRenderPlugin/evenNumber.ts +4 -0
  149. package/resources/fivePlugins/CSS3DRenderPlugin/index.ts +254 -0
  150. package/resources/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.ts +5 -0
  151. package/resources/fivePlugins/CameraMovementPlugin/index.ts +19 -12
  152. package/resources/react/index.tsx +7 -3
  153. package/resources/shared-utils/AduioLike.ts +109 -0
  154. package/resources/shared-utils/addResizeListener.ts +46 -0
  155. package/resources/shared-utils/createTransMatrix.ts +12 -0
  156. package/resources/shared-utils/getFileExpandedName.ts +6 -0
  157. package/resources/shared-utils/getMediaInfo.ts +52 -0
  158. package/resources/shared-utils/setElementDataset.ts +18 -0
  159. package/resources/typings/VreoUnit.ts +41 -3
  160. package/stylesheets/custom/SpatialScenePanel.css +2 -1
  161. package/stylesheets/default.css +350 -84
@@ -2,165 +2,293 @@ import { Five, Subscribe } from '@realsee/five'
2
2
  import { action, computed, makeObservable, observable, reaction } from 'mobx'
3
3
  import * as React from 'react'
4
4
  import { requestAnimationFrameInterval } from '../shared-utils/animationFrame'
5
- import { VreoKeyframe, VreoKeyframeEnum, VreoKeyframeEvent, VreoUnit } from '../typings/VreoUnit'
5
+ import { VreoKeyframe, VreoKeyframeEnum, VreoKeyframeEvent, VreoUnit, VreoVideo } from '../typings/VreoUnit'
6
6
  import { VideoAgentScene } from './modules/VideoAgent/VideoAgentScene'
7
- import { PlayerConfigs } from './typings'
7
+ import { Appearance, PlayerConfigs, WaveAppearance } from './typings'
8
+ import setElementDataset from '../shared-utils/setElementDataset'
9
+ import { getMediaType } from '../shared-utils/getMediaInfo'
8
10
 
9
11
  /**
10
12
  * 逻辑控制器:内部状态。
11
13
  */
12
14
  export class Controller extends Subscribe<VreoKeyframeEvent> {
13
15
 
14
- $five?: Five
15
- configs?: PlayerConfigs
16
- videoAgentScene?: VideoAgentScene
17
- vreoUnit?: VreoUnit
18
- stopInterval?: () => void
19
- playing = false
20
-
21
- visible = false
22
-
23
- get isAudio() {
24
- return !this.videoAgentScene?.videoAgentMesh.videoUrl?.endsWith('.mp4')
25
- }
26
-
27
- popUp: string | JSX.Element | null = null
28
-
29
- openPopUp(popUp: string | JSX.Element | false) {
30
- if (!popUp) {
31
- this.popUp = null
32
- return
33
- }
34
- this.popUp = popUp
35
- }
36
-
37
- drawerConfig: {
38
- content: string | JSX.Element
39
- height?: number | string
40
- } | null = null
41
-
42
- setVisible(v: boolean) {
43
- this.visible = v
44
- }
45
-
46
- setPlaying(playing: boolean) {
47
- this.playing = playing
48
- }
49
-
50
- openDrawer(drawerConfig?: false | { content: string | JSX.Element; height?: number | string }) {
51
- if (!drawerConfig) {
52
- this.drawerConfig = {
53
- content: '',
54
- height: this.drawerConfig?.height
55
- }
56
- return
57
- }
58
-
59
- this.drawerConfig = drawerConfig
60
- }
61
-
62
- constructor() {
63
- super()
64
-
65
- makeObservable(this, {
66
- visible: observable,
67
- setVisible: action,
68
- playing: observable,
69
- setPlaying: action,
70
- popUp: observable.ref,
71
- openPopUp: action,
72
- drawerConfig: observable.ref,
73
- openDrawer: action,
74
- })
75
-
76
- // 监听播放情况:抛出触发时机
77
- reaction(
78
- () => this.playing,
79
- (playing) => {
80
- this.emit(playing ? 'playing' : 'paused')
81
- }
82
- )
83
- }
84
-
85
- get ready() {
86
- return !!this.videoAgentScene
87
- }
88
-
89
- get currentTime() {
90
- return this.videoAgentScene?.videoAgentMesh.currentTime || 0
91
- }
92
-
93
- get currentKeyframes() {
94
- if (!this.vreoUnit) return []
95
- const keyframes = this.vreoUnit.keyframes
96
- // 没有被解析过且开始时间低于当前时间戳 100ms
97
- return keyframes.filter((keyframe: VreoKeyframe) => {
98
- if (keyframe.parsed) return false
99
- const dur = this.currentTime - keyframe.start
100
- return dur <= 100 && dur >= 0
101
- })
102
- }
103
-
104
- get videoInstance() {
105
- return this.videoAgentScene?.videoAgentMesh.videoInstance
106
- }
107
-
108
- /**
109
- * 逐帧任务
110
- */
111
- requestAnimationFrameLoop(callback: (type: VreoKeyframeEnum, keyframe: VreoKeyframe) => void) {
112
- if (this.videoInstance?.ended) {
113
- this.setPlaying(false)
114
- this.videoInstance.pause()
115
- return
116
- }
117
- if (!this.playing) {
118
- if (!this.videoInstance?.paused) {
119
- this.videoInstance?.pause()
120
- }
121
- return
122
- }
123
- if (this.videoInstance?.paused && this.playing) {
124
- this.videoInstance.play()
125
- }
126
-
127
- const currentKeyframes = this.currentKeyframes
128
-
129
- currentKeyframes.forEach((keyframe) => {
130
- if (keyframe.parsed) return
131
- keyframe.parsed = true
132
- this.emit(keyframe.type, keyframe)
133
- if (callback) {
134
- callback(keyframe.type, keyframe)
135
- }
136
- })
137
- }
138
-
139
- run(callback: (type: VreoKeyframeEnum, keyframe: VreoKeyframe) => void) {
140
- if (this.stopInterval) return
141
- this.stopInterval = requestAnimationFrameInterval(() => this.requestAnimationFrameLoop(callback))
142
- }
143
-
144
- dispose() {
145
- this.setPlaying(false)
146
-
147
- if (this.currentKeyframes) {
148
- this.currentKeyframes.forEach((keyframe) => (keyframe.parsed = false))
16
+ five: Five
17
+ configs: PlayerConfigs
18
+ videoAgentScene?: VideoAgentScene
19
+ vreoUnit?: VreoUnit
20
+ stopInterval?: () => void
21
+ playing = false
22
+ ended = false
23
+ loading: boolean | null = false // null 表示加载失败
24
+ containerSize: { width: number, height: number } = { width: 0, height: 0 }
25
+ appSize?: 'S' | 'M' | 'L' | 'XL'
26
+ container: Element
27
+ waveAppearance: WaveAppearance | null = null
28
+ appearance: Appearance = {
29
+ waveStyle: 'wave',
30
+ }
31
+ avatar: VreoVideo['avatar'] = {}
32
+
33
+
34
+ visible = false
35
+
36
+ get agentType() {
37
+ const type = getMediaType(this.videoAgentScene?.videoAgentMesh.videoUrl)
38
+ if (this.avatar?.force) return 'avatar'
39
+ if (type === 'video') return 'video'
40
+ return 'none'
41
+ }
42
+
43
+ popUp: string | JSX.Element | null = null
44
+
45
+ openPopUp(popUp: string | JSX.Element | false) {
46
+ if (!popUp) {
47
+ this.popUp = null
48
+ return
49
+ }
50
+ this.popUp = popUp
51
+ }
52
+
53
+ setLoading(loading: boolean | null) {
54
+ this.loading = loading
55
+ }
56
+
57
+ drawerConfig: {
58
+ content: string | JSX.Element
59
+ height?: number | string
60
+ } | null = null
61
+
62
+ setAvatar(avatar: VreoVideo['avatar']) {
63
+ this.avatar = avatar
64
+ }
65
+
66
+ setContainerSize(width: number, height: number) {
67
+ this.containerSize = { width, height }
68
+ }
69
+
70
+ setVisible(v: boolean) {
71
+ this.visible = v
72
+ }
73
+
74
+ setPlaying(playing: boolean) {
75
+ this.playing = playing
76
+ }
77
+
78
+ setEnded(ended: boolean) {
79
+ this.ended = ended
80
+ }
81
+
82
+ setAppearance(appearance: Appearance) {
83
+ this.appearance = { ...this.appearance, ...appearance }
84
+ }
85
+
86
+ openDrawer(drawerConfig?: false | { content: string | JSX.Element; height?: number | string }) {
87
+ if (!drawerConfig) {
88
+ this.drawerConfig = {
89
+ content: '',
90
+ height: this.drawerConfig?.height
91
+ }
92
+ return
93
+ }
94
+
95
+ this.drawerConfig = drawerConfig
96
+ }
97
+
98
+ constructor({five, container, configs}: { five: Five, container: Element, configs: PlayerConfigs }) {
99
+ super()
100
+
101
+ this.configs = configs
102
+ this.container = container
103
+ this.five = five
104
+ this.appSize = configs.appSize
105
+ this.appearance = { ...this.appearance, ...configs.appearance }
106
+
107
+ makeObservable(this, {
108
+ visible: observable,
109
+ setVisible: action,
110
+ playing: observable,
111
+ setPlaying: action,
112
+ loading: observable,
113
+ setLoading: action,
114
+ popUp: observable.ref,
115
+ openPopUp: action,
116
+ drawerConfig: observable.ref,
117
+ openDrawer: action,
118
+ ended: observable,
119
+ waveAppearance: observable,
120
+ avatar: observable,
121
+ containerSize: observable,
122
+ setContainerSize: action,
123
+ appearance: observable,
124
+ setAppearance: action,
125
+ configs: observable.ref,
126
+ setEnded: action,
127
+ setAvatar: action,
128
+ })
129
+
130
+ reaction<[typeof this.appearance.waveStyle, boolean | null], boolean>(
131
+ () => [this.appearance.waveStyle, this.loading],
132
+ ([waveStyle, loading]) => {
133
+ if (loading === null) {
134
+ this.waveAppearance = null
135
+ return
136
+ }
137
+ if (waveStyle === 'wave') {
138
+ switch (loading) {
139
+ case true:
140
+ this.waveAppearance = 'double'
141
+ break
142
+ case false:
143
+ this.waveAppearance = 'solid'
144
+ break
145
+ }
146
+ } else if (waveStyle === 'solid') {
147
+ switch (loading) {
148
+ case true:
149
+ this.waveAppearance = 'swap'
150
+ break
151
+ case false:
152
+ this.waveAppearance = 'expand'
153
+ break
154
+ }
155
+ }
156
+ },
157
+ { fireImmediately: true }
158
+ )
159
+
160
+ if (!this.appSize) {
161
+ reaction(
162
+ () => this.containerSize,
163
+ (containerSize) => {
164
+ if (!containerSize?.width) return
165
+ const width = containerSize.width
166
+ const height = containerSize.height
167
+ const size = (() => {
168
+ if (width <= 500) return 'S'
169
+ if (width <= 1024) return 'M'
170
+ if (width <= 2048) return 'L'
171
+ return 'XL'
172
+ })()
173
+ const orientation = (() => {
174
+ if (height > width) return 'portrait'
175
+ return 'landscape'
176
+ })()
177
+ setElementDataset(this.container, { size })
178
+ setElementDataset(this.container, { orientation })
179
+ },
180
+ { fireImmediately: true }
181
+ )
182
+ } else {
183
+ setElementDataset(this.container, { size: this.appSize })
184
+ }
185
+
186
+ // 监听播放情况:抛出触发时机
187
+ reaction(
188
+ () => this.ended,
189
+ (ended) => {
190
+ if (ended) {
191
+ this.emit('paused', true)
192
+ }
193
+ }
194
+ )
195
+
196
+ reaction(
197
+ () => this.playing,
198
+ (playing) => {
199
+ if (!this.ended) {
200
+ this.emit(playing ? 'playing' : 'paused')
201
+ }
202
+ }
203
+ )
204
+
205
+ }
206
+
207
+ get ready() {
208
+ return !!this.videoAgentScene
209
+ }
210
+
211
+ get currentTime() {
212
+ return this.videoAgentScene?.videoAgentMesh.currentTime || 0
213
+ }
214
+
215
+ get currentKeyframes() {
216
+ if (!this.vreoUnit) return []
217
+ const keyframes = this.vreoUnit.keyframes
218
+ // 没有被解析过且开始时间低于当前时间戳 100ms
219
+ return keyframes.filter((keyframe: VreoKeyframe) => {
220
+ if (keyframe.parsed) return false
221
+ const dur = this.currentTime - keyframe.start
222
+ return dur <= 100 && dur >= 0
223
+ })
224
+ }
225
+
226
+ get mediaInstance() {
227
+ return this.videoAgentScene?.videoAgentMesh.mediaInstance
149
228
  }
150
229
 
151
230
  /**
152
- * 清理掉数据
231
+ * 逐帧任务
153
232
  */
154
- this.vreoUnit = undefined
155
- if (this.videoInstance) {
156
- this.videoInstance.currentTime = 0
233
+ requestAnimationFrameLoop(callback: (type: VreoKeyframeEnum, keyframe: VreoKeyframe) => void) {
234
+ if (this.mediaInstance?.ended) {
235
+ this.setEnded(true)
236
+ this.setPlaying(false)
237
+ this.mediaInstance.pause()
238
+ return
239
+ }
240
+
241
+ if (!this.playing) {
242
+ if (!this.mediaInstance?.paused) {
243
+ this.mediaInstance?.pause()
244
+ }
245
+ return
246
+ }
247
+
248
+ if (this.mediaInstance?.paused && this.playing) {
249
+ this.mediaInstance.play()
250
+ }
251
+
252
+ const currentKeyframes = this.currentKeyframes
253
+
254
+ currentKeyframes.forEach((keyframe) => {
255
+ if (keyframe.parsed) return
256
+ keyframe.parsed = true
257
+ this.emit(keyframe.type, keyframe)
258
+ if (callback) {
259
+ callback(keyframe.type, keyframe)
260
+ }
261
+ })
157
262
  }
158
263
 
159
- if (this.stopInterval) {
160
- this.stopInterval()
161
- this.stopInterval = undefined
264
+ run(callback: (type: VreoKeyframeEnum, keyframe: VreoKeyframe) => void) {
265
+ if (this.stopInterval) return
266
+ this.stopInterval = requestAnimationFrameInterval(() => this.requestAnimationFrameLoop(callback))
267
+ }
268
+
269
+ dispose() {
270
+ this.setPlaying(false)
271
+
272
+ if (this.currentKeyframes) {
273
+ this.currentKeyframes.forEach((keyframe) => (keyframe.parsed = false))
274
+ }
275
+
276
+ /**
277
+ * 清理掉数据
278
+ */
279
+ this.vreoUnit = undefined
280
+ if (this.mediaInstance) {
281
+ this.mediaInstance.currentTime = 0
282
+ }
283
+
284
+ if (this.stopInterval) {
285
+ this.stopInterval()
286
+ this.stopInterval = undefined
287
+ }
162
288
  }
163
- }
164
289
  }
165
290
 
166
- export const ControllerContext = React.createContext<Controller | null>(null)
291
+ const ControllerContext = React.createContext<Controller | null>(null)
292
+
293
+ export { ControllerContext }
294
+
@@ -1,10 +1,9 @@
1
1
  import * as React from 'react'
2
2
  import ReactDOM from 'react-dom'
3
3
  import { Five } from '@realsee/five'
4
- import * as THREE from 'three'
5
- import { Object3D, Raycaster, Vector3 } from 'three'
6
- import { tweenProgress } from '@realsee/dnalogel/shared-utils/animationFrame/BetterTween'
7
- import { CSS3DRenderPlugin, CSS3DRenderPluginExportType } from '@realsee/dnalogel/plugins/CSS3DRenderPlugin'
4
+ import { Raycaster, Vector3 } from 'three'
5
+ import { tweenProgress } from '../../../shared-utils/animationFrame/BetterTween'
6
+ import { CSS3DRenderPlugin, CSS3DRenderPluginExportType } from '../../../fivePlugins/CSS3DRenderPlugin'
8
7
 
9
8
  import { VreoKeyframe, VreoKeyframeEnum } from '../../../typings/VreoUnit'
10
9
  import { CustomVreoKeyframeProps } from '../../typings'
@@ -33,6 +32,7 @@ import { CustomVreoKeyframeProps } from '../../typings'
33
32
  // "temperature": "27",
34
33
  // "title": "沉浸式回家"
35
34
  // }
35
+
36
36
  export interface SpatialScenePanelData {
37
37
  customType: 'SpatialScenePanel'
38
38
  title: string
@@ -222,7 +222,7 @@ const Panel = React.forwardRef(
222
222
  <div className="SpatialScenePanel-body">
223
223
  {props.data?.stateList?.map((state, index) => (
224
224
  <div key={`scene-${state.text}`} className={`SpatialScenePanel-item index_${index}`}>
225
- <img className="SpatialScenePanel-icon" src={state.icon}></img>
225
+ <img className="SpatialScenePanel-icon" src={state.icon} alt={`${state.text}`}></img>
226
226
  <div className="SpatialScenePanel-text">{state.text}</div>
227
227
  <div className="SpatialScenePanel-dot"></div>
228
228
  </div>
@@ -2,8 +2,6 @@ import React from 'react'
2
2
  import { Vector3 } from 'three'
3
3
  import { ControllerContext } from './Controller'
4
4
 
5
-
6
-
7
5
  export function useController() {
8
6
  const controller = React.useContext(ControllerContext)
9
7
  if (!controller) {
@@ -15,14 +13,14 @@ export function useController() {
15
13
 
16
14
  export function useFiveInstance() {
17
15
  const controller = useController()
18
- if (!controller.$five) {
16
+ if (!controller.five) {
19
17
  throw new Error('没有找到 "five" 实例')
20
18
  }
21
19
 
22
- return controller.$five
20
+ return controller.five
23
21
  }
24
22
 
25
23
  export function useFiveProject2d() {
26
24
  const five = useFiveInstance()
27
25
  return (vector: Vector3) => five.project2d(vector, false)
28
- }
26
+ }