I’ve got a maths question, I am trying to work out how to tween a point away from a sphere centre. I know the sphere x,y,z position, the point’s x1,y1,z1 position and the distance the point should travel, is it possible to work out its new x2,y2,z2 coordinates from those values?
Something like that:
var point = new THREE.Vector3(10, 11, 12); var distance = 8; var direction = point.clone().normalize(); var pointNew = point.clone().addScaledVector(direction, distance); // your new point
I would say this is only true if the center of the sphere is the origin. The correct calculation of the direction vector is:
direction.subVectors( pointOnSphere, sphere.center ).normalize();
Thank you, much appreciated, both options work for me, and good to know how to handle cases when the origin is not centre. I thought I’d need some complicated maths to do that, seems like three.js is taking care of that : )