c-frame / aframe-physics-system

community-maintained fork of n5ro's aframe-physics-system
https://c-frame.github.io/aframe-physics-system/
MIT License
43 stars 11 forks source link

Physics for A-Frame VR

A C-Frame fork, collectively maintained by the A-Frame community. Also see the wiki page.

Latest NPM release GitHub license

Components for A-Frame physics integration.

Supports CANNON.js and Ammo.js. See examples.

Contents

Picking an engine

Which engine you pick will depend a lot on your specific requirements. Currently there are 3 options for A-Frame physics that may be worth considering:

Since each driver has a slightly different component interface and schema, it will require some significant updates to your code to switch from one driver to another, so it's worth taking some time up-front to consider which driver is most likely to suit your needs.

At a high level:

For each of these drivers, there is the potential for specific limitations that could be problematic. These could be limitations

See Driver-specific Limitations below for a list of known driver-specific limitations.

Installation

Installation instructions vary slightly depending on the driver being used, so see detailed documentation for each driver

Basics

The components and schemas for aframe-physics system vary depending on whether you are using the Cannon.js or Ammo.js driver.

See detailed documentation for each driver

Although the syntax for each driver is different, the basic concepts are the same.

For more details, see detailed documentation for each driver

Constraints and APIs

More sophisticated use cases require more than just the configuration of dynamic, static and kinematic bodies.

Both drivers also allow for the configuration of constraints

Constraints such as hinges, springs and so on can be configured between bodies (or between specific points on the surfaces bodies), to provide more sophisticated interactions. See driver-specific documentation for details.

Both drivers also have APIs that offer

Specific details vary between drivers, so you should consult driver-specific documentation for details. Since Cannon.js is written in native Javascript, its API is generally easier to use, and problems are simpler to debug. In comparison, making use of the Ammo.js APIs can be quite hard work (there's definitely scope to improve the available documentation and examples here!)

Driver-specific limitations

This is a list of limitations that has been oberved with particular drivers (and also with physx). It's intended to provide a checklist to help developers to choose between physics drivers for a particular project, so they don't pick a driver that turns out to be missing some feature that is fundamental for their application.

This list is probably incomplete, so if you find an additional significant limitation, please add it to this list.

Cannon.js

Ammo.js

phsyx

Examples

To help demonstrate the features and capabilities of aframe-physics-system a collection of examples have been prepared. Please see examples for a summary and link to each of the prepared examples.