/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{clamp as t}from"../../../../core/mathUtils.js";import{normalize as r}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newFloatArray as a}from"../../../../geometry/support/FloatArray.js";import{newShortArray as n}from"../../../../geometry/support/ShortArray.js";function s(t,r,o,a,n,s=2,e=0){const i=1/(Math.abs(o)+Math.abs(a)+Math.abs(n)),c=o*i,f=a*i,h=n<=0?(c>=0?1:-1)*(1-Math.abs(f)):c,u=n<=0?(f>=0?1:-1)*(1-Math.abs(c)):f,l=r*s+e;t[l]=m(h),t[l+1]=m(u)}function e(t,r){const o=t.length/3;r??=n(2*o);let a=0;for(let n=0;n<o;++n)s(r,n,t[a++],t[a++],t[a++]);return r}function i(t,o,a,n=2,s=0){const e=a*n+s,i=f(o[e]),c=f(o[e+1]),m=1-Math.abs(i)-Math.abs(c);return t[2]=m,m<0?(t[0]=(i>=0?1:-1)*(1-Math.abs(c)),t[1]=(c>=0?1:-1)*(1-Math.abs(i))):(t[0]=i,t[1]=c),r(t,t)}function c(t,r=2){const n=t.length/r,s=a(3*n),e=o();let c=0;for(let o=0;o<n;++o)i(e,t,o,r),s[c++]=e[0],s[c++]=e[1],s[c++]=e[2];return s}function m(r){return t(Math.round(32767*r),-32767,32767)}function f(r){return t(r/32767,-1,1)}export{s as compressNormal,e as compressNormals,f as decodeInt16,i as decompressNormal,c as decompressNormals,m as encodeInt16};
