Reference Source
public interface | source

SceneModel

Direct Implemented:

Abstract base class for buildable 3D scene model classes.

Defines methods to build geometries, textures, meshes and entities within the model.

Implementations:

  • VBOSceneModel - WebGL2-based model representation that stores geometry as vertex buffer objects (VBOs).

Member Summary

Public Members
public get abstract

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

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

public get abstract

Sets if backfaces are rendered for this SceneModel.

public set abstract

Sets if backfaces are rendered for this SceneModel.

public get abstract

Gets if this SceneModel casts a shadow.

public set abstract

Sets if this SceneModel casts a shadow.

public get abstract

Gets if Entitys in this SceneModel are clippable.

public set abstract

Sets if Entitys in this SceneModel are clippable.

public get abstract

Gets if this SceneModel is collidable.

public set abstract

Sets if Entitys in this SceneModel are collidable.

public get abstract

Gets if color textures are enabled for this SceneModel.

public get abstract

Gets the RGB colorize color for this SceneModel.

public set abstract

Sets the RGB colorize color for this SceneModel.

public get abstract

Gets if this SceneModel is culled from view.

public set abstract

Sets if this SceneModel is culled from view.

public get abstract

Configures the appearance of edges of Entitys within this SceneModel.

public get abstract

Gets if any Entitys in this SceneModel have edges emphasised.

public set abstract

Sets if all Entitys in this SceneModel have edges emphasised.

public get abstract

Gets the list of Entitys within this SceneModel.

public get abstract

Configures the appearance of highlighted Entitys within this SceneModel.

public get abstract

Gets if any Entitys in this SceneModel are highlighted.

public set abstract

Sets if all Entitys in this SceneModel are highlighted.

public get abstract

Returns true to indicate that SceneModel is implements Drawable.

public get abstract

Returns true to indicate that SceneModel is an Entity.

public get abstract

Returns true if this SceneModel represents a model.

public get abstract

Returns false to indicate that SceneModel never represents an object.

public get abstract

Gets the SceneModel'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 get abstract

The approximate number of line primitives in this SceneModel.

public get abstract

The approximate number of point primitives in this SceneModel.

public get abstract

The approximate number of triangle primitives in this SceneModel.

public get abstract

objects: * | {}

Returns the Entitys in this SceneModel.

public get abstract

Gets this SceneModel's opacity factor.

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

public set abstract

Sets the opacity factor for this SceneModel.

public get abstract

Gets the 3D World-space origin for this SceneModel.

public get abstract

Gets if physically-based rendering (PBR) is enabled for this SceneModel.

public get abstract

Gets if this SceneModel is pickable.

public set abstract

Sets if Entitys in this SceneModel are pickable.

public get abstract

Gets the SceneModel's local translation.

Default value is [0,0,0].

public get abstract

Gets the SceneModels's local rotation quaternion.

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

public get abstract

Sets if this SceneModel can have shadow cast upon it.

public set abstract

Sets if this SceneModel can have shadow cast upon it.

public get abstract

Gets the SceneModel'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 abstract

Gets if Scalable Ambient Obscurance (SAO) will apply to this SceneModel.

public get abstract

Gets the SceneModel's local scale.

Default value is [1,1,1].

public get abstract

Gets if any Entitys in this SceneModel are selected.

public set abstract

Sets if all Entitys in this SceneModel are selected.

public get abstract

Configures the appearance of selected Entitys within this SceneModel.

public get abstract

Gets if any Entitys in this SceneModel are visible.

public set abstract

Sets if this SceneModel is visible.

public get abstract

Gets the SceneModel's World matrix.

public get abstract

Gets the SceneModel's World normal matrix.

public get abstract

Configures the appearance of xrayed Entitys within this SceneModel.

public get abstract

Gets if any Entitys in this SceneModel are xrayed.

public set abstract

Sets if all Entitys in this SceneModel are xrayed.

Method Summary

Public Methods
public abstract

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

public abstract

createGeometry(cfg: *)

Creates a reusable geometry within this SceneModel.

public abstract

Creates a mesh within this SceneModel.

public abstract

createTexture(cfg: *)

Creates a texture within this SceneModel.

public abstract

Creates a texture set within this SceneModel.

public abstract

Destroys this SceneModel.

public abstract

Finalizes this SceneModel.

Public Members

public get abstract aabb: Number[] source

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

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

public get abstract backfaces: Boolean source

Sets if backfaces are rendered for this SceneModel.

Default is false.

public set abstract backfaces: Boolean source

Sets if backfaces are rendered for this SceneModel.

Default is false.

When we set this true, then backfaces are always rendered for this SceneModel.

When we set this false, then we allow the Viewer to decide whether to render backfaces. In this case, the Viewer will:

  • hide backfaces on watertight meshes,
  • show backfaces on open meshes, and
  • always show backfaces on meshes when we slice them open with SectionPlanes.

public get abstract castsShadow: Boolean source

Gets if this SceneModel casts a shadow.

public set abstract castsShadow: Boolean source

Sets if this SceneModel casts a shadow.

public get abstract clippable: Boolean source

Gets if Entitys in this SceneModel are clippable.

Clipping is done by the SectionPlanes in Scene#sectionPlanes.

public set abstract clippable: Boolean source

Sets if Entitys in this SceneModel are clippable.

Clipping is done by the SectionPlanes in Scene#sectionPlanes.

public get abstract collidable: Boolean source

Gets if this SceneModel is collidable.

public set abstract collidable: Boolean source

Sets if Entitys in this SceneModel are collidable.

public get abstract colorTextureEnabled: Boolean source

Gets if color textures are enabled for this SceneModel.

Only works when Scene#colorTextureEnabled is also true.

public get abstract colorize: Number[] source

Gets the RGB colorize color for this SceneModel.

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

public set abstract colorize: Number[] source

Sets the RGB colorize color for this SceneModel.

Multiplies by rendered fragment colors.

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

public get abstract culled: Boolean source

Gets if this SceneModel is culled from view.

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

public set abstract culled: Boolean source

Sets if this SceneModel is culled from view.

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

public get abstract edgeMaterial: EdgeMaterial source

Configures the appearance of edges of Entitys within this SceneModel.

This is the Scene#edgeMaterial.

public get abstract edges: Boolean source

Gets if any Entitys in this SceneModel have edges emphasised.

public set abstract edges: Boolean source

Sets if all Entitys in this SceneModel have edges emphasised.

public get abstract entityList: Entity[] source

Gets the list of Entitys within this SceneModel.

Return:

Entity[]

public get abstract highlightMaterial: EmphasisMaterial source

Configures the appearance of highlighted Entitys within this SceneModel.

This is the Scene#highlightMaterial.

public get abstract highlighted: Boolean source

Gets if any Entitys in this SceneModel are highlighted.

public set abstract highlighted: Boolean source

Sets if all Entitys in this SceneModel are highlighted.

public get abstract isDrawable: Boolean source

Returns true to indicate that SceneModel is implements Drawable.

public get abstract isEntity: Boolean source

Returns true to indicate that SceneModel is an Entity.

public get abstract isModel: Boolean source

Returns true if this SceneModel represents a model.

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

public get abstract isObject: Boolean source

Returns false to indicate that SceneModel never represents an object.

public get abstract matrix: Number[] source

Gets the SceneModel'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 get abstract numLines: Number source

The approximate number of line primitives in this SceneModel.

public get abstract numPoints: Number source

The approximate number of point primitives in this SceneModel.

public get abstract numTriangles: Number source

The approximate number of triangle primitives in this SceneModel.

public get abstract objects: * | {} source

Returns the Entitys in this SceneModel.

Return:

* | {}

public get abstract opacity: Number source

Gets this SceneModel's opacity factor.

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

public set abstract opacity: Number source

Sets the opacity factor for this SceneModel.

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

public get abstract origin: Float64Array source

Gets the 3D World-space origin for this SceneModel.

Each geometry or mesh origin, if supplied, is relative to this origin.

Default value is [0,0,0].

public get abstract pbrEnabled: Boolean source

Gets if physically-based rendering (PBR) is enabled for this SceneModel.

Only works when Scene#pbrEnabled is also true.

public get abstract pickable: Boolean source

Gets if this SceneModel is pickable.

Picking is done via calls to Scene#pick.

