UNPKG

terriajs

Version:

Geospatial data visualization platform.

45 lines 2.14 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; import { observable, runInAction } from "mobx"; import IonResource from "terriajs-cesium/Source/Core/IonResource"; /** * A mixin for a model that can be loaded from Cesium ion via an `ionAssetId`. If an asset ID is supplied, * the `ionResource` will be populated asynchronously after `loadIonResource` is called (usually from * `forceLoadMetadata`). If defined, the resource in this property should be used as the "URL" given to * CesiumJS instead of a regular URL. */ export default function CesiumIonMixin(Base) { class CesiumIonMixin extends Base { /** * The {@link IonResource} that can be given to CesiumJS most places that a resource URL can be used. */ ionResource = undefined; /** * Populates the the `ionResource` from the `ionAssetId`, `ionAccessToken`, and `ionServer` * traits. This should be called from `forceLoadMetadata`. */ async loadIonResource() { if (this.ionAssetId) { const resource = await IonResource.fromAssetId(this.ionAssetId, { accessToken: this.ionAccessToken, server: this.ionServer }); runInAction(() => { this.ionResource = resource; }); } else { this.ionResource = undefined; } } } __decorate([ observable ], CesiumIonMixin.prototype, "ionResource", void 0); return CesiumIonMixin; } //# sourceMappingURL=CesiumIonMixin.js.map