- 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
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
addBody(body)
Method to add a physics body to the engine. Necessary to update the body over time.
Parameters
Returns
removeBody(body)
Remove a body from the engine. Detaches body from all forces and constraints. TODO: Fix for in loop
Parameters
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
Returns
attachTo(agentID, target)
Append a body to the targets of a previously defined physics agent.
Parameters
detach(id)
Undoes PhysicsEngine.attach. Removes an agent and its associated effect on its affected Bodies.
Parameters
detach(id, target)
Remove a single Body from a previously defined agent.
Parameters
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
getParticles()
Returns all particles that are currently managed by the Physics Engine.
Returns
getBodies()
Returns all bodies, except particles, that are currently managed by the Physics Engine.
Returns
getBodies()
Returns all bodies that are currently managed by the Physics Engine.
Returns
forEachParticle(fn, dt)
Iterates over every Particle and applies a function whose first argument is the Particle
Parameters
forEachBody(fn, dt)
Iterates over every Body that isn't a Particle and applies a function whose first argument is the Body
Parameters
forEach(fn, dt)
Iterates over every Body and applies a function whose first argument is the Body
Parameters
getAgentEnergy(agentId)
Calculates the potential energy of an agent, like a spring, by its Id
Parameters
Returns
getEnergy()
Calculates the kinetic energy of all Body objects and potential energy of all attached agents. TODO: implement.
Returns
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
isActive()
Tells whether the Physics Engine is sleeping or awake.
Returns
sleep()
Stops the Physics Engine update loop. Emits an 'end' event.
wake()
Restarts the Physics Engine update loop. Emits an 'start' event.