Files
cocos4/cocos/physics/framework/physics-ray-result.ts
T
jiaxin.lai 1a99b886b6 refactor physics framework & wrapper (#5667)
* basic physics abstract spec

* spec tweaks

* stash

* cannon refactor

* builtin refactor

* cannon wrapper & framework tweaks

* cannon wrapper import tweaks

* remve unneeded code

* group mask tweaks

* hiding, wait for 1.0.3

* builtin tweaks

* delete unneed code

* export CANNON

* update @cocos/cannon to 1.0.3

* using hasTigger property

* fix remove cannon body

* rebase

* update cannon version to 1.0.4

* rename stash

* rename I-rigid-body to i-rigid-body
2019-12-13 16:00:22 +08:00

64 lines
1.3 KiB
TypeScript

/**
* @category physics
*/
import { Vec3 } from '../../core/math';
import { ColliderComponent } from '../../../exports/physics-framework';
/**
* @zh
* 用于保存物理射线检测结果
*/
export class PhysicsRayResult {
/**
* @zh
* 击中点
*/
get hitPoint (): Vec3 {
return this._hitPoint;
}
/**
* @zh
* 距离
*/
get distance (): number {
return this._distance;
}
/**
* @zh
* 击中的碰撞盒
*/
get collider (): ColliderComponent {
return this._collidier!;
}
private _hitPoint: Vec3 = new Vec3();
private _distance: number = 0;
private _collidier: ColliderComponent | null = null;
/**
* @zh
* 设置射线,此方法由引擎内部使用,请勿在外部脚本调用
*/
public _assign (hitPoint: Vec3, distance: number, collider: ColliderComponent) {
Vec3.copy(this._hitPoint, hitPoint);
this._distance = distance;
this._collidier = collider;
}
/**
* @zh
* 克隆
*/
public clone () {
const c = new PhysicsRayResult();
Vec3.copy(c._hitPoint, this._hitPoint);
c._distance = this._distance;
c._collidier = this._collidier;
return c;
}
}