@realsee/vreo 0.2.0-alpha.2 → 0.2.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.
- package/CHANGELOG.md +5 -0
- package/README.md +80 -5
- package/docs/assets/custom.css +2 -2
- package/docs/assets/highlight.css +1 -1
- package/docs/assets/main.js +2 -2
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +28 -2
- package/docs/classes/Player.AudioLike.html +52 -0
- package/docs/classes/Player.Controller.html +13 -13
- package/docs/classes/Player.Player-1.html +11 -11
- package/docs/classes/Player.VideoAgentMesh.html +53 -53
- package/docs/classes/Player.VideoAgentScene.html +1 -1
- package/docs/demo/assets/AppReact.ec0a6e82.js +1 -0
- package/docs/demo/assets/default.55c3f308.css +1 -0
- package/docs/demo/assets/default.a5d6dd99.js +3952 -0
- package/docs/demo/assets/dynamic.8c30b7ae.js +1 -0
- package/docs/demo/assets/examples.dac4a6fe.css +1 -0
- package/docs/demo/assets/examples.ddb41c97.js +25 -0
- package/docs/demo/assets/index.a7bafdff.css +1 -0
- package/docs/demo/assets/index.fc42be2b.js +1 -0
- package/docs/demo/assets/main.d119ebf7.js +1 -0
- package/docs/demo/assets/react.2d403aee.js +25 -0
- package/docs/demo/assets/react.855b3d23.css +1 -0
- package/docs/demo/assets/znRoyv06SZQeqA7m.0057e8ae.js +1 -0
- package/docs/demo/examples.html +17 -0
- package/docs/demo/index-react-dynamic.html +20 -0
- package/docs/demo/index-react.html +20 -0
- package/docs/demo/index.html +19 -0
- package/docs/enums/Player.InfoPanelStyleEnum.html +1 -0
- package/docs/enums/Player.InfoPanelTypeEnum.html +2 -2
- package/docs/enums/Player.PanoEffectEnum.html +2 -2
- package/docs/enums/Player.PanoTagEnum.html +2 -2
- package/docs/enums/Player.PanoTagStyleEnum.html +7 -0
- package/docs/enums/Player.VreoKeyframeEnum.html +12 -12
- package/docs/enums/fivePlugins.CameraMovementEffect.html +1 -1
- package/docs/enums/fivePlugins.Rotation.html +1 -1
- package/docs/index.html +37 -6
- package/docs/interfaces/Player.CustomVreoKeyframeProps.html +1 -1
- package/docs/interfaces/Player.PlayerConfigs.html +3 -3
- package/docs/interfaces/Player.Vertex.html +2 -2
- package/docs/interfaces/Player.VideoAgentMeshOptions.html +8 -1
- package/docs/interfaces/Player.VreoKeyframe.html +2 -2
- package/docs/interfaces/Player.VreoUnit.html +2 -2
- package/docs/interfaces/Player.VreoVideo.html +2 -2
- package/docs/interfaces/fivePlugins.CSS3DRenderPluginExportType.html +4 -0
- package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +1 -1
- package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +2 -2
- package/docs/interfaces/fivePlugins.CameraMovementPluginParameterType.html +1 -1
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginData.html +1 -1
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginExportType.html +1 -1
- package/docs/interfaces/fivePlugins.ModelTVVideoPluginParameterType.html +1 -1
- package/docs/interfaces/fivePlugins.Vector3Position.html +3 -0
- package/docs/interfaces/react.VreoActionCallbacks.html +15 -7
- package/docs/interfaces/react.VreoProviderProps.html +1 -1
- package/docs/modules/Player.html +21 -15
- package/docs/modules/custom.html +1 -1
- package/docs/modules/fivePlugins.html +5 -2
- package/docs/modules/react.html +1 -1
- package/docs/modules.html +1 -1
- package/lib/PlayController/createHTMLAudioElement.d.ts +1 -0
- package/lib/PlayController/createHTMLAudioElement.js +47 -0
- package/lib/PlayController/index.d.ts +38 -0
- package/lib/PlayController/index.js +300 -0
- package/lib/Player/App.js +5 -4
- package/lib/Player/Controller.d.ts +5 -1
- package/lib/Player/Controller.js +38 -5
- package/lib/Player/custom/SpatialScenePanel/index.d.ts +2 -2
- package/lib/Player/custom/SpatialScenePanel/index.js +98 -26
- package/lib/Player/index.d.ts +3 -2
- package/lib/Player/index.js +116 -24
- package/lib/Player/modules/Drawer/index.js +1 -1
- package/lib/Player/modules/PopUp/index.d.ts +2 -0
- package/lib/Player/modules/PopUp/index.js +43 -0
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.d.ts +17 -2
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +113 -37
- package/lib/Player/modules/VideoAgent/VideoAgentScene.d.ts +5 -1
- package/lib/Player/modules/VideoAgent/VideoAgentScene.js +9 -4
- package/lib/Player/modules/VideoAgent/index.d.ts +2 -0
- package/lib/Player/modules/VideoAgent/index.js +2 -2
- package/lib/Player/modules/keyframes/BgMusic/index.js +1 -1
- package/lib/Player/modules/keyframes/CameraMovement/index.js +42 -6
- package/lib/Player/modules/keyframes/InfoPanel/index.js +74 -36
- package/lib/Player/modules/keyframes/ModelVideo/index.js +46 -9
- package/lib/Player/modules/keyframes/PanoEffect/index.js +1 -1
- package/lib/Player/modules/keyframes/PanoEffect/lineAnime.js +1 -1
- package/lib/Player/modules/keyframes/PanoTag/index.js +20 -7
- package/lib/Player/modules/keyframes/PanoTextLabel/index.d.ts +3 -0
- package/lib/Player/modules/keyframes/PanoTextLabel/index.js +96 -51
- package/lib/Player/modules/keyframes/Prompter/index.js +5 -19
- package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +31 -19
- package/lib/Player/modules/keyframes/VideoEffect/index.js +1 -1
- package/lib/Player/typings.d.ts +6 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.d.ts +2 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.js +12 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.d.ts +7 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.js +32 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.d.ts +3 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.js +11 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/index.d.ts +56 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/index.js +275 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.d.ts +7 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.js +18 -0
- package/lib/fivePlugins/CameraMovementPlugin/index.js +104 -90
- package/lib/fivePlugins/CameraMovementPlugin/typings.d.ts +1 -0
- package/lib/fivePlugins/ModelTVVideoPlugin/index.js +1 -1
- package/lib/react/index.d.ts +7 -3
- package/lib/react/index.js +3 -3
- package/lib/shared-utils/AduioLike.d.ts +37 -0
- package/lib/shared-utils/AduioLike.js +165 -0
- package/lib/shared-utils/animationFrame/BetterTween.js +7 -3
- package/lib/shared-utils/animationFrame/tween.js +1 -1
- package/lib/shared-utils/createTransMatrix.d.ts +1 -0
- package/lib/shared-utils/createTransMatrix.js +43 -0
- package/lib/typings/VreoUnit.d.ts +42 -5
- package/lib/typings/VreoUnit.js +26 -6
- package/package.json +8 -8
- package/resources/PlayController/createHTMLAudioElement.ts +53 -0
- package/resources/PlayController/index.ts +167 -0
- package/resources/Player/App.tsx +2 -0
- package/resources/Player/Controller.ts +155 -121
- package/resources/Player/custom/SpatialScenePanel/index.tsx +148 -45
- package/resources/Player/index.tsx +186 -110
- package/resources/Player/modules/PopUp/index.tsx +26 -0
- package/resources/Player/modules/VideoAgent/VideoAgentMesh.ts +66 -14
- package/resources/Player/modules/VideoAgent/VideoAgentScene.ts +3 -3
- package/resources/Player/modules/VideoAgent/index.tsx +3 -2
- package/resources/Player/modules/keyframes/CameraMovement/index.tsx +7 -3
- package/resources/Player/modules/keyframes/InfoPanel/index.tsx +79 -34
- package/resources/Player/modules/keyframes/ModelVideo/index.tsx +36 -3
- package/resources/Player/modules/keyframes/PanoTag/index.tsx +31 -12
- package/resources/Player/modules/keyframes/PanoTextLabel/index.tsx +87 -34
- package/resources/Player/modules/keyframes/Prompter/index.tsx +5 -15
- package/resources/Player/modules/keyframes/UpdateVRPanorama/index.tsx +25 -16
- package/resources/Player/typings.ts +5 -0
- package/resources/fivePlugins/CSS3DRenderPlugin/centerPoint.ts +5 -0
- package/resources/fivePlugins/CSS3DRenderPlugin/createResizeObserver.ts +17 -0
- package/resources/fivePlugins/CSS3DRenderPlugin/evenNumber.ts +4 -0
- package/resources/fivePlugins/CSS3DRenderPlugin/index.ts +254 -0
- package/resources/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.ts +5 -0
- package/resources/fivePlugins/CameraMovementPlugin/index.ts +59 -48
- package/resources/fivePlugins/CameraMovementPlugin/typings.ts +2 -1
- package/resources/react/index.tsx +7 -3
- package/resources/shared-utils/AduioLike.ts +108 -0
- package/resources/shared-utils/createTransMatrix.ts +12 -0
- package/resources/typings/VreoUnit.ts +46 -5
- package/stylesheets/custom/SpatialScenePanel.css +14 -8
- package/stylesheets/default.css +116 -12
|
@@ -2,12 +2,37 @@ import * as React from 'react'
|
|
|
2
2
|
import ReactDOM from 'react-dom'
|
|
3
3
|
import { Five } from '@realsee/five'
|
|
4
4
|
import { Raycaster, Vector3 } from 'three'
|
|
5
|
-
import { tweenProgress } from '
|
|
6
|
-
import { CSS3DRenderPlugin, CSS3DRenderPluginExportType } from '
|
|
5
|
+
import { tweenProgress } from '../../../shared-utils/animationFrame/BetterTween'
|
|
6
|
+
import { CSS3DRenderPlugin, CSS3DRenderPluginExportType } from '../../../fivePlugins/CSS3DRenderPlugin'
|
|
7
7
|
|
|
8
8
|
import { VreoKeyframe, VreoKeyframeEnum } from '../../../typings/VreoUnit'
|
|
9
9
|
import { CustomVreoKeyframeProps } from '../../typings'
|
|
10
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
|
+
|
|
11
36
|
export interface SpatialScenePanelData {
|
|
12
37
|
customType: 'SpatialScenePanel'
|
|
13
38
|
title: string
|
|
@@ -16,25 +41,34 @@ export interface SpatialScenePanelData {
|
|
|
16
41
|
text: string
|
|
17
42
|
icon: string
|
|
18
43
|
}[]
|
|
19
|
-
position
|
|
20
|
-
quaternion
|
|
44
|
+
position?: { x: number; y: number; z: number }
|
|
45
|
+
quaternion?: [number, number, number, number]
|
|
21
46
|
}
|
|
22
47
|
|
|
23
48
|
interface SearchParams {
|
|
24
49
|
five: Five
|
|
25
|
-
position: Vector3
|
|
26
|
-
rotation?: Vector3
|
|
27
|
-
quaternion: [number, number, number, number]
|
|
28
|
-
dom: HTMLDivElement
|
|
50
|
+
// position: Vector3
|
|
51
|
+
// rotation?: Vector3
|
|
52
|
+
// quaternion: [number, number, number, number]
|
|
53
|
+
dom: HTMLDivElement
|
|
29
54
|
}
|
|
30
55
|
|
|
31
|
-
const
|
|
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) => {
|
|
32
65
|
const cameraDirection = new Vector3()
|
|
33
66
|
five.camera.getWorldDirection(cameraDirection)
|
|
34
67
|
const cameraPosition = five.camera.position
|
|
35
68
|
const [intersect] = five.model.intersectRaycaster(new Raycaster(cameraPosition, cameraDirection))
|
|
36
69
|
const point = five.project2d(intersect.point)
|
|
37
70
|
|
|
71
|
+
const widescreen = window.innerWidth > 560 ? true : false
|
|
38
72
|
// const width = dom!.clientWidth
|
|
39
73
|
const height = dom!.clientHeight
|
|
40
74
|
dom!.style.left = point!.x + 'px'
|
|
@@ -48,16 +82,18 @@ const searchV1 = ({ five, position, rotation, dom }: SearchParams) => {
|
|
|
48
82
|
const rightBottom = new Vector3(right, bottom)
|
|
49
83
|
|
|
50
84
|
const points = [leftBottom, rightBottom, rightTop, leftTop].map((point) => {
|
|
51
|
-
point.setX((point.x / window.innerWidth) * 2 - 1)
|
|
52
|
-
point.setY(-(point.y / window.innerHeight) * 2 + 1)
|
|
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))
|
|
53
87
|
point.setZ(0.5)
|
|
54
88
|
return point.unproject(five.camera).addScaledVector(cameraDirection, 0.2)
|
|
55
89
|
})
|
|
56
90
|
|
|
91
|
+
// __debug__
|
|
57
92
|
// const colors = [0xdc143c, 0xffff00, 0x0000ff, 0x008000]
|
|
58
93
|
// points.forEach((p, index) => five.scene.add(getSphere(p, colors[index])))
|
|
59
94
|
|
|
60
|
-
|
|
95
|
+
// 判断是手机 150
|
|
96
|
+
const ratio = leftBottom.distanceTo(rightBottom) / (widescreen ? 150 : 120)
|
|
61
97
|
return { points, ratio }
|
|
62
98
|
}
|
|
63
99
|
|
|
@@ -66,12 +102,12 @@ const searchV1 = ({ five, position, rotation, dom }: SearchParams) => {
|
|
|
66
102
|
* @returns
|
|
67
103
|
*/
|
|
68
104
|
export function SpatialScenePanel(props: CustomVreoKeyframeProps) {
|
|
105
|
+
const timeoutRef = React.useRef<NodeJS.Timeout | null>(null)
|
|
69
106
|
const ref = React.useRef<HTMLDivElement>(null)
|
|
70
107
|
const panelRef = React.useRef<HTMLDivElement | null>(null)
|
|
71
108
|
const rendererRef = React.useRef<CSS3DRenderPluginExportType>(CSS3DRenderPlugin(props.five))
|
|
72
109
|
|
|
73
110
|
React.useEffect(() => {
|
|
74
|
-
|
|
75
111
|
if (!ref.current) {
|
|
76
112
|
return
|
|
77
113
|
}
|
|
@@ -82,64 +118,103 @@ export function SpatialScenePanel(props: CustomVreoKeyframeProps) {
|
|
|
82
118
|
}
|
|
83
119
|
|
|
84
120
|
const data = keyframe.data as SpatialScenePanelData
|
|
85
|
-
// const data = mockData as SpatialScenePanelData
|
|
86
121
|
|
|
122
|
+
// const data = mockData
|
|
87
123
|
const { points, ratio } = searchV1({
|
|
88
124
|
five: props.five,
|
|
89
|
-
|
|
90
|
-
quaternion: data.quaternion,
|
|
91
|
-
dom: ref.current!
|
|
125
|
+
dom: ref.current!,
|
|
92
126
|
})
|
|
93
127
|
|
|
94
|
-
console.log(points, ratio)
|
|
95
|
-
|
|
96
128
|
const { container, dispose, css3DObject, render } =
|
|
97
129
|
rendererRef.current.create3DDomContainer(points, { ratio, autoRender: false }) || {}
|
|
98
130
|
|
|
131
|
+
Object.assign(window, { $css3DObject: css3DObject })
|
|
99
132
|
if (!container) return
|
|
100
133
|
|
|
101
|
-
|
|
102
134
|
ReactDOM.render(<Panel ref={(ref) => (panelRef.current = ref)} data={data} />, container)
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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)
|
|
125
169
|
}
|
|
126
170
|
|
|
127
|
-
Object.assign(window, {$
|
|
171
|
+
Object.assign(window, { $callback: callback })
|
|
172
|
+
|
|
173
|
+
// setTimeout(() => {callback()}, 8000)
|
|
128
174
|
props.subscribe.on(VreoKeyframeEnum.Custom, callback)
|
|
129
175
|
|
|
130
176
|
return () => {
|
|
131
177
|
props.subscribe.off(VreoKeyframeEnum.Custom, callback)
|
|
178
|
+
if (timeoutRef.current) {
|
|
179
|
+
clearTimeout(timeoutRef.current)
|
|
180
|
+
}
|
|
132
181
|
}
|
|
133
182
|
}, [])
|
|
134
183
|
|
|
135
184
|
return <div className="vreo-SpatialScenePanel" ref={ref}></div>
|
|
136
185
|
}
|
|
137
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
|
+
|
|
138
213
|
const Panel = React.forwardRef(
|
|
139
214
|
(props: { data: SpatialScenePanelData }, myRef: React.LegacyRef<HTMLDivElement> | undefined) => (
|
|
140
215
|
<div className="SpatialScenePanel" ref={myRef}>
|
|
141
216
|
<div className="SpatialScenePanel-show-area">
|
|
142
|
-
<
|
|
217
|
+
<SpatialScenePanelBg />
|
|
143
218
|
<div className="SpatialScenePanel-header">
|
|
144
219
|
<div className="SpatialScenePanel-title">{props.data?.title}</div>
|
|
145
220
|
<div className="SpatialScenePanel-temperature">{props.data?.temperature}℃</div>
|
|
@@ -157,5 +232,33 @@ const Panel = React.forwardRef(
|
|
|
157
232
|
|
|
158
233
|
<div className="SpatialScenePanel-disappear-area"></div>
|
|
159
234
|
</div>
|
|
160
|
-
)
|
|
235
|
+
)
|
|
161
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
|
+
// }
|
|
@@ -4,129 +4,205 @@ import { Five, Subscribe } from '@realsee/five'
|
|
|
4
4
|
|
|
5
5
|
import { App } from './App'
|
|
6
6
|
import { Controller, ControllerContext } from './Controller'
|
|
7
|
-
import { VreoKeyframeEvent, VreoUnit } from '../typings/VreoUnit'
|
|
7
|
+
import { CameraMovementData, VreoKeyframeEnum, VreoKeyframeEvent, VreoUnit } from '../typings/VreoUnit'
|
|
8
8
|
import { reaction } from 'mobx'
|
|
9
9
|
import { Drawer } from './modules/Drawer'
|
|
10
10
|
import { PlayerConfigs } from './typings'
|
|
11
|
+
import { PopUp } from './modules/PopUp'
|
|
11
12
|
|
|
12
13
|
export class Player extends Subscribe<VreoKeyframeEvent> {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
$five: Five
|
|
15
|
+
private controller: Controller
|
|
16
|
+
configs: Readonly<PlayerConfigs>
|
|
17
|
+
|
|
18
|
+
constructor(five: Five, configs: Partial<PlayerConfigs> = {}) {
|
|
19
|
+
super()
|
|
20
|
+
this.controller = new Controller()
|
|
21
|
+
this.$five = this.controller.$five = five
|
|
22
|
+
|
|
23
|
+
if (!configs.containter) {
|
|
24
|
+
const containter = document.getElementById('vreo-app') || document.createElement('div')
|
|
25
|
+
ReactDOM.unmountComponentAtNode(containter)
|
|
26
|
+
containter.setAttribute('id', 'vreo-app')
|
|
27
|
+
configs.containter = containter
|
|
28
|
+
const fiveCanvasDomParent = five.getElement()?.parentNode
|
|
29
|
+
if (fiveCanvasDomParent) {
|
|
30
|
+
fiveCanvasDomParent.append(containter)
|
|
31
|
+
} else {
|
|
32
|
+
document.body.append(containter)
|
|
33
|
+
}
|
|
34
|
+
// document.body.append(containter)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
this.configs = Object.freeze(
|
|
38
|
+
Object.assign(
|
|
39
|
+
{
|
|
40
|
+
keyframeMap: {},
|
|
41
|
+
},
|
|
42
|
+
configs
|
|
43
|
+
)
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
this.controller.configs = this.configs
|
|
47
|
+
|
|
48
|
+
ReactDOM.render(
|
|
49
|
+
<ControllerContext.Provider value={this.controller}>
|
|
50
|
+
<App />
|
|
51
|
+
<Drawer />
|
|
52
|
+
<PopUp />
|
|
53
|
+
{this.configs.customKeyframes &&
|
|
54
|
+
this.configs.customKeyframes.map((CustomCmpt, key) => (
|
|
55
|
+
<CustomCmpt
|
|
56
|
+
key={key}
|
|
57
|
+
subscribe={{
|
|
58
|
+
on: (name, callback) => this.on(name, callback),
|
|
59
|
+
once: (name, callback) => this.once(name, callback),
|
|
60
|
+
off: (name, callback) => this.off(name, callback),
|
|
61
|
+
}}
|
|
62
|
+
five={five}
|
|
63
|
+
/>
|
|
64
|
+
))}
|
|
65
|
+
</ControllerContext.Provider>,
|
|
66
|
+
configs.containter
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
// 监听播放情况:抛出触发时机
|
|
70
|
+
reaction(
|
|
71
|
+
() => this.controller.ended,
|
|
72
|
+
(ended) => {
|
|
73
|
+
if (ended) {
|
|
74
|
+
this.emit('paused', true)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
reaction(
|
|
80
|
+
() => this.controller.playing,
|
|
81
|
+
(playing) => {
|
|
82
|
+
if (!this.controller.ended) {
|
|
83
|
+
this.emit(playing ? 'playing' : 'paused')
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
)
|
|
28
87
|
}
|
|
29
88
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
89
|
+
async load(vreoUnit: VreoUnit, currentTime = 0, preload = false, force = false) {
|
|
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.videoInstance?.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 panoIndexs = Object.keys(panoIndexMap)
|
|
142
|
+
for (let i = 0; i < panoIndexs.length; i++) {
|
|
143
|
+
await this.$five.preloadPano(Number(panoIndexs[i]))
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// 新数据载入就绪
|
|
148
|
+
this.emit('loaded', vreoUnit)
|
|
149
|
+
this.controller.emit('loaded', vreoUnit)
|
|
150
|
+
|
|
151
|
+
if (this.controller.videoAgentScene?.videoAgentMesh.videoInstance) {
|
|
152
|
+
this.controller.videoAgentScene.videoAgentMesh.videoInstance.currentTime = currentTime / 1000
|
|
153
|
+
}
|
|
154
|
+
await this.controller.videoAgentScene?.videoAgentMesh.play(
|
|
155
|
+
vreoUnit.video.url,
|
|
156
|
+
currentTime / 1000,
|
|
157
|
+
vreoUnit.video.duration
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
this.controller.setEnded(false)
|
|
161
|
+
this.play()
|
|
162
|
+
|
|
163
|
+
this.controller.run((type, keyframe) => this.emit(type, keyframe))
|
|
164
|
+
return true
|
|
77
165
|
}
|
|
78
166
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
this.controller.stopInterval = undefined
|
|
167
|
+
get paused() {
|
|
168
|
+
return !this.controller.playing
|
|
82
169
|
}
|
|
83
170
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
this.controller.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
171
|
+
play(currentTime?: number) {
|
|
172
|
+
if (this.controller.playing) return true
|
|
173
|
+
if (currentTime && this.controller.videoInstance) {
|
|
174
|
+
this.controller.videoInstance.currentTime = currentTime / 1000
|
|
175
|
+
}
|
|
176
|
+
Object.assign(window, { $vreoController: this.controller })
|
|
177
|
+
|
|
178
|
+
this.controller.setPlaying(true)
|
|
179
|
+
return true
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
pause() {
|
|
183
|
+
this.controller.setPlaying(false)
|
|
95
184
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
hide() {
|
|
119
|
-
this.controller.setVisible(false)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
dispose() {
|
|
123
|
-
this.pause()
|
|
124
|
-
this.controller.dispose()
|
|
125
|
-
|
|
126
|
-
if (this.configs.containter) {
|
|
127
|
-
ReactDOM.unmountComponentAtNode(this.configs.containter as Element)
|
|
185
|
+
|
|
186
|
+
show() {
|
|
187
|
+
this.controller.setVisible(true)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
hide() {
|
|
191
|
+
this.controller.setVisible(false)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
getCurrentTime() {
|
|
195
|
+
return this.controller.currentTime
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
dispose() {
|
|
199
|
+
this.pause()
|
|
200
|
+
this.controller.dispose()
|
|
201
|
+
|
|
202
|
+
if (this.configs.containter) {
|
|
203
|
+
ReactDOM.unmountComponentAtNode(this.configs.containter as Element)
|
|
204
|
+
}
|
|
128
205
|
}
|
|
129
|
-
}
|
|
130
206
|
}
|
|
131
207
|
|
|
132
208
|
console.log(`
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
}
|