BoundingBoxHelper constructor
BoundingBoxHelper(
- BoundingBox? box, [
- int color = 0xffff00
box -- the Box3 to show.
color -- (optional) the box's color. Default is 0xffff00.
Creates a new wireframe box that represents the passed BoundingBox.
Implementation
factory BoundingBoxHelper(BoundingBox? box, [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
]);
List<double> positions = [
1,
1,
1,
-1,
1,
1,
-1,
-1,
1,
1,
-1,
1,
1,
1,
-1,
-1,
1,
-1,
-1,
-1,
-1,
1,
-1,
-1
];
final geometry = BufferGeometry();
geometry.setIndex(Uint16BufferAttribute.fromList(indices, 1, false));
geometry.setAttributeFromString('position',Float32BufferAttribute.fromList(positions, 3, false));
final bbHelper = BoundingBoxHelper.create(geometry, LineBasicMaterial.fromMap({"color": color, "toneMapped": false}));
bbHelper.box = box;
bbHelper.type = 'BoundingBoxHelper';
bbHelper.geometry!.computeBoundingSphere();
return bbHelper;
}