New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

aframe-physics-components

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aframe-physics-components

Physics components for A-Frame VR.

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

aframe-physics-components

Experimental physics components for A-Frame VR using cannon.js.

physics2

Usage

Browser Installation

Install and use by directly including the browser files:

<head>
  <title>My A-Frame Scene</title>
  <script src="https://aframe.io/releases/0.2.0/aframe.min.js"></script>
  <script src="https://github.com/ngokevin/aframe-physics-components/blob/master/dist/aframe-physics-components.min.js"></script>
</head>

<body>
  <a-scene physics-world="gravity: 0 -9.8 0">
    <a-entity physics-body="boundingBox: 1 1 1; mass: 5; velocity: 0.2 0 0"
              geometry="primitive: box" material="color: red"></a-entity>
  </a-scene>
</body>

NPM Installation

Install via NPM:

npm install aframe-physics-component

Then register and use.

require('aframe');
require('aframe-physics-components');

API

physics-body Component

PropertyDescriptionTypeDefault Value
angularVelocity(in deg/s)vec30 0 0
boundingBoxCollision box (in m).vec30 0 0
mass(in kg)number1
velocity(in m/s)vec30 0 0
Event NameDescription
collideEmitted 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 = document.querySelector('#hit-me-entity').components['physics-body'];
hitMeBody.applyImpulse({ x: 10, y: 0, z: 0 }, { x: -1, y: 1, z: 0 });

physics-world Component

PropertyDescriptionDefault Value
gravityvec30 -9.8 0
Event NameDescription
beginContactEmitted when an entity in the world begins contact with another entity. Event contains bodyA and bodyB.
endContactEmitted when an entity in the world ends contact with another entity. Event contains bodyA and bodyB.

Keywords

aframe

FAQs

Package last updated on 26 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts