UNPKG

forma-embedded-view-sdk

Version:

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

147 lines (146 loc) 6 kB
import type { GrossFloorAreaPolygon, GraphBuilding as ImportedGraphBuilding, RepresentationSelection } from "forma-elements"; import type { IframeMessenger } from "./iframe-messenger.js"; export declare namespace Representation { type VolumeMesh = { /** @deprecated use selection instead */ id?: string; data: ArrayBuffer; selection?: RepresentationSelection; }; type Footprint = { /** @deprecated use selection instead */ id?: string; data: GeoJSON.FeatureCollection; selection?: RepresentationSelection; }; type GrossFloorAreaPolygons = { data: GrossFloorAreaPolygon[]; }; type GraphBuilding = { data: ImportedGraphBuilding; }; } /** * The Forma element system is composed of internal (private) representation and * derived (public) representation. The RepresentationsAPI allows you to access * the derived representations of elements. The internal is owned by the authoring * application and is private to all other components of the system. * * For a given element you can inspect the `representations` property to see what * representations are available. * * One important point is that the representations are given in the local coordinate * system of the element. These need to be transformed to the global coordinate system * of the proposal to be used in the context of the proposal. To do this you can use the * `Forma.elements.getWorldTransform` method, and then applying this as an affine * transformation to the representation. * * @example * void Forma.selection.subscribe(({ paths }) => { * const { element } = await Forma.elements.getByPath({ path: paths[0] }) * if (element.representations?.volumeMesh) { * const volume = await Forma.elements.representations.volumeMesh(element) * } * }) * * * @remarks * Avaliable via {@link auto.Forma | Forma}.{@link index.EmbeddedViewSdk.elements | elements}.{@link index.EmbeddedViewSdk.elements.representations | representations}. */ export declare class RepresentationsApi { #private; /** @hidden */ constructor(iframeMessenger: IframeMessenger); /** * Get the volume mesh for the element, the volume mesh is a triangulated visual model. * The data is returned as a buffer of gltf data. * * Refer to the Typescript type of `element.representations.volumeMesh` for a * detailed description of the volume mesh representation. * * If the `id` field is set, then the returned volume mesh is a batch where you * need to extract the mesh with the given id. The id is set as a name property * on the mesh inside the gltf file. * * @param request urn of the element * * @example * const { element } = await Forma.elements.get({ urn }) * if (element.representations?.volumeMesh) { * const volume = await Forma.elements.representations.volumeMesh(element) * } * * @returns The volume mesh representation of the element */ volumeMesh(request: { /** The urn for the element */ urn: string; }): Promise<Representation.VolumeMesh | undefined>; /** * Get the footprint of the element, the footprint is a 2D representation of * the space the element occupies on the ground plane. * * Refer to the Typescript type of `element.representations.footprint` for a * detailed description of the footprint representation. * * If the `id` field is set, then the returned footprints is a batch where you * need to extract the feature with the given id. The id is set as the id property * on the Feature inside the FeatureCollection. * * @param request urn of the element * * @example * const { element } = await Forma.elements.get({ urn }) * if (element.representations?.footprint) { * const {id, data} = await Forma.elements.representations.footprint(element) * * const feature = data.features.find(f => f.id === id) * } * * @returns The footprint representation of the element */ footprint(request: { /** The urn for the element */ urn: string; }): Promise<Representation.Footprint | undefined>; /** * Get the gross floor area of the element as a set of 3d positined polygons. * * Refer to the Typescript type of `element.representations.grossFloorAreaPolygons` for a * detailed description of the gross floor area polygons representation. * * @param request urn of the element * * @example * const { element } = await Forma.elements.get({ urn }) * if (element.representations?.grossFloorAreaPolygons) { * const grossFloorAreaPolygons = await Forma.elements.representations.grossFloorAreaPolygons(element) * } * * @returns The gross floor area polygons representation of the element */ grossFloorAreaPolygons(request: { /** The urn for the element */ urn: string; }): Promise<Representation.GrossFloorAreaPolygons | undefined>; /** * The graph building describes the partitioning of space for a building. The representation is composed of an ordered set of vertically-aligned levels and an unordered set of units, which may span multiple levels. * * Refer to the Typescript type of `element.representations.graphBuilding` for a * detailed description of the graph building representation. * * @param request urn of the element * * @example * const { element } = await Forma.elements.get({ urn }) * if (element.representations?.graphBuilding) { * const graphBuilding = await Forma.elements.representations.graphBuilding(element) * } * * @returns The graph building representation of the element */ graphBuilding(request: { /** The urn for the element */ urn: string; }): Promise<Representation.GraphBuilding | undefined>; }