Reference Source
public class | source

PerformanceModel

Extends:

Component → PerformanceModel

Implements:

A high-performance model representation for efficient rendering and low memory usage.

Examples

User Guide

Constructor Summary

Public Constructor
public

constructor(owner: Component, cfg: *)

Member Summary

Public Members
public get

Gets the PerformanceModel's World-space 3D axis-aligned bounding box.

Represented by a six-element Float32Array containing the min/max extents of the axis-aligned volume, ie. [xmin, ymin,zmin,xmax,ymax, zmax].

public set

Sets if this PerformanceModel casts a shadow.

public get

Gets if this PerformanceModel casts a shadow.

public get

Gets if Entitys in this PerformanceModel are clippable.

public set

Sets if Entitys in this PerformanceModel are clippable.

public set

Sets if Entitys in this PerformanceModel are collidable.

public get

Gets if this PerformanceModel is collidable.

public get

Gets the RGB colorize color for this PerformanceModel.

public set

Sets the RGB colorize color for this PerformanceModel.

public get

Gets if this PerformanceModel is culled from view.

public set

Sets if this PerformanceModel is culled from view.

public get

Configures the appearance of edges of Entitys within this PerformanceModel.

public get

Gets if any Entitys in this PerformanceModel have edges emphasised.

public set

Sets if all Entitys in this PerformanceModel have edges emphasised.

public get

Configures the appearance of highlighted Entitys within this PerformanceModel.

public get

Gets if any Entitys in this PerformanceModel are highlighted.

public set

Sets if all Entitys in this PerformanceModel are highlighted.

public get

Returns true to indicate that PerformanceModel is implements Drawable.

public get

Returns true to indicate that PerformanceModel is an Entity.

public get

Returns true if this PerformanceModel represents a model.

public get

Returns false to indicate that PerformanceModel never represents an object.

public get

Returns true to indicate that this Component is a PerformanceModel.

public get

Gets the PerformanceModel's local modeling transform matrix.

Default value is [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1].

public set

Sets the opacity factor for this PerformanceModel.

public get

Gets this PerformanceModel's opacity factor.

This is a factor in range [0..1] which multiplies by the rendered fragment alphas.

public set

Sets if Entitys in this PerformanceModel are pickable.

public get

Gets if this PerformanceModel is pickable.

public get

Gets the PerformanceModel's local translation.

Default value is [0,0,0].

public get

Gets the PerformanceModels's local rotation quaternion.

Default value is [0,0,0,1].

public get

Sets if this PerformanceModel can have shadow cast upon it.

public set

Sets if this PerformanceModel can have shadow cast upon it.

public get

Gets the PerformanceModel's local rotation, as Euler angles given in degrees, for each of the X, Y and Z axis.

Default value is [0,0,0].

public get

Gets the PerformanceModel's local scale.

Default value is [1,1,1].

public get

Gets if any Entitys in this PerformanceModel are selected.

public set

Sets if all Entitys in this PerformanceModel are selected.

public get

Configures the appearance of selected Entitys within this PerformanceModel.

public set

Sets if this PerformanceModel is visible.

public get

Gets if any Entitys in this PerformanceModel are visible.

public get

Gets the PerformanceModel's World matrix.

public get

Gets the PerformanceModel's World normal matrix.

public get

Configures the appearance of xrayed Entitys within this PerformanceModel.

public get

Gets if any Entitys in this PerformanceModel are xrayed.

public set

Sets if all Entitys in this PerformanceModel are xrayed.

Method Summary

Public Methods
public

Creates an Entity within this PerformanceModel, giving it one or more meshes previously created with PerformanceModel#createMesh.

public

createGeometry(cfg: *)

Creates a reusable geometry within this PerformanceModel.

public

createMesh(cfg: object): *

Creates a mesh within this PerformanceModel.

public

createTile(cfg: *)

Starts building a tile.

public

Destroys this PerformanceModel.

public

Finalizes this PerformanceModel.

public

finalizeTile(tileId: String)

Finalizes a tile.

Inherited Summary

