@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 3.21 kB
JavaScript
import{isSome as e}from"../../../../core/maybe.js";import{f as t}from"../../../../chunks/vec2f32.js";import{Z as r}from"../../../../chunks/vec2f64.js";import{newLayout as i}from"../../support/buffer/InterleavedLayout.js";import{ShaderOutput as s}from"../core/shaderLibrary/ShaderOutput.js";import{HUDSpace as n}from"../core/shaderLibrary/hud/HUD.glsl.js";import a from"../lib/GLMaterial.js";import{Material as o,MaterialParameters as u}from"../lib/Material.js";import{RenderSlot as c}from"../lib/RenderSlot.js";import{VertexAttribute as f}from"../lib/VertexAttribute.js";import{writePosition as l,writeNormal as h,writeBufferVec4 as d}from"./internal/bufferWriterUtils.js";import{LineCalloutTechnique as m}from"../shaders/LineCalloutTechnique.js";import{LineCalloutTechniqueConfiguration as p}from"../shaders/LineCalloutTechniqueConfiguration.js";class g extends o{get uniqueMaterialIdentifier(){return this._uniqueMaterialIdentifier}constructor(e){super(e,new S),this._configuration=new p,this._uniqueMaterialIdentifier=g.uniqueMaterialIdentifier(this.parameters)}getPassParameters(){return this.parameters}getConfiguration(t,r){const i=r?.slot!==c.LINE_CALLOUTS;return this._configuration.occlusionTestEnabled=this.parameters.occlusionTest,this._configuration.hasVerticalOffset=e(this.parameters.verticalOffset),this._configuration.hasScreenSizePerspective=e(this.parameters.screenSizePerspective),this._configuration.depthHudEnabled=i,this._configuration.depthHudAlignStartEnabled=!!this.parameters.depthHUDAlignStart,this._configuration.screenCenterOffsetUnitsEnabled="screen"===this.parameters.centerOffsetUnits?n.Screen:n.World,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasMultipassGeometry=r.multipassGeometry.enabled,this._configuration}intersect(){}requiresSlot(e,t){if(t===s.Color)switch(e){case c.LINE_CALLOUTS:case c.LINE_CALLOUTS_HUD_DEPTH:return!0}return!1}createGLMaterial(e){return new O(e)}createBufferWriter(){return new b}validateParameters(e){const t=g.uniqueMaterialIdentifier(e);t!==this._uniqueMaterialIdentifier&&(this._uniqueMaterialIdentifier=t)}static uniqueMaterialIdentifier(e){return JSON.stringify({screenOffset:e.screenOffset||[0,0],centerOffsetUnits:e.centerOffsetUnits||"world"})}}class O extends a{beginSlot(e){return this.ensureTechnique(m,e)}}class S extends u{constructor(){super(...arguments),this.screenOffset=r,this.color=[0,0,0,1],this.size=1,this.occlusionTest=!1,this.shaderPolygonOffset=1e-5,this.depthHUDAlignStart=!1,this.centerOffsetUnits="world",this.hasSlicePlane=!1}}const L=i().vec3f(f.POSITION).vec3f(f.NORMAL).vec2f(f.UV0).vec4f(f.AUXPOS1),I=[t(0,0),t(1,0),t(0,1),t(1,0),t(1,1),t(0,1)];class b{constructor(){this.vertexBufferLayout=L}allocate(e){return this.vertexBufferLayout.createBuffer(e)}elementCount(e){return 6*e.indices.get(f.POSITION).length}write(e,t,r,i,s){l(r.indices.get(f.POSITION),r.vertexAttributes.get(f.POSITION).data,e,i.position,s,6),h(r.indices.get(f.NORMAL),r.vertexAttributes.get(f.NORMAL).data,t,i.normal,s,6),d(r.indices.get(f.AUXPOS1),r.vertexAttributes.get(f.AUXPOS1).data,i.auxpos1,s,6);for(let n=0;n<I.length;++n)i.uv0.setVec(s+n,I[n])}}export{g as LineCalloutMaterial,S as Parameters};