Please help me understand fillStyle

According to the reference on scene.voxels:fillStyle ( style ):

Sets the current fill style. There are several styles that can be used:

REPLACE - Replace fill style, new blocks will replace any existing ones
UNION - Union fill style, new blocks will only replace empty ones
INTERSECT - Intersect style, new blocks will only replace non-existing ones
CLEAR - Clear style, new blocks will clear any existing blocks

…this confuses me.

  1. UNION replaces “empty” blocks and INTERSECT replaces “non-existing” blocks? What’s the difference?
  2. CLEAR clears existing blocks—does that mean that when you are using the CLEAR fill style, it doesn’t matter what kind of block you use to set voxels:fill(…), it will just clear out the location, not placing any blocks at all? So is the effect of CLEAR the same as setting voxels:fill( 'name', 'empty')?

@John , @Simeon , any pointers here?

@UberGoober Here’s an example using fillStyle. I draw 4 rows of blocks. When you tap the change parameter, I redraw 2 blocks, one above the other over the middle of each row based on the fillStyle.

The top row is CLEAR and doesn’t seem to do anything.

The next row down is UNION and draws a new cube only where a cube wasn’t drawn before.

The row below that is INTERSECT and draws a new block over an existing block, but not over a blank block.

The bottom row is REPLACE and draws a new block over an existing block and a blank block.

So I’m not sure if I’m doing something wrong or the doc isn’t explaining it right.

viewer.mode=STANDARD

function setup()
    parameter.action("change",xxx)
    assert(OrbitViewer, "Please include Cameras as a dependency")
    scene = craft.scene() 
    v=scene.camera:add(OrbitViewer,vec3(5,5,0), 40, 0, 2000)
    
    scene.voxels.blocks:addAssetPack("Blocks")
    snow = scene.voxels.blocks:new("Snow")
    snow.setTexture(ALL, "Blocks:Snow")
    grass = scene.voxels.blocks:new("Grass Top")
    grass.setTexture(ALL, "Blocks:Grass Top")
    
    scene.voxels:resize(vec3(10,1,10))          
    scene.voxels.coordinates = vec3(0,0,0) 
    
    scene.voxels:fill("Snow")
    for x=0,10 do
        for y=0,9,3 do
            scene.voxels:block(x,y,0)
        end
    end
end

function update(dt)
    scene:update(dt)
end

function draw()
    update(DeltaTime)
    scene:draw()
end

function xxx()
    scene.voxels:fillStyle(CLEAR)
    scene.voxels:fill("Grass Top")
    scene.voxels:block(5,9,0)
    scene.voxels:block(5,10,0)
    
    scene.voxels:fillStyle(UNION)
    scene.voxels:fill("Grass Top")
    scene.voxels:block(5,6,0)
    scene.voxels:block(5,7,0)
    
    scene.voxels:fillStyle(INTERSECT)
    scene.voxels:fill("Grass Top")
    scene.voxels:block(5,3,0)
    scene.voxels:block(5,4,0)
    
    scene.voxels:fillStyle(REPLACE)
    scene.voxels:fill("Grass Top")
    scene.voxels:block(5,0,0)
    scene.voxels:block(5,1,0)
end

names seem weird, don’t thet?

The names make sense in @dave1707 ’s test, don’t they? That’s how I’d expect them to work. I think the whole problem is the word “non-“ in the INTERSECT explanation, because without that it reads “new blocks will only replace existing ones,” which seems accurate.

@John, @Simeon, would it make sense to have some special way to report documentation issues, or turn the documentation into a semi-open wiki for moderators, or something? I feel like whenever documentation problems pop up they often get lost in the shuffle of forum posts.

For me, it sounds like the CLEAR shouldn’t need a fill name cause the CLEAR should remove any block at a given x,y,z position. But when I try it, it looks like nothing happens at those x,y,z positions.

Yeah, CLEAR needs better explanation.