Reference Source
public class | source

BIMServerLoaderPlugin

Extends:

Plugin → BIMServerLoaderPlugin

Viewer plugin that loads models from a BIMServer.

Tested with BIMServer v1.5.120 and IFC schema ifc2x3tc1.

  • For each model loaded, creates a tree of Entitys within its Viewer's Scene, with the root Entity representing the model and sub-Entitys representing objects within the model.
  • The root Entity will have Entity#isModel set true and will be registered by Entity#id in Scene#models.
  • Each sub-Entity that represents an object will have Entity#isObject set true and will be registered by Entity#id in Scene#objects.
  • When loading a model, we can specify a World-space transformation to position and orient it, along with initial rendering states to recursively apply to the Entity tree.

Usage

In the example below, we'll load the latest revision of a project's model from BIMSserver. We'll assume that we have a BIMServer instance running and serving requests on port 8082, with a model loaded for project ID 131073.

Since xeokit's default World "up" direction is +Y, while the model's "up" is +Z, we'll rotate the model 90 degrees about the X-axis as we load it. Note that we could also instead configure xeokit to use +Z as "up".

A BIMServerLoaderPlugin is configured with a BIMServerClient, which provides a client-side facade through which we can issue RPC calls to the BIMServer Service Interface. The BIMServerLoaderPlugin makes RPC calls through that to download the model and it's IFC metadata.

Note that BIMServerLoaderPlugin works with BIMServer V1.5.120 or later.

Read more about this example in the user guide on Viewing Models from BIMServer.

[Run this example]

import {Viewer} from "./../src/viewer/Viewer.js";
import BimServerClient from "./../src/viewer/utils/BIMServerClient/bimserverclient.js"
import {BIMServerLoaderPlugin} from "./../src/plugins/BIMServerLoaderPlugin/BIMServerLoaderPlugin.js";

const bimServerAddress = "https://xeokit.cleverapps.io/";
const username = "kevin.flynn@en.com";
const password = "secretPassword";
const poid = 196609;

// Create a xeokit Viewer
const viewer = new Viewer({
    canvasId: "myCanvas"
});

// Create a BimServerClient
const bimServerClient = new BimServerClient(bimServerAddress);

// Add a BIMServerLoaderPlugin to the Viewer, configured with the BIMServerClient
const bimServerLoader = new BIMServerLoaderPlugin(viewer, {
    bimServerClient: bimServerClient
});

// Initialize the BIMServer client
bimServerClient.init(() => {

    // Login to BIMServer
    bimServerClient.login(username, password, () => {

        // Query a project by ID
        bimServerClient.call("ServiceInterface", "getProjectByPoid", {
            poid: poid
        }, (project) => {

            // From the project info returned by BIMServerClient, we'll get the ID of the latest
            // model revision and the version of the IFC schema to which the model conforms.

            // Load the latest revision of the project

            const roid = project.lastRevisionId;
            const schema = project.schema;

            var model = bimServerLoader.load({ // Returns an Entity
                id: "myModel",
                poid: poid,                      // Project ID
                roid: roid,                      // Revision ID
                schema: schema,                  // Schema version
                edges: true,                     // Render with emphasized edges (default is false)
                lambertMaterial: true,          // Lambertian flat-shading instead of default Blinn/Phong
                scale: [0.001, 0.001, 0.001],    // Shrink the model a bit
                rotation: [-90, 0, 0]            // Rotate model for World +Y "up"
            });

            const scene = viewer.scene;  // xeokit.Scene
            const camera = scene.camera; // xeokit.Camera

            model.on("loaded", () => { // When loaded, fit camera and start orbiting
                camera.orbitPitch(20);
                viewer.cameraFlight.flyTo(model);
                scene.on("tick", () => {
                    camera.orbitYaw(0.3);
                })

                // We can find the model Entity by ID
                model = viewer.scene.models["myModel"];

                // To destroy the model, call destroy() on the model Entity
                model.destroy();
            });

            model.on("error", function(errMsg}
                 console.error("Error while loading: " + errMsg);
            });
        });
    });
});

Constructor Summary

Public Constructor
public

constructor(viewer: Viewer, cfg: Object)

Member Summary

Public Members
public

Version of BIMServer supported by this plugin.

public

bimServerClient: BIMServerClient

The BIMServer API.

public

hiddenTypes: {IfcOpeningElement: boolean, IfcSpace: boolean}

IFC types that are hidden by default.

public set

objectDefaults: {String: Object}

