j3d

3d viewer for ply, stl, obj, vox, off, trc, gltf, glb

3d · cpu · large-files · mesh · ply
入门
GitHub在线演示
Stars:11
License:MIT License
更新:2025/11/12

README

j3d

3d viewer for ply, stl, obj, vox, off. Also minor support for gltf and glb (geometry is loaded, but not all textures and materials will be loaded).

Introduction

j3d is a simple and straightforward application for visualizing 3d meshes and point clouds. The application uses software rendering so it can be used together with, for instance, Windows Remote Desktop without problems. Furthermore very large files can also be handled provided you have sufficient RAM. You need approximately 39 bytes of RAM per triangle (assuming no textures or vertex colors are present in the file). Thus, you need 11.7Gb of RAM to render a file with 300 million triangles.

Building

First of all, j3d uses submodules, so don't forget to also call

 git submodule update --init

Next, run CMake to generate a solution file on Windows, a make file on Linux, or an XCode project on MacOs. You can build j3d without building other external projects (as all necessary dependencies are delivered with the code).

On MacOs, you might need to install X11. This can be done with the command

brew install --cask xquartz

Furthermore it is possible that linking with OpenGL fails. That's because I've hardcoded the location of my OpenGL binaries in the j3d/CMakeLists.txt file. Simply change the location of the OpenGL include and library folders/files and you should be good to go.

The default multithreading approach uses std::thread. There is however the option to use multithreading via Intel's TBB library. This is an option in CMake: set the JTK_THREADING variable to tbb. You will have to make sure that you have the correct dll files and lib files to link with TBB. You can set the necessary variables TBB_INCLUDE_DIR and TBB_LIBRARIES via CMake.

If you build for a Mac M1 with ARM processor, then set the CMake variables JTK_TARGET to arm.

File format comparisons

The table below compares different file formats that are supported by j3d. We show the time necessary to load the file from disk, and the size that the file format takes on the disk. The comparison is done on a moderately large file, Lucy (see screenshot), from the Stanford 3D Scanning Repository. This file contains 28 million triangles and 14 million vertices. The file formats TRC, PLY, STL, and GLB are binary file formats. The file formats GLTF, OFF, OBJ are human readable file formats.

File formatLoad timeFile sizeReference
TRC0.9s268,039 KBtrico
PLY2.52s520,566 KBwikipedia
STL4.53s1,369,910 KBwikipedia
GLB5.6s547,965 KBwikipedia
GLTF12.5s657,558 KBwikipedia
OFF26.8s1,231,375 KBwikipedia
OBJ34s1,139,098 KBwikipedia

Note that, apart from the disk loading time, j3d also spends time to construct a bounding volume hierarchy (bvh) for rendering. The time to generate a bvh for Lucy is about 3.6s.

Conversion to MagicaVoxel example

We start from a Wavefront obj file that was downloaded from https://free3d.com/nl/3d-model/skull-v3--785914.html.

We saved this file as a .vox file, which is the MagicaVoxel file format (https://ephtracy.github.io/). The resolution of the voxel file can be set via the Vox menu. In this example the size of the largest dimension equals 100 voxels.

The generated .vox file can be loaded in MagicaVoxel.

Compressing STL files by a factor 5

Load any file, and save it to TRC file format, see trico.

The following table comes from trico, and shows the compression ratios of the TRC file format. Note that TRC is much faster in compression and decompression than the standard zip algorithm (zdeflate / zinflate). TRC is lossless. The files were taken from the Stanford 3D Scanning Repository.

ModelTrianglesVerticesBinary STLBinary PLYBinary PLY zippedTricoCompression ratio vs STLCompression ratio vs PLYCompression ratio vs PLY zipped
Stanford Bunny69451359473392 KB1291 KB522 KB571 KB5.942.260.91
Happy Buddha108771654365253112 KB20180 KB10135 KB9146 KB5.812.211.11
Dragon87141443764542550 KB16192 KB8129 KB7274 KB5.852.231.12
Armadillo34594417297416892 KB6757 KB3794 KB4059 KB4.161.660.93
Lucy28055742140278721369910 KB520566 KB296014 kB230609 KB5.942.261.28
Asian Dragon72190453609600352493 KB133949 KB68541 KB49896 KB7.062.681.37
Vellum manuscript*43058182155617210246 KB86241 KB42783 KB23465 KB8.963.681.82
Thai Statue100000004999996488282 KB185548 KB104048 KB86165 KB5.672.151.21

* the PLY and Trico file contain vertex colors, the STL file does not.

Thirdparty