Reference Source

Function

Static Public Summary
public

Creates box-shaped triangle mesh geometry arrays.

public

Creates box-shaped line segment geometry arrays.

public

Creates cylinder-shaped geometry arrays.

public

Creates grid-shaped geometry arrays..

public

Creates plane-shaped geometry arrays.

public

Creates sphere-shaped geometry arrays.

public

Creates torus-shaped geometry arrays.

public

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, 3DXML, glTF, LAZ and LAS.

public

Loads 3DXML into an XKTModel.

public

Parses a CityJSON model into an XKTModel.

public

Parses glTF JSON into an XKTModel.

public

Parses IFC STEP file data into an XKTModel.

public

async parseLASIntoXKTModel(params: Object)

Parses LAS and LAZ point cloud data into an XKTModel.

public

Parses JSON metamodel into an XKTModel.

public

Parses PCD point cloud data into an XKTModel.

public

Parses PLY file data into an XKTModel.

public

Parses STL file data into an XKTModel.

public

Writes an XKTModel to an ArrayBuffer.

Static Public

public buildBoxGeometry(cfg: *): Object source

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.

[Run this example]

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:

NameTypeAttributeDescription
cfg *
  • optional

Configs

cfg.center Number[]
  • optional

3D point indicating the center position.

cfg.xSize Number
  • optional
  • default: 1.0

Half-size on the X-axis.

cfg.ySize Number
  • optional
  • default: 1.0

Half-size on the Y-axis.

cfg.zSize Number
  • optional
  • default: 1.0

Half-size on the Z-axis.

Return:

Object

Geometry arrays for XKTModel#createGeometry or XKTModel#createMesh.

public buildBoxLinesGeometry(cfg: *): Object source

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.

[Run this example]

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:

NameTypeAttributeDescription
cfg *
  • optional

Configs

cfg.center Number[]
  • optional

3D point indicating the center position.

cfg.xSize Number
  • optional
  • default: 1.0

Half-size on the X-axis.

cfg.ySize Number
  • optional
  • default: 1.0

Half-size on the Y-axis.

cfg.zSize Number
  • optional
  • default: 1.0

Half-size on the Z-axis.

Return:

Object

Geometry arrays for XKTModel#createGeometry or XKTModel#createMesh.

public buildCylinderGeometry(cfg: *): Object source

Creates cylinder-shaped geometry arrays.

Usage

In the example below we'll create an XKTModel, then create an XKTMesh with a cylinder-shaped XKTGeometry.

[Run this example]

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:

NameTypeAttributeDescription
cfg *
  • optional

Configs

cfg.center Number[]
  • optional

3D point indicating the center position.

cfg.radiusTop Number
  • optional
  • default: 1

Radius of top.

cfg.radiusBottom Number
  • optional
  • default: 1

Radius of bottom.

cfg.height Number
  • optional
  • default: 1

Height.

cfg.radialSegments Number
  • optional
  • default: 60

Number of horizontal segments.

cfg.heightSegments Number
  • optional
  • default: 1

Number of vertical segments.

cfg.openEnded Boolean
  • optional
  • default: false

Whether or not the cylinder has solid caps on the ends.

Return:

Object

Geometry arrays for XKTModel#createGeometry or XKTModel#createMesh.

public buildGridGeometry(cfg: *): Object source

Creates grid-shaped geometry arrays..

Usage

In the example below we'll create an XKTModel, then create an XKTMesh with a grid-shaped XKTGeometry.

[Run this example]

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();

Params:

NameTypeAttributeDescription
cfg *
  • optional

Configs

cfg.size Number
  • optional
  • default: 1

Dimension on the X and Z-axis.

cfg.divisions Number
  • optional
  • default: 1

Number of divisions on X and Z axis..

Return:

Object

Geometry arrays for XKTModel#createGeometry or XKTModel#createMesh.

public buildPlaneGeometry(cfg: *): Object source

Creates plane-shaped geometry arrays.

Usage

In the example below we'll create an XKTModel, then create an XKTMesh with a plane-shaped XKTGeometry.

[Run this example]

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:

NameTypeAttributeDescription
cfg *
  • optional

Configs

cfg.center Number[]
  • optional

3D point indicating the center position.

cfg.xSize Number
  • optional
  • default: 1

