Reference Source
import {Controller} from '@xeokit/xeokit-viewer/src/Controller.js'
public class | source

Controller

Base class for all xeokit-ui components.

Member Summary

Public Members
public

server: *

public

viewer: *

public

Method Summary

Public Methods
public

Destroys this Controller.

public

error(message: String)

Logs an error for this Controller to the JavaScript console.

public

fire(event: String, value: Object, forget: Boolean)

Fires an event on this Controller.

public

Gets whether or not this Controller is active.

public

Gets whether or not this Controller is enabled.

public

log(message: String)

Logs a console debugging message for this Controller.

public

off(subId: String)

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

public

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

Subscribes to an event on this Controller.

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 handled.

public

setActive(active: boolean)

Activates or deactivates this Controller.

public

setEnabled(enabled: boolean)

Enables or disables this Controller.

public

warn(message: String)

Logs a warning for this Controller to the JavaScript console.

Public Members

public server: * source

public viewer: * source

public viewerUI: * source

Public Methods

public destroy() source

Destroys this Controller.

public error(message: String) source

Logs an error for this Controller to the JavaScript console.

The console message will have this format: [ERROR] [<component type> =<component id>: <message>

Params:

NameTypeAttributeDescription
message String

The message to log

public fire(event: String, value: Object, forget: Boolean) source

Fires an event on this Controller.

Params:

NameTypeAttributeDescription
event String

The event type name

value Object

The event parameters

forget Boolean
  • optional
  • default: false

When true, does not retain for subsequent subscribers

public getActive(): boolean source

Gets whether or not this Controller is active.

Return:

boolean

public getEnabled(): boolean source

Gets whether or not this Controller is enabled.

Return:

boolean

public log(message: String) source

Logs a console debugging message for this Controller.

The console message will have this format: [LOG] [<component type> <component id>: <message>

Params:

NameTypeAttributeDescription
message String

The message to log

public off(subId: String) source

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

Params:

NameTypeAttributeDescription
subId String

Subscription ID

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

Subscribes to an event on this Controller.

The callback is be called with this component as scope.

Params:

NameTypeAttributeDescription
event String

The event

callback Function

Called fired on the event

scope Object
  • optional
  • default: this

Scope for the callback

Return:

String

Handle to the subscription, which may be used to unsubscribe with #off.

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

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

This is equivalent to calling Controller#on, and then calling Controller#off inside the callback function.

Params:

NameTypeAttributeDescription
event String

Data event to listen to

callback Function

Called when fresh data is available at the event

scope Object
  • optional
  • default: this

Scope for the callback

public setActive(active: boolean) source

Activates or deactivates this Controller.

Fires an "active" event on update.

Params:

NameTypeAttributeDescription
active boolean

Whether or not to activate.

public setEnabled(enabled: boolean) source

Enables or disables this Controller.

Fires an "enabled" event on update.

Params:

NameTypeAttributeDescription
enabled boolean

Whether or not to enable.

public warn(message: String) source

Logs a warning for this Controller to the JavaScript console.

The console message will have this format: [WARN] [<component type> =<component id>: <message>

Params:

NameTypeAttributeDescription
message String

The message to log