Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A Javascript port of the standard gluUnProject function used for mapping window coordinates to object coordinates.
JavaScript
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
GLU.js Fixed up some jsdoc and formatting.
README.md Added reference to working example.

README.md

WebGL Unproject

This is a port of the usual gluUnProject function to javascript for use in WebGL applications. To use, read the included JSDoc for the unProject function -- it closely matches the API for the common C variant of the same function.

This code was originally written for picking support in Lanyard (http://github.com/fintler/lanyard). See lanyard.BasicOrbitView for a working example.

Simple Example

var viewportArray = [
    viewportOriginX, viewportOriginY, viewportWidth, viewportHeight
];

// The results of the operation will be stored in this array.
var modelPointArrayResults = [];

var success = GLU.unProject(
    windowPointX, windowPointY, windowPointZ,
    modelViewMatrix, projectionMatrix,
    viewportArray, modelPointArrayResults);

modelPointArrayResults[0] = <'x' model coordinate value>
modelPointArrayResults[1] = <'y' model coordinate value>
modelPointArrayResults[2] = <'z' model coordinate value>
Something went wrong with that request. Please try again.