@arcgis/core 4.23.0-next.20220123 → 4.23.0-next.20220124
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/{5383a8f3e4ec1a8a4fcd.js → fe864d01e72aa24574b6.js} +1 -1
- package/assets/esri/themes/base/widgets/_FeatureTable.scss +6 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/dark-blue/main.css +1 -1
- package/assets/esri/themes/dark-green/main.css +1 -1
- package/assets/esri/themes/dark-purple/main.css +1 -1
- package/assets/esri/themes/dark-red/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/themes/light-blue/main.css +1 -1
- package/assets/esri/themes/light-green/main.css +1 -1
- package/assets/esri/themes/light-purple/main.css +1 -1
- package/assets/esri/themes/light-red/main.css +1 -1
- package/core/accessorSupport/ensureType.js +1 -1
- package/core/accessorSupport/get.js +1 -1
- package/core/accessorSupport/set.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/RenderGeometry.js +1 -1
- package/views/3d/webgl-engine/parts/Model.js +1 -1
- package/widgets/FeatureTable/Grid/Grid.js +1 -1
- package/widgets/FeatureTable.js +1 -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.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../has.js";import e from"../Logger.js";import{getOrCreateMapValue as n}from"../MapUtils.js";const r=e.getLogger("esri.core.Accessor");function t(e){return null==e?e:new Date(e)}function o(e){return null==e?e:!!e}function u(e){return null==e?e:e.toString()}function a(e){return null==e?e:(e=parseFloat(e),isNaN(e)?0:e)}function s(e){return null==e?e:Math.round(parseFloat(e))}function
|
|
5
|
+
import"../has.js";import e from"../Logger.js";import{getOrCreateMapValue as n}from"../MapUtils.js";const r=e.getLogger("esri.core.Accessor");function t(e){return null==e?e:new Date(e)}function o(e){return null==e?e:!!e}function u(e){return null==e?e:e.toString()}function a(e){return null==e?e:(e=parseFloat(e),isNaN(e)?0:e)}function s(e){return null==e?e:Math.round(parseFloat(e))}function i(e){return e&&e.constructor&&void 0!==e.constructor.__accessorMetadata__}function l(e,n){return null!=n&&e&&!(n instanceof e)}function c(e){return e&&"isCollection"in e}function f(e){return e&&e.Type?"function"==typeof e.Type?e.Type:e.Type.base:null}function p(e,n){if(!n||!n.constructor||!c(n.constructor))return y(e,n)?n:new e(n);const r=f(e.prototype.itemType),t=f(n.constructor.prototype.itemType);return r?t?r===t?n:r.prototype.isPrototypeOf(t.prototype)?new e(n):(y(e,n),n):new e(n):n}function y(e,n){return!!i(n)&&(r.error("Accessor#set","Assigning an instance of '"+(n.declaredClass||"unknown")+"' which is not a subclass of '"+g(e)+"'"),!0)}function v(e,n){return null==n?n:c(e)?p(e,n):l(e,n)?y(e,n)?n:new e(n):n}function g(e){return e&&e.prototype&&e.prototype.declaredClass||"unknown"}const d=new WeakMap;function h(e){switch(e){case Number:return a;case S:return s;case Boolean:return o;case String:return u;case Date:return t;default:return n(d,e,(()=>v.bind(null,e)))}}function b(e,n){const r=h(e);return 1===arguments.length?r:r(n)}function m(e,n,r){return 1===arguments.length?m.bind(null,e):n?Array.isArray(n)?n.map((n=>e(n,r))):[e(n,r)]:n}function w(e,n){return 1===arguments.length?m(b.bind(null,e)):m(b.bind(null,e),n)}function A(e,n,r){return 0!==n&&Array.isArray(r)?r.map((r=>A(e,n-1,r))):e(r)}function $(e,n,r){if(2===arguments.length)return $.bind(null,e,n);if(!r)return r;let t=n,o=r=A(e,n,r);for(;t>0&&Array.isArray(o);)t--,o=o[0];if(void 0!==o)for(let u=0;u<t;u++)r=[r];return r}function j(e,n,r){return 2===arguments.length?$(b.bind(null,e),n):$(b.bind(null,e),n,r)}function k(e){return!!Array.isArray(e)&&!e.some((n=>{const r=typeof n;return!("string"===r||"number"===r||"function"===r&&e.length>1)}))}function M(e,n){if(2===arguments.length)return M(e).call(null,n);const t=new Set,o=e.filter((e=>"function"!=typeof e)),u=e.filter((e=>"function"==typeof e));for(const r of e)"string"!=typeof r&&"number"!=typeof r||t.add(r);let a=null,s=null;return(e,n)=>{if(null==e)return e;const i=typeof e,c="string"===i||"number"===i;return c&&(t.has(e)||u.some((e=>"string"===i&&e===String||"number"===i&&e===Number)))||"object"===i&&u.some((n=>!l(e,n)))?e:(c&&o.length?(a||(a=o.map((e=>"string"==typeof e?`'${e}'`:`${e}`)).join(", ")),r.error("Accessor#set",`'${e}' is not a valid value for this property, only the following values are valid: ${a}`)):"object"==typeof e&&u.length?(s||(s=u.map((e=>g(e))).join(", ")),r.error("Accessor#set",`'${e}' is not a valid value for this property, value must be one of ${s}`)):r.error("Accessor#set",`'${e}' is not a valid value for this property`),n&&(n.valid=!1),null)}}function N(e,n){if(2===arguments.length)return N(e).call(null,n);const t={},o=[],u=[];for(const r in e.typeMap){const n=e.typeMap[r];t[r]=b(n),o.push(g(n)),u.push(r)}const a=()=>`'${o.join("', '")}'`,s=()=>`'${u.join("', '")}'`,c="string"==typeof e.key?n=>n[e.key]:e.key;return n=>{if(e.base&&!l(e.base,n))return n;if(null==n)return n;const o=c(n)||e.defaultKeyValue,u=t[o];if(!u)return r.error("Accessor#set",`Invalid property value, value needs to be one of ${a()}, or a plain object that can autocast (having .type = ${s()})`),null;if(!l(e.typeMap[o],n))return n;if("string"==typeof e.key&&!i(n)){const r={};for(const t in n)t!==e.key&&(r[t]=n[t]);return u(r)}return u(n)}}class S{}const T={native:e=>({type:"native",value:e}),array:e=>({type:"array",value:e}),oneOf:e=>({type:"one-of",values:e})};function _(e){if(!e||!("type"in e))return!1;switch(e.type){case"native":case"array":case"one-of":return!0}return!1}function B(e){switch(e.type){case"native":return b(e.value);case"array":return m(B(e.value));case"one-of":return C(e);default:return null}}function C(e){let n=null;return(t,o)=>F(t,e)?t:(null==n&&(n=D(e)),r.error("Accessor#set",`Invalid property value, value needs to be of type ${n}`),o&&(o.valid=!1),null)}function D(e){switch(e.type){case"native":switch(e.value){case Number:return"number";case String:return"string";case Boolean:return"boolean";case S:return"integer";case Date:return"date";default:return g(e.value)}case"array":return`array of ${D(e.value)}`;case"one-of":{const n=e.values.map((e=>D(e)));return`one of ${n.slice(0,n.length-1)} or ${n[n.length-1]}`}}return"unknown"}function F(e,n){if(null==e)return!0;switch(n.type){case"native":switch(n.value){case Number:case S:return"number"==typeof e;case Boolean:return"boolean"==typeof e;case String:return"string"==typeof e}return e instanceof n.value;case"array":return!!Array.isArray(e)&&!e.some((e=>!F(e,n.value)));case"one-of":return n.values.some((n=>F(e,n)))}}export{S as Integer,w as ensureArray,m as ensureArrayTyped,o as ensureBoolean,v as ensureClass,t as ensureDate,s as ensureInteger,B as ensureLongFormType,j as ensureNArray,$ as ensureNArrayTyped,a as ensureNumber,M as ensureOneOf,N as ensureOneOfType,u as ensureString,b as ensureType,i as isClassedType,_ as isLongFormType,k as isOneOf,l as requiresType,T as types};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{pathToArray as t,getProperties as n,isPropertyDeclared as r}from"./utils.js";function e(t,e){const i="?"===t[t.length-1]?t.slice(0,-1):t;if(null!=e.getItemAt||Array.isArray(e)){const t=parseInt(i,10);if(!isNaN(t))return Array.isArray(e)?e[t]:e.getItemAt(t)}const
|
|
5
|
+
import{pathToArray as t,getProperties as n,isPropertyDeclared as r}from"./utils.js";function e(t,e){const i="?"===t[t.length-1]?t.slice(0,-1):t;if(null!=e.getItemAt||Array.isArray(e)){const t=parseInt(i,10);if(!isNaN(t))return Array.isArray(e)?e[t]:e.getItemAt(t)}const o=n(e);return r(o,i)?o.get(i):e[i]}function i(t,n,r){if(null==t)return t;const o=e(n[r],t);return!o&&r<n.length-1?void 0:r===n.length-1?o:i(o,n,r+1)}function o(n,r,o=0){return"string"==typeof r&&-1===r.indexOf(".")?e(r,n):i(n,t(r),o)}function u(t,n){return o(t,n)}function s(t,n){return void 0!==o(n,t)}export{s as exists,u as get,o as valueOf};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import o from"../Error.js";import r from"../has.js";import t from"../Logger.js";import{get as e}from"./get.js";function n(o,r,t){if(o&&r)if("object"==typeof r)for(const e of Object.getOwnPropertyNames(r))n(o,e,r[e]);else{if(-1!==r.indexOf(".")){const s=r.split("."),i=s.splice(s.length-1,1)[0];return void n(e(o,s),i,t)}const i=o.__accessor__;null!=i&&s(r,i),o[r]=t}}function s(t,e){if(r("esri-unknown-property-errors")&&!i(t,e))throw new o("set:unknown-property",
|
|
5
|
+
import o from"../Error.js";import r from"../has.js";import t from"../Logger.js";import{get as e}from"./get.js";function n(o,r,t){if(o&&r)if("object"==typeof r)for(const e of Object.getOwnPropertyNames(r))n(o,e,r[e]);else{if(-1!==r.indexOf(".")){const s=r.split("."),i=s.splice(s.length-1,1)[0];return void n(e(o,s),i,t)}const i=o.__accessor__;null!=i&&s(r,i),o[r]=t}}function s(t,e){if(r("esri-unknown-property-errors")&&!i(t,e))throw new o("set:unknown-property",c(t,e))}function i(o,r){return null!=r.metadatas[o]}function c(o,r){return"setting unknown property '"+o+"' on instance of "+r.host.declaredClass}t.getLogger("esri.core.accessorSupport.set");export{n as set};
|
package/package.json
CHANGED
package/support/revision.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const b="
|
|
5
|
+
const b="20220124",c="7b2ac1e8f09dcfba456186b5eb5018fd2157106d";export{b as buildDate,c as commitHash};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import"../../../../symbols.js";import{result as t}from"../../../../core/asyncUtils.js";import r from"../../../../core/has.js";import i from"../../../../core/Error.js";import{isSome as s,get as a,isNone as o,releaseMaybe as n,unwrap as l}from"../../../../core/maybe.js";import{throwIfAbortError as c,throwIfAborted as h}from"../../../../core/promiseUtils.js";import{pt2px as m,px2pt as u}from"../../../../core/screenUtils.js";import{dataComponents as d,isSVG as _}from"../../../../core/urlUtils.js";import{c as p}from"../../../../chunks/mat4f64.js";import{f,a as y}from"../../../../chunks/vec2f64.js";import{Z as g,O as b,f as x}from"../../../../chunks/vec3f64.js";import{c as S}from"../../../../chunks/vec4.js";import{f as v,c as z}from"../../../../chunks/vec4f64.js";import{projectPointToVector as P}from"../../../../geometry/projection.js";import{containsPoint as R}from"../../../../geometry/support/aaBoundingBox.js";import{createRendererExpression as M}from"../../../../support/arcadeOnDemand.js";import{defaultPrimitive as C}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{getIconHref as w}from"../../../../symbols/support/utils.js";import j from"../../../2d/arcade/callExpressionWithFeature.js";import{TRANSPARENT_UNIT as I}from"./constants.js";import{perObjectElevationAligner as E}from"./ElevationAligners.js";import{SymbolUpdateType as O,elevationModeChangeUpdateType as T,needsElevationUpdates2D as L}from"./elevationAlignmentUtils.js";import{ElevationContext as D}from"./ElevationContext.js";import F from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as G}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as U}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as A,namedAnchorToHUDMaterialAnchorPos as V}from"./graphicUtils.js";import{ApplyRendererDiffResult as k}from"./interfaces.js";import{placePointOnGeometry as B,createStageObjectForHUD as N,extendPointGraphicElevationContext as q}from"./pointUtils.js";import{createTriangle as H,createX as W,createCross as Z,createKite as $,createSquare as J,createCircle as K}from"./sdfPrimitives.js";import{initFastSymbolUpdatesState as Q,updateFastSymbolUpdatesState as X,evaluateModelTransform as Y}from"../support/FastSymbolUpdates.js";import{DRAPED_Z as ee}from"../../terrain/OverlayRenderer.js";import{PowerOfTwoResizeMode as te}from"../../webgl-engine/lib/basicInterfaces.js";import re from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as ie}from"../../webgl-engine/lib/RenderGeometry.js";import{Texture as se}from"../../webgl-engine/lib/Texture.js";import{HUDMaterial as ae}from"../../webgl-engine/materials/HUDMaterial.js";import{TextureWrapMode as oe}from"../../../webgl/enums.js";import ne from"../../../../symbols/CIMSymbol.js";const le=p(),ce=x(0,0,1),he=16,me=1.5,ue=128,de=.5,_e=[de/2,de/2,1-de/2,1-de/2],pe=[ue*de,ue*de];class fe extends U{constructor(e,t,r,i){super(e,t,r,i),this._cimLayers=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimRequiredFields=null,this._cimScaleFactorOrFunction=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}getCachedSize(){return{size:this._getIconSize()}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),r=this._getPrimitive();if(s(r))this._prepareResourcesPrimitive(t,r);else{const r=w(this.symbol,this.symbolLayer),i=d(r);i&&"application/json"===i.mediaType?await this._prepareResourcesCIM(t,JSON.parse(i.data),e):await this._prepareResourcesHref(t,r,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=A(this._getIconSize());if(e)throw new i("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?m(e.size):he);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e){const t=this._getGraphicHash(e);let r=""===t?null:this._cimSymbolTextures.get(t);if(!r){const i={scaleFactor:this._cimScaleFactorOrFunction},s=this._context.sharedResources.cimSymbolRasterizer.rasterizeCIMSymbol(this._cimLayers,e,"esriGeometryPoint",i,null,null);this._cimMaterialParametersInfo.anchorPos=this._getAnchorPos("relative",s.anchorPosition);const a={width:s.imageData.width,height:s.imageData.height,powerOfTwoResizeMode:te.PAD};r=new se(s.imageData,a),this._cimSymbolTextures.set(t,r),this._context.stage.add(r)}return r}_computeSize(e,t){const r=e.width/e.height;return r>1?[t,Math.round(t/r)]:[Math.round(t*r),t]}_prepareMaterialParameters(){const e={anchorPos:this._getAnchorPos(this.symbolLayer.anchor,this.symbolLayer.anchorPosition)},t=this.symbol;if(ye(t)){const{screenLength:r,minWorldLength:i,maxWorldLength:s}=t.verticalOffset;e.verticalOffset={screenLength:m(r),minWorldLength:i||0,maxWorldLength:null!=s?s:1/0}}return this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),e.occlusionTest=!0,e.slicePlaneEnabled=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const r=this._getOutlineSize();if(ge(t)&&0===r)throw new Error("Nothing to render");this._outlineSize=r,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize;const i=this._context.sharedResources.textures.fromData(t,(()=>be(t)));this._texture=i.texture,this._releaseTexture=i,e.textureIsSignedDistanceField=!0,e.distanceFieldBoundingBox=_e,e.textureId=this._texture.id;const s=this._getIconSize();this._size=[s,s],this._symbolTextureRatio=1/de,this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesHref(e,s,a){if(!r("esri-canvas-svg-support")&&_(s)){throw new i("graphics3diconsymbollayer:unsupported-image-format","IconSymbol3DLayer failed to load (SVG symbols are not supported in IE11)")}this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),n=o*this._context.graphicsCoreOwner.view.pixelRatio,l=await t(this._context.sharedResources.textures.fromUrl(s,n,{signal:a}));if(!1===l.ok){c(l.error);throw new i("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${s})`)}this._releaseTexture=l.value;const h=l.value.texture,m=h.params;this._size=this._computeSize(m,o),e.textureId=h.id,this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesCIM(e,t,r){const i=new ne({data:t});if(!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;h(r),this._context.sharedResources.cimSymbolRasterizer||(this._context.sharedResources.cimSymbolRasterizer=new e(this._context.renderCoordsHelper.spatialReference,!0))}const s=this._context.layer.fields?this._context.layer.fields.map((e=>e.toJSON())):null;let a,o;if(this._cimLayers=await this._context.sharedResources.cimSymbolRasterizer.analyzeCIMSymbol(i,s,this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null,"esriGeometryPoint",{signal:r}),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(isNaN(e.scaleExpression)){const t=e.scaleExpression,r=await M(t,this._context.layer.spatialReference,s);o=(e,t,i)=>{const s=j(r,e,{$view:i},"esriGeometryPoint",t);return null!==s?s:1}}else a=Number(e.scaleExpression)}this._cimScaleFactorOrFunction=a||o||1;const n=this._context.renderer?await this._context.renderer.getRequiredFields(this._context.layer.fieldsIndex):[];h(r);const l=this._context.layer.fieldsIndex;this._cimRequiredFields=n.map((e=>l.get(e).name)),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return this.symbolLayer.resource&&this.symbolLayer.resource.href?null:this.symbolLayer.resource&&this.symbolLayer.resource.primitive||C}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(s(t.outline)&&null!=t.outline.size)return Math.max(m(t.outline.size),0);return e=ge(this._getPrimitive())?me:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),r=this.symbolLayer,i=a(r,"outline","color");if(s(i)){const r=e.toUnitRGB(i),s=i.a*t;return[r[0],r[1],r[2],s]}return[0,0,0,0]}_getFillColor(){if(ge(this._getPrimitive()))return I;const e=o(this._getPrimitive()),t=a(this.symbolLayer,"material","color");return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}_getAnchorPos(e,t){return"relative"===e?f((t.x||0)+.5,.5-(t.y||0)):e in V?V[e]:V.center}_createMaterialAndAddToStage(e,t){if(this._cimLayers?this._fastUpdates={enabled:!1}:this._fastUpdates=Q(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates.enabled&&Object.assign(e,this._fastUpdates.materialParameters),this._cimLayers){let r=this._cimSymbolMaterials.get(e.textureId);return r||(r=new ae(e),this._cimSymbolMaterials.set(e.textureId,r),t.add(r)),r}return this._material=new ae(e),t.add(this._material),this._material}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial((e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,slicePlaneEnabled:!1,shaderPolygonOffset:0,isDraped:this.draped})})),this.layerOpacityChanged())}destroy(){super.destroy(),this._forEachMaterial((e=>this._context.stage.remove(e))),this._material=null,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach((e=>this._context.stage.remove(e))),this._cimSymbolTextures.clear(),this._releaseTexture=n(this._releaseTexture)}_getScaleFactor(e,t){if(this._drivenProperties.size&&e.size){for(let t=0;t<3;t++){const r=e.size[t];r&&"symbol-value"!==r&&"proportional"!==r&&(e.size[t]=m(r))}if("symbol-value"===e.size[0])return 1;if(isFinite(+e.size[0]))return+e.size[0]/t;if(isFinite(+e.size[2]))return+e.size[2]/t}return 1}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;let r,i;if(this._cimLayers){if(!this._cimLayers.length)return null;const e=this._generateTextureCIM(t),s={textureId:e.id,...this._cimMaterialParametersInfo};i=this._createMaterialAndAddToStage(s,this._context.stage),r=[e.params.width,e.params.height]}else r=this._size,i=l(this._material);const s=B(t.geometry);if(o(s))return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const a=e.renderingInfo,n=this._getVertexOpacityAndColor(a);let c=1;if(!this._fastUpdates.enabled||!this._fastUpdates.visualVariables.size){const e=r[0]>r[1]?r[0]:r[1];c=this._getScaleFactor(a,e)}c*=this._symbolTextureRatio;const h=[r[0]*c,r[1]*c],m=this.setGraphicElevationContext(t,new D);return this.ensureDrapedStatus("on-the-ground"===m.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,s,i,n,h,e.layer.uid):this._createAs3DShape(t,s,i,n,h,m,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();return this._forEachMaterial((r=>{r.setParameters({color:e}),r.setParameters({outlineColor:t})})),!0}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=T(fe.elevationModeChangeTypes,r,i);if(s!==O.UPDATE)return s;const a=L(i)||"absolute-height"===i;return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>a))}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial((e=>{e.setParameters({slicePlaneEnabled:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!!this._getPrimitive()}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return k.Recreate_Symbol;if(!X(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return k.Recreate_Symbol;s(this._material)&&this._material.setParameters(this._fastUpdates.materialParameters)}return k.Fast_Update}_defaultElevationInfoNoZ(){return xe}_createAs3DShape(e,t,r,i,s,a,o){const n=this.getFastUpdateAttrValues(e),l=n?e=>Y(this._fastUpdates.materialParameters,n,e):null,c=[re.createPointGeometry(ce,null,i,s,Se,null,n)],h=N(this._context,t,c,[r],a,this._context.layer.uid,o,l);if(null===h)return null;const m=new G(this,h.object,c,null,null,E,a);return m.alignedSampledElevation=h.sampledElevation,m.needsElevationUpdates=L(a.mode)||"absolute-height"===a.mode,m.getScreenSize=this._createScreenSizeGetter(s,l),m.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(m.getScreenSize(),1,e),q(m,t,this._context.elevationProvider),m}_createAsOverlay(e,t,r,i,a,o){r.renderPriority=this._renderPriority;const n=z();P(t,n,this._context.overlaySR),n[2]=ee;const l=this._context.clippingExtent;if(s(l)&&!R(l,n))return null;const c=this.getFastUpdateAttrValues(e),h=c?e=>Y(this._fastUpdates.materialParameters,c,e):null,m=re.createPointGeometry(ce,n,i,a,null,null,c),u=new ie(m,r,o,e.uid);n[3]=0,S(u.boundingSphere,n),u.calculateShaderTransformation=h;const d=new F(this,[u],null);return d.getScreenSize=this._createScreenSizeGetter(a,h),d.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(d.getScreenSize(),1,e),d}_createScreenSizeGetter(e,t){const r=this._outlineSize+2;if(this._fastUpdates.enabled){const i=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=y())=>{const a=t(le);return e[0]=a[0]*i+r,e[1]=a[5]*s+r,e}}{const t=e[0]/this._symbolTextureRatio+r,i=e[1]/this._symbolTextureRatio+r;return(e=y())=>(e[0]=t,e[1]=i,e)}}_fastVisualVariableConvertOptions(){const e=this._size[0]>this._size[1]?this._size[0]:this._size[1],t=x(e,e,e),r=u(1),i=e*r;return{modelSize:t,symbolSize:x(i,i,i),unitInMeters:r,transformation:{anchor:g,scale:b,rotation:g}}}_getGraphicHash(e){let t="";for(const r of this._cimRequiredFields)t+=r+e.attributes[r];return t}_forEachMaterial(e){s(this._material)&&e(this._material),this._cimSymbolMaterials.forEach(e)}}function ye(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function ge(e){return!!s(e)&&("cross"===e||"x"===e)}function be(e){let t;const r=ue,i=r*de;switch(e){case"circle":t=K(r,i);break;case"square":t=J(r,i);break;case"kite":t=$(r,i);break;case"cross":t=Z(r,i);break;case"x":t=W(r,i);break;case"triangle":t=H(r,i)}return new se(t,{mipmap:!1,wrap:{s:oe.CLAMP_TO_EDGE,t:oe.CLAMP_TO_EDGE},width:ue,height:ue,components:4,noUnpackFlip:!0})}fe.PRIMITIVE_SIZE=pe,fe.elevationModeChangeTypes={definedChanged:O.UPDATE,staysOnTheGround:O.NONE,onTheGroundChanged:O.RECREATE};const xe={mode:"relative-to-ground",offset:0},Se=v(0,0,0,1);export{fe as Graphics3DIconSymbolLayer,fe as default};
|
|
5
|
+
import e from"../../../../Color.js";import"../../../../symbols.js";import{result as t}from"../../../../core/asyncUtils.js";import r from"../../../../core/has.js";import i from"../../../../core/Error.js";import{isSome as s,get as a,isNone as o,releaseMaybe as n,unwrap as l}from"../../../../core/maybe.js";import{throwIfAbortError as c,throwIfAborted as h}from"../../../../core/promiseUtils.js";import{pt2px as m,px2pt as u}from"../../../../core/screenUtils.js";import{dataComponents as d,isSVG as _}from"../../../../core/urlUtils.js";import{c as p}from"../../../../chunks/mat4f64.js";import{f,a as y}from"../../../../chunks/vec2f64.js";import{Z as g,O as b,f as x}from"../../../../chunks/vec3f64.js";import{c as S}from"../../../../chunks/vec4.js";import{f as v,c as z}from"../../../../chunks/vec4f64.js";import{projectPointToVector as P}from"../../../../geometry/projection.js";import{containsPoint as R}from"../../../../geometry/support/aaBoundingBox.js";import{createRendererExpression as M}from"../../../../support/arcadeOnDemand.js";import{defaultPrimitive as C}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{getIconHref as w}from"../../../../symbols/support/utils.js";import j from"../../../2d/arcade/callExpressionWithFeature.js";import{TRANSPARENT_UNIT as I}from"./constants.js";import{perObjectElevationAligner as E}from"./ElevationAligners.js";import{SymbolUpdateType as O,elevationModeChangeUpdateType as T,needsElevationUpdates2D as L}from"./elevationAlignmentUtils.js";import{ElevationContext as D}from"./ElevationContext.js";import U from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as F}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as G}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as A,namedAnchorToHUDMaterialAnchorPos as V}from"./graphicUtils.js";import{ApplyRendererDiffResult as k}from"./interfaces.js";import{placePointOnGeometry as B,createStageObjectForHUD as N,extendPointGraphicElevationContext as q}from"./pointUtils.js";import{createTriangle as H,createX as W,createCross as Z,createKite as $,createSquare as J,createCircle as K}from"./sdfPrimitives.js";import{initFastSymbolUpdatesState as Q,updateFastSymbolUpdatesState as X,evaluateModelTransform as Y}from"../support/FastSymbolUpdates.js";import{DRAPED_Z as ee}from"../../terrain/OverlayRenderer.js";import{PowerOfTwoResizeMode as te}from"../../webgl-engine/lib/basicInterfaces.js";import re from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as ie}from"../../webgl-engine/lib/RenderGeometry.js";import{Texture as se}from"../../webgl-engine/lib/Texture.js";import{HUDMaterial as ae}from"../../webgl-engine/materials/HUDMaterial.js";import{TextureWrapMode as oe}from"../../../webgl/enums.js";import ne from"../../../../symbols/CIMSymbol.js";const le=p(),ce=x(0,0,1),he=16,me=1.5,ue=128,de=.5,_e=[de/2,de/2,1-de/2,1-de/2],pe=[ue*de,ue*de];class fe extends G{constructor(e,t,r,i){super(e,t,r,i),this._cimLayers=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimRequiredFields=null,this._cimScaleFactorOrFunction=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}getCachedSize(){return{size:this._getIconSize()}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),r=this._getPrimitive();if(s(r))this._prepareResourcesPrimitive(t,r);else{const r=w(this.symbol,this.symbolLayer),i=d(r);i&&"application/json"===i.mediaType?await this._prepareResourcesCIM(t,JSON.parse(i.data),e):await this._prepareResourcesHref(t,r,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=A(this._getIconSize());if(e)throw new i("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?m(e.size):he);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e){const t=this._getGraphicHash(e);let r=""===t?null:this._cimSymbolTextures.get(t);if(!r){const i={scaleFactor:this._cimScaleFactorOrFunction},s=this._context.sharedResources.cimSymbolRasterizer.rasterizeCIMSymbol(this._cimLayers,e,"esriGeometryPoint",i,null,null);this._cimMaterialParametersInfo.anchorPos=this._getAnchorPos("relative",s.anchorPosition);const a={width:s.imageData.width,height:s.imageData.height,powerOfTwoResizeMode:te.PAD};r=new se(s.imageData,a),this._cimSymbolTextures.set(t,r),this._context.stage.add(r)}return r}_computeSize(e,t){const r=e.width/e.height;return r>1?[t,Math.round(t/r)]:[Math.round(t*r),t]}_prepareMaterialParameters(){const e={anchorPos:this._getAnchorPos(this.symbolLayer.anchor,this.symbolLayer.anchorPosition)},t=this.symbol;if(ye(t)){const{screenLength:r,minWorldLength:i,maxWorldLength:s}=t.verticalOffset;e.verticalOffset={screenLength:m(r),minWorldLength:i||0,maxWorldLength:null!=s?s:1/0}}return this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),e.occlusionTest=!0,e.slicePlaneEnabled=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const r=this._getOutlineSize();if(ge(t)&&0===r)throw new Error("Nothing to render");this._outlineSize=r,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize;const i=this._context.sharedResources.textures.fromData(t,(()=>be(t)));this._texture=i.texture,this._releaseTexture=i,e.textureIsSignedDistanceField=!0,e.distanceFieldBoundingBox=_e,e.textureId=this._texture.id;const s=this._getIconSize();this._size=[s,s],this._symbolTextureRatio=1/de,this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesHref(e,s,a){if(!r("esri-canvas-svg-support")&&_(s)){throw new i("graphics3diconsymbollayer:unsupported-image-format","IconSymbol3DLayer failed to load (SVG symbols are not supported in IE11)")}this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),n=o*this._context.graphicsCoreOwner.view.pixelRatio,l=await t(this._context.sharedResources.textures.fromUrl(s,n,{signal:a}));if(!1===l.ok){c(l.error);throw new i("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${s})`)}this._releaseTexture=l.value;const h=l.value.texture,m=h.params;this._size=this._computeSize(m,o),e.textureId=h.id,this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesCIM(e,t,r){const i=new ne({data:t});if(!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;h(r),this._context.sharedResources.cimSymbolRasterizer||(this._context.sharedResources.cimSymbolRasterizer=new e(this._context.renderCoordsHelper.spatialReference,!0))}const s=this._context.layer.fields?this._context.layer.fields.map((e=>e.toJSON())):null;let a,o;if(this._cimLayers=await this._context.sharedResources.cimSymbolRasterizer.analyzeCIMSymbol(i,s,this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null,"esriGeometryPoint",{signal:r}),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(isNaN(e.scaleExpression)){const t=e.scaleExpression,r=await M(t,this._context.layer.spatialReference,s);o=(e,t,i)=>{const s=j(r,e,{$view:i},"esriGeometryPoint",t);return null!==s?s:1}}else a=Number(e.scaleExpression)}this._cimScaleFactorOrFunction=a||o||1;const n=this._context.renderer?await this._context.renderer.getRequiredFields(this._context.layer.fieldsIndex):[];h(r);const l=this._context.layer.fieldsIndex;this._cimRequiredFields=n.map((e=>l.get(e).name)),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return this.symbolLayer.resource&&this.symbolLayer.resource.href?null:this.symbolLayer.resource&&this.symbolLayer.resource.primitive||C}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(s(t.outline)&&null!=t.outline.size)return Math.max(m(t.outline.size),0);return e=ge(this._getPrimitive())?me:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),r=this.symbolLayer,i=a(r,"outline","color");if(s(i)){const r=e.toUnitRGB(i),s=i.a*t;return[r[0],r[1],r[2],s]}return[0,0,0,0]}_getFillColor(){if(ge(this._getPrimitive()))return I;const e=o(this._getPrimitive()),t=a(this.symbolLayer,"material","color");return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}_getAnchorPos(e,t){return"relative"===e?f((t.x||0)+.5,.5-(t.y||0)):e in V?V[e]:V.center}_createMaterialAndAddToStage(e,t){if(this._cimLayers?this._fastUpdates={enabled:!1}:this._fastUpdates=Q(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates.enabled&&Object.assign(e,this._fastUpdates.materialParameters),this._cimLayers){let r=this._cimSymbolMaterials.get(e.textureId);return r||(r=new ae(e),this._cimSymbolMaterials.set(e.textureId,r),t.add(r)),r}return this._material=new ae(e),t.add(this._material),this._material}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial((e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,slicePlaneEnabled:!1,shaderPolygonOffset:0,isDraped:this.draped})})),this.layerOpacityChanged())}destroy(){super.destroy(),this._forEachMaterial((e=>this._context.stage.remove(e))),this._material=null,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach((e=>this._context.stage.remove(e))),this._cimSymbolTextures.clear(),this._releaseTexture=n(this._releaseTexture)}_getScaleFactor(e,t){if(this._drivenProperties.size&&e.size){for(let t=0;t<3;t++){const r=e.size[t];r&&"symbol-value"!==r&&"proportional"!==r&&(e.size[t]=m(r))}if("symbol-value"===e.size[0])return 1;if(isFinite(+e.size[0]))return+e.size[0]/t;if(isFinite(+e.size[2]))return+e.size[2]/t}return 1}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;let r,i;if(this._cimLayers){if(!this._cimLayers.length)return null;const e=this._generateTextureCIM(t),s={textureId:e.id,...this._cimMaterialParametersInfo};i=this._createMaterialAndAddToStage(s,this._context.stage),r=[e.params.width,e.params.height]}else r=this._size,i=l(this._material);const s=B(t.geometry);if(o(s))return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const a=e.renderingInfo,n=this._getVertexOpacityAndColor(a);let c=1;if(!this._fastUpdates.enabled||!this._fastUpdates.visualVariables.size){const e=r[0]>r[1]?r[0]:r[1];c=this._getScaleFactor(a,e)}c*=this._symbolTextureRatio;const h=[r[0]*c,r[1]*c],m=this.setGraphicElevationContext(t,new D);return this.ensureDrapedStatus("on-the-ground"===m.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,s,i,n,h,e.layer.uid):this._createAs3DShape(t,s,i,n,h,m,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();return this._forEachMaterial((r=>{r.setParameters({color:e}),r.setParameters({outlineColor:t})})),!0}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=T(fe.elevationModeChangeTypes,r,i);if(s!==O.UPDATE)return s;const a=L(i)||"absolute-height"===i;return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>a))}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial((e=>{e.setParameters({slicePlaneEnabled:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!!this._getPrimitive()}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return k.Recreate_Symbol;if(!X(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return k.Recreate_Symbol;s(this._material)&&this._material.setParameters(this._fastUpdates.materialParameters)}return k.Fast_Update}_defaultElevationInfoNoZ(){return xe}_createAs3DShape(e,t,r,i,s,a,o){const n=this.getFastUpdateAttrValues(e),l=n?e=>Y(this._fastUpdates.materialParameters,n,e):null,c=[re.createPointGeometry(ce,null,i,s,Se,null,n)],h=N(this._context,t,c,[r],a,this._context.layer.uid,o,l);if(null===h)return null;const m=new F(this,h.object,c,null,null,E,a);return m.alignedSampledElevation=h.sampledElevation,m.needsElevationUpdates=L(a.mode)||"absolute-height"===a.mode,m.getScreenSize=this._createScreenSizeGetter(s,l),m.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(m.getScreenSize(),1,e),q(m,t,this._context.elevationProvider),m}_createAsOverlay(e,t,r,i,a,o){r.renderPriority=this._renderPriority;const n=z();P(t,n,this._context.overlaySR),n[2]=ee;const l=this._context.clippingExtent;if(s(l)&&!R(l,n))return null;const c=this.getFastUpdateAttrValues(e),h=c?e=>Y(this._fastUpdates.materialParameters,c,e):null,m=re.createPointGeometry(ce,n,i,a,null,null,c),u=new ie(m,r,{layerUid:o,graphicUid:e.uid,calculateShaderTransformation:h});n[3]=0,S(u.boundingSphere,n);const d=new U(this,[u],null);return d.getScreenSize=this._createScreenSizeGetter(a,h),d.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(d.getScreenSize(),1,e),d}_createScreenSizeGetter(e,t){const r=this._outlineSize+2;if(this._fastUpdates.enabled){const i=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=y())=>{const a=t(le);return e[0]=a[0]*i+r,e[1]=a[5]*s+r,e}}{const t=e[0]/this._symbolTextureRatio+r,i=e[1]/this._symbolTextureRatio+r;return(e=y())=>(e[0]=t,e[1]=i,e)}}_fastVisualVariableConvertOptions(){const e=this._size[0]>this._size[1]?this._size[0]:this._size[1],t=x(e,e,e),r=u(1),i=e*r;return{modelSize:t,symbolSize:x(i,i,i),unitInMeters:r,transformation:{anchor:g,scale:b,rotation:g}}}_getGraphicHash(e){let t="";for(const r of this._cimRequiredFields)t+=r+e.attributes[r];return t}_forEachMaterial(e){s(this._material)&&e(this._material),this._cimSymbolMaterials.forEach(e)}}function ye(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function ge(e){return!!s(e)&&("cross"===e||"x"===e)}function be(e){let t;const r=ue,i=r*de;switch(e){case"circle":t=K(r,i);break;case"square":t=J(r,i);break;case"kite":t=$(r,i);break;case"cross":t=Z(r,i);break;case"x":t=W(r,i);break;case"triangle":t=H(r,i)}return new se(t,{mipmap:!1,wrap:{s:oe.CLAMP_TO_EDGE,t:oe.CLAMP_TO_EDGE},width:ue,height:ue,components:4,noUnpackFlip:!0})}fe.PRIMITIVE_SIZE=pe,fe.elevationModeChangeTypes={definedChanged:O.UPDATE,staysOnTheGround:O.NONE,onTheGroundChanged:O.RECREATE};const xe={mode:"relative-to-ground",offset:0},Se=v(0,0,0,1);export{fe as Graphics3DIconSymbolLayer,fe as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../../geometry.js";import e from"../../../../core/Error.js";import{get as t,isNone as i,isSome as r}from"../../../../core/maybe.js";import{px2pt as a,pt2px as s}from"../../../../core/screenUtils.js";import{I as n}from"../../../../chunks/mat4f64.js";import{s as o}from"../../../../chunks/vec4.js";import{f as l}from"../../../../chunks/vec4f64.js";import{create as h,empty as p,expandWithBuffer as m,intersectsClippingArea as c,expandWithAABB as d}from"../../../../geometry/support/aaBoundingBox.js";import{getDriverAxisSizeValueAny as y}from"../../../../renderers/support/renderingInfoUtils.js";import{perVertexElevationAligner as _}from"./ElevationAligners.js";import{SymbolUpdateType as g,elevationModeChangeUpdateType as u,needsElevationUpdates2D as f}from"./elevationAlignmentUtils.js";import{ElevationContext as b}from"./ElevationContext.js";import E from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as v}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as M,getAttributeValue as w}from"./Graphics3DSymbolLayer.js";import{ApplyRendererDiffResult as P}from"./interfaces.js";import{parseCapType as D,geometryToRenderInfo as L,RemoveDuplicateStartEnd as R,createGeometry as x,geometryToRenderInfoDraped as A}from"./lineUtils.js";import{initFastSymbolUpdatesState as S,updateFastSymbolUpdatesState as U}from"../support/FastSymbolUpdates.js";import C from"../../support/debugFlags.js";import{Object3D as j}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as z}from"../../webgl-engine/lib/RenderGeometry.js";import{getStipplePatternForLinePattern as G}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as O}from"../../webgl-engine/materials/RibbonLineMaterial.js";import V from"../../../../geometry/Extent.js";import F from"../../../../geometry/Polygon.js";const I=["polyline","polygon","extent"];class T extends M{constructor(e,t,i,r){super(e,t,i,r),this._uniformSize=1}async doLoad(){if(this._vvConvertOptions={modelSize:[1,1,1],symbolSize:[1,1,1],unitInMeters:1,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=S(this._context.renderer,this._vvConvertOptions):this._fastUpdates={enabled:!1},!this._drivenProperties.size){const t=null!=this.symbolLayer.size?this.symbolLayer.size:a(1);if(t<0)throw new e("graphics3dlinesymbollayer:invalid-size","Symbol sizes may not be negative values");this._uniformSize=t}}_getMaterialParameters(e){const i=t(this.symbolLayer,"material","color"),r=this._getCombinedOpacityAndColor(i);this._patternHidesLine&&(r[3]=0);const n=r[3],o={width:1,color:r,polygonOffset:!0,join:this.symbolLayer.join||"miter",cap:D(this.symbolLayer.cap||"butt"),transparent:n<1||this.needsDrivenTransparentPass,slicePlaneEnabled:this._context.slicePlaneEnabled,isClosed:e,stipplePattern:G(this.symbolLayer.pattern),stippleScaleWithLineWidth:!0};if(this._drivenProperties.size)this._fastUpdates.enabled&&this._fastUpdates.visualVariables.size&&(o.width=s(1));else{const e=null!=this.symbolLayer.size?this.symbolLayer.size:a(1);o.width=s(e)}return this._fastUpdates&&this._fastUpdates.visualVariables?{...o,...this._fastUpdates.materialParameters}:o}get lineMaterial(){return i(this._lineMaterial)&&(this._lineMaterial=new O(this._getMaterialParameters(!1)),this._context.stage.add(this._lineMaterial)),this._lineMaterial}get ringMaterial(){return i(this._ringMaterial)&&(this._ringMaterial=new O(this._getMaterialParameters(!0)),this._context.stage.add(this._ringMaterial)),this._ringMaterial}get wireframeLineMaterial(){return i(this._wireframeLineMaterial)&&(this._wireframeLineMaterial=new O({...this._getMaterialParameters(!1),wireframe:!0}),this._context.stage.add(this._wireframeLineMaterial)),this._wireframeLineMaterial}get wireframeRingMaterial(){return i(this._wireframeRingMaterial)&&(this._wireframeRingMaterial=new O({...this._getMaterialParameters(!0),wireframe:!0}),this._context.stage.add(this._wireframeRingMaterial)),this._wireframeRingMaterial}destroy(){super.destroy(),this._forEachMaterial((e=>this._context.stage.remove(e))),this._lineMaterial=null,this._ringMaterial=null,this._wireframeLineMaterial=null,this._wireframeRingMaterial=null}_getDrivenSize(e){return this._drivenProperties.size&&e.size?s(y(e.size)):1}_getSizeFeatureAttributeData(e){return this._fastUpdates.enabled&&this._fastUpdates.visualVariables.size?w(this._fastUpdates.visualVariables.size.field,e):null}_getDrivenColor(e){const t=l(1,1,1,1);return this._drivenProperties.color&&e.color&&(t[0]=e.color[0],t[1]=e.color[1],t[2]=e.color[2],e.color.length>0&&(t[3]=e.color[3])),this._drivenProperties.opacity&&e.opacity&&(t[3]=e.opacity),t}_getColorFeatureAttributeData(e){return this._fastUpdates.enabled&&this._fastUpdates.visualVariables.color?w(this._fastUpdates.visualVariables.color.field,e):null}_getOpacityFeatureAttributeData(e){return this._fastUpdates.enabled&&this._fastUpdates.visualVariables.opacity?w(this._fastUpdates.visualVariables.opacity.field,e):null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,I,this.symbolLayer.type))return null;const i=this.setGraphicElevationContext(t,new b);return this.ensureDrapedStatus("on-the-ground"===i.mode),this.draped?this._createAsOverlay(e,this._context.layer.uid):this._createAs3DShape(e,i,t.uid)}applyRendererDiff(e,t){for(const i in e.diff){if("visualVariables"!==i)return P.Recreate_Symbol;if(!U(this._fastUpdates,t,this._vvConvertOptions))return P.Recreate_Symbol;this._forEachMaterial((e=>e.setParameters(this._fastUpdates.materialParameters)))}return P.Fast_Update}layerOpacityChanged(){return this._forEachMaterial((e=>this._updateMaterialLayerOpacity(e))),!0}_forEachMaterial(e){r(this._lineMaterial)&&e(this._lineMaterial),r(this._ringMaterial)&&e(this._ringMaterial),r(this._wireframeLineMaterial)&&e(this._wireframeLineMaterial),r(this._wireframeRingMaterial)&&e(this._wireframeRingMaterial)}_updateMaterialLayerOpacity(e){const i=e.parameters.color,r=t(this.symbolLayer,"material","color"),a=this._patternHidesLine?0:this._getCombinedOpacity(r),s=a<1||this.needsDrivenTransparentPass,n=[i[0],i[1],i[2],a];e.setParameters({color:n,transparent:s})}layerElevationInfoChanged(e,t,i){const r=this._elevationContext.mode,a=u(T.elevationModeChangeTypes,i,r);if(a!==g.UPDATE)return a;const s=f(r);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>s))}slicePlaneEnabledChanged(){const e={slicePlaneEnabled:this._context.slicePlaneEnabled};return this._forEachMaterial((t=>t.setParameters(e))),!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!0}_getGeometryAsPolygonOrPolyline(e){switch(e.type){case"extent":if(e instanceof V)return F.fromExtent(e);break;case"polygon":case"polyline":return e}return null}_createAs3DShape(e,t,i){const a=e.graphic,s=this._getGeometryAsPolygonOrPolyline(a.geometry),o="polygon"===s.type?s.rings:s.paths,l=new Array,d=new Array,y=new Array,g=h(),u=L(s,this._context.elevationProvider,this._context.renderCoordsHelper,t),b="polygon"===s.type?"rings":"paths";this._logGeometryCreationWarnings(u,o,b,"LineSymbol3DLayer");for(let h=0;h<u.lines.length;h++){const{position:t,mapPosition:i}=u.lines[h];r(this._context.clippingExtent)&&(p(g),m(g,i),!c(g,this._context.clippingExtent))||(l.push(this._createGeometry(e,t,i,s.type,W.ELEVATED)),d.push("polygon"===s.type?this.ringMaterial:this.lineMaterial),y.push(n),C.LINE_WIREFRAMES&&(l.push(this._createGeometry(e,t,i,s.type,W.ELEVATED)),d.push("polygon"===s.type?this.wireframeRingMaterial:this.wireframeLineMaterial),y.push(n)))}if(0===l.length)return null;const E=new j({geometries:l,materials:d,transformations:y,castShadow:!1,metadata:{layerUid:this._context.layer.uid,graphicUid:i}}),M=new v(this,E,l,null,null,_,t);return M.alignedSampledElevation=u.sampledElevation,M.needsElevationUpdates=f(t.mode),M}_createGeometry(e,t,i,r,a){const s="polygon"===r?R.REMOVE:R.KEEP,n=this._fastUpdates.enabled&&this._fastUpdates.visualVariables.color,o=this._fastUpdates.enabled&&this._fastUpdates.visualVariables.size;return x({overlayInfo:a===W.DRAPED?{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper}:null,removeDuplicateStartEnd:s,uniformSize:this._uniformSize,attributeData:{position:t,mapPosition:i,size:o?null:this._getDrivenSize(e.renderingInfo),color:n?null:this._getDrivenColor(e.renderingInfo),sizeFeature:this._getSizeFeatureAttributeData(e.graphic),colorFeature:this._getColorFeatureAttributeData(e.graphic),opacityFeature:this._getOpacityFeatureAttributeData(e.graphic)}})}_createAsOverlay(e,t){const i=e.graphic,r=this._getGeometryAsPolygonOrPolyline(i.geometry),a="polygon"===r.type?r.rings:r.paths,s="polygon"===r.type?this.ringMaterial:this.lineMaterial;s.renderPriority=this._renderPriority;const n=C.LINE_WIREFRAMES?"polygon"===r.type?this.wireframeRingMaterial:this.wireframeLineMaterial:null;n&&(n.renderPriority=this._renderPriority-.001);const o=new Array,l=h(),y=p(),_=A(r,this._context.overlaySR),g="polygon"===r.type?"rings":"paths";this._logGeometryCreationWarnings(_,a,g,"LineSymbol3DLayer");for(const h of _.lines){if(p(l),m(l,h.position),!c(l,this._context.clippingExtent))continue;d(y,l);const a=new z(this._createGeometry(e,h.position,null,r.type,W.DRAPED),s,t,i.uid);if(this._updateBoundingSphere(a,l),o.push(a),C.LINE_WIREFRAMES){const a=new z(this._createGeometry(e,h.position,null,r.type,W.DRAPED),n,t,i.uid);this._updateBoundingSphere(a,l),o.push(a)}}return new E(this,o,y)}_updateBoundingSphere(e,t){o(e.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])))}get _patternHidesLine(){const e=this.symbolLayer.pattern;return r(e)&&"style"===e.type&&"none"===e.style}}var W;T.elevationModeChangeTypes={definedChanged:g.RECREATE,staysOnTheGround:g.NONE,onTheGroundChanged:g.RECREATE},function(e){e[e.DRAPED=0]="DRAPED",e[e.ELEVATED=1]="ELEVATED"}(W||(W={}));export{T as Graphics3DLineSymbolLayer,T as default};
|
|
5
|
+
import"../../../../geometry.js";import e from"../../../../core/Error.js";import{get as t,isNone as i,isSome as r}from"../../../../core/maybe.js";import{px2pt as a,pt2px as s}from"../../../../core/screenUtils.js";import{I as n}from"../../../../chunks/mat4f64.js";import{s as o}from"../../../../chunks/vec4.js";import{f as l}from"../../../../chunks/vec4f64.js";import{create as h,empty as p,expandWithBuffer as c,intersectsClippingArea as m,expandWithAABB as d}from"../../../../geometry/support/aaBoundingBox.js";import{getDriverAxisSizeValueAny as y}from"../../../../renderers/support/renderingInfoUtils.js";import{perVertexElevationAligner as _}from"./ElevationAligners.js";import{SymbolUpdateType as g,elevationModeChangeUpdateType as u,needsElevationUpdates2D as f}from"./elevationAlignmentUtils.js";import{ElevationContext as b}from"./ElevationContext.js";import E from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as v}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as M,getAttributeValue as w}from"./Graphics3DSymbolLayer.js";import{ApplyRendererDiffResult as P}from"./interfaces.js";import{parseCapType as D,geometryToRenderInfo as L,RemoveDuplicateStartEnd as U,createGeometry as R,geometryToRenderInfoDraped as x}from"./lineUtils.js";import{initFastSymbolUpdatesState as A,updateFastSymbolUpdatesState as S}from"../support/FastSymbolUpdates.js";import C from"../../support/debugFlags.js";import{Object3D as j}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as z}from"../../webgl-engine/lib/RenderGeometry.js";import{getStipplePatternForLinePattern as G}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as O}from"../../webgl-engine/materials/RibbonLineMaterial.js";import V from"../../../../geometry/Extent.js";import F from"../../../../geometry/Polygon.js";const I=["polyline","polygon","extent"];class T extends M{constructor(e,t,i,r){super(e,t,i,r),this._uniformSize=1}async doLoad(){if(this._vvConvertOptions={modelSize:[1,1,1],symbolSize:[1,1,1],unitInMeters:1,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=A(this._context.renderer,this._vvConvertOptions):this._fastUpdates={enabled:!1},!this._drivenProperties.size){const t=null!=this.symbolLayer.size?this.symbolLayer.size:a(1);if(t<0)throw new e("graphics3dlinesymbollayer:invalid-size","Symbol sizes may not be negative values");this._uniformSize=t}}_getMaterialParameters(e){const i=t(this.symbolLayer,"material","color"),r=this._getCombinedOpacityAndColor(i);this._patternHidesLine&&(r[3]=0);const n=r[3],o={width:1,color:r,polygonOffset:!0,join:this.symbolLayer.join||"miter",cap:D(this.symbolLayer.cap||"butt"),transparent:n<1||this.needsDrivenTransparentPass,slicePlaneEnabled:this._context.slicePlaneEnabled,isClosed:e,stipplePattern:G(this.symbolLayer.pattern),stippleScaleWithLineWidth:!0};if(this._drivenProperties.size)this._fastUpdates.enabled&&this._fastUpdates.visualVariables.size&&(o.width=s(1));else{const e=null!=this.symbolLayer.size?this.symbolLayer.size:a(1);o.width=s(e)}return this._fastUpdates&&this._fastUpdates.visualVariables?{...o,...this._fastUpdates.materialParameters}:o}get lineMaterial(){return i(this._lineMaterial)&&(this._lineMaterial=new O(this._getMaterialParameters(!1)),this._context.stage.add(this._lineMaterial)),this._lineMaterial}get ringMaterial(){return i(this._ringMaterial)&&(this._ringMaterial=new O(this._getMaterialParameters(!0)),this._context.stage.add(this._ringMaterial)),this._ringMaterial}get wireframeLineMaterial(){return i(this._wireframeLineMaterial)&&(this._wireframeLineMaterial=new O({...this._getMaterialParameters(!1),wireframe:!0}),this._context.stage.add(this._wireframeLineMaterial)),this._wireframeLineMaterial}get wireframeRingMaterial(){return i(this._wireframeRingMaterial)&&(this._wireframeRingMaterial=new O({...this._getMaterialParameters(!0),wireframe:!0}),this._context.stage.add(this._wireframeRingMaterial)),this._wireframeRingMaterial}destroy(){super.destroy(),this._forEachMaterial((e=>this._context.stage.remove(e))),this._lineMaterial=null,this._ringMaterial=null,this._wireframeLineMaterial=null,this._wireframeRingMaterial=null}_getDrivenSize(e){return this._drivenProperties.size&&e.size?s(y(e.size)):1}_getSizeFeatureAttributeData(e){return this._fastUpdates.enabled&&this._fastUpdates.visualVariables.size?w(this._fastUpdates.visualVariables.size.field,e):null}_getDrivenColor(e){const t=l(1,1,1,1);return this._drivenProperties.color&&e.color&&(t[0]=e.color[0],t[1]=e.color[1],t[2]=e.color[2],e.color.length>0&&(t[3]=e.color[3])),this._drivenProperties.opacity&&e.opacity&&(t[3]=e.opacity),t}_getColorFeatureAttributeData(e){return this._fastUpdates.enabled&&this._fastUpdates.visualVariables.color?w(this._fastUpdates.visualVariables.color.field,e):null}_getOpacityFeatureAttributeData(e){return this._fastUpdates.enabled&&this._fastUpdates.visualVariables.opacity?w(this._fastUpdates.visualVariables.opacity.field,e):null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,I,this.symbolLayer.type))return null;const i=this.setGraphicElevationContext(t,new b);return this.ensureDrapedStatus("on-the-ground"===i.mode),this.draped?this._createAsOverlay(e,this._context.layer.uid):this._createAs3DShape(e,i,t.uid)}applyRendererDiff(e,t){for(const i in e.diff){if("visualVariables"!==i)return P.Recreate_Symbol;if(!S(this._fastUpdates,t,this._vvConvertOptions))return P.Recreate_Symbol;this._forEachMaterial((e=>e.setParameters(this._fastUpdates.materialParameters)))}return P.Fast_Update}layerOpacityChanged(){return this._forEachMaterial((e=>this._updateMaterialLayerOpacity(e))),!0}_forEachMaterial(e){r(this._lineMaterial)&&e(this._lineMaterial),r(this._ringMaterial)&&e(this._ringMaterial),r(this._wireframeLineMaterial)&&e(this._wireframeLineMaterial),r(this._wireframeRingMaterial)&&e(this._wireframeRingMaterial)}_updateMaterialLayerOpacity(e){const i=e.parameters.color,r=t(this.symbolLayer,"material","color"),a=this._patternHidesLine?0:this._getCombinedOpacity(r),s=a<1||this.needsDrivenTransparentPass,n=[i[0],i[1],i[2],a];e.setParameters({color:n,transparent:s})}layerElevationInfoChanged(e,t,i){const r=this._elevationContext.mode,a=u(T.elevationModeChangeTypes,i,r);if(a!==g.UPDATE)return a;const s=f(r);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>s))}slicePlaneEnabledChanged(){const e={slicePlaneEnabled:this._context.slicePlaneEnabled};return this._forEachMaterial((t=>t.setParameters(e))),!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!0}_getGeometryAsPolygonOrPolyline(e){switch(e.type){case"extent":if(e instanceof V)return F.fromExtent(e);break;case"polygon":case"polyline":return e}return null}_createAs3DShape(e,t,i){const a=e.graphic,s=this._getGeometryAsPolygonOrPolyline(a.geometry),o="polygon"===s.type?s.rings:s.paths,l=new Array,d=new Array,y=new Array,g=h(),u=L(s,this._context.elevationProvider,this._context.renderCoordsHelper,t),b="polygon"===s.type?"rings":"paths";this._logGeometryCreationWarnings(u,o,b,"LineSymbol3DLayer");for(let h=0;h<u.lines.length;h++){const{position:t,mapPosition:i}=u.lines[h];r(this._context.clippingExtent)&&(p(g),c(g,i),!m(g,this._context.clippingExtent))||(l.push(this._createGeometry(e,t,i,s.type,W.ELEVATED)),d.push("polygon"===s.type?this.ringMaterial:this.lineMaterial),y.push(n),C.LINE_WIREFRAMES&&(l.push(this._createGeometry(e,t,i,s.type,W.ELEVATED)),d.push("polygon"===s.type?this.wireframeRingMaterial:this.wireframeLineMaterial),y.push(n)))}if(0===l.length)return null;const E=new j({geometries:l,materials:d,transformations:y,castShadow:!1,metadata:{layerUid:this._context.layer.uid,graphicUid:i}}),M=new v(this,E,l,null,null,_,t);return M.alignedSampledElevation=u.sampledElevation,M.needsElevationUpdates=f(t.mode),M}_createGeometry(e,t,i,r,a){const s="polygon"===r?U.REMOVE:U.KEEP,n=this._fastUpdates.enabled&&this._fastUpdates.visualVariables.color,o=this._fastUpdates.enabled&&this._fastUpdates.visualVariables.size;return R({overlayInfo:a===W.DRAPED?{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper}:null,removeDuplicateStartEnd:s,uniformSize:this._uniformSize,attributeData:{position:t,mapPosition:i,size:o?null:this._getDrivenSize(e.renderingInfo),color:n?null:this._getDrivenColor(e.renderingInfo),sizeFeature:this._getSizeFeatureAttributeData(e.graphic),colorFeature:this._getColorFeatureAttributeData(e.graphic),opacityFeature:this._getOpacityFeatureAttributeData(e.graphic)}})}_createAsOverlay(e,t){const i=e.graphic,r=this._getGeometryAsPolygonOrPolyline(i.geometry),a="polygon"===r.type?r.rings:r.paths,s="polygon"===r.type?this.ringMaterial:this.lineMaterial;s.renderPriority=this._renderPriority;const n=C.LINE_WIREFRAMES?"polygon"===r.type?this.wireframeRingMaterial:this.wireframeLineMaterial:null;n&&(n.renderPriority=this._renderPriority-.001);const o=new Array,l=h(),y=p(),_=x(r,this._context.overlaySR),g="polygon"===r.type?"rings":"paths";this._logGeometryCreationWarnings(_,a,g,"LineSymbol3DLayer");for(const h of _.lines){if(p(l),c(l,h.position),!m(l,this._context.clippingExtent))continue;d(y,l);const a=new z(this._createGeometry(e,h.position,null,r.type,W.DRAPED),s,{layerUid:t,graphicUid:i.uid});if(this._updateBoundingSphere(a,l),o.push(a),C.LINE_WIREFRAMES){const a=new z(this._createGeometry(e,h.position,null,r.type,W.DRAPED),n,{layerUid:t,graphicUid:i.uid});this._updateBoundingSphere(a,l),o.push(a)}}return new E(this,o,y)}_updateBoundingSphere(e,t){o(e.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])))}get _patternHidesLine(){const e=this.symbolLayer.pattern;return r(e)&&"style"===e.type&&"none"===e.style}}var W;T.elevationModeChangeTypes={definedChanged:g.RECREATE,staysOnTheGround:g.NONE,onTheGroundChanged:g.RECREATE},function(e){e[e.DRAPED=0]="DRAPED",e[e.ELEVATED=1]="ELEVATED"}(W||(W={}));export{T as Graphics3DLineSymbolLayer,T as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/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 a}from"../../../../chunks/earcut.js";import{I as s}from"../../../../chunks/mat4f64.js";import{s as l}from"../../../../chunks/vec4.js";import{create as u,empty as c,expandWithBuffer as p,intersectsClippingArea as h,expandWithAABB as d}from"../../../../geometry/support/aaBoundingBox.js";import{BufferViewMat3f64 as m,BufferViewVec3f64 as _,BufferViewVec4f as y}from"../../../../geometry/support/buffer/BufferView.js";import{SymbolUpdateType as g,elevationModeChangeUpdateType as f,needsElevationUpdates2D as b}from"./elevationAlignmentUtils.js";import{ElevationContext as v}from"./ElevationContext.js";import E from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as M}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as x}from"./Graphics3DSymbolLayer.js";import{mixinColorAndOpacity as O}from"./graphicUtils.js";import{parseCapType as D,createGeometry as S,RemoveDuplicateStartEnd as A}from"./lineUtils.js";import{geometryAsPolygon 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 a}from"../../../../chunks/earcut.js";import{I as s}from"../../../../chunks/mat4f64.js";import{s as l}from"../../../../chunks/vec4.js";import{create as u,empty as c,expandWithBuffer as p,intersectsClippingArea as h,expandWithAABB as d}from"../../../../geometry/support/aaBoundingBox.js";import{BufferViewMat3f64 as m,BufferViewVec3f64 as _,BufferViewVec4f as y}from"../../../../geometry/support/buffer/BufferView.js";import{SymbolUpdateType as g,elevationModeChangeUpdateType as f,needsElevationUpdates2D as b}from"./elevationAlignmentUtils.js";import{ElevationContext as v}from"./ElevationContext.js";import E from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as M}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as x}from"./Graphics3DSymbolLayer.js";import{mixinColorAndOpacity as O}from"./graphicUtils.js";import{parseCapType as D,createGeometry as S,RemoveDuplicateStartEnd as A}from"./lineUtils.js";import{geometryAsPolygon as U,geometryToRenderInfo as P,createColorGeometry as C,geometryToRenderInfoDraped as w}from"./polygonUtils.js";import{createMaterial as G,uvElevationAligner as T}from"../support/patternUtils.js";import{createMapSpaceUVCoords as j,createMapSpaceUVCoordsDraped as R}from"../support/uvUtils.js";import{VertexAttribute as B}from"../../webgl-engine/lib/basicInterfaces.js";import{Object3D as L}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as N}from"../../webgl-engine/lib/RenderGeometry.js";import{getStipplePatternForLinePattern as F}from"../../webgl-engine/materials/lineStippleUtils.js";import{PatternMaterial as V}from"../../webgl-engine/materials/PatternMaterial.js";import{RibbonLineMaterial as I}from"../../webgl-engine/materials/RibbonLineMaterial.js";const H=["polyline","polygon","extent"];class W extends x{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=G(this.symbolLayer,{color:r,transparent:r[3]<1||this.needsDrivenTransparentPass,polygonOffset:!1,vertexColors:!0,writeLinearDepth:!0,slicePlaneEnabled:this._context.slicePlaneEnabled},{isDraped:this.draped}),this._needsUV=this._material instanceof V,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 I({width:t,color:this._getOutlineColor(),polygonOffset:!0,slicePlaneEnabled:this._context.slicePlaneEnabled,isClosed:!0,stipplePattern:i,stippleScaleWithLineWidth:!0,cap:D(e.patternCap||"butt")})};this._outlineMaterial=i(o(e.size)),this._context.stage.add(this._outlineMaterial)}_isValidOutline(e){return t(e)&&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,H,this.symbolLayer.type))return null;const i=this._getVertexOpacityAndColor(e.renderingInfo,255),r=this.setGraphicElevationContext(t,new v);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()]})}return!0}layerElevationInfoChanged(e,t,i){const r=this._elevationContext.mode,n=f(W.elevationModeChangeTypes,i,r);if(n!==g.UPDATE)return n;const o=b(r);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>o))}slicePlaneEnabledChanged(){if(t(this._material)&&this._material.setParameters({slicePlaneEnabled:this._context.slicePlaneEnabled}),t(this._outlineMaterial)){const e={slicePlaneEnabled:this._context.slicePlaneEnabled};this._outlineMaterial.setParameters(e)}return!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!0}_createAs3DShape(e,t,i){const n=U(e.geometry);if(r(n))return null;z.renderData=P(n,this._context.elevationProvider,this._context.renderCoordsHelper,i),z.color=t;const o=z.renderData.position.length/3;if(this._needsUV&&(z.uvMapSpace=new Float32Array(4*o),z.boundingRect=new Float64Array(9*o)),z.outNum=0,z.outGeometries=[],z.outTransforms=[],z.outMaterials=[],this._createAs3DShapeFill(z),this._hasOutline&&this._createAs3DShapeOutline(z),this._logGeometryCreationWarnings(z.renderData,n.rings,"rings","FillSymbol3DLayer"),0===z.outNum)return null;this._needsUV&&j(y.fromTypedArray(z.uvMapSpace),_.fromTypedArray(z.renderData.position),this._context.renderCoordsHelper,m.fromTypedArray(z.boundingRect));const a=new L({geometries:z.outGeometries,materials:z.outMaterials,transformations:z.outTransforms,castShadow:!1,metadata:{layerUid:this._context.layer.uid,graphicUid:e.uid}}),s=new M(this,a,z.outGeometries,null,null,T,i);return s.alignedSampledElevation=z.renderData.sampledElevation,s.needsElevationUpdates=b(i.mode),s}_createAs3DShapeFill(e){const i=e.renderData.polygons;for(const{position:r,mapPosition:o,holeIndices:l,index:u,count:d}of i){if(t(this._context.clippingExtent)&&(c(k),p(k,o),!h(k,this._context.clippingExtent)))continue;const i=a(o,l,3);if(0===i.length)continue;const m=new Uint32Array(i),_=C({indices:m,attributeData:{position:r,color:e.color,mapPosition:o,uvMapSpace:this._needsUV?new Float32Array(e.uvMapSpace.buffer,4*u*e.uvMapSpace.BYTES_PER_ELEMENT,4*d):null,boundingRect:this._needsUV?new Float64Array(e.boundingRect.buffer,9*u*e.boundingRect.BYTES_PER_ELEMENT,9*d):null}});e.outGeometries.push(_),e.outMaterials.push(n(this._material)),e.outTransforms.push(s),e.outNum++}}_createAs3DShapeOutline(e){if(!this._hasOutline)return;const i=e.renderData.outlines;for(let r=0;r<i.length;++r){const{mapPosition:o,position:a}=i[r];if(t(this._context.clippingExtent)&&(c(k),p(k,o),!h(k,this._context.clippingExtent)))continue;const l=S({overlayInfo:null,removeDuplicateStartEnd:A.REMOVE,attributeData:{position:a,mapPosition:o}}),u=l.vertexAttributes.get(B.POSITION);u.data===a&&(u.data=new Float64Array(a)),e.outGeometries.push(l),e.outMaterials.push(n(this._outlineMaterial)),e.outTransforms.push(s),e.outNum++}}_createAsOverlay(e,i){const o=U(e.geometry);if(r(o))return null;n(this._material).renderPriority=this._renderPriority+this._renderPriorityStep/2,t(this._outlineMaterial)&&(this._outlineMaterial.renderPriority=this._renderPriority),Y.renderData=w(o,this._context.overlaySR),Y.color=i;const a=Y.renderData.position.length/3;return this._needsUV&&(Y.uvMapSpace=new Float32Array(4*a)),Y.outNum=0,Y.outGeometries=[],Y.outBoundingBox=c(),Y.layerUid=this._context.layer.uid,Y.graphicsUid=e.uid,this._createAsOverlayFill(Y),this._hasOutline&&this._createAsOverlayOutline(Y),this._logGeometryCreationWarnings(Y.renderData,o.rings,"rings","FillSymbol3DLayer"),0===Y.outNum?null:(this._needsUV&&R(y.fromTypedArray(Y.uvMapSpace),_.fromTypedArray(Y.renderData.position),this._context.overlaySR,this._context.graphicsCoreOwner.view.state.viewingMode),Y.outNum>0?new E(this,Y.outGeometries,Y.outBoundingBox):null)}_createAsOverlayFill(e){const t=e.renderData.polygons;for(const{position:i,holeIndices:r,index:o,count:s}of t){if(c(k),p(k,i),!h(k,this._context.clippingExtent))continue;const t=a(i,r,3);if(0===t.length)continue;d(e.outBoundingBox,k);const u=new Uint32Array(t),m=C({indices:u,attributeData:{position:i,color:e.color,uvMapSpace:this._needsUV?new Float32Array(e.uvMapSpace.buffer,4*o*e.uvMapSpace.BYTES_PER_ELEMENT,4*s):null}}),_=new N(m,n(this._material),{layerUid:e.layerUid,graphicUid:e.graphicsUid}),y=k;l(_.boundingSphere,.5*(y[0]+y[3]),.5*(y[1]+y[4]),0,.5*Math.sqrt((y[3]-y[0])*(y[3]-y[0])+(y[4]-y[1])*(y[4]-y[1]))),e.outGeometries.push(_),e.outNum++}}_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(k),p(k,r),!h(k,this._context.clippingExtent))continue;d(e.outBoundingBox,k);const o=S({overlayInfo:{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper},removeDuplicateStartEnd:A.REMOVE,attributeData:{position:r}}),a=new N(o,n(this._outlineMaterial),{layerUid:e.layerUid,graphicUid:e.graphicsUid}),s=k;l(a.boundingSphere,.5*(s[0]+s[3]),.5*(s[1]+s[4]),0,.5*Math.sqrt((s[3]-s[0])*(s[3]-s[0])+(s[4]-s[1])*(s[4]-s[1]))),e.outGeometries.push(a),e.outNum++}}_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 O(t(r)?e.toUnitRGB(r):null,n)}get test(){return{createAsOverlay:(e,t)=>this._createAsOverlay(e,t),createAs3DShape:(e,t,i)=>this._createAs3DShape(e,t,i)}}}W.elevationModeChangeTypes={definedChanged:g.RECREATE,staysOnTheGround:g.NONE,onTheGroundChanged:g.RECREATE};const k=u(),z={renderData:null,color:null,uvMapSpace:null,boundingRect:null,outNum:0,outBoundingBox:null,outGeometries:null,outMaterials:null,outTransforms:null},Y={renderData:null,color:null,uvMapSpace:null,outNum:0,outBoundingBox:null,outGeometries:null,outMaterials:null,outTransforms:null};export{W as Graphics3DPolygonFillSymbolLayer,W as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/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 a}from"../../../../chunks/earcut.js";import{I as n}from"../../../../chunks/mat4f64.js";import{s}from"../../../../chunks/vec2.js";import{f as l,a as u}from"../../../../chunks/vec2f64.js";import{b as c,s as m}from"../../../../chunks/vec4.js";import{t as h}from"../../../../chunks/common.js";import{create as d,empty as p,expandWithBuffer as g,intersectsClippingArea as y,expandWithAABB as f}from"../../../../geometry/support/aaBoundingBox.js";import{create as _,empty as v,expandPointInPlace as x}from"../../../../geometry/support/aaBoundingRect.js";import{perVertexElevationAligner as D}from"./ElevationAligners.js";import{SymbolUpdateType as b,elevationModeChangeUpdateType as C,needsElevationUpdates2D as E}from"./elevationAlignmentUtils.js";import{ElevationContext as w}from"./ElevationContext.js";import G from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as S}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as j}from"./Graphics3DSymbolLayer.js";import{geometryAsPolygon as T,geometryToRenderInfo as A,createWaterGeometry 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 a}from"../../../../chunks/earcut.js";import{I as n}from"../../../../chunks/mat4f64.js";import{s}from"../../../../chunks/vec2.js";import{f as l,a as u}from"../../../../chunks/vec2f64.js";import{b as c,s as m}from"../../../../chunks/vec4.js";import{t as h}from"../../../../chunks/common.js";import{create as d,empty as p,expandWithBuffer as g,intersectsClippingArea as y,expandWithAABB as f}from"../../../../geometry/support/aaBoundingBox.js";import{create as _,empty as v,expandPointInPlace as x}from"../../../../geometry/support/aaBoundingRect.js";import{perVertexElevationAligner as D}from"./ElevationAligners.js";import{SymbolUpdateType as b,elevationModeChangeUpdateType as C,needsElevationUpdates2D as E}from"./elevationAlignmentUtils.js";import{ElevationContext as w}from"./ElevationContext.js";import G from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as S}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as j}from"./Graphics3DSymbolLayer.js";import{geometryAsPolygon as T,geometryToRenderInfo as A,createWaterGeometry as U,geometryToRenderInfoDraped as P}from"./polygonUtils.js";import{Object3D as M}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as B}from"../../webgl-engine/lib/RenderGeometry.js";import{WaterMaterial as O}from"../../webgl-engine/materials/WaterMaterial.js";import{defaultWaterMaterialParameters as R,wavePresets as L}from"../../webgl-engine/materials/internal/waterMaterialUtils.js";const N=["polyline","polygon","extent"];class V 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,N,this.symbolLayer.type))return null;const r=this.setGraphicElevationContext(t,new w);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={...R},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)?V.headingVectorFromAngle(this.symbolLayer.waveDirection):l(0,0);const a=this.symbolLayer.waveStrength+"-"+this.symbolLayer.waterbodySize,n=L[a];r.waveStrength=n.waveStrength,r.waveTextureRepeat=n.textureRepeat,r.waveVelocity=n.waveVelocity,r.flowStrength=n.perturbationStrength,r.slicePlaneEnabled=this._context.slicePlaneEnabled,r.isDraped=this.draped,this._material=new O(r),this._context.stage.add(this._material)}layerOpacityChanged(){if(r(this._material))return!0;const e=this._material.parameters.color,t=this._getCombinedOpacity(this.symbolLayer.color,{hasIntrinsicColor:!0}),o=t<1||this.needsDrivenTransparentPass;return this._material.setParameters({color:[e[0],e[1],e[2],t],transparent:o}),!0}layerElevationInfoChanged(e,t,r){const o=this._elevationContext.mode,i=C(V.elevationModeChangeTypes,r,o);if(i!==b.UPDATE)return i;const a=E(o);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>a))}slicePlaneEnabledChanged(){return t(this._material)&&this._material.setParameters({slicePlaneEnabled:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!0}_createAs3DShape(e,t,o){const i=T(e.geometry);if(r(i))return null;z.renderData=A(i,this._context.elevationProvider,this._context.renderCoordsHelper,t);const a=z.renderData.position.length/3;if(z.uvCoords=new Float64Array(2*a),z.outNum=0,z.outGeometries=[],z.outTransforms=[],z.outMaterials=[],this._create3DShapeGeometries(z),this._logGeometryCreationWarnings(z.renderData,i.rings,"rings","WaterSymbol3DLayer"),0===z.outNum)return null;this._createUVCoordsFromVertices(z.uvCoords,z.renderData.mapPosition,a,this._context.elevationProvider.spatialReference);const n=new M({geometries:z.outGeometries,materials:z.outMaterials,transformations:z.outTransforms,castShadow:!1,metadata:{layerUid:this._context.layer.uid,graphicUid:o}}),s=new S(this,n,z.outGeometries,null,null,D,t);return s.alignedSampledElevation=z.renderData.sampledElevation,s.needsElevationUpdates=E(t.mode),s}_createUVCoordsFromVertices(e,t,r,o){const a=i(o);v(I);for(let i=0;i<r;i++)s(W,t[3*i+0],t[3*i+1]),x(I,W);c(I,I,a);const n=I[0]%V.unitSizeOfTexture,l=I[1]%V.unitSizeOfTexture;F[0]=I[0]-n,F[1]=I[1]-l;for(let i=0;i<r;i++)e[2*i+0]=(t[3*i+0]*a-F[0])/V.unitSizeOfTexture,e[2*i+1]=(t[3*i+1]*a-F[1])/V.unitSizeOfTexture}_create3DShapeGeometries(e){const r=e.renderData.polygons,i=e.uvCoords;for(const{count:s,index:l,position:u,mapPosition:c,holeIndices:m}of r){if(t(this._context.clippingExtent)&&(p(k),g(k,c),!y(k,this._context.clippingExtent)))continue;const r=a(c,m,3);if(0===r.length)continue;const h=new Uint32Array(r),d=new Float64Array(i.buffer,2*l*i.BYTES_PER_ELEMENT,2*s),f=U({indices:h,attributeData:{position:u,uv0:d,mapPosition:c}});e.outGeometries.push(f),e.outMaterials.push(o(this._material)),e.outTransforms.push(n),e.outNum++}}_createAsOverlay(e){const t=T(e.geometry);if(r(t))return null;o(this._material).renderPriority=this._renderPriority,Y.renderData=P(t,this._context.overlaySR);const i=Y.renderData.position.length/3;return Y.uvCoords=new Float64Array(2*i),Y.outNum=0,Y.outGeometries=[],Y.outBoundingBox=p(),Y.layerUid=this._context.layer.uid,Y.graphicsUid=e.uid,this._createAsOverlayWater(Y),this._logGeometryCreationWarnings(Y.renderData,t.rings,"rings","WaterSymbol3DLayer"),0===Y.outNum?null:(this._createUVCoordsFromVertices(Y.uvCoords,Y.renderData.position,i,this._context.overlaySR),Y.outNum>0?new G(this,Y.outGeometries,Y.outBoundingBox):null)}_createAsOverlayWater(e){const t=e.uvCoords,r=e.renderData.polygons;for(const{position:i,holeIndices:n,index:s,count:l}of r){if(p(k),g(k,i),!y(k,this._context.clippingExtent))continue;f(e.outBoundingBox,k);const r=a(i,n,3);if(0===r.length)continue;const u=new Uint32Array(r),c=new Float64Array(t.buffer,2*s*t.BYTES_PER_ELEMENT,2*l),h=U({indices:u,attributeData:{position:i,uv0:c}}),d=new B(h,o(this._material),{layerUid:e.layerUid,graphicUid:e.graphicsUid}),_=k;m(d.boundingSphere,.5*(_[0]+_[3]),.5*(_[1]+_[4]),0,.5*Math.sqrt((_[3]-_[0])*(_[3]-_[0])+(_[4]-_[1])*(_[4]-_[1]))),e.outGeometries.push(d),e.outNum++}}static headingVectorFromAngle(e){const t=u(),r=h(e);return t[0]=Math.sin(r),t[1]=Math.cos(r),t}get test(){return{create3DShape:e=>this._createAs3DShape(e.graphic,e.elevationContext,e.graphicUid),ensureMaterial:()=>this.ensureMaterial()}}}V.unitSizeOfTexture=100,V.elevationModeChangeTypes={definedChanged:b.RECREATE,staysOnTheGround:b.NONE,onTheGroundChanged:b.RECREATE};const F=u(),I=_(),W=u(),k=d(),z={renderData:null,uvCoords:null,outNum:0,outBoundingBox:null,outGeometries:null,outMaterials:null,outTransforms:null},Y={renderData:null,uvCoords:null,outNum:0,outBoundingBox:null,outGeometries:null,outMaterials:null,outTransforms:null};export{V as Graphics3DWaterSymbolLayer,V as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import t from"../../../core/Evented.js";import s from"../../../core/Handles.js";import i from"../../../core/Logger.js";import{someMap as a}from"../../../core/MapUtils.js";import{releaseMaybe as o,disposeMaybe as n,isSome as l,unwrapOr as h,isNone as d,unwrap as c}from"../../../core/maybe.js";import u from"../../../core/PooledArray.js";import{someSet as p}from"../../../core/SetUtils.js";import{init as g}from"../../../core/watchUtils.js";import{property as m}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as y}from"../../../core/accessorSupport/decorators/subclass.js";import{q as _,f}from"../../../chunks/mat4.js";import{a as R}from"../../../chunks/vec2f64.js";import{f as T,c as b}from"../../../chunks/vec3f64.js";import{I as w}from"../../../chunks/mat4f64.js";import{ViewingMode as v}from"../../ViewingMode.js";import{DrapeTargetType as x,DrapeSourceType as O}from"../layers/interfaces.js";import E from"../support/debugFlags.js";import{OverlayIndex as L,RenderTargetType as j}from"./interfaces.js";import{Overlay as A}from"./Overlay.js";import{OverlayFramebufferObject as S}from"./OverlayFramebufferObject.js";import{OverlayRenderTarget as P}from"./OverlayRenderTarget.js";import{ShaderTechniqueRepository as C}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js";import{autoDispose as D,AutoDisposableMixin as G}from"../webgl-engine/lib/AutoDisposable.js";import{TransparencyPassType as I,UpdatePolicy as V}from"../webgl-engine/lib/basicInterfaces.js";import M from"../webgl-engine/lib/Camera.js";import{GLMaterialRepository as U}from"../webgl-engine/lib/GLMaterialRepository.js";import{createEmptyDepthTexture as F,createQuadVAO as q}from"../webgl-engine/lib/glUtil3D.js";import{GridLocalOriginFactory as H}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{newIntersectorResult as W}from"../webgl-engine/lib/Intersector.js";import{StoreResults as N,IntersectorType as B}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as k}from"../webgl-engine/lib/Material.js";import{ModelDirty as z}from"../webgl-engine/lib/ModelDirtyTypes.js";import{OverlayRenderContext as Y}from"../webgl-engine/lib/RenderContext.js";import{RenderPass as X}from"../webgl-engine/lib/RenderPass.js";import{RenderSlot as Q}from"../webgl-engine/lib/RenderSlot.js";import{SortedRenderGeometryRenderer as J}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{TextureTechniqueConfiguration as K,TextureTechnique as Z}from"../webgl-engine/lib/TextureTechnique.js";import{AmbientLight as $}from"../webgl-engine/lighting/Lightsources.js";import{SceneLighting as ee}from"../webgl-engine/lighting/SceneLighting.js";import{StippleTextureRepository as re}from"../webgl-engine/materials/StippleTextureRepository.js";import{C as te}from"../../../chunks/Compositing.glsl.js";import{AlphaMode as se}from"../webgl-engine/shaders/CompositingTechnique.js";import{ImmediateTask as ie,TaskPriority as ae,noBudget as oe}from"../../support/Scheduler.js";import{ClearBufferBit as ne,PrimitiveType as le,TextureType as he,PixelFormat as de,PixelType as ce,TextureSamplingMode as ue}from"../../webgl/enums.js";import{Texture as pe}from"../../webgl/Texture.js";import{vertexCount as ge}from"../../webgl/Util.js";const me=i.getLogger("esri.views.3d.webgl-engine.lib.OverlayRenderer");let ye=class extends(G(r)){constructor(e){super(e),this._overlays=null,this._overlayRenderTarget=null,this._hasHighlights=!1,this._rendersOccluded=!1,this._hasWater=!1,this._lighting=new ee,this._handles=new s,this._frameTask=ie,this._layerRenderers=new Map,this._sortedLayerRenderersDirty=!1,this._sortedLayerRenderers=new u,this._geometries=new Map,this.worldToPCSRatio=1,this.events=new t,this.longitudeCyclical=null}initialize(){const e=this.view._stage.renderView;this._rctx=e.renderingContext,this._renderContext=new Y(this._rctx);const r=e.waterTextureRepository;this._stippleTextureRepository=new re(e.renderingContext),this._shaderTechniqueRepository=new C({rctx:this._rctx,viewingMode:v.Local,stippleTextureRepository:this._stippleTextureRepository,waterTextureRepository:r}),this._handles.add([g(r,"loadingState",(()=>this.events.emit("content-changed"))),g(this,"spatialReference",(e=>this._localOrigins=new H(e)))]),this._materialRepository=new U(e.textureRepository,this._shaderTechniqueRepository,(e=>{(e.renderOccluded&Oe)>0!==this._rendersOccluded&&this._updateRendersOccluded(),this.events.emit("content-changed"),this.notifyChange("updating")}),(()=>this.events.emit("content-changed"))),this._lighting.groundLightingFactor=1,this._lighting.globalFactor=0,this._lighting.set([new $(T(1,1,1))]),this._bindParameters={slot:Q.DRAPED_MATERIAL,highlightDepthTexture:F(this._rctx),camera:be,inverseViewport:R(),origin:null,screenToWorldRatio:null,screenToPCSRatio:null,shadowMappingEnabled:!1,slicePlane:null,ssaoEnabled:!1,hasOccludees:!1,linearDepthTexture:null,lastFrameColorTexture:null,reprojectionMatrix:w,ssrEnabled:!1,lighting:this._lighting,transparencyPassType:I.NONE,terrainLinearDepthTexture:null,geometryLinearDepthTexture:null,multipassTerrainEnabled:!1,cullAboveGround:!1,multipassGeometryEnabled:!1,highlightColorTexture:null},this._frameTask=this.view.resourceController.scheduler.registerTask(ae.STAGE,this),this._handles.add(this._frameTask)}dispose(){this._handles.destroy(),this._layerRenderers.forEach((e=>e.dispose())),this._layerRenderers.clear(),this._debugTextureTechnique=o(this._debugTextureTechnique),this._debugPatternTexture=n(this._debugPatternTexture),this._bindParameters.highlightDepthTexture=n(this._bindParameters.highlightDepthTexture),this._shaderTechniqueRepository=n(this._shaderTechniqueRepository),this._temporaryFBO=n(this._temporaryFBO),this._quadVAO=n(this._quadVAO),this.disposeOverlays()}get updating(){return this._sortedLayerRenderersDirty||this._frameTask.updating||a(this._layerRenderers,(e=>e.updating))}get hasOverlays(){return l(this._overlays)&&l(this._overlayRenderTarget)}get gpuMemoryUsage(){return l(this._overlayRenderTarget)?this._overlayRenderTarget.gpuMemoryUsage:0}collectUnusedRenderTargetMemory(e){let r=!1;if(l(this._overlayRenderTarget))for(const t of this._overlayRenderTarget.renderTargets){const s=this.overlays[0].validTargets[t.type]||!this.overlays[1].validTargets[t.type];r=this._overlayRenderTarget.validateUsageForTarget(s,t,e)||r}return r}get overlays(){return h(this._overlays,[])}ensureDrapeTargets(e){l(this._overlays)&&this._overlays.forEach((r=>{r.hasTargetWithoutRasterImage=p(e,(e=>e.drapeTargetType===x.WithoutRasterImage))}))}ensureDrapeSources(e){l(this._overlays)&&this._overlays.forEach((r=>{r.hasDrapedFeatureSource=a(e,((e,r)=>r.drapeSourceType===O.Features)),r.hasDrapedRasterSource=a(e,((e,r)=>r.drapeSourceType===O.RasterImage))}))}ensureOverlays(e,r){d(this._overlays)&&(this._overlayRenderTarget=new P(this._rctx),this._overlays=[new A(L.INNER,this._overlayRenderTarget),new A(L.OUTER,this._overlayRenderTarget)]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r)}disposeOverlays(){this._overlays=null,this._overlayRenderTarget=n(this._overlayRenderTarget),this.events.emit("textures-disposed")}get running(){return this.updating}runTask(e,r=(()=>!0)){this._frameTask.processQueue(e),e.done||this._processLayers(e,r)}_processLayers(e,r){let t=!1;for(const[s,i]of this._layerRenderers){if(e.done)break;(s.destroyed||r(s))&&(i.commitChanges()&&(t=!0,e.madeProgress()),i.isEmpty&&(t=!0,this._sortedLayerRenderersDirty=!0,this._layerRenderers.delete(s),this._handles.remove(s)))}this._updateSortedLayerRenderers(),t&&(l(this._overlays)&&0===this._layerRenderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.events.emit("content-changed"),this._updateHasHighlights(),this._updateRendersOccluded(),this._updateHasWater())}processSyncLayers(){this._processLayers(oe,(e=>e.updatePolicy===V.SYNC))}addGeometries(e,r,t){for(const s of e)d(s.origin)&&(s.origin=this._localOrigins.getOrigin(s.boundingSphere)),this._geometries.set(s.id,s);this._ensureLayerRenderer(r).add(e),t===z.Geometry.UPDATE&&this._notifyGraphicGeometryChanged(e,r)}removeGeometries(e,r,t){for(const i of e)this._geometries.delete(c(i.id));const s=this._layerRenderers.get(r);s&&(s.remove(e),t===z.Geometry.UPDATE&&this._notifyGraphicGeometryChanged(e,r))}updateGeometries(e,r,t){const s=this._layerRenderers.get(r);if(s)switch(s.modify(e,t),t){case z.State.TRANSFORMATION:case z.State.VERTEXATTRS:return this._notifyGraphicGeometryChanged(e,r);case z.State.VISIBILITIES:return this._notifyGraphicVisibilityChanged(e,r)}else me.warn("Attempted to update geometry for nonexistent layer")}_notifyGraphicGeometryChanged(e,r){if(d(r.notifyGraphicGeometryChanged))return;let t;for(const s of e){const e=s.graphicUid;l(e)&&e!==t&&(r.notifyGraphicGeometryChanged(e),t=e)}}_notifyGraphicVisibilityChanged(e,r){if(d(r.notifyGraphicVisibilityChanged))return;let t;for(const s of e){const e=s.graphicUid;l(e)&&e!==t&&(r.notifyGraphicVisibilityChanged(e),t=e)}}updateHighlights(e,r){const t=this._layerRenderers.get(r);t?t.modify(e,z.State.HIGHLIGHTS):me.warn("Attempted to update highlights for nonexistent layer")}isEmpty(){return 0===this._geometries.size&&!E.OVERLAY_DRAW_DEBUG_TEXTURE}get hasHighlights(){return this._hasHighlights}get hasWater(){return this._hasWater}get rendersOccluded(){return this._rendersOccluded}updateAnimation(e){let r=!1;return this._layerRenderers.forEach((t=>r=t.updateAnimation(e)||r)),r}updateLayerOrder(){this._sortedLayerRenderersDirty=!0}drawTarget(e,r,t){const s=e.canvasGeometries;if(0===s.numViews)return!1;this._screenToWorldRatio=t*e.mapUnitsPerPixel;const i=r.renderPass;if(this.isEmpty()||i===X.MATERIAL_HIGHLIGHT&&!this.hasHighlights||i===X.MATERIAL_NORMAL&&!this.hasWater||!e.hasSomeSizedView())return!1;const a=r.fbo;if(!a.isValid())return!1;const o=2*e.resolution,n=e.resolution;a.resize(o,n);const h=this._rctx;be.pixelRatio=e.pixelRatio*t,this._renderContext.pass=i,this._bindParameters.screenToWorldRatio=this._screenToWorldRatio,this._bindParameters.screenToPCSRatio=this._screenToWorldRatio*this.worldToPCSRatio,this._bindParameters.slot=i===X.MATERIAL_NORMAL?Q.DRAPED_WATER:Q.DRAPED_MATERIAL,e.applyViewport(this._rctx),a.bind(h),e.index===L.INNER&&(h.setClearColor(0,0,0,0),h.clearSafe(ne.COLOR_BUFFER_BIT));const d=r.type===j.ColorNoRasterImage?_e.ExcludeRasterImage:r.type===j.Occluded?_e.OccludedOnly:_e.Normal;if(d===_e.OccludedOnly&&(this._renderContext.renderOccludedMask=Oe),E.OVERLAY_DRAW_DEBUG_TEXTURE&&d!==_e.OccludedOnly)for(let l=0;l<s.numViews;l++)this._setViewParameters(s.extents[l],e,be),this._drawDebugTexture(e.resolution,Re[e.index]);return this._layerRenderers.size>0&&this._sortedLayerRenderers.forAll((({layerView:r,renderer:t})=>{if(d===_e.ExcludeRasterImage&&l(r)&&r.drapeSourceType===O.RasterImage)return;const u=l(r)&&l(r.fullOpacity)&&r.fullOpacity<1&&i===X.MATERIAL;u&&(this.bindTemporaryFramebuffer(this._rctx,o,n),h.clearSafe(ne.COLOR_BUFFER_BIT));for(let i=0;i<s.numViews;i++)this._setViewParameters(s.extents[i],e,be),t.render(this._renderContext,this._bindParameters);u&&l(this._temporaryFBO)&&(a.bind(h),this.view._stage.renderView.compositingHelper.composite(this._temporaryFBO.getTexture(),se.PremultipliedAlpha,c(c(r).fullOpacity),te.OverlayWithTransparency,e.index))})),h.bindFramebuffer(null),a.generateMipMap(),this._renderContext.resetRenderOccludedMask(),!0}bindTemporaryFramebuffer(e,r,t){d(this._temporaryFBO)&&(this._temporaryFBO=new S(e,!1)),this._temporaryFBO.resize(r,t),this._temporaryFBO.bind(e)}async reloadShaders(){await this._shaderTechniqueRepository.reloadAll()}intersect(e,r,t,s){let i=0;this._geometries.forEach((a=>{if(s&&!s(a))return;this._intersectRenderGeometry(a,t,r,0,e,i);const o=this.longitudeCyclical;o&&(a.boundingSphere[0]-a.boundingSphere[3]<o.min&&this._intersectRenderGeometry(a,t,r,o.range,e,i),a.boundingSphere[0]+a.boundingSphere[3]>o.max&&this._intersectRenderGeometry(a,t,r,-o.range,e,i)),i++}))}_intersectRenderGeometry(e,r,t,s,i,a){if(!e.instanceParameters.visible)return;let o=0;l(e.transformation)&&(s+=e.transformation[12],o=e.transformation[13]),we[0]=t[0]-s,we[1]=t[1]-o,we[2]=1,ve[0]=t[0]-s,ve[1]=t[1]-o,ve[2]=0,e.screenToWorldRatio=this._screenToWorldRatio,e.material.intersect(e,null,e.getShaderTransformation(),i,we,ve,((t,s,o)=>{Te(r,o,e.material.renderPriority,a,i,e.layerUid,e.graphicUid)}),e.calculateShaderTransformation,r)}_ensureLayerRenderer(e){let r=this._layerRenderers.get(e);return r||(r=new J({rctx:this._rctx,materialRepository:this._materialRepository}),this._layerRenderers.set(e,r),this._sortedLayerRenderersDirty=!0,"fullOpacity"in e&&this._handles.add(e.watch("fullOpacity",(()=>this.events.emit("content-changed"))),e),this._handles.add(g(r,"updating",(()=>this.notifyChange("updating"))),e)),r}_updateSortedLayerRenderers(){if(!this._sortedLayerRenderersDirty)return;if(this._sortedLayerRenderersDirty=!1,this._sortedLayerRenderers.clear(),0===this._layerRenderers.size)return;const e=new Set(this._layerRenderers.values());this.view.allLayerViews.forEach((r=>{const t=r,s=this._layerRenderers.get(t);s&&(this._sortedLayerRenderers.push(new fe(t,s)),e.delete(s))})),e.forEach((e=>this._sortedLayerRenderers.push(new fe(null,e))))}_setViewParameters(e,r,t){t.viewport[0]=t.viewport[1]=0,t.viewport[2]=t.viewport[3]=r.resolution,_(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),f(t.viewMatrix,[-e[0],-e[1],0]),this._renderContext.camera=t,this._bindParameters.camera=t,this._bindParameters.inverseViewport[0]=1/t.fullViewport[2],this._bindParameters.inverseViewport[1]=1/t.fullViewport[3]}_updateHasWater(){const e=a(this._layerRenderers,(e=>e.hasWater));e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water",e))}_updateHasHighlights(){const e=a(this._layerRenderers,(e=>e.hasHighlights));e!==this._hasHighlights&&(this._hasHighlights=e,this.events.emit("has-highlights",e))}_updateRendersOccluded(){const e=a(this._layerRenderers,(e=>e.rendersOccluded));e!==this._rendersOccluded&&(this._rendersOccluded=e,this.events.emit("renders-occluded",e))}_drawDebugTexture(e,r){const t=this._rctx;this._ensureDebugPatternResources(e,e);const s=this._debugTextureTechnique.program;t.useProgram(s),this._debugTextureTechnique.bindPipelineState(t),s.setUniform4f("color",r[0],r[1],r[2],1),s.bindTexture(this._debugPatternTexture,"tex"),t.bindVAO(this._quadVAO),t.drawArrays(le.TRIANGLE_STRIP,0,ge(this._quadVAO,"geometry"))}_ensureDebugPatternResources(e,r){if(this._debugPatternTexture)return;const t=new Uint8Array(e*r*4);let s=0;for(let a=0;a<r;a++)for(let i=0;i<e;i++){const o=Math.floor(i/10),n=Math.floor(a/10);o<2||n<2||10*o>e-20||10*n>r-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&o&&1&n?1&i^1&a?0:255:1&o^1&n?0:128)}this._debugPatternTexture=new pe(this._rctx,{target:he.TEXTURE_2D,pixelFormat:de.RGBA,dataType:ce.UNSIGNED_BYTE,samplingMode:ue.NEAREST,width:e,height:r},t);const i=new K;i.hasAlpha=!0,this._debugTextureTechnique=this._shaderTechniqueRepository.acquire(Z,i),this._quadVAO=q(this._rctx)}get test(){return{layerRenderers:this._layerRenderers}}};var _e;e([m()],ye.prototype,"_frameTask",void 0),e([m()],ye.prototype,"_sortedLayerRenderersDirty",void 0),e([D()],ye.prototype,"_shaderTechniqueRepository",void 0),e([D()],ye.prototype,"_stippleTextureRepository",void 0),e([m({constructOnly:!0})],ye.prototype,"view",void 0),e([m()],ye.prototype,"worldToPCSRatio",void 0),e([m()],ye.prototype,"spatialReference",void 0),e([m({type:Boolean,readOnly:!0})],ye.prototype,"updating",null),ye=e([y("esri.views.3d.terrain.OverlayRenderer")],ye),function(e){e[e.Normal=0]="Normal",e[e.OccludedOnly=1]="OccludedOnly",e[e.ExcludeRasterImage=2]="ExcludeRasterImage"}(_e||(_e={}));class fe{constructor(e,r){this.layerView=e,this.renderer=r}}const Re=[[1,.5,.5],[.5,.5,1]];function Te(e,r,t,s,i,a,o){const n={layerUid:a,graphicUid:o,triangleNr:r},l=r=>{r.set(B.OVERLAY,n,e.dist,e.normal,e.transformation,t,s)};if((null==i.results.min.drapedLayerOrder||t>=i.results.min.drapedLayerOrder)&&(null==i.results.min.dist||i.results.ground.dist<=i.results.min.dist)&&l(i.results.min),i.options.store!==N.MIN&&(null==i.results.max.drapedLayerOrder||t<i.results.max.drapedLayerOrder)&&(null==i.results.max.dist||i.results.ground.dist>i.results.max.dist)&&l(i.results.max),i.options.store===N.ALL){const e=W(i.ray);l(e),i.results.all.push(e)}}const be=new M;be.near=1,be.far=1e4,be.relativeElevation=null;const we=b(),ve=b(),xe=-2,Oe=k.OccludeAndTransparent;export{xe as DRAPED_Z,_e as DrawPassOption,ye as OverlayRenderer,Oe as overlayRenderOccludedFlag};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import t from"../../../core/Evented.js";import s from"../../../core/Handles.js";import i from"../../../core/Logger.js";import{someMap as a}from"../../../core/MapUtils.js";import{releaseMaybe as o,disposeMaybe as n,isSome as h,unwrapOr as l,isNone as d,unwrap as c}from"../../../core/maybe.js";import u from"../../../core/PooledArray.js";import{someSet as p}from"../../../core/SetUtils.js";import{init as g}from"../../../core/watchUtils.js";import{property as m}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as y}from"../../../core/accessorSupport/decorators/subclass.js";import{q as _,f}from"../../../chunks/mat4.js";import{a as R}from"../../../chunks/vec2f64.js";import{f as T,c as b}from"../../../chunks/vec3f64.js";import{I as w}from"../../../chunks/mat4f64.js";import{ViewingMode as v}from"../../ViewingMode.js";import{DrapeTargetType as x,DrapeSourceType as O}from"../layers/interfaces.js";import E from"../support/debugFlags.js";import{OverlayIndex as L,RenderTargetType as j}from"./interfaces.js";import{Overlay as A}from"./Overlay.js";import{OverlayFramebufferObject as S}from"./OverlayFramebufferObject.js";import{OverlayRenderTarget as P}from"./OverlayRenderTarget.js";import{ShaderTechniqueRepository as C}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js";import{autoDispose as D,AutoDisposableMixin as G}from"../webgl-engine/lib/AutoDisposable.js";import{TransparencyPassType as I,UpdatePolicy as M}from"../webgl-engine/lib/basicInterfaces.js";import V from"../webgl-engine/lib/Camera.js";import{GLMaterialRepository as U}from"../webgl-engine/lib/GLMaterialRepository.js";import{createEmptyDepthTexture as F,createQuadVAO as q}from"../webgl-engine/lib/glUtil3D.js";import{GridLocalOriginFactory as H}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{newIntersectorResult as W}from"../webgl-engine/lib/Intersector.js";import{StoreResults as N,IntersectorType as B}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as k}from"../webgl-engine/lib/Material.js";import{ModelDirty as z}from"../webgl-engine/lib/ModelDirtyTypes.js";import{OverlayRenderContext as Y}from"../webgl-engine/lib/RenderContext.js";import{RenderPass as X}from"../webgl-engine/lib/RenderPass.js";import{RenderSlot as Q}from"../webgl-engine/lib/RenderSlot.js";import{SortedRenderGeometryRenderer as J}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{TextureTechniqueConfiguration as K,TextureTechnique as Z}from"../webgl-engine/lib/TextureTechnique.js";import{AmbientLight as $}from"../webgl-engine/lighting/Lightsources.js";import{SceneLighting as ee}from"../webgl-engine/lighting/SceneLighting.js";import{StippleTextureRepository as re}from"../webgl-engine/materials/StippleTextureRepository.js";import{C as te}from"../../../chunks/Compositing.glsl.js";import{AlphaMode as se}from"../webgl-engine/shaders/CompositingTechnique.js";import{ImmediateTask as ie,TaskPriority as ae,noBudget as oe}from"../../support/Scheduler.js";import{ClearBufferBit as ne,PrimitiveType as he,TextureType as le,PixelFormat as de,PixelType as ce,TextureSamplingMode as ue}from"../../webgl/enums.js";import{Texture as pe}from"../../webgl/Texture.js";import{vertexCount as ge}from"../../webgl/Util.js";const me=i.getLogger("esri.views.3d.webgl-engine.lib.OverlayRenderer");let ye=class extends(G(r)){constructor(e){super(e),this._overlays=null,this._overlayRenderTarget=null,this._hasHighlights=!1,this._rendersOccluded=!1,this._hasWater=!1,this._lighting=new ee,this._handles=new s,this._frameTask=ie,this._layerRenderers=new Map,this._sortedLayerRenderersDirty=!1,this._sortedLayerRenderers=new u,this._geometries=new Map,this.worldToPCSRatio=1,this.events=new t,this.longitudeCyclical=null}initialize(){const e=this.view._stage.renderView;this._rctx=e.renderingContext,this._renderContext=new Y(this._rctx);const r=e.waterTextureRepository;this._stippleTextureRepository=new re(e.renderingContext),this._shaderTechniqueRepository=new C({rctx:this._rctx,viewingMode:v.Local,stippleTextureRepository:this._stippleTextureRepository,waterTextureRepository:r}),this._handles.add([g(r,"loadingState",(()=>this.events.emit("content-changed"))),g(this,"spatialReference",(e=>this._localOrigins=new H(e)))]),this._materialRepository=new U(e.textureRepository,this._shaderTechniqueRepository,(e=>{(e.renderOccluded&Oe)>0!==this._rendersOccluded&&this._updateRendersOccluded(),this.events.emit("content-changed"),this.notifyChange("updating")}),(()=>this.events.emit("content-changed"))),this._lighting.groundLightingFactor=1,this._lighting.globalFactor=0,this._lighting.set([new $(T(1,1,1))]),this._bindParameters={slot:Q.DRAPED_MATERIAL,highlightDepthTexture:F(this._rctx),camera:be,inverseViewport:R(),origin:null,screenToWorldRatio:null,screenToPCSRatio:null,shadowMappingEnabled:!1,slicePlane:null,ssaoEnabled:!1,hasOccludees:!1,linearDepthTexture:null,lastFrameColorTexture:null,reprojectionMatrix:w,ssrEnabled:!1,lighting:this._lighting,transparencyPassType:I.NONE,terrainLinearDepthTexture:null,geometryLinearDepthTexture:null,multipassTerrainEnabled:!1,cullAboveGround:!1,multipassGeometryEnabled:!1,highlightColorTexture:null},this._frameTask=this.view.resourceController.scheduler.registerTask(ae.STAGE,this),this._handles.add(this._frameTask)}dispose(){this._handles.destroy(),this._layerRenderers.forEach((e=>e.dispose())),this._layerRenderers.clear(),this._debugTextureTechnique=o(this._debugTextureTechnique),this._debugPatternTexture=n(this._debugPatternTexture),this._bindParameters.highlightDepthTexture=n(this._bindParameters.highlightDepthTexture),this._shaderTechniqueRepository=n(this._shaderTechniqueRepository),this._temporaryFBO=n(this._temporaryFBO),this._quadVAO=n(this._quadVAO),this.disposeOverlays()}get updating(){return this._sortedLayerRenderersDirty||this._frameTask.updating||a(this._layerRenderers,(e=>e.updating))}get hasOverlays(){return h(this._overlays)&&h(this._overlayRenderTarget)}get gpuMemoryUsage(){return h(this._overlayRenderTarget)?this._overlayRenderTarget.gpuMemoryUsage:0}collectUnusedRenderTargetMemory(e){let r=!1;if(h(this._overlayRenderTarget))for(const t of this._overlayRenderTarget.renderTargets){const s=this.overlays[0].validTargets[t.type]||!this.overlays[1].validTargets[t.type];r=this._overlayRenderTarget.validateUsageForTarget(s,t,e)||r}return r}get overlays(){return l(this._overlays,[])}ensureDrapeTargets(e){h(this._overlays)&&this._overlays.forEach((r=>{r.hasTargetWithoutRasterImage=p(e,(e=>e.drapeTargetType===x.WithoutRasterImage))}))}ensureDrapeSources(e){h(this._overlays)&&this._overlays.forEach((r=>{r.hasDrapedFeatureSource=a(e,((e,r)=>r.drapeSourceType===O.Features)),r.hasDrapedRasterSource=a(e,((e,r)=>r.drapeSourceType===O.RasterImage))}))}ensureOverlays(e,r){d(this._overlays)&&(this._overlayRenderTarget=new P(this._rctx),this._overlays=[new A(L.INNER,this._overlayRenderTarget),new A(L.OUTER,this._overlayRenderTarget)]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r)}disposeOverlays(){this._overlays=null,this._overlayRenderTarget=n(this._overlayRenderTarget),this.events.emit("textures-disposed")}get running(){return this.updating}runTask(e,r=(()=>!0)){this._frameTask.processQueue(e),e.done||this._processLayers(e,r)}_processLayers(e,r){let t=!1;for(const[s,i]of this._layerRenderers){if(e.done)break;(s.destroyed||r(s))&&(i.commitChanges()&&(t=!0,e.madeProgress()),i.isEmpty&&(t=!0,this._sortedLayerRenderersDirty=!0,this._layerRenderers.delete(s),this._handles.remove(s)))}this._updateSortedLayerRenderers(),t&&(h(this._overlays)&&0===this._layerRenderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.events.emit("content-changed"),this._updateHasHighlights(),this._updateRendersOccluded(),this._updateHasWater())}processSyncLayers(){this._processLayers(oe,(e=>e.updatePolicy===M.SYNC))}addGeometries(e,r,t){for(const s of e)d(s.origin)&&(s.origin=this._localOrigins.getOrigin(s.boundingSphere)),this._geometries.set(s.id,s);this._ensureLayerRenderer(r).add(e),t===z.Geometry.UPDATE&&this._notifyGraphicGeometryChanged(e,r)}removeGeometries(e,r,t){for(const i of e)this._geometries.delete(c(i.id));const s=this._layerRenderers.get(r);s&&(s.remove(e),t===z.Geometry.UPDATE&&this._notifyGraphicGeometryChanged(e,r))}updateGeometries(e,r,t){const s=this._layerRenderers.get(r);if(s)switch(s.modify(e,t),t){case z.State.TRANSFORMATION:case z.State.VERTEXATTRS:return this._notifyGraphicGeometryChanged(e,r);case z.State.VISIBILITIES:return this._notifyGraphicVisibilityChanged(e,r)}else me.warn("Attempted to update geometry for nonexistent layer")}_notifyGraphicGeometryChanged(e,r){if(d(r.notifyGraphicGeometryChanged))return;let t;for(const s of e){const e=s.graphicUid;h(e)&&e!==t&&(r.notifyGraphicGeometryChanged(e),t=e)}}_notifyGraphicVisibilityChanged(e,r){if(d(r.notifyGraphicVisibilityChanged))return;let t;for(const s of e){const e=s.graphicUid;h(e)&&e!==t&&(r.notifyGraphicVisibilityChanged(e),t=e)}}updateHighlights(e,r){const t=this._layerRenderers.get(r);t?t.modify(e,z.State.HIGHLIGHTS):me.warn("Attempted to update highlights for nonexistent layer")}isEmpty(){return 0===this._geometries.size&&!E.OVERLAY_DRAW_DEBUG_TEXTURE}get hasHighlights(){return this._hasHighlights}get hasWater(){return this._hasWater}get rendersOccluded(){return this._rendersOccluded}updateAnimation(e){let r=!1;return this._layerRenderers.forEach((t=>r=t.updateAnimation(e)||r)),r}updateLayerOrder(){this._sortedLayerRenderersDirty=!0}drawTarget(e,r,t){const s=e.canvasGeometries;if(0===s.numViews)return!1;this._screenToWorldRatio=t*e.mapUnitsPerPixel;const i=r.renderPass;if(this.isEmpty()||i===X.MATERIAL_HIGHLIGHT&&!this.hasHighlights||i===X.MATERIAL_NORMAL&&!this.hasWater||!e.hasSomeSizedView())return!1;const a=r.fbo;if(!a.isValid())return!1;const o=2*e.resolution,n=e.resolution;a.resize(o,n);const l=this._rctx;be.pixelRatio=e.pixelRatio*t,this._renderContext.pass=i,this._bindParameters.screenToWorldRatio=this._screenToWorldRatio,this._bindParameters.screenToPCSRatio=this._screenToWorldRatio*this.worldToPCSRatio,this._bindParameters.slot=i===X.MATERIAL_NORMAL?Q.DRAPED_WATER:Q.DRAPED_MATERIAL,e.applyViewport(this._rctx),a.bind(l),e.index===L.INNER&&(l.setClearColor(0,0,0,0),l.clearSafe(ne.COLOR_BUFFER_BIT));const d=r.type===j.ColorNoRasterImage?_e.ExcludeRasterImage:r.type===j.Occluded?_e.OccludedOnly:_e.Normal;if(d===_e.OccludedOnly&&(this._renderContext.renderOccludedMask=Oe),E.OVERLAY_DRAW_DEBUG_TEXTURE&&d!==_e.OccludedOnly)for(let h=0;h<s.numViews;h++)this._setViewParameters(s.extents[h],e,be),this._drawDebugTexture(e.resolution,Re[e.index]);return this._layerRenderers.size>0&&this._sortedLayerRenderers.forAll((({overlayLayer:r,renderer:t})=>{if(d===_e.ExcludeRasterImage&&r.drapeSourceType===O.RasterImage)return;const{fullOpacity:c}=r,u=h(c)&&c<1&&i===X.MATERIAL;u&&(this.bindTemporaryFramebuffer(this._rctx,o,n),l.clearSafe(ne.COLOR_BUFFER_BIT));for(let i=0;i<s.numViews;i++)this._setViewParameters(s.extents[i],e,be),t.render(this._renderContext,this._bindParameters);u&&h(this._temporaryFBO)&&(a.bind(l),this.view._stage.renderView.compositingHelper.composite(this._temporaryFBO.getTexture(),se.PremultipliedAlpha,c,te.OverlayWithTransparency,e.index))})),l.bindFramebuffer(null),a.generateMipMap(),this._renderContext.resetRenderOccludedMask(),!0}bindTemporaryFramebuffer(e,r,t){d(this._temporaryFBO)&&(this._temporaryFBO=new S(e,!1)),this._temporaryFBO.resize(r,t),this._temporaryFBO.bind(e)}async reloadShaders(){await this._shaderTechniqueRepository.reloadAll()}intersect(e,r,t,s){let i=0;this._geometries.forEach((a=>{if(s&&!s(a))return;this._intersectRenderGeometry(a,t,r,0,e,i);const o=this.longitudeCyclical;o&&(a.boundingSphere[0]-a.boundingSphere[3]<o.min&&this._intersectRenderGeometry(a,t,r,o.range,e,i),a.boundingSphere[0]+a.boundingSphere[3]>o.max&&this._intersectRenderGeometry(a,t,r,-o.range,e,i)),i++}))}_intersectRenderGeometry(e,r,t,s,i,a){if(!e.instanceParameters.visible)return;let o=0;h(e.transformation)&&(s+=e.transformation[12],o=e.transformation[13]),we[0]=t[0]-s,we[1]=t[1]-o,we[2]=1,ve[0]=t[0]-s,ve[1]=t[1]-o,ve[2]=0,e.screenToWorldRatio=this._screenToWorldRatio,e.material.intersect(e,null,e.getShaderTransformation(),i,we,ve,((t,s,o)=>{Te(r,o,e.material.renderPriority,a,i,e.layerUid,e.graphicUid)}),e.calculateShaderTransformation,r)}_ensureLayerRenderer(e){let r=this._layerRenderers.get(e);return r||(r=new J({rctx:this._rctx,materialRepository:this._materialRepository}),this._layerRenderers.set(e,r),this._sortedLayerRenderersDirty=!0,"fullOpacity"in e&&this._handles.add(e.watch("fullOpacity",(()=>this.events.emit("content-changed"))),e),this._handles.add(g(r,"updating",(()=>this.notifyChange("updating"))),e)),r}_updateSortedLayerRenderers(){if(!this._sortedLayerRenderersDirty)return;if(this._sortedLayerRenderersDirty=!1,this._sortedLayerRenderers.clear(),0===this._layerRenderers.size)return;const e=this.view.map.allLayers;this._layerRenderers.forEach(((r,t)=>{const s=e.indexOf(t.layer);this._sortedLayerRenderers.push(new fe(t,r,s<0?1/0:s))})),this._sortedLayerRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r,t){t.viewport[0]=t.viewport[1]=0,t.viewport[2]=t.viewport[3]=r.resolution,_(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),f(t.viewMatrix,[-e[0],-e[1],0]),this._renderContext.camera=t,this._bindParameters.camera=t,this._bindParameters.inverseViewport[0]=1/t.fullViewport[2],this._bindParameters.inverseViewport[1]=1/t.fullViewport[3]}_updateHasWater(){const e=a(this._layerRenderers,(e=>e.hasWater));e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water",e))}_updateHasHighlights(){const e=a(this._layerRenderers,(e=>e.hasHighlights));e!==this._hasHighlights&&(this._hasHighlights=e,this.events.emit("has-highlights",e))}_updateRendersOccluded(){const e=a(this._layerRenderers,(e=>e.rendersOccluded));e!==this._rendersOccluded&&(this._rendersOccluded=e,this.events.emit("renders-occluded",e))}_drawDebugTexture(e,r){const t=this._rctx;this._ensureDebugPatternResources(e,e);const s=this._debugTextureTechnique.program;t.useProgram(s),this._debugTextureTechnique.bindPipelineState(t),s.setUniform4f("color",r[0],r[1],r[2],1),s.bindTexture(this._debugPatternTexture,"tex"),t.bindVAO(this._quadVAO),t.drawArrays(he.TRIANGLE_STRIP,0,ge(this._quadVAO,"geometry"))}_ensureDebugPatternResources(e,r){if(this._debugPatternTexture)return;const t=new Uint8Array(e*r*4);let s=0;for(let a=0;a<r;a++)for(let i=0;i<e;i++){const o=Math.floor(i/10),n=Math.floor(a/10);o<2||n<2||10*o>e-20||10*n>r-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&o&&1&n?1&i^1&a?0:255:1&o^1&n?0:128)}this._debugPatternTexture=new pe(this._rctx,{target:le.TEXTURE_2D,pixelFormat:de.RGBA,dataType:ce.UNSIGNED_BYTE,samplingMode:ue.NEAREST,width:e,height:r},t);const i=new K;i.hasAlpha=!0,this._debugTextureTechnique=this._shaderTechniqueRepository.acquire(Z,i),this._quadVAO=q(this._rctx)}get test(){return{layerRenderers:this._layerRenderers}}};var _e;e([m()],ye.prototype,"_frameTask",void 0),e([m()],ye.prototype,"_sortedLayerRenderersDirty",void 0),e([D()],ye.prototype,"_shaderTechniqueRepository",void 0),e([D()],ye.prototype,"_stippleTextureRepository",void 0),e([m({constructOnly:!0})],ye.prototype,"view",void 0),e([m()],ye.prototype,"worldToPCSRatio",void 0),e([m()],ye.prototype,"spatialReference",void 0),e([m({type:Boolean,readOnly:!0})],ye.prototype,"updating",null),ye=e([y("esri.views.3d.terrain.OverlayRenderer")],ye),function(e){e[e.Normal=0]="Normal",e[e.OccludedOnly=1]="OccludedOnly",e[e.ExcludeRasterImage=2]="ExcludeRasterImage"}(_e||(_e={}));class fe{constructor(e,r,t){this.overlayLayer=e,this.renderer=r,this.index=t}}const Re=[[1,.5,.5],[.5,.5,1]];function Te(e,r,t,s,i,a,o){const n={layerUid:a,graphicUid:o,triangleNr:r},h=r=>{r.set(B.OVERLAY,n,e.dist,e.normal,e.transformation,t,s)};if((null==i.results.min.drapedLayerOrder||t>=i.results.min.drapedLayerOrder)&&(null==i.results.min.dist||i.results.ground.dist<=i.results.min.dist)&&h(i.results.min),i.options.store!==N.MIN&&(null==i.results.max.drapedLayerOrder||t<i.results.max.drapedLayerOrder)&&(null==i.results.max.dist||i.results.ground.dist>i.results.max.dist)&&h(i.results.max),i.options.store===N.ALL){const e=W(i.ray);h(e),i.results.all.push(e)}}const be=new V;be.near=1,be.far=1e4,be.relativeElevation=null;const we=b(),ve=b(),xe=-2,Oe=k.OccludeAndTransparent;export{xe as DRAPED_Z,_e as DrawPassOption,ye as OverlayRenderer,Oe as overlayRenderOccludedFlag};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{
|
|
5
|
+
import{unwrapOr as t,isNone as r,isSome as i}from"../../../../core/maybe.js";import{generateUID as s}from"../../../../core/uid.js";import{c as a}from"../../../../chunks/mat4.js";import{c as n,I as e}from"../../../../chunks/mat4f64.js";import{m as o}from"../../../../chunks/vec3.js";import{c as h}from"../../../../chunks/vec4f64.js";import{maxScale as m}from"../../support/mathUtils.js";import{VertexAttribute as c,Object3DState as d}from"./basicInterfaces.js";import{computeAttachmentOriginTriangles as f}from"./geometryDataUtils.js";import{InstanceParameters as u}from"./InstanceParameters.js";import{Object3DStateID as g}from"./Object3DStateID.js";import{addObject3DStateID as l,removeObject3DStateID as p}from"../materials/renderers/utils.js";class T{constructor(r,i,a={}){this.data=r,this.material=i,this.boundingSphere=h(),this.instanceParameters=new u,this._transformation=n(),this._shaderTransformationDirty=!0,this.layerUid=t(a.layerUid,null),this.graphicUid=t(a.graphicUid,null),this.id=a.id?a.id:s(),this.boundingInfo=t(a.boundingInfo,null),this.calculateShaderTransformation=t(this.calculateShaderTransformation,null),this.castShadow=!!a.castShadow&&a.castShadow}get transformation(){return this._transformation}updateTransformation(t){t(this._transformation),this._shaderTransformationDirty=!0,this.computeBoundingSphere(this._transformation,this.boundingSphere)}shaderTransformationChanged(){this._shaderTransformationDirty=!0}computeBoundingSphere(t,i,s=m(t)){r(this.boundingInfo)||(o(i,this.boundingInfo.getCenter(),t),i[3]=this.boundingInfo.getBSRadius()*s)}get hasShaderTransformation(){return i(this.calculateShaderTransformation)}get primitiveType(){return this.data.primitiveType}getShaderTransformation(){return r(this.calculateShaderTransformation)?t(this.transformation,e):(this._shaderTransformationDirty&&(this._shaderTransformation||(this._shaderTransformation=n()),a(this._shaderTransformation,this.calculateShaderTransformation(t(this.transformation,e))),this._shaderTransformationDirty=!1),this._shaderTransformation)}computeAttachmentOrigin(t){if(this.material.computeAttachmentOrigin)return!!this.material.computeAttachmentOrigin(this,t)&&(i(this._transformation)&&o(t,t,this._transformation),!0);const r=this.indices.get(c.POSITION),s=this.vertexAttributes.get(c.POSITION);return!!f(s,r,t)&&(i(this._transformation)&&o(t,t,this._transformation),!0)}get indices(){return this.data.indices}get vertexAttributes(){return this.data.vertexAttributes}addHighlight(){const t=new g(d.Highlight),r=this.instanceParameters;return r.highlights=l(r.highlights,t),t}removeHighlight(t){const r=this.instanceParameters;r.highlights=p(r.highlights,t)}}class S extends T{}export{T as RenderGeometry,S as ValidatedRenderGeometry};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../core/Accessor.js";import{isSome as o,isNone as r}from"../../../../core/maybe.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{ContentObjectType as s}from"../lib/ContentObjectType.js";import{GridLocalOriginFactory as a}from"../lib/GridLocalOriginFactory.js";import c from"../lib/ModelDirtySet.js";import{RenderGeometry as d}from"../lib/RenderGeometry.js";import{assert as m}from"../lib/Util.js";import{isWebGLLayer as l}from"../lib/WebGLLayer.js";let
|
|
5
|
+
import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../core/Accessor.js";import{isSome as o,isNone as r}from"../../../../core/maybe.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{ContentObjectType as s}from"../lib/ContentObjectType.js";import{GridLocalOriginFactory as a}from"../lib/GridLocalOriginFactory.js";import c from"../lib/ModelDirtySet.js";import{RenderGeometry as d}from"../lib/RenderGeometry.js";import{assert as m}from"../lib/Util.js";import{isWebGLLayer as l}from"../lib/WebGLLayer.js";let h=class extends e{constructor(){super(...arguments),this.dirtySet=new c({model:this}),this._content=new Map,this._originFactory=new a(null,75e4)}getObject(t){return this._content.get(t)}add(t){const e=t.id;m(!this._content.has(e),"Model/Stage already contains object to be added"),this._content.set(e,t),l(t)&&this.dirtySet.layerAdded(t)}remove(t){m(this._content.has(t.id),"Model/Stage doesn't contain object to be removed"),this._content.delete(t.id),t.unload(),l(t)&&this.dirtySet.layerRemoved(t)}addMany(t){for(const e of t)o(e)&&(m(!this._content.has(e.id),"Model/Stage already contains object to be added"),this._content.set(e.id,e))}removeMany(t){for(const e of t)m(this._content.has(e.id),"Model/Stage doesn't contain object to be removed"),this._content.delete(e.id),e.unload()}has(t){return this._content.has(t.id)}forEachOfType(t,e){this._content.forEach((o=>{o.type===t&&e(o)}))}getRenderGeometry(t,e){const{geometry:o,material:r,id:n,shaderTransformation:i,origin:s,instanceParameters:a}=e,c=new d(o,r,{id:n,boundingInfo:o.boundingInfo,calculateShaderTransformation:i,castShadow:t.castShadow});return c.updateTransformation((o=>t.getCombinedStaticTransformation(e,o))),c.origin=s||this._originFactory.getOrigin(c.boundingSphere),c.instanceParameters=a,c}updateRenderGeometryTransformation(t,e,o){if(r(t))return!1;o.updateTransformation((o=>t.getCombinedStaticTransformation(e,o)));const n=this._originFactory.getOrigin(o.boundingSphere);return o.origin!==n}getStats(){const t={},e=Array.from(this._content.values());for(let o=0;o<s.COUNT;++o)t[o]=e.filter((t=>t.type===o)).length;return{contentTypes:t,dirtySet:this.dirtySet.formatDebugInfo()}}get test(){return{content:Array.from(this._content.values())}}};t([n({constructOnly:!0})],h.prototype,"dirtySet",void 0),h=t([i("esri.views.3d.webgl-engine.parts.Model")],h);export{h as Model};
|
|
@@ -956,4 +956,4 @@ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Col
|
|
|
956
956
|
<template class="header" id="headerTemplate">
|
|
957
957
|
<vaadin-grid-sorter path="[[path]]" direction="{{direction}}">[[_getHeader(header, path)]]</vaadin-grid-sorter>
|
|
958
958
|
</template>
|
|
959
|
-
`}static get is(){return"vaadin-grid-sort-column"}static get properties(){return{path:String,direction:{type:String,notify:!0}}}_prepareHeaderTemplate(){const e=this._prepareTemplatizer(this.$.headerTemplate);return e.templatizer.dataHost=this,e}_getHeader(e,t){return e||this._generateHeader(t)}}customElements.define(Ka.is,Ka);const Qa={selectionColumn:!0},el={base:"esri-grid",content:"esri-grid__content",grid:"esri-grid__grid",widget:"esri-widget"};let tl=class extends(s(c)){constructor(e,i){super(e,i),this._grid=null,this._headerStyles="display: flex; font-weight: 400;",this._hostStyles='font-family: "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 1em; background-color: inherit; color: inherit;',this._rowHoverStyles="background-color: var(--lumo-row-background-hover);",this._columnElements=[],this.cellClassNameGenerator=null,this.columnReorderingEnabled=!0,this.dataProvider=null,this.itemIdPath=null,this.label=void 0,this.messages=null,this.pageSize=50,this.selectedItems=new t,this.size=null,this.rowDetailsRenderer=null,this.store=null,this.viewModel=new u,this.visibleElements={...Qa}}initialize(){this.handles.add([this.columns.on("change",(()=>this._syncColumnRenderers())),n(this,"viewModel.size",(()=>this._updateGridSize())),n(this,"store.state",((e,t)=>{"ready"!==e||"loaded"!==t&&"error"!==t||this.refreshCache()})),o(this,"_grid.$.table","scroll",(()=>{var e;null==(e=this.viewModel)||e.closeColumnMenus()}))])}destroy(){var e;this.handles.removeAll(),this.resetColumns(),null==(e=this.columns)||e.destroy()}resetColumns(){this.columns.items.forEach((e=>e.destroy())),this.columns.removeAll()}castVisibleElements(e){return{...Qa,...e}}render(){return m("div",{bind:this,class:this.classes(el.base,el.widget)},m("div",{bind:this,class:el.content},this.renderGrid()))}renderGrid(){return m("vaadin-grid",{...this.getGridProps()},this.renderAllColumns())}renderAllColumns(){if("disabled"!==this.viewModel.state&&this.columns&&this.columns.length)return[this.renderSelectionColumn(),this.renderColumns()]}renderSelectionColumn(){return m("vaadin-grid-selection-column",{_selectAllHidden:!0,selectAll:!1,bind:this,hidden:!this.visibleElements.selectionColumn,sortable:!1,frozen:!p(this.container)})}renderColumns(){return this.columns.items.map(((e,t)=>m("vaadin-grid-column",{...this.getColumnProps(e,t)})))}getGridProps(){const{columnReorderingEnabled:e,id:t,pageSize:i,size:s}=this;return{_safari:!1,class:el.grid,id:`${t}_grid`,theme:"compact column-borders",ref:"grid",bind:this,afterCreate:this._afterGridCreate,afterUpdate:this._afterGridUpdate,columnReorderingAllowed:e,pageSize:i,size:s}}getColumnProps(e,t){const{id:i}=this,{autoWidth:s,direction:n,flexGrow:o,frozen:a,header:l,hidden:d,path:h,resizable:c,textAlign:u,width:p}=e;return{autoWidth:s,direction:n,flexGrow:o,frozen:a,header:l,hidden:d,key:`${i}_${l}_${r(t)?t:h}`,path:h,resizable:c,"text-align":u,width:"number"==typeof p?`${p}px`:p,bind:this,afterCreate:this._afterColumnCreate,afterRemoved:this._afterColumnRemoved}}clearSelection(){this._clearSelection(),this.scheduleRender()}clearSort(){let e=!1;if(this._grid&&this._grid._sorters&&this._grid._sorters.length&&(this._grid._sorters=[],e=!0),this.columns&&this.columns.length){!!this.columns.find((e=>!!e.direction))&&(this.columns.forEach((e=>e.direction=null)),e=!0)}e&&this.scheduleRender()}deselectItem(e){this._deselectRowByItem(e)}deselectRow(e){const t=this.viewModel.getRowItemAt(e);t&&this._deselectRowByItem(t)}findColumn(){}generateCellClassNames(){var e;null==(e=this._grid)||e.generateCellClassNames()}getSlotElementByName(e){var t,i;return null==(t=this._grid)||null==(i=t.shadowRoot)?void 0:i.querySelector(`slot[name='${e}']`)}hideColumn(e){var t;null==(t=this.viewModel)||t.hideColumn(e),this.scheduleRender()}notifyResize(){var e;null==(e=this._grid)||e.notifyResize()}recalculateColumnWidths(){var e;null==(e=this._grid)||e.recalculateColumnWidths()}async refresh(){var e;this._clearSelection(),await(null==(e=this.store)?void 0:e.reset()),this.scrollToTop()}refreshCache(){var e;null==(e=this._grid)||e.clearCache()}selectRows(e){const t=this._grid.selectedItems.slice();e.forEach((e=>{t.findIndex((t=>t.objectId===e.objectId))<0&&this._grid.selectedItems.push(e)})),this._updateSelectionProps(),this._grid.render()}deselectRows(e){const t=this._grid.selectedItems.slice();e.forEach((e=>{const i=t.findIndex((t=>t.objectId===e.objectId));i>-1&&t.splice(i,1)})),this._grid.selectedItems=t,this._updateSelectionProps(),this._grid.render()}selectItem(e){this._selectRowByItem(e)}selectRow(e){const t=this.viewModel.getRowItemAt(e);t&&this._selectRowByItem(t)}showColumn(e){var t;null==(t=this.viewModel)||t.showColumn(e),this.scheduleRender()}sort({path:e,direction:t}){var i;null==(i=this.viewModel)||i.sortColumn(e,t)}scrollToIndex(e){var t;null==(t=this._grid)||t.scrollToIndex(e)}scrollToTop(){var e;null==(e=this._grid)||e.scrollToIndex(0)}_afterGridCreate(e){const{cellClassNameGenerator:t,dataProvider:i,itemIdPath:s,rowDetailsRenderer:r}=this;e.cellClassNameGenerator=t,e.dataProvider=i,e.rowDetailsRenderer=r,e.itemIdPath=s,this._grid=e,customElements.whenDefined("vaadin-grid").then((()=>{this._appendStyles(),this._addGridEventListeners()}))}_afterGridUpdate(e){this._grid||(this._grid=e)}_afterColumnCreate(e){this._applyRenderersToColumnElement(e),this._columnElements.push(e)}_afterColumnRemoved(e){const t=this._columnElements.indexOf(e,0);t>-1&&this._columnElements.splice(t,1)}_syncColumnRenderers(){this._columnElements.forEach((e=>this._applyRenderersToColumnElement(e)))}_appendStyles(){var e;const t=null==(e=this._grid)?void 0:e.shadowRoot,i=document.createElement("style");i.textContent=`\n :host { ${this._hostStyles} }\n [part~="header-cell"] ::slotted(vaadin-grid-cell-content) { ${this._headerStyles} }\n [part~="row"]:hover [part~="body-cell"] { ${this._rowHoverStyles} }\n `,null==t||t.appendChild(i)}_updateGridSize(){this._grid&&(this._grid.size=this.size||0,this.scheduleRender())}_addGridEventListeners(){const{_grid:e}=this;this.handles.add([i(e,"click",(e=>this._onRowClick(e))),i(e,"selected-items-changed",(e=>this._onSelectionChange(e)))])}_onRowClick(e){const{_grid:t}=this,i=t.getEventContext(e),{item:s,section:r}=i;s&&r&&"details"!==r&&"header"!==r&&this.emit("row-click",{context:i,native:e})}_selectRowByItem(e){var t;null==(t=this._grid)||t.selectItem(e)}_deselectRowByItem(e){var t;null==(t=this._grid)||t.deselectItem(e)}_clearSelection(){var e,t;null!=(e=this._grid)&&null!=(t=e.selectedItems)&&t.length&&(this._grid.selectedItems=[],this._updateSelectionProps(),this._grid.render())}_onSelectionChange(e){const t=e;if("selectedItems.splices"===t.detail.path){const{removed:e,index:i,object:s}=t.detail.value.indexSplices[0];this._updateSelectionProps(),this.emit("selection-change",{index:i,added:s,removed:e})}}_updateSelectionProps(){this.selectedItems.length&&this.selectedItems.removeAll(),this._grid&&this.selectedItems.addMany(this._grid.selectedItems)}_applyRenderersToColumnElement(e){const t=e.getAttribute("path"),i=this.viewModel.findColumn(t);if(i)try{i.renderFunction&&(e.renderer=(e,t,s)=>i.renderFunction({root:e,column:t,rowData:s})),i.footerRenderFunction&&(e.footerRenderer=(e,t)=>i.footerRenderFunction({root:e,column:t})),i.headerRenderFunction&&(e.headerRenderer=(e,t)=>i.headerRenderFunction({root:e,column:t}))}catch(s){}}};e([d()],tl.prototype,"_grid",void 0),e([a("viewModel.cellClassNameGenerator")],tl.prototype,"cellClassNameGenerator",void 0),e([a("viewModel.columns")],tl.prototype,"columns",void 0),e([a("viewModel.columnReorderingEnabled")],tl.prototype,"columnReorderingEnabled",void 0),e([a("viewModel.dataProvider")],tl.prototype,"dataProvider",void 0),e([d()],tl.prototype,"itemIdPath",void 0),e([d({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],tl.prototype,"label",void 0),e([d(),_("esri/widgets/FeatureTable/t9n/FeatureTable")],tl.prototype,"messages",void 0),e([a("viewModel.pageSize")],tl.prototype,"pageSize",void 0),e([d({readOnly:!0})],tl.prototype,"selectedItems",void 0),e([a("viewModel.size")],tl.prototype,"size",void 0),e([a("viewModel.rowDetailsRenderer")],tl.prototype,"rowDetailsRenderer",void 0),e([a("viewModel.store")],tl.prototype,"store",void 0),e([d()],tl.prototype,"viewModel",void 0),e([d()],tl.prototype,"visibleElements",void 0),e([l("visibleElements")],tl.prototype,"castVisibleElements",null),e([a("viewModel.findColumn")],tl.prototype,"findColumn",null),tl=e([h("esri.widgets.FeatureTable.Grid.Grid")],tl);const il=tl;export{il as default};
|
|
959
|
+
`}static get is(){return"vaadin-grid-sort-column"}static get properties(){return{path:String,direction:{type:String,notify:!0}}}_prepareHeaderTemplate(){const e=this._prepareTemplatizer(this.$.headerTemplate);return e.templatizer.dataHost=this,e}_getHeader(e,t){return e||this._generateHeader(t)}}customElements.define(Ka.is,Ka);const Qa={selectionColumn:!0,columnMenus:!0},el={base:"esri-grid",content:"esri-grid__content",grid:"esri-grid__grid",noColumnMenu:"esri-grid--no-column-menu",widget:"esri-widget"};let tl=class extends(s(c)){constructor(e,i){super(e,i),this._grid=null,this._headerStyles="display: flex; font-weight: 400;",this._hostStyles='font-family: "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 1em; background-color: inherit; color: inherit;',this._rowHoverStyles="background-color: var(--lumo-row-background-hover);",this._columnElements=[],this.cellClassNameGenerator=null,this.columnReorderingEnabled=!0,this.dataProvider=null,this.itemIdPath=null,this.label=void 0,this.messages=null,this.pageSize=50,this.selectedItems=new t,this.size=null,this.rowDetailsRenderer=null,this.store=null,this.viewModel=new u,this.visibleElements={...Qa}}initialize(){this.handles.add([this.columns.on("change",(()=>this._syncColumnRenderers())),n(this,"viewModel.size",(()=>this._updateGridSize())),n(this,"store.state",((e,t)=>{"ready"!==e||"loaded"!==t&&"error"!==t||this.refreshCache()})),o(this,"_grid.$.table","scroll",(()=>{var e;null==(e=this.viewModel)||e.closeColumnMenus()}))])}destroy(){var e;this.handles.removeAll(),this.resetColumns(),null==(e=this.columns)||e.destroy()}resetColumns(){this.columns.items.forEach((e=>e.destroy())),this.columns.removeAll()}castVisibleElements(e){return{...Qa,...e}}render(){const{columnMenus:e}=this.visibleElements;return m("div",{bind:this,class:this.classes(el.base,el.widget,{[el.noColumnMenu]:!e})},m("div",{bind:this,class:el.content},this.renderGrid()))}renderGrid(){return m("vaadin-grid",{...this.getGridProps()},this.renderAllColumns())}renderAllColumns(){if("disabled"!==this.viewModel.state&&this.columns&&this.columns.length)return[this.renderSelectionColumn(),this.renderColumns()]}renderSelectionColumn(){return m("vaadin-grid-selection-column",{_selectAllHidden:!0,selectAll:!1,bind:this,hidden:!this.visibleElements.selectionColumn,sortable:!1,frozen:!p(this.container)})}renderColumns(){return this.columns.items.map(((e,t)=>m("vaadin-grid-column",{...this.getColumnProps(e,t)})))}getGridProps(){const{columnReorderingEnabled:e,id:t,pageSize:i,size:s}=this;return{_safari:!1,class:el.grid,id:`${t}_grid`,theme:"compact column-borders",ref:"grid",bind:this,afterCreate:this._afterGridCreate,afterUpdate:this._afterGridUpdate,columnReorderingAllowed:e,pageSize:i,size:s}}getColumnProps(e,t){const{id:i}=this,{autoWidth:s,direction:n,flexGrow:o,frozen:a,header:l,hidden:d,path:h,resizable:c,textAlign:u,width:p}=e;return{autoWidth:s,direction:n,flexGrow:o,frozen:a,header:l,hidden:d,key:`${i}_${l}_${r(t)?t:h}`,path:h,resizable:c,"text-align":u,width:"number"==typeof p?`${p}px`:p,bind:this,afterCreate:this._afterColumnCreate,afterRemoved:this._afterColumnRemoved}}clearSelection(){this._clearSelection(),this.scheduleRender()}clearSort(){let e=!1;if(this._grid&&this._grid._sorters&&this._grid._sorters.length&&(this._grid._sorters=[],e=!0),this.columns&&this.columns.length){!!this.columns.find((e=>!!e.direction))&&(this.columns.forEach((e=>e.direction=null)),e=!0)}e&&this.scheduleRender()}deselectItem(e){this._deselectRowByItem(e)}deselectRow(e){const t=this.viewModel.getRowItemAt(e);t&&this._deselectRowByItem(t)}findColumn(){}generateCellClassNames(){var e;null==(e=this._grid)||e.generateCellClassNames()}getSlotElementByName(e){var t,i;return null==(t=this._grid)||null==(i=t.shadowRoot)?void 0:i.querySelector(`slot[name='${e}']`)}hideColumn(e){var t;null==(t=this.viewModel)||t.hideColumn(e),this.scheduleRender()}notifyResize(){var e;null==(e=this._grid)||e.notifyResize()}recalculateColumnWidths(){var e;null==(e=this._grid)||e.recalculateColumnWidths()}async refresh(){var e;this._clearSelection(),await(null==(e=this.store)?void 0:e.reset()),this.scrollToTop()}refreshCache(){var e;null==(e=this._grid)||e.clearCache()}selectRows(e){const t=this._grid.selectedItems.slice();e.forEach((e=>{t.findIndex((t=>t.objectId===e.objectId))<0&&this._grid.selectedItems.push(e)})),this._updateSelectionProps(),this._grid.render()}deselectRows(e){const t=this._grid.selectedItems.slice();e.forEach((e=>{const i=t.findIndex((t=>t.objectId===e.objectId));i>-1&&t.splice(i,1)})),this._grid.selectedItems=t,this._updateSelectionProps(),this._grid.render()}selectItem(e){this._selectRowByItem(e)}selectRow(e){const t=this.viewModel.getRowItemAt(e);t&&this._selectRowByItem(t)}showColumn(e){var t;null==(t=this.viewModel)||t.showColumn(e),this.scheduleRender()}sort({path:e,direction:t}){var i;null==(i=this.viewModel)||i.sortColumn(e,t)}scrollToIndex(e){var t;null==(t=this._grid)||t.scrollToIndex(e)}scrollToTop(){var e;null==(e=this._grid)||e.scrollToIndex(0)}_afterGridCreate(e){const{cellClassNameGenerator:t,dataProvider:i,itemIdPath:s,rowDetailsRenderer:r}=this;e.cellClassNameGenerator=t,e.dataProvider=i,e.rowDetailsRenderer=r,e.itemIdPath=s,this._grid=e,customElements.whenDefined("vaadin-grid").then((()=>{this._appendStyles(),this._addGridEventListeners()}))}_afterGridUpdate(e){this._grid||(this._grid=e)}_afterColumnCreate(e){this._applyRenderersToColumnElement(e),this._columnElements.push(e)}_afterColumnRemoved(e){const t=this._columnElements.indexOf(e,0);t>-1&&this._columnElements.splice(t,1)}_syncColumnRenderers(){this._columnElements.forEach((e=>this._applyRenderersToColumnElement(e)))}_appendStyles(){var e;const t=null==(e=this._grid)?void 0:e.shadowRoot,i=document.createElement("style");i.textContent=`\n :host { ${this._hostStyles} }\n [part~="header-cell"] ::slotted(vaadin-grid-cell-content) { ${this._headerStyles} }\n [part~="row"]:hover [part~="body-cell"] { ${this._rowHoverStyles} }\n `,null==t||t.appendChild(i)}_updateGridSize(){this._grid&&(this._grid.size=this.size||0,this.scheduleRender())}_addGridEventListeners(){const{_grid:e}=this;this.handles.add([i(e,"click",(e=>this._onRowClick(e))),i(e,"selected-items-changed",(e=>this._onSelectionChange(e)))])}_onRowClick(e){const{_grid:t}=this,i=t.getEventContext(e),{item:s,section:r}=i;s&&r&&"details"!==r&&"header"!==r&&this.emit("row-click",{context:i,native:e})}_selectRowByItem(e){var t;null==(t=this._grid)||t.selectItem(e)}_deselectRowByItem(e){var t;null==(t=this._grid)||t.deselectItem(e)}_clearSelection(){var e,t;null!=(e=this._grid)&&null!=(t=e.selectedItems)&&t.length&&(this._grid.selectedItems=[],this._updateSelectionProps(),this._grid.render())}_onSelectionChange(e){const t=e;if("selectedItems.splices"===t.detail.path){const{removed:e,index:i,object:s}=t.detail.value.indexSplices[0];this._updateSelectionProps(),this.emit("selection-change",{index:i,added:s,removed:e})}}_updateSelectionProps(){this.selectedItems.length&&this.selectedItems.removeAll(),this._grid&&this.selectedItems.addMany(this._grid.selectedItems)}_applyRenderersToColumnElement(e){const t=e.getAttribute("path"),i=this.viewModel.findColumn(t);if(i)try{i.renderFunction&&(e.renderer=(e,t,s)=>i.renderFunction({root:e,column:t,rowData:s})),i.footerRenderFunction&&(e.footerRenderer=(e,t)=>i.footerRenderFunction({root:e,column:t})),i.headerRenderFunction&&(e.headerRenderer=(e,t)=>i.headerRenderFunction({root:e,column:t}))}catch(s){}}};e([d()],tl.prototype,"_grid",void 0),e([a("viewModel.cellClassNameGenerator")],tl.prototype,"cellClassNameGenerator",void 0),e([a("viewModel.columns")],tl.prototype,"columns",void 0),e([a("viewModel.columnReorderingEnabled")],tl.prototype,"columnReorderingEnabled",void 0),e([a("viewModel.dataProvider")],tl.prototype,"dataProvider",void 0),e([d()],tl.prototype,"itemIdPath",void 0),e([d({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],tl.prototype,"label",void 0),e([d(),_("esri/widgets/FeatureTable/t9n/FeatureTable")],tl.prototype,"messages",void 0),e([a("viewModel.pageSize")],tl.prototype,"pageSize",void 0),e([d({readOnly:!0})],tl.prototype,"selectedItems",void 0),e([a("viewModel.size")],tl.prototype,"size",void 0),e([a("viewModel.rowDetailsRenderer")],tl.prototype,"rowDetailsRenderer",void 0),e([a("viewModel.store")],tl.prototype,"store",void 0),e([d()],tl.prototype,"viewModel",void 0),e([d()],tl.prototype,"visibleElements",void 0),e([l("visibleElements")],tl.prototype,"castVisibleElements",null),e([a("viewModel.findColumn")],tl.prototype,"findColumn",null),tl=e([h("esri.widgets.FeatureTable.Grid.Grid")],tl);const il=tl;export{il as default};
|
package/widgets/FeatureTable.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{HandleOwnerMixin as l}from"../core/HandleOwner.js";import{on as o,watch as s}from"../core/watchUtils.js";import{aliasOf as i}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as n}from"../core/accessorSupport/decorators/cast.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import d from"./Widget.js";import u from"./FeatureTable/FeatureTableViewModel.js";import c from"./FeatureTable/Grid/support/ButtonMenu.js";import m from"./FeatureTable/Grid/support/ButtonMenuItem.js";import"./support/widgetUtils.js";import{messageBundle as h}from"./support/decorators/messageBundle.js";import"../core/Logger.js";import{tsx as p}from"./support/jsxFactory.js";import{onLocaleChange as g}from"../intl/locale.js";import{substitute as v}from"../intl/substitute.js";import{fetchMessageBundle as w}from"../intl/messages.js";const b={header:!0,menu:!0,menuItems:{clearSelection:!0,refreshData:!0,toggleColumns:!0},selectionColumn:!0},f={base:"esri-feature-table",header:"esri-feature-table__header",title:"esri-feature-table__title",content:"esri-feature-table__content",loader:"esri-feature-table__loader",loaderContainer:"esri-feature-table__loader-container",menuContainer:"esri-feature-table__menu",menuIcon:"esri-icon-handle-horizontal",menuItemGroupOpenedIcon:"esri-icon-down",menuItemGroupClosedIcon:"esri-icon-right",checkmarkIcon:"esri-icon-check-mark",widget:"esri-widget"};let M=class extends(l(d)){constructor(e,l){super(e,l),this.attachmentsEnabled=null,this.columns=new t,this.editingEnabled=null,this.fieldConfigs=null,this.filterGeometry=null,this.grid=null,this.highlightOnRowSelectEnabled=!0,this.label=void 0,this.layer=null,this.messages=null,this.menu=null,this.menuConfig=null,this.pageSize=50,this.view=null,this.viewModel=new u,this.visibleElements={...b}}initialize(){var e,t,l;const i=async()=>this.messages=await w("esri/widgets/FeatureTable/t9n/FeatureTable");i(),this.handles.add([g(i),o(this,"grid.selectedItems","change",(e=>this._onSelectionChange(e))),s(this,["viewModel.store.querying","viewModel.store.syncing","grid.size"],(()=>this.scheduleRender())),o(this,"viewModel.columns","change",(()=>this._updateMenuItems())),s(this,"menuConfig",(()=>this._syncMenuConfig())),s(this,"messages",(()=>{var e;this.menu.label=null==(e=this.messages)?void 0:e.options,this._updateMenuItems()}))]),this._set("menu",new c({label:null==(e=this.messages)?void 0:e.options,iconClass:f.menuIcon,...this.menuConfig}));const{attachmentsEnabled:n,relatedRecordsEnabled:r}=this;null==(t=this.viewModel)||null==(l=t.store)||l.set({attachmentsEnabled:n,relatedRecordsEnabled:r})}destroy(){var e;this.clearSelection(),this.handles.removeAll(),null==(e=this.menu)||e.destroy()}castVisibleElements(e){var t;const l={...b,...e};return null==(t=this.grid)||t.set("visibleElements",{...this.grid.visibleElements,selectionColumn:l.selectionColumn}),l}clearHighlights(){}clearSelection(){}deselectRows(){}hideColumn(e){var t;null==(t=this.grid)||t.hideColumn(e),this._updateMenuItems()}refresh(){}showColumn(e){var t;null==(t=this.grid)||t.showColumn(e),this._updateMenuItems()}sortColumn(){}selectRows(){}scrollToIndex(){}render(){var e;return p("div",{bind:this,class:this.classes(f.base,f.widget)},this.visibleElements.header?this._renderHeader():null,p("div",{class:f.content},"disabled"!==this.state&&(null==(e=this.grid)?void 0:e.render())))}_renderHeader(){return p("div",{key:"header",class:f.header},this._renderLoader(),this._renderTitle(),this.visibleElements.menu?this._renderMenu():null)}_renderTitle(){return p("div",{class:f.title,key:"title"},this._getTitle())}_getTitle(){const{grid:e,layer:{title:t},messages:l,viewModel:{size:o}}=this;return e?v(l.header,{title:t,count:o,selected:e.selectedItems.length||0}):""}_renderLoader(){const{state:e,store:t}=this.viewModel,l="loading"===e||t.syncing||t.querying;return p("div",{class:f.loaderContainer},l?p("div",{class:f.loader,key:"loader"}):null)}_renderMenu(){return p("div",{class:f.menuContainer},this.menu.render())}_onSelectionChange(e){const{added:t,removed:l}=e;this.emit("selection-change",{added:[...t],removed:[...l]})}_syncMenuConfig(){var e;null==(e=this.menu)||e.set({...this.menuConfig,items:this._getMenuItems()})}_updateMenuItems(){var e;null==(e=this.menu)||e.set("items",this._getMenuItems())}_getMenuItems(){var e;const t=null==(e=this.menuConfig)?void 0:e.items,l=this._getDefaultMenuItems(),o=[];return(null==l?void 0:l.length)&&o.push(...l),(null==t?void 0:t.length)&&o.push(...t),o}_getDefaultMenuItems(){var e;const{messages:t,viewModel:l,visibleElements:o}=this,{menuItems:s}=o,i=[];return(null==s?void 0:s.clearSelection)&&i.push(new m({selectionEnabled:!1,label:null==t?void 0:t.clearSelection,clickFunction:()=>this.clearSelection()})),(null==s?void 0:s.refreshData)&&i.push(new m({selectionEnabled:!1,label:null==t?void 0:t.refreshData,clickFunction:()=>this.refresh()})),(null==s?void 0:s.toggleColumns)&&i.push(new m({iconClass:f.menuItemGroupClosedIcon,label:null==t?void 0:t.toggleColumns,clickFunction:this._toggleMenuItemSelectedIcon,items:null==l||null==(e=l.columns)?void 0:e.items.map((({header:e,hidden:t,path:l})=>new m({label:e||l,selected:!t,selectionEnabled:!0,iconClass:f.checkmarkIcon,clickFunction:()=>this._toggleColumnFromMenuItem(l)})))})),i.length?i:null}_toggleMenuItemSelectedIcon({item:e}){null==e||e.set("iconClass",null!=e&&e.selected?f.menuItemGroupOpenedIcon:f.menuItemGroupClosedIcon)}_toggleColumnFromMenuItem(e){const{grid:t,viewModel:l}=this,o=l.findColumn(e);null!=o&&o.hidden?t.showColumn(e):t.hideColumn(e)}};e([i("viewModel.attachmentsEnabled")],M.prototype,"attachmentsEnabled",void 0),e([i("viewModel.columns")],M.prototype,"columns",void 0),e([i("viewModel.editingEnabled")],M.prototype,"editingEnabled",void 0),e([i("viewModel.fieldConfigs")],M.prototype,"fieldConfigs",void 0),e([i("viewModel.filterGeometry")],M.prototype,"filterGeometry",void 0),e([i("viewModel.grid")],M.prototype,"grid",void 0),e([i("viewModel.highlightOnRowSelectEnabled")],M.prototype,"highlightOnRowSelectEnabled",void 0),e([r({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],M.prototype,"label",void 0),e([i("viewModel.layer")],M.prototype,"layer",void 0),e([r(),h("esri/widgets/FeatureTable/t9n/FeatureTable")],M.prototype,"messages",void 0),e([r({readOnly:!0})],M.prototype,"menu",void 0),e([r()],M.prototype,"menuConfig",void 0),e([i("viewModel.pageSize")],M.prototype,"pageSize",void 0),e([i("viewModel.relatedRecordsEnabled")],M.prototype,"relatedRecordsEnabled",void 0),e([i("viewModel.state")],M.prototype,"state",void 0),e([i("viewModel.view")],M.prototype,"view",void 0),e([r()],M.prototype,"viewModel",void 0),e([r()],M.prototype,"visibleElements",void 0),e([n("visibleElements")],M.prototype,"castVisibleElements",null),e([i("viewModel.clearHighlights")],M.prototype,"clearHighlights",null),e([i("viewModel.clearSelection")],M.prototype,"clearSelection",null),e([i("viewModel.deselectRows")],M.prototype,"deselectRows",null),e([i("viewModel.refresh")],M.prototype,"refresh",null),e([i("viewModel.sortColumn")],M.prototype,"sortColumn",null),e([i("viewModel.selectRows")],M.prototype,"selectRows",null),e([i("viewModel.scrollToIndex")],M.prototype,"scrollToIndex",null),M=e([a("esri.widgets.FeatureTable")],M);const y=M;export{y as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{HandleOwnerMixin as l}from"../core/HandleOwner.js";import{on as o,watch as s}from"../core/watchUtils.js";import{aliasOf as i}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as n}from"../core/accessorSupport/decorators/cast.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import d from"./Widget.js";import u from"./FeatureTable/FeatureTableViewModel.js";import c from"./FeatureTable/Grid/support/ButtonMenu.js";import m from"./FeatureTable/Grid/support/ButtonMenuItem.js";import"./support/widgetUtils.js";import{messageBundle as h}from"./support/decorators/messageBundle.js";import"../core/Logger.js";import{tsx as p}from"./support/jsxFactory.js";import{onLocaleChange as g}from"../intl/locale.js";import{substitute as v}from"../intl/substitute.js";import{fetchMessageBundle as w}from"../intl/messages.js";const b={header:!0,menu:!0,menuItems:{clearSelection:!0,refreshData:!0,toggleColumns:!0},selectionColumn:!0,columnMenus:!0},f={base:"esri-feature-table",header:"esri-feature-table__header",title:"esri-feature-table__title",content:"esri-feature-table__content",loader:"esri-feature-table__loader",loaderContainer:"esri-feature-table__loader-container",menuContainer:"esri-feature-table__menu",menuIcon:"esri-icon-handle-horizontal",menuItemGroupOpenedIcon:"esri-icon-down",menuItemGroupClosedIcon:"esri-icon-right",checkmarkIcon:"esri-icon-check-mark",widget:"esri-widget"};let M=class extends(l(d)){constructor(e,l){super(e,l),this.attachmentsEnabled=null,this.columns=new t,this.editingEnabled=null,this.fieldConfigs=null,this.filterGeometry=null,this.grid=null,this.highlightOnRowSelectEnabled=!0,this.label=void 0,this.layer=null,this.messages=null,this.menu=null,this.menuConfig=null,this.pageSize=50,this.view=null,this.viewModel=new u,this.visibleElements={...b}}initialize(){var e,t,l;const i=async()=>this.messages=await w("esri/widgets/FeatureTable/t9n/FeatureTable");i(),this.handles.add([g(i),o(this,"grid.selectedItems","change",(e=>this._onSelectionChange(e))),s(this,["viewModel.store.querying","viewModel.store.syncing","grid.size"],(()=>this.scheduleRender())),o(this,"viewModel.columns","change",(()=>this._updateMenuItems())),s(this,"menuConfig",(()=>this._syncMenuConfig())),s(this,"messages",(()=>{var e;this.menu.label=null==(e=this.messages)?void 0:e.options,this._updateMenuItems()}))]),this._set("menu",new c({label:null==(e=this.messages)?void 0:e.options,iconClass:f.menuIcon,...this.menuConfig}));const{attachmentsEnabled:n,relatedRecordsEnabled:r}=this;null==(t=this.viewModel)||null==(l=t.store)||l.set({attachmentsEnabled:n,relatedRecordsEnabled:r})}destroy(){var e;this.clearSelection(),this.handles.removeAll(),null==(e=this.menu)||e.destroy()}castVisibleElements(e){var t;const l={...b,...e};return null==(t=this.grid)||t.set("visibleElements",{...this.grid.visibleElements,selectionColumn:l.selectionColumn,columnMenus:l.columnMenus}),l}clearHighlights(){}clearSelection(){}deselectRows(){}hideColumn(e){var t;null==(t=this.grid)||t.hideColumn(e),this._updateMenuItems()}refresh(){}showColumn(e){var t;null==(t=this.grid)||t.showColumn(e),this._updateMenuItems()}sortColumn(){}selectRows(){}scrollToIndex(){}render(){var e;return p("div",{bind:this,class:this.classes(f.base,f.widget)},this.visibleElements.header?this._renderHeader():null,p("div",{class:f.content},"disabled"!==this.state&&(null==(e=this.grid)?void 0:e.render())))}_renderHeader(){return p("div",{key:"header",class:f.header},this._renderLoader(),this._renderTitle(),this.visibleElements.menu?this._renderMenu():null)}_renderTitle(){return p("div",{class:f.title,key:"title"},this._getTitle())}_getTitle(){const{grid:e,layer:{title:t},messages:l,viewModel:{size:o}}=this;return e?v(l.header,{title:t,count:o,selected:e.selectedItems.length||0}):""}_renderLoader(){const{state:e,store:t}=this.viewModel,l="loading"===e||t.syncing||t.querying;return p("div",{class:f.loaderContainer},l?p("div",{class:f.loader,key:"loader"}):null)}_renderMenu(){return p("div",{class:f.menuContainer},this.menu.render())}_onSelectionChange(e){const{added:t,removed:l}=e;this.emit("selection-change",{added:[...t],removed:[...l]})}_syncMenuConfig(){var e;null==(e=this.menu)||e.set({...this.menuConfig,items:this._getMenuItems()})}_updateMenuItems(){var e;null==(e=this.menu)||e.set("items",this._getMenuItems())}_getMenuItems(){var e;const t=null==(e=this.menuConfig)?void 0:e.items,l=this._getDefaultMenuItems(),o=[];return(null==l?void 0:l.length)&&o.push(...l),(null==t?void 0:t.length)&&o.push(...t),o}_getDefaultMenuItems(){var e;const{messages:t,viewModel:l,visibleElements:o}=this,{menuItems:s}=o,i=[];return(null==s?void 0:s.clearSelection)&&i.push(new m({selectionEnabled:!1,label:null==t?void 0:t.clearSelection,clickFunction:()=>this.clearSelection()})),(null==s?void 0:s.refreshData)&&i.push(new m({selectionEnabled:!1,label:null==t?void 0:t.refreshData,clickFunction:()=>this.refresh()})),(null==s?void 0:s.toggleColumns)&&i.push(new m({iconClass:f.menuItemGroupClosedIcon,label:null==t?void 0:t.toggleColumns,clickFunction:this._toggleMenuItemSelectedIcon,items:null==l||null==(e=l.columns)?void 0:e.items.map((({header:e,hidden:t,path:l})=>new m({label:e||l,selected:!t,selectionEnabled:!0,iconClass:f.checkmarkIcon,clickFunction:()=>this._toggleColumnFromMenuItem(l)})))})),i.length?i:null}_toggleMenuItemSelectedIcon({item:e}){null==e||e.set("iconClass",null!=e&&e.selected?f.menuItemGroupOpenedIcon:f.menuItemGroupClosedIcon)}_toggleColumnFromMenuItem(e){const{grid:t,viewModel:l}=this,o=l.findColumn(e);null!=o&&o.hidden?t.showColumn(e):t.hideColumn(e)}};e([i("viewModel.attachmentsEnabled")],M.prototype,"attachmentsEnabled",void 0),e([i("viewModel.columns")],M.prototype,"columns",void 0),e([i("viewModel.editingEnabled")],M.prototype,"editingEnabled",void 0),e([i("viewModel.fieldConfigs")],M.prototype,"fieldConfigs",void 0),e([i("viewModel.filterGeometry")],M.prototype,"filterGeometry",void 0),e([i("viewModel.grid")],M.prototype,"grid",void 0),e([i("viewModel.highlightOnRowSelectEnabled")],M.prototype,"highlightOnRowSelectEnabled",void 0),e([r({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],M.prototype,"label",void 0),e([i("viewModel.layer")],M.prototype,"layer",void 0),e([r(),h("esri/widgets/FeatureTable/t9n/FeatureTable")],M.prototype,"messages",void 0),e([r({readOnly:!0})],M.prototype,"menu",void 0),e([r()],M.prototype,"menuConfig",void 0),e([i("viewModel.pageSize")],M.prototype,"pageSize",void 0),e([i("viewModel.relatedRecordsEnabled")],M.prototype,"relatedRecordsEnabled",void 0),e([i("viewModel.state")],M.prototype,"state",void 0),e([i("viewModel.view")],M.prototype,"view",void 0),e([r()],M.prototype,"viewModel",void 0),e([r()],M.prototype,"visibleElements",void 0),e([n("visibleElements")],M.prototype,"castVisibleElements",null),e([i("viewModel.clearHighlights")],M.prototype,"clearHighlights",null),e([i("viewModel.clearSelection")],M.prototype,"clearSelection",null),e([i("viewModel.deselectRows")],M.prototype,"deselectRows",null),e([i("viewModel.refresh")],M.prototype,"refresh",null),e([i("viewModel.sortColumn")],M.prototype,"sortColumn",null),e([i("viewModel.selectRows")],M.prototype,"selectRows",null),e([i("viewModel.scrollToIndex")],M.prototype,"scrollToIndex",null),M=e([a("esri.widgets.FeatureTable")],M);const y=M;export{y as default};
|