A-Frame Physics Extras
Add-on components for the
to add additional collision detection and behavior control options.
A collision detection component powered by the physics simulation with low overhead and precise collision zones. This is intended to be placed on tracked controller entities to monitor collisions and report them to a gesture interpretation component such as super-hands.
|ignoreSleep||Wake sleeping bodies on collision?||
physics-collider can also report collisions with static bodies when
true. This can be useful to create collision detection zones
for interactivity with things other than dynamic bodies.
|collisions||Emitted each tick if there are changes to the collision list||
Control which physics bodies interact with each other or ignore each other.
This can improve physics system performance by skipping unnecessary
collision checks. It also controls which entities can be interacted with
|group||Collision group this entity belongs to||
|collidesWith||Array of collision groups this entity will interact with||
|collisionForces||Should other bodies react to collisions with this body?||
collisionForces controls whether collisions with this body generate any
forces. Setting this to
false allows for collisions to be registered and
tracked without causing any corresponding movement. This is useful for
your controller entities with
physics-collider because it is difficult
to pick things up if they are constantly bumped away when your hand gets close.
This can be toggles through events with a controller button press
if you want to be able to bump other
objects sometimes and reach inside to pick them up other times.
There is an example of this on the examples page.
collisionForces can also be useful
for setting static bodies as collision zones to detect the presence
of other entities without disturbing them.
Make entities settle down and be still after physics collisions. Very useful for zero-gravity user interfaces to keep entities from floating away. Also can help performance as sleeping bodies are handled efficiently by the physics simulation.
|allowSleep||Enable sleep for this body||
|speedLimit||Maximum velocity for sleep to initiate||
|delay||Time interval to check for sleep initiation (seconds)||
|linearDamping||Deceleration of liner forces on the entity (0 to 1)||
|angularDamping||Deceleration of angular forces on the entity (0 to 1)||
|holdState||Entity state in which sleep is suspended||
sleepy to any body will activate sleep for the entire physics system
and will affect other bodies because the cannon defaults for all bodies
are to allow sleep with a speed limit of 0.1 and delay of 1 second. You can
sleepy="allowSleep: false; linearDamping: 0.01; angularDamping: 0.01"
to restore default behavior to an entity if needed.
Sleeping bodies will ignore static bodies
physics-collider has an
ignoreSleep setting) until they
are woken by a dynamic or kinematic body. Sleep will break constraints,
holdState property allows you to suspend sleep during interactions
such as grabbing/carrying the entity.
View the examples page to see
aframe-physics-extras in action.
Install and use by directly including the browser files:
My A-Frame Scene<!-- settings pulled in from controller mixin above --><!-- can be picked up because it collides with the hands group and vice versa --><!-- even though the controller has blue in its collidesWith list,since the blue cube doesn't also have hands in its list, you cannotpick it up, but you can knock it around with the red cube --><!-- floor entity. 'default' collision group so cubes will bounce off -->
Install via npm:
Then require and use.