Appearance
物理
属性
bounds
默认值:GameVector3(1, 1, 1)
实体边界框的半径,沿着 x/y/z 方向,每帧都会重新计算
entityContacts
默认值:[]
返回正在和玩家/实体发生碰撞的全部实体列表。
voxelContacts
默认值:[]
返回正在和玩家/实体发生碰撞的全部方块列表。
fluidContacts
默认值:[]
返回正在被玩家/实体触碰的全部液体方块列表。
collides
默认值:true
如果为假(false),则实体不会碰撞
fixed
默认值:false
如果为真(true),则实体不会移动
meshScale
实体的缩放比例。
friction
默认值:0
范围:0-1
控制实体的粘性(0 = 滑,1 = 粘)
gravity
默认值:true
如果为假(false),则实体不会下落
mass
默认值:1
实体物理质量。
restitution
默认值:0
范围:0-1
控制实体的弹性(0 = 软, 1 = 弹)
velocity
默认值:GameVector3(0, 0, 0)
实体的速度。
点击查看示例代码
javascript
// 让所有玩家每五秒跳一下
setInterval(() => {
console.log("jump around!");
world.querySelectorAll("player").forEach((e) => {
e.velocity.y += 1;
});
}, 5000);
contactForce
默认值:GameVector3(0, 0, 0)
实体受到的碰撞力。
接口
GameEntityContact
活跃实体对接触
参数 | 类型 | 说明 |
---|---|---|
other | GameEntity | 接触的另一个实体 |
force | GameVector3 | 接触力 |
axis | GameVector3 | 接触轴 |
GameVoxelContact
活跃方块接触状态
参数 | 类型 | 说明 |
---|---|---|
x | number | 方块的 X 坐标 |
y | number | 方块的 Y 坐标 |
z | number | 方块的 Z 坐标 |
voxel | number | 方块 ID |
force | GameVector3 | 接触力 |
axis | GameVector3 | 接触轴 |
GameFluidContact
活跃流体接触
参数 | 类型 | 说明 |
---|---|---|
voxel | number | 方块 ID |
volume | number | 流体体积 |