So I’m going to state I think it’s a bug now with render3D… Given this code:
export var x0 = -5
export var y0 = -5
export var z0 = -5
export function render3D(index, x, y, z)
{
if (index == 0)
{
x0 = x
y0 = y
z0 = z
}
hsv(x*y,1,z)
}
as the values are not being updated for index=0:
Same result for index=630. So they only update for 1-629, which is one pixel short.
Note: for render (not render3D) the working values are 1-630… So it’s NOT zero based, but should be given arrays are 0 based. I’ve also seen a few patterns fail with index out of range issues on render3D because of this.
That said, you asked for my map code:
function (pixelCount) {
var map = [];
var vA = new Point(0,0,0);
var vB = new Point(0.943, 0.000, -1.333);
var vC = new Point(-0.471, 0.816, -1.333);
var vD = new Point(-0.471, -0.816, -1.333);
var vE = new Point(0,0,-2.666);
// channel 1
map = map.concat(getLineSegment(70, vA, vB));
map = map.concat(getLineSegment(70, vB, vC));
map = map.concat(getLineSegment(70, vC, vE));
// channel 2
map = map.concat(getLineSegment(70, vA, vC));
map = map.concat(getLineSegment(70, vC, vD));
map = map.concat(getLineSegment(70, vD, vE));
// channel 3
map = map.concat(getLineSegment(70, vA, vD));
map = map.concat(getLineSegment(70, vD, vB));
map = map.concat(getLineSegment(70, vB, vE));
return map;
}
function getLineSegment(pixelCount, p1, p2) {
var m = [];
var xStep = safeDiv(p2.x - p1.x, pixelCount);
var yStep = safeDiv(p2.y - p1.y, pixelCount);
var zStep = safeDiv(p2.z - p1.z, pixelCount);
for (var j = 0; j < (pixelCount); j++) {
m.push([p1.x + xStep * j, p1.y + yStep * j, p1.z + zStep * j]);
}
return m;
}
function Point(x,y,z) {
this.x = x;
this.y = y;
this.z = z;
}