/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{set as o,subtract as t,cross as n,normalize as r}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as s}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";function e(o,t){if(o.components)for(const n of o.components)n.faces&&"smooth"===n.shading&&c(n.faces,t)}function c(s,e){null==e.normal&&(e.normal=new Float32Array(e.position.length));const{position:c,normal:a}=e,p=s.length/3;for(let r=0;r<p;++r){const e=3*s[3*r],m=3*s[3*r+1],p=3*s[3*r+2],g=o(i,c[e],c[e+1],c[e+2]),h=o(l,c[m],c[m+1],c[m+2]),u=o(f,c[p],c[p+1],c[p+2]),x=t(h,h,g),b=t(u,u,g),j=n(x,x,b);a[e]+=j[0],a[e+1]+=j[1],a[e+2]+=j[2],a[m]+=j[0],a[m+1]+=j[1],a[m+2]+=j[2],a[p]+=j[0],a[p+1]+=j[1],a[p+2]+=j[2]}for(let t=0;t<a.length;t+=3)o(m,a[t],a[t+1],a[t+2]),r(m,m),a[t]=m[0],a[t+1]=m[1],a[t+2]=m[2]}const i=s(),l=s(),f=s(),m=s();export{e as smoothNormals};
