File: README.md

package info (click to toggle)
vtk9 9.5.2%2Bdfsg3-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 205,984 kB
  • sloc: cpp: 2,336,570; ansic: 327,116; python: 111,200; yacc: 4,104; java: 3,977; sh: 3,032; xml: 2,771; perl: 2,189; lex: 1,787; makefile: 181; javascript: 165; objc: 153; tcl: 59
file content (35 lines) | stat: -rw-r--r-- 1,179 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Build

This example needs VTK.wasm compiled with `VTK_WEBASSEMBLY_THREADS=ON`. If you're compiling
with vtk-wasm-sdk image from dockerhub, make sure to use the threads variant.

Compared to `AsyncClipper`, the main difference in this example is that there is no `main(int, char**)`
function and the entire application is driven from javascript through C++ functions wrapped with embind.

This example shows in detail how to create a pthread and transfer the
canvas offscreen so that the new web worker can render into it. In the
`AsyncClipper`, we used `-sPROXY_TO_PTHREAD` link flag which did all the
tasks necessary to run our `main(int, char**)` on a new web worker.

```
emcmake cmake \
  -G Ninja \
  -S /path/to/vtk/Examples/Emscripten/Cxx/Cone \
  -B out/build \
  -DVTK_DIR=/path/to/where/vtk/wasm/was/built

cmake --build out/build
```

# Serve and test generated code

This example uses wasm in web workers and needs `SharedArrayBuffer`.
For that reason, use the `server.py` from this directory which configures the required
HTTP headers for browsers to allow `SharedArrayBuffer`.

```
cd out/build
python3 ./server.py
```

Open your browser to http://localhost:8000