@twinfinity/core
    Preparing search index...

    Class BimApi

    BimApi is the main API class. This a subclass of BimCoreApi that is extended with information only available from the Twinfinity API backend.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    camera: BimCamera

    Camera is an instance of BimCamera and used for manipulating the 3D camera view of the BIM viewer.

    Exposes viewer internals. Use this to access BabylonJS API. Disclaimer! Accessing BabylonJS internals is considered advanced usage and you are effectively bypassing BimCoreApi (and subclasses). We cannot make guarantees that:

    • BabylonJS APIs will remain backwards compatible. Therefore, your application may break when BabylonJS is updated to a new version.
    • Babylonjs data that BimCoreApi creates, such as scene hierarchy, lights, camera etc., will remain backwards compatible between versions. Relying on this may break your application.
    • Your modifications to BabylonJS data (such as scene hierarchy, lights, cameras etc.) will not be changed by code in this package.
    • Other bugs will not occur as a result of direct usage of BabylonJS APIs. https://doc.babylonjs.com/api/classes/babylon.scene
    api.viewer.scene.ambientColor = new Color3(1, 0, 0);
    
    runRenderLoop: RunRenderLoopHandler = ...

    Extension point for applications that need to run the renderloop outside their own change handling (AngularJs is one such example). Assignment should be done before creation of a BimCoreApi instance.

     const bimApi: BimApi;
    BimCoreApi.runRenderLoop = this.ngZone.runOutSideAngular;

    Renderloop function will be provided by the viewer. Simply call it in your provided function

    Accessors

    • get axes(): boolean

      Gets or sets a value indicating whether to hide or show coordinate system axes.

      Returns boolean

    • set axes(isEnabled: boolean): void

      Parameters

      • isEnabled: boolean

      Returns void

    • get currentContainerInfo(): BimContainerInfo

      Gives information on currently selected container such as title, language and also details of the current user.

      Returns BimContainerInfo

    • get grid(): GridOptions

      Gets or sets options for 3D help grid visualization.

      Returns GridOptions

    • get isSkyboxEnabled(): boolean

      Gets or sets a value indicating whether to show or hide skybox.

      Returns boolean

    • set isSkyboxEnabled(enabled: boolean): void

      Parameters

      • enabled: boolean

      Returns void

    • get onPointerObservable(): Observable<
          DeepImmutableObject<PointerInfoWithTimings>,
      >

      Subscribe to get access to pointer events (mouse, touchpad etc) and to determine what (if anything) a mouse click interacted with (what object was 'picked' in the 3D scene).

      Returns Observable<DeepImmutableObject<PointerInfoWithTimings>>

    • get selectables(): Selectables

      Exposes methods related to selection operations. For example, what the user actually clicked on.

      Returns Selectables

    Methods

    • Updates the viewer with the latest visual changes on BIM objects. See foreach for an example.

      Returns Promise<void>

    • Clears api (any loaded IFC files etc are unloaded).

      Returns void

    • Disposes the API and releases all resources including WASM memory and Babylon.js resources. After calling this method, the API instance should not be used.

      Returns void

    • Use this function to iterate over all BIM objects.

      Parameters

      Returns void

      api.foreach((o, recursionOptions) => {
      if (o.hasGeometry && o.class.id !== "IfcFlowSegment") {
      console.log(o.gid);
      o.visible(true);
      } else {
      o.visible(false);
      }
      });
    • Intersects all visible BIM objects using ray from origin towards direction

      Parameters

      • origin: Vector3

        Vector3

      • direction: Vector3

        Vector3

      • objects: BimIfcObject[] = []

        BimIfcObject[]

      Returns undefined | Intersection[]

      Intersection[] | undefined

      // GetIntersections makes a hit test on all visible BIM objects, from origin in direction and return first object intersection.
      const intersections = this.api.getIntersections([0, 0, 0], [1, 1, 1]);
      // GetIntersections makes a hit test on a subset of  BIM objects, from origin in direction and return first object intersection.
      const intersections = this.api.withSelection(myVisibleObjects, objects => this.api.getIntersections([0, 0, 0], [1, 1, 1]);
      // GetIntersections makes a hit test on a subset of visible BIM objects, from origin in direction and return first object intersection.
      const intersections = this.api.getIntersections([0, 0, 0], [1, 1, 1], myObjects);
    • Called from createApi. Subclasses can implement if they need to initialize more data during API creation in createApi

      Returns Promise<void>

    • Sets a handler to event of given type

      Parameters

      • type: "click"

        Type of event. For now only "click" is supported

      • clickEventHandler: ClickEventHandler

        Function that gets called when the event occurs

      Returns void

      Use onPointerObservable instead.

    • Create a iterator that can be used to iterate over all BimIfcObject's. Same as foreach but with a iterator instead.

      Returns IterableIterator<BimIfcObject>

      Iterator that can be used to iterate over all BimIfcObject's.

      for(const o of api.products()) {
      if (o.hasGeometry && o.class.id !== "IfcFlowSegment") {
      console.log(o.gid);
      o.visible(true);
      } else {
      o.visible(false);
      }
      };
    • Sets background color in viewer

      Parameters

      • color: Color3 | Color

        RGB in range 0-1

      Returns void

      api.setBackgroundColor([0.95, 0.95, 0.95]);
      
    • Sets highlight color in viewer

      Parameters

      • color: Color3

        RGB in range 0-1

      • highlightIndex: ColoredHighlightIndexes

        The highlight index tgo change, it's restricted to One, Two and Three because it makes no sense to change the color of the Empty index (since it's only there to denote that a productMesh has no highlight). The highlight index defaults to One

      Returns void

      api.setHighlightColor([1.0, 0.0, 0.0]); <-- Sets the color of the first highlight index to solid red
      api.setHighlightColor([0.0, 1.0, 0.0], HighlightIndex.Two); <-- Sets the color of the second highlight index to solid green
    • Makes it possible to perform API operations, that operate on the set of visible BIM objects, on a smaller set of (still visible) BIM objects

      Type Parameters

      • T

      Parameters

      Returns T

      // GetIntersections makes a hit test on a subset of visible BIM objects, from origin in direction and return first object intersection.
      const intersections = this.api.withVisibleBimObjects(myVisibleBimObjects, objects => api.getIntersections([0, 0, 0], [1, 1, 1]));
    • Creates a new instance of BimApi.

      Parameters

      • _htmlElementOrId: string | HTMLElement

        ID of the HTML element where the viewer should be created.

      • absoluteContainerUrlOrApiClient: string | URL | TwinfinityApiClient

        Absolute URL to the container.

      • Optionaloptions: BimApiOptions

        Creation options.

      Returns Promise<BimApi>

      // Create an API instance.
      const api = await BimApi.create('viewer', 'project-url'); // Open project directly.
      const api = await BimApi.create('viewer', new BimTwinfinityApiClient(url)); // Create API. If a valid container url is given, the API automatically switches to it, otherwise calls api.setContainer() afterwards.
    • Creates a new instance of BimCoreApi or subclass of BimCoreApi.

      Type Parameters

      Parameters

      • _htmlElementOrId: string | HTMLElement

        ID of the HTML element where the viewer should be created.

      • apiFactory: (canvas: HTMLCanvasElement) => TBimApi

        Factory function to create the API instance.

      Returns Promise<TBimApi>

      // Create an API instance.
      const bimCoreApi = await BimCoreApi.create('viewer', canvas => new BimCoreApi(canvas, new BimApiClientTwinfinity()));
      const bimApi = await BimCoreApi.create('viewer', canvas => new BimApi(canvas, new BimApiClientTwinfinity()));