@arcgis/core 4.26.0-next.20230213 → 4.26.0-next.20230215
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/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{4b41a08d603e846306da.js → 1faf0e2aeabe003e2f64.js} +1 -1
- package/assets/esri/core/workers/chunks/{1770729d33e57bb2919a.js → 674d4a032e6db9a86f74.js} +1 -1
- package/assets/esri/core/workers/chunks/8111fc49f8e8f260981d.js +1 -0
- package/assets/esri/core/workers/chunks/979d5e22dbdcec90029f.js +1 -0
- package/assets/esri/core/workers/chunks/9f8aad19c5973e201604.js +1 -0
- package/assets/esri/core/workers/chunks/{21f1d91121d95ef21604.js → bb6e4affafef9855b8fd.js} +1 -1
- package/assets/esri/core/workers/chunks/{accb787c5c8ee7bfe35b.js → caa8768192cecad99776.js} +1 -1
- package/interfaces.d.ts +2 -2
- package/layers/graphics/sources/support/QueryTask.js +1 -1
- package/layers/support/rasterFunctions/BaseRasterFunction.js +1 -1
- package/layers/support/rasterFunctions/LocalFunction.js +1 -1
- package/layers/support/rasterFunctions/LocalFunctionArguments.js +1 -1
- package/layers/support/rasterFunctions/localUtils.js +1 -1
- package/package.json +1 -1
- package/portal/PortalItem.js +1 -1
- package/renderers/visualVariables/SizeVariable.js +1 -1
- package/rest/query/executeQuery.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/CIMImageColorSubstitutionHelper.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/WGLMarkerTemplate.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/3d/environment/EnvironmentRenderer.js +1 -1
- package/views/3d/interactive/Manipulator3D.js +1 -1
- package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/MoveXYAxisManipulation.js +1 -1
- package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.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/Graphics3DPathSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
- package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
- package/views/interactive/snapping/ParallelLineSnapper.js +1 -1
- package/views/interactive/snapping/RightAngleSnapper.js +1 -1
- package/views/interactive/snapping/RightAngleTriangleSnapper.js +1 -1
- package/views/interactive/snapping/Settings.js +1 -1
- package/views/interactive/snapping/SnappingAlgorithm.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Feature/FeatureExpression/FeatureExpressionViewModel.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/FeatureForm/FormExpressionsManager.js +1 -1
- package/widgets/FeatureForm/InputField.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/FieldColumn.js +1 -1
- package/widgets/FeatureTable/Grid/Grid.js +1 -1
- package/widgets/Slice.js +1 -1
- package/assets/esri/core/workers/chunks/52e40e348c27a0e66f9a.js +0 -1
- package/assets/esri/core/workers/chunks/8be68f08c270c62e38bb.js +0 -1
- package/assets/esri/core/workers/chunks/978220022a8c9a3e9261.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.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import"../../../../core/has.js";import{isSome as t,isNone as r,unwrapOr as o,get as a}from"../../../../core/maybe.js";import{f as n,t as s}from"../../../../chunks/mat3.js";import{c as i}from"../../../../chunks/mat3f64.js";import{f as l,m as c,a as u}from"../../../../chunks/mat4.js";import{c as m,b as h}from"../../../../chunks/mat4f64.js";import{a as f,g as p,e as g,n as d,b as x,f as _}from"../../../../chunks/vec3.js";import{Z as T,O as y,c as b}from"../../../../chunks/vec3f64.js";import{O as v}from"../../../../chunks/vec4f64.js";import{projectVectorToDehydratedPoint as C,projectBuffer as O,computeTranslationToOriginAndRotation as w,canProjectWithoutEngine as A}from"../../../../geometry/projection.js";import{create as M,empty as j,expandWithBuffer as E,intersectsClippingArea as R}from"../../../../geometry/support/aaBoundingBox.js";import N from"../../../../geometry/support/MeshComponent.js";import P from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import{BufferViewVec3f64 as I,BufferViewVec3f as B}from"../../../../geometry/support/buffer/BufferView.js";import{t as S,a as F}from"../../../../chunks/vec32.js";import{transformPosition as L,transformNormal as V,projectNormalToPCPF as U,transformTangent as G,projectTangentToPCPF as $}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as D}from"../../../../layers/graphics/dehydratedFeatures.js";import{ViewingMode as k}from"../../../ViewingMode.js";import{isEncodedMeshTexture as q}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as H}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as W}from"./ElevationAligners.js";import{needsElevationUpdates3D as Y,evaluateElevationInfoAtPoint as z}from"./elevationAlignmentUtils.js";import{ElevationContext as Z}from"./ElevationContext.js";import{Object3DEdgeState as J,Graphics3DObject3DGraphicLayer as K}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as Q}from"./Graphics3DSymbolLayer.js";import{createMaterial as X}from"../support/edgeUtils.js";import{parseColorMixMode as ee,encodeSymbolColor as te}from"../support/symbolColorUtils.js";import re from"../../support/debugFlags.js";import{Attribute as oe}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as ae,CullFaceOptions as ne}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as se}from"../../webgl-engine/lib/ContentObjectType.js";import{newFloatArray as ie}from"../../webgl-engine/lib/FloatArray.js";import{Geometry as le}from"../../webgl-engine/lib/Geometry.js";import{generateDefaultIndexArray as ce}from"../../webgl-engine/lib/Indices.js";import{Object3D as ue}from"../../webgl-engine/lib/Object3D.js";import{Texture as me}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as he}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as fe}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as pe}from"../../webgl-engine/materials/NativeLineMaterial.js";import{TextureWrapMode as ge}from"../../../webgl/enums.js";const de=["mesh"];class xe extends Q{constructor(e,t,r,o){super(e,t,r,o),this._materials=new Map,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){re.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new pe({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new pe({color:[0,1,1,1]}))}destroy(){super.destroy(),this._context.stage.removeMany(Array.from(this._materials.values(),(e=>e.material))),this._context.stage.removeMany(Array.from(this._textures.values())),this._materials.clear(),this._textures.clear()}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,de,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t,new Z),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}layerOpacityChanged(e,r){const o=this._getLayerOpacity();this._materials.forEach((e=>{e.material.setParameters({layerOpacity:o});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>{const a=r(e);t(a)&&a.layerOpacityChanged(o,this._context.isAsync)}))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,Y)}slicePlaneEnabledChanged(e,r){return this._materials.forEach((e=>{e.material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>{const o=r(e);t(o)&&o.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._materials.forEach((t=>t.material.setParameters({usePBR:e}))),!0}pixelRatioChanged(){return!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return r(t)?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:n,normalTexture:s,doubleSided:i,alphaCutoff:l,alphaMode:c}=t.material,u=this._colorOrTextureUid(a),m=this._colorOrTextureUid(n),h=this._colorOrTextureUid(s);if(o.color=a,o.colorTexture=n,o.normalTexture=s,o.uid=`${o.uid},cmuid:${u},ctmuid:${m},ntmuid:${h},ds:${i},ac:${l},am:${c}`,t.material instanceof P){const{metallic:e,roughness:r,metallicRoughnessTexture:a,emissiveColor:n,emissiveTexture:s,occlusionTexture:i}=t.material,l=this._colorOrTextureUid(a),c=this._colorOrTextureUid(n),u=this._colorOrTextureUid(s),m=this._colorOrTextureUid(i);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=n,o.emissiveTexture=s,o.occlusionTexture=i,o.colorTextureTransform=t.material.colorTextureTransform,o.normalTextureTransform=t.material.normalTextureTransform,o.emissiveTextureTransform=t.material.emissiveTextureTransform,o.occlusionTextureTransform=t.material.occlusionTextureTransform,o.metallicRoughnessTextureTransform=t.material.metallicRoughnessTextureTransform,o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${l},emuid:${c},etmuid:${u},otmuid:${m}`}return o}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data?e.data:e.url}_getInternalTextureId(e){const r=this._getInternalTexture(e,ae.Opaque);return t(r)?r.id:null}_getInternalTexture(e,r){const o=this._getLoadableTextureResource(e);if(!o)return null;const a=`${e.contentHash}/${r}`;let n=this._textures.get(a);return n||(n=new me(q(o)?o.data:o,{mipmap:!0,wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,preMultiplyAlpha:!q(o)&&r!==ae.Opaque,encoding:q(o)&&t(o.encoding)?o.encoding:void 0}),this._textures.set(a,n),this._context.stage.add(n),this._context.stage.loadImmediate(n)),n}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return ge.CLAMP_TO_EDGE;case"mirror":return ge.MIRRORED_REPEAT;default:return ge.REPEAT}}_setInternalMaterialParameters(r,o){if(t(r.color)&&this._setInternalColorValueParameters(r.color,o),t(r.colorTexture)){const e=this._getInternalTexture(r.colorTexture,o.textureAlphaMode);t(e)?(o.textureId=e.id,o.textureAlphaPremultiplied=!!e.params.preMultiplyAlpha):o.textureId=void 0}t(r.normalTexture)&&(o.normalTextureId=this._getInternalTextureId(r.normalTexture)),t(r.emissiveColor)&&(o.emissiveFactor=e.toUnitRGB(r.emissiveColor)),t(r.emissiveTexture)&&(o.emissiveTextureId=this._getInternalTextureId(r.emissiveTexture)),t(r.occlusionTexture)&&(o.occlusionTextureId=this._getInternalTextureId(r.occlusionTexture)),t(r.metallicRoughnessTexture)&&(o.metallicRoughnessTextureId=this._getInternalTextureId(r.metallicRoughnessTexture)),o.colorTextureTransformMatrix=H(r.colorTextureTransform),o.normalTextureTransformMatrix=H(r.normalTextureTransform),o.occlusionTextureTransformMatrix=H(r.occlusionTextureTransform),o.emissiveTextureTransformMatrix=H(r.emissiveTextureTransform),o.metallicRoughnessTextureTransformMatrix=H(r.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(r){const o=this._drivenProperties.color;let a=t(this.symbolLayer.material)?this.symbolLayer.material.colorMixMode:null;if(o)r.externalColor=v;else{const o=t(this.symbolLayer.material)?this.symbolLayer.material.color:null;t(o)?r.externalColor=e.toUnitRGBA(o):(a=null,r.externalColor=v)}a&&(r.colorMixMode=a),r.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(r(t))return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(e,r){const o=r.material?.color,a=r.material?.colorTexture,n=r.material?.alphaMode,s="blend"===n,i=!("opaque"===n)&&(this._hasTransparentVertexColors(e)||t(o)&&o.a<1||t(a)&&a.transparent||s),l=this._materialProperties(e,r,i),c=this._materials.get(l.uid);if(c)return c.material;const u={material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=null==l.metallicRoughnessTexture&&null==l.metallic&&null==l.roughness,h={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:T,diffuse:y,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:ne.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};m||(h.mrrFactors=[null!=l.metallic?l.metallic:1,null!=l.roughness?l.roughness:1,.5]),r.material&&(h.doubleSided=r.material.doubleSided,h.cullFace=r.material.doubleSided?ne.None:ne.Back,h.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(h),this._setMaterialTransparentParameter(h,u),this._setInternalMaterialParameters(l,h);const f=new fe(h);return u.material=f,this._materials.set(l.uid,u),this._context.stage.add(f),f}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?ae.MaskBlend:ae.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?ae.Opaque:"mask"===t.alphaMode?ae.Mask:ae.Blend}_addDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,a=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),n=[],s=[],i=[],l=[];for(let h=0;h<r;h++){const e=t[h],r=e.vertexAttributes.get(he.POSITION),o=e.vertexAttributes.get(he.NORMAL),c=e.indices.get(he.POSITION),u=e.indices.get(he.NORMAL),m=r.data,g=o.data;for(let t=0;t<c.length;t++){const e=3*c[t],r=3*u[t];for(let t=0;t<3;t++)n.push(m[e+t]);for(let t=0;t<3;t++)n.push(m[e+t]+g[r+t]*a);if(s.push(s.length),s.push(s.length),t%3==0){this._calculateFaceNormal(m,c,t,Ce),this._getFaceVertices(m,c,t,ye,be,ve),f(ye,ye,be),f(ye,ye,ve),p(ye,ye,1/3);for(let e=0;e<3;e++)i.push(ye[e]);for(let e=0;e<3;e++)i.push(ye[e]+Ce[e]*a);l.push(l.length),l.push(l.length)}}}const c=t[0].transformation,u=new le(this._debugVertexNormalMaterial,[[he.POSITION,new oe(n,3,!0)]],[[he.POSITION,s]],null,se.Line);t.push(u),u.transformation=c;const m=new le(this._debugFaceNormalMaterial,[[he.POSITION,new oe(i,3,!0)]],[[he.POSITION,l]],null,se.Line);m.transformation=c,t.push(m)}_createAs3DShape(e,o,a,n){const s=e.geometry;if("mesh"!==s.type)return null;const i=this._createGeometryInfo(s,o,n);if(r(i))return null;const{geometries:l,objectTransformation:c}=i;re.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(s,l);const u=new ue({geometries:l,metadata:{layerUid:this._context.layer.uid,graphicUid:n}});u.transformation=c;const m=X(this.symbolLayer,{opacity:this._getLayerOpacity()}),h=t(m)?new J(l[0].material,[m],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,f=new K(this,u,l,null,null,W,a,h);f.needsElevationUpdates=Y(a.mode),f.useObjectOriginAsAttachmentOrigin=!0,a.centerPointInElevationSR=this._getCenterPointInElevationSR(u);const{elevationProvider:p,renderCoordsHelper:g}=this._context,d=(e,t)=>z(e,p,a,g,t);return f.alignedSampledElevation=W(f,a,p.spatialReference,d,g),f}_getCenterPointInElevationSR(e){const r=D(0,0,0,t(this._context.elevationProvider.spatialReference)?this._context.elevationProvider.spatialReference:null);return C([e.transformation[12],e.transformation[13],e.transformation[14]],this._context.renderCoordsHelper.spatialReference,r),r}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){default:case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o)}}_createComponentNormalsSource(e,t,o,a){if(r(t))return this._createComponentNormalsFlat(e,a);let n=!1;if(!o.trustSourceNormals)for(let r=0;r<a.length;r+=3){this._calculateFaceNormal(e,a,r,Ce);for(let e=0;e<3;e++){const o=3*a[r+e];ye[0]=t[o+0],ye[1]=t[o+1],ye[2]=t[o+2],g(Ce,ye)<0&&(t[o+0]=-t[o+0],t[o+1]=-t[o+1],t[o+2]=-t[o+2],n=!0)}}return new _e(t,a,n)}_createComponentNormalsFlat(e,t){const r=ie(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const n=this._calculateFaceNormal(e,t,a,Ce);for(let e=0;e<3;e++)r[a+e]=n[e],o[a+e]=a/3}return new _e(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let n=0;n<t.length;n+=3){const o=this._calculateFaceNormal(e,t,n,Ce);for(let e=0;e<3;e++){const a=t[n+e];let s=r[a];s||(s={normal:b(),count:0},r[a]=s),f(s.normal,s.normal,o),s.count++}}const o=ie(3*t.length),a=new Array(3*t.length);for(let n=0;n<t.length;n++){const e=r[t[n]];1!==e.count&&(d(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*n+t]=e.normal[t];a[n]=n}return new _e(o,a,!1)}_getFaceVertices(e,t,r,o,a,n){const s=3*t[r+0],i=3*t[r+1],l=3*t[r+2];o[0]=e[s+0],o[1]=e[s+1],o[2]=e[s+2],a[0]=e[i+0],a[1]=e[i+1],a[2]=e[i+2],n[0]=e[l+0],n[1]=e[l+1],n[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,ye,be,ve),x(be,be,ye),x(ve,ve,ye),_(ye,be,ve),d(o,ye),o}_getOrCreateComponents(e){return o(e.components,Me)}_createPositionBuffer(e,r){let o=e.vertexAttributes.position;const a=r.reprojection===je.ECEF?r.transformBeforeProject:null;if(t(a)&&(o=L(o,new Float64Array(o.length),a)),r.reprojection===je.NONE)return r.needsBufferCopy?new Float64Array(o):o;const n=t(a)?o:new Float64Array(o.length);return O(o,e.spatialReference,0,n,this._context.renderCoordsHelper.spatialReference,0,o.length/3),n}_createNormalBuffer(e,o,a){let n=e.vertexAttributes.normal;if(r(n))return null;const s=a.reprojection===je.ECEF?a.transformBeforeProject:null;t(s)&&(n=V(n,new Float32Array(n.length),s));if("local"===this._context.graphicsCoreOwner.view.viewingMode||a.reprojection===je.NONE)return a.needsBufferCopy&&e.vertexAttributes.normal===n?new Float32Array(n):n;const i=e.vertexAttributes.position,l=t(s)?n:new Float32Array(n.length);return U(n,i,o,e.spatialReference,l)}_createTangentBuffer(e,o,a){let n=e.vertexAttributes.tangent;if(r(n))return null;const s=a.reprojection===je.ECEF?a.transformBeforeProject:null;t(s)&&(n=G(n,new Float32Array(n.length),s));if("local"===this._context.graphicsCoreOwner.view.viewingMode||a.reprojection===je.NONE)return a.needsBufferCopy&&e.vertexAttributes.normal===n?new Float32Array(n):n;const i=e.vertexAttributes.position,l=t(s)?n:new Float32Array(n.length);return $(n,i,o,e.spatialReference,l)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=ee(a(this.symbolLayer,"material","colorMixMode")),o=new Uint8Array(4);return te(t,r,o),o}return null}_createBuffers(e,r){const o=e.vertexAttributes&&e.vertexAttributes.position;if(!o)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const a=e.vertexAttributes.normal,n=e.vertexAttributes.uv,s=e.vertexAttributes.tangent;if(t(a)&&a.length!==o.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(t(s)&&s.length/4!=o.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(t(n)&&n.length/2!=o.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const i=this._computeReprojectionInfo(e),l=this._createPositionBuffer(e,i),c=this._createColorBuffer(e),u=this._createSymbolColorBuffer(r),h=this._createNormalBuffer(e,l,i),f=this._createTangentBuffer(e,l,i);return{positionBuffer:l,normalBuffer:h,tangentBuffer:f,uvBuffer:n,colorBuffer:c,symbolColorBuffer:u,objectTransformation:i.reprojection===je.NONE&&t(i.objectTransformation)?i.objectTransformation:this._transformOriginLocal(e,l,h,f),geometryTransformation:i.reprojection===je.NONE&&t(i.geometryTransformation)?i.geometryTransformation:m()}}_computeReprojectionInfo(e){const r=t(e.transform),o=r&&e.transform.geographic||this._context.renderCoordsHelper.viewingMode===k.Local?je.NONE:je.ECEF;if(r){if(o===je.NONE){const t=m();w(e.spatialReference,e.transform.origin,t,this._context.renderCoordsHelper.spatialReference);return{reprojection:o,objectTransformation:t,geometryTransformation:h(e.transform.localMatrix),needsBufferCopy:!1}}const t=l(m(),e.transform.origin);return c(t,t,e.transform.localMatrix),{reprojection:o,transformBeforeProject:t,needsBufferCopy:!0}}return{reprojection:o,needsBufferCopy:!0}}_transformOriginLocal(e,r,o,a){const i=this._context.renderCoordsHelper.spatialReference,l=e.anchor;Te[0]=l.x,Te[1]=l.y,Te[2]=l.z;const c=m();w(e.spatialReference,Te,c,i);const h=I.fromTypedArray(r);if(u(Oe,c),S(h,h,Oe),t(o)||t(a)){if(n(we,c),s(we,we),t(o)){const e=B.fromTypedArray(o);F(e,e,we)}if(t(a)){const e=B.fromTypedArray(a,4*a.BYTES_PER_ELEMENT);F(e,e,we)}}return c}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_getOrCreateFaces(e,t){return t.faces?t.faces:ce(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return!1;const o=this._context.elevationProvider.spatialReference;let a;const n=r.length/3;return t(o)&&!e.spatialReference.equals(o)?(a=new Float64Array(r.length),O(e.vertexAttributes.position,e.spatialReference,0,a,o,0,n)):a=r,j(Ae),E(Ae,a,0,n),!R(Ae,this._context.clippingExtent)}_createGeometryInfo(e,o,a){if(!A(e.spatialReference,this._context.graphicsCoreOwner.view.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const n=this._createBuffers(e,o);if(r(n))return null;const{positionBuffer:s,uvBuffer:i,colorBuffer:l,symbolColorBuffer:c,normalBuffer:u,tangentBuffer:m,objectTransformation:h,geometryTransformation:f}=n,p=this._getOrCreateComponents(e),g=new Array;let d=!1;for(const r of p){if(!this._validateFaces(e,r))return null;const o=this._getOrCreateFaces(e,r);if(0===o.length)continue;const n=this._createComponentNormals(s,u,r,o);n.didFlipNormals&&(d=!0);const h=[[he.POSITION,new oe(s,3,!0)],[he.NORMAL,new oe(n.normals,3,!0)]],p=[[he.POSITION,o],[he.NORMAL,n.indices]];t(l)&&(h.push([he.COLOR,new oe(l,4,!0)]),p.push([he.COLOR,o])),t(c)&&(h.push([he.SYMBOLCOLOR,new oe(c,4,!0)]),p.push([he.SYMBOLCOLOR,new Array(o.length).fill(0)])),t(i)&&(h.push([he.UV0,new oe(i,2,!0)]),p.push([he.UV0,o])),t(m)&&(h.push([he.TANGENT,new oe(m,4,!0)]),p.push([he.TANGENT,o]));const x=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:a,layerUid:this._context.layer.uid}),_=this._getOrCreateMaterial(e,r),T=new le(_,h,p,null,se.Mesh,x);T.transformation=f,g.push(T)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:g,objectTransformation:h}}}class _e{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const Te=b(),ye=b(),be=b(),ve=b(),Ce=b(),Oe=m(),we=i(),Ae=M(),Me=[new N];var je;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(je||(je={}));export{xe as Graphics3DMeshFillSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import"../../../../core/has.js";import{isSome as t,isNone as r,unwrapOr as o,get as a}from"../../../../core/maybe.js";import{f as n,t as s}from"../../../../chunks/mat3.js";import{c as i}from"../../../../chunks/mat3f64.js";import{f as l,m as c,a as u}from"../../../../chunks/mat4.js";import{c as m,b as h}from"../../../../chunks/mat4f64.js";import{a as f,g as p,e as g,n as d,b as x,f as _}from"../../../../chunks/vec3.js";import{Z as T,O as y,c as b}from"../../../../chunks/vec3f64.js";import{O as v}from"../../../../chunks/vec4f64.js";import{projectVectorToDehydratedPoint as C,projectBuffer as O,computeTranslationToOriginAndRotation as w,canProjectWithoutEngine as A}from"../../../../geometry/projection.js";import{create as M,empty as j,expandWithBuffer as E,intersectsClippingArea as R}from"../../../../geometry/support/aaBoundingBox.js";import N from"../../../../geometry/support/MeshComponent.js";import P from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import{BufferViewVec3f64 as I,BufferViewVec3f as B}from"../../../../geometry/support/buffer/BufferView.js";import{t as S,a as F}from"../../../../chunks/vec32.js";import{transformPosition as L,transformNormal as V,projectNormalToPCPF as U,transformTangent as G,projectTangentToPCPF as $}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as D}from"../../../../layers/graphics/dehydratedFeatures.js";import{ViewingMode as k}from"../../../ViewingMode.js";import{isEncodedMeshTexture as H}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as q}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as W}from"./ElevationAligners.js";import{needsElevationUpdates3D as Y,evaluateElevationInfoAtPoint as z}from"./elevationAlignmentUtils.js";import{ElevationContext as Z}from"./ElevationContext.js";import{Object3DEdgeState as J,Graphics3DObject3DGraphicLayer as K}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as Q}from"./Graphics3DSymbolLayer.js";import{createMaterial as X}from"../support/edgeUtils.js";import{parseColorMixMode as ee,encodeSymbolColor as te}from"../support/symbolColorUtils.js";import re from"../../support/debugFlags.js";import{Attribute as oe}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as ae,CullFaceOptions as ne}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as se}from"../../webgl-engine/lib/ContentObjectType.js";import{newFloatArray as ie}from"../../webgl-engine/lib/FloatArray.js";import{Geometry as le}from"../../webgl-engine/lib/Geometry.js";import{generateDefaultIndexArray as ce}from"../../webgl-engine/lib/Indices.js";import{Object3D as ue}from"../../webgl-engine/lib/Object3D.js";import{Texture as me}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as he}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as fe}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as pe}from"../../webgl-engine/materials/NativeLineMaterial.js";import{TextureWrapMode as ge}from"../../../webgl/enums.js";const de=["mesh"];class xe extends Q{constructor(e,t,r,o){super(e,t,r,o),this._materials=new Map,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){re.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new pe({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new pe({color:[0,1,1,1]}))}destroy(){super.destroy(),this._context.stage.removeMany(Array.from(this._materials.values(),(e=>e.material))),this._context.stage.removeMany(Array.from(this._textures.values())),this._materials.clear(),this._textures.clear()}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,de,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t,new Z),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}layerOpacityChanged(e,r){const o=this._getLayerOpacity();this._materials.forEach((e=>{e.material.setParameters({layerOpacity:o});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>{const a=r(e);t(a)&&a.layerOpacityChanged(o,this._context.isAsync)}))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,Y)}slicePlaneEnabledChanged(e,r){return this._materials.forEach((e=>{e.material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>{const o=r(e);t(o)&&o.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._materials.forEach((t=>t.material.setParameters({usePBR:e}))),!0}pixelRatioChanged(){return!0}skipHighSymbolLodsChanged(){return!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return r(t)?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:n,normalTexture:s,doubleSided:i,alphaCutoff:l,alphaMode:c}=t.material,u=this._colorOrTextureUid(a),m=this._colorOrTextureUid(n),h=this._colorOrTextureUid(s);if(o.color=a,o.colorTexture=n,o.normalTexture=s,o.uid=`${o.uid},cmuid:${u},ctmuid:${m},ntmuid:${h},ds:${i},ac:${l},am:${c}`,t.material instanceof P){const{metallic:e,roughness:r,metallicRoughnessTexture:a,emissiveColor:n,emissiveTexture:s,occlusionTexture:i}=t.material,l=this._colorOrTextureUid(a),c=this._colorOrTextureUid(n),u=this._colorOrTextureUid(s),m=this._colorOrTextureUid(i);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=n,o.emissiveTexture=s,o.occlusionTexture=i,o.colorTextureTransform=t.material.colorTextureTransform,o.normalTextureTransform=t.material.normalTextureTransform,o.emissiveTextureTransform=t.material.emissiveTextureTransform,o.occlusionTextureTransform=t.material.occlusionTextureTransform,o.metallicRoughnessTextureTransform=t.material.metallicRoughnessTextureTransform,o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${l},emuid:${c},etmuid:${u},otmuid:${m}`}return o}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data?e.data:e.url}_getInternalTextureId(e){const r=this._getInternalTexture(e,ae.Opaque);return t(r)?r.id:null}_getInternalTexture(e,r){const o=this._getLoadableTextureResource(e);if(!o)return null;const a=`${e.contentHash}/${r}`;let n=this._textures.get(a);return n||(n=new me(H(o)?o.data:o,{mipmap:!0,wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,preMultiplyAlpha:!H(o)&&r!==ae.Opaque,encoding:H(o)&&t(o.encoding)?o.encoding:void 0}),this._textures.set(a,n),this._context.stage.add(n),this._context.stage.loadImmediate(n)),n}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return ge.CLAMP_TO_EDGE;case"mirror":return ge.MIRRORED_REPEAT;default:return ge.REPEAT}}_setInternalMaterialParameters(r,o){if(t(r.color)&&this._setInternalColorValueParameters(r.color,o),t(r.colorTexture)){const e=this._getInternalTexture(r.colorTexture,o.textureAlphaMode);t(e)?(o.textureId=e.id,o.textureAlphaPremultiplied=!!e.params.preMultiplyAlpha):o.textureId=void 0}t(r.normalTexture)&&(o.normalTextureId=this._getInternalTextureId(r.normalTexture)),t(r.emissiveColor)&&(o.emissiveFactor=e.toUnitRGB(r.emissiveColor)),t(r.emissiveTexture)&&(o.emissiveTextureId=this._getInternalTextureId(r.emissiveTexture)),t(r.occlusionTexture)&&(o.occlusionTextureId=this._getInternalTextureId(r.occlusionTexture)),t(r.metallicRoughnessTexture)&&(o.metallicRoughnessTextureId=this._getInternalTextureId(r.metallicRoughnessTexture)),o.colorTextureTransformMatrix=q(r.colorTextureTransform),o.normalTextureTransformMatrix=q(r.normalTextureTransform),o.occlusionTextureTransformMatrix=q(r.occlusionTextureTransform),o.emissiveTextureTransformMatrix=q(r.emissiveTextureTransform),o.metallicRoughnessTextureTransformMatrix=q(r.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(r){const o=this._drivenProperties.color;let a=t(this.symbolLayer.material)?this.symbolLayer.material.colorMixMode:null;if(o)r.externalColor=v;else{const o=t(this.symbolLayer.material)?this.symbolLayer.material.color:null;t(o)?r.externalColor=e.toUnitRGBA(o):(a=null,r.externalColor=v)}a&&(r.colorMixMode=a),r.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(r(t))return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(e,r){const o=r.material?.color,a=r.material?.colorTexture,n=r.material?.alphaMode,s="blend"===n,i=!("opaque"===n)&&(this._hasTransparentVertexColors(e)||t(o)&&o.a<1||t(a)&&a.transparent||s),l=this._materialProperties(e,r,i),c=this._materials.get(l.uid);if(c)return c.material;const u={material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=null==l.metallicRoughnessTexture&&null==l.metallic&&null==l.roughness,h={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:T,diffuse:y,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:ne.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};m||(h.mrrFactors=[null!=l.metallic?l.metallic:1,null!=l.roughness?l.roughness:1,.5]),r.material&&(h.doubleSided=r.material.doubleSided,h.cullFace=r.material.doubleSided?ne.None:ne.Back,h.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(h),this._setMaterialTransparentParameter(h,u),this._setInternalMaterialParameters(l,h);const f=new fe(h);return u.material=f,this._materials.set(l.uid,u),this._context.stage.add(f),f}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?ae.MaskBlend:ae.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?ae.Opaque:"mask"===t.alphaMode?ae.Mask:ae.Blend}_addDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,a=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),n=[],s=[],i=[],l=[];for(let h=0;h<r;h++){const e=t[h],r=e.vertexAttributes.get(he.POSITION),o=e.vertexAttributes.get(he.NORMAL),c=e.indices.get(he.POSITION),u=e.indices.get(he.NORMAL),m=r.data,g=o.data;for(let t=0;t<c.length;t++){const e=3*c[t],r=3*u[t];for(let t=0;t<3;t++)n.push(m[e+t]);for(let t=0;t<3;t++)n.push(m[e+t]+g[r+t]*a);if(s.push(s.length),s.push(s.length),t%3==0){this._calculateFaceNormal(m,c,t,Ce),this._getFaceVertices(m,c,t,ye,be,ve),f(ye,ye,be),f(ye,ye,ve),p(ye,ye,1/3);for(let e=0;e<3;e++)i.push(ye[e]);for(let e=0;e<3;e++)i.push(ye[e]+Ce[e]*a);l.push(l.length),l.push(l.length)}}}const c=t[0].transformation,u=new le(this._debugVertexNormalMaterial,[[he.POSITION,new oe(n,3,!0)]],[[he.POSITION,s]],null,se.Line);t.push(u),u.transformation=c;const m=new le(this._debugFaceNormalMaterial,[[he.POSITION,new oe(i,3,!0)]],[[he.POSITION,l]],null,se.Line);m.transformation=c,t.push(m)}_createAs3DShape(e,o,a,n){const s=e.geometry;if("mesh"!==s.type)return null;const i=this._createGeometryInfo(s,o,n);if(r(i))return null;const{geometries:l,objectTransformation:c}=i;re.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(s,l);const u=new ue({geometries:l,metadata:{layerUid:this._context.layer.uid,graphicUid:n}});u.transformation=c;const m=X(this.symbolLayer,{opacity:this._getLayerOpacity()}),h=t(m)?new J(l[0].material,[m],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,f=new K(this,u,l,null,null,W,a,h);f.needsElevationUpdates=Y(a.mode),f.useObjectOriginAsAttachmentOrigin=!0,a.centerPointInElevationSR=this._getCenterPointInElevationSR(u);const{elevationProvider:p,renderCoordsHelper:g}=this._context,d=(e,t)=>z(e,p,a,g,t);return f.alignedSampledElevation=W(f,a,p.spatialReference,d,g),f}_getCenterPointInElevationSR(e){const r=D(0,0,0,t(this._context.elevationProvider.spatialReference)?this._context.elevationProvider.spatialReference:null);return C([e.transformation[12],e.transformation[13],e.transformation[14]],this._context.renderCoordsHelper.spatialReference,r),r}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){default:case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o)}}_createComponentNormalsSource(e,t,o,a){if(r(t))return this._createComponentNormalsFlat(e,a);let n=!1;if(!o.trustSourceNormals)for(let r=0;r<a.length;r+=3){this._calculateFaceNormal(e,a,r,Ce);for(let e=0;e<3;e++){const o=3*a[r+e];ye[0]=t[o+0],ye[1]=t[o+1],ye[2]=t[o+2],g(Ce,ye)<0&&(t[o+0]=-t[o+0],t[o+1]=-t[o+1],t[o+2]=-t[o+2],n=!0)}}return new _e(t,a,n)}_createComponentNormalsFlat(e,t){const r=ie(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const n=this._calculateFaceNormal(e,t,a,Ce);for(let e=0;e<3;e++)r[a+e]=n[e],o[a+e]=a/3}return new _e(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let n=0;n<t.length;n+=3){const o=this._calculateFaceNormal(e,t,n,Ce);for(let e=0;e<3;e++){const a=t[n+e];let s=r[a];s||(s={normal:b(),count:0},r[a]=s),f(s.normal,s.normal,o),s.count++}}const o=ie(3*t.length),a=new Array(3*t.length);for(let n=0;n<t.length;n++){const e=r[t[n]];1!==e.count&&(d(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*n+t]=e.normal[t];a[n]=n}return new _e(o,a,!1)}_getFaceVertices(e,t,r,o,a,n){const s=3*t[r+0],i=3*t[r+1],l=3*t[r+2];o[0]=e[s+0],o[1]=e[s+1],o[2]=e[s+2],a[0]=e[i+0],a[1]=e[i+1],a[2]=e[i+2],n[0]=e[l+0],n[1]=e[l+1],n[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,ye,be,ve),x(be,be,ye),x(ve,ve,ye),_(ye,be,ve),d(o,ye),o}_getOrCreateComponents(e){return o(e.components,Me)}_createPositionBuffer(e,r){let o=e.vertexAttributes.position;const a=r.reprojection===je.ECEF?r.transformBeforeProject:null;if(t(a)&&(o=L(o,new Float64Array(o.length),a)),r.reprojection===je.NONE)return r.needsBufferCopy?new Float64Array(o):o;const n=t(a)?o:new Float64Array(o.length);return O(o,e.spatialReference,0,n,this._context.renderCoordsHelper.spatialReference,0,o.length/3),n}_createNormalBuffer(e,o,a){let n=e.vertexAttributes.normal;if(r(n))return null;const s=a.reprojection===je.ECEF?a.transformBeforeProject:null;t(s)&&(n=V(n,new Float32Array(n.length),s));if("local"===this._context.graphicsCoreOwner.view.viewingMode||a.reprojection===je.NONE)return a.needsBufferCopy&&e.vertexAttributes.normal===n?new Float32Array(n):n;const i=e.vertexAttributes.position,l=t(s)?n:new Float32Array(n.length);return U(n,i,o,e.spatialReference,l)}_createTangentBuffer(e,o,a){let n=e.vertexAttributes.tangent;if(r(n))return null;const s=a.reprojection===je.ECEF?a.transformBeforeProject:null;t(s)&&(n=G(n,new Float32Array(n.length),s));if("local"===this._context.graphicsCoreOwner.view.viewingMode||a.reprojection===je.NONE)return a.needsBufferCopy&&e.vertexAttributes.normal===n?new Float32Array(n):n;const i=e.vertexAttributes.position,l=t(s)?n:new Float32Array(n.length);return $(n,i,o,e.spatialReference,l)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=ee(a(this.symbolLayer,"material","colorMixMode")),o=new Uint8Array(4);return te(t,r,o),o}return null}_createBuffers(e,r){const o=e.vertexAttributes&&e.vertexAttributes.position;if(!o)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const a=e.vertexAttributes.normal,n=e.vertexAttributes.uv,s=e.vertexAttributes.tangent;if(t(a)&&a.length!==o.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(t(s)&&s.length/4!=o.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(t(n)&&n.length/2!=o.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const i=this._computeReprojectionInfo(e),l=this._createPositionBuffer(e,i),c=this._createColorBuffer(e),u=this._createSymbolColorBuffer(r),h=this._createNormalBuffer(e,l,i),f=this._createTangentBuffer(e,l,i);return{positionBuffer:l,normalBuffer:h,tangentBuffer:f,uvBuffer:n,colorBuffer:c,symbolColorBuffer:u,objectTransformation:i.reprojection===je.NONE&&t(i.objectTransformation)?i.objectTransformation:this._transformOriginLocal(e,l,h,f),geometryTransformation:i.reprojection===je.NONE&&t(i.geometryTransformation)?i.geometryTransformation:m()}}_computeReprojectionInfo(e){const r=t(e.transform),o=r&&e.transform.geographic||this._context.renderCoordsHelper.viewingMode===k.Local?je.NONE:je.ECEF;if(r){if(o===je.NONE){const t=m();w(e.spatialReference,e.transform.origin,t,this._context.renderCoordsHelper.spatialReference);return{reprojection:o,objectTransformation:t,geometryTransformation:h(e.transform.localMatrix),needsBufferCopy:!1}}const t=l(m(),e.transform.origin);return c(t,t,e.transform.localMatrix),{reprojection:o,transformBeforeProject:t,needsBufferCopy:!0}}return{reprojection:o,needsBufferCopy:!0}}_transformOriginLocal(e,r,o,a){const i=this._context.renderCoordsHelper.spatialReference,l=e.anchor;Te[0]=l.x,Te[1]=l.y,Te[2]=l.z;const c=m();w(e.spatialReference,Te,c,i);const h=I.fromTypedArray(r);if(u(Oe,c),S(h,h,Oe),t(o)||t(a)){if(n(we,c),s(we,we),t(o)){const e=B.fromTypedArray(o);F(e,e,we)}if(t(a)){const e=B.fromTypedArray(a,4*a.BYTES_PER_ELEMENT);F(e,e,we)}}return c}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_getOrCreateFaces(e,t){return t.faces?t.faces:ce(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return!1;const o=this._context.elevationProvider.spatialReference;let a;const n=r.length/3;return t(o)&&!e.spatialReference.equals(o)?(a=new Float64Array(r.length),O(e.vertexAttributes.position,e.spatialReference,0,a,o,0,n)):a=r,j(Ae),E(Ae,a,0,n),!R(Ae,this._context.clippingExtent)}_createGeometryInfo(e,o,a){if(!A(e.spatialReference,this._context.graphicsCoreOwner.view.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const n=this._createBuffers(e,o);if(r(n))return null;const{positionBuffer:s,uvBuffer:i,colorBuffer:l,symbolColorBuffer:c,normalBuffer:u,tangentBuffer:m,objectTransformation:h,geometryTransformation:f}=n,p=this._getOrCreateComponents(e),g=new Array;let d=!1;for(const r of p){if(!this._validateFaces(e,r))return null;const o=this._getOrCreateFaces(e,r);if(0===o.length)continue;const n=this._createComponentNormals(s,u,r,o);n.didFlipNormals&&(d=!0);const h=[[he.POSITION,new oe(s,3,!0)],[he.NORMAL,new oe(n.normals,3,!0)]],p=[[he.POSITION,o],[he.NORMAL,n.indices]];t(l)&&(h.push([he.COLOR,new oe(l,4,!0)]),p.push([he.COLOR,o])),t(c)&&(h.push([he.SYMBOLCOLOR,new oe(c,4,!0)]),p.push([he.SYMBOLCOLOR,new Array(o.length).fill(0)])),t(i)&&(h.push([he.UV0,new oe(i,2,!0)]),p.push([he.UV0,o])),t(m)&&(h.push([he.TANGENT,new oe(m,4,!0)]),p.push([he.TANGENT,o]));const x=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:a,layerUid:this._context.layer.uid}),_=this._getOrCreateMaterial(e,r),T=new le(_,h,p,null,se.Mesh,x);T.transformation=f,g.push(T)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:g,objectTransformation:h}}}class _e{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const Te=b(),ye=b(),be=b(),ve=b(),Ce=b(),Oe=m(),we=i(),Ae=M(),Me=[new N];var je;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(je||(je={}));export{xe as Graphics3DMeshFillSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import has from"../../../../core/has.js";import{isSome as t,get as s,none as r,isNone as i,unwrapOr as a}from"../../../../core/maybe.js";import{throwIfAborted as o}from"../../../../core/promiseUtils.js";import{pt2px as n}from"../../../../core/screenUtils.js";import{c,i as l,k as h,w as d}from"../../../../chunks/mat4.js";import{c as p}from"../../../../chunks/mat4f64.js";import{l as m,o as u,c as y,B as f,a as _,s as b}from"../../../../chunks/vec3.js";import{d as g,O as P,Z as x,f as R,c as v}from"../../../../chunks/vec3f64.js";import{O as L,c as S}from"../../../../chunks/vec4f64.js";import{projectPointToVector as C,computeTranslationToOriginAndRotation as j}from"../../../../geometry/projection.js";import{create as w,size as U,containsPoint as E,center as T}from"../../../../geometry/support/aaBoundingBox.js";import{defaultPrimitive as A}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as B,objectSymbolLayerSizeWithResourceSize as I}from"../../../../symbols/support/symbolLayerUtils3D.js";import{perLodInstanceElevationAligner as O}from"./ElevationAligners.js";import{needsElevationUpdates3D as G,evaluateElevationInfoAtPoint as D,SampleElevationInfo as M}from"./elevationAlignmentUtils.js";import{ElevationContext as z}from"./ElevationContext.js";import F from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as V}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as k,mixinColorAndOpacity as H,computeObjectScale as W,computeObjectRotation as q}from"./graphicUtils.js";import{ApplyRendererDiffResult as N}from"./interfaces.js";import{LoadStatus as $}from"./Loadable.js";import{makeLodResources as Z}from"./lodResourceUtils.js";import{fetch as J}from"./objectResourceUtils.js";import{placePointOnGeometry as K,extendPointGraphicElevationContext as Q}from"./pointUtils.js";import{isValidPrimitive as X,primitiveLodResources as Y}from"./primitiveObjectSymbolUtils.js";import{defaultSymbolLayerMemoryComplexity as ee}from"./symbolComplexity.js";import{initFastSymbolUpdatesState as te,updateFastSymbolUpdatesState as se,evaluateModelTransform as re,evaluateModelTransformScale as ie}from"../support/FastSymbolUpdates.js";import{CullFaceOptions as ae}from"../../webgl-engine/lib/basicInterfaces.js";import{VertexAttribute as oe}from"../../webgl-engine/lib/VertexAttribute.js";import{LodRenderer as ne}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{materialsFromLodResources as ce,texturesFromLodResources as le,geometriesFromLodResources as he,geometriesFromLodLevelResources as de}from"../../webgl-engine/lib/lodRendering/LodResources.js";import{DefaultMaterial as pe}from"../../webgl-engine/materials/DefaultMaterial.js";class me{constructor(e,t,s,r,i,a,o,n,c,l,h,d){this.lodResources=e,this.lodRenderer=t,this.stageResources=s,this.originalMaterialParameters=r,this.resourceSize=i,this.isEsriSymbolResource=a,this.isWosr=o,this.resourceBoundingBox=n,this.symbolSize=c,this.extentPadding=l,this.physicalBasedRenderingEnabled=h,this.pivotOffset=d}}class ue extends V{getCachedSize(){const[e,s,r]=t(this._resources)?this._resources.symbolSize:[1,1,1];return{width:e,depth:s,height:r}}constructor(e,t,s,r){super(e,t,s,r),this._resources=null,this._optionalFields=new Array,this._instanceIndexToGraphicUid=new Map,this._hasLoadedPBRTextures=!1,this._disposeResourceHandles=new Array,this.ensureDrapedStatus(!1),this._hasLoadedPBRTextures=s.physicalBasedRenderingEnabled}async doLoad(e){if(!this._drivenProperties.size){if(k(this.symbolLayer))throw new Error}const t=this.symbolLayer;if(this._isPrimitive){const s=t.resource?t.resource.primitive:A;this._resources=await this._createResourcesForPrimitive(s,e)}else this._resources=await this._createResourcesForUrl(t.resource.href,e);this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicalBasedRenderingChanged(),this.complexity=this.computeComplexity()}get extentPadding(){return t(this._resources)?this._resources.extentPadding:0}get _isPrimitive(){return!(this.symbolLayer.resource&&this.symbolLayer.resource.href)}get lodRenderer(){return t(this._resources)?this._resources.lodRenderer:null}_setMaterialTransparencyParams(e,t=s(this.symbolLayer,"material","color")){const r=this._getCombinedOpacity(t),i=r<1||this.needsDrivenTransparentPass;return e.transparent=i,e.opacity=r,e.cullFace=i?ae.None:ae.Back,e}async _createResourcesForPrimitive(s,i){if(!X(s))throw new Error(`Unknown object symbol primitive: ${s}`);const a=this.symbolLayer,o=w(B(s)),c=g(U(o)),l=g(I(c,a)),h=m(l),d=!1,p=!1,u={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,ambient:P,diffuse:P,hasSlicePlane:this._context.slicePlaneEnabled,hasSliceHighlight:!1,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!this.symbolLayer.isPrimitive},y=!!u.usePBR;this._setMaterialTransparencyParams(u);const f=this.symbol;if("point-3d"===f.type&&f.verticalOffset){const{screenLength:e,minWorldLength:s,maxWorldLength:r}=f.verticalOffset;u.verticalOffset={screenLength:n(e),minWorldLength:s||0,maxWorldLength:t(r)?r:1/0},u.castShadows=!1}if(this._context.screenSizePerspectiveEnabled&&(u.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),this._drivenProperties.color)u.externalColor=L;else{const s=t(a.material)?a.material.color:null,r=t(s)?e.toUnitRGBA(s):L;u.externalColor=r}this._fastUpdates=te(this._context.renderer,this._fastVisualVariableConvertOptions(o,l,c,r)),u.instanced=["transformation"],this._fastUpdates.enabled?(Object.assign(u,this._fastUpdates.materialParameters),u.instanced.push("featureAttribute"),this._optionalFields.push("featureAttribute")):this._hasPerInstanceColor()&&(u.instanced.push("color"),this._optionalFields.push("color")),has("enable-feature:objectAndLayerId-rendering")&&(u.instanced.push("objectAndLayerIdColor"),this._optionalFields.push("objectAndLayerIdColor"));const _=new pe(u),b=Y(s,_);if(!b)throw new Error(`Unknown object symbol primitive: ${s}`);const x=ce(b).map((e=>({opacity:1,transparent:e.parameters.transparent}))),R=await this._createStageResources(b,y,i),v=await this._createLodRenderer(b,i);return new me(b,v,R,x,c,d,p,o,l,h,y,r)}async _createResourcesForUrl(e,i){const a=["transformation"],o={materialParamsMixin:{instanced:a,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},streamDataRequester:this._context.streamDataRequester,cache:this._context.sharedResources.objectResourceCache};this._fastUpdates=te(this._context.renderer,this._fastVisualVariableConvertOptions(r,r,r,r)),this._fastUpdates.enabled?(Object.assign(o.materialParamsMixin,this._fastUpdates.materialParameters),a.push("featureAttribute"),this._optionalFields.push("featureAttribute")):this._hasPerInstanceColor()&&(a.push("color"),this._optionalFields.push("color")),has("enable-feature:objectAndLayerId-rendering")&&(a.push("objectAndLayerIdColor"),this._optionalFields.push("objectAndLayerIdColor"));const c=this.symbol;if("point-3d"===c.type&&c.verticalOffset){const{screenLength:e,minWorldLength:s,maxWorldLength:r}=c.verticalOffset;o.materialParamsMixin.verticalOffset={screenLength:n(e),minWorldLength:s||0,maxWorldLength:t(r)?r:1/0},o.materialParamsMixin.castShadows=!1}o.signal=i,o.usePBR=this._context.physicalBasedRenderingEnabled,o.skipHighLods=this._context.skipHighSymbolLods;const l=o.usePBR,h=await J(e,o),d=h.isEsriSymbolResource,p=h.isWosr,u=Z(h.lods);u.levels.sort(((e,t)=>e.minScreenSpaceRadius-t.minScreenSpaceRadius));const y=this._context,f=this.symbolLayer.material,_=this._getExternalColorParameters(f),b=s(this.symbolLayer,"material","color"),P=this._getCombinedOpacity(b,{hasIntrinsicColor:!0}),x=this.needsDrivenTransparentPass,R=ce(u),v=ce(u).map((e=>({opacity:e.parameters.opacity||1,transparent:e.parameters.transparent})));R.forEach((e=>{const t=e.parameters;e.setParameters(_);const s=t.opacity*P,r=s<1||x||t.transparent;e.setParameters({opacity:s,transparent:r}),y.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:y.sharedResources.screenSizePerspectiveSettings})}));const L=h.referenceBoundingBox,S=g(U(L)),C=g(u.levels[0].pivotOffset),j=g(I(S,this.symbolLayer)),w=m(j);se(this._fastUpdates,this._context.renderer,this._fastVisualVariableConvertOptions(L,j,S,C))&&R.forEach((e=>e.setParameters(this._fastUpdates.materialParameters)));const E=await this._createStageResources(u,l,i),T=await this._createLodRenderer(u,i);return new me(u,T,E,v,S,d,p,L,j,w,l,C)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(e,t,s){const r=this._context.stage,i=ce(e);t!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged(),r.addMany(i),this._addDisposeResource((()=>r.removeMany(i)));const a=le(e);r.addMany(a),this._addDisposeResource((()=>r.removeMany(a))),await r.load(a,s),o(s);const n=he(e);return r.addMany(n),this._addDisposeResource((()=>r.removeMany(n))),{materials:i,textures:a,geometries:n}}async _createLodRenderer(e,t){const s=this._context.stage,r={layerUid:this._context.layer.uid,graphicUid:e=>this._instanceIndexToGraphicUid.get(e),notifyGraphicGeometryChanged:e=>this._context.notifyGraphicGeometryChanged(this._instanceIndexToGraphicUid.get(e)),notifyGraphicVisibilityChanged:e=>this._context.notifyGraphicVisibilityChanged(this._instanceIndexToGraphicUid.get(e))},i=this._fastUpdates.enabled?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,be),c(s,re(this._fastUpdates.materialParameters,be,s))},scaleFactor:(e,t,s)=>(t.getFeatureAttribute(s,be),ie(e,this._fastUpdates.materialParameters,be))}:null,a=new ne({symbol:e,optionalFields:this._optionalFields,metadata:r,shaderTransformation:i},this._context.scheduler);return a.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource((()=>{s.removeRenderPlugin(a),a.destroy()})),await s.addRenderPlugin(a.slots,a,t),a}_getExternalColorParameters(s){const r={};return this._drivenProperties.color?r.externalColor=L:t(s)&&t(s.color)?r.externalColor=e.toUnitRGBA(s.color):(r.externalColor=L,r.colorMixMode="ignore"),r}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach((e=>e())),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const s=K(t.geometry);if(i(s))return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const r=this.setGraphicElevationContext(t,new z),a=e.renderingInfo;return this._createAs3DShape(t,s,a,r,t.uid,e.layer.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(i(this._resources))return;const e=this._drivenProperties.opacity,t=!this._isPrimitive,r=this._resources.stageResources.materials,a=this._resources.originalMaterialParameters;for(let i=0;i<r.length;i++){const o=r[i],n=s(this.symbolLayer,"material","color"),c=a[i],l=this._getCombinedOpacity(n,{hasIntrinsicColor:t})*c.opacity,h=l<1||e||c.transparent;o.setParameters({opacity:l,transparent:h}),this._isPrimitive&&o.setParameters({cullFace:h?ae.None:ae.Back})}}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,G)}slicePlaneEnabledChanged(){if(i(this._resources))return!0;this._resources.lodRenderer.slicePlaneEnabled=this._context.slicePlaneEnabled;for(const e of this._resources.stageResources.materials)e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled});return!0}physicalBasedRenderingChanged(){if(i(this._resources))return!0;const{stageResources:e,isWosr:t}=this._resources;for(const s of e.materials)this._isPrimitive?s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}):t||s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!1});return!1!==this._hasLoadedPBRTextures||!0!==this._context.physicalBasedRenderingEnabled||(this._hasLoadedPBRTextures=!0,!1)}pixelRatioChanged(){return!0}applyRendererDiff(e,t){if(i(this._resources))return N.Recreate_Symbol;const{stageResources:{materials:s},lodRenderer:r,resourceBoundingBox:a,symbolSize:o,resourceSize:n,pivotOffset:c}=this._resources;for(const i in e.diff){if("visualVariables"!==i)return N.Recreate_Symbol;if(!se(this._fastUpdates,t,this._fastVisualVariableConvertOptions(a,o,n,c)))return N.Recreate_Symbol;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return N.Fast_Update}computeComplexity(){if(i(this._resources))return super.computeComplexity();const e=this._resources.lodResources,t=de(e.levels[0]).reduce(((e,t)=>e+t.indices.get(oe.POSITION).length),0)/3,s=e=>Array.from(e.vertexAttributes.values()).reduce(((e,t)=>e+(t.data.buffer?.byteLength??0)),0)+Array.from(e.indices.values()).reduce(((e,t)=>e+(Array.isArray(t)?12*t.length:t.buffer.byteLength)),0),r=le(e).reduce(((e,t)=>e+(t.params.encoding&&"image/ktx2"===t.params.encoding?t.estimatedTexMemRequired:t.estimatedTexMemRequired/4)),0)+he(e).reduce(((e,t)=>e+s(t)),0);return{primitivesPerFeature:t,primitivesPerCoordinate:0,drawCallsPerFeature:0,estimated:!1,memory:{...ee(this.symbol,this.symbolLayer),resourceBytes:r}}}_hasLodRenderer(){return t(this._resources)}_createAs3DShape(e,s,r,a,o,n){if(!this._hasLodRenderer()||i(this._resources))return null;const c=this.getFastUpdateAttrValues(e),l=!this._fastUpdates.enabled&&this._hasPerInstanceColor()?H(r.color,r.opacity):null,h=this._context.clippingExtent;if(C(s,ye,this._context.elevationProvider.spatialReference),t(h)&&!E(h,ye))return null;const d=this._requiresTerrainElevation(a),p=this._computeGlobalTransform(s,a,_e,ge),m=this._computeLocalTransform(this._resources,this.symbolLayer,r,fe),u=this._resources.lodRenderer.instanceData,y=u.addInstance();this._instanceIndexToGraphicUid.set(y,o),u.setLocalTransform(y,m,!1),u.setGlobalTransform(y,p),c&&u.setFeatureAttribute(y,c),l&&u.setColor(y,l),t(this._context.stage.renderView.objectAndLayerIdRenderHelper)&&u.setObjectAndLayerIdColor(y,this._context.stage.renderView.objectAndLayerIdRenderHelper.getObjectAndLayerIdColor({graphicUid:o,layerUid:n}));const f=new F(this,y,O,a);return d&&(f.alignedSampledElevation=ge.sampledElevation),f.needsElevationUpdates=G(a.mode),Q(f,s,this._context.elevationProvider),f}_computeGlobalTransform(e,t,s,r){return D(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),ye[0]=e.x,ye[1]=e.y,ye[2]=r.z,j(e.spatialReference,ye,s,this._context.renderCoordsHelper.spatialReference),s}_computeLocalTransform(e,t,s,r){return l(r),this._applyObjectRotation(s,!1,r),this._applyObjectRotation(t,!0,r),this._applyObjectScale(e,s,r),this._applyAnchor(e,t,r),r}_applyObjectScale(e,t,s){if(this._fastUpdates.enabled&&this._fastUpdates.requiresShaderTransformation)return;const r=this._drivenProperties.size&&t.size?t.size:e.symbolSize,i=W(r,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===i[0]&&1===i[1]&&1===i[2]||h(s,s,i)}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchTransform(e,t),this._preparePatchColor(e,t)}updateGeometry(e,t){if(i(this._resources))return!0;const s=t&&K(t);if(i(s))return!1;const r=this.getGeometryElevationMode(t);return e.elevationContext.mode===r&&(this._computeGlobalTransform(s,e.elevationContext,_e,ge),this._requiresTerrainElevation(e.elevationContext)&&(e.alignedSampledElevation=ge.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(e.instanceIndex,_e,!0),Q(e,s,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!(t.heading||t.tilt||t.roll||t.width||t.height||t.depth||t.anchor||t.anchorPosition))return;if(i(this._resources))return;const s=(e,t,s)=>a(null!=e&&"complete"===e.type?e.newValue:t,s),r=s(t.heading,this.symbolLayer.heading,0),o=s(t.tilt,this.symbolLayer.tilt,0),n=s(t.roll,this.symbolLayer.roll,0),c=s(t.width,this.symbolLayer.width,void 0),l=s(t.height,this.symbolLayer.height,void 0),h=s(t.depth,this.symbolLayer.depth,void 0),d=s(t.anchor,this.symbolLayer.anchor,void 0),p=s(t.anchorPosition,this.symbolLayer.anchorPosition,void 0);delete t.heading,delete t.tilt,delete t.roll,delete t.width,delete t.height,delete t.depth,delete t.anchor,delete t.anchorPosition;const m={heading:r,tilt:o,roll:n,anchor:d,anchorPosition:p},u=this._resources;this.loadStatus===$.LOADED&&e.symbolLayerStatePatches.push((()=>{u.symbolSize=g(I(u.resourceSize,{width:c,height:l,depth:h,isPrimitive:this.symbolLayer.isPrimitive}))})),e.graphics3DGraphicPatches.push(((e,t)=>{const s=this._computeLocalTransform(u,m,t,fe),r=e.instanceIndex;u.lodRenderer.instanceData.setLocalTransform(r,s,!0)}))}_preparePatchColor(s,r){if(!r.material||"partial"!==r.material.type)return;const a=r.material.diff;if(!a.color||"complete"!==a.color.type||null==a.color.newValue||null==a.color.oldValue)return;const o=a.color.newValue,n=t(o)?e.toUnitRGBA(o):L;delete a.color;const c=this._resources;i(c)||s.graphics3DGraphicPatches.push((e=>{let t;this._hasPerInstanceColor()?(c.lodRenderer.instanceData.setColor(e.instanceIndex,n),t=this._setMaterialTransparencyParams({},o)):t=this._setMaterialTransparencyParams({externalColor:n},o);for(const s of c.stageResources.materials)s.setParameters(t)}))}_requiresTerrainElevation(e){return"absolute-height"!==e.mode}_applyObjectRotation(e,t,s){if(!(this._fastUpdates.enabled&&this._fastUpdates.requiresShaderTransformation&&t))return q(e.heading,e.tilt,e.roll,s)}_computeAnchor(e,s,r){const i=v();switch(r.anchor){case"center":y(i,T(e)),u(i,i);break;case"top":{const t=T(e);b(i,-t[0],-t[1],-e[5]);break}case"bottom":{const t=T(e);b(i,-t[0],-t[1],-e[2]);break}case"relative":{const t=T(e),s=U(e),a=r.anchorPosition,o=a?R(a.x,a.y,a.z):x;f(i,s,o),_(i,i,t),u(i,i);break}default:t(s)?u(i,s):y(i,x)}return i}_applyAnchor(e,t,s){if(this._fastUpdates.enabled&&this._fastUpdates.requiresShaderTransformation)return;const r=this._computeAnchor(e.resourceBoundingBox,e.pivotOffset,t);r&&d(s,s,r)}_hasPerInstanceColor(){return this._drivenProperties.color||this._drivenProperties.opacity}_fastVisualVariableConvertOptions(e,s,r,i){const a=t(e)?g(U(e)):P,o=t(e)?this._computeAnchor(e,i,this.symbolLayer):x,n=this._context.renderCoordsHelper.unitInMeters,c=W(t(s)?s:void 0,s,r,n),l=R(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return{modelSize:a,symbolSize:t(s)?s:P,unitInMeters:n,transformation:{anchor:o,scale:c,rotation:l}}}}const ye=v(),fe=p(),_e=p(),be=S(),ge=new M;export{ue as Graphics3DObjectSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import has from"../../../../core/has.js";import{isSome as t,get as s,none as r,isNone as i,unwrapOr as a}from"../../../../core/maybe.js";import{throwIfAborted as o}from"../../../../core/promiseUtils.js";import{pt2px as n}from"../../../../core/screenUtils.js";import{c,i as l,k as h,w as d}from"../../../../chunks/mat4.js";import{c as p}from"../../../../chunks/mat4f64.js";import{l as m,o as u,c as y,B as f,a as _,s as b}from"../../../../chunks/vec3.js";import{d as g,O as P,Z as x,f as R,c as v}from"../../../../chunks/vec3f64.js";import{O as L,c as S}from"../../../../chunks/vec4f64.js";import{projectPointToVector as C,computeTranslationToOriginAndRotation as j}from"../../../../geometry/projection.js";import{create as w,size as U,containsPoint as E,center as T}from"../../../../geometry/support/aaBoundingBox.js";import{defaultPrimitive as A}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as B,objectSymbolLayerSizeWithResourceSize as I}from"../../../../symbols/support/symbolLayerUtils3D.js";import{perLodInstanceElevationAligner as O}from"./ElevationAligners.js";import{needsElevationUpdates3D as G,evaluateElevationInfoAtPoint as D,SampleElevationInfo as M}from"./elevationAlignmentUtils.js";import{ElevationContext as z}from"./ElevationContext.js";import F from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as V}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as k,mixinColorAndOpacity as H,computeObjectScale as W,computeObjectRotation as q}from"./graphicUtils.js";import{ApplyRendererDiffResult as N}from"./interfaces.js";import{LoadStatus as $}from"./Loadable.js";import{makeLodResources as Z}from"./lodResourceUtils.js";import{fetch as J}from"./objectResourceUtils.js";import{placePointOnGeometry as K,extendPointGraphicElevationContext as Q}from"./pointUtils.js";import{isValidPrimitive as X,primitiveLodResources as Y}from"./primitiveObjectSymbolUtils.js";import{defaultSymbolLayerMemoryComplexity as ee}from"./symbolComplexity.js";import{initFastSymbolUpdatesState as te,updateFastSymbolUpdatesState as se,evaluateModelTransform as re,evaluateModelTransformScale as ie}from"../support/FastSymbolUpdates.js";import{CullFaceOptions as ae}from"../../webgl-engine/lib/basicInterfaces.js";import{VertexAttribute as oe}from"../../webgl-engine/lib/VertexAttribute.js";import{LodRenderer as ne}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{materialsFromLodResources as ce,texturesFromLodResources as le,geometriesFromLodResources as he,geometriesFromLodLevelResources as de}from"../../webgl-engine/lib/lodRendering/LodResources.js";import{DefaultMaterial as pe}from"../../webgl-engine/materials/DefaultMaterial.js";class me{constructor(e,t,s,r,i,a,o,n,c,l,h,d){this.lodResources=e,this.lodRenderer=t,this.stageResources=s,this.originalMaterialParameters=r,this.resourceSize=i,this.isEsriSymbolResource=a,this.isWosr=o,this.resourceBoundingBox=n,this.symbolSize=c,this.extentPadding=l,this.physicalBasedRenderingEnabled=h,this.pivotOffset=d}}class ue extends V{getCachedSize(){const[e,s,r]=t(this._resources)?this._resources.symbolSize:[1,1,1];return{width:e,depth:s,height:r}}constructor(e,t,s,r){super(e,t,s,r),this._resources=null,this._optionalFields=new Array,this._instanceIndexToGraphicUid=new Map,this._hasLoadedPBRTextures=!1,this._disposeResourceHandles=new Array,this.ensureDrapedStatus(!1),this._hasLoadedPBRTextures=s.physicalBasedRenderingEnabled}async doLoad(e){if(!this._drivenProperties.size){if(k(this.symbolLayer))throw new Error}const t=this.symbolLayer;if(this._isPrimitive){const s=t.resource?t.resource.primitive:A;this._resources=await this._createResourcesForPrimitive(s,e)}else this._resources=await this._createResourcesForUrl(t.resource.href,e);this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicalBasedRenderingChanged(),this.complexity=this.computeComplexity()}get extentPadding(){return t(this._resources)?this._resources.extentPadding:0}get _isPrimitive(){return!(this.symbolLayer.resource&&this.symbolLayer.resource.href)}get lodRenderer(){return t(this._resources)?this._resources.lodRenderer:null}_setMaterialTransparencyParams(e,t=s(this.symbolLayer,"material","color")){const r=this._getCombinedOpacity(t),i=r<1||this.needsDrivenTransparentPass;return e.transparent=i,e.opacity=r,e.cullFace=i?ae.None:ae.Back,e}async _createResourcesForPrimitive(s,i){if(!X(s))throw new Error(`Unknown object symbol primitive: ${s}`);const a=this.symbolLayer,o=w(B(s)),c=g(U(o)),l=g(I(c,a)),h=m(l),d=!1,p=!1,u={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,ambient:P,diffuse:P,hasSlicePlane:this._context.slicePlaneEnabled,hasSliceHighlight:!1,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!this.symbolLayer.isPrimitive},y=!!u.usePBR;this._setMaterialTransparencyParams(u);const f=this.symbol;if("point-3d"===f.type&&f.verticalOffset){const{screenLength:e,minWorldLength:s,maxWorldLength:r}=f.verticalOffset;u.verticalOffset={screenLength:n(e),minWorldLength:s||0,maxWorldLength:t(r)?r:1/0},u.castShadows=!1}if(this._context.screenSizePerspectiveEnabled&&(u.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),this._drivenProperties.color)u.externalColor=L;else{const s=t(a.material)?a.material.color:null,r=t(s)?e.toUnitRGBA(s):L;u.externalColor=r}this._fastUpdates=te(this._context.renderer,this._fastVisualVariableConvertOptions(o,l,c,r)),u.instanced=["transformation"],this._fastUpdates.enabled?(Object.assign(u,this._fastUpdates.materialParameters),u.instanced.push("featureAttribute"),this._optionalFields.push("featureAttribute")):this._hasPerInstanceColor()&&(u.instanced.push("color"),this._optionalFields.push("color")),has("enable-feature:objectAndLayerId-rendering")&&(u.instanced.push("objectAndLayerIdColor"),this._optionalFields.push("objectAndLayerIdColor"));const _=new pe(u),b=Y(s,_);if(!b)throw new Error(`Unknown object symbol primitive: ${s}`);const x=ce(b).map((e=>({opacity:1,transparent:e.parameters.transparent}))),R=await this._createStageResources(b,y,i),v=await this._createLodRenderer(b,i);return new me(b,v,R,x,c,d,p,o,l,h,y,r)}async _createResourcesForUrl(e,i){const a=["transformation"],o={materialParamsMixin:{instanced:a,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},streamDataRequester:this._context.streamDataRequester,cache:this._context.sharedResources.objectResourceCache};this._fastUpdates=te(this._context.renderer,this._fastVisualVariableConvertOptions(r,r,r,r)),this._fastUpdates.enabled?(Object.assign(o.materialParamsMixin,this._fastUpdates.materialParameters),a.push("featureAttribute"),this._optionalFields.push("featureAttribute")):this._hasPerInstanceColor()&&(a.push("color"),this._optionalFields.push("color")),has("enable-feature:objectAndLayerId-rendering")&&(a.push("objectAndLayerIdColor"),this._optionalFields.push("objectAndLayerIdColor"));const c=this.symbol;if("point-3d"===c.type&&c.verticalOffset){const{screenLength:e,minWorldLength:s,maxWorldLength:r}=c.verticalOffset;o.materialParamsMixin.verticalOffset={screenLength:n(e),minWorldLength:s||0,maxWorldLength:t(r)?r:1/0},o.materialParamsMixin.castShadows=!1}o.signal=i,o.usePBR=this._context.physicalBasedRenderingEnabled,o.skipHighLods=this._context.skipHighSymbolLods;const l=o.usePBR,h=await J(e,o),d=h.isEsriSymbolResource,p=h.isWosr,u=Z(h.lods);u.levels.sort(((e,t)=>e.minScreenSpaceRadius-t.minScreenSpaceRadius));const y=this._context,f=this.symbolLayer.material,_=this._getExternalColorParameters(f),b=s(this.symbolLayer,"material","color"),P=this._getCombinedOpacity(b,{hasIntrinsicColor:!0}),x=this.needsDrivenTransparentPass,R=ce(u),v=ce(u).map((e=>({opacity:e.parameters.opacity||1,transparent:e.parameters.transparent})));R.forEach((e=>{const t=e.parameters;e.setParameters(_);const s=t.opacity*P,r=s<1||x||t.transparent;e.setParameters({opacity:s,transparent:r}),y.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:y.sharedResources.screenSizePerspectiveSettings})}));const L=h.referenceBoundingBox,S=g(U(L)),C=g(u.levels[0].pivotOffset),j=g(I(S,this.symbolLayer)),w=m(j);se(this._fastUpdates,this._context.renderer,this._fastVisualVariableConvertOptions(L,j,S,C))&&R.forEach((e=>e.setParameters(this._fastUpdates.materialParameters)));const E=await this._createStageResources(u,l,i),T=await this._createLodRenderer(u,i);return new me(u,T,E,v,S,d,p,L,j,w,l,C)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(e,t,s){const r=this._context.stage,i=ce(e);t!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged(),r.addMany(i),this._addDisposeResource((()=>r.removeMany(i)));const a=le(e);r.addMany(a),this._addDisposeResource((()=>r.removeMany(a))),await r.load(a,s),o(s);const n=he(e);return r.addMany(n),this._addDisposeResource((()=>r.removeMany(n))),{materials:i,textures:a,geometries:n}}async _createLodRenderer(e,t){const s=this._context.stage,r={layerUid:this._context.layer.uid,graphicUid:e=>this._instanceIndexToGraphicUid.get(e),notifyGraphicGeometryChanged:e=>this._context.notifyGraphicGeometryChanged(this._instanceIndexToGraphicUid.get(e)),notifyGraphicVisibilityChanged:e=>this._context.notifyGraphicVisibilityChanged(this._instanceIndexToGraphicUid.get(e))},i=this._fastUpdates.enabled?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,be),c(s,re(this._fastUpdates.materialParameters,be,s))},scaleFactor:(e,t,s)=>(t.getFeatureAttribute(s,be),ie(e,this._fastUpdates.materialParameters,be))}:null,a=new ne({symbol:e,optionalFields:this._optionalFields,metadata:r,shaderTransformation:i},this._context.scheduler);return a.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource((()=>{s.removeRenderPlugin(a),a.destroy()})),await s.addRenderPlugin(a.slots,a,t),a}_getExternalColorParameters(s){const r={};return this._drivenProperties.color?r.externalColor=L:t(s)&&t(s.color)?r.externalColor=e.toUnitRGBA(s.color):(r.externalColor=L,r.colorMixMode="ignore"),r}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach((e=>e())),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const s=K(t.geometry);if(i(s))return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const r=this.setGraphicElevationContext(t,new z),a=e.renderingInfo;return this._createAs3DShape(t,s,a,r,t.uid,e.layer.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(i(this._resources))return;const e=this._drivenProperties.opacity,t=!this._isPrimitive,r=this._resources.stageResources.materials,a=this._resources.originalMaterialParameters;for(let i=0;i<r.length;i++){const o=r[i],n=s(this.symbolLayer,"material","color"),c=a[i],l=this._getCombinedOpacity(n,{hasIntrinsicColor:t})*c.opacity,h=l<1||e||c.transparent;o.setParameters({opacity:l,transparent:h}),this._isPrimitive&&o.setParameters({cullFace:h?ae.None:ae.Back})}}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,G)}slicePlaneEnabledChanged(){if(i(this._resources))return!0;this._resources.lodRenderer.slicePlaneEnabled=this._context.slicePlaneEnabled;for(const e of this._resources.stageResources.materials)e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled});return!0}physicalBasedRenderingChanged(){if(i(this._resources))return!0;const{stageResources:e,isWosr:t}=this._resources;for(const s of e.materials)this._isPrimitive?s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}):t||s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!1});return!1!==this._hasLoadedPBRTextures||!0!==this._context.physicalBasedRenderingEnabled||(this._hasLoadedPBRTextures=!0,!1)}pixelRatioChanged(){return!0}skipHighSymbolLodsChanged(){return!1}applyRendererDiff(e,t){if(i(this._resources))return N.Recreate_Symbol;const{stageResources:{materials:s},lodRenderer:r,resourceBoundingBox:a,symbolSize:o,resourceSize:n,pivotOffset:c}=this._resources;for(const i in e.diff){if("visualVariables"!==i)return N.Recreate_Symbol;if(!se(this._fastUpdates,t,this._fastVisualVariableConvertOptions(a,o,n,c)))return N.Recreate_Symbol;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return N.Fast_Update}computeComplexity(){if(i(this._resources))return super.computeComplexity();const e=this._resources.lodResources,t=de(e.levels[0]).reduce(((e,t)=>e+t.indices.get(oe.POSITION).length),0)/3,s=e=>Array.from(e.vertexAttributes.values()).reduce(((e,t)=>e+(t.data.buffer?.byteLength??0)),0)+Array.from(e.indices.values()).reduce(((e,t)=>e+(Array.isArray(t)?12*t.length:t.buffer.byteLength)),0),r=le(e).reduce(((e,t)=>e+(t.params.encoding&&"image/ktx2"===t.params.encoding?t.estimatedTexMemRequired:t.estimatedTexMemRequired/4)),0)+he(e).reduce(((e,t)=>e+s(t)),0);return{primitivesPerFeature:t,primitivesPerCoordinate:0,drawCallsPerFeature:0,estimated:!1,memory:{...ee(this.symbol,this.symbolLayer),resourceBytes:r}}}_hasLodRenderer(){return t(this._resources)}_createAs3DShape(e,s,r,a,o,n){if(!this._hasLodRenderer()||i(this._resources))return null;const c=this.getFastUpdateAttrValues(e),l=!this._fastUpdates.enabled&&this._hasPerInstanceColor()?H(r.color,r.opacity):null,h=this._context.clippingExtent;if(C(s,ye,this._context.elevationProvider.spatialReference),t(h)&&!E(h,ye))return null;const d=this._requiresTerrainElevation(a),p=this._computeGlobalTransform(s,a,_e,ge),m=this._computeLocalTransform(this._resources,this.symbolLayer,r,fe),u=this._resources.lodRenderer.instanceData,y=u.addInstance();this._instanceIndexToGraphicUid.set(y,o),u.setLocalTransform(y,m,!1),u.setGlobalTransform(y,p),c&&u.setFeatureAttribute(y,c),l&&u.setColor(y,l),t(this._context.stage.renderView.objectAndLayerIdRenderHelper)&&u.setObjectAndLayerIdColor(y,this._context.stage.renderView.objectAndLayerIdRenderHelper.getObjectAndLayerIdColor({graphicUid:o,layerUid:n}));const f=new F(this,y,O,a);return d&&(f.alignedSampledElevation=ge.sampledElevation),f.needsElevationUpdates=G(a.mode),Q(f,s,this._context.elevationProvider),f}_computeGlobalTransform(e,t,s,r){return D(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),ye[0]=e.x,ye[1]=e.y,ye[2]=r.z,j(e.spatialReference,ye,s,this._context.renderCoordsHelper.spatialReference),s}_computeLocalTransform(e,t,s,r){return l(r),this._applyObjectRotation(s,!1,r),this._applyObjectRotation(t,!0,r),this._applyObjectScale(e,s,r),this._applyAnchor(e,t,r),r}_applyObjectScale(e,t,s){if(this._fastUpdates.enabled&&this._fastUpdates.requiresShaderTransformation)return;const r=this._drivenProperties.size&&t.size?t.size:e.symbolSize,i=W(r,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===i[0]&&1===i[1]&&1===i[2]||h(s,s,i)}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchTransform(e,t),this._preparePatchColor(e,t)}updateGeometry(e,t){if(i(this._resources))return!0;const s=t&&K(t);if(i(s))return!1;const r=this.getGeometryElevationMode(t);return e.elevationContext.mode===r&&(this._computeGlobalTransform(s,e.elevationContext,_e,ge),this._requiresTerrainElevation(e.elevationContext)&&(e.alignedSampledElevation=ge.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(e.instanceIndex,_e,!0),Q(e,s,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!(t.heading||t.tilt||t.roll||t.width||t.height||t.depth||t.anchor||t.anchorPosition))return;if(i(this._resources))return;const s=(e,t,s)=>a(null!=e&&"complete"===e.type?e.newValue:t,s),r=s(t.heading,this.symbolLayer.heading,0),o=s(t.tilt,this.symbolLayer.tilt,0),n=s(t.roll,this.symbolLayer.roll,0),c=s(t.width,this.symbolLayer.width,void 0),l=s(t.height,this.symbolLayer.height,void 0),h=s(t.depth,this.symbolLayer.depth,void 0),d=s(t.anchor,this.symbolLayer.anchor,void 0),p=s(t.anchorPosition,this.symbolLayer.anchorPosition,void 0);delete t.heading,delete t.tilt,delete t.roll,delete t.width,delete t.height,delete t.depth,delete t.anchor,delete t.anchorPosition;const m={heading:r,tilt:o,roll:n,anchor:d,anchorPosition:p},u=this._resources;this.loadStatus===$.LOADED&&e.symbolLayerStatePatches.push((()=>{u.symbolSize=g(I(u.resourceSize,{width:c,height:l,depth:h,isPrimitive:this.symbolLayer.isPrimitive}))})),e.graphics3DGraphicPatches.push(((e,t)=>{const s=this._computeLocalTransform(u,m,t,fe),r=e.instanceIndex;u.lodRenderer.instanceData.setLocalTransform(r,s,!0)}))}_preparePatchColor(s,r){if(!r.material||"partial"!==r.material.type)return;const a=r.material.diff;if(!a.color||"complete"!==a.color.type||null==a.color.newValue||null==a.color.oldValue)return;const o=a.color.newValue,n=t(o)?e.toUnitRGBA(o):L;delete a.color;const c=this._resources;i(c)||s.graphics3DGraphicPatches.push((e=>{let t;this._hasPerInstanceColor()?(c.lodRenderer.instanceData.setColor(e.instanceIndex,n),t=this._setMaterialTransparencyParams({},o)):t=this._setMaterialTransparencyParams({externalColor:n},o);for(const s of c.stageResources.materials)s.setParameters(t)}))}_requiresTerrainElevation(e){return"absolute-height"!==e.mode}_applyObjectRotation(e,t,s){if(!(this._fastUpdates.enabled&&this._fastUpdates.requiresShaderTransformation&&t))return q(e.heading,e.tilt,e.roll,s)}_computeAnchor(e,s,r){const i=v();switch(r.anchor){case"center":y(i,T(e)),u(i,i);break;case"top":{const t=T(e);b(i,-t[0],-t[1],-e[5]);break}case"bottom":{const t=T(e);b(i,-t[0],-t[1],-e[2]);break}case"relative":{const t=T(e),s=U(e),a=r.anchorPosition,o=a?R(a.x,a.y,a.z):x;f(i,s,o),_(i,i,t),u(i,i);break}default:t(s)?u(i,s):y(i,x)}return i}_applyAnchor(e,t,s){if(this._fastUpdates.enabled&&this._fastUpdates.requiresShaderTransformation)return;const r=this._computeAnchor(e.resourceBoundingBox,e.pivotOffset,t);r&&d(s,s,r)}_hasPerInstanceColor(){return this._drivenProperties.color||this._drivenProperties.opacity}_fastVisualVariableConvertOptions(e,s,r,i){const a=t(e)?g(U(e)):P,o=t(e)?this._computeAnchor(e,i,this.symbolLayer):x,n=this._context.renderCoordsHelper.unitInMeters,c=W(t(s)?s:void 0,s,r,n),l=R(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return{modelSize:a,symbolSize:t(s)?s:P,unitInMeters:n,transformation:{anchor:o,scale:c,rotation:l}}}}const ye=v(),fe=p(),_e=p(),be=S(),ge=new M;export{ue as Graphics3DObjectSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../../core/has.js";import t from"../../../../core/Error.js";import{acosClamped as e,reciprocalClamped as i}from"../../../../core/mathUtils.js";import{isSome as r,get as s}from"../../../../core/maybe.js";import{s as a}from"../../../../chunks/mat2.js";import{s as o,b as n}from"../../../../chunks/vec2.js";import{f as l,b as h}from"../../../../chunks/vec2f64.js";import{s as c,c as p,a as m,e as f,f as d,g as u,n as g,o as y,b as _}from"../../../../chunks/vec3.js";import{d as b,c as v}from"../../../../chunks/vec3f64.js";import{projectBuffer as x}from"../../../../geometry/projection.js";import{create as w,empty as S,expandWithBuffer as P,intersectsClippingArea as R}from"../../../../geometry/support/aaBoundingBox.js";import{makeDehydratedPoint as j}from"../../../../layers/graphics/dehydratedFeatures.js";import{needsElevationUpdates3D as C,evaluateElevationAlignmentAtPoint as D,SampleElevationInfo as U}from"./elevationAlignmentUtils.js";import{ElevationContext as L}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as A}from"./Graphics3DObject3DGraphicLayer.js";import{PATH_NUM_CIRCLE_PROFILE_SUBDIVISIONS as V,PATH_NUM_ROUND_JOIN_SUBDIVISIONS as E,PATH_NUM_ROUND_CAP_EXTRUSION_SUBDIVISIONS as z}from"./Graphics3DPathSymbolLayerConstants.js";import{Graphics3DSymbolLayer as M,getAttributeValue as k}from"./Graphics3DSymbolLayer.js";import{isValidSize as I}from"./graphicUtils.js";import{ApplyRendererDiffResult as F}from"./interfaces.js";import{initFastSymbolUpdatesState as G,updateFastSymbolUpdatesState as B}from"../support/FastSymbolUpdates.js";import{CullFaceOptions as O}from"../../webgl-engine/lib/basicInterfaces.js";import{newDoubleArray as q}from"../../webgl-engine/lib/DoubleArray.js";import{Object3D as H}from"../../webgl-engine/lib/Object3D.js";import{UpVectorAlignment as W,PathGeometry as T,isPathGeometry as N}from"../../webgl-engine/lib/PathGeometry.js";import{creatQuadProfile as Z,createCircleProfile as J,SimpleExtruder as K,MiterExtruder as Q,RoundCapBuilder as X,TriangulationCapBuilder as Y,NoCapBuilder as $,PathVertex as tt,Path as et,Builder as it,FastUpdatePathGeometry as rt,StaticPathGeometry as st,computeMinimumRotationTangentFrame as at,vertexSpaceToProfileSpace as ot}from"../../webgl-engine/lib/pathGeometryUtils.js";import{DefaultMaterial as nt}from"../../webgl-engine/materials/DefaultMaterial.js";import{PathMaterial as lt}from"../../webgl-engine/materials/PathMaterial.js";const ht=["polyline"];class ct extends M{constructor(t,e,i,r){super(t,e,i,r),this._intrinsicSize=l(1,1),this._upVectorAlignment=W.Path,this._stencilWidth=.1,this.ensureDrapedStatus(!1)}async doLoad(){const e=r(this.symbolLayer.width)?this.symbolLayer.width:this.symbolLayer.height,i=r(this.symbolLayer.height)?this.symbolLayer.height:e;this._vvConvertOptions={modelSize:[1,1,1],symbolSize:[e,1,i],unitInMeters:this._context.renderCoordsHelper.unitInMeters,transformation:{anchor:[0,0,0],scale:[1,1,1],rotation:[0,0,0]},supportedTypes:{size:!0,color:!0,opacity:!0,rotation:!1}},this._context.renderer&&this._context.renderer.visualVariables&&this._context.renderer.visualVariables.length>0?this._fastUpdates=G(this._context.renderer,this._vvConvertOptions):this._fastUpdates={enabled:!1};const a=this.symbolLayer.anchor||"center";this._upVectorAlignment="heading"===this.symbolLayer.profileRotation?W.World:W.Path;const l=this.symbolLayer.profile||"circle";switch(l){default:case"circle":this._profile=J(V);break;case"quad":this._profile=Z()}let c=[0,0];switch("center"!==a&&(c={left:[.5,0],right:[-.5,0],top:[0,-.5],bottom:[0,.5]}[a],this._profile.translate(c[0],c[1])),this.symbolLayer.join){case"round":this._extruder=new Q(0,E);break;case"bevel":this._extruder=new Q(0,1);break;case"miter":this._extruder=new Q(.8*Math.PI,1);break;default:this._extruder=new K}const p=this.symbolLayer.cap||"butt";switch(p){case"none":this._startCap=new $,this._endCap=new $;break;case"butt":default:this._startCap=new Y(this._profile,0),this._endCap=new Y(this._profile,0,!0);break;case"square":this._startCap=new Y(this._profile,-.5),this._endCap=new Y(this._profile,.5,!0);break;case"round":{const t="quad"===l;this._startCap=new X({profile:this._profile,flip:!1,breakNormals:t,subdivisions:z}),this._endCap=new X({profile:this._profile,flip:!0,breakNormals:t,subdivisions:z});break}}const m=s(this.symbolLayer,"material","color"),f=this._getCombinedOpacityAndColor(m),d=b(f),u=f[3],g=u<1||this.needsDrivenTransparentPass,y={diffuse:d,ambient:d,opacity:u,transparent:g,hasVertexColors:!1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,cullFace:g||"none"===p?O.None:O.Back,offsetTransparentBackfaces:!0};if(!this._drivenProperties.size&&(o(this._intrinsicSize,e,i),!I(this._intrinsicSize[0])||!I(this._intrinsicSize[1])))throw new t("graphics3dpathsymbollayer:invalid-size","Symbol sizes may not be negative values");if(this._fastUpdates.enabled&&this._fastUpdates.visualVariables.size||n(this._intrinsicSize,this._intrinsicSize,1/this._context.renderCoordsHelper.unitInMeters),this._fastUpdates.enabled){const t={...y,...this._fastUpdates.materialParameters,size:h(this._intrinsicSize)};this._material=new lt(t)}else y.hasVertexColors=this._drivenProperties.color||this._drivenProperties.opacity,this._material=new nt(y);this._material.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),this._context.stage.add(this._material)}destroy(){super.destroy(),this._context.stage.remove(this._material),this._material=null}createGraphics3DGraphic(t){const e=t.graphic;if(!this._validateGeometry(e.geometry,ht,this.symbolLayer.type))return null;const i=this.setGraphicElevationContext(e,new L),r=t.renderingInfo;return this._createAs3DShape(e,r,i,e.uid)}layerOpacityChanged(){const t=s(this.symbolLayer,"material","color"),e=this._getCombinedOpacity(t),i=e<1||this.needsDrivenTransparentPass;this._material.setParameters({opacity:e,transparent:i})}layerElevationInfoChanged(t,e){return this.updateGraphics3DGraphicElevationInfo(t,e,C)}slicePlaneEnabledChanged(){return this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return this._material.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),!0}pixelRatioChanged(){return!0}applyRendererDiff(t,e){for(const i in t.diff){if("visualVariables"!==i)return F.Recreate_Symbol;if(!B(this._fastUpdates,e,this._vvConvertOptions))return F.Recreate_Symbol;this._material.setParameters(this._fastUpdates.materialParameters)}return F.Fast_Update}_getVertexData(t){let e=0;const i=t.paths,s=[],a=t.spatialReference,o=this._context.elevationProvider.spatialReference,n=this._context.renderCoordsHelper.spatialReference;for(const r of i)e+=r.length;const l=q(3*e),h=q(3*e);let c=0;for(const r of i){s.push({index:c,numVertices:r.length});for(const e of r)l[c++]=e[0],l[c++]=e[1],l[c++]=t.hasZ?e[2]:0}let p=!0;return r(o)&&!a.equals(o)&&(p=x(l,a,0,l,o,0,e)),r(o)&&!o.equals(n)?x(l,o,0,h,n,0,e):this._copyVertices(l,0,h,0,e),{pathVertexDataInfos:s,vertexDataES:l,vertexDataRS:h,projectionSuccess:p,terrainElevation:0}}_copyVertices(t,e,i,r,s){e*=3,r*=3;for(let a=0;a<s;++a)i[r++]=t[e++],i[r++]=t[e++],i[r++]=t[e++]}_createAs3DShape(t,e,i,s){const a=t.geometry,o=new Array,n=a.spatialReference,l=w(),h=this._context.renderCoordsHelper;gt.spatialReference=n;const m=this._getVertexData(a);if(!m.projectionSuccess)return this.logger.warn("PathSymbol3DLayer geometry failed to be created (failed to project geometry to view spatial reference)"),null;if(0===m.pathVertexDataInfos.length)return 0!==a.paths.length&&a.paths.some((t=>t.length>0))||this.logger.warn("PathSymbol3DLayer geometry failed to be created (no paths were defined)"),null;for(const g of m.pathVertexDataInfos){const a=g.index,f=g.numVertices;if(f<2)continue;if(r(this._context.clippingExtent)&&(S(l),P(l,m.vertexDataES,3*a,f),!R(l,this._context.clippingExtent)))continue;const d=[];for(let t=a;t<a+3*f;){const e=t++,r=t++,s=t++,a=new tt;c(a.posES,m.vertexDataES[e],m.vertexDataES[r],m.vertexDataES[s]);const o=D(a.posES,this._context.elevationProvider,i,h);c(yt,m.vertexDataRS[e],m.vertexDataRS[r],m.vertexDataRS[s]),h.setAltitude(yt,o),p(a.pos,yt),d.push(a)}const u=new et(d);pt(u,this._upVectorAlignment,this._context.renderCoordsHelper);const y=new it(u,this._profile,this._extruder,this._startCap,this._endCap);let _=null;if(this._fastUpdates.enabled){const e=this._fastUpdates.visualVariables,i=e.size?k(e.size.field,t):0,r=e.color?k(e.color.field,t):0,s=e.opacity?k(e.opacity.field,t):0;_=new rt(y,i,r,s)}else{const t=[this._intrinsicSize[0],this._intrinsicSize[1]];if(this._drivenProperties.size){const i=e.size;t[0]*=mt(i[0],"symbol-value"===i[2]?this.symbolLayer.height||0:i[2],this.symbolLayer.width||0),t[1]*=mt(i[2],"symbol-value"===i[0]?this.symbolLayer.width||0:i[0],this.symbolLayer.height||0)}let i;this._drivenProperties.color&&(i=e.color),this._drivenProperties.opacity&&null!=e.opacity&&(i=i?[i[0],i[1],i[2],e.opacity]:[1,1,1,e.opacity]);const r=new st(y);r.bake(t),i&&r.bakeVertexColors(i),_=r}const{vertexAttributes:b,indices:v}=_.createGeometryData(),x=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:s,layerUid:this._context.layer.uid}),w=new T(this._material,b,v,_,n,this._upVectorAlignment,this._stencilWidth,x);w.transformation=_.xform,o.push(w)}if(0===o.length)return null;const f={layerUid:this._context.layer.uid,graphicUid:s},d=new H({geometries:o,metadata:f}),u=new A(this,d,o,null,null,dt,i);return u.alignedSampledElevation=m.terrainElevation,u.needsElevationUpdates=C(i.mode),u}}function pt(t,r,s){switch(r){default:case W.World:for(const r of t.vertices){m(yt,r.pos,t.offset),s.worldUpAtPosition(yt,yt),r.setFrameFromUpVector(yt),r.rotationFrameUp=r.frame.up,o(r.rotationRight,1,0),u(yt,r.frame.up,f(r.frame.up,r.vLeft)),_(yt,r.vLeft,yt),y(yt,yt),g(yt,yt),u(_t,r.frame.up,f(r.frame.up,r.vRight)),_(_t,r.vRight,_t),g(_t,_t),d(bt,r.rotationFrameUp,r.vLeft);const n=Math.sign(f(bt,r.vRight));if(r.rotationAngle=n*(Math.PI-e(f(yt,_t))),Math.abs(r.rotationAngle)>0){const t=i(Math.cos(.5*r.rotationAngle));a(r.miterStretch,t-1+1,0,0,1)}const l=Math.PI-r.rotationAngle;r.maxStretchDistance=Math.abs(r.vMinSiblingLength/Math.cos(.5*l))}break;case W.Path:m(yt,t.vertices[0].pos,t.offset),s.worldUpAtPosition(yt,yt),at(t,yt);for(const r of t.vertices){const t=Math.sign(f(r.frame.right,r.vRight));d(r.rotationFrameUp,r.vRight,r.vLeft),u(r.rotationFrameUp,r.rotationFrameUp,t),g(r.rotationFrameUp,r.rotationFrameUp);const s=f(r.rotationFrameUp,r.frame.up),o=f(r.rotationFrameUp,r.frame.right);if(u(yt,r.frame.up,-o),u(_t,r.frame.right,s),m(yt,yt,_t),g(yt,yt),ot(r.rotationRight,r.frame,yt),y(yt,r.vLeft),r.rotationAngle=-t*(Math.PI-e(f(yt,r.vRight))),Math.abs(r.rotationAngle)>0){const t=i(Math.cos(.5*r.rotationAngle));a(r.miterStretch,1+(t-1)*r.rotationRight[0]*r.rotationRight[0],(t-1)*r.rotationRight[0]*r.rotationRight[1],(t-1)*r.rotationRight[0]*r.rotationRight[1],1+(t-1)*r.rotationRight[1]*r.rotationRight[1])}const n=Math.PI-r.rotationAngle;r.maxStretchDistance=Math.abs(r.vMinSiblingLength*i(Math.cos(.5*n)))}}}function mt(t,e,i){switch(t){case"symbol-value":return i;case"proportional":return e;default:return t}}function ft(t,e,i,r){let s=0;for(const a of t.vertices)i(a.posES,vt),s+=vt.sampledElevation,m(yt,a.pos,t.offset),r.setAltitude(yt,vt.z),_(a.pos,yt,t.offset);return t.updatePathVertexInformation(),s/t.vertices.length}function dt(t,e,i,r,s){const a=t.stageObject,o=a.geometries;let n=0;ut.spatialReference=s.spatialReference;for(const l of o){if(!N(l))continue;const t=l.path,i=t.builder.path,o=l.geometrySR;gt.spatialReference=o,n+=ft(i,e,r,s),l.upVectorAlignment!==W.World&&pt(i,l.upVectorAlignment,s),t.onPathChanged(),l.invalidateBoundingInfo(),a.geometryVertexAttrsUpdated(l)}return n/o.length}const ut=j(0,0,0,null),gt=j(0,0,0,null),yt=v(),_t=v(),bt=v(),vt=new U;export{ct as Graphics3DPathSymbolLayer};
|
|
5
|
+
import"../../../../core/has.js";import t from"../../../../core/Error.js";import{acosClamped as e,reciprocalClamped as i}from"../../../../core/mathUtils.js";import{isSome as r,get as s}from"../../../../core/maybe.js";import{s as a}from"../../../../chunks/mat2.js";import{s as o,b as n}from"../../../../chunks/vec2.js";import{f as l,b as h}from"../../../../chunks/vec2f64.js";import{s as c,c as p,a as m,e as f,f as d,g as u,n as g,o as y,b as _}from"../../../../chunks/vec3.js";import{d as b,c as v}from"../../../../chunks/vec3f64.js";import{projectBuffer as x}from"../../../../geometry/projection.js";import{create as w,empty as S,expandWithBuffer as P,intersectsClippingArea as R}from"../../../../geometry/support/aaBoundingBox.js";import{makeDehydratedPoint as j}from"../../../../layers/graphics/dehydratedFeatures.js";import{needsElevationUpdates3D as C,evaluateElevationAlignmentAtPoint as D,SampleElevationInfo as U}from"./elevationAlignmentUtils.js";import{ElevationContext as L}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as A}from"./Graphics3DObject3DGraphicLayer.js";import{PATH_NUM_CIRCLE_PROFILE_SUBDIVISIONS as V,PATH_NUM_ROUND_JOIN_SUBDIVISIONS as E,PATH_NUM_ROUND_CAP_EXTRUSION_SUBDIVISIONS as z}from"./Graphics3DPathSymbolLayerConstants.js";import{Graphics3DSymbolLayer as M,getAttributeValue as k}from"./Graphics3DSymbolLayer.js";import{isValidSize as I}from"./graphicUtils.js";import{ApplyRendererDiffResult as F}from"./interfaces.js";import{initFastSymbolUpdatesState as G,updateFastSymbolUpdatesState as B}from"../support/FastSymbolUpdates.js";import{CullFaceOptions as O}from"../../webgl-engine/lib/basicInterfaces.js";import{newDoubleArray as H}from"../../webgl-engine/lib/DoubleArray.js";import{Object3D as q}from"../../webgl-engine/lib/Object3D.js";import{UpVectorAlignment as W,PathGeometry as T,isPathGeometry as N}from"../../webgl-engine/lib/PathGeometry.js";import{creatQuadProfile as Z,createCircleProfile as J,SimpleExtruder as K,MiterExtruder as Q,RoundCapBuilder as X,TriangulationCapBuilder as Y,NoCapBuilder as $,PathVertex as tt,Path as et,Builder as it,FastUpdatePathGeometry as rt,StaticPathGeometry as st,computeMinimumRotationTangentFrame as at,vertexSpaceToProfileSpace as ot}from"../../webgl-engine/lib/pathGeometryUtils.js";import{DefaultMaterial as nt}from"../../webgl-engine/materials/DefaultMaterial.js";import{PathMaterial as lt}from"../../webgl-engine/materials/PathMaterial.js";const ht=["polyline"];class ct extends M{constructor(t,e,i,r){super(t,e,i,r),this._intrinsicSize=l(1,1),this._upVectorAlignment=W.Path,this._stencilWidth=.1,this.ensureDrapedStatus(!1)}async doLoad(){const e=r(this.symbolLayer.width)?this.symbolLayer.width:this.symbolLayer.height,i=r(this.symbolLayer.height)?this.symbolLayer.height:e;this._vvConvertOptions={modelSize:[1,1,1],symbolSize:[e,1,i],unitInMeters:this._context.renderCoordsHelper.unitInMeters,transformation:{anchor:[0,0,0],scale:[1,1,1],rotation:[0,0,0]},supportedTypes:{size:!0,color:!0,opacity:!0,rotation:!1}},this._context.renderer&&this._context.renderer.visualVariables&&this._context.renderer.visualVariables.length>0?this._fastUpdates=G(this._context.renderer,this._vvConvertOptions):this._fastUpdates={enabled:!1};const a=this.symbolLayer.anchor||"center";this._upVectorAlignment="heading"===this.symbolLayer.profileRotation?W.World:W.Path;const l=this.symbolLayer.profile||"circle";switch(l){default:case"circle":this._profile=J(V);break;case"quad":this._profile=Z()}let c=[0,0];switch("center"!==a&&(c={left:[.5,0],right:[-.5,0],top:[0,-.5],bottom:[0,.5]}[a],this._profile.translate(c[0],c[1])),this.symbolLayer.join){case"round":this._extruder=new Q(0,E);break;case"bevel":this._extruder=new Q(0,1);break;case"miter":this._extruder=new Q(.8*Math.PI,1);break;default:this._extruder=new K}const p=this.symbolLayer.cap||"butt";switch(p){case"none":this._startCap=new $,this._endCap=new $;break;case"butt":default:this._startCap=new Y(this._profile,0),this._endCap=new Y(this._profile,0,!0);break;case"square":this._startCap=new Y(this._profile,-.5),this._endCap=new Y(this._profile,.5,!0);break;case"round":{const t="quad"===l;this._startCap=new X({profile:this._profile,flip:!1,breakNormals:t,subdivisions:z}),this._endCap=new X({profile:this._profile,flip:!0,breakNormals:t,subdivisions:z});break}}const m=s(this.symbolLayer,"material","color"),f=this._getCombinedOpacityAndColor(m),d=b(f),u=f[3],g=u<1||this.needsDrivenTransparentPass,y={diffuse:d,ambient:d,opacity:u,transparent:g,hasVertexColors:!1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,cullFace:g||"none"===p?O.None:O.Back,offsetTransparentBackfaces:!0};if(!this._drivenProperties.size&&(o(this._intrinsicSize,e,i),!I(this._intrinsicSize[0])||!I(this._intrinsicSize[1])))throw new t("graphics3dpathsymbollayer:invalid-size","Symbol sizes may not be negative values");if(this._fastUpdates.enabled&&this._fastUpdates.visualVariables.size||n(this._intrinsicSize,this._intrinsicSize,1/this._context.renderCoordsHelper.unitInMeters),this._fastUpdates.enabled){const t={...y,...this._fastUpdates.materialParameters,size:h(this._intrinsicSize)};this._material=new lt(t)}else y.hasVertexColors=this._drivenProperties.color||this._drivenProperties.opacity,this._material=new nt(y);this._material.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),this._context.stage.add(this._material)}destroy(){super.destroy(),this._context.stage.remove(this._material),this._material=null}createGraphics3DGraphic(t){const e=t.graphic;if(!this._validateGeometry(e.geometry,ht,this.symbolLayer.type))return null;const i=this.setGraphicElevationContext(e,new L),r=t.renderingInfo;return this._createAs3DShape(e,r,i,e.uid)}layerOpacityChanged(){const t=s(this.symbolLayer,"material","color"),e=this._getCombinedOpacity(t),i=e<1||this.needsDrivenTransparentPass;this._material.setParameters({opacity:e,transparent:i})}layerElevationInfoChanged(t,e){return this.updateGraphics3DGraphicElevationInfo(t,e,C)}slicePlaneEnabledChanged(){return this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return this._material.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),!0}pixelRatioChanged(){return!0}skipHighSymbolLodsChanged(){return!0}applyRendererDiff(t,e){for(const i in t.diff){if("visualVariables"!==i)return F.Recreate_Symbol;if(!B(this._fastUpdates,e,this._vvConvertOptions))return F.Recreate_Symbol;this._material.setParameters(this._fastUpdates.materialParameters)}return F.Fast_Update}_getVertexData(t){let e=0;const i=t.paths,s=[],a=t.spatialReference,o=this._context.elevationProvider.spatialReference,n=this._context.renderCoordsHelper.spatialReference;for(const r of i)e+=r.length;const l=H(3*e),h=H(3*e);let c=0;for(const r of i){s.push({index:c,numVertices:r.length});for(const e of r)l[c++]=e[0],l[c++]=e[1],l[c++]=t.hasZ?e[2]:0}let p=!0;return r(o)&&!a.equals(o)&&(p=x(l,a,0,l,o,0,e)),r(o)&&!o.equals(n)?x(l,o,0,h,n,0,e):this._copyVertices(l,0,h,0,e),{pathVertexDataInfos:s,vertexDataES:l,vertexDataRS:h,projectionSuccess:p,terrainElevation:0}}_copyVertices(t,e,i,r,s){e*=3,r*=3;for(let a=0;a<s;++a)i[r++]=t[e++],i[r++]=t[e++],i[r++]=t[e++]}_createAs3DShape(t,e,i,s){const a=t.geometry,o=new Array,n=a.spatialReference,l=w(),h=this._context.renderCoordsHelper;gt.spatialReference=n;const m=this._getVertexData(a);if(!m.projectionSuccess)return this.logger.warn("PathSymbol3DLayer geometry failed to be created (failed to project geometry to view spatial reference)"),null;if(0===m.pathVertexDataInfos.length)return 0!==a.paths.length&&a.paths.some((t=>t.length>0))||this.logger.warn("PathSymbol3DLayer geometry failed to be created (no paths were defined)"),null;for(const g of m.pathVertexDataInfos){const a=g.index,f=g.numVertices;if(f<2)continue;if(r(this._context.clippingExtent)&&(S(l),P(l,m.vertexDataES,3*a,f),!R(l,this._context.clippingExtent)))continue;const d=[];for(let t=a;t<a+3*f;){const e=t++,r=t++,s=t++,a=new tt;c(a.posES,m.vertexDataES[e],m.vertexDataES[r],m.vertexDataES[s]);const o=D(a.posES,this._context.elevationProvider,i,h);c(yt,m.vertexDataRS[e],m.vertexDataRS[r],m.vertexDataRS[s]),h.setAltitude(yt,o),p(a.pos,yt),d.push(a)}const u=new et(d);pt(u,this._upVectorAlignment,this._context.renderCoordsHelper);const y=new it(u,this._profile,this._extruder,this._startCap,this._endCap);let _=null;if(this._fastUpdates.enabled){const e=this._fastUpdates.visualVariables,i=e.size?k(e.size.field,t):0,r=e.color?k(e.color.field,t):0,s=e.opacity?k(e.opacity.field,t):0;_=new rt(y,i,r,s)}else{const t=[this._intrinsicSize[0],this._intrinsicSize[1]];if(this._drivenProperties.size){const i=e.size;t[0]*=mt(i[0],"symbol-value"===i[2]?this.symbolLayer.height||0:i[2],this.symbolLayer.width||0),t[1]*=mt(i[2],"symbol-value"===i[0]?this.symbolLayer.width||0:i[0],this.symbolLayer.height||0)}let i;this._drivenProperties.color&&(i=e.color),this._drivenProperties.opacity&&null!=e.opacity&&(i=i?[i[0],i[1],i[2],e.opacity]:[1,1,1,e.opacity]);const r=new st(y);r.bake(t),i&&r.bakeVertexColors(i),_=r}const{vertexAttributes:b,indices:v}=_.createGeometryData(),x=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:s,layerUid:this._context.layer.uid}),w=new T(this._material,b,v,_,n,this._upVectorAlignment,this._stencilWidth,x);w.transformation=_.xform,o.push(w)}if(0===o.length)return null;const f={layerUid:this._context.layer.uid,graphicUid:s},d=new q({geometries:o,metadata:f}),u=new A(this,d,o,null,null,dt,i);return u.alignedSampledElevation=m.terrainElevation,u.needsElevationUpdates=C(i.mode),u}}function pt(t,r,s){switch(r){default:case W.World:for(const r of t.vertices){m(yt,r.pos,t.offset),s.worldUpAtPosition(yt,yt),r.setFrameFromUpVector(yt),r.rotationFrameUp=r.frame.up,o(r.rotationRight,1,0),u(yt,r.frame.up,f(r.frame.up,r.vLeft)),_(yt,r.vLeft,yt),y(yt,yt),g(yt,yt),u(_t,r.frame.up,f(r.frame.up,r.vRight)),_(_t,r.vRight,_t),g(_t,_t),d(bt,r.rotationFrameUp,r.vLeft);const n=Math.sign(f(bt,r.vRight));if(r.rotationAngle=n*(Math.PI-e(f(yt,_t))),Math.abs(r.rotationAngle)>0){const t=i(Math.cos(.5*r.rotationAngle));a(r.miterStretch,t-1+1,0,0,1)}const l=Math.PI-r.rotationAngle;r.maxStretchDistance=Math.abs(r.vMinSiblingLength/Math.cos(.5*l))}break;case W.Path:m(yt,t.vertices[0].pos,t.offset),s.worldUpAtPosition(yt,yt),at(t,yt);for(const r of t.vertices){const t=Math.sign(f(r.frame.right,r.vRight));d(r.rotationFrameUp,r.vRight,r.vLeft),u(r.rotationFrameUp,r.rotationFrameUp,t),g(r.rotationFrameUp,r.rotationFrameUp);const s=f(r.rotationFrameUp,r.frame.up),o=f(r.rotationFrameUp,r.frame.right);if(u(yt,r.frame.up,-o),u(_t,r.frame.right,s),m(yt,yt,_t),g(yt,yt),ot(r.rotationRight,r.frame,yt),y(yt,r.vLeft),r.rotationAngle=-t*(Math.PI-e(f(yt,r.vRight))),Math.abs(r.rotationAngle)>0){const t=i(Math.cos(.5*r.rotationAngle));a(r.miterStretch,1+(t-1)*r.rotationRight[0]*r.rotationRight[0],(t-1)*r.rotationRight[0]*r.rotationRight[1],(t-1)*r.rotationRight[0]*r.rotationRight[1],1+(t-1)*r.rotationRight[1]*r.rotationRight[1])}const n=Math.PI-r.rotationAngle;r.maxStretchDistance=Math.abs(r.vMinSiblingLength*i(Math.cos(.5*n)))}}}function mt(t,e,i){switch(t){case"symbol-value":return i;case"proportional":return e;default:return t}}function ft(t,e,i,r){let s=0;for(const a of t.vertices)i(a.posES,vt),s+=vt.sampledElevation,m(yt,a.pos,t.offset),r.setAltitude(yt,vt.z),_(a.pos,yt,t.offset);return t.updatePathVertexInformation(),s/t.vertices.length}function dt(t,e,i,r,s){const a=t.stageObject,o=a.geometries;let n=0;ut.spatialReference=s.spatialReference;for(const l of o){if(!N(l))continue;const t=l.path,i=t.builder.path,o=l.geometrySR;gt.spatialReference=o,n+=ft(i,e,r,s),l.upVectorAlignment!==W.World&&pt(i,l.upVectorAlignment,s),t.onPathChanged(),l.invalidateBoundingInfo(),a.geometryVertexAttrsUpdated(l)}return n/o.length}const ut=j(0,0,0,null),gt=j(0,0,0,null),yt=v(),_t=v(),bt=v(),vt=new U;export{ct as Graphics3DPathSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import{isSome as t,get as i,isNone as r,unwrap as n}from"../../../../core/maybe.js";import{pt2px as o}from"../../../../core/screenUtils.js";import{e as s}from"../../../../chunks/earcut.js";import{s as a}from"../../../../chunks/vec4.js";import{create as l,empty as c,expandWithBuffer as h,intersectsClippingArea as p,expandWithAABB as u}from"../../../../geometry/support/aaBoundingBox.js";import{SymbolUpdateType as d,elevationModeChangeUpdateType as m,needsElevationUpdates2D as _}from"./elevationAlignmentUtils.js";import{ElevationContext as g}from"./ElevationContext.js";import y from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as f}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as b}from"./Graphics3DSymbolLayer.js";import{mixinColorAndOpacity as x}from"./graphicUtils.js";import{parseCapType as v}from"./lineUtils.js";import{geometryAsPolygon as O,createColorGeometry as C,PolygonCreationDataBase as D}from"./polygonUtils.js";import{createMaterial as
|
|
5
|
+
import e from"../../../../Color.js";import{isSome as t,get as i,isNone as r,unwrap as n}from"../../../../core/maybe.js";import{pt2px as o}from"../../../../core/screenUtils.js";import{e as s}from"../../../../chunks/earcut.js";import{s as a}from"../../../../chunks/vec4.js";import{create as l,empty as c,expandWithBuffer as h,intersectsClippingArea as p,expandWithAABB as u}from"../../../../geometry/support/aaBoundingBox.js";import{SymbolUpdateType as d,elevationModeChangeUpdateType as m,needsElevationUpdates2D as _}from"./elevationAlignmentUtils.js";import{ElevationContext as g}from"./ElevationContext.js";import y from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as f}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as b}from"./Graphics3DSymbolLayer.js";import{mixinColorAndOpacity as x}from"./graphicUtils.js";import{parseCapType as v}from"./lineUtils.js";import{geometryAsPolygon as O,createColorGeometry as C,PolygonCreationDataBase as D}from"./polygonUtils.js";import{createMaterial as S,uvElevationAligner as j}from"../support/patternUtils.js";import{createMapSpaceUVCoords as A,createMapSpaceUVCoordsDraped as M}from"../support/uvUtils.js";import{createGeometry as P}from"../../support/engineContent/line.js";import{geometryToRenderInfo as E,geometryToRenderInfoDraped as L}from"../../support/renderInfoUtils/polygon.js";import{newDoubleArray as G,doubleSubArray as w,doubleArrayFrom as U}from"../../webgl-engine/lib/DoubleArray.js";import{newFloatArray as I,floatSubArray as R}from"../../webgl-engine/lib/FloatArray.js";import{Object3D as V}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as B}from"../../webgl-engine/lib/RenderGeometry.js";import{VertexAttribute as T}from"../../webgl-engine/lib/VertexAttribute.js";import{getStipplePatternForLinePattern as F}from"../../webgl-engine/materials/lineStippleUtils.js";import{PatternMaterial as H}from"../../webgl-engine/materials/PatternMaterial.js";import{RibbonLineMaterial as W}from"../../webgl-engine/materials/RibbonLineMaterial.js";const k=["polyline","polygon","extent"];class z extends b{constructor(e,t,i,r){super(e,t,i,r),this._needsUV=!1,this._hasOutline=!1}async doLoad(){}_ensureMaterials(){this._ensureFillMaterial(),this._ensureOutlineMaterial()}_ensureFillMaterial(){if(t(this._material))return;const e=i(this.symbolLayer,"material","color"),r=this._getCombinedOpacityAndColor(e);this._material=S(this.symbolLayer,{color:r,transparent:r[3]<1||this.needsDrivenTransparentPass,polygonOffset:!1,hasVertexColors:!0,writeLinearDepth:!0,hasSlicePlane:this._context.slicePlaneEnabled},{isDraped:this.draped}),this._needsUV=this._material instanceof H,this._context.stage.add(this._material)}_ensureOutlineMaterial(){const e=this.symbolLayer.outline;if(t(this._outlineMaterial)||!this._isValidOutline(e))return;this._hasOutline=!0;const i=t=>{const i=F(e.pattern);return new W({width:t,color:this._getOutlineColor(),hasPolygonOffset:!0,hasSlicePlane:this._context.slicePlaneEnabled,isClosed:!0,stipplePattern:i,stippleScaleWithLineWidth:!0,cap:v(e.patternCap||"butt")})};this._outlineMaterial=i(o(e.size)),this._context.stage.add(this._outlineMaterial)}_isValidOutline(e){return t(e)&&null!=e.size&&e.size>0&&t(e.color)&&(r(e.pattern)||"style"!==e.pattern.type||"none"!==e.pattern.style)}destroy(){super.destroy(),this._context.stage.remove(this._material),this._material=null,this._context.stage.remove(this._outlineMaterial),this._outlineMaterial=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,k,this.symbolLayer.type))return null;const i=this._getVertexOpacityAndColor(e.renderingInfo,255),r=this.setGraphicElevationContext(t,new g);return this.ensureDrapedStatus("on-the-ground"===r.mode),this._ensureMaterials(),this.draped?this._createAsOverlay(t,i):this._createAs3DShape(t,i,r)}layerOpacityChanged(){if(t(this._material)){const e=this._material.parameters.color,t=i(this.symbolLayer,"material","color"),r=this._getCombinedOpacity(t);this._material.setParameters({color:[e[0],e[1],e[2],r],transparent:r<1||this.needsDrivenTransparentPass})}if(t(this._outlineMaterial)){const e=this._outlineMaterial.parameters.color;this._outlineMaterial.setParameters({color:[e[0],e[1],e[2],this._getOutlineOpacity()]})}}layerElevationInfoChanged(e,t,i){const r=this._elevationContext.mode,n=m(z.elevationModeChangeTypes,i,r);if(n!==d.UPDATE)return n;const o=_(r);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>o))}slicePlaneEnabledChanged(){if(t(this._material)&&this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),t(this._outlineMaterial)){const e={hasSlicePlane:this._context.slicePlaneEnabled};this._outlineMaterial.setParameters(e)}return!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!0}skipHighSymbolLodsChanged(){return!0}_createAs3DShape(e,t,i){const n=O(e.geometry);if(r(n))return null;const o=E(n,this._context.elevationProvider,this._context.renderCoordsHelper,i),s=new q(o,t,this._context.layer.uid,e.uid),a=s.renderData.position.length/3;if(this._needsUV&&(s.uvMapSpace=I(4*a,!0),s.boundingRect=G(9*a,!0),A(s.uvMapSpace,s.boundingRect,s.renderData.position,this._context.renderCoordsHelper)),s.objectAndLayerIdColor=this._context.stage.renderView?.getObjectAndLayerIdColor(s),this._createAs3DShapeFill(s),this._hasOutline&&this._createAs3DShapeOutline(s),this._logGeometryCreationWarnings(s.renderData,n.rings,"rings","FillSymbol3DLayer"),0===s.outGeometries.length)return null;const l=new V({geometries:s.outGeometries,castShadow:!1,metadata:{layerUid:this._context.layer.uid,graphicUid:e.uid}}),c=new f(this,l,s.outGeometries,null,null,j,i);return c.alignedSampledElevation=s.renderData.sampledElevation,c.needsElevationUpdates=_(i.mode),c}_createAs3DShapeFill(e){const i=e.renderData.polygons;for(const{position:r,mapPositions:o,holeIndices:a,index:l,count:u}of i){if(t(this._context.clippingExtent)&&(c(N),h(N,o),!p(N,this._context.clippingExtent)))continue;const i=s(o,a,3);if(0===i.length)continue;const d=C({material:n(this._material),indices:i,mapPositions:o,attributeData:{position:r,color:e.color,uvMapSpace:this._needsUV?R(e.uvMapSpace,4*l,4*u):null,boundingRect:this._needsUV?w(e.boundingRect,9*l,9*u):null,objectAndLayerIdColor:e.objectAndLayerIdColor}});e.outGeometries.push(d)}}_createAs3DShapeOutline(e){if(!this._hasOutline)return;const i=e.renderData.outlines;for(let r=0;r<i.length;++r){const{mapPositions:o,position:s}=i[r];if(t(this._context.clippingExtent)&&(c(N),h(N,o),!p(N,this._context.clippingExtent)))continue;const a=P(n(this._outlineMaterial),{overlayInfo:null,removeDuplicateStartEnd:!0,mapPositions:o,attributeData:{position:s}},e.objectAndLayerIdColor),l=a.vertexAttributes.get(T.POSITION);l.data===s&&(l.data=U(s)),e.outGeometries.push(a)}}_createAsOverlay(e,i){const o=O(e.geometry);if(r(o))return null;n(this._material).renderPriority=this._renderPriority+this._renderPriorityStep/2,t(this._outlineMaterial)&&(this._outlineMaterial.renderPriority=this._renderPriority);const s=L(o,this._context.overlaySR),a=new J(s,i,this._context.layer.uid,e.uid),l=a.renderData.position.length/3;return this._needsUV&&(a.uvMapSpace=I(4*l,!0),M(a.uvMapSpace,a.renderData.position,this._context.overlaySR,this._context.graphicsCoreOwner.view.state.viewingMode)),a.outBoundingBox=c(),a.objectAndLayerIdColor=this._context.stage.renderView?.getObjectAndLayerIdColor(a),this._createAsOverlayFill(a),this._hasOutline&&this._createAsOverlayOutline(a),this._logGeometryCreationWarnings(a.renderData,o.rings,"rings","FillSymbol3DLayer"),0===a.outGeometries.length?null:new y(this,a.outGeometries,a.outBoundingBox,this._context.drapeSourceRenderer)}_createAsOverlayFill(e){const t=e.renderData.polygons;for(const{position:i,holeIndices:r,index:o,count:l}of t){const t=c(N);if(h(t,i),!p(t,this._context.clippingExtent))continue;const d=s(i,r,3);if(0===d.length)continue;u(e.outBoundingBox,t);const m=C({material:n(this._material),indices:d,attributeData:{position:i,color:e.color,uvMapSpace:this._needsUV?R(e.uvMapSpace,4*o,4*l):null,objectAndLayerIdColor:e.objectAndLayerIdColor}}),_=new B(m,e);a(_.boundingSphere,.5*(t[0]+t[3]),.5*(t[1]+t[4]),0,.5*Math.sqrt((t[3]-t[0])*(t[3]-t[0])+(t[4]-t[1])*(t[4]-t[1]))),e.outGeometries.push(_)}}_createAsOverlayOutline(e){if(!this._hasOutline)return;const t=e.renderData.outlines;for(let i=0;i<t.length;++i){const{position:r}=t[i];if(c(N),h(N,r),!p(N,this._context.clippingExtent))continue;u(e.outBoundingBox,N);const o=P(n(this._outlineMaterial),{overlayInfo:{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper},removeDuplicateStartEnd:!0,attributeData:{position:r}},e.objectAndLayerIdColor),s=new B(o,e),l=N;a(s.boundingSphere,.5*(l[0]+l[3]),.5*(l[1]+l[4]),0,.5*Math.sqrt((l[3]-l[0])*(l[3]-l[0])+(l[4]-l[1])*(l[4]-l[1]))),e.outGeometries.push(s)}}_getOutlineOpacity(){const e=i(this.symbolLayer,"outline","color");return(this.draped?1:this._getLayerOpacity())*(t(e)?e.a:0)}_getOutlineColor(){const r=i(this.symbolLayer,"outline","color"),n=this._getOutlineOpacity();return x(t(r)?e.toUnitRGB(r):null,n)}test(){return{...super.test(),createAsOverlay:(e,t)=>this._createAsOverlay(e,t),createAs3DShape:(e,t,i)=>this._createAs3DShape(e,t,i)}}}z.elevationModeChangeTypes={definedChanged:d.RECREATE,staysOnTheGround:d.NONE,onTheGroundChanged:d.RECREATE};const N=l();class q extends D{constructor(e,t,i,r){super(e,i,r),this.color=t}}class J extends D{constructor(e,t,i,r){super(e,i,r),this.color=t}}export{z as Graphics3DPolygonFillSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import"../../../../core/has.js";import t from"../../../../core/Logger.js";import{isSome as i,unwrap as o,unwrapOr as r}from"../../../../core/maybe.js";import{O as n}from"../../../../chunks/vec3f64.js";import{f as s}from"../../../../chunks/vec4f64.js";import{SymbolUpdateType as a}from"./elevationAlignmentUtils.js";import{ElevationContext as l}from"./ElevationContext.js";import{zeroContext as p}from"./featureExpressionInfoUtils.js";import{mixinColorAndOpacity as c}from"./graphicUtils.js";import{ApplyRendererDiffResult as d}from"./interfaces.js";import{Loadable as
|
|
5
|
+
import e from"../../../../Color.js";import"../../../../core/has.js";import t from"../../../../core/Logger.js";import{isSome as i,unwrap as o,unwrapOr as r}from"../../../../core/maybe.js";import{O as n}from"../../../../chunks/vec3f64.js";import{f as s}from"../../../../chunks/vec4f64.js";import{SymbolUpdateType as a}from"./elevationAlignmentUtils.js";import{ElevationContext as l}from"./ElevationContext.js";import{zeroContext as p}from"./featureExpressionInfoUtils.js";import{mixinColorAndOpacity as c}from"./graphicUtils.js";import{ApplyRendererDiffResult as d}from"./interfaces.js";import{Loadable as h}from"./Loadable.js";import{defaultSymbolLayerComplexity as u}from"./symbolComplexity.js";const f=t.getLogger("esri.views.3d.layers.graphics.Graphics3DSymbolLayer");class y extends h{constructor(e,t,i,o){super(i.schedule),this.symbol=e,this.symbolLayer=t,this._context=i,this._elevationInfoOverride=null,this._ignoreDrivers=!1,this._drivenProperties={color:!1,opacity:!1,opacityAlwaysOpaque:!0,size:!1},this.complexity=null,this.logger=f,this._elevationOptions={supportsOffsetAdjustment:!1,supportsOnTheGround:!0},this._renderPriority=o.renderPriority,this._renderPriorityStep=o.renderPriorityStep,this._elevationContext=new l,this.complexity=this.computeComplexity(),this._ignoreDrivers=o.ignoreDrivers,this._ignoreDrivers||(this._drivenProperties=g(this._context.renderer)),this._updateElevationContext()}getCachedSize(){return null}get extentPadding(){return 0}_drivenPropertiesChanged(e){if(this._ignoreDrivers)return!1;const t=this._drivenProperties,i=g(e);return i.color!==t.color||i.opacity!==t.opacity||i.opacityAlwaysOpaque!==t.opacityAlwaysOpaque||i.size!==t.size}get needsDrivenTransparentPass(){return this._drivenProperties.opacity&&!this._drivenProperties.opacityAlwaysOpaque}_logGeometryCreationWarnings(e,t,i,o){const r=e.projectionSuccess,n="polygons"in e?e.polygons:null,s=`${o} geometry failed to be created`;let a=null;r?!this._logGeometryValidationWarnings(t,i,o)&&n&&0===n.length&&"rings"===i&&t.length>0&&t[0].length>2&&(a=`${s} (filled rings should use clockwise winding - try reversing the order of vertices)`):a=`${s} (failed to project geometry to view spatial reference)`,a&&f.warnOncePerTick(a)}_logGeometryValidationWarnings(e,t,i){const o=`${i} geometry failed to be created`;return!e.length||1===e.length&&!e[0].length?(f.warnOncePerTick(`${o} (no ${t} were defined)`),!0):(!Array.isArray(e)||!Array.isArray(e[0]))&&(f.warnOncePerTick(`${o} (${t} should be defined as a 2D array)`),!0)}_validateGeometry(e,t=null,o=null){if(i(t)&&!t.includes(e.type))return this.logger.warn("unsupported geometry type for "+o+` symbol: ${e.type}`),!1;if("point"===e.type){const t=e;if(!isFinite(t.x)||!isFinite(t.y))return f.warn("point coordinate is not a valid number, graphic skipped"),!1}return!0}_defaultElevationInfoNoZ(){return m}_defaultElevationInfoZ(){return _}_updateElevationContext(){i(this._elevationInfoOverride)?(this._elevationContext.setFromElevationInfo(this._elevationInfoOverride),this._elevationContext.updateFeatureExpressionInfoContext(null)):this._context.layer.elevationInfo?(this._elevationContext.setFromElevationInfo(this._context.layer.elevationInfo),this._elevationContext.updateFeatureExpressionInfoContext(this._context.featureExpressionInfoContext)):this._elevationContext.reset()}getDefaultElevationInfo(e){return e.hasZ?this._defaultElevationInfoZ():this._defaultElevationInfoNoZ()}getGeometryElevationMode(e,t=this.getDefaultElevationInfo(e)){return this._elevationContext.mode||t.mode}setElevationInfoOverride(e){this._elevationInfoOverride=e,this._updateElevationContext()}setGraphicElevationContext(e,t){const i=o(e.geometry),n=this.getDefaultElevationInfo(i);t.unit=null!=this._elevationContext.unit?this._elevationContext.unit:n.unit,t.mode=this.getGeometryElevationMode(i,n),t.offsetMeters=r(this._elevationContext.meterUnitOffset,r(n.offset,0));const s=!this._elevationOptions.supportsOnTheGround&&"on-the-ground"===t.mode;s&&(t.mode="relative-to-ground",t.offsetMeters=0);const a=s?p:this._elevationContext.featureExpressionInfoContext;return t.updateFeatureExpressionInfoContext(a,e,this._context.layer),t}prepareSymbolLayerPatch(e){}updateGeometry(e,t){return!1}onRemoveGraphic(e){}_getLayerOpacity(){if(this._context.graphicsCoreOwner&&"fullOpacity"in this._context.graphicsCoreOwner)return this._context.graphicsCoreOwner.fullOpacity??0;const e=this._context.layer.opacity;return e??1}_getCombinedOpacity(e,t=x){let o=1;return this.draped||(o*=this._getLayerOpacity()),this._drivenProperties.opacity||(i(e)?o*=e.a:t.hasIntrinsicColor||(o=0)),o}_getCombinedOpacityAndColor(t,o=x){const r=this._getCombinedOpacity(t,o);if(this._drivenProperties.color)return c(null,r);const s=i(t)?e.toUnitRGB(t):n;return c(s,r)}_getVertexOpacityAndColor(e,t=null){const o=this._drivenProperties.color?e.color:null,r=this._drivenProperties.opacity?e.opacity:null,n=c(o,r);return i(t)&&(n[0]*=t,n[1]*=t,n[2]*=t,n[3]*=t),n}isFastUpdatesEnabled(){return this._fastUpdates&&this._fastUpdates.enabled}computeComplexity(){return u(this.symbol,this.symbolLayer)}globalPropertyChanged(e,t,i){switch(e){case"opacity":return this.layerOpacityChanged(t,i),!0;case"elevationInfo":{const e=this._elevationContext.mode;this._updateElevationContext();return this.layerElevationInfoChanged(t,i,e)!==a.RECREATE}case"slicePlaneEnabled":return this.slicePlaneEnabledChanged(t,i);case"physicalBasedRenderingEnabled":return this.physicalBasedRenderingChanged();case"pixelRatio":return this.pixelRatioChanged();case"skipHighSymbolLods":return this.skipHighSymbolLodsChanged();default:return!1}}updateGraphics3DGraphicElevationInfo(e,t,o){let r=a.UPDATE;return e.forEach((e=>{const n=t(e);if(i(n)){const t=e.graphic;this.setGraphicElevationContext(t,n.elevationContext),n.needsElevationUpdates=o(n.elevationContext.mode)}else r=a.RECREATE})),r}applyRendererDiff(e,t){return d.Recreate_Symbol}getFastUpdateAttrValues(e){if(!this._fastUpdates.enabled)return null;const t=this._fastUpdates.visualVariables,i=t.size?v(t.size.field,e):0,o=t.color?v(t.color.field,e):0,r=t.opacity?v(t.opacity.field,e):0;return s(i,o,r,0)}get draped(){return this._draped}ensureDrapedStatus(e){return null==this._draped?(this._draped=e,!0):(e!==this.draped&&f.warnOnce("A symbol can only produce either draped or non-draped visualizations. Use two separate symbol instances for draped and non-draped graphics if necessary."),!1)}test(){const e=()=>({size:this._fastUpdates?.visualVariables?.size?.field??null,color:this._fastUpdates?.visualVariables?.color?.field??null,opacity:this._fastUpdates?.visualVariables?.opacity?.field??null,rotation:this._fastUpdates?.visualVariables?.rotation?.field??null});return{drivenProperties:this._drivenProperties,getVisVarFields:e}}}function v(e,t){const i=null!=e?t.attributes[e]:0;return null!=i&&isFinite(i)?i:0}function g(e){const t={color:!1,opacity:!1,opacityAlwaysOpaque:!0,size:!1};return e&&"visualVariables"in e&&e.visualVariables&&e.visualVariables.forEach((e=>{switch(e.type){case"color":if(t.color=!0,e.stops)for(let i=0;i<e.stops.length;i++){const o=e.stops[i].color;o&&(t.opacity=!0,o.a<1&&(t.opacityAlwaysOpaque=!1))}break;case"opacity":t.opacity=!0,t.opacityAlwaysOpaque=!1;break;case"size":t.size=!0}})),t}const m={mode:"on-the-ground",offset:0,unit:"meters"},_={mode:"absolute-height",offset:0,unit:"meters"},x={hasIntrinsicColor:!1};export{y as Graphics3DSymbolLayer,v as getAttributeValue};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../core/Error.js";import{isNone as t,isSome as r,get as s,unwrap as n}from"../../../../core/maybe.js";import{isPromiseLike as i}from"../../../../core/promiseUtils.js";import{pt2px as o}from"../../../../core/screenUtils.js";import{f as a,Z as l,a as c}from"../../../../chunks/vec2f64.js";import{hasCalloutSupport as m,textSymbolLayerSupportsVerticalOffset as h}from"../../../../symbols/callouts/calloutUtils.js";import{CreateLabelParameters as
|
|
5
|
+
import e from"../../../../core/Error.js";import{isNone as t,isSome as r,get as s,unwrap as n}from"../../../../core/maybe.js";import{isPromiseLike as i}from"../../../../core/promiseUtils.js";import{pt2px as o}from"../../../../core/screenUtils.js";import{f as a,Z as l,a as c}from"../../../../chunks/vec2f64.js";import{hasCalloutSupport as m,textSymbolLayerSupportsVerticalOffset as h}from"../../../../symbols/callouts/calloutUtils.js";import{CreateLabelParameters as d}from"./CreateLabelParameters.js";import{perObjectElevationAligner as p}from"./ElevationAligners.js";import{SymbolUpdateType as f,needsElevationUpdates2D as u}from"./elevationAlignmentUtils.js";import{ElevationContext as g}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as y}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DObjectMetadata as x}from"./Graphics3DObjectMetadata.js";import{Graphics3DSymbolLayer as b}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as v}from"./graphicUtils.js";import{verticalPlacementFromAlignment as P,textRenderAlignmentFromHorizontalPlacement as O,horizontalPlacementToAnchorX as j,anchorFromPlacements as w,namedAnchorToHUDMaterialAnchorPos as S}from"./placementUtils.js";import{placePointOnGeometry as _,createStageObject as E,extendPointGraphicElevationContext as L}from"./pointUtils.js";import{createPointGeometry as C}from"../../webgl-engine/lib/GeometryUtil.js";import{TextRenderParameters as z}from"../../webgl-engine/lib/TextRenderParameters.js";import G from"../../webgl-engine/lib/TextTextureFactory.js";import{HUDMaterial as R}from"../../webgl-engine/materials/HUDMaterial.js";const U=[0,0,1];class D extends b{constructor(e,t,r,s){super(e,t,r,s),this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!1},this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const t=v(this.symbolLayer.size);if(t)throw new e("graphics3dtextsymbollayer:invalid-size",t)}await this._createTextRenderParameters()}async _createTextRenderParameters(){const e=this._context.graphicsCoreOwner.view.state.rasterPixelRatio;this._textRenderParameters=await z.fromSymbol(this.symbolLayer,e)}destroy(){super.destroy()}createGraphics3DGraphic(e){const s=e.graphic,n=_(s.geometry);if(t(n))return this.logger.warn(`unsupported geometry type for text symbol: ${s.geometry.type}`),null;const i=this.symbolLayer.text;if(t(i)||""===i)return null;const o=m(this.symbol)&&this.symbol.hasVisibleVerticalOffset()?this.symbol.verticalOffset:null;if(r(o)&&!h(this.symbolLayer))return this.logger.errorOncePerTick(`Callouts and vertical offset on text symbols are currently only supported with 'center' horizontal alignment (not with '${this.symbolLayer.horizontalAlignment}' alignment)`),null;const a=new d(o,this.symbolLayer.horizontalAlignment,P(this.symbolLayer.verticalAlignment));return this._createAs3DShape(s,n,i,a)}createLabel(e,r,s,n){const i=e.graphic,o=_(i.geometry);if(t(o))return this.logger.warn(`unsupported geometry type for label: ${i.geometry.type}`),null;const a=r.text;return!a||/^\s+$/.test(a)?null:this._createAs3DShape(i,o,a,r,s,n)}setGraphicElevationContext(e,t,r=0){const s=super.setGraphicElevationContext(e,t);return s.addOffsetRenderUnits(r),s}layerOpacityChanged(){return this.logger.warn("layer opacity change not yet implemented in Graphics3DTextSymbolLayer"),!1}layerElevationInfoChanged(e,t){return A(e,t,((e,t)=>{this.updateGraphicElevationContext(t,e)})),f.UPDATE}slicePlaneEnabledChanged(e,t){return A(e,t,(e=>{for(const t of e.stageObject.geometries)t.material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!1}skipHighSymbolLodsChanged(){return!0}updateGraphicElevationContext(e,t){const s=t.elevationContext;this.setGraphicElevationContext(e,s,r(t.metadata)?t.metadata.elevationOffset:0),t.needsElevationUpdates=u(s.mode)||"absolute-height"===s.mode}_defaultElevationInfoNoZ(){return W}_createAs3DShape(e,m,h,d,f,b){const v=this.setGraphicElevationContext(e,new g,d.elevationOffset),P="polyline"===s(e.geometry,"type"),j=e.uid;let w=null,S=null;if(t(b)){const e=O(d.horizontalPlacement);w=new G(h,e,this._textRenderParameters);let s=null;if(r(this._context.sharedResources.textures)){S=this._context.sharedResources.textures.fromData(w.key,(()=>n(w).create()),(()=>{r(s)&&s.release()}));const e=this._context.stage.renderView.textureRepository.acquire(S.texture.id);if(t(e)||i(e))return S.release(),null;s=e}}const _=T(w,d),z={occlusionTest:!0,screenOffset:d.screenOffset,anchorPosition:_,polygonOffset:!0,color:[1,1,1,1],centerOffsetUnits:d.centerOffsetUnits,drawInSecondSlot:!0};if(r(b)?z.textureId=b.id:r(S)&&(z.textureId=S.texture.id),r(d.verticalOffset)){const{screenLength:e,minWorldLength:t,maxWorldLength:s}=d.verticalOffset;z.verticalOffset={screenLength:o(e),minWorldLength:t||0,maxWorldLength:r(s)?s:1/0}}if(this._context.screenSizePerspectiveEnabled){const{screenSizePerspectiveSettings:e,screenSizePerspectiveSettingsLabels:t}=this._context.sharedResources;z.screenSizePerspective=t.overridePadding(this._textRenderParameters.haloSize+this._textRenderParameters.definition.background.padding[0]),z.screenSizePerspectiveAlignment=e}let D;if(P&&(z.shaderPolygonOffset=1e-4),z.hasSlicePlane=this._context.slicePlaneEnabled,r(f)){const e=JSON.stringify(z);D=f.get(e),t(D)&&(D=new R(z),f.add(e,D))}else D=new R(z);const A=d.translation,W=r(w)?a(w.displayWidth,w.displayHeight):l,k=d.centerOffset,I=C(D,U,A,null,W,k,[0,0],null),H=E(this._context,m,I,v,j);if(t(H))return null;const $=new y(this,H.object,[I],t(f)?[D]:null,S,p,v);$.alignedSampledElevation=H.sampledElevation,$.needsElevationUpdates=u(v.mode)||"absolute-height"===v.mode;const{displayWidth:V,displayHeight:M}=r(w)?w:d;$.getScreenSize=(e=c())=>(e[0]=V,e[1]=M,e);const N=new x(d.elevationOffset,h);return $.metadata=N,L($,m,this._context.elevationProvider),$}}function A(e,t,s){e&&e.forEach((e=>{const n=t(e);r(n)&&s(n,e.graphic)}))}function T(e,t){if("baseline"===t.verticalPlacement){const s=j[t.horizontalPlacement],n=r(e)?e.baselineAnchorY:0;return a(s,n)}const s=w(t.horizontalPlacement,t.verticalPlacement);return S[s]}const W={mode:"relative-to-ground",offset:0};export{D as Graphics3DTextSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import{isSome as t,isNone as r,unwrap as o}from"../../../../core/maybe.js";import{getMetersPerUnitForSR as i}from"../../../../core/unitUtils.js";import{e as n}from"../../../../chunks/earcut.js";import{s}from"../../../../chunks/vec2.js";import{f as a,a as l}from"../../../../chunks/vec2f64.js";import{b as c,s as h}from"../../../../chunks/vec4.js";import{t as m}from"../../../../chunks/common.js";import{create as p,empty as u,expandWithBuffer as d,intersectsClippingArea as g,expandWithAABB as y}from"../../../../geometry/support/aaBoundingBox.js";import{create as f,empty as _,expandPointInPlace as v}from"../../../../geometry/support/aaBoundingRect.js";import{perVertexElevationAligner as x}from"./ElevationAligners.js";import{SymbolUpdateType as b,elevationModeChangeUpdateType as D,needsElevationUpdates2D as C}from"./elevationAlignmentUtils.js";import{ElevationContext as S}from"./ElevationContext.js";import w from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as G}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as j}from"./Graphics3DSymbolLayer.js";import{geometryAsPolygon as E,createWaterGeometry as P,PolygonCreationDataBase as A}from"./polygonUtils.js";import{geometryToRenderInfo as O,geometryToRenderInfoDraped as R}from"../../support/renderInfoUtils/polygon.js";import{newDoubleArray as T,doubleSubArray as
|
|
5
|
+
import e from"../../../../Color.js";import{isSome as t,isNone as r,unwrap as o}from"../../../../core/maybe.js";import{getMetersPerUnitForSR as i}from"../../../../core/unitUtils.js";import{e as n}from"../../../../chunks/earcut.js";import{s}from"../../../../chunks/vec2.js";import{f as a,a as l}from"../../../../chunks/vec2f64.js";import{b as c,s as h}from"../../../../chunks/vec4.js";import{t as m}from"../../../../chunks/common.js";import{create as p,empty as u,expandWithBuffer as d,intersectsClippingArea as g,expandWithAABB as y}from"../../../../geometry/support/aaBoundingBox.js";import{create as f,empty as _,expandPointInPlace as v}from"../../../../geometry/support/aaBoundingRect.js";import{perVertexElevationAligner as x}from"./ElevationAligners.js";import{SymbolUpdateType as b,elevationModeChangeUpdateType as D,needsElevationUpdates2D as C}from"./elevationAlignmentUtils.js";import{ElevationContext as S}from"./ElevationContext.js";import w from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as G}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as j}from"./Graphics3DSymbolLayer.js";import{geometryAsPolygon as E,createWaterGeometry as P,PolygonCreationDataBase as A}from"./polygonUtils.js";import{geometryToRenderInfo as O,geometryToRenderInfoDraped as R}from"../../support/renderInfoUtils/polygon.js";import{newDoubleArray as T,doubleSubArray as L}from"../../webgl-engine/lib/DoubleArray.js";import{Object3D as U}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as B}from"../../webgl-engine/lib/RenderGeometry.js";import{WaterMaterialParameters as M,WaterMaterial as V}from"../../webgl-engine/materials/WaterMaterial.js";import{wavePresets as I}from"../../webgl-engine/materials/internal/waterMaterialUtils.js";const W=["polyline","polygon","extent"];class k extends j{constructor(e,t,r,o){super(e,t,r,o)}async doLoad(){}destroy(){super.destroy(),this._context.stage.remove(this._material),this._material=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,W,this.symbolLayer.type))return null;const r=this.setGraphicElevationContext(t,new S);return this.ensureDrapedStatus("on-the-ground"===r.mode),this.ensureMaterial(),this.draped?this._createAsOverlay(t):this._createAs3DShape(t,r,t.uid)}ensureMaterial(){if(t(this._material))return;const r=new M,o=this.symbolLayer.color;t(o)&&(r.color=e.toUnitRGBA(o));const i=this._getCombinedOpacity(o,{hasIntrinsicColor:!0});r.color=[r.color[0],r.color[1],r.color[2],i],r.transparent=i<1||this.needsDrivenTransparentPass,r.waveDirection=t(this.symbolLayer.waveDirection)?k.headingVectorFromAngle(this.symbolLayer.waveDirection):a(0,0);const n=this.symbolLayer.waveStrength+"-"+this.symbolLayer.waterbodySize,s=I[n];r.waveStrength=s.waveStrength,r.waveTextureRepeat=s.textureRepeat,r.waveVelocity=s.waveVelocity,r.flowStrength=s.perturbationStrength,r.hasSlicePlane=this._context.slicePlaneEnabled,r.isDraped=this.draped,this._material=new V(r),this._context.stage.add(this._material)}layerOpacityChanged(){if(r(this._material))return;const e=this._material.parameters.color,t=this._getCombinedOpacity(this.symbolLayer.color,{hasIntrinsicColor:!0}),o=t<1||this.needsDrivenTransparentPass;this._material.setParameters({color:[e[0],e[1],e[2],t],transparent:o})}layerElevationInfoChanged(e,t,r){const o=this._elevationContext.mode,i=D(k.elevationModeChangeTypes,r,o);if(i!==b.UPDATE)return i;const n=C(o);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>n))}slicePlaneEnabledChanged(){return t(this._material)&&this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!0}skipHighSymbolLodsChanged(){return!0}_createAs3DShape(e,t,o){const i=E(e.geometry);if(r(i))return null;const n=O(i,this._context.elevationProvider,this._context.renderCoordsHelper,t),s=n.position.length/3,a=T(2*s);this._createUVCoordsFromVertices(a,n.mapPositions,s,this._context.elevationProvider.spatialReference);const l=new q(n,a);if(this._create3DShapeGeometries(l),this._logGeometryCreationWarnings(l.renderData,i.rings,"rings","WaterSymbol3DLayer"),0===l.outGeometries.length)return null;const c=new U({geometries:l.outGeometries,castShadow:!1,metadata:{layerUid:this._context.layer.uid,graphicUid:o}}),h=new G(this,c,l.outGeometries,null,null,x,t);return h.alignedSampledElevation=l.renderData.sampledElevation,h.needsElevationUpdates=C(t.mode),h}_createUVCoordsFromVertices(e,t,r,o){const n=i(o);_(F);for(let i=0;i<r;i++)s(H,t[3*i],t[3*i+1]),v(F,H);c(F,F,n);const a=F[0]%k.unitSizeOfTexture,l=F[1]%k.unitSizeOfTexture;z[0]=F[0]-a,z[1]=F[1]-l;for(let i=0;i<r;i++)e[2*i]=(t[3*i]*n-z[0])/k.unitSizeOfTexture,e[2*i+1]=(t[3*i+1]*n-z[1])/k.unitSizeOfTexture}_create3DShapeGeometries(e){const r=e.renderData.polygons,i=e.uvCoords;for(const{count:s,index:a,position:l,mapPositions:c,holeIndices:h}of r){if(t(this._context.clippingExtent)&&(u(N),d(N,c),!g(N,this._context.clippingExtent)))continue;const r=n(c,h,3);if(0===r.length)continue;const m=L(i,2*a,2*s),p=P({material:o(this._material),indices:r,mapPositions:c,attributeData:{position:l,uv0:m}});e.outGeometries.push(p)}}_createAsOverlay(e){const t=E(e.geometry);if(r(t))return null;o(this._material).renderPriority=this._renderPriority;const i=R(t,this._context.overlaySR),n=i.position.length/3,s=T(2*n);this._createUVCoordsFromVertices(s,i.position,n,this._context.overlaySR);const a=new J(i,s,this._context.layer.uid,e.uid);return a.outBoundingBox=u(),this._createAsOverlayWater(a),this._logGeometryCreationWarnings(a.renderData,t.rings,"rings","WaterSymbol3DLayer"),0===a.outGeometries.length?null:new w(this,a.outGeometries,a.outBoundingBox,this._context.drapeSourceRenderer)}_createAsOverlayWater(e){const t=e.uvCoords,r=e.renderData.polygons;for(const{position:i,holeIndices:s,index:a,count:l}of r){if(u(N),d(N,i),!g(N,this._context.clippingExtent))continue;y(e.outBoundingBox,N);const r=n(i,s,3);if(0===r.length)continue;const c=L(t,2*a,2*l),m=P({material:o(this._material),indices:r,attributeData:{position:i,uv0:c}}),p=new B(m,e),f=N;h(p.boundingSphere,.5*(f[0]+f[3]),.5*(f[1]+f[4]),0,.5*Math.sqrt((f[3]-f[0])*(f[3]-f[0])+(f[4]-f[1])*(f[4]-f[1]))),e.outGeometries.push(p)}}static headingVectorFromAngle(e){const t=l(),r=m(e);return t[0]=Math.sin(r),t[1]=Math.cos(r),t}test(){return{...super.test(),create3DShape:e=>this._createAs3DShape(e.graphic,e.elevationContext,e.graphicUid),ensureMaterial:()=>this.ensureMaterial()}}}k.unitSizeOfTexture=100,k.elevationModeChangeTypes={definedChanged:b.RECREATE,staysOnTheGround:b.NONE,onTheGroundChanged:b.RECREATE};const z=l(),F=f(),H=l(),N=p();class q extends A{constructor(e,t){super(e,null,null),this.uvCoords=t}}class J extends A{constructor(e,t,r,o){super(e,r,o),this.uvCoords=t}}export{k as Graphics3DWaterSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import{HandleOwner as t}from"../../../core/HandleOwner.js";import r from"../../../core/Handles.js";import{someMap as s}from"../../../core/MapUtils.js";import{isSome as o,isNone as a,unwrap as n}from"../../../core/maybe.js";import{eachAlwaysValues as i,throwIfAborted as c}from"../../../core/promiseUtils.js";import{sync as u,watch as p,syncAndInitial as l}from"../../../core/reactiveUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import{HandleOwner as t}from"../../../core/HandleOwner.js";import r from"../../../core/Handles.js";import{someMap as s}from"../../../core/MapUtils.js";import{isSome as o,isNone as a,unwrap as n}from"../../../core/maybe.js";import{eachAlwaysValues as i,throwIfAborted as c}from"../../../core/promiseUtils.js";import{sync as u,watch as p,syncAndInitial as l}from"../../../core/reactiveUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{c as g}from"../../../chunks/vec3.js";import{c as m}from"../../../chunks/vec3f64.js";import{g as y}from"../../../chunks/common.js";import{SnappingTypes as S}from"../../../layers/graphics/data/QueryEngineResult.js";import{absoluteHeightElevationInfo as f}from"../../../support/elevationInfoUtils.js";import{VerticalHalfPlaneConstraint as w}from"./SnappingConstraint.js";import{SnappingDomain as v}from"./SnappingDomain.js";import{anyMapPointToSnappingPoint as _}from"./SnappingPoint.js";import{sortCandidatesInPlace as j,screenDistance as C}from"./snappingUtils.js";import{DrapedEdgeSnappingCandidate as F}from"./candidates/DrapedEdgeSnappingCandidate.js";import{EdgeSnappingCandidate as b}from"./candidates/EdgeSnappingCandidate.js";import{FeatureSnappingCandidate as x}from"./candidates/FeatureSnappingCandidate.js";import{RightAngleSnappingCandidate as M,OtherVertexType as R}from"./candidates/RightAngleSnappingCandidate.js";import{vectorToScreenPoint as L}from"../support/viewUtils.js";let E=class extends t{get updating(){return s(this.snappingSources,(({snappingSource:e})=>e.updating))||this.updatingHandles.updating}get snappingSources(){const e=this._get("snappingSources")||new Map,t=new Map;if(o(this.options)&&o(this.options.featureSources))for(const r of this.options.featureSources.items){const s=r.layer.uid,a=e.get(s);if(a){e.delete(s),t.set(s,a);continue}if(!r.layer.loaded){this.updatingHandles.addPromise(r.layer.load());continue}const n=this._createSourceInfo(r);o(n)&&t.set(s,n)}for(const[,r]of e)r.destroy();return t}constructor(e){super(e),this.options=null,this._domain=v.FEATURE,this._sourceModules={featureService:{module:null,loader:null},featureCollection:{module:null,loader:null},graphics:{module:null,loader:null},notes:{module:null,loader:null},scene:{module:null,loader:null}}}initialize(){this.updatingHandles.add((()=>this.snappingSources),(()=>this.notifyChange("updating")),u),o(this.view)&&this.handles.add([this.view.on("layerview-create",(e=>this._updateLayerView(e.layer,e.layerView))),this.view.on("layerview-destroy",(e=>this._updateLayerView(e.layer,null)))])}_updateLayerView(e,t){for(const[,r]of this.snappingSources)r.snappingSource.layerSource.layer===e&&(r.layerView=t)}destroy(){this._set("options",null);for(const[,e]of this.snappingSources)e.destroy()}async fetchCandidates(e,t,r,s){if(!(t&this._domain)||a(this.options)||!this.options.effectiveFeatureEnabled)return[];const u=[],p=this._computeScreenSizeDistanceParameters(e,r),l={distance:p,mode:n(this.view)?.type??"2d",point:e,coordinateHelper:r.coordinateHelper,types:this._types};for(const[,{snappingSource:a,layerView:n}]of this.snappingSources)!a.layerSource.enabled||o(n)&&n.suspended||u.push(a.fetchCandidates(l,s).then((e=>e.filter((e=>!this._candidateIsExcluded(a,e,r.excludeFeature))))));const d=(await i(u)).flat();return this._addRightAngleCandidates(d,e,p,r),c(s),j(e,d),d}_addRightAngleCandidates(e,t,r,s){const a=o(s.vertexHandle)?s.vertexHandle.rightEdge?.rightVertex?.pos:o(s.editGeometryOperations)&&"polygon"===s.editGeometryOperations.data.type?n(s.editGeometryOperations.data.components[0]?.getFirstVertex())?.pos:null,i=o(s.vertexHandle)?s.vertexHandle.leftEdge?.leftVertex?.pos:o(s.editGeometryOperations)?n(s.editGeometryOperations.data.components[0]?.getLastVertex())?.pos:null,{view:c}=this,u=_(a,c,s),p=_(i,c,s),l=e.length;for(let o=0;o<l;o++)this._addRightAngleCandidate(e[o],p,t,r,e),this._addRightAngleCandidate(e[o],u,t,r,e)}_addRightAngleCandidate(e,t,r,s,o){if(a(t)||!V(e))return;const n=e.constraint.closestTo(t),i=(n[0]-r[0])/s.x,c=(n[1]-r[1])/s.y;if(i*i+c*c<=1){const r=new M({targetPoint:n,otherVertex:t,otherVertexType:R.NEXT,previousVertex:e.constraint.start,constraint:new w(t,n),objectId:e.objectId,isDraped:e.isDraped});o.push(r)}}_computeScreenSizeDistanceParameters(e,t){let r=o(this.options)?this.options.distance*("touch"===t.pointer?this.options.touchSensitivityMultiplier:1):0;return a(this.view)?{x:r,y:r,z:r,distance:r}:"2d"===this.view.type?(r*=this.view.resolution,{x:r,y:r,z:r,distance:r}):this._computeScreenSizeDistanceParameters3D(e,r,this.view,t)}_computeScreenSizeDistanceParameters3D(e,t,r,s){const{spatialReference:o}=s;r.renderCoordsHelper.toRenderCoords(e,o,P);const a=r.state.camera.computeScreenPixelSizeAt(P),n=a*r.renderCoordsHelper.unitInMeters/r.mapCoordsHelper.unitInMeters,i=t*n,c=L(e,o,f,r),u=c?G(c,e,n,0,0,r,s):0,p=c?G(c,e,0,n,0,r,s):0,l=c?G(c,e,0,0,n,r,s):0;return{x:0===u?0:i/u,y:0===p?0:i/p,z:0===l?0:i/l,distance:a*t}}get _types(){return S.EDGE|S.VERTEX}_candidateIsExcluded(e,t,r){if(a(r))return!1;const s=this._getCandidateObjectId(t);if(a(s))return!1;const o=e.layerSource.layer;return"graphics"===o.type?r.uid===s:r.sourceLayer===o&&(!(!r.attributes||!("objectIdField"in o))&&r.attributes[o.objectIdField]===s)}_getCandidateObjectId(e){return e instanceof x?e.objectId:null}_createSourceInfo(e){const t=this._createFeatureSnappingSourceType(e);if(a(t))return null;if("loading"in t)return this.updatingHandles.addPromise(t.loading.then((()=>{this.destroyed||this.notifyChange("snappingSources")}))),null;const r=o(this.view)?this.view.allLayerViews.find((t=>t.layer===e.layer)):null;return new H(t.source,r)}_createFeatureSnappingSourceType(e){switch(e.layer.type){case"feature":case"geojson":case"csv":case"oriented-imagery":case"subtype-group":case"wfs":return this._createFeatureSnappingSourceFeatureLayer(e);case"graphics":return this._createFeatureSnappingSourceGraphicsLayer(e);case"map-notes":return this._createFeatureSnappingSourceMapNotesLayer(e);case"scene":case"building-scene":return this._createFeatureSnappingSourceSceneLayer(e)}return null}_createFeatureSnappingSourceSceneLayer(e){const{view:t}=this;if(a(t)||"3d"!==t.type)return null;const r=this._getSourceModule("scene");return o(r.module)?{source:new r.module.SceneLayerSnappingSource({layerSource:e,view:t})}:{loading:r.loader}}_createFeatureSnappingSourceFeatureLayer(e){switch(e.layer.source?.type){case"feature-layer":case"oriented-imagery":{const t=this._getSourceModule("featureService");return o(t.module)?{source:new t.module.FeatureServiceSnappingSource({spatialReference:this.spatialReference,view:this.view,layerSource:e})}:{loading:t.loader}}case"memory":case"csv":case"geojson":case"wfs":{if("mesh"===e.layer.geometryType)return null;const t=this._getSourceModule("featureCollection");return o(t.module)?{source:new t.module.FeatureCollectionSnappingSource({layerSource:e,view:this.view})}:{loading:t.loader}}}return null}_createFeatureSnappingSourceGraphicsLayer(e){const t=this._getSourceModule("graphics");return o(t.module)?{source:new t.module.GraphicsSnappingSource({getGraphicsLayers:()=>[e.layer],spatialReference:this.spatialReference,view:this.view,layerSource:e})}:{loading:t.loader}}_createFeatureSnappingSourceMapNotesLayer(e){const t=this._getSourceModule("notes");return o(t.module)?{source:new t.module.GraphicsSnappingSource({getGraphicsLayers:()=>o(e.layer.sublayers)?e.layer.sublayers.toArray():[],spatialReference:this.spatialReference,view:this.view,layerSource:e})}:{loading:t.loader}}_getSourceModule(e){const t=this._sourceModules[e];if(a(t.loader)){const r=this._loadSourceModule(e).then((e=>{t.module=e}));return t.loader=r,{module:t.module,loader:r}}return{module:t.module,loader:t.loader}}_loadSourceModule(e){const t=this.updatingHandles;switch(e){case"featureService":return t.addPromise(import("./featureSources/FeatureServiceSnappingSource.js"));case"featureCollection":return t.addPromise(import("./featureSources/FeatureCollectionSnappingSource.js"));case"graphics":case"notes":return t.addPromise(import("./featureSources/GraphicsSnappingSource.js"));case"scene":return t.addPromise(import("./featureSources/SceneLayerSnappingSource.js"))}}};e([d({constructOnly:!0})],E.prototype,"spatialReference",void 0),e([d({constructOnly:!0})],E.prototype,"view",void 0),e([d()],E.prototype,"options",void 0),e([d({readOnly:!0})],E.prototype,"updating",null),e([d({readOnly:!0})],E.prototype,"snappingSources",null),E=e([h("esri.views.interactive.snapping.FeatureSnappingEngine")],E);class H{constructor(e,t){this.snappingSource=e,this.layerView=t,this.handles=new r;const s=this.snappingSource.layerSource.layer;if("refresh"in s){const t=s;this.handles.add(t.on("refresh",(()=>e.refresh())))}this.handles.add([p((()=>e.updating),(t=>e.layerSource.updating=t),l),p((()=>e.availability),(t=>e.layerSource.availability=t),l)])}destroy(){this.snappingSource.destroy(),this.handles.destroy()}}function V(e){return(e instanceof b||e instanceof F)&&!I(e)}function I({constraint:{start:e,end:t}}){const r=y();return Math.abs(t[0]-e[0])<=r&&Math.abs(t[1]-e[1])<=r}function G(e,t,r,s,o,a,{spatialReference:n}){const i=g(O,t);i[0]+=r,i[1]+=s,i[2]+=o;const c=L(i,n,f,a);return c?C(c,e):1/0}const P=m(),O=m();export{E as FeatureSnappingEngine};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{unwrap as e}from"../../../core/maybe.js";import{k as t}from"../../../chunks/vec2.js";import{a as r}from"../../../chunks/vec2f64.js";import{f as
|
|
5
|
+
import{unwrap as e}from"../../../core/maybe.js";import{k as t}from"../../../chunks/vec2.js";import{a as r}from"../../../chunks/vec2f64.js";import{f as i}from"../../../chunks/vec3f64.js";import{absoluteHeightElevationInfo as s}from"../../../support/elevationInfoUtils.js";import{defaults as o}from"./Settings.js";import{SnappingAlgorithm as n}from"./SnappingAlgorithm.js";import{anyMapPointToSnappingPoint as l,asSnappingPoint as a}from"./SnappingPoint.js";import{editEdgeToSnappingEdge as c,squaredScreenDistance as h}from"./snappingUtils.js";import{ParallelLineSnappingCandidate as p}from"./candidates/ParallelLineSnappingCandidate.js";import{vectorToScreenPoint as d}from"../support/viewUtils.js";import{projectPointToLine as f}from"../../support/geometry2dUtils.js";class g extends n{snapNewVertex(e,t){const r=t.editGeometryOperations.data.components[0],i=r.edges.length,o=r.vertices.length,n=[];if(i<2)return n;const{view:a}=this,h=d(e,t.spatialReference,s,a),p=l(r.vertices[o-1].pos,a,t),f=l(r.vertices[0].pos,a,t),g=r.edges[i-1];let m=g;do{if(this.edgeExceedsShortLineThreshold(m,t)){const r=c(m,a,t);this._checkEdgeForParallelLines(r,p,e,h,t,n),this._checkEdgeForParallelLines(r,f,e,h,t,n)}m=m.leftVertex.leftEdge}while(m&&m!==g);return n}snapExistingVertex(t,r){const i=[],o=e(r.vertexHandle),n=o.component;if(n.edges.length<3)return i;const{view:a}=this,h=d(t,r.spatialReference,s,a),p=o.leftEdge,f=o.rightEdge,g=n.vertices[0],m=l(g.pos,a,r),u=n.vertices.length,v=n.vertices[u-1],E=l(v.pos,a,r),L=n.edges[0];let x=L;do{if(x!==p&&x!==f&&this.edgeExceedsShortLineThreshold(x,r)){const e=c(x,a,r);p&&this._checkEdgeForParallelLines(e,l(p.leftVertex.pos,a,r),t,h,r,i),f&&this._checkEdgeForParallelLines(e,l(f.rightVertex.pos,a,r),t,h,r,i),o===g?this._checkEdgeForParallelLines(e,E,t,h,r,i):o===v&&this._checkEdgeForParallelLines(e,m,t,h,r,i)}x=x.rightVertex.rightEdge}while(x&&x!==L);return i}_checkEdgeForParallelLines(e,r,n,l,c,g){const u=e.left,v=e.right;if(f(m,r,u,v),t(m,r)<o.parallelLineThreshold)return;f(m,n,u,v,r);const{spatialReference:E,pointer:L}=c,x=a(i(m[0],m[1],n[2]));if(h(l,d(x,E,s,this.view))<this.squaredProximityThreshold(L)){if(this.isVertical(x,r)||this.isVertical(u,v))return;if(this._parallelToPreviousCandidate(e,g))return;g.push(new p({referenceLine:e,lineStart:r,targetPoint:x,isDraped:"on-the-ground"===c.elevationInfo?.mode}))}}_parallelToPreviousCandidate(e,r){const i=e.left,s=e.right;for(const n of r)if(f(m,s,n.constraint.start,n.constraint.end,i),t(m,s)<o.parallelLineThreshold)return n.addReferenceLine(e),!0;return!1}}const m=r();export{g as ParallelLineSnapper};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{unwrap as e}from"../../../core/maybe.js";import{a as t,h as i,v as
|
|
5
|
+
import{unwrap as e}from"../../../core/maybe.js";import{a as t,h as i,v as s,w as r}from"../../../chunks/vec2.js";import{a as o}from"../../../chunks/vec2f64.js";import{s as n,z as a}from"../../../chunks/vec3.js";import{a as p,c as h}from"../../../chunks/vec3f64.js";import{absoluteHeightElevationInfo as c}from"../../../support/elevationInfoUtils.js";import{SnappingAlgorithm as d}from"./SnappingAlgorithm.js";import{VerticalHalfPlaneConstraint as g}from"./SnappingConstraint.js";import{anyMapPointToSnappingPoint as f,asSnappingPoint as l}from"./SnappingPoint.js";import{squaredScreenDistance as m}from"./snappingUtils.js";import{RightAngleSnappingCandidate as x,OtherVertexType as v}from"./candidates/RightAngleSnappingCandidate.js";import{vectorToScreenPoint as E}from"../support/viewUtils.js";class V extends d{snapNewVertex(e,t){const i=t.editGeometryOperations.data.components[0],s=i.vertices.length,r=[];if(s<2)return r;const{view:o}=this,n=E(e,t.spatialReference,c,o),a=i.vertices[s-1];if(this.edgeExceedsShortLineThreshold(a.leftEdge,t)){const i=f(a.pos,o,t),s=f(a.leftEdge.leftVertex.pos,o,t);this._checkForSnappingCandidate(r,s,i,e,n,t)}const p=i.vertices[0];if(this.edgeExceedsShortLineThreshold(p.rightEdge,t)){const i=f(p.pos,o,t),s=f(p.rightEdge.rightVertex.pos,o,t);this._checkForSnappingCandidate(r,s,i,e,n,t)}return r}snapExistingVertex(t,i){const s=[],r=e(i.vertexHandle);if(r.component.vertices.length<3)return s;const{view:o}=this,n=E(t,i.spatialReference,c,o),a=r.leftEdge,p=r.rightEdge;if(a&&a.leftVertex.leftEdge){const e=a.leftVertex.leftEdge;if(this.edgeExceedsShortLineThreshold(e,i)){const r=f(e.rightVertex.pos,o,i),a=f(e.leftVertex.pos,o,i);this._checkForSnappingCandidate(s,a,r,t,n,i)}}if(p&&p.rightVertex.rightEdge){const e=p.rightVertex.rightEdge;if(this.edgeExceedsShortLineThreshold(e,i)){const r=f(e.leftVertex.pos,o,i),a=f(e.rightVertex.pos,o,i);this._checkForSnappingCandidate(s,a,r,t,n,i)}}return s}_checkForSnappingCandidate(e,o,d,f,V,j){const{spatialReference:k,pointer:w}=j;t(u,d,o);const C=n(S,u[1],-u[0],0),T=i(C,t(u,f,d))/s(C),F=l(r(p(f),d,C,T));if(m(V,E(F,k,c,this.view))<this.squaredProximityThreshold(w)){if(this.isVertical(F,d)||this.isVertical(d,o))return;const t=a(h(),d,C,Math.sign(T));e.push(new x({targetPoint:F,constraint:new g(d,l(t)),previousVertex:o,otherVertex:d,otherVertexType:v.CENTER,isDraped:"on-the-ground"===j.elevationInfo?.mode}))}}}const u=o(),S=h();export{V as RightAngleSnapper};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{unwrap as e}from"../../../core/maybe.js";import{l as t,d as
|
|
5
|
+
import{unwrap as e}from"../../../core/maybe.js";import{l as t,d as i}from"../../../chunks/vec2.js";import{a as s}from"../../../chunks/vec2f64.js";import{c as r}from"../../../chunks/vec3f64.js";import{absoluteHeightElevationInfo as o}from"../../../support/elevationInfoUtils.js";import{SnappingAlgorithm as n}from"./SnappingAlgorithm.js";import{anyMapPointToSnappingPoint as p,asSnappingPoint as a}from"./SnappingPoint.js";import{squaredScreenDistance as d}from"./snappingUtils.js";import{RightAngleTriangleSnappingCandidate as m}from"./candidates/RightAngleTriangleSnappingCandidate.js";import{vectorToScreenPoint as c}from"../support/viewUtils.js";import{projectPointToCircle as l}from"../../support/geometry2dUtils.js";class h extends n{snapNewVertex(e,t){const i=t.editGeometryOperations.data.components[0],s=[],r=i.vertices.length;if("polygon"!==t.editGeometryOperations.data.type||r<2)return s;const{view:o}=this,n=i.vertices[0],a=i.vertices[r-1],d=p(n.pos,o,t),m=p(a.pos,o,t);return this._processCandidateProposal(d,m,e,t,s),s}snapExistingVertex(t,i){const s=[],r=e(i.vertexHandle),o=r.component;if(o.edges.length<2)return s;if("polyline"===i.editGeometryOperations.data.type&&(0===r.index||r.index===o.vertices.length-1))return s;const{view:n}=this,a=p(r.leftEdge.leftVertex.pos,n,i),d=p(r.rightEdge.rightVertex.pos,n,i);return this._processCandidateProposal(a,d,t,i,s),s}_processCandidateProposal(e,s,n,p,h){if(!this.exceedsShortLineThreshold(e,s,p))return;const g=t(f,e,s,.5),u=.5*i(e,s),v=r();l(v,n,g,u),v[2]=n[2];const x=a(v),{spatialReference:j,pointer:y}=p,w=c(n,j,o,this.view);if(d(w,c(x,j,o,this.view))<this.squaredProximityThreshold(y)){if(this.isVertical(e,x)||this.isVertical(x,s))return;h.push(new m({targetPoint:x,point1:e,point2:s,isDraped:"on-the-ground"===p.elevationInfo?.mode}))}}}const f=s();export{h as RightAngleTriangleSnapper};
|