Reference Source
public class | source

XKTModel

A document model that represents the contents of an .XKT file.

Usage

See main docs page for usage examples.

Constructor Summary

Public Constructor
public

constructor(cfg: *)

Constructs a new XKTModel.

Member Summary

Public Members
public

The axis-aligned 3D World-space boundary of this XKTModel.

public

The model author, if available.

public

The date the model was created, if available.

public

The application that created the model, if available.

public
public

entities: {String: XKTEntity}

Map of XKTEntitys within this XKTModel, each mapped to XKTEntity#entityId.

public

XKTEntitys within this XKTModel.

public

Indicates if this XKTModel has been finalized.

public

geometries: {Number: XKTGeometry}

Map of XKTGeometrys within this XKTModel, each mapped to XKTGeometry#geometryId.

public

List of XKTGeometrys within this XKTModel, in the order they were created.

public

meshes: {Number: XKTMesh}

Map of XKTMeshs within this XKTModel, each mapped to XKTMesh#meshId.

public

List of XKTMeshs within this XKTModel, in the order they were created.

public

Map of XKTMetaObjects within this XKTModel, each mapped to XKTMetaObject#metaObjectId.

public

XKTMetaObjects within this XKTModel.

public

Minimum diagonal size of the boundary of an XKTTile.

public

Optional overall AABB that contains all the XKTEntitys we'll create in this model, if previously known.

This is the AABB of a complete set of input files that are provided as a split-model set for conversion.

This is used to help the XKTTile.aabbs within split models align neatly with each other, as we build them with a k-d tree in XKTModel#finalize. Without this, the AABBs of the different parts tend to misalign slightly, resulting in excess number of XKTTiles, which degrades memory and rendering performance when the XKT is viewer in the xeokit Viewer.

public

The model's ID, if available.

Will be "default" by default.

public

The project ID, if available.

public

Map of XKTPropertySets within this XKTModel, each mapped to XKTPropertySet#propertySetId.

public

XKTPropertySets within this XKTModel.

public

The positions of all shared XKTGeometrys are de-quantized using this singular de-quantization matrix.

public

The revision ID, if available.

public

The model schema version, if available.

public

Map of XKTTextureSets within this XKTModel, each mapped to XKTTextureSet#textureSetId.

public

List of XKTTextureSets within this XKTModel, in the order they were created.

public

textures: {Number: XKTTexture}

Map of XKTTextures within this XKTModel, each mapped to XKTTexture#textureId.

public

List of XKTTextures within this XKTModel, in the order they were created.

public

XKTTiles within this XKTModel.

public

The XKT format version.

Method Summary

Public Methods
public

Creates a default XKTMetaObject for each XKTEntity that does not already have one.

public

createEntity(params: *): XKTEntity

Creates an XKTEntity within this XKTModel.

public

Creates an XKTGeometry within this XKTModel.

public

createMesh(params: *): XKTMesh

Creates an XKTMesh within this XKTModel.

public

Creates an XKTMetaObject within this XKTModel.

public

Creates an XKTPropertySet within this XKTModel.

public

Creates an XKTTexture within this XKTModel.

public

Creates an XKTTextureSet within this XKTModel.

public

async finalize()

Finalizes this XKTModel.

Public Constructors

public constructor(cfg: *) source

Constructs a new XKTModel.

Params:

NameTypeAttributeDescription
cfg *
  • optional

Configuration

cfg.edgeThreshold Number
  • optional
  • default: 10
cfg.minTileSize Number
  • optional
  • default: 500

Public Members

public aabb: Float64Array source

The axis-aligned 3D World-space boundary of this XKTModel.

Created by XKTModel#finalize.

public author: String source

The model author, if available.

Will be an empty string by default.

Properties:

NameTypeAttributeDescription
author *

public createdAt: String source

The date the model was created, if available.

Will be an empty string by default.

Properties:

NameTypeAttributeDescription
createdAt *

public creatingApplication: String source

The application that created the model, if available.

Will be an empty string by default.

Properties:

NameTypeAttributeDescription
creatingApplication *

public edgeThreshold: Number | number source

public entities: {String: XKTEntity} source

Map of XKTEntitys within this XKTModel, each mapped to XKTEntity#entityId.

