{"_id":"@dandre3000/rapier3d-sandbox","name":"@dandre3000/rapier3d-sandbox","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@dandre3000/rapier3d-sandbox","version":"0.1.0","license":"MIT","author":{"name":"DeAundre Payne","email":"apps.fondling796@passinbox.com","url":"https://github.com/dandre3000"},"repository":{"type":"git","url":"git+https://github.com/dandre3000/rapier3d-sandbox.git"},"description":"Rapier3D physics in a worker sandbox.","keywords":["rapier3d","physics","worker","sandbox","thread"],"exports":{"types":"./build/index.d.ts","import":"./build/index.js"},"dependencies":{"@dandre3000/sandbox":"^0.2.0","@dimforge/rapier3d-compat":"^0.19.3"},"devDependencies":{"typescript":"^6.0.3"},"scripts":{"types":"tsc --project tsconfig.build.json","transpile-index":"bun build ./src/index.ts --external @dandre3000/sandbox --outdir ./build --minify-whitespace --minify-syntax","transpile-worker":"bun build ./src/worker.ts --external @dandre3000/sandbox --external @dimforge/rapier3d-compat --outdir ./build --minify-whitespace --minify-syntax","build":"bun run types && bun run transpile-index && bun run transpile-worker && bun post-transpile.js","prepack":"bun run build"},"type":"module","_id":"@dandre3000/rapier3d-sandbox@0.1.0","gitHead":"59b0d1ad930215e12904caa159d8d7122e938816","bugs":{"url":"https://github.com/dandre3000/rapier3d-sandbox/issues"},"homepage":"https://github.com/dandre3000/rapier3d-sandbox#readme","_nodeVersion":"23.5.0","_npmVersion":"11.0.0","dist":{"integrity":"sha512-A+4FsQnMnW+9wyibMjllH6iJ+sqRStOjn4XQuPs79w+THOIvbKtVhK0MJlUsBuY4oLpeolMjZnFgpIHqi80Ltw==","shasum":"c41e8d3909090270c64a388870ffb68142c2eb13","tarball":"https://registry.npmjs.org/@dandre3000/rapier3d-sandbox/-/rapier3d-sandbox-0.1.0.tgz","fileCount":6,"unpackedSize":5627,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDj/kTw1thocjtXbbGNHaQyU46NkoNasew3WEWjFsQ4GAiAF1Y6vJTpb6paVPpxneq4eX9y00aZccXHdOKZ41vo5rA=="}]},"_npmUser":{"name":"dandre3000","email":"apps.fondling796@passinbox.com"},"directories":{},"maintainers":[{"name":"dandre3000","email":"apps.fondling796@passinbox.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/rapier3d-sandbox_0.1.0_1780191583649_0.6000078787930396"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-31T01:39:43.502Z","0.1.0":"2026-05-31T01:39:43.785Z","modified":"2026-05-31T01:39:43.989Z"},"maintainers":[{"name":"dandre3000","email":"apps.fondling796@passinbox.com"}],"description":"Rapier3D physics in a worker sandbox.","homepage":"https://github.com/dandre3000/rapier3d-sandbox#readme","keywords":["rapier3d","physics","worker","sandbox","thread"],"repository":{"type":"git","url":"git+https://github.com/dandre3000/rapier3d-sandbox.git"},"author":{"name":"DeAundre Payne","email":"apps.fondling796@passinbox.com","url":"https://github.com/dandre3000"},"bugs":{"url":"https://github.com/dandre3000/rapier3d-sandbox/issues"},"license":"MIT","readme":"# @dandre3000/rapier3d-sandbox\n\nRapier3D physics in a worker sandbox.\n\n## Install\n\nnpm i @dandre3000/rapier3d-sandbox\n\n## Usage\n\n```js\nimport { Rapier3DSandbox } from '@dandre3000/rapier3d-sandbox'\n\nconst sandbox = new Rapier3DSandbox\n\nconst physics = async () => {\n    /** @type {import(\"@dandre3000/rapier3d-sandbox\").Rapier3DSandboxContext} */\n    const { rapier } = globalThis\n\n    await rapier.init()\n\n    let gravity = { x: 0.0, y: -9.81, z: 0.0 }\n    let world = new rapier.World(gravity)\n\n    // Create the ground\n    let groundColliderDesc = rapier.ColliderDesc.cuboid(10.0, 0.1, 10.0)\n    world.createCollider(groundColliderDesc)\n\n    // Create a dynamic rigid-body.\n    let rigidBodyDesc = rapier.RigidBodyDesc.dynamic()\n        .setTranslation(0.0, 1.0, 0.0)\n    let rigidBody = world.createRigidBody(rigidBodyDesc)\n\n    // Create a cuboid collider attached to the dynamic rigidBody.\n    let colliderDesc = rapier.ColliderDesc.cuboid(0.5, 0.5, 0.5)\n    let collider = world.createCollider(colliderDesc, rigidBody)\n\n    globalThis.rigidBody = rigidBody\n    globalThis.world = world\n}\n\nconst step = () => {\n    // Step the simulation forward.  \n    world.step()\n\n    // Get and print the rigid-body's position.\n    let position = rigidBody.translation()\n    console.log(\"Rigid-body position: \", position.x, position.y)\n}\n\nsandbox.setRemoteFunction('physics', physics)\nsandbox.setRemoteFunction('step', step)\nawait sandbox.callRemoteFunction('physics')\n\nsetInterval(() => {\n    sandbox.callRemoteFunction('step')\n}, 16)\n```\n## Exports\n\n<h4>type Rapier3DSandboxContext = import('@dandre3000/sandbox').RestrictedGlobalProxy & {\n    </br>&emsp;global: Rapier3DSandboxContext\n    </br>&emsp;globalThis: Rapier3DSandboxContext\n    </br>&emsp;rapier: typeof import('@dimforge/rapier3d-compat')\n</br>}</h4>\n\n### Class Rapier3DSandbox\n\n#### setLocalFunction (id: string, fn: Function | null): void\nCreate sandboxed function on the main thread or remove it if fn is null.\n\n#### setRemoteFunction (id: string, fn: Function | null): Promise&lt;void&gt;\nCreate a sandboxed function on the physics thread or remove it if fn is null.\n\n#### callRemoteFunction (id: string): Promise&lt;void&gt;\nCall a sandboxed function on the physics thread.\n\n## License\n\n[MIT](https://github.com/dandre3000/rapier3d-sandbox/blob/main/LICENSE)","readmeFilename":"README.md","_rev":"1-b4d841b5a027bf6b4409de80a0c3d109"}