Where to use Web Assembly in a ThreeJs CAD Software

There is this video that I found:

I believe they use ThreeJs, but I found out that they might be using C++ somewhere:

Does anyone know where they use ThreeJs, and where they could be using C++ and WASM?

For example, the 2D Window, is all that logic in threejs, like making new rooms, creating walls?
How does the mouse detect each room, and how do the rooms have information?

Is there any C++ code that they use for the 3D Window?

Essentially what I am trying to figure out, is if I were to create a “simplified revit” for the web, where using C++ is better than threejs.

  1. Cpp is a programming language - three.js is a JavaScript library. It’s not possible to compare them in any reasonable way. What you could compare is an equivalent 3D library built for Cpp (raylib for ex.) otherwise you’re comparing airplanes to airlines - they are connected, but have zero logical overlap.

  2. Cpp libraries will have way better memory control and GPU access. Three is limited by what browsers allow. You need exceptional performance and don’t need portability browsers give? Go for Cpp.

  3. Three can run on most devices that have internet browsers - Cpp requires more complex building pipelines depending on what you’re building for.

  4. Since that appeared recently - due to its environment limitations, three can’t handle super large files unless it’s run outside the browser (in electron for ex.) - which may be an important factor for CAD apps. Browsers won’t let you edit gigabyte-sized files easily.

1 Like

okay thank you, i have an additional question, if u watched the video do you think any of the features that they have is mostly using javascript and threejs? Because im thinking where they could possibly using C++.

I didn’t watch the entire video - it’s 10mins long :sweat_smile:

But skipping through parts of the video - all of this can be done in either js (if you’d need file system access - just using electron instead of browser directly) or in cpp; nothing in there seems heavy / complex enough to make the differences between the two languages relevant in this case.

As someone working with revit data atm, i don’t think that this is a one man job tbh. Especially if you are asking questions like this (no offense).

Yeah you would probably be better off using c++ or rust for most of this functionality, since its faster and more efficient.

So your saying that its either C++ or Threejs? Not both?

We are also using wasm + three for a similar use case https://buerli.io.

We had to make lots of changes and fixes to support both the C++ codebase runtime and wasm via Empscripten. The wasm backend takes care of parts & assemblies, constraint solving and nurbs topo. The state is synced between the front and back end via json-patch. It’s using threejs via react-three-fiber for visualisation. The sketcher was completely made in javascript/react.

If you have specific questions i might be able to answer …

2 Likes

How do you get data out of wasm?

Cpp has to run on a local / server machine - you can’t effectively run it in the browser (even with WASM.), and js can run in the browser. How you mix and match them - 100% your decision, no answer should be dramatically wrong in this case.

  • If you want to build a browser app - just js + three will be way easier and quicker. And as above - nothing in the video seems to really need Cpp-level of performance.
  • If you need to build a native app - just js + electron will be way easier and quicker (since codebase will be using js everywhere.)
  • If you have a valid reason to use Cpp + js (ex. you’re way more experienced with Cpp and just want three.js on the frontend layer) - go for Cpp and js, ain’t nothing wrong with mixing them.
1 Like

i wanted to ask why you decided to use wasm for things like:

  • boolean
    • why didnt you just use an existing CSG library for three?

What made you decide to use wasm instead of threejs functions? and how much C++ experience do you you think someone needs to create some functionality like this? Personally I have experience with C++, but never with computational geometry.