Files
cocos4/cocos/physics/framework/components/collider/sphere-collider-component.ts
T
jiaxin.lai a4af34630f integrate trimesh shape of ammo & cannon (#6232)
* stash

* cannon impl

* ammo mesh collider

* finish ammo mesh collider

* cannon trimesh shape

* tweaks

* tweaks

* tweaks

* update @cocos/ammo &  @cocos/cannon

* fix ci

* naming norm

* use config object

* renaming

* naming norm

* naming norm

* tweaks

* stash

* stash

* stash

* add error map

* export impl

* update package-lock

* export impl of world

* tweaks
2020-03-15 19:41:16 +08:00

65 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';
import { EDITOR, TEST } from 'internal:constants';
/**
* @zh
* 球碰撞器
*/
@ccclass('cc.SphereColliderComponent')
@executionOrder(98)
@menu('Physics/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 (!EDITOR && !TEST) {
this.shape.setRadius(this._radius);
}
}
public get shape () {
return this._shape as ISphereShape;
}
/// PRIVATE PROPERTY ///
@property
private _radius: number = 1;
constructor () {
super();
if (!EDITOR && !TEST) {
this._shape = createSphereShape(this._radius);
}
}
}