NGL@0.10.4 Home Manual Reference Source GalleryRepository
import Component from 'ngl/src/component/component.js'
public interface | source

Component

Base class for components

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

Events emitted by the component

Method Summary

Public Methods
public

addAnnotation(position: Vector3, content: String | Element, params: Object): Annotation

Add an anotation object

public

Add a new representation to the component

public

autoView(duration: Integer): undefined

Automatically center and zoom the component

public
public abstract
public
public

Remove all annotations from the component

public

Removes all representation components

public

Remove the give annotation from the component

public

Removes a representation component

public

Set position transform

public

Set rotation transform

public

Set scale transform

public

Set general transform.

public

Set the visibility of the component, including added representations

Public Constructors

public constructor(stage: Stage, params: ComponentParameters) source

Params:

NameTypeAttributeDescription
stage Stage

stage object the component belongs to

params ComponentParameters

parameter object

Public Members

public signals: ComponentSignals source

Events emitted by the component

Public Methods

public addAnnotation(position: Vector3, content: String | Element, params: Object): Annotation source

Add an anotation object

Params:

NameTypeAttributeDescription
position Vector3

the 3d position

content String | Element

the HTML content

params Object
  • optional

parameters

params.offsetX Integer

2d offset in x direction

params.offsetY Integer

2d offset in y direction

Return:

Annotation

the added annotation object

public addRepresentation(type: String, object: Object, params: RepresentationParameters): RepresentationComponent source

Add a new representation to the component

Params:

NameTypeAttributeDescription
type String

the name of the representation

object Object

the object on which the representation should be based

params RepresentationParameters
  • optional

representation parameters

Return:

RepresentationComponent

the created representation wrapped into a representation component object

public autoView(duration: Integer): undefined source

Automatically center and zoom the component

Params:

NameTypeAttributeDescription
duration Integer
  • optional

duration of the animation, defaults to 0

Return:

undefined

public getBox(): Box3 source

Return:

Box3

the component's bounding box

public abstract getBoxUntransformed(): Box3 source

Return:

Box3

the untransformed component's bounding box

public getCenter(): Vector3 source

Return:

Vector3

the component's center position

public removeAllAnnotations(): undefined source

Remove all annotations from the component

Return:

undefined

public removeAllRepresentations(): undefined source

Removes all representation components

Return:

undefined

public removeAnnotation(annotation: Annotation): undefined source

Remove the give annotation from the component

Params:

NameTypeAttributeDescription
annotation Annotation

the annotation to remove

Return:

undefined

public removeRepresentation(repr: RepresentationComponent): undefined source

Removes a representation component

Params:

NameTypeAttributeDescription
repr RepresentationComponent

the representation component

Return:

undefined

public setPosition(p: Vector3 | Array): Component source

Set position transform

Params:

NameTypeAttributeDescription
p Vector3 | Array

the coordinates

Return:

Component

this object

Example:

// translate by 25 angstrom along x axis
component.setPosition( [ 25, 0, 0 ] );

public setRotation(r: Quaternion | Euler | Array): Component source

Set rotation transform

Params:

NameTypeAttributeDescription
r Quaternion | Euler | Array

the rotation

Return:

Component

this object

Example:

// rotate by 2 degree radians on x axis
component.setRotation( [ 2, 0, 0 ] );

public setScale(s: Number): Component source

Set scale transform

Params:

NameTypeAttributeDescription
s Number

the scale

Return:

Component

this object

Example:

// scale by factor of two
component.setScale( 2 );

public setTransform(m: Matrix4): Component source

Set general transform. Is applied before and in addition to the position, rotation and scale transformations

Params:

NameTypeAttributeDescription
m Matrix4

the matrix

Return:

Component

this object

Example:

component.setTransform( matrix );

public setVisibility(value: Boolean): Component source

Set the visibility of the component, including added representations

Params:

NameTypeAttributeDescription
value Boolean

visibility flag

Return:

Component

this object