calculateWorldAABB method

  1. @override
void calculateWorldAABB(
  1. Vec3 pos,
  2. Quaternion quat,
  3. Vec3 min,
  4. Vec3 max,
)
override

@todo use abstract for these kind of methods

Implementation

@override
void calculateWorldAABB(Vec3 pos, Quaternion quat, Vec3 min, Vec3 max) {
  // The plane AABB is infinite, except if the normal is pointing along any axis
  _tempNormal.set(0, 0, 1); // Default plane normal is z
  quat.vmult(_tempNormal, _tempNormal);
  const maxVal = double.infinity;
  min.set(-maxVal, -maxVal, -maxVal);
  max.set(maxVal, maxVal, maxVal);

  if (_tempNormal.x == 1) {
    max.x = pos.x;
  } else if (_tempNormal.x == -1) {
    min.x = pos.x;
  }

  if (_tempNormal.y == 1) {
    max.y = pos.y;
  } else if (_tempNormal.y == -1) {
    min.y = pos.y;
  }

  if (_tempNormal.z == 1) {
    max.z = pos.z;
  } else if (_tempNormal.z == -1) {
    min.z = pos.z;
  }
}