So I want a list of all positions if I give two positions(Vector3) in Javascript.
The Image is an example. I have two positions, p1 and p2. Now I need an algorith that gives me the positions of all cubes in that space. The numbers do not need to be decimal numbers. image
I tried this:
p1 = new Vector3(-1,-1,3)
p2 = new Vector3(3,3,1)
var result = []
for(var x = 0; x < p2.x+1; x++){
for(var y = 0; y < p2.y+1; y++){
for(var z = 0; z < p2.z+1; z++){
result.push(new Vector3(p1.x+x,p1.y+y,p1.z+z))
}
}
}
But it doesnt work with negative numbers.
We just need to add an helper function that returns an iterable array containing all the values between a certain range :