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, 3DXML, glTF, LAZ and LAS. |
|
public |
parse3DXMLIntoXKTModel(params: Object): * Loads 3DXML into an XKTModel. |
|
public |
parseCityJSONIntoXKTModel(params: Object): Promise Parses a CityJSON model into an XKTModel. |
|
public |
parseGLTFIntoXKTModel(params: Object): Promise Parses glTF JSON into an XKTModel. |
|
public |
parseIFCIntoXKTModel(params: Object): * Parses IFC STEP file data into an XKTModel. |
|
public |
async parseLASIntoXKTModel(params: Object) 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 |
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): ArrayBuffer Writes an XKTModel to an ArrayBuffer. |
Static Public
public buildBoxGeometry(cfg: *): Object source
import {buildBoxGeometry} from '@xeokit/xeokit-xkt-utils/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-xkt-utils/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-xkt-utils/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-xkt-utils/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-xkt-utils/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-xkt-utils/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-xkt-utils/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-xkt-utils/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-xkt-utils/src/convert2xkt.js'
Converts model files into xeokit's native XKT format.
Supported source formats are: IFC, CityJSON, 3DXML, glTF, LAZ and LAS.
Params:
Name | Type | Attribute | Description |
params | Object | Conversion parameters. |
|
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.metaModelData | ArrayBuffer | JSON |
|
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.log | Function |
|
Logging callback. |
public parse3DXMLIntoXKTModel(params: Object): * source
import {parse3DXMLIntoXKTModel} from '@xeokit/xeokit-xkt-utils/src/parsers/parse3DXMLIntoXKTModel.js'
Loads 3DXML into an XKTModel.
Supports 3DXML Schema 4.2.
Params:
Name | Type | Attribute | Description |
params | Object | Parsing parameters. |
|
params.data | ArrayBuffer | 3DXML BLOB data. |
|
params.domParser | DOMParser | A DOMParser implementation (eg. |
|
params.xktModel | XKTModel | XKTModel to parse into. |
|
params.autoNormals | Boolean |
|
When true, the parser will ignore the 3DXML geometry normals, and the 3DXML
data will rely on the xeokit |
params.stats | Object |
|
Collects statistics. |
params.log | function |
|
Logging callback. |
Return:
* |
public parseCityJSONIntoXKTModel(params: Object): Promise source
import {parseCityJSONIntoXKTModel} from '@xeokit/xeokit-xkt-utils/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.rotateX | Boolean |
|
Whether to rotate the model 90 degrees about the X axis to make the Y axis "up", if neccessary. |
params.stats | Object |
|
Collects statistics. |
params.log | function |
|
Logging callback. |
public parseGLTFIntoXKTModel(params: Object): Promise source
import {parseGLTFIntoXKTModel} from '@xeokit/xeokit-xkt-utils/src/parsers/parseGLTFIntoXKTModel.js'
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.
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:
Name | Type | Attribute | Description |
params | Object | Parsing parameters. |
|
params.data | Object | The glTF JSON. |
|
params.xktModel | XKTModel | XKTModel to parse into. |
|
params.autoNormals | Boolean |
|
When true, the parser will ignore the glTF geometry normals, and the glTF
data will rely on the xeokit |
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): * source
import {parseIFCIntoXKTModel} from '@xeokit/xeokit-xkt-utils/src/parsers/parseIFCIntoXKTModel.js'
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.
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:
Name | Type | Attribute | Description |
params | Object | Parsing params. |
|
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.wasmPath | String | Path to |
|
params.stats | Object |
|
Collects statistics. |
params.log | function |
|
Logging callback. |
Return:
* |
public async parseLASIntoXKTModel(params: Object) source
import {parseLASIntoXKTModel} from '@xeokit/xeokit-xkt-utils/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,
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.rotateX | Boolean |
|
Whether to rotate the model 90 degrees about the X axis to make the Y axis "up", if necessary. |
params.stats | Object |
|
Collects statistics. |
params.log | function |
|
Logging callback. |
public parseMetaModelIntoXKTModel(params: Object): Promise source
import {parseMetaModelIntoXKTModel} from '@xeokit/xeokit-xkt-utils/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-xkt-utils/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 parsePLYIntoXKTModel(params: Object): Promise source
import {parsePLYIntoXKTModel} from '@xeokit/xeokit-xkt-utils/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-xkt-utils/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): ArrayBuffer source
import {writeXKTModelToArrayBuffer} from '@xeokit/xeokit-xkt-utils/src/XKTModel/writeXKTModelToArrayBuffer.js'
Writes an XKTModel to an ArrayBuffer.