/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{deg2rad as t}from"../../../core/mathUtils.js";import r from"../../../layers/support/PixelBlock.js";function e({distance:r,yaw:e,horizontalFieldOfView:n,pitch:o,verticalFieldOfView:i,origin:s=[0,0,0],positionLength:a=25}){const f=a-1,l=a*a,c=new Float32Array(2*l),u=new Float64Array(3*l),h=new Float32Array(3*l).fill(0),p=new Uint32Array(f**2*6);for(let w=0,m=0;w<l;w++){const l=Math.floor(w/a),g=w%a,y=1-g/f,A=l/f,b=2*w,d=3*w;c[b]=y,c[b+1]=A;const F=o+i/2-A*i,M=t(e-n/2+y*n),L=t(F),D=Math.sin(L),O=Math.cos(L),j=[D*Math.sin(M),Math.cos(M)*D,-O];u[d]=s[0]+r*j[0],u[d+1]=s[1]+r*j[1],u[d+2]=s[2]+r*j[2],h[d]=-j[0],h[d+1]=-j[1],h[d+2]=-j[2],l!==f&&g!==f&&(p[m++]=w,p[m++]=w+a,p[m++]=w+a+1,p[m++]=w,p[m++]=w+a+1,p[m++]=w+1)}return{result:{position:u,uv:c,normal:h,faces:p},transferList:[u.buffer,c.buffer,h.buffer,p?.buffer]}}function n(t){const e=r.fromJSON(t);e.premultiplyAlpha=!0;const n=e.getAsRGBA(),o=e.width,i=e.height,s=new ImageData(n,o,i);return{result:s,transferList:[s.data.buffer]}}function o({oldDistance:t,newDistance:r,position:e,origin:n=[0,0,0]}){const o=e.length/3;for(let i=0;i<o;i+=3){const o=3*i;e[o]=n[0]+(e[o]-n[0])*(r/t),e[o+1]=n[1]+(e[o+1]-n[1])*(r/t),e[o+2]=n[2]+(e[o+2]-n[2])*(r/t)}return{result:e,transferList:[e.buffer]}}export{n as convertPixelBlockToImageData,e as getFacesWithVertexAttributes,o as recomputePositions};
