用户:
星星上的雪花查看:15 回复:9 评论:15 创建时间:2022-04-09T23:57:21
const h = 5; // 房间的高度
const sample = //房间的地形,可自定义更改
`\
墙墙墙墙墙墙墙墙墙墙墙墙墙墙
墙空空空空空空空空空空空空墙
墙空空空空空空空空空空空空墙
墙空空空空空空空空空墙墙墙墙
墙空空空空空空空空空门
墙空空空空空空空空空门
墙空空空空空空空空空墙墙墙墙
墙空空空空空空空空空空空空墙
墙空空空空空空空空空空空空墙
墙墙墙墙墙墙墙墙墙墙墙墙墙墙`;
const room = [];
const v = (x=0, y=0, z=0) => new Box3Vector3(x,y,z);
for(let index = 0; index < sample.split("\n").length; index ++)
{
const part = sample.split("\n")[index];
const build = [];
const high = 8;
for(const block of part)
{
if(block === "墙")
build.push([
"powder_blue",
v(index,high,build.length)
])
if(block === "空")
build.push([
"ice_brick",
v(index,high,build.length)
])
if(block === "门")
build.push([
"wood",
v(index,high,build.length)
])
};
room.push(build)
};
for(let x = 0; x < 255; x += 20)
for(let y = 0; y <= h; y ++)
for(let z = 0; z < 255; z += 20)
{
for(const a of room)
{
for(const b of a)
{
voxels.setVoxel(b[1].x+x,b[1].y+y,b[1].z+z,b[0])
}
}
};
星星上的雪花生成空心房间
{
const h = 5; // 房间的高度
const sample = //房间的地形,可自定义更改
`\
墙墙墙墙墙墙墙墙墙墙墙墙墙墙
墙空空空空空空空空空空空空墙
墙空空空空空空空空空空空空墙
墙空空空空空空空空空墙墙墙墙
墙空空空空空空空空空门
墙空空空空空空空空空门
墙空空空空空空空空空墙墙墙墙
墙空空空空空空空空空空空空墙
墙空空空空空空空空空空空空墙
墙墙墙墙墙墙墙墙墙墙墙墙墙墙`;
const room = [];
const v = (x=0, y=0, z=0) => new Box3Vector3(x,y,z);
for(let index = 0; index < sample.split("\n").length; index ++)
{
const part = sample.split("\n")[index];
const build = [];
const high = 8;
for(const block of part)
{
if(block === "墙")
build.push([
"powder_blue",
v(index,high,build.length)
])
if(block === "空")
build.push([
"air",
v(index,high,build.length)
])
if(block === "门")
build.push([
"wood",
v(index,high,build.length)
])
};
room.push(build)
};
for(let x = 0; x < 255; x += 20)
for(let y = 1; y <= h; y ++)
for(let z = 0; z < 255; z += 20)
{
for(const a of room)
{
for(const b of a)
{
voxels.setVoxel(b[1].x+x,b[1].y+y,b[1].z+z,b[0])
}
}
};
}点赞0
评论
该账号已被封禁其实完全可以这样
let id={
'墙':'powder_blue',
'空':'air',
'门':'wood'
};
......
build.push([id[block],{x:index,y:high,z:build.length}]);
点赞0
评论