目录
- 说在前面
- 环境搭建
- 编译
- 自定义接口
说在前面
- 操作系统:windows11+wsl2
- physx版本:5.3.1
- 参考:physx-js-webidl (physx版本为该作者fork出的某个版本)
环境搭建
- 这里使用的是
wsl2
+docker
进行编译的,搭建步骤参考:WSL2 上的 Docker 远程容器入门 docker
在wsl2
下的安装使用有两种方式,即上述链接中使用的安装Docker Desktop
以及在wsl2中直接安装docker
的方式- 建议使用安装
Docker Desktop
的方式 - docker compose安装
编译
-
clone仓库
git clone https://github.com/fabmax/physx-js-webidlcd physx-js-webidlgit submodule update --init
-
在wsl2中执行
# Build the image docker compose up# Build Release docker compose run --rm builder ./make.sh
-
正常编译过程如下
docker compose run --rm builder ./make.sh WARN[0000] /mnt/d/physx-js-webidl/docker-compose.yaml: `version` is obsolete rm: cannot remove 'sdk_source_bin/physx-js-webidl.*': No such file or directory [ 3%] Built target PhysXFoundation Consolidate compiler generated dependencies of target LowLevel [ 6%] Built target LowLevel [ 8%] Built target LowLevelAABB [ 13%] Built target LowLevelDynamics [ 13%] Built target PhysXTask Consolidate compiler generated dependencies of target PhysXCommon [ 49%] Built target PhysXCommon [ 50%] Built target SceneQuery Consolidate compiler generated dependencies of target SimulationController [ 61%] Built target SimulationController [ 64%] Built target PhysXPvdSDK Consolidate compiler generated dependencies of target PhysX [ 74%] Built target PhysX [ 76%] Built target PhysXCharacterKinematic [ 76%] Built target PhysXCooking [ 76%] Built target FastXml [ 91%] Built target PhysXExtensions [ 95%] Built target PhysXVehicle [ 99%] Built target PhysXVehicle2 [100%] Built target physx-js-bindings [100%] Building physx-js-webidl webassembly cache:INFO: generating system asset: symbol_lists/f2bd8d746d6715009fc24cdf2c62977da469a12b.json... (this will be cached in "/emsdk/upstream/emscripten/cache/symbol_lists/f2bd8d746d6715009fc24cdf2c62977da469a12b.json" for subsequent builds) cache:INFO: - ok [100%] Built target PhysXWasmBindings
-
问题1:
docker compose
命令不存在
安装docker-compose
。(如果使用的是DockerDesktop
,默认是有该命令的,docker compose) -
问题2:
.sh
编码格式不正确-bash: ./make.sh: /bin/bash^M: bad interpreter: No such file or directory
可以在vscode将其转换成
LF
自定义接口
- 在本文中,添加了一个与
createCollectionFromXml
同级的接口,
首先我们需要实现该接口:
而后在idl文件中添加对应描述,其路径为.\PhysX\physx\source\webidlbindings\src\wasm\PhysXWasm.idl
- 最后重新编译即可,在生成的
physx-js-webidl.js
可以看到新增的接口