exportGraphics Method
Export meshes suitable for graphics APIs from arbitrary geometry in elements in this IModelDb.
- Requests can be slow when processing many elements so it is expected that this function be used on a dedicated backend, or that shared backends export a limited number of elements at a time.
- Vertices are exported in the IModelDb's world coordinate system, which is right-handed with Z pointing up.
- The results of changing ExportGraphicsOptions during the ExportGraphicsOptions.onGraphics callback are not defined.
Example that prints the mesh for element 1 to stdout in OBJ format
const onGraphics: ExportGraphicsFunction = (info: ExportGraphicsInfo) => {
const mesh: ExportGraphicsMesh = info.mesh;
for (let i = 0; i < mesh.points.length; i += 3) {
process.stdout.write(`v ${mesh.points[i]} ${mesh.points[i + 1]} ${mesh.points[i + 2]}\n`);
process.stdout.write(`vn ${mesh.normals[i]} ${mesh.normals[i + 1]} ${mesh.normals[i + 2]}\n`);
}
for (let i = 0; i < mesh.params.length; i += 2) {
process.stdout.write(`vt ${mesh.params[i]} ${mesh.params[i + 1]}\n`);
}
for (let i = 0; i < mesh.indices.length; i += 3) {
const p1 = mesh.indices[i];
const p2 = mesh.indices[i + 1];
const p3 = mesh.indices[i + 2];
process.stdout.write(`f ${p1}/${p1}/${p1} ${p2}/${p2}/${p2} ${p3}/${p3}/${p3}\n`);
}
};
iModel.exportGraphics(({ onGraphics, elementIdArray: ["0x1"] }));
exportGraphics(exportProps: ExportGraphicsOptions): DbResult
Parameter | Type | Description |
---|---|---|
exportProps | ExportGraphicsOptions |
Returns - DbResult
0 if successful, status otherwise
Defined in
- backend/src/IModelDb.ts Line 1236
Last Updated: 30 November, 2023