@realsee/vreo 1.0.0-alpha.2 → 1.0.0-alpha.21

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 (127) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/README.md +46 -36
  3. package/lib/PlayController/index.js +1 -1
  4. package/lib/Player/Controller.d.ts +4 -4
  5. package/lib/Player/Controller.js +30 -17
  6. package/lib/Player/index.js +4 -1
  7. package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +2 -2
  8. package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +3 -3
  9. package/lib/Player/modules/VideoAgent/index.js +1 -1
  10. package/lib/Player/modules/Wave/index.js +174 -25
  11. package/lib/Player/modules/keyframes/BgMusic/index.js +54 -35
  12. package/lib/Player/modules/keyframes/PanoTag/index.js +3 -3
  13. package/lib/shared-utils/{AduioLike.d.ts → AudioLike.d.ts} +0 -0
  14. package/lib/shared-utils/{AduioLike.js → AudioLike.js} +4 -6
  15. package/lib/typings/VreoUnit.d.ts +6 -6
  16. package/package.json +2 -4
  17. package/stylesheets/default.css +11 -4
  18. package/docs/.nojekyll +0 -1
  19. package/docs/assets/custom.css +0 -78
  20. package/docs/assets/highlight.css +0 -127
  21. package/docs/assets/icons.css +0 -1043
  22. package/docs/assets/icons.png +0 -0
  23. package/docs/assets/icons@2x.png +0 -0
  24. package/docs/assets/main.js +0 -52
  25. package/docs/assets/search.js +0 -1
  26. package/docs/assets/style.css +0 -1414
  27. package/docs/assets/widgets.png +0 -0
  28. package/docs/assets/widgets@2x.png +0 -0
  29. package/docs/classes/Player.AudioLike.html +0 -52
  30. package/docs/classes/Player.Controller.html +0 -54
  31. package/docs/classes/Player.Player-1.html +0 -50
  32. package/docs/classes/Player.VideoAgentMesh.html +0 -142
  33. package/docs/classes/Player.VideoAgentScene.html +0 -1
  34. package/docs/demo/assets/AppReact.d0ee843a.js +0 -1
  35. package/docs/demo/assets/default.63925584.js +0 -3984
  36. package/docs/demo/assets/default.f3f3ca8c.css +0 -1
  37. package/docs/demo/assets/dynamic.76506c2c.js +0 -1
  38. package/docs/demo/assets/examples.3d8323db.js +0 -25
  39. package/docs/demo/assets/examples.dac4a6fe.css +0 -1
  40. package/docs/demo/assets/index.7e31122c.js +0 -1
  41. package/docs/demo/assets/index.9331038f.css +0 -1
  42. package/docs/demo/assets/main.79b11b9d.js +0 -1
  43. package/docs/demo/assets/react.2ee8565f.css +0 -1
  44. package/docs/demo/assets/react.c1c07c14.js +0 -25
  45. package/docs/demo/assets/znRoyv06SZQeqA7m.0057e8ae.js +0 -1
  46. package/docs/demo/examples.html +0 -17
  47. package/docs/demo/index-react-dynamic.html +0 -20
  48. package/docs/demo/index-react.html +0 -20
  49. package/docs/demo/index.html +0 -19
  50. package/docs/enums/Player.InfoPanelStyleEnum.html +0 -1
  51. package/docs/enums/Player.InfoPanelTypeEnum.html +0 -3
  52. package/docs/enums/Player.PanoEffectEnum.html +0 -5
  53. package/docs/enums/Player.PanoTagEnum.html +0 -3
  54. package/docs/enums/Player.PanoTagStyleEnum.html +0 -7
  55. package/docs/enums/Player.VreoKeyframeEnum.html +0 -25
  56. package/docs/enums/fivePlugins.CameraMovementEffect.html +0 -1
  57. package/docs/enums/fivePlugins.Rotation.html +0 -1
  58. package/docs/index.html +0 -245
  59. package/docs/interfaces/Player.CustomVreoKeyframeProps.html +0 -1
  60. package/docs/interfaces/Player.PlayerConfigs.html +0 -7
  61. package/docs/interfaces/Player.Vertex.html +0 -3
  62. package/docs/interfaces/Player.VideoAgentMeshOptions.html +0 -8
  63. package/docs/interfaces/Player.VreoKeyframe.html +0 -3
  64. package/docs/interfaces/Player.VreoUnit.html +0 -3
  65. package/docs/interfaces/Player.VreoVideo.html +0 -3
  66. package/docs/interfaces/fivePlugins.CSS3DRenderPluginExportType.html +0 -4
  67. package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +0 -1
  68. package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +0 -7
  69. package/docs/interfaces/fivePlugins.CameraMovementPluginParameterType.html +0 -1
  70. package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +0 -1
  71. package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +0 -1
  72. package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +0 -1
  73. package/docs/interfaces/fivePlugins.Vector3Position.html +0 -3
  74. package/docs/interfaces/react.VreoActionCallbacks.html +0 -23
  75. package/docs/interfaces/react.VreoProviderProps.html +0 -1
  76. package/docs/modules/Player.html +0 -37
  77. package/docs/modules/custom.html +0 -3
  78. package/docs/modules/fivePlugins.html +0 -6
  79. package/docs/modules/react.html +0 -1
  80. package/docs/modules.html +0 -1
  81. package/resources/PlayController/createHTMLAudioElement.ts +0 -53
  82. package/resources/PlayController/index.ts +0 -154
  83. package/resources/Player/App.tsx +0 -66
  84. package/resources/Player/Controller.ts +0 -297
  85. package/resources/Player/custom/SpatialScenePanel/index.tsx +0 -264
  86. package/resources/Player/hooks.ts +0 -26
  87. package/resources/Player/index.tsx +0 -225
  88. package/resources/Player/modules/Drawer/index.tsx +0 -40
  89. package/resources/Player/modules/PopUp/index.tsx +0 -26
  90. package/resources/Player/modules/ResizeObserver/index.tsx +0 -23
  91. package/resources/Player/modules/VideoAgent/VideoAgentMesh.ts +0 -302
  92. package/resources/Player/modules/VideoAgent/VideoAgentScene.ts +0 -56
  93. package/resources/Player/modules/VideoAgent/index.tsx +0 -53
  94. package/resources/Player/modules/Wave/index.tsx +0 -18
  95. package/resources/Player/modules/keyframes/BgMusic/index.tsx +0 -66
  96. package/resources/Player/modules/keyframes/CameraMovement/index.tsx +0 -37
  97. package/resources/Player/modules/keyframes/InfoPanel/index.tsx +0 -165
  98. package/resources/Player/modules/keyframes/ModelVideo/index.tsx +0 -77
  99. package/resources/Player/modules/keyframes/PanoEffect/index.tsx +0 -99
  100. package/resources/Player/modules/keyframes/PanoEffect/lineAnime.ts +0 -31
  101. package/resources/Player/modules/keyframes/PanoTag/index.tsx +0 -83
  102. package/resources/Player/modules/keyframes/PanoTextLabel/index.tsx +0 -117
  103. package/resources/Player/modules/keyframes/Prompter/index.tsx +0 -56
  104. package/resources/Player/modules/keyframes/UpdateVRPanorama/index.tsx +0 -99
  105. package/resources/Player/modules/keyframes/VideoEffect/index.tsx +0 -115
  106. package/resources/Player/typings.ts +0 -49
  107. package/resources/fivePlugins/CSS3DRenderPlugin/centerPoint.ts +0 -5
  108. package/resources/fivePlugins/CSS3DRenderPlugin/createResizeObserver.ts +0 -17
  109. package/resources/fivePlugins/CSS3DRenderPlugin/evenNumber.ts +0 -4
  110. package/resources/fivePlugins/CSS3DRenderPlugin/index.ts +0 -254
  111. package/resources/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.ts +0 -5
  112. package/resources/fivePlugins/CameraMovementPlugin/index.ts +0 -226
  113. package/resources/fivePlugins/CameraMovementPlugin/typings.ts +0 -59
  114. package/resources/fivePlugins/ModelTVVideoPlugin/index.ts +0 -278
  115. package/resources/index.ts +0 -1
  116. package/resources/react/index.tsx +0 -121
  117. package/resources/shared-utils/AduioLike.ts +0 -109
  118. package/resources/shared-utils/Preloader.ts +0 -35
  119. package/resources/shared-utils/addResizeListener.ts +0 -46
  120. package/resources/shared-utils/animationFrame/BetterTween.ts +0 -33
  121. package/resources/shared-utils/animationFrame/index.ts +0 -48
  122. package/resources/shared-utils/animationFrame/tween.ts +0 -51
  123. package/resources/shared-utils/createTransMatrix.ts +0 -12
  124. package/resources/shared-utils/getFileExpandedName.ts +0 -6
  125. package/resources/shared-utils/getMediaInfo.ts +0 -52
  126. package/resources/shared-utils/setElementDataset.ts +0 -18
  127. package/resources/typings/VreoUnit.ts +0 -314
