addShape method

Body addShape(
  1. Shape shape, [
  2. Vec3? offset,
  3. Quaternion? orientation
])

Add a shape to the body with a local offset and orientation. @return The body object, for chainability.

Implementation

Body addShape(Shape shape,[Vec3? offset, Quaternion? orientation]){
  final off = Vec3();
  final or = Quaternion();

  if (offset != null) {
    off.copy(offset);
  }
  if (orientation != null) {
    or.copy(orientation);
  }

  shapes.add(shape);
  shapeOffsets.add(off);
  shapeOrientations.add(or);
  updateMassProperties();
  updateBoundingRadius();

  aabbNeedsUpdate = true;
  shape.body = this;

  return this;
}