From class Component
public get

The Component that owns the lifecycle of this Component, if any.

public

True as soon as this Component has been destroyed

public

ID of this Component, unique within the Scene.

public

meta: *

Arbitrary, user-defined metadata on this component.

public

The parent Scene that contains this Component.

public

The viewer that contains this Scene.

public

clear()

Destroys all Components that are owned by this.

public

Destroys this component.

public

error(message: String)

Logs an error for this component to the JavaScript console.

public

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

Fires an event on this component.

public

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

public

isType(type: *): *: Boolean

Tests if this component is of the given type, or is a subclass of the given type.

public

log(message: String)

Logs a console debugging message for this component.

public

off(subId: String)

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

public

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

Subscribes to an event on this component.

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

warn(message: String)

Logs a warning for this component to the JavaScript console.

Public Constructors

public constructor(owner: Component, cfg: *) source

Override:

Component#constructor

Params:

NameTypeAttributeDescription
owner Component

Owner component. When destroyed, the owner will destroy this component as well.

cfg *
  • optional

Configs

cfg.id String
  • optional

Optional ID, unique among all components in the parent scene, generated automatically when omitted.

cfg.isModel Boolean
  • optional

Specify true if this PerformanceModel represents a model, in which case the PerformanceModel will be registered by PerformanceModel#id in Scene#models and may also have a corresponding MetaModel with matching MetaModel#id, registered by that ID in MetaScene#metaModels.

cfg.position Number[]
  • optional
  • default: [0,0,0]

Local 3D position.

cfg.scale Number[]
  • optional
  • default: [1,1,1]

Local scale.

cfg.rotation Number[]
  • optional
  • default: [0,0,0]

Local rotation, as Euler angles given in degrees, for each of the X, Y and Z axis.

cfg.matrix Number[]
  • optional
  • default: [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1] Local modelling transform matrix. Overrides the position, scale and rotation parameters.
cfg.visible Boolean
  • optional
  • default: true

Indicates if the PerformanceModel is initially visible.

cfg.culled Boolean
  • optional
  • default: false

Indicates if the PerformanceModel is initially culled from view.

cfg.pickable Boolean
  • optional
  • default: true

Indicates if the PerformanceModel is initially pickable.

cfg.clippable Boolean
  • optional
  • default: true

Indicates if the PerformanceModel is initially clippable.

cfg.collidable Boolean
  • optional
  • default: true

Indicates if the PerformanceModel is initially included in boundary calculations.

cfg.xrayed Boolean
  • optional
  • default: false

Indicates if the PerformanceModel is initially xrayed.

cfg.highlighted Boolean
  • optional
  • default: false

Indicates if the PerformanceModel is initially highlighted.

cfg.selected Boolean
  • optional
  • default: false

Indicates if the PerformanceModel is initially selected.

cfg.edges Boolean
  • optional
  • default: false

Indicates if the PerformanceModel's edges are initially emphasized.

cfg.colorize Number[]
  • optional
  • default: [1.0,1.0,1.0]

PerformanceModel's initial RGB colorize color, multiplies by the rendered fragment colors.

cfg.opacity Number
  • optional
  • default: 1.0

PerformanceModel's initial opacity factor, multiplies by the rendered fragment alpha.

cfg.preCompressed Boolean
  • optional
  • default: false

When this is true, positions are assumed to be quantized and in World-space, and normals are also assumed to be oct-encoded and in World-space. When true, PerformanceModel#createMesh will ignore matrix, position, scale and rotation parameters.

Public Members

public get aabb: Number[] source

Gets the PerformanceModel's World-space 3D axis-aligned bounding box.

Represented by a six-element Float32Array containing the min/max extents of the axis-aligned volume, ie. [xmin, ymin,zmin,xmax,ymax, zmax].

public set castsShadow: Boolean source

Sets if this PerformanceModel casts a shadow.

public get castsShadow: Boolean source

Gets if this PerformanceModel casts a shadow.

public get clippable: Boolean source

Gets if Entitys in this PerformanceModel are clippable.

