Record Class ModelBoundingBox
java.lang.Object
java.lang.Record
kr.toxicity.model.api.data.blueprint.ModelBoundingBox
- Record Components:
minX- the minimum X coordinateminY- the minimum Y coordinateminZ- the minimum Z coordinatemaxX- the maximum X coordinatemaxY- the maximum Y coordinatemaxZ- the maximum Z coordinate
public record ModelBoundingBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
extends Record
Represents an axis-aligned bounding box (AABB) for a model part.
This record defines the spatial extent of a model element or group, used for hitboxes and collision detection.
- Since:
- 1.15.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ModelBoundingBoxA minimal bounding box size (0.1 x 0.1 x 0.1). -
Constructor Summary
ConstructorsConstructorDescriptionModelBoundingBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) Creates an instance of aModelBoundingBoxrecord class. -
Method Summary
Modifier and TypeMethodDescription@NotNull ModelBoundingBoxcenter()Returns a new bounding box with the same dimensions but centered at the origin (0,0,0).@NotNull org.joml.Vector3fReturns the center point of the bounding box as a vector.doublecenterY()Returns the Y coordinate of the center of the bounding box.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@NotNull ModelBoundingBoxinvert()Inverts the X and Z coordinates of the bounding box.doublelength()Calculates the full diagonal length of the bounding box.doublelengthZX()Calculates the diagonal length in the XZ plane.@NotNull org.joml.Vector3dmax()Returns the maximum corner as a vector.doublemaxX()Returns the value of themaxXrecord component.doublemaxY()Returns the value of themaxYrecord component.doublemaxZ()Returns the value of themaxZrecord component.@NotNull org.joml.Vector3dmin()Returns the minimum corner as a vector.doubleminX()Returns the value of theminXrecord component.doubleminY()Returns the value of theminYrecord component.doubleminZ()Returns the value of theminZrecord component.static @NotNull ModelBoundingBoxof(double x, double y, double z) Creates a bounding box centered at the origin with the given dimensions.static @NotNull ModelBoundingBoxof(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) Creates a bounding box from explicit min/max coordinates.static @NotNull ModelBoundingBoxof(@NotNull org.joml.Vector3d min, @NotNull org.joml.Vector3d max) Creates a bounding box from two corner vectors.@NotNull ModelBoundingBoxrotate(@NotNull org.joml.Quaterniond quaterniond) Rotates the bounding box around its center.@NotNull ModelBoundingBoxtimes(double scale) Scales the bounding box by a uniform factor.final StringtoString()Returns a string representation of this record class.doublex()Returns the width of the bounding box (X-axis extent).doubley()Returns the height of the bounding box (Y-axis extent).doublez()Returns the depth of the bounding box (Z-axis extent).
-
Field Details
-
MIN
A minimal bounding box size (0.1 x 0.1 x 0.1).- Since:
- 1.15.2
-
-
Constructor Details
-
ModelBoundingBox
public ModelBoundingBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) Creates an instance of aModelBoundingBoxrecord class.
-
-
Method Details
-
of
@NotNull public static @NotNull ModelBoundingBox of(@NotNull @NotNull org.joml.Vector3d min, @NotNull @NotNull org.joml.Vector3d max) Creates a bounding box from two corner vectors.- Parameters:
min- the minimum corner vectormax- the maximum corner vector- Returns:
- the bounding box
- Since:
- 1.15.2
-
of
Creates a bounding box centered at the origin with the given dimensions.- Parameters:
x- the width (X-axis)y- the height (Y-axis)z- the depth (Z-axis)- Returns:
- the centered bounding box
- Since:
- 1.15.2
-
of
@NotNull public static @NotNull ModelBoundingBox of(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) Creates a bounding box from explicit min/max coordinates.This method automatically ensures that min values are less than or equal to max values.
- Parameters:
minX- the first X coordinateminY- the first Y coordinateminZ- the first Z coordinatemaxX- the second X coordinatemaxY- the second Y coordinatemaxZ- the second Z coordinate- Returns:
- the normalized bounding box
- Since:
- 1.15.2
-
x
public double x()Returns the width of the bounding box (X-axis extent).- Returns:
- the width
- Since:
- 1.15.2
-
y
public double y()Returns the height of the bounding box (Y-axis extent).- Returns:
- the height
- Since:
- 1.15.2
-
centerY
public double centerY()Returns the Y coordinate of the center of the bounding box.- Returns:
- the center Y
- Since:
- 1.15.2
-
z
public double z()Returns the depth of the bounding box (Z-axis extent).- Returns:
- the depth
- Since:
- 1.15.2
-
centerPoint
@NotNull public @NotNull org.joml.Vector3f centerPoint()Returns the center point of the bounding box as a vector.- Returns:
- the center vector
- Since:
- 1.15.2
-
times
Scales the bounding box by a uniform factor.- Parameters:
scale- the scale factor- Returns:
- the scaled bounding box
- Since:
- 1.15.2
-
center
Returns a new bounding box with the same dimensions but centered at the origin (0,0,0).- Returns:
- the centered bounding box
- Since:
- 1.15.2
-
invert
Inverts the X and Z coordinates of the bounding box.- Returns:
- the inverted bounding box
- Since:
- 1.15.2
-
rotate
@NotNull public @NotNull ModelBoundingBox rotate(@NotNull @NotNull org.joml.Quaterniond quaterniond) Rotates the bounding box around its center.- Parameters:
quaterniond- the rotation quaternion- Returns:
- the rotated bounding box
- Since:
- 1.15.2
-
min
@NotNull public @NotNull org.joml.Vector3d min()Returns the minimum corner as a vector.- Returns:
- the min vector
- Since:
- 1.15.2
-
max
@NotNull public @NotNull org.joml.Vector3d max()Returns the maximum corner as a vector.- Returns:
- the max vector
- Since:
- 1.15.2
-
lengthZX
public double lengthZX()Calculates the diagonal length in the XZ plane.- Returns:
- the XZ diagonal length
- Since:
- 1.15.2
-
length
public double length()Calculates the full diagonal length of the bounding box.- Returns:
- the diagonal length
- Since:
- 1.15.2
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
minX
public double minX()Returns the value of theminXrecord component.- Returns:
- the value of the
minXrecord component
-
minY
public double minY()Returns the value of theminYrecord component.- Returns:
- the value of the
minYrecord component
-
minZ
public double minZ()Returns the value of theminZrecord component.- Returns:
- the value of the
minZrecord component
-
maxX
public double maxX()Returns the value of themaxXrecord component.- Returns:
- the value of the
maxXrecord component
-
maxY
public double maxY()Returns the value of themaxYrecord component.- Returns:
- the value of the
maxYrecord component
-
maxZ
public double maxZ()Returns the value of themaxZrecord component.- Returns:
- the value of the
maxZrecord component
-