-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
sphere-collider.ts
68 lines (59 loc) · 1.39 KB
/
sphere-collider.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
* @category physics
*/
import {
ccclass,
help,
executeInEditMode,
menu,
tooltip,
serializable,
} from 'cc.decorator';
import { Collider } from './collider';
import { ISphereShape } from '../../../spec/i-physics-shape';
import { EDITOR, TEST } from 'internal:constants';
import { EColliderType } from '../../physics-enum';
/**
* @en
* Sphere collider component.
* @zh
* 球碰撞器。
*/
@ccclass('cc.SphereCollider')
@help('i18n:cc.SphereCollider')
@menu('Physics/SphereCollider')
@executeInEditMode
export class SphereCollider extends Collider {
/// PUBLIC PROPERTY GETTER\SETTER ///
/**
* @en
* Gets or sets the radius of the sphere.
* @zh
* 获取或设置球的半径。
*/
@tooltip('球的半径')
public get radius () {
return this._radius;
}
public set radius (value) {
this._radius = value;
if (!EDITOR && !TEST) {
this.shape.setRadius(this._radius);
}
}
/**
* @en
* Gets the wrapper object, through which the lowLevel instance can be accessed.
* @zh
* 获取封装对象,通过此对象可以访问到底层实例。
*/
public get shape () {
return this._shape as ISphereShape;
}
/// PRIVATE PROPERTY ///
@serializable
private _radius: number = 0.5;
constructor () {
super(EColliderType.SPHERE);
}
}