UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 2.33 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{releaseMaybe as t}from"../../../core/maybe.js";import{maxUint16 as e}from"../../../core/typedArrayUtil.js";import{f as s}from"../../../chunks/vec32.js";import{empty as i}from"../../../geometry/support/aaBoundingBox.js";import{internalAssert as r}from"./terrainUtils.js";import{decompressNormal as n,compressNormal as o}from"../webgl-engine/lib/Normals.js";class d{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=i(),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,i(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,e,i,r){this._getEdgeVertexRaw(this.getEdgeAttributeIndex(t,r),e),s(e,e,i)}getEdgeNormal(t,e,s){const{typedBuffer:i,typedBufferStride:r}=this.vertexAttributes.normalCompressed;n(e,i,this.getEdgeAttributeIndex(t,s),r)}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:n}=this.vertexAttributes.normalCompressed;o(r,t,e,s,i,n)}_setUV(t,s,i){this.vertexAttributes.uv0.setValues(t,Math.round(s*e),Math.round(i*e))}getEdgeAttributeIndex(t,e){return r(0<=e&&e<this.getEdgeCount(t)),this.getEdgeFirstVertexIndex(t)+e}}export{d as PatchGeometry};