@realsee/vreo 1.0.0-alpha.9 → 1.1.0-dev.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.
- package/CHANGELOG.md +9 -1
- package/README.md +46 -36
- package/lib/PlayController/index.js +1 -1
- package/lib/Player/Controller.d.ts +3 -2
- package/lib/Player/Controller.js +31 -14
- package/lib/Player/index.js +27 -16
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +2 -2
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +7 -12
- package/lib/Player/modules/VideoAgent/index.js +1 -1
- package/lib/Player/modules/Wave/index.js +160 -25
- package/lib/Player/modules/keyframes/BgMusic/index.js +52 -40
- package/lib/Player/modules/keyframes/PanoTag/index.js +1 -0
- package/lib/fivePlugins/CameraMovementPlugin/index.js +3 -2
- package/lib/shared-utils/Audio.d.ts +14 -0
- package/lib/shared-utils/Audio.js +158 -0
- package/lib/shared-utils/{AduioLike.d.ts → AudioLike.d.ts} +0 -0
- package/lib/shared-utils/{AduioLike.js → AudioLike.js} +4 -6
- package/lib/shared-utils/animationFrame/tween.d.ts +3 -58
- package/lib/shared-utils/animationFrame/tween.js +3 -9
- package/lib/typings/VreoUnit.d.ts +8 -5
- package/package.json +8 -6
- package/stylesheets/default.css +7 -2
- package/docs/.nojekyll +0 -1
- package/docs/assets/custom.css +0 -78
- package/docs/assets/highlight.css +0 -127
- package/docs/assets/icons.css +0 -1043
- package/docs/assets/icons.png +0 -0
- package/docs/assets/icons@2x.png +0 -0
- package/docs/assets/main.js +0 -52
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1414
- package/docs/assets/widgets.png +0 -0
- package/docs/assets/widgets@2x.png +0 -0
- package/docs/classes/Player.AudioLike.html +0 -52
- package/docs/classes/Player.Controller.html +0 -54
- package/docs/classes/Player.Player-1.html +0 -50
- package/docs/classes/Player.VideoAgentMesh.html +0 -142
- package/docs/classes/Player.VideoAgentScene.html +0 -1
- package/docs/demo/assets/AppReact.6ca5d1d2.js +0 -1
- package/docs/demo/assets/default.5a762ce2.js +0 -3988
- package/docs/demo/assets/default.bc4c715d.css +0 -1
- package/docs/demo/assets/dynamic.efc5200d.js +0 -1
- package/docs/demo/assets/examples.80a27156.js +0 -25
- package/docs/demo/assets/examples.dac4a6fe.css +0 -1
- package/docs/demo/assets/index.9331038f.css +0 -1
- package/docs/demo/assets/index.ca7c5881.js +0 -1
- package/docs/demo/assets/main.c164d1d2.js +0 -1
- package/docs/demo/assets/react.2ee8565f.css +0 -1
- package/docs/demo/assets/react.a4774aef.js +0 -25
- package/docs/demo/assets/znRoyv06SZQeqA7m.0057e8ae.js +0 -1
- package/docs/demo/examples.html +0 -17
- package/docs/demo/index-react-dynamic.html +0 -20
- package/docs/demo/index-react.html +0 -20
- package/docs/demo/index.html +0 -19
- package/docs/enums/Player.InfoPanelStyleEnum.html +0 -1
- package/docs/enums/Player.InfoPanelTypeEnum.html +0 -3
- package/docs/enums/Player.PanoEffectEnum.html +0 -5
- package/docs/enums/Player.PanoTagEnum.html +0 -3
- package/docs/enums/Player.PanoTagStyleEnum.html +0 -7
- package/docs/enums/Player.VreoKeyframeEnum.html +0 -25
- package/docs/enums/fivePlugins.CameraMovementEffect.html +0 -1
- package/docs/enums/fivePlugins.Rotation.html +0 -1
- package/docs/index.html +0 -245
- package/docs/interfaces/Player.CustomVreoKeyframeProps.html +0 -1
- package/docs/interfaces/Player.PlayerConfigs.html +0 -7
- package/docs/interfaces/Player.Vertex.html +0 -3
- package/docs/interfaces/Player.VideoAgentMeshOptions.html +0 -8
- package/docs/interfaces/Player.VreoKeyframe.html +0 -3
- package/docs/interfaces/Player.VreoUnit.html +0 -3
- package/docs/interfaces/Player.VreoVideo.html +0 -3
- package/docs/interfaces/fivePlugins.CSS3DRenderPluginExportType.html +0 -4
- package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +0 -1
- package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +0 -7
- package/docs/interfaces/fivePlugins.CameraMovementPluginParameterType.html +0 -1
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +0 -1
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +0 -1
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +0 -1
- package/docs/interfaces/fivePlugins.Vector3Position.html +0 -3
- package/docs/interfaces/react.VreoActionCallbacks.html +0 -23
- package/docs/interfaces/react.VreoProviderProps.html +0 -1
- package/docs/modules/Player.html +0 -37
- package/docs/modules/custom.html +0 -3
- package/docs/modules/fivePlugins.html +0 -6
- package/docs/modules/react.html +0 -1
- package/docs/modules.html +0 -1
- package/resources/PlayController/createHTMLAudioElement.ts +0 -53
- package/resources/PlayController/index.ts +0 -154
- package/resources/Player/App.tsx +0 -66
- package/resources/Player/Controller.ts +0 -294
- package/resources/Player/custom/SpatialScenePanel/index.tsx +0 -264
- package/resources/Player/hooks.ts +0 -26
- package/resources/Player/index.tsx +0 -227
- package/resources/Player/modules/Drawer/index.tsx +0 -40
- package/resources/Player/modules/PopUp/index.tsx +0 -26
- package/resources/Player/modules/ResizeObserver/index.tsx +0 -23
- package/resources/Player/modules/VideoAgent/VideoAgentMesh.ts +0 -302
- package/resources/Player/modules/VideoAgent/VideoAgentScene.ts +0 -56
- package/resources/Player/modules/VideoAgent/index.tsx +0 -53
- package/resources/Player/modules/Wave/index.tsx +0 -18
- package/resources/Player/modules/keyframes/BgMusic/index.tsx +0 -66
- package/resources/Player/modules/keyframes/CameraMovement/index.tsx +0 -37
- package/resources/Player/modules/keyframes/InfoPanel/index.tsx +0 -165
- package/resources/Player/modules/keyframes/ModelVideo/index.tsx +0 -77
- package/resources/Player/modules/keyframes/PanoEffect/index.tsx +0 -99
- package/resources/Player/modules/keyframes/PanoEffect/lineAnime.ts +0 -31
- package/resources/Player/modules/keyframes/PanoTag/index.tsx +0 -82
- package/resources/Player/modules/keyframes/PanoTextLabel/index.tsx +0 -117
- package/resources/Player/modules/keyframes/Prompter/index.tsx +0 -56
- package/resources/Player/modules/keyframes/UpdateVRPanorama/index.tsx +0 -99
- package/resources/Player/modules/keyframes/VideoEffect/index.tsx +0 -115
- package/resources/Player/typings.ts +0 -49
- package/resources/fivePlugins/CSS3DRenderPlugin/centerPoint.ts +0 -5
- package/resources/fivePlugins/CSS3DRenderPlugin/createResizeObserver.ts +0 -17
- package/resources/fivePlugins/CSS3DRenderPlugin/evenNumber.ts +0 -4
- package/resources/fivePlugins/CSS3DRenderPlugin/index.ts +0 -254
- package/resources/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.ts +0 -5
- package/resources/fivePlugins/CameraMovementPlugin/index.ts +0 -226
- package/resources/fivePlugins/CameraMovementPlugin/typings.ts +0 -59
- package/resources/fivePlugins/ModelTVVideoPlugin/index.ts +0 -278
- package/resources/index.ts +0 -1
- package/resources/react/index.tsx +0 -121
- package/resources/shared-utils/AduioLike.ts +0 -109
- package/resources/shared-utils/Preloader.ts +0 -35
- package/resources/shared-utils/addResizeListener.ts +0 -46
- package/resources/shared-utils/animationFrame/BetterTween.ts +0 -33
- package/resources/shared-utils/animationFrame/index.ts +0 -48
- package/resources/shared-utils/animationFrame/tween.ts +0 -51
- package/resources/shared-utils/createTransMatrix.ts +0 -12
- package/resources/shared-utils/getFileExpandedName.ts +0 -6
- package/resources/shared-utils/getMediaInfo.ts +0 -52
- package/resources/shared-utils/setElementDataset.ts +0 -18
- 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,227 +0,0 @@
|
|
|
1
|
-
// 下面这一行不能删
|
|
2
|
-
import * as React from 'react'
|
|
3
|
-
import * as ReactDOM from 'react-dom'
|
|
4
|
-
import { Five, Subscribe } from '@realsee/five'
|
|
5
|
-
|
|
6
|
-
import { App } from './App'
|
|
7
|
-
import { Controller, ControllerContext } from './Controller'
|
|
8
|
-
import { CameraMovementData, VreoKeyframeEnum, VreoKeyframeEvent, VreoUnit } from '../typings/VreoUnit'
|
|
9
|
-
import { reaction } from 'mobx'
|
|
10
|
-
import { Drawer } from './modules/Drawer'
|
|
11
|
-
import { Appearance, PlayerConfigs, WaveAppearance } from './typings'
|
|
12
|
-
import { PopUp } from './modules/PopUp'
|
|
13
|
-
|
|
14
|
-
export class Player extends Subscribe<VreoKeyframeEvent> {
|
|
15
|
-
$five: Five
|
|
16
|
-
private controller: Controller
|
|
17
|
-
configs: Readonly<PlayerConfigs>
|
|
18
|
-
|
|
19
|
-
constructor(five: Five, configs: Partial<PlayerConfigs> = {}) {
|
|
20
|
-
super()
|
|
21
|
-
this.$five = five
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (!configs.container) {
|
|
25
|
-
configs.container = configs.containter
|
|
26
|
-
}
|
|
27
|
-
if (!configs.container) {
|
|
28
|
-
const container = document.getElementById('vreo-app') || document.createElement('div')
|
|
29
|
-
ReactDOM.unmountComponentAtNode(container)
|
|
30
|
-
container.setAttribute('id', 'vreo-app')
|
|
31
|
-
configs.container = container
|
|
32
|
-
const fiveCanvasDomParent = five.getElement()?.parentNode
|
|
33
|
-
if (fiveCanvasDomParent) {
|
|
34
|
-
fiveCanvasDomParent.append(container)
|
|
35
|
-
} else {
|
|
36
|
-
document.body.append(container)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (!configs.container.classList.contains('vreo-app')) configs.container.classList.add('vreo-app')
|
|
41
|
-
|
|
42
|
-
this.configs = Object.freeze( Object.assign({ keyframeMap: {} }, configs) )
|
|
43
|
-
|
|
44
|
-
this.controller = new Controller({five, container:configs.container, configs: this.configs})
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
ReactDOM.render(
|
|
48
|
-
<ControllerContext.Provider value={this.controller}>
|
|
49
|
-
<App />
|
|
50
|
-
<Drawer />
|
|
51
|
-
<PopUp />
|
|
52
|
-
{this.configs.customKeyframes &&
|
|
53
|
-
this.configs.customKeyframes.map((CustomCmpt, key) => (
|
|
54
|
-
<CustomCmpt
|
|
55
|
-
key={key}
|
|
56
|
-
subscribe={{
|
|
57
|
-
on: (name, callback) => this.on(name, callback),
|
|
58
|
-
once: (name, callback) => this.once(name, callback),
|
|
59
|
-
off: (name, callback) => this.off(name, callback),
|
|
60
|
-
}}
|
|
61
|
-
five={five}
|
|
62
|
-
/>
|
|
63
|
-
))}
|
|
64
|
-
</ControllerContext.Provider>,
|
|
65
|
-
configs.container
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
// 监听播放情况:抛出触发时机
|
|
69
|
-
reaction(
|
|
70
|
-
() => this.controller.ended,
|
|
71
|
-
(ended) => {
|
|
72
|
-
if (ended) {
|
|
73
|
-
this.emit('paused', true)
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
reaction(
|
|
79
|
-
() => this.controller.playing,
|
|
80
|
-
(playing) => {
|
|
81
|
-
if (!this.controller.ended) {
|
|
82
|
-
this.emit(playing ? 'playing' : 'paused')
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async load(vreoUnit: VreoUnit, currentTime = 0, preload = false, force = false) {
|
|
89
|
-
this.controller.setLoading(true)
|
|
90
|
-
if (force) {
|
|
91
|
-
vreoUnit = JSON.parse(JSON.stringify(vreoUnit))
|
|
92
|
-
}
|
|
93
|
-
if (!this.controller.visible) {
|
|
94
|
-
this.controller.setVisible(true)
|
|
95
|
-
// 延迟 500ms 规避跟 DOM 动画冲突
|
|
96
|
-
await new Promise((resolve) => {
|
|
97
|
-
setTimeout(() => resolve(true), 500)
|
|
98
|
-
})
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (this.controller.stopInterval) {
|
|
102
|
-
this.controller.stopInterval()
|
|
103
|
-
this.controller.stopInterval = undefined
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
this.controller.vreoUnit = vreoUnit
|
|
107
|
-
this.controller.mediaInstance?.pause()
|
|
108
|
-
|
|
109
|
-
// 预载逻辑
|
|
110
|
-
// 是否降低图片分辨率
|
|
111
|
-
if (
|
|
112
|
-
this.$five.imageOptions.size &&
|
|
113
|
-
this.configs.imageOptions?.size &&
|
|
114
|
-
this.$five.imageOptions.size > this.configs.imageOptions.size
|
|
115
|
-
) {
|
|
116
|
-
this.$five.imageOptions.size = this.configs.imageOptions.size
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// 预载数据中的点位
|
|
120
|
-
if (preload || (preload === undefined && this.configs.autoPreload)) {
|
|
121
|
-
const panoIndexMap = vreoUnit.keyframes
|
|
122
|
-
.filter((vreoKeyframe) => {
|
|
123
|
-
if (vreoKeyframe.type !== VreoKeyframeEnum.CameraMovement) {
|
|
124
|
-
return false
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const data = vreoKeyframe.data as CameraMovementData
|
|
128
|
-
if (data.panoIndex === undefined) {
|
|
129
|
-
return false
|
|
130
|
-
}
|
|
131
|
-
return true
|
|
132
|
-
})
|
|
133
|
-
.reduce((accu: Record<number, boolean>, curr) => {
|
|
134
|
-
const panoIndex = curr.data.panoIndex as number
|
|
135
|
-
if (!accu[panoIndex]) {
|
|
136
|
-
accu[panoIndex] = true
|
|
137
|
-
}
|
|
138
|
-
return accu
|
|
139
|
-
}, {})
|
|
140
|
-
|
|
141
|
-
const panoIndexes = Object.keys(panoIndexMap)
|
|
142
|
-
for (let i = 0; i < panoIndexes.length; i++) {
|
|
143
|
-
await this.$five.preloadPano(Number(panoIndexes[i]))
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// 新数据载入就绪
|
|
148
|
-
this.emit('loaded', vreoUnit)
|
|
149
|
-
this.controller.emit('loaded', vreoUnit)
|
|
150
|
-
|
|
151
|
-
if (this.controller.videoAgentScene?.videoAgentMesh.mediaInstance) {
|
|
152
|
-
this.controller.videoAgentScene.videoAgentMesh.mediaInstance.currentTime = currentTime / 1000
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
this.controller.setAvatar(vreoUnit.video.avatar)
|
|
156
|
-
|
|
157
|
-
await this.controller.videoAgentScene?.videoAgentMesh.play(
|
|
158
|
-
vreoUnit.video.url,
|
|
159
|
-
currentTime / 1000,
|
|
160
|
-
vreoUnit.video.duration
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
this.controller.setEnded(false)
|
|
164
|
-
this.play()
|
|
165
|
-
|
|
166
|
-
this.controller.run((type, keyframe) => this.emit(type, keyframe))
|
|
167
|
-
this.controller.setLoading(false)
|
|
168
|
-
return true
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
get paused() {
|
|
172
|
-
return !this.controller.playing
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
play(currentTime?: number) {
|
|
176
|
-
if (this.controller.playing) return true
|
|
177
|
-
if (currentTime && this.controller.mediaInstance) {
|
|
178
|
-
this.controller.mediaInstance.currentTime = currentTime / 1000
|
|
179
|
-
}
|
|
180
|
-
Object.assign(window, { $vreoController: this.controller })
|
|
181
|
-
|
|
182
|
-
this.controller.setPlaying(true)
|
|
183
|
-
return true
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
setAppearance(appearance: Appearance) {
|
|
187
|
-
this.controller.setAppearance(appearance)
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
pause() {
|
|
191
|
-
this.controller.setPlaying(false)
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
show() {
|
|
195
|
-
this.controller.setVisible(true)
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
hide() {
|
|
199
|
-
this.controller.setVisible(false)
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
getCurrentTime() {
|
|
203
|
-
return this.controller.currentTime
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
dispose() {
|
|
207
|
-
this.pause()
|
|
208
|
-
this.controller.dispose()
|
|
209
|
-
|
|
210
|
-
if (this.configs.container) {
|
|
211
|
-
ReactDOM.unmountComponentAtNode(this.configs.container as Element)
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
console.log(`
|
|
217
|
-
|
|
218
|
-
┏━━━┓━━━━━━━━━┏┓━━━━━━━━━━━━━
|
|
219
|
-
┃┏━┓┃━━━━━━━━━┃┃━━━━━━━━━━━━━
|
|
220
|
-
┃┗━┛┃┏━━┓┏━━┓━┃┃━┏━━┓┏━━┓┏━━┓
|
|
221
|
-
┃┏┓┏┛┃┏┓┃┗━┓┃━┃┃━┃━━┫┃┏┓┃┃┏┓┃
|
|
222
|
-
┃┃┃┗┓┃┃━┫┃┗┛┗┓┃┗┓┣━━┃┃┃━┫┃┃━┫
|
|
223
|
-
┗┛┗━┛┗━━┛┗━━━┛┗━┛┗━━┛┗━━┛┗━━┛
|
|
224
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
225
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
226
|
-
|
|
227
|
-
`)
|
|
@@ -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
|
-
}
|