var object1 = //Some random block in the world;
var object2 = //Another random block in the world;
var objects = [
{
pos: object1.getPosition(),
type: object1.model.material.name
},
{
pos: object2.getPosition(),
type: object2.model.material.name
}
];
When the player breaks a block, or some other entity, how can I remove the element from the array that corresponds to the broken block?
In your other thread, I showed how to store the state of your ‘block world’ in a 3-dimensional array. Any block can be looked up with x, y and z indices. Each block has a position in 3D space. Assuming each block is 1x1x1 meters, you can actually use the position of the block (returned by the getPosition function) to provide the x, y, z indices to look up the corresponding entry in the game state.
So say the player deletes a particular block. You just do something like:
var pos = block.getPosition();
gameState[pos.y][pos.x][pos.z].type = BLOCKTYPE_BLANK;
block.destroy();