Skip to main content

BimApiWithTwin

Hierarchy

  • BimApi
    • BimApiWithTwin

Index

Constructors

publicconstructor

Properties

readonlycamera

camera: BimCamera

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

readonlyviewer

viewer: TwinfinityViewer

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);

staticrunRenderLoop
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

axes

  • 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

currentContainerInfo

  • get currentContainerInfo(): BimContainerInfo
  • Gives information on currently selected container such as title, language and also details of the current user.


    Returns BimContainerInfo

grid

  • get grid(): GridOptions
  • Gets or sets options for 3D help grid visualization.


    Returns GridOptions

isSkyboxEnabled

  • 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

onPointerObservable

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

selectables

  • get selectables(): Selectables
  • Exposes methods related to selection operations. For example, what the user actually clicked on.


    Returns Selectables

Methods

applyVisualChanges

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

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


    Returns Promise<void>

clear

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


    Returns void

createCoordinateTracker

  • createCoordinateTracker<Tracked3D>(): CoordinateTracker<Tracked3D>
  • Gets a CoordinateTracker instance.


    Type parameters

    • Tracked3D: Vertex3 = any

    Returns CoordinateTracker<Tracked3D>

filter

  • filter(predicate: BimIfcObjectForEachPredicate): BimIfcObject[]
  • Iterate the BimIfcObject instances and return those that match the specified predicate.


    Parameters

    • predicate: BimIfcObjectForEachPredicate

      Predicate. Items matching this will be returned in array format.

    Returns BimIfcObject[]

    Array with BimIfcObject instances matched by the specified predicate.

foreach

  • foreach(a: BimIfcObjectForEachAction): void
  • 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

    • a: BimIfcObjectForEachAction

    Returns void

getIntersections

  • getIntersections(origin: Vector3, direction: Vector3, objects?: BimIfcObject[]): undefined | Intersection[]
  • 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
    • optionalobjects: BimIfcObject[]

    Returns undefined | Intersection[]

    Intersection[] | undefined

info

  • info(): TwinfinityInfo
  • General Twinfinity information such as customer portal name, Twinfinity API version etc.


    Returns TwinfinityInfo

loadPropertySets

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

    @deprecated

    Use ifc.loadPropertySets instead.


    Returns Promise<void>

on

  • on(type: click, clickEventHandler: ClickEventHandler): void
  • 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

products

  • products(): IterableIterator<BimIfcObject>
  • 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.

setBackgroundColor

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

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

    Parameters

    • color: Color | Color3

      RGB in range 0-1

    Returns void

setContainer

  • setContainer(containerOrUrl: URL | BimContainer, options?: BimApiLoadOptions): Promise<void>
  • @async

    Sets the container of the current BimApi instance.


    Parameters

    Returns Promise<void>

setHighlightColor

  • setHighlightColor(color: Color3, highlightIndex: ColoredHighlightIndexes): void
  • 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: 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

withVisibleBimObjects

  • withVisibleBimObjects<T>(visibleBimObjects: BimIfcObject[], action: (objects: BimIfcObject[]) => T): T
  • 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

    • visibleBimObjects: BimIfcObject[]

      Visible objects to run operation on

    • action: (objects: BimIfcObject[]) => T

      Operation

    Returns T

zoomToExtent

  • zoomToExtent(products: BimIfcObject[]): void
  • This function zooms the camera to contain BIM objects in view frustum.


    Parameters

    • products: BimIfcObject[]

    Returns void

publicstaticcreate

staticcreateApi

  • 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

    • TBimApi: BimCoreApi<TBimApi>

    Parameters

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

    Returns Promise<TBimApi>