Reference Source
public class | source

PlanViewsPlugin

Extends:

Plugin → PlanViewsPlugin

A Viewer plugin that provides plan view images of storeys within IFC building models.

A plan view image consists of a downward-looking orthographic snapshot image of Entitys within a storey belonging to a building model.

Each building storey is represented by a MetaObject of type "IfcBuildingStorey" within the Viewer's MetaScene.

The Entitys within a storey correspond to MetaObjects within the structural subtree of the "IfcBuildingStorey" MetaObject.

PlanViewPlugin automatically creates its PlanViews as MetaModels are created within its Viewer's MetaScene.

PlanViewPlugin configures the visual state of each Entity within each plan view according to the type of its corresponding MetaObject, using the map of properties in IFCPlanViewObjectStates by default. You can customize the appearance of the Entities by providing your own PlanViewsPlugin#objectStates.

[Run this example]

import {Viewer} from "../src/viewer/Viewer.js";
import {GLTFLoaderPlugin} from "../src/viewer/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.js";
import {PlanViewsPlugin} from "../src/viewer/plugins/PlanViewsPlugin/PlanViewsPlugin.js";

// Create a Viewer, arrange the camera

const viewer = new Viewer({
       canvasId: "myCanvas",
       transparent: true
   });

viewer.camera.eye = [-2.56, 8.38, 8.27];
viewer.camera.look = [13.44, 3.31, -14.83];
viewer.camera.up = [0.10, 0.98, -0.14];

// Load a model and fit it to view

const gltfLoader = new GLTFLoaderPlugin(viewer);

const model = gltfLoader.load({
     id: "myModel",
     src: "./models/gltf/schependomlaan/scene.gltf",
     metaModelSrc: "./metaModels/schependomlaan/metaModel.json",
     edges: true
});

// Add a PlanViewsPlugin
// This will automatically create PlanViews when the model has loaded

const planViews = new PlanViewsPlugin(viewer, {
     size: [220, 220],
     format: "png",  // Default
     ortho: true     // Default
 });


// When model loaded, get all PlanViews from StoryViewsPlugin

model.on("loaded", function () {

     const planViewIds = Object.keys(planViews.planViews);

     for (var i = 0, len = planViewIds.length; i < len; i++) {

         const planViewId     = planViewIds[i];

         const planView       = planViews.planViews[planViewId];

         const aabb           = planView.aabb; // Boundary of storey elements
         const modelId        = planView.modelId; // "myModel"
         const storeyObjectId = planView.storeyObjectId; // ID of IfcBuildingStorey
         const snapshotData   = planView.snapshotData;

         //...
     }
});

Constructor Summary

Public Constructor
public

constructor(viewer: Viewer, cfg: Object)

Member Summary

Public Members
public get

bgColor: * | number[]: *

Gets the background color of PlanView images.

public set

bgColor(bgColor: *)

Sets the background color of PlanView images.

public set

format(format: *)

Sets the format of PlanView images.

public get

format: * | number[]: *

Gets the format of PlanView images.

public

A map PlanViews for each MetaModel.

public set

objectStates: {String: Object}

Sets map of visual states for the Entitys as rendered within each PlanView.

public get

objectStates: {String: Object}

Gets map of visual states for the Entitys as rendered within each PlanView.

public set

ortho(ortho: *)

Sets whether or not to capture an orthographic or perspective view for each PlanView.

public get

Gets whether or not to capture an orthographic or perspective view for each PlanView.

public

planViews: {String: PlanView}

A PlanView for each MetaObject whose MetaObject#type equals "IfcBuildingStorey", mapped to Entity#id.

public get

size: * | number[]: *

Gets the size of PlanView images.

public set

size(size: *)

Sets the size of PlanView images.

Method Summary

Public Methods
public

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: "GLTFLoader"

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

cfg.objectStates Object
  • optional

Map of visual states for the Entitys as rendered within each PlanView. Default value is IFCPlanViewObjectStates.

cfg.ortho Boolean
  • optional
  • default: true

Whether to capture an orthographic or perspective view for each PlanView.

cfg.size Number[]
  • optional
  • default: [200,200]

Size of PlanView images.

cfg.format String
  • optional
  • default: "png"

Format of PlanView images. Allowed values are "png" and "jpeg".

Public Members

public get bgColor: * | number[]: * source

Gets the background color of PlanView images.

Return:

* | number[]

public set bgColor(bgColor: *) source

Sets the background color of PlanView images.

Rebuilds PlanViews when updated.

public set format(format: *) source

Sets the format of PlanView images. Allowed values are "png" and "jpeg".

Rebuilds PlanViews when updated.

public get format: * | number[]: * source

Gets the format of PlanView images. Allowed values are "png" and "jpeg".

Return:

* | number[]

public modelPlanViews: {String: PlanView} source

A map PlanViews for each MetaModel.

public set objectStates: {String: Object} source

Sets map of visual states for the Entitys as rendered within each PlanView.

Default value is IFCPlanViewObjectStates.

public get objectStates: {String: Object} source

Gets map of visual states for the Entitys as rendered within each PlanView.

Default value is IFCPlanViewObjectStates.

public set ortho(ortho: *) source

Sets whether or not to capture an orthographic or perspective view for each PlanView.

public get ortho: boolean: * source

Gets whether or not to capture an orthographic or perspective view for each PlanView.

Return:

boolean

public planViews: {String: PlanView} source

A PlanView for each MetaObject whose MetaObject#type equals "IfcBuildingStorey", mapped to Entity#id.

public get size: * | number[]: * source

Gets the size of PlanView images.

Return:

* | number[]

public set size(size: *) source

Sets the size of PlanView images.

Rebuilds PlanViews when updated.

Public Methods

public destroy() source

Destroys this Plugin and removes it from its Viewer.

Override:

Plugin#destroy