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.xkt"
});

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

viewer: Viewer

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, forget: Boolean)

Fires an event on this Plugin.

public

Returns true if there are any subscribers to the given event on this Plugin.

public

log(msg: String)

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

public

off(subId: String)

Cancels an event subscription that was previously made with Plugin#on or Plugin#once.

public

on(event: String, callback: Function, scope: Object): String

Subscribes to an event on this Plugin.

public

once(event: String, callback: Function, scope: Object)

Subscribes to the next occurrence of the given event, then un-subscribes as soon as the event is subIdd.

public

scheduleTask(task: *)

Schedule a task to perform on the next browser interval

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