@@ -1,264 +0,0 @@
1
- import * as React from 'react'
2
- import ReactDOM from 'react-dom'
3
- import { Five } from '@realsee/five'
4
- import { Raycaster, Vector3 } from 'three'
5
- import { tweenProgress } from '../../../shared-utils/animationFrame/BetterTween'
6
- import { CSS3DRenderPlugin, CSS3DRenderPluginExportType } from '../../../fivePlugins/CSS3DRenderPlugin'
7
-
8
- import { VreoKeyframe, VreoKeyframeEnum } from '../../../typings/VreoUnit'
9
- import { CustomVreoKeyframeProps } from '../../typings'
10
-
11
- // __debug__
12
- // const mockData: SpatialScenePanelData = {
13
- // customType: 'SpatialScenePanel',
14
- // "stateList": [
15
- // {
16
- // "icon": "http://vrlab-public.ljcdn.com/release/seesay/tools/___fc42f951076607a22fd5c54f005ba553.png",
17
- // "text": "窗帘关闭"
18
- // },
19
- // {
20
- // "icon": "http://vrlab-public.ljcdn.com/release/seesay/tools/___b331e7ad732debc07250a169a3393b13.png",
21
- // "text": "摄像头休眠"
22
- // },
23
- // {
24
- // "icon": "http://vrlab-public.ljcdn.com/release/seesay/tools/___2e425a81ac0ad88232d50d4e52a9abfa.png",
25
- // "text": "氛围音乐"
26
- // },
27
- // {
28
- // "icon": "http://vrlab-public.ljcdn.com/release/seesay/tools/___bff48bb81cde37aa6a319d6f5d56e3a4.png",
29
- // "text": "空调打开"
30
- // }
31
- // ],
32
- // "temperature": "27",
33
- // "title": "沉浸式回家"
34
- // }
35
-
36
- export interface SpatialScenePanelData {
37
- customType: 'SpatialScenePanel'
38
- title: string
39
- temperature: string
40
- stateList: {
41
- text: string
42
- icon: string
43
- }[]
44
- position?: { x: number; y: number; z: number }
45
- quaternion?: [number, number, number, number]
46
- }
47
-
48
- interface SearchParams {
49
- five: Five
50
- // position: Vector3
51
- // rotation?: Vector3
52
- // quaternion: [number, number, number, number]
53
- dom: HTMLDivElement
54
- }
55
-
56
- // const getSphere = (position: Vector3, color = 0xffff00) => {
57
- // const geometry = new SphereGeometry(0.05, 32, 16)
58
- // const material = new MeshBasicMaterial({ color })
59
- // const sphere = new Mesh(geometry, material)
60
- // sphere.position.copy(position)
61
- // return sphere
62
- // }
63
-
64
- const searchV1 = ({ five, dom }: SearchParams) => {
65
- const cameraDirection = new Vector3()
66
- five.camera.getWorldDirection(cameraDirection)
67
- const cameraPosition = five.camera.position
68
- const [intersect] = five.model.intersectRaycaster(new Raycaster(cameraPosition, cameraDirection))
69
- const point = five.project2d(intersect.point)
70
-
71
- const widescreen = window.innerWidth > 560 ? true : false
72
- // const width = dom!.clientWidth
73
- const height = dom!.clientHeight
74
- dom!.style.left = point!.x + 'px'
75
- dom!.style.top = point!.y - height / 2 + 'px'
76
- const rect = dom!.getBoundingClientRect()
77
- const { left, top, bottom, right } = rect
78
-
79
- const leftBottom = new Vector3(left, bottom)
80
- const leftTop = new Vector3(left, top)
81
- const rightTop = new Vector3(right, top)
82
- const rightBottom = new Vector3(right, bottom)
83
-
84
- const points = [leftBottom, rightBottom, rightTop, leftTop].map((point) => {
85
- point.setX((point.x / window.innerWidth) * 2 - (widescreen ? 1.25: 1.75))
86
- point.setY(-(point.y / window.innerHeight) * 2 + (widescreen ? 1.35: 1.125))
87
- point.setZ(0.5)
88
- return point.unproject(five.camera).addScaledVector(cameraDirection, 0.2)
89
- })
90
-
91
- // __debug__
92
- // const colors = [0xdc143c, 0xffff00, 0x0000ff, 0x008000]
93
- // points.forEach((p, index) => five.scene.add(getSphere(p, colors[index])))
94
-
95
- // 判断是手机 150
96
- const ratio = leftBottom.distanceTo(rightBottom) / (widescreen ? 150 : 120)
97
- return { points, ratio }
98
- }
99
-
100
- /**
101
- * 空间场景面板
102
- * @returns
103
- */
104
- export function SpatialScenePanel(props: CustomVreoKeyframeProps) {
105
- const timeoutRef = React.useRef<NodeJS.Timeout | null>(null)
106
- const ref = React.useRef<HTMLDivElement>(null)
107
- const panelRef = React.useRef<HTMLDivElement | null>(null)
108
- const rendererRef = React.useRef<CSS3DRenderPluginExportType>(CSS3DRenderPlugin(props.five))
109
-
110
- React.useEffect(() => {
111
- if (!ref.current) {
112
- return
113
- }
114
-
115
- const callback = (keyframe: VreoKeyframe) => {
116
- if (keyframe.data.customType !== 'SpatialScenePanel') {
117
- return
118
- }
119
-
120
- const data = keyframe.data as SpatialScenePanelData
121
-
122
- // const data = mockData
123
- const { points, ratio } = searchV1({
124
- five: props.five,
125
- dom: ref.current!,
126
- })
127
-
128
- const { container, dispose, css3DObject, render } =
129
- rendererRef.current.create3DDomContainer(points, { ratio, autoRender: false }) || {}
130
-
131
- Object.assign(window, { $css3DObject: css3DObject })
132
- if (!container) return
133
-
134
- ReactDOM.render(<Panel ref={(ref) => (panelRef.current = ref)} data={data} />, container)
135
- const startRotateY = -(Math.PI * 2) / 9
136
- let lastRotateY = 0
137
-
138
- tweenProgress(1000)
139
- .onUpdate(({ progress }) => {
140
- const needRotateY = (Math.PI / 90) * 11 * progress
141
- const rotateY = needRotateY - lastRotateY
142
- css3DObject?.rotateY(rotateY)
143
- // css3DObject?.rotateZ
144
- lastRotateY = needRotateY
145
- })
146
- .onStart(() => {
147
- css3DObject?.rotateY(startRotateY)
148
- render!()
149
- })
150
- .onDispose(() => {
151
- panelRef.current?.classList.add('show')
152
- })
153
- .play()
154
-
155
- // Object.assign(window, { $dispose: () => {
156
- // panelRef.current?.classList.add('hide')
157
- // setTimeout(() => dispose?.(), 1500)
158
- // } })
159
-
160
- const { start, end } = keyframe
161
-
162
- timeoutRef.current = setTimeout(() => {
163
- panelRef.current?.classList.add('hide')
164
- timeoutRef.current = setTimeout(() => {
165
- dispose?.()
166
- timeoutRef.current = null
167
- }, 1500)
168
- }, end - start)
169
- }
170
-
171
- Object.assign(window, { $callback: callback })
172
-
173
- // setTimeout(() => {callback()}, 8000)
174
- props.subscribe.on(VreoKeyframeEnum.Custom, callback)
175
-
176
- return () => {
177
- props.subscribe.off(VreoKeyframeEnum.Custom, callback)
178
- if (timeoutRef.current) {
179
- clearTimeout(timeoutRef.current)
180
- }
181
- }
182
- }, [])
183
-
184
- return <div className="vreo-SpatialScenePanel" ref={ref}></div>
185
- }
186
-
187
- /** 背景动画:控制延迟 */
188
- function SpatialScenePanelBg() {
189
- const ref = React.useRef<HTMLDivElement>(null)
190
- const timeoutRef = React.useRef<NodeJS.Timeout | null>(null)
191
- React.useEffect(() => {
192
- if (!ref.current) return
193
-
194
- const listener = () => {
195
- ref.current?.setAttribute('class', 'SpatialScenePanel-bg')
196
-
197
- timeoutRef.current = setTimeout(() => {
198
- ref.current?.setAttribute('class', 'SpatialScenePanel-bg SpatialScenePanel-bg--animation')
199
- timeoutRef.current = null
200
- }, 3000)
201
- }
202
-
203
- ref.current.addEventListener('animationend', listener)
204
-
205
- return () => {
206
- if (ref.current) ref.current.removeEventListener('animationend', listener)
207
- if (timeoutRef.current) clearTimeout(timeoutRef.current)
208
- }
209
- }, [])
210
- return <div ref={ref} className="SpatialScenePanel-bg SpatialScenePanel-bg--animation"></div>
211
- }
212
-
213
- const Panel = React.forwardRef(
214
- (props: { data: SpatialScenePanelData }, myRef: React.LegacyRef<HTMLDivElement> | undefined) => (
215
- <div className="SpatialScenePanel" ref={myRef}>
216
- <div className="SpatialScenePanel-show-area">
217
- <SpatialScenePanelBg />
218
- <div className="SpatialScenePanel-header">
219
- <div className="SpatialScenePanel-title">{props.data?.title}</div>
220
- <div className="SpatialScenePanel-temperature">{props.data?.temperature}℃</div>
221
- </div>
222
- <div className="SpatialScenePanel-body">
223
- {props.data?.stateList?.map((state, index) => (
224
- <div key={`scene-${state.text}`} className={`SpatialScenePanel-item index_${index}`}>
225
- <img className="SpatialScenePanel-icon" src={state.icon} alt={`${state.text}`}></img>
226
- <div className="SpatialScenePanel-text">{state.text}</div>
227
- <div className="SpatialScenePanel-dot"></div>
228
- </div>
229
- ))}
230
- </div>
231
- </div>
232
-
233
- <div className="SpatialScenePanel-disappear-area"></div>
234
- </div>
235
- )
236
- )
237
-
238
-
239
- // export function SpatialScenePanel() {
240
- // // const data = mockData
241
-
242
- // return (
243
- // <div className="SpatialScenePanel" >
244
- // <div className="SpatialScenePanel-show-area">
245
- // <SpatialScenePanelBg />
246
- // <div className="SpatialScenePanel-header">
247
- // <div className="SpatialScenePanel-title">{data?.title}</div>
248
- // <div className="SpatialScenePanel-temperature">{data?.temperature}℃</div>
249
- // </div>
250
- // <div className="SpatialScenePanel-body">
251
- // {data?.stateList?.map((state, index) => (
252
- // <div key={`scene-${state.text}`} className={`SpatialScenePanel-item index_${index}`}>
253
- // <img className="SpatialScenePanel-icon" src={state.icon}></img>
254
- // <div className="SpatialScenePanel-text">{state.text}</div>
255
- // <div className="SpatialScenePanel-dot"></div>
256
- // </div>
257
- // ))}
258
- // </div>
259
- // </div>
260
-
261
- // <div className="SpatialScenePanel-disappear-area"></div>
262
- // </div>
263
- // )
264
- // }
@@ -1,26 +0,0 @@
1
- import React from 'react'
2
- import { Vector3 } from 'three'
3
- import { ControllerContext } from './Controller'
4
-
5
- export function useController() {
6
- const controller = React.useContext(ControllerContext)
7
- if (!controller) {
8
- throw new Error('没有找到 "ControllerContext"')
9
- }
10
-
11
- return controller
12
- }
13
-
14
- export function useFiveInstance() {
15
- const controller = useController()
16
- if (!controller.five) {
17
- throw new Error('没有找到 "five" 实例')
18
- }
19
-
20
- return controller.five
21
- }
22
-
23
- export function useFiveProject2d() {
24
- const five = useFiveInstance()
25
- return (vector: Vector3) => five.project2d(vector, false)
26
- }
@@ -1,225 +0,0 @@
1
- import * as ReactDOM from 'react-dom'
2
- import { Five, Subscribe } from '@realsee/five'
3
-
4
- import { App } from './App'
5
- import { Controller, ControllerContext } from './Controller'
6
- import { CameraMovementData, VreoKeyframeEnum, VreoKeyframeEvent, VreoUnit } from '../typings/VreoUnit'
7
- import { reaction } from 'mobx'
8
- import { Drawer } from './modules/Drawer'
9
- import { Appearance, PlayerConfigs, WaveAppearance } from './typings'
10
- import { PopUp } from './modules/PopUp'
11
-
12
- export class Player extends Subscribe<VreoKeyframeEvent> {
13
- $five: Five
14
- private controller: Controller
15
- configs: Readonly<PlayerConfigs>
16
-
17
- constructor(five: Five, configs: Partial<PlayerConfigs> = {}) {
18
- super()
19
- this.$five = five
20
-
21
-
22
- if (!configs.container) {
23
- configs.container = configs.containter
24
- }
25
- if (!configs.container) {
26
- const container = document.getElementById('vreo-app') || document.createElement('div')
27
- ReactDOM.unmountComponentAtNode(container)
28
- container.setAttribute('id', 'vreo-app')
29
- configs.container = container
30
- const fiveCanvasDomParent = five.getElement()?.parentNode
31
- if (fiveCanvasDomParent) {
32
- fiveCanvasDomParent.append(container)
33
- } else {
34
- document.body.append(container)
35
- }
36
- }
37
-
38
- if (!configs.container.classList.contains('vreo-app')) configs.container.classList.add('vreo-app')
39
-
40
- this.configs = Object.freeze( Object.assign({ keyframeMap: {} }, configs) )
41
-
42
- this.controller = new Controller({five, container:configs.container, configs: this.configs})
43
-
44
-
45
- ReactDOM.render(
46
- <ControllerContext.Provider value={this.controller}>
47
- <App />
48
- <Drawer />
49
- <PopUp />
50
- {this.configs.customKeyframes &&
51
- this.configs.customKeyframes.map((CustomCmpt, key) => (
52
- <CustomCmpt
53
- key={key}
54
- subscribe={{
55
- on: (name, callback) => this.on(name, callback),
56
- once: (name, callback) => this.once(name, callback),
57
- off: (name, callback) => this.off(name, callback),
58
- }}
59
- five={five}
60
- />
61
- ))}
62
- </ControllerContext.Provider>,
63
- configs.container
64
- )
65
-
66
- // 监听播放情况:抛出触发时机
67
- reaction(
68
- () => this.controller.ended,
69
- (ended) => {
70
- if (ended) {
71
- this.emit('paused', true)
72
- }
73
- }
74
- )
75
-
76
- reaction(
77
- () => this.controller.playing,
78
- (playing) => {
79
- if (!this.controller.ended) {
80
- this.emit(playing ? 'playing' : 'paused')
81
- }
82
- }
83
- )
84
- }
85
-
86
- async load(vreoUnit: VreoUnit, currentTime = 0, preload = false, force = false) {
87
- this.controller.setLoading(true)
88
- if (force) {
89
- vreoUnit = JSON.parse(JSON.stringify(vreoUnit))
90
- }
91
- if (!this.controller.visible) {
92
- this.controller.setVisible(true)
93
- // 延迟 500ms 规避跟 DOM 动画冲突
94
- await new Promise((resolve) => {
95
- setTimeout(() => resolve(true), 500)
96
- })
97
- }
98
-
99
- if (this.controller.stopInterval) {
100
- this.controller.stopInterval()
101
- this.controller.stopInterval = undefined
102
- }
103
-
104
- this.controller.vreoUnit = vreoUnit
105
- this.controller.mediaInstance?.pause()
106
-
107
- // 预载逻辑
108
- // 是否降低图片分辨率
109
- if (
110
- this.$five.imageOptions.size &&
111
- this.configs.imageOptions?.size &&
112
- this.$five.imageOptions.size > this.configs.imageOptions.size
113
- ) {
114
- this.$five.imageOptions.size = this.configs.imageOptions.size
115
- }
116
-
117
- // 预载数据中的点位
118
- if (preload || (preload === undefined && this.configs.autoPreload)) {
119
- const panoIndexMap = vreoUnit.keyframes
120
- .filter((vreoKeyframe) => {
121
- if (vreoKeyframe.type !== VreoKeyframeEnum.CameraMovement) {
122
- return false
123
- }
124
-
125
- const data = vreoKeyframe.data as CameraMovementData
126
- if (data.panoIndex === undefined) {
127
- return false
128
- }
129
- return true
130
- })
131
- .reduce((accu: Record<number, boolean>, curr) => {
132
- const panoIndex = curr.data.panoIndex as number
133
- if (!accu[panoIndex]) {
134
- accu[panoIndex] = true
135
- }
136
- return accu
137
- }, {})
138
-
139
- const panoIndexes = Object.keys(panoIndexMap)
140
- for (let i = 0; i < panoIndexes.length; i++) {
141
- await this.$five.preloadPano(Number(panoIndexes[i]))
142
- }
143
- }
144
-
145
- // 新数据载入就绪
146
- this.emit('loaded', vreoUnit)
147
- this.controller.emit('loaded', vreoUnit)
148
-
149
- if (this.controller.videoAgentScene?.videoAgentMesh.mediaInstance) {
150
- this.controller.videoAgentScene.videoAgentMesh.mediaInstance.currentTime = currentTime / 1000
151
- }
152
-
153
- this.controller.setAvatar(vreoUnit.video.avatar)
154
-
155
- await this.controller.videoAgentScene?.videoAgentMesh.play(
156
- vreoUnit.video.url,
157
- currentTime / 1000,
158
- vreoUnit.video.duration
159
- )
160
-
161
- this.controller.setEnded(false)
162
- this.play()
163
-
164
- this.controller.run((type, keyframe) => this.emit(type, keyframe))
165
- this.controller.setLoading(false)
166
- return true
167
- }
168
-
169
- get paused() {
170
- return !this.controller.playing
171
- }
172
-
173
- play(currentTime?: number) {
174
- if (this.controller.playing) return true
175
- if (currentTime && this.controller.mediaInstance) {
176
- this.controller.mediaInstance.currentTime = currentTime / 1000
177
- }
178
- Object.assign(window, { $vreoController: this.controller })
179
-
180
- this.controller.setPlaying(true)
181
- return true
182
- }
183
-
184
- setAppearance(appearance: Appearance) {
185
- this.controller.setAppearance(appearance)
186
- }
187
-
188
- pause() {
189
- this.controller.setPlaying(false)
190
- }
191
-
192
- show() {
193
- this.controller.setVisible(true)
194
- }
195
-
196
- hide() {
197
- this.controller.setVisible(false)
198
- }
199
-
200
- getCurrentTime() {
201
- return this.controller.currentTime
202
- }
203
-
204
- dispose() {
205
- this.pause()
206
- this.controller.dispose()
207
-
208
- if (this.configs.container) {
209
- ReactDOM.unmountComponentAtNode(this.configs.container as Element)
210
- }
211
- }
212
- }
213
-
214
- console.log(`
215
-
216
- ┏━━━┓━━━━━━━━━┏┓━━━━━━━━━━━━━
217
- ┃┏━┓┃━━━━━━━━━┃┃━━━━━━━━━━━━━
218
- ┃┗━┛┃┏━━┓┏━━┓━┃┃━┏━━┓┏━━┓┏━━┓
219
- ┃┏┓┏┛┃┏┓┃┗━┓┃━┃┃━┃━━┫┃┏┓┃┃┏┓┃
220
- ┃┃┃┗┓┃┃━┫┃┗┛┗┓┃┗┓┣━━┃┃┃━┫┃┃━┫
221
- ┗┛┗━┛┗━━┛┗━━━┛┗━┛┗━━┛┗━━┛┗━━┛
222
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
223
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
224
-
225
- `)
@@ -1,40 +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
-
7
- const DrawerView = observer(({ controller }: { controller: Controller }) => {
8
- const maxHeight = '400px'
9
- const height = (() => {
10
- const height = controller.drawerConfig?.height
11
- if (!height) {
12
- return 'max-content'
13
- }
14
-
15
- if (typeof height === 'number') {
16
- return height + 'px'
17
- }
18
-
19
- return height
20
- })()
21
-
22
- return (
23
- <div
24
- className={classNames('vreo-drawer', {
25
- 'vreo-drawer-visible': controller.drawerConfig && controller.drawerConfig.content,
26
- })}
27
- onClick={() => controller.openDrawer(false)}
28
- >
29
- <div className="vreo-drawer-inner" style={{ height, maxHeight }}>
30
- {controller.drawerConfig?.content || ''}
31
- </div>
32
- </div>
33
- )
34
- })
35
-
36
- export function Drawer() {
37
- const controller = useController()
38
-
39
- return <DrawerView controller={controller} />
40
- }
@@ -1,26 +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
-
7
- const PopUpView = observer(({ controller }: { controller: Controller }) => {
8
-
9
- return (
10
- <div
11
- className={classNames('vreo-PopUp', {
12
- 'vreo-PopUp-visible': controller.popUp,
13
- })}
14
- onClick={() => controller.openPopUp(false)}
15
- >
16
- <div className="vreo-PopUp-inner">
17
- {controller.popUp || ''}
18
- </div>
19
- </div>
20
- )
21
- })
22
-
23
- export function PopUp() {
24
- const controller = useController()
25
- return <PopUpView controller={controller} />
26
- }
@@ -1,23 +0,0 @@
1
- import React from 'react'
2
- import { addResizeListener, hasResizeListener } from '../../../shared-utils/addResizeListener'
3
- import { useController } from '../../hooks'
4
-
5
- export function ResizeObserver() {
6
- const ref = React.useRef<HTMLDivElement>(null)
7
- const controller = useController()
8
-
9
- React.useEffect(() => {
10
- if (!ref.current) return
11
- const resizeElement = controller.container.parentElement
12
- if (hasResizeListener(resizeElement)) return
13
- const dispose = addResizeListener(resizeElement, (width, height) => {
14
- controller.setContainerSize(width, height)
15
- })
16
-
17
- return () => {
18
- dispose()
19
- }
20
- }, [])
21
-
22
- return <div className="resizeObserver-element" ref={ref}></div>
23
- }