Clipping is done by the SectionPlanes in Scene#sectionPlanes.

public set clippable: Boolean source

Sets if Entitys in this PerformanceModel are clippable.

Clipping is done by the SectionPlanes in Scene#sectionPlanes.

public set collidable: Boolean source

Sets if Entitys in this PerformanceModel are collidable.

public get collidable: Boolean source

Gets if this PerformanceModel is collidable.

public get colorize: Number[] source

Gets the RGB colorize color for this PerformanceModel.

Each element of the color is in range [0..1].

public set colorize: Number[] source

Sets the RGB colorize color for this PerformanceModel.

Multiplies by rendered fragment colors.

Each element of the color is in range [0..1].

public get culled: Boolean source

Gets if this PerformanceModel is culled from view.

The PerformanceModel is only rendered when PerformanceModel#visible is true and PerformanceModel#culled is false.

public set culled: Boolean source

Sets if this PerformanceModel is culled from view.

The PerformanceModel is only rendered when PerformanceModel#visible is true and PerformanceModel#culled is false.

public get edgeMaterial: EdgeMaterial source

Configures the appearance of edges of Entitys within this PerformanceModel.

This is the Scene#edgeMaterial.

public get edges: Boolean source

Gets if any Entitys in this PerformanceModel have edges emphasised.

public set edges: Boolean source

Sets if all Entitys in this PerformanceModel have edges emphasised.

public get highlightMaterial: EmphasisMaterial source

Configures the appearance of highlighted Entitys within this PerformanceModel.

This is the Scene#highlightMaterial.

public get highlighted: Boolean source

Gets if any Entitys in this PerformanceModel are highlighted.

public set highlighted: Boolean source

Sets if all Entitys in this PerformanceModel are highlighted.

public get isDrawable: Boolean source

Returns true to indicate that PerformanceModel is implements Drawable.

public get isEntity: Boolean source

Returns true to indicate that PerformanceModel is an Entity.

public get isModel: Boolean source

Returns true if this PerformanceModel represents a model.

When true the PerformanceModel will be registered by PerformanceModel#id in Scene#models and may also have a MetaObject with matching MetaObject#id.

public get isObject: Boolean source

Returns false to indicate that PerformanceModel never represents an object.

public get isPerformanceModel: Boolean source

Returns true to indicate that this Component is a PerformanceModel.

public get matrix: Number[] source

Gets the PerformanceModel's local modeling transform matrix.

Default value is [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1].

public set opacity: Number source

Sets the opacity factor for this PerformanceModel.

This is a factor in range [0..1] which multiplies by the rendered fragment alphas.

public get opacity: Number source

Gets this PerformanceModel's opacity factor.

This is a factor in range [0..1] which multiplies by the rendered fragment alphas.

public set pickable: Boolean source

Sets if Entitys in this PerformanceModel are pickable.

Picking is done via calls to Scene#pick.

public get pickable: Boolean source

Gets if this PerformanceModel is pickable.

Picking is done via calls to Scene#pick.

public get position: Number[] source

Gets the PerformanceModel's local translation.

Default value is [0,0,0].

public get quaternion: Number[] source

Gets the PerformanceModels's local rotation quaternion.

Default value is [0,0,0,1].

public get receivesShadow: Boolean source

Sets if this PerformanceModel can have shadow cast upon it.

public set receivesShadow: Boolean source

Sets if this PerformanceModel can have shadow cast upon it.

public get rotation: Number[] source

Gets the PerformanceModel's local rotation, as Euler angles given in degrees, for each of the X, Y and Z axis.

Default value is [0,0,0].

public get scale: Number[] source

Gets the PerformanceModel's local scale.

Default value is [1,1,1].

public get selected: Boolean source

Gets if any Entitys in this PerformanceModel are selected.

public set selected: Boolean source

Sets if all Entitys in this PerformanceModel are selected.

public get selectedMaterial: EmphasisMaterial source

Configures the appearance of selected Entitys within this PerformanceModel.

This is the Scene#selectedMaterial.

public set visible: Boolean source

Sets if this PerformanceModel is visible.

The PerformanceModel is only rendered when PerformanceModel#visible is true and PerformanceModel#culled is false. *

public get visible: Boolean source

Gets if any Entitys in this PerformanceModel are visible.

The PerformanceModel is only rendered when PerformanceModel#visible is true and PerformanceModel#culled is false.

public get worldMatrix: Number[] source

Gets the PerformanceModel's World matrix.

Properties:

NameTypeAttributeDescription
worldMatrix *

public get worldNormalMatrix: Number[] source

Gets the PerformanceModel's World normal matrix.

public get xrayMaterial: EmphasisMaterial source

Configures the appearance of xrayed Entitys within this PerformanceModel.

This is the Scene#xrayMaterial.

public get xrayed: Boolean source

Gets if any Entitys in this PerformanceModel are xrayed.

public set xrayed: Boolean source

Sets if all Entitys in this PerformanceModel are xrayed.

Public Methods

public createEntity(cfg: Object): Entity source

Creates an Entity within this PerformanceModel, giving it one or more meshes previously created with PerformanceModel#createMesh.

A mesh can only belong to one Entity, so you'll get an error if you try to reuse a mesh among multiple Entitys.

Params:

NameTypeAttributeDescription
cfg Object

Entity configuration.

cfg.id String

Optional ID for the new Entity. Must not clash with any existing components within the Scene.

cfg.tileId String
  • optional

Optional ID of a tile to add the Entity to. The tile must have been created with PerformanceModel#createTile and not yet finalized with PerformanceModel#finalizeTile.

cfg.isObject Boolean
  • optional

Set true if the Entity represents an object, in which case it will be registered by Entity#id in Scene#objects and can also have a corresponding MetaObject with matching MetaObject#id, registered by that ID in MetaScene#metaObjects.

cfg.visible Boolean
  • optional
  • default: true

Indicates if the Entity is initially visible.

cfg.culled Boolean
  • optional
  • default: false

Indicates if the Entity is initially culled from view.

cfg.pickable Boolean
  • optional
  • default: true

Indicates if the Entity is initially pickable.

cfg.clippable Boolean
  • optional
  • default: true

Indicates if the Entity is initially clippable.

cfg.collidable Boolean
  • optional
  • default: true

Indicates if the Entity is initially included in boundary calculations.

cfg.castsShadow Boolean
  • optional
  • default: true

Indicates if the Entity initially casts shadows.

cfg.receivesShadow Boolean
  • optional
  • default: true

Indicates if the Entity initially receives shadows.

cfg.xrayed Boolean
  • optional
  • default: false

Indicates if the Entity is initially xrayed. XRayed appearance is configured by PerformanceModel#xrayMaterial.

cfg.highlighted Boolean
  • optional
  • default: false

Indicates if the Entity is initially highlighted. Highlighted appearance is configured by PerformanceModel#highlightMaterial.

cfg.selected Boolean
  • optional
  • default: false

Indicates if the Entity is initially selected. Selected appearance is configured by PerformanceModel#selectedMaterial.

cfg.edges Boolean
  • optional
  • default: false

Indicates if the Entity's edges are initially emphasized. Edges appearance is configured by PerformanceModel#edgeMaterial.

Return:

Entity

public createGeometry(cfg: *) source

Creates a reusable geometry within this PerformanceModel.

We can then supply the geometry ID to PerformanceModel#createMesh when we want to create meshes that instance the geometry.

Note that positions, normals and indices are all required in geometry data.

Params:

NameTypeAttributeDescription
cfg *

Geometry properties.

cfg.id String | Number

Mandatory ID for the geometry, to refer to with PerformanceModel#createMesh.

cfg.tileId String
  • optional

Optional ID of a tile to add the geometry to. The tile must have been created with PerformanceModel#createTile and not yet finalized with PerformanceModel#finalizeTile.

cfg.primitive String
  • optional
  • default: "triangles"

The primitive type. Accepted values are 'points', 'lines', 'line-loop', 'line-strip', 'triangles', 'triangle-strip' and 'triangle-fan'.

