Class: Triangle

PD. Triangle

Adds a plane equation reference to each triangle to make intersection testing slightly more efficient.

Whilst the constructor will create a new plane for each triangle, it is more typical to give it as an argument, taken directly from the PD.Polyline, PD.Polygon, PD.BRep.Face that owns each triangle, so that the same existing plane instance can be shared by multiple triangles as well as the host.


new Triangle( [a] [, b] [, c] [, plane] [, host] [, offsetZ])

Creates a new triangle.

Parameters:
Name Type Argument Description
a THREE.Vector3 <optional>

An optional first vertex.

b THREE.Vector3 <optional>

An optional second vertex.

c THREE.Vector3 <optional>

An optional third vertex.

plane THREE.Plane <optional>

An optional plane equation for the triangle.

host PD.Polygon | PD.BRep.Face | THREE.Mesh <optional>

An optional host object to which the triangle belongs.

offsetZ number <optional>

A vertical offset value (in the Z axis), defaults to zero.

Author:
  • drajmarsh

Extends

  • THREE.Triangle

Members


:PD.Polygon|PD.BRep.Face|THREE.Mesh|null

host

A reference to the host object to which the triangle belongs.

Type

:number

offsetZ

Stores a vertical offset value (in the Z axis), typically used to account for the different floor heights of level geometry.

This value is not used internally by any octree processes, but is returned with the intersected triangle as part of the hit results of any intersection tests. The resulting intersection point can then be adjusted as required by the host application.

All levels store their geometry at their own zero-based height, which is then translated into world coordinates when the level is rendered. This means that intersecting octrees on different levels may require adjustment based on the current level's floor height. Different parts of the BIM framework will use this value differently as needed.

Type
  • number

:THREE.Plane|null

plane

Stores a reference to the plane equation of the triangle.

Type
  • THREE.Plane | null

Methods


copy(triangle)

Copies the values of the given triangle to this instance.

Parameters:
Name Type Description
triangle PD.Triangle

The triangle to copy.

Returns:

A reference to this triangle.

Type
PD.Triangle

getNormal(target)

Returns the normal vector of the triangle, computing it if necessary.

Parameters:
Name Type Description
target Vector3

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

Returns:

The triangle's normal.

Type
Vector3

getPlane(target)

Returns the plane the triangle lies within, computing it if necessary.

Parameters:
Name Type Description
target Plane

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

Returns:

The plane the triangle lies within.

Type
Plane

insideBox(box)

Tests if the triangle is completely contained within the given box.

Parameters:
Name Type Description
box THREE.Box3

The box to test against.

Returns:

Returns true if all triangle vertices are inside the box, otherwise false.

Type
boolean

intersectRay(ray, target)

Tests for an intersection between the given ray and this triangle.

Parameters:
Name Type Description
ray THREE.Ray

The ray to test.

target THREE.Vector3

A point to receive the intersection position.

Returns:

Returns true if the triangle was hit and the intersection set.

Type
boolean