Releases: schteppe/p2.js
Releases · schteppe/p2.js
v0.7.1
v0.7.0
Summary
- This release makes it more easy and verbose to construct Shapes due to new constructors.
- Shapes now have
position
andangle
properties, which indicates the local position in the body they are attached to. This also means that aShape
instance can be attached to a singleBody
. - The raycasting API is refactored and should now be more verbose and flexible.
TopDownVehicle
class was added. Use it to make racing games!
Changes
- Renamed
Rectangle
toBox
380aaa5 - Updated all
Shape
constructors so they take their parameters via an options object. This way,Shape
constructor parameters can be passed in the same options object. 380aaa5new Rectangle(w, h)
=>new Box({ width: w, height: h })
new Capsule(l, r)
=>new Capsule({ length: l, radius: r })
new Circle(r)
=>new Circle({ radius: r })
new Convex(array)
=>new Convex({ vertices: array })
new Heightfield(array, options)
=>new Heightfield({ heights: array, [...other options...] })
new Line(l)
=>new Line({ length: l })
- Removed
.shapeOffsets
and.shapeAngles
fromBody
in favor of the new.position
and.angle
properties in the Shape instances. This means that a shape can only be added to one body. 16e1a47 - Raycasting API is scratched and rewritten. Replaced World.prototype.raycastAll, .raycastClosest and .raycastAny with
.raycast(result, ray)
. Moved the intersection methods inRay
to their respectiveShape
. d1feff1 - Enabled island splitting by default 1aed70b
- Increased default solver tolerance 1aed70b
- The "point" argument in
Body.prototype.applyForce
should now be a vector relative to theBody
position, instead of a world point 28494c1
Fixes
- Event objects now release references to objects in parameters after emit fe2461b
- Fix for requirejs via phaser ced0558
Additions
- The following options can now be passed via the
Shape
constructor: material, position, angle, collisionGroup, collisionMask, sensor, collisionResponse 6a20c75 380aaa5 - Added AABB.prototype.containsPoint 9423e3a
- Added vec2.getLineSegmentsIntersection and vec2.getLineSegmentsIntersectionFraction a01ee11
- Added
AABB.prototype.overlapsRay
- Added
vec2.reflect
ea9b6d5 - Added
TopDownVehicle
class 33846a5 - Added
Body.prototype.getVelocityAtPoint
33846a5 - Added object pools and prefilling 3537a2e 0b2a648
- Added
Body.prototype.applyLocalForce
28494c1 - The following options can now be passed to Body constructor: allowSleep, collisionResponse, gravityScale, sleepSpeedLimit, sleepTimeLimit, id
- Added
Body.prototype.applyImpulse
,.applyImpulseLocal
,.vectorToLocalFrame
,. vectorToWorldFrame
872ea6c - Added
vec2.vectorToLocalFrame
andvec2.vectorToGlobalFrame
238d120
Removals
- Removed
GridBroadphase
since it is buggy and mostly unused e90c672 - Removed
World.prototype.setGlobalEquationParameters
. Use.setGlobalStiffness
and.setGlobalRelaxation
instead 69d494b - Removed
doProfiling
andlastStepTime
properties fromWorld
since it is much easier to use the browser profiling tools nowadays. 4223c88 - Removed broken method
World.prototype.clone
c330903
v0.6.1
Small release, fixes some bugs and adds basic raycasting + experimental CCD.
Changes
- Changed default broadphase algorithm to
SAPBroadphase
.
Fixes
- Fixed bug in
endContact
event, bodyB had the value of bodyA. - Require.js fix for the build files, making it possible to use p2.js on the same page as require.js
.idleTime
inBody
is now initialized correctly- All classes now have .constructor set correctly
Additions
- Added
.collisonResponse
flag forBody
andShape
. - Added methods
.raycastClosest
,.raycastAll
and.raycastAny
toWorld
- Added method
Body.prototype.integrate
- Added properties
.ccdSpeedThreshold
and.ccdIterations
toBody
v0.6.0
Breaking changes
- Renamed property
.motionState
to.type
in classBody
. - Changed constructor of
RevoluteConstraint
. Now the local pivots are passed as options instead of direct arguments. See the constraints demo. - Removed
World.prototype.toJSON
and.fromJSON
. - Removed properties
.enableBodySleeping
and.enableIslandSleeping
fromWorld
instances. The enum.sleepMode
can be used instead. See the sleep demo. - Converted
Spring
to a base class for the newLinearSpring
andRotationalSpring
classes.LinearSpring
can be used as the oldSpring
. Utils.ARRAY_TYPE
can now be overridden by injecting a global calledP2_ARRAY_TYPE
. Support forGLMAT_ARRAY_TYPE
has been removed.
Other changes
- Added flag
.enableFrictionReduction
toNarrowphase
. - Added
RevoluteConstraint.prototype.setLimits
. - Added
PrismaticConstraint.prototype.setLimits
. LockConstraint
,DistanceConstraint
, andGearConstraint
can now be constructed from current body transforms.RevoluteConstraint
can now be constructed from the current body transforms and a world point.Material
id can now be passed via constructor.ContactMaterial
instances now have a property.contactSkinSize
.- Added method
Body.prototype.getAABB
. - Limits for
DistanceConstraint
. See the DistanceConstraint demo. - Added
Body.prototype.overlaps
. - Added class
OverlapKeeper
. - If substepping is used in
World.prototype.step
, the substeps are aborted if slower than real time. - Added
Heightfield
/Convex
andHeightfield
/Circle
collision support. - Added property
.overlapKeeper
toWorld
. EventEmitter.prototype.has
can now check if any listeners were added to a given topic.- Added
Utils.defaults
.
v0.5.0
- Added property
.enableIslandSleeping
toWorld
. - Added property
.useFrictionGravityOnZeroGravity
toWorld
. - Renamed
.useWorldGravityForFrictionApproximation
inWorld
to.useWorldGravityAsFrictionGravity
to keep things more uniform. - Sleep improvements.
- Added property
.frictionIterations
toGSSolver
, and removed.skipFrictionIterations
. - Upgraded to gl-matrix
2.1.0
. - Removed
QuadTree
. - Removed
mat2
. - Added
Utils.extend
. - Added methods
.setStiffness
and.setRelaxation
methods toConstraint
. - Removed properties
.stiffness
,.relaxation
and.useGlobalEquationParameters
fromGSSolver
. - Added methods
.setGlobalStiffness
,.setGlobalRelaxation
,.setGlobalEquationParameters
toWorld
. - Renamed property
.eps
to.epsilon
forEquation
. - Removed property
.useBoundingBoxes
fromNaiveBroadphase
in favor of the new property.boundingVolumeType
inBroadphase
. - Added methods
.getMaxForce
and.setMaxForce
toLockConstraint
. - Changed property names
.bi
,.bj
,.ni
,.ri
,.rj
to.bodyA
,.bodyB
,.normalA
,.contactPointA
,.contactPointB
inEquation
,ContactEquation
andFrictionEquation
classes. - Removed
IslandSolver
in favor of the new propertyWorld.islandSplit
. - Changed constructors of the
Constraints
so they all take anoptions
object as last parameter. - Added property
.collideConnected
toConstraint
. - Added property
.islandSplit
toWorld
. - Added methods
.disableBodyCollision
and.enableBodyCollision
toWorld
. - Added properties
.useWorldGravityForFrictionApproximation
and.frictionGravity
toWorld
. - Added
Heightfield
class. - Removed properties
.defaultFriction
and.defaultRestitution
fromWorld
, in favor of.defaultContactMaterial
. - Added property
.enabled
toEquation
. - Added property
.surfaceVelocity
toContactMaterial
. - Added property
.sensor
toShape
. World
now emits events'beginContact'
,'endContact'
and'preSolve'
.- Added property
.gravityScale
toBody
. - Renamed class
SAP1DBroadphase
toSAPBroadphase
. - Added property
.interpolatedPosition
to `Body``. - Added method
.internalStep
toWorld
. - Added property
.applyGravity
toWorld
. - Renamed method
.computeC
to.computeInvC
inEquation
, and made it compute the inverse. - Added static method
Utils.splice
. - Added property
.world
toBody
. - Added property
.fixedRotation
toBody
. - Added class
AABB
. - Added properties
.aabb
and.aabbNeedsUpdate
toBody
, as well as a method.updateAABB
. - Added property
.useBoundingBoxes
toNaiveBroadphase
. - Added static method
Broadphase.aabbCheck
. - Added method
.computeAABB
toShape
. - Added static method
Broadphase.canCollide
. Body
now inherits fromEventEmitter
, and dispatches events'sleep'
,'sleepy'
and'wakeup'
.- Added properties
.allowSleep
,.sleepState
,.sleepSpeedLimit
,.sleepTimeLimit
,.lastTimeSleepy
as well as methods.sleep
,.wakeUp
and.sleepTick
toBody
. - Added enums
Body.AWAKE
,Body.SLEEPY
,Body.SLEEPING
. - Added property
.enableBodySleeping
toWorld
. - Added options
.disableRotationalLock
,.lowerLimit
,.upperLimit
toPrismaticConstraint
constructor. - Added methods
.enableMotor
,.disableMotor
toPrismaticConstraint
as well as properties.motorEnabled
,.motorSpeed
,.motorEquation
.
v0.4.0
- Added properties
.damping
and.angularDamping
toBody
. - Added property
.applyDamping
toWorld
. - Added properties
.shapeA
and.shapeB
toContactEquation
andFrictionEquation
. - Added property
.contactEquation
toFrictionEquation
. - Added property
.multiplier
toEquation
. - Added properties
.lowerLimitEnabled
,.lowerLimit
,.upperLimitEnabled
,.upperLimit
toRevoluteConstraint
. - Added property
.frictionCoefficient
toFrictionEquation
andNarrowphase
. The solver now updates the friction force bounds dynamically in the solver from this value.FrictionEquation.setSlipForce()
is thus deprecated. - Changed name of
Narrowphase.convexPlane
toNarrowphase.planeConvex
. - Changed name of
Narrowphase.capsulePlane
toNarrowphase.planeCapsule
. - Added property
.emitImpactEvent
toWorld
. - Added method
.getBodyById
toWorld
. - Added property
.skipFrictionIterations
toGSSolver
. - Changed parameter names for
PrismaticConstraint
. This breaks backwards compatibility. - Added properties
.localAxisA
,.localAnchorA
,.localAnchorB
, toPrismaticConstraint
.