Created by XKTModel#createEntity.

public entitiesList: XKTEntity[] source

XKTEntitys within this XKTModel.

Each XKTEntity holds its position in this list in XKTEntity#entityIndex.

Created by XKTModel#finalize.

public finalized: boolean source

Indicates if this XKTModel has been finalized.

Set true by XKTModel#finalize.

public geometries: {Number: XKTGeometry} source

Map of XKTGeometrys within this XKTModel, each mapped to XKTGeometry#geometryId.

Created by XKTModel#createGeometry.

public geometriesList: XKTGeometry[] source

List of XKTGeometrys within this XKTModel, in the order they were created.

Each XKTGeometry holds its position in this list in XKTGeometry#geometryIndex.

Created by XKTModel#finalize.

public meshes: {Number: XKTMesh} source

Map of XKTMeshs within this XKTModel, each mapped to XKTMesh#meshId.

Created by XKTModel#createMesh.

public meshesList: XKTMesh[] source

List of XKTMeshs within this XKTModel, in the order they were created.

Each XKTMesh holds its position in this list in XKTMesh#meshIndex.

Created by XKTModel#finalize.

public metaObjects: {String: XKTMetaObject} source

Map of XKTMetaObjects within this XKTModel, each mapped to XKTMetaObject#metaObjectId.

Created by XKTModel#createMetaObject.

public metaObjectsList: XKTMetaObject[] source

XKTMetaObjects within this XKTModel.

Each XKTMetaObject holds its position in this list in XKTMetaObject#metaObjectIndex.

Created by XKTModel#finalize.

public minTileSize: Number | number source

Minimum diagonal size of the boundary of an XKTTile.

public modelAABB: * source

Optional overall AABB that contains all the XKTEntitys we'll create in this model, if previously known.

This is the AABB of a complete set of input files that are provided as a split-model set for conversion.

This is used to help the XKTTile.aabbs within split models align neatly with each other, as we build them with a k-d tree in XKTModel#finalize. Without this, the AABBs of the different parts tend to misalign slightly, resulting in excess number of XKTTiles, which degrades memory and rendering performance when the XKT is viewer in the xeokit Viewer.

public modelId: String source

The model's ID, if available.

Will be "default" by default.

public projectId: String source

The project ID, if available.

Will be an empty string by default.

public propertySets: {String: XKTPropertySet} source

Map of XKTPropertySets within this XKTModel, each mapped to XKTPropertySet#propertySetId.

Created by XKTModel#createPropertySet.

public propertySetsList: XKTPropertySet[] source

XKTPropertySets within this XKTModel.

Each XKTPropertySet holds its position in this list in XKTPropertySet#propertySetIndex.

Created by XKTModel#finalize.

public reusedGeometriesDecodeMatrix: Float32Array source

The positions of all shared XKTGeometrys are de-quantized using this singular de-quantization matrix.

This de-quantization matrix is generated from the collective Local-space boundary of the positions of all shared XKTGeometrys.

public revisionId: String source

The revision ID, if available.

Will be an empty string by default.

public schema: String source

The model schema version, if available.

In the case of IFC, this could be "IFC2x3" or "IFC4", for example.

Will be an empty string by default.

Properties:

NameTypeAttributeDescription
schema *

public textureSets: {Number: XKTTextureSet} source

Map of XKTTextureSets within this XKTModel, each mapped to XKTTextureSet#textureSetId.

Created by XKTModel#createTextureSet.

public textureSetsList: XKTTextureSet[] source

List of XKTTextureSets within this XKTModel, in the order they were created.

Each XKTTextureSet holds its position in this list in XKTTextureSet#textureSetIndex.

Created by XKTModel#finalize.

public textures: {Number: XKTTexture} source

Map of XKTTextures within this XKTModel, each mapped to XKTTexture#textureId.

Created by XKTModel#createTexture.

public texturesList: XKTTexture[] source

List of XKTTextures within this XKTModel, in the order they were created.

Each XKTTexture holds its position in this list in XKTTexture#textureIndex.

Created by XKTModel#finalize.

public tilesList: XKTTile[] source

XKTTiles within this XKTModel.

Created by XKTModel#finalize.

