@realsee/vreo 0.2.0-alpha.18 → 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/docs/assets/search.js +1 -1
- package/docs/classes/Player.AudioLike.html +2 -2
- package/docs/classes/Player.Controller.html +9 -9
- package/docs/classes/Player.Player-1.html +9 -9
- package/docs/classes/Player.VideoAgentMesh.html +11 -11
- package/docs/classes/Player.VideoAgentScene.html +1 -1
- package/docs/demo/assets/{AppReact.10c53460.js → AppReact.ec0a6e82.js} +1 -1
- package/docs/demo/assets/{default.03c59a9e.js → default.a5d6dd99.js} +2 -2
- package/docs/demo/assets/{dynamic.74fff6a1.js → dynamic.8c30b7ae.js} +1 -1
- package/docs/demo/assets/{examples.b3de04c9.js → examples.ddb41c97.js} +2 -2
- package/docs/demo/assets/{index.d79aab1a.js → index.fc42be2b.js} +1 -1
- package/docs/demo/assets/{main.4104126d.js → main.d119ebf7.js} +1 -1
- package/docs/demo/assets/{react.465bd89e.js → react.2d403aee.js} +1 -1
- package/docs/demo/examples.html +2 -2
- package/docs/demo/index-react-dynamic.html +4 -4
- package/docs/demo/index-react.html +4 -4
- package/docs/demo/index.html +3 -3
- package/docs/enums/Player.InfoPanelStyleEnum.html +1 -1
- package/docs/enums/Player.InfoPanelTypeEnum.html +1 -1
- package/docs/enums/Player.PanoEffectEnum.html +1 -1
- package/docs/enums/Player.PanoTagEnum.html +1 -1
- package/docs/enums/Player.PanoTagStyleEnum.html +2 -2
- 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/interfaces/Player.CustomVreoKeyframeProps.html +1 -1
- package/docs/interfaces/Player.PlayerConfigs.html +2 -2
- package/docs/interfaces/Player.Vertex.html +1 -1
- package/docs/interfaces/Player.VideoAgentMeshOptions.html +3 -3
- package/docs/interfaces/Player.VreoKeyframe.html +1 -1
- package/docs/interfaces/Player.VreoUnit.html +1 -1
- package/docs/interfaces/Player.VreoVideo.html +1 -1
- package/docs/interfaces/fivePlugins.CSS3DRenderPluginExportType.html +2 -2
- package/docs/interfaces/fivePlugins.CameraMovementOptsCallback.html +1 -1
- package/docs/interfaces/fivePlugins.CameraMovementPluginExportType.html +2 -2
- 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 +1 -1
- package/docs/interfaces/react.VreoActionCallbacks.html +6 -6
- package/docs/interfaces/react.VreoProviderProps.html +1 -1
- package/docs/modules/Player.html +16 -16
- package/docs/modules/custom.html +1 -1
- package/docs/modules/fivePlugins.html +3 -3
- package/docs/modules/react.html +1 -1
- package/lib/Player/Controller.d.ts +2 -0
- package/lib/Player/Controller.js +21 -2
- package/lib/Player/index.d.ts +1 -0
- package/lib/Player/index.js +18 -4
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +12 -4
- package/lib/typings/VreoUnit.d.ts +1 -0
- package/package.json +3 -2
- package/resources/Player/Controller.ts +149 -129
- package/resources/Player/index.tsx +176 -161
- package/resources/Player/modules/VideoAgent/VideoAgentMesh.ts +6 -1
- package/resources/typings/VreoUnit.ts +2 -0
|
@@ -11,158 +11,178 @@ import { PlayerConfigs } from './typings'
|
|
|
11
11
|
*/
|
|
12
12
|
export class Controller extends Subscribe<VreoKeyframeEvent> {
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
$five?: Five
|
|
15
|
+
configs?: PlayerConfigs
|
|
16
|
+
videoAgentScene?: VideoAgentScene
|
|
17
|
+
vreoUnit?: VreoUnit
|
|
18
|
+
stopInterval?: () => void
|
|
19
|
+
playing = false
|
|
20
|
+
ended = false
|
|
21
|
+
|
|
22
|
+
visible = false
|
|
23
|
+
|
|
24
|
+
get isAudio() {
|
|
25
|
+
return !this.videoAgentScene?.videoAgentMesh.videoUrl?.endsWith('.mp4')
|
|
26
|
+
}
|
|
20
27
|
|
|
21
|
-
|
|
28
|
+
popUp: string | JSX.Element | null = null
|
|
22
29
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
30
|
+
openPopUp(popUp: string | JSX.Element | false) {
|
|
31
|
+
if (!popUp) {
|
|
32
|
+
this.popUp = null
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
this.popUp = popUp
|
|
36
|
+
}
|
|
26
37
|
|
|
27
|
-
|
|
38
|
+
drawerConfig: {
|
|
39
|
+
content: string | JSX.Element
|
|
40
|
+
height?: number | string
|
|
41
|
+
} | null = null
|
|
28
42
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.popUp = null
|
|
32
|
-
return
|
|
33
|
-
}
|
|
34
|
-
this.popUp = popUp
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
drawerConfig: {
|
|
38
|
-
content: string | JSX.Element
|
|
39
|
-
height?: number | string
|
|
40
|
-
} | null = null
|
|
41
|
-
|
|
42
|
-
setVisible(v: boolean) {
|
|
43
|
-
this.visible = v
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
setPlaying(playing: boolean) {
|
|
47
|
-
this.playing = playing
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
openDrawer(drawerConfig?: false | { content: string | JSX.Element; height?: number | string }) {
|
|
51
|
-
if (!drawerConfig) {
|
|
52
|
-
this.drawerConfig = {
|
|
53
|
-
content: '',
|
|
54
|
-
height: this.drawerConfig?.height
|
|
55
|
-
}
|
|
56
|
-
return
|
|
43
|
+
setVisible(v: boolean) {
|
|
44
|
+
this.visible = v
|
|
57
45
|
}
|
|
58
46
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
constructor() {
|
|
63
|
-
super()
|
|
64
|
-
|
|
65
|
-
makeObservable(this, {
|
|
66
|
-
visible: observable,
|
|
67
|
-
setVisible: action,
|
|
68
|
-
playing: observable,
|
|
69
|
-
setPlaying: action,
|
|
70
|
-
popUp: observable.ref,
|
|
71
|
-
openPopUp: action,
|
|
72
|
-
drawerConfig: observable.ref,
|
|
73
|
-
openDrawer: action,
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
// 监听播放情况:抛出触发时机
|
|
77
|
-
reaction(
|
|
78
|
-
() => this.playing,
|
|
79
|
-
(playing) => {
|
|
80
|
-
this.emit(playing ? 'playing' : 'paused')
|
|
81
|
-
}
|
|
82
|
-
)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
get ready() {
|
|
86
|
-
return !!this.videoAgentScene
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
get currentTime() {
|
|
90
|
-
return this.videoAgentScene?.videoAgentMesh.currentTime || 0
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
get currentKeyframes() {
|
|
94
|
-
if (!this.vreoUnit) return []
|
|
95
|
-
const keyframes = this.vreoUnit.keyframes
|
|
96
|
-
// 没有被解析过且开始时间低于当前时间戳 100ms
|
|
97
|
-
return keyframes.filter((keyframe: VreoKeyframe) => {
|
|
98
|
-
if (keyframe.parsed) return false
|
|
99
|
-
const dur = this.currentTime - keyframe.start
|
|
100
|
-
return dur <= 100 && dur >= 0
|
|
101
|
-
})
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
get videoInstance() {
|
|
105
|
-
return this.videoAgentScene?.videoAgentMesh.videoInstance
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* 逐帧任务
|
|
110
|
-
*/
|
|
111
|
-
requestAnimationFrameLoop(callback: (type: VreoKeyframeEnum, keyframe: VreoKeyframe) => void) {
|
|
112
|
-
if (this.videoInstance?.ended) {
|
|
113
|
-
this.setPlaying(false)
|
|
114
|
-
this.videoInstance.pause()
|
|
115
|
-
return
|
|
47
|
+
setPlaying(playing: boolean) {
|
|
48
|
+
this.playing = playing
|
|
116
49
|
}
|
|
117
50
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
this.videoInstance?.pause()
|
|
121
|
-
}
|
|
122
|
-
return
|
|
51
|
+
setEnded(ended: boolean) {
|
|
52
|
+
this.ended = ended
|
|
123
53
|
}
|
|
124
54
|
|
|
125
|
-
|
|
126
|
-
|
|
55
|
+
openDrawer(drawerConfig?: false | { content: string | JSX.Element; height?: number | string }) {
|
|
56
|
+
if (!drawerConfig) {
|
|
57
|
+
this.drawerConfig = {
|
|
58
|
+
content: '',
|
|
59
|
+
height: this.drawerConfig?.height
|
|
60
|
+
}
|
|
61
|
+
return
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
this.drawerConfig = drawerConfig
|
|
127
65
|
}
|
|
128
66
|
|
|
129
|
-
|
|
67
|
+
constructor() {
|
|
68
|
+
super()
|
|
69
|
+
|
|
70
|
+
makeObservable(this, {
|
|
71
|
+
visible: observable,
|
|
72
|
+
setVisible: action,
|
|
73
|
+
playing: observable,
|
|
74
|
+
setPlaying: action,
|
|
75
|
+
popUp: observable.ref,
|
|
76
|
+
openPopUp: action,
|
|
77
|
+
drawerConfig: observable.ref,
|
|
78
|
+
openDrawer: action,
|
|
79
|
+
ended: observable,
|
|
80
|
+
setEnded: action
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
// 监听播放情况:抛出触发时机
|
|
84
|
+
reaction(
|
|
85
|
+
() => this.ended,
|
|
86
|
+
(ended) => {
|
|
87
|
+
if (ended) {
|
|
88
|
+
this.emit('paused', true)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
reaction(
|
|
94
|
+
() => this.playing,
|
|
95
|
+
(playing) => {
|
|
96
|
+
if (!this.ended) {
|
|
97
|
+
this.emit(playing ? 'playing' : 'paused')
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
)
|
|
130
101
|
|
|
131
|
-
|
|
132
|
-
if (keyframe.parsed) return
|
|
133
|
-
keyframe.parsed = true
|
|
134
|
-
this.emit(keyframe.type, keyframe)
|
|
135
|
-
if (callback) {
|
|
136
|
-
callback(keyframe.type, keyframe)
|
|
137
|
-
}
|
|
138
|
-
})
|
|
139
|
-
}
|
|
102
|
+
}
|
|
140
103
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
104
|
+
get ready() {
|
|
105
|
+
return !!this.videoAgentScene
|
|
106
|
+
}
|
|
145
107
|
|
|
146
|
-
|
|
147
|
-
|
|
108
|
+
get currentTime() {
|
|
109
|
+
return this.videoAgentScene?.videoAgentMesh.currentTime || 0
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
get currentKeyframes() {
|
|
113
|
+
if (!this.vreoUnit) return []
|
|
114
|
+
const keyframes = this.vreoUnit.keyframes
|
|
115
|
+
// 没有被解析过且开始时间低于当前时间戳 100ms
|
|
116
|
+
return keyframes.filter((keyframe: VreoKeyframe) => {
|
|
117
|
+
if (keyframe.parsed) return false
|
|
118
|
+
const dur = this.currentTime - keyframe.start
|
|
119
|
+
return dur <= 100 && dur >= 0
|
|
120
|
+
})
|
|
121
|
+
}
|
|
148
122
|
|
|
149
|
-
|
|
150
|
-
|
|
123
|
+
get videoInstance() {
|
|
124
|
+
return this.videoAgentScene?.videoAgentMesh.videoInstance
|
|
151
125
|
}
|
|
152
126
|
|
|
153
127
|
/**
|
|
154
|
-
*
|
|
128
|
+
* 逐帧任务
|
|
155
129
|
*/
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
130
|
+
requestAnimationFrameLoop(callback: (type: VreoKeyframeEnum, keyframe: VreoKeyframe) => void) {
|
|
131
|
+
if (this.videoInstance?.ended) {
|
|
132
|
+
this.setEnded(true)
|
|
133
|
+
this.setPlaying(false)
|
|
134
|
+
this.videoInstance.pause()
|
|
135
|
+
return
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (!this.playing) {
|
|
139
|
+
if (!this.videoInstance?.paused) {
|
|
140
|
+
this.videoInstance?.pause()
|
|
141
|
+
}
|
|
142
|
+
return
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (this.videoInstance?.paused && this.playing) {
|
|
146
|
+
this.videoInstance.play()
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const currentKeyframes = this.currentKeyframes
|
|
150
|
+
|
|
151
|
+
currentKeyframes.forEach((keyframe) => {
|
|
152
|
+
if (keyframe.parsed) return
|
|
153
|
+
keyframe.parsed = true
|
|
154
|
+
this.emit(keyframe.type, keyframe)
|
|
155
|
+
if (callback) {
|
|
156
|
+
callback(keyframe.type, keyframe)
|
|
157
|
+
}
|
|
158
|
+
})
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
run(callback: (type: VreoKeyframeEnum, keyframe: VreoKeyframe) => void) {
|
|
162
|
+
if (this.stopInterval) return
|
|
163
|
+
this.stopInterval = requestAnimationFrameInterval(() => this.requestAnimationFrameLoop(callback))
|
|
159
164
|
}
|
|
160
165
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
166
|
+
dispose() {
|
|
167
|
+
this.setPlaying(false)
|
|
168
|
+
|
|
169
|
+
if (this.currentKeyframes) {
|
|
170
|
+
this.currentKeyframes.forEach((keyframe) => (keyframe.parsed = false))
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* 清理掉数据
|
|
175
|
+
*/
|
|
176
|
+
this.vreoUnit = undefined
|
|
177
|
+
if (this.videoInstance) {
|
|
178
|
+
this.videoInstance.currentTime = 0
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (this.stopInterval) {
|
|
182
|
+
this.stopInterval()
|
|
183
|
+
this.stopInterval = undefined
|
|
184
|
+
}
|
|
164
185
|
}
|
|
165
|
-
}
|
|
166
186
|
}
|
|
167
187
|
|
|
168
188
|
export const ControllerContext = React.createContext<Controller | null>(null)
|
|
@@ -11,183 +11,198 @@ import { PlayerConfigs } from './typings'
|
|
|
11
11
|
import { PopUp } from './modules/PopUp'
|
|
12
12
|
|
|
13
13
|
export class Player extends Subscribe<VreoKeyframeEvent> {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
+
)
|
|
37
87
|
}
|
|
38
88
|
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
|
90
165
|
}
|
|
91
166
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this.controller.stopInterval = undefined
|
|
167
|
+
get paused() {
|
|
168
|
+
return !this.controller.playing
|
|
95
169
|
}
|
|
96
170
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
this.$five.imageOptions.size &&
|
|
104
|
-
this.configs.imageOptions?.size &&
|
|
105
|
-
this.$five.imageOptions.size > this.configs.imageOptions.size
|
|
106
|
-
) {
|
|
107
|
-
this.$five.imageOptions.size = this.configs.imageOptions.size
|
|
108
|
-
}
|
|
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 })
|
|
109
177
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const panoIndexMap = vreoUnit.keyframes
|
|
113
|
-
.filter((vreoKeyframe) => {
|
|
114
|
-
if (vreoKeyframe.type !== VreoKeyframeEnum.CameraMovement) {
|
|
115
|
-
return false
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const data = vreoKeyframe.data as CameraMovementData
|
|
119
|
-
if (data.panoIndex === undefined) {
|
|
120
|
-
return false
|
|
121
|
-
}
|
|
122
|
-
return true
|
|
123
|
-
})
|
|
124
|
-
.reduce((accu: Record<number, boolean>, curr) => {
|
|
125
|
-
const panoIndex = curr.data.panoIndex as number
|
|
126
|
-
if (!accu[panoIndex]) {
|
|
127
|
-
accu[panoIndex] = true
|
|
128
|
-
}
|
|
129
|
-
return accu
|
|
130
|
-
}, {})
|
|
131
|
-
|
|
132
|
-
const panoIndexs = Object.keys(panoIndexMap)
|
|
133
|
-
for (let i = 0; i < panoIndexs.length; i++) {
|
|
134
|
-
await this.$five.preloadPano(Number(panoIndexs[i]))
|
|
135
|
-
}
|
|
178
|
+
this.controller.setPlaying(true)
|
|
179
|
+
return true
|
|
136
180
|
}
|
|
137
181
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
this.controller.emit('loaded', vreoUnit)
|
|
141
|
-
|
|
142
|
-
if (this.controller.videoAgentScene?.videoAgentMesh.videoInstance) {
|
|
143
|
-
this.controller.videoAgentScene.videoAgentMesh.videoInstance.currentTime = currentTime / 1000
|
|
144
|
-
}
|
|
145
|
-
await this.controller.videoAgentScene?.videoAgentMesh.play(
|
|
146
|
-
vreoUnit.video.url,
|
|
147
|
-
currentTime / 1000,
|
|
148
|
-
vreoUnit.video.duration
|
|
149
|
-
)
|
|
150
|
-
this.play()
|
|
151
|
-
|
|
152
|
-
this.controller.run((type, keyframe) => this.emit(type, keyframe))
|
|
153
|
-
return true
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
get paused() {
|
|
157
|
-
return !this.controller.playing
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
play(currentTime?: number) {
|
|
161
|
-
if (this.controller.playing) return true
|
|
162
|
-
if (currentTime && this.controller.videoInstance) {
|
|
163
|
-
this.controller.videoInstance.currentTime = currentTime / 1000
|
|
182
|
+
pause() {
|
|
183
|
+
this.controller.setPlaying(false)
|
|
164
184
|
}
|
|
165
|
-
Object.assign(window, {$vreoController: this.controller})
|
|
166
185
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
pause() {
|
|
172
|
-
this.controller.setPlaying(false)
|
|
173
|
-
}
|
|
186
|
+
show() {
|
|
187
|
+
this.controller.setVisible(true)
|
|
188
|
+
}
|
|
174
189
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
190
|
+
hide() {
|
|
191
|
+
this.controller.setVisible(false)
|
|
192
|
+
}
|
|
178
193
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
194
|
+
getCurrentTime() {
|
|
195
|
+
return this.controller.currentTime
|
|
196
|
+
}
|
|
182
197
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
198
|
+
dispose() {
|
|
199
|
+
this.pause()
|
|
200
|
+
this.controller.dispose()
|
|
186
201
|
|
|
187
|
-
|
|
188
|
-
|
|
202
|
+
if (this.configs.containter) {
|
|
203
|
+
ReactDOM.unmountComponentAtNode(this.configs.containter as Element)
|
|
204
|
+
}
|
|
189
205
|
}
|
|
190
|
-
}
|
|
191
206
|
}
|
|
192
207
|
|
|
193
208
|
console.log(`
|