/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../chunks/vec4f64","../../../geometry/support/aaBoundingBox","../../../geometry/support/buffer/BufferPool","../support/buffer/InterleavedLayout","./TerrainConst","./terrainUtils","../webgl-engine/lib/VertexAttribute"],(function(t,e,i,s,u,n,r,f){"use strict";let o=function(){this.indices=null,this.vertexAttributes=null,this.boundingBox=i.empty(),this.indexCount=0,this.numVerticesPerSide=0,this.uvOffsetAndScale=e.create(),this.outerEdges=[null,null,null,null],this.innerEdges=[null,null,null,null]},h=function(){function t(t,e,i,s,u){this._buf=t,this._localOrigin=e,this.offset0=i,this.stride=s,this.count=u}var e=t.prototype;return e.getVertexOffset=function(t){return r.internalAssert(0<=t&&t<this.count),this.offset0+this.stride*t},e.getVertex=function(t,e){const i=this.getVertexOffset(e)*n.GEOMETRY_VERTEX_STRIDE;t[0]=this._buf[i+0]+this._localOrigin[0],t[1]=this._buf[i+1]+this._localOrigin[1],t[2]=this._buf[i+2]+this._localOrigin[2]},e.getVertexZ=function(t){const e=this.getVertexOffset(t)*n.GEOMETRY_VERTEX_STRIDE;return this._buf[e+2]+this._localOrigin[2]},e.setVertex=function(t,e,i,s){const u=this.getVertexOffset(t)*n.GEOMETRY_VERTEX_STRIDE;this._buf[u+0]=e[0]-this._localOrigin[0],this._buf[u+1]=e[1]-this._localOrigin[1],this._buf[u+2]=e[2]-this._localOrigin[2],this._buf[u+3]=i,this._buf[u+4]=s},e.getNormal=function(t,e){const i=this.getVertexOffset(e)*n.GEOMETRY_VERTEX_STRIDE;t[0]=this._buf[i+5],t[1]=this._buf[i+6],t[2]=this._buf[i+7]},e.setVertexRawXYZUV=function(t,e,i,s,u,r){const f=this.getVertexOffset(t)*n.GEOMETRY_VERTEX_STRIDE;this._buf[f+0]=e,this._buf[f+1]=i,this._buf[f+2]=s,this._buf[f+3]=u,this._buf[f+4]=r},e.setVertexRawXYZUVN=function(t,e,i,s,u,r,f,o,h){const l=this.getVertexOffset(t)*n.GEOMETRY_VERTEX_STRIDE;this._buf[l+0]=e,this._buf[l+1]=i,this._buf[l+2]=s,this._buf[l+3]=u,this._buf[l+4]=r,this._buf[l+5]=f,this._buf[l+6]=o,this._buf[l+7]=h},e.setVertexRawNormal=function(t,e,i,s){const u=this.getVertexOffset(t)*n.GEOMETRY_VERTEX_STRIDE;this._buf[u+5]=e,this._buf[u+6]=i,this._buf[u+7]=s},e.getVertexRawNormal=function(t,e){const i=this.getVertexOffset(e)*n.GEOMETRY_VERTEX_STRIDE;t[0]=this._buf[i+5],t[1]=this._buf[i+6],t[2]=this._buf[i+7]},t}();const l=u.newLayout().vec3f(f.VertexAttribute.POSITION).vec2f(f.VertexAttribute.UV0).vec3f(f.VertexAttribute.NORMAL),_=new s.BufferPool((t=>l.createBuffer(t)),(t=>t.count));function c(){_.clear()}function b(t){return _.acquire(t)}function E(t){_.release(t.vertexAttributes),t.vertexAttributes=null,t.indices=null}t.EdgeDescriptor=h,t.PatchGeometry=o,t.acquireTerrainAttributes=b,t.clearCaches=c,t.releaseGeometry=E,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
