Reference Source
public class | source

ViewCullPlugin

Extends:

Plugin → ViewCullPlugin

Viewer plugin that performs view frustum culling to accelerate rendering performance.

For each Entity that represents an object, ViewCullPlugin will automatically set Entity#culledfalse whenever it falls outside our field of view.

When culled, an Entity is not processed by xeokit's renderer.

Internally, ViewCullPlugin organizes Entitys in a bounding volume hierarchy, implemented as a kd-tree.

On each Scene "tick" event, ViewCullPlugin searches the kd-tree using a frustum generated from the Camera, marking each Entity culled* if it falls outside the frustum.

Use ViewCullPlugin by simply adding it to your Viewer:

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

const viewCullPlugin = new ViewCullPlugin(viewer, {
   maxTreeDepth: 20
});

const xktLoader = new XKTLoaderPlugin(viewer);

const model = xktLoader.load({
     id: "myModel",
     src: "./models/xkt/OTCConferenceCenter/OTCConferenceCenter.xkt",
     metaModelSrc: "./metaModels/OTCConferenceCenter/metaModel.json"
});

Constructor Summary

Public Constructor
public

constructor(viewer: Viewer, cfg: Object)

Member Summary

Public Members
public set

enabled(enabled: Boolean)

Sets whether view culling is enabled.

public get

enabled: *

Gets whether view culling is enabled.

Method Summary

Public Methods
public

Destroys this ViewCullPlugin.

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

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

cfg.maxTreeDepth Number
  • optional
  • default: 8

Maximum depth of the kd-tree.

Public Members

public set enabled(enabled: Boolean) source

Sets whether view culling is enabled.

public get enabled: * source

Gets whether view culling is enabled.

Public Methods

public destroy() source

Destroys this ViewCullPlugin.

Override:

Plugin#destroy