glsl-look-at
Generate a 3D lookAt matrix in GLSL
Last updated 6 years ago by hughsk .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install glsl-look-at 
SYNC missed versions from official npm registry.

glsl-look-at

stable

Generates a 3D lookAt matrix in GLSL.

Usage

NPM

mat3 lookAt(vec3 origin, vec3 target, float roll)

Creates a mat3 matrix you can use to transform coordinates to look towards a given point, where:

  • origin is the position of the camera.
  • target is the position to look towards.
  • roll is the roll rotation of the camera.
#pragma glslify: lookAt = require('glsl-look-at')

uniform vec2 iResolution;

void main() {
  // Required bootstrap for a Shadertoy-style
  // raytracing scene:
  vec2 p  = (2.0*gl_FragCoord.xy-iResolution.xy)/iResolution.y;
  vec2 ro = vec3(3.5*sin(0.0),3.0,3.5*cos(0.0));
  vec2 ta = vec3(0.0,0.0,0.0);

  // ...

  mat3 camMat = lookAt(ro, ta, 0.0);
  vec3 rd = normalize(camMat * vec3(p, 2.0));

  // ...
}

Contributing

See stackgl/contributing for details.

License

MIT. See LICENSE.md for details.

Current Tags

  • 1.0.0                                ...           latest (6 years ago)

1 Versions

  • 1.0.0                                ...           6 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (9)

Copyright 2014 - 2016 © taobao.org |