(wx: f64, wy: f64, wz: f64)
| 1752 | |
| 1753 | #[wasm_bindgen] |
| 1754 | pub fn bloom_project_to_screen(wx: f64, wy: f64, wz: f64) -> f64 { |
| 1755 | let eng = engine(); |
| 1756 | let vp = eng.renderer.vp_matrix(); |
| 1757 | let w = eng.renderer.width() as f32; |
| 1758 | let h = eng.renderer.height() as f32; |
| 1759 | |
| 1760 | let x = wx as f32; |
| 1761 | let y = wy as f32; |
| 1762 | let z = wz as f32; |
| 1763 | let clip_x = vp[0][0]*x + vp[1][0]*y + vp[2][0]*z + vp[3][0]; |
| 1764 | let clip_y = vp[0][1]*x + vp[1][1]*y + vp[2][1]*z + vp[3][1]; |
| 1765 | let clip_w = vp[0][3]*x + vp[1][3]*y + vp[2][3]*z + vp[3][3]; |
| 1766 | |
| 1767 | if clip_w <= 0.0 { |
| 1768 | unsafe { LAST_PROJECT = (-9999.0, -9999.0); } |
| 1769 | return -9999.0; |
| 1770 | } |
| 1771 | |
| 1772 | let ndc_x = clip_x / clip_w; |
| 1773 | let ndc_y = clip_y / clip_w; |
| 1774 | let screen_x = ((ndc_x + 1.0) * 0.5 * w) as f64; |
| 1775 | let screen_y = ((1.0 - ndc_y) * 0.5 * h) as f64; |
| 1776 | |
| 1777 | unsafe { LAST_PROJECT = (screen_x, screen_y); } |
| 1778 | screen_x |
| 1779 | } |
| 1780 | |
| 1781 | #[wasm_bindgen] |
| 1782 | pub fn bloom_project_screen_y() -> f64 { |
no test coverage detected