3ea347e5 |
1 | WebGL: 3D Viewer (JavaScript|C++|WebAssembly) {#occt_samples_webgl} |
565baee6 |
2 | ================== |
3 | |
4 | This sample demonstrates simple way of using OCCT libraries in Web application written in C++ and translated into WebAssembly module using Emscripten SDK (emsdk): |
5 | https://emscripten.org/ |
6 | |
7 | Sample consists of the Open CASCADE 3D Viewer with a button for opening a model in BREP format. |
8 | The sample requires a WebGL 2.0 capable browser supporting WebAssembly 1.0 (Wasm). |
3ea347e5 |
9 | The sample could be found within OCCT repository in folder `/samples/webgl/`. |
10 | |
11 | @figure{sample_webgl.png,"",240} height=408px |
565baee6 |
12 | |
13 | Installation and configuration: |
14 | 1. Install Emscripten SDK and activate minimal configuration (Python, Java and CLang) following *emsdk* documentation. Activate also MinGW when building sample on Windows host. |
15 | 2. Build (using *emsdk*) or download FreeType static library. |
16 | 3. Configure CMake for building Open CASCADE Technology (OCCT) static libraries (BUILD_LIBRARY_TYPE="Static"). |
17 | For this, activate *emsdk* command prompt, configure CMake for building OCCT using cross-compilation toolchain, disable *BUILD_MODULE_Draw*. |
18 | 4. Perform building and installation steps. |
19 | ~~~~~ |
20 | > ${EMSDK}/fastcomp/emscripten/cmake/Modules/Platform/Emscripten.cmake |
21 | ~~~~~ |
22 | 5. Configure CMake for building this WebGL sample using *emsdk* with paths to OCCT and FreeType. Perform building and installation steps. |
23 | 6. Copy data/occ/Ball.brep from OCCT into "samples" folder within WebGL sample installation path. |
24 | 7. Navigate to installation folder and start web server from it; Python coming with *emsdk* can be used for this purpose: |
25 | ~~~~~ |
26 | > python -m SimpleHTTPServer 8080 |
27 | ~~~~~ |
28 | 8. Open compatible browser and enter path taking into account your web server settings: |
29 | ~~~~~ |
30 | > http://localhost:8080/occt-webgl-sample.html |
31 | ~~~~~ |