Dimension on the X-axis.

cfg.zSize Number
  • optional
  • default: 1

Dimension on the Z-axis.

cfg.xSegments Number
  • optional
  • default: 1

Number of segments on the X-axis.

cfg.zSegments Number
  • optional
  • default: 1

Number of segments on the Z-axis.

Return:

Object

Geometry arrays for XKTModel#createGeometry or XKTModel#createMesh.

public buildSphereGeometry(cfg: *): Object source

Creates sphere-shaped geometry arrays.

Usage

In the example below we'll create an XKTModel, then create an XKTMesh with a sphere-shaped XKTGeometry.

[Run this example]

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:

NameTypeAttributeDescription
cfg *
  • optional

Configs

cfg.center Number[]
  • optional

3D point indicating the center position.

cfg.radius Number
  • optional
  • default: 1

Radius.

cfg.heightSegments Number
  • optional
  • default: 24

Number of latitudinal bands.

cfg.widthSegments Number
  • optional
  • default: 18

Number of longitudinal bands.

Return:

Object

Geometry arrays for XKTModel#createGeometry or XKTModel#createMesh.

public buildTorusGeometry(cfg: *): Object source

Creates torus-shaped geometry arrays.

Usage

In the example below we'll create an XKTModel, then create an XKTMesh with a torus-shaped XKTGeometry.

[Run this example]

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:

NameTypeAttributeDescription
cfg *
  • optional

Configs

cfg.center Number[]
  • optional

3D point indicating the center position.

cfg.radius Number
  • optional
  • default: 1

The overall radius.

cfg.tube Number
  • optional
  • default: 0.3

The tube radius.

cfg.radialSegments Number
  • optional
  • default: 32

The number of radial segments.

cfg.tubeSegments Number
  • optional
  • default: 24

The number of tubular segments.

cfg.arc Number
  • optional
  • default: Math.PI*0.5

The length of the arc in radians, where Math.PI*2 is a closed torus.

Return:

Object

Geometry arrays for XKTModel#createGeometry or XKTModel#createMesh.

public buildVectorTextGeometry(cfg: *): Object source

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.

[Run this example]

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:

NameTypeAttributeDescription
cfg *
  • optional

Configs

cfg.center Number[]
  • optional

3D point indicating the center position.

cfg.origin Number[]
  • optional

3D point indicating the top left corner.

cfg.size Number
  • optional
  • default: 1

Size of each character.

cfg.text String
  • optional
  • default: ""

The text.

Return:

Object

Geometry arrays for XKTModel#createGeometry or XKTModel#createMesh.

public convert2xkt(params: Object, stats: Object): Promise<number> source

Converts model files into xeokit's native XKT format.

Supported source formats are: IFC, CityJSON, 3DXML, glTF, LAZ and LAS.

Params:

NameTypeAttributeDescription
params Object

Conversion parameters.

params.source String
  • optional

Path to source file. Alternative to sourceData.

params.sourceData ArrayBuffer | JSON
  • optional

Source file data. Alternative to source.

params.sourceFormat String
  • optional

Format of source file/data. Always needed with sourceData, but not normally needed with source, because convert2xkt will determine the format automatically from the file extension of source.

params.metaModelData ArrayBuffer | JSON
  • optional

Source file data. Overrides metadata from metaModelSource, sourceData and source.

params.metaModelSource String
  • optional

Path to source metaModel file. Overrides metadata from sourceData and source. Overridden by metaModelData.

params.output String
  • optional

Path to destination XKT file. Directories on this path are automatically created if not existing.

params.outputXKTModel Function
  • optional

Callback to collect the XKTModel that is internally build by this method.

params.outputXKT Function
  • optional

Callback to collect XKT file data.

params.includeTypes String[]
  • optional

Option to only convert objects of these types.

params.excludeTypes String[]
  • optional

Option to never convert objects of these types.

stats Object
  • optional

Collects conversion statistics. Statistics are attached to this object if provided.

params.outputStats Function
  • optional

Callback to collect statistics.

params.rotateX Boolean
  • optional
  • default: false

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.log Function
  • optional

Logging callback.

Return:

Promise<number>

public parse3DXMLIntoXKTModel(params: Object): * source

Loads 3DXML into an XKTModel.

