This sample demonstrates how to use SceneLayer.queryModels() and SceneLayer.queryModel() to inspect and download source and derived models from a 3D object layer. The sample lets you select features in the scene, lists the available models for those features in a side panel, and downloads the chosen model files on demand.

Use queryModels() to retrieve the model metadata for the selected features. The method returns model information grouped by object ID, and the sample converts those grouped results into rows in the side panel.

const modelsByObjectId = await sceneLayer.queryModels({ objectIds });
const entries = [...modelsByObjectId].flatMap(([objectId, models]) =>
models.map((model) => ({
objectId,
model,
format: model.format,
isSource: model.isSource,
files: model.files,
size: model.size,
})),
);

Clicking Download for a model row calls queryModel() to retrieve that specific model. If the format parameter is omitted, the source model is returned; if a format such as glb is provided, the matching derived model is returned when available. The formats supported by the service are listed in sceneLayer.capabilities.data.queryFormats. After that, download each returned ModelFileInfo with arrayBuffer().

const options = entry.isSource ? undefined : { format: entry.model.format };
const model = await sceneLayer.queryModel(entry.objectId, options);
if (!model) {
return;
}
for (const [index, file] of model.files.entries()) {
const blob = new Blob([await file.arrayBuffer()], { type: "application/octet-stream" });
triggerDownload(blob, downloadName(entry, index, model.files.length));
}

If you need displayable Mesh geometry instead of model metadata or downloadable files, use SceneLayer.queryFeatures() with returnGeometry set to true.

For more detail, see the Inspecting source and derived models section in 3D object workflows in the SDK.