public set abstract pickable: Boolean source

Sets if Entitys in this SceneModel are pickable.

Picking is done via calls to Scene#pick.

public get abstract position: Number[] source

Gets the SceneModel's local translation.

Default value is [0,0,0].

public get abstract quaternion: Number[] source

Gets the SceneModels's local rotation quaternion.

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

public get abstract receivesShadow: Boolean source

Sets if this SceneModel can have shadow cast upon it.

public set abstract receivesShadow: Boolean source

Sets if this SceneModel can have shadow cast upon it.

public get abstract rotation: Number[] source

Gets the SceneModel'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 abstract saoEnabled: Boolean source

Gets if Scalable Ambient Obscurance (SAO) will apply to this SceneModel.

SAO is configured by the Scene's SAO component.

Only works when SAO#enabled is also true.

public get abstract scale: Number[] source

Gets the SceneModel's local scale.

Default value is [1,1,1].

public get abstract selected: Boolean source

Gets if any Entitys in this SceneModel are selected.

public set abstract selected: Boolean source

Sets if all Entitys in this SceneModel are selected.

public get abstract selectedMaterial: EmphasisMaterial source

Configures the appearance of selected Entitys within this SceneModel.

This is the Scene#selectedMaterial.

public get abstract visible: Boolean source

Gets if any Entitys in this SceneModel are visible.

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

public set abstract visible: Boolean source

Sets if this SceneModel is visible.

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

public get abstract worldMatrix: Number[] source

Gets the SceneModel's World matrix.

Properties:

NameTypeAttributeDescription
worldMatrix *

public get abstract worldNormalMatrix: Number[] source

Gets the SceneModel's World normal matrix.

public get abstract xrayMaterial: EmphasisMaterial source

Configures the appearance of xrayed Entitys within this SceneModel.

This is the Scene#xrayMaterial.

public get abstract xrayed: Boolean source

Gets if any Entitys in this SceneModel are xrayed.

public set abstract xrayed: Boolean source

Sets if all Entitys in this SceneModel are xrayed.

Public Methods

public abstract createEntity(cfg: Object): Entity source

Creates an Entity within this SceneModel, giving it one or more meshes previously created with SceneModel#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.meshIds String[]

IDs of one or more meshes created previously with {@link SceneModel@createMesh}.

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 SceneModel#xrayMaterial.

cfg.highlighted Boolean
  • optional
  • default: false

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

cfg.selected Boolean
  • optional
  • default: false

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

cfg.edges Boolean
  • optional
  • default: false

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

Return:

Entity

public abstract createGeometry(cfg: *) source

Creates a reusable geometry within this SceneModel.

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

Params:

NameTypeAttributeDescription
cfg *

Geometry properties.

cfg.id String | Number

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

cfg.primitive String

The primitive type. Accepted values are 'points', 'lines', 'triangles', 'solid' and 'surface'.

cfg.positions Number[]
  • optional

Flat array of uncompressed 3D vertex positions positions. Required for all primitive types. Overridden by positionsCompressed.

cfg.positionsCompressed Number[]
  • optional

Flat array of quantized 3D vertex positions. Overrides positions, and must be accompanied by positionsDecodeMatrix.

cfg.positionsDecodeMatrix Number[]
  • optional

A 4x4 matrix for decompressing positionsCompressed. Must be accompanied by positionsCompressed.

cfg.normals Number[]
  • optional

Flat array of normal vectors. Only used with "triangles", "solid" and "surface" primitives. When no normals are given, the geometry will be flat shaded using auto-generated face-aligned normals.

cfg.normalsCompressed Number[]
  • optional

Flat array of oct-encoded normal vectors. Overrides normals. Only used with "triangles", "solid" and "surface" primitives. When no normals are given, the geometry will be flat shaded using auto-generated face-aligned normals.

cfg.colors Number[]
  • optional

Flat array of uncompressed RGBA vertex colors, as float values in range [0..1]. Ignored when geometryId is given. Overridden by color and colorsCompressed.

cfg.colorsCompressed Number[]
  • optional

Flat array of compressed RGBA vertex colors, as unsigned short integers in range [0..255]. Ignored when geometryId is given. Overrides colors and is overridden by color.

cfg.uv Number[]
  • optional

Flat array of uncompressed vertex UV coordinates. Only used with "triangles", "solid" and "surface" primitives. Required for textured rendering.

cfg.uvCompressed Number[]
  • optional

Flat array of compressed vertex UV coordinates. Only used with "triangles", "solid" and "surface" primitives. Overrides uv. Must be accompanied by uvDecodeMatrix. Only used with "triangles", "solid" and "surface" primitives. Required for textured rendering.

cfg.uvDecodeMatrix Number[]
  • optional

A 3x3 matrix for decompressing uvCompressed.

cfg.indices Number[]
  • optional

Array of primitive connectivity indices. Not required for points primitives.

cfg.edgeIndices Number[]
  • optional

Array of edge line indices. Used only with 'triangles', 'solid' and 'surface' primitives. Automatically generated internally if not supplied, using the optional edgeThreshold given to the SceneModel constructor.

cfg.origin Number[]
  • optional

Optional geometry origin, relative to SceneModel#origin. When this is given, then positions are assumed to be relative to this.

public abstract createMesh(cfg: object) source

Creates a mesh within this SceneModel.

A mesh can either define its own geometry or share it with other meshes. To define own geometry, provide the various geometry arrays to this method. To share a geometry, provide the ID of a geometry created earlier with SceneModel#createGeometry.

Internally, SceneModel will batch all unique mesh geometries into the same arrays, which improves rendering performance.

If you accompany the arrays with an origin, then createMesh() will assume that the positions are in relative-to-center (RTC) coordinates, with origin being the origin of their RTC coordinate system.

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.textureSetId String | Number
  • optional

