Files
cocos4/cocos/physics/framework/components/collider/sphere-collider-component.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 {
ccclass,
executeInEditMode,
executionOrder,
menu,
property,
} from '../../../../core/data/class-decorator';
import { createSphereShape } from '../../instance';
import { ColliderComponent } from './collider-component';
import { ISphereShape } from '../../../spec/i-physics-shape';
/**
* @zh
* 球碰撞器
*/
@ccclass('cc.SphereColliderComponent')
@executionOrder(98)
@menu('Components/SphereCollider')
@executeInEditMode
export class SphereColliderComponent extends ColliderComponent {
/// PUBLIC PROPERTY GETTER\SETTER ///
/**
* @en
* Get or set the radius of the sphere.
* @zh
* 获取或设置球的半径。
*/
@property({
tooltip:'球的半径',
})
public get radius () {
return this._radius;
}
public set radius (value) {
this._radius = value;
if (!CC_EDITOR) {
this.sphereShape.radius = this._radius;
}
}
public get sphereShape (): ISphereShape {
return this._shape as ISphereShape;
}
/// PRIVATE PROPERTY ///
@property
private _radius: number = 1;
constructor () {
super();
if (!CC_EDITOR) {
this._shape = createSphereShape(this._radius);
}
}
}