bbi.geometry

Construct 3D points, areas, and volumes using the following geometry primitives.

These geometry primitives also implement methods for sampling points, which can be used by placement strategies to sample points for object placement.

class Geometry(node_id: str, transform: Transform)

Bases: Node

Base Geometry class. Geometries must be named uniquely for identification within the scene hierarchy.

They implement a bounds method for calculating the 3D bounding volume of the geometry, useful for collision detection and spatial queries.

uniform_random_points(n: int) list[Vector3]

Return n uniformly random points within the geometry.

class Point(node_id: str, position: Vector3, rotation: Vector3 = Vector3.zero())

Bases: Geometry

A 3D point in space.

Parameters:
  • node_id (str) – The node ID of the point.

  • position (Vector3) – The position of the point.

  • rotation (Vector3, optional) – The rotation of the point. Defaults to Vector3(0, 0, 0).

uniform_random_points(n: int) list[Vector3]

Return n uniformly random points within the geometry.

class Spline(node_id: str, points: list[Vector3], tangents: list[Vector3] | None = None)

Bases: Geometry

A curved spline constructed using a list of Vector3 positions, and optionally a list of Vector3 tangents.

Spline will pass through all points provided. A minimum of one point must be provided to construct a spline. If tangents are not provided, they are automatically calculated using the points.

Parameters:
  • node_id (str) – The node ID of the spline.

  • points (list[Vector3]) – The list of input positions in Vector3.

  • tangents (list[Vector3], optional) – The list of tangents at each point. Defaults to None.

property length: float

The length of the spline in meters.

get_position(t: float) Vector3

Given a particular progress value, get the position along the spline.

Parameters:

t (float) – The time parameter in the range [0, 1].

get_rotation(t: float, look_ahead_value: float = 0.01) Vector3

Given a particular progress value, get a rotation vector useful for aligning assets along the spline.

Parameters:
  • t (float) – The time parameter in the range [0, 1].

  • look_ahead_value (float, optional) – The amount to look ahead to calculate the rotation. Defaults to 0.01.

set_width(width: float) None

Assign a width to the spline. The width would act as an obstacle, so that collision checks would factor in width distance from the spline. The spline must be added to the scene before calling this function.

Parameters:

width (float) – The width of the spline.

class Cuboid(node_id: str, origin: Vector3, size: Vector3, rotation: Vector3)

Bases: Geometry

A 3D cuboid defined by an origin and size.

Parameters:
  • node_id (str) – The node ID of the cuboid.

  • origin (Vector3) – The origin of the cuboid.

  • size (Vector3) – The size of the cuboid.

uniform_random_points(n: int) list[Vector3]

Return n uniformly random points within the cuboid.

Parameters:

n (int) – The number of points to sample.

property min_x: float
property min_y: float
property min_z: float
property max_x: float
property max_y: float
property max_z: float
class Polygon(node_id: str, points: list[Vector3])

Bases: Geometry

A 3D polygon defined by a list of Vector3 points.

Parameters:
  • node_id (str) – The node ID of the polygon.

  • points (list[Vector3]) – The list of points that define the polygon.

property points: list[Vector3]
property is_simple: bool
property area: float
contains_point(point: Vector3) bool

Check if a point is within the polygon.

uniform_random_points(n: int) list[Vector3]

Sample n random points within the polygon.

intersection(other: Polygon) Polygon | None

Returns the intersection of this polygon with another polygon.

Parameters:

other (Polygon) – The polygon to intersect with.

difference(other: Polygon) list[Polygon] | None

Returns the difference of this polygon with another polygon.

Parameters:

other (Polygon) – The polygon to subtract from this polygon.