用户:
cool-creeper查看:0 回复:0 评论:0 创建时间:2021-01-15T21:04:30
以前shyfcka(现在改名了)发布了这个帖子:https://shequ.codemao.cn/community/331137
不过这里面的代码有bug,我修正了一下(其实只是shy打错了一个字符,把0打成了O而已……):
world.onPress(({ button,raycast: { voxelIndex,normal}})=>{;//监听按下预越事什
if (button == Box3ButtonType.ACTION0){//如果是actione,即电脑端的左键
voxels.setVoxel(voxelIndex.x,voxelIndex.y,voxelIndex.z,0);//破坏点击到的方块
}else if (button == Box3ButtonType.ACTION1){//如果是action1,对应电脑端右键
let v = voxelIndex.add(normal);//用点击到的方块坐标加上法向量,得到邻边方块位置
voxels.setVoxel(v.x,v.y,v.z, 'white');//设置邻边方块为白色,当然还可以自定义
}
});
world.onPlayerJoin(({entity})=>{//监听玩家进入事件
entity.player.enable3Dcursor =true;//打开玩家的3D光标
});
此代码在代码岛v.0.3.5运行成功,其他版本可能失效