UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 5.68 kB
import{isSome as e}from"../../../../core/maybe.js";import{s as t,F as r,m as a}from"../../../../chunks/vec3.js";import{c as s}from"../../../../chunks/vec3f64.js";import{newLayout as i}from"../../support/buffer/InterleavedLayout.js";import{ShaderOutput as n}from"../core/shaderLibrary/ShaderOutput.js";import{GLTextureMaterial as o}from"../lib/GLTextureMaterial.js";import{Material as h,RenderOccludedFlag as c}from"../lib/Material.js";import{RenderSlot as u}from"../lib/RenderSlot.js";import{VertexAttribute as l}from"../lib/VertexAttribute.js";import{VisualVariablePassParameters as p}from"./VisualVariablePassParameters.js";import{vertexAttributeLocations as m,LineMarkerTechnique as d}from"../shaders/LineMarkerTechnique.js";import{LineMarkerTechniqueConfiguration as A,LineMarkerSpace as f,LineMarkerAnchor as E}from"../shaders/LineMarkerTechniqueConfiguration.js";import{CapType as T}from"../shaders/RibbonLineTechniqueConfiguration.js";class v extends h{constructor(e){super(e,new S),this._vertexAttributeLocations=m,this._configuration=new A,this._layout=this.createLayout()}dispose(){}getConfiguration(e,t){return this._configuration.output=e,this._configuration.space=t.slot===u.DRAPED_MATERIAL?f.Draped:this.parameters.worldSpace?f.World:f.Screen,this._configuration.hideOnShortSegments=this.parameters.hideOnShortSegments,this._configuration.hasCap=this.parameters.cap!==T.BUTT,this._configuration.anchor=this.parameters.anchor,this._configuration.hasTip=this.parameters.hasTip,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasOccludees=this.parameters.hasOccludees,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.vvColor=this.parameters.vvColorEnabled,this._configuration.vvOpacity=this.parameters.vvOpacityEnabled,this._configuration.vvSize=this.parameters.vvSizeEnabled,this._configuration.occluder=this.parameters.renderOccluded===c.OccludeAndTransparentStencil,this._configuration.transparencyPassType=t.transparencyPassType,this._configuration.hasMultipassTerrain=t.multipassTerrain.enabled,this._configuration.cullAboveGround=t.multipassTerrain.cullAboveGround,this._configuration}intersect(){}createLayout(){const e=i().vec3f(l.POSITION).vec2f(l.UV0).vec3f(l.AUXPOS1);return this.parameters.worldSpace&&e.vec3f(l.NORMAL),this.parameters.vvSizeEnabled?e.f32(l.SIZEFEATUREATTRIBUTE):e.f32(l.SIZE),this.parameters.vvColorEnabled?e.f32(l.COLORFEATUREATTRIBUTE):e.vec4f(l.COLOR),this.parameters.vvOpacityEnabled&&e.f32(l.OPACITYFEATUREATTRIBUTE),e}createBufferWriter(){return new O(this._layout,this.parameters)}requiresSlot(e,t){if(t===n.Color||t===n.Alpha||t===n.Highlight||t===n.Depth){if(e===u.DRAPED_MATERIAL)return!0;if(this.parameters.renderOccluded===c.OccludeAndTransparentStencil)return e===u.OPAQUE_MATERIAL||e===u.OCCLUDER_MATERIAL||e===u.TRANSPARENT_OCCLUDER_MATERIAL;if(t===n.Color||t===n.Alpha){return e===(this.parameters.writeDepth?u.TRANSPARENT_MATERIAL:u.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL)}return e===u.OPAQUE_MATERIAL}return!1}createGLMaterial(e){return new _(e)}}class _ extends o{_updateParameters(e){return this.updateTexture(this._material.parameters.textureId),this._material.setParameters(this.textureBindParameters),this.ensureTechnique(d,e)}_updateOccludeeState(e){e.hasOccludees!==this._material.parameters.hasOccludees&&this._material.setParameters({hasOccludees:e.hasOccludees})}beginSlot(e){return this._output!==n.Color&&this._output!==n.Alpha||this._updateOccludeeState(e),this._updateParameters(e)}}class S extends p{constructor(){super(...arguments),this.width=0,this.color=[1,1,1,1],this.placement="end",this.cap=T.BUTT,this.anchor=E.Center,this.hasTip=!1,this.worldSpace=!1,this.hideOnShortSegments=!1,this.writeDepth=!0,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.hasOccludees=!1}}class O{constructor(e,t){this.vertexBufferLayout=e,this._parameters=t}allocate(e){return this.vertexBufferLayout.createBuffer(e)}elementCount(){return"begin-end"===this._parameters.placement?12:6}write(s,i,n,o,h){const c=n.vertexAttributes.get(l.POSITION).data,u=c.length/3;let p=[1,0,0];const m=n.vertexAttributes.get(l.NORMAL);this._parameters.worldSpace&&e(m)&&(p=m.data);let d=1,A=0;this._parameters.vvSizeEnabled?A=n.vertexAttributes.get(l.SIZEFEATUREATTRIBUTE).data[0]:n.vertexAttributes.has(l.SIZE)&&(d=n.vertexAttributes.get(l.SIZE).data[0]);let f=[1,1,1,1],E=0;this._parameters.vvColorEnabled?E=n.vertexAttributes.get(l.COLORFEATUREATTRIBUTE).data[0]:n.vertexAttributes.has(l.COLOR)&&(f=n.vertexAttributes.get(l.COLOR).data);let T=0;this._parameters.vvOpacityEnabled&&(T=n.vertexAttributes.get(l.OPACITYFEATUREATTRIBUTE).data[0]);const v=new Float32Array(o.buffer);let _=h*(this.vertexBufferLayout.stride/4);const S=(e,t,r,a)=>{if(v[_++]=e[0],v[_++]=e[1],v[_++]=e[2],v[_++]=r[0],v[_++]=r[1],v[_++]=t[0],v[_++]=t[1],v[_++]=t[2],this._parameters.worldSpace&&(v[_++]=p[0],v[_++]=p[1],v[_++]=p[2]),this._parameters.vvSizeEnabled?v[_++]=A:v[_++]=d,this._parameters.vvColorEnabled)v[_++]=E;else{const e=Math.min(4*a,f.length-4);v[_++]=f[e+0],v[_++]=f[e+1],v[_++]=f[e+2],v[_++]=f[e+3]}this._parameters.vvOpacityEnabled&&(v[_++]=T)};let O;!function(e){e[e.ASCENDING=1]="ASCENDING",e[e.DESCENDING=-1]="DESCENDING"}(O||(O={}));const R=(e,i)=>{const n=t(b,c[3*e],c[3*e+1],c[3*e+2]),o=g;let h=e+i;do{t(o,c[3*h],c[3*h+1],c[3*h+2]),h+=i}while(r(n,o)&&h>=0&&h<u);s&&(a(n,n,s),a(o,o,s)),S(n,o,[-1,-1],e),S(n,o,[1,-1],e),S(n,o,[1,1],e),S(n,o,[-1,-1],e),S(n,o,[1,1],e),S(n,o,[-1,1],e)},I=this._parameters.placement;"begin"!==I&&"begin-end"!==I||R(0,O.ASCENDING),"end"!==I&&"begin-end"!==I||R(u-1,O.DESCENDING)}}const b=s(),g=s();export{v as LineMarkerMaterial,S as Parameters};