%%{init:{"theme":"dark"}}%%
flowchart LR
A[SceneModel] --> B[inspectSceneModel]
B --> C[InspectionReport]
C --> D[applyFixes]
D --> E[ApplyFixesResult]
E -- re-inspect --> B
%%{init:{"theme":"default"}}%%
flowchart LR
A[SceneModel] --> B[inspectSceneModel]
B --> C[InspectionReport]
C --> D[applyFixes]
D --> E[ApplyFixesResult]
E -- re-inspect --> B
flowchart LR
A[SceneModel] --> B[inspectSceneModel]
B --> C[InspectionReport]
C --> D[applyFixes]
D --> E[ApplyFixesResult]
E -- re-inspect --> B
Installation
npminstall@xeokit/sdk
Core Types
Issue: one finding with severity, code, message,
optional resource id, and optional context.
FixRegistry: issue-code dispatch table used by
applyFixes. DEFAULT_FIX_REGISTRY contains the
built-in fixes. Registering a fix for an existing code replaces
the previous mapping.
Tests and one-off pipelines can create fresh registries and pass
them through the matching registry field on the params object.
// Register a fix in the default registry. import*assceneModelInspectorfrom"@xeokit/sdk/inspect/sceneModel";
GEOMETRY_SIMILAR — fits a rigid transform via Kabsch (Horn's quaternion method) and instances each similar geometry through its referencing meshes' matrices
// Re-inspect after applying fixes. constafter = sceneModelInspector.inspectSceneModel({sceneModel});
optimizeSceneModel runs inspection first, stops on
errors, splits oversized geometries, and prunes orphan resources.
Use inspectSceneModel and applyFixes directly when you need
per-rule control.
SceneModel Inspector
Runs inspections on a SceneModel and returns a structured InspectionReport.
applyFixes applies registered fixes for supported issue codes. The module also exports registries, async variants, and optimizeSceneModel.
Shape
Pipeline
Installation
Core Types
context.{codes[], description, run}. Walks a SceneModel and returns issues.{codes[], description, apply}. Handles one or more issue codes.Registries
Inspections and fixes are stored in separate registries:
Tests and one-off pipelines can create fresh registries and pass them through the matching
registryfield on the params object.Use
unregister(code)to remove a fix mapping.Built-in inspections
Built-in inspections are registered in DEFAULT_INSPECTION_REGISTRY.
GEOMETRY_NO_POSITIONS,GEOMETRY_POSITIONS_LENGTH,GEOMETRY_PRIMITIVE_UNSUPPORTED,GEOMETRY_NORMALS_LENGTH,GEOMETRY_UVS_LENGTH,GEOMETRY_COLORS_LENGTH,GEOMETRY_AABB_LENGTH,GEOMETRY_AABB_NONFINITE,GEOMETRY_AABB_INVERTED,GEOMETRY_NO_INDICES,GEOMETRY_INDICES_LENGTH,GEOMETRY_INDEX_OUT_OF_RANGE,GEOMETRY_EDGE_INDICES_LENGTH,GEOMETRY_EDGE_INDEX_OUT_OF_RANGE,GEOMETRY_SPLAT_SCALES_LENGTH,GEOMETRY_SPLAT_ROTATIONS_LENGTH(errors)MESH_DANGLING_GEOMETRY,MESH_DANGLING_MATERIAL,MESH_DANGLING_TRANSFORM,MESH_NONFINITE_MATRIX(errors)OBJECT_DANGLING_MESH(error)TRANSFORM_CYCLE(error)MATERIAL_UNUSED,TEXTURE_UNUSED,TRANSFORM_UNUSED(warnings)TRANSFORM_IDENTITY(warning)GEOMETRY_DUPLICATE(warning, opt-in viacheckDuplicateGeometries)GEOMETRY_SIMILAR(warning, opt-in viacheckSimilarGeometries)GEOMETRY_OVER_BUDGET(warning, opt-in viacheckDenseGeometries)GEOMETRY_OVER_EXTENT(warning, opt-in viacheckLargeGeometries)GEOMETRY_ZERO_VOLUME_AABB,GEOMETRY_DEGENERATE_TRIANGLES,GEOMETRY_UNUSED_VERTICES,GEOMETRY_DUPLICATE_VERTICES,GEOMETRY_NON_WATERTIGHT,GEOMETRY_INCONSISTENT_WINDING,GEOMETRY_AABB_NOT_TIGHT,GEOMETRY_DUPLICATE_INDICES(warnings, opt-in viacheckGeometryQuality)OBJECT_FAR_FROM_ORIGIN,OBJECT_DUPLICATE_AABB(warnings, opt-in viacheckObjectStructure)TEXTURE_NPOT,TEXTURE_OVERSIZED(warnings, opt-in viacheckTextureSanity)GEOMETRY_FAR_FROM_ORIGIN(warning, opt-in viacheckGeometryFarFromOrigin)Built-in fixes
Built-in fixes are registered in DEFAULT_FIX_REGISTRY.
MATERIAL_TEXTURED_GEOMETRY_NO_UVS— synthesises planar UVsMATERIAL_PBR_GEOMETRY_NO_NORMALS— synthesises smooth normalsOBJECT_DANGLING_MESHMATERIAL_UNUSED— destroys the orphan SceneMaterialTEXTURE_UNUSED— destroys the orphan SceneTextureTRANSFORM_UNUSED— destroys the orphan SceneTransformTRANSFORM_IDENTITY— re-parents referencers and destroys the identity transformGEOMETRY_DUPLICATEGEOMETRY_SIMILAR— fits a rigid transform via Kabsch (Horn's quaternion method) and instances each similar geometry through its referencing meshes' matricesGEOMETRY_OVER_BUDGET— splits dense / over-budget geometries (one split per apply)GEOMETRY_OVER_EXTENT— splits large / over-extent geometries (one split per apply)GEOMETRY_DEGENERATE_TRIANGLES— drops zero-area triangles fromgeom.indicesGEOMETRY_UNUSED_VERTICES— compacts unused vertex slots, remaps indicesGEOMETRY_DUPLICATE_VERTICES— coalesces byte-identical vertex slots, remaps indicesGEOMETRY_NON_WATERTIGHT— flipsSolidPrimitive→SurfacePrimitiveOBJECT_DUPLICATE_AABB— destroys duplicate SceneObjects (detach + destroy meshes, then destroy object)GEOMETRY_FAR_FROM_ORIGIN— shifts the AABB to origin and composes the inverse offset into each referencing mesh's matrixGEOMETRY_INCONSISTENT_WINDING— flood-fill flip wrongly-wound triangles to match the seedGEOMETRY_AABB_NOT_TIGHT— re-quantises positions into a tight AABB to recover precisionGEOMETRY_DUPLICATE_INDICES— drops duplicate triangles (same vertex set, any rotation / winding) from indicesCodes without a built-in fix include
MESH_DANGLING_*,MESH_NONFINITE_MATRIX, malformedGEOMETRY_*issues, andTRANSFORM_CYCLE.Typical pipeline: load -> inspect -> applyFixes -> re-inspect -> render.
Example
optimizeSceneModel runs inspection first, stops on errors, splits oversized geometries, and prunes orphan resources. Use
inspectSceneModelandapplyFixesdirectly when you need per-rule control.