My latest project involves rendering a 16x16 grid of boxes in THREE.js using custom code.
const drawGroup = () => {
const blockSize = 16
// Positioning
for (let x = 0; x < blockSize; x++) {
for (let y = 0; y < blockSize; y++) {
for (let z = 0; z < blockSize; z++) {
const mesh = new THREE.Mesh(geometry, material)
mesh.position.set(x, y, z)
scene.add(mesh)
const lines = new THREE.LineSegments(edgesGeometry, edgesMaterial)
mesh.add(lines)
//console.log(mesh.position)
}
}
}
}
drawGroup()
Now, I am looking to save all the positions of the box group in a 3D array. How can I achieve this?