Files
cocos4/cocos/physics/framework/components/collider/mesh-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

70 lines
1.4 KiB
TypeScript

/**
* @category physics
*/
import {
ccclass,
executeInEditMode,
executionOrder,
menu,
property,
} from '../../../../core/data/class-decorator';
import { ColliderComponent } from './collider-component';
import { createTrimeshShape } from '../../instance';
import { Mesh } from '../../../../core';
import { ITrimeshShape } from '../../../spec/i-physics-shape';
import { EDITOR, TEST } from 'internal:constants';
/**
* @zh
* 三角网格碰撞器
*/
@ccclass('cc.MeshColliderComponent')
@executionOrder(98)
@menu('Physics/MeshCollider')
@executeInEditMode
export class MeshColliderComponent extends ColliderComponent {
/// PUBLIC PROPERTY GETTER\SETTER ///
@property({
type: Mesh,
})
get mesh () {
return this._mesh;
}
set mesh (value) {
this._mesh = value;
if (!EDITOR && !TEST) this.shape.setMesh(this._mesh);
}
// @property
// get convex () {
// return this._convex;
// }
// set convex (value) {
// this._convex = value;
// }
get shape () {
return this._shape as ITrimeshShape;
}
/// PRIVATE PROPERTY ///
@property
private _mesh: Mesh | null = null;
// @property
// private _convex: boolean = false;
constructor () {
super();
if (!EDITOR && !TEST) {
this._shape = createTrimeshShape();
}
}
}