( object, material, raycaster, ray, uv, uv1, normal, a, b, c )
| 438 | } |
| 439 | |
| 440 | function checkGeometryIntersection( object, material, raycaster, ray, uv, uv1, normal, a, b, c ) { |
| 441 | |
| 442 | object.getVertexPosition( a, _vA ); |
| 443 | object.getVertexPosition( b, _vB ); |
| 444 | object.getVertexPosition( c, _vC ); |
| 445 | |
| 446 | const intersection = checkIntersection( object, material, raycaster, ray, _vA, _vB, _vC, _intersectionPoint ); |
| 447 | |
| 448 | if ( intersection ) { |
| 449 | |
| 450 | const barycoord = new Vector3(); |
| 451 | Triangle.getBarycoord( _intersectionPoint, _vA, _vB, _vC, barycoord ); |
| 452 | |
| 453 | if ( uv ) { |
| 454 | |
| 455 | intersection.uv = Triangle.getInterpolatedAttribute( uv, a, b, c, barycoord, new Vector2() ); |
| 456 | |
| 457 | } |
| 458 | |
| 459 | if ( uv1 ) { |
| 460 | |
| 461 | intersection.uv1 = Triangle.getInterpolatedAttribute( uv1, a, b, c, barycoord, new Vector2() ); |
| 462 | |
| 463 | } |
| 464 | |
| 465 | if ( normal ) { |
| 466 | |
| 467 | intersection.normal = Triangle.getInterpolatedAttribute( normal, a, b, c, barycoord, new Vector3() ); |
| 468 | |
| 469 | if ( intersection.normal.dot( ray.direction ) > 0 ) { |
| 470 | |
| 471 | intersection.normal.multiplyScalar( - 1 ); |
| 472 | |
| 473 | } |
| 474 | |
| 475 | } |
| 476 | |
| 477 | const face = { |
| 478 | a: a, |
| 479 | b: b, |
| 480 | c: c, |
| 481 | normal: new Vector3(), |
| 482 | materialIndex: 0 |
| 483 | }; |
| 484 | |
| 485 | Triangle.getNormal( _vA, _vB, _vC, face.normal ); |
| 486 | |
| 487 | intersection.face = face; |
| 488 | intersection.barycoord = barycoord; |
| 489 | |
| 490 | } |
| 491 | |
| 492 | return intersection; |
| 493 | |
| 494 | } |
| 495 | |
| 496 | export { Mesh }; |
no test coverage detected