Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ jobs:
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
# No actions-cache-folder: that would put emsdk inside the workspace, and
# emcc --emit-tsd runs tsc from the emsdk directory, where TypeScript 6
# refuses (TS5112) once it finds a tsconfig.json in a parent directory.
- uses: mymindstorm/setup-emsdk@v16
with:
version: 4.0.18
actions-cache-folder: emsdk-cache
version: 6.0.2
# also fetches the pinned Box3D source: the @erincatto/box3d git dependency
- run: pnpm install --frozen-lockfile
- name: Fetch pinned Box3D source
run: pnpm fetch-deps
- run: pnpm build
- run: pnpm test
- uses: actions/upload-artifact@v7
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Dependency directories
node_modules/
deps/

# Build output
build/
Expand Down
425 changes: 334 additions & 91 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions csrc/glue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -928,12 +928,12 @@ struct Body

val getLocalCenterOfMass() const
{
return fromVec3( b3Body_GetLocalCenterOfMass( id ) );
return fromVec3( b3Body_GetLocalCenter( id ) );
}

val getWorldCenterOfMass() const
{
return fromVec3( b3Body_GetWorldCenterOfMass( id ) );
return fromVec3( b3Body_GetWorldCenter( id ) );
}

val getLocalPoint( val worldPoint ) const
Expand Down
39 changes: 28 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
{
"name": "box3d-wasm",
"name": "@frsource/box3d-wasm",
"version": "0.2.0",
"description": "Box3D, Erin Catto's 3D physics engine, compiled to WebAssembly with SIMD and optional wasm threads. Isomorphic: works in browsers and Node.js, auto-detecting thread support.",
"type": "module",
"main": "dist/entry.mjs",
"exports": {
".": "./dist/entry.mjs",
"./standard": "./dist/box3d.mjs",
"./deluxe": "./dist/box3d.deluxe.mjs",
"./package.json": "./package.json",
"./iso": "./dist/iso.mjs"
".": {
"types": "./dist/entry.d.ts",
"default": "./dist/entry.mjs"
},
"./standard": {
"types": "./dist/box3d.d.ts",
"default": "./dist/box3d.mjs"
},
"./deluxe": {
"types": "./dist/box3d.deluxe.d.ts",
"default": "./dist/box3d.deluxe.mjs"
},
"./iso": "./dist/iso.mjs",
"./package.json": "./package.json"
},
"files": [
"dist",
Expand All @@ -21,11 +30,11 @@
"node": ">=22"
},
"scripts": {
"fetch-deps": "bash scripts/fetch-deps.sh",
"build": "bash scripts/build.sh",
"build:debug": "TARGET_TYPE=Debug bash scripts/build.sh",
"test": "node --test \"test/*.test.mjs\"",
"prepublishOnly": "pnpm test",
"prepack": "pnpm build",
"lint": "eslint . && prettier . --check && pnpm lint:native",
"lint:native": "clang-format --dry-run --Werror csrc/*.cpp",
"fix": "eslint . --fix && prettier . --write && clang-format -i csrc/*.cpp",
Expand All @@ -50,13 +59,17 @@
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/monteslu/box3d-wasm.git"
"url": "git+https://github.com/FRSOURCE/box3d-wasm.git"
},
"bugs": {
"url": "https://github.com/monteslu/box3d-wasm/issues"
"url": "https://github.com/FRSOURCE/box3d-wasm/issues"
},
"homepage": "https://github.com/FRSOURCE/box3d-wasm#readme",
"publishConfig": {
"access": "public"
},
"homepage": "https://github.com/monteslu/box3d-wasm#readme",
"devDependencies": {
"@erincatto/box3d": "github:erincatto/box3d#e77352cd606dc1a34209094076199549a52ea0a1",
"@frsource/eslint-config": "1.86.0",
"@frsource/prettier-config": "1.48.0",
"@frsource/semantic-release-config": "1.117.1",
Expand All @@ -67,5 +80,9 @@
"semantic-release": "25.0.9",
"typescript": "6.0.3"
},
"packageManager": "pnpm@12.5.1"
"packageManager": "pnpm@12.5.1",
"contributors": [
"Jakub Freisler <jakub.freisler@frsource.org> (https://www.frsource.org/)"
],
"types": "dist/entry.d.ts"
}
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion renovate.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["github>FRSOURCE/renovate-config"]
"extends": ["github>FRSOURCE/renovate-config"],
"packageRules": [
{
"matchDepNames": ["erincatto/box3d"],
"semanticCommitType": "feat",
"semanticCommitScope": "engine",
"automerge": true,
"schedule": ["at any time"]
}
]
}
13 changes: 9 additions & 4 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ ROOT="$(dirname "$DIR")"

FLAVOURS="${FLAVOURS:-standard deluxe}"
TARGET_TYPE="${TARGET_TYPE:-Release}"
BOX3D_SRC="$ROOT/deps/box3d"
# Box3D is a git dependency in package.json (github:erincatto/box3d#<sha>), so
# pnpm puts its source tree here. Renovate bumps the pinned commit.
BOX3D_SRC="$ROOT/node_modules/@erincatto/box3d"

if [ ! -f "$BOX3D_SRC/CMakeLists.txt" ]; then
echo "deps/box3d missing. Run: npm run fetch-deps" >&2
echo "node_modules/@erincatto/box3d missing. Run: pnpm install" >&2
exit 1
fi

Expand Down Expand Up @@ -62,7 +64,7 @@ for FLAVOUR in $FLAVOURS; do
> "$CMAKE_BUILD_DIR.cmake.log" 2>&1 || { cat "$CMAKE_BUILD_DIR.cmake.log" >&2; exit 1; }

echo "==> build libbox3d.a ($FLAVOUR)"
cmake --build "$CMAKE_BUILD_DIR" -j"$(nproc)" > "$CMAKE_BUILD_DIR.build.log" 2>&1 \
cmake --build "$CMAKE_BUILD_DIR" -j"$(nproc 2>/dev/null || sysctl -n hw.ncpu)" > "$CMAKE_BUILD_DIR.build.log" 2>&1 \
|| { tail -50 "$CMAKE_BUILD_DIR.build.log" >&2; exit 1; }

LIB="$CMAKE_BUILD_DIR/src/libbox3d.a"
Expand Down Expand Up @@ -100,14 +102,17 @@ for FLAVOUR in $FLAVOURS; do
esac

echo "==> emcc link ($FLAVOUR) -> dist/$BASENAME.mjs"
# --emit-tsd derives dist/$BASENAME.d.ts from the embind registrations, so
# the published types can never drift from the compiled binding.
emcc "$ROOT/csrc/glue.cpp" "$ROOT/csrc/flat.cpp" "$LIB" \
-I "$BOX3D_SRC/include" \
"${EMCC_OPTS[@]}" \
"${FLAVOUR_FLAGS[@]:-}" \
--emit-tsd "$BASENAME.d.ts" \
-o "$ROOT/dist/$BASENAME.mjs"
done

cp "$ROOT/src/entry.mjs" "$ROOT/dist/entry.mjs"
cp "$ROOT/src/entry.mjs" "$ROOT/src/entry.d.ts" "$ROOT/dist/"

# The isomorphic surface: the shared TS frontend (type-STRIPPED, not
# transformed -- the same file must compile under a native host's static
Expand Down
24 changes: 0 additions & 24 deletions scripts/fetch-deps.sh

This file was deleted.

6 changes: 0 additions & 6 deletions scripts/versions.json

This file was deleted.

6 changes: 6 additions & 0 deletions src/entry.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// The auto-detecting entry resolves to either flavour at runtime; both expose
// the same embind surface, so the standard build's generated types describe it.
import type { MainModule } from './box3d';

export type * from './box3d';
export default function Box3D(options?: unknown): Promise<MainModule>;
Loading