diff --git a/lookAt.glsl b/lookAt.glsl new file mode 100644 index 0000000..2b1d09d --- /dev/null +++ b/lookAt.glsl @@ -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)