@arcgis/core 4.29.0-next.20240222 → 4.29.0
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/0bc21d2a0b65bd4e9d76.js +1 -0
- package/assets/esri/core/workers/chunks/9307d485a9e5f9fa77d1.js +1 -0
- package/assets/esri/core/workers/chunks/{e7b26c7e9e24dc6255be.js → cacf97b0a7a1057b9f79.js} +1 -1
- package/config.js +1 -1
- package/copyright.txt +56 -28
- package/geometry/support/meshUtils/rotate.js +1 -1
- package/interfaces.d.ts +6 -6
- package/kernel.js +1 -1
- package/layers/orientedImagery/core/CameraOrientation.js +1 -1
- package/layers/orientedImagery/core/ElevationSourceDefinitions.js +1 -1
- package/layers/orientedImagery/transformations/imageToWorld.js +5 -0
- package/layers/orientedImagery/transformations/updateElevation.js +5 -0
- package/layers/orientedImagery/transformations/updateElevationUtils.js +5 -0
- package/layers/orientedImagery/transformations/utils.js +1 -1
- package/layers/orientedImagery/transformations/worldToImage.js +5 -0
- package/layers/support/EditingCapabilities.js +1 -1
- package/layers/support/editableLayers.js +1 -1
- package/package.json +1 -1
- package/smartMapping/renderers/pieChart.js +1 -1
- package/support/revision.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/layers/support/editableLayerViews.js +5 -0
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/support/EditorEditingCapabilities.js +1 -1
- package/widgets/Editor/support/EditorItem.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace.js +1 -1
- package/assets/esri/core/workers/chunks/25f73748df0ee82d06cb.js +0 -1
- package/assets/esri/core/workers/chunks/2d7a18f8c540269ecee9.js +0 -1
package/config.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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"./core/has.js";import{deepMerge as e}from"./core/object.js";
|
|
5
|
+
import"./core/has.js";import{deepMerge as e}from"./core/object.js";const s={apiKey:void 0,applicationName:"",applicationUrl:globalThis.location?.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",userPrivilegesApplied:!0,portalUrl:"https://www.arcgis.com",routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{crossOriginNoCorsDomains:null,httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],maxUrlLength:2e3,priority:"high",proxyRules:[],proxyUrl:null,timeout:6e4,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(s,globalThis.esriConfig,!0),delete s.has),!s.assetsPath){{const e="4.29";s.assetsPath=`https://js.arcgis.com/${e}/@arcgis/core/assets`}s.defaultAssetsPath=s.assetsPath}export{s as default};
|
package/copyright.txt
CHANGED
|
@@ -172,34 +172,6 @@ THE SOFTWARE.
|
|
|
172
172
|
|
|
173
173
|
-----------------------------------------------------------------
|
|
174
174
|
|
|
175
|
-
libpannellum.js
|
|
176
|
-
pannellum.js
|
|
177
|
-
|
|
178
|
-
https://github.com/mpetroff/pannellum/
|
|
179
|
-
|
|
180
|
-
MIT License
|
|
181
|
-
|
|
182
|
-
Copyright (c) 2011-2022 Matthew Petroff
|
|
183
|
-
|
|
184
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
185
|
-
this software and associated documentation files (the "Software"), to deal in
|
|
186
|
-
the Software without restriction, including without limitation the rights to
|
|
187
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
188
|
-
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
189
|
-
subject to the following conditions:
|
|
190
|
-
|
|
191
|
-
The above copyright notice and this permission notice shall be included in all
|
|
192
|
-
copies or substantial portions of the Software.
|
|
193
|
-
|
|
194
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
195
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
196
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
197
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
198
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
199
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
200
|
-
|
|
201
|
-
-----------------------------------------------------------------
|
|
202
|
-
|
|
203
175
|
esri/libs/popper
|
|
204
176
|
|
|
205
177
|
The MIT License (MIT)
|
|
@@ -1234,3 +1206,59 @@ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
|
1234
1206
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
1235
1207
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
1236
1208
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1209
|
+
|
|
1210
|
+
-----------------------------------------------------------------
|
|
1211
|
+
|
|
1212
|
+
stencil/
|
|
1213
|
+
|
|
1214
|
+
https://github.com/ionic-team/stencil
|
|
1215
|
+
|
|
1216
|
+
The MIT License (MIT)
|
|
1217
|
+
|
|
1218
|
+
Copyright (c) 2019-present Drifty Co.
|
|
1219
|
+
|
|
1220
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1221
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
1222
|
+
in the Software without restriction, including without limitation the rights
|
|
1223
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1224
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
1225
|
+
furnished to do so, subject to the following conditions:
|
|
1226
|
+
|
|
1227
|
+
The above copyright notice and this permission notice shall be included in
|
|
1228
|
+
all copies or substantial portions of the Software.
|
|
1229
|
+
|
|
1230
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1231
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1232
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1233
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1234
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1235
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1236
|
+
THE SOFTWARE.
|
|
1237
|
+
|
|
1238
|
+
-----------------------------------------------------------------
|
|
1239
|
+
|
|
1240
|
+
monaco-editor/
|
|
1241
|
+
|
|
1242
|
+
https://github.com/microsoft/monaco-editor
|
|
1243
|
+
|
|
1244
|
+
The MIT License (MIT)
|
|
1245
|
+
|
|
1246
|
+
Copyright (c) 2016 - present Microsoft Corporation
|
|
1247
|
+
|
|
1248
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1249
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
1250
|
+
in the Software without restriction, including without limitation the rights
|
|
1251
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1252
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
1253
|
+
furnished to do so, subject to the following conditions:
|
|
1254
|
+
|
|
1255
|
+
The above copyright notice and this permission notice shall be included in all
|
|
1256
|
+
copies or substantial portions of the Software.
|
|
1257
|
+
|
|
1258
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1259
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1260
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1261
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1262
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1263
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1264
|
+
SOFTWARE.
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
5
|
+
import e from"../../../core/Logger.js";import{fromMat4 as t}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as r}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromRotation as o}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as i}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{f as n,g as a,t as s,e as l}from"../../../chunks/vec32.js";import{create as c,ZEROS as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getSphericalPCPF as m}from"../../spatialReferenceEllipsoidUtils.js";import{computeTranslationToOriginAndRotation as f}from"../../projection/computeTranslationToOriginAndRotation.js";import{projectPointToVector as g}from"../../projection/projectPointToVector.js";import{create as u,compose as j,axis as x,angleRad as d}from"../axisAngleDegrees.js";import b from"../MeshTransform.js";import{isRelativeVertexSpace as h}from"../meshVertexSpaceUtils.js";import{usesLocalTangentPlaneOnECEFForOperations as v}from"./geographicUtils.js";import{projectToPCPF as A,projectNormalToPCPF as w,projectTangentToPCPF as y,projectFromPCPF as R,projectNormalFromPCPF as k,projectTangentFromPCPF as L}from"./projection.js";const F="esri.geometry.support.meshUtils.rotate";function T(e,t,r){if(!e.vertexAttributes?.position||0===t[3])return;const{spatialReference:o,vertexSpace:i}=e,n=r?.origin??e.anchor,a=r?.geographic;if(h(i))U(e,t,n);else{v(F,i,o,a)?$(e,t,n):P(e,t,n)}}function U(t,r,o){t.transform??=new b;const{vertexSpace:i,transform:s}=t,l=i.origin,p=C;if(!g(o,p,t.spatialReference))return void e.getLogger(F).error(`Failed to project specified origin (wkid:${o.spatialReference.wkid}) to mesh spatial reference (wkid:${t.spatialReference.wkid}). Projection may be possible after calling projection.load().`);const m=n(C,p,l),f=s.applyLocalInverse(m,I);s.rotation=j(s.rotation,r,u());const x=s.applyLocalInverse(m,V),d=n(C,x,f),h=s.applyLocal(d,C);s.translation=a(c(),s.translation,h)}function $(e,r,o){const i=e.spatialReference,n=m(i),a=M;g(o,a,n)||g(e.origin,a,n);const l=e.vertexAttributes.position,c=e.vertexAttributes.normal,p=e.vertexAttributes.tangent,u=new Float64Array(l.length),j=null!=c?new Float32Array(c.length):null,d=null!=p?new Float32Array(p.length):null;f(n,a,D,n),t(E,D);const b=z;s(x(z),x(r),E),b[3]=r[3],A(l,i,u),null!=c&&null!=j&&w(c,l,u,i,j),null!=p&&null!=d&&y(p,l,u,i,d),S(u,b,3,a),R(u,l,i),null!=c&&null!=j&&(S(j,b,3),k(j,l,u,i,c)),null!=p&&null!=d&&(S(d,b,4),L(d,l,u,i,p)),e.vertexAttributesChanged()}function P(t,r,o){const i=M;if(!g(o,i,t.spatialReference)){const r=t.origin;i[0]=r.x,i[1]=r.y,i[2]=r.z,e.getLogger(F).error(`Failed to project specified origin (wkid:${o.spatialReference.wkid}) to mesh spatial reference (wkid:${t.spatialReference.wkid}). Projection may be possible after calling projection.load().`)}S(t.vertexAttributes.position,r,3,i),S(t.vertexAttributes.normal,r,3),S(t.vertexAttributes.tangent,r,4),t.vertexAttributesChanged()}function S(e,t,r,i=p){if(null!=e){o(D,d(t),x(t));for(let t=0;t<e.length;t+=r){for(let r=0;r<3;r++)C[r]=e[t+r]-i[r];l(C,C,D);for(let r=0;r<3;r++)e[t+r]=C[r]+i[r]}}}const C=c(),I=c(),V=c(),z=u(),D=i(),E=r(),M=c();export{T as rotate};
|
package/interfaces.d.ts
CHANGED
|
@@ -7276,7 +7276,7 @@ declare namespace __esri {
|
|
|
7276
7276
|
*/
|
|
7277
7277
|
readonly type: "georeferenced";
|
|
7278
7278
|
/**
|
|
7279
|
-
* A
|
|
7279
|
+
* A mesh vertex space that indicates mesh vertices to be either absolute georeferenced map coordinates or relative offsets in map space to a fully georeferenced origin.
|
|
7280
7280
|
*
|
|
7281
7281
|
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-MeshGeoreferencedVertexSpace.html)
|
|
7282
7282
|
*/
|
|
@@ -7310,7 +7310,7 @@ declare namespace __esri {
|
|
|
7310
7310
|
*/
|
|
7311
7311
|
readonly type: "local";
|
|
7312
7312
|
/**
|
|
7313
|
-
* A
|
|
7313
|
+
* A mesh vertex space that indicates mesh vertices to be in a plain cartesian space as often encountered in 3D modeling and CAD applications.
|
|
7314
7314
|
*
|
|
7315
7315
|
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-MeshLocalVertexSpace.html)
|
|
7316
7316
|
*/
|
|
@@ -45913,7 +45913,7 @@ declare namespace __esri {
|
|
|
45913
45913
|
|
|
45914
45914
|
export class UniqueValueRenderer {
|
|
45915
45915
|
/**
|
|
45916
|
-
* This property is only relevant
|
|
45916
|
+
* This property is only relevant when symbolizing polygon features with marker symbols (or [IconSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html)) in the [uniqueValueInfos](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#uniqueValueInfos) of this renderer.
|
|
45917
45917
|
*
|
|
45918
45918
|
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#backgroundFillSymbol)
|
|
45919
45919
|
*/
|
|
@@ -46033,7 +46033,7 @@ declare namespace __esri {
|
|
|
46033
46033
|
|
|
46034
46034
|
interface UniqueValueRendererProperties extends RendererProperties, VisualVariablesMixinProperties {
|
|
46035
46035
|
/**
|
|
46036
|
-
* This property is only relevant
|
|
46036
|
+
* This property is only relevant when symbolizing polygon features with marker symbols (or [IconSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html)) in the [uniqueValueInfos](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#uniqueValueInfos) of this renderer.
|
|
46037
46037
|
*
|
|
46038
46038
|
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#backgroundFillSymbol)
|
|
46039
46039
|
*/
|
|
@@ -111318,11 +111318,11 @@ declare namespace __esri {
|
|
|
111318
111318
|
*/
|
|
111319
111319
|
duplicate(): void;
|
|
111320
111320
|
/**
|
|
111321
|
-
* Allows creation of a graphic similar to create with the difference that
|
|
111321
|
+
* Allows creation of a graphic similar to create with the difference that the geometry can be provided directly for the graphic being created.
|
|
111322
111322
|
*
|
|
111323
111323
|
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#place)
|
|
111324
111324
|
*/
|
|
111325
|
-
place(): void;
|
|
111325
|
+
place(geometry: Mesh): void;
|
|
111326
111326
|
/**
|
|
111327
111327
|
* Incrementally redo actions recorded in the stack.
|
|
111328
111328
|
*
|
package/kernel.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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";import{buildDate as s,commitHash as e}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const r="4.29";let t,
|
|
5
|
+
import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";import{buildDate as s,commitHash as e}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const r="4.29";let t,i=r;i="4.29.0";function n(o){t=o}function m(s){const e=t?.findCredential(s);return e?.token?o(s,"token",e.token):s}has("host-webworker");export{m as addTokenParameter,s as buildDate,i as fullVersion,t as id,e as revision,n as setId,r as version};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as
|
|
5
|
+
import{_ as t}from"../../../chunks/tslib.es6.js";import o from"../../../core/Accessor.js";import{property as e}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import{getHeightModel as i,getVerticalUnit as s,getHorizontalUnit as n}from"../constants/utils.js";let p=class extends o{constructor(){super(...arguments),this.verticalWKID=null}get isAdvanced(){const{affineTransformations:t,focalLength:o,principalOffsetPoint:e,radialDistortionCoefficients:r,tangentialDistortionCoefficients:i}=this;return t?.length>1&&!Number.isNaN(o)&&e?.length>1&&r?.length>1&&i?.length>1}get unitAndHeightInfo(){const{horizontalWKID:t,verticalWKID:o}=this;let e=t,r=o;const p=this;if(4===p.type){const{properties:t}=p;e=4326,r=t.verticalWKID}return{heightModel:i(r,e),heightUnit:s(r,e),horizontalUnit:n(e)}}};t([e({json:{write:!0}})],p.prototype,"affineTransformations",void 0),t([e({json:{write:!0}})],p.prototype,"focalLength",void 0),t([e({json:{write:!0}})],p.prototype,"principalOffsetPoint",void 0),t([e({json:{write:!0}})],p.prototype,"radialDistortionCoefficients",void 0),t([e({json:{write:!0}})],p.prototype,"tangentialDistortionCoefficients",void 0),t([e({json:{write:!0}})],p.prototype,"horizontalWKID",void 0),t([e({json:{write:!0}})],p.prototype,"verticalWKID",void 0),t([e({json:{write:!0}})],p.prototype,"x",void 0),t([e({json:{write:!0}})],p.prototype,"y",void 0),t([e({json:{write:!0}})],p.prototype,"z",void 0),t([e({json:{write:!0}})],p.prototype,"type",void 0),t([e({readOnly:!0})],p.prototype,"unitAndHeightInfo",null),p=t([r("esri.layers.orientedImagery.core.CameraOrientation")],p);const a=p;export{a 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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as
|
|
5
|
+
import{_ as o}from"../../../chunks/tslib.es6.js";import e from"../../../core/Error.js";import{JSONSupport as r}from"../../../core/JSONSupport.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{fetchArcGISServiceJSON as n}from"../../../support/requestPresets.js";let i=class extends r{constructor(){super(...arguments),this.url=null}};o([t({type:Number,json:{write:!0}})],i.prototype,"lod",void 0),o([t({type:String,json:{write:!0}})],i.prototype,"rasterFunction",void 0),o([t({type:String,json:{write:!0}})],i.prototype,"url",void 0),i=o([s("esri.layers.orientedImagery.core.ElevationSourceDefinitions.ElevationSource")],i);let p=class extends r{constructor(){super(...arguments),this.constantElevation=null}};o([t({type:Number,json:{write:!0}})],p.prototype,"constantElevation",void 0),p=o([s("esri.layers.orientedImagery.cor.ElevationSourceDefinitions.ConstantElevation")],p);const a=o=>null!=o&&"constantElevation"in o&&"number"==typeof o.constantElevation,c=o=>null!=o&&"url"in o&&!!o.url;async function l(o){const r=await n(o),{tileInfo:t,cacheType:s}=r;return r.hasOwnProperty("bandCount")&&r.hasOwnProperty("pixelSizeX")?"LERC"!==t?.format?.toUpperCase()||s&&"elevation"!==s.toLowerCase()?{isSupported:!0,isDynamic:!0}:{isSupported:!0}:{isSupported:!1,error:new e("elevation-source:invalid-service-url",`ElevationSource URL expects an elevation 3D image service but given ${o}`)}}export{p as ConstantElevation,i as ElevationSource,a as isConstantElevation,c as isElevationSource,l as validateElevationSourceURL};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import"../../../geometry.js";import{deg2rad as e}from"../../../core/mathUtils.js";import{memoize as t}from"../../../core/memoize.js";import{zeros as a}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{y as r,g as o}from"../../../chunks/vec32.js";import{webMercatorToGeographic as i,geographicToWebMercator as n}from"../../../geometry/support/webMercatorUtils.js";import c from"../core/cameraOrientationFactory.js";import{scaleWithFactor as s,scaleAndAddWithFactor as l,projectiveTransform2 as m,ltpToGeographic as f,computeHFOVAndVFOV as p,calculateRotationMatrix as y,transformMat3 as u}from"./utils.js";import{worldToImageWithLTPFlag as g,worldToImage as z,getScalingFactor as h}from"./worldToImage.js";import x from"../../../geometry/Point.js";function d(e,t){const a=Array.isArray(e)?e:[e],{effectiveVerticalFieldOfView:r,imageVertices:o,scalingFactor:i,shouldConvertToLatLong:n,worldFootprint:c,localTangentPlane:s,cameraLocation:l}=L(t),m=new Array;for(const f of a){const e=R(c,o,{...f,z:1},l,t,s);m.push(w(e,l,i,(l.z??0)-t.cameraHeight,t.cameraPitch,r,n))}return 1===m.length?m[0]:m}function w(e,t,o,n,c,m,f){let p=e.clone();const y=Math.sqrt((e.z-t.z)**2+(Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)/o)**2)*o,u=s(r(a(),[e.x,e.y,e.z],[t.x,t.y,t.z]),1/y,1/o);if(e.z<n||c+m/2<90){const a=Math.abs((t.z-n)/-u[2])*o,r=l([t.x,t.y,t.z],u,a,o);p=new x({x:r[0],y:r[1],z:r[2],spatialReference:e.spatialReference})}else p.z=n;return f&&(p=i(e)),p}function R(e,t,a,r,o,i){let n=null;const c=9;let s,l=0,f=e,p=t;for(;l<=c;){const e=F(a,p,f,{...o,cameraLocation:r},a);if(s=e.error,n=e.transformedPoint,s<=1||l===c)break;f=[{x:a.x-s,y:a.y-s,z:1},{x:a.x+s,y:a.y-s,z:1},{x:a.x+s,y:a.y+s,z:1},{x:a.x-s,y:a.y+s,z:1}].map((e=>new x({...m(e,t,f),spatialReference:r.spatialReference}))),p=g(i,f,o),l++}return n}function F(e,t,a,r,o){const{cameraLocation:i}=r,n=new x({...m(e,t,a),spatialReference:i.spatialReference});return{transformedPoint:n,error:O(o,z(n,r))}}function O(e,t){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)}function L(e){const t="string"==typeof e.cameraOrientation?c.getCameraOrientation(e.cameraOrientation):e.cameraOrientation,a=4===t?.type,r=e.cameraLocation.spatialReference.isWGS84&&a;let o=new x(e.cameraLocation);if(a){const e=t;o=new x(f(o,[e.latitude,e.longitude,e.ellipsoidRadius,e.squaredEccentricity]))}o.spatialReference.isGeographic&&(o=n(o));const i=h(o);o.z||(o.z=e.cameraHeight);const s=j({...e,scalingFactor:i});return{cameraOrientation:t,cameraLocation:o,imageVertices:g(a,s,e),localTangentPlane:a,effectiveVerticalFieldOfView:p(e.horizontalFieldOfView,e.verticalFieldOfView,e.cameraRoll??0).vfov,worldFootprint:s,scalingFactor:i,shouldConvertToLatLong:r}}const j=t((t=>{const{cameraLocation:i,scalingFactor:n}=t,c=2*Math.tan(e(t.verticalFieldOfView)/2)*t.farDistance*n,m=2*Math.tan(e(t.horizontalFieldOfView)/2)*t.farDistance*n,f=y("HPR",[t.cameraHeading,t.cameraPitch,t.cameraRoll??0]),p=u([0,0,-1],f),g=l([i.x,i.y,i.z],p,t.farDistance*n,n),z=u([0,1,0],f),h=u([1,0,0],f),d=s(z,c/2,n),w=s(h,m/2,n),R=r(a(),d,w),F=o(a(),d,w);return[o(a(),g,R),o(a(),g,F),r(a(),g,R),r(a(),g,F)].map((e=>{const[t,a,r]=e;return new x({x:t,y:a,z:r,spatialReference:i.spatialReference})}))}));export{d as imageToWorld};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{isConstantElevation as e,isElevationSource as t}from"../core/ElevationSourceDefinitions.js";import{updateUsingElevationSampler as n,updateUsingConstant as o,updateUsingElevationSource as i,updateUsingCameraProperties as a}from"./updateElevationUtils.js";async function l(l,r,v){const c="elevationSample"in r&&null!=r.elevationSample,s="elevationSource"in r?r.elevationSource:void 0,u="extent"in r?r.extent:void 0;return c?n(l,r.elevationSample,v):e(s)?o(l,s.constantElevation,!0,v):t(s)?i(l,{...s,extent:u},v):a(r,l)}export{l as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import e from"../../../core/Error.js";import t from"../../../core/Logger.js";import{memoize as r}from"../../../core/memoize.js";import{waitTick as o,isAbortError as a}from"../../../core/promiseUtils.js";import{projectWithZConversion as n}from"../../../geometry/projection.js";import{fromExtent as i}from"../../../geometry/support/aaBoundingRect.js";import s from"../../ElevationLayer.js";import c from"../../ImageryLayer.js";import{TileElevationSampler as l}from"../../support/ElevationSampler.js";import{ElevationTile as p}from"../../support/ElevationTile.js";import{ElevationTileData as u}from"../../support/ElevationTileData.js";import m from"../../support/RasterFunction.js";import f from"../../support/TileInfo.js";import{TileKey as w}from"../../support/TileKey.js";import{fetchArcGISServiceJSON as y}from"../../../support/requestPresets.js";import{logAndThrow as g}from"../../../widgets/OrientedImageryViewer/utils.js";async function v(t,r,o){const a="url"in r?await j(r):r;if(!a)throw g("esri.layers.orientedImagery.transformations",new e("update-elevation:elevation-source","could not create a sampler using provided elevation source",r));return d(t,a,o)}async function d(e,t,r){await o(r);const a=new Array,n=z(t,r);for(const o of e){const e=await n(o);a.push(e)}return a}async function E(e,t,r=!0,a){await o(a);const{cameraHeight:n,cameraLocation:i,cameraOrientation:s}=e;return A(t,s&&"number"==typeof i.z?i.z-n:0,r,a)}var h;!function(e){e[e.DYNAMIC=0]="DYNAMIC",e[e.ELEVATION=1]="ELEVATION"}(h||(h={}));const j=r((async(e,r)=>{let o;const{extent:n,rasterFunction:i,url:s}=e;try{o=await R(s)}catch(c){if(a(c))return;t.getLogger("esri.layers.orientedImagery.transformations").error("updateElevationUsingElevationSource",c)}switch(o){case h.DYNAMIC:return await L(s,n,i,r);case h.ELEVATION:return await I(s,n,r);default:return}}));async function I(e,r,o){const n=new s(e);let i;try{await n.load(),i=await n.createElevationSampler(r,o)}catch(c){if(a(c))return;t.getLogger(n).error(c)}finally{n.destroy()}return i}async function L(e,t,r,o){const a=r?new m({functionName:r}):void 0,n=new c({url:e,rasterFunction:a,format:"lerc"});await n.load(o);let s,y=512,g=512;const v=t.width/t.height;v>1?(g/=v,s=t.height/g):(y*=v,s=t.width/y);const d=await n.fetchImage(t,y,g,o),E=f.create({scales:[s],size:512,spatialReference:t.spatialReference}),h=new w(null,0,0,0,i(t)),j=new u(d.pixelData.pixelBlock.pixels[0],y,g,0),I=new p(h,j);return new l(I,E,void 0)}async function R(t){const r=await y(t),{tileInfo:o,cacheType:a}=r;if(!r.hasOwnProperty("bandCount")||!r.hasOwnProperty("pixelSizeX"))throw new e("elevation-source:invalid-service-url",`ElevationSource URL expects an elevation 3D image service but given ${t}`);return"LERC"!==o?.format?.toUpperCase()||a&&"elevation"!==a.toLowerCase()?h.DYNAMIC:h.ELEVATION}function z(e,t){return async r=>{let o=r.clone();const a=r.spatialReference.equals(e.spatialReference)?o:await n(r,e.spatialReference,t),i=e.queryElevation(a);if(i){o=r.spatialReference.equals(e.spatialReference)?i.clone():await n(i,r.spatialReference,t)}return o.z=o.z??1,o}}async function A(e,t,r=!0,a){if(await o(a),r)return e.map((e=>(e.z=t,e)));for(const o of e)o.z=t;return e}export{j as getElevationSampler,E as updateUsingCameraProperties,A as updateUsingConstant,d as updateUsingElevationSampler,v as updateUsingElevationSource,R as validateElevationSourceURL};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{rad2deg as t,deg2rad as a}from"../../../core/mathUtils.js";import{create as n}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as s}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{zeros as h}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{invertOrIdentity as M}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{initializeProjection as i,projectWithZConversion as o}from"../../../geometry/projection.js";import{earth as r}from"../../../geometry/support/Ellipsoid.js";import{isWebMercator as c}from"../../../geometry/support/spatialReferenceUtils.js";import{defaultImageSphereSize as e}from"../../../widgets/PanoramicViewer/constants.js";function z(t,a,n){const[s,h,M,i]=a,[o,r,c,e]=n;return u(t,s,h,M,i,o,r,c,e)}function u(t,a,n,h,i,o,r,c,e){let z=!1;0===a.z&&0===n.z&&0===h.z&&0===i.z&&(a.z=n.z=h.z=i.z=1,t.z=1),a.z=a.z??1,n.z=n.z??1,h.z=h.z??1,i.z=i.z??1,0===o.z&&0===r.z&&0===c.z&&0===e.z&&(z=!0,o.z=r.z=c.z=e.z=1),o.z=o.z??1,r.z=r.z??1,c.z=c.z??1,e.z=e.z??1;const u=m(a,n,h,i),f=m(o,r,c,e),x=M(s(),u),y=s();y[0]=f[0]*x[0]+f[1]*x[4]+f[2]*x[8]+f[3]*x[12],y[1]=f[0]*x[1]+f[1]*x[5]+f[2]*x[9]+f[3]*x[13],y[2]=f[0]*x[2]+f[1]*x[6]+f[2]*x[10]+f[3]*x[14],y[3]=f[0]*x[3]+f[1]*x[7]+f[2]*x[11]+f[3]*x[15],y[4]=f[4]*x[0]+f[5]*x[4]+f[6]*x[8]+f[7]*x[12],y[5]=f[4]*x[1]+f[5]*x[5]+f[6]*x[9]+f[7]*x[13],y[6]=f[4]*x[2]+f[5]*x[6]+f[6]*x[10]+f[7]*x[14],y[7]=f[4]*x[3]+f[5]*x[7]+f[6]*x[11]+f[7]*x[15],y[8]=f[8]*x[0]+f[9]*x[4]+f[10]*x[8]+f[11]*x[12],y[9]=f[8]*x[1]+f[9]*x[5]+f[10]*x[9]+f[11]*x[13],y[10]=f[8]*x[2]+f[9]*x[6]+f[10]*x[10]+f[11]*x[14],y[11]=f[8]*x[3]+f[9]*x[7]+f[10]*x[11]+f[11]*x[15],y[12]=f[12]*x[0]+f[13]*x[4]+f[14]*x[8]+f[15]*x[12],y[13]=f[12]*x[1]+f[13]*x[5]+f[14]*x[9]+f[15]*x[13],y[14]=f[12]*x[2]+f[13]*x[6]+f[14]*x[10]+f[15]*x[14],y[15]=f[12]*x[3]+f[13]*x[7]+f[14]*x[11]+f[15]*x[15];const p=y[0]*t.x+y[1]*t.y+y[2]*t.z+y[3],l=y[4]*t.x+y[5]*t.y+y[6]*t.z+y[7],b=y[8]*t.x+y[9]*t.y+y[10]*t.z+y[11];let g=y[12]*t.x+y[13]*t.y+y[14]*t.z+y[15];return 0===g&&(g=1),{x:p/g,y:l/g,z:z?0:b/g}}function m(t,a,n,s){const h=p([s.x,s.y,s.z,1],M(new Array(16),[t.x,a.x,n.x,0,t.y,a.y,n.y,0,t.z,a.z,n.z,0,1,1,1,1])),i=h[0],o=h[1],r=h[2],c=new Array(16);return c[0]=i*t.x,c[1]=o*a.x,c[2]=r*n.x,c[3]=0,c[4]=i*t.y,c[5]=o*a.y,c[6]=r*n.y,c[7]=0,c[8]=i*t.z,c[9]=o*a.z,c[10]=r*n.z,c[11]=0,c[12]=i,c[13]=o,c[14]=r,c[15]=1,c}function f(t,a,n,s,M=h()){return M[0]=t[0]+a[0]*n,M[1]=t[1]+a[1]*n,M[2]=t[2]+a[2]*(n/s),M}function x(t,a,n){const s=h();return s[0]=t[0]*a,s[1]=t[1]*a,s[2]=t[2]*(a/n),s}function y(t,a){const[n,s,M]=t,i=h();return i[0]=n*a[0]+s*a[3]+M*a[6],i[1]=n*a[1]+s*a[4]+M*a[7],i[2]=n*a[2]+s*a[5]+M*a[8],i}function p(t,a){const[n,s,h,M]=t,i=new Array(4);return i[0]=n*a[0]+s*a[1]+h*a[2]+M*a[3],i[1]=n*a[4]+s*a[5]+h*a[6]+M*a[7],i[2]=n*a[8]+s*a[9]+h*a[10]+M*a[11],i[3]=n*a[12]+s*a[13]+h*a[14]+M*a[15],i}function l(t,a){const s=Math.PI/180,h=n();if("OPK"===t){const t=Number(a[0])*s,n=Number(a[1])*s,M=Number(a[2])*s;h[0]=Math.cos(n)*Math.cos(M),h[1]=Math.cos(t)*Math.sin(M)+Math.sin(t)*Math.sin(n)*Math.cos(M),h[2]=Math.sin(t)*Math.sin(M)-Math.cos(t)*Math.sin(n)*Math.cos(M),h[3]=-Math.cos(n)*Math.sin(M),h[4]=Math.cos(t)*Math.cos(M)-Math.sin(t)*Math.sin(n)*Math.sin(M),h[5]=Math.sin(t)*Math.cos(M)+Math.cos(t)*Math.sin(n)*Math.sin(M),h[6]=Math.sin(n),h[7]=-Math.sin(t)*Math.cos(n),h[8]=Math.cos(t)*Math.cos(n)}else{const t=Number(a[0])*s,n=Number(a[1])*s,M=Number(a[2])*s;h[0]=Math.cos(t)*Math.cos(M)-Math.sin(t)*Math.cos(n)*Math.sin(M),h[1]=Math.sin(t)*Math.cos(M)*-1-Math.cos(t)*Math.cos(n)*Math.sin(M),h[2]=Math.sin(M)*Math.sin(n)*-1,h[3]=Math.cos(t)*Math.sin(M)+Math.sin(t)*Math.cos(n)*Math.cos(M),h[4]=Math.sin(t)*Math.sin(M)*-1+Math.cos(t)*Math.cos(n)*Math.cos(M),h[5]=Math.cos(M)*Math.sin(n),h[6]=Math.sin(t)*Math.sin(n)*-1,h[7]=Math.cos(t)*Math.sin(n)*-1,h[8]=Math.cos(n)}return h}function b(t,a,n){const s=Math.sin(n*Math.PI/180),h=Math.cos(n*Math.PI/180),M=[[t,0],[t,a],[0,a]];M.forEach(((t,a)=>{M[a]=[h*t[0]-s*t[1],s*t[0]+h*t[1]]}));const i={xmin:Math.min(0,M[0][0],M[1][0],M[2][0]),xmax:Math.max(0,M[0][0],M[1][0],M[2][0]),ymin:Math.min(0,M[0][1],M[1][1],M[2][1]),ymax:Math.max(0,M[0][1],M[1][1],M[2][1])};return{hfov:Math.abs(i.xmax-i.xmin),vfov:Math.abs(i.ymax-i.ymin)}}function g(t,a,n,s,h,M){const i=n*(a.x-t.x)+s*(a.y-t.y)+h*(a.z-t.z);if(0===i)return null;const o=-(n*t.x+s*t.y+h*t.z+M)/i;return{x:t.x+o*(a.x-t.x),y:t.y+o*(a.y-t.y),z:t.z+o*(a.z-t.z)}}function j(t,a){const n=Math.PI/180,s=t.y*n,h=t.x*n,M=t.z||0,i=a[0]*n,o=a[1]*n,r=a[2]/Math.sqrt(1-a[3]*Math.sin(i)**2),c=h-o,e=a[2]/Math.sqrt(1-a[3]*Math.sin(s)**2),z=a[3]*(r*Math.sin(i)-e*Math.sin(s));return{x:(e+M)*Math.cos(s)*Math.sin(c),y:(e+M)*(Math.sin(s)*Math.cos(i)-Math.sin(i)*Math.cos(s)*Math.cos(c))+z*Math.cos(i),z:(e+M)*(Math.sin(s)*Math.sin(i)+Math.cos(i)*Math.cos(s)*Math.cos(c))-r+z*Math.sin(i)}}function q(t,a){const n=Math.PI/180,s=Number(t.x),h=Number(t.y),M=Number(t.z),i=a[0]*n,o=a[1]*n,r=a[2]/Math.sqrt(1-a[3]*Math.sin(i)**2),c=s/r,e=h/r,z=M/r,u=Math.cos(i)-Math.sin(i)*e+Math.cos(i)*z,m=Math.sin(i)+Math.cos(i)*e+Math.sin(i)*z,f=Math.sqrt(u**2+c**2),x=a[3]*r*Math.sin(i),y=i,p=Math.atan(m/f-(x-a[3]*(a[2]/Math.sqrt(1-a[3]*Math.sin(y)**2))*Math.sin(y))/(r*f)),l=Math.atan(m/f-(x-a[3]*(a[2]/Math.sqrt(1-a[3]*Math.sin(p)**2))*Math.sin(p))/(r*f)),b=Math.atan(m/f-(x-a[3]*(a[2]/Math.sqrt(1-a[3]*Math.sin(l)**2))*Math.sin(l))/(r*f)),g=Math.atan(m/f-(x-a[3]*(a[2]/Math.sqrt(1-a[3]*Math.sin(b)**2))*Math.sin(b))/(r*f)),j=Math.atan(s/(r*u))+o;return{x:j/n,y:g/n,z:s/(Math.cos(g)*Math.sin(j-o))-a[2]/Math.sqrt(1-a[3]*Math.sin(g)**2),spatialReference:{wkid:4326}}}function N(t){return t&&c(t?.spatialReference)?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*t.y/r.radius))):1}function d(t,a,n){const s=360/a,h=180/n;return{heading:(t.x-a/2)*s,pitch:90-(t.y-n/2)*h}}function w(t,a,n,s=e/2){const{heading:h,pitch:M}=I(t,s);return P(h,M,a,n)}function P(t,a,n,s){return{x:n/2+t/(360/n),y:s-a/(180/s),heading:t,pitch:a}}function I(a,n){const s=t(Math.acos(-a.z/n));return{heading:t(Math.atan2(a.x,a.y)),pitch:s}}function R(t,n,s=e/2){return[s*(Math.sin(a(t))*Math.sin(a(n))),s*(Math.cos(a(t))*Math.sin(a(n))),s*Math.cos(a(180-n))]}async function v(a,n,s){await i(n.spatialReference,a.spatialReference,null,s);const h=await o(n,a.spatialReference,s);let M=t(Math.atan2(h.y-a.y,h.x-a.x));return M=M>=0&&M<=90?90-M:M>90&&M<=180?360-M+90:90+Math.abs(M),M}export{l as calculateRotationMatrix,b as computeHFOVAndVFOV,R as convertHeadingPitchToSphereVertex,P as convertOrientationToPixelLocation,d as convertPixelToHeadingPitch,I as convertSphereVertexToOrientation,w as convertSphereVertexToPixelLocation,j as geographicToLTP,v as getInitialAngle,g as getPlaneLineIntersectionPoint,N as getWebMercatorScalingFactor,m as linearEquationSolve,q as ltpToGeographic,u as projectiveTransform,z as projectiveTransform2,f as scaleAndAddWithFactor,x as scaleWithFactor,y as transformMat3,p as transformMat4};
|
|
5
|
+
import{rad2deg as t,deg2rad as a}from"../../../core/mathUtils.js";import{create as n}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as s}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{zeros as h}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{invertOrIdentity as M}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{initializeProjection as i,projectWithZConversion as o}from"../../../geometry/projection.js";import{earth as r}from"../../../geometry/support/Ellipsoid.js";import{isWebMercator as c}from"../../../geometry/support/spatialReferenceUtils.js";import{defaultImageSphereSize as e}from"../../../widgets/PanoramicViewer/constants.js";function z(t,a,n){const[s,h,M,i]=a,[o,r,c,e]=n;return u(t,s,h,M,i,o,r,c,e)}function u(t,a,n,h,i,o,r,c,e){let z=!1;0===a.z&&0===n.z&&0===h.z&&0===i.z&&(a.z=n.z=h.z=i.z=1,t.z=1),a.z=a.z??1,n.z=n.z??1,h.z=h.z??1,i.z=i.z??1,0===o.z&&0===r.z&&0===c.z&&0===e.z&&(z=!0,o.z=r.z=c.z=e.z=1),o.z=o.z??1,r.z=r.z??1,c.z=c.z??1,e.z=e.z??1;const u=m(a,n,h,i),f=m(o,r,c,e),x=M(s(),u),y=s();y[0]=f[0]*x[0]+f[1]*x[4]+f[2]*x[8]+f[3]*x[12],y[1]=f[0]*x[1]+f[1]*x[5]+f[2]*x[9]+f[3]*x[13],y[2]=f[0]*x[2]+f[1]*x[6]+f[2]*x[10]+f[3]*x[14],y[3]=f[0]*x[3]+f[1]*x[7]+f[2]*x[11]+f[3]*x[15],y[4]=f[4]*x[0]+f[5]*x[4]+f[6]*x[8]+f[7]*x[12],y[5]=f[4]*x[1]+f[5]*x[5]+f[6]*x[9]+f[7]*x[13],y[6]=f[4]*x[2]+f[5]*x[6]+f[6]*x[10]+f[7]*x[14],y[7]=f[4]*x[3]+f[5]*x[7]+f[6]*x[11]+f[7]*x[15],y[8]=f[8]*x[0]+f[9]*x[4]+f[10]*x[8]+f[11]*x[12],y[9]=f[8]*x[1]+f[9]*x[5]+f[10]*x[9]+f[11]*x[13],y[10]=f[8]*x[2]+f[9]*x[6]+f[10]*x[10]+f[11]*x[14],y[11]=f[8]*x[3]+f[9]*x[7]+f[10]*x[11]+f[11]*x[15],y[12]=f[12]*x[0]+f[13]*x[4]+f[14]*x[8]+f[15]*x[12],y[13]=f[12]*x[1]+f[13]*x[5]+f[14]*x[9]+f[15]*x[13],y[14]=f[12]*x[2]+f[13]*x[6]+f[14]*x[10]+f[15]*x[14],y[15]=f[12]*x[3]+f[13]*x[7]+f[14]*x[11]+f[15]*x[15];const p=y[0]*t.x+y[1]*t.y+y[2]*t.z+y[3],l=y[4]*t.x+y[5]*t.y+y[6]*t.z+y[7],b=y[8]*t.x+y[9]*t.y+y[10]*t.z+y[11];let g=y[12]*t.x+y[13]*t.y+y[14]*t.z+y[15];return 0===g&&(g=1),{x:p/g,y:l/g,z:z?0:b/g}}function m(t,a,n,s){const h=p([s.x,s.y,s.z,1],M(new Array(16),[t.x,a.x,n.x,0,t.y,a.y,n.y,0,t.z,a.z,n.z,0,1,1,1,1])),i=h[0],o=h[1],r=h[2],c=new Array(16);return c[0]=i*t.x,c[1]=o*a.x,c[2]=r*n.x,c[3]=0,c[4]=i*t.y,c[5]=o*a.y,c[6]=r*n.y,c[7]=0,c[8]=i*t.z,c[9]=o*a.z,c[10]=r*n.z,c[11]=0,c[12]=i,c[13]=o,c[14]=r,c[15]=1,c}function f(t,a,n,s,M=h()){return M[0]=t[0]+a[0]*n,M[1]=t[1]+a[1]*n,M[2]=t[2]+a[2]*(n/s),M}function x(t,a,n){const s=h();return s[0]=t[0]*a,s[1]=t[1]*a,s[2]=t[2]*(a/n),s}function y(t,a){const[n,s,M]=t,i=h();return i[0]=n*a[0]+s*a[3]+M*a[6],i[1]=n*a[1]+s*a[4]+M*a[7],i[2]=n*a[2]+s*a[5]+M*a[8],i}function p(t,a){const[n,s,h,M]=t,i=new Array(4);return i[0]=n*a[0]+s*a[1]+h*a[2]+M*a[3],i[1]=n*a[4]+s*a[5]+h*a[6]+M*a[7],i[2]=n*a[8]+s*a[9]+h*a[10]+M*a[11],i[3]=n*a[12]+s*a[13]+h*a[14]+M*a[15],i}function l(t,a){const s=Math.PI/180,h=n();if("OPK"===t){const t=Number(a[0])*s,n=Number(a[1])*s,M=Number(a[2])*s;h[0]=Math.cos(n)*Math.cos(M),h[1]=Math.cos(t)*Math.sin(M)+Math.sin(t)*Math.sin(n)*Math.cos(M),h[2]=Math.sin(t)*Math.sin(M)-Math.cos(t)*Math.sin(n)*Math.cos(M),h[3]=-Math.cos(n)*Math.sin(M),h[4]=Math.cos(t)*Math.cos(M)-Math.sin(t)*Math.sin(n)*Math.sin(M),h[5]=Math.sin(t)*Math.cos(M)+Math.cos(t)*Math.sin(n)*Math.sin(M),h[6]=Math.sin(n),h[7]=-Math.sin(t)*Math.cos(n),h[8]=Math.cos(t)*Math.cos(n)}else{const t=Number(a[0])*s,n=Number(a[1])*s,M=Number(a[2])*s;h[0]=Math.cos(t)*Math.cos(M)-Math.sin(t)*Math.cos(n)*Math.sin(M),h[1]=Math.sin(t)*Math.cos(M)*-1-Math.cos(t)*Math.cos(n)*Math.sin(M),h[2]=Math.sin(M)*Math.sin(n)*-1,h[3]=Math.cos(t)*Math.sin(M)+Math.sin(t)*Math.cos(n)*Math.cos(M),h[4]=Math.sin(t)*Math.sin(M)*-1+Math.cos(t)*Math.cos(n)*Math.cos(M),h[5]=Math.cos(M)*Math.sin(n),h[6]=Math.sin(t)*Math.sin(n)*-1,h[7]=Math.cos(t)*Math.sin(n)*-1,h[8]=Math.cos(n)}return h}function b(t,a,n){const s=Math.sin(n*Math.PI/180),h=Math.cos(n*Math.PI/180),M=[[t,0],[t,a],[0,a]];M.forEach(((t,a)=>{M[a]=[h*t[0]-s*t[1],s*t[0]+h*t[1]]}));const i={xmin:Math.min(0,M[0][0],M[1][0],M[2][0]),xmax:Math.max(0,M[0][0],M[1][0],M[2][0]),ymin:Math.min(0,M[0][1],M[1][1],M[2][1]),ymax:Math.max(0,M[0][1],M[1][1],M[2][1])};return{hfov:Math.abs(i.xmax-i.xmin),vfov:Math.abs(i.ymax-i.ymin)}}function g(t,a,n,s,h,M){const i=n*(a.x-t.x)+s*(a.y-t.y)+h*(a.z-t.z);if(0===i)return null;const o=-(n*t.x+s*t.y+h*t.z+M)/i;return{x:t.x+o*(a.x-t.x),y:t.y+o*(a.y-t.y),z:t.z+o*(a.z-t.z)}}function j(t,a){const n=Math.PI/180,s=t.y*n,h=t.x*n,M=t.z||0,i=a[0]*n,o=a[1]*n,r=a[2]/Math.sqrt(1-a[3]*Math.sin(i)**2),c=h-o,e=a[2]/Math.sqrt(1-a[3]*Math.sin(s)**2),z=a[3]*(r*Math.sin(i)-e*Math.sin(s));return{x:(e+M)*Math.cos(s)*Math.sin(c),y:(e+M)*(Math.sin(s)*Math.cos(i)-Math.sin(i)*Math.cos(s)*Math.cos(c))+z*Math.cos(i),z:(e+M)*(Math.sin(s)*Math.sin(i)+Math.cos(i)*Math.cos(s)*Math.cos(c))-r+z*Math.sin(i)}}function q(t,a){const n=Math.PI/180,s=Number(t.x),h=Number(t.y),M=Number(t.z),i=a[0]*n,o=a[1]*n,r=a[2]/Math.sqrt(1-a[3]*Math.sin(i)**2),c=s/r,e=h/r,z=M/r,u=Math.cos(i)-Math.sin(i)*e+Math.cos(i)*z,m=Math.sin(i)+Math.cos(i)*e+Math.sin(i)*z,f=Math.sqrt(u**2+c**2),x=a[3]*r*Math.sin(i),y=i,p=Math.atan(m/f-(x-a[3]*(a[2]/Math.sqrt(1-a[3]*Math.sin(y)**2))*Math.sin(y))/(r*f)),l=Math.atan(m/f-(x-a[3]*(a[2]/Math.sqrt(1-a[3]*Math.sin(p)**2))*Math.sin(p))/(r*f)),b=Math.atan(m/f-(x-a[3]*(a[2]/Math.sqrt(1-a[3]*Math.sin(l)**2))*Math.sin(l))/(r*f)),g=Math.atan(m/f-(x-a[3]*(a[2]/Math.sqrt(1-a[3]*Math.sin(b)**2))*Math.sin(b))/(r*f)),j=Math.atan(s/(r*u))+o;return{x:j/n,y:g/n,z:s/(Math.cos(g)*Math.sin(j-o))-a[2]/Math.sqrt(1-a[3]*Math.sin(g)**2),spatialReference:{wkid:4326}}}function N(t){return t&&c(t?.spatialReference)?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*t.y/r.radius))):1}function d(t,a,n){const s=360/a,h=180/n;return{heading:(t.x-a/2)*s,pitch:90-(t.y-n/2)*h}}function w(t,a,n,s=e/2){const{heading:h,pitch:M}=I(t,s);return P(h,M,a,n)}function P(t,a,n,s){return{x:n/2+t/(360/n),y:s-a/(180/s),heading:t,pitch:a}}function I(a,n){const s=t(Math.acos(-a.z/n));return{heading:t(Math.atan2(a.x,a.y)),pitch:s}}function R(t,n,s=e/2){return[s*(Math.sin(a(t))*Math.sin(a(n))),s*(Math.cos(a(t))*Math.sin(a(n))),s*Math.cos(a(180-n))]}async function v(a,n,s){await i(n.spatialReference,a.spatialReference,null,s);const h=await o(n,a.spatialReference,s);let M=t(Math.atan2(h.y-a.y,h.x-a.x));return M=M>=0&&M<=90?90-M:M>90&&M<=180?360-M+90:90+Math.abs(M),M}function A(t,a,n){const s=Math.cos(n),h=Math.sin(n),M=[1,0,0,1,0,0],i=M[0]*s+M[2]*h,o=M[1]*s+M[3]*h,r=-M[0]*h+M[2]*s,c=-M[1]*h+M[3]*s;M[0]=i,M[1]=o,M[2]=r,M[3]=c;return[t*M[0]+a*M[2]+M[4],t*M[1]+a*M[3]+M[5]]}export{l as calculateRotationMatrix,b as computeHFOVAndVFOV,R as convertHeadingPitchToSphereVertex,P as convertOrientationToPixelLocation,d as convertPixelToHeadingPitch,I as convertSphereVertexToOrientation,w as convertSphereVertexToPixelLocation,j as geographicToLTP,v as getInitialAngle,g as getPlaneLineIntersectionPoint,N as getWebMercatorScalingFactor,m as linearEquationSolve,q as ltpToGeographic,u as projectiveTransform,z as projectiveTransform2,A as rotatePixel,f as scaleAndAddWithFactor,x as scaleWithFactor,y as transformMat3,p as transformMat4};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import"../../../geometry.js";import{deg2rad as t}from"../../../core/mathUtils.js";import{create as a}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{mul as e}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{earth as r}from"../../../geometry/support/Ellipsoid.js";import{isWebMercator as i}from"../../../geometry/support/spatialReferenceUtils.js";import{webMercatorToGeographic as o,geographicToWebMercator as n}from"../../../geometry/support/webMercatorUtils.js";import c from"../core/cameraOrientationFactory.js";import{geographicToLTP as s,calculateRotationMatrix as m}from"./utils.js";import f from"../../../geometry/Point.js";function l(t,a){const{cameraOrientation:e,cameraLocation:r,pointsToTransform:i,rotationMatrix:o,scalingFactor:n}=g(t,a),c=new Array;return e?.isAdvanced?u(i,c,o,{...a,cameraOrientation:e,scalingFactor:n,cameraLocation:r}):h(i,c,o,{...a,cameraOrientation:e,scalingFactor:n,cameraLocation:r}),1===c.length?c[0]:c}function p(t,a,e){return l(t?a.map((t=>o(t))):a,e).map((t=>({...t,z:1})))}function u(t,a,e,r){const{cameraOrientation:i,cameraLocation:o,scalingFactor:n}=r,{principalOffsetPoint:c,focalLength:s,radialDistortionCoefficients:m,affineTransformations:f,tangentialDistortionCoefficients:l}=i;for(const p of t){const[t,r,u]=y(p,i,o,n),g=(e[0]*t+e[1]*r+e[2]*u)/(e[6]*t+e[7]*r+e[8]*u),h=(e[3]*t+e[4]*r+e[5]*u)/(e[6]*t+e[7]*r+e[8]*u),O=g**2+h**2;let d=0,x=0,M=0,b=0,R=0,j=0,F=0;m&&(d=m[0]??0,x=m[1]??0,M=m[2]??0),l&&(b=l[0],R=l[1]),c&&(j=c[0]??0,F=c[1]??0);const P=1+(d||0)*O+(x||0)*O*O+(M||0)*O*O*O;let z=g*P+(b||0)*(O+2*g**2)+2*(R||0)*g*h,L=h*P+(R||0)*(O+2*h**2)+2*(b||0)*g*h;z=-(s??0)*z+j,L=-(s??0)*L+F;const w=Number(f[0])+Number(f[1])*z+Number(f[2])*L,N=Number(f[3])+Number(f[4])*z+Number(f[5])*L;a.push({x:w,y:N})}}function g(t,a){const e=Array.isArray(t)||"items"in t?t:[t],r="string"==typeof a.cameraOrientation?c.getCameraOrientation(a.cameraOrientation):a.cameraOrientation,i=O({...a,cameraOrientation:r});let o=new f(a.cameraLocation);(o.spatialReference.isWGS84&&4!==r?.type||o.spatialReference.isGeographic)&&(o=n(o)),o.z||(o.z=a.cameraHeight);return{cameraOrientation:r,pointsToTransform:e,rotationMatrix:i,scalingFactor:d(o),cameraLocation:o}}function h(r,i,o,n){const{horizontalFieldOfView:c,verticalFieldOfView:s,cameraOrientation:m,cameraLocation:f,scalingFactor:l}=n,p=t(n.imageRotation??0),u=Math.sin(p),g=Math.cos(p),h=n.imageWidth||1,O=n.imageHeight||1,d=[Math.abs(g*h+u*O),Math.abs(g*O-u*h)],x={horizontal:1/(2*Math.tan(t(c)/2)),vertical:1/(2*Math.tan(t(s)/2))},M=a();M[0]=-x.horizontal,M[2]=.5,M[4]=x.vertical,M[5]=.5;const b=e(a(),o,M);for(const t of r){const[a,e,r]=y(t,m,f,l),o=(b[0]*a+b[1]*e+b[2]*r)/(b[6]*a+b[7]*e+b[8]*r),n=(b[3]*a+b[4]*e+b[5]*r)/(b[6]*a+b[7]*e+b[8]*r),c={x:o*d[0],y:n*d[1]};i.push({x:g*(c.x-d[0]/2)+u*(c.y-d[1]/2)+h/2,y:-u*(c.x-d[0]/2)+g*(c.y-d[1]/2)+O/2})}}function y(t,a,e,r){let i=new f(t);if(i.spatialReference.isGeographic)if(i.spatialReference.isWGS84&&4===a?.type){const{latitude:t,longitude:e,ellipsoidRadius:r,squaredEccentricity:o}=a;i=new f(s(i,[t,e,r,o]))}else i=n(i);const o=(i.z??0)-(e.z??0),c=(i.y-e.y)/r;return[(i.x-e.x)/r,c,o]}function O(t){const{cameraHeading:a,cameraPitch:e,cameraRoll:r,cameraOrientation:i}=t;if("OPK"===(i?.isAdvanced&&2===i.type?"OPK":"HPR")){const{omega:t,phi:a,kappa:e}=i;return m("OPK",[t,a,e])}return m("HPR",[a,e,r])}function d(t){return i(t?.spatialReference)?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*t.y/r.radius))):1}export{d as getScalingFactor,l as worldToImage,p as worldToImageWithLTPFlag};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveEditingEnabled as s,getEffectiveLayerCapabilities as a}from"./layerUtils.js";let
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveEditingEnabled as s,getEffectiveLayerCapabilities as a}from"./layerUtils.js";let n=class extends t{constructor(e){super(e),this.layer=null}get attachments(){return{enabled:this._effectiveEnabled&&!!this._effectiveCapabilities?.data.supportsAttachment}}get create(){const{_effectiveCapabilities:e,layer:t}=this,r=this._createEnabled,i=r,s=t.capabilities?.operations.supportsAdd,a=!!e?.operations.supportsAdd;return{attachments:{enabled:r&&this.attachments.enabled},attributes:r,enabled:r,geometry:i,reliesOnOwnerAdminPrivileges:!s&&a}}get delete(){const{_effectiveCapabilities:e,layer:t}=this,r=t.capabilities?.operations.supportsDelete,i=!!e?.operations.supportsDelete;return{enabled:this._effectiveEnabled&&!!e?.operations.supportsDelete,reliesOnOwnerAdminPrivileges:!r&&i}}get reliesOnOwnerAdminPrivileges(){return this._effectiveEnabled&&!this.layer.editingEnabled||this.create.reliesOnOwnerAdminPrivileges||this.update.reliesOnOwnerAdminPrivileges||this.delete.reliesOnOwnerAdminPrivileges}get update(){const{_effectiveCapabilities:e,layer:t}=this,r=this._updateEnabled,i=!(!r||!e?.editing.supportsGeometryUpdate),s=t.capabilities?.operations.supportsUpdate,a=!!e?.operations.supportsUpdate,n=this.attachments.enabled,p=n&&this._canCreateOrUpdate;return{attachments:{enabled:n,create:p,update:p},attributes:r,enabled:r,geometry:i,reliesOnOwnerAdminPrivileges:!s&&a}}get _createEnabled(){return this._effectiveEnabled&&!!this._effectiveCapabilities?.operations.supportsAdd}get _updateEnabled(){return this._effectiveEnabled&&!!this._effectiveCapabilities?.operations.supportsUpdate}get _canCreateOrUpdate(){return!(!this._createEnabled&&!this._updateEnabled)}get _effectiveEnabled(){return s(this.layer)}get _effectiveCapabilities(){return a(this.layer)}};e([r()],n.prototype,"attachments",null),e([r()],n.prototype,"create",null),e([r()],n.prototype,"delete",null),e([r()],n.prototype,"layer",void 0),e([r()],n.prototype,"reliesOnOwnerAdminPrivileges",null),e([r()],n.prototype,"update",null),e([r()],n.prototype,"_createEnabled",null),e([r()],n.prototype,"_updateEnabled",null),e([r()],n.prototype,"_canCreateOrUpdate",null),e([r()],n.prototype,"_effectiveEnabled",null),e([r()],n.prototype,"_effectiveCapabilities",null),n=e([i("esri.layers.support.EditingCapabilities")],n);const p=n;export{p 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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
5
|
+
import{getEffectiveLayerCapabilities as t,getEffectiveEditingEnabled as e}from"./layerUtils.js";function i(i){return!(!(i&&"object"==typeof i&&"loaded"in i&&i.loaded&&t(i)?.operations?.supportsEditing&&"type"in i)||"editingEnabled"in i&&!e(i))}export{i as isEditableLayer};
|
package/package.json
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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../Color.js";import"../../renderers/ClassBreaksRenderer.js";import"../../renderers/DictionaryRenderer.js";import"../../renderers/DotDensityRenderer.js";import"../../renderers/HeatmapRenderer.js";import r from"../../renderers/PieChartRenderer.js";import"../../renderers/Renderer.js";import"../../renderers/SimpleRenderer.js";import"../../renderers/UniqueValueRenderer.js";import"../../renderers/support/jsonUtils.js";import"../../core/Logger.js";import"../../symbols.js";import{isSome as a}from"../../core/arrayUtils.js";import t from"../../core/Error.js";import{toPt as n}from"../../core/screenUtils.js";import{fetchMessageBundle as i}from"../../intl/messages.js";import s from"../../layers/support/AggregateField.js";import o from"../../layers/support/ExpressionInfo.js";import l from"../../renderers/support/AttributeColorInfo.js";import{OthersCategory as u}from"../../renderers/support/OthersCategory.js";import p from"../heuristics/outline.js";import m from"../heuristics/sizeRange.js";import{createVisualVariables as c}from"./size.js";import{errorCallback as d,createColors as f,createSymbol as h,getSymbolOutlineFromScheme as b,verifyBasicFieldValidity as y,getBasemapInfo as w}from"./support/utils.js";import g from"../statistics/predominantCategories.js";import{getSumOfAttributesExpr as v}from"../statistics/support/utils.js";import{verifyBinningParams as S}from"../support/binningUtils.js";import{getFieldsList as z}from"../support/utils.js";import{LayerType as E,binningCapableLayerTypes as j,createLayerAdapter as C,getLayerTypeLabels as x,getLayerTypes as V}from"../support/adapters/support/layerUtils.js";import{cloneScheme as $,getSchemes as T}from"../symbology/pieChart.js";import{getCIMSymbolColor as I}from"../../symbols/support/cimSymbolUtils.js";import k from"../../symbols/SimpleLineSymbol.js";const O=[E.CSVLayer,E.FeatureLayer,E.GeoJSONLayer,E.OGCFeatureLayer,E.OrientedImageryLayer,E.StreamLayer,E.WFSLayer];async function q(e){if(!(e?.layer&&e.view&&e.attributes?.length))throw new t("pie-chart-renderer:missing-parameters","'layer', 'view' and 'attributes' parameters are required");if(e.attributes.length>10)throw new t("pie-chart-renderer:invalid-parameters","PieChart renderer does not support more than 10 attributes");e.forBinning&&S(e,"pie-chart-renderer");const r={...e,layer:e.layer,view:e.view,attributes:e.attributes};r.shape=r.shape||"pie",r.othersCategoryEnabled??=!0,r.includeSizeVariable=e.includeSizeVariable||!1;const a=e.forBinning?j:O,n=C(r.layer,a,e.forBinning);if(!n)throw new t("pie-chart-renderer:invalid-parameters","'layer' must be one of these types: "+x(a).join(", "));r.layer=n;const i=null!=r.signal?{signal:r.signal}:null;await Promise.all([e.view.when(),n.load(i)]);const s=n.geometryType,o="polygon"===s,l="point"===s||"multipoint"===s||o;if(r.outlineOptimizationEnabled=!!o&&r.outlineOptimizationEnabled,r.sizeOptimizationEnabled=!!l&&r.sizeOptimizationEnabled,!l)throw new t("pie-chart-renderer:not-supported","PieChart renderer is only supported for point and polygon layers");const u=[],p=r.attributes;for(const t of p){const e=await z({field:t.field,valueExpression:t.valueExpression});u.push(...e)}const m=y(n,u.filter(Boolean),"pie-chart-renderer:invalid-parameters");if(m)throw m;return r}async function L(e){let r=e.pieChartScheme,a=null,t=null;const n=await w(e.basemap,e.view);if(a=null!=n.basemapId?n.basemapId:null,t=null!=n.basemapTheme?n.basemapTheme:null,r)return{scheme:$(r),basemapId:a,basemapTheme:t};const i=T({numColors:e.attributes.length,geometryType:e.layer.geometryType,basemapTheme:t});return i&&(r=i.primaryScheme,a=i.basemapId,t=i.basemapTheme),{scheme:r,basemapId:a,basemapTheme:t}}async function B(e,r){const{valueExpression:a,sqlExpression:t,sqlWhere:n}=v(e.attributes),s=await i("esri/smartMapping/t9n/smartMapping");return c({layer:e.layer,basemap:e.basemap,valueExpression:a,sqlExpression:t,sqlWhere:n,sizeScheme:r,sizeOptimizationEnabled:e.sizeOptimizationEnabled,legendOptions:{title:s.sumOfCategories},view:e.view,signal:e.signal})}async function R(e){const[s,o]=await Promise.all([q(e),i("esri/smartMapping/t9n/smartMapping")]),c=await L(s),y=c?.scheme;if(!y)throw new t("pie-chart-renderer:insufficient-info","Unable to find pie-chart scheme");const w=s.layer,{includeSizeVariable:v,sizeOptimizationEnabled:S,outlineOptimizationEnabled:z,view:E,signal:j}=s,C=y.sizeScheme,x=s.attributes,V=x.map((e=>e.field)).filter(a),[T,I,O,R]=await Promise.all([V.length>1?g({layer:w,fields:V,view:E,signal:j}):null,v?B(s,C):null,!v&&S?m({layer:w,view:E,signal:j}).catch(d):null,z?p({layer:w,view:E,signal:j}).catch(d):null]),P=T?.predominantCategoryInfos?{uniqueValueInfos:T.predominantCategoryInfos}:{uniqueValueInfos:V.map((e=>({value:e,count:0})))},U=f(y.colors,x.length),F=x.map(((e,r)=>new l({field:e.field,valueExpression:e.valueExpression,label:e.label,valueExpressionTitle:e.valueExpressionTitle,color:U[r]}))),M=w.geometryType,N=null!=C&&"background"in C&&C.background,_=new r({attributes:F,othersCategory:new u({label:o.other,color:s.othersCategoryEnabled?y.colorForOthersCategory:null,threshold:.04}),holePercentage:"donut"===s.shape?.45:0,backgroundFillSymbol:N?h(M,{type:"2d",color:N.color,outline:b(N,M,R?.opacity)}):null,size:n(y.size),outline:new k(b(y,"point",R?.opacity)),legendOptions:s.legendOptions});if(I&&(S||I.visualVariables.forEach((e=>{"number"==typeof e.minSize&&"number"==typeof e.maxSize&&(e.minSize*=2.5,e.maxSize*=1.8)})),S&&"point"===M&&I.visualVariables.forEach((e=>{e?.minSize&&"object"==typeof e.minSize&&e.minSize?.stops?.forEach((e=>{e.size*=1.8}))})),_.authoringInfo=I.authoringInfo.clone(),_.visualVariables=I.visualVariables?.map((e=>e.clone()))),R?.visualVariables?.length){const e=R.visualVariables.map((e=>e.clone()));_.visualVariables?_.visualVariables.push(...e):_.visualVariables=e}return O?.minSize&&("point"===M&&O.minSize.stops?.forEach((e=>{e.size*=2.5})),"polygon"===M&&O.minSize.stops?.forEach((e=>{e.size*=1.8})),_.visualVariables?_.visualVariables.push(O.minSize):_.visualVariables=[O.minSize]),{renderer:_,pieChartScheme:$(y),size:I,basemapId:c.basemapId,basemapTheme:c.basemapTheme,statistics:P}}const P=new Set(["unique-value","class-breaks"]),U=new e("#aaaaaa"),F=new e("#5c5c5c"),M=[new e("#e60049"),new e("#0bb4ff"),new e("#50e991"),new e("#e6d800"),new e("#9b19f5"),new e("#ffa300"),new e("#dc0ab4"),new e("#b3d4ff"),new e("#00bfa0"),new e("#f0cccc")];async function N(e){if(!e||!e.layer)throw new t("pie-chart-cluster-renderer:missing-parameters","'layer' parameter is required");const r={...e};r.shape=r.shape||"pie",r.defaultSymbolEnabled??=!0;const a=e.layer;if(!V(O).includes(a.type))throw new t("pie-chart-cluster-renderer:invalid-parameters","'layer' must be one of these types: "+x(O).join(", "));const n=null!=r.signal?{signal:r.signal}:null;await a.load(n);if(!("point"===a.geometryType))throw new t("pie-chart-cluster-renderer:invalid-parameters","Cluster renderers are only supported for point layers");const{renderer:i}=a;if(!i)throw new t("pie-chart-cluster-renderer:invalid-parameters","input layer does not have a renderer.");if(!P.has(i.type))throw new t("pie-chart-cluster-renderer:invalid-parameters",`Cannot create a pie chart renderer for clusters based on a ${i.type} renderer.`);if("valueExpression"in i&&i.valueExpression)throw new t("pie-chart-cluster-renderer:invalid-parameters","Cannot create a pie chart renderer for clusters from a layer whose renderer contains a valueExpression.");if("unique-value"===i.type){if(i.field2)throw new t("pie-chart-cluster-renderer:invalid-parameters","Cannot create a pie chart renderer for clusters from a UniqueValueRenderer using more than one field.");if(null!=i.uniqueValueInfos&&i.uniqueValueInfos.length>10)throw new t("pie-chart-cluster-renderer:invalid-parameters","PieChart cluster renderer cannot be created from a UniqueValueRenderer with more than 10 unique value infos.")}if("class-breaks"===i.type){if(i.classBreakInfos.length<2)throw new t("pie-chart-cluster-renderer:invalid-parameters","Cannot create a pie chart renderer for clusters from a layer renderer with a continuous color or size gradient.");if(i.classBreakInfos.length>10)throw new t("pie-chart-cluster-renderer:invalid-parameters","PieChart cluster renderer can not be created from a ClassBreaksRenderer with more than 10 class break infos.");if("class-breaks-size"===i?.authoringInfo?.type)throw new t("pie-chart-cluster-renderer:invalid-parameters","PieChart cluster renderer can not be created from a ClassBreaksRenderer with breaks varied by size instead of color.")}return r}async function _(e){const a=await N(e),{layer:t,shape:n,defaultSymbolEnabled:s,legendOptions:o}=a,{renderer:u}=t,p=(await i("esri/smartMapping/t9n/smartMapping")).other;let m=[];"unique-value"===u?.type&&(m=A({renderer:u,defaultSymbolEnabled:s,defaultLabelBackup:p})),"class-breaks"===u?.type&&(m=D({renderer:u,defaultSymbolEnabled:s,defaultLabelBackup:p}));const c=[],d=[];for(const r of m){const{field:e,color:a}=r;c.push(e),d.push(new l({color:a,field:e.name,label:e.alias}))}return{fields:c,renderer:new r({attributes:d,legendOptions:o,holePercentage:"donut"===n?.45:0,outline:null,size:18,othersCategory:null})}}function A(e){const{renderer:r,defaultSymbolEnabled:a,defaultLabelBackup:t}=e,{field:n,defaultSymbol:i,defaultLabel:l}=r,u=r.uniqueValueInfos??[],p=i&&a,m=p?9:10,c=f(M,m),d=u.slice(0,m).map(((e,r)=>{const a=e.label,t=c[r];return{field:new s({name:W(e.value?.toString()),alias:a,onStatisticExpression:new o({title:`Field definition - ${a}`,expression:H(n,e),returnType:"number"}),statisticType:"sum"}),color:G(e.symbol,t)}}))??[];if(p){const e="cluster_default",r=l||t;d.push({field:new s({name:W(e),alias:r,onStatisticExpression:new o({title:`Field definition - ${r}`,expression:J(n,u),returnType:"number"}),statisticType:"sum"}),color:G(i,F)})}return d}function D(e){const{renderer:r,defaultSymbolEnabled:a,defaultLabelBackup:t}=e,{field:n,classBreakInfos:i,defaultSymbol:l,defaultLabel:u}=r,p=l&&a,m=p?9:10,c=f(M,m),d=i.slice(0,m).map(((e,r)=>{const a=e.label||`${e.minValue} - ${e.maxValue}`,t=c[r];return{field:new s({name:W(a),alias:a,onStatisticExpression:new o({title:`Field definition - ${a}`,expression:Z(n,e),returnType:"number"}),statisticType:"sum"}),color:G(e.symbol,t)}}));if(p){const e="cluster_default",r=u||t;d.push({field:new s({name:W(e),alias:r,onStatisticExpression:new o({title:`Field definition - ${r}`,expression:K(n,i),returnType:"number"}),statisticType:"sum"}),color:G(l,F)})}return d}function W(e){return"SUM_"+(e+"").replaceAll(/[^a-zA-Z0-9_]/g,"_")}function G(e,r){if("simple-marker"===e?.type&&e.color)return e.color.clone();if("cim"===e?.type){const r=I(e);if(r)return r.clone()}return r?r.clone():U.clone()}function H(e,r){return`Number(Text($feature["${e}"]) == "${r.value+""}")`}function J(e,r){return`Number(!(${r.map((r=>`(Text($feature["${e}"]) == "${r.value+""}")`)).join(" || ")}))`}function Z(e,r){return`Number($feature["${e}"] >= ${r.minValue} && $feature["${e}"] < ${r.maxValue})`}function K(e,r){return`Number(!(${r.map((r=>`($feature["${e}"] >= ${r.minValue} && $feature["${e}"] < ${r.maxValue})`)).join(" || ")}))`}export{R as createRenderer,_ as createRendererForClustering};
|
|
5
|
+
import e from"../../Color.js";import"../../renderers/ClassBreaksRenderer.js";import"../../renderers/DictionaryRenderer.js";import"../../renderers/DotDensityRenderer.js";import"../../renderers/HeatmapRenderer.js";import r from"../../renderers/PieChartRenderer.js";import"../../renderers/Renderer.js";import"../../renderers/SimpleRenderer.js";import"../../renderers/UniqueValueRenderer.js";import"../../renderers/support/jsonUtils.js";import"../../core/Logger.js";import"../../symbols.js";import{isSome as a}from"../../core/arrayUtils.js";import t from"../../core/Error.js";import{toPt as n}from"../../core/screenUtils.js";import{fetchMessageBundle as i}from"../../intl/messages.js";import s from"../../layers/support/AggregateField.js";import o from"../../layers/support/ExpressionInfo.js";import l from"../../renderers/support/AttributeColorInfo.js";import{OthersCategory as u}from"../../renderers/support/OthersCategory.js";import p from"../heuristics/outline.js";import m from"../heuristics/sizeRange.js";import{createVisualVariables as c}from"./size.js";import{errorCallback as d,createColors as f,createSymbol as h,getSymbolOutlineFromScheme as b,verifyBasicFieldValidity as y,getBasemapInfo as w}from"./support/utils.js";import g from"../statistics/predominantCategories.js";import{getSumOfAttributesExpr as v}from"../statistics/support/utils.js";import{verifyBinningParams as S}from"../support/binningUtils.js";import{getFieldsList as z}from"../support/utils.js";import{LayerType as E,binningCapableLayerTypes as j,createLayerAdapter as C,getLayerTypeLabels as x,getLayerTypes as V}from"../support/adapters/support/layerUtils.js";import{cloneScheme as $,getSchemes as T}from"../symbology/pieChart.js";import{getCIMSymbolColor as I}from"../../symbols/support/cimSymbolUtils.js";import k from"../../symbols/SimpleLineSymbol.js";const O=[E.CSVLayer,E.FeatureLayer,E.GeoJSONLayer,E.OGCFeatureLayer,E.OrientedImageryLayer,E.StreamLayer,E.WFSLayer];async function q(e){if(!(e?.layer&&e.view&&e.attributes?.length))throw new t("pie-chart-renderer:missing-parameters","'layer', 'view' and 'attributes' parameters are required");if(e.attributes.length>10)throw new t("pie-chart-renderer:invalid-parameters","PieChart renderer does not support more than 10 attributes");e.forBinning&&S(e,"pie-chart-renderer");const r={...e,layer:e.layer,view:e.view,attributes:e.attributes};r.shape=r.shape||"pie",r.othersCategoryEnabled??=!0,r.includeSizeVariable=e.includeSizeVariable||!1;const a=e.forBinning?j:O,n=C(r.layer,a,e.forBinning);if(!n)throw new t("pie-chart-renderer:invalid-parameters","'layer' must be one of these types: "+x(a).join(", "));r.layer=n;const i=null!=r.signal?{signal:r.signal}:null;await Promise.all([e.view.when(),n.load(i)]);const s=n.geometryType,o="polygon"===s,l="point"===s||"multipoint"===s||o;if(r.outlineOptimizationEnabled=!!o&&r.outlineOptimizationEnabled,r.sizeOptimizationEnabled=!!l&&r.sizeOptimizationEnabled,!l)throw new t("pie-chart-renderer:not-supported","PieChart renderer is only supported for point and polygon layers");const u=[],p=r.attributes;for(const t of p){const e=await z({field:t.field,valueExpression:t.valueExpression});u.push(...e)}const m=y(n,u.filter(Boolean),"pie-chart-renderer:invalid-parameters");if(m)throw m;return r}async function L(e){let r=e.pieChartScheme,a=null,t=null;const n=await w(e.basemap,e.view);if(a=null!=n.basemapId?n.basemapId:null,t=null!=n.basemapTheme?n.basemapTheme:null,r)return{scheme:$(r),basemapId:a,basemapTheme:t};const i=T({numColors:e.attributes.length,geometryType:e.layer.geometryType,basemapTheme:t});return i&&(r=i.primaryScheme,a=i.basemapId,t=i.basemapTheme),{scheme:r,basemapId:a,basemapTheme:t}}async function B(e,r){const{valueExpression:a,sqlExpression:t,sqlWhere:n}=v(e.attributes),s=await i("esri/smartMapping/t9n/smartMapping");return c({layer:e.layer,basemap:e.basemap,valueExpression:a,sqlExpression:t,sqlWhere:n,sizeScheme:r,sizeOptimizationEnabled:e.sizeOptimizationEnabled,legendOptions:{title:s.sumOfCategories},view:e.view,signal:e.signal})}async function R(e){const[s,o]=await Promise.all([q(e),i("esri/smartMapping/t9n/smartMapping")]),c=await L(s),y=c?.scheme;if(!y)throw new t("pie-chart-renderer:insufficient-info","Unable to find pie-chart scheme");const w=s.layer,{includeSizeVariable:v,sizeOptimizationEnabled:S,outlineOptimizationEnabled:z,view:E,signal:j}=s,C=y.sizeScheme,x=s.attributes,V=x.map((e=>e.field)).filter(a),[T,I,O,R]=await Promise.all([V.length>1?g({layer:w,fields:V,view:E,signal:j}):null,v?B(s,C):null,!v&&S?m({layer:w,view:E,signal:j}).catch(d):null,z?p({layer:w,view:E,signal:j}).catch(d):null]),P=T?.predominantCategoryInfos?{uniqueValueInfos:T.predominantCategoryInfos}:{uniqueValueInfos:V.map((e=>({value:e,count:0})))},U=f(y.colors,x.length),F=x.map(((e,r)=>new l({field:e.field,valueExpression:e.valueExpression,label:e.label,valueExpressionTitle:e.valueExpressionTitle,color:U[r]}))),M=w.geometryType,N=null!=C&&"background"in C&&C.background,_=new r({attributes:F,othersCategory:new u({label:o.other,color:s.othersCategoryEnabled?y.colorForOthersCategory:null,threshold:.04}),holePercentage:"donut"===s.shape?.45:0,backgroundFillSymbol:N?h(M,{type:"2d",color:N.color,outline:b(N,M,R?.opacity)}):null,size:n(y.size),outline:new k(b(y,"point",R?.opacity)),legendOptions:s.legendOptions});if(I&&(S||I.visualVariables.forEach((e=>{"number"==typeof e.minSize&&"number"==typeof e.maxSize&&(e.minSize*=2.5,e.maxSize*=1.8)})),S&&"point"===M&&I.visualVariables.forEach((e=>{e?.minSize&&"object"==typeof e.minSize&&e.minSize?.stops?.forEach((e=>{e.size*=1.8}))})),_.authoringInfo=I.authoringInfo.clone(),_.visualVariables=I.visualVariables?.map((e=>e.clone()))),R?.visualVariables?.length){const e=R.visualVariables.map((e=>e.clone()));_.visualVariables?_.visualVariables.push(...e):_.visualVariables=e}return O?.minSize&&("point"===M&&O.minSize.stops?.forEach((e=>{e.size*=2.5})),"polygon"===M&&O.minSize.stops?.forEach((e=>{e.size*=1.8})),_.visualVariables?_.visualVariables.push(O.minSize):_.visualVariables=[O.minSize]),{renderer:_,pieChartScheme:$(y),size:I,basemapId:c.basemapId,basemapTheme:c.basemapTheme,statistics:P}}const P=new Set(["unique-value","class-breaks"]),U=new e("#aaaaaa"),F=new e("#5c5c5c"),M=[new e("#e60049"),new e("#0bb4ff"),new e("#50e991"),new e("#e6d800"),new e("#9b19f5"),new e("#ffa300"),new e("#dc0ab4"),new e("#b3d4ff"),new e("#00bfa0"),new e("#f0cccc")];async function N(e){if(!e||!e.layer)throw new t("pie-chart-cluster-renderer:missing-parameters","'layer' parameter is required");const r={...e};r.shape=r.shape||"pie",r.defaultSymbolEnabled??=!0;const a=e.layer;if(!V(O).includes(a.type))throw new t("pie-chart-cluster-renderer:invalid-parameters","'layer' must be one of these types: "+x(O).join(", "));const n=null!=r.signal?{signal:r.signal}:null;await a.load(n);if(!("point"===a.geometryType))throw new t("pie-chart-cluster-renderer:invalid-parameters","Cluster renderers are only supported for point layers");const{renderer:i}=a;if(!i)throw new t("pie-chart-cluster-renderer:invalid-parameters","input layer does not have a renderer.");if(!P.has(i.type))throw new t("pie-chart-cluster-renderer:invalid-parameters",`Cannot create a pie chart renderer for clusters based on a ${i.type} renderer.`);if("valueExpression"in i&&i.valueExpression)throw new t("pie-chart-cluster-renderer:invalid-parameters","Cannot create a pie chart renderer for clusters from a layer whose renderer contains a valueExpression.");if("unique-value"===i.type){if(i.field2)throw new t("pie-chart-cluster-renderer:invalid-parameters","Cannot create a pie chart renderer for clusters from a UniqueValueRenderer using more than one field.");if(null!=i.uniqueValueInfos&&i.uniqueValueInfos.length>10)throw new t("pie-chart-cluster-renderer:invalid-parameters","PieChart cluster renderer cannot be created from a UniqueValueRenderer with more than 10 unique value infos.")}if("class-breaks"===i.type){if(i.classBreakInfos.length<2)throw new t("pie-chart-cluster-renderer:invalid-parameters","Cannot create a pie chart renderer for clusters from a layer renderer with a continuous color or size gradient.");if(i.classBreakInfos.length>10)throw new t("pie-chart-cluster-renderer:invalid-parameters","PieChart cluster renderer can not be created from a ClassBreaksRenderer with more than 10 class break infos.");if("class-breaks-size"===i?.authoringInfo?.type)throw new t("pie-chart-cluster-renderer:invalid-parameters","PieChart cluster renderer can not be created from a ClassBreaksRenderer with breaks varied by size instead of color.")}return r}async function _(e){const a=await N(e),{layer:t,shape:n,defaultSymbolEnabled:s,legendOptions:o}=a,{renderer:u}=t,p=(await i("esri/smartMapping/t9n/smartMapping")).other;let m=[];"unique-value"===u?.type&&(m=A({renderer:u,defaultSymbolEnabled:s,defaultLabelBackup:p})),"class-breaks"===u?.type&&(m=D({renderer:u,defaultSymbolEnabled:s,defaultLabelBackup:p}));const c=[],d=[];for(const r of m){const{field:e,color:a}=r;c.push(e),d.push(new l({color:a,field:e.name,label:e.alias}))}return{fields:c,renderer:new r({attributes:d,legendOptions:o,holePercentage:"donut"===n?.45:0,outline:null,size:9,othersCategory:null})}}function A(e){const{renderer:r,defaultSymbolEnabled:a,defaultLabelBackup:t}=e,{field:n,defaultSymbol:i,defaultLabel:l}=r,u=r.uniqueValueInfos??[],p=i&&a,m=p?9:10,c=f(M,m),d=u.slice(0,m).map(((e,r)=>{const a=e.label,t=c[r];return{field:new s({name:W(e.value?.toString()),alias:a,onStatisticExpression:new o({title:`Field definition - ${a}`,expression:H(n,e),returnType:"number"}),statisticType:"sum"}),color:G(e.symbol,t)}}))??[];if(p){const e="cluster_default",r=l||t;d.push({field:new s({name:W(e),alias:r,onStatisticExpression:new o({title:`Field definition - ${r}`,expression:J(n,u),returnType:"number"}),statisticType:"sum"}),color:G(i,F)})}return d}function D(e){const{renderer:r,defaultSymbolEnabled:a,defaultLabelBackup:t}=e,{field:n,classBreakInfos:i,defaultSymbol:l,defaultLabel:u}=r,p=l&&a,m=p?9:10,c=f(M,m),d=i.slice(0,m).map(((e,r)=>{const a=e.label||`${e.minValue} - ${e.maxValue}`,t=c[r];return{field:new s({name:W(a),alias:a,onStatisticExpression:new o({title:`Field definition - ${a}`,expression:Z(n,e),returnType:"number"}),statisticType:"sum"}),color:G(e.symbol,t)}}));if(p){const e="cluster_default",r=u||t;d.push({field:new s({name:W(e),alias:r,onStatisticExpression:new o({title:`Field definition - ${r}`,expression:K(n,i),returnType:"number"}),statisticType:"sum"}),color:G(l,F)})}return d}function W(e){return"SUM_"+(e+"").replaceAll(/[^a-zA-Z0-9_]/g,"_")}function G(e,r){if("simple-marker"===e?.type&&e.color)return e.color.clone();if("cim"===e?.type){const r=I(e);if(r)return r.clone()}return r?r.clone():U.clone()}function H(e,r){return`Number(Text($feature["${e}"]) == "${r.value+""}")`}function J(e,r){return`Number(!(${r.map((r=>`(Text($feature["${e}"]) == "${r.value+""}")`)).join(" || ")}))`}function Z(e,r){return`Number($feature["${e}"] >= ${r.minValue} && $feature["${e}"] < ${r.maxValue})`}function K(e,r){return`Number(!(${r.map((r=>`($feature["${e}"] >= ${r.minValue} && $feature["${e}"] < ${r.maxValue})`)).join(" || ")}))`}export{R as createRenderer,_ as createRendererForClustering};
|
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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const e="
|
|
5
|
+
const e="20240223",d="417264d9eb93e159f11fe008e11ab15de964fd70";export{e as buildDate,d 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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{fromMat4 as r,transpose as o}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as s,multiply as n,invert as i,getTranslation as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c,IDENTITY as u,clone as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as h}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{s as f,g as p,h as d,j as g,n as x,f as _,b as T}from"../../../../chunks/vec32.js";import{ZEROS as b,ONES as y,create as v}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as C}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as j}from"../../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as w}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as R}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToPoint as M}from"../../../../geometry/projection/projectVectorToPoint.js";import{create as O,empty as P,expandWithBuffer as A,intersectsClippingArea as E}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as N}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as I,getZeroIndexArray as S}from"../../../../geometry/support/Indices.js";import U from"../../../../geometry/support/MeshComponent.js";import B from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import F from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as D}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as L}from"../../../../geometry/support/spatialReferenceUtils.js";import{a as $,b as V}from"../../../../chunks/vec3.js";import{project as G}from"../../../../geometry/support/meshUtils/georeference.js";import{transformNormal as H,projectNormalToPCPF as k,transformTangent as q,projectTangentToPCPF as W}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as z}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as Y}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as J}from"../../../ViewingMode.js";import{isEncodedMeshTexture as K}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as Q}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as X}from"./ElevationAligners.js";import{needsElevationUpdates3D as Z,evaluateElevationInfoAtPoint as ee}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as te}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as re}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as oe}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as ae,MeshFastUpdateProcessor as se}from"./MeshFastUpdateProcessor.js";import{createMaterial as ne}from"../support/edgeUtils.js";import{parseColorMixMode as ie,encodeSymbolColor as le}from"../support/symbolColorUtils.js";import{debugFlags as ce}from"../../support/debugFlags.js";import{Attribute as ue}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as me,CullFaceOptions as he}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as fe}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as pe}from"../../webgl-engine/lib/Geometry.js";import{Object3D as de}from"../../webgl-engine/lib/Object3D.js";import{Texture as ge}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as xe}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as _e}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as Te}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as be,defaultSchematicMRRFactors as ye,defaultAdvancedMRRFactors as ve}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as Ce}from"../../../webgl/enums.js";const je=["mesh"];class we extends oe{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new ae,this._fastUpdateProcessor=new se,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){ce.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new Te({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new Te({color:[0,1,1,1]}))}destroy(){super.destroy(),this._textures.forEach((e=>e.unload())),this._context.stage.removeMany(this._materialInfoCache.materials),this._context.stage.removeMany(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy(this._context.stage)}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,je,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache,this._context)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>t(e)?.layerOpacityChanged(r,this._context.isAsync)))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,Z)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync))),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters((({material:t})=>t.setParameters({usePBR:e}))),!0}updateTransform(e,t,r,o){const a=e.fastTransformUpdatesEnabled;switch(o){case Y.EnableFastUpdates:if(a)return!0;break;case Y.DisableFastUpdates:if(!a)return!0;break;default:if(!a)return!1}const s=this._context.renderCoordsHelper.spatialReference,n=Se,{origin:i,transform:l}=r;if(!w(t,f(Oe,i.x,i.y,i.z??0),n,s))return!1;switch(o){case Y.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case Y.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case Y.UpdateFastLocalOrigin:e.updateFastLocalOrigin(n,l,this._context.localOriginFactory)}const{elevationContext:c}=e;c.centerPointInElevationSR=this._getCenterPointInElevationSR(n);const{elevationProvider:u,renderCoordsHelper:m}=this._context,h=(e,t)=>ee(e,u,c,m,t);return e.alignedSampledElevation=X(e,c,u.spatialReference,h,m,n),e.updateTransform(n,l,this._context.isAsync),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_textureTransformUid(e){const{offset:t,scale:r,rotation:o}=e??Fe;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:s,colorTextureTransform:n,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,h=this._colorOrTextureUid(a),f=this._colorOrTextureUid(s),p=this._textureTransformUid(n),d=this._colorOrTextureUid(i),g=this._textureTransformUid(l);if(o.color=a,o.colorTexture=s,o.normalTexture=i,o.uid=`${o.uid},cmuid:${h},ctmuid:${f},cttuid:${p},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof B){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:s,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:h}=t.material,f=this._colorOrTextureUid(a),p=this._textureTransformUid(s),d=this._colorOrTextureUid(i),g=this._colorOrTextureUid(c),x=this._textureTransformUid(u),_=this._colorOrTextureUid(m),T=this._textureTransformUid(h);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=this._convertTextureTransform(n),o.normalTextureTransform=this._convertTextureTransform(l),o.emissiveTextureTransform=this._convertTextureTransform(u),o.occlusionTextureTransform=this._convertTextureTransform(h),o.metallicRoughnessTextureTransform=this._convertTextureTransform(s),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${f},mrtt:${p},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${T}`}return o}_convertTextureTransform(e){if(!e)return null;const{scale:r,offset:o,rotation:a}=e;return{scale:r,offset:o,rotation:t(a)}}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data??e.url}_getInternalTextureId(e){const t=this._getInternalTexture(e,me.Opaque);return t?.id}_getInternalTexture(e,t){const r=this._getLoadableTextureResource(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let a=this._textures.get(o);if(!a){let s=null;const n=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,i={wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,maxAnisotropy:n,mipmap:n>1};K(r)?(s=r.data,i.preMultiplyAlpha=!1,i.encoding=r.encoding):(s=r,i.preMultiplyAlpha=t!==me.Opaque,i.downsampleUncompressed=this._context.graphicsCoreOwner.view.qualitySettings.graphics3D.uncompressedTextureDownsamplingEnabled),a=new ge(s,i),this._textures.set(o,a),a.load(this._context.stage.renderView.renderingContext),this._context.stage.add(a)}return a}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return Ce.CLAMP_TO_EDGE;case"mirror":return Ce.MIRRORED_REPEAT;default:return Ce.REPEAT}}_setInternalMaterialParameters(t,r){if(null!=t.color&&this._setInternalColorValueParameters(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=Q(t.colorTextureTransform),r.normalTextureTransformMatrix=Q(t.normalTextureTransform);const o=null!=t.normalTextureTransform?.scale?t.normalTextureTransform?.scale:h;r.scale=[o[0],o[1]],r.occlusionTextureTransformMatrix=Q(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=Q(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=Q(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=this.symbolLayer.material?.colorMixMode??null;if(r)t.externalColor=C;else{const r=this.symbolLayer.material?.color??null;r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=C)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(t,r){const o=r.material?.color,a=r.material?.colorTexture,s=r.material?.alphaMode,n="blend"===s,i=!("opaque"===s)&&(this._hasTransparentVertexColors(t)||null!=o&&o.a<1||a?.transparent||n),l=this._materialProperties(t,r,i),c=this._materialInfoCache.byUid(l.uid);if(c)return c.material;const u={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=be({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGB(l.emissiveColor),occlusionTexture:l.occlusionTexture}),h={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:b,diffuse:y,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:he.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};h.mrrFactors=m?[...ye]:[l.metallic,l.roughness,ve[2]],r.material&&(h.doubleSided=r.material.doubleSided,h.cullFace=r.material.doubleSided?he.None:he.Back,h.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(h),this._setMaterialTransparentParameter(h,u),this._setInternalMaterialParameters(l,h);const f=new _e(h);return u.material=f,this._materialInfoCache.set(l.uid,u),this._context.stage.add(f),f}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?me.MaskBlend:me.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?me.Opaque:"mask"===t.alphaMode?me.Mask:me.Blend}_addDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,a=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),s=[],n=[],i=[],l=[];for(let h=0;h<r;h++){const e=t[h],r=e.attributes.get(xe.POSITION),o=e.attributes.get(xe.NORMAL),c=r.data,u=r.indices,m=o.data,f=o.indices;for(let t=0;t<u.length;t++){const e=3*u[t],r=3*f[t];for(let t=0;t<3;t++)s.push(c[e+t]);for(let t=0;t<3;t++)s.push(c[e+t]+m[r+t]*a);if(n.push(n.length),n.push(n.length),t%3==0){this._calculateFaceNormal(c,u,t,Ee),this._getFaceVertices(c,u,t,Oe,Pe,Ae),p(Oe,Oe,Pe),p(Oe,Oe,Ae),d(Oe,Oe,1/3);for(let e=0;e<3;e++)i.push(Oe[e]);for(let e=0;e<3;e++)i.push(Oe[e]+Ee[e]*a);l.push(l.length),l.push(l.length)}}}const c=t[0].transformation,u=new pe(this._debugVertexNormalMaterial,[[xe.POSITION,new ue(s,n,3,!0)]],null,fe.Line);t.push(u),u.transformation=c;const m=new pe(this._debugFaceNormalMaterial,[[xe.POSITION,new ue(i,l,3,!0)]],null,fe.Line);m.transformation=c,t.push(m)}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const s=this._createGeometryInfo(a,t,o);if(null==s)return null;const{geometries:n,objectTransformation:i}=s;ce.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(a,n);const l=new de({geometries:n,layerUid:this._context.layer.uid,graphicUid:o,isElevationSource:!0});l.transformation=i;const c=ne(this.symbolLayer,{opacity:this._getLayerOpacity()}),u=c?new re(n[0].material,[c],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new te(this,l,n,null,null,X,r,u);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=Z(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:h,renderCoordsHelper:f}=this._context,p=(e,t)=>ee(e,h,r,f,t);return m.alignedSampledElevation=X(m,r,h.spatialReference,p,f),m}_getCenterPointInElevationSR(e){const t=z(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return M([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){default:case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o)}}_createComponentNormalsSource(e,t,r,o){if(null==t)return this._createComponentNormalsFlat(e,o);let a=!1;if(!r.trustSourceNormals)for(let s=0;s<o.length;s+=3){this._calculateFaceNormal(e,o,s,Ee);for(let e=0;e<3;e++){const r=3*o[s+e];Oe[0]=t[r],Oe[1]=t[r+1],Oe[2]=t[r+2],g(Ee,Oe)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new Re(t,o,a)}_createComponentNormalsFlat(e,t){const r=N(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const s=this._calculateFaceNormal(e,t,a,Ee);for(let e=0;e<3;e++)r[a+e]=s[e],o[a+e]=a/3}return new Re(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let s=0;s<t.length;s+=3){const o=this._calculateFaceNormal(e,t,s,Ee);for(let e=0;e<3;e++){const a=t[s+e];let n=r[a];n||(n={normal:v(),count:0},r[a]=n),p(n.normal,n.normal,o),n.count++}}const o=N(3*t.length),a=new Array(3*t.length);for(let s=0;s<t.length;s++){const e=r[t[s]];1!==e.count&&(x(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*s+t]=e.normal[t];a[s]=s}return new Re(o,a,!1)}_getFaceVertices(e,t,r,o,a,s){const n=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[n],o[1]=e[n+1],o[2]=e[n+2],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],s[0]=e[l],s[1]=e[l+1],s[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,Oe,Pe,Ae),_(Pe,Pe,Oe),_(Ae,Ae,Oe),T(Oe,Pe,Ae),x(o,Oe),o}_getOrCreateComponents(e){return e.components??Be}_createPositionBuffer(e,t){let r=e.vertexAttributes.position;const o=t.reprojection===De.RENDER?t.transformBeforeProject:null;if(o&&(r=$(new Float64Array(r.length),r,o)),t.reprojection===De.NONE)return t.needsBufferCopy?new Float64Array(r):r;const a=o?r:new Float64Array(r.length);return R(r,e.spatialReference,0,a,this._context.renderCoordsHelper.spatialReference,0,r.length/3),a}_createNormalBuffer(e,t,r){let o=e.vertexAttributes.normal;if(null==o)return null;const a=r.reprojection===De.RENDER?r.transformBeforeProject:null;a&&(o=H(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===De.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const s=e.vertexAttributes.position,n=a?o:new Float32Array(o.length);return k(o,s,t,e.spatialReference,n)}_createTangentBuffer(e,t,r){let o=e.vertexAttributes.tangent;if(null==o)return null;const a=r.reprojection===De.RENDER?r.transformBeforeProject:null;a&&(o=q(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===De.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const s=e.vertexAttributes.position,n=a?o:new Float32Array(o.length);return W(o,s,t,e.spatialReference,n)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=ie(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return le(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,a=e.vertexAttributes.uv,s=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(s&&s.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const n=this._computeReprojectionInfo(e),i=this._createPositionBuffer(e,n),l=this._createColorBuffer(e),u=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,n),h=this._createTangentBuffer(e,i,n);return{positionBuffer:i,normalBuffer:m,tangentBuffer:h,uvBuffer:a,colorBuffer:l,symbolColorBuffer:u,objectTransformation:n.reprojection===De.NONE&&n.objectTransformation?n.objectTransformation:this._transformOriginLocal(e,i,m,h),geometryTransformation:n.reprojection===De.NONE&&n.geometryTransformation?n.geometryTransformation:c()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?L(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?De.NONE:De.RENDER:De.NONE;if(D(t)){const o=t.origin,a=c(),i=e.transform?.localMatrix??u;if(r===De.NONE){w(e.spatialReference,o,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:a,geometryTransformation:m(i),needsBufferCopy:!1}}const l=s(c(),o);return n(l,l,i),{reprojection:r,transformBeforeProject:l,needsBufferCopy:!0}}return{reprojection:r,needsBufferCopy:!0}}_transformOriginLocal(e,t,a,s){const n=this._context.renderCoordsHelper.spatialReference,l=e.anchor;Me[0]=l.x,Me[1]=l.y,Me[2]=l.z??0;const u=c();return w(e.spatialReference,Me,u,n),i(Ne,u),$(t,t,Ne),(a||s)&&(r(Ie,u),o(Ie,Ie),a&&V(a,a,Ie),s&&V(s,s,Ie,4)),u}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_getOrCreateFaces(e,t){return t.faces??I(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=G({positions:t,transform:e.transform,vertexSpace:e.vertexSpace,inSpatialReference:e.spatialReference,outSpatialReference:r??e.spatialReference,localMode:this._context.stage.viewingMode===J.Local}),a=o.length/3;return P(Ue),A(Ue,o,0,a),!E(Ue,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!j(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:a,uvBuffer:s,colorBuffer:n,symbolColorBuffer:i,normalBuffer:c,tangentBuffer:u,objectTransformation:m,geometryTransformation:h}=o,f=this._getOrCreateComponents(e),p=new Array;let d=!1;const g=l(Oe,m),x=this._context.localOriginFactory.getOrigin(g);for(const l of f){if(!this._validateFaces(e,l))return null;const t=this._getOrCreateFaces(e,l);if(0===t.length)continue;const o=this._createComponentNormals(a,c,l,t);o.didFlipNormals&&(d=!0);const m=[[xe.POSITION,new ue(a,t,3,!0)],[xe.NORMAL,new ue(o.normals,o.indices,3,!0)]];n&&m.push([xe.COLOR,new ue(n,t,4,!0)]),i&&m.push([xe.SYMBOLCOLOR,new ue(i,S(t.length),4,!0)]),s&&m.push([xe.UV0,new ue(s,t,2,!0)]),u&&m.push([xe.TANGENT,new ue(u,t,4,!0)]);const f=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),g=this._getOrCreateMaterial(e,l),_=new pe(g,m,null,fe.Mesh,f);_.transformation=h,_.localOrigin=x,p.push(_)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:p,objectTransformation:m}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}test(){return{...super.test(),materials:this._materialInfoCache.materials}}}class Re{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const Me=v(),Oe=v(),Pe=v(),Ae=v(),Ee=v(),Ne=c(),Ie=a(),Se=c(),Ue=O(),Be=[new U],Fe=new F;var De;!function(e){e[e.NONE=0]="NONE",e[e.RENDER=1]="RENDER"}(De||(De={}));export{we as Graphics3DMeshFillSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{fromMat4 as r,transpose as o}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as s,multiply as n,invert as i,getTranslation as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c,IDENTITY as u,clone as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as h}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{s as f,g as p,h as d,j as g,n as x,f as _,b as T}from"../../../../chunks/vec32.js";import{ZEROS as b,ONES as y,create as v}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as C}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as w}from"../../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as j}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as R}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToPoint as M}from"../../../../geometry/projection/projectVectorToPoint.js";import{create as O,empty as P,expandWithBuffer as A,intersectsClippingArea as E}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as N}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as I,getZeroIndexArray as S}from"../../../../geometry/support/Indices.js";import U from"../../../../geometry/support/MeshComponent.js";import B from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import F from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as D}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as L}from"../../../../geometry/support/spatialReferenceUtils.js";import{a as V,b as $}from"../../../../chunks/vec3.js";import{project as G}from"../../../../geometry/support/meshUtils/georeference.js";import{transformNormal as H,projectNormalToPCPF as k,transformTangent as q,projectTangentToPCPF as W}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as z}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as Y}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as J}from"../../../ViewingMode.js";import{isEncodedMeshTexture as K}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as Q}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as X}from"./ElevationAligners.js";import{needsElevationUpdates3D as Z,evaluateElevationInfoAtPoint as ee}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as te}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as re}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as oe}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as ae,MeshFastUpdateProcessor as se}from"./MeshFastUpdateProcessor.js";import{createMaterial as ne}from"../support/edgeUtils.js";import{parseColorMixMode as ie,encodeSymbolColor as le}from"../support/symbolColorUtils.js";import{debugFlags as ce}from"../../support/debugFlags.js";import{Attribute as ue}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as me,CullFaceOptions as he}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as fe}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as pe}from"../../webgl-engine/lib/Geometry.js";import{Object3D as de}from"../../webgl-engine/lib/Object3D.js";import{Texture as ge}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as xe}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as _e}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as Te}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as be,defaultSchematicMRRFactors as ye,defaultAdvancedMRRFactors as ve}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as Ce}from"../../../webgl/enums.js";const we=["mesh"];class je extends oe{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new ae,this._fastUpdateProcessor=new se,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){ce.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new Te({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new Te({color:[0,1,1,1]}))}destroy(){super.destroy(),this._textures.forEach((e=>e.unload())),this._context.stage.removeMany(this._materialInfoCache.materials),this._context.stage.removeMany(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy(this._context.stage)}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,we,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache,this._context)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>t(e)?.layerOpacityChanged(r,this._context.isAsync)))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,Z)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync))),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters((({material:t})=>t.setParameters({usePBR:e}))),!0}updateTransform(e,t,r,o){const a=e.fastTransformUpdatesEnabled;switch(o){case Y.EnableFastUpdates:if(a)return!0;break;case Y.DisableFastUpdates:if(!a)return!0;break;default:if(!a)return!1}const s=this._context.renderCoordsHelper.spatialReference,n=Se,{origin:i,transform:l}=r;if(!j(t,f(Oe,i.x,i.y,i.z??0),n,s))return!1;switch(o){case Y.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case Y.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case Y.UpdateFastLocalOrigin:e.updateFastLocalOrigin(n,l,this._context.localOriginFactory)}const{elevationContext:c}=e;c.centerPointInElevationSR=this._getCenterPointInElevationSR(n);const{elevationProvider:u,renderCoordsHelper:m}=this._context,h=(e,t)=>ee(e,u,c,m,t);return e.alignedSampledElevation=X(e,c,u.spatialReference,h,m,n),e.updateTransform(n,l,this._context.isAsync),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_textureTransformUid(e){const{offset:t,scale:r,rotation:o}=e??Fe;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:s,colorTextureTransform:n,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,h=this._colorOrTextureUid(a),f=this._colorOrTextureUid(s),p=this._textureTransformUid(n),d=this._colorOrTextureUid(i),g=this._textureTransformUid(l);if(o.color=a,o.colorTexture=s,o.normalTexture=i,o.uid=`${o.uid},cmuid:${h},ctmuid:${f},cttuid:${p},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof B){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:s,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:h}=t.material,f=this._colorOrTextureUid(a),p=this._textureTransformUid(s),d=this._colorOrTextureUid(i),g=this._colorOrTextureUid(c),x=this._textureTransformUid(u),_=this._colorOrTextureUid(m),T=this._textureTransformUid(h);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=this._convertTextureTransform(n),o.normalTextureTransform=this._convertTextureTransform(l),o.emissiveTextureTransform=this._convertTextureTransform(u),o.occlusionTextureTransform=this._convertTextureTransform(h),o.metallicRoughnessTextureTransform=this._convertTextureTransform(s),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${f},mrtt:${p},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${T}`}return o}_convertTextureTransform(e){if(!e)return null;const{scale:r,offset:o,rotation:a}=e;return{scale:r,offset:o,rotation:t(a)}}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data??e.url}_getInternalTextureId(e){const t=this._getInternalTexture(e,me.Opaque);return t?.id}_getInternalTexture(e,t){const r=this._getLoadableTextureResource(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let a=this._textures.get(o);if(!a){let s=null;const n=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,i={wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,maxAnisotropy:n,mipmap:n>1};K(r)?(s=r.data,i.preMultiplyAlpha=!1,i.encoding=r.encoding):(s=r,i.preMultiplyAlpha=t!==me.Opaque,i.downsampleUncompressed=this._context.graphicsCoreOwner.view.qualitySettings.graphics3D.uncompressedTextureDownsamplingEnabled),a=new ge(s,i),this._textures.set(o,a),a.load(this._context.stage.renderView.renderingContext),this._context.stage.add(a)}return a}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return Ce.CLAMP_TO_EDGE;case"mirror":return Ce.MIRRORED_REPEAT;default:return Ce.REPEAT}}_setInternalMaterialParameters(t,r){if(null!=t.color&&this._setInternalColorValueParameters(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=Q(t.colorTextureTransform),r.normalTextureTransformMatrix=Q(t.normalTextureTransform);const o=null!=t.normalTextureTransform?.scale?t.normalTextureTransform?.scale:h;r.scale=[o[0],o[1]],r.occlusionTextureTransformMatrix=Q(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=Q(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=Q(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=this.symbolLayer.material?.colorMixMode??null;if(r)t.externalColor=C;else{const r=this.symbolLayer.material?.color??null;r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=C)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(t,r){const o=r.material?.color,a=r.material?.colorTexture,s=r.material?.alphaMode,n="blend"===s,i=!("opaque"===s)&&(this._hasTransparentVertexColors(t)||null!=o&&o.a<1||a?.transparent||n),l=this._materialProperties(t,r,i),c=this._materialInfoCache.byUid(l.uid);if(c)return c.material;const u={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=be({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGB(l.emissiveColor),occlusionTexture:l.occlusionTexture}),h={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:b,diffuse:y,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:he.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};h.mrrFactors=m?[...ye]:[l.metallic,l.roughness,ve[2]],r.material&&(h.doubleSided=r.material.doubleSided,h.cullFace=r.material.doubleSided?he.None:he.Back,h.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(h),this._setMaterialTransparentParameter(h,u),this._setInternalMaterialParameters(l,h);const f=new _e(h);return u.material=f,this._materialInfoCache.set(l.uid,u),this._context.stage.add(f),f}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?me.MaskBlend:me.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?me.Opaque:"mask"===t.alphaMode?me.Mask:me.Blend}_addDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,a=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),s=[],n=[],i=[],l=[];for(let h=0;h<r;h++){const e=t[h],r=e.attributes.get(xe.POSITION),o=e.attributes.get(xe.NORMAL),c=r.data,u=r.indices,m=o.data,f=o.indices;for(let t=0;t<u.length;t++){const e=3*u[t],r=3*f[t];for(let t=0;t<3;t++)s.push(c[e+t]);for(let t=0;t<3;t++)s.push(c[e+t]+m[r+t]*a);if(n.push(n.length),n.push(n.length),t%3==0){this._calculateFaceNormal(c,u,t,Ee),this._getFaceVertices(c,u,t,Oe,Pe,Ae),p(Oe,Oe,Pe),p(Oe,Oe,Ae),d(Oe,Oe,1/3);for(let e=0;e<3;e++)i.push(Oe[e]);for(let e=0;e<3;e++)i.push(Oe[e]+Ee[e]*a);l.push(l.length),l.push(l.length)}}}const c=t[0].transformation,u=new pe(this._debugVertexNormalMaterial,[[xe.POSITION,new ue(s,n,3,!0)]],null,fe.Line);t.push(u),u.transformation=c;const m=new pe(this._debugFaceNormalMaterial,[[xe.POSITION,new ue(i,l,3,!0)]],null,fe.Line);m.transformation=c,t.push(m)}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const s=this._createGeometryInfo(a,t,o);if(null==s)return null;const{geometries:n,objectTransformation:i}=s;ce.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(a,n);const l=new de({geometries:n,layerUid:this._context.layer.uid,graphicUid:o,isElevationSource:!0});l.transformation=i;const c=ne(this.symbolLayer,{opacity:this._getLayerOpacity()}),u=c?new re(n[0].material,[c],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new te(this,l,n,null,null,X,r,u);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=Z(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:h,renderCoordsHelper:f}=this._context,p=(e,t)=>ee(e,h,r,f,t);return m.alignedSampledElevation=X(m,r,h.spatialReference,p,f),m}_getCenterPointInElevationSR(e){const t=z(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return M([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){default:case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o)}}_createComponentNormalsSource(e,t,r,o){if(null==t)return this._createComponentNormalsFlat(e,o);let a=!1;if(!r.trustSourceNormals)for(let s=0;s<o.length;s+=3){this._calculateFaceNormal(e,o,s,Ee);for(let e=0;e<3;e++){const r=3*o[s+e];Oe[0]=t[r],Oe[1]=t[r+1],Oe[2]=t[r+2],g(Ee,Oe)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new Re(t,o,a)}_createComponentNormalsFlat(e,t){const r=N(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const s=this._calculateFaceNormal(e,t,a,Ee);for(let e=0;e<3;e++)r[a+e]=s[e],o[a+e]=a/3}return new Re(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let s=0;s<t.length;s+=3){const o=this._calculateFaceNormal(e,t,s,Ee);for(let e=0;e<3;e++){const a=t[s+e];let n=r[a];n||(n={normal:v(),count:0},r[a]=n),p(n.normal,n.normal,o),n.count++}}const o=N(3*t.length),a=new Array(3*t.length);for(let s=0;s<t.length;s++){const e=r[t[s]];1!==e.count&&(x(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*s+t]=e.normal[t];a[s]=s}return new Re(o,a,!1)}_getFaceVertices(e,t,r,o,a,s){const n=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[n],o[1]=e[n+1],o[2]=e[n+2],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],s[0]=e[l],s[1]=e[l+1],s[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,Oe,Pe,Ae),_(Pe,Pe,Oe),_(Ae,Ae,Oe),T(Oe,Pe,Ae),x(o,Oe),o}_getOrCreateComponents(e){return e.components??Be}_createPositionBuffer(e,t){let r=e.vertexAttributes.position;const o=t.reprojection===De.RENDER?t.transformBeforeProject:null;if(o&&(r=V(new Float64Array(r.length),r,o)),t.reprojection===De.NONE)return t.needsBufferCopy?new Float64Array(r):r;const a=o?r:new Float64Array(r.length);return R(r,e.spatialReference,0,a,this._context.renderCoordsHelper.spatialReference,0,r.length/3),a}_createNormalBuffer(e,t,r){let o=e.vertexAttributes.normal;if(null==o)return null;const a=r.reprojection===De.RENDER?r.transformBeforeProject:null;a&&(o=H(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===De.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const s=e.vertexAttributes.position,n=a?o:new Float32Array(o.length);return k(o,s,t,e.spatialReference,n)}_createTangentBuffer(e,t,r){let o=e.vertexAttributes.tangent;if(null==o)return null;const a=r.reprojection===De.RENDER?r.transformBeforeProject:null;a&&(o=q(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===De.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const s=e.vertexAttributes.position,n=a?o:new Float32Array(o.length);return W(o,s,t,e.spatialReference,n)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=ie(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return le(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,a=e.vertexAttributes.uv,s=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(s&&s.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const n=this._computeReprojectionInfo(e),i=this._createPositionBuffer(e,n),l=this._createColorBuffer(e),u=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,n),h=this._createTangentBuffer(e,i,n);return{positionBuffer:i,normalBuffer:m,tangentBuffer:h,uvBuffer:a,colorBuffer:l,symbolColorBuffer:u,objectTransformation:n.reprojection===De.NONE&&n.objectTransformation?n.objectTransformation:this._transformOriginLocal(e,i,m,h),geometryTransformation:n.reprojection===De.NONE&&n.geometryTransformation?n.geometryTransformation:c()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?L(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?De.NONE:De.RENDER:De.NONE;if(D(t)){const o=t.origin,a=c(),i=e.transform?.localMatrix??u;if(r===De.NONE){j(e.spatialReference,o,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:a,geometryTransformation:m(i),needsBufferCopy:!1}}const l=s(c(),o);return n(l,l,i),{reprojection:r,transformBeforeProject:l,needsBufferCopy:!0}}return{reprojection:r,needsBufferCopy:!0}}_transformOriginLocal(e,t,a,s){const n=this._context.renderCoordsHelper.spatialReference,l=e.anchor;Me[0]=l.x,Me[1]=l.y,Me[2]=l.z??0;const u=c();return j(e.spatialReference,Me,u,n),i(Ne,u),V(t,t,Ne),(a||s)&&(r(Ie,u),o(Ie,Ie),a&&$(a,a,Ie),s&&$(s,s,Ie,4)),u}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_getOrCreateFaces(e,t){return t.faces??I(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=G({positions:t,transform:e.transform,vertexSpace:e.vertexSpace,inSpatialReference:e.spatialReference,outSpatialReference:r??e.spatialReference,localMode:this._context.stage.viewingMode===J.Local}),a=o.length/3;return P(Ue),A(Ue,o,0,a),!E(Ue,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!w(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(!this._validateVertexSpace(e))return null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:a,uvBuffer:s,colorBuffer:n,symbolColorBuffer:i,normalBuffer:c,tangentBuffer:u,objectTransformation:m,geometryTransformation:h}=o,f=this._getOrCreateComponents(e),p=new Array;let d=!1;const g=l(Oe,m),x=this._context.localOriginFactory.getOrigin(g);for(const l of f){if(!this._validateFaces(e,l))return null;const t=this._getOrCreateFaces(e,l);if(0===t.length)continue;const o=this._createComponentNormals(a,c,l,t);o.didFlipNormals&&(d=!0);const m=[[xe.POSITION,new ue(a,t,3,!0)],[xe.NORMAL,new ue(o.normals,o.indices,3,!0)]];n&&m.push([xe.COLOR,new ue(n,t,4,!0)]),i&&m.push([xe.SYMBOLCOLOR,new ue(i,S(t.length),4,!0)]),s&&m.push([xe.UV0,new ue(s,t,2,!0)]),u&&m.push([xe.TANGENT,new ue(u,t,4,!0)]);const f=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),g=this._getOrCreateMaterial(e,l),_=new pe(g,m,null,fe.Mesh,f);_.transformation=h,_.localOrigin=x,p.push(_)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:p,objectTransformation:m}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}_validateVertexSpace(e){const{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:r}=e;return t!==J.Local||"local"!==r.type||(this.logger.warn("Displaying a mesh with a local vertex space in a view in local viewing mode is not supported."),!1)}test(){return{...super.test(),materials:this._materialInfoCache.materials}}}class Re{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const Me=v(),Oe=v(),Pe=v(),Ae=v(),Ee=v(),Ne=c(),Ie=a(),Se=c(),Ue=O(),Be=[new U],Fe=new F;var De;!function(e){e[e.NONE=0]="NONE",e[e.RENDER=1]="RENDER"}(De||(De={}));export{je as Graphics3DMeshFillSymbolLayer};
|