from-3d-to-2d 
Take a transformation matrix like you're used to constructing with WebGL, and
project arbitrary 3D points onto your 2D screen.
You can use this to take a point in your WebGL scene and get its onscreen
position on the canvas, e.g. to add DOM element overlays, or bootstrapping your
own canvas/SVG.
Usage

transform(out, position, matrix)
Given a 3-element array position
and a 16-element array matrix
, update
the out
array to contain your new 2D points – each of them ranging from 0 to
- For example:
var mat4 = require('gl-matrix').mat4
var camera = require('orbit-camera')()
var transform = require('from-3d-to-2d')
var projection = new Float32Array(16)
var view = new Float32Array(16)
var pvMatrix = new Float32Array(16)
var point = new Float32Array(2)
function render() {
camera.view(view)
mat4.perspective(projection
, Math.PI / 4
, canvas.width / canvas.height
, 0.00001
, 10000
)
mat4.mul(pvMatrix, projection, view)
transform(point, [0, 0, 0], pvMatrix)
var x = point[0]
var y = point[1]
}
See Also
License
MIT. See LICENSE.md for details.