Options
All
  • Public
  • Public/Protected
  • All
Menu

Base class for all Components.

Webvs renders visualizations by layering different Components or effects one after the other. Each Component type will have a different rendering behaviour which can be configured through the component options. Some components may have sub components, in which case the rendering of all the subcomponents is modified/controlled in some manner by the parent. eg. EffectList, which renders a set of components into a separate buffer which is then blended back into the main render.

Options on components can be modified with a Model.set call. This allows Components to respond to changes in options in real-time. Eg: Changing colors, Code etc. This feature can be used to build Live-Edit User Interfaces for presets development.

Hierarchy

Index

Properties

constructor

  • Constructs new Component. Components are usually instantated by a Container component or Main in the case of the root EffectList.

    Parameters

    • main: IMain

      the main object that manages this component

    • parent: IContainer

      the parent that manages this component

    • options: any

      the initial options for this component

    Returns Component

Private enabled

enabled: boolean

Private id

id: string

Private lastError

lastError: any

Protected main

main: IMain

The main instance that manages this component

Protected opts

opts: any

current options of the component

Protected parent

parent: IContainer

The parent component that manages this component

Static Protected componentName

componentName: string = "Component"

Name of the component.

Static Protected componentTag

componentTag: string = ""

A string tag that categorizes the component. e.g. trans, render

Static Protected defaultOptions

defaultOptions: any

Default options for this component

Static Protected optUpdateHandlers

optUpdateHandlers: object = null

Map from option name to handler methods. The handler methods are called in order when on an option is updated with a Model.set call. This allows component to respond to option changes live. e.g. In a Live-Edit User Interface for preset development.

Type declaration

  • [key: string]: string | string[]

Static prefixed

prefixed: string | boolean

Methods

addListener

  • addListener(event: string | symbol, fn: ListenerFn, context?: any): this
  • Parameters

    • event: string | symbol
    • fn: ListenerFn
    • Optional context: any

    Returns this

destroy

  • destroy(): void
  • Destroys and cleansup resources. Please override to cleanup component specific resources.

    Returns void

Abstract draw

  • draw(): any
  • Performs drawing operations. Override to implement drawing for this component. Typically you'd make some WebGL operations to render to the framebuffer manager of this components parent.

    Returns any

emit

  • emit(event: string | symbol, ...args: Array<any>): boolean
  • Calls each of the listeners registered for a given event.

    Parameters

    • event: string | symbol
    • Rest ...args: Array<any>

    Returns boolean

eventNames

  • eventNames(): Array<string | symbol>
  • Return an array listing the events for which the emitter has registered listeners.

    Returns Array<string | symbol>

get

  • get(name: string): any
  • returns a component options given name

    Parameters

    • name: string

    Returns any

getId

  • getId(): string

getLastError

  • getLastError(): any
  • Returns the last error. That raised an error:* event

    Returns any

getPath

  • getPath(): string
  • Returns a / path to the component from the root.

    Returns string

Abstract init

  • init(): any
  • Initializes the component. Override this method to add initialization for the component. Typically you'd call some updateHandlers here to initialize states from the component options.

    Returns any

isEnabled

  • isEnabled(): boolean
  • Returns whether this component is enabled or not

    Returns boolean

Protected listenTo

  • listenTo(emitter: EventEmitter, event: string, callback: function): void
  • Add a listener to another EventEmitter.

    This provides an event subscription list facility. Allowing subclasses to listen to other emitters and remove all or some listeners with a single call to Model.stopListening, later.

    Parameters

    • emitter: EventEmitter

      the event emitter to listen to

    • event: string

      the name of the event to listen to

    • callback: function

      the callback for the event handler

        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns void

listenerCount

  • listenerCount(event: string | symbol): number
  • Return the number of listeners listening to a given event.

    Parameters

    • event: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Array<ListenerFn>
  • Return the listeners registered for a given event.

    Parameters

    • event: string | symbol

    Returns Array<ListenerFn>

off

  • off(event: string | symbol, fn?: ListenerFn, context?: any, once?: boolean): this
  • Parameters

    • event: string | symbol
    • Optional fn: ListenerFn
    • Optional context: any
    • Optional once: boolean

    Returns this

on

  • on(event: string | symbol, fn: ListenerFn, context?: any): this
  • Add a listener for a given event.

    Parameters

    • event: string | symbol
    • fn: ListenerFn
    • Optional context: any

    Returns this

once

  • once(event: string | symbol, fn: ListenerFn, context?: any): this
  • Add a one-time listener for a given event.

    Parameters

    • event: string | symbol
    • fn: ListenerFn
    • Optional context: any

    Returns this

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Remove all listeners, or those of the specified event.

    Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: string | symbol, fn?: ListenerFn, context?: any, once?: boolean): this
  • Remove the listeners of a given event.

    Parameters

    • event: string | symbol
    • Optional fn: ListenerFn
    • Optional context: any
    • Optional once: boolean

    Returns this

set

  • set(key: string | any, value: any, options?: any): boolean
  • Safely set an attribute(s).

    If the attribute set succeeds, a change:[attribute name] event is fired. change:[attribute name] event handler receives this object, the new value and options as arguments.

    Additionally a change event is also fired when all changes succeed. The change event receives this object and the options as arguments.

    Parameters

    • key: string | any

      the name of the attribute or map of values

    • value: any

      the new value of the attribute

    • Optional options: any

      this object is sent down to the event handlers, useful to things down to your handler. if options.silent is true then events are not fired.

    Returns boolean

Protected setAttribute

  • setAttribute(key: string, value: any, options: any): boolean

setParent

  • Sets the parent of this component

    Parameters

    • newParent: IContainer

      the new parent of this component

    Returns void

Protected stopListening

  • stopListening(emitter?: EventEmitter, event?: string, callback?: function): void
  • Removes to one or more listeners that were set earlier with calls to Model.listenTo.

    Use the arguments to filter subscriptions. eg: model.stopListening(em) will remove all listeners on emitter em. model.stopListening(em, 'change') will remove all listeners for change event on emitter em.

    Parameters

    • Optional emitter: EventEmitter

      the event emitter on which the listener was set

    • Optional event: string

      the event to be removed

    • Optional callback: function

      the callback to be removed

        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns void

toJSON

  • toJSON(): any
  • Returns the JSON representation of the component options.

    This value if passed into constructor will instantiate a component that behaves the same as this component.

    Returns any

Static getComponentName

  • getComponentName(): string
  • Returns the name of the component

    Returns string

Static getComponentTag

  • getComponentTag(): string
  • Returns a string tag that categorizes the component. e.g. trans, render

    Returns string