跳转到主要内容

使用WASM的VTK本地渲染

项目描述

VTK本地渲染使用VTK/WASM与服务器端渲染管道在客户端匹配。当前的代码库仍处于起步阶段,但我们希望使其成为使用trame的VTK/ParaView本地渲染的默认实现。

许可证

这个库是开源的,遵循Apache软件许可证

安装

pip install trame-vtklocal

# We need a VTK that has its wasm counterpart
# This is the first version available with it
# For ParaView (not yet supported), VTK don't need to be installed
pip install "vtk==9.3.20240921.dev0" --extra-index-url https://wheels.vtk.org

开发

构建并安装Vue组件

cd vue-components
npm i
npm run build
cd -

安装库

pip install -e .

可选,您可以通过以下步骤使用 bleeding edge VTK进行开发。请确保您有这些工具 1. git 2. CMake 3. Ninja 4. Python 5. NodeJS >= 22.0.0: https://node.org.cn/en/download/package-manager 6. Emscripten SDK:请参阅 https://emscripten.webassembly.net.cn/docs/getting_started/downloads.html#download-and-install

# Compile VTK for wasm32 architecture using emscripten. Build artifacts can be found in dev/vtk/build/wasm
./utils/build_vtk.sh -u https://gitlab.kitware.com/vtk/vtk.git -b master -t wasm32 -p RelWithDebInfo

# Compile VTK with python wrappings using system C++ compiler. Build artifacts can be found in dev/vtk/build/py
./utils/build_vtk.sh -u https://gitlab.kitware.com/vtk/vtk.git -b master -t py -p RelWithDebInfo

# Set environment variables
source ./utils/dev_environment.sh -b master -p RelWithDebInfo

运行示例

pip install trame trame-vtklocal trame-vuetify trame-vtk

# We need a VTK that has its wasm counterpart
# This is the first version available with it
# For ParaView (not yet supported), VTK don't need to be installed
pip install "vtk==9.3.20240810.dev0" --extra-index-url https://wheels.vtk.org

# regular trame app
python ./examples/vtk/cone.py

某些示例旨在测试和验证WASM渲染。某些示例默认为远程渲染,但如果您想强制使用WASM,请在执行它们之前运行 export USE_WASM=1

SharedArrayBuffer

要在trame中启用SharedArrayBuffer,您只需在服务器上设置以下内容

server.http_headers.shared_array_buffer = True

这将下载线程化的WASM版本。否则,将使用非线程化版本,因为它不需要SharedArrayBuffer。

项目详情


下载文件

下载适用于您的平台文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

trame-vtklocal-0.6.0.tar.gz (13.2 kB 查看哈希值)

上传时间 源代码

构建分发

trame_vtklocal-0.6.0-py3-none-any.whl (14.4 kB 查看哈希值)

上传时间 Python 3

支持者