IOViewer provides classes and methods for creating, manipulating, and exporting 3D BIM/CAD models into self-contained HTML/WebGL viewers and structured JSON.
The model data is the IOScene scene model, referenced by the IOViewer package. Its contract
(docs/contract.md) defines every type; in short:
SceneDocument: models, elements, instances, geometries, materials, textures, property sets, levels, grids, viewpoints, 4D schedules and clash tests, in metres with Z up.AddMeshadds one element drawn by one mesh,ComputeBounds()returns the box of what is placed, andValidate()lists what breaks the contract.SceneModel: one source file or linked file, with a uniqueKey. IOViewer shows the first model as the host and the others as linked files.SceneElement: one element (Revit element, IFC product, Navisworks node) with name, category, type, level, property sets and an optionalSourceId, its id in the source format, which the viewer shows and finds in the tree search.SceneInstance: places aSceneGeometryfor an element, with an optionalTransform3d, material and colour. The colour alpha is the only opacity.SceneGeometry: vertices, indices, normals and UVs with a topology. The viewer drawsTrianglesand skips the rest.SceneMaterial,SceneTexture: colour, roughness, metalness and an optional texture with its real-world size in metres, which scales the UVs.SceneViewpoint,SceneGridSystem,SceneSchedule(tasks withElementIds) andSceneClashTest(results withElement1IdandElement2Id; without them the viewer matches an element by name only when the name is unique).
ViewerDocument: aSceneplus what only the viewer uses:SectionPlanes,SectionBoxandHiddenModelKeys, the keys of the linked models hidden at start.Titlereads and writesScene.Title.ViewerSectionPlane: Cutting plane defined by axis or normal vector with offset and flip direction.ViewerSectionBox: 6-sided 3D clipping volume. Section planes and boxes are kept in viewer JSON; the HTML viewer does not apply them when it opens.
HtmlViewerExporter: Generates self-contained, offline-ready 3D HTML viewers using packed Base64 binary buffers. Takes aViewerDocumentor aSceneDocument. The page is written to the output stream as it is produced.HtmlViewerOptions: Title, which data to include (properties, viewpoints, grids, 4D schedule, clashes), the initial display mode (InitialWireframe,InitialWhiteMode), andMaxMeshVertices, which is unlimited by default; when a lower limit leaves meshes out, the viewer shows how many were written.JsonViewerExporter: Writes aViewerDocumentas viewer JSON ("Kind": "ioviewer","Format": 2). A scene alone is written with IOScene'sSceneJson.
GlbViewerImporter: Reads binary glTF 2.0 (.glb) files into aViewerDocumentwith one model. Each glTF mesh primitive becomes oneSceneGeometry, and each node that uses it aSceneInstanceper primitive with the node's world transform, converted from glTF's Y-up to the viewer's Z-up. Each such node also becomes aSceneElement(categoryGLB, named after the node, else the mesh) that all its instances belong to. A material's base colour factor is linear in glTF and becomes an sRGB colour with the same alpha. A node hierarchy that is not a tree (a node referenced twice or a cycle) is rejected withInvalidDataException.ObjViewerImporter: Reads Wavefront OBJ geometry into aViewerDocumentas is, without changing the up axis. Each object or group (o/g) becomes oneSceneGeometryholding only the vertices its faces use, oneSceneInstanceand oneSceneElement(categoryOBJ) with its name. Material (.mtl) files are not read.JsonViewerImporter: Reads viewer JSON (format 2), IOScene scene files and IOViewer 0.1/0.2 snapshots (files withoutKind) into aViewerDocument. A 0.1/0.2 mesh without an element gets an element of its own. A newer format or an unknown kind is rejected withInvalidDataException.