SetRaycaster sets the specified raycaster with this camera position in world coordinates pointing to the direction defined by the specified coordinates unprojected using this camera.
(cam *camera.Camera, sx, sy float32)
| 132 | // SetRaycaster sets the specified raycaster with this camera position in world coordinates |
| 133 | // pointing to the direction defined by the specified coordinates unprojected using this camera. |
| 134 | func (rc *Raycaster) SetFromCamera(cam *camera.Camera, sx, sy float32) error { // TODO maybe use ICamera |
| 135 | |
| 136 | var origin, direction math32.Vector3 |
| 137 | matrixWorld := cam.MatrixWorld() |
| 138 | origin.SetFromMatrixPosition(&matrixWorld) |
| 139 | direction.Set(sx, sy, 0.5) |
| 140 | |
| 141 | unproj := cam.Unproject(&direction) // unproj = direction after this point TODO improve clarity |
| 142 | unproj.Sub(&origin).Normalize() |
| 143 | rc.Set(&origin, &direction) |
| 144 | cam.ViewMatrix(&rc.ViewMatrix) // Update the view matrix of the raycaster |
| 145 | return nil |
| 146 | } |
| 147 | |
| 148 | // RaycastSprite checks intersections between the raycaster and the specified sprite |
| 149 | // and if any found appends it to the specified intersects array. |
nothing calls this directly
no test coverage detected