{"id":16647051,"url":"https://github.com/fenomas/voxel-physics-engine","last_synced_at":"2025-03-16T22:31:56.063Z","repository":{"id":26221582,"uuid":"29668132","full_name":"fenomas/voxel-physics-engine","owner":"fenomas","description":"Simple but physical engine for voxels. Demo: ","archived":false,"fork":false,"pushed_at":"2024-03-15T11:10:16.000Z","size":56,"stargazers_count":70,"open_issues_count":0,"forks_count":10,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-10-13T08:43:46.981Z","etag":null,"topics":["physics-engine","voxel"],"latest_commit_sha":null,"homepage":"https://fenomas.github.io/noa-lt/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"OpenGenus/cosmos","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fenomas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-01-22T08:08:25.000Z","updated_at":"2024-08-15T23:48:02.000Z","dependencies_parsed_at":"2024-06-19T00:08:04.222Z","dependency_job_id":"ed408e9d-f68e-4713-be46-c38fc1ce640d","html_url":"https://github.com/fenomas/voxel-physics-engine","commit_stats":{"total_commits":64,"total_committers":2,"mean_commits":32.0,"dds":0.015625,"last_synced_commit":"53685b1219eba404fbf7ad35216f8c593ed0db41"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fenomas%2Fvoxel-physics-engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fenomas%2Fvoxel-physics-engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fenomas%2Fvoxel-physics-engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fenomas%2Fvoxel-physics-engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fenomas","download_url":"https://codeload.github.com/fenomas/voxel-physics-engine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221668854,"owners_count":16860741,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["physics-engine","voxel"],"created_at":"2024-10-12T08:43:43.445Z","updated_at":"2024-10-27T11:29:43.757Z","avatar_url":"https://github.com/fenomas.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# voxel-physics-engine\n\nAbstracted terrain physics for voxel game engines.\n\nThis implements reasonably realistic physics for voxel games. It was made to work with [noa](https://github.com/fenomas/noa) or `voxel.js`, but all it requires is abstracted `(x,y,z) =\u003e boolean` test functions for voxel properties, so it can be used with any engine.\n\nThis library replaces [voxel-physical](https://github.com/chrisdickinson/voxel-physical), though it works quite differently and behaves more physically. The engine can be seen in action in [noa](https://github.com/fenomas/noa) or projects using it.\n\nNote: this simple engine only handles collisions between bodies and solid voxels. It does not handle collisions between rigid bodies, or non-cubic voxels.\n\n\n### Usage:\n 1. Create engine and supply a `(x,y,z) =\u003e boolean` functions that return whether a given voxel is solid or liquid.\n 1. Add rigid bodies with `var body = addBody(..)`\n 1. Modify body properties, or call its methods to apply forces, impulses, etc.\n 1. Call `tick(dt)` on the engine object\n\nand the engine will update each body and handle voxel collisions.\n\n#### Example\n\n``` javascript\nimport { Physics } from 'voxel-physics-engine'\nvar opts = { gravity: [0, -10, 0] }\nvar voxelIsSolid = (x, y, z) =\u003e (y \u003c 0)\nvar voxelIsLiquid = (x, y, z) =\u003e (x \u003e 5)\n\nvar phys = new Physics(opts, voxelIsSolid, voxelIsLiquid)\nvar body = phys.addBody( aabb, mass, friction, restitution, gravityMult, onCollide )\nphys.tick( dt_in_miliseconds )\nphys.removeBody( body )\n```\n\n#### Features\n\n * Reasonably physical, supports standard properties (friction, restitution, etc.)\n * Query the body's `resting[axis]` property (-1,0,1 on each axis) to tell if it's currently touching a solid voxel.\n   E.g. `body.resting[1]` is `1` when the body is colliding with the ceiling.\n * Collisions with terrain trigger each body's `onCollide(impacts)` callback. \n   The argument is a `vec3` of the collision impulse on each axis.\n   (A body resting on the ground will produce a small impact each tick due to gravity.)\n * If you set a body's `autoStep` property, the engine will cause it to \n   automatically \"step\" onto one-block obstructions.\n  \n#### Changes in latest version:\n\n * `0.13.0` - minor fixes to typing and internals\n * `0.11.0` - export a named constructor function instead of a callback\n * `0.10.0`\n   * Fixes `body.onCollide` arg to be a correctly scaled impulse vector\n   * Body `onCollide` now passed before bounces are resolved (allowing client to adjust `body.restitution` depending on the terrain)\n * `0.9.0`\n   * Air and fluid friction properties renamed to `airDrag` and `fluidDrag`, and now work equivalently (no drag at `0`, large drag at `1`)\n   * Per body `airDrag` and `fluidDrag` override global settings if `\u003e= 0`\n * `0.8.0`\n   * Friction now uses regular coefficients, and works in all directions, not just downwards\n   * Bodies have an `.airFriction` that overrides the global value (if nonzero)\n   * Air and regular friction should now scale correctly with frame rate\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffenomas%2Fvoxel-physics-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffenomas%2Fvoxel-physics-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffenomas%2Fvoxel-physics-engine/lists"}