UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 4.05 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{clamp as t}from"../../../../core/mathUtils.js";import{clone as e}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as r}from"../../../../geometry/support/aaBoundingBox.js";import{isShadowLike as s,is3DGeometryOutputMRT as a,isColor as o}from"../core/shaderLibrary/ShaderOutput.js";import n from"../lib/GLMaterial.js";import{Material as h}from"../lib/Material.js";import{isPathGeometry as c}from"../lib/PathGeometry.js";import{MeshIntersectionOptions as p,intersectAabbInvDir as u}from"../lib/RayIntersections.js";import{DefaultBufferWriter as m}from"./DefaultBufferWriter.js";import{getLayout as l,PathPassParameters as f,PathTechnique as d}from"./PathTechnique.js";import{PathTechniqueConfiguration as b}from"./PathTechniqueConfiguration.js";import{alphaCutoff as g}from"../../../../webscene/support/AlphaCutoff.js";class _ extends h{constructor(t,e){super(t,w),this.supportsEdges=!0,this._pp0=i(0,0,1),this._pp1=i(0,0,0),this.produces=new Map([[2,t=>(this.parameters.castShadows&&s(t)||a(t))&&!this.transparent],[4,t=>(this.parameters.castShadows&&s(t)||a(t))&&this.transparent]]),this._configuration=new b(e.spherical)}get hasEmissions(){return this.parameters.emissiveStrength>0}getConfiguration(t,e){return super.getConfiguration(t,e,this._configuration),this._configuration.hasVVSize=this.parameters.hasVVSize,this._configuration.hasVVColor=this.parameters.hasVVColor,this._configuration.hasVVOpacity=this.parameters.hasVVOpacity,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.transparent=this.transparent,this._configuration.hasOccludees=e.hasOccludees,o(t)?(this._configuration.doubleSidedMode=this.parameters.doubleSided&&"normal"===this.parameters.doubleSidedType?1:this.parameters.doubleSided&&"winding-order"===this.parameters.doubleSidedType?2:0,this._configuration.receiveShadows=e.shadowMap.enabled,this._configuration.receiveAmbientOcclusion=null!=e.ssao):this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._configuration.pbrMode=this.parameters.usePBR?2:0,this._configuration.emissionSource=this.parameters.usePBR?1:0,this._configuration.terrainDepthTest=e.terrainDepthTest,this._configuration.cullAboveTerrain=e.cullAboveTerrain,this._configuration.snowCover=e.snowCover>0,this._configuration}isVisibleForOutput(t){return 3!==t&&5!==t&&4!==t||this.parameters.castShadows}get visible(){return this.parameters.opacity>=g}intersect(t,e,i,r,s,a){this._intersect(t,i,r,s,a)}intersectDraped(t,e,i,r){return this._pp0[0]=this._pp1[0]=i[0],this._pp0[1]=this._pp1[1]=i[1],this._intersect(t,e,this._pp0,this._pp1,r)}_intersect(i,s,a,o,n){const h=i;if(!c(h))return;const m=h.path,l=e(this.parameters.size);if(this.parameters.vvSize){const{offset:e,factor:i,minSize:r,maxSize:s,fallback:a}=this.parameters.vvSize,o=m.sizeAttributeValue;Number.isNaN(o)?(l[0]*=a[0],l[1]*=a[2]):(l[0]*=t(e[0]+o*i[0],r[0],s[0]),l[1]*=t(e[2]+o*i[2],r[2],s[2]))}const f=new p(s.tolerance,!1,s.options.normalRequired),d=Math.max(l[0],l[1]),b=i.boundingInfo;if(null==b)return void v(m,l,a,o,f,n);const g=r(b.bbMin[0]-d,b.bbMin[1]-d,b.bbMin[2]-d,b.bbMax[0]+d,b.bbMax[1]+d,b.bbMax[2]+d),_=[o[0]-a[0],o[1]-a[1],o[2]-a[2]],S=Math.sqrt(_[0]*_[0]+_[1]*_[1]+_[2]*_[2]),w=[S/_[0],S/_[1],S/_[2]];u(g,a,w,s.tolerance)&&v(m,l,a,o,f,n)}createBufferWriter(){return new m(l(this.parameters))}createGLMaterial(t){return new S(t)}get transparent(){const{parameters:t}=this;return t.drivenOpacity||t.opacity<1}}class S extends n{beginSlot(t){return this.getTechnique(d,t)}}function v(t,e,i,r,s,a){t.baked.size&&t.baked.size[0]===e[0]&&t.baked.size[1]===e[1]||t.baked.bake(e),t.baked.intersect(i,r,s,a)}class w extends f{constructor(){super(...arguments),this.doubleSided=!1,this.doubleSidedType="normal",this.castShadows=!0,this.hasSlicePlane=!1,this.drivenOpacity=!1,this.usePBR=!1}}export{w as Parameters,_ as PathMaterial};