XKTModel
A document model that represents the contents of an .XKT file.
- An XKTModel contains XKTTiles, which spatially subdivide the model into axis-aligned, box-shaped regions.
- Each XKTTile contains XKTEntitys, which represent the objects within its region.
- Each XKTEntity has XKTMeshs, which each have a XKTGeometry. Each XKTGeometry can be shared by multiple XKTMeshs.
- Import models into an XKTModel using parseGLTFIntoXKTModel, parseIFCIntoXKTModel, parse3DXMLIntoXKTModel, parseCityJSONIntoXKTModel etc.
- Build an XKTModel programmatically using XKTModel#createGeometry, XKTModel#createMesh and XKTModel#createEntity.
- Serialize an XKTModel to an ArrayBuffer using writeXKTModelToArrayBuffer.
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 |
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 |
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 |
metaObjects: {String: XKTMetaObject} 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 |
propertySets: {String: XKTPropertySet} 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 |
createGeometry(params: *): XKTGeometry Creates an XKTGeometry within this XKTModel. |
|
public |
createMesh(params: *): XKTMesh Creates an XKTMesh within this XKTModel. |
|
public |
createMetaObject(params: *): XKTMetaObject Creates an XKTMetaObject within this XKTModel. |
|
public |
createPropertySet(params: *): XKTPropertySet Creates an XKTPropertySet within this XKTModel. |
|
public |
finalize() Finalizes this XKTModel. |
Public Constructors
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:
Name | Type | Attribute | Description |
author | * |
public createdAt: String source
The date the model was created, if available.
Will be an empty string by default.
Properties:
Name | Type | Attribute | Description |
createdAt | * |
public creatingApplication: String source
The application that created the model, if available.
Will be an empty string by default.
Properties:
Name | Type | Attribute | Description |
creatingApplication | * |
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 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 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).
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:
Name | Type | Attribute | Description |
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[] |
|
Floating-point vertex normals for the XKTGeometry. Only used with triangles primitives. Ignored for points and lines. |
params.colors | Number[] |
|
Floating-point RGBA vertex colors for the XKTGeometry. Required for points primitives. Ignored for lines and triangles. |
params.colorsCompressed | Number[] |
|
Integer RGBA vertex colors for the XKTGeometry. Required for points primitives. Ignored for lines and triangles. |
params.indices | Uint32Array |
|
Indices for the XKTGeometry. Required for triangles and lines primitives. Ignored for points. |
params.edgeThreshold | Number |
|
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:
Name | Type | Attribute | Description |
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 |
|
How metallic the XKTMesh is, in range [0..1]. A value of |
params.roughness | Number |
|
How rough the XKTMesh is, in range [0..1]. A value of |
params.opacity | Number | Opacity factor for the XKTMesh, in range [0..1]. |
|
params.matrix | Float64Array |
|
Modeling matrix for the XKTMesh. Overrides |
params.position | Number[] |
|
Position of the XKTMesh. Overridden by the |
params.scale | Number[] |
|
Scale of the XKTMesh. Overridden by the |
params.rotation | Number[] |
|
Rotation of the XKTMesh as Euler angles given in degrees, for each of the X, Y and Z axis. Overridden by the |
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:
Name | Type | Attribute | Description |
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 |
|
A meta type for the XKTMetaObject. Can be anything, but is usually an IFC type, such as "IfcSite" or "IfcWall". |
params.metaObjectName | String |
|
Human-readable name for the XKTMetaObject. Defaults to the |
params.parentMetaObjectId | String |
|
ID of the parent XKTMetaObject, if any. Defaults to the |
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:
Name | Type | Attribute | Description |
params | * | Method parameters. |
|
params.propertySetId | String | Unique ID for the XKTPropertySet. |
|
params.propertySetType | String |
|
A meta type for the XKTPropertySet. |
params.propertySetName | String |
|
Human-readable name for the XKTPropertySet. Defaults to the |
params.properties | String[] | Properties for the 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:
- for each XKTEntity that doesn't already have a XKTMetaObject, creates one with XKTMetaObject#metaObjectType set to "default"
- sets each XKTEntity's XKTEntity#hasReusedGeometries true if it shares its XKTGeometrys with other XKTEntitys,
- creates each XKTEntity's XKTEntity#aabb,
- creates XKTTiles in XKTModel#tilesList, and
- sets XKTModel#finalized
true
.