@qispace/vue3-player 0.0.6 → 0.0.7
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/dist/components/apartmentChooser/QiApartmentChooser.vue.d.ts +471 -3
- package/dist/components/apartmentChooser/QiApartmentChooserNavigation.vue.d.ts +50 -3
- package/dist/components/apartmentChooser/QiApartmentChooserRaster.vue.d.ts +151 -3
- package/dist/components/apartmentChooser/QiApartmentChooserRotator.vue.d.ts +66 -3
- package/dist/components/apartmentChooser/QiApartmentChooserSvg.vue.d.ts +124 -3
- package/dist/components/buildingPicker/QiBuildingChooser.vue.d.ts +425 -2
- package/dist/components/buildingPicker/QiBuildingChooserRaster.vue.d.ts +154 -3
- package/dist/components/buildingPicker/QiBuildingChooserRasterOverlay.vue.d.ts +53 -3
- package/dist/components/buildingPicker/QiBuildingChooserSceneImageStack.vue.d.ts +32 -3
- package/dist/components/buildingPicker/QiBuildingChooserSunSimControl.vue.d.ts +41 -4
- package/dist/components/buildingPicker/QiBuildingChooserSvg.vue.d.ts +156 -3
- package/dist/components/shared/QiFloatingCard.vue.d.ts +17 -3
- package/dist/components/shared/QiHoverProbe.vue.d.ts +3 -3
- package/dist/components/shared/QiNorthDirection.vue.d.ts +20 -2
- package/dist/components/shared/QiZoomBox.vue.d.ts +82 -3
- package/dist/components/virtualTourV2/Disclaimer.vue.d.ts +3 -3
- package/dist/components/virtualTourV2/FullScreenButton.vue.d.ts +13 -2
- package/dist/components/virtualTourV2/ManualSlideShow.vue.d.ts +72 -3
- package/dist/components/virtualTourV2/ManualSlideShowPlayer.vue.d.ts +14 -3
- package/dist/components/virtualTourV2/SingleImage.vue.d.ts +25 -3
- package/dist/components/virtualTourV2/SocialShare.vue.d.ts +9 -3
- package/dist/components/virtualTourV2/WaypointCarousel.vue.d.ts +30 -3
- package/dist/entry.css +1 -0
- package/dist/{vue3-player.esm.js → vue3-player.mjs} +647 -581
- package/dist/vue3-player.umd.js +2 -3
- package/package.json +12 -10
- package/dist/components/apartmentChooser/QiApartmentChooser.vue.d.ts.map +0 -1
- package/dist/components/apartmentChooser/QiApartmentChooserNavigation.vue.d.ts.map +0 -1
- package/dist/components/apartmentChooser/QiApartmentChooserRaster.vue.d.ts.map +0 -1
- package/dist/components/apartmentChooser/QiApartmentChooserRotator.vue.d.ts.map +0 -1
- package/dist/components/apartmentChooser/QiApartmentChooserSvg.vue.d.ts.map +0 -1
- package/dist/components/buildingPicker/QiBuildingChooser.vue.d.ts.map +0 -1
- package/dist/components/buildingPicker/QiBuildingChooserRaster.vue.d.ts.map +0 -1
- package/dist/components/buildingPicker/QiBuildingChooserRasterOverlay.vue.d.ts.map +0 -1
- package/dist/components/buildingPicker/QiBuildingChooserSceneImageStack.vue.d.ts.map +0 -1
- package/dist/components/buildingPicker/QiBuildingChooserSunSimControl.vue.d.ts.map +0 -1
- package/dist/components/buildingPicker/QiBuildingChooserSvg.vue.d.ts.map +0 -1
- package/dist/components/shared/QiFloatingCard.vue.d.ts.map +0 -1
- package/dist/components/shared/QiHoverProbe.vue.d.ts.map +0 -1
- package/dist/components/shared/QiNorthDirection.vue.d.ts.map +0 -1
- package/dist/components/shared/QiZoomBox.vue.d.ts.map +0 -1
- package/dist/components/virtualTourV2/Disclaimer.vue.d.ts.map +0 -1
- package/dist/components/virtualTourV2/FullScreenButton.vue.d.ts.map +0 -1
- package/dist/components/virtualTourV2/ManualSlideShow.vue.d.ts.map +0 -1
- package/dist/components/virtualTourV2/ManualSlideShowPlayer.vue.d.ts.map +0 -1
- package/dist/components/virtualTourV2/SingleImage.vue.d.ts.map +0 -1
- package/dist/components/virtualTourV2/SocialShare.vue.d.ts.map +0 -1
- package/dist/components/virtualTourV2/WaypointCarousel.vue.d.ts.map +0 -1
- package/dist/lib/virtualTour__/ApartmentConfig.d.ts +0 -27
- package/dist/lib/virtualTour__/ApartmentFiles.d.ts +0 -7
- package/dist/lib/virtualTour__/MinimapConfig.d.ts +0 -23
- package/dist/lib/virtualTour__/impl/HttpApartmentFiles.d.ts +0 -19
- package/dist/vue3-player.cjs.js +0 -2
- package/dist/vue3-player.iife.js +0 -3
- package/src/entry.esm.js +0 -17
- package/src/entry.js +0 -13
- package/src/entry.ts_ +0 -17
- package/src/lib/virtualTour__/ApartmentConfig.ts +0 -80
- package/src/lib/virtualTour__/ApartmentFiles.ts +0 -8
- package/src/lib/virtualTour__/CameraNavigator.js_ +0 -74
- package/src/lib/virtualTour__/CameraSnapshot.js +0 -42
- package/src/lib/virtualTour__/CoordConversions.js +0 -43
- package/src/lib/virtualTour__/FullscreenModel.js +0 -69
- package/src/lib/virtualTour__/MinimapConfig.ts +0 -46
- package/src/lib/virtualTour__/PlayerViewModel.js +0 -423
- package/src/lib/virtualTour__/config/ApartmentConfig.js +0 -92
- package/src/lib/virtualTour__/config/CameraConfig.js +0 -97
- package/src/lib/virtualTour__/config/Interaction.js +0 -393
- package/src/lib/virtualTour__/config/Panorama.js +0 -78
- package/src/lib/virtualTour__/config/PlayerConfig.js +0 -812
- package/src/lib/virtualTour__/config/rawinflate.export.js +0 -833
- package/src/lib/virtualTour__/config/shaders.js +0 -24
- package/src/lib/virtualTour__/impl/HttpApartmentFiles.ts +0 -57
- package/src/lib/virtualTour__/index.js +0 -1
- package/src/lib/virtualTour__/textures/arrow.png +0 -0
- package/src/lib/virtualTour__/textures/compass-bg.png +0 -0
- package/src/lib/virtualTour__/textures/compass-needle.png +0 -0
- package/src/lib/virtualTour__/textures/compass-north.png +0 -0
- package/src/lib/virtualTour__/textures/floor-1.svg +0 -4
- package/src/lib/virtualTour__/textures/floor-2.svg +0 -4
- package/src/lib/virtualTour__/textures/marker.png +0 -0
- package/src/lib/virtualTour__/textures/tod-sun.png +0 -0
- package/src/main.ts_ +0 -24
- package/src/shims-png.d.ts +0 -4
- package/src/shims-tsx.d.ts +0 -11
- package/src/shims-vue.d.ts +0 -4
- package/src/style.css +0 -0
- package/src/vite-env.d.ts +0 -5
|
@@ -1,393 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
import * as THREE from 'three'
|
|
3
|
-
|
|
4
|
-
const DOM_KEY_LOCATION_STANDARD = 0
|
|
5
|
-
const DOM_KEY_LOCATION_LEFT = 1
|
|
6
|
-
const DOM_KEY_LOCATION_RIGHT = 2
|
|
7
|
-
const DOM_KEY_LOCATION_NUMPAD = 3
|
|
8
|
-
|
|
9
|
-
const NUMPAD_KEYS = [
|
|
10
|
-
'ArrowDown',
|
|
11
|
-
'ArrowUp',
|
|
12
|
-
'ArrowLeft',
|
|
13
|
-
'ArrowRight',
|
|
14
|
-
'Home',
|
|
15
|
-
'PageUp',
|
|
16
|
-
]
|
|
17
|
-
|
|
18
|
-
class Interaction {
|
|
19
|
-
constructor(eventTarget, player) {
|
|
20
|
-
this._player = player
|
|
21
|
-
this.scaling = false
|
|
22
|
-
this.prevDist = NaN
|
|
23
|
-
|
|
24
|
-
if (!eventTarget || !player) return false
|
|
25
|
-
|
|
26
|
-
if (!player.consts.isMobile) {
|
|
27
|
-
eventTarget.addEventListener(
|
|
28
|
-
'pointerleave',
|
|
29
|
-
() => {
|
|
30
|
-
player.isUserInteracting = false
|
|
31
|
-
},
|
|
32
|
-
{ passive: false }
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Mouse events
|
|
37
|
-
eventTarget.addEventListener('mousedown', (e) => this.onMouseDown(e))
|
|
38
|
-
eventTarget.addEventListener('wheel', (e) => this.onDocumentMouseWheel(e))
|
|
39
|
-
eventTarget.addEventListener(
|
|
40
|
-
'mousemove',
|
|
41
|
-
(e) => {
|
|
42
|
-
this.onMouseMove(e)
|
|
43
|
-
},
|
|
44
|
-
{ passive: false }
|
|
45
|
-
)
|
|
46
|
-
eventTarget.addEventListener(
|
|
47
|
-
'mouseup',
|
|
48
|
-
(e) => {
|
|
49
|
-
this.onMouseUp(e)
|
|
50
|
-
},
|
|
51
|
-
{ passive: false }
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
// Touch events
|
|
55
|
-
eventTarget.addEventListener('touchstart', (e) => this.onTouchStart(e), {
|
|
56
|
-
passive: false,
|
|
57
|
-
})
|
|
58
|
-
eventTarget.addEventListener('touchmove', (e) => this.onTouchMove(e), {
|
|
59
|
-
passive: false,
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
// Use same handler for pointer{up,cancel,out,leave} events since
|
|
63
|
-
// the semantics for these events - in this app - are the same.
|
|
64
|
-
eventTarget.addEventListener('touchend', (e) => this.onTouchEnd(e), {
|
|
65
|
-
passive: false,
|
|
66
|
-
})
|
|
67
|
-
eventTarget.addEventListener('touchcancel', (e) => this.onTouchEnd(e), {
|
|
68
|
-
passive: false,
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
// Key events
|
|
72
|
-
window.addEventListener(
|
|
73
|
-
'keydown',
|
|
74
|
-
(e) => {
|
|
75
|
-
this.onKeyDown(e)
|
|
76
|
-
},
|
|
77
|
-
{ passive: false }
|
|
78
|
-
)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
onTouchStart(e) {
|
|
82
|
-
if (e.touches.length === 2) {
|
|
83
|
-
this.scaling = true
|
|
84
|
-
} else {
|
|
85
|
-
this.onMouseDown(e)
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
onTouchMove(e) {
|
|
90
|
-
if (this.scaling) {
|
|
91
|
-
const dist = Math.hypot(
|
|
92
|
-
e.touches[0].pageX - e.touches[1].pageX,
|
|
93
|
-
e.touches[0].pageY - e.touches[1].pageY
|
|
94
|
-
)
|
|
95
|
-
if (!Number.isNaN(this.prevDist)) {
|
|
96
|
-
const currDist = this.prevDist - dist
|
|
97
|
-
const camera = this._player.camera
|
|
98
|
-
const fov = camera.fov + currDist * 0.2
|
|
99
|
-
camera.fov = THREE.MathUtils.clamp(fov, 35, 90)
|
|
100
|
-
camera.updateProjectionMatrix()
|
|
101
|
-
}
|
|
102
|
-
this.prevDist = dist
|
|
103
|
-
} else {
|
|
104
|
-
if (e.scale !== 1) {
|
|
105
|
-
e.preventDefault()
|
|
106
|
-
}
|
|
107
|
-
this.onMouseMove(e)
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
onTouchEnd(e) {
|
|
112
|
-
if (this.scaling) {
|
|
113
|
-
this.scaling = false
|
|
114
|
-
this.prevDist = NaN
|
|
115
|
-
} else {
|
|
116
|
-
this.onMouseUp(e)
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
removeEvent(ev) {
|
|
121
|
-
// Remove this event from the target's cache
|
|
122
|
-
const index = this.evCache.findIndex(
|
|
123
|
-
(cachedEv) => cachedEv.pointerId === ev.pointerId
|
|
124
|
-
)
|
|
125
|
-
this.evCache.splice(index, 1)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
onDocumentMouseWheel(event) {
|
|
129
|
-
const camera = this._player.camera
|
|
130
|
-
const fov = camera.fov + event.deltaY * 0.05
|
|
131
|
-
camera.fov = THREE.MathUtils.clamp(fov, 35, 90)
|
|
132
|
-
camera.updateProjectionMatrix()
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
onMouseDown(event) {
|
|
136
|
-
if (this._player.isTransition) return false
|
|
137
|
-
this._player.transitionRotateCamera = true
|
|
138
|
-
this._player.isMouseDown = true
|
|
139
|
-
this._player.isUserInteracting = true
|
|
140
|
-
this._player.isMouseMoved = false
|
|
141
|
-
|
|
142
|
-
this._player.nMouseMove = 0
|
|
143
|
-
|
|
144
|
-
const clientX = this._player.getX(event)
|
|
145
|
-
const clientY = this._player.getY(event)
|
|
146
|
-
|
|
147
|
-
this._player.onMouseDownMouseX = clientX
|
|
148
|
-
this._player.onMouseDownMouseY = clientY
|
|
149
|
-
this._player.onMouseDownLon = this._player.lon
|
|
150
|
-
this._player.onMouseDownLat = this._player.lat
|
|
151
|
-
this._player.oldLon = this._player.lon
|
|
152
|
-
this._player.oldLat = this._player.lat
|
|
153
|
-
this._player.speedLon = 0
|
|
154
|
-
this._player.speedLat = 0
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
onMouseMove(event) {
|
|
158
|
-
if (!this._player.currentPanorama) return false
|
|
159
|
-
if (this._player.isUserInteracting === true) {
|
|
160
|
-
this._player.nMouseMove = this._player.nMouseMove + 1
|
|
161
|
-
this._player.isMouseMoved = this._player.nMouseMove > 4
|
|
162
|
-
const clientX = this._player.getX(event)
|
|
163
|
-
const clientY = this._player.getY(event)
|
|
164
|
-
|
|
165
|
-
this._player.lon =
|
|
166
|
-
(this._player.onMouseDownMouseX - clientX) *
|
|
167
|
-
this._player.mouseSensitivity +
|
|
168
|
-
this._player.onMouseDownLon
|
|
169
|
-
this._player.lat =
|
|
170
|
-
(clientY - this._player.onMouseDownMouseY) *
|
|
171
|
-
this._player.mouseSensitivity +
|
|
172
|
-
this._player.onMouseDownLat
|
|
173
|
-
}
|
|
174
|
-
const gamecontainer = document.getElementById('gameinstance')
|
|
175
|
-
|
|
176
|
-
if (!gamecontainer) return false
|
|
177
|
-
|
|
178
|
-
const rect = gamecontainer.getBoundingClientRect()
|
|
179
|
-
|
|
180
|
-
// Map to -1 to 1
|
|
181
|
-
this._player.mouse.x =
|
|
182
|
-
((event.clientX - rect.left) / this._player.width) * 2 - 1
|
|
183
|
-
this._player.mouse.y =
|
|
184
|
-
-((event.clientY - rect.top) / this._player.height) * 2 + 1
|
|
185
|
-
|
|
186
|
-
this._player.raycaster.setFromCamera(
|
|
187
|
-
this._player.mouse,
|
|
188
|
-
this._player.camera
|
|
189
|
-
)
|
|
190
|
-
const t =
|
|
191
|
-
(this._player.currentPanorama.cameraConfig.floor_vertical_position -
|
|
192
|
-
this._player.raycaster.ray.origin.y) /
|
|
193
|
-
this._player.raycaster.ray.direction.y
|
|
194
|
-
this._player.mouseFloorHitpoint.set(
|
|
195
|
-
this._player.raycaster.ray.origin.x +
|
|
196
|
-
this._player.raycaster.ray.direction.x * t,
|
|
197
|
-
this._player.raycaster.ray.origin.y +
|
|
198
|
-
this._player.raycaster.ray.direction.y * t,
|
|
199
|
-
this._player.raycaster.ray.origin.z +
|
|
200
|
-
this._player.raycaster.ray.direction.z * t
|
|
201
|
-
)
|
|
202
|
-
|
|
203
|
-
// Handle arrow
|
|
204
|
-
if (this._player.arrowMesh) {
|
|
205
|
-
this._player.arrowMesh.position.set(
|
|
206
|
-
this._player.mouseFloorHitpoint.x,
|
|
207
|
-
this._player.mouseFloorHitpoint.y + 0.04,
|
|
208
|
-
this._player.mouseFloorHitpoint.z
|
|
209
|
-
)
|
|
210
|
-
|
|
211
|
-
const deltaZ =
|
|
212
|
-
this._player.arrowMesh.position.z -
|
|
213
|
-
this._player.currentPanorama.cameraConfig.position.z
|
|
214
|
-
const deltaX =
|
|
215
|
-
this._player.arrowMesh.position.x -
|
|
216
|
-
this._player.currentPanorama.cameraConfig.position.x
|
|
217
|
-
this._player.arrowMesh.rotation.z =
|
|
218
|
-
-Math.atan2(deltaZ, deltaX) - Math.PI / 2
|
|
219
|
-
|
|
220
|
-
this._player.arrowMesh.visible =
|
|
221
|
-
!this._player.isUserInteracting &&
|
|
222
|
-
!this._player.isLoadingPanorama &&
|
|
223
|
-
!this._player.isTransition
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
onMouseUp() {
|
|
228
|
-
this._player.isMouseDown = false
|
|
229
|
-
if (!this._player.isMouseMoved && !this._player.isTransition)
|
|
230
|
-
this.onMouseClick()
|
|
231
|
-
this._player.isUserInteracting = false
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
onMouseClick() {
|
|
235
|
-
const camera = this._player.apartmentConfig.findClosestVisibleCamera(
|
|
236
|
-
this._player.mouseFloorHitpoint,
|
|
237
|
-
null
|
|
238
|
-
)
|
|
239
|
-
if (camera && camera != this._player.currentPanorama.cameraConfig) {
|
|
240
|
-
this._player.loadPanorama(
|
|
241
|
-
camera.cameraID,
|
|
242
|
-
this._player.onPanoramaLoaded,
|
|
243
|
-
false
|
|
244
|
-
)
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
debugDepth(pointsTotal = 1000) {
|
|
249
|
-
for (let n = 0; n < pointsTotal; n++) {
|
|
250
|
-
const ray = new THREE.Vector3(
|
|
251
|
-
Math.random() * 2 - 1,
|
|
252
|
-
Math.random() * 2 - 1,
|
|
253
|
-
Math.random() * 2 - 1
|
|
254
|
-
)
|
|
255
|
-
|
|
256
|
-
ray.normalize()
|
|
257
|
-
|
|
258
|
-
const d = this._player.currentPanorama.getDepth(ray.x, ray.y, ray.z)
|
|
259
|
-
|
|
260
|
-
let gray = d * 0.1
|
|
261
|
-
|
|
262
|
-
if (gray > 1) gray = 1
|
|
263
|
-
|
|
264
|
-
if (gray < 0) gray = 0
|
|
265
|
-
|
|
266
|
-
gray = 1 - gray
|
|
267
|
-
|
|
268
|
-
const col = new THREE.Color(gray, gray, gray)
|
|
269
|
-
|
|
270
|
-
const geometry = new THREE.BoxGeometry(0.005, 0.005, 0.005)
|
|
271
|
-
const material = new THREE.MeshBasicMaterial({
|
|
272
|
-
color: col,
|
|
273
|
-
opacity: 0.2,
|
|
274
|
-
transparent: true,
|
|
275
|
-
})
|
|
276
|
-
|
|
277
|
-
const cube = new THREE.Mesh(geometry, material)
|
|
278
|
-
|
|
279
|
-
const x = this._player.currentPanorama.cameraConfig.position.x + ray.x * d
|
|
280
|
-
const y = this._player.currentPanorama.cameraConfig.position.y + ray.y * d
|
|
281
|
-
const z = this._player.currentPanorama.cameraConfig.position.z + ray.z * d
|
|
282
|
-
|
|
283
|
-
cube.position.set(x, y, z)
|
|
284
|
-
this._player.scene.add(cube)
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
isNumpadMoveKey(event) {
|
|
289
|
-
if (event.location === DOM_KEY_LOCATION_NUMPAD) {
|
|
290
|
-
if (NUMPAD_KEYS.includes(event.key || event.code)) {
|
|
291
|
-
return true
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
return false
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
debugCameraMovement(key, camera, amount = 0.1) {
|
|
298
|
-
switch (key) {
|
|
299
|
-
case 'ArrowUp':
|
|
300
|
-
camera.translateZ(-amount)
|
|
301
|
-
break
|
|
302
|
-
case 'ArrowDown':
|
|
303
|
-
camera.translateZ(amount)
|
|
304
|
-
break
|
|
305
|
-
case 'ArrowLeft':
|
|
306
|
-
camera.translateX(-amount)
|
|
307
|
-
break
|
|
308
|
-
case 'ArrowRight':
|
|
309
|
-
camera.translateX(amount)
|
|
310
|
-
break
|
|
311
|
-
case 'PageUp':
|
|
312
|
-
camera.translateY(amount)
|
|
313
|
-
break
|
|
314
|
-
case 'Home':
|
|
315
|
-
camera.translateY(-amount)
|
|
316
|
-
break
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
onKeyDown(event) {
|
|
321
|
-
if (this._player.isLoadingPanorama || this._player.isTransition) return
|
|
322
|
-
let dx = 0
|
|
323
|
-
let dz = 0
|
|
324
|
-
|
|
325
|
-
const key = event.key || event.code
|
|
326
|
-
|
|
327
|
-
if (window._debug && this.isNumpadMoveKey(event)) {
|
|
328
|
-
this.debugCameraMovement(key, this._player.camera)
|
|
329
|
-
return
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
switch (key) {
|
|
333
|
-
case 'a':
|
|
334
|
-
case 'A':
|
|
335
|
-
case 'KeyA':
|
|
336
|
-
case 'ArrowLeft':
|
|
337
|
-
dx = -1
|
|
338
|
-
break
|
|
339
|
-
case 'd':
|
|
340
|
-
case 'D':
|
|
341
|
-
case 'KeyD':
|
|
342
|
-
case 'ArrowRight':
|
|
343
|
-
dx = 1
|
|
344
|
-
break
|
|
345
|
-
case 'w':
|
|
346
|
-
case 'W':
|
|
347
|
-
case 'KeyW':
|
|
348
|
-
case 'ArrowUp':
|
|
349
|
-
dz = 1
|
|
350
|
-
break
|
|
351
|
-
case 's':
|
|
352
|
-
case 'S':
|
|
353
|
-
case 'KeyS':
|
|
354
|
-
case 'ArrowDown':
|
|
355
|
-
dz = -1
|
|
356
|
-
break
|
|
357
|
-
case 'q':
|
|
358
|
-
window._debug && this.debugDepth()
|
|
359
|
-
break
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
const v = new THREE.Vector3()
|
|
363
|
-
if (dz != 0 || dx != 0) {
|
|
364
|
-
v.y = 0
|
|
365
|
-
v.normalize()
|
|
366
|
-
|
|
367
|
-
this._player.camera.getWorldDirection(v)
|
|
368
|
-
|
|
369
|
-
if (dx != 0) {
|
|
370
|
-
dz = dx
|
|
371
|
-
const swap = v.x
|
|
372
|
-
v.x = -v.z
|
|
373
|
-
v.z = swap
|
|
374
|
-
}
|
|
375
|
-
const c =
|
|
376
|
-
this._player.apartmentConfig.findClosestVisibleCameraInDirection(
|
|
377
|
-
v.x * dz,
|
|
378
|
-
v.z * dz,
|
|
379
|
-
v,
|
|
380
|
-
this._player.currentPanorama
|
|
381
|
-
)
|
|
382
|
-
|
|
383
|
-
if (c) {
|
|
384
|
-
this._player.loadPanorama(
|
|
385
|
-
c.cameraID,
|
|
386
|
-
this._player.onPanoramaLoaded,
|
|
387
|
-
false
|
|
388
|
-
)
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
export { Interaction }
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
// We load three.min.js in index.html instead because importing it here gives error in IE11,
|
|
3
|
-
// using global commen instead
|
|
4
|
-
|
|
5
|
-
import * as THREE from 'three'
|
|
6
|
-
class Panorama {
|
|
7
|
-
constructor(texture, rawDepth, cameraConfig, version) {
|
|
8
|
-
texture.wrapS = THREE.RepeatWrapping
|
|
9
|
-
texture.wrapT = THREE.RepeatWrapping
|
|
10
|
-
this._texture = texture
|
|
11
|
-
this._version = version
|
|
12
|
-
|
|
13
|
-
console.log('QiSpace data version: ' + this._version)
|
|
14
|
-
if (this._version > 1.0) {
|
|
15
|
-
texture.repeat.set(-1, 1)
|
|
16
|
-
texture.offset.set(0.25, 0)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
this._cameraConfig = cameraConfig
|
|
20
|
-
this._depth = new Float32Array(512 * 256)
|
|
21
|
-
let o = 4 // Skip 4 bytes header
|
|
22
|
-
for (let i = 0; i < this._depth.byteLength; i++)
|
|
23
|
-
this._depth[i] = (rawDepth[o++] | (rawDepth[o++] << 8)) / 512 // 512 samples per meter, max 128 meter
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
get texture() {
|
|
27
|
-
return this._texture
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
get depth() {
|
|
31
|
-
return this._depth
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
get cameraConfig() {
|
|
35
|
-
return this._cameraConfig
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Assumes the ray is cast from the middle of the panorama sphere
|
|
39
|
-
getDepth(rayX, rayY, rayZ) {
|
|
40
|
-
// Normalize
|
|
41
|
-
const length = Math.sqrt(rayX * rayX + rayY * rayY + rayZ * rayZ)
|
|
42
|
-
if (length > 0) {
|
|
43
|
-
rayX /= length
|
|
44
|
-
rayY /= length
|
|
45
|
-
rayZ /= length
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Invert
|
|
49
|
-
rayX *= -1
|
|
50
|
-
rayY *= -1
|
|
51
|
-
rayZ *= -1
|
|
52
|
-
|
|
53
|
-
const u = (Math.atan2(rayX, rayZ) / (2 * Math.PI) + 0.75) % 1
|
|
54
|
-
const v = 0.5 - Math.asin(rayY) / Math.PI
|
|
55
|
-
|
|
56
|
-
return this.getDepthTexture(u, v)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
getDepthTexture(u, v) {
|
|
60
|
-
if (this._version > 1.0) {
|
|
61
|
-
//2.0+ format
|
|
62
|
-
u = -u + 0.25
|
|
63
|
-
const i = parseInt(u * 511) & 0x1ff
|
|
64
|
-
const j = parseInt(v * 255) & 0xff
|
|
65
|
-
return this._depth[i + j * 512]
|
|
66
|
-
} else {
|
|
67
|
-
//Legacy format
|
|
68
|
-
const i = parseInt(u * 511) & 0x1ff
|
|
69
|
-
const j = parseInt(v * 255) & 0xff
|
|
70
|
-
return this._depth[i + j * 512]
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
dispose() {
|
|
75
|
-
this._texture.dispose()
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
export { Panorama }
|