ID of a texture set previously created with {@link SceneModel#createTextureSet"}.

cfg.geometryId String | Number
  • optional

ID of a geometry to instance, previously created with {@link SceneModel#createGeometry"}. Overrides all other geometry parameters given to this method.

cfg.primitive String

The primitive type. Accepted values are 'points', 'lines', 'triangles', 'solid' and 'surface'.

cfg.positions Number[]
  • optional

Flat array of uncompressed 3D vertex positions positions. Required for all primitive types. Overridden by positionsCompressed.

cfg.positionsCompressed Number[]
  • optional

Flat array of quantized 3D vertex positions. Overrides positions, and must be accompanied by positionsDecodeMatrix.

cfg.positionsDecodeMatrix Number[]
  • optional

A 4x4 matrix for decompressing positionsCompressed. Must be accompanied by positionsCompressed.

cfg.normals Number[]
  • optional

Flat array of normal vectors. Only used with "triangles", "solid" and "surface" primitives. When no normals are given, the geometry will be flat shaded using auto-generated face-aligned normals.

cfg.normalsCompressed Number[]
  • optional

Flat array of oct-encoded normal vectors. Overrides normals. Only used with "triangles", "solid" and "surface" primitives. When no normals are given, the geometry will be flat shaded using auto-generated face-aligned normals.

cfg.colors Number[]
  • optional

Flat array of uncompressed RGBA vertex colors, as float values in range [0..1]. Ignored when geometryId is given. Overridden by color and colorsCompressed.

cfg.colorsCompressed Number[]
  • optional

Flat array of compressed RGBA vertex colors, as unsigned short integers in range [0..255]. Ignored when geometryId is given. Overrides colors and is overridden by color.

cfg.uv Number[]
  • optional

Flat array of uncompressed vertex UV coordinates. Only used with "triangles", "solid" and "surface" primitives. Required for textured rendering.

cfg.uvCompressed Number[]
  • optional

Flat array of compressed vertex UV coordinates. Only used with "triangles", "solid" and "surface" primitives. Overrides uv. Must be accompanied by uvDecodeMatrix. Only used with "triangles", "solid" and "surface" primitives. Required for textured rendering.

cfg.uvDecodeMatrix Number[]
  • optional

A 3x3 matrix for decompressing uvCompressed.

cfg.indices Number[]
  • optional

Array of primitive connectivity indices. Not required for points primitives.

cfg.edgeIndices Number[]
  • optional

Array of edge line indices. Used only with 'triangles', 'solid' and 'surface' primitives. Automatically generated internally if not supplied, using the optional edgeThreshold given to the SceneModel constructor.

cfg.origin Number[]
  • optional

Optional geometry origin, relative to SceneModel#origin. When this is given, then positions are assumed to be relative to this.

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..1, 0..1]. Overridden by texture set colorTexture. Overrides colors and colorsCompressed.

cfg.opacity Number
  • optional
  • default: 1

Opacity in range [0..1]. Overridden by texture set colorTexture.

cfg.metallic Number
  • optional
  • default: 0

Metallic factor in range [0..1]. Overridden by texture set metallicRoughnessTexture.

cfg.roughness Number
  • optional
  • default: 1

Roughness factor in range [0..1]. Overridden by texture set metallicRoughnessTexture.

public abstract createTexture(cfg: *) source

Creates a texture within this SceneModel.

We can then supply the texture ID to SceneModel#createTextureSet when we want to create texture sets that use the texture.

Params:

NameTypeAttributeDescription
cfg *

Texture properties.

cfg.id String | Number

Mandatory ID for the texture, to refer to with VBOSceneModel#createTextureSet.

cfg.src String
  • optional

Image file for the texture. Assumed to be transcoded if not having a recognized image file extension (jpg, jpeg, png etc.). If transcoded, then assumes VBOSceneModel is configured with a TextureTranscoder.

cfg.buffers ArrayBuffer[]
  • optional

Transcoded texture data. Assumes VBOSceneModel is configured with a TextureTranscoder. This parameter is given as an array of buffers so we can potentially support multi-image textures, such as cube maps.

cfg.image HTMLImageElement
  • optional

HTML Image object to load into this texture. Overrides src and buffers. Never transcoded.

cfg.minFilter Number
  • optional
  • default: LinearMipmapLinearFilter

How the texture is sampled when a texel covers less than one pixel. Supported values are LinearMipmapLinearFilter, LinearMipMapNearestFilter, NearestMipMapNearestFilter, NearestMipMapLinearFilter and LinearMipMapLinearFilter.

cfg.magFilter Number
  • optional
  • default: LinearFilter

How the texture is sampled when a texel covers more than one pixel. Supported values are LinearFilter and NearestFilter.

cfg.wrapS Number
  • optional
  • default: RepeatWrapping

Wrap parameter for texture coordinate S. Supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping.

cfg.wrapT Number
  • optional
  • default: RepeatWrapping

Wrap parameter for texture coordinate T. Supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping.

cfg.wrapR Number
  • optional
  • default: RepeatWrapping

Wrap parameter for texture coordinate R. Supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping.

cfg.flipY Boolean
  • optional
  • default: false

Flips this Texture's source data along its vertical axis when true.

cfg.encoding Number
  • optional
  • default: LinearEncoding

Encoding format. Supported values are LinearEncoding and sRGBEncoding.

public abstract createTextureSet(cfg: *) source

Creates a texture set within this SceneModel.

A texture set is a collection of textures that can be shared among meshes. We can then supply the texture set ID to SceneModel#createMesh when we want to create meshes that use the texture set.

The textures can work as a texture atlas, where each mesh can have geometry UVs that index a different part of the textures. This allows us to minimize the number of textures in our models, which means faster rendering.

Params:

NameTypeAttributeDescription
cfg *

Texture set properties.

cfg.id String | Number

Mandatory ID for the texture set, to refer to with SceneModel#createMesh.

cfg.colorTextureId *
  • optional

ID of RGBA base color texture, with color in RGB and alpha in A.

cfg.metallicRoughnessTextureId *
  • optional

ID of RGBA metal-roughness texture, with the metallic factor in R, and roughness factor in G.

cfg.normalsTextureId *
  • optional

ID of RGBA normal map texture, with normal map vectors in RGB.

cfg.emissiveTextureId *
  • optional

ID of RGBA emissive map texture, with emissive color in RGB.

cfg.occlusionTextureId *
  • optional

ID of RGBA occlusion map texture, with occlusion factor in R.

public abstract destroy() source

Destroys this SceneModel.

public abstract finalize() source

Finalizes this SceneModel.

Immediately creates the SceneModel's Entitys within the Scene.

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