/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{clone as e}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{clone as t}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{BufferViewUint16 as n,BufferViewUint32 as o,BufferViewVec3f as i,BufferViewVec3u8 as r,BufferViewVec3u16 as a,BufferViewVec4f as s,BufferViewVec4u8 as f,BufferViewVec4u16 as u}from"../../../geometry/support/buffer/BufferView.js";import{processTiles3DVertices as l}from"./support/IntegratedMesh3DTilesVertexProcessing.js";function c(){}function d(e){const{colorData:t,colorElementCount:n}=e;if(null==t||0===n)return;const o=t.byteOffset,l=o+t.byteLength;return 3===n?t instanceof Float32Array?new i(t.buffer,o,void 0,l):t instanceof Uint8Array?new r(t.buffer,o,void 0,l):new a(t.buffer,o,void 0,l):t instanceof Float32Array?new s(t.buffer,o,void 0,l):t instanceof Uint8Array?new f(t.buffer,o,void 0,l):new u(t.buffer,o,void 0,l)}function b(e){return e.map((e,t)=>{const{indicesData:r}=e,a=e.positionData.byteOffset,s=a+e.positionData.byteLength,f=e.positionStride*Float32Array.BYTES_PER_ELEMENT,u=r.byteOffset,l=u+r.byteLength;return{componentIndex:t,positionView:new i(e.positionData.buffer,a,f,s),indicesView:r instanceof Uint16Array?new n(r.buffer,u,void 0,l):new o(r.buffer,u,void 0,l),texCoord0Data:e.texCoord0Data??void 0,colorView:d(e),normalsData:e.normalsData??void 0}})}function p(e,t){return e.map(e=>({positionData:t?e.positionView.typedBuffer:null,interleavedVertexData:e.interleavedVertexData,renderIndices:e.indices===e.indicesView.typedBuffer?null:e.indices}))}function m(e){const t=[];for(const n of e)null!=n.positionData&&t.push(n.positionData.buffer),t.push(n.interleavedVertexData),null!=n.renderIndices&&t.push(n.renderIndices.buffer);return t}async function v(n){const o={center:t(n.tileObbCenter),quaternionConjugate:e(n.tileObbQuaternionConjugate)},{vertexProcessingOutputs:i,obbHalfSizeAccumulator:r,elevationRange:a}=l(b(n.inputs),n.origin,n.ellipsoidRadius,n.isGlobal,n.ecefRotation,o,n.imVertexNormals),s=p(i,n.isGlobal),f=m(s);return{result:{outputs:s,obbHalfSizeAccumulator:t(r),minElevation:a.minElevation,maxElevation:a.maxElevation},transferList:f}}function y(e){}export{y as destroyContext,c as initialize,v as processVertices};
