Skip to main content

SpecsInteractionModule.TriangleHit

Class

Triangle hit information, available when a cast from SpecsInteractionModule intersects a collision mesh.

  • Snapchat: not supported
  • SPECS: fully supported
  • Camera Kit Web: not supported
  • Camera Kit Mobile: not supported
  • SnapchatNot supported — Available on SPECS only
  • SPECSFully supported
  • Camera Kit WebNot supported — Available on SPECS only
  • Camera Kit MobileNot supported — Available on SPECS only

Platform details

  • Snapchat — Not supported — Available on SPECS only.

  • SPECS — Fully supported.

  • Camera Kit Web — Not supported — Available on SPECS only.

  • Camera Kit Mobile — Not supported — Available on SPECS only.

Since Lens Scripting v375

Triangle hit information, available when a cast from SpecsInteractionModule intersects a collision mesh.

Index

Example

const queryMask = LayerSet.all();
interaction.rayCast(rayStart, rayEnd, queryMask, function (hit) {
if (hit && hit.triangle) {
print("hit triangle " + hit.triangle.index);
}
});

Extends

Properties

barycentricCoordinate

readonly barycentricCoordinate: vec3

SPECS

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 CastHit, but 'V' can be any interpolated value, such as color or texture coordinate.

Since

Lens Scripting Version 375


index

readonly index: number

SPECS

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 375


mesh

readonly mesh: CollisionMesh

SPECS

Collision mesh containing the triangle. Null if the mesh has been destroyed.

Since

Lens Scripting Version 375


vertexIndices

readonly vertexIndices: number[]

SPECS

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 375


vertexPositions

readonly vertexPositions: vec3[]

SPECS

World-space vertex positions.

Since

Lens Scripting Version 375

Methods

getTypeName()

static getTypeName(): TypeName<TriangleHit>

SPECS

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 375

Overrides

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.isOfType


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

ParameterType
otherScriptObject

Returns

boolean

Inherited from

ScriptObject.isSame