aframe-physics-components
Experimental physics components for A-Frame VR using cannon.js.
Usage
Browser Installation
Install and use by directly including the browser files:
My A-Frame Scene
NPM Installation
Install via NPM:
npm install aframe-physics-component
Then register and use.
;;
API
physics-body Component
Property | Description | Type | Default Value |
---|---|---|---|
angularVelocity | (in deg/s) | vec3 | 0 0 0 |
boundingBox | Collision box (in m). | vec3 | 0 0 0 |
mass | (in kg) | number | 1 |
velocity | (in m/s) | vec3 | 0 0 0 |
Event Name | Description |
---|---|
collide | Emitted when entity collides with another entity. Event contains contact . |
applyImpulse (impulseVec3, positionVec3)
Applies an impulse (indicated by impulseVec3
) at the body's local point
(indicated by positionVec3
). forceVec3
is in Force / Time (Newtons /
Seconds).
// Applies a small force from left-to-right to the top-left of the body.var hitMeBody = documentcomponents'physics-body';hitMeBody;
physics-world Component
Property | Description | Default Value |
---|---|---|
gravity | vec3 | 0 -9.8 0 |
Event Name | Description |
---|---|
beginContact | Emitted when an entity in the world begins contact with another entity. Event contains bodyA and bodyB . |
endContact | Emitted when an entity in the world ends contact with another entity. Event contains bodyA and bodyB . |