Files
esengine/source/src/Physics/RaycastHit.ts

57 lines
1.6 KiB
TypeScript
Raw Normal View History

2020-07-31 17:17:44 +08:00
module es {
export class RaycastHit {
/**
* 线
*/
public collider: Collider;
/**
* 沿线
*/
public fraction: number = 0;
/**
* 线
*/
public distance: number = 0;
/**
* 线
*/
public point: Vector2 = Vector2.zero;
/**
* 线
*/
public normal: Vector2 = Vector2.zero;
/**
* 使
*/
public centroid: Vector2;
constructor(collider: Collider, fraction: number, distance: number, point: Vector2, normal: Vector2){
this.collider = collider;
this.fraction = fraction;
this.distance = distance;
this.point = point;
this.centroid = Vector2.zero;
}
public setValues(collider: Collider, fraction: number, distance: number, point: Vector2){
this.collider = collider;
this.fraction = fraction;
this.distance = distance;
this.point = point;
}
public reset(){
this.collider = null;
this.fraction = this.distance = 0;
}
public toString(){
return `[RaycastHit] fraction: ${this.fraction}, distance: ${this.distance}, normal: ${this.normal}, centroid: ${this.centroid}, point: ${this.point}`;
}
}
}