UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 2.03 kB
import{glLayout as t}from"../../../support/buffer/glUtil.js";import{Default3D as r}from"../DefaultVertexAttributeLocations.js";import{GLMaterials as e}from"../GLMaterials.js";import{newIntersectorResult as s}from"../Intersector.js";import{IntersectorType as o,StoreResults as i}from"../IntersectorInterfaces.js";import{VertexArrayObject as a}from"../VertexArrayObject.js";import{LodTarget as n}from"./Intersector.js";import{BufferObject as m}from"../../../../webgl/BufferObject.js";import{Usage as l}from"../../../../webgl/enums.js";class u{constructor(s,o){const i=s.renderContext.rctx,n=o.geometry;this._materialRepository=s.materialRepository,n.material.setParameters({instancedDoublePrecision:!0});const u=n.material.createBufferWriter(),f=u.vertexBufferLayout,d=u.elementCount(n),p=u.allocate(d);u.write(null,null,n,p,0),this.geometry=n,this.material=n.material,this.glMaterials=new e(n.material,this._materialRepository),this.vertexBufferLayout=f,this.vbo=m.createVertex(i,l.STATIC_DRAW,p.buffer),this.vao=new a(i,r,{geometry:t(f)},{geometry:this.vbo}),this.vertexCount=d}destroy(){this.glMaterials.destroy(),this.vbo.dispose(),this.vao.dispose()}get boundingInfo(){return this.geometry.boundingInfo}get triangleCount(){return this.vertexCount/3}intersect(t,r,e,a,m,l,u,f){const d=this.geometry.id;this.material.intersect(this.geometry,t.transform.transform,t,e,a,((e,a,p,c,y)=>{if(e>=0){if(null!=r&&!r(t.rayBegin,t.rayEnd,e))return;const c=new n(l.layerUid,l.graphicUid(m),d,p,u,f);if((null==t.results.min.drapedLayerOrder||y>=t.results.min.drapedLayerOrder)&&(null==t.results.min.dist||e<t.results.min.dist)&&t.results.min.set(o.LOD,c,e,a,t.transform.transform,y),t.options.store!==i.MIN&&(null==t.results.max.drapedLayerOrder||y>=t.results.max.drapedLayerOrder)&&(null==t.results.max.dist||e>t.results.max.dist)&&t.results.max.set(o.LOD,c,e,a,t.transform.transform,y),t.options.store===i.ALL){const r=s(t.results.min.ray);r.set(o.LOD,c,e,a,t.transform.transform,y),t.results.all.push(r)}}}))}}export{u as LodComponentData};