LookAt - Interactive 3D Graphics

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

I think an example with hand calculations will help.

Assume the hawk's head (camera) at 2:18 is at point_a=(0, 1, 1).

The up vector is <0, 0, -1>.

The lookAt is a point point_b=(0, 0, 1). The direction_vector is point_b-point_a=<0, -1, 0>. For a camera object, the direction_vector defines the direction of the camera's -z axis.

The +x axis of the camera is the cross product defined by x_axis_vector = direction_vector X up. In this case, x_axis_vector = <0, -1, 0> X <0, 0, -1> = <1, 0, 0>. y_axis_vector = x_axis_vector X direction_vector = <1, 0, 0> X <0, -1, 0> = <0, 0, -1>.

For a camera object, the direction vector defines the -z axis, but for an Object3D object, the direction vector defines the +z axis. The cross products for Object3D() are

x_axis_vector = up X direction_vector
y_axis_vector = direction_vector X x_axis_vector

Always define .up before .lookAt AND after, run either .updateProjectionMatrix for camera objects and updateMatrixWorld() for Object3D objects.

I will add another comment with some JavaScript as an example. This may or may not work if YouTube's comment system filters out JS code.

chrisa
Автор

I suggest watching 3b1b's essence of linear algreba series to understand matrix transformation. It is so clear and consise. I was able to create my own view matrix without libraries (such as GLMatrix).

xylxylxylxyl
Автор

In the hawk example, why isn't the look at vector -y and the up vector -z?

snoowwe
Автор

i didn't understand the up Vector why it exist how would it help plz reply

مبارياتالعضماء