camera-project
project 3D point into 2D window space
Last updated 12 years ago by mattdesl .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install camera-project 
SYNC missed versions from official npm registry.

camera-project

stable

Projects a 3D world point into 2D window space.

var mat4 = require('gl-mat4')
var project = require('camera-project')

//projection * view matrix
var combinedProjView = mat4.multiply([], projection, view)

//viewport bounds
var viewport = [x, y, width, height]

//3D world point
var point = [0, -1, 2.5]

//vec4 output
var output = []

project(output, point, viewport, combinedProjView)

The output z component contains the window space depth, and w is the value of (1 / clip.w). Assumes depth range is 0 to 1.

Usage

NPM

vec4 = project(out, point, viewport, combined)

Projects the 3D point into window space using the viewport bounds (screen x, y, width, height) and combined matrix (result of multiplying projection * view matrices).

The result is stored in out and returned.

See Also

License

MIT, see LICENSE.md for details.

Current Tags

  • 1.0.2                                ...           latest (12 years ago)

3 Versions

  • 1.0.2                                ...           12 years ago
  • 1.0.1                                ...           12 years ago
  • 1.0.0                                ...           12 years ago
Maintainers (1)
Downloads
Total 12
Today 0
This Week 1
This Month 5
Last Day 1
Last Week 1
Last Month 0
Dependencies (1)
Dev Dependencies (4)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE