How kovacsv/online3dviewer works
Purpose and Deliverables
Online 3D Viewer is a browser-based 3D model viewer and reusable JavaScript library. It imports many CAD/mesh formats, builds a normalized model representation, renders and explores it in the browser, and exports selected formats. The deployable site is rooted at website/index.html; the reusable engine’s public aggregation point is source/engine/main.js.
Entry Points and Product Layers
The website application boots through source/website/index.js and coordinates UI/application state in source/website/website.js. Embeddable integrations are a distinct surface via source/website/embed.js and engine viewer API source/engine/viewer/embeddedviewer.js. Static deployment assets and sample models reside under website/.
Import Pipeline
source/engine/import/importer.js selects format-specific importers and manages import flow; source/engine/import/importerfiles.js handles file sets and related resources. Individual parsers, such as source/engine/import/importergltf.js, source/engine/import/importerifc.js, and source/engine/import/importerocct.js, form the format boundary. Input can originate from local files, URLs, archives, and dependent files; importers resolve these before producing the common model.
Canonical Model and Geometry
The engine isolates format parsing from rendering through its internal scene/model representation: source/engine/model/model.js, source/engine/model/mesh.js, and source/engine/model/node.js. Meshes, materials, instances, properties, topology, and transforms are normalized here. Foundational math and spatial operations are under source/engine/geometry/, including source/engine/geometry/transformation.js and source/engine/geometry/octree.js. source/engine/model/modelfinalization.js is the likely post-import boundary for making models renderable and queryable.
Rendering and Interaction
source/engine/threejs/threeconverter.js bridges the canonical model into Three.js objects; source/engine/threejs/threemodelloader.js loads that converted scene. Rendering state and interaction are owned by source/engine/viewer/viewer.js, source/engine/viewer/viewermodel.js, source/engine/viewer/camera.js, and source/engine/viewer/navigation.js. This separates browser/WebGL rendering from file-format and model logic.
Website UI Orchestration
The application UI wraps the engine viewer with loading, navigation, inspection, settings, sharing, snapshots, and export. The central model-loading UI adapter is source/website/threemodelloaderui.js; hierarchical model/material/mesh browsing is split across source/website/navigator.js, source/website/navigatoritems.js, and panel modules. URL hash state is managed at source/website/hashhandler.js, enabling URL-based model loading and shareable views.
Export and External Runtime Boundaries
source/engine/export/exporter.js dispatches export, while source/engine/export/exportermodel.js serializes the canonical model through format exporters such as source/engine/export/exportergltf.js and source/engine/export/exporterobj.js. Browser-oriented binary/text/file utilities are centralized in source/engine/io/. Material external dependencies include Three.js for rendering; fflate/Draco for compressed assets; rhino3dm, web-ifc, and occt-import-js for specialized CAD imports. The project is Node/npm-built and published, with CI/release workflows in .github/workflows/.
Main entry points: website.js Website coordinator · importer.js Import dispatcher · model.js Canonical model · main.js Engine public API
Components 22
Website App
Browser-facing application and embed surface.
- Deployable site · Hosts the viewer and sample assets.
website/index.html - Website bootstrap
source/website/index.js - Website coordinator · Coordinates UI state and viewer workflows.
source/website/website.js - Model loader UI · Connects loading progress and results to the application.
source/website/threemodelloaderui.js - Model navigator · Browses model, material, and mesh hierarchy.
source/website/navigator.js - URL hash state · Loads models and views from shareable URLs.
source/website/hashhandler.js - Embed API
source/website/embed.js
Import Pipeline
Format ingestion and resource resolution.
- Import dispatcher · Selects importers and manages import flow.
source/engine/import/importer.js - File-set resolver · Resolves dependent files and related resources.
source/engine/import/importerfiles.js - Format parsers · Includes glTF, IFC, OCCT, and other format importers.
source/engine/import/importergltf.js
Model & Geometry
Normalized engine representation.
- Canonical model · Normalizes meshes, materials, instances, properties, and transforms.
source/engine/model/model.js - Model finalization · Makes imported models renderable and queryable.
source/engine/model/modelfinalization.js - Geometry & spatial ops · Provides transformations and octree-based spatial operations.
Viewer & Rendering
Three.js conversion, rendering, and interaction.
- Engine public API
source/engine/main.js - Three.js converter · Converts the canonical model into Three.js objects.
source/engine/threejs/threeconverter.js - Viewer runtime · Owns rendering state, camera, navigation, and viewer model.
source/engine/viewer/viewer.js - Embedded viewer
source/engine/viewer/embeddedviewer.js
Export Pipeline
Canonical-model serialization.
- Export dispatcher
source/engine/export/exporter.js - Model serializer · Serializes canonical models through glTF, OBJ, and other exporters.
source/engine/export/exportermodel.js
External Boundaries
- Browser I/O · Centralizes browser binary, text, and file handling.
- Three.js
- CAD import runtimes · rhino3dm, web-ifc, and occt-import-js support specialized imports.
Connections 26
- Deployable site → Website bootstrap: loads
- Website bootstrap → Website coordinator: boots
- Website coordinator → Model loader UI: uses
- Website coordinator → Model navigator: drives
- Website coordinator → URL hash state: syncs
- URL hash state → Model loader UI: URL model load
- Model loader UI → Import dispatcher: imports
- Embed API → Embedded viewer: creates
- Engine public API → Import dispatcher: exports
- Engine public API → Embedded viewer: exports
- Engine public API → Export dispatcher: exports
- Import dispatcher → File-set resolver: resolves inputs
- Import dispatcher → Format parsers: dispatches
- File-set resolver → Browser I/O: reads resources
- Format parsers → CAD import runtimes: uses
- Format parsers → Canonical model: produces
- Canonical model → Model finalization: post-processes
- Geometry & spatial ops → Model finalization: supports
- Model finalization → Three.js converter: supplies
- Three.js converter → Three.js: creates objects for
- Three.js converter → Viewer runtime: loads scene
- Viewer runtime → Three.js: renders with
- Website coordinator → Viewer runtime: controls
- Model navigator → Canonical model: inspects
- Export dispatcher → Model serializer: dispatches
- Model serializer → Canonical model: serializes