UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 4.12 kB
import{f as t}from"../../../../chunks/vec4f64.js";import{BufferViewMat3f as e,BufferViewVec4f as r,BufferViewVec4u8 as i,BufferViewVec3f as s}from"../../../../geometry/support/buffer/BufferView.js";import{newLayout as a}from"../../support/buffer/InterleavedLayout.js";import{ShaderOutput as o}from"../core/shaderLibrary/ShaderOutput.js";import{CullFaceOptions as n}from"../lib/basicInterfaces.js";import c from"../lib/GLMaterial.js";import{MaterialParameters as h}from"../lib/Material.js";import{OITPolygonOffsetLimit as u}from"../lib/OrderIndependentTransparency.js";import{RenderSlot as l}from"../lib/RenderSlot.js";import{assert as p}from"../lib/Util.js";import{VertexAttribute as f}from"../lib/VertexAttribute.js";import{DefaultBufferWriter as m}from"./DefaultBufferWriter.js";import{Style as d}from"./PatternStyle.js";import{TriangleMaterial as g}from"./TriangleMaterial.js";import{writeBufferVec4 as _,writeColor as A,writePosition as b}from"./internal/bufferWriterUtils.js";import{vertexAttributeLocations as O,PatternTechniqueConfiguration as T,PatternTechnique as P}from"../shaders/PatternTechnique.js";class S extends g{constructor(t){super(t,new R),this.supportsEdges=!0,this._vertexAttributeLocations=O,this._configuration=new T}getConfiguration(t,e){return this._configuration.output=t,this._configuration.cullFace=this.parameters.cullFace,this._configuration.hasVertexColors=this.parameters.hasVertexColors,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.polygonOffset=this.parameters.polygonOffset,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.style=this.parameters.style,this._configuration.patternSpacing=this.parameters.patternSpacing,this._configuration.lineWidth=this.parameters.lineWidth,this._configuration.draped=this.parameters.draped,this._configuration.transparencyPassType=e.transparencyPassType,this._configuration.enableOffset=e.camera.relativeElevation<u,this._configuration.hasMultipassTerrain=e.multipassTerrain.enabled,this._configuration.cullAboveGround=e.multipassTerrain.cullAboveGround,this._configuration}requiresSlot(t,e){if(e===o.Color||e===o.Alpha||e===o.Highlight||e===o.Depth&&this.parameters.writeLinearDepth){if(t===l.DRAPED_MATERIAL)return!0;if(e===o.Highlight)return t===l.OPAQUE_MATERIAL;return t===(this.parameters.writeDepth?l.TRANSPARENT_MATERIAL:l.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL)}return!1}createGLMaterial(t){return new y(t)}createBufferWriter(){const t=a().vec3f(f.POSITION).vec4u8(f.COLOR).vec4f(f.UVMAPSPACE);return this.parameters.draped||t.mat3f(f.BOUNDINGRECT),new E(t)}}class y extends c{_updateParameters(t){return this.ensureTechnique(P,t)}_updateOccludeeState(t){t.hasOccludees!==this._material.parameters.hasOccludees&&this._material.setParameters({hasOccludees:t.hasOccludees})}beginSlot(t){return this._output!==o.Color&&this._output!==o.Alpha||this._updateOccludeeState(t),this._updateParameters(t)}}class E extends m{write(t,a,o,n,c){for(const h of this.vertexBufferLayout.fieldNames){const a=o.vertexAttributes.get(h),u=o.indices.get(h);if(a&&u)switch(h){case f.POSITION:{p(3===a.size);const e=n.getField(h,s);e&&b(u,a.data,t,e,c);break}case f.COLOR:{p(3===a.size||4===a.size);const t=n.getField(h,i);t&&A(u,a.data,a.size,t,c);break}case f.UVMAPSPACE:{p(4===a.size);const t=n.getField(h,r);t&&_(u,a.data,t,c);break}case f.BOUNDINGRECT:{p(9===a.size);const r=n.getField(h,e);r&&this.writeBoundingRect(u,a.data,t,r,c);break}}}}writeBoundingRect(t,e,r,i,s){const a=r,o=i.typedBuffer,n=i.typedBufferStride,c=t.length;s*=n;for(let h=0;h<c;++h){const r=9*t[h],i=e[r],c=e[r+1],u=e[r+2];o[s]=a[0]*i+a[4]*c+a[8]*u+a[12],o[s+1]=a[1]*i+a[5]*c+a[9]*u+a[13],o[s+2]=a[2]*i+a[6]*c+a[10]*u+a[14];for(let t=3;t<9;++t)o[s+t]=e[r+t];s+=n}}}class R extends h{constructor(){super(...arguments),this.color=t(1,1,1,1),this.writeDepth=!0,this.writeLinearDepth=!1,this.hasVertexColors=!1,this.polygonOffset=!1,this.hasSlicePlane=!1,this.cullFace=n.None,this.hasOccludees=!1,this.style=d.Cross,this.patternSpacing=10,this.lineWidth=1,this.draped=!0}}export{R as Parameters,S as PatternMaterial};