φ Famo.us University Famo.us/Angular Docs Help Blog Download
  • core
  • Context
  • ElementAllocator
  • ElementOutput
  • Engine
  • Entity
  • EventEmitter
  • EventHandler
  • Group
  • Modifier
  • OptionsManager
  • RenderNode
  • Scene
  • SpecParser
  • Transform
  • View
  • ViewSequence
  • events
  • EventArbiter
  • EventFilter
  • EventMapper
  • inputs
  • Accumulator
  • GenericSync
  • MouseSync
  • PinchSync
  • RotateSync
  • ScaleSync
  • ScrollSync
  • TouchSync
  • TouchTracker
  • TwoFingerSync
  • math
  • Matrix
  • Quaternion
  • Random
  • Utilities
  • Vector
  • modifiers
  • Draggable
  • Fader
  • ModifierChain
  • StateModifier
  • physics
  • PhysicsEngine
  • physics/bodies
  • Body
  • Circle
  • Particle
  • Rectangle
  • physics/constraints
  • Surface
  • Collision
  • Constraint
  • Curve
  • Distance
  • Snap
  • Wall
  • Walls
  • physics/forces
  • Drag
  • Force
  • Repulsion
  • RotationalDrag
  • RotationalSpring
  • Spring
  • VectorField
  • physics/integrators
  • SymplecticEuler
  • surfaces
  • CanvasSurface
  • ContainerSurface
  • ImageSurface
  • InputSurface
  • TextareaSurface
  • VideoSurface
  • transitions
  • CachedMap
  • Easing
  • MultipleTransition
  • SnapTransition
  • SpringTransition
  • Transitionable
  • TransitionableTransform
  • TweenTransition
  • WallTransition
  • utilities
  • KeyCodes
  • Timer
  • Utility
  • views
  • ContextualView
  • Deck
  • DrawerLayout
  • EdgeSwapper
  • FlexibleLayout
  • Flipper
  • GridLayout
  • HeaderFooterLayout
  • Lightbox
  • RenderController
  • ScrollContainer
  • Scroller
  • Scrollview
  • SequentialLayout
  • widgets
  • NavigationBar
  • TabBar

PhysicsEngine

The Physics Engine is responsible for mediating bodies with their interaction with forces and constraints (agents). Specifically, it is responsible for: - adding and removing bodies - updating a body's state over time - attaching and detaching agents - sleeping upon equillibrium and waking upon excitation

Overview

Options
Methods
constraintSteps
sleepTolerance
velocityCap
angularVelocityCap
setOptions
addBody
removeBody
attach
attachTo
detach
detach
detachAll
getAgent
getParticles
getBodies
getBodies
forEachParticle
forEachBody
forEach
getAgentEnergy
getEnergy
step
isSleeping
isActive
sleep
wake

PhysicsEngine(options)

Constructor Parameters

options

Object

options

Methods

PhysicsEngine.DEFAULT_OPTIONS()ProtectedStatic

constraintSteps()

The number of iterations the engine takes to resolve constraints

sleepTolerance()

The energy threshold required for the Physics Engine to update

velocityCap()

The maximum velocity magnitude of a physics body Range : [0, Infinity]

angularVelocityCap()

The maximum angular velocity magnitude of a physics body Range : [0, Infinity]

setOptions(opts)

Options setter

Parameters
opts
Object

addBody(body)

Method to add a physics body to the engine. Necessary to update the body over time.

Parameters
body
Body
Returns
Body
body

removeBody(body)

Remove a body from the engine. Detaches body from all forces and constraints. TODO: Fix for in loop

Parameters
body
Body

attach(agents, targets, source)

Attaches a force or constraint to a Body. Returns an AgentId of the attached agent which can be used to detach the agent.

Parameters
agents
Agent|Array.Agent
A force, constraint, or array of them.
targets
Body|Array.Body
The Body or Bodies affected by the agent
source
Body
The source of the agent
Returns
Number
AgentId

attachTo(agentID, target)

Append a body to the targets of a previously defined physics agent.

Parameters
agentID
AgentId
The agentId of a previously defined agent
target
Body
The Body affected by the agent

detach(id)

Undoes PhysicsEngine.attach. Removes an agent and its associated effect on its affected Bodies.

Parameters
id
AgentId
The agentId of a previously defined agent

detach(id, target)

Remove a single Body from a previously defined agent.

Parameters
id
AgentId
The agentId of a previously defined agent
target
Body
The body to remove from the agent

detachAll()

A convenience method to give the Physics Engine a clean slate of agents. Preserves all added Body objects.

getAgent(id)

Returns the corresponding agent given its agentId.

Parameters
id
AgentId

getParticles()

Returns all particles that are currently managed by the Physics Engine.

Returns
Array.Particles
particles

getBodies()

Returns all bodies, except particles, that are currently managed by the Physics Engine.

Returns
Array.Bodies
bodies

getBodies()

Returns all bodies that are currently managed by the Physics Engine.

Returns
Array.Bodies
bodies

forEachParticle(fn, dt)

Iterates over every Particle and applies a function whose first argument is the Particle

Parameters
fn
Function
Function to iterate over
dt
Number
Delta time

forEachBody(fn, dt)

Iterates over every Body that isn't a Particle and applies a function whose first argument is the Body

Parameters
fn
Function
Function to iterate over
dt
Number
Delta time

forEach(fn, dt)

Iterates over every Body and applies a function whose first argument is the Body

Parameters
fn
Function
Function to iterate over
dt
Number
Delta time

getAgentEnergy(agentId)

Calculates the potential energy of an agent, like a spring, by its Id

Parameters
agentId
Number
The attached agent Id
Returns
Number
energy

getEnergy()

Calculates the kinetic energy of all Body objects and potential energy of all attached agents. TODO: implement.

Returns
Number
energy

step()

Updates all Body objects managed by the physics engine over the time duration since the last time step was called.

isSleeping()

Tells whether the Physics Engine is sleeping or awake.

Returns
Boolean

isActive()

Tells whether the Physics Engine is sleeping or awake.

Returns
Boolean

sleep()

Stops the Physics Engine update loop. Emits an 'end' event.

wake()

Restarts the Physics Engine update loop. Emits an 'start' event.

Branding Terms Privacy Jobs © Famous Industries, Inc. 2015