@arcgis/core 4.27.0-rc.1 → 4.27.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{92e7f224a80195e606d6.js → 1f69fb9687de9ebfcf90.js} +1 -1
- package/assets/esri/core/workers/chunks/{0a02ac5628d1739372c6.js → 2b55295590b4a0503749.js} +1 -1
- package/assets/esri/core/workers/chunks/471f6eba213412b82840.js +1 -0
- package/assets/esri/core/workers/chunks/{f339db2b599fa9585283.js → 5e6471dd2a08e66b47d0.js} +79 -81
- package/assets/esri/core/workers/chunks/{474d9b334812533bab36.js → 6cd248d065f6d1616294.js} +1 -1
- package/assets/esri/core/workers/chunks/{d8bd3f498b3fa8153404.js → 6f510f28526c73ab453c.js} +1 -1
- package/assets/esri/core/workers/chunks/83e3d104886b48f00397.js +1 -0
- package/assets/esri/core/workers/chunks/{3c5a64a545272f148e93.js → 9621b7d8d951aa881686.js} +1 -1
- package/assets/esri/core/workers/chunks/{b6e173eddaad4244cb5f.js → b31974524932e638df8c.js} +1 -1
- package/assets/esri/core/workers/chunks/da57eba2fe25495ea217.js +1 -0
- package/assets/esri/core/workers/chunks/dabd889e064c4e7807fa.js +1 -0
- package/assets/esri/core/workers/chunks/f35895e03c036d67b3ed.js +1 -0
- package/assets/esri/core/workers/chunks/{c6efe2e04ea6a55bb6e3.js → f6e68befe2812b90b40d.js} +1 -1
- package/assets/esri/themes/base/widgets/_Feature.scss +4 -0
- package/assets/esri/themes/base/widgets/_FeatureContent.scss +9 -2
- package/assets/esri/themes/base/widgets/_ScaleRangeSlider.scss +1 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/DefaultMaterial.glsl.js +3 -2
- package/chunks/ShadowCastAccumulate.glsl.js +1 -1
- package/core/timeUtils.js +1 -1
- package/geometry/Mesh.js +1 -1
- package/geometry/support/meshVertexSpaceUtils.js +5 -0
- package/interfaces.d.ts +179 -31
- package/kernel.js +1 -1
- package/layers/VideoLayer.js +1 -1
- package/layers/graphics/controllers/StreamController.js +1 -1
- package/layers/graphics/data/QueryEngine.js +1 -1
- package/layers/graphics/data/attributeSupport.js +1 -1
- package/layers/graphics/editingSupport.js +1 -1
- package/layers/graphics/sources/FeatureLayerSource.js +1 -1
- package/layers/video/VideoController.js +1 -1
- package/layers/video/videoUtils.js +5 -0
- package/package.json +1 -1
- package/rest/support/meshFeatureSet.js +1 -1
- package/smartMapping/symbology/flow.js +1 -1
- package/statistics/utils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/CIMSymbolHelper.js +1 -1
- package/views/2d/layers/StreamLayerView2D.js +1 -1
- package/views/2d/layers/features/sources/StreamSource.js +1 -1
- package/views/3d/environment/ChapmanAtmosphereTechnique.js +1 -1
- package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
- package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/II3SMeshView3D.js +1 -1
- package/views/3d/layers/SceneLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/AllRenderPasses.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/Transform.glsl.js +3 -9
- package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +12 -9
- package/views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js +10 -10
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterDistortion.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/TerrainTexture.glsl.js +8 -8
- package/views/3d/webgl-engine/core/shaderModules/Matrix4sDrawUniform.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowHighlight.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
- package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/pbrUtils.js +1 -1
- package/views/3d/webgl-engine/shaders/AtmosphereCompositingTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadowHighlightTechnique.js +1 -1
- package/views/draw/DrawGraphicTool.js +1 -1
- package/views/layers/GroupLayerView.js +1 -1
- package/widgets/Daylight/DaylightViewModel.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/Workflow.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
- package/widgets/Feature/FeatureRelationship.js +1 -1
- package/widgets/FeatureForm/EditableInput.d.ts +2 -2
- package/widgets/FeatureTable/FieldColumn.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace/support/GeometryHandler.js +1 -1
- package/widgets/UtilityNetworkTrace/support/ResultAreaHandler.js +1 -1
- package/widgets/UtilityNetworkTrace.js +1 -1
- package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +1 -1
- package/widgets/UtilityNetworkValidateTopology.js +1 -1
- package/widgets/ValuePicker/ValuePickerBaseComponent.js +1 -1
- package/widgets/ValuePicker.js +1 -1
- package/assets/esri/core/workers/chunks/07651ef8348f702d59ac.js +0 -1
- package/assets/esri/core/workers/chunks/39714837f9d3708e3806.js +0 -1
- package/assets/esri/core/workers/chunks/785a6c925f29bc962992.js +0 -1
- package/assets/esri/core/workers/chunks/90da1ed112b82712d0ef.js +0 -1
- package/assets/esri/core/workers/chunks/b5fc6f2044ed047c5afd.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{adjustStaticAGOUrl as e}from"../../../../core/devEnvironmentUtils.js";import{b as t}from"../../../../chunks/mat3.js";import{c as r}from"../../../../chunks/mat3f64.js";import{a as o}from"../../../../chunks/mat4.js";import{c as s}from"../../../../chunks/mat4f64.js";import{m as
|
|
5
|
+
import{adjustStaticAGOUrl as e}from"../../../../core/devEnvironmentUtils.js";import{b as t}from"../../../../chunks/mat3.js";import{c as r}from"../../../../chunks/mat3f64.js";import{a as o}from"../../../../chunks/mat4.js";import{c as s}from"../../../../chunks/mat4f64.js";import{m as i,b as n,D as l,l as u,n as a,h as c}from"../../../../chunks/vec3.js";import{c as m}from"../../../../chunks/vec3f64.js";import{empty as f,expandWithVec3 as d}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as p}from"../../../../geometry/support/FloatArray.js";import{BufferViewVec4f as g,BufferViewVec4u8 as x,BufferViewVec4u16 as b,BufferViewVec3f as h,BufferViewVec3u8 as T,BufferViewVec3u16 as y}from"../../../../geometry/support/buffer/BufferView.js";import{t as R,a as w,s as v}from"../../../../chunks/vec32.js";import{t as M,s as j}from"../../../../chunks/vec42.js";import{n as B}from"../../../../chunks/vec22.js";import{c as S}from"../../../../chunks/vec33.js";import{c as F}from"../../../../chunks/vec43.js";import{DefaultLoadingContext as L}from"../../glTF/DefaultLoadingContext.js";import{loadGLTF as O}from"../../glTF/loader.js";import{convertPrimitiveToTriangles as A}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as I}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as k}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as C}from"./ProcessedObjectResource.js";import{load as E,processLoadResult as N}from"./wosrLoader.js";import{NormalType as P}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as U}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as V,DepthTestFunction as D,CullFaceOptions as _}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as G}from"../../webgl-engine/lib/Geometry.js";import{Texture as H}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as q}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as W}from"../../webgl-engine/materials/DefaultMaterial.js";import{COLOR_GAMMA as $}from"../../webgl-engine/materials/DefaultMaterial_COLOR_GAMMA.js";import{defaultEsriSymbologyMRRFactors as z,defaultAdvancedMRRFactors as K,useSchematicPBR as Q,defaultSchematicMRRFactors as J}from"../../webgl-engine/materials/pbrUtils.js";async function X(t,r){const o=Y(e(t));if("wosr"===o.fileType){const e=await(r.cache?r.cache.loadWOSR(o.url,r):E(o.url,r)),{engineResources:t,referenceBoundingBox:s}=N(e,r);return{lods:t,referenceBoundingBox:s,isEsriSymbolResource:!1,isWosr:!0}}const s=await(r.cache?r.cache.loadGLTF(o.url,r,!!r.usePBR):O(new L(r.streamDataRequester),o.url,r,r.usePBR)),i=s.model.meta?.ESRI_proxyEllipsoid,n=s.meta.isEsriSymbolResource&&null!=i&&s.meta.uri.includes("/RealisticTrees/");n&&!s.customMeta.esriTreeRendering&&(s.customMeta.esriTreeRendering=!0,se(s,i));const l=!!r.usePBR,u=s.meta.isEsriSymbolResource?{usePBR:l,isSchematic:!1,treeRendering:n,mrrFactors:[...z]}:{usePBR:l,isSchematic:!1,treeRendering:!1,mrrFactors:[...K]},a={...r.materialParamsMixin,treeRendering:n},{engineResources:c,referenceBoundingBox:m}=Z(s,u,a,r.skipHighLods&&null==o.specifiedLodIndex?{skipHighLods:!0}:{skipHighLods:!1,singleLodIndex:o.specifiedLodIndex});return{lods:c,referenceBoundingBox:m,isEsriSymbolResource:s.meta.isEsriSymbolResource,isWosr:!1}}function Y(e){const t=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(t)return{fileType:"gltf",url:t[1],specifiedLodIndex:null!=t[4]?Number(t[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function Z(e,t,r,o){const s=e.model,i=new Array,n=new Map,l=new Map,u=s.lods.length,a=f();return s.lods.forEach(((e,c)=>{const m=!0===o.skipHighLods&&(u>1&&0===c||u>3&&1===c)||!1===o.skipHighLods&&null!=o.singleLodIndex&&c!==o.singleLodIndex;if(m&&0!==c)return;const f=new C(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach((e=>{const o=m?new W({}):ee(s,e,f,t,r,n,l),{geometry:i,vertexCount:u}=te(e,null!=o?o:new W({})),p=i.boundingInfo;null!=p&&0===c&&(d(a,p.bbMin),d(a,p.bbMax)),null!=o&&(f.stageResources.geometries.push(i),f.numberOfVertices+=u)})),m||i.push(f)})),{engineResources:i,referenceBoundingBox:a}}function ee(e,t,r,o,s,i,n){const l=t.material+(t.attributes.normal?"_normal":"")+(t.attributes.color?"_color":"")+(t.attributes.texCoord0?"_texCoord0":"")+(t.attributes.tangent?"_tangent":""),u=e.materials.get(t.material),a=null!=t.attributes.texCoord0,c=null!=t.attributes.normal;if(null==u)return null;const m=oe(u.alphaMode);if(!i.has(l)){if(a){const t=(t,r=!1)=>{if(null!=t&&!n.has(t)){const o=e.textures.get(t);if(null!=o){const e=o.data;n.set(t,new H(I(e)?e.data:e,{...o.parameters,preMultiplyAlpha:!I(e)&&r,encoding:I(e)&&null!=e.encoding?e.encoding:void 0}))}}};t(u.textureColor,m!==V.Opaque),t(u.textureNormal),t(u.textureOcclusion),t(u.textureEmissive),t(u.textureMetallicRoughness)}const r=u.color[0]**(1/$),f=u.color[1]**(1/$),d=u.color[2]**(1/$),p=u.emissiveFactor[0]**(1/$),g=u.emissiveFactor[1]**(1/$),x=u.emissiveFactor[2]**(1/$),b=null!=u.textureColor&&a?n.get(u.textureColor):null,h=Q({normalTexture:u.textureNormal,metallicRoughnessTexture:u.textureMetallicRoughness,metallicFactor:u.metallicFactor,roughnessFactor:u.roughnessFactor,emissiveTexture:u.textureEmissive,emissiveFactor:u.emissiveFactor,occlusionTexture:u.textureOcclusion});i.set(l,new W({...o,transparent:m===V.Blend,customDepthTest:D.Lequal,textureAlphaMode:m,textureAlphaCutoff:u.alphaCutoff,diffuse:[r,f,d],ambient:[r,f,d],opacity:u.opacity,doubleSided:u.doubleSided,doubleSidedType:"winding-order",cullFace:u.doubleSided?_.None:_.Back,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:c?P.Attribute:P.ScreenDerivative,castShadows:!0,receiveSSAO:!0,textureId:null!=b?b.id:void 0,colorMixMode:u.colorMixMode,normalTextureId:null!=u.textureNormal&&a?n.get(u.textureNormal).id:void 0,textureAlphaPremultiplied:null!=b&&!!b.parameters.preMultiplyAlpha,occlusionTextureId:null!=u.textureOcclusion&&a?n.get(u.textureOcclusion).id:void 0,emissiveTextureId:null!=u.textureEmissive&&a?n.get(u.textureEmissive).id:void 0,metallicRoughnessTextureId:null!=u.textureMetallicRoughness&&a?n.get(u.textureMetallicRoughness).id:void 0,emissiveFactor:[p,g,x],mrrFactors:h?[...J]:[u.metallicFactor,u.roughnessFactor,o.mrrFactors[2]],isSchematic:h,colorTextureTransformMatrix:k(u.colorTextureTransform),normalTextureTransformMatrix:k(u.normalTextureTransform),occlusionTextureTransformMatrix:k(u.occlusionTextureTransform),emissiveTextureTransformMatrix:k(u.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:k(u.metallicRoughnessTextureTransform),...s}))}const f=i.get(l);if(r.stageResources.materials.push(f),a){const e=e=>{null!=e&&r.stageResources.textures.push(n.get(e))};e(u.textureColor),e(u.textureNormal),e(u.textureOcclusion),e(u.textureEmissive),e(u.textureMetallicRoughness)}return f}function te(e,r){const o=e.attributes.position.count,s=A(e.indices||o,e.primitiveType),i=p(3*o),{typedBuffer:n,typedBufferStride:l}=e.attributes.position;R(i,n,e.transform,3,l);const u=[[q.POSITION,new U(i,3,!0)]],a=[[q.POSITION,s]];if(null!=e.attributes.normal){const r=p(3*o),{typedBuffer:i,typedBufferStride:n}=e.attributes.normal;t(re,e.transform),w(r,i,re,3,n),u.push([q.NORMAL,new U(r,3,!0)]),a.push([q.NORMAL,s])}if(null!=e.attributes.tangent){const r=p(4*o),{typedBuffer:i,typedBufferStride:n}=e.attributes.tangent;t(re,e.transform),M(r,i,re,4,n),u.push([q.TANGENT,new U(r,4,!0)]),a.push([q.TANGENT,s])}if(null!=e.attributes.texCoord0){const t=p(2*o),{typedBuffer:r,typedBufferStride:i}=e.attributes.texCoord0;B(t,r,2,i),u.push([q.UV0,new U(t,2,!0)]),a.push([q.UV0,s])}if(null!=e.attributes.color){const t=new Uint8Array(4*o);4===e.attributes.color.elementCount?e.attributes.color instanceof g?j(t,e.attributes.color,255):e.attributes.color instanceof x?F(t,e.attributes.color):e.attributes.color instanceof b&&j(t,e.attributes.color,1/256):(t.fill(255),e.attributes.color instanceof h?v(t,e.attributes.color,255,4):e.attributes.color instanceof T?S(t,e.attributes.color.typedBuffer,4,e.attributes.color.typedBufferStride):e.attributes.color instanceof y&&v(t,e.attributes.color,1/256,4)),u.push([q.COLOR,new U(t,4,!0)]),a.push([q.COLOR,s])}return{geometry:new G(r,u,a),vertexCount:o}}const re=r();function oe(e){switch(e){case"BLEND":return V.Blend;case"MASK":return V.Mask;case"OPAQUE":case null:case void 0:return V.Opaque}}function se(e,t){for(let r=0;r<e.model.lods.length;++r){const f=e.model.lods[r];for(const d of f.parts){const f=d.attributes.normal;if(null==f)return;const p=d.attributes.position,g=p.count,b=m(),T=m(),y=m(),R=new Uint8Array(4*g),w=new Float64Array(3*g),v=o(s(),d.transform);let M=0,j=0;for(let o=0;o<g;o++){p.getVec(o,T),f.getVec(o,b),i(T,T,d.transform),n(y,T,t.center),l(y,y,t.radius);const s=y[2],m=u(y),g=Math.min(.45+.55*m*m,1);l(y,y,t.radius),null!==v&&i(y,y,v),a(y,y),r+1!==e.model.lods.length&&e.model.lods.length>1&&c(y,y,b,s>-1?.2:Math.min(-4*s-3.8,1)),w[M]=y[0],w[M+1]=y[1],w[M+2]=y[2],M+=3,R[j]=255*g,R[j+1]=255*g,R[j+2]=255*g,R[j+3]=255,j+=4}d.attributes.normal=new h(w),d.attributes.color=new x(R)}}}export{X as fetch,Z as gltfToEngineResources,Y as parseUrl};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import t from"../../../../core/Error.js";import{MIN_PRIORITY as o}from"../../../../core/MemCache.js";import{generateUUID as n}from"../../../../core/uuid.js";import{projectBoundingSphere as r,projectBuffer as s,canProjectWithoutEngine as a,isLoaded as l,load as i}from"../../../../geometry/projection.js";import{newDoubleArray as u}from"../../../../geometry/support/DoubleArray.js";import{k as d}from"../../../../chunks/sphere.js";import{project as c}from"../../../../geometry/support/meshUtils/georeference.js";import{loadImageAsync as m}from"../../../../support/requestUtils.js";import{EncodedMeshTexture as h}from"../../glTF/internal/resourceUtils.js";import{TextureUsage as f,TextureEncoding as p}from"./enums.js";import{CullFaceOptions as g}from"../../webgl-engine/lib/basicInterfaces.js";import{useSchematicPBR as x}from"../../webgl-engine/materials/pbrUtils.js";class y{constructor(e,t,o,n){this._id2Meta=new Map,this._oid2Meta=new Map,this._nextMeshNodeId=2,this._uid=e,this._indexSR=t,this._renderSR=o,this._memoryController=n,this._memCache=this._memoryController.newCache(`sl-client-mesh-data-${this._uid}`)}get indexSR(){return this._indexSR}get renderSR(){return this._renderSR}createMeshNodeInfo(e,t){const o="mesh"+this._nextMeshNodeId++,n=e.extent,s=n.spatialReference,a=this._indexSR,l=M(n,e.origin);r(l,s,l,a);return{type:"mesh",id:o,version:T(e),oid:t,mbs:l,componentNodeIds:[],unloadedMesh:e,nodeIndex:null,loadMeshPromise:null}}addMeshNode(e,t){t.nodeIndex=e,this._id2Meta.set(t.id,t),this._oid2Meta.set(t.oid,t)}getMeshNodeIndex(e){const t=this._oid2Meta.get(e);return null==t||"mesh"!==t.type?null:t.nodeIndex}removeNode(e){if(null==e)return;const t=this._id2Meta.get(e);null!=t&&(this._id2Meta.delete(e),"mesh"===t.type&&this._oid2Meta.delete(t.oid))}async loadNodeJSON(e){const o=this._id2Meta.get(e);if(null==o)throw new t(`I3SClientNodeLoader::loadNodeJSON unable to find node ${e}`);switch(o.type){case"mesh":return this._loadMeshNodeJSON(o);case"mesh-component":return this._loadMeshComponentNodeJSON(o);default:throw new t(`I3SClientNodeLoader::loadNodeJSON unable to handle node ${e}`)}}async _loadMeshNodeJSON(e){const t=e.id,o=(await this._getMeshData(e)).loadedMesh;if(null==o.components||0===o.components.length)return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null};const n=[],r=o.components;for(let s=0;s<r.length;++s){const o=`${t}-component${s}`,r={type:"mesh-component",id:o,mbs:e.mbs,componentIndex:s,meshNodeInfo:e,textureData:new Map};this._id2Meta.set(r.id,r),e.componentNodeIds.push(o),n.push({id:r.id,href:null,mbs:r.mbs,obb:null})}return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:n}}updateNodeIndex(e,t,o){if(null==e)return;const n=this._id2Meta.get(e);n&&"mesh"===n.type&&(n.nodeIndex=o)}async _loadMeshComponentNodeJSON(e){return{id:e.id,version:e.meshNodeInfo.version,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null,isEmpty:!1}}async loadNodeData(e,o){const n=e.id,r=this._id2Meta.get(n);if(null==r||"mesh-component"!==r.type)throw new t(`Failed to load client node data for node ${e.id} (unexpected node info)`);const a=r.meshNodeInfo,l=await this._getMeshData(a),i=l.loadedMesh,d=a.oid;if(null==i.components)throw new t(`Failed to load client node data for node ${e.id} (unexpected null reference)`);const m=i.components[r.componentIndex],{material:h,requiredTextures:f,textureData:p}=await w(m.material);if(null!=p)for(const t of p)null!=t&&r.textureData.set(t.id,t);const g={params:{material:h},type:"ArrayBufferView"},{vertexSpace:x,origin:y,transform:M}=i,b=y.x,I=y.y,_=y.z??0,v={featureDataPosition:[b,I,_],featureIds:[],geometries:[g]},T={attributeData:{},loadedAttributes:[]};let S=null;if(null==l.projectedVertices){const e=i.vertexAttributes.position;x.isRelative?S=c(i.spatialReference,M,x,e,this._indexSR):(S=u(e.length),s(e,i.spatialReference,0,S,this._indexSR,0,S.length/3));for(let t=0;t<S.length;t+=3)S[t]-=b,S[t+1]-=I,S[t+2]-=_;l.projectedVertices=S,l.usedMemoryInBytes+=8*S.length,this._memCache.updateSize(a.version,l,l.usedMemoryInBytes)}else S=l.projectedVertices;const{geometryBuffer:R,geometryDescriptor:D}=N(S,m.faces,i.vertexAttributes.normal,i.vertexAttributes.uv,i.vertexAttributes.color,d);return{geometryData:v,attributeDataInfo:T,geometryBuffer:R,geometryDescriptor:D,requiredTextures:f,textureData:p}}async loadAttributes(e,t,o){const n=e.numFeatures;for(const{field:{name:r}}of t)new Array(n);return{}}async loadTextures(e,t,o){const n=e.id,r=this._id2Meta.get(n);if(null==r||"mesh-component"!==r.type)throw new Error(`Failed to load textures for node ${e.id} (unexpected node info)`);const s=[];for(const a of t)s.push(r.textureData.get(a.id)||null);return s}async _getMeshData(e){const t=e.version,n=this._memCache.get(t);if(null==n){if(null!=e.loadMeshPromise)return e.loadMeshPromise;const n=async(n,r)=>{const s=e.unloadedMesh.clone();try{await s.load()}catch(c){r(c)}s.vertexSpace.isRelative||a(s.spatialReference,this._indexSR)||l()||await i();const u=s.memoryUsage,d={loadedMesh:s,projectedVertices:null,usedMemoryInBytes:u};this._memCache.put(t,d,u,o),e.loadMeshPromise=null,n(d)};return e.loadMeshPromise=new Promise(((e,t)=>n(e,t))),e.loadMeshPromise}return n}}function M(e,t){const o=[1,-1],n=[.5*e.width,.5*e.height,e.hasZ?.5*(e.zmax-e.zmin):0],r=e.center;let s=0;if(e.hasZ)for(let a=0;a<2;++a)for(let e=0;e<2;++e)for(let l=0;l<2;++l){const i=r.x+o[a]*n[0]-t.x,u=r.y+o[e]*n[1]-t.y,d=r.z+o[l]*n[2]-t.z;s=Math.max(i*i+u*u+d*d,s)}else for(let a=0;a<2;++a)for(let e=0;e<2;++e){const l=r.x+o[a]*n[0]-t.x,i=r.y+o[e]*n[1]-t.y;s=Math.max(l*l+i*i,s)}return d([t.x,t.y,t.z],Math.sqrt(s))}async function w(t){const o=[],n=[];if(null==t){return{material:{alphaMode:"opaque",alphaCutoff:.1,doubleSided:!0,cullFace:0,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[1,1,1,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6000000238418579},wrapTextures:!1,hasParametersFromSource:!0},requiredTextures:o,textureData:n}}const r=_(t);"auto"===t.alphaMode&&console.warn('alphaMode "auto" not supported by I3S PBRMaterial - defaulting to "blend".');return{material:{alphaMode:"auto"===t.alphaMode?"blend":t.alphaMode,alphaCutoff:t.alphaCutoff,doubleSided:t.doubleSided,cullFace:t.doubleSided?g.None:g.Back,normalTextureId:await b(t.normalTexture,o,n,f.Normal),emissiveTextureId:r?await b(t.emissiveTexture,o,n,f.Emissive):-1,occlusionTextureId:r?await b(t.occlusionTexture,o,n,f.Occlusion):-1,emissiveFactor:r&&null!=t.emissiveColor?e.toUnitRGB(t.emissiveColor):[0,0,0],metallicRoughness:{baseColorFactor:null!=t.color?e.toUnitRGBA(t.color):[1,1,1,1],baseColorTextureId:await b(t.colorTexture,o,n,f.Color),metallicRoughnessTextureId:r?await b(t.metallicRoughnessTexture,o,n,f.MetallicRoughness):-1,metallicFactor:r?t.metallic:0,roughnessFactor:r?t.roughness:0},wrapTextures:!0,hasParametersFromSource:x({normalTexture:t.normalTexture,emissiveTexture:r?t.emissiveTexture:null,emissiveFactor:r?e.toUnitRGBA(t.emissiveColor):null,occlusionTexture:r?t.occlusionTexture:null,metallicRoughnessTexture:r?t.metallicRoughnessTexture:null,metallicFactor:r?t.metallic:null,roughnessFactor:r?t.roughness:null})},requiredTextures:o,textureData:n}}async function b(e,o,n,r){if(null==e)return-1;const s=n.length,a=e.data,l=e.url;if(null!=a){if(a instanceof HTMLImageElement||a instanceof HTMLCanvasElement){const{data:e,downsampled:t}=I(a);return n.push({id:s,usage:r,data:e,encoding:p.PNG,downsampled:t}),o.push({id:s,usage:r,encodings:[{name:void 0,encoding:p.PNG}]}),s}if(a instanceof HTMLVideoElement)return-1;if(a instanceof ImageData)throw new t("ImageData textures not supported yet for client side I3S nodes");if(a instanceof h)throw new t("EncodedMeshTexture textures not supported yet for client side I3S nodes")}else if(null!=l){const e=new Image;e.src=l;const t=await m(e,e.src,!1,void 0),{data:a,downsampled:i}=I(t);return n.push({id:s,usage:r,data:a,encoding:p.PNG,downsampled:i}),o.push({id:s,usage:r,encodings:[{name:void 0,encoding:p.PNG}]}),s}return-1}function I(e){const t=1048576,o=4096,n=2;let r=e.width*e.height;if(r>=o){let o=e.width,s=e.height;do{o=Math.ceil(o/n),s=Math.ceil(s/n),r=o*s}while(r>t);const a=document.createElement("canvas");a.width=o,a.height=s;return a.getContext("2d").drawImage(e,0,0,o,s),{data:a,downsampled:!0}}return{data:e,downsampled:!1}}function _(e){return e.hasOwnProperty("metallicRoughnessTexture")}function N(e,t,o,n,r,s){const a=1,l=t.length/3,i=3*l;let u=0,d=0,c=!1,m=0,h=!1,f=0,p=!1,g=0,x=0,y=0;u+=S,u+=S,d=u,u+=3*i*R,null!=o&&(c=!0,m=u,u+=3*i*R),null!=n&&(h=!0,f=u,u+=2*i*R),null!=r&&(p=!0,g=u,u+=4*i*D),x=u,u+=a*C,y=u,u+=2*a*S;const M=new ArrayBuffer(u),w=new Uint8Array(M);v(w,0,i),v(w,S,a);const b=new Float32Array(M,d),I=null!=o?new Float32Array(M,m):null,_=null!=n?new Float32Array(M,f):null,N=null!=r?new Uint8Array(M,g):null;for(let v=0;v<l;++v){const s=3*v;for(let a=0;a<3;++a){const l=t[s+a],i=3*l,u=9*v+3*a;if(b[u]=e[i],b[u+1]=e[i+1],b[u+2]=e[i+2],null!=I&&(I[u]=o[i],I[u+1]=o[i+1],I[u+2]=o[i+2]),null!=_){const e=2*l,t=6*v+2*a;_[t]=n[e],_[t+1]=n[e+1]}if(null!=N){const e=4*l,t=12*v+4*a;N[t]=r[e],N[t+1]=r[e+1],N[t+2]=r[e+2],N[t+3]=r[e+3]}}}v(w,x,s),v(w,x+S,s/2**32),v(w,y,0),v(w,y+S,l-1);return{geometryBuffer:M,geometryDescriptor:{isDraco:!1,isLegacy:!0,color:p,normal:c,uv0:h,uvRegion:!1,featureIndex:!0}}}function v(e,t,o){e[t]=255&o,e[t+1]=255&o>>8,e[t+2]=255&o>>16,e[t+3]=255&o>>24}function T(e){const t=e.metadata.displaySource?.source;if(null==t||!Array.isArray(t)||!t.length||t[0]instanceof File)return n();const o=t;let r="";for(const n of o)r+=n.makeHash();return r+JSON.stringify(null!=e.transform?e.transform.toJSON():"")}const S=4,R=4,D=1,C=8;export{y as I3SClientNodeLoader,N as createGeometryData};
|
|
5
|
+
import e from"../../../../Color.js";import t from"../../../../core/Error.js";import{MIN_PRIORITY as o}from"../../../../core/MemCache.js";import{generateUUID as n}from"../../../../core/uuid.js";import{projectBoundingSphere as r,projectBuffer as s,canProjectWithoutEngine as a,isLoaded as l,load as i}from"../../../../geometry/projection.js";import{newDoubleArray as u}from"../../../../geometry/support/DoubleArray.js";import{k as d}from"../../../../chunks/sphere.js";import{project as c}from"../../../../geometry/support/meshUtils/georeference.js";import{loadImageAsync as m}from"../../../../support/requestUtils.js";import{EncodedMeshTexture as h}from"../../glTF/internal/resourceUtils.js";import{TextureUsage as f,TextureEncoding as p}from"./enums.js";import{CullFaceOptions as g}from"../../webgl-engine/lib/basicInterfaces.js";import{useSchematicPBR as x}from"../../webgl-engine/materials/pbrUtils.js";class y{constructor(e,t,o,n){this._uid=e,this._indexSR=t,this._renderSR=o,this._id2Meta=new Map,this._oid2Meta=new Map,this._nextMeshNodeId=2,this._memCache=n.newCache(`sl-client-mesh-data-${this._uid}`)}get indexSR(){return this._indexSR}get renderSR(){return this._renderSR}createMeshNodeInfo(e,t){const o="mesh"+this._nextMeshNodeId++,n=e.extent,s=n.spatialReference,a=this._indexSR,l=M(n,e.origin);r(l,s,l,a);return{type:"mesh",id:o,version:_(e),oid:t,mbs:l,componentNodeIds:[],unloadedMesh:e,nodeIndex:null,loadMeshPromise:null}}addMeshNode(e,t){t.nodeIndex=e,this._id2Meta.set(t.id,t),this._oid2Meta.set(t.oid,t)}getMeshNodeIndex(e){const t=this._oid2Meta.get(e);return null==t||"mesh"!==t.type?null:t.nodeIndex}removeNode(e){if(null==e)return;const t=this._id2Meta.get(e);null!=t&&(this._id2Meta.delete(e),"mesh"===t.type&&this._oid2Meta.delete(t.oid))}async loadNodeJSON(e){const o=this._id2Meta.get(e);if(null==o)throw new t(`I3SClientNodeLoader::loadNodeJSON unable to find node ${e}`);switch(o.type){case"mesh":return this._loadMeshNodeJSON(o);case"mesh-component":return this._loadMeshComponentNodeJSON(o);default:throw new t(`I3SClientNodeLoader::loadNodeJSON unable to handle node ${e}`)}}async _loadMeshNodeJSON(e){const t=e.id,o=(await this._getMeshData(e)).loadedMesh;if(null==o.components||0===o.components.length)return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null};const n=[],r=o.components;for(let s=0;s<r.length;++s){const o=`${t}-component${s}`,r={type:"mesh-component",id:o,mbs:e.mbs,componentIndex:s,meshNodeInfo:e,textureData:new Map};this._id2Meta.set(r.id,r),e.componentNodeIds.push(o),n.push({id:r.id,href:null,mbs:r.mbs,obb:null})}return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:n}}updateNodeIndex(e,t,o){if(null==e)return;const n=this._id2Meta.get(e);n&&"mesh"===n.type&&(n.nodeIndex=o)}async _loadMeshComponentNodeJSON(e){return{id:e.id,version:e.meshNodeInfo.version,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null,isEmpty:!1}}async loadNodeData(e,o){const n=e.id,r=this._id2Meta.get(n);if(null==r||"mesh-component"!==r.type)throw new t(`Failed to load client node data for node ${e.id} (unexpected node info)`);const a=r.meshNodeInfo,l=await this._getMeshData(a),i=l.loadedMesh,d=a.oid;if(null==i.components)throw new t(`Failed to load client node data for node ${e.id} (unexpected null reference)`);const m=i.components[r.componentIndex],{material:h,requiredTextures:f,textureData:p}=await w(m.material);if(null!=p)for(const t of p)null!=t&&r.textureData.set(t.id,t);const g={params:{material:h},type:"ArrayBufferView"},{vertexSpace:x,origin:y,transform:M}=i,b=y.x,I=y.y,N=y.z??0,T={featureDataPosition:[b,I,N],featureIds:[],geometries:[g]},_={attributeData:{},loadedAttributes:[]};let S=null;if(null==l.projectedVertices){const e=i.vertexAttributes.position;x.isRelative?S=c(i.spatialReference,M,x,e,this._indexSR):(S=u(e.length),s(e,i.spatialReference,0,S,this._indexSR,0,S.length/3));for(let t=0;t<S.length;t+=3)S[t]-=b,S[t+1]-=I,S[t+2]-=N;l.projectedVertices=S,l.usedMemoryInBytes+=8*S.length,this._memCache.updateSize(a.version,l,l.usedMemoryInBytes)}else S=l.projectedVertices;const{geometryBuffer:R,geometryDescriptor:D}=v(S,m.faces,i.vertexAttributes.normal,i.vertexAttributes.uv,i.vertexAttributes.color,d);return{geometryData:T,attributeDataInfo:_,geometryBuffer:R,geometryDescriptor:D,requiredTextures:f,textureData:p}}async loadAttributes(e,t,o){const n=e.numFeatures;for(const{field:{name:r}}of t)new Array(n);return{}}async loadTextures(e,t,o){const n=e.id,r=this._id2Meta.get(n);if(null==r||"mesh-component"!==r.type)throw new Error(`Failed to load textures for node ${e.id} (unexpected node info)`);const s=[];for(const a of t)s.push(r.textureData.get(a.id)||null);return s}async _getMeshData(e){const t=e.version,n=this._memCache.get(t);if(null==n){if(null!=e.loadMeshPromise)return e.loadMeshPromise;const n=async(n,r)=>{const s=e.unloadedMesh.clone();try{await s.load()}catch(c){r(c)}s.vertexSpace.isRelative||a(s.spatialReference,this._indexSR)||l()||await i();const u=s.memoryUsage,d={loadedMesh:s,projectedVertices:null,usedMemoryInBytes:u};this._memCache.put(t,d,u,o),e.loadMeshPromise=null,n(d)};return e.loadMeshPromise=new Promise(((e,t)=>n(e,t))),e.loadMeshPromise}return n}}function M(e,t){const o=[1,-1],n=[.5*e.width,.5*e.height,e.hasZ?.5*(e.zmax-e.zmin):0],r=e.center;let s=0;if(e.hasZ)for(let a=0;a<2;++a)for(let e=0;e<2;++e)for(let l=0;l<2;++l){const i=r.x+o[a]*n[0]-t.x,u=r.y+o[e]*n[1]-t.y,d=r.z+o[l]*n[2]-t.z;s=Math.max(i*i+u*u+d*d,s)}else for(let a=0;a<2;++a)for(let e=0;e<2;++e){const l=r.x+o[a]*n[0]-t.x,i=r.y+o[e]*n[1]-t.y;s=Math.max(l*l+i*i,s)}return d([t.x,t.y,t.z],Math.sqrt(s))}async function w(t){const o=[],n=[];if(null==t){return{material:{alphaMode:"opaque",alphaCutoff:.1,doubleSided:!0,cullFace:0,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[1,1,1,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6000000238418579},wrapTextures:!1,hasParametersFromSource:!0},requiredTextures:o,textureData:n}}const r=N(t);"auto"===t.alphaMode&&console.warn('alphaMode "auto" not supported by I3S PBRMaterial - defaulting to "blend".');return{material:{alphaMode:"auto"===t.alphaMode?"blend":t.alphaMode,alphaCutoff:t.alphaCutoff,doubleSided:t.doubleSided,cullFace:t.doubleSided?g.None:g.Back,normalTextureId:await b(t.normalTexture,o,n,f.Normal),emissiveTextureId:r?await b(t.emissiveTexture,o,n,f.Emissive):-1,occlusionTextureId:r?await b(t.occlusionTexture,o,n,f.Occlusion):-1,emissiveFactor:r&&null!=t.emissiveColor?e.toUnitRGB(t.emissiveColor):[0,0,0],metallicRoughness:{baseColorFactor:null!=t.color?e.toUnitRGBA(t.color):[1,1,1,1],baseColorTextureId:await b(t.colorTexture,o,n,f.Color),metallicRoughnessTextureId:r?await b(t.metallicRoughnessTexture,o,n,f.MetallicRoughness):-1,metallicFactor:r?t.metallic:0,roughnessFactor:r?t.roughness:0},wrapTextures:!0,hasParametersFromSource:x({normalTexture:t.normalTexture,emissiveTexture:r?t.emissiveTexture:null,emissiveFactor:r?e.toUnitRGBA(t.emissiveColor):null,occlusionTexture:r?t.occlusionTexture:null,metallicRoughnessTexture:r?t.metallicRoughnessTexture:null,metallicFactor:r?t.metallic:null,roughnessFactor:r?t.roughness:null})},requiredTextures:o,textureData:n}}async function b(e,o,n,r){if(null==e)return-1;const s=n.length,a=e.data,l=e.url;if(null!=a){if(a instanceof HTMLImageElement||a instanceof HTMLCanvasElement){const e=I(a);return n.push({id:s,usage:r,data:e,encoding:p.PNG,downsampled:!1}),o.push({id:s,usage:r,encodings:[{name:void 0,encoding:p.PNG}]}),s}if(a instanceof HTMLVideoElement)return-1;if(a instanceof ImageData)throw new t("ImageData textures not supported yet for client side I3S nodes");if(a instanceof h)throw new t("EncodedMeshTexture textures not supported yet for client side I3S nodes")}else if(null!=l){const e=new Image;e.src=l;const t=I(await m(e,e.src,!1,void 0));return n.push({id:s,usage:r,data:t,encoding:p.PNG,downsampled:!1}),o.push({id:s,usage:r,encodings:[{name:void 0,encoding:p.PNG}]}),s}return-1}function I(e){const t=1048576,o=4096,n=2;let r=e.width*e.height;if(r>=o){let o=e.width,s=e.height;do{o=Math.ceil(o/n),s=Math.ceil(s/n),r=o*s}while(r>t);const a=document.createElement("canvas");a.width=o,a.height=s;return a.getContext("2d").drawImage(e,0,0,o,s),a}return e}function N(e){return e.hasOwnProperty("metallicRoughnessTexture")}function v(e,t,o,n,r,s){const a=1,l=t.length/3,i=3*l;let u=0,d=0,c=!1,m=0,h=!1,f=0,p=!1,g=0,x=0,y=0;u+=S,u+=S,d=u,u+=3*i*R,null!=o&&(c=!0,m=u,u+=3*i*R),null!=n&&(h=!0,f=u,u+=2*i*R),null!=r&&(p=!0,g=u,u+=4*i*D),x=u,u+=a*C,y=u,u+=2*a*S;const M=new ArrayBuffer(u),w=new Uint8Array(M);T(w,0,i),T(w,S,a);const b=new Float32Array(M,d),I=null!=o?new Float32Array(M,m):null,N=null!=n?new Float32Array(M,f):null,v=null!=r?new Uint8Array(M,g):null;for(let T=0;T<l;++T){const s=3*T;for(let a=0;a<3;++a){const l=t[s+a],i=3*l,u=9*T+3*a;if(b[u]=e[i],b[u+1]=e[i+1],b[u+2]=e[i+2],null!=I&&(I[u]=o[i],I[u+1]=o[i+1],I[u+2]=o[i+2]),null!=N){const e=2*l,t=6*T+2*a;N[t]=n[e],N[t+1]=n[e+1]}if(null!=v){const e=4*l,t=12*T+4*a;v[t]=r[e],v[t+1]=r[e+1],v[t+2]=r[e+2],v[t+3]=r[e+3]}}}T(w,x,s),T(w,x+S,s/2**32),T(w,y,0),T(w,y+S,l-1);return{geometryBuffer:M,geometryDescriptor:{isDraco:!1,isLegacy:!0,color:p,normal:c,uv0:h,uvRegion:!1,featureIndex:!0}}}function T(e,t,o){e[t]=255&o,e[t+1]=255&o>>8,e[t+2]=255&o>>16,e[t+3]=255&o>>24}function _(e){const t=e.metadata.displaySource?.source;if(null==t||!Array.isArray(t)||!t.length||t[0]instanceof File)return n();const o=t;let r="";for(const n of o)r+=n.makeHash();return r+JSON.stringify(null!=e.transform?e.transform.toJSON():"")}const S=4,R=4,D=1,C=8;export{y as I3SClientNodeLoader,v as createGeometryData};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"../../../../core/has.js";import{clamp as e}from"../../../../core/mathUtils.js";import{TextureEncoding as
|
|
5
|
+
import has from"../../../../core/has.js";import{clamp as e}from"../../../../core/mathUtils.js";import{TextureEncoding as o,TextureUsage as a}from"./enums.js";import{RenderTexture as r}from"../../webgl-engine/core/material/RenderTexture.js";import{defaultMaskAlphaCutoff as s}from"../../webgl-engine/core/shaderLibrary/util/AlphaCutoff.js";import{getEllipsoidMode as t}from"../../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{TextureEncodingMimeType as l,CullFaceOptions as n,AlphaDiscardMode as i}from"../../webgl-engine/lib/basicInterfaces.js";import{Texture as u}from"../../webgl-engine/lib/Texture.js";import{useSchematicPBR as c,defaultSchematicMRRFactors as m,defaultAdvancedMRRFactors as d}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as p}from"../../../webgl/enums.js";function g(e,o){const r=new Map,s=(e,o)=>{if(null==e)return-1;const a=r.get(e.id);if(a)return a.usage|=o,a.id;const s=r.size;return r.set(e.id,{id:s,usage:o}),s},t=o.pbrMetallicRoughness,l=t?.baseColorFactor,i=o.emissiveFactor,u=c({normalTexture:o.normalTexture,emissiveTexture:o.emissiveTexture,emissiveFactor:o.emissiveFactor,occlusionTexture:o.occlusionTexture,metallicRoughnessTexture:t?.metallicRoughnessTexture,metallicFactor:t?.metallicFactor,roughnessFactor:t?.roughnessFactor}),p=u?m[0]:t?.metallicFactor??d[0],g=u?m[1]:t?.roughnessFactor??d[1],T="mask"===o.alphaMode?a.Color|a.AlphaMask:a.Color,x={baseColorFactor:l?[l[0],l[1],l[2],l[3]]:[1,1,1,1],baseColorTextureId:s(t&&t.baseColorTexture,T),metallicRoughnessTextureId:s(t&&t.metallicRoughnessTexture,a.MetallicRoughness),metallicFactor:p,roughnessFactor:g},b={alphaMode:o.alphaMode,alphaCutoff:o.alphaCutoff,doubleSided:o.doubleSided,cullFace:"none"===o.cullFace?n.None:"back"===o.cullFace?n.Back:"front"===o.cullFace?n.Front:n.None,normalTextureId:s(o.normalTexture,a.Normal),emissiveTextureId:s(o.emissiveTexture,a.Emissive),occlusionTextureId:s(o.occlusionTexture,a.Occlusion),emissiveFactor:i?[i[0],i[1],i[2]]:[0,0,0],metallicRoughness:x,wrapTextures:!1,hasParametersFromSource:u},F=[];return r.forEach((({usage:o},a)=>{const r=null!=e&&e[a]&&e[a].formats,s=r?h(r.map((({name:e,format:o})=>({name:e,encoding:f[o]})))):[];F.push({id:a,usage:o,encodings:s})})),{material:b,textures:F}}function h(e){return e.sort(((e,o)=>e.encoding-o.encoding))}const f={ktx2:o.KTX2,basis:o.Basis,dds:o.DDS_S3TC,png:o.PNG,jpg:o.JPG,"ktx-etc2":o.KTX_ETC2},T={[l.KTX2_ENCODING]:o.Basis,[l.BASIS_ENCODING]:o.Basis,[l.DDS_ENCODING]:o.DDS_S3TC,"image/png":o.PNG,"image/jpg":o.JPG,"image/jpeg":o.JPG,"image/ktx":o.KTX_ETC2};function x(o){const r=o&&o.materialDefinitions?Object.keys(o.materialDefinitions)[0]:null,s=o&&o.textureDefinitions?Object.keys(o.textureDefinitions)[0]:null,t=r?o.materialDefinitions?.[r]:null,l=s?o.textureDefinitions?.[s]:null,i=b();if(null!=t){const o=t.params;o.diffuse&&(i.metallicRoughness.baseColorFactor=[o.diffuse[0],o.diffuse[1],o.diffuse[2],1]),null!=o.doubleSided&&(i.doubleSided=o.doubleSided,i.cullFace=o.doubleSided?n.None:n.Back),"none"!==o.cullFace&&"front"!==o.cullFace&&"back"!==o.cullFace||(i.cullFace="none"===o.cullFace?n.None:"back"===o.cullFace?n.Back:n.Front),o.transparency&&(i.metallicRoughness.baseColorFactor[3]=e(1-o.transparency,0,1)),(o.useVertexColorAlpha||i.metallicRoughness.baseColorFactor[3]<1)&&(i.alphaMode="blend")}const u=[];if(null!=l){const e=0;!l.wrap||"repeat"!==l.wrap[0]&&"repeat"!==l.wrap[1]||(i.wrapTextures=!0);let o=a.Color;"rgba"===l.channels&&(i.alphaMode="blend",o|=a.AlphaMask);const r=l.images.length-1,s=l.images[r],t=e=>e&&e.split("/").pop(),n=Array.isArray(l.encoding)?h(l.encoding.map(((e,o)=>({name:t(s.href[o]),encoding:T[e]||0})))):[{name:t(s.href),encoding:T[l.encoding]||0}];u.push({id:e,usage:o,encodings:n}),i.metallicRoughness.baseColorTextureId=e}return{material:i,textures:u}}const b=()=>({alphaMode:"opaque",alphaCutoff:s,doubleSided:!0,cullFace:n.None,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[.8,.8,.8,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6},wrapTextures:!1,hasParametersFromSource:!0});function F(e,o,r,s){if(null==e||null==e.data)return null;const t=e.data,l=s.renderingContext.parameters.maxMaxAnisotropy,n=!e.downsampled&&l>1,i=r||!o.wrapTextures?C:P,c=w(e.encoding),m=e.usage&a.Color?"opaque"===o.alphaMode?3:4:3;return new u(t,{mipmap:n,maxAnisotropy:l,encoding:c,wrap:i,components:m,noUnpackFlip:!0})}const C={s:p.CLAMP_TO_EDGE,t:p.CLAMP_TO_EDGE},P={s:p.REPEAT,t:p.REPEAT};function S(o,l,n,u,c,p){const g=p.rendererTextureUsage,h=e=>R(u,n,e&g),f=l.metallicRoughness.baseColorFactor,T=e(l.metallicRoughness.baseColorFactor[3],0,1);o.baseColor=[f[0],f[1],f[2],T],o.hasParametersFromSource=!!l.hasParametersFromSource,o.usePBR=p.usePBR,o.mrrFactors=[l.metallicRoughness.metallicFactor,l.metallicRoughness.roughnessFactor,l.hasParametersFromSource?m[2]:d[2]],o.emissiveFactor=l.emissiveFactor,o.isIntegratedMesh=p.isIntegratedMesh,o.textureAlphaCutoff="mask"===l.alphaMode?l.alphaCutoff:s,o.alphaDiscardMode="opaque"===l.alphaMode?i.Opaque:"mask"===l.alphaMode?i.Mask:i.MaskBlend;const x=[],b=h(a.Color|a.AlphaMask);null!=b&&(o.baseColorTexture=new r(c,b),x.push(o.baseColorTexture.loadPromise));const F=h(a.MetallicRoughness);null!=F&&(o.metallicRoughnessTexture=new r(c,F),x.push(o.metallicRoughnessTexture.loadPromise));const C=h(a.Emissive);null!=C&&(o.emissionTexture=new r(c,C),x.push(o.emissionTexture.loadPromise));const P=h(a.Occlusion);null!=P&&(o.occlusionTexture=new r(c,P),x.push(o.occlusionTexture.loadPromise));const S=h(a.Normal);return null!=S&&(o.normalTexture=new r(c,S),x.push(o.normalTexture.loadPromise)),o.commonMaterialParameters.hasSlicePlane=p.slicePlaneEnabled,o.commonMaterialParameters.doubleSided=l.doubleSided,o.commonMaterialParameters.cullFace=l.cullFace,o.ellipsoidMode=t(p.viewSpatialReference),Promise.all(x)}function M(e){const a=!!e.compressedTextureS3TC,r=!!e.compressedTextureETC,s=has("disable-feature:i3s-basis")?0:o.Basis|o.KTX2,t=o.JPG|o.PNG,l=s|o.DDS_S3TC;return t|(a?l:0)|(r?s:0)}function D(e,o){if(null!=o)return e.find((e=>0!=(e.encoding&o)))}function R(e,o,r){if(null==e||r===a.None)return null;for(let a=0;a<e.length;a++){const s=e[a];if(null!=s&&0!=(s.usage&r)){const e=o[a];return null!=e?e.id:null}}return null}function w(e){switch(e){case o.KTX2:return l.KTX2_ENCODING;case o.Basis:return l.BASIS_ENCODING;case o.DDS_S3TC:return l.DDS_ENCODING;case o.PNG:return"image/png";case o.JPG:return"image/jpeg";case o.KTX_ETC2:return"image/ktx";default:return""}}export{S as configureMaterial,F as createTexture,b as defaultMaterial,g as getMaterialAndTextures,x as getMaterialAndTexturesFromShared,M as getSupportedEncodings,D as selectEncoding};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../request.js";import s from"../../../../core/Accessor.js";import{splitIntoChunks as i}from"../../../../core/arrayUtils.js";import{resultOrAbort as r,result as o}from"../../../../core/asyncUtils.js";import{estimateStringByteSize as n,estimateNumberByteSize as a}from"../../../../core/byteSizeEstimations.js";import d from"../../../../core/Collection.js";import c from"../../../../core/Logger.js";import{destroyMaybe as h,abortMaybe as l}from"../../../../core/maybe.js";import{whenOrAbort as u}from"../../../../core/promiseUtils.js";import{watch as m,initial as g}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/has.js";import{subclass as y}from"../../../../core/accessorSupport/decorators/subclass.js";import{formatNumber as _}from"../../../../intl/number.js";import{getMaximumQuerySize as b,queryAllJSON as f}from"../../../../layers/support/featureQueryAll.js";import{assetMapFromAssetMapsJSON as O,extractMesh as C}from"../../../../rest/support/meshFeatureSet.js";import{direct3DObjectFeatureLayerDisplayEnabled as j,i3sPatchingEnabled as I,sceneLayerEditingEnabled as v}from"../../../../support/featureFlags.js";import F from"../FeatureLayerView3D.js";let A=class extends s{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._maximumNumberOfEditOVerrides=x,this._original3DOFLDefinitionExpression=null,this._interactiveEditingSessions=new d,this.geometryOverrides=new d,this._clientGeometryCache=new Map,this._associatedLayerView=null,this._attributeChangedObjectIds=new Set,this._geometryChangedObjectIds=new Set,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController}initialize(){this._memCache=this.memoryController.newCache(`i3s-attribute-overrides-${this.layer.uid}`),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.then((async()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null})),this.is3DOFL&&null!=this._associatedLayer&&(j()?this._associatedLayer.load().then((e=>{this.destroyed||(this._original3DOFLDefinitionExpression=e.definitionExpression,this.addHandles(m((()=>this._definitionExpression),(t=>e.definitionExpression=t),g)),this._associatedLayerView=new F({layer:this._associatedLayer,view:this.view}))})):I())}destroy(){this.is3DOFL&&null!=this._associatedLayer&&(j()?null!=this._associatedLayerView&&(this._associatedLayer.definitionExpression=this._original3DOFLDefinitionExpression):I()),this._set("layer",null),this._memCache=h(this._memCache),this._pendingFetchAbortController=l(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null}get is3DOFL(){return v()&&null!=this._associatedLayer&&null!=this._associatedLayer.infoFor3D}get sortedGeometryChangedObjectIds(){return this.is3DOFL?[...this._geometryChangedObjectIds].sort(((e,t)=>e-t)):[]}get _associatedLayer(){return null==this.layer?null:this.layer.associatedLayer}get _definitionExpression(){const e=this.sortedGeometryChangedObjectIds;return 0===e.length?"1 = 0":`OBJECTID IN (${e.join(",")})`}get updating(){if(!this.is3DOFL)return!1;if(j()){return!(null!=this._associatedLayerView)||null!=this._associatedLayerView&&this._associatedLayerView.updating}return I(),!1}get isEmpty(){return null==this._pendingFetchChangedObjectIds&&0===this._attributeChangedObjectIds.size&&0===this._geometryChangedObjectIds.size}createInteractiveEditSession(e){this._attributeChangedObjectIds.add(e),this.notifyChange("_attributeChangedObjectIds");const t=v()&&I()&&null!=this.is3DOFL,s=this._interactiveEditingSessions,i=new L(e,{rollback:()=>{s.remove(i)},commit:(s,i)=>{for(const[t,r]of s)this.updateAttributeValue(e,t,r);t&&null!=i&&this.updateGeometry(e,i)}});return s.unshift(i),i}async applyAttributeOverrides(e,t,s){if(null==t)return;const{loadedAttributes:i,attributeData:r}=t;if(null==i||0===i.length||null==r)return;if(this._pendingFetchChangedObjectIds&&await u(this._pendingFetchChangedObjectIds,s),0===this._attributeChangedObjectIds.size)return;const o={loadedAttributes:i,attributeData:r},n=this._getOverridesFromCache(e,o,this._attributeChangedObjectIds),{objectIds:a,fieldNames:d}=n;if(0===a.length||0===d.length)return;const c=await this._queryOverridesFromAssociatedLayer(a,d,!1,s);null!=c&&this._processOverridesFromAssociatedLayer(e,c,d,o)}updateGeometry(e,t){this._geometryChangedObjectIds.add(e);const s=this._clientGeometryCache.get(e);if(null!=s&&(this.geometryOverrides.remove(s),this._clientGeometryCache.delete(e)),null!=t){const s={oid:e,mesh:t};this.geometryOverrides.add(s),this._clientGeometryCache.set(e,s)}this.notifyChange("_geometryChangedObjectIds")}updateAttributeValue(e,t,s){this._attributeChangedObjectIds.add(e),this._cacheAttributeValue(e,t,s),this.notifyChange("_attributeChangedObjectIds")}_cacheAttributeValue(e,t,s){this._memCache.put(this._getAttributeCacheKey(e,t),s,this._memCacheAttributeValueSize(s))}_cacheGeometry(e,t){this._memCache.put(this._getGeometryCacheKey(e),t,this._memCacheGeometrySize(t))}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:s},i){const r=new Set,o=new Array;if(this.is3DOFL&&0===Object.keys(s).length)return{objectIds:Array.from(e),fieldNames:t.map((e=>e.name))};for(const a of t)o[a.index]=s[a.name];const n=new Set;for(let a=0;a<e.length;a++){const s=e[a];if(i.has(s))for(const e of t){const t=this._attributeFromCache(s,e.index);void 0===t?(r.add(s),n.add(e.name)):o[e.index][a]=t}}return{objectIds:Array.from(r),fieldNames:Array.from(n)}}_attributeFromCache(e,t){const s=this._fromInteractiveEditingSession(e,t);if(void 0!==s)return s;const i=this._getAttributeCacheKey(e,t);return this._memCache.get(i)}_fromInteractiveEditingSession(e,t){if(null!=this._interactiveEditingSessions)for(const s of this._interactiveEditingSessions){if(s.objectId!==e)continue;const i=s.getAttribute(t);if(void 0!==i)return i}}_getAttributeCacheKey(e,t){return`${e}-${t}`}_getGeometryCacheKey(e){return`${e}-geometry`}async _queryOverridesFromAssociatedLayer(e,t,s,o){if(0===e.length||!1===s&&0===t.length)return null;e=e.sort(((e,t)=>e-t)),this._warnMaximumChangedObjectsExceeded&&(this._warnMaximumChangedObjectsExceeded=!1,this._logMaximumObjectsExceededWarning());const n=this.layer.associatedLayer;if(null==n)return null;const a=s&&this.is3DOFL&&I(),d=[n.objectIdField,...t];a&&null!=n.globalIdField&&d.push(n.globalIdField);const c=n.createQuery();c.where="1=1",c.returnGeometry=s,c.outFields=d,c.cacheHint=!0,c.objectIds=e;const h=b(n),l=e.length>h?i(e,h).map((e=>{const t=c.clone();return t.objectIds=e,r(f(n,t,{signal:o}))})):[r(f(n,c,{signal:o}))],u=await Promise.all(l);if(a&&null!=n.infoFor3D){const e=n.infoFor3D,t=n.spatialReference,s=[];for(const i of u){if(!i.ok)continue;const r=i.value;if(null==r.assetMaps)continue;const o=O(e,r.assetMaps);for(const i of r.features){const n=C(i,r.globalIdFieldName,t,e,o),a=i;null!=n?(a.geometry=n,s.push(a)):a.geometry=null}}return s}return u.reduce(((e,t)=>e.concat(t.ok?t.value.features:[])),[])}_logMaximumObjectsExceededWarning(){let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${_(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`;const t=this.layer.portalItem;t&&t.loaded?e+=` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:e+=` (${this.layer.parsedUrl.path})`,c.getLogger("esri.views.3d.layers.i3s.I3SOverrides").warn("#queryOverrides()",this.layer.title,`${e}.`)}_processOverridesFromAssociatedLayer(e,t,s,{loadedAttributes:i,attributeData:r}){const o=this._associatedLayer;if(null==o)return;const n=o.objectIdField,a=s.map((t=>(t in r||(r[t]=new Array(e.length)),r[t]))),d=new Map(i.map((e=>[e.name,e.index]))),c=s.map((e=>d.get(e))),h=new Map(Array.from(e,((e,t)=>[e,t])));for(const l of t){const e=l.attributes[n];for(let t=0;t<s.length;t++){const i=c[t],r=h.get(e),o=l.attributes[s[t]];a[t][r]=o,this._cacheAttributeValue(e,i,o)}}}_memCacheAttributeValueSize(e){return"string"==typeof e?n(e):a()}_memCacheGeometrySize(e){return 256}async _fetchChangedObjectIds(e){const s=this.layer;await s.load({signal:e}),this._geometryChangedObjectIds.clear(),this._attributeChangedObjectIds.clear();const{associatedLayer:i}=s;if(null==i||!i.capabilities?.operations?.supportsChangeTracking)return;const r=this._getFetchChangedObjectIdsServerGen();if(null==r)return;const n=i.layerId,a=this.is3DOFL,d={f:"json",returnIdsOnly:!0,layers:`[${n}]`,returnUpdates:!0,returnDeletes:a,returnInserts:a,layerServerGens:JSON.stringify([{id:n,serverGen:r}])};if(a){const e=i.infoFor3D;d.fieldsToCompare=JSON.stringify({fields:[...Object.values(e.transformFieldRoles),e.sourceHashField]})}const c=await o(t(`${i.url}/extractChanges`,{method:"post",query:d,timeout:w,signal:e}));if(c.ok&&1===c.value.data?.edits?.length){const t=c.value.data.edits[0],s=t?.objectIds,r=t?.fieldUpdates,o=s?.adds??[],n=s?.updates??[],a=s?.deletes??[],d=[...o,...n,...a],h=[...o,...r??n,...a],l=Math.min(this._maximumNumberOfEditOVerrides,d.length);l<d.length&&(this._warnMaximumChangedObjectsExceeded=!0);const u=d.sort(((e,t)=>e-t));for(let e=0;e<l;++e){const t=u[e];this._attributeChangedObjectIds.add(t)}for(const e of h)this._geometryChangedObjectIds.add(e);if(this.is3DOFL&&I()&&this._geometryChangedObjectIds.size>0){const t=await this._queryOverridesFromAssociatedLayer(Array.from(this._geometryChangedObjectIds),[],!0,e);if(null!=t)for(const e of t)null!=e.geometry&&this.updateGeometry(e.attributes[i.objectIdField],e.geometry)}}this.notifyChange("_attributeChangedObjectIds"),this.notifyChange("_geometryChangedObjectIds")}_getFetchChangedObjectIdsServerGen(){const e=this.layer;if(null!=e.serviceUpdateTimeStamp&&null!=e.serviceUpdateTimeStamp.lastUpdate)return e.serviceUpdateTimeStamp.lastUpdate;const t=e.associatedLayer;return null!=t&&null!=t.serverGens&&null!=t.serverGens.minServerGen?t.serverGens.minServerGen:null}get test(){const e=Array.from(this._attributeChangedObjectIds),t=this._pendingFetchChangedObjectIds,s=this;return{changedObjectIds:e,pendingFetchChangedObjectIds:t,get maximumNumberOfEditOVerrides(){return s._maximumNumberOfEditOVerrides},set maximumNumberOfEditOVerrides(e){s._maximumNumberOfEditOVerrides=e}}}};e([p({constructOnly:!0})],A.prototype,"view",void 0),e([p({constructOnly:!0})],A.prototype,"layer",void 0),e([p({readOnly:!0})],A.prototype,"is3DOFL",null),e([p()],A.prototype,"_interactiveEditingSessions",void 0),e([p({readOnly:!0})],A.prototype,"sortedGeometryChangedObjectIds",null),e([p({readOnly:!0})],A.prototype,"geometryOverrides",void 0),e([p()],A.prototype,"_clientGeometryCache",void 0),e([p()],A.prototype,"_associatedLayer",null),e([p()],A.prototype,"_associatedLayerView",void 0),e([p({constructOnly:!0})],A.prototype,"memoryController",void 0),e([p()],A.prototype,"_attributeChangedObjectIds",void 0),e([p()],A.prototype,"_geometryChangedObjectIds",void 0),e([p()],A.prototype,"_pendingFetchChangedObjectIds",void 0),e([p()],A.prototype,"_definitionExpression",null),e([p()],A.prototype,"updating",null),e([p()],A.prototype,"isEmpty",null),A=e([y("esri.views.3d.layers.i3s.I3SOverrides")],A);class L{constructor(e,t){this.objectId=e,this._options=t,this._updates=new Map,this._updatedGeometry=void 0,this._state=E.ACTIVE}getAttribute(e){return this._updates.get(e)}setAttribute(e,t){this.isActive&&this._updates.set(e,t)}getGeometry(){return this._updatedGeometry}setGeometry(e){this.isActive&&(this._updatedGeometry=e)}rollback(){this.isActive&&(this._state=E.ROLLED_BACK,this._options.rollback(),this._updatedGeometry=void 0)}commit(){this.isActive&&(this._state=E.COMMITTED,this._options.commit(this._updates,this._updatedGeometry),this._updates.clear(),this._updatedGeometry=void 0)}get isActive(){return this._state===E.ACTIVE}}var E;!function(e){e[e.ACTIVE=0]="ACTIVE",e[e.COMMITTED=1]="COMMITTED",e[e.ROLLED_BACK=2]="ROLLED_BACK"}(E||(E={}));const w=1e4,x=5e4;export{A as I3SOverrides};
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../request.js";import s from"../../../../core/Accessor.js";import{splitIntoChunks as i}from"../../../../core/arrayUtils.js";import{resultOrAbort as r,result as o}from"../../../../core/asyncUtils.js";import{estimateStringByteSize as n,estimateNumberByteSize as a}from"../../../../core/byteSizeEstimations.js";import d from"../../../../core/Collection.js";import c from"../../../../core/Logger.js";import{destroyMaybe as h,abortMaybe as l}from"../../../../core/maybe.js";import{whenOrAbort as u}from"../../../../core/promiseUtils.js";import{watch as m,initial as g}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/has.js";import{subclass as y}from"../../../../core/accessorSupport/decorators/subclass.js";import{formatNumber as _}from"../../../../intl/number.js";import{getMaximumQuerySize as b,queryAllJSON as f}from"../../../../layers/support/featureQueryAll.js";import{assetMapFromAssetMapsJSON as O,extractMesh as C}from"../../../../rest/support/meshFeatureSet.js";import{direct3DObjectFeatureLayerDisplayEnabled as j,i3sPatchingEnabled as I,sceneLayerEditingEnabled as v}from"../../../../support/featureFlags.js";import F from"../FeatureLayerView3D.js";let A=class extends s{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._maximumNumberOfEditOVerrides=x,this._original3DOFLDefinitionExpression=null,this._interactiveEditingSessions=new d,this.geometryOverrides=new d,this._clientGeometryCache=new Map,this._associatedLayerView=null,this._attributeChangedObjectIds=new Set,this._geometryChangedObjectIds=new Set,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController}initialize(){this._memCache=this.memoryController.newCache(`i3s-attribute-overrides-${this.layer.uid}`),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.then((async()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null})),this.is3DOFL&&null!=this._associatedLayer&&(j()?this._associatedLayer.load().then((e=>{this.destroyed||(this._original3DOFLDefinitionExpression=e.definitionExpression,this.addHandles(m((()=>this._definitionExpression),(t=>e.definitionExpression=t),g)),this._associatedLayerView=new F({layer:this._associatedLayer,view:this.view}))})):I())}destroy(){this.is3DOFL&&null!=this._associatedLayer&&(j()?null!=this._associatedLayerView&&(this._associatedLayer.definitionExpression=this._original3DOFLDefinitionExpression):I()),this._set("layer",null),this._memCache=h(this._memCache),this._pendingFetchAbortController=l(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null}get is3DOFL(){return v()&&null!=this._associatedLayer&&null!=this._associatedLayer.infoFor3D}get sortedGeometryChangedObjectIds(){return this.is3DOFL?[...this._geometryChangedObjectIds].sort(((e,t)=>e-t)):[]}get _associatedLayer(){return null==this.layer?null:this.layer.associatedLayer}get _definitionExpression(){const e=this.sortedGeometryChangedObjectIds;return 0===e.length?"1 = 0":`OBJECTID IN (${e.join(",")})`}get updating(){if(!this.is3DOFL)return!1;if(j()){return!(null!=this._associatedLayerView)||null!=this._associatedLayerView&&this._associatedLayerView.updating}return I(),!1}get isEmpty(){return null==this._pendingFetchChangedObjectIds&&0===this._attributeChangedObjectIds.size&&0===this._geometryChangedObjectIds.size}createInteractiveEditSession(e){this._attributeChangedObjectIds.add(e),this.notifyChange("_attributeChangedObjectIds");const t=v()&&I()&&null!=this.is3DOFL,s=this._interactiveEditingSessions,i=new L(e,{rollback:()=>{s.remove(i)},commit:(s,i)=>{for(const[t,r]of s)this.updateAttributeValue(e,t,r);t&&null!=i&&this.updateGeometry(e,i)}});return s.unshift(i),i}async applyAttributeOverrides(e,t,s){if(null==t)return;const{loadedAttributes:i,attributeData:r}=t;if(null==i||0===i.length||null==r)return;if(this._pendingFetchChangedObjectIds&&await u(this._pendingFetchChangedObjectIds,s),0===this._attributeChangedObjectIds.size)return;const o={loadedAttributes:i,attributeData:r},n=this._getOverridesFromCache(e,o,this._attributeChangedObjectIds),{objectIds:a,fieldNames:d}=n;if(0===a.length||0===d.length)return;const c=await this._queryOverridesFromAssociatedLayer(a,d,!1,s);null!=c&&this._processOverridesFromAssociatedLayer(e,c,d,o)}updateGeometry(e,t){this._geometryChangedObjectIds.add(e);const s=this._clientGeometryCache.get(e);if(null!=s&&(this.geometryOverrides.remove(s),this._clientGeometryCache.delete(e)),null!=t){const s={oid:e,mesh:t};this.geometryOverrides.add(s),this._clientGeometryCache.set(e,s)}this.notifyChange("_geometryChangedObjectIds")}updateAttributeValue(e,t,s){this._attributeChangedObjectIds.add(e),this._cacheAttributeValue(e,t,s),this.notifyChange("_attributeChangedObjectIds")}_cacheAttributeValue(e,t,s){this._memCache.put(this._getAttributeCacheKey(e,t),s,this._memCacheAttributeValueSize(s))}_cacheGeometry(e,t){this._memCache.put(this._getGeometryCacheKey(e),t,this._memCacheGeometrySize(t))}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:s},i){const r=new Set,o=new Array;if(this.is3DOFL&&0===Object.keys(s).length)return{objectIds:Array.from(e),fieldNames:t.map((e=>e.name))};for(const a of t)o[a.index]=s[a.name];const n=new Set;for(let a=0;a<e.length;a++){const s=e[a];if(i.has(s))for(const e of t){const t=this._attributeFromCache(s,e.index);void 0===t?(r.add(s),n.add(e.name)):o[e.index][a]=t}}return{objectIds:Array.from(r),fieldNames:Array.from(n)}}_attributeFromCache(e,t){const s=this._fromInteractiveEditingSession(e,t);if(void 0!==s)return s;const i=this._getAttributeCacheKey(e,t);return this._memCache.get(i)}_fromInteractiveEditingSession(e,t){if(null!=this._interactiveEditingSessions)for(const s of this._interactiveEditingSessions){if(s.objectId!==e)continue;const i=s.getAttribute(t);if(void 0!==i)return i}}_getAttributeCacheKey(e,t){return`${e}-${t}`}_getGeometryCacheKey(e){return`${e}-geometry`}async _queryOverridesFromAssociatedLayer(e,t,s,o){if(0===e.length||!1===s&&0===t.length)return null;e=e.sort(((e,t)=>e-t)),this._warnMaximumChangedObjectsExceeded&&(this._warnMaximumChangedObjectsExceeded=!1,this._logMaximumObjectsExceededWarning());const n=this.layer.associatedLayer;if(null==n)return null;const a=s&&this.is3DOFL&&I(),d=[n.objectIdField,...t];a&&null!=n.globalIdField&&d.push(n.globalIdField);const c=n.createQuery();c.where="1=1",c.returnGeometry=s,c.outFields=d,c.cacheHint=!0,c.objectIds=e;const h=b(n),l=e.length>h?i(e,h).map((e=>{const t=c.clone();return t.objectIds=e,r(f(n,t,{signal:o}))})):[r(f(n,c,{signal:o}))],u=await Promise.all(l);if(a&&null!=n.infoFor3D){const e=n.infoFor3D,t=n.spatialReference,s=[];for(const i of u){if(!i.ok)continue;const r=i.value;if(null==r.assetMaps)continue;const o=O(e,r.assetMaps);for(const i of r.features){const n=C(i,r.globalIdFieldName,t,e,o),a=i;null!=n?(a.geometry=n,s.push(a)):a.geometry=null}}return s}return u.reduce(((e,t)=>e.concat(t.ok?t.value.features:[])),[])}_logMaximumObjectsExceededWarning(){let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${_(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`;const t=this.layer.portalItem;t&&t.loaded?e+=` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:e+=` (${this.layer.parsedUrl.path})`,c.getLogger("esri.views.3d.layers.i3s.I3SOverrides").warn("#queryOverrides()",this.layer.title,`${e}.`)}_processOverridesFromAssociatedLayer(e,t,s,{loadedAttributes:i,attributeData:r}){const o=this._associatedLayer;if(null==o)return;const n=o.objectIdField,a=s.map((t=>(t in r||(r[t]=new Array(e.length)),r[t]))),d=new Map(i.map((e=>[e.name,e.index]))),c=s.map((e=>d.get(e))),h=new Map(Array.from(e,((e,t)=>[e,t])));for(const l of t){const e=l.attributes[n];for(let t=0;t<s.length;t++){const i=c[t],r=h.get(e),o=l.attributes[s[t]];a[t][r]=o,this._cacheAttributeValue(e,i,o)}}}_memCacheAttributeValueSize(e){return"string"==typeof e?n(e):a()}_memCacheGeometrySize(e){return 256}async _fetchChangedObjectIds(e){const s=this.layer;await s.load({signal:e}),this._geometryChangedObjectIds.clear(),this._attributeChangedObjectIds.clear();const{associatedLayer:i}=s;if(null==i||!i.capabilities?.operations?.supportsChangeTracking)return;const r=this._getFetchChangedObjectIdsServerGen();if(null==r)return;const n=i.layerId,a=this.is3DOFL,d={f:"json",returnIdsOnly:!0,layers:`[${n}]`,returnUpdates:!0,returnDeletes:a,returnInserts:a,layerServerGens:JSON.stringify([{id:n,serverGen:r}])};if(a){const e=i.infoFor3D;d.fieldsToCompare=JSON.stringify({fields:[...Object.values(e.transformFieldRoles),e.sourceHashField]})}const c=await o(t(`${i.url}/extractChanges`,{method:"post",query:d,timeout:w,signal:e}));if(c.ok&&1===c.value.data?.edits?.length){const t=c.value.data.edits[0],s=t?.objectIds,r=t?.fieldUpdates,o=s?.adds??[],n=s?.updates??[],d=s?.deletes??[],h=[...o,...n,...d],l=a?[...o,...r??n,...d]:[],u=Math.min(this._maximumNumberOfEditOVerrides,h.length);u<h.length&&(this._warnMaximumChangedObjectsExceeded=!0);const m=h.sort(((e,t)=>e-t));for(let e=0;e<u;++e){const t=m[e];this._attributeChangedObjectIds.add(t)}for(const e of l)this._geometryChangedObjectIds.add(e);if(this.is3DOFL&&I()&&this._geometryChangedObjectIds.size>0){const t=await this._queryOverridesFromAssociatedLayer(Array.from(this._geometryChangedObjectIds),[],!0,e);if(null!=t)for(const e of t)null!=e.geometry&&this.updateGeometry(e.attributes[i.objectIdField],e.geometry)}}this.notifyChange("_attributeChangedObjectIds"),this.notifyChange("_geometryChangedObjectIds")}_getFetchChangedObjectIdsServerGen(){const e=this.layer;if(null!=e.serviceUpdateTimeStamp&&null!=e.serviceUpdateTimeStamp.lastUpdate)return e.serviceUpdateTimeStamp.lastUpdate;const t=e.associatedLayer;return null!=t&&null!=t.serverGens&&null!=t.serverGens.minServerGen?t.serverGens.minServerGen:null}get test(){const e=Array.from(this._attributeChangedObjectIds),t=this._pendingFetchChangedObjectIds,s=this;return{changedObjectIds:e,pendingFetchChangedObjectIds:t,get maximumNumberOfEditOVerrides(){return s._maximumNumberOfEditOVerrides},set maximumNumberOfEditOVerrides(e){s._maximumNumberOfEditOVerrides=e}}}};e([p({constructOnly:!0})],A.prototype,"view",void 0),e([p({constructOnly:!0})],A.prototype,"layer",void 0),e([p({readOnly:!0})],A.prototype,"is3DOFL",null),e([p()],A.prototype,"_interactiveEditingSessions",void 0),e([p({readOnly:!0})],A.prototype,"sortedGeometryChangedObjectIds",null),e([p({readOnly:!0})],A.prototype,"geometryOverrides",void 0),e([p()],A.prototype,"_clientGeometryCache",void 0),e([p()],A.prototype,"_associatedLayer",null),e([p()],A.prototype,"_associatedLayerView",void 0),e([p({constructOnly:!0})],A.prototype,"memoryController",void 0),e([p()],A.prototype,"_attributeChangedObjectIds",void 0),e([p()],A.prototype,"_geometryChangedObjectIds",void 0),e([p()],A.prototype,"_pendingFetchChangedObjectIds",void 0),e([p()],A.prototype,"_definitionExpression",null),e([p()],A.prototype,"updating",null),e([p()],A.prototype,"isEmpty",null),A=e([y("esri.views.3d.layers.i3s.I3SOverrides")],A);class L{constructor(e,t){this.objectId=e,this._options=t,this._updates=new Map,this._updatedGeometry=void 0,this._state=E.ACTIVE}getAttribute(e){return this._updates.get(e)}setAttribute(e,t){this.isActive&&this._updates.set(e,t)}getGeometry(){return this._updatedGeometry}setGeometry(e){this.isActive&&(this._updatedGeometry=e)}rollback(){this.isActive&&(this._state=E.ROLLED_BACK,this._options.rollback(),this._updatedGeometry=void 0)}commit(){this.isActive&&(this._state=E.COMMITTED,this._options.commit(this._updates,this._updatedGeometry),this._updates.clear(),this._updatedGeometry=void 0)}get isActive(){return this._state===E.ACTIVE}}var E;!function(e){e[e.ACTIVE=0]="ACTIVE",e[e.COMMITTED=1]="COMMITTED",e[e.ROLLED_BACK=2]="ROLLED_BACK"}(E||(E={}));const w=1e4,x=5e4;export{A as I3SOverrides};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../../chunks/tslib.es6.js";import{releaseMaybe as t}from"../../../../../../core/maybe.js";import{e as r,t as s}from"../../../../../../chunks/mat3.js";import{a as o}from"../../../../../../chunks/mat3f32.js";import{b as a}from"../../../../../../chunks/mat3f64.js";import{G as i}from"../../../../../../chunks/vec3.js";import{f as l}from"../../../../../../chunks/vec3f64.js";import{v as n}from"../../../../../../chunks/vec4.js";import{f as u}from"../../../../../../chunks/vec4f64.js";import{ColorMixModeEnum as h}from"../../../../layers/support/symbolColorUtils.js";import{OverlayIndex as p,RenderTargetType as c}from"../../../../terrain/interfaces.js";import{ComponentTechnique as d}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as m,IntegratedMeshMode as g}from"./ComponentTechniqueConfiguration.js";import{ComponentDataType as y}from"./shader/ComponentData.glsl.js";import{g as T}from"../../../../../../chunks/ComponentShader.glsl.js";import{VertexDiscardMode as x}from"./shader/VertexDiscardByOpacity.glsl.js";import{MaterialBase as f,parameter as v,parameterBlock as b,MaterialParameterBlock as M}from"../../../core/material/MaterialBase.js";import{RenderPassIdentifier as O}from"../../../core/renderPasses/AllRenderPasses.js";import{ShaderOutput as C}from"../../../core/shaderLibrary/ShaderOutput.js";import{NormalType as w}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{NormalsDoubleSidedMode as S}from"../../../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as P}from"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{defaultMaskAlphaCutoff as j}from"../../../core/shaderLibrary/util/AlphaCutoff.js";import{EllipsoidMode as N}from"../../../core/shaderLibrary/util/EllipsoidMode.js";import{TwoVectorPosition as q}from"../../../core/util/TwoVectorPosition.js";import{AlphaDiscardMode as A,CullFaceOptions as D}from"../../../lib/basicInterfaces.js";import{TransparencyPassType as R}from"../../../lib/TransparencyPassType.js";class I extends f{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 _,this.componentParameters=new W,this.textureAlphaCutoff=j,this.alphaDiscardMode=A.Opaque,this.isIntegratedMesh=!1,this.polygonOffsetEnabled=!1,this.ellipsoidMode=N.Earth,this.hasOccludees=!1,this._techniqueConfiguration=new m;const i=new q(e.position),n=o(e.rotationScale);r(n,n),this.transformNormalGlobalFromModel=a(s(n,n)),this.transformWorldFromModelTL=i.low,this.transformWorldFromModelTH=i.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 null!=this.baseColorTexture?this.baseColorTexture.glTexture:null}get textureMetallicRoughness(){return null!=this.metallicRoughnessTexture?this.metallicRoughnessTexture.glTexture:null}get textureEmissive(){return null!=this.emissionTexture?this.emissionTexture.glTexture:null}get textureOcclusion(){return null!=this.occlusionTexture?this.occlusionTexture.glTexture:null}get textureNormal(){return null!=this.normalTexture?this.normalTexture.glTexture:null}prepareTechnique(e,t,r,s){const o=this._techniqueConfiguration;o.hasVertexColors=s.colors,o.hasNormals=s.normals,o.textureCoordinateType=s.textureCoordinates,o.hasMetallicRoughnessTexture=null!=this.metallicRoughnessTexture,o.hasEmissionTexture=null!=this.emissionTexture,o.hasOcclusionTexture=null!=this.occlusionTexture,o.hasNormalTexture=null!=this.normalTexture,o.transparencyPassType=t.identifier===O.Material&&null!=r.transparencyPassType?r.transparencyPassType:R.NONE,o.hasMultipassTerrain=t.identifier===O.Material&&null!=r.multipassTerrain&&r.multipassTerrain.enabled,o.cullAboveGround=t.identifier===O.Material&&null!=r.multipassTerrain&&r.multipassTerrain.cullAboveGround,o.ellipsoidMode=this.ellipsoidMode,o.componentData=this.componentParameters.type,o.cullFace=this.commonMaterialParameters.cullFace,o.doubleSidedMode=this.commonMaterialParameters.doubleSided?S.View:S.None,o.hasBaseColorTexture=null!=this.baseColorTexture;const a=this._computeWhichMaterialPass();o.blendingEnabled=a===k.Transparent||a===k.OpaqueAndTransparent,o.alphaDiscardMode=this.alphaDiscardMode,o.integratedMeshMode=this.isIntegratedMesh?L(r)?T(r)?g.ColorOverlayWithWater:g.ColorOverlay:g.NoOverlay:g.None,o.hasPolygonOffset=this.polygonOffsetEnabled;const i=this.hasParametersFromSource&&null==this.baseColorTexture;if(o.pbrMode=o.integratedMeshMode===g.ColorOverlayWithWater?P.WaterOnIntegratedMesh:this.usePBR?i?P.Schematic:P.Normal:P.Disabled,o.normalType=o.integratedMeshMode===g.None?o.hasNormals?w.Compressed:w.ScreenDerivative:w.Ground,o.hasSlicePlane=null!=r.slicePlane&&this.commonMaterialParameters.hasSlicePlane,t.identifier===O.ShadowMap)o.output=C.Shadow,o.vertexDiscardMode=x.None;else if(t.identifier===O.Highlight)o.output=C.Highlight,o.vertexDiscardMode=x.None;else{switch(this._computeWhichMaterialPass()===k.OpaqueAndTransparent?o.vertexDiscardMode=t.transparent?x.Opaque:x.Transparent:o.vertexDiscardMode=x.None,o.output=t.output,o.receiveAmbientOcclusion=!1,o.receiveShadows=!1,t.output){case C.Color:o.receiveAmbientOcclusion=r.ssaoHelper.active,o.hasOccludees=r.hasOccludees,o.receiveShadows=r.shadowMap.ready,o.hasScreenSpaceReflections=r.ssr.enabled,o.hasCloudsReflections=null!=r.cloudsFade.data;break;case C.Alpha:o.hasOccludees=r.hasOccludees;break;case C.ObjectAndLayerIdColor:o.objectAndLayerIdColor=!0}o.snowCover=this.hasSnowCover(r)}return this._technique=e.releaseAndAcquire(d,o,this._technique),this._setClean(),this._technique}hasSnowCover(e){return null!=e.weather&&e.weatherVisible&&"snowy"===e.weather.type&&"enabled"===e.weather.snowCover}submit(e,t,r){if(0===this.objectOpacity)return;const s=r.renderable.geometry,o=r.components,a=r.renderable.meta.cameraDepthSquared,i=o.geometryRanges,l=o.highlightRanges,n=o.defaultShadowMapRanges;switch(this._computeWhichMaterialPass()){case k.Opaque:e.materialOpaque.submitDraw(this,s,i,a);break;case k.Transparent:e.materialTransparent.submitDraw(this,s,i,a);break;case k.OpaqueAndTransparent:e.materialOpaque.submitDraw(this,s,i,a),e.materialTransparent.submitDraw(this,s,i,a);break;case k.IntegratedMesh:e.materialIntegratedMesh.submitDraw(this,s,i,a),B(t)&&e.highlightIntegratedMesh.submitDraw(this,s,i,a)}const u=this.componentParameters.castShadows!==F.None;u&&e.shadowMap.submitDraw(this,s,i,a),null!=l&&(e.highlight.submitDraw(this,s,l,a),u&&e.highlightShadowMap.submitDraw(this,s,l,a)),u&&null!=n&&e.defaultShadowMap.submitDraw(this,s,n,a)}_computeWhichMaterialPass(){return this.isIntegratedMesh?k.IntegratedMesh:this.objectOpacity<1?k.Transparent:this.componentParameters.opaqueOverride===F.All?k.Opaque:this.baseColor[3]<1||this.alphaDiscardMode===A.Blend||this.alphaDiscardMode===A.MaskBlend?k.Transparent:this.componentParameters.transparent===F.None?k.Opaque:this.componentParameters.transparent===F.All?k.Transparent:k.OpaqueAndTransparent}}var k,F;e([v({vectorOps:n})],I.prototype,"baseColor",void 0),e([v()],I.prototype,"usePBR",void 0),e([v()],I.prototype,"hasParametersFromSource",void 0),e([v({vectorOps:i})],I.prototype,"mrrFactors",void 0),e([v({vectorOps:i})],I.prototype,"emissiveFactor",void 0),e([v({dispose:!0})],I.prototype,"baseColorTexture",void 0),e([v({dispose:!0})],I.prototype,"metallicRoughnessTexture",void 0),e([v({dispose:!0})],I.prototype,"emissionTexture",void 0),e([v({dispose:!0})],I.prototype,"occlusionTexture",void 0),e([v({dispose:!0})],I.prototype,"normalTexture",void 0),e([v()],I.prototype,"objectOpacity",void 0),e([b()],I.prototype,"commonMaterialParameters",void 0),e([b()],I.prototype,"componentParameters",void 0),e([v()],I.prototype,"textureAlphaCutoff",void 0),e([v()],I.prototype,"alphaDiscardMode",void 0),e([v()],I.prototype,"isIntegratedMesh",void 0),e([v()],I.prototype,"polygonOffsetEnabled",void 0),e([v()],I.prototype,"ellipsoidMode",void 0),e([v()],I.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"}(k||(k={}));class _ extends M{constructor(){super(...arguments),this.doubleSided=!1,this.cullFace=D.Back,this.hasSlicePlane=!0}}e([v()],_.prototype,"doubleSided",void 0),e([v()],_.prototype,"cullFace",void 0),e([v()],_.prototype,"hasSlicePlane",void 0);class W extends M{constructor(){super(...arguments),this.externalColor=u(1,1,1,1),this.externalColorMixMode=h.Multiply,this.castShadows=F.All}get transparent(){return this.externalColor[3]<1?F.All:F.None}get opaqueOverride(){return this.externalColorMixMode===h.Replace&&1===this.externalColor[3]?F.All:F.None}get visible(){return this.externalColor[3]>0?F.All:F.None}get type(){return y.Uniform}}e([v({vectorOps:n})],W.prototype,"externalColor",void 0),e([v()],W.prototype,"externalColorMixMode",void 0),e([v()],W.prototype,"castShadows",void 0),function(e){e[e.All=0]="All",e[e.Some=1]="Some",e[e.None=2]="None"}(F||(F={}));class E extends M{constructor(){super(...arguments),this.texture=null,this.transparent=F.None,this.opaqueOverride=F.None,this.castShadows=F.None}get type(){return y.Varying}}function B(e){return 0!==e.overlays.length&&null!=e.overlays[p.INNER].getValidTexture(c.Highlight)}function L(e){return 0!==e.overlays.length&&null!=e.overlays[p.INNER].getColorTextureNoRasterImage()}e([v()],E.prototype,"texture",void 0),e([v()],E.prototype,"transparent",void 0),e([v()],E.prototype,"opaqueOverride",void 0),e([v()],E.prototype,"castShadows",void 0);export{_ as CommonMaterialParameters,I as ComponentMaterial,F as ComponentParameterSummary,W as ComponentParametersUniform,E as ComponentParametersVarying};
|
|
5
|
+
import{_ as e}from"../../../../../../chunks/tslib.es6.js";import{releaseMaybe as t}from"../../../../../../core/maybe.js";import{e as r,t as s}from"../../../../../../chunks/mat3.js";import{a as o}from"../../../../../../chunks/mat3f32.js";import{b as a}from"../../../../../../chunks/mat3f64.js";import{G as i}from"../../../../../../chunks/vec3.js";import{g as l,f as n}from"../../../../../../chunks/vec3f64.js";import{v as u}from"../../../../../../chunks/vec4.js";import{f as h}from"../../../../../../chunks/vec4f64.js";import{ColorMixModeEnum as p}from"../../../../layers/support/symbolColorUtils.js";import{OverlayIndex as c,RenderTargetType as d}from"../../../../terrain/interfaces.js";import{ComponentTechnique as m}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as g,IntegratedMeshMode as y}from"./ComponentTechniqueConfiguration.js";import{ComponentDataType as T}from"./shader/ComponentData.glsl.js";import{g as x}from"../../../../../../chunks/ComponentShader.glsl.js";import{VertexDiscardMode as f}from"./shader/VertexDiscardByOpacity.glsl.js";import{MaterialBase as v,parameter as b,parameterBlock as M,MaterialParameterBlock as O}from"../../../core/material/MaterialBase.js";import{RenderPassIdentifier as C}from"../../../core/renderPasses/AllRenderPasses.js";import{ShaderOutput as w}from"../../../core/shaderLibrary/ShaderOutput.js";import{NormalType as S}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{NormalsDoubleSidedMode as P}from"../../../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as j}from"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{defaultMaskAlphaCutoff as N}from"../../../core/shaderLibrary/util/AlphaCutoff.js";import{EllipsoidMode as q}from"../../../core/shaderLibrary/util/EllipsoidMode.js";import{TwoVectorPosition as A}from"../../../core/util/TwoVectorPosition.js";import{AlphaDiscardMode as D,CullFaceOptions as R}from"../../../lib/basicInterfaces.js";import{TransparencyPassType as I}from"../../../lib/TransparencyPassType.js";import{defaultAdvancedMRRFactors as k}from"../../../materials/pbrUtils.js";class F extends v{constructor(e,t){super(),this.toMapSpace=t,this.baseColor=h(1,1,1,1),this.usePBR=!1,this.hasParametersFromSource=!1,this.mrrFactors=l(k),this.emissiveFactor=n(0,0,0),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null,this.objectOpacity=1,this.commonMaterialParameters=new E,this.componentParameters=new B,this.textureAlphaCutoff=N,this.alphaDiscardMode=D.Opaque,this.isIntegratedMesh=!1,this.polygonOffsetEnabled=!1,this.ellipsoidMode=q.Earth,this.hasOccludees=!1,this._techniqueConfiguration=new g;const i=new A(e.position),u=o(e.rotationScale);r(u,u),this.transformNormalGlobalFromModel=a(s(u,u)),this.transformWorldFromModelTL=i.low,this.transformWorldFromModelTH=i.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 null!=this.baseColorTexture?this.baseColorTexture.glTexture:null}get textureMetallicRoughness(){return null!=this.metallicRoughnessTexture?this.metallicRoughnessTexture.glTexture:null}get textureEmissive(){return null!=this.emissionTexture?this.emissionTexture.glTexture:null}get textureOcclusion(){return null!=this.occlusionTexture?this.occlusionTexture.glTexture:null}get textureNormal(){return null!=this.normalTexture?this.normalTexture.glTexture:null}prepareTechnique(e,t,r,s){const o=this._techniqueConfiguration;o.hasVertexColors=s.colors,o.hasNormals=s.normals,o.textureCoordinateType=s.textureCoordinates,o.hasMetallicRoughnessTexture=null!=this.metallicRoughnessTexture,o.hasEmissionTexture=null!=this.emissionTexture,o.hasOcclusionTexture=null!=this.occlusionTexture,o.hasNormalTexture=null!=this.normalTexture,o.transparencyPassType=t.identifier===C.Material&&null!=r.transparencyPassType?r.transparencyPassType:I.NONE,o.hasMultipassTerrain=t.identifier===C.Material&&null!=r.multipassTerrain&&r.multipassTerrain.enabled,o.cullAboveGround=t.identifier===C.Material&&null!=r.multipassTerrain&&r.multipassTerrain.cullAboveGround,o.ellipsoidMode=this.ellipsoidMode,o.componentData=this.componentParameters.type,o.cullFace=this.commonMaterialParameters.cullFace,o.doubleSidedMode=this.commonMaterialParameters.doubleSided?P.View:P.None,o.hasBaseColorTexture=null!=this.baseColorTexture;const a=this._computeWhichMaterialPass();o.blendingEnabled=a===_.Transparent||a===_.OpaqueAndTransparent,o.alphaDiscardMode=this.alphaDiscardMode,o.integratedMeshMode=this.isIntegratedMesh?G(r)?x(r)?y.ColorOverlayWithWater:y.ColorOverlay:y.NoOverlay:y.None,o.hasPolygonOffset=this.polygonOffsetEnabled;const i=this.hasParametersFromSource&&null==this.baseColorTexture;if(o.pbrMode=o.integratedMeshMode===y.ColorOverlayWithWater?j.WaterOnIntegratedMesh:this.usePBR?i?j.Schematic:j.Normal:j.Disabled,o.normalType=o.integratedMeshMode===y.None?o.hasNormals?S.Compressed:S.ScreenDerivative:S.Ground,o.hasSlicePlane=null!=r.slicePlane&&this.commonMaterialParameters.hasSlicePlane,t.identifier===C.ShadowMap)o.output=w.Shadow,o.vertexDiscardMode=f.None;else if(t.identifier===C.Highlight)o.output=w.Highlight,o.vertexDiscardMode=f.None;else{switch(this._computeWhichMaterialPass()===_.OpaqueAndTransparent?o.vertexDiscardMode=t.transparent?f.Opaque:f.Transparent:o.vertexDiscardMode=f.None,o.output=t.output,o.receiveAmbientOcclusion=!1,o.receiveShadows=!1,t.output){case w.Color:o.receiveAmbientOcclusion=r.ssaoHelper.active,o.hasOccludees=r.hasOccludees,o.receiveShadows=r.shadowMap.ready,o.hasScreenSpaceReflections=r.ssr.enabled,o.hasCloudsReflections=null!=r.cloudsFade.data;break;case w.Alpha:o.hasOccludees=r.hasOccludees;break;case w.ObjectAndLayerIdColor:o.objectAndLayerIdColor=!0}o.snowCover=this.hasSnowCover(r)}return this._technique=e.releaseAndAcquire(m,o,this._technique),this._setClean(),this._technique}hasSnowCover(e){return null!=e.weather&&e.weatherVisible&&"snowy"===e.weather.type&&"enabled"===e.weather.snowCover}submit(e,t,r){if(0===this.objectOpacity)return;const s=r.renderable.geometry,o=r.components,a=r.renderable.meta.cameraDepthSquared,i=o.geometryRanges,l=o.highlightRanges,n=o.defaultShadowMapRanges;switch(this._computeWhichMaterialPass()){case _.Opaque:e.materialOpaque.submitDraw(this,s,i,a);break;case _.Transparent:e.materialTransparent.submitDraw(this,s,i,a);break;case _.OpaqueAndTransparent:e.materialOpaque.submitDraw(this,s,i,a),e.materialTransparent.submitDraw(this,s,i,a);break;case _.IntegratedMesh:e.materialIntegratedMesh.submitDraw(this,s,i,a),V(t)&&e.highlightIntegratedMesh.submitDraw(this,s,i,a)}const u=this.componentParameters.castShadows!==W.None;u&&e.shadowMap.submitDraw(this,s,i,a),null!=l&&(e.highlight.submitDraw(this,s,l,a),u&&e.highlightShadowMap.submitDraw(this,s,l,a)),u&&null!=n&&e.defaultShadowMap.submitDraw(this,s,n,a)}_computeWhichMaterialPass(){return this.isIntegratedMesh?_.IntegratedMesh:this.objectOpacity<1?_.Transparent:this.componentParameters.opaqueOverride===W.All?_.Opaque:this.baseColor[3]<1||this.alphaDiscardMode===D.Blend||this.alphaDiscardMode===D.MaskBlend?_.Transparent:this.componentParameters.transparent===W.None?_.Opaque:this.componentParameters.transparent===W.All?_.Transparent:_.OpaqueAndTransparent}}var _,W;e([b({vectorOps:u})],F.prototype,"baseColor",void 0),e([b()],F.prototype,"usePBR",void 0),e([b()],F.prototype,"hasParametersFromSource",void 0),e([b({vectorOps:i})],F.prototype,"mrrFactors",void 0),e([b({vectorOps:i})],F.prototype,"emissiveFactor",void 0),e([b({dispose:!0})],F.prototype,"baseColorTexture",void 0),e([b({dispose:!0})],F.prototype,"metallicRoughnessTexture",void 0),e([b({dispose:!0})],F.prototype,"emissionTexture",void 0),e([b({dispose:!0})],F.prototype,"occlusionTexture",void 0),e([b({dispose:!0})],F.prototype,"normalTexture",void 0),e([b()],F.prototype,"objectOpacity",void 0),e([M()],F.prototype,"commonMaterialParameters",void 0),e([M()],F.prototype,"componentParameters",void 0),e([b()],F.prototype,"textureAlphaCutoff",void 0),e([b()],F.prototype,"alphaDiscardMode",void 0),e([b()],F.prototype,"isIntegratedMesh",void 0),e([b()],F.prototype,"polygonOffsetEnabled",void 0),e([b()],F.prototype,"ellipsoidMode",void 0),e([b()],F.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"}(_||(_={}));class E extends O{constructor(){super(...arguments),this.doubleSided=!1,this.cullFace=R.Back,this.hasSlicePlane=!0}}e([b()],E.prototype,"doubleSided",void 0),e([b()],E.prototype,"cullFace",void 0),e([b()],E.prototype,"hasSlicePlane",void 0);class B extends O{constructor(){super(...arguments),this.externalColor=h(1,1,1,1),this.externalColorMixMode=p.Multiply,this.castShadows=W.All}get transparent(){return this.externalColor[3]<1?W.All:W.None}get opaqueOverride(){return this.externalColorMixMode===p.Replace&&1===this.externalColor[3]?W.All:W.None}get visible(){return this.externalColor[3]>0?W.All:W.None}get type(){return T.Uniform}}e([b({vectorOps:u})],B.prototype,"externalColor",void 0),e([b()],B.prototype,"externalColorMixMode",void 0),e([b()],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 L extends O{constructor(){super(...arguments),this.texture=null,this.transparent=W.None,this.opaqueOverride=W.None,this.castShadows=W.None}get type(){return T.Varying}}function V(e){return 0!==e.overlays.length&&null!=e.overlays[c.INNER].getValidTexture(d.Highlight)}function G(e){return 0!==e.overlays.length&&null!=e.overlays[c.INNER].getColorTextureNoRasterImage()}e([b()],L.prototype,"texture",void 0),e([b()],L.prototype,"transparent",void 0),e([b()],L.prototype,"opaqueOverride",void 0),e([b()],L.prototype,"castShadows",void 0);export{E as CommonMaterialParameters,F as ComponentMaterial,W as ComponentParameterSummary,B as ComponentParametersUniform,L as ComponentParametersVarying};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{c as t}from"../../../../../chunks/vec3f64.js";import{ShaderOutput as s}from"../shaderLibrary/ShaderOutput.js";import{VertexNormalPassParameters as i,VertexNormalDrawParameters as r}from"../shaderLibrary/attributes/VertexNormal.glsl.js";class e extends i{constructor(){super(...arguments),this.slicePlaneLocalOrigin=t(),this.origin=this.slicePlaneLocalOrigin}}class a extends r{}var o;!function(t){t[t.Material=0]="Material",t[t.ShadowMap=1]="ShadowMap",t[t.Highlight=2]="Highlight"}(o||(o={}));class
|
|
5
|
+
import{c as t}from"../../../../../chunks/vec3f64.js";import{ShaderOutput as s}from"../shaderLibrary/ShaderOutput.js";import{VertexNormalPassParameters as i,VertexNormalDrawParameters as r}from"../shaderLibrary/attributes/VertexNormal.glsl.js";class e extends i{constructor(){super(...arguments),this.slicePlaneLocalOrigin=t(),this.origin=this.slicePlaneLocalOrigin,this.modelTransformation=null}}class a extends r{}var o;!function(t){t[t.Material=0]="Material",t[t.ShadowMap=1]="ShadowMap",t[t.Highlight=2]="Highlight"}(o||(o={}));class n extends e{constructor(){super(...arguments),this.identifier=o.Material,this.output=s.Color,this.transparent=!1,this.integratedMesh=!1}}class h extends e{constructor(){super(...arguments),this.identifier=o.ShadowMap}}class l extends e{constructor(){super(...arguments),this.identifier=o.Highlight}}export{a as DrawParameters,l as HighlightPassParameters,n as MaterialPassParameters,e as PassParameters,o as RenderPassIdentifier,h as ShadowMapPassParameters};
|
|
@@ -2,16 +2,10 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{addCalculateLinearDepth as e}from"./ForwardLinearDepth.glsl.js";import{glsl as
|
|
6
|
-
vec4 eye = view * (model * vec4(pos, 1.0));
|
|
7
|
-
depth = calculateLinearDepth(nearFar, eye.z);
|
|
8
|
-
return proj * eye;
|
|
9
|
-
}`),void r.vertex.code.add(o`vec4 transformPosition(mat4 proj, mat4 view, mat4 model, vec3 pos) {
|
|
10
|
-
return proj * (view * (model * vec4(pos, 1.0)));
|
|
11
|
-
}`);r.vertex.code.add(o`vec4 transformPositionWithDepth(mat4 proj, mat4 view, vec3 pos, vec2 nearFar, out float depth) {
|
|
5
|
+
import{addCalculateLinearDepth as e}from"./ForwardLinearDepth.glsl.js";import{glsl as r}from"../shaderModules/interfaces.js";function o(o){e(o),o.vertex.code.add(r`vec4 transformPositionWithDepth(mat4 proj, mat4 view, vec3 pos, vec2 nearFar, out float depth) {
|
|
12
6
|
vec4 eye = view * vec4(pos, 1.0);
|
|
13
7
|
depth = calculateLinearDepth(nearFar,eye.z);
|
|
14
8
|
return proj * eye;
|
|
15
|
-
}`),
|
|
9
|
+
}`),o.vertex.code.add(r`vec4 transformPosition(mat4 proj, mat4 view, vec3 pos) {
|
|
16
10
|
return proj * (view * vec4(pos, 1.0));
|
|
17
|
-
}`)}export{
|
|
11
|
+
}`)}export{o as Transform};
|
package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{I as o}from"../../../../../../chunks/mat4f64.js";import{addNearFar as
|
|
5
|
+
import{I as o}from"../../../../../../chunks/mat4f64.js";import{addNearFar as e}from"../ForwardLinearDepth.glsl.js";import{ShaderOutput as r}from"../ShaderOutput.js";import{SliceDraw as t}from"../Slice.glsl.js";import{Transform as i}from"../Transform.glsl.js";import{NormalAttribute as a,NormalType as s}from"../attributes/NormalAttribute.glsl.js";import{ObjectAndLayerIdColor as l}from"../attributes/ObjectAndLayerIdColor.glsl.js";import{TextureCoordinateAttribute as d}from"../attributes/TextureCoordinateAttribute.glsl.js";import{VertexNormal as n}from"../attributes/VertexNormal.glsl.js";import{OutputDepth as c}from"../output/OutputDepth.glsl.js";import{OutputHighlight as u}from"../output/OutputHighlight.glsl.js";import{VisualVariables as m}from"../shading/VisualVariables.glsl.js";import{DiscardOrAdjustAlphaPass as p}from"../util/AlphaDiscard.glsl.js";import{addProjViewLocalOrigin as v}from"../util/View.glsl.js";import{glsl as f}from"../../shaderModules/interfaces.js";import{Matrix4PassUniform as h}from"../../shaderModules/Matrix4PassUniform.js";import{Texture2DPassUniform as g}from"../../shaderModules/Texture2DPassUniform.js";import{AlphaDiscardMode as x}from"../../../lib/basicInterfaces.js";function j(j,w){const{vertex:C,fragment:O}=j,b=w.hasModelTransformation;b&&C.uniforms.add(new h("model",(e=>e.modelTransformation??o)));const T=w.hasColorTexture&&w.alphaDiscardMode!==x.Opaque;switch(w.output){case r.Depth:case r.Shadow:case r.ShadowHighlight:case r.ShadowExcludeHighlight:case r.ObjectAndLayerIdColor:v(C,w),j.include(i,w),j.include(d,w),j.include(m,w),j.include(c,w),j.include(t,w),j.include(l,w),e(j),j.varyings.add("depth","float"),T&&O.uniforms.add(new g("tex",(o=>o.texture))),C.code.add(f`
|
|
6
6
|
void main(void) {
|
|
7
7
|
vpos = calculateVPos();
|
|
8
|
+
${b?"vpos = (model * vec4(vpos, 1.0)).xyz;":""}
|
|
8
9
|
vpos = subtractOrigin(vpos);
|
|
9
10
|
vpos = addVerticalOffset(vpos, localOrigin);
|
|
10
|
-
gl_Position = transformPositionWithDepth(proj, view,
|
|
11
|
+
gl_Position = transformPositionWithDepth(proj, view, vpos, nearFar, depth);
|
|
11
12
|
forwardTextureCoordinates();
|
|
12
13
|
forwardObjectAndLayerIdColor();
|
|
13
14
|
}
|
|
@@ -17,20 +18,21 @@ import{I as o}from"../../../../../../chunks/mat4f64.js";import{addNearFar as r}f
|
|
|
17
18
|
${T?f`
|
|
18
19
|
vec4 texColor = texture(tex, ${w.hasColorTextureTransform?f`colorUV`:f`vuv0`});
|
|
19
20
|
discardOrAdjustAlpha(texColor);`:""}
|
|
20
|
-
${w.output===
|
|
21
|
+
${w.output===r.ObjectAndLayerIdColor?f`outputObjectAndLayerIdColor();`:f`outputDepth(depth);`}
|
|
21
22
|
}
|
|
22
|
-
`);break;case
|
|
23
|
+
`);break;case r.Normal:{v(C,w),j.include(i,w),j.include(a,w),j.include(n,w),j.include(d,w),j.include(m,w),T&&O.uniforms.add(new g("tex",(o=>o.texture))),w.normalType===s.ScreenDerivative&&j.varyings.add("vPositionView","vec3");const o=w.normalType===s.Attribute||w.normalType===s.Compressed;C.code.add(f`
|
|
23
24
|
void main(void) {
|
|
24
25
|
vpos = calculateVPos();
|
|
26
|
+
${b?"vpos = (model * vec4(vpos, 1.0)).xyz;":""}
|
|
25
27
|
|
|
26
28
|
${o?f`
|
|
27
29
|
vNormalWorld = dpNormalView(vvLocalNormal(normalModel()));`:f`
|
|
28
30
|
// Get vertex position in camera space for screen-space derivative normals
|
|
29
|
-
vPositionView = (view *
|
|
31
|
+
vPositionView = (view * vec4(vpos, 1.0)).xyz;
|
|
30
32
|
`}
|
|
31
33
|
vpos = subtractOrigin(vpos);
|
|
32
34
|
vpos = addVerticalOffset(vpos, localOrigin);
|
|
33
|
-
gl_Position = transformPosition(proj, view,
|
|
35
|
+
gl_Position = transformPosition(proj, view, vpos);
|
|
34
36
|
forwardTextureCoordinates();
|
|
35
37
|
}
|
|
36
38
|
`),j.include(t,w),j.include(p,w),O.code.add(f`
|
|
@@ -47,15 +49,16 @@ import{I as o}from"../../../../../../chunks/mat4f64.js";import{addNearFar as r}f
|
|
|
47
49
|
}`}
|
|
48
50
|
fragColor = vec4(0.5 + 0.5 * normal, 1.0);
|
|
49
51
|
}
|
|
50
|
-
`);break}case
|
|
52
|
+
`);break}case r.Highlight:v(C,w),j.include(i,w),j.include(d,w),j.include(m,w),T&&O.uniforms.add(new g("tex",(o=>o.texture))),C.code.add(f`
|
|
51
53
|
void main(void) {
|
|
52
54
|
vpos = calculateVPos();
|
|
55
|
+
${b?"vpos = (model * vec4(vpos, 1.0)).xyz;":""}
|
|
53
56
|
vpos = subtractOrigin(vpos);
|
|
54
57
|
vpos = addVerticalOffset(vpos, localOrigin);
|
|
55
|
-
gl_Position = transformPosition(proj, view,
|
|
58
|
+
gl_Position = transformPosition(proj, view, vpos);
|
|
56
59
|
forwardTextureCoordinates();
|
|
57
60
|
}
|
|
58
|
-
`),j.include(t,w),j.include(p,w),j.include(
|
|
61
|
+
`),j.include(t,w),j.include(p,w),j.include(u,w),O.code.add(f`
|
|
59
62
|
void main() {
|
|
60
63
|
discardBySlice(vpos);
|
|
61
64
|
${T?f`
|
package/views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js
CHANGED
|
@@ -2,33 +2,33 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{
|
|
5
|
+
import{VertexTextureCoordinates as e}from"../attributes/VertexTextureCoordinates.glsl.js";import{Float3DrawUniform as s}from"../../shaderModules/Float3DrawUniform.js";import{Float3PassUniform as o}from"../../shaderModules/Float3PassUniform.js";import{glsl as r}from"../../shaderModules/interfaces.js";import{Texture2DDrawUniform as i}from"../../shaderModules/Texture2DDrawUniform.js";import{Texture2DPassUniform as t}from"../../shaderModules/Texture2DPassUniform.js";import{BindType as a}from"../../shaderTechnique/BindType.js";import{GLTextureMaterialBindParameters as n}from"../../../lib/GLTextureMaterial.js";var c;!function(e){e[e.Disabled=0]="Disabled",e[e.Normal=1]="Normal",e[e.Schematic=2]="Schematic",e[e.Water=3]="Water",e[e.WaterOnIntegratedMesh=4]="WaterOnIntegratedMesh",e[e.Terrain=5]="Terrain",e[e.TerrainWithWater=6]="TerrainWithWater",e[e.COUNT=7]="COUNT"}(c||(c={}));class u extends n{}function l(n,u){const l=n.fragment,m=u.hasMetallicRoughnessTexture||u.hasEmissionTexture||u.hasOcclusionTexture;if(u.pbrMode===c.Normal&&m&&n.include(e,u),u.pbrMode!==c.Schematic)if(u.pbrMode!==c.Disabled){if(u.pbrMode===c.Normal){l.code.add(r`vec3 mrr;
|
|
6
6
|
vec3 emission;
|
|
7
|
-
float occlusion;`);const e=
|
|
7
|
+
float occlusion;`);const e=u.pbrTextureBindType;u.hasMetallicRoughnessTexture&&(l.uniforms.add(e===a.Pass?new t("texMetallicRoughness",(e=>e.textureMetallicRoughness)):new i("texMetallicRoughness",(e=>e.textureMetallicRoughness))),l.code.add(r`void applyMetallnessAndRoughness(vec2 uv) {
|
|
8
8
|
vec3 metallicRoughness = textureLookup(texMetallicRoughness, uv).rgb;
|
|
9
9
|
mrr[0] *= metallicRoughness.b;
|
|
10
10
|
mrr[1] *= metallicRoughness.g;
|
|
11
|
-
}`)),
|
|
11
|
+
}`)),u.hasEmissionTexture&&(l.uniforms.add(e===a.Pass?new t("texEmission",(e=>e.textureEmissive)):new i("texEmission",(e=>e.textureEmissive))),l.code.add(r`void applyEmission(vec2 uv) {
|
|
12
12
|
emission *= textureLookup(texEmission, uv).rgb;
|
|
13
|
-
}`)),
|
|
13
|
+
}`)),u.hasOcclusionTexture?(l.uniforms.add(e===a.Pass?new t("texOcclusion",(e=>e.textureOcclusion)):new i("texOcclusion",(e=>e.textureOcclusion))),l.code.add(r`void applyOcclusion(vec2 uv) {
|
|
14
14
|
occlusion *= textureLookup(texOcclusion, uv).r;
|
|
15
15
|
}
|
|
16
16
|
float getBakedOcclusion() {
|
|
17
17
|
return occlusion;
|
|
18
|
-
}`)):
|
|
18
|
+
}`)):l.code.add(r`float getBakedOcclusion() { return 1.0; }`),e===a.Pass?l.uniforms.add(new o("emissionFactor",(e=>e.emissiveFactor)),new o("mrrFactors",(e=>e.mrrFactors))):l.uniforms.add(new s("emissionFactor",(e=>e.emissiveFactor)),new s("mrrFactors",(e=>e.mrrFactors))),l.code.add(r`
|
|
19
19
|
void applyPBRFactors() {
|
|
20
20
|
mrr = mrrFactors;
|
|
21
21
|
emission = emissionFactor;
|
|
22
22
|
occlusion = 1.0;
|
|
23
23
|
|
|
24
|
-
${
|
|
24
|
+
${u.hasMetallicRoughnessTexture?r`applyMetallnessAndRoughness(${u.hasMetallicRoughnessTextureTransform?r`metallicRoughnessUV`:"vuv0"});`:""}
|
|
25
25
|
|
|
26
|
-
${
|
|
26
|
+
${u.hasEmissionTexture?r`applyEmission(${u.hasEmissiveTextureTransform?r`emissiveUV`:"vuv0"});`:""}
|
|
27
27
|
|
|
28
|
-
${
|
|
28
|
+
${u.hasOcclusionTexture?r`applyOcclusion(${u.hasOcclusionTextureTransform?r`occlusionUV`:"vuv0"});`:""}
|
|
29
29
|
}
|
|
30
|
-
`)}}else
|
|
30
|
+
`)}}else l.code.add(r`float getBakedOcclusion() { return 1.0; }`);else l.code.add(r`vec3 mrr = vec3(0.0, 0.6, 0.2);
|
|
31
31
|
vec3 emission = vec3(0.0);
|
|
32
32
|
float occlusion = 1.0;
|
|
33
33
|
void applyPBRFactors() {}
|
|
34
|
-
float getBakedOcclusion() { return 1.0; }`)}export{
|
|
34
|
+
float getBakedOcclusion() { return 1.0; }`)}export{u as PBRBindParameters,c as PBRMode,l as PhysicallyBasedRenderingParameters};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{
|
|
5
|
+
import{I as e}from"../../../../../../chunks/mat4f64.js";import{c as a}from"../../../../../../chunks/vec3f64.js";import{RgbaFloatEncoding as s}from"../util/RgbaFloatEncoding.glsl.js";import{Float4PassUniform as o}from"../../shaderModules/Float4PassUniform.js";import{IntegerPassUniform as t}from"../../shaderModules/IntegerPassUniform.js";import{NoParameters as i,glsl as r}from"../../shaderModules/interfaces.js";import{Matrix4sDrawUniform as d}from"../../shaderModules/Matrix4sDrawUniform.js";import{Matrix4sPassUniform as l}from"../../shaderModules/Matrix4sPassUniform.js";import{Texture2DPassUniform as n}from"../../shaderModules/Texture2DPassUniform.js";class p extends i{constructor(){super(...arguments),this.origin=a()}}class c extends p{constructor(){super(...arguments),this.modelTransformation=e}}function h(e,a){a.receiveShadows&&(e.fragment.uniforms.add(new l("shadowMapMatrix",((e,a)=>a.shadowMap.getShadowMapMatrices(e.origin,e.modelTransformation)),4)),f(e))}function v(e,a){a.receiveShadows&&(e.fragment.uniforms.add(new d("shadowMapMatrix",((e,a,s)=>a.shadowMap.getShadowMapMatrices(e.origin,s.modelTransformation)),4)),f(e))}function f(e){const a=e.fragment;a.include(s),a.uniforms.add(new n("shadowMapTex",((e,a)=>a.shadowMap.depthTexture)),new t("numCascades",((e,a)=>a.shadowMap.numCascades)),new o("cascadeDistances",((e,a)=>a.shadowMap.cascadeDistances))),a.code.add(r`int chooseCascade(float depth, out mat4 mat) {
|
|
6
6
|
vec4 distance = cascadeDistances;
|
|
7
7
|
int i = depth < distance[1] ? 0 : depth < distance[2] ? 1 : depth < distance[3] ? 2 : 3;
|
|
8
8
|
mat = i == 0 ? shadowMapMatrix[0] : i == 1 ? shadowMapMatrix[1] : i == 2 ? shadowMapMatrix[2] : shadowMapMatrix[3];
|
|
@@ -40,4 +40,4 @@ if (lvpos.z >= 1.0) { return 0.0; }
|
|
|
40
40
|
if (lvpos.x < 0.0 || lvpos.x > 1.0 || lvpos.y < 0.0 || lvpos.y > 1.0) { return 0.0; }
|
|
41
41
|
vec2 uv = cascadeCoordinates(i, lvpos);
|
|
42
42
|
return filterShadow(uv, lvpos, float(textureSize(shadowMapTex, 0).x), shadowMapTex);
|
|
43
|
-
}`)}export{p as
|
|
43
|
+
}`)}export{v as ReadShadowMapDraw,p as ReadShadowMapDrawParameters,h as ReadShadowMapPass,c as ReadShadowMapPassParameters};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{s as e}from"../../../../../../chunks/vec2.js";import{a as t}from"../../../../../../chunks/vec2f64.js";import{s as r}from"../../../../../../chunks/vec4.js";import{c as a}from"../../../../../../chunks/vec4f64.js";import{FoamIntensity as o}from"./FoamRendering.glsl.js";import{
|
|
5
|
+
import{s as e}from"../../../../../../chunks/vec2.js";import{a as t}from"../../../../../../chunks/vec2f64.js";import{s as r}from"../../../../../../chunks/vec4.js";import{c as a}from"../../../../../../chunks/vec4f64.js";import{FoamIntensity as o}from"./FoamRendering.glsl.js";import{ReadShadowMapPassParameters as m}from"./ReadShadowMap.glsl.js";import{Float2PassUniform as s}from"../../shaderModules/Float2PassUniform.js";import{Float4PassUniform as v}from"../../shaderModules/Float4PassUniform.js";import{glsl as l}from"../../shaderModules/interfaces.js";import{Texture2DPassUniform as u}from"../../shaderModules/Texture2DPassUniform.js";function i(t){t.fragment.uniforms.add(new u("texWaveNormal",(e=>e.waveNormal)),new u("texWavePerturbation",(e=>e.wavePertubation)),new v("waveParams",(e=>r(f,e.waveStrength,e.waveTextureRepeat,e.flowStrength,e.flowOffset))),new s("waveDirection",(t=>e(c,t.waveDirection[0]*t.waveVelocity,t.waveDirection[1]*t.waveVelocity)))),t.include(o),t.fragment.code.add(l`const vec2 FLOW_JUMP = vec2(6.0/25.0, 5.0/24.0);
|
|
6
6
|
vec2 textureDenormalized2D(sampler2D _tex, vec2 _uv) {
|
|
7
7
|
return 2.0 * texture(_tex, _uv).rg - 1.0;
|
|
8
8
|
}
|
|
@@ -51,4 +51,4 @@ float waveTextureRepeat = waveParams[1];
|
|
|
51
51
|
vec3 normal = getWaveLayer(texWaveNormal, texWavePerturbation, _uv * waveTextureRepeat, waveDirection, _time);
|
|
52
52
|
float foam = normals2FoamIntensity(normal, waveParams[0]);
|
|
53
53
|
return vec4(normal, foam);
|
|
54
|
-
}`)}class n extends
|
|
54
|
+
}`)}class n extends m{}const f=a(),c=t();export{i as WaterDistortion,n as WaterDistortionPassParameters};
|
|
@@ -2,26 +2,26 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{OverlayIndex as e}from"../../../../terrain/interfaces.js";import{BackgroundGrid as
|
|
5
|
+
import{OverlayIndex as e}from"../../../../terrain/interfaces.js";import{ReadShadowMapPassParameters as o}from"../shading/ReadShadowMap.glsl.js";import{BackgroundGrid as r}from"./BackgroundGrid.glsl.js";import{overlay as t}from"./Overlay.glsl.js";import{TileBlendInput as s}from"./TileBlendInput.js";import{FloatPassUniform as c}from"../../shaderModules/FloatPassUniform.js";import{glsl as a}from"../../shaderModules/interfaces.js";import{Texture2DPassUniform as n}from"../../shaderModules/Texture2DPassUniform.js";import{Uniform as d}from"../../shaderModules/Uniform.js";class i extends o{constructor(){super(...arguments),this.overlayOpacity=1}}function l(o,r){o.vertex.uniforms.add(new v("overlayTexOffset"),new v("overlayTexScale")),o.fragment.uniforms.add(new c("overlayOpacity",(e=>e.overlayOpacity)),new n("ovColorTex",((o,r)=>0===r.overlays.length?null:r.overlays[e.INNER].getColorTexture(o.overlaySource)))),t(o,r)}function u(e,o){const{vertex:t,fragment:c,varyings:n}=e;n.add("vtc","vec2"),t.uniforms.add(new v("texOffsetAndScale")),c.uniforms.add(new m("tex")),c.uniforms.add(new x("textureOpacities"));const d=o.textureFadingEnabled&&!o.renderOccluded;d&&(t.uniforms.add(new v("nextTexOffsetAndScale")),n.add("nvtc","vec2"),c.uniforms.add(new m("texNext")),c.uniforms.add(new x("nextTexOpacities")),c.uniforms.add(new f("fadeFactor")));const i=o.tileBlendInput===s.ColorComposite,l=o.tileBlendInput===s.GridComposite;l&&c.include(r),i&&c.uniforms.add(new x("backgroundColor")),t.code.add(a`
|
|
6
6
|
void forwardTextureCoordinatesWithTransform(in vec2 uv) {
|
|
7
7
|
vtc = uv * texOffsetAndScale.zw + texOffsetAndScale.xy;
|
|
8
|
-
${d?
|
|
9
|
-
}`),
|
|
8
|
+
${d?a`nvtc = uv * nextTexOffsetAndScale.zw + nextTexOffsetAndScale.xy;`:a``}
|
|
9
|
+
}`),c.code.add(a`
|
|
10
10
|
vec4 getColor(vec4 color, vec2 uv, vec3 opacities) {
|
|
11
|
-
${l||i?
|
|
11
|
+
${l||i?a`
|
|
12
12
|
if (opacities.y <= 0.0) {
|
|
13
13
|
return color * opacities.z * opacities.x;
|
|
14
14
|
}
|
|
15
|
-
vec4 bg = vec4(${i?
|
|
15
|
+
vec4 bg = vec4(${i?a`backgroundColor`:a`gridColor(uv)`} * opacities.y, opacities.y);
|
|
16
16
|
vec4 layer = color * opacities.z;
|
|
17
|
-
return (bg * (1.0 - layer.a) + layer) * opacities.x;`:
|
|
18
|
-
}`),d?
|
|
17
|
+
return (bg * (1.0 - layer.a) + layer) * opacities.x;`:a`return color;`}
|
|
18
|
+
}`),d?c.code.add(a`vec4 getTileColor() {
|
|
19
19
|
vec4 color = getColor(texture(tex, vtc), vtc, textureOpacities);
|
|
20
20
|
if (fadeFactor >= 1.0) {
|
|
21
21
|
return color;
|
|
22
22
|
}
|
|
23
23
|
vec4 nextColor = getColor(texture(texNext, nvtc), nvtc, nextTexOpacities);
|
|
24
24
|
return mix(nextColor, color, fadeFactor);
|
|
25
|
-
}`):
|
|
25
|
+
}`):c.code.add(a`vec4 getTileColor() {
|
|
26
26
|
return getColor(texture(tex, vtc), vtc, textureOpacities);
|
|
27
27
|
}`)}class f extends d{constructor(e){super(e,"float")}}class x extends d{constructor(e){super(e,"vec3")}}class v extends d{constructor(e){super(e,"vec4")}}class m extends d{constructor(e){super(e,"sampler2D")}}export{x as Float3Uniform,l as OverlayTerrain,i as OverlayTerrainPassParameters,u as TerrainTexture,m as Texture2DUniform};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{Uniform as r}from"./Uniform.js";import{BindType as e}from"../shaderTechnique/BindType.js";class o extends r{constructor(r,o,s){super(r,"mat4",e.Draw,((e,s,t)=>e.setUniformMatrix4fv(r,o(s,t))),s)}}export{o as Matrix4sDrawUniform};
|
|
5
|
+
import{Uniform as r}from"./Uniform.js";import{BindType as e}from"../shaderTechnique/BindType.js";class o extends r{constructor(r,o,s){super(r,"mat4",e.Draw,((e,s,t,i)=>e.setUniformMatrix4fv(r,o(s,t,i))),s)}}export{o as Matrix4sDrawUniform};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{smoothstep as t,clamp as e}from"../../../../core/mathUtils.js";import{disposeMaybe as s,releaseMaybe as a}from"../../../../core/maybe.js";import{n as i,s as r,e as h}from"../../../../chunks/vec3.js";import{c as o}from"../../../../chunks/vec3f64.js";import{ViewingMode as c}from"../../../ViewingMode.js";import{
|
|
5
|
+
import{smoothstep as t,clamp as e}from"../../../../core/mathUtils.js";import{disposeMaybe as s,releaseMaybe as a}from"../../../../core/maybe.js";import{n as i,s as r,e as h}from"../../../../chunks/vec3.js";import{c as o}from"../../../../chunks/vec3f64.js";import{ViewingMode as c}from"../../../ViewingMode.js";import{ReadShadowMapDrawParameters as m}from"../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{createQuadVAO as n}from"./glUtil3D.js";import{ShadowHighlightPassParameters as _,ShadowHighlightTechnique as p}from"../shaders/ShadowHighlightTechnique.js";import{vertexCount as d}from"../../../webgl/Util.js";const u=.001953125,l=4e4,g=5e4;class w{constructor(t,e){this._rctx=t,this._viewingMode=e,this._maxOpacity=1,this._passParameters=new _,this._drawParameters=new m,this._vao=n(this._rctx)}get _technique(){return null==this._techniqueCached&&(this._techniqueCached=new p({rctx:this._rctx,viewingMode:this._viewingMode})),this._techniqueCached}render(t,e){if(!t.shadowMap.enabled||!t.linearDepthTexture||!this.isVisible)return;const s=this._technique;this._drawParameters.origin=t.camera.center,this._rctx.bindFramebuffer(e),this._rctx.bindTechnique(s,this._passParameters,t).bindDraw(this._drawParameters,t,this._passParameters),this._rctx.bindVAO(this._vao),this._rctx.drawArrays(s.primitiveType,0,d(this._vao,"geometry"))}get gpuMemoryUsage(){return this._vao?.memoryEstimate??0}setDefaultOptions(t){this._passParameters={...this._passParameters,...t},this._updateMaxOpacity()}updateParameters(s,a){this._passParameters.opacityElevation=1-t(l,g,s.relativeElevation);const o=this._viewingMode===c.Global?i(y,s.center):r(y,0,0,1),m=h(o,a);this._passParameters.dayNightTerminator=t(0,1,e(30*m,0,1))}dispose(){this._vao=s(this._vao),this._techniqueCached=a(this._techniqueCached)}get isVisible(){const{opacityElevation:t,dayNightTerminator:e}=this._passParameters;return this._maxOpacity*t*e>=u}_updateMaxOpacity(){const t=Math.max(this._passParameters.shadowOpacity,this._passParameters.occludedShadowOpacity);this._maxOpacity=t*this._passParameters.shadowColor[3]}}const y=o();export{w as ShadowHighlight};
|