Skip to main content

BimCoreApi

BimCoreApi is a generic API class. It is completely unaware about the Twinfinity API backend and can therefore be used as a base for integration with a completely different backend. This must be used in conjunction with a specialized implementation of BimCoreApiClient. BimApi is an actual example of such an implementation.

Hierarchy

Index

Constructors

publicconstructor

  • Constructor. Use createApi instead.


    Parameters

    Returns BimCoreApi

Properties

publicreadonlycamera

camera: BimCamera

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

publicreadonlyviewer

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
@example
api.viewer.scene.ambientColor = new Color3(1, 0, 0);

publicstaticrunRenderLoop
beta

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.

@example

Example for Angular JS

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

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

Accessors

publicaxes

  • get axes(): boolean
  • set axes(isEnabled: boolean): void
  • Gets or sets a value indicating whether to hide or show coordinate system axes.


    Returns boolean

  • Parameters

    • isEnabled: boolean

    Returns void

publicbackend

  • Direct access to the methods for communicating with the backend.


    Returns BimCoreApiClient

publicgrid

  • Gets or sets options for 3D help grid visualization.


    Returns GridOptions

publicisSkyboxEnabled

  • get isSkyboxEnabled(): boolean
  • set isSkyboxEnabled(enabled: boolean): void
  • Gets or sets a value indicating whether to show or hide skybox.


    Returns boolean

  • Parameters

    • enabled: boolean

    Returns void

publiconPointerObservable

  • 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>>

publicselectables

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


    Returns Selectables

Methods

publicapplyVisualChanges

  • applyVisualChanges(): Promise<void>
  • @async

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


    Returns Promise<void>

publicclear

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


    Returns void

publiccreateCoordinateTracker

publicfilter

publicforeach

  • Use this function to iterate over all BIM objects.

    @example
    api.foreach((o, recursionOptions) => {
    if (o.hasGeometry && o.class.id !== "IfcFlowSegment") {
    console.log(o.gid);
    o.visible(true);
    } else {
    o.visible(false);
    }
    });

    Parameters

    Returns void

publicgetIntersections

  • Intersects all visible BIM objects using ray from origin towards direction

    @example
    // 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]);
    @example
    // 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]);
    @example
    // 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);

    Parameters

    • origin: Vector3
    • direction: Vector3
    • objects: BimIfcObject[] = []

    Returns undefined | Intersection[]

    Intersection[] | undefined

publicloadPropertySets

  • loadPropertySets(): Promise<void>
  • Loads all BIM property sets for all loaded files.

    @deprecated

    Use ifc.loadPropertySets instead.


    Returns Promise<void>

publicon

  • Sets a handler to event of given type

    @deprecated

    Use onPointerObservable instead.


    Parameters

    • type: click

      Type of event. For now only “click” is supported

    • clickEventHandler: ClickEventHandler

    Returns void

publicproducts

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

    @example
    for(const o of api.products()) {
    if (o.hasGeometry && o.class.id !== "IfcFlowSegment") {
    console.log(o.gid);
    o.visible(true);
    } else {
    o.visible(false);
    }
    };

    Returns IterableIterator<BimIfcObject>

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

publicsetBackgroundColor

  • setBackgroundColor(color: Color3 | Color): void
  • Sets background color in viewer

    @example
    api.setBackgroundColor([0.95, 0.95, 0.95]);

    Parameters

    • color: Color3 | Color

      RGB in range 0-1

    Returns void

publicsetContainer

publicsetHighlightColor

  • Sets highlight color in viewer

    @example
    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

    Parameters

    • color: Color3

      RGB in range 0-1

    • highlightIndex: IfcMaterialHighlightIndex = IfcMaterialHighlightIndex.One

      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

publicwithVisibleBimObjects

  • 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

    @example
    // 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]));

    Type parameters

    • T

    Parameters

    Returns T

publiczoomToExtent

  • This function zooms the camera to contain BIM objects in view frustum.


    Parameters

    Returns void

publicstaticcreateApi

  • createApi<TBimApi>(_htmlElementOrId: string | HTMLElement, apiFactory: (canvas: HTMLCanvasElement) => TBimApi): Promise<TBimApi>
  • @async

    Creates a new instance of BimCoreApi or subclass of BimCoreApi.

    @example
    // 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()));

    Type parameters

    Parameters

    • _htmlElementOrId: string | HTMLElement
    • apiFactory: (canvas: HTMLCanvasElement) => TBimApi

    Returns Promise<TBimApi>