Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://opensource.org/licenses/MIT)
[![Platform](https://img.shields.io/badge/.NET-8.0%20%7C%2010.0-512BD4?style=flat-square&logo=dotnet)](https://dotnet.microsoft.com/)

IOViewer is a fast, 100% managed .NET library and command line tool that generates standalone interactive 3D WebGL / HTML BIM & CAD model viewers from code, glTF/GLB, Wavefront OBJ, or JSON. Geometry read by sibling libraries ([RvtIO](https://github.com/IOExtend/RvtIO), [IfcIO](https://github.com/IOExtend/IfcIO), and [NwcIO](https://github.com/IOExtend/NwcIO)) can be passed in by building a `SceneDocument` in code, and the `ioviewer` command line tool reads IFC and Revit files directly through IfcIO and RvtIO. The scene model comes from the [IOScene](https://github.com/IOExtend/IOScene) package; the IOViewer library has no dependency on the format libraries.
IOViewer is a fast, 100% managed .NET library and command line tool that generates standalone interactive 3D WebGL / HTML BIM & CAD model viewers from code, glTF/GLB, Wavefront OBJ, or JSON. Builds of the `ioviewer` CLI from this repository also read IFC, Revit and Navisworks cache files (`.nwc`) through `IfcIO.Scene`, `RvtIO.Scene` and `NwcIO.Scene`. The IOViewer library accepts the `SceneDocument` these adapters produce and depends on [IOScene](https://github.com/IOExtend/IOScene) for the scene model.

The generated HTML is a single file with no external dependencies that works offline: it opens from disk (`file://`) in a current browser with WebGL 2 and makes no network requests. The viewer is built on [three.js](https://threejs.org/), which is embedded in the file (see [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md)).

Expand Down Expand Up @@ -137,6 +137,22 @@ var doc = GlbViewerImporter.Load("complex_building.glb");
HtmlViewerExporter.Save(doc, "complex_building.html");
```

To view a Navisworks cache, install `NwcIO.Scene` with `dotnet add package NwcIO.Scene --version 0.13.0` and pass its scene to IOViewer.

```csharp
using IOViewer.Exporters;
using NwcIO.Scene;

var result = NwcSceneReader.Read("Tower.nwc");
HtmlViewerExporter.Save(result.Document, "Tower.html");
```

The adapter is in preview and can reject some NWC caches. Check `result.Diagnostics` for conversion warnings and errors. For supported inputs and limits, see the
[NwcIO.Scene guide](https://github.com/IOExtend/NwcIO/blob/v0.13.0/docs/scene.md).

For `IOViewer.Cli` 0.3.1, save the same scene with `IOScene.SceneJson.Save(result.Document, "Tower.scene.json")` and run
`ioviewer Tower.scene.json`. See the [IOScene JSON handoff](docs/getting-started.md#navisworks-cache) for the full workflow.

See the [public API](docs/public-api.md) for the supported surface and [getting started guide](docs/getting-started.md) for detailed workflows.

## Documentation
Expand Down
35 changes: 35 additions & 0 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ ioviewer model.nwc
ioviewer model.glb --serve
```

The direct `.nwc` command is available in CLI builds from this repository. Published `IOViewer.Cli` 0.3.1 uses the
[IOScene JSON handoff](#navisworks-cache) for Navisworks models.

## C# API usage

The model data is a `SceneDocument` from the [IOScene](https://github.com/IOExtend/IOScene) package: models, elements,
Expand All @@ -52,6 +55,38 @@ HtmlViewerExporter.Save(scene, "tower_viewer.html");
box and the keys of the models hidden at start. `JsonViewerExporter` writes it as viewer JSON, and `JsonViewerImporter`
reads viewer JSON, IOScene scene files and IOViewer 0.1/0.2 snapshots.

## Navisworks cache

Add `NwcIO.Scene` alongside `IOViewer` in your .NET project.

```sh
dotnet add package NwcIO.Scene --version 0.13.0
```

Read the `.nwc` file into an IOScene document and export it to HTML.

```csharp
using IOViewer.Exporters;
using NwcIO.Scene;

var result = NwcSceneReader.Read("Tower.nwc");
HtmlViewerExporter.Save(result.Document, "Tower.html");
```

Inspect `result.Diagnostics` for warnings and errors. See the [NwcIO.Scene guide](https://github.com/IOExtend/NwcIO/blob/v0.13.0/docs/scene.md)
for supported caches, diagnostics and conversion limits.

The adapter is in preview. Some caches, including the IFC-derived office and terrain caches in the
[Safe Software Navisworks example](https://support.safe.com/hc/en-us/articles/37510812360717-Getting-Started-with-Navisworks),
fail to load with `NwcIO.Scene` 0.13.0. If you have the original IFC or Revit file, you can pass it directly to `ioviewer`.

For the IOScene JSON handoff, save the scene with `IOScene.SceneJson.Save(result.Document, "Tower.scene.json")`.
Then open it with the CLI, including `IOViewer.Cli` 0.3.1.

```sh
ioviewer Tower.scene.json -o Tower.html
```

## Sharing geometry between instances

Repeated shapes, such as identical fittings or columns, are stored once in `SceneDocument.Geometries` and placed by
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: IOViewer

# IOViewer

**IOViewer** is a fast, 100% managed .NET library and CLI tool for generating standalone interactive 3D WebGL / HTML BIM & CAD model viewers directly from code or file formats (glTF/GLB, Wavefront OBJ and JSON; the CLI tool also reads IFC and Revit files through IfcIO and RvtIO).
**IOViewer** is a fast, 100% managed .NET library and CLI tool for generating standalone interactive 3D WebGL / HTML BIM & CAD model viewers directly from code or from glTF/GLB, Wavefront OBJ and JSON. CLI builds from this repository also read IFC, Revit and Navisworks cache files (`.nwc`) through `IfcIO.Scene`, `RvtIO.Scene` and `NwcIO.Scene`. For the library and published CLI 0.3.1, see the [Navisworks workflow](getting-started.md#navisworks-cache).

The generated HTML is a single file with no external dependencies that works offline: it opens from disk in a current browser with WebGL 2, without servers, plug-ins or network requests. The viewer is built on three.js, embedded in the file.

Expand Down
3 changes: 3 additions & 0 deletions src/IOViewer/Viewer/test/e2e/global-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ export default function globalSetup() {
exportHtml(widePath, 'wide-ids');

const building = JSON.parse(readFileSync(path.join(fixturesDir, 'building.json'), 'utf8'));
const noGrids = path.join(results, 'building-no-grids.json');
writeFileSync(noGrids, JSON.stringify({ ...building, Scene: { ...building.Scene, Grids: [] } }));
exportHtml(noGrids, 'building-no-grids');
const planes = [{ Axis: 3, Normal: [0, 0, 2], Offset: 2 }, { Axis: 0, Offset: -100, Enabled: false }];
for (const [name, box] of [
['building-section-planes', null],
Expand Down
17 changes: 7 additions & 10 deletions src/IOViewer/Viewer/test/e2e/sections.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ for (const inverted of [false, true]) {
}

test('a Z plane through the middle cuts the roof away; flipping it brings the roof back and cuts the ground slab; reset restores', async ({ page }) => {
const errors = await open(page);
await page.evaluate(() => window.__ioviewer.grids.setVisible(false)); // axis 2 runs across the sampled slab rim
// Axis 2 runs across the sampled slab rim.
const errors = await open(page, 'building-no-grids');
const roof = await indexOf(page, 'Roof Slab');
const ground = await indexOf(page, 'Ground Slab');
// Roof top near its back edge (seen past the roof there is only background) and the ground slab rim right of the
Expand All @@ -147,23 +147,20 @@ test('a Z plane through the middle cuts the roof away; flipping it brings the ro
expect(state).toMatchObject({ mode: 'planes', axis: 'z' });
expect(state.z).toBeCloseTo(state.mid, 9);
await page.evaluate(() => window.__ioviewer.sections.setGizmoVisible(false)); // keep the handles off the sampled pixels
await frame(page);
expect(cleared(await rgb(page, roofAt), roofBefore)).toBe(true);
await expect.poll(async () => cleared(await rgb(page, roofAt), roofBefore)).toBe(true);
expect(await pickAt(page, roofAt)).not.toBe(roof);
expect(cleared(await rgb(page, groundAt), groundBefore)).toBe(false);
expect(await pickAt(page, groundAt)).toBe(ground);

await panel(page).getByRole('button', { name: 'Сменить сторону' }).click();
await frame(page);
expect(await rgb(page, roofAt)).toEqual(roofBefore); // the roof is in front of the plane rectangle
await expect.poll(() => rgb(page, roofAt)).toEqual(roofBefore); // the roof is in front of the plane rectangle
expect(await pickAt(page, roofAt)).toBe(roof);
expect(cleared(await rgb(page, groundAt), groundBefore)).toBe(true);
await expect.poll(async () => cleared(await rgb(page, groundAt), groundBefore)).toBe(true);
expect(await pickAt(page, groundAt)).not.toBe(ground);

await tool(page, 'resetSections').click();
await frame(page);
expect(await rgb(page, roofAt)).toEqual(roofBefore);
expect(await rgb(page, groundAt)).toEqual(groundBefore);
await expect.poll(() => rgb(page, roofAt)).toEqual(roofBefore);
await expect.poll(() => rgb(page, groundAt)).toEqual(groundBefore);
expect(await page.evaluate(() => [window.__ioviewer.sections.mode, window.__ioviewer.sections.planes.length])).toEqual(['off', 0]);
await expect(tool(page, 'plane')).not.toHaveClass(/active/);
expect(errors).toEqual([]);
Expand Down
4 changes: 3 additions & 1 deletion src/IOViewer/Viewer/test/e2e/ui.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ test('right click on nothing opens the short menu; Esc, an outside click and the
// The same for a tree row under the press.
await rail(page, 'model').click();
await sidePanel(page, 'model').locator('.ioviewer-tree').evaluate((t) => (t.scrollTop = 0)); // it scrolled to D3
const ducts = await rows(page).filter({ hasText: 'Ducts' }).boundingBox();
const ductsRow = rows(page).filter({ hasText: 'Ducts' });
await expect(ductsRow).toBeVisible();
const ducts = await ductsRow.boundingBox();
await page.mouse.click(1000, 40, { button: 'right' }); // background clear of the open panel and the view cube
await expect(menu(page)).toBeVisible();
await page.mouse.click(ducts.x + 20, ducts.y + ducts.height / 2); // press on the Ducts category header
Expand Down
Loading