mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-06 19:42:39 +08:00
a4af34630f
* 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
70 lines
1.4 KiB
TypeScript
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();
|
|
}
|
|
}
|
|
}
|