/*
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/_rollupPluginBabelHelpers","../../../support/buffer/glUtil","../DefaultVertexAttributeLocations","../GLMaterials","../Intersector","../IntersectorInterfaces","../../../../webgl/BufferObject","../../../../webgl/enums","../../../../webgl/VertexArrayObject"],(function(e,t,r,s,n,o,i,a,l,u){"use strict";let f=function(){function e(e,t){const o=e.renderContext.rctx,{geometry:i,material:f}=t;this._materialRepository=e.materialRep,f.setParameters({instancedDoublePrecision:!0});const m=f.createBufferWriter(),c=m.vertexBufferLayout,d=m.elementCount(i),y=m.allocate(d);m.write({},i,y,0),this.geometry=i,this.material=f,this.glMaterials=new n.GLMaterials(f,this._materialRepository),this.vertexBufferLayout=c,this.vbo=a.BufferObject.createVertex(o,l.Usage.STATIC_DRAW,y.buffer),this.vao=new u.VertexArrayObject(o,s.Default3D,{geometry:r.glLayout(c)},{geometry:this.vbo}),this.vertexCount=d}var f=e.prototype;return f.destroy=function(){this.glMaterials.destroy(),this.vbo.dispose(),this.vao.dispose()},f.intersect=function(e,t,r,s,n,a,l,u){const f=this.geometry.id;this.material.intersect(this.geometry,null,e.transform.transform,e,r,s,((r,s,m,c,d)=>{if(r>=0){if(null!=t&&!t(e.rayBegin,e.rayEnd,r))return;const c={layerUid:a.layerUid,graphicUid:a.graphicUid(n),geometryId:f,triangleNr:m,baseBoundingSphere:l,numLodLevels:u};if((null==e.results.min.drapedLayerOrder||d>=e.results.min.drapedLayerOrder)&&(null==e.results.min.dist||r<e.results.min.dist)&&e.results.min.set(i.IntersectorType.LOD,c,r,s,e.transform.transform,d),e.options.store!==i.StoreResults.MIN&&(null==e.results.max.drapedLayerOrder||d>=e.results.max.drapedLayerOrder)&&(null==e.results.max.dist||r>e.results.max.dist)&&e.results.max.set(i.IntersectorType.LOD,c,r,s,e.transform.transform,d),e.options.store===i.StoreResults.ALL){const t=o.newIntersectorResult(e.results.min.ray);t.set(i.IntersectorType.LOD,c,r,s,e.transform.transform,d),e.results.all.push(t)}}}))},t._createClass(e,[{key:"boundingInfo",get:function(){return this.geometry.boundingInfo}},{key:"triangleCount",get:function(){return this.vertexCount/3}}]),e}();e.LodComponentData=f,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
