/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{clamp as t}from"../../../../core/mathUtils.js";import{t as r,n as o}from"../../../../chunks/vec32.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newFloatArray as a}from"../../../../geometry/support/FloatArray.js";import{newShortArray as s}from"../../../../geometry/support/ShortArray.js";function e(t,r,o,n,a,s=2){const e=1/(Math.abs(o)+Math.abs(n)+Math.abs(a)),c=o*e,f=n*e,u=a<=0?(c>=0?1:-1)*(1-Math.abs(f)):c,h=a<=0?(f>=0?1:-1)*(1-Math.abs(c)):f,m=r*s;t[m]=i(u),t[m+1]=i(h)}function c(t){const r=t.length/3,o=s(2*r);let n=0;for(let a=0;a<r;++a)e(o,a,t[n++],t[n++],t[n++]);return o}function f(t,o){const a=t.length/3,s=new Int16Array(2*a);let c=0;const f=n();for(let n=0;n<a;++n)f[0]=t[c++],f[1]=t[c++],f[2]=t[c++],r(f,f,o),e(s,n,f[0],f[1],f[2]);return s}function u(t,r,n,a=2){const s=n*a,e=m(r[s]),c=m(r[s+1]),f=1-Math.abs(e)-Math.abs(c);return t[2]=f,f<0?(t[0]=(e>=0?1:-1)*(1-Math.abs(c)),t[1]=(c>=0?1:-1)*(1-Math.abs(e))):(t[0]=e,t[1]=c),o(t,t)}function h(t,r=2){const o=t.length/r,s=a(3*o),e=n();let c=0;for(let n=0;n<o;++n)u(e,t,n,r),s[c++]=e[0],s[c++]=e[1],s[c++]=e[2];return s}function i(r){return t(Math.round(32767*r),-32767,32767)}function m(r){return t(r/32767,-1,1)}export{f as compressAndTransformNormals,e as compressNormal,c as compressNormals,m as decodeInt16,u as decompressNormal,h as decompressNormals,i as encodeInt16};
