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.6 kB
/** * Render GLBs in the 3D scene. * * @remarks * Available via {@link auto.Forma | Forma}.{@link index.EmbeddedViewSdk.render | render}.{@link render.RenderApi.glb | glb}. */ export class RenderGlbApi { #iframeMessenger; constructor(iframeMessenger) { this.#iframeMessenger = iframeMessenger; } /** * Add a GLB to the scene. * * @returns Unique identifier of the GLB object in the scene. * * @example * const {id} = await Forma.render.glb.add({ glb }), */ async add(request) { return await this.#iframeMessenger.sendRequest("scene/render/glb/add", request); } /** * Upsert an mesh in the scene. If the mesh does not exist, it will be added. * * This method can also be used as an upsert. * * @example * await Forma.render.glb.update({ id: "myPreviouslyAddedGlbId", glb }) */ async update(request) { await this.#iframeMessenger.sendRequest("scene/render/glb/update", request); } /** * Remove an existing GLB from the scene. * * @example * await Forma.render.glb.remove({ id: "myPreviouslyAddedGlbId" }) */ async remove(request) { await this.#iframeMessenger.sendRequest("scene/render/glb/remove", request); } /** * Remove all GLBs added by this API from the scene. * * Called automatically when the extension is unloaded * * @example * await Forma.render.glb.cleanup() */ async cleanup() { await this.#iframeMessenger.sendRequest("scene/render/glb/cleanup"); } }