射线检测完善

This commit is contained in:
yhh
2020-08-03 14:45:57 +08:00
parent a4fe9f5798
commit 8e3bcc1257
14 changed files with 814 additions and 53 deletions

View File

@@ -63,6 +63,18 @@ module es {
throw new Error(`Collisions of Circle to ${other} are not supported`);
}
public collidesWithLine(start: es.Vector2, end: es.Vector2, hit: es.RaycastHit): boolean {
return ShapeCollisions.lineToCircle(start, end, this, hit);
}
/**
* 获取所提供的点是否在此范围内
* @param point
*/
public containsPoint(point: es.Vector2) {
return (Vector2.subtract(point, this.position)).lengthSquared() <= this.radius * this.radius;
}
public pointCollidesWithShape(point: Vector2, result: CollisionResult): boolean {
return ShapeCollisions.pointToCircle(point, this, result);
}