Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

camera-unproject

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

camera-unproject

unproject 2D point to 3D coordinate

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.8K
increased by48.79%
Maintainers
1
Weekly downloads
 
Created
Source

camera-unproject

stable

Unprojects a 2D screen space point into 3D space using the inverse of your camera's combined matrix.

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

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

//now invert it
var invProjView = mat4.invert([], combinedProjView)

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

//2D point in screen space
//z=0 means "near plane"
var point = [123, 52, 0]

//vec3 output
var output = []

unproject(output, point, viewport, invProjView)

Usage

NPM

vec3 unproject(out, point, viewport, invCombined)

Unprojects the 2D point into 3D space using the viewport bounds (screen x, y, width, height) and invCombined matrix.

Where point [x, y, z] uses window coordinates for XY and a range between 0.0 (near plane) and 1.0 (far plane) for Z. invCombined is typically the invert of the combined projection * view matrix for your camera.

The [x, y, z] result is stored in out and returned.

See Also

License

MIT, see LICENSE.md for details.

Keywords

FAQs

Package last updated on 14 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc