UNPKG

forma-embedded-view-sdk

Version:

The Forma Embedded View SDK is a JavaScript library for creating custom extensions in Autodesk Forma (previously Spacemaker).

55 lines (54 loc) 1.71 kB
/** * Render Geojson in the 3D scene. * * @remarks * Available via {@link auto.Forma | Forma}.{@link index.EmbeddedViewSdk.render | render}.{@link render.RenderApi.geojson | geojson}. */ export class RenderGeojsonApi { #iframeMessenger; constructor(iframeMessenger) { this.#iframeMessenger = iframeMessenger; } /** * Add a Geojson to the scene. * * @returns Unique identifier of the Geojson object in the scene. * * @example * const {id} = await Forma.render.geojson.add({ geojson }), */ async add(request) { return await this.#iframeMessenger.sendRequest("scene/render/geojson/add", request); } /** * Upsert an geojson in the scene. If the geojson does not exist, it will be added. * * This method can also be used as an upsert. * * @example * await Forma.render.geojson.update({ id: "myPreviouslyAddedGeojsonId", geojson, isImperial, transform }) */ async update(request) { await this.#iframeMessenger.sendRequest("scene/render/geojson/update", request); } /** * Remove an existing Geojson from the scene. * * @example * await Forma.render.geojson.remove({ id: "myPreviouslyAddedGeojsonId" }) */ async remove(request) { await this.#iframeMessenger.sendRequest("scene/render/geojson/remove", request); } /** * Remove all Geojsons added by this API from the scene. * * Called automatically when the extension is unloaded * * @example * await Forma.render.geojson.cleanup() */ async cleanup() { await this.#iframeMessenger.sendRequest("scene/render/geojson/cleanup"); } }