#How do I fill spheres?
1 messages · Page 1 of 1 (latest)
Look online and find a sphere calculating formula. I can explain the math but basically you just use some basic trig to generate a number of points that fall into a sphere with an input radius.
Then that will return a pile of location vectors which you can set to your desired block type with an offset.
Example?
How do I generate that list of blocks?
Use this ig
function sphere(center, radius, hollow = false) {
const points = [];
const rSq = radius * radius;
const innerSq = (radius - 1) * (radius - 1);
for (let x = Math.floor(center.x - radius); x <= Math.ceil(center.x + radius); x++) {
for (let y = Math.floor(center.y - radius); y <= Math.ceil(center.y + radius); y++) {
for (let z = Math.floor(center.z - radius); z <= Math.ceil(center.z + radius); z++) {
const dx = x - center.x;
const dy = y - center.y;
const dz = z - center.z;
const distSq = dx * dx + dy * dy + dz * dz;
if (distSq <= rSq && (!hollow || distSq >= innerSq)) {
points.push({ x, y, z });
}
}
}
}
return points;
}
Where is this from?
wdym, its mine lol.
np
Command : !sphere <bloc> <rayon> [creux:true/false] //True = hollow: therefore the interior is empty, False = full: therefore the interior is full
Maximum radius 50 info, otherwise it's buggy.