Sets map of initial default states for each loaded Entity that represents an object.

public get

objectDefaults: {String: Object}

Gets map of initial default states for each loaded Entity that represents an object.

Method Summary

Public Methods
public

Destroys this BIMServerLoaderPlugin.

public

load(params: Object): Entity

Loads a model from a BIMServer into this BIMServerLoaderPlugin's Viewer.

Creates a tree of Entitys that represents the model.

The root Entity will have Entity#isModel set true to indicate that it represents a model, and will therefore be registered in Scene#models.

Inherited Summary

From class Plugin
public

ID for this Plugin, unique within its Viewer.

public

The Viewer that contains this Plugin.

public

Destroys this Plugin and removes it from its Viewer.

public

error(msg: String)

Logs an error message to the JavaScript developer console, prefixed with the ID of this Plugin.

public

fire(event: String, value: Object)

Fires an event at this Plugin.

public

log(msg: String)

Logs a message to the JavaScript developer console, prefixed with the ID of this Plugin.

public

on(event: String, callback: Function)

Subscribes to an event fired at this Plugin.

public

warn(msg: String)

Logs a warning message to the JavaScript developer console, prefixed with the ID of this Plugin.

Public Constructors

public constructor(viewer: Viewer, cfg: Object) source

Creates this Plugin and installs it into the given Viewer.

Override:

Plugin#constructor

Params:

NameTypeAttributeDescription
viewer Viewer

The Viewer.

cfg Object

Plugin configuration.

cfg.id String
  • optional
  • default: "BIMServerModels"

Optional ID for this plugin, so that we can find it within Viewer#plugins.

cfg.bimServerClient Object

A BIMServer client API instance.

cfg.objectDefaults {String: Object}
  • optional

Map of initial default states for each loaded Entity that represents an object. Default value for this parameter is IFCObjectDefaults.

Public Members

public BIMSERVER_VERSION: string source

Version of BIMServer supported by this plugin.

public bimServerClient: BIMServerClient source

The BIMServer API.

public hiddenTypes: {IfcOpeningElement: boolean, IfcSpace: boolean} source

IFC types that are hidden by default.

public set objectDefaults: {String: Object} source

Sets map of initial default states for each loaded Entity that represents an object.

Default value is IFCObjectDefaults.

public get objectDefaults: {String: Object} source

Gets map of initial default states for each loaded Entity that represents an object.

Default value is IFCObjectDefaults.

Public Methods

public destroy() source

Destroys this BIMServerLoaderPlugin.

Override:

Plugin#destroy

public load(params: Object): Entity source

Loads a model from a BIMServer into this BIMServerLoaderPlugin's Viewer.

Creates a tree of Entitys that represents the model.

The root Entity will have Entity#isModel set true to indicate that it represents a model, and will therefore be registered in Scene#models.

Params:

NameTypeAttributeDescription
params Object

Loading parameters.

params.id String
  • optional

ID to assign to the root Entity#id, unique among all components in the Viewer's Scene, generated automatically by default.

params.poid Number

ID of the model's project within BIMServer.

params.roid Number

ID of the model's revision within BIMServer. See the class example for how to query the latest project revision ID via the BIMServer client API.

params.schema Number

The model's IFC schema. See the class example for how to query the project's schema via the BIMServer client API.

params.objectDefaults {String: Object}
  • optional

Map of initial default states for each loaded Entity that represents an object. Default value for this parameter is IFCObjectDefaults.

params.edges Boolean
  • optional
  • default: false

Whether or not xeokit renders the model with edges emphasized.

params.position Number[]
  • optional
  • default: [0,0,0]

The model World-space 3D position.

params.scale Number[]
  • optional
  • default: [1,1,1]

The model's World-space scale.

params.rotation Number[]
  • optional
  • default: [0,0,0]

The model's World-space rotation, as Euler angles given in degrees, for each of the X, Y and Z axis.

params.matrix Number[]
  • optional
  • default: [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]

The model's world transform matrix. Overrides the position, scale and rotation parameters.

params.backfaces Boolean
  • optional
  • default: false

When true, allows visible backfaces, wherever specified. When false, ignores backfaces.

params.edgeThreshold Number
  • optional
  • default: 20

When xraying, highlighting, selecting or edging, this is the threshold angle between normals of adjacent triangles, below which their shared wireframe edge is not drawn.

Return:

Entity

Root Entity representing the loaded model. The Entity will have Entity#isModel set true and will be registered by Entity#id in Scene#models