Famo.us comes packaged with a fully integrated physics engine that you can use to add excitement and dynamism to your application.
In this section, we’ll look at how to use Famo.us’ physics modules to bring your application to life. If you’re new to physics, don’t worry; we’ll cover the basics so you can use Famo.us physics even if you have no prior experience with the math.
What do we mean by physics? And how does Famo.us use it, exactly? By physics, we just mean what happens to real-world objects when forces (such as gravity) act on them. What happens to a heavy weight when dropped to the ground? How would the end result differ if we instead dropped a basketball?
Famo.us has a PhysicsEngine
module that can mathematically represent these relationships, and then convert the math into animations. You, the developer, describe what physical properties your elements should have, and the PhysicsEngine
will figures out the rest: how to animate it when a particular force (or set of forces) is applied.
Many Famo.us components use the physics engine internally. For example, the SpringTransition
module actually calls the physics engine to compute the math behind the springy animation effect it provides. In these sections, we’ll show you how to use the physics engine directly in your own application.
Particles and forces are the main components we’ll use when creating physics-based animations. By applying forces to particles, then attaching renderables to those particles, the renderables will appear to animate like physical, real-world objects. Learn about particles and forces »
Bodies are like particles, but with a few extra properties that give them a size and a defined shape to work with. Constraints, meanwhile, are like the flipside of forces: they put limitations on the actions of particles and bodies. Learn about bodies and constraints »
What happens when two bodies run into one another? Do they pass through each other like ghosts? Or do they bounce back like billiard balls? The result we want to get can be controlled using collisions, a special type of constraint included in Famo.us. Learn about collisions »
Lower-level components called vectors and fields give us even finer-grained control over physical interaction. Warning! This section gets a little math-heavy. Learn about vectors and fields »
Torque is a rotational force that can be applied to a body, allowing it to spin. In combination with orientation, we can add effects that occur when bodies are oriented in specific directions. This section also covers some math-heavy topics like quaternions. Learn about torque & orientation »
First stop: Particles & forces »
Copyright © 2013-2015 Famous Industries, Inc.