chore: automated housekeeping...

This commit is contained in:
Pieter Vander Vennet 2025-04-15 18:18:44 +02:00
parent 79b6927b56
commit 42ded4c1b1
328 changed files with 4062 additions and 1284 deletions

View file

@ -4,38 +4,37 @@ import { Feature, Geometry, Point } from "geojson"
import { GeoOperations } from "../../Logic/GeoOperations"
import { HotspotProperties, PanoramaView } from "../../Logic/ImageProviders/ImageProvider"
export class PhotoSphereViewerWrapper {
private imageInfo: Feature<Point, PanoramaView>
private readonly viewer: Pannellum.Viewer
private nearbyFeatures: Feature<Geometry, HotspotProperties>[] = []
constructor(container: HTMLElement, imageInfo: Feature<Point, PanoramaView>, nearbyFeatures?: Feature<Geometry, HotspotProperties>[]) {
constructor(
container: HTMLElement,
imageInfo: Feature<Point, PanoramaView>,
nearbyFeatures?: Feature<Geometry, HotspotProperties>[]
) {
this.imageInfo = imageInfo
this.viewer = pannellum.viewer(container,
<any>{
default: {
firstScene: imageInfo.properties.url,
sceneFadeDuration: 250
this.viewer = pannellum.viewer(container, <any>{
default: {
firstScene: imageInfo.properties.url,
sceneFadeDuration: 250,
},
scenes: {
[imageInfo.properties.url]: {
type: "equirectangular",
hfov: 110,
panorama: imageInfo.properties.url,
autoLoad: true,
hotSpots: [],
sceneFadeDuration: 250,
compass: true,
showControls: false,
northOffset: imageInfo.properties.northOffset,
horizonPitch: imageInfo.properties.pitchOffset,
},
scenes: {
[imageInfo.properties.url]:
{
type: "equirectangular",
hfov: 110,
panorama: imageInfo.properties.url,
autoLoad: true,
hotSpots: [],
sceneFadeDuration: 250,
compass: true,
showControls: false,
northOffset: imageInfo.properties.northOffset,
horizonPitch: imageInfo.properties.pitchOffset
}
}
}
)
},
})
this.setNearbyFeatures(nearbyFeatures)
}
@ -43,12 +42,13 @@ export class PhotoSphereViewerWrapper {
public calculatePitch(feature: Feature): number {
const coors = this.imageInfo.geometry.coordinates
const distance = GeoOperations.distanceBetween(
<[number, number]>coors, GeoOperations.centerpointCoordinates(feature)
<[number, number]>coors,
GeoOperations.centerpointCoordinates(feature)
)
// In: -pi/2 up to pi/2
const alpha = Math.atan(distance / 4) // in radians
const degrees = alpha * 360 / (2 * Math.PI)
const degrees = (alpha * 360) / (2 * Math.PI)
return -degrees
}
@ -62,7 +62,7 @@ export class PhotoSphereViewerWrapper {
this.viewer.addScene(imageInfo.properties.url, <any>{
panorama: imageInfo.properties.url,
northOffset: imageInfo.properties.northOffset,
type: "equirectangular"
type: "equirectangular",
})
this.viewer.loadScene(imageInfo.properties.url, 0, imageInfo.properties.northOffset)
@ -70,7 +70,8 @@ export class PhotoSphereViewerWrapper {
}
private clearHotspots() {
const hotspots = this.viewer.getConfig()["scenes"][this.imageInfo.properties.url].hotSpots ?? []
const hotspots =
this.viewer.getConfig()["scenes"][this.imageInfo.properties.url].hotSpots ?? []
for (const hotspot of hotspots) {
this.viewer.removeHotSpot(hotspot?.id, this.imageInfo.properties.url)
}
@ -95,20 +96,21 @@ export class PhotoSphereViewerWrapper {
} else if (!isNaN(f.properties.pitch)) {
pitch = f.properties.pitch
}
this.viewer.addHotSpot({
type: f.properties.gotoPanorama !== undefined ? "scene" : "info",
yaw: (yaw - northOffs) % 360,
pitch,
text: f.properties.name,
clickHandlerFunc: () => {
this.setPanorama(f.properties.gotoPanorama)
}
}, this.imageInfo.properties.url)
this.viewer.addHotSpot(
{
type: f.properties.gotoPanorama !== undefined ? "scene" : "info",
yaw: (yaw - northOffs) % 360,
pitch,
text: f.properties.name,
clickHandlerFunc: () => {
this.setPanorama(f.properties.gotoPanorama)
},
},
this.imageInfo.properties.url
)
if (f.properties.focus) {
this.viewer.setYaw(yaw - northOffs)
}
}
}
}