GCubeSDK
©2026 FenixFox®Studios

Triangle

Class representing a geometric triangle. A triangle is defined by three Vector3 points (a, b, c) representing its vertices.

Methods

Triangle(const Vector3& a, const Vector3& b, const Vector3& c)

Constructor to create new triangle

a first corner of the triangle Vector3()
b second corner of the triangle Vector3()
c third corner of the triangle Vector3()

Triangle& set(const Vector3& a, const Vector3& b, const Vector3& c)

Sets the triangle's vertices by copying the given values

a first corner of the triangle
b second corner of the triangle
c third corner of the triangle

Triangle& setFromPointsAndIndices(const vector<Vector3>& points, u32 i0, u32 i1, u32 i2)

Sets the triangle's vertices by copying the given array values

points array with 3D points
i0 array index representing the first corner
i1 array index representing the second corner
i2 array index representing the third corner

Triangle& setFromAttributeAndIndices(const BufferAttribute& attribute, u32 i0, u32 i1, u32 i2)

Sets the triangle's vertices by copying the given attribute values

attribute buffer attribute with 3D points data
i0 attribute index representing the first corner
i1 attribute index representing the second corner
i2 attribute index representing the third corner

Triangle clone() const

Returns a new triangle with copied values from this instance

Triangle& copy(const Triangle& triangle)

Copies the values of the given triangle to this instance

triangle Triangle to copy from

f32 getArea() const

Computes the area of the triangle

Vector3& getMidpoint(Vector3& target) const

Computes the midpoint of the triangle

target target vector that is used to store the method's result

Vector3& getNormal(Vector3& target) const

Computes the normal of the triangle

target target vector that is used to store the method's result

Plane& getPlane(Plane& target) const

Computes a plane the triangle lies within

target target plane that is used to store the method's result

Vector3* getBarycoord(const Vector3& point, Vector3& target) const

Computes barycentric coordinates from the given vector

point point in 3D space
target target vector that is used to store the method's result

bool containsPoint(const Vector3& point) const

Returns true if the given point, when projected onto the plane of the triangle, lies within the triangle

point point in 3D space to test

Vector3& closestPointToPoint(const Vector3& p, Vector3& target) const

Returns the closest point on the triangle to the given point

p point to compute the closest point for
target target vector that is used to store the method's result

bool intersectsBox(const Box3& box) const

Returns true if this triangle intersects with the given box

box box to intersect

bool isFrontFacing(const Vector3& direction) const

Returns true if the triangle is oriented towards the given direction

direction (normalized) direction vector

Vector3* getInterpolation(const Vector3& point, const Vector3& v1, const Vector3& v2, const Vector3& v3, Vector3& target) const

Computes the value barycentrically interpolated for the given point on the triangle

point position of interpolated point
v1 value to interpolate of first vertex
v2 value to interpolate of second vertex
v3 value to interpolate of third vertex
target target vector that is used to store the method's result

bool equals(const Triangle& triangle) const

Returns true if this triangle is equal with the given one

triangle triangle to compare with this one

bool operator==(const Triangle& triangle) const

Checks if this triangle equals another

triangle triangle to compare with

bool operator!=(const Triangle& triangle) const

Checks if this triangle does not equal another

triangle triangle to compare with

Properties

a Vector3 first corner of the triangle
b Vector3 second corner of the triangle
c Ve third corner of the triangle
enabled bool Active/inactive
id u32 Unique identifier
isTriangle bool Read-only tag
name string Optional display name
uuid string UUID string
version u32 Bumps on change