Namespace scenemodel

xeokit SceneModelParams Importer and Exporter


Import and export renderable SceneModels using xeokit’s JSON-based scene!SceneModelParams interchange format.


This module provides utilities for serializing and deserializing SceneModels to and from the SDK’s canonical JSON representation, scene!SceneModelParams. The format captures a SceneModel’s complete renderable state, including geometry, meshes, textures, materials, transforms, and coordinate-system information.


npm install @xeokit/sdk

Use SceneModelParamsExporter to serialize a SceneModel into a SceneModelParams object, which can then be stored or transmitted as JSON.

import { SceneModelParamsExporter } from "@xeokit/sdk/scenemodel";

const exporter = new SceneModelParamsExporter();

const paramsResult = exporter.write({
sceneModel
});

if (!paramsResult.ok) {
console.error(paramsResult.error);
} else {
const sceneModelParams = paramsResult.value;
const json = JSON.stringify(sceneModelParams, null, 2);
// persist or transmit `json`
}

Use SceneModelParamsLoader to reconstruct a SceneModel from a previously serialized scene!SceneModelParams|SceneModelParams object.

import { SceneModelParamsLoader } from "@xeokit/sdk/scenemodel";
import { Scene } from "@xeokit/sdk/scene";

const scene = new Scene();

const loader = new SceneModelParamsLoader();

const result = loader.load({
sceneModelParams,
scene
});

if (!result.ok) {
console.error(result.error);
} else {
const sceneModel = result.value;
console.log("SceneModel loaded:", sceneModel.id);
}

SceneModelParams is a lossless representation of a SceneModel’s internal state. A SceneModel can be exported and re-imported without changing geometry IDs, object IDs, transforms, or coordinate-system settings, making this format suitable for caching and synchronization workflows.


Classes

SceneModelParamsExporter
SceneModelParamsLoader