MCPcopy
hub / github.com/g3n/engine / Unproject

Method Unproject

camera/camera.go:291–307  ·  view source on GitHub ↗

Unproject transforms the specified position from camera projected coordinates to world coordinates.

(v *math32.Vector3)

Source from the content-addressed store, hash-verified

289
290// Unproject transforms the specified position from camera projected coordinates to world coordinates.
291func (c *Camera) Unproject(v *math32.Vector3) *math32.Vector3 {
292
293 // Get inverted camera view matrix
294 invViewMat := c.MatrixWorld()
295
296 // Get inverted camera projection matrix
297 var invProjMat math32.Matrix4
298 c.ProjMatrix(&invProjMat)
299 err := invProjMat.GetInverse(&invProjMat)
300 if err != nil {
301 panic("Camera.Unproject: Couldn't invert matrix")
302 }
303
304 // Apply invViewMat * invProjMat to the provided vector
305 v.ApplyProjection(invViewMat.Multiply(&invProjMat))
306 return v
307}

Callers 1

SetFromCameraMethod · 0.80

Calls 5

ProjMatrixMethod · 0.95
GetInverseMethod · 0.95
MatrixWorldMethod · 0.80
ApplyProjectionMethod · 0.80
MultiplyMethod · 0.45

Tested by

no test coverage detected