Here’s an example I have for drawing voxels and volumes.
PS. Made changes to the coords for the hole in the sphere. Made it just large enough so it goes thru, but still leaves the single block a each end.
viewer.mode=FULLSCREEN
function setup()
assert(OrbitViewer, "Please include Cameras as a dependency")
scene=craft.scene()
craft.scene.main=scene
v=scene.camera:add(OrbitViewer,vec3(20,0,0),100,0,200)
v.rx=10
scene.voxels.blocks:addAssetPack("Blocks")
missing=scene.voxels.blocks:new("Missing")
missing.setTexture(ALL,"Blocks:Missing")
error=scene.voxels.blocks:new("Error")
error.setTexture(ALL,"Blocks:Error")
oven=scene.voxels.blocks:new("Oven")
oven.setTexture(ALL,"Blocks:Oven")
scene.voxels:resize(vec3(16,1,16))
scene.voxels.coordinates=vec3(20,0,20)
-- draw a single block
scene.voxels:set(20,3,1,BLOCK_NAME,"missing")
-- draw a single block
scene.voxels:fill(BLOCK_NAME,"Solid",COLOR,color(239,255,0))
scene.voxels:block(18,4,8)
-- draw a box (floor) 40x40 1 block high
scene.voxels:fill(BLOCK_NAME,"Solid",COLOR,color(255,0,0))
scene.voxels:box(0,0,0,40,0,40)
-- draw a large box
scene.voxels:fill(BLOCK_NAME,"error")
scene.voxels:box(2,20,15,5,25,20)
-- draw a sphere 10 block radius
scene.voxels:fill(BLOCK_NAME,"Solid",COLOR,color(255))
scene.voxels:sphere(20,15,20,10)
-- draw a hole in the sphere
scene.voxels:fill(BLOCK_NAME,"empty")
scene.voxels:box(19,14,11,21,16,29)
-- draw a line
scene.voxels:fill(BLOCK_NAME,"oven")
scene.voxels:line(35,2,2,35,25,30)
-- draw a large volume block
volume = scene:entity():add(craft.volume,5,15,5)
for x=1,5 do
for y=1,15 do
for z=1,5 do
volume:set(x,y,z,COLOR,color(0,222,255),BLOCK_NAME,"Solid")
end
end
end
end
function draw()
scene:draw()
end