I'm having trouble grasping the significance of this line in the code
this.position = convertlatlonToVec3(cardinal.lat, cardinal.lon).multiplyScalar(radius);
within the labelBox function. Can you explain how multiplyScalar(radius) functions?
function convertlatlonToVec3(lat, lon)
{
var cosLat = Math.cos(circle.getCenter().lat() * degrees);
var sinLat = Math.sin(circle.getCenter().lat() * degrees);
var xSphere = radiusEquator * cosLat;
var ySphere = 0;
var zSphere = radiusPoles * sinLat;
var rSphere = Math.sqrt(xSphere*xSphere + ySphere*ySphere + zSphere*zSphere);
var tmp = rSphere * Math.cos(lat * degrees);
xSphere = tmp * Math.cos((lon - circle.getCenter().lng()) * degrees);
ySphere = tmp * Math.sin((lon - circle.getCenter().lng()) * degrees);
zSphere = rSphere * Math.sin(lat * degrees);
var x = -ySphere/circle.getRadius();
var y = (zSphere*cosLat - xSphere*sinLat)/circle.getRadius();
var z = 0;
return new THREE.Vector3(x, y, z);
}
function labelBox(cardinal, radius, root)
{
this.screenvector = new THREE.Vector3(0,0,0);
this.labelID = 'MovingLabel'+ cardinal.ID;
this.position = convertlatlonToVec3(cardinal.lat, cardinal.lon).multiplyScalar(radius);
}