UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 2.75 kB
import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Accessor.js";import{smoothstep as s}from"../../../core/mathUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{n as i,e as a,g as n,h as c,l as p}from"../../../chunks/vec3.js";import{c as m}from"../../../chunks/vec3f64.js";import{getReferenceEllipsoid as h}from"../../../geometry/ellipsoidUtils.js";import{atmosphereHeight as u}from"./atmosphereUtils.js";import{F as d}from"../../../chunks/FogHaze.glsl.js";import{FogTechnique as l,FogHazeTechniqueConfiguration as g}from"./FogTechnique.js";import{weatherHeightLimit as f}from"./weather.js";import{Pos2Tex as _}from"../webgl-engine/lib/DefaultVertexBufferLayouts.js";import{createQuadVAO as j}from"../webgl-engine/lib/glUtil3D.js";import{PrimitiveType as b}from"../../webgl/enums.js";const x=.95,y=1;let P=class extends e{constructor(t){super(t),this._passParameters=new d;const e=t.context.renderContext.rctx;this._vao=j(e,_),this._technique=t.context.techniqueRepository.acquire(l,new g);const s=h(t.view.spatialReference);this._planetRadius=s.radius,this._atmosphereRadius=s.radius+u}destroy(){this._technique.release(),this._vao.dispose()}set strength(t){this._passParameters.fogStrength=t}get strength(){return this._passParameters.fogStrength}render(t,e){if(this._update(t,e),this._passParameters.fogAmount<=0)return;const s=this._technique;if(!s.compiled)return void this.context.requestRender();const r=t.offscreenRenderingHelper;r.renderDepthDetached((()=>{this._passParameters.depthTexture=r.depthTexture;const e=t.rctx.bindTechnique(s,this._passParameters,t.bindParameters);this._renderFog(e,t)}))}_renderFog(t,e){const s=e.rctx;s.bindVAO(this._vao),t.assertCompatibleVertexAttributeLocations(this._vao),s.drawArrays(b.TRIANGLE_STRIP,0,4)}_update(t,e){const r=t.bindParameters.camera;i(R,r.eye);const o=Math.max(0,a(R,t.bindParameters.lighting.mainLight.direction)),m=e.color;n(w,m,.1),c(this._passParameters.fogColor,w,m,o);const h=p(r.eye),u=h*h;this._passParameters.atmosphereC=u-this._atmosphereRadius*this._atmosphereRadius,this._passParameters.fogAmount=(1-s(x*f,y*f,Math.abs(h-this._planetRadius)))*e.amount,this._passParameters.fogStrength=e.strength}static isSupported(t){return t.capabilities.depthTexture}};t([r({constructOnly:!0})],P.prototype,"context",void 0),t([r({constructOnly:!0})],P.prototype,"view",void 0),P=t([o("esri.views.3d.environment.Fog")],P);class v{constructor(){this.color=m(),this.strength=0,this.amount=0}}const R=m(),w=m();export{P as Fog,v as FogParameters};