Skip to content

Commit

Permalink
🔫 Remove deprecated body.preStep and body.postStep (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcofugaro authored Jan 17, 2022
1 parent 0bc1c66 commit e888dfd
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 33 deletions.
4 changes: 2 additions & 2 deletions examples/callbacks.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@
const planet = new CANNON.Body({ mass: 0 })
planet.addShape(planetShape)

moon.preStep = () => {
world.addEventListener('preStep', () => {
const moon_to_planet = new CANNON.Vec3()
moon.position.negate(moon_to_planet)

const distance = moon_to_planet.length()

moon_to_planet.normalize()
moon_to_planet.scale(1500 / Math.pow(distance, 2), moon.force)
}
})

world.addBody(moon)
world.addBody(planet)
Expand Down
14 changes: 0 additions & 14 deletions src/objects/Body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,6 @@ export class Body extends EventTarget {
*/
world: World | null

/**
* Callback function that is used BEFORE stepping the system. Use it to apply forces, for example. Inside the function, "this" will refer to this Body object. Deprecated - use World events instead.
* @deprecated Use World events instead
*/
preStep: (() => void) | null

/**
* Callback function that is used AFTER stepping the system. Inside the function, "this" will refer to this Body object. Deprecated - use World events instead.
* @deprecated Use World events instead
*/
postStep: (() => void) | null

vlambda: Vec3

/**
Expand Down Expand Up @@ -444,8 +432,6 @@ export class Body extends EventTarget {
this.id = Body.idCounter++
this.index = -1
this.world = null
this.preStep = null
this.postStep = null
this.vlambda = new Vec3()

this.collisionFilterGroup = typeof options.collisionFilterGroup === 'number' ? options.collisionFilterGroup : 1
Expand Down
17 changes: 0 additions & 17 deletions src/world/World.ts
Original file line number Diff line number Diff line change
Expand Up @@ -821,14 +821,6 @@ export class World extends EventTarget {

this.dispatchEvent(World_step_preStepEvent)

// Invoke pre-step callbacks
for (i = 0; i !== N; i++) {
const bi = bodies[i]
if (bi.preStep) {
bi.preStep.call(bi)
}
}

// Leap frog
// vnew = v + h*f/m
// xnew = x + h*vnew
Expand All @@ -855,15 +847,6 @@ export class World extends EventTarget {

this.dispatchEvent(World_step_postStepEvent)

// Invoke post-step callbacks
for (i = 0; i !== N; i++) {
const bi = bodies[i]
const postStep = bi.postStep
if (postStep) {
postStep.call(bi)
}
}

// Sleeping update
let hasActiveBodies = true
if (this.allowSleep) {
Expand Down

0 comments on commit e888dfd

Please sign in to comment.