My current project involves simulating a 3D distribution of galaxies.
In this simulation, the galaxies are represented as points.
question1.htm references galaxydata1.txt to calculate and load the galaxy positions:
rawFile.open("GET", "galaxydata1.txt", false);
var parts = data[i].split("\t");
var D = parts[0];
var glon = parts[1]*3.1416/180;
var glat = parts[2]*3.1416/180;
var z = D*Math.sin(glat);
var xy = D*Math.cos(glat);
var x = xy*Math.cos(glon);
var y = xy*Math.sin(glon);
dotGeometry.vertices.push(new THREE.Vector3( x, y, z ));
To ensure the simulation works on devices with limited resources, I pre-calculated and saved the positions in a file.
I accomplished this using write.htm to generate galaxydata2.txt.
question2.htm utilizes galaxydata2.txt for loading the galaxy positions:
var parts = data[i].split(" ");
rawFile.open("GET", "galaxydata2.txt", false);
dotGeometry.vertices.push(new THREE.Vector3( parts[0], parts[1], parts[2] ));
The accuracy of the transformation can be verified as both question1.htm and question2.htm generate identical models.
I have recently added a galaxy search feature that locates a specific galaxy by name and centers it using:
controls.target = dots.geometry.vertices[i];
You can test this feature by searching for "m31" (one of the names for the Andromeda galaxy).
Interestingly, while the galaxy search function functions correctly in question1.htm, it fails in question2.htm!
I have dedicated considerable time over the past two days trying to troubleshoot this issue but have been unable to pinpoint the problem.
It should be noted that I used exactly the same code to calculate the positions in both scenarios.
Chances are high that I am overlooking something obvious that experts could easily identify.
If possible, kindly provide guidance on resolving this challenge.