mrdoob/three.js — Issue #1181: Shortcut for calculating distance to axis
Author: rudiedirkx
Created: 2012-01-25 00:21:12+00:00
State: open

I calculate distances to axes a lot. Not to a point, but to the axis. Like a map/flat distance. Don't know what it's called in 3D world.

Right now, I do that like this:

// for the Y axis
object.position.distanceTo(new THREE.Vector3(0, object.position.y, 0))

If the target isn't the axis of the object's parent:

object.position.distanceTo(target.position.clone().setY(object.position.y))

again for the Y axis.

1. Is there a better way?
2. Is there a 'standard' / existing way?
3. If not: might it be an idea to include it?

`object.position.distanceToAxis('y', target.position);`

(ofcourse assuming they have the same parent or `target` is the parent)