@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.
Files changed (88) hide show
  1. package/dist/components/apartmentChooser/QiApartmentChooser.vue.d.ts +471 -3
  2. package/dist/components/apartmentChooser/QiApartmentChooserNavigation.vue.d.ts +50 -3
  3. package/dist/components/apartmentChooser/QiApartmentChooserRaster.vue.d.ts +151 -3
  4. package/dist/components/apartmentChooser/QiApartmentChooserRotator.vue.d.ts +66 -3
  5. package/dist/components/apartmentChooser/QiApartmentChooserSvg.vue.d.ts +124 -3
  6. package/dist/components/buildingPicker/QiBuildingChooser.vue.d.ts +425 -2
  7. package/dist/components/buildingPicker/QiBuildingChooserRaster.vue.d.ts +154 -3
  8. package/dist/components/buildingPicker/QiBuildingChooserRasterOverlay.vue.d.ts +53 -3
  9. package/dist/components/buildingPicker/QiBuildingChooserSceneImageStack.vue.d.ts +32 -3
  10. package/dist/components/buildingPicker/QiBuildingChooserSunSimControl.vue.d.ts +41 -4
  11. package/dist/components/buildingPicker/QiBuildingChooserSvg.vue.d.ts +156 -3
  12. package/dist/components/shared/QiFloatingCard.vue.d.ts +17 -3
  13. package/dist/components/shared/QiHoverProbe.vue.d.ts +3 -3
  14. package/dist/components/shared/QiNorthDirection.vue.d.ts +20 -2
  15. package/dist/components/shared/QiZoomBox.vue.d.ts +82 -3
  16. package/dist/components/virtualTourV2/Disclaimer.vue.d.ts +3 -3
  17. package/dist/components/virtualTourV2/FullScreenButton.vue.d.ts +13 -2
  18. package/dist/components/virtualTourV2/ManualSlideShow.vue.d.ts +72 -3
  19. package/dist/components/virtualTourV2/ManualSlideShowPlayer.vue.d.ts +14 -3
  20. package/dist/components/virtualTourV2/SingleImage.vue.d.ts +25 -3
  21. package/dist/components/virtualTourV2/SocialShare.vue.d.ts +9 -3
  22. package/dist/components/virtualTourV2/WaypointCarousel.vue.d.ts +30 -3
  23. package/dist/entry.css +1 -0
  24. package/dist/{vue3-player.esm.js → vue3-player.mjs} +647 -581
  25. package/dist/vue3-player.umd.js +2 -3
  26. package/package.json +12 -10
  27. package/dist/components/apartmentChooser/QiApartmentChooser.vue.d.ts.map +0 -1
  28. package/dist/components/apartmentChooser/QiApartmentChooserNavigation.vue.d.ts.map +0 -1
  29. package/dist/components/apartmentChooser/QiApartmentChooserRaster.vue.d.ts.map +0 -1
  30. package/dist/components/apartmentChooser/QiApartmentChooserRotator.vue.d.ts.map +0 -1
  31. package/dist/components/apartmentChooser/QiApartmentChooserSvg.vue.d.ts.map +0 -1
  32. package/dist/components/buildingPicker/QiBuildingChooser.vue.d.ts.map +0 -1
  33. package/dist/components/buildingPicker/QiBuildingChooserRaster.vue.d.ts.map +0 -1
  34. package/dist/components/buildingPicker/QiBuildingChooserRasterOverlay.vue.d.ts.map +0 -1
  35. package/dist/components/buildingPicker/QiBuildingChooserSceneImageStack.vue.d.ts.map +0 -1
  36. package/dist/components/buildingPicker/QiBuildingChooserSunSimControl.vue.d.ts.map +0 -1
  37. package/dist/components/buildingPicker/QiBuildingChooserSvg.vue.d.ts.map +0 -1
  38. package/dist/components/shared/QiFloatingCard.vue.d.ts.map +0 -1
  39. package/dist/components/shared/QiHoverProbe.vue.d.ts.map +0 -1
  40. package/dist/components/shared/QiNorthDirection.vue.d.ts.map +0 -1
  41. package/dist/components/shared/QiZoomBox.vue.d.ts.map +0 -1
  42. package/dist/components/virtualTourV2/Disclaimer.vue.d.ts.map +0 -1
  43. package/dist/components/virtualTourV2/FullScreenButton.vue.d.ts.map +0 -1
  44. package/dist/components/virtualTourV2/ManualSlideShow.vue.d.ts.map +0 -1
  45. package/dist/components/virtualTourV2/ManualSlideShowPlayer.vue.d.ts.map +0 -1
  46. package/dist/components/virtualTourV2/SingleImage.vue.d.ts.map +0 -1
  47. package/dist/components/virtualTourV2/SocialShare.vue.d.ts.map +0 -1
  48. package/dist/components/virtualTourV2/WaypointCarousel.vue.d.ts.map +0 -1
  49. package/dist/lib/virtualTour__/ApartmentConfig.d.ts +0 -27
  50. package/dist/lib/virtualTour__/ApartmentFiles.d.ts +0 -7
  51. package/dist/lib/virtualTour__/MinimapConfig.d.ts +0 -23
  52. package/dist/lib/virtualTour__/impl/HttpApartmentFiles.d.ts +0 -19
  53. package/dist/vue3-player.cjs.js +0 -2
  54. package/dist/vue3-player.iife.js +0 -3
  55. package/src/entry.esm.js +0 -17
  56. package/src/entry.js +0 -13
  57. package/src/entry.ts_ +0 -17
  58. package/src/lib/virtualTour__/ApartmentConfig.ts +0 -80
  59. package/src/lib/virtualTour__/ApartmentFiles.ts +0 -8
  60. package/src/lib/virtualTour__/CameraNavigator.js_ +0 -74
  61. package/src/lib/virtualTour__/CameraSnapshot.js +0 -42
  62. package/src/lib/virtualTour__/CoordConversions.js +0 -43
  63. package/src/lib/virtualTour__/FullscreenModel.js +0 -69
  64. package/src/lib/virtualTour__/MinimapConfig.ts +0 -46
  65. package/src/lib/virtualTour__/PlayerViewModel.js +0 -423
  66. package/src/lib/virtualTour__/config/ApartmentConfig.js +0 -92
  67. package/src/lib/virtualTour__/config/CameraConfig.js +0 -97
  68. package/src/lib/virtualTour__/config/Interaction.js +0 -393
  69. package/src/lib/virtualTour__/config/Panorama.js +0 -78
  70. package/src/lib/virtualTour__/config/PlayerConfig.js +0 -812
  71. package/src/lib/virtualTour__/config/rawinflate.export.js +0 -833
  72. package/src/lib/virtualTour__/config/shaders.js +0 -24
  73. package/src/lib/virtualTour__/impl/HttpApartmentFiles.ts +0 -57
  74. package/src/lib/virtualTour__/index.js +0 -1
  75. package/src/lib/virtualTour__/textures/arrow.png +0 -0
  76. package/src/lib/virtualTour__/textures/compass-bg.png +0 -0
  77. package/src/lib/virtualTour__/textures/compass-needle.png +0 -0
  78. package/src/lib/virtualTour__/textures/compass-north.png +0 -0
  79. package/src/lib/virtualTour__/textures/floor-1.svg +0 -4
  80. package/src/lib/virtualTour__/textures/floor-2.svg +0 -4
  81. package/src/lib/virtualTour__/textures/marker.png +0 -0
  82. package/src/lib/virtualTour__/textures/tod-sun.png +0 -0
  83. package/src/main.ts_ +0 -24
  84. package/src/shims-png.d.ts +0 -4
  85. package/src/shims-tsx.d.ts +0 -11
  86. package/src/shims-vue.d.ts +0 -4
  87. package/src/style.css +0 -0
  88. package/src/vite-env.d.ts +0 -5
@@ -1,46 +0,0 @@
1
- import { ProjectFiles, ProjectFile } from './ApartmentFiles'
2
-
3
-
4
- export interface Coordinate3D{
5
- x: number,
6
- y: number,
7
- z: number
8
- }
9
-
10
- export interface MinimapStorey {
11
- sunsimFilesTimeStamps: string[],
12
- sunsimFiles: string[],
13
- fovY: number,
14
- rotation: Coordinate3D,
15
- position: Coordinate3D,
16
- }
17
- export interface MinimapMetadata {
18
- storeys: MinimapStorey[]
19
- }
20
-
21
- export class MinimapConfig {
22
- constructor(private readonly apartmentFiles: ProjectFiles) {}
23
-
24
- async getMinimapData(): Promise<Object | undefined> {
25
- const metadata = await this.readMinimapMetadata()
26
- if (!metadata) return undefined
27
-
28
- const fileNames = metadata.storeys[0].sunsimFiles
29
- const files = fileNames.map((name) => this.constructMinimapFile(name).toPath())
30
-
31
- // TODO: for DUPLEX this will be different
32
- const minimapData = metadata.storeys[0]
33
-
34
- return {...minimapData, sunsimFiles: files }
35
- }
36
-
37
- private async readMinimapMetadata(): Promise<MinimapMetadata | undefined> {
38
- const metadataFile = this.constructMinimapFile('minimap.json')
39
- const metadata = await metadataFile.readJson<MinimapMetadata>()
40
- return metadata
41
- }
42
-
43
- private constructMinimapFile(filename: string): ProjectFile {
44
- return this.apartmentFiles.makeFile('minimap', filename)
45
- }
46
- }
@@ -1,423 +0,0 @@
1
- import Vue from 'vue'
2
- import axios from 'axios'
3
- import PlayerConfig from './config/PlayerConfig'
4
- import { CameraNavigator } from './CameraNavigator'
5
-
6
- export const ViewModeVirtualTour = 'virtualTour'
7
- export const ViewModeSlideShow = 'slideShow'
8
- export const ViewModeManualSlideShow = 'manualSlideShow'
9
-
10
- function parseTimeOfDay(floatValue) {
11
- if (floatValue === undefined) return null
12
-
13
- const hours = Math.floor(floatValue)
14
- const minutes = Math.floor((hours - floatValue) * 60)
15
- return { hours, minutes }
16
- }
17
-
18
- function getFirstCameraId(cameras) {
19
- const camera = cameras && cameras[0]
20
- return camera ? camera.id : undefined
21
- }
22
-
23
- function getAvailableViewModesFromUnitViewMode(unitViewMode) {
24
- switch (unitViewMode) {
25
- case 'slideShowOnly':
26
- return [ViewModeSlideShow]
27
- case 'virtualTourOnly':
28
- return [ViewModeVirtualTour]
29
- case 'virtualTourAndSlideShowDefaultVirtualTour':
30
- case 'virtualTourAndSlideShowDefaultSlideShow':
31
- return [ViewModeVirtualTour, ViewModeSlideShow]
32
- case 'manualSlideShow':
33
- return [ViewModeManualSlideShow]
34
- default:
35
- console.error('cannot initialize player without viewModes')
36
- }
37
- }
38
-
39
- function getInitialViewModeFromUnitViewMode(unitViewMode) {
40
- switch (unitViewMode) {
41
- case 'slideShowOnly':
42
- case 'virtualTourAndSlideShowDefaultSlideShow':
43
- return ViewModeSlideShow
44
- case 'virtualTourAndSlideShowDefaultVirtualTour':
45
- case 'virtualTourOnly':
46
- return ViewModeVirtualTour
47
- case 'manualSlideShow':
48
- return ViewModeManualSlideShow
49
- default:
50
- console.error('cannot initialize player without viewModes')
51
- }
52
- }
53
-
54
- export default class PlayerViewModel {
55
- static makeCdnModel(modelParams) {
56
- return new CdnPlayerViewModel(modelParams)
57
- }
58
-
59
- constructor(initData) {
60
- this._state = Vue.observable({
61
- _initialized: false,
62
- _viewMode: getInitialViewModeFromUnitViewMode(initData.unitViewMode),
63
- _availableViewModes: getAvailableViewModesFromUnitViewMode(
64
- initData.unitViewMode
65
- ),
66
- _selectedArchetypeIndex: initData.selectedArchetypeIndex || 0,
67
- _cameras: [],
68
- _timeOfDay: initData.timeOfDay,
69
- _archetypes: initData.archetypes || [],
70
- _cameraSnapshot: {
71
- requested: null,
72
- latest: null,
73
- },
74
- _panoramaOrientation: { lat: 0.0, lon: 0.0 },
75
- adminMode: initData.adminMode || false,
76
- })
77
- this._navigator = new CameraNavigator()
78
-
79
- this._cdnFileResolver =
80
- typeof initData.cdnFileResolver === 'string'
81
- ? (name) => initData.cdnFileResolver + name
82
- : initData.cdnFileResolver
83
- this._apartmentId = initData.apartmentId
84
- this._websiteUrl = initData.websiteUrl
85
- this._unitViewMode = initData.unitViewMode
86
-
87
- this._manualSlideshowImages = initData.manualSlideshowImages
88
-
89
- this._addBuildVersionToUrls = initData.addBuildVersionToUrls
90
- this._showCompass = !!initData.showCompass
91
- this._showMiniMap = initData.showMiniMap
92
- this._onInformationButtonPress = initData.onInformationButtonPress
93
- this._mouseSensitivityFactor = initData.mouseSensitivity ? initData.mouseSensitivity : 1
94
-
95
- this._initData = undefined
96
- }
97
-
98
- takeCameraSnapshot() {
99
- this._state._cameraSnapshot.requested = new Date()
100
- }
101
-
102
- async initializeData({ initialArchetypeId, initialWaypointIndex } = {}) {
103
- if (this._state._viewMode === ViewModeManualSlideShow) {
104
- this._initData = this._manualSlideshowImages
105
- this._state._timeOfDay = undefined
106
- this._state._cameras = this._manualSlideshowImages
107
-
108
- this._navigator.initialize(
109
- this._manualSlideshowImages,
110
- getFirstCameraId(this._manualSlideshowImages),
111
- 0
112
- )
113
- } else {
114
- if (this.archetypes.length === 0) {
115
- await this._loadArchetypesFromConfig(initialArchetypeId)
116
- } else if (initialArchetypeId) {
117
- let index = this.archetypes.findIndex(
118
- ({ id }) => id === initialArchetypeId
119
- )
120
- if (index < 0) {
121
- index = 0
122
- }
123
- this.selectArchetypeByIndex(index)
124
- }
125
-
126
- this._state._archetypes = await this._loadMinimaps()
127
-
128
- // TODO: With Ulven project, apartment.json is an empty stub file
129
- // The code needs to be ready for such a situation
130
- const apartments = (
131
- await axios.get(this.resolveApartmentFile('apartment.json'))
132
- ).data
133
- const thumbs = (await axios.get(this.resolveApartmentFile('thumbs.json')))
134
- .data
135
-
136
- this._initData = apartments
137
- this._state._timeOfDay = parseTimeOfDay(apartments.timeInHours)
138
- this._state._cameras = apartments.cameras
139
-
140
- this._navigator.initialize(
141
- thumbs.cameras,
142
- getFirstCameraId(apartments.cameras),
143
- initialWaypointIndex
144
- )
145
- }
146
-
147
- this._state._initialized = true
148
- }
149
-
150
- async _loadArchetypesFromConfig(initialArchetypeId) {
151
- const projectConfig = (await axios.get(this.getFilename('/config.json')))
152
- .data
153
-
154
- this._state._archetypes = projectConfig.archetypes.map(
155
- ({ description, archetypeID, title, enabled }) => {
156
- return {
157
- id: archetypeID,
158
- description,
159
- label: title || archetypeID,
160
- enabled,
161
- }
162
- }
163
- )
164
-
165
- let index = this.archetypes.findIndex(
166
- ({ id }) =>
167
- id ===
168
- (initialArchetypeId
169
- ? initialArchetypeId
170
- : projectConfig.defaultArchetypeID)
171
- )
172
- if (index < 0) {
173
- index = 0
174
- }
175
- this.selectArchetypeByIndex(index)
176
- }
177
-
178
- async _loadMinimaps() {
179
- return Promise.all(
180
- this.archetypes.map(async (a) => {
181
- try {
182
- const metadata = (
183
- await axios.get(this.resolveApartmentFile('/minimap/minimap.json'))
184
- ).data
185
-
186
-
187
- let sunsimFilesByStorey = metadata.storeys.map((item) => { return item.sunsimFiles })
188
-
189
- let sunsimFiles = []
190
-
191
- for (let index = 0; index < sunsimFilesByStorey.length; index++) {
192
- const element = sunsimFilesByStorey[index];
193
- const fileUrls = element.map(name => this.resolveApartmentFile(`/minimap/${name}`))
194
- sunsimFiles = [...sunsimFiles, fileUrls]
195
- }
196
-
197
- const minimapData = { data: metadata.storeys, sunsimFiles }
198
- return { ...a, minimapData }
199
- } catch {
200
- return a
201
- }
202
- })
203
- )
204
- }
205
-
206
- startPlayer(domElement, onStartedCb) {
207
- const player = new PlayerConfig({
208
- target: domElement,
209
- addBuildVersionToUrls: this._addBuildVersionToUrls,
210
- fileResolver: (name) => this.resolveApartmentFile(name),
211
- onPlayerCameraChanged: (cameraID) => this.playerCameraChangedTo(cameraID),
212
- panoramaOrientation: this._state._panoramaOrientation,
213
- mouseSensitivityFactor: this._mouseSensitivityFactor
214
- })
215
-
216
- player.start(this._initData, this.getStartCameraId(), onStartedCb)
217
- return player
218
- }
219
-
220
- playerCameraChangedTo(cameraId) {
221
- this._navigator.selectedCameraId = cameraId
222
- }
223
-
224
- selectArchetypeByIndex(index) {
225
- this._state._selectedArchetypeIndex = index
226
- }
227
-
228
- get isInitialized() {
229
- return this._state._initialized
230
- }
231
-
232
- get viewMode() {
233
- return this._state._viewMode
234
- }
235
-
236
- get availableViewModes() {
237
- return this._state._availableViewModes
238
- }
239
-
240
- get isViewModeVirtualTour() {
241
- return this._state._viewMode === ViewModeVirtualTour
242
- }
243
-
244
- get isViewModeSlideShow() {
245
- return this._state._viewMode === ViewModeSlideShow
246
- }
247
-
248
- nextViewMode() {
249
- if (this._state._availableViewModes.length > 1) {
250
- const currentIndex = this._state._availableViewModes.findIndex(
251
- (m) => m === this._state._viewMode
252
- )
253
- if (currentIndex === this._state._availableViewModes.length - 1) {
254
- this._state._viewMode = this._state._availableViewModes[0]
255
- } else {
256
- this._state._viewMode =
257
- this._state._availableViewModes[currentIndex + 1]
258
- }
259
- }
260
- }
261
-
262
- getStartCameraId() {
263
- if (this._navigator.selectedCameraId)
264
- return this._navigator.selectedCameraId
265
- else throw new Error('Unable to detect a starting camera for virtual tour')
266
- }
267
-
268
- resolveCdnApartment() {
269
- return `/${this.archetypeId}/${this.apartmentId}`
270
- }
271
-
272
- getFilename(name) {
273
-
274
- if (this._state.adminMode) {
275
- return this._cdnFileResolver(name) + `?v=${Date.now()}`
276
- }
277
-
278
- return this._cdnFileResolver(name)
279
-
280
-
281
- }
282
-
283
- resolveApartmentFile(name) {
284
- if (!name.startsWith('/')) {
285
- name = '/' + name
286
- }
287
- return this.getFilename(this.resolveCdnApartment() + name)
288
- }
289
-
290
- get apartmentId() {
291
- return this._apartmentId
292
- }
293
-
294
- get archetype() {
295
- const archetype = this.archetypes
296
- ? this.archetypes[this._state._selectedArchetypeIndex]
297
- : undefined
298
- return archetype
299
- }
300
-
301
- get minimapData() {
302
- return this.archetype && this.archetype.minimapData
303
- }
304
-
305
- get archetypeId() {
306
- const archetype = this.archetypes
307
- ? this.archetypes[this._state._selectedArchetypeIndex]
308
- : undefined
309
- return archetype && archetype.id
310
- }
311
-
312
- get selectedArchetypeIndex() {
313
- return this._state._selectedArchetypeIndex
314
- }
315
-
316
- get websiteUrl() {
317
- return this._websiteUrl
318
- }
319
-
320
- get archetypes() {
321
- return this._state._archetypes
322
- }
323
-
324
- get thumbnails() {
325
- if (this._state._viewMode === ViewModeManualSlideShow) {
326
- return this._manualSlideshowImages
327
- }
328
-
329
- return this._navigator.waypoints.map((thumb) => ({
330
- id: thumb.id,
331
- url: this.getWaypointThumbnailUrl(this.archetypeId, thumb.id),
332
- }))
333
- }
334
-
335
- getWaypointThumbnailUrl(interiorId, cameraId) {
336
- return this.getFilename(
337
- `/${interiorId}/${this.apartmentId}/thumbs/200/${cameraId}.jpg`
338
- )
339
- }
340
-
341
- get selectedWaypointImageUrl() {
342
- const selectedWaypoint = this._navigator.selectedWaypoint
343
-
344
- if (this._state._viewMode === ViewModeManualSlideShow && selectedWaypoint) {
345
- return selectedWaypoint.url
346
- }
347
-
348
- return selectedWaypoint
349
- ? this.getFilename(
350
- `/${this.archetypeId}/${this.apartmentId}/images/1280/${selectedWaypoint.id}.jpg`
351
- )
352
- : undefined
353
- }
354
-
355
- get panoramaOrientation() {
356
- return this._state._panoramaOrientation
357
- }
358
-
359
- get cameraSnapshot() {
360
- return this._state._cameraSnapshot.latest
361
- }
362
-
363
- set cameraSnapshot(value) {
364
- this._state._cameraSnapshot.latest = value
365
- }
366
-
367
- get cameraSnapshotRequested() {
368
- return this._state._cameraSnapshot.requested
369
- }
370
-
371
- get allCameras() {
372
- return this._state._cameras
373
- }
374
-
375
- get showCompass() {
376
- return this._showCompass
377
- }
378
-
379
- get showMiniMap() {
380
- return this._showMiniMap
381
- }
382
-
383
- get waypointNavigator() {
384
- return this._navigator
385
- }
386
-
387
- get timeOfDay() {
388
- return this._state._timeOfDay
389
- }
390
-
391
- get hasInformationButtonCallback() {
392
- return !!this._onInformationButtonPress
393
- }
394
-
395
- get onInformationButtonPress() {
396
- return this._onInformationButtonPress
397
- }
398
- }
399
-
400
- class CdnPlayerViewModel extends PlayerViewModel {
401
- constructor(modelParams) {
402
- super({
403
- ...modelParams,
404
- cdnFileResolver: (name) => modelParams.cdnRoot + name,
405
- })
406
- this._cdnRoot = modelParams.cdnRoot
407
- }
408
-
409
- dehydrate() {
410
- return {
411
- cdnRoot: this._cdnRoot,
412
- apartmentId: this._apartmentId,
413
- archetypes: this._state._archetypes,
414
- selectedArchetypeIndex: this._state._selectedArchetypeIndex,
415
- websiteUrl: this._websiteUrl,
416
- unitViewMode: this._unitViewMode,
417
- showCompass: this._showCompass,
418
- showMiniMap: this._showMiniMap,
419
- timeOfDay: this._timeOfDay,
420
- onInformationButtonPress: this._onInformationButtonPress,
421
- }
422
- }
423
- }
@@ -1,92 +0,0 @@
1
- /* eslint-disable */
2
-
3
- import { CameraConfig } from './CameraConfig'
4
-
5
- class ApartmentConfig {
6
- constructor(json, scene) {
7
- this._cameras = {}
8
- this._apartmentID = json.id
9
- this._version = json.version
10
- for (let i = 0; i < json.cameras.length; i++) {
11
- const camera = json.cameras[i]
12
- this._cameras[camera.id.toUpperCase()] = new CameraConfig(
13
- camera.id,
14
- camera,
15
- scene
16
- )
17
- }
18
- }
19
-
20
- get apartmentID() {
21
- return this._apartmentID
22
- }
23
-
24
- get cameras() {
25
- return this._cameras
26
- }
27
-
28
- findClosestVisibleCamera(point, ignoreCamera) {
29
- let closestCamera = null
30
- let minDistance = 10000
31
- for (const key in this._cameras) {
32
- const c = this._cameras[key]
33
- if (c.isVisible && c != ignoreCamera) {
34
- const dx = c.position.x - point.x
35
- const dz = c.position.z - point.z
36
- const distance = Math.sqrt(dx * dx + dz * dz)
37
- if (distance < minDistance) {
38
- minDistance = distance
39
- closestCamera = c
40
- }
41
- }
42
- }
43
- return closestCamera
44
- }
45
-
46
- findClosestVisibleCameraInDirection(dx, dz, v, currentPanorama) {
47
- for (let dist = 0; dist < 10; dist += 0.1) {
48
- v.x = currentPanorama.cameraConfig.position.x + dx * dist
49
- v.y = currentPanorama.cameraConfig.position.y
50
- v.z = currentPanorama.cameraConfig.position.z + dz * dist
51
- const c = this.findClosestVisibleCamera(v, null)
52
- if (c != currentPanorama.cameraConfig) return c
53
- }
54
- return null
55
- }
56
-
57
- updateVisible(panorama) {
58
- for (const key in this._cameras) {
59
- // Check if something is in front of the given camera (at camera level), in that case it is invisible
60
- const c = this._cameras[key]
61
- var dx = c.position.x - panorama.cameraConfig.position.x
62
- var dy = c.position.y - panorama.cameraConfig.position.y
63
- var dz = c.position.z - panorama.cameraConfig.position.z
64
- var distance = Math.sqrt(dx * dx + dy * dy + dz * dz)
65
- c.isVisible = panorama.getDepth(dx, dy, dz) > distance
66
- c.mesh.visible = c.isVisible
67
-
68
- // Check if the visible camera positions are obstructed at slightly above ground level
69
- if (c.isVisible) {
70
- var dx = c.position.x - panorama.cameraConfig.position.x
71
- const floorOffset = c._floor_vertical_position + 0.2
72
- var dy = floorOffset - panorama.cameraConfig.position.y
73
- var dz = c.position.z - panorama.cameraConfig.position.z
74
- var distance = Math.sqrt(dx * dx + dy * dy + dz * dz)
75
- c.isObstructed = panorama.getDepth(dx, dy, dz) <= distance
76
- }
77
- }
78
- }
79
-
80
- animateMarkers(panorama, elapsedTime) {
81
- if (!panorama) return false
82
- for (const key in this._cameras) {
83
- const c = this._cameras[key]
84
- const dist = c.position.distanceTo(panorama.cameraConfig.position)
85
- const baseOpacityModifier = c.isObstructed ? 0.1 : 0.2
86
- c.mesh.material.opacity =
87
- (Math.sin(-elapsedTime * 3 + dist * 0.5) + 1) *
88
- baseOpacityModifier
89
- }
90
- }
91
- }
92
- export { ApartmentConfig }
@@ -1,97 +0,0 @@
1
- /* eslint-disable */
2
- import * as THREE from 'three'
3
- import markerTexture from '../textures/marker.png'
4
- import { stringToVector3ConvertPositionFromUnity, stringToVector3ConvertRotationFromUnity } from '../CoordConversions'
5
-
6
- function stringToVector3(str) {
7
- const split = str.split(',', 3)
8
- const v = new THREE.Vector3(
9
- parseFloat(split[0]),
10
- parseFloat(split[1]),
11
- parseFloat(split[2])
12
- )
13
- return v
14
- }
15
-
16
- function stringToVector3ConvertPositionFromBlender(str) {
17
- const split = str.split(',', 3)
18
- const v = new THREE.Vector3(
19
- -parseFloat(split[0]),
20
- parseFloat(split[2]),
21
- parseFloat(split[1])
22
- )
23
- return v
24
- }
25
-
26
- class CameraConfig {
27
- constructor(
28
- cameraID,
29
- camera,
30
- scene
31
- ) {
32
- this._cameraID = cameraID //.toUpperCase()
33
- this._floor_vertical_position = parseFloat(camera.floor_vertical_position)
34
- if (camera.uposition && camera.urotation) {
35
- this._position = stringToVector3ConvertPositionFromUnity(
36
- camera.uposition
37
- )
38
- this._rotation = stringToVector3ConvertRotationFromUnity(
39
- camera.urotation
40
- )
41
- } else {
42
- this._position = stringToVector3ConvertPositionFromBlender(
43
- camera.position
44
- )
45
- this._rotation = stringToVector3(camera.rotation) // "90.00,180.00,41.59"
46
- }
47
-
48
- this._isVisible = true
49
-
50
- const geometry = new THREE.PlaneGeometry(0.35, 0.35, 1, 1)
51
- const material = new THREE.MeshBasicMaterial({
52
- map: new THREE.TextureLoader().load(markerTexture),
53
- transparent: true,
54
- opacity: 0.0,
55
- color: 0xffffff,
56
- })
57
-
58
- this._mesh = new THREE.Mesh(geometry, material)
59
- this._mesh.rotation.x = -Math.PI / 2
60
- scene.add(this._mesh)
61
-
62
- this._mesh.position.set(
63
- this._position.x,
64
- this._floor_vertical_position,
65
- this._position.z
66
- )
67
- }
68
-
69
- get cameraID() {
70
- return this._cameraID
71
- }
72
-
73
- get floor_vertical_position() {
74
- return this._floor_vertical_position
75
- }
76
-
77
- get position() {
78
- return this._position
79
- }
80
-
81
- get mesh() {
82
- return this._mesh
83
- }
84
-
85
- get rotation() {
86
- return this._rotation
87
- }
88
-
89
- get isVisible() {
90
- return this._isVisible
91
- }
92
-
93
- set isVisible(v) {
94
- this._isVisible = v
95
- }
96
- }
97
- export { CameraConfig }