
Ask HN: Best Graphics libraries to build CAD solutions? - sheunl
I am building custom CAD software for electrical and mechanical design. Which Graphics libraries or solution do you recommend? And is Java 3D API viable?
======
ampdepolymerase
If you are being pragmatic about things, a game engine is probably the best.
For 3D, give Godot a try. Otherwise there are plenty of other commercial
solutions (Unity, Unreal, there are quite a few). 2D engines are more common
than 3D engines, so simply select one that is most compatible with your
preferred tech stack. Game engines will require more upfront work for the GUI
part of CAD software, but it will make the actual CAD a lot easier as a large
amount of constraints and collision physics already come built in. Modern game
engines also come with importers for common CAD file formats, so that will
make your life a lot easier too. The modern Unity-style game engine with
everything and the kitchen sink included is somewhat of a recent phenomenon.
Traditionally game engines are small poorly documented libraries and therefore
less than helpful unless you were truly desperate. Also, the CAD field moves
slowly when it comes to adoption of new technology and most of the incumbents
are still using core in-house technology from decades ago. My above assessment
is based on the current state of the art for both fields.

Some helpful links:

[http://www.publicworksgroup.com/blog/2012/02/will-gaming-
eng...](http://www.publicworksgroup.com/blog/2012/02/will-gaming-engines-
replace-cad/)

[https://www.unrealengine.com/en-US/spotlights/meshmatic-
opti...](https://www.unrealengine.com/en-US/spotlights/meshmatic-optimizing-
cad-data-for-interactive-visualization)

[https://www.researchgate.net/figure/Unity3D-Game-Engine-
and-...](https://www.researchgate.net/figure/Unity3D-Game-Engine-and-
preferred-integration-with-CAD-BIM-software_fig3_258241826)

------
sbayeta
If you're building for the web, konva.js apparently can do that. I recently
spent a few days reasarching for libraries to implement simple CAD
functionality (similar to what you would use for a gerber file viewer), and
finally decided to use that library.

The other options I considered were: \- pixi.js (very popular and active, very
high performance, too low level for my needs) \- fabric.js (also very popular,
similar to konva but does not support layers functionality)

Konva seems to be very actively maintained, and has been around for several
years. Users in forums seem mostly happy with it. Very simple to use too (I'm
just starting with it, so not much experience).

