Creating a simple web application with 3D viewer

Hello,

I am fairly new to OpenCASCADE and I am trying to understand the process of creating a simple 3D viewer web application, similar to the WebGL sample provided in the OCCT source. I've been reading a lot about building OCCT with Emscripten, but i can't get it to work properly (i also can't get the sample to build) and I feel I am missing some basic knowledge, but I am not really sure, what exactly. If I want to make use of Emscripten, do I need to build OCCT with Emscripten (and therefore things like VTK, Freetype etc.), or would it be enough to build my project that references OCCT (that was built with CMake and Visual Studio)?

What I am trying to achieve:

I want to make a simple website that can load a STEP file and display it in a generic viewer. I am developing on Windows.

What I already got working:

I was able to build OCCT from source with Visual Studio and CMake. I included VTK and was able to successfully load a STEP file, convert it to VTK format and display it in the VTK render window. I have found examples of VTK used in the web and was thinking about using it too, but it's not a must if OCCT can achieve this goal natively.

I can't seem to find the right resources to learn how to get it to work, so even some pointers on where to start would be much appreciated! Ideally of course would be a list of steps i have to go through in order to get my already working code to work in a browser environment (preferably on Windows and by compiling to WASM).

Thank you in advance!

gkv311 n's picture

would it be enough to build my project that references OCCT (that was built with CMake and Visual Studio)?

When you target WebAssembly platform, all dependencies should be built for the same platform. Emscripten wouldn't be able converting DLLs for Windows into WASM.

In general, you should just forget about Visual Studio existence while targeting WASM - it is of no use here other than just a text editor.

convert it to VTK format and display it in the VTK render window.

Either you are going to use vtk.js or native OCCT viewer (AIS) - the latter is demonstrated by WebGL sample. Notice that IVtk libraries coming with OCCT have been developed only for desktop platform, and likely wouldn't compiler into WASM without modifications. So I would rather avoid building OCCT with VTK dependency.

Jan-Niklas Velten's picture

Thanks for your reply!

I will look into AIS then. Do I understand correctly that AIS is dependent on TCL/TK, or is it possible to create a web based viewer without it?

gkv311 n's picture

AIS (application interactive services, which includes libraries like TKV3d, TKService, TKOpenGl) doesn't depend on Tcl/Tk.

You need Tcl only for building Draw Harness application (which is usually not what you want, although it is possible building and running DRAWEXE for the Web ).