BoxHelper constructor

BoxHelper(
  1. dynamic object, {
  2. int color = 0xffff00,
})

object -- (optional) the object3D to show the world-axis-aligned boundingbox.

color -- (optional) hexadecimal value that defines the box's color. Default is 0xffff00.

Creates a new wireframe box that bounds the passed object. Internally this uses setFromObject to calculate the dimensions. Note that this includes any children.

Implementation

factory BoxHelper(object, {int color = 0xffff00}) {
  final indices = Uint16List.fromList([
    0,
    1,
    1,
    2,
    2,
    3,
    3,
    0,
    4,
    5,
    5,
    6,
    6,
    7,
    7,
    4,
    0,
    4,
    1,
    5,
    2,
    6,
    3,
    7
  ]);
  final positions = Float32List(8 * 3);

  final geometry = BufferGeometry();
  geometry.setIndex(Uint16BufferAttribute.fromList(indices, 1, false));
  geometry.setAttributeFromString('position', Float32BufferAttribute.fromList(positions, 3, false));

  final boxHelper = BoxHelper.create(
      geometry, LineBasicMaterial.fromMap({"color": color, "toneMapped": false}));

  boxHelper.object = object;
  boxHelper.type = 'BoxHelper';

  boxHelper.matrixAutoUpdate = false;

  boxHelper.update();

  return boxHelper;
}