Apologies for the lengthy code, but unfortunately, I was unable to create a minimal example that reproduces the issue. The function below returns two arrays, with each cell containing a number:
function VNtorus(R, r, nx, ny) {
var Vertices = new Array(nx);
var Normals = new Array(nx);
for (var i = 0; i < nx; i++) {
Vertices[i] = new Array(ny);
Normals[i] = new Array(ny);
var u = i / nx * 2 * Math.PI;
var cos_u = Math.cos(u);
var sin_u = Math.sin(u);
var cx = R * cos_u;
var cy = R * sin_u;
for (var j = 0; j < ny; j++) {
var v = j / ny * 2 * Math.PI;
var rcos_v = r * Math.cos(v);
var rsin_v = r * Math.sin(v);
Vertices[i][j] = new THREE.Vector3(
cx + rcos_v * cos_u,
cy + rcos_v * sin_u,
rsin_v
);
Normals[i][j] = new THREE.Vector3(
rcos_v * cos_u,
rcos_v * sin_u,
rsin_v
);
}
}
return {
vertices : Vertices,
normals : Normals
}
}
If interested, the context of this code can be found here: Cannot render a mesh with THREE js
However, when I use the function as shown below, the first array turns out to be empty in the resulting arrays:
var a = 3; var c = 0.7; var mu = 1.7;
var b = Math.sqrt(a * a - c * c);
var bb = b * Math.sqrt(mu * mu - c * c);
var omega = (a * mu + bb) / c;
var Omega = new THREE.Vector3(omega, 0, 0)
var inversion = function (M) {
var OmegaM = Omega.sub(M);
var k = OmegaM.dot(OmegaM);
return Omega.addScaledVector(OmegaM, k);
}
var d = (a - c) * (mu - c) + bb;
var r = c * c * (mu - c) / ((a + c) * (mu - c) + bb) / d;
var R = c * c * (a - c) / ((a - c) * (mu + c) + bb) / d;
var omegaT = omega - (b * b * (omega - c)) /
((a - c) * (mu + omega) - b * b) / ((a + c) * (omega - c) + b * b);
var tmesh = VNtorus(10, 3, 64, 32);
var tvertices = tmesh.vertices;
var tnormals = tmesh.normals;
console.log(tvertices)
// ...
0: Array(32)
length: 32
__proto__: Array(0)
1: Array(32)
0: p {x: 0.008700136926854488, y: 0.0008568886953253847, z: 0}
1: p {x: 0.008532966235351477, y: 0.0008404238193190658, z: 0.0017055250840917766}
....
This situation has left me feeling quite perplexed. Being relatively new to Javascript, I fear that I may have made a beginner's mistake somewhere.