UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 4.74 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{clamp as e}from"../../../../core/mathUtils.js";import{p as t}from"../../../../chunks/vec32.js";import{ZEROS as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as r}from"../../../../geometry/support/aaBoundingBox.js";import{newLayout as s}from"../../support/buffer/InterleavedLayout.js";import{isShadowRelatedOutput as a,is3DGeometryOutputMRT as o,isColorOrColorEmission as n,ShaderOutput as c}from"../core/shaderLibrary/ShaderOutput.js";import{EmissionSource as h}from"../core/shaderLibrary/output/Emissions.glsl.js";import{NormalsDoubleSidedMode as u}from"../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as m}from"../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{olidEnabled as p}from"../effects/geometry/olidUtils.js";import f from"../lib/GLMaterial.js";import{Material as l}from"../lib/Material.js";import{isPathGeometry as d}from"../lib/PathGeometry.js";import{MeshIntersectionOptions as b,intersectAabbInvDir as g}from"../lib/RayIntersections.js";import{RenderSlot as v}from"../lib/RenderSlot.js";import{VertexAttribute as S}from"../lib/VertexAttribute.js";import{DefaultBufferWriter as _}from"./DefaultBufferWriter.js";import{vertexAttributeLocations as A,PathTechnique as P,PathPassParameters as R}from"./PathTechnique.js";import{PathTechniqueConfiguration as j}from"./PathTechniqueConfiguration.js";import{alphaCutoff as O}from"../../../../webscene/support/AlphaCutoff.js";class y extends l{constructor(e,t){super(e,E),this._vertexBufferLayout=L(),this.vertexAttributeLocations=A,this.supportsEdges=!0,this.produces=new Map([[v.OPAQUE_MATERIAL,e=>(this.parameters.castShadows&&a(e)||o(e))&&!this.parameters.transparent],[v.TRANSPARENT_MATERIAL,e=>(this.parameters.castShadows&&a(e)||o(e))&&this.parameters.transparent]]),this._configuration=new j(t.spherical,t.doublePrecisionRequiresObfuscation)}get hasEmissions(){return!t(this.parameters.emissiveFactor,i)}getConfiguration(e,t){return this._configuration.output=e,this._configuration.vvSize=!!this.parameters.vvSize,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.vvOpacity=!!this.parameters.vvOpacity,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.transparent=this.parameters.transparent,this._configuration.hasOccludees=t.hasOccludees,n(e)?(this._configuration.doubleSidedMode=this.parameters.doubleSided&&"normal"===this.parameters.doubleSidedType?u.View:this.parameters.doubleSided&&"winding-order"===this.parameters.doubleSidedType?u.WindingOrder:u.None,this._configuration.receiveShadows=t.shadowMap.enabled,this._configuration.receiveAmbientOcclusion=null!=t.ssao):this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._configuration.pbrMode=this.parameters.usePBR?m.Schematic:m.Disabled,this._configuration.emissionSource=this.parameters.usePBR?h.Value:h.None,this._configuration.oitPass=t.oitPass,this._configuration.terrainDepthTest=t.terrainDepthTest,this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration}isVisibleForOutput(e){return e!==c.Shadow&&e!==c.ShadowExcludeHighlight&&e!==c.ShadowHighlight||this.parameters.castShadows}get visible(){return this.parameters.opacity>=O}intersect(t,i,s,a,o,n){const c=t;if(!d(c))return;const h=c.path,u=[this.parameters.size[0],this.parameters.size[1]];if(this.parameters.vvSize){const{offset:t,factor:i,minSize:r,maxSize:s}=this.parameters.vvSize,a=h.sizeAttributeValue;u[0]*=e(t[0]+a*i[0],r[0],s[0]),u[1]*=e(t[2]+a*i[2],r[2],s[2])}const m=new b(!1,s.options.normalRequired),p=Math.max(u[0],u[1]),f=t.boundingInfo;if(null==f)return void w(h,u,a,o,m,n);const l=r(f.bbMin[0]-p,f.bbMin[1]-p,f.bbMin[2]-p,f.bbMax[0]+p,f.bbMax[1]+p,f.bbMax[2]+p),v=[o[0]-a[0],o[1]-a[1],o[2]-a[2]],S=Math.sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]),_=[S/v[0],S/v[1],S/v[2]];g(l,a,_,s.tolerance)&&w(h,u,a,o,m,n)}createBufferWriter(){return new _(this._vertexBufferLayout)}createGLMaterial(e){return new T(e)}}function L(){const e=s().vec3f(S.POSITION).vec4f(S.PROFILERIGHT).vec4f(S.PROFILEUP).vec4f(S.PROFILEVERTEXANDNORMAL).vec4f(S.FEATUREVALUE);return p()&&e.vec4u8(S.OBJECTANDLAYERIDCOLOR),e}class T extends f{beginSlot(e){return this.getTechnique(P,e)}}function w(e,t,i,r,s,a){e.baked.size&&e.baked.size[0]===t[0]&&e.baked.size[1]===t[1]||e.baked.bake(t),e.baked.intersect(i,r,s,a)}class E extends R{constructor(){super(...arguments),this.doubleSided=!1,this.doubleSidedType="normal",this.castShadows=!0,this.hasSlicePlane=!1,this.transparent=!1,this.usePBR=!1}}export{E as Parameters,y as PathMaterial};