// Create a block volume representing a cubic region conststartLocation: Vector3 = { x:0, y:64, z:0 }; constendLocation: Vector3 = { x:10, y:74, z:10 };
// Create a new block volume using the constructor constblockVolume = newBlockVolume(startLocation, endLocation);
// Example usage of the block volume console.log( `Volume spans from (${blockVolume.from.x}, ${blockVolume.from.y}, ${blockVolume.from.z}) to (${blockVolume.to.x}, ${blockVolume.to.y}, ${blockVolume.to.z})` );
// Check if a location touches faces of the volume consttestLocation: Vector3 = { x:5, y:68, z:5 }; consttouchesFaces = blockVolume.doesLocationTouchFaces(testLocation); console.log(`Location (5, 68, 5) ${touchesFaces?"touches":"does not touch"} the volume faces`);
// Create another volume to test intersection constotherVolume = newBlockVolume({ x:5, y:60, z:5 }, { x:15, y:70, z:15 }); constvolumesIntersect = blockVolume.intersects(otherVolume); console.log(`Volumes ${volumesIntersect?"intersect":"do not intersect"}`);
// Get an iterator for all block locations in the volume constiterator = blockVolume.getBlockLocationIterator(); letblockCount = 0; for (constlocationofiterator) { blockCount++; if (blockCount <= 5) { console.log(`Block ${blockCount}: (${location.x}, ${location.y}, ${location.z})`); } }
Example: createBlockVolume.ts