A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(physics): 3D physics on a device, and the example that found it missing
esengine41bb850e14bb
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d7ed1b604..b5f056878 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,6 +16,20 @@ published separately; it ships inside the editor.### Added+- **3D physics on a device.** The Jolt module is compiled into the native host+ the way Box2D already is, so an iOS, Android or desktop build carries the 3D+ world instead of failing to find a side module that has no story there. Its+ entry points are declared once (`Physics3DBindings.hpp`) and both platforms+ bind the same file — until now the SDK's TypeScript interface was the only+ statement of that surface, which is exactly the drift the 2D module documented+ when it grew the same header.++- **A 3D physics example.** `examples/physics-3d`: a character walks, climbs two+ steps, shoves crates and swings a hinged door, drawn by the debug overlay so+ the project ships no art. Every check until now was a synthetic fixture; this+ is the first project that uses the whole chain, and it found the gap above on+ its first run.+- **The running game can draw its own 3D shapes.** `Physics3DDebugDraw` outlinesevery collider the solver built, in the game rather than in the editor — whichis the only place the question "why did the player get stuck there" can bediff --git a/build-tools/tasks/native.js b/build-tools/tasks/native.jsindex d68d23b9d..d2a808820 100644--- a/build-tools/tasks/native.js+++ b/build-tools/tasks/native.js@@ -73,6 +73,7 @@ export const ENGINE_BINDING_HEADERS = [// together under modules/<name>/, so the entry is a path, not a bare filename.export const MODULE_BINDING_HEADERS = ['modules/physics/PhysicsBindings.hpp',+ 'modules/physics3d/Physics3DBindings.hpp','modules/video/VideoBindings.hpp','modules/spine/SpineBindings.hpp','modules/dragonbones/DragonBonesBindings.hpp',diff --git a/examples/physics-3d/assets/scenes/main.esscene b/examples/physics-3d/assets/scenes/main.esscenenew file mode 100644index 000000000..2bd783c38--- /dev/null+++ b/examples/physics-3d/assets/scenes/main.esscene@@ -0,0 +1,415 @@+{+ "version": 1,+ "name": "Main",+ "entities": [+ {+ "id": 0,+ "name": "Camera",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 260,+ "z": 900+ }+ }+ },+ {+ "type": "Camera",+ "data": {+ "projectionType": 0,+ "fov": 55,+ "nearPlane": 10,+ "farPlane": 4000,+ "isActive": true,+ "priority": 0+ }+ }+ ]+ },+ {+ "id": 1,+ "name": "Ground",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": -20,+ "z": 0+ }+ }+ },+ {+ "type": "RigidBody3D",+ "data": {+ "bodyType": 0+ }+ },+ {+ "type": "BoxCollider3D",+ "data": {+ "halfExtents": {+ "x": 700,+ "y": 20,+ "z": 500+ },+ "friction": 0.5+ }+ }+ ]+ },+ {+ "id": 2,+ "name": "Step1",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 300,+ "y": 15,+ "z": 0+ }+ }+ },+ {+ "type": "RigidBody3D",+ "data": {+ "bodyType": 0+ }+ },+ {+ "type": "BoxCollider3D",+ "data": {+ "halfExtents": {+ "x": 120,+ "y": 15,+ "z": 150+ },+ "friction": 0.5+ }+ }+ ]+ },+ {+ "id": 3,+ "name": "Step2",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 520,+ "y": 45,+ "z": 0+ }+ }+ },+ {+ "type": "RigidBody3D",+ "data": {+ "bodyType": 0+ }+ },+ {+ "type": "BoxCollider3D",+ "data": {+ "halfExtents": {+ "x": 120,+ "y": 45,+ "z": 150+ },+ "friction": 0.5+ }+ }+ ]+ },+ {+ "id": 4,+ "name": "Wall",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": -620,+ "y": 100,+ "z": 0+ }+ }+ },+ {+ "type": "RigidBody3D",+ "data": {+ "bodyType": 0+ }+ },+ {+ "type": "BoxCollider3D",+ "data": {+ "halfExtents": {+ "x": 20,+ "y": 100,+ "z": 400+ },+ "friction": 0.5+ }+ }+ ]+ },+ {+ "id": 10,+ "name": "Crate1",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": -260,+ "y": 30,+ "z": -150+ }+ }+ },+ {+ "type": "RigidBody3D",+ "data": {+ "bodyType": 2,+ "linearDamping": 0.2,+ "angularDamping": 0.4+ }+ },+ {+ "type": "BoxCollider3D",+ "data": {+ "halfExtents": {+ "x": 30,+ "y": 30,+ "z": 30+ },+ "friction": 0.2+ }+ }+ ]+ },+ {+ "id": 11,+ "name": "Crate2",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": -160,+ "y": 30,+ "z": -150+ }+ }+ },+ {+ "type": "RigidBody3D",+ "data": {+ "bodyType": 2,+ "linearDamping": 0.2,+ "angularDamping": 0.4+ }+ },+ {+ "type": "BoxCollider3D",+ "data": {+ "halfExtents": {+ "x": 30,+ "y": 30,+ "z": 30+ },+ "friction": 0.2+ }+ }+ ]+ },+ {+ "id": 12,+ "name": "Crate3",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": -60,+ "y": 30,+ "z": -150+ }+ }+ },+ {+ "type": "RigidBody3D",+ "data": {+ "bodyType": 2,+ "linearDamping": 0.2,+ "angularDamping": 0.4+ }+ },+ {+ "type": "BoxCollider3D",+ "data": {+ "halfExtents": {+ "x": 30,+ "y": 30,+ "z": 30+ },+ "friction": 0.2+ }+ }+ ]+ },+ {+ "id": 20,+ "name": "DoorFrame",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": -80,+ "y": 120,+ "z": -320+ }+ }+ },+ {+ "type": "RigidBody3D",+ "data": {+ "bodyType": 0+ }+ },+ {+ "type": "BoxCollider3D",+ "data": {+ "halfExtents": {+ "x": 20,+ "y": 120,+ "z": 20+ },+ "friction": 0.5+ }+ }+ ]+ },+ {+ "id": 21,+ "name": "Door",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 80,+ "y": 120,+ "z": -320+ }+ }+ },+ {+ "type": "RigidBody3D",+ "data": {+ "bodyType": 2,+ "linearDamping": 0.4,+ "angularDamping": 0.6+ }+ },+ {+ "type": "BoxCollider3D",+ "data": {+ "halfExtents": {+ "x": 140,+ "y": 120,+ "z": 12+ },+ "friction": 0.5+ }+ },+ {+ "type": "HingeJoint3D",+ "data": {+ "connectedEntity": 20,+ "anchor": {+ "x": -160,+ "y": 0,+ "z": 0+ },+ "axis": {+ "x": 0,+ "y": 1,+ "z": 0+ },+ "enableLimit": true,+ "lowerAngle": -1.4,+ "upperAngle": 1.4+ }+ }+ ]+ },+ {+ "id": 30,+ "name": "Hero",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 120,+ "z": 250+ }+ }+ },+ {+ "type": "CharacterController3D",+ "data": {+ "radius": 30,+ "halfHeight": 50,+ "stepHeight": 40,+ "snapDown": 50+ }+ }+ ]+ }+ ]+}diff --git a/examples/physics-3d/assets/scenes/main.esscene.meta b/examples/physics-3d/assets/scenes/main.esscene.metanew file mode 100644index 000000000..81782613c--- /dev/null+++ b/examples/physics-3d/assets/scenes/main.esscene.meta@@ -0,0 +1,8 @@+{+ "uuid": "8dd0c1c6-d322-4dad-aaf0-b9d379f22b91",+ "version": "2.0",+ "type": "scene",+ "importer": {+ "autoMigrate": true+ }+}diff --git a/examples/physics-3d/project.esproject b/examples/physics-3d/project.esprojectnew file mode 100644index 000000000..7445d6256--- /dev/null+++ b/examples/physics-3d/project.esproject@@ -0,0 +1,13 @@+{+ "formatVersion": "1",+ "name": "3D Physics",+ "description": "A character walks, climbs, shoves crates and swings a door open \u2014 drawn by the physics debug overlay, so the world needs no art.",+ "tag": "3D",+ "version": "0.1.0",+ "defaultScene": "assets/scenes/main.esscene",+ "designResolution": {+ "width": 960,+ "height": 640+ },+ "spineVersion": "none"+}diff --git a/examples/physics-3d/src/main.ts b/examples/physics-3d/src/main.tsnew file mode 100644index 000000000..59b0463a1--- /dev/null+++ b/examples/physics-3d/src/main.ts@@ -0,0 +1,10 @@+import { addSystemToSchedule, Schedule } from 'esengine';++import { controlSystem, debugToggleSystem, showShapesSystem } from './systems/control';+import { cameraFollowSystem } from './systems/camera';++// The 3D world itself needs no wiring: a scene carrying 3D components gets it.+addSystemToSchedule(Schedule.Startup, showShapesSystem);+addSystemToSchedule(Schedule.Update, controlSystem);+addSystemToSchedule(Schedule.Update, debugToggleSystem);+addSystemToSchedule(Schedule.Update, cameraFollowSystem);diff --git a/examples/physics-3d/src/systems/camera.ts b/examples/physics-3d/src/systems/camera.tsnew file mode 100644index 000000000..9131194dd--- /dev/null+++ b/examples/physics-3d/src/systems/camera.ts@@ -0,0 +1,29 @@+import {+ defineSystem, Query, Mut, Res, Time, Transform, Camera, CharacterController3D,+} from 'esengine';++const OFFSET = { x: 0, y: 300, z: 700 };+/** Fraction of the remaining distance closed per second — a lag the eye reads as+ * weight rather than as the camera being late. */+const CATCH_UP = 4;++export const cameraFollowSystem = defineSystem(+ [Query(Mut(Transform), Camera), Query(Transform, CharacterController3D), Res(Time)],+ (cameras, heroes, time) => {+ let target: { x: number; y: number; z: number } | null = null;+ for (const [, transform] of heroes) {+ target = transform.position;+ break;+ }+ if (!target) return;++ const t = Math.min(1, CATCH_UP * time.delta);+ for (const [, transform] of cameras) {+ const p = transform.position;+ p.x += (target.x + OFFSET.x - p.x) * t;+ p.y += (target.y + OFFSET.y - p.y) * t;+ p.z += (target.z + OFFSET.z - p.z) * t;+ }+ },+ { name: 'CameraFollowSystem' },+);diff --git a/examples/physics-3d/src/systems/control.ts b/examples/physics-3d/src/systems/control.tsnew file mode 100644index 000000000..69551eb4f--- /dev/null+++ b/examples/physics-3d/src/systems/control.ts@@ -0,0 +1,51 @@+import {+ defineSystem, Query, Mut, Res, ResMut, Input,+ CharacterController3D, Physics3DDebugDraw,+} from 'esengine';++const WALK_SPEED = 320;+const JUMP_SPEED = 520;++/**+ * Drive the character from the keyboard.+ *+ * Only the horizontal components are written: the vertical one is carried by the+ * world, so a zero there means "walk", not "hang in the air". A jump is the one+ * time a game writes it.+ */+export const controlSystem = defineSystem(+ [Query(Mut(CharacterController3D)), Res(Input)],+ (query, input) => {+ for (const [, character] of query) {+ let dx = 0;+ let dz = 0;+ if (input.isKeyDown('KeyW') || input.isKeyDown('ArrowUp')) dz -= 1;+ if (input.isKeyDown('KeyS') || input.isKeyDown('ArrowDown')) dz += 1;+ if (input.isKeyDown('KeyA') || input.isKeyDown('ArrowLeft')) dx -= 1;+ if (input.isKeyDown('KeyD') || input.isKeyDown('ArrowRight')) dx += 1;++ const length = Math.hypot(dx, dz);+ character.velocity.x = length > 0 ? (dx / length) * WALK_SPEED : 0;+ character.velocity.z = length > 0 ? (dz / length) * WALK_SPEED : 0;+ character.velocity.y = input.isKeyDown('Space') && character.isOnFloor ? JUMP_SPEED : 0;+ }+ },+ { name: 'ControlSystem' },+);++/** The overlay IS the scenery here: this project ships no meshes, so the shapes+ * the solver built are the whole picture. */+export const showShapesSystem = defineSystem(+ [ResMut(Physics3DDebugDraw)],+ (debug) => { debug.modify((config) => { config.enabled = true; }); },+ { name: 'ShowShapesSystem' },+);++export const debugToggleSystem = defineSystem(+ [Res(Input), ResMut(Physics3DDebugDraw)],+ (input, debug) => {+ if (!input.isKeyPressed('F1')) return;+ debug.modify((config) => { config.enabled = !config.enabled; });+ },+ { name: 'DebugToggleSystem' },+);diff --git a/examples/physics-3d/tsconfig.json b/examples/physics-3d/tsconfig.jsonnew file mode 100644index 000000000..1f11ff310--- /dev/null+++ b/examples/physics-3d/tsconfig.json@@ -0,0 +1,20 @@+{+ "compilerOptions": {+ "target": "ES2020",+ "module": "ESNext",+ "moduleResolution": "bundler",+ "strict": true,+ "esModuleInterop": true,+ "skipLibCheck": true,+ "forceConsistentCasingInFileNames": true,+ "declaration": false,+ "outDir": "./dist",+ "rootDir": ".",+ "paths": {+ "esengine": ["./.esengine/sdk/index.d.ts"],+ "esengine/wasm": ["./.esengine/sdk/wasm.d.ts"]+ }+ },+ "include": ["src/**/*"],+ "exclude": ["node_modules"]+}diff --git a/native/CMakeLists.txt b/native/CMakeLists.txtindex 5d0a8925f..ce138cb71 100644--- a/native/CMakeLists.txt+++ b/native/CMakeLists.txt@@ -132,6 +132,17 @@ set(BOX2D_UNIT_TESTS OFF CACHE BOOL "" FORCE)set(BOX2D_VALIDATE OFF CACHE BOOL "" FORCE) # release: no heavy internal assertionsadd_subdirectory("${TP}/box2d" "${CMAKE_BINARY_DIR}/box2d" EXCLUDE_FROM_ALL)+# Jolt, on the same reasoning as Box2D above: the 3D world is a wasm side module+# on the web and a linked-in library here. Its own sources, globbed — the vendored+# tree carries no CMake of its own (see third_party/CMakeLists.txt, which builds+# it the same way for the web).+file(GLOB_RECURSE JOLT_SOURCES "${TP}/jolt/Jolt/*.cpp")+add_library(jolt STATIC ${JOLT_SOURCES})+target_include_directories(jolt PUBLIC "${TP}/jolt")+target_compile_features(jolt PUBLIC cxx_std_17)+target_compile_definitions(jolt PUBLIC JPH_USE_CPU_COMPUTE)+es_silence_warnings(jolt)+# The Spine runtime: the vendored release plus the module's entry points, compiled# into the host. Every runtime backend exports the same symbol names, so a binary# carries exactly ONE — which is why the web ships a module per version and a native@@ -204,6 +215,13 @@ add_library(estella_physics STATIC ${ESTELLA_PHYSICS_SOURCES})target_include_directories(estella_physics PUBLIC "${SRC}" "${TP}/box2d/include")target_link_libraries(estella_physics PUBLIC box2d)+set(ESTELLA_PHYSICS3D_SOURCES+ "${SRC}/esengine/bindings/modules/physics3d/Physics3DModuleEntry.cpp"+ "${SRC}/esengine/bindings/modules/physics3d/Physics3DConstraints.cpp")+add_library(estella_physics3d STATIC ${ESTELLA_PHYSICS3D_SOURCES})+target_include_directories(estella_physics3d PUBLIC "${SRC}")+target_link_libraries(estella_physics3d PUBLIC jolt)+if(ANDROID)add_library(native_app_glue STATIC"${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c")@@ -326,7 +344,8 @@ if(ESTELLA_QUICKJS_DIR)set_source_files_properties(host/media/native_audio.cpphost/media/audio_spectrum.cpp PROPERTIESCOMPILE_OPTIONS "-x;objective-c++")- target_link_libraries(estella_js_host esengine estella_physics estella_video estella_spine+ target_link_libraries(estella_js_host esengine estella_physics estella_physics3d+ estella_video estella_spineestella_dragonbones qjs"-framework UIKit" "-framework QuartzCore" "-framework Foundation""-framework AVFoundation" "-framework CoreAudio" "-framework AudioToolbox"@@ -337,6 +356,7 @@ if(ESTELLA_QUICKJS_DIR)COMMAND libtool -static -o "${CMAKE_BINARY_DIR}/libestella_ios.a"$<TARGET_FILE:estella_js_host> $<TARGET_FILE:esengine>$<TARGET_FILE:estella_physics> $<TARGET_FILE:box2d>+ $<TARGET_FILE:estella_physics3d> $<TARGET_FILE:jolt>$<TARGET_FILE:estella_video>$<TARGET_FILE:estella_spine> $<TARGET_FILE:spine_runtime>$<TARGET_FILE:estella_dragonbones> $<TARGET_FILE:dragonbones_runtime>@@ -360,8 +380,8 @@ if(ESTELLA_QUICKJS_DIR)${DESKTOP_OS_SOURCES})set_target_properties(estella_js_host PROPERTIES OUTPUT_NAME estella_desktop)target_compile_definitions(estella_js_host PRIVATE ESTELLA_DESKTOP)- target_link_libraries(estella_js_host esengine estella_physics estella_video estella_spine- estella_dragonbones qjs SDL3::SDL3)+ target_link_libraries(estella_js_host esengine estella_physics estella_physics3d+ estella_video estella_spine estella_dragonbones qjs SDL3::SDL3)if(ESTELLA_WINDOWS)# Dawn's D3D12 backend, DirectWrite for the font match, WinHTTP for the# fetch. miniaudio reaches WASAPI through the COM headers it includes.@@ -393,7 +413,8 @@ if(ESTELLA_QUICKJS_DIR)# Android: plain C++; miniaudio dlopens AAudio/OpenSL at runtime (no extra# link libs). native_audio.cpp's Obj-C paths are __APPLE__-guarded out.add_library(estella_js_host SHARED ${HOST_SOURCES} host/platform/android.cpp)- target_link_libraries(estella_js_host esengine estella_physics estella_video estella_spine+ target_link_libraries(estella_js_host esengine estella_physics estella_physics3d+ estella_video estella_spineestella_dragonbones qjs native_app_glue android log)set_target_properties(estella_js_host PROPERTIES LINK_FLAGS "-u ANativeActivity_onCreate")endif()diff --git a/sdk/src/ecs/bridge/nativeSideModules.ts b/sdk/src/ecs/bridge/nativeSideModules.tsindex 960e3759d..915a01033 100644--- a/sdk/src/ecs/bridge/nativeSideModules.ts+++ b/sdk/src/ecs/bridge/nativeSideModules.ts@@ -48,6 +48,7 @@ const SPINE_PROBES = SPINE_VERSIONS.reduce<Partial<Record<SideModuleId, string>>export const NATIVE_SIDE_MODULE_PROBES: Partial<Record<SideModuleId, string>> = {physics: 'es_physics_init',+ physics3d: 'es_physics3d_init',videodec: 'es_video_open',// One entry, not one per version: the DragonBones format is frozen, so unlike// Spine there is no "which runtime did this binary link" question to ask.diff --git a/src/esengine/bindings/modules/physics3d/Physics3DBindings.hpp b/src/esengine/bindings/modules/physics3d/Physics3DBindings.hppnew file mode 100644index 000000000..ac87188f2--- /dev/null+++ b/src/esengine/bindings/modules/physics3d/Physics3DBindings.hpp@@ -0,0 +1,143 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file Physics3DBindings.hpp+ * @brief The Jolt module's entry points, declared once for both platforms.+ * @details The same arrangement the 2D module has: plain `extern "C"` over one+ * world, linked into a wasm side module on the web and compiled into the+ * host binary on a device, where there is no dynamic-linking story to+ * have. Until this file existed the SDK's `Physics3DWasmModule` interface+ * was the only statement of the surface and could drift from the C+++ * silently — and a native host had no way to bind it at all.+ *+ * Bulk data crosses as an offset into the caller's heap, so the readback+ * getters carry `@heapreturn`: they hand back memory the MODULE owns, and+ * a native wrapper copies exactly that many bytes into the heap the SDK+ * reads. The byte counts come from the module, never from a stride+ * guessed on the far side.+ *+ * @author ESEngine Team+ * @date 2026+ *+ * @copyright Copyright (c) 2026 ESEngine Team+ * Licensed under the Apache License, Version 2.0.+ */+#pragma once++#include <cstddef>+#include <cstdint>++extern "C" {++// World lifecycle+void physics3d_init(float gx, float gy, float gz, uint32_t maxBodies);+void physics3d_shutdown();+int physics3d_isReady();+void physics3d_step(float dt, int collisionSteps);+void physics3d_optimize();+void physics3d_setLayerMask(uint32_t layer, uint32_t mask);++// Bodies+uint32_t physics3d_addBox(uint32_t entity, float hx, float hy, float hz,+ float px, float py, float pz,+ float qx, float qy, float qz, float qw,+ int motion, float gravityScale, float linearDamping,+ float angularDamping, int fixedRotation, uint32_t layer,+ int continuous, float friction, float restitution, int isSensor);+uint32_t physics3d_addSphere(uint32_t entity, float radius,+ float px, float py, float pz,+ float qx, float qy, float qz, float qw,+ int motion, float gravityScale, float linearDamping,+ float angularDamping, int fixedRotation, uint32_t layer,+ int continuous, float friction, float restitution, int isSensor);+uint32_t physics3d_addCapsule(uint32_t entity, float radius, float halfHeight,+ float px, float py, float pz,+ float qx, float qy, float qz, float qw,+ int motion, float gravityScale, float linearDamping,+ float angularDamping, int fixedRotation, uint32_t layer,+ int continuous, float friction, float restitution, int isSensor);+uint32_t physics3d_addMeshBody(uint32_t entity, uintptr_t vertexPtr, uint32_t vertexCount,+ uintptr_t indexPtr, uint32_t indexCount,+ float px, float py, float pz,+ float qx, float qy, float qz, float qw,+ uint32_t layer, float friction, float restitution);+uint32_t physics3d_addConvexBody(uint32_t entity, uintptr_t vertexPtr, uint32_t vertexCount,+ float px, float py, float pz,+ float qx, float qy, float qz, float qw,+ int motion, float gravityScale, float linearDamping,+ float angularDamping, int fixedRotation, uint32_t layer,+ int continuous, float friction, float restitution, int isSensor);+void physics3d_removeBody(uint32_t bodyId);+void physics3d_setTransform(uint32_t bodyId, float px, float py, float pz,+ float qx, float qy, float qz, float qw);+void physics3d_setLinearVelocity(uint32_t bodyId, float vx, float vy, float vz);+int physics3d_getBodyState(uint32_t bodyId);++// Characters — swept rather than solved, and not bodies.+uint32_t physics3d_addCharacter(uint32_t entity, float radius, float halfHeight,+ float px, float py, float pz, float maxSlope, float mass,+ uint32_t layer, float pushForce);+void physics3d_removeCharacter(uint32_t characterId);+void physics3d_moveCharacter(uint32_t characterId, float vx, float vy, float vz,+ float dt, float stepUp, float stepDown);+void physics3d_setCharacterPosition(uint32_t characterId, float px, float py, float pz);++// Joints+uint32_t physics3d_addPointJoint(uint32_t entity, uint32_t bodyA, uint32_t bodyB,+ float px, float py, float pz, int collideConnected);+uint32_t physics3d_addHingeJoint(uint32_t entity, uint32_t bodyA, uint32_t bodyB,+ float px, float py, float pz,+ float ax, float ay, float az,+ int enableLimit, float lowerAngle, float upperAngle,+ int enableMotor, float motorSpeed, float maxTorque,+ int collideConnected);+uint32_t physics3d_addSliderJoint(uint32_t entity, uint32_t bodyA, uint32_t bodyB,+ float px, float py, float pz,+ float ax, float ay, float az,+ int enableLimit, float lower, float upper,+ int enableMotor, float motorSpeed, float maxForce,+ int collideConnected);+uint32_t physics3d_addDistanceJoint(uint32_t entity, uint32_t bodyA, uint32_t bodyB,+ float ax, float ay, float az,+ float bx, float by, float bz,+ float minLength, float maxLength,+ float frequency, float damping, int collideConnected);+uint32_t physics3d_addFixedJoint(uint32_t entity, uint32_t bodyA, uint32_t bodyB,+ int collideConnected);+void physics3d_removeJoint(uint32_t entity, uint32_t bodyA, uint32_t bodyB);+void physics3d_setJointMotor(uint32_t entity, int enable, float speed);+float physics3d_jointValue(uint32_t entity);++// Queries. Each answers a hit count and leaves the hits in the query buffer.+int physics3d_raycast(float ox, float oy, float oz, float dx, float dy, float dz,+ uint32_t layerMask);+int physics3d_sphereCast(float px, float py, float pz, float radius,+ float dx, float dy, float dz, uint32_t layerMask);+int physics3d_overlapSphere(float px, float py, float pz, float radius, uint32_t layerMask);+int physics3d_overlapBox(float px, float py, float pz, float hx, float hy, float hz,+ uint32_t layerMask);++// Readback. A pointer crosses as an integer, the same way the 2D module's+// getters do: the caller reads `*Bytes()` from the module and copies exactly+// that much out of the heap it names.++// @heapreturn physics3d_transformsBytes()+uintptr_t physics3d_transforms();+size_t physics3d_transformsBytes();+// @heapreturn physics3d_contactEntersBytes()+uintptr_t physics3d_contactEnters();+size_t physics3d_contactEntersBytes();+// @heapreturn physics3d_contactExitsBytes()+uintptr_t physics3d_contactExits();+size_t physics3d_contactExitsBytes();+// @heapreturn physics3d_sensorEntersBytes()+uintptr_t physics3d_sensorEnters();+size_t physics3d_sensorEntersBytes();+// @heapreturn physics3d_sensorExitsBytes()+uintptr_t physics3d_sensorExits();+size_t physics3d_sensorExitsBytes();+// @heapreturn physics3d_queryResultBytes()+uintptr_t physics3d_queryResult();+size_t physics3d_queryResultBytes();++} // extern "C"diff --git a/src/esengine/bindings/modules/physics3d/Physics3DModuleEntry.cpp b/src/esengine/bindings/modules/physics3d/Physics3DModuleEntry.cppindex c873ef635..b4eb19bdc 100644--- a/src/esengine/bindings/modules/physics3d/Physics3DModuleEntry.cpp+++ b/src/esengine/bindings/modules/physics3d/Physics3DModuleEntry.cpp@@ -687,7 +687,9 @@ int physics3d_raycast(float ox, float oy, float oz, float dx, float dy, float dz// ReadbackEMSCRIPTEN_KEEPALIVE-const float* physics3d_transforms() { return g().transformBuffer.data(); }+uintptr_t physics3d_transforms() {+ return reinterpret_cast<uintptr_t>(g().transformBuffer.data());+}EMSCRIPTEN_KEEPALIVEsize_t physics3d_transformsBytes() {@@ -695,7 +697,9 @@ size_t physics3d_transformsBytes() {}EMSCRIPTEN_KEEPALIVE-const float* physics3d_contactEnters() { return g().contactEnterBuffer.data(); }+uintptr_t physics3d_contactEnters() {+ return reinterpret_cast<uintptr_t>(g().contactEnterBuffer.data());+}EMSCRIPTEN_KEEPALIVEsize_t physics3d_contactEntersBytes() {@@ -703,7 +707,9 @@ size_t physics3d_contactEntersBytes() {}EMSCRIPTEN_KEEPALIVE-const float* physics3d_contactExits() { return g().contactExitBuffer.data(); }+uintptr_t physics3d_contactExits() {+ return reinterpret_cast<uintptr_t>(g().contactExitBuffer.data());+}EMSCRIPTEN_KEEPALIVEsize_t physics3d_contactExitsBytes() {@@ -711,7 +717,9 @@ size_t physics3d_contactExitsBytes() {}EMSCRIPTEN_KEEPALIVE-const float* physics3d_sensorEnters() { return g().sensorEnterBuffer.data(); }+uintptr_t physics3d_sensorEnters() {+ return reinterpret_cast<uintptr_t>(g().sensorEnterBuffer.data());+}EMSCRIPTEN_KEEPALIVEsize_t physics3d_sensorEntersBytes() {@@ -719,7 +727,9 @@ size_t physics3d_sensorEntersBytes() {}EMSCRIPTEN_KEEPALIVE-const float* physics3d_sensorExits() { return g().sensorExitBuffer.data(); }+uintptr_t physics3d_sensorExits() {+ return reinterpret_cast<uintptr_t>(g().sensorExitBuffer.data());+}EMSCRIPTEN_KEEPALIVEsize_t physics3d_sensorExitsBytes() {@@ -727,7 +737,9 @@ size_t physics3d_sensorExitsBytes() {}EMSCRIPTEN_KEEPALIVE-const float* physics3d_queryResult() { return g().queryBuffer.data(); }+uintptr_t physics3d_queryResult() {+ return reinterpret_cast<uintptr_t>(g().queryBuffer.data());+}EMSCRIPTEN_KEEPALIVEsize_t physics3d_queryResultBytes() {