https://github.com/bringhurst/webgl-unproject
A Javascript port of the standard gluUnProject function used for mapping window coordinates to object coordinates.
https://github.com/bringhurst/webgl-unproject
Last synced: about 1 year ago
JSON representation
A Javascript port of the standard gluUnProject function used for mapping window coordinates to object coordinates.
- Host: GitHub
- URL: https://github.com/bringhurst/webgl-unproject
- Owner: bringhurst
- Created: 2011-01-24T16:38:26.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2022-02-06T21:56:17.000Z (over 4 years ago)
- Last Synced: 2025-04-03T05:32:00.859Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 13
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
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
--------------
```js
const viewportArray = [
viewportOriginX, viewportOriginY, viewportWidth, viewportHeight
];
// The results of the operation will be stored in this array.
const modelPointArrayResults = [];
const 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>
```