@realsee/vreo 1.0.0-alpha.19 → 1.0.0-alpha.20

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 (112) hide show
  1. package/lib/Player/modules/keyframes/BgMusic/index.js +2 -4
  2. package/package.json +1 -3
  3. package/docs/.nojekyll +0 -1
  4. package/docs/assets/custom.css +0 -78
  5. package/docs/assets/highlight.css +0 -127
  6. package/docs/assets/icons.css +0 -1043
  7. package/docs/assets/icons.png +0 -0
  8. package/docs/assets/icons@2x.png +0 -0
  9. package/docs/assets/main.js +0 -52
  10. package/docs/assets/search.js +0 -1
  11. package/docs/assets/style.css +0 -1414
  12. package/docs/assets/widgets.png +0 -0
  13. package/docs/assets/widgets@2x.png +0 -0
  14. package/docs/classes/Player.AudioLike.html +0 -52
  15. package/docs/classes/Player.Controller.html +0 -54
  16. package/docs/classes/Player.Player-1.html +0 -50
  17. package/docs/classes/Player.VideoAgentMesh.html +0 -142
  18. package/docs/classes/Player.VideoAgentScene.html +0 -1
  19. package/docs/demo/assets/AppReact.20163f9a.js +0 -1
  20. package/docs/demo/assets/default.17872c62.css +0 -1
  21. package/docs/demo/assets/default.5069891b.js +0 -3988
  22. package/docs/demo/assets/dynamic.c8118cc9.js +0 -1
  23. package/docs/demo/assets/examples.5391fc1f.js +0 -25
  24. package/docs/demo/assets/examples.dac4a6fe.css +0 -1
  25. package/docs/demo/assets/index.2272a9ef.js +0 -1
  26. package/docs/demo/assets/index.9331038f.css +0 -1
  27. package/docs/demo/assets/main.b335b989.js +0 -1
  28. package/docs/demo/assets/react.2ee8565f.css +0 -1
  29. package/docs/demo/assets/react.efea3f3f.js +0 -25
  30. package/docs/demo/assets/znRoyv06SZQeqA7m.0057e8ae.js +0 -1
  31. package/docs/demo/examples.html +0 -17
  32. package/docs/demo/index-react-dynamic.html +0 -20
  33. package/docs/demo/index-react.html +0 -20
  34. package/docs/demo/index.html +0 -19
  35. package/docs/enums/Player.InfoPanelStyleEnum.html +0 -1
  36. package/docs/enums/Player.InfoPanelTypeEnum.html +0 -3
  37. package/docs/enums/Player.PanoEffectEnum.html +0 -5
  38. package/docs/enums/Player.PanoTagEnum.html +0 -3
  39. package/docs/enums/Player.PanoTagStyleEnum.html +0 -7
  40. package/docs/enums/Player.VreoKeyframeEnum.html +0 -25
  41. package/docs/enums/fivePlugins.CameraMovementEffect.html +0 -1
  42. package/docs/enums/fivePlugins.Rotation.html +0 -1
  43. package/docs/index.html +0 -248
  44. package/docs/interfaces/Player.CustomVreoKeyframeProps.html +0 -1
  45. package/docs/interfaces/Player.PlayerConfigs.html +0 -7
  46. package/docs/interfaces/Player.Vertex.html +0 -3
  47. package/docs/interfaces/Player.VideoAgentMeshOptions.html +0 -8
  48. package/docs/interfaces/Player.VreoKeyframe.html +0 -3
  49. package/docs/interfaces/Player.VreoUnit.html +0 -3
  50. package/docs/interfaces/Player.VreoVideo.html +0 -3
  51. package/docs/interfaces/fivePlugins.CSS3DRenderPluginExportType.html +0 -4
  52. package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +0 -1
  53. package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +0 -7
  54. package/docs/interfaces/fivePlugins.CameraMovementPluginParameterType.html +0 -1
  55. package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +0 -1
  56. package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +0 -1
  57. package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +0 -1
  58. package/docs/interfaces/fivePlugins.Vector3Position.html +0 -3
  59. package/docs/interfaces/react.VreoActionCallbacks.html +0 -23
  60. package/docs/interfaces/react.VreoProviderProps.html +0 -1
  61. package/docs/modules/Player.html +0 -37
  62. package/docs/modules/custom.html +0 -3
  63. package/docs/modules/fivePlugins.html +0 -6
  64. package/docs/modules/react.html +0 -1
  65. package/docs/modules.html +0 -1
  66. package/resources/PlayController/createHTMLAudioElement.ts +0 -53
  67. package/resources/PlayController/index.ts +0 -154
  68. package/resources/Player/App.tsx +0 -66
  69. package/resources/Player/Controller.ts +0 -295
  70. package/resources/Player/custom/SpatialScenePanel/index.tsx +0 -264
  71. package/resources/Player/hooks.ts +0 -26
  72. package/resources/Player/index.tsx +0 -227
  73. package/resources/Player/modules/Drawer/index.tsx +0 -40
  74. package/resources/Player/modules/PopUp/index.tsx +0 -26
  75. package/resources/Player/modules/ResizeObserver/index.tsx +0 -23
  76. package/resources/Player/modules/VideoAgent/VideoAgentMesh.ts +0 -302
  77. package/resources/Player/modules/VideoAgent/VideoAgentScene.ts +0 -56
  78. package/resources/Player/modules/VideoAgent/index.tsx +0 -53
  79. package/resources/Player/modules/Wave/index.tsx +0 -150
  80. package/resources/Player/modules/keyframes/BgMusic/index.tsx +0 -75
  81. package/resources/Player/modules/keyframes/CameraMovement/index.tsx +0 -37
  82. package/resources/Player/modules/keyframes/InfoPanel/index.tsx +0 -165
  83. package/resources/Player/modules/keyframes/ModelVideo/index.tsx +0 -77
  84. package/resources/Player/modules/keyframes/PanoEffect/index.tsx +0 -99
  85. package/resources/Player/modules/keyframes/PanoEffect/lineAnime.ts +0 -31
  86. package/resources/Player/modules/keyframes/PanoTag/index.tsx +0 -83
  87. package/resources/Player/modules/keyframes/PanoTextLabel/index.tsx +0 -117
  88. package/resources/Player/modules/keyframes/Prompter/index.tsx +0 -56
  89. package/resources/Player/modules/keyframes/UpdateVRPanorama/index.tsx +0 -99
  90. package/resources/Player/modules/keyframes/VideoEffect/index.tsx +0 -115
  91. package/resources/Player/typings.ts +0 -49
  92. package/resources/fivePlugins/CSS3DRenderPlugin/centerPoint.ts +0 -5
  93. package/resources/fivePlugins/CSS3DRenderPlugin/createResizeObserver.ts +0 -17
  94. package/resources/fivePlugins/CSS3DRenderPlugin/evenNumber.ts +0 -4
  95. package/resources/fivePlugins/CSS3DRenderPlugin/index.ts +0 -254
  96. package/resources/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.ts +0 -5
  97. package/resources/fivePlugins/CameraMovementPlugin/index.ts +0 -226
  98. package/resources/fivePlugins/CameraMovementPlugin/typings.ts +0 -59
  99. package/resources/fivePlugins/ModelTVVideoPlugin/index.ts +0 -278
  100. package/resources/index.ts +0 -1
  101. package/resources/react/index.tsx +0 -121
  102. package/resources/shared-utils/AudioLike.ts +0 -107
  103. package/resources/shared-utils/Preloader.ts +0 -35
  104. package/resources/shared-utils/addResizeListener.ts +0 -46
  105. package/resources/shared-utils/animationFrame/BetterTween.ts +0 -33
  106. package/resources/shared-utils/animationFrame/index.ts +0 -48
  107. package/resources/shared-utils/animationFrame/tween.ts +0 -51
  108. package/resources/shared-utils/createTransMatrix.ts +0 -12
  109. package/resources/shared-utils/getFileExpandedName.ts +0 -6
  110. package/resources/shared-utils/getMediaInfo.ts +0 -52
  111. package/resources/shared-utils/setElementDataset.ts +0 -18
  112. package/resources/typings/VreoUnit.ts +0 -314
package/docs/modules.html DELETED
@@ -1 +0,0 @@
1
- <!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Vreo</title><meta name="description" content="Documentation for Vreo"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><link rel="stylesheet" href="assets/custom.css"/><script async src="assets/search.js" id="search-script"></script></head><body><script>document.body.classList.add(localStorage.getItem("tsd-theme") || "os")</script><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base="."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="index.html" class="title">Vreo</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label><input type="checkbox" id="tsd-filter-externals" checked/><label class="tsd-widget" for="tsd-filter-externals">Externals</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><h1> Vreo </h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>Modules</h3><ul class="tsd-index-list"><li class="tsd-kind-module"><a href="modules/Player.html" class="tsd-kind-icon">Player</a></li><li class="tsd-kind-module"><a href="modules/custom.html" class="tsd-kind-icon">custom</a></li><li class="tsd-kind-module"><a href="modules/fivePlugins.html" class="tsd-kind-icon">five<wbr/>Plugins</a></li><li class="tsd-kind-module"><a href="modules/react.html" class="tsd-kind-icon">react</a></li></ul></section></div></section></section></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class="current"><a href="modules.html">Modules</a></li><li class=" tsd-kind-module"><a href="modules/Player.html">Player</a></li><li class=" tsd-kind-module"><a href="modules/custom.html">custom</a></li><li class=" tsd-kind-module"><a href="modules/fivePlugins.html">five<wbr/>Plugins</a></li><li class=" tsd-kind-module"><a href="modules/react.html">react</a></li></ul></nav></div></div></div><footer class=""><div class="container"><h2>Legend</h2><div class="tsd-legend-group"><ul class="tsd-legend"><li class="tsd-kind-variable"><span class="tsd-kind-icon">Variable</span></li><li class="tsd-kind-function"><span class="tsd-kind-icon">Function</span></li><li class="tsd-kind-function tsd-has-type-parameter"><span class="tsd-kind-icon">Function with type parameter</span></li><li class="tsd-kind-type-alias"><span class="tsd-kind-icon">Type alias</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-enum"><span class="tsd-kind-icon">Enumeration</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-interface"><span class="tsd-kind-icon">Interface</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-class"><span class="tsd-kind-icon">Class</span></li></ul></div><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="overlay"></div><script src="assets/main.js"></script></body></html>
@@ -1,53 +0,0 @@
1
-
2
- const BLANK_AUDIO = ''
3
- + 'data:audio/mpeg;base64,'
4
- + '//uQxAAAAAAAAAAAAAAAAAAAAAAASW5mbwAAAA8AAAADAAAGhgBVVVVVVVVVVVVVVVVVVVVVVVV'
5
- + 'VVVVVVVVVVVVVVVVVVVWqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr///////////'
6
- + '////////////////////////////////8AAAA5TEFNRTMuOThyAc0AAAAAAAAAABSAJAiqQgAAg'
7
- + 'AAABobxtI73AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
8
- + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
9
- + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
10
- + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
11
- + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//uQxAACFEII9ACZ/sJZwWEoEb8w/////N//////Jcxj'
12
- + 'Hjf+7/v/H2PzCCFAiDtGeyBCIx7bJJ1mmEEMy6g8mm2c8nrGABB4h2Mkmn//4z/73u773R5qHHu'
13
- + '/j/w7Kxkzh5lWRWdsifCkNAnY9Zc1HvDAhjhSHdFkHFzLmabt/AQxSg2wwzLhHIJOBnAWwVY4zr'
14
- + 'hIYhhc2kvhYDfQ4hDi2Gmh5KyFn8EcGIrHAngNgIwVIEMf5bzbAiTRoAD///8z/KVhkkWEle6IX'
15
- + '+d/z4fvH3BShK1e5kmjkCMoxVmXhd4ROlTKo3iipasvTilY21q19ta30/v/0/idPX1v8PNxJL6r'
16
- + 'amnOVsdvMv2akO0iSYIzdJFirtzWXCZicS9vHqvSKyqm5XJBdqBwPxyfJdykhWTZ0G0ZyTZGpLK'
17
- + 'xsNwwoRhsx3tZfhwmeOBVISm3impAC/IT/8hP/EKEM1KMdVdVKM2rHV4x7HVXZvbVVKN/qq8CiV'
18
- + '9VL9jjH/6l6qf7MBCjZmOqsAibjcP+qqqv0oxqpa/NVW286hPo1nz2L/h8+jXt//uSxCmDU2IK/'
19
- + 'ECN98KKtE5IYzNoCfbw+u9i5r8PoadUMFPKqWL4LK3T/LCraMSHGkW4bpLXR/E6LlHOVQxmslKV'
20
- + 'J8IULktMN06N0FKCpHCoYsjC4F+Z0NVqdNFoGSTjSiyjzLdnZ2fNqTi2eHKONONKLMPMKLONKLM'
21
- + 'PQRJGlFxZRoKcJFAYEeIFiRQkUWUeYfef//Ko04soswso40UJAgMw8wosososy0EalnZyjQUGBR'
22
- + 'QGIFggOWUacWUeYmuadrZziQKKEgQsQLAhQkUJAgMQDghltLO1onp0cpkNInSFMqlYeSEJ5AHsq'
23
- + 'FdOwy1DA2sRmRJKxdKRfLhfLw5BzUxBTUUzLjk4LjJVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV'
24
- + 'VVVVVVVVVVVVVVVVVUxBTUUzLjk4LjJVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV'
25
- + 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV'
26
- + 'VVVVVVVVVVVVVVVVVVVf/7ksRRA8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVV'
27
- + 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV'
28
- + 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV'
29
- + 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV'
30
- + 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV'
31
- + 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV'
32
- + 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV'
33
- + 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVU=';
34
-
35
-
36
- export function createHTMLAudioElement(): HTMLAudioElement {
37
- const ndAudio = document.querySelector('#vreo-playController-audio')
38
- if (ndAudio) {
39
- return ndAudio as HTMLAudioElement
40
- }
41
-
42
- const audio = document.createElement('audio')
43
- audio.style.display = 'none'
44
- audio.setAttribute('id', 'vreo-playController-audio')
45
- audio.controls = false
46
- document.body.appendChild(audio)
47
- audio.src = BLANK_AUDIO
48
-
49
- // 触发一次播放
50
- Promise.resolve(async () => await audio.play())
51
-
52
- return audio
53
- }
@@ -1,154 +0,0 @@
1
- import { Subscribe } from '@realsee/five'
2
- import { requestAnimationFrameInterval } from '../shared-utils/animationFrame'
3
- import { VreoKeyframe, VreoKeyframeEvent, VreoUnit } from '../typings/VreoUnit'
4
- import { createHTMLAudioElement } from './createHTMLAudioElement'
5
-
6
- export interface PlayControllerConfig {
7
- audio?: HTMLAudioElement
8
- }
9
-
10
- const closures: Record<string, any> = {}
11
-
12
- export class PlayController extends Subscribe<VreoKeyframeEvent> {
13
-
14
- vreoUnit?: VreoUnit
15
-
16
- config: PlayControllerConfig = {}
17
- stopInterval: () => void
18
-
19
- get paused() {
20
- return this.audioInstance.paused
21
- }
22
-
23
- get audioInstance() {
24
- return this.config.audio!
25
- }
26
-
27
- get currentTime() {
28
- return this.audioInstance.currentTime * 1000
29
- }
30
-
31
- get currentKeyframes() {
32
- if (!this.vreoUnit) return []
33
- const keyframes = this.vreoUnit.keyframes
34
- // 没有被解析过且开始时间低于当前时间戳 100ms
35
- return keyframes.filter((keyframe: VreoKeyframe) => {
36
- if (keyframe.parsed) return false
37
- const dur = this.currentTime - keyframe.start
38
- return dur <= 100 && dur >= 0
39
- })
40
- }
41
-
42
- /**
43
- * 音频时长 不一定能获取得到,建议以 VreoUnit 配置的时长为准。
44
- */
45
- get duration() {
46
- return this.audioInstance.duration * 1000
47
- }
48
-
49
- constructor(config: PlayControllerConfig = {}) {
50
- super()
51
-
52
- if (!config.audio) {
53
- config.audio = createHTMLAudioElement()
54
- }
55
-
56
- this.config = Object.assign(this.config, config)
57
-
58
- closures.onPlaying = () => this.emit('playing')
59
- closures.onPaused = () => this.emit('paused')
60
- closures.onEnded = () => this.emit('paused', true)
61
-
62
- this.audioInstance.addEventListener('play', closures.onPlaying)
63
- this.audioInstance.addEventListener('pause', closures.onPaused)
64
- this.audioInstance.addEventListener('ended', closures.onEnded)
65
-
66
- this.stopInterval = requestAnimationFrameInterval(() => {
67
- if (this.audioInstance.paused) {
68
- return
69
- }
70
-
71
- if (!this.vreoUnit) {
72
- return
73
- }
74
-
75
- const keyframes = this.vreoUnit.keyframes
76
- const currentTime = this.currentTime
77
- // 没有被解析过且开始时间低于当前时间戳 100ms
78
- const currentKeyframes = keyframes.filter((keyframe: VreoKeyframe) => {
79
- if (keyframe.parsed) return false
80
-
81
- const dur = currentTime - keyframe.start
82
- return dur <= 60 && dur >= 0
83
- })
84
-
85
- currentKeyframes.forEach((keyframe) => {
86
- if (keyframe.parsed) return
87
- keyframe.parsed = true
88
- this.emit(keyframe.type, keyframe, this.currentTime)
89
- })
90
- })
91
-
92
- }
93
-
94
-
95
-
96
- /**
97
- * 载入数据
98
- */
99
- async load(vreoUnit: VreoUnit): Promise<boolean> {
100
- this.vreoUnit = vreoUnit
101
-
102
- await this.pause()
103
- return await new Promise((resolve, reject) => {
104
- if (vreoUnit.video.url === this.audioInstance.src) {
105
- return resolve(true)
106
- }
107
-
108
- this.audioInstance.src = vreoUnit.video.url
109
- const canplaythrough = () => {
110
- resolve(true)
111
- this.audioInstance.removeEventListener('canplaythrough', canplaythrough)
112
- }
113
- const error = (err: any) => {
114
- reject(err)
115
- this.audioInstance.removeEventListener('error', error)
116
- }
117
- this.audioInstance.addEventListener('canplaythrough', canplaythrough)
118
- this.audioInstance.addEventListener('error', error)
119
- })
120
- }
121
-
122
- /**
123
- * 播放
124
- */
125
- async play() {
126
- closures.playPromise = this.audioInstance.play()
127
- }
128
-
129
- /**
130
- * 暂停
131
- */
132
- async pause() {
133
- if (closures.playPromise) {
134
- await closures.playPromise
135
- }
136
- this.audioInstance.pause()
137
- }
138
-
139
- /**
140
- * 销毁资源
141
- * @notice 一旦销毁,创建的实例将不可用:需重新创建实例。
142
- *
143
- * @deprecated **慎重执行**
144
- */
145
- dispose() {
146
- // 清理事件监听
147
- this.audioInstance.removeEventListener('play', closures.onPlaying)
148
- this.audioInstance.removeEventListener('pasue', closures.onPaused)
149
- this.audioInstance.removeEventListener('ended', closures.onEnded)
150
- if (this.stopInterval) {
151
- this.stopInterval()
152
- }
153
- }
154
- }
@@ -1,66 +0,0 @@
1
- import * as React from 'react'
2
- import classNames from 'classnames'
3
- import { observer } from 'mobx-react'
4
- import { Controller } from './Controller'
5
- import { useController } from './hooks'
6
- import { CameraMovement } from './modules/keyframes/CameraMovement'
7
- import { ResizeObserver } from './modules/ResizeObserver'
8
- import { InfoPanel } from './modules/keyframes/InfoPanel'
9
- import { ModelVideo } from './modules/keyframes/ModelVideo'
10
- import { PanoEffect } from './modules/keyframes/PanoEffect'
11
- import { PanoTag } from './modules/keyframes/PanoTag'
12
- import { PanoTextLabel } from './modules/keyframes/PanoTextLabel'
13
- import { Prompter } from './modules/keyframes/Prompter'
14
- import { UpdateVRPanorama } from './modules/keyframes/UpdateVRPanorama'
15
- import { VideoEffect } from './modules/keyframes/VideoEffect'
16
- import { VideoAgent } from './modules/VideoAgent'
17
- import { BgMusic } from './modules/keyframes/BgMusic'
18
- import { Wave } from './modules/Wave'
19
-
20
- const AppView = observer(({ controller }: { controller: Controller }) => {
21
-
22
- return (
23
- <div
24
- className={classNames('vreo-panel', {
25
- 'vreo-panel--hidden': !controller.visible,
26
- })}
27
- >
28
- <div className="vreo-panel-inner">
29
- {controller.waveAppearance && <Wave appearance={controller.waveAppearance}/>}
30
- <VideoAgent
31
- onClick={() => {
32
- if (controller.playing) {
33
- controller.setPlaying(false)
34
- } else {
35
- controller.setPlaying(true)
36
- }
37
- }}
38
- options={controller.configs?.videoAgentMeshOptions || {}}
39
- />
40
- <Prompter />
41
- {controller.configs?.customPanelChildren}
42
- </div>
43
- </div>
44
- )
45
- })
46
-
47
- export function App() {
48
- const controller = useController()
49
- return (
50
- <>
51
- <>
52
- <ResizeObserver />
53
- <CameraMovement />
54
- <ModelVideo />
55
- <UpdateVRPanorama />
56
- <VideoEffect />
57
- <PanoTag />
58
- <PanoTextLabel />
59
- <InfoPanel />
60
- <PanoEffect />
61
- <BgMusic />
62
- </>
63
- <AppView controller={controller} />
64
- </>
65
- )
66
- }
@@ -1,295 +0,0 @@
1
- import { Five, Subscribe } from '@realsee/five'
2
- import { action, computed, makeObservable, observable, reaction } from 'mobx'
3
- import * as React from 'react'
4
- import { requestAnimationFrameInterval } from '../shared-utils/animationFrame'
5
- import { VreoKeyframe, VreoKeyframeEnum, VreoKeyframeEvent, VreoUnit, VreoVideo } from '../typings/VreoUnit'
6
- import { VideoAgentScene } from './modules/VideoAgent/VideoAgentScene'
7
- import { Appearance, PlayerConfigs, WaveAppearance } from './typings'
8
- import setElementDataset from '../shared-utils/setElementDataset'
9
- import { getMediaType } from '../shared-utils/getMediaInfo'
10
-
11
- /**
12
- * 逻辑控制器:内部状态。
13
- */
14
- export class Controller extends Subscribe<VreoKeyframeEvent> {
15
-
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
- // videoAgentScene: observable.ref,
114
- setLoading: action,
115
- popUp: observable.ref,
116
- openPopUp: action,
117
- drawerConfig: observable.ref,
118
- openDrawer: action,
119
- ended: observable,
120
- waveAppearance: observable,
121
- avatar: observable,
122
- containerSize: observable,
123
- setContainerSize: action,
124
- appearance: observable,
125
- setAppearance: action,
126
- configs: observable.ref,
127
- setEnded: action,
128
- setAvatar: action,
129
- })
130
-
131
- reaction<[typeof this.appearance.waveStyle, boolean | null], boolean>(
132
- () => [this.appearance.waveStyle, this.loading],
133
- ([waveStyle, loading]) => {
134
- if (loading === null) {
135
- this.waveAppearance = null
136
- return
137
- }
138
- if (waveStyle === 'wave') {
139
- switch (loading) {
140
- case true:
141
- this.waveAppearance = 'double'
142
- break
143
- case false:
144
- this.waveAppearance = 'solid'
145
- break
146
- }
147
- } else if (waveStyle === 'solid') {
148
- switch (loading) {
149
- case true:
150
- this.waveAppearance = 'swap'
151
- break
152
- case false:
153
- this.waveAppearance = 'expand'
154
- break
155
- }
156
- }
157
- },
158
- { fireImmediately: true }
159
- )
160
-
161
- if (!this.appSize) {
162
- reaction(
163
- () => this.containerSize,
164
- (containerSize) => {
165
- if (!containerSize?.width) return
166
- const width = containerSize.width
167
- const height = containerSize.height
168
- const size = (() => {
169
- if (width <= 500) return 'S'
170
- if (width <= 1024) return 'M'
171
- if (width <= 2048) return 'L'
172
- return 'XL'
173
- })()
174
- const orientation = (() => {
175
- if (height > width) return 'portrait'
176
- return 'landscape'
177
- })()
178
- setElementDataset(this.container, { size })
179
- setElementDataset(this.container, { orientation })
180
- },
181
- { fireImmediately: true }
182
- )
183
- } else {
184
- setElementDataset(this.container, { size: this.appSize })
185
- }
186
-
187
- // 监听播放情况:抛出触发时机
188
- reaction(
189
- () => this.ended,
190
- (ended) => {
191
- if (ended) {
192
- this.emit('paused', true)
193
- }
194
- }
195
- )
196
-
197
- reaction(
198
- () => this.playing,
199
- (playing) => {
200
- if (!this.ended) {
201
- this.emit(playing ? 'playing' : 'paused')
202
- }
203
- }
204
- )
205
-
206
- }
207
-
208
- get ready() {
209
- return !!this.videoAgentScene
210
- }
211
-
212
- get currentTime() {
213
- return this.videoAgentScene?.videoAgentMesh.currentTime || 0
214
- }
215
-
216
- get currentKeyframes() {
217
- if (!this.vreoUnit) return []
218
- const keyframes = this.vreoUnit.keyframes
219
- // 没有被解析过且开始时间低于当前时间戳 100ms
220
- return keyframes.filter((keyframe: VreoKeyframe) => {
221
- if (keyframe.parsed) return false
222
- const dur = this.currentTime - keyframe.start
223
- return dur <= 100 && dur >= 0
224
- })
225
- }
226
-
227
- get mediaInstance() {
228
- return this.videoAgentScene?.videoAgentMesh.mediaInstance
229
- }
230
-
231
- /**
232
- * 逐帧任务
233
- */
234
- requestAnimationFrameLoop(callback: (type: VreoKeyframeEnum, keyframe: VreoKeyframe, currentTime: number) => void) {
235
- if (this.mediaInstance?.ended) {
236
- this.setEnded(true)
237
- this.setPlaying(false)
238
- this.mediaInstance.pause()
239
- return
240
- }
241
-
242
- if (!this.playing) {
243
- if (!this.mediaInstance?.paused) {
244
- this.mediaInstance?.pause()
245
- }
246
- return
247
- }
248
-
249
- if (this.mediaInstance?.paused && this.playing) {
250
- this.mediaInstance.play()
251
- }
252
-
253
- const currentKeyframes = this.currentKeyframes
254
-
255
- currentKeyframes.forEach((keyframe) => {
256
- if (keyframe.parsed) return
257
- keyframe.parsed = true
258
- this.emit(keyframe.type, keyframe, this.currentTime)
259
- if (callback) {
260
- callback(keyframe.type, keyframe, this.currentTime)
261
- }
262
- })
263
- }
264
-
265
- run(callback: (type: VreoKeyframeEnum, keyframe: VreoKeyframe) => void) {
266
- if (this.stopInterval) return
267
- this.stopInterval = requestAnimationFrameInterval(() => this.requestAnimationFrameLoop(callback))
268
- }
269
-
270
- dispose() {
271
- this.setPlaying(false)
272
-
273
- if (this.currentKeyframes) {
274
- this.currentKeyframes.forEach((keyframe) => (keyframe.parsed = false))
275
- }
276
-
277
- /**
278
- * 清理掉数据
279
- */
280
- this.vreoUnit = undefined
281
- if (this.mediaInstance) {
282
- this.mediaInstance.currentTime = 0
283
- }
284
-
285
- if (this.stopInterval) {
286
- this.stopInterval()
287
- this.stopInterval = undefined
288
- }
289
- }
290
- }
291
-
292
- const ControllerContext = React.createContext<Controller | null>(null)
293
-
294
- export { ControllerContext }
295
-