TriangleHit
ClassTriangle hit information, available when a ray cast intersects a collision mesh.
- Available on all platforms
Since Lens Scripting v181
Index
Properties
Methods
Example
var probe = Physics.createGlobalProbe();
function printHit(hit) {
var tri = hit.triangle;
if (tri) {
print("triangle: " + tri);
print("mesh: " + tri.mesh);
print("index: " + tri.index);
print("vertexIndices: " + tri.vertexIndices);
print("vertexPositions: " + tri.vertexPositions);
print("barycentricCoordinate: " + tri.barycentricCoordinate);
}
}
probe.rayCast(fromPos, toPos, function onHitNearest(hit) {
if (hit) {
printHit(hit);
}
});
Extends
Properties
barycentricCoordinate
readonlybarycentricCoordinate:vec3
Barycentric coordinate of the hit on the triangle. This is used to interpolate values over the triangle surface. Essentially, these are weights for each of the 3 triangle vertices. For example, you can compute the hit position from vertex positions as: (V0*b0 + V1*b1 + V2*b2). We already have the hit position in RayCastHit, but 'V' can be any interpolated value, such as color or texture coordinate.
Since
Lens Scripting Version 181
index
readonlyindex:number
Index of the triangle in the mesh. Note, this is the index of the triangle in the collision mesh, which won't necessarily correspond to the same index on the render mesh (depending on type and bake settings).
Since
Lens Scripting Version 181
mesh
readonlymesh:CollisionMesh
Collision mesh containing the triangle.
Since
Lens Scripting Version 181
vertexIndices
readonlyvertexIndices:number[]
Vertex indices in the mesh. Note, these are the indices of the vertices in the collision mesh, which won't necessarily correspond to the same indices in the render mesh (depending on type and bake settings).
Since
Lens Scripting Version 181
vertexPositions
readonlyvertexPositions:vec3[]
World-space vertex positions.
Since
Lens Scripting Version 181
Methods
getTypeName()
staticgetTypeName():TypeName<TriangleHit>
Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().
Returns
TypeName<TriangleHit>
Since
Lens Scripting Version 181
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object is the same as other. Useful for checking if two references point to the same thing.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean