Function
Static Public Summary | ||
public |
buildBoxGeometry(cfg: *): Object Creates box-shaped triangle mesh geometry arrays. |
|
public |
buildBoxLinesGeometry(cfg: *): Object Creates box-shaped line segment geometry arrays. |
|
public |
buildCylinderGeometry(cfg: *): Object Creates cylinder-shaped geometry arrays. |
|
public |
buildGridGeometry(cfg: *): Object Creates grid-shaped geometry arrays.. |
|
public |
buildPlaneGeometry(cfg: *): Object Creates plane-shaped geometry arrays. |
|
public |
buildSphereGeometry(cfg: *): Object Creates sphere-shaped geometry arrays. |
|
public |
buildTorusGeometry(cfg: *): Object Creates torus-shaped geometry arrays. |
|
public |
buildVectorTextGeometry(cfg: *): Object Creates wireframe text-shaped geometry arrays. |
|
public |
convert2xkt(params: Object, stats: Object): Promise<number> Converts model files into xeokit's native XKT format. Supported source formats are: IFC, CityJSON, glTF, LAZ and LAS. Only bundled in xeokit-convert.cjs.js. Usage
|
|
public |
parseCityJSONIntoXKTModel(params: Object): Promise Parses a CityJSON model into an XKTModel. |
|
public |
parseGLTFIntoXKTModel(params: Object): Promise Parses glTF into an XKTModel, supporting |
|
public |
parseGLTFIntoXKTModel(params: Object): Promise Parses glTF into an XKTModel, supporting |
|
public |
parseGLTFIntoXKTModel(params: Object): Promise Parses glTF into an XKTModel, supporting |
|
public |
parseGLTFJSONIntoXKTModel(params: Object): Promise Parses glTF JSON into an XKTModel, without |
|
public |
parseIFCIntoXKTModel(params: Object): Promise Parses IFC STEP file data into an XKTModel. |
|
public |
parseLASIntoXKTModel(params: Object): Promise Parses LAS and LAZ point cloud data into an XKTModel. |
|
public |
parseMetaModelIntoXKTModel(params: Object): Promise Parses JSON metamodel into an XKTModel. |
|
public |
parsePCDIntoXKTModel(params: Object): Promise Parses PCD point cloud data into an XKTModel. |
|
public |
async parsePLYIntoXKTModel(params: Object): Promise Parses PLY file data into an XKTModel. |
|
public |
async parseSTLIntoXKTModel(params: Object): Promise Parses STL file data into an XKTModel. |
|
public |
writeXKTModelToArrayBuffer(xktModel: XKTModel, metaModelJSON: String, stats: Object, options: Object): ArrayBuffer Writes an XKTModel to an ArrayBuffer. |
Static Public
public buildBoxGeometry(cfg: *): Object source
import {buildBoxGeometry} from '@xeokit/xeokit-convert/src/geometryBuilders/buildBoxGeometry.js'
Creates box-shaped triangle mesh geometry arrays.
Usage
In the example below we'll create an XKTModel, then create an XKTMesh with a box-shaped XKTGeometry.
const xktModel = new XKTModel();
const box = buildBoxGeometry({
primitiveType: "triangles" // or "lines"
center: [0,0,0],
xSize: 1, // Half-size on each axis
ySize: 1,
zSize: 1
});
const xktGeometry = xktModel.createGeometry({
geometryId: "boxGeometry",
primitiveType: box.primitiveType,
positions: box.positions,
normals: box.normals,
indices: box.indices
});
const xktMesh = xktModel.createMesh({
meshId: "redBoxMesh",
geometryId: "boxGeometry",
position: [-4, -6, -4],
scale: [1, 3, 1],
rotation: [0, 0, 0],
color: [1, 0, 0],
opacity: 1
});
const xktEntity = xktModel.createEntity({
entityId: "redBox",
meshIds: ["redBoxMesh"]
});
xktModel.finalize();
Params:
Name | Type | Attribute | Description |
cfg | * |
|
Configs |
cfg.center | Number[] |
|
3D point indicating the center position. |
cfg.xSize | Number |
|
Half-size on the X-axis. |
cfg.ySize | Number |
|
Half-size on the Y-axis. |
cfg.zSize | Number |
|
Half-size on the Z-axis. |
public buildBoxLinesGeometry(cfg: *): Object source
import {buildBoxLinesGeometry} from '@xeokit/xeokit-convert/src/geometryBuilders/buildBoxLinesGeometry.js'
Creates box-shaped line segment geometry arrays.
Usage
In the example below we'll create an XKTModel, then create an XKTMesh with a box-shaped XKTGeometry.
const xktModel = new XKTModel();
const box = buildBoxLinesGeometry({
center: [0,0,0],
xSize: 1, // Half-size on each axis
ySize: 1,
zSize: 1
});
const xktGeometry = xktModel.createGeometry({
geometryId: "boxGeometry",
primitiveType: box.primitiveType, // "lines"
positions: box.positions,
normals: box.normals,
indices: box.indices
});
const xktMesh = xktModel.createMesh({
meshId: "redBoxMesh",
geometryId: "boxGeometry",
position: [-4, -6, -4],
scale: [1, 3, 1],
rotation: [0, 0, 0],
color: [1, 0, 0],
opacity: 1
});
const xktEntity = xktModel.createEntity({
entityId: "redBox",
meshIds: ["redBoxMesh"]
});
xktModel.finalize();
Params:
Name | Type | Attribute | Description |
cfg | * |
|
Configs |
cfg.center | Number[] |
|
3D point indicating the center position. |
cfg.xSize | Number |
|
Half-size on the X-axis. |
cfg.ySize | Number |
|
Half-size on the Y-axis. |
cfg.zSize | Number |
|
Half-size on the Z-axis. |
public buildCylinderGeometry(cfg: *): Object source
import {buildCylinderGeometry} from '@xeokit/xeokit-convert/src/geometryBuilders/buildCylinderGeometry.js'
Creates cylinder-shaped geometry arrays.
Usage
In the example below we'll create an XKTModel, then create an XKTMesh with a cylinder-shaped XKTGeometry.
const xktModel = new XKTModel();
const cylinder = buildCylinderGeometry({
center: [0,0,0],
radiusTop: 2.0,
radiusBottom: 2.0,
height: 5.0,
radialSegments: 20,
heightSegments: 1,
openEnded: false
});
const xktGeometry = xktModel.createGeometry({
geometryId: "cylinderGeometry",
primitiveType: cylinder.primitiveType,
positions: cylinder.positions,
normals: cylinder.normals,
indices: cylinder.indices
});
const xktMesh = xktModel.createMesh({
meshId: "redCylinderMesh",
geometryId: "cylinderGeometry",
position: [-4, -6, -4],
scale: [1, 3, 1],
rotation: [0, 0, 0],
color: [1, 0, 0],
opacity: 1
});
const xktEntity = xktModel.createEntity({
entityId: "redCylinder",
meshIds: ["redCylinderMesh"]
});
xktModel.finalize();
Params:
Name | Type | Attribute | Description |
cfg | * |
|
Configs |
cfg.center | Number[] |
|
3D point indicating the center position. |
cfg.radiusTop | Number |
|
Radius of top. |
cfg.radiusBottom | Number |
|
Radius of bottom. |
cfg.height | Number |
|
Height. |
cfg.radialSegments | Number |
|
Number of horizontal segments. |
cfg.heightSegments | Number |
|
Number of vertical segments. |
cfg.openEnded | Boolean |
|
Whether or not the cylinder has solid caps on the ends. |
public buildGridGeometry(cfg: *): Object source
import {buildGridGeometry} from '@xeokit/xeokit-convert/src/geometryBuilders/buildGridGeometry.js'
Creates grid-shaped geometry arrays..
Usage
In the example below we'll create an XKTModel, then create an XKTMesh with a grid-shaped XKTGeometry.
const xktModel = new XKTModel();
const grid = buildGridGeometry({
size: 1000,
divisions: 500
});
const xktGeometry = xktModel.createGeometry({
geometryId: "gridGeometry",
primitiveType: grid.primitiveType, // Will be "lines"
positions: grid.positions,
indices: grid.indices
});
const xktMesh = xktModel.createMesh({
meshId: "redGridMesh",
geometryId: "gridGeometry",
position: [-4, -6, -4],
scale: [1, 3, 1],
rotation: [0, 0, 0],
color: [1, 0, 0],
opacity: 1
});
const xktEntity = xktModel.createEntity({
entityId: "redGrid",
meshIds: ["redGridMesh"]
});
xktModel.finalize();
public buildPlaneGeometry(cfg: *): Object source
import {buildPlaneGeometry} from '@xeokit/xeokit-convert/src/geometryBuilders/buildPlaneGeometry.js'
Creates plane-shaped geometry arrays.
Usage
In the example below we'll create an XKTModel, then create an XKTMesh with a plane-shaped XKTGeometry.
const xktModel = new XKTModel();
const plane = buildPlaneGeometry({
center: [0,0,0],
xSize: 2,
zSize: 2,
xSegments: 10,
zSegments: 10
});
const xktGeometry = xktModel.createGeometry({
geometryId: "planeGeometry",
primitiveType: plane.primitiveType, // Will be "triangles"
positions: plane.positions,
normals: plane.normals,
indices: plane.indices
});
const xktMesh = xktModel.createMesh({
meshId: "redPlaneMesh",
geometryId: "planeGeometry",
position: [-4, -6, -4],
scale: [1, 3, 1],
rotation: [0, 0, 0],
color: [1, 0, 0],
opacity: 1
});
const xktEntity = xktModel.createEntity({
entityId: "redPlane",
meshIds: ["redPlaneMesh"]
});
xktModel.finalize();
Params:
Name | Type | Attribute | Description |
cfg | * |
|
Configs |
cfg.center | Number[] |
|
3D point indicating the center position. |
cfg.xSize | Number |
|
Dimension on the X-axis. |
cfg.zSize | Number |
|
Dimension on the Z-axis. |
cfg.xSegments | Number |
|
Number of segments on the X-axis. |
cfg.zSegments | Number |
|
Number of segments on the Z-axis. |
public buildSphereGeometry(cfg: *): Object source
import {buildSphereGeometry} from '@xeokit/xeokit-convert/src/geometryBuilders/buildSphereGeometry.js'
Creates sphere-shaped geometry arrays.
Usage
In the example below we'll create an XKTModel, then create an XKTMesh with a sphere-shaped XKTGeometry.
const xktModel = new XKTModel();
const sphere = buildSphereGeometry({
center: [0,0,0],
radius: 1.5,
heightSegments: 60,
widthSegments: 60
});
const xktGeometry = xktModel.createGeometry({
geometryId: "sphereGeometry",
primitiveType: sphere.primitiveType, // Will be "triangles"
positions: sphere.positions,
normals: sphere.normals,
indices: sphere.indices
});
const xktMesh = xktModel.createMesh({
meshId: "redSphereMesh",
geometryId: "sphereGeometry",
position: [-4, -6, -4],
scale: [1, 3, 1],
rotation: [0, 0, 0],
color: [1, 0, 0],
opacity: 1
});
const xktEntity = xktModel.createEntity({
entityId: "redSphere",
meshIds: ["redSphereMesh"]
});
xktModel.finalize();
Params:
Name | Type | Attribute | Description |
cfg | * |
|
Configs |
cfg.center | Number[] |
|
3D point indicating the center position. |
cfg.radius | Number |
|
Radius. |
cfg.heightSegments | Number |
|
Number of latitudinal bands. |
cfg.widthSegments | Number |
|
Number of longitudinal bands. |
public buildTorusGeometry(cfg: *): Object source
import {buildTorusGeometry} from '@xeokit/xeokit-convert/src/geometryBuilders/buildTorusGeometry.js'
Creates torus-shaped geometry arrays.
Usage
In the example below we'll create an XKTModel, then create an XKTMesh with a torus-shaped XKTGeometry.
const xktModel = new XKTModel();
const torus = buildTorusGeometry({
center: [0,0,0],
radius: 1.0,
tube: 0.5,
radialSegments: 32,
tubeSegments: 24,
arc: Math.PI * 2.0
});
const xktGeometry = xktModel.createGeometry({
geometryId: "torusGeometry",
primitiveType: torus.primitiveType, // Will be "triangles"
positions: torus.positions,
normals: torus.normals,
indices: torus.indices
});
const xktMesh = xktModel.createMesh({
meshId: "redTorusMesh",
geometryId: "torusGeometry",
position: [-4, -6, -4],
scale: [1, 3, 1],
rotation: [0, 0, 0],
color: [1, 0, 0],
opacity: 1
});
const xktEntity = xktModel.createEntity({
entityId: "redTorus",
meshIds: ["redTorusMesh"]
});
xktModel.finalize();
Params:
Name | Type | Attribute | Description |
cfg | * |
|
Configs |
cfg.center | Number[] |
|
3D point indicating the center position. |
cfg.radius | Number |
|
The overall radius. |
cfg.tube | Number |
|
The tube radius. |
cfg.radialSegments | Number |
|
The number of radial segments. |
cfg.tubeSegments | Number |
|
The number of tubular segments. |
cfg.arc | Number |
|
The length of the arc in radians, where Math.PI*2 is a closed torus. |
public buildVectorTextGeometry(cfg: *): Object source
import {buildVectorTextGeometry} from '@xeokit/xeokit-convert/src/geometryBuilders/buildVectorTextGeometry.js'
Creates wireframe text-shaped geometry arrays.
Usage
In the example below we'll create an XKTModel, then create an XKTMesh with a text-shaped XKTGeometry.
const xktModel = new XKTModel();
const text = buildVectorTextGeometry({
origin: [0,0,0],
text: "On the other side of the screen, it all looked so easy"
});
const xktGeometry = xktModel.createGeometry({
geometryId: "textGeometry",
primitiveType: text.primitiveType, // Will be "lines"
positions: text.positions,
indices: text.indices
});
const xktMesh = xktModel.createMesh({
meshId: "redTextMesh",
geometryId: "textGeometry",
position: [-4, -6, -4],
scale: [1, 3, 1],
rotation: [0, 0, 0],
color: [1, 0, 0],
opacity: 1
});
const xktEntity = xktModel.createEntity({
entityId: "redText",
meshIds: ["redTextMesh"]
});
xktModel.finalize();
Params:
Name | Type | Attribute | Description |
cfg | * |
|
Configs |
cfg.center | Number[] |
|
3D point indicating the center position. |
cfg.origin | Number[] |
|
3D point indicating the top left corner. |
cfg.size | Number |
|
Size of each character. |
cfg.text | String |
|
The text. |
public convert2xkt(params: Object, stats: Object): Promise<number> source
import {convert2xkt} from '@xeokit/xeokit-convert/src/convert2xkt.js'
Converts model files into xeokit's native XKT format.
Supported source formats are: IFC, CityJSON, glTF, LAZ and LAS.
Only bundled in xeokit-convert.cjs.js.
Usage
const convert2xkt = require("@xeokit/xeokit-convert/dist/convert2xkt.cjs.js");
const fs = require('fs');
convert2xkt({
sourceData: fs.readFileSync("rme_advanced_sample_project.ifc"),
outputXKT: (xtkArrayBuffer) => {
fs.writeFileSync("rme_advanced_sample_project.ifc.xkt", xtkArrayBuffer);
}
}).then(() => {
console.log("Converted.");
}, (errMsg) => {
console.error("Conversion failed: " + errMsg)
});
Params:
Name | Type | Attribute | Description |
params | Object | Conversion parameters. |
|
params.WebIFC | Object | The WebIFC library. We pass this in as an external dependency, in order to give the caller the choice of whether to use the Browser or NodeJS version. |
|
params.configs | * |
|
Configurations. |
params.source | String |
|
Path to source file. Alternative to |
params.sourceData | ArrayBuffer | JSON |
|
Source file data. Alternative to |
params.sourceFormat | String |
|
Format of source file/data. Always needed with |
params.metaModelDataStr | String |
|
Source file data. Overrides metadata from |
params.metaModelSource | String |
|
Path to source metaModel file. Overrides metadata from |
params.output | String |
|
Path to destination XKT file. Directories on this path are automatically created if not existing. |
params.outputXKTModel | Function |
|
Callback to collect the |
params.outputXKT | Function |
|
Callback to collect XKT file data. |
params.includeTypes | String[] |
|
Option to only convert objects of these types. |
params.excludeTypes | String[] |
|
Option to never convert objects of these types. |
stats | Object |
|
Collects conversion statistics. Statistics are attached to this object if provided. |
params.outputStats | Function |
|
Callback to collect statistics. |
params.rotateX | Boolean |
|
Whether to rotate the model 90 degrees about the X axis to make the Y axis "up", if necessary. Applies to CityJSON and LAS/LAZ models. |
params.reuseGeometries | Boolean |
|
When true, will enable geometry reuse within the XKT. When false, will automatically "expand" all reused geometries into duplicate copies. This has the drawback of increasing the XKT file size (~10-30% for typical models), but can make the model more responsive in the xeokit Viewer, especially if the model has excessive geometry reuse. An example of excessive geometry reuse would be when a model (eg. glTF) has 4000 geometries that are shared amongst 2000 objects, ie. a large number of geometries with a low amount of reuse, which can present a pathological performance case for xeokit's underlying graphics APIs (WebGL, WebGPU etc). |
params.includeTextures | Boolean |
|
Whether to convert textures. Only works for |
params.includeNormals | Boolean |
|
Whether to convert normals. When false, the parser will ignore
geometry normals, and the modelwill rely on the xeokit |
params.minTileSize | Number |
|
Minimum RTC coordinate tile size. Set this to a value between 100 and 10000, depending on how far from the coordinate origin the model's vertex positions are; specify larger tile sizes when close to the origin, and smaller sizes when distant. This compensates for decreasing precision as floats get bigger. |
params.log | Function |
|
Logging callback. |
public parseCityJSONIntoXKTModel(params: Object): Promise source
import {parseCityJSONIntoXKTModel} from '@xeokit/xeokit-convert/src/parsers/parseCityJSONIntoXKTModel.js'
Parses a CityJSON model into an XKTModel.
CityJSON is a JSON-based encoding for a subset of the CityGML data model (version 2.0.0), which is an open standardised data model and exchange format to store digital 3D models of cities and landscapes. CityGML is an official standard of the Open Geospatial Consortium.
This converter function supports most of the CityJSON 1.0.2 Specification, with the following limitations:
- Does not (yet) support CityJSON semantics for geometry primitives.
- Does not (yet) support textured geometries.
- Does not (yet) support geometry templates.
- When the CityJSON file provides multiple themes for a geometry, then we parse only the first of the provided themes for that geometry.
Usage
In the example below we'll create an XKTModel, then load a CityJSON model into it.
utils.loadJSON("./models/cityjson/DenHaag.json", async (data) => {
const xktModel = new XKTModel();
parseCityJSONIntoXKTModel({
data,
xktModel,
log: (msg) => { console.log(msg); }
}).then(()=>{
xktModel.finalize();
},
(msg) => {
console.error(msg);
});
});
Params:
Name | Type | Attribute | Description |
params | Object | Parsing params. |
|
params.data | Object | CityJSON data. |
|
params.xktModel | XKTModel | XKTModel to parse into. |
|
params.center | boolean |
|
Set true to center the CityJSON vertex positions to [0,0,0]. This is applied before the transformation matrix, if specified. |
params.transform | Boolean |
|
4x4 transformation matrix to transform CityJSON vertex positions. Use this to rotate, translate and scale them if neccessary. |
params.stats | Object |
|
Collects statistics. |
params.log | function |
|
Logging callback. |
public parseGLTFIntoXKTModel(params: Object): Promise source
import {parseGLTFIntoXKTModel} from '@xeokit/xeokit-convert/src/parsers/parseGLTFIntoXKTModel.OLD.js'
Parses glTF into an XKTModel, supporting .glb
and textures.
- Supports
.glb
and textures - For a lightweight glTF JSON parser that ignores textures, see parseGLTFJSONIntoXKTModel.
Usage
In the example below we'll create an XKTModel, then load a binary glTF model into it.
utils.loadArraybuffer("../assets/models/gltf/HousePlan/glTF-Binary/HousePlan.glb", async (data) => {
const xktModel = new XKTModel();
parseGLTFIntoXKTModel({
data,
xktModel,
log: (msg) => { console.log(msg); }
}).then(()=>{
xktModel.finalize();
},
(msg) => {
console.error(msg);
});
});
Params:
Name | Type | Attribute | Description |
params | Object | Parsing parameters. |
|
params.data | ArrayBuffer | The glTF. |
|
params.baseUri | String |
|
The base URI used to load this glTF, if any. For resolving relative uris to linked resources. |
params.metaModelData | Object |
|
Metamodel JSON. If this is provided, then parsing is able to ensure that the XKTObjects it creates will fit the metadata properly. |
params.xktModel | XKTModel | XKTModel to parse into. |
|
params.includeTextures | Boolean |
|
Whether to parse textures. |
params.includeNormals | Boolean |
|
Whether to parse normals. When false, the parser will ignore the glTF
geometry normals, and the glTF data will rely on the xeokit |
params.stats | Object |
|
Collects statistics. |
params.log | function |
|
Logging callback. |
public parseGLTFIntoXKTModel(params: Object): Promise source
import {parseGLTFIntoXKTModel} from '@xeokit/xeokit-convert/src/parsers/parseGLTFIntoXKTModel.WITH_IMPORTANT_UPDATES.js'
Parses glTF into an XKTModel, supporting .glb
and textures.
- Supports
.glb
and textures - For a lightweight glTF JSON parser that ignores textures, see parseGLTFJSONIntoXKTModel.
Usage
In the example below we'll create an XKTModel, then load a binary glTF model into it.
utils.loadArraybuffer("../assets/models/gltf/HousePlan/glTF-Binary/HousePlan.glb", async (data) => {
const xktModel = new XKTModel();
parseGLTFIntoXKTModel({
data,
xktModel,
log: (msg) => { console.log(msg); }
}).then(()=>{
xktModel.finalize();
},
(msg) => {
console.error(msg);
});
});
Params:
Name | Type | Attribute | Description |
params | Object | Parsing parameters. |
|
params.data | ArrayBuffer | The glTF. |
|
params.baseUri | String |
|
The base URI used to load this glTF, if any. For resolving relative uris to linked resources. |
params.metaModelData | Object |
|
Metamodel JSON. If this is provided, then parsing is able to ensure that the XKTObjects it creates will fit the metadata properly. |
params.xktModel | XKTModel | XKTModel to parse into. |
|
params.includeTextures | Boolean |
|
Whether to parse textures. |
params.includeNormals | Boolean |
|
Whether to parse normals. When false, the parser will ignore the glTF
geometry normals, and the glTF data will rely on the xeokit |
params.stats | Object |
|
Collects statistics. |
params.log | function |
|
Logging callback. |
public parseGLTFIntoXKTModel(params: Object): Promise source
import {parseGLTFIntoXKTModel} from '@xeokit/xeokit-convert/src/parsers/parseGLTFIntoXKTModel.js'
Parses glTF into an XKTModel, supporting .glb
and textures.
- Supports
.glb
and textures - For a lightweight glTF JSON parser that ignores textures, see parseGLTFJSONIntoXKTModel.
Usage
In the example below we'll create an XKTModel, then load a binary glTF model into it.
utils.loadArraybuffer("../assets/models/gltf/HousePlan/glTF-Binary/HousePlan.glb", async (data) => {
const xktModel = new XKTModel();
parseGLTFIntoXKTModel({
data,
xktModel,
log: (msg) => { console.log(msg); }
}).then(()=>{
xktModel.finalize();
},
(msg) => {
console.error(msg);
});
});
Params:
Name | Type | Attribute | Description |
params | Object | Parsing parameters. |
|
params.data | ArrayBuffer | The glTF. |
|
params.baseUri | String |
|
The base URI used to load this glTF, if any. For resolving relative uris to linked resources. |
params.metaModelData | Object |
|
Metamodel JSON. If this is provided, then parsing is able to ensure that the XKTObjects it creates will fit the metadata properly. |
params.xktModel | XKTModel | XKTModel to parse into. |
|
params.includeTextures | Boolean |
|
Whether to parse textures. |
params.includeNormals | Boolean |
|
Whether to parse normals. When false, the parser will ignore the glTF
geometry normals, and the glTF data will rely on the xeokit |
params.stats | Object |
|
Collects statistics. |
params.log | function |
|
Logging callback. |
public parseGLTFJSONIntoXKTModel(params: Object): Promise source
import {parseGLTFJSONIntoXKTModel} from '@xeokit/xeokit-convert/src/parsers/parseGLTFJSONIntoXKTModel.js'
Parses glTF JSON into an XKTModel, without .glb
and textures.
- Lightweight JSON-based glTF parser which ignores textures
- For texture and
.glb
support, see parseGLTFIntoXKTModel
Usage
In the example below we'll create an XKTModel, then load a glTF model into it.
utils.loadJSON("./models/gltf/duplex/scene.gltf", async (data) => {
const xktModel = new XKTModel();
parseGLTFJSONIntoXKTModel({
data,
xktModel,
log: (msg) => { console.log(msg); }
}).then(()=>{
xktModel.finalize();
},
(msg) => {
console.error(msg);
});
});
Params:
Name | Type | Attribute | Description |
params | Object | Parsing parameters. |
|
params.data | Object | The glTF JSON. |
|
params.metaModelData | Object |
|
Metamodel JSON. If this is provided, then parsing is able to ensure that the XKTObjects it creates will fit the metadata properly. |
params.xktModel | XKTModel | XKTModel to parse into. |
|
params.includeNormals | Boolean |
|
Whether to parse normals. When false, the parser will ignore the glTF
geometry normals, and the glTF data will rely on the xeokit |
params.reuseGeometries | Boolean |
|
When true, the parser will enable geometry reuse within the XKTModel. When false, will automatically "expand" all reused geometries into duplicate copies. This has the drawback of increasing the XKT file size (~10-30% for typical models), but can make the model more responsive in the xeokit Viewer, especially if the model has excessive geometry reuse. An example of excessive geometry reuse would be if we have 4000 geometries that are shared amongst 2000 objects, ie. a large number of geometries with a low amount of reuse, which can present a pathological performance case for xeokit's underlying graphics APIs (WebGL, WebGPU etc). |
params.getAttachment | function |
|
Callback through which to fetch attachments, if the glTF has them. |
params.stats | Object |
|
Collects statistics. |
params.log | function |
|
Logging callback. |
public parseIFCIntoXKTModel(params: Object): Promise source
import {parseIFCIntoXKTModel} from '@xeokit/xeokit-convert/src/parsers/parseIFCIntoXKTModel.js'
Parses IFC STEP file data into an XKTModel.
This function uses web-ifc to parse the IFC, which relies on a WASM file to do the parsing.
Depending on how we use this function, we may need to provide it with a path to the directory where that WASM file is stored.
This function is tested with web-ifc version 0.0.34.
Usage
In the example below we'll create an XKTModel, then load an IFC model into it.
import {XKTModel, parseIFCIntoXKTModel, writeXKTModelToArrayBuffer} from "xeokit-convert.es.js";
import * as WebIFC from "web-ifc-api.js";
utils.loadArraybuffer("rac_advanced_sample_project.ifc", async (data) => {
const xktModel = new XKTModel();
parseIFCIntoXKTModel({
WebIFC,
data,
xktModel,
wasmPath: "../dist/",
autoNormals: true,
log: (msg) => { console.log(msg); }
}).then(()=>{
xktModel.finalize();
},
(msg) => {
console.error(msg);
});
});
Params:
Name | Type | Attribute | Description |
params | Object | Parsing params. |
|
params.WebIFC | Object | The WebIFC library. We pass this in as an external dependency, in order to give the caller the choice of whether to use the Browser or NodeJS version. |
|
params.data | ArrayBuffer |
|
IFC file data. |
params.xktModel | XKTModel |
|
XKTModel to parse into. |
params.autoNormals | Boolean |
|
When true, the parser will ignore the IFC geometry normals, and the IFC
data will rely on the xeokit |
params.includeTypes | String[] |
|
Option to only convert objects of these types. |
params.excludeTypes | String[] |
|
Option to never convert objects of these types. |
params.wasmPath | String | Path to |
|
params.stats | Object |
|
Collects statistics. |
params.log | function |
|
Logging callback. |
public parseLASIntoXKTModel(params: Object): Promise source
import {parseLASIntoXKTModel} from '@xeokit/xeokit-convert/src/parsers/parseLASIntoXKTModel.js'
Parses LAS and LAZ point cloud data into an XKTModel.
This parser handles both the LASER file format (LAS) and its compressed version (LAZ), a public format for the interchange of 3-dimensional point cloud data data, developed for LIDAR mapping purposes.
Usage
In the example below we'll create an XKTModel, then load an LAZ point cloud model into it.
utils.loadArraybuffer("./models/laz/autzen.laz", async (data) => {
const xktModel = new XKTModel();
await parseLASIntoXKTModel({
data,
xktModel,
rotateX: true,
log: (msg) => { console.log(msg); }
}).then(()=>{
xktModel.finalize();
},
(msg) => {
console.error(msg);
});
});
Params:
Name | Type | Attribute | Description |
params | Object | Parsing params. |
|
params.data | ArrayBuffer | LAS/LAZ file data. |
|
params.xktModel | XKTModel | XKTModel to parse into. |
|
params.center | boolean |
|
Set true to center the LAS point positions to [0,0,0]. This is applied before the transformation matrix, if specified. |
params.transform | Boolean |
|
4x4 transformation matrix to transform point positions. Use this to rotate, translate and scale them if neccessary. |
params.colorDepth | Number | String |
|
Whether colors encoded using 8 or 16 bits. Can be set to 'auto'. LAS specification recommends 16 bits. |
params.fp64 | Boolean |
|
Configures if LASLoaderPlugin assumes that LAS positions are stored in 64-bit floats instead of 32-bit. |
params.skip | Number |
|
Read one from every n points. |
params.stats | Object |
|
Collects statistics. |
params.log | function |
|
Logging callback. |
public parseMetaModelIntoXKTModel(params: Object): Promise source
import {parseMetaModelIntoXKTModel} from '@xeokit/xeokit-convert/src/parsers/parseMetaModelIntoXKTModel.js'
Parses JSON metamodel into an XKTModel.
Params:
Name | Type | Attribute | Description |
params | Object | Parsing parameters. |
|
params.metaModelData | JSON | Metamodel data. |
|
params.excludeTypes | String[] |
|
Types to exclude from parsing. |
params.includeTypes | String[] |
|
Types to include in parsing. |
params.xktModel | XKTModel | XKTModel to parse into. |
|
params.log | function |
|
Logging callback. |
public parsePCDIntoXKTModel(params: Object): Promise source
import {parsePCDIntoXKTModel} from '@xeokit/xeokit-convert/src/parsers/parsePCDIntoXKTModel.js'
Parses PCD point cloud data into an XKTModel.
Usage
In the example below we'll create an XKTModel, then load an LAZ point cloud model into it.
utils.loadArraybuffer(""./models/pcd/ism_test_cat.pcd"", async (data) => {
const xktModel = new XKTModel();
await parsePCDIntoXKTModel({
data,
xktModel,
log: (msg) => { console.log(msg); }
}).then(()=>{
xktModel.finalize();
},
(msg) => {
console.error(msg);
});
});
Params:
Name | Type | Attribute | Description |
params | Object | Parsing params. |
|
params.data | ArrayBuffer | PCD file data. |
|
params.littleEndian | Boolean |
|
Whether PCD binary data is Little-Endian or Big-Endian. |
params.xktModel | XKTModel | XKTModel to parse into. |
|
params.stats | Object |
|
Collects statistics. |
params.log | function |
|
Logging callback. |
public async parsePLYIntoXKTModel(params: Object): Promise source
import {parsePLYIntoXKTModel} from '@xeokit/xeokit-convert/src/parsers/parsePLYIntoXKTModel.js'
Parses PLY file data into an XKTModel.
Usage
In the example below we'll create an XKTModel, then load a PLY model into it.
utils.loadArraybuffer("./models/ply/test.ply", async (data) => {
const xktModel = new XKTModel();
parsePLYIntoXKTModel({data, xktModel}).then(()=>{
xktModel.finalize();
},
(msg) => {
console.error(msg);
});
});
Params:
Name | Type | Attribute | Description |
params | Object | Parsing params. |
|
params.data | ArrayBuffer | PLY file data. |
|
params.xktModel | XKTModel | XKTModel to parse into. |
|
params.stats | Object |
|
Collects statistics. |
params.log | function |
|
Logging callback. |
public async parseSTLIntoXKTModel(params: Object): Promise source
import {parseSTLIntoXKTModel} from '@xeokit/xeokit-convert/src/parsers/parseSTLIntoXKTModel.js'
Parses STL file data into an XKTModel.
- Supports binary and ASCII STL formats.
- Option to create a separate XKTEntity for each group of faces that share the same vertex colors.
- Option to smooth face-aligned normals loaded from STL.
- Option to reduce XKT file size by ignoring STL normals and relying on xeokit to auto-generate them.
Usage
In the example below we'll create an XKTModel, then load an STL model into it.
utils.loadArraybuffer("./models/stl/binary/spurGear.stl", async (data) => {
const xktModel = new XKTModel();
parseSTLIntoXKTModel({data, xktModel});
xktModel.finalize();
});
Params:
Name | Type | Attribute | Description |
params | Object | Parsing params. |
|
params.data | ArrayBuffer | String |
|
STL file data. Can be binary or string. |
params.autoNormals | Boolean |
|
When true, the parser will ignore the STL geometry normals, and the STL
data will rely on the xeokit |
params.smoothNormals | Boolean |
|
When true, automatically converts face-oriented STL normals to vertex normals, for a smooth appearance. Ignored if |
params.smoothNormalsAngleThreshold | Number |
|
This is the threshold angle between normals of adjacent triangles, below which their shared wireframe edge is not drawn. |
params.splitMeshes | Boolean |
|
When true, creates a separate XKTEntity for each group of faces that share the same vertex colors. Only works with binary STL (ie. when |
params.xktModel | XKTModel |
|
XKTModel to parse into. |
params.stats | Object |
|
Collects statistics. |
params.log | function |
|
Logging callback. |
public writeXKTModelToArrayBuffer(xktModel: XKTModel, metaModelJSON: String, stats: Object, options: Object): ArrayBuffer source
import {writeXKTModelToArrayBuffer} from '@xeokit/xeokit-convert/src/XKTModel/writeXKTModelToArrayBuffer.js'
Writes an XKTModel to an ArrayBuffer.