added a new function lookAt.

This commit is contained in:
yoichi kobayashi 2018-01-11 17:17:30 +09:00
parent a4836d5854
commit 037746bee6

10
lookAt.glsl Normal file
View File

@ -0,0 +1,10 @@
#pragma glslify: rotateAxisAngle = require(./rotateAxisAngle);
vec3 lookAt(vec3 base, vec3 p1, vec3 p2, vec3 up) {
vec3 diff = normalize(p2 - p1);
float d = dot(diff, up);
vec3 c = cross(p1, p2);
float a = acos(d);
return rotateAxisAngle(base, c, a);
}
#pragma glslify: export(lookAt)