Udostępnij za pośrednictwem


Why did we change LookAtPoint to LookDirection?

Ernie posted about the differences between the old LookAtPoint property and the new LookDirection property on ProjectionCamera (via KarstenJ.)  The quick summary is that LookAtPoint caused the camera to look at a fixed point in space (Figure 1a).  The new LookDirection property causes the camera to look in a fixed direction (Figure 1b).

 

LookDirection-1

LookDirection-2

Figure 1a

When the camera’s position moves from point A to point B it is automatically re-orientated so that the LookAtPoint remains centered in its view.

Figure 1b

When the camera’s position moves from point A to point B it continues to face in the direction specified by the LookDirection.

 

In terms of the camera configurations that can be represented the two properties are equally expressive.  It is easy to convert between the two using the following equation:

 

LookDirection = LookAtPoint - Position

However, there are some pragmatic advantages to choosing LookDirection.  One is that LookDirection is similar to other properties in the system (e.g., SpotLight.Direction.)  Another is that LookAtPoint leads to a common misunderstanding that the camera can be rotated by simply updating the camera’s position.  Unless you also transform the UpDirection this will lead to (usually) unexpected flipping behavior at the poles.

 

It was the addition of Camera.Transform, however, that was the largest motivation to switch to LookDirection.  Being able to apply Transform3Ds to Cameras simplifies a lot of animation scenarios.  In fact, it’s currently the only way to animate a MatrixCamera.  Also, the ability to share Transform3Ds between Cameras and nodes in the Visual tree enables scenarios where the Camera follows an object in the scene.  (Incidentally, this is how the headlight feature of the ModelViewer sample works.)

 

The addition of Camera.Transform raised questions about LookAtPoint.  Should LookAtPoint be affected by the transform or should it continue to be defined in world space?  If LookAtPoint is in world space, as most people initially suppose, it breaks the illusion that the camera is a physical object in the scene because rotating the camera 180 degrees does not necessarily mean that the camera is looking in the opposite direction since it will continue to look in the direction of the same fixed point in world space.

 

On the other hand, if the camera’s transform LookAtPoint is affected by the transform then users need to convert into the camera’s coordinate system to specify the LookAtPoint.  This is no less difficult than calculating the LookDirection and more error prone.

 

When all these things were considered: the difficulty in reconciling LookAtPoint with Camera.Transform, the fact that the perceived simplicity of LookAtPoint is negated by the need to handle the UpDirection, and that elsewhere in the system we have consistently specified orientation with direction vectors, we decided that in the long term our customers will be happier with LookDirection.