/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{h as o,e as n,f as t,n as s}from"../../../../../chunks/vec32.js";import{create as e}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";function r(o,n){if(o.components)for(const t of o.components)t.faces&&"smooth"===t.shading&&c(t.faces,n)}function c(e,r){null==r.normal&&(r.normal=new Float32Array(r.position.length));const{position:c,normal:m}=r,h=e.length/3;for(let s=0;s<h;++s){const r=3*e[3*s],l=3*e[3*s+1],h=3*e[3*s+2],p=o(a,c[r],c[r+1],c[r+2]),g=o(f,c[l],c[l+1],c[l+2]),u=o(i,c[h],c[h+1],c[h+2]),j=n(g,g,p),v=n(u,u,p),x=t(j,j,v);m[r]+=x[0],m[r+1]+=x[1],m[r+2]+=x[2],m[l]+=x[0],m[l+1]+=x[1],m[l+2]+=x[2],m[h]+=x[0],m[h+1]+=x[1],m[h+2]+=x[2]}for(let n=0;n<m.length;n+=3)o(l,m[n],m[n+1],m[n+2]),s(l,l),m[n]=l[0],m[n+1]=l[1],m[n+2]=l[2]}const a=e(),f=e(),i=e(),l=e();export{r as smoothNormals};