[https://konvajs.org/docs/sandbox/index.html](https://konvajs.org/docs/sandbox/index.html)

------
leon_sbt
If you're targeting a browser based solution. Three JS and Babylon.js gives
you the building blocks.

If you're looking more of a Constructive Solid Geometry based web solution
jscad/CSG.js.

If you want something more turnkey with a BREP kernel look at what the folks
at [https://www.autodrop3d.com/parametric-
cad.html](https://www.autodrop3d.com/parametric-cad.html) and
[https://buerli.io/](https://buerli.io/) are building. Super interesting.

Not affiliated with the above companies, I just do dev on related software.

------
jasode
Autodesk Fusion 360 uses Qt gui library. Some screenshots of its UI :
[https://www.google.com/search?q=%22autodesk+fusion+360%22+ui...](https://www.google.com/search?q=%22autodesk+fusion+360%22+ui&source=lnms&tbm=isch)

Here are some more CAD apps using Qt:
[https://en.wikipedia.org/wiki/Category:Engineering_software_...](https://en.wikipedia.org/wiki/Category:Engineering_software_that_uses_Qt)

(Although Fusion 360 was launched June 2013, nobody edited the wiki page to
include it yet.)

~~~
colejohnson66
I never would’ve guessed F360 was Qt based. It almost looks like they’re all
custom widgets, but I haven’t used Qt for a bit, so I could be wrong.

------
deepaksurti
If open source suits you fine then I would recommend Blender. See [1] and [2]
as examples of blender plugins for open foam based simulations.

With Blender you get advantages of open source, game engines and a fairly
extensible 3d toolkit.

[1] [https://github.com/dmsurti/reynolds-
blender](https://github.com/dmsurti/reynolds-blender)

[2] [https://github.com/dmsurti/reynolds](https://github.com/dmsurti/reynolds)

Disclaimer. I am the author of [1] and [2].

------
tmilard
I think your question is very-very related to your development language.

\- 1) C++ : I think many, if not most 3D graphic libraries are based on C++
language. I am no specialist here.google it.

\- 2) java : I use java3D but I believe there are now other more active 3D
apis .Like JMonkey.

\- 3) javascript/typeScipt : If you use the web as your target, I think the
best-and-easiest 3D API is clearly BabylonJs. I use it and I think it is super
easy to begin wih.

Thierry, [https://free-visit.net](https://free-visit.net)

------
scott31
[https://github.com/bkaradzic/bgfx](https://github.com/bkaradzic/bgfx)

------
Const-me
Since you asked about Java 3D, I assume you want to render 3D in your app.

I’ve built a couple of moderately advanced CAD/CAM/CAE apps with WPF +
Direct3D 11. Both me and my clients were happy with the software.

You don’t want C++ for 2D GUI parts, or other higher-level pieces like disk
I/O or networking. It’s too low-level, and too unsafe which inevitably gonna
cause issues once your code grows complex enough. If you only want to support
Win10, UWP might be even better because easier to integrate with Direct3D, for
WPF you’ll need to write a page of C++ code to make sense of DXGI surface
sharing (WPF renders with DirectX9 not D3D11, but it’s possible to pass frames
in VRAM by sharing a texture).

On Windows, you want Direct3D for the GPU API. If you have a good PC with a
recent nVidia card all of them gonna work great. However, as your install base
grows, you’ll inevitably have to deal with Intel and AMD GPUs (Intel only
supports VK since Skylake), GPUs older than a few years, outdated GPU drivers,
and other shenanigans. Direct3D is way more reliable than GL or VK in these
cases, because supported by MS (GL and VK are only supported by GPU vendors),
better integrated into Windows (major parts of D3D are in dxgkrnl.sys kernel
mode driver), and used a lot by the OS itself (since Vista, desktop compositor
uses D3D to render desktop; in Win10, all UWP apps like calculator render with
D3D 11).

You do want C++ in the backend. Not just because D3D (that alone is solvable
with SharpDX and others), because too many C++ libraries useful for CAD were
written over the course of decades. The 3 most useful for me were DirectXMath,
Eigen, and Geometric Tools. Fortunately, interop between C++ and C# in the
same process is both simple and efficient. On Windows I usually use COM
interfaces created by C functions exported from a native DLL.

Game engines are huge, and designed for different use cases. They are trying
to render stuff at refresh rate of the display; you don’t want that in a CAD
app, your only want to render frames when things change. They assume most
things are immutable once loaded from disk and rely on offline pre-processing
for a lot of things, while CAD apps need to import whatever, and many things
are user-editable. Game engines often strive for photorealistic rendering. You
probably don’t need deferred shading or volumetric lightning in your CAD app,
let alone water, vegetation, day/night cycle or character animation. All these
features complicate a lot of things in game engines.

If you want to be able to port to non-Windows, look for a GPU abstraction
library as opposed to a game engine. For example, I have positive experience
(unrelated to CAD) with this library [http://diligentgraphics.com/diligent-
engine/](http://diligentgraphics.com/diligent-engine/) It has “engine” in the
name but I don’t think that’s an engine, it’s a GPU abstraction library which
was exactly what I wanted.

------
dekhn
qt

~~~
colejohnson66
I’d absolutely love if Qt was available in Rust as “easily”[a] as GTK is.

[a] While getting a “Hello, world” GUI working with GTK-rs on Windows is an
exercise in frustration, Qt on Rust is harder as it requires generating
bindings due to the C++ API.

------
emteycz
Because someone said game engines, I recommend Bevy engine (Rust, with full
web support). Includes good UI solution.

