|
@@ -6,6 +6,7 @@
|
|
|
import { Vector2 } from '../math/Vector2.js';
|
|
|
import { Vector3 } from '../math/Vector3.js';
|
|
|
import { Matrix4 } from '../math/Matrix4.js';
|
|
|
+import { Triangle } from '../math/Triangle.js';
|
|
|
import { Object3D } from '../core/Object3D.js';
|
|
|
import { BufferGeometry } from '../core/BufferGeometry.js';
|
|
|
import { InterleavedBuffer } from '../core/InterleavedBuffer.js';
|
|
@@ -66,6 +67,10 @@ Sprite.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
var vB = new Vector3();
|
|
|
var vC = new Vector3();
|
|
|
|
|
|
+ var uvA = new Vector2();
|
|
|
+ var uvB = new Vector2();
|
|
|
+ var uvC = new Vector2();
|
|
|
+
|
|
|
function transformVertex( vertexPosition, mvPosition, center, scale, sin, cos ) {
|
|
|
|
|
|
// compute position in camera space
|
|
@@ -114,6 +119,10 @@ Sprite.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
transformVertex( vB.set( 0.5, - 0.5, 0 ), mvPosition, center, worldScale, sin, cos );
|
|
|
transformVertex( vC.set( 0.5, 0.5, 0 ), mvPosition, center, worldScale, sin, cos );
|
|
|
|
|
|
+ uvA.set( 0, 0 );
|
|
|
+ uvB.set( 1, 0 );
|
|
|
+ uvC.set( 1, 1 );
|
|
|
+
|
|
|
// check first triangle
|
|
|
var intersect = raycaster.ray.intersectTriangle( vA, vB, vC, false, intersectPoint );
|
|
|
|
|
@@ -121,6 +130,8 @@ Sprite.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
|
|
|
// check second triangle
|
|
|
transformVertex( vB.set( - 0.5, 0.5, 0 ), mvPosition, center, worldScale, sin, cos );
|
|
|
+ uvB.set( 0, 1 );
|
|
|
+
|
|
|
intersect = raycaster.ray.intersectTriangle( vA, vC, vB, false, intersectPoint );
|
|
|
if ( intersect === null ) {
|
|
|
|
|
@@ -138,6 +149,7 @@ Sprite.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
|
|
|
distance: distance,
|
|
|
point: intersectPoint.clone(),
|
|
|
+ uv: Triangle.getUV( intersectPoint, vA, vB, vC, uvA, uvB, uvC, new Vector2() ),
|
|
|
face: null,
|
|
|
object: this
|
|
|
|