@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 10.2 kB
JavaScript
import{_ as e}from"../../../../../../chunks/tslib.es6.js";import{releaseMaybe as t,isSome as r,isNone as s}from"../../../../../../core/maybe.js";import{e as o,t as a}from"../../../../../../chunks/mat3.js";import{a as i}from"../../../../../../chunks/mat3f32.js";import{G as n}from"../../../../../../chunks/vec3.js";import{f as l}from"../../../../../../chunks/vec3f32.js";import{v as h}from"../../../../../../chunks/vec4.js";import{f as u}from"../../../../../../chunks/vec4f32.js";import{f as p}from"../../../../../../chunks/vec4f64.js";import{ColorMixModeEnum as c}from"../../../../layers/support/symbolColorUtils.js";import d from"../../../../support/debugFlags.js";import{OverlayIndex as m,RenderTargetType as g}from"../../../../terrain/interfaces.js";import{ComponentTechnique as y}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as T,IntegratedMeshMode as x}from"./ComponentTechniqueConfiguration.js";import{ComponentDataType as f}from"./shader/ComponentData.glsl.js";import{g as v}from"../../../../../../chunks/ComponentShader.glsl.js";import{VertexDiscardMode as b}from"./shader/VertexDiscardByOpacity.glsl.js";import{MaterialBase as M,parameter as O,parameterBlock as C,MaterialParameterBlock as w}from"../../../core/material/MaterialBase.js";import{RenderPassIdentifier as S}from"../../../core/renderPasses/AllRenderPasses.js";import{ShaderOutput as P}from"../../../core/shaderLibrary/ShaderOutput.js";import{NormalAttributeType as j}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{NormalsDoubleSidedMode as N}from"../../../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as A}from"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{defaultMaskAlphaCutoff as q}from"../../../core/shaderLibrary/util/AlphaCutoff.js";import{EllipsoidMode as D}from"../../../core/shaderLibrary/util/EllipsoidMode.js";import{TwoVectorPosition as R}from"../../../core/util/TwoVectorPosition.js";import{AlphaDiscardMode as I,CullFaceOptions as F}from"../../../lib/basicInterfaces.js";import{TransparencyPassType as k}from"../../../lib/TransparencyPassType.js";class _ extends M{constructor(e,t){super(),this.toMapSpace=t,this.baseColor=u(1,1,1,1),this.usePBR=!1,this.hasParametersFromSource=!1,this.mrrFactors=l(1,1,.5),this.emissiveFactor=l(0,0,0),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null,this.objectOpacity=1,this.commonMaterialParameters=new L,this.componentParameters=new B,this.textureAlphaCutoff=q,this.alphaDiscardMode=I.Opaque,this.isIntegratedMesh=!1,this.polygonOffsetEnabled=!1,this.ellipsoidMode=D.Earth,this.hasOccludees=!1,this._techniqueConfiguration=new T;const r=new R(e.position),s=i(e.rotationScale);o(s,s),this.transformNormalGlobalFromModel=a(s,s),this.transformWorldFromModelTL=r.low,this.transformWorldFromModelTH=r.high,this.transformWorldFromModelRS=e.rotationScale}dispose(){this._technique=t(this._technique),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null}get texture(){return r(this.baseColorTexture)?this.baseColorTexture.glTexture:null}get textureMetallicRoughness(){return r(this.metallicRoughnessTexture)?this.metallicRoughnessTexture.glTexture:null}get textureEmissive(){return r(this.emissionTexture)?this.emissionTexture.glTexture:null}get textureOcclusion(){return r(this.occlusionTexture)?this.occlusionTexture.glTexture:null}get textureNormal(){return r(this.normalTexture)?this.normalTexture.glTexture:null}prepareTechnique(e,t,o,a){const i=this._techniqueConfiguration;i.hasVertexColors=a.colors,i.hasNormals=a.normals,i.textureCoordinateType=a.textureCoordinates,i.hasMetallicRoughnessTexture=r(this.metallicRoughnessTexture),i.hasEmissionTexture=r(this.emissionTexture),i.hasOcclusionTexture=r(this.occlusionTexture),i.hasNormalTexture=r(this.normalTexture),i.transparencyPassType=t.identifier===S.Material&&null!=o.transparencyPassType?o.transparencyPassType:k.NONE,i.hasMultipassTerrain=t.identifier===S.Material&&null!=o.multipassTerrain&&o.multipassTerrain.enabled,i.cullAboveGround=t.identifier===S.Material&&null!=o.multipassTerrain&&o.multipassTerrain.cullAboveGround,i.ellipsoidMode=this.ellipsoidMode,i.componentData=this.componentParameters.type,i.cullFace=this.commonMaterialParameters.cullFace,i.doubleSidedMode=this.commonMaterialParameters.doubleSided?N.View:N.None,i.hasBaseColorTexture=r(this.baseColorTexture);const n=this._computeWhichMaterialPass();i.blendingEnabled=n===E.Transparent||n===E.OpaqueAndTransparent,i.alphaDiscardMode=this.alphaDiscardMode,i.integratedMeshMode=this.isIntegratedMesh?H(o)?v(o)?x.ColorOverlayWithWater:x.ColorOverlay:x.NoOverlay:x.None,i.useLegacyTerrainShading=this.isIntegratedMesh&&d.TERRAIN_USE_LEGACY_SHADING,i.hasPolygonOffset=this.polygonOffsetEnabled;const l=this.hasParametersFromSource&&s(this.baseColorTexture);if(i.pbrMode=i.integratedMeshMode===x.ColorOverlayWithWater?A.WaterOnIntegratedMesh:this.usePBR?l?A.Schematic:A.Normal:A.Disabled,i.normalType=i.integratedMeshMode===x.None?i.hasNormals?j.CompressedAttribute:j.ScreenDerivative:j.Ground,i.hasSlicePlane=r(o.slicePlane)&&this.commonMaterialParameters.hasSlicePlane,t.identifier===S.ShadowMap)i.output=P.Shadow,i.vertexDiscardMode=b.None;else if(t.identifier===S.Highlight)i.output=P.Highlight,i.vertexDiscardMode=b.None;else{switch(this._computeWhichMaterialPass()===E.OpaqueAndTransparent?i.vertexDiscardMode=t.transparent?b.Opaque:b.Transparent:i.vertexDiscardMode=b.None,i.output=t.output,i.receiveAmbientOcclusion=!1,i.receiveShadows=!1,t.output){case P.Color:i.receiveAmbientOcclusion=o.ssaoHelper.active,i.hasOccludees=o.hasOccludees,i.receiveShadows=o.shadowMap.ready,i.hasScreenSpaceReflections=o.ssr.enabled,i.hasCloudsReflections=r(o.cloudsFade.data);break;case P.Alpha:i.hasOccludees=o.hasOccludees;break;case P.ObjectAndLayerIdColor:i.objectAndLayerIdColor=!0}i.snowCover=this.hasSnowCover(o)}return this._technique=e.releaseAndAcquire(y,i,this._technique),this._setClean(),this._technique}hasSnowCover(e){return r(e.weather)&&e.weatherVisible&&"snowy"===e.weather.type&&"enabled"===e.weather.snowCover}submit(e,t,s){if(0===this.objectOpacity)return;const o=s.renderable.geometry,a=s.components,i=s.renderable.meta.cameraDepthSquared,n=a.geometryRanges,l=a.highlightRanges,h=a.defaultShadowMapRanges;switch(this._computeWhichMaterialPass()){case E.Opaque:e.materialOpaque.submitDraw(this,o,n,i);break;case E.Transparent:e.materialTransparent.submitDraw(this,o,n,i);break;case E.OpaqueAndTransparent:e.materialOpaque.submitDraw(this,o,n,i),e.materialTransparent.submitDraw(this,o,n,i);break;case E.IntegratedMesh:e.materialIntegratedMesh.submitDraw(this,o,n,i),V(t)&&e.highlightIntegratedMesh.submitDraw(this,o,n,i)}const u=this.componentParameters.castShadows!==W.None;u&&e.shadowMap.submitDraw(this,o,n,i),r(l)&&(e.highlight.submitDraw(this,o,l,i),u&&e.highlightShadowMap.submitDraw(this,o,l,i)),u&&r(h)&&e.defaultShadowMap.submitDraw(this,o,h,i)}_computeWhichMaterialPass(){return this.isIntegratedMesh?E.IntegratedMesh:this.objectOpacity<1?E.Transparent:this.componentParameters.opaqueOverride===W.All?E.Opaque:this.baseColor[3]<1||this.alphaDiscardMode===I.Blend||this.alphaDiscardMode===I.MaskBlend?E.Transparent:this.componentParameters.transparent===W.None?E.Opaque:this.componentParameters.transparent===W.All?E.Transparent:E.OpaqueAndTransparent}}var E,W;e([O({vectorOps:h})],_.prototype,"baseColor",void 0),e([O()],_.prototype,"usePBR",void 0),e([O()],_.prototype,"hasParametersFromSource",void 0),e([O({vectorOps:n})],_.prototype,"mrrFactors",void 0),e([O({vectorOps:n})],_.prototype,"emissiveFactor",void 0),e([O({dispose:!0})],_.prototype,"baseColorTexture",void 0),e([O({dispose:!0})],_.prototype,"metallicRoughnessTexture",void 0),e([O({dispose:!0})],_.prototype,"emissionTexture",void 0),e([O({dispose:!0})],_.prototype,"occlusionTexture",void 0),e([O({dispose:!0})],_.prototype,"normalTexture",void 0),e([O()],_.prototype,"objectOpacity",void 0),e([C()],_.prototype,"commonMaterialParameters",void 0),e([C()],_.prototype,"componentParameters",void 0),e([O()],_.prototype,"textureAlphaCutoff",void 0),e([O()],_.prototype,"alphaDiscardMode",void 0),e([O()],_.prototype,"isIntegratedMesh",void 0),e([O()],_.prototype,"polygonOffsetEnabled",void 0),e([O()],_.prototype,"ellipsoidMode",void 0),e([O()],_.prototype,"hasOccludees",void 0),function(e){e[e.Opaque=0]="Opaque",e[e.Transparent=1]="Transparent",e[e.OpaqueAndTransparent=2]="OpaqueAndTransparent",e[e.IntegratedMesh=3]="IntegratedMesh"}(E||(E={}));class L extends w{constructor(){super(...arguments),this.doubleSided=!1,this.cullFace=F.Back,this.hasSlicePlane=!0}}e([O()],L.prototype,"doubleSided",void 0),e([O()],L.prototype,"cullFace",void 0),e([O()],L.prototype,"hasSlicePlane",void 0);class B extends w{constructor(){super(...arguments),this.externalColor=p(1,1,1,1),this.externalColorMixMode=c.Multiply,this.castShadows=W.All}get transparent(){return this.externalColor[3]<1?W.All:W.None}get opaqueOverride(){return this.externalColorMixMode===c.Replace&&1===this.externalColor[3]?W.All:W.None}get visible(){return this.externalColor[3]>0?W.All:W.None}get type(){return f.Uniform}}e([O({vectorOps:h})],B.prototype,"externalColor",void 0),e([O()],B.prototype,"externalColorMixMode",void 0),e([O()],B.prototype,"castShadows",void 0),function(e){e[e.All=0]="All",e[e.Some=1]="Some",e[e.None=2]="None"}(W||(W={}));class G extends w{constructor(){super(...arguments),this.texture=null,this.transparent=W.None,this.opaqueOverride=W.None,this.castShadows=W.None}get type(){return f.Varying}}function V(e){return 0!==e.overlays.length&&r(e.overlays[m.INNER].getValidTexture(g.Highlight))}function H(e){return 0!==e.overlays.length&&r(e.overlays[m.INNER].getColorTextureNoRasterImage())}e([O()],G.prototype,"texture",void 0),e([O()],G.prototype,"transparent",void 0),e([O()],G.prototype,"opaqueOverride",void 0),e([O()],G.prototype,"castShadows",void 0);export{L as CommonMaterialParameters,_ as ComponentMaterial,W as ComponentParameterSummary,B as ComponentParametersUniform,G as ComponentParametersVarying};