cfg.positions Number[]

Flat array of positions.

cfg.normals Number[]

Flat array of normal vectors.

cfg.indices Number[]

Array of triangle indices.

cfg.edgeIndices Number[]

Array of edge line indices.

public createMesh(cfg: object): * source

Creates a mesh within this PerformanceModel.

A mesh has a geometry, given either as the ID of a shared geometry created with PerformanceModel#createGeometry, or as geometr data arrays to create a unique geometry belong to the mesh.

When you provide a geometry ID, then the PerformanceModelMesh will instance the shared geometry for the mesh.

When you provide arrays, then PerformanceModel will combine the geometry in a batch with the other non-shared unique geometries in the model.

Note that positions, normals and indices are all required in geometry data.

Params:

NameTypeAttributeDescription
cfg object

Object properties.

cfg.id String

Mandatory ID for the new mesh. Must not clash with any existing components within the Scene.

cfg.tileId String
  • optional

Optional ID of a tile to add the mesh to. The tile must have been created with PerformanceModel#createTile and not yet finalized with PerformanceModel#finalizeTile.

cfg.geometryId String | Number
  • optional

ID of a geometry to instance, previously created with {@link PerformanceModel#createGeometry:method"}}createMesh(){{/crossLink}}. Overrides all other geometry parameters given to this method. If a tile ID is also given, then the geometry must exist within that tile.

cfg.primitive String
  • optional
  • default: "triangles"

Geometry primitive type. Ignored when geometryId is given. Accepted values are 'points', 'lines', 'line-loop', 'line-strip', 'triangles', 'triangle-strip' and 'triangle-fan'.

cfg.positions Number[]
  • optional

Flat array of geometry positions. Ignored when geometryId is given.

cfg.normals Number[]
  • optional

Flat array of normal vectors. Ignored when geometryId is given.

cfg.positionsDecodeMatrix Number[]
  • optional

A 4x4 matrix for decompressing positions. Only used when preCompressed is true.

cfg.indices Number[]
  • optional

Array of triangle indices. Ignored when geometryId is given.

cfg.edgeIndices Number[]
  • optional

Array of edge line indices. Ignored when geometryId is given.

cfg.position Number[]
  • optional
  • default: [0,0,0]

Local 3D position. of the mesh

cfg.scale Number[]
  • optional
  • default: [1,1,1]

Scale of the mesh.

cfg.rotation Number[]
  • optional
  • default: [0,0,0]

Rotation of the mesh as Euler angles given in degrees, for each of the X, Y and Z axis.

cfg.matrix Number[]
  • optional
  • default: [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]

Mesh modelling transform matrix. Overrides the position, scale and rotation parameters.

cfg.color Number[]
  • optional
  • default: [1,1,1]

RGB color in range [0..1, 0..`, 0..1].

cfg.opacity Number
  • optional
  • default: 1

Opacity in range [0..1].

Return:

*

public createTile(cfg: *) source

Starts building a tile.

Tiles are used to incrementally show the Entitys within a PerformanceModel as it is being built. As each geometry, mesh or Entity is created in the PerformanceModel, it may be optionally added to a tile. When that tile is then finalized, then all its Entitys are immediately created within the Scene.

Params:

NameTypeAttributeDescription
cfg *

Geometry properties.

cfg.id String | Number

Mandatory ID for the tile, to refer to with PerformanceModel#finalizeTile.

public destroy() source

Destroys this PerformanceModel.

Override:

Component#destroy

public finalize() source

Finalizes this PerformanceModel.

Implicitly finalizes all tiles created with {#link PerformanceModel#createTile}.

Immediately creates the PerformanceModel's Entitys within the Scene.

Once finalized, you can't add anything more to this PerformanceModel.

public finalizeTile(tileId: String) source

Finalizes a tile.

Immediately creates the tile's Entitys within the Scene.

Once finalized, you can't add anything more to the tile.

Params:

NameTypeAttributeDescription
tileId String

ID of tile previously created with PerformanceModel#createTile.