import {SceneModel} from '@xeokit/xeokit-sdk/src/viewer/scene/models/SceneModel.js'
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. |
|
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 |
entityList: Entity[] 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 |
|
public get abstract |
Returns |
|
public get abstract |
Gets the SceneModel's local modeling transform matrix. Default value is |
|
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 |
|
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 |
|
public get abstract |
quaternion: Number[] Gets the SceneModels's local rotation quaternion. Default value is |
|
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 |
|
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 |
|
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 |
createEntity(cfg: Object): Entity 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 |
createMesh(cfg: object) Creates a mesh within this SceneModel. |
|
public abstract |
createTexture(cfg: *) Creates a texture within this SceneModel. |
|
public abstract |
createTextureSet(cfg: *) Creates a texture set within this SceneModel. |
|
public abstract |
destroy() Destroys this SceneModel. |
|
public abstract |
finalize() 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 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 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 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 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 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 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:
Name | Type | Attribute | Description |
worldMatrix | * |
public get abstract xrayMaterial: EmphasisMaterial source
Configures the appearance of xrayed Entitys within this SceneModel.
This is the Scene#xrayMaterial.
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:
Name | Type | Attribute | Description |
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 |
|
Set |
cfg.visible | Boolean |
|
Indicates if the Entity is initially visible. |
cfg.culled | Boolean |
|
Indicates if the Entity is initially culled from view. |
cfg.pickable | Boolean |
|
Indicates if the Entity is initially pickable. |
cfg.clippable | Boolean |
|
Indicates if the Entity is initially clippable. |
cfg.collidable | Boolean |
|
Indicates if the Entity is initially included in boundary calculations. |
cfg.castsShadow | Boolean |
|
Indicates if the Entity initially casts shadows. |
cfg.receivesShadow | Boolean |
|
Indicates if the Entity initially receives shadows. |
cfg.xrayed | Boolean |
|
Indicates if the Entity is initially xrayed. XRayed appearance is configured by SceneModel#xrayMaterial. |
cfg.highlighted | Boolean |
|
Indicates if the Entity is initially highlighted. Highlighted appearance is configured by SceneModel#highlightMaterial. |
cfg.selected | Boolean |
|
Indicates if the Entity is initially selected. Selected appearance is configured by SceneModel#selectedMaterial. |
cfg.edges | Boolean |
|
Indicates if the Entity's edges are initially emphasized. Edges appearance is configured by SceneModel#edgeMaterial. |
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:
Name | Type | Attribute | Description |
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[] |
|
Flat array of uncompressed 3D vertex positions positions. Required for all primitive types. Overridden by |
cfg.positionsCompressed | Number[] |
|
Flat array of quantized 3D vertex positions. Overrides |
cfg.positionsDecodeMatrix | Number[] |
|
A 4x4 matrix for decompressing |
cfg.normals | Number[] |
|
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[] |
|
Flat array of oct-encoded normal vectors. Overrides |
cfg.colors | Number[] |
|
Flat array of uncompressed RGBA vertex colors, as float values in range |
cfg.colorsCompressed | Number[] |
|
Flat array of compressed RGBA vertex colors, as unsigned short integers in range |
cfg.uv | Number[] |
|
Flat array of uncompressed vertex UV coordinates. Only used with "triangles", "solid" and "surface" primitives. Required for textured rendering. |
cfg.uvCompressed | Number[] |
|
Flat array of compressed vertex UV coordinates. Only used with "triangles", "solid" and "surface" primitives. Overrides |
cfg.uvDecodeMatrix | Number[] |
|
A 3x3 matrix for decompressing |
cfg.indices | Number[] |
|
Array of primitive connectivity indices. Not required for |
cfg.edgeIndices | Number[] |
|
Array of edge line indices. Used only with 'triangles', 'solid' and 'surface' primitives. Automatically generated internally if not supplied, using the optional |
cfg.origin | Number[] |
|
Optional geometry origin, relative to SceneModel#origin. When this is given, then |
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:
Name | Type | Attribute | Description |
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 |
|
ID of a texture set previously created with {@link SceneModel#createTextureSet"}. |
cfg.geometryId | String | Number |
|
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[] |
|
Flat array of uncompressed 3D vertex positions positions. Required for all primitive types. Overridden by |
cfg.positionsCompressed | Number[] |
|
Flat array of quantized 3D vertex positions. Overrides |
cfg.positionsDecodeMatrix | Number[] |
|
A 4x4 matrix for decompressing |
cfg.normals | Number[] |
|
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[] |
|
Flat array of oct-encoded normal vectors. Overrides |
cfg.colors | Number[] |
|
Flat array of uncompressed RGBA vertex colors, as float values in range |
cfg.colorsCompressed | Number[] |
|
Flat array of compressed RGBA vertex colors, as unsigned short integers in range |
cfg.uv | Number[] |
|
Flat array of uncompressed vertex UV coordinates. Only used with "triangles", "solid" and "surface" primitives. Required for textured rendering. |
cfg.uvCompressed | Number[] |
|
Flat array of compressed vertex UV coordinates. Only used with "triangles", "solid" and "surface" primitives. Overrides |
cfg.uvDecodeMatrix | Number[] |
|
A 3x3 matrix for decompressing |
cfg.indices | Number[] |
|
Array of primitive connectivity indices. Not required for |
cfg.edgeIndices | Number[] |
|
Array of edge line indices. Used only with 'triangles', 'solid' and 'surface' primitives. Automatically generated internally if not supplied, using the optional |
cfg.origin | Number[] |
|
Optional geometry origin, relative to SceneModel#origin. When this is given, then |
cfg.position | Number[] |
|
Local 3D position of the mesh. |
cfg.scale | Number[] |
|
Scale of the mesh. |
cfg.rotation | Number[] |
|
Rotation of the mesh as Euler angles given in degrees, for each of the X, Y and Z axis. |
cfg.matrix | Number[] |
|
Mesh modelling transform matrix. Overrides the |
cfg.color | Number[] |
|
RGB color in range |
cfg.opacity | Number |
|
Opacity in range |
cfg.metallic | Number |
|
Metallic factor in range |
cfg.roughness | Number |
|
Roughness factor in range |
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:
Name | Type | Attribute | Description |
cfg | * | Texture properties. |
|
cfg.id | String | Number | Mandatory ID for the texture, to refer to with VBOSceneModel#createTextureSet. |
|
cfg.src | String |
|
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 |
cfg.buffers | ArrayBuffer[] |
|
Transcoded texture data. Assumes |
cfg.image | HTMLImageElement |
|
HTML Image object to load into this texture. Overrides |
cfg.minFilter | Number |
|
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 |
|
How the texture is sampled when a texel covers more than one pixel. Supported values are LinearFilter and NearestFilter. |
cfg.wrapS | Number |
|
Wrap parameter for texture coordinate S. Supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. |
cfg.wrapT | Number |
|
Wrap parameter for texture coordinate T. Supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. |
cfg.wrapR | Number |
|
Wrap parameter for texture coordinate R. Supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. |
cfg.flipY | Boolean |
|
Flips this Texture's source data along its vertical axis when |
cfg.encoding | Number |
|
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:
Name | Type | Attribute | Description |
cfg | * | Texture set properties. |
|
cfg.id | String | Number | Mandatory ID for the texture set, to refer to with SceneModel#createMesh. |
|
cfg.colorTextureId | * |
|
ID of RGBA base color texture, with color in RGB and alpha in A. |
cfg.metallicRoughnessTextureId | * |
|
ID of RGBA metal-roughness texture, with the metallic factor in R, and roughness factor in G. |
cfg.normalsTextureId | * |
|
ID of RGBA normal map texture, with normal map vectors in RGB. |
cfg.emissiveTextureId | * |
|
ID of RGBA emissive map texture, with emissive color in RGB. |
cfg.occlusionTextureId | * |
|
ID of RGBA occlusion map texture, with occlusion factor in R. |