@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.32 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{releaseMaybe as t}from"../../../core/maybe.js";import{g as e}from"../../../chunks/vec32.js";import{empty as s}from"../../../geometry/support/aaBoundingBox.js";import{internalAssert as i}from"./terrainUtils.js";import{decompressNormal as r,compressNormal as n}from"../webgl-engine/lib/Normals.js";class o{constructor(){this.indices=null,this.indexCount=0,this.edgeIndicesStartIndex=0,this.poleIndicesStartIndex=0,this.vertexAttributes=null,this.edgeVerticesStartIndex=0,this.poleVerticesStartIndex=0,this.maxEdgeVertexCount=0,this.boundingBox=s(),this.numVerticesPerSide=0,this.minu=0,this.minv=0,this.maxu=1,this.maxv=1,this.outerEdgesOffsetAndLength=[0,0,0,0,0,0,0,0]}release(){this.vertexAttributes=t(this.vertexAttributes),this.indices=null}reset(){this.indices=null,this.vertexAttributes=null,s(this.boundingBox),this.numVerticesPerSide=0}getEdgeFirstVertexIndex(t){return this.outerEdgesOffsetAndLength[2*t]}getEdgeCount(t){return this.outerEdgesOffsetAndLength[2*t+1]}getEdgeVertexIndex(t,e){return this.getEdgeAttributeIndex(t,e)}getEdgeVertexPosition(t,s,i,r){this._getEdgeVertexRaw(this.getEdgeAttributeIndex(t,r),s),e(s,s,i)}getEdgeNormal(t,e,s){const{typedBuffer:i,typedBufferStride:n}=this.vertexAttributes.normalCompressed;r(e,i,this.getEdgeAttributeIndex(t,s),n)}setEdgeNormalFromValues(t,e,s,i,r){this._setNormal(this.getEdgeAttributeIndex(t,e),s,i,r)}setEdgeVertexFromValuesRawPositionUV(t,e,s,i,r,n,o){const d=this.getEdgeAttributeIndex(t,e);this.vertexAttributes.position.setValues(d,s,i,r),this._setUV(d,n,o)}setEdgeVertexFromValuesRawPositionUVNormal(t,e,s,i,r,n,o,d,u,g){const h=this.getEdgeAttributeIndex(t,e);this.vertexAttributes.position.setValues(h,s,i,r),this._setUV(h,n,o),this._setNormal(h,d,u,g)}_getEdgeVertexRaw(t,e){this.vertexAttributes.position.getVec(t,e)}_setNormal(t,e,s,i){const{typedBuffer:r,typedBufferStride:o}=this.vertexAttributes.normalCompressed;n(r,t,e,s,i,o)}_setUV(t,e,s){u(this.vertexAttributes.uv0,t,e,s)}getEdgeAttributeIndex(t,e){return i(0<=e&&e<this.getEdgeCount(t)),this.getEdgeFirstVertexIndex(t)+e}}const d=16384;function u(t,e,s,i){t.setValues(e,s*d,i*d)}export{o as PatchGeometry,u as encodeUVInBuffer};