Supports 3DXML Schema 4.2.

Params:

NameTypeAttributeDescription
params Object

Parsing parameters.

params.data ArrayBuffer

3DXML BLOB data.

params.domParser DOMParser

A DOMParser implementation (eg. xmldom), required when we're not running in a browser and window.DOMParser is not available.

params.xktModel XKTModel

XKTModel to parse into.

params.autoNormals Boolean
  • optional
  • default: false

When true, the parser will ignore the 3DXML geometry normals, and the 3DXML data will rely on the xeokit Viewer to automatically generate them. This has the limitation that the normals will be face-aligned, and therefore the Viewer will only be able to render a flat-shaded representation of the 3DXML model. This is false by default because CAD models tend to prefer smooth shading.

params.stats Object
  • optional

Collects statistics.

params.log function
  • optional

Logging callback.

Return:

*

public parseCityJSONIntoXKTModel(params: Object): Promise source

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.

[Run this example]

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:

NameTypeAttributeDescription
params Object

Parsing params.

params.data Object

CityJSON data.

params.xktModel XKTModel

XKTModel to parse into.

params.rotateX Boolean
  • optional
  • default: true

Whether to rotate the model 90 degrees about the X axis to make the Y axis "up", if neccessary.

params.stats Object
  • optional

Collects statistics.

params.log function
  • optional

Logging callback.

Return:

Promise

public parseGLTFIntoXKTModel(params: Object): Promise source

Parses glTF JSON into an XKTModel.

  • Supports glTF 2.
  • Provides 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 a glTF model into it.

[Run this example]

utils.loadJSON("./models/gltf/duplex/scene.gltf", async (data) => {

    const xktModel = new XKTModel();

    parseGLTFIntoXKTModel({
         data,
         xktModel,
         log: (msg) => { console.log(msg); }
    }).then(()=>{
       xktModel.finalize();
    },
    (msg) => {
        console.error(msg);
    });
});

Params:

NameTypeAttributeDescription
params Object

Parsing parameters.

params.data Object

The glTF JSON.

params.xktModel XKTModel

XKTModel to parse into.

params.autoNormals Boolean
  • optional
  • default: false

When true, the parser will ignore the glTF geometry normals, and the glTF data will rely on the xeokit Viewer to automatically generate them. This has the limitation that the normals will be face-aligned, and therefore the Viewer will only be able to render a flat-shaded representation of the glTF.

params.getAttachment function
  • optional

Callback through which to fetch attachments, if the glTF has them.

params.stats Object
  • optional

Collects statistics.

params.log function
  • optional

Logging callback.

Return:

Promise

public parseIFCIntoXKTModel(params: Object): * source

Parses IFC STEP file data into an XKTModel.

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

Usage

In the example below we'll create an XKTModel, then load an IFC model into it.

[Run this example]

utils.loadArraybuffer("./models/ifc/rac_advanced_sample_project.ifc", async (data) => {

    const xktModel = new XKTModel();

    parseIFCIntoXKTModel({
         data,
         xktModel,
         wasmPath: "../dist/",
         autoNormals: true,
         log: (msg) => { console.log(msg); }
    }).then(()=>{
       xktModel.finalize();
    },
    (msg) => {
        console.error(msg);
    });
});

Params:

NameTypeAttributeDescription
params Object

Parsing params.

params.data ArrayBuffer
  • optional

IFC file data.

params.xktModel XKTModel
  • optional

XKTModel to parse into.

params.autoNormals Boolean
  • optional
  • default: true

When true, the parser will ignore the IFC geometry normals, and the IFC data will rely on the xeokit Viewer to automatically generate them. This has the limitation that the normals will be face-aligned, and therefore the Viewer will only be able to render a flat-shaded representation of the IFC model. This is true by default, because IFC models tend to look acceptable with flat-shading, and we always want to minimize IFC model size wherever possible.

params.wasmPath String

Path to web-ifc.wasm, required by this function.

params.stats Object
  • optional

Collects statistics.

params.log function
  • optional

Logging callback.

Return:

*

public async parseLASIntoXKTModel(params: Object) source

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,
         log: (msg) => { console.log(msg); }
    }).then(()=>{
       xktModel.finalize();
    },
    (msg) => {
        console.error(msg);
    });
});

Params:

NameTypeAttributeDescription
params Object

Parsing params.

params.data ArrayBuffer

LAS/LAZ file data.

params.xktModel XKTModel

XKTModel to parse into.

params.rotateX Boolean
  • optional
  • default: true

Whether to rotate the model 90 degrees about the X axis to make the Y axis "up", if necessary.

params.stats Object
  • optional

Collects statistics.

params.log function
  • optional

Logging callback.

public parseMetaModelIntoXKTModel(params: Object): Promise source

Parses JSON metamodel into an XKTModel.

Params:

NameTypeAttributeDescription
params Object

Parsing parameters.

params.metaModelData JSON

Metamodel data.

params.excludeTypes String[]
  • optional

Types to exclude from parsing.

params.includeTypes String[]
  • optional

Types to include in parsing.

params.xktModel XKTModel

XKTModel to parse into.

params.log function
  • optional

Logging callback.

Return:

Promise

public parsePCDIntoXKTModel(params: Object): Promise source

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.

[Run this example]

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:

NameTypeAttributeDescription
params Object

Parsing params.

params.data ArrayBuffer

PCD file data.

params.littleEndian Boolean
  • optional
  • default: true

Whether PCD binary data is Little-Endian or Big-Endian.

params.xktModel XKTModel

XKTModel to parse into.

params.stats Object
  • optional

Collects statistics.

params.log function
  • optional

Logging callback.

Return:

Promise

public parsePLYIntoXKTModel(params: Object): Promise source

Parses PLY file data into an XKTModel.

Usage

In the example below we'll create an XKTModel, then load a PLY model into it.

[Run this example]

utils.loadArraybuffer("./models/ply/test.ply", async (data) => {

    const xktModel = new XKTModel();

    parsePLYIntoXKTModel({data, xktModel}).then(()=>{
       xktModel.finalize();
    },
    (msg) => {
        console.error(msg);
    });
});

Params:

NameTypeAttributeDescription
params Object

Parsing params.

params.data ArrayBuffer

PLY file data.

params.xktModel XKTModel

XKTModel to parse into.

params.stats Object
  • optional

Collects statistics.

params.log function
  • optional

Logging callback.

Return:

Promise

public async parseSTLIntoXKTModel(params: Object): Promise source

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:

NameTypeAttributeDescription
params Object

Parsing params.

params.data ArrayBuffer | String
  • optional

STL file data. Can be binary or string.

params.autoNormals Boolean
  • optional
  • default: false

When true, the parser will ignore the STL geometry normals, and the STL data will rely on the xeokit Viewer to automatically generate them. This has the limitation that the normals will be face-aligned, and therefore the Viewer will only be able to render a flat-shaded representation of the STL. Overrides smoothNormals when true. This ignores the normals in the STL, and loads no normals from the STL into the XKTModel, resulting in the XKT file storing no normals for the STL model. The xeokit-sdk will then automatically generate the normals within its shaders. The disadvantages are that auto-normals may slow rendering down a little bit, and that the normals can only be face-aligned (and thus rendered using flat shading). The advantages, however, are a smaller XKT file size, and the ability to apply certain geometry optimizations during parsing, such as removing duplicated STL vertex positions, that are not possible when normals are loaded for the STL vertices.

params.smoothNormals Boolean
  • optional
  • default: true

When true, automatically converts face-oriented STL normals to vertex normals, for a smooth appearance. Ignored if autoNormals is true.

params.smoothNormalsAngleThreshold Number
  • optional
  • default: 20

This is the threshold angle between normals of adjacent triangles, below which their shared wireframe edge is not drawn.

params.splitMeshes Boolean
  • optional
  • default: true

When true, creates a separate XKTEntity for each group of faces that share the same vertex colors. Only works with binary STL (ie. when data is an ArrayBuffer).

params.xktModel XKTModel
  • optional

XKTModel to parse into.

params.stats Object
  • optional

Collects statistics.

params.log function
  • optional

Logging callback.

Return:

Promise

public writeXKTModelToArrayBuffer(xktModel: XKTModel): ArrayBuffer source

Writes an XKTModel to an ArrayBuffer.

Params:

NameTypeAttributeDescription
xktModel XKTModel

The XKTModel.

Return:

ArrayBuffer

The ArrayBuffer.