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

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

XKTTiles within this XKTModel.

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

Finalizes this XKTModel.

Public Constructors

public constructor(cfg: *) source

Constructs a new XKTModel.

Params:

NameTypeAttributeDescription
cfg *
  • optional

Configuration

cfg.edgeThreshold Number
  • optional
  • default: 10

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 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 tilesList: XKTTile[] source

XKTTiles within this XKTModel.

Created by XKTModel#finalize.

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.

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.

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.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.

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.color Uint8Array

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 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: