1

I'm building a globe(sphere geometry) with set of predefined locations on geo-mapped and drawn as point(sphere geometry). I would like to focus(moving one location to another) those locations by rotating globe along y-axis. I tried the following code, seems not working for all locations.

location.geometry.computeBoundingBox();
var position = new THREE.Vector3();
position.subVectors( location.geometry.boundingBox.max, location.geometry.boundingBox.min );
position.multiplyScalar( 0.20 );
position.sub( location.geometry.boundingBox.min );
location.matrixWorld.multiplyVector3( position );
var point1 = scene.clone().position;
var point2 = position;
var distance = point1.distanceTo( point2 );
locationCollection.rotation.y = distance;

I think, I don't understand the concept enough. Hopefully, I will get some idea from the community.

Fiddle

Lee Taylor
  • 7,761
  • 16
  • 33
  • 49
senthanal
  • 548
  • 5
  • 9
  • Could you create a fiddle (jsfiddle.net) to show a working version of your code? – Lee Taylor Jul 04 '13 at 16:12
  • 1
    I have created fiddle. Bit more code. I have written some short comments for code blocks. Hopefully, it fulfils the purpose. Here follows the fiddle link, http://jsfiddle.net/senthanal/j7mda/25/ – senthanal Jul 05 '13 at 09:27

1 Answers1

2
var c = group.rotation.y;
var d = -b * (Math.PI / 180)%(2 * Math.PI);
var e = Math.PI / 2 * -1;
group.rotation.y = c % (2 * Math.PI);
group.rotation.x = a * (Math.PI / 180) % Math.PI;
group.rotation.y= d+e;

where a= latitude, b= longitude,group=Object3D(or sphere)

GK90
  • 31
  • 4