UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 964 B
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{i as o,d as n,e 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,p=e.length/3;for(let s=0;s<p;++s){const r=3*e[3*s],l=3*e[3*s+1],p=3*e[3*s+2],h=o(a,c[r],c[r+1],c[r+2]),g=o(i,c[l],c[l+1],c[l+2]),u=o(f,c[p],c[p+1],c[p+2]),d=n(g,g,h),j=n(u,u,h),v=t(d,d,j);m[r]+=v[0],m[r+1]+=v[1],m[r+2]+=v[2],m[l]+=v[0],m[l+1]+=v[1],m[l+2]+=v[2],m[p]+=v[0],m[p+1]+=v[1],m[p+2]+=v[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(),i=e(),f=e(),l=e();export{r as smoothNormals};