feat(physics): 集成 Rapier2D 物理引擎并修复预览重置问题 (#244)
* feat(physics): 集成 Rapier2D 物理引擎并修复预览重置问题 * fix: 修复 CI 流程并清理代码
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
import { Component, ECSComponent, Serializable, Serialize } from '@esengine/ecs-framework';
|
||||
|
||||
/**
|
||||
* 盒型碰撞器组件
|
||||
*/
|
||||
@ECSComponent('BoxCollider')
|
||||
@Serializable({ version: 1, typeId: 'BoxCollider' })
|
||||
export class BoxColliderComponent extends Component {
|
||||
/** 是否为触发器 */
|
||||
@Serialize() public isTrigger: boolean = false;
|
||||
|
||||
/** 中心点X偏移 */
|
||||
@Serialize() public centerX: number = 0;
|
||||
|
||||
/** 中心点Y偏移 */
|
||||
@Serialize() public centerY: number = 0;
|
||||
|
||||
/** 中心点Z偏移 */
|
||||
@Serialize() public centerZ: number = 0;
|
||||
|
||||
/** 宽度 */
|
||||
@Serialize() public width: number = 1;
|
||||
|
||||
/** 高度 */
|
||||
@Serialize() public height: number = 1;
|
||||
|
||||
/** 深度 */
|
||||
@Serialize() public depth: number = 1;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import { Component, ECSComponent, Serializable, Serialize } from '@esengine/ecs-framework';
|
||||
|
||||
/**
|
||||
* 圆形碰撞器组件
|
||||
*/
|
||||
@ECSComponent('CircleCollider')
|
||||
@Serializable({ version: 1, typeId: 'CircleCollider' })
|
||||
export class CircleColliderComponent extends Component {
|
||||
/** 是否为触发器 */
|
||||
@Serialize() public isTrigger: boolean = false;
|
||||
|
||||
/** 中心点X偏移 */
|
||||
@Serialize() public centerX: number = 0;
|
||||
|
||||
/** 中心点Y偏移 */
|
||||
@Serialize() public centerY: number = 0;
|
||||
|
||||
/** 半径 */
|
||||
@Serialize() public radius: number = 0.5;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
import { Component, ECSComponent, Serializable, Serialize } from '@esengine/ecs-framework';
|
||||
|
||||
/**
|
||||
* 刚体类型
|
||||
*/
|
||||
export enum BodyType {
|
||||
Static = 'static',
|
||||
Dynamic = 'dynamic',
|
||||
Kinematic = 'kinematic'
|
||||
}
|
||||
|
||||
/**
|
||||
* 刚体组件 - 管理物理模拟
|
||||
*/
|
||||
@ECSComponent('RigidBody')
|
||||
@Serializable({ version: 1, typeId: 'RigidBody' })
|
||||
export class RigidBodyComponent extends Component {
|
||||
/** 刚体类型 */
|
||||
@Serialize() public bodyType: BodyType = BodyType.Dynamic;
|
||||
|
||||
/** 质量 */
|
||||
@Serialize() public mass: number = 1;
|
||||
|
||||
/** 线性阻尼 */
|
||||
@Serialize() public linearDamping: number = 0;
|
||||
|
||||
/** 角阻尼 */
|
||||
@Serialize() public angularDamping: number = 0.05;
|
||||
|
||||
/** 重力缩放 */
|
||||
@Serialize() public gravityScale: number = 1;
|
||||
|
||||
/** 是否使用连续碰撞检测 */
|
||||
@Serialize() public continuousDetection: boolean = false;
|
||||
|
||||
/** 是否冻结X轴旋转 */
|
||||
@Serialize() public freezeRotationX: boolean = false;
|
||||
|
||||
/** 是否冻结Y轴旋转 */
|
||||
@Serialize() public freezeRotationY: boolean = false;
|
||||
|
||||
/** 是否冻结Z轴旋转 */
|
||||
@Serialize() public freezeRotationZ: boolean = false;
|
||||
|
||||
/** X轴速度 */
|
||||
@Serialize() public velocityX: number = 0;
|
||||
|
||||
/** Y轴速度 */
|
||||
@Serialize() public velocityY: number = 0;
|
||||
|
||||
/** Z轴速度 */
|
||||
@Serialize() public velocityZ: number = 0;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,8 @@ export { CameraComponent, CameraProjection } from './CameraComponent';
|
||||
// 系统
|
||||
export { SpriteAnimatorSystem } from './systems/SpriteAnimatorSystem';
|
||||
|
||||
// 物理
|
||||
export { RigidBodyComponent, BodyType } from './RigidBodyComponent';
|
||||
export { BoxColliderComponent } from './BoxColliderComponent';
|
||||
export { CircleColliderComponent } from './CircleColliderComponent';
|
||||
// 物理组件已移至 @esengine/physics-rapier2d 包
|
||||
// Physics components have been moved to @esengine/physics-rapier2d package
|
||||
|
||||
// 音频
|
||||
export { AudioSourceComponent } from './AudioSourceComponent';
|
||||
|
||||
Reference in New Issue
Block a user