Skip to content
WebODMPublic

About

Fast streaming of OBJ / binary glTF textured meshes in three.js

Resources

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

 

History

13 Commits

Folders and files

Repository files navigation

CNXT

Converts textured meshes into streamable multiresolution NXT files and displays them in the browser with a three.js viewer.

image

Accepts .obj (+ .mtl) and .glb. Output is a single .nxt written next to the input: model.obj becomes model.nxt.

Install

Download the prebuilt binaries from the Releases page.

Command line

cnxt /path/to/model.obj
Flag Effect
-o, --output <FILE> Override output path.
--metadata <JSON> JSON object stored in the header, available to the viewer before streaming.
-q, --jpeg-quality <N> JPEG quality of the finest level. Default 90.
-s, --scaling <F> Texel reduction per level. Default 0.25.
-f, --faces-per-node <N> Max triangles per node. Default 32768.
-n, --no-normals Do not store per-vertex normals.
-j, --threads <N> Worker threads. Default: all cores.
-v, --verbose More output.
--progress Print only progress percentages (0%-100%), one per line.
-h, --help All options.

Viewer

You must serve .nxt files from a server that supports HTTP Range requests.

<script src="three.min.js"></script>
<script src="nxt-three.min.js"></script>
<script>
  const model = new THREE.NXTObject("model.nxt", { renderer });
  scene.add(model);
</script>

viewer/index.html is an example viewer: open a URL or drop a .nxt file, with a debug view of the tile streaming.

To try it, run python3 viewer/test/serve.py 8000 viewer and open http://localhost:8000.

Build

Requires: CMake 3.16+ and a C++17 compiler (GCC, Clang or clang-cl)

cmake -S . -B build
cmake --build build --config Release

x86-64 builds target AVX2 CPUs. Pass -DCNXT_AVX2=OFF for older CPUs.

To rebuild the viewer after editing viewer/src (requires Node.js 18+):

cd viewer
npm ci
npm run build

Design Goals

The program is designed with two primary goals in mind:

  • Fast generation of .NXT files
  • Seamless display of meshes that have relatively small triangle counts but very large textures

For this reason, coarser levels are not geometrically simplified. Simplifying the geometries would provide small savings in the rendering budget and node size, but cause "jumps" in rendering and make the build time much longer. For this reason, we don't do it.

Credits

CNXT is based on Nexus by the Visual Computing Lab, ISTI-CNR. The NXT format is derived from Nexus' NXS format, and geometry is compressed with corto.

License

CNXT is licensed under the AGPLv3.

Nexus is GPLv3-licensed. Third-party code keeps its own license: corto (MIT), draco (Apache 2.0), stb (MIT / public domain) and three.js (MIT). See the license files in each third_party folder.

About

Fast streaming of OBJ / binary glTF textured meshes in three.js

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages