UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

8 lines (7 loc) 1.33 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{set as r}from"../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as o}from"../../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{s as t}from"../../../../../../chunks/vec42.js";import{create as e}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{Float2BindUniform as i}from"../../shaderModules/Float2BindUniform.js";import{Float4BindUniform as a}from"../../shaderModules/Float4BindUniform.js";import{glsl as s}from"../../shaderModules/glsl.js";function f(r){r.fragment.uniforms.add(new a("projInfo",(r=>n(r.camera)))),r.fragment.uniforms.add(new i("zScale",(r=>m(r.camera)))),r.fragment.code.add(s`vec3 reconstructPosition(vec2 fragCoord, float depth) { return vec3((fragCoord * projInfo.xy + projInfo.zw) * (zScale.x * depth + zScale.y), depth); }`)}function n(r){const o=r.projectionMatrix;return 0===o[11]?t(c,2/(r.fullWidth*o[0]),2/(r.fullHeight*o[5]),(1+o[12])/o[0],(1+o[13])/o[5]):t(c,-2/(r.fullWidth*o[0]),-2/(r.fullHeight*o[5]),(1-o[8])/o[0],(1-o[9])/o[5])}const c=e();function m(o){return 0===o.projectionMatrix[11]?r(l,0,1):r(l,1,0)}const l=o();export{f as CameraSpace,n as getProjectionInfo,m as getZScale};