Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/objects/Body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,34 @@ export class Body extends EventTarget {
return this
}

/**
* Remove a shape from the body.
* @method removeShape
* @param {Shape} shape
* @return {Body} The body object, for chainability.
*/
removeShape(shape: Shape): Body {

const index = this.shapes.indexOf(shape)

if (index === -1) {
console.warn('Shape does not belong to the body');
return this;
}

this.shapes.splice(index, 1)
this.shapeOffsets.splice(index, 1)
this.shapeOrientations.splice(index, 1)
this.updateMassProperties()
this.updateBoundingRadius()

this.aabbNeedsUpdate = true

shape.body = null

return this
}

/**
* Update the bounding radius of the body. Should be done if any of the shapes are changed.
* @method updateBoundingRadius
Expand Down