Module @xeokit/dtx - v0.1.0

npm version

xeokit DTX Importer and Exporter


Import and export models as xeokit's native binary DTX format


The xeokit SDK allows us to import 3D models from DTX, which is xeokit's native runtime asset delivery format for model representations and semantics.

The DTX format compresses large double-precision model representations and semantic data to a compact payload that loads quickly over the Web into a xeokit viewer running in the browser.

To import a DTX model into xeokit, use the loadDTX function, which will load the file into a SceneModel and a DataModel.

To export a DTX model from xeokit, use the saveDTX function, which will save a SceneModel and a DataModel to DTX file data.



Installation

npm install @xeokit/dtx

Usage

In the example below, we'll use loadDTX to import a DTX file into a DataModel and a SceneModel. The @xeokit/core!SDKError class is used to handle errors that may occur during the process:

import {Data} from "@xeokit/data";
import {Scene} from "@xeokit/scene";
import {loadDTX, saveDTX} from "@xeokit/dtx";

const data = new Data();
const scene = new Scene();

const dataModel = data.createModel({
id: "myModel
});

const sceneModel = scene.createModel({
id: "myModel
});

if (dataModel instanceof SDKError) {
console.error(dataModel.message);
} else if (sceneModel instanceof SDKError) {
console.error(dataModel.message);
} else {
fetch("myModel.dtx").then(response => {

response.arrayBuffer().then(data => {

loadDTX({ data, dataModel, sceneModel });

dataModel.build();
sceneModel.build();
});
});
});

Using @xeokit/dtx!saveDTX to export the DataModel and SceneModel to DTX file data in an ArrayBuffer:

const arrayBuffer = saveDTX({
dataModel,
sceneModel
});

@xeokit/dtx

Index

Interfaces

Functions

Generated using TypeDoc