mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-02 16:52:43 +08:00
1a99b886b6
* 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
67 lines
1.4 KiB
TypeScript
67 lines
1.4 KiB
TypeScript
/**
|
|
* @category physics
|
|
*/
|
|
|
|
import {
|
|
ccclass,
|
|
executeInEditMode,
|
|
executionOrder,
|
|
menu,
|
|
property,
|
|
} from '../../../../core/data/class-decorator';
|
|
import { Vec3 } from '../../../../core/math';
|
|
import { createBoxShape } from '../../instance';
|
|
import { ColliderComponent } from './collider-component';
|
|
import { IBoxShape } from '../../../spec/i-physics-shape';
|
|
|
|
/**
|
|
* @zh
|
|
* 盒子碰撞器
|
|
*/
|
|
@ccclass('cc.BoxColliderComponent')
|
|
@executionOrder(98)
|
|
@menu('Components/BoxCollider')
|
|
@executeInEditMode
|
|
export class BoxColliderComponent extends ColliderComponent {
|
|
|
|
/// PUBLIC PROPERTY GETTER\SETTER ///
|
|
|
|
/**
|
|
* @en
|
|
* Get or set the size of the box, in local space.
|
|
* @zh
|
|
* 获取或设置盒的大小。
|
|
*/
|
|
@property({
|
|
type: Vec3,
|
|
tooltip:'盒的大小,即长、宽、高'
|
|
})
|
|
public get size () {
|
|
return this._size;
|
|
}
|
|
|
|
public set size (value) {
|
|
Vec3.copy(this._size, value);
|
|
if (!CC_EDITOR) {
|
|
this.boxShape.size = this._size;
|
|
}
|
|
}
|
|
|
|
public get boxShape (): IBoxShape {
|
|
return this._shape as IBoxShape;
|
|
}
|
|
|
|
/// PRIVATE PROPERTY ///
|
|
|
|
@property
|
|
private _size: Vec3 = new Vec3(1, 1, 1);
|
|
|
|
constructor () {
|
|
super();
|
|
if (!CC_EDITOR) {
|
|
this._shape = createBoxShape(this._size);
|
|
}
|
|
}
|
|
|
|
}
|