UNPKG

playcanvas

Version:

Open-source WebGL/WebGPU 3D engine for the web

14 lines (13 loc) 335 B
var spherical_default = ` vec2 toSpherical(vec3 dir) { return vec2(dir.xz == vec2(0.0) ? 0.0 : atan(dir.x, dir.z), asin(dir.y)); } vec2 toSphericalUv(vec3 dir) { const float PI = 3.141592653589793; vec2 uv = toSpherical(dir) / vec2(PI * 2.0, PI) + 0.5; return vec2(uv.x, 1.0 - uv.y); } `; export { spherical_default as default };