{"id":20430739,"url":"https://github.com/whitestormjs/physics-module-ammonext","last_synced_at":"2025-04-12T20:33:35.462Z","repository":{"id":53922614,"uuid":"76443850","full_name":"WhitestormJS/physics-module-ammonext","owner":"WhitestormJS","description":"Physics module for Whitestorm.js [Beta]","archived":false,"fork":false,"pushed_at":"2018-06-06T18:56:12.000Z","size":7873,"stargazers_count":38,"open_issues_count":9,"forks_count":13,"subscribers_count":22,"default_branch":"master","last_synced_at":"2024-11-09T10:48:31.618Z","etag":null,"topics":["3d","ammo","physics","physics-module","whitestormjs"],"latest_commit_sha":null,"homepage":"https://whsjs.readme.io/docs","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WhitestormJS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-14T09:17:45.000Z","updated_at":"2024-09-16T04:53:56.000Z","dependencies_parsed_at":"2022-08-13T04:30:30.681Z","dependency_job_id":null,"html_url":"https://github.com/WhitestormJS/physics-module-ammonext","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WhitestormJS%2Fphysics-module-ammonext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WhitestormJS%2Fphysics-module-ammonext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WhitestormJS%2Fphysics-module-ammonext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WhitestormJS%2Fphysics-module-ammonext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WhitestormJS","download_url":"https://codeload.github.com/WhitestormJS/physics-module-ammonext/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224748518,"owners_count":17363312,"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":["3d","ammo","physics","physics-module","whitestormjs"],"created_at":"2024-11-15T08:08:49.661Z","updated_at":"2024-11-15T08:08:51.002Z","avatar_url":"https://github.com/WhitestormJS.png","language":"JavaScript","readme":"# physics-module-ammonext [![NPM Version](https://img.shields.io/npm/v/physics-module-ammonext.svg?style=flat-square)](https://www.npmjs.com/package/physics-module-ammonext)\nPhysics module for Whitestorm.js [Beta]\n\n\u003e Go to [WhitestormJS/whitestorm.js](https://github.com/WhitestormJS/whitestorm.js)\n\n![physics module](http://i.imgur.com/ZdMhDwb.png)\n\n# Modules list\n\n## `new PHYSICS.WorldModule()`\n\n```javascript\nconst app = new WHS.App([\n  // ...\n  new PHYSICS.WorldModule({\n    gravity: new THREE.Vector3(0, -10, 0),\n    ammo: 'path/to/ammo.js'\n  })\n]);\n\napp.start();\n```\n\n## `new PHYSICS.BoxModule()`\n\n```javascript\nconst box = new WHS.Box({\n  geometry: {\n    width: 2,\n    height: 2,\n    depth: 4\n  },\n  \n  modules: [\n    new PHYSICS.BoxModule({\n      mass: 10\n    })\n  ],\n  \n  material: new THREE.MeshBasicMaterial({color: 0xff0000})\n});\n\nbox.addTo(app);\n```\n\n![](http://i.imgur.com/v7hzbeS.png)\n\n## `new PHYSICS.SphereModule()`\n```javascript\nconst sphere = new WHS.Box({\n  geometry: {\n    radius: 3\n  },\n  \n  modules: [\n    new PHYSICS.SphereModule({\n      mass: 10\n    })\n  ],\n  \n  material: new THREE.MeshBasicMaterial({color: 0xff0000})\n});\n\nsphere.addTo(app);\n```\n\n![](http://i.imgur.com/GgqDeuX.png)\n## `new PHYSICS.PlaneModule()`\n```javascript\nconst plane = new WHS.Plane({\n  geometry: {\n    width: 100,\n    height: 100\n  },\n  \n  modules: [\n    new PHYSICS.PlaneModule({\n      mass: 5\n    })\n  ],\n  \n  material: new THREE.MeshBasicMaterial({color: 0xff0000})\n});\n\nplane.addTo(app);\n```\n\n## `new PHYSICS.CapsuleModule()`\nNo example yet.\n\n## `new PHYSICS.ConeModule()`\n```javascript\nconst sphere = new WHS.Cylinder({\n  geometry: {\n    radiusTop: 0,\n    radiusBottom: 3,\n    height: 4\n  },\n  \n  modules: [\n    new PHYSICS.ConeModule({\n      mass: 2\n    })\n  ],\n  \n  material: new THREE.MeshBasicMaterial({color: 0xff0000})\n});\n\nbox.addTo(app);\n```\n## `new PHYSICS.ConvexModule()`\n```javascript\nconst teapot = new WHS.Model({\n  geometry: {\n    path: 'path/to/teapot.json'\n  },\n  \n  modules: [\n    new PHYSICS.ConvexModule({\n      mass: 2,\n      path: 'path/to/simplified/teapot.json'\n    })\n  ],\n  \n  material: new THREE.MeshBasicMaterial({color: 0xff0000})\n});\n\nteapot.addTo(app);\n```\n## `new PHYSICS.CylinderModule()`\n```javascript\nconst sphere = new WHS.Cylinder({\n  geometry: {\n    radiusTop: 3,\n    radiusBottom: 3,\n    height: 4\n  },\n  \n  modules: [\n    new PHYSICS.CylinderModule({\n      mass: 2\n    })\n  ],\n  \n  material: new THREE.MeshBasicMaterial({color: 0xff0000})\n});\n\nbox.addTo(app);\n```\n\n![](http://i.imgur.com/WohSp97.png)\n## `new PHYSICS.HeightfieldModule()`\n```javascript\nconst terrain = new WHS.Parametric({\n  geometry: {\n    func: myFunction\n  },\n  \n  modules: [\n    new PHYSICS.HeightfieldModule({\n      mass: 5,\n      size: new THREE.Vector2(100, 100),\n      autoAlign: true // center physics object automatically.\n    })\n  ],\n  \n  material: new THREE.MeshBasicMaterial({color: 0xff0000})\n});\n\nterrain.addTo(app);\n```\n\n![](http://i.imgur.com/h6Z8IIq.png)\n\n## `new PHYSICS.CompoundModule()`\nThis module should be used only if you want to create a copmound physics object without shape and then add needed objects. `CompoundModule` is selected by default if you add object to another object.\n\n## `new PHYSICS.ConcaveModule()`\n```javascript\nconst teapot = new WHS.Model({\n  geometry: {\n    path: 'path/to/teapot.json'\n  },\n  \n  modules: [\n    new PHYSICS.ConcaveModule({\n      mass: 2,\n      path: 'path/to/simplified/teapot.json'\n    })\n  ],\n  \n  material: new THREE.MeshBasicMaterial({color: 0xff0000})\n});\n\nteapot.addTo(app);\n```\n\n![](http://i.imgur.com/aoJ7fgv.jpg)\n## `new PHYSICS.SoftbodyModule()`\n```javascript\nconst sphere = new WHS.Icosahedron({\n  geometry: {\n    radius: 3,\n    detial: 2\n  },\n  \n  modules: [\n    new PHYSICS.SoftbodyModule({\n      mass: 5,\n      pressure: 500\n    })\n  ],\n  \n  material: new THREE.MeshBasicMaterial({color: 0xff0000})\n});\n\nsphere.addTo(app);\n```\n## `new PHYSICS.ClothModule()`\n\n\u003e Used only with `WHS.Plane`\n\n```javascript\nconst cloth = new WHS.Plane({\n  geometry: {\n    width: 100,\n    height: 50\n  },\n  \n  modules: [\n    new PHYSICS.ClothModule({\n      mass: 5\n    })\n  ],\n  \n  material: new THREE.MeshBasicMaterial({color: 0xff0000})\n});\n\ncloth.addTo(app);\n```\n\n## `new PHYSICS.RopeModule()`\n\n```javascript\nconst rope = new WHS.Line({\n  geometry: {\n    curve: new THREE.LineCurve3(new THREE.Vector3(0, 10, 0), new THREE.Vector3(0, 20, 0))\n  },\n  \n  modules: [\n    new PHYSICS.RopeModule({\n      mass: 5\n    })\n  ],\n  \n  material: new THREE.MeshBasicMaterial({color: 0xff0000})\n});\n\nrope.addTo(app);\n```\n\n# Additional available physics parameters\n## RigidBody\n\n```javascript\n{\n  restitution: 0.3,\n  friction: 0.8,\n  damping: 0,\n  margin: 0\n}\n```\n\n## SoftBody (`SoftModule`, `ClothModule`, `RopeModule`)\n\n```javascript\n{\n  friction: 0.8,\n  damping: 0,\n  margin: 0,\n  klst: 0.9,\n  kvst: 0.9,\n  kast: 0.9,\n  piterations: 1,\n  viterations: 0,\n  diterations: 0,\n  citerations: 4,\n  anchorHardness: 0.7,\n  rigidHardness: 1\n}\n```\n\n# Events\n## `collision`\n[Example](https://github.com/WhitestormJS/physics-module-ammonext/blob/master/src/modules/controls/FirstPersonModule.js#L39)\n\n```javascript\nplayer.on('collision', (otherObject, v, r, contactNormal) =\u003e {\n  if (contactNormal.y \u003c 0.5) // Use a \"good\" threshold value between 0 and 1 here!\n    canJump = true;\n});\n```\n\n## FAQ\n**Q: My `ClothModule` doesn't work properly, what to do?**\n\nA: In 90% cases it is because you have set `pressure` parameter. You shouldn't set it for `ClothModule`.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhitestormjs%2Fphysics-module-ammonext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhitestormjs%2Fphysics-module-ammonext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhitestormjs%2Fphysics-module-ammonext/lists"}