checkGeometryIntersection method

Intersection? checkGeometryIntersection(
  1. Mesh object,
  2. Material? material,
  3. Raycaster raycaster,
  4. Ray ray,
  5. BufferAttribute<NativeArray<num>>? uv,
  6. BufferAttribute<NativeArray<num>>? uv1,
  7. BufferAttribute<NativeArray<num>>? normal,
  8. int a,
  9. int b,
  10. int c,
)
inherited

Implementation

Intersection? checkGeometryIntersection(Mesh object, Material? material, Raycaster raycaster, Ray ray, BufferAttribute? uv, BufferAttribute? uv1, BufferAttribute? normal, int a, int b, int c ) {
  object.getVertexPosition( a, _vA );
  object.getVertexPosition( b, _vB );
  object.getVertexPosition( c, _vC );

  final intersection = checkIntersection( object, material, raycaster, ray, _vA, _vB, _vC, _intersectionPoint );

  if ( intersection != null) {

    final barycoord = new Vector3();
    TriangleUtil.getBarycoord( _intersectionPoint, _vA, _vB, _vC, barycoord );

    if ( uv != null) {
      intersection.uv = TriangleUtil.getInterpolatedAttribute( uv, a, b, c, barycoord, Vector2() ) as Vector2;
    }

    if ( uv1 != null) {
      intersection.uv1 = TriangleUtil.getInterpolatedAttribute( uv1, a, b, c, barycoord, Vector2() )as Vector2;
    }

    if ( normal != null) {
      intersection.normal = TriangleUtil.getInterpolatedAttribute( normal, a, b, c, barycoord, Vector3() ) as Vector3;

      if ( (intersection.normal?.dot( ray.direction ) ?? 0) > 0 ) {
        intersection.normal?.scale( - 1 );
      }
    }

    final face = Face(
      a,
      b,
      c,
      Vector3(),
      0
    );

    TriangleUtil.getNormal( _vA, _vB, _vC, face.normal );

    intersection.face = face;
    intersection.barycoord = barycoord;
  }

  return intersection;
}