checkBufferGeometryIntersection function

Intersection? checkBufferGeometryIntersection(
  1. Object3D object,
  2. Material material,
  3. Raycaster raycaster,
  4. Ray ray,
  5. BufferAttribute<NativeArray<num>> position,
  6. dynamic morphPosition,
  7. dynamic morphTargetsRelative,
  8. dynamic uv,
  9. dynamic uv2,
  10. int a,
  11. int b,
  12. int c,
)

Implementation

Intersection? checkBufferGeometryIntersection(Object3D object, Material material, Raycaster raycaster, Ray ray,
    BufferAttribute position, morphPosition, morphTargetsRelative, uv, uv2, int a, int b, int c) {
  _vA.fromBufferAttribute(position, a);
  _vB.fromBufferAttribute(position, b);
  _vC.fromBufferAttribute(position, c);

  var morphInfluences = object.morphTargetInfluences;

  if (morphPosition != null && morphInfluences != null) {
    _morphA.set(0, 0, 0);
    _morphB.set(0, 0, 0);
    _morphC.set(0, 0, 0);

    for (var i = 0, il = morphPosition.length; i < il; i++) {
      var influence = morphInfluences[i];
      var morphAttribute = morphPosition[i];

      if (influence == 0) continue;

      _tempA.fromBufferAttribute(morphAttribute, a);
      _tempB.fromBufferAttribute(morphAttribute, b);
      _tempC.fromBufferAttribute(morphAttribute, c);

      if (morphTargetsRelative) {
        _morphA.addScaledVector(_tempA, influence);
        _morphB.addScaledVector(_tempB, influence);
        _morphC.addScaledVector(_tempC, influence);
      } else {
        _morphA.addScaledVector(_tempA.sub(_vA), influence);
        _morphB.addScaledVector(_tempB.sub(_vB), influence);
        _morphC.addScaledVector(_tempC.sub(_vC), influence);
      }
    }

    _vA.add(_morphA);
    _vB.add(_morphB);
    _vC.add(_morphC);
  }

  if (object is SkinnedMesh) {
    object.boneTransform(a, _vA);
    object.boneTransform(b, _vB);
    object.boneTransform(c, _vC);
  }

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

  if (intersection != null) {
    if (uv != null) {
      _uvA.fromBufferAttribute(uv, a);
      _uvB.fromBufferAttribute(uv, b);
      _uvC.fromBufferAttribute(uv, c);

      intersection.uv = Triangle.staticGetUV(_intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, Vector2(null, null));
    }

    if (uv2 != null) {
      _uvA.fromBufferAttribute(uv2, a);
      _uvB.fromBufferAttribute(uv2, b);
      _uvC.fromBufferAttribute(uv2, c);

      intersection.uv2 = Triangle.staticGetUV(_intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, Vector2(null, null));
    }

    var face = Face.fromJSON({"a": a, "b": b, "c": c, "normal": Vector3.init(), "materialIndex": 0});

    Triangle.staticGetNormal(_vA, _vB, _vC, face.normal);

    intersection.face = face;
  }

  return intersection;
}