public xktVersion: number source

The XKT format version.

Properties:

NameTypeAttributeDescription
xktVersion; *

Public Methods

public createDefaultMetaObjects() source

Creates a default XKTMetaObject for each XKTEntity that does not already have one.

public createEntity(params: *): XKTEntity source

Creates an XKTEntity within this XKTModel.

Registers the new XKTEntity in XKTModel#entities and XKTModel#entitiesList.

Logs error and does nothing if this XKTModel has been finalized (see XKTModel#finalized).

Params:

NameTypeAttributeDescription
params *

Method parameters.

params.entityId String

Unique ID for the XKTEntity.

params.meshIds String[]

IDs of XKTMeshes used by the XKTEntity. Note that each XKTMesh can only be used by one XKTEntity.

Return:

XKTEntity

The new XKTEntity.

public createGeometry(params: *): XKTGeometry source

Creates an XKTGeometry within this XKTModel.

Registers the new XKTGeometry in XKTModel#geometries and XKTModel#geometriesList.

Logs error and does nothing if this XKTModel has been finalized (see XKTModel#finalized).

Params:

NameTypeAttributeDescription
params *

Method parameters.

params.geometryId Number

Unique ID for the XKTGeometry.

params.primitiveType String

The type of XKTGeometry: "triangles", "lines" or "points".

params.positions Float64Array

Floating-point Local-space vertex positions for the XKTGeometry. Required for all primitive types.

params.normals Number[]
  • optional

Floating-point vertex normals for the XKTGeometry. Only used with triangles primitives. Ignored for points and lines.

params.colors Number[]
  • optional

Floating-point RGBA vertex colors for the XKTGeometry. Required for points primitives. Ignored for lines and triangles.

params.colorsCompressed Number[]
  • optional

Integer RGBA vertex colors for the XKTGeometry. Required for points primitives. Ignored for lines and triangles.

params.uvs Number[]
  • optional

Floating-point vertex UV coordinates for the XKTGeometry. Alias for uv.

params.uv Number[]
  • optional

Floating-point vertex UV coordinates for the XKTGeometry. Alias for uvs.

params.colorsCompressed Number[]
  • optional

Integer RGBA vertex colors for the XKTGeometry. Required for points primitives. Ignored for lines and triangles.

params.indices Uint32Array
  • optional

Indices for the XKTGeometry. Required for triangles and lines primitives. Ignored for points.

params.edgeThreshold Number
  • optional
  • default: 10

Return:

XKTGeometry

The new XKTGeometry.

public createMesh(params: *): XKTMesh source

Creates an XKTMesh within this XKTModel.

An XKTMesh can be owned by one XKTEntity, which can own multiple XKTMeshes.

Registers the new XKTMesh in XKTModel#meshes and XKTModel#meshesList.

Params:

NameTypeAttributeDescription
params *

Method parameters.

params.meshId Number

Unique ID for the XKTMesh.

params.geometryId Number

ID of an existing XKTGeometry in XKTModel#geometries.

params.textureSetId Number
  • optional

Unique ID of an XKTTextureSet in XKTModel#textureSets.

params.color Float32Array

RGB color for the XKTMesh, with each color component in range [0..1].

params.metallic Number
  • optional
  • default: 0

How metallic the XKTMesh is, in range [0..1]. A value of 0 indicates fully dielectric material, while 1 indicates fully metallic.

params.roughness Number
  • optional
  • default: 1

How rough the XKTMesh is, in range [0..1]. A value of 0 indicates fully smooth, while 1 indicates fully rough.

params.opacity Number

Opacity factor for the XKTMesh, in range [0..1].

params.matrix Float64Array
  • optional

Modeling matrix for the XKTMesh. Overrides position, scale and rotation parameters.

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

Position of the XKTMesh. Overridden by the matrix parameter.

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

Scale of the XKTMesh. Overridden by the matrix parameter.

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

Rotation of the XKTMesh as Euler angles given in degrees, for each of the X, Y and Z axis. Overridden by the matrix parameter.

Return:

XKTMesh

The new XKTMesh.

public createMetaObject(params: *): XKTMetaObject source

Creates an XKTMetaObject within this XKTModel.

Logs error and does nothing if this XKTModel has been finalized (see XKTModel#finalized).

Params:

NameTypeAttributeDescription
params *

Method parameters.

params.metaObjectId String

Unique ID for the XKTMetaObject.

params.propertySetIds String

ID of one or more property sets that contains additional metadata about this XKTMetaObject. The property sets could be stored externally (ie not managed at all by the XKT file), or could be XKTPropertySets within XKTModel#propertySets.

params.metaObjectType String
  • optional
  • default: "default"

A meta type for the XKTMetaObject. Can be anything, but is usually an IFC type, such as "IfcSite" or "IfcWall".

params.metaObjectName String
  • optional

Human-readable name for the XKTMetaObject. Defaults to the metaObjectId parameter.

params.parentMetaObjectId String
  • optional

ID of the parent XKTMetaObject, if any. Defaults to the metaObjectId parameter.

Return:

XKTMetaObject

The new XKTMetaObject.

public createPropertySet(params: *): XKTPropertySet source

Creates an XKTPropertySet within this XKTModel.

Logs error and does nothing if this XKTModel has been finalized (see XKTModel#finalized).

Params:

NameTypeAttributeDescription
params *

Method parameters.

params.propertySetId String

Unique ID for the XKTPropertySet.

params.propertySetType String
  • optional
  • default: "default"

A meta type for the XKTPropertySet.

params.propertySetName String
  • optional

Human-readable name for the XKTPropertySet. Defaults to the propertySetId parameter.

params.properties String[]

Properties for the XKTPropertySet.

Return:

XKTPropertySet

The new XKTPropertySet.

public createTexture(params: *): XKTTexture source

Creates an XKTTexture within this XKTModel.

Registers the new XKTTexture in XKTModel#textures and XKTModel#texturesList.

Logs error and does nothing if this XKTModel has been finalized (see XKTModel#finalized).

Params:

NameTypeAttributeDescription
params *

Method parameters.

params.textureId Number

Unique ID for the XKTTexture.

params.src String
  • optional

Source of an image file for the texture.

params.imageData Buffer
  • optional

Image data for the texture.

params.mediaType Number
  • optional

Media type (ie. MIME type) of imageData. Supported values are GIFMediaType, PNGMediaType and JPEGMediaType.

params.width Number
  • optional

Texture width, used with imageData. Ignored for compressed textures.

params.height Number
  • optional

Texture height, used with imageData. Ignored for compressed textures.

params.compressed Boolean
  • optional
  • default: true

Whether to compress the texture.

params.minFilter Number
  • optional
  • default: LinearMipMapNearestFilter

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

params.magFilter Number
  • optional
  • default: LinearMipMapNearestFilter

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

params.wrapS Number
  • optional
  • default: RepeatWrapping

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

params.wrapT Number
  • optional
  • default: RepeatWrapping

Wrap parameter for texture coordinate T. Supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. Ignored for compressed textures. {@param {Number} [params.wrapR=RepeatWrapping] Wrap parameter for texture coordinate R. Supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. Ignored for compressed textures.

Return:

XKTTexture

The new XKTTexture.

public createTextureSet(params: *): XKTTextureSet source

Creates an XKTTextureSet within this XKTModel.

Registers the new XKTTextureSet in XKTModel#textureSets and XKTModel#.textureSetsList.

Logs error and does nothing if this XKTModel has been finalized (see XKTModel#finalized).

Params:

NameTypeAttributeDescription
params *

Method parameters.

params.textureSetId Number

Unique ID for the XKTTextureSet.

params.colorTextureId *
  • optional

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

params.metallicRoughnessTextureId *
  • optional

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

params.normalsTextureId *
  • optional

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

params.emissiveTextureId *
  • optional

ID of RGBA emissive XKTTexture, with emissive color in RGB.

params.occlusionTextureId *
  • optional

ID of RGBA occlusion XKTTexture, with occlusion factor in R.

Return:

XKTTextureSet

The new XKTTextureSet.

public async finalize() source

Finalizes this XKTModel.

After finalizing, we may then serialize the model to an array buffer using writeXKTModelToArrayBuffer.

Logs error and does nothing if this XKTModel has already been finalized.

Internally, this method: