UNPKG

@geogirafe/lib-geoportal

Version:

GeoGirafe is a flexible application to build online geoportals.

33 lines (32 loc) 951 B
export default class GlobeSerializer { context; constructor(context) { this.context = context; } get globe() { return this.context.stateManager.state.globe; } brainSerialize(globe) { return JSON.stringify({ display: globe.display, shadows: globe.shadows, shadowsTimestamp: globe.shadowsTimestamp, camera: globe.camera }); } brainDeserialize(str) { const parsedGlobe = JSON.parse(str); const globe = this.globe; if (parsedGlobe.display) { globe.display = parsedGlobe.display; } if (parsedGlobe.shadows !== undefined) { globe.shadows = parsedGlobe.shadows; } if (parsedGlobe.shadowsTimestamp) { globe.shadowsTimestamp = parsedGlobe.shadowsTimestamp; } globe.camera = parsedGlobe.camera ?? null; globe.loaded = false; } }