@arcgis/core 5.0.0-next.28 → 5.0.0-next.29
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/Map.js +1 -1
- package/WebScene.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{aca72ca7f43f70eb8077.js → 0bfb7db0a151a5e85dd1.js} +1 -1
- package/assets/esri/core/workers/chunks/2d0d8243ed0c21f8a498.js +1 -0
- package/assets/esri/core/workers/chunks/{e873359e00e0866d4ef6.js → 66853ecdebfc2aa68ce7.js} +21 -22
- package/assets/esri/core/workers/chunks/6c8f5a56e94fdbe6a4a5.js +1 -0
- package/assets/esri/core/workers/chunks/6ce7ca6bebdc61d8eada.js +1 -0
- package/assets/esri/core/workers/chunks/{8b33732e3c2924c1f60d.js → e615983fab688d515205.js} +1 -1
- package/assets/esri/core/workers/chunks/e6fa6f9c278589c8a713.js +1 -0
- package/chunks/CheckerBoard.glsl.js +2 -2
- package/chunks/ColorMaterial.glsl.js +2 -2
- package/chunks/ComponentShader.glsl.js +2 -2
- package/chunks/DefaultMaterial.glsl.js +2 -2
- package/chunks/ImageMaterial.glsl.js +2 -2
- package/chunks/LineMarker.glsl.js +2 -2
- package/chunks/NativeLine.glsl.js +2 -2
- package/chunks/Path.glsl.js +3 -3
- package/chunks/Pattern.glsl.js +2 -2
- package/chunks/RealisticTree.glsl.js +2 -2
- package/chunks/RibbonLine.glsl.js +2 -2
- package/chunks/ShadedColorMaterial.glsl.js +2 -2
- package/chunks/Terrain.glsl.js +27 -37
- package/chunks/WaterSurface.glsl.js +2 -2
- package/config.js +1 -1
- package/core/accessorSupport/decorators/property.js +1 -1
- package/core/has.js +1 -1
- package/geometry/Circle.js +1 -1
- package/geometry/support/MeshMaterial.js +1 -1
- package/geometry/support/MeshMaterialMetallicRoughness.js +1 -1
- package/interfaces.d.ts +29 -23
- package/kernel.js +1 -1
- package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
- package/package.json +2 -2
- package/renderers/support/UniqueValueClass.js +1 -1
- package/renderers/visualVariables/SizeVariable.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterColorizerTechnique.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
- package/views/3d/layers/support/Tiles3DIntersectionHandler.js +1 -1
- package/views/3d/state/ViewState.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
- package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
- package/views/3d/support/QualityProfile.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/webgl-engine/Stage.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentData.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticBVH.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentShader.glsl.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/TriangleIntersectionData.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/shaders/CheckerBoard.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ColorMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ImageMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/LineMarker.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/NativeLine.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/{OutputColorHighlightOID.glsl.js → OutputColorHighlightOLID.glsl.js} +2 -3
- package/views/3d/webgl-engine/shaders/Path.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/Pattern.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/RealisticTree.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLine.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadedColorMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/TerrainTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/shaders/WaterSurface.glsl.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/View.js +1 -1
- package/views/View2D.js +1 -1
- package/views/Viewport2DMixin.js +1 -1
- package/views/navigation/Momentum.js +1 -1
- package/views/video/VideoOperationalDataView.js +1 -1
- package/webscene/Slide.js +1 -1
- package/widgets/BasemapGallery/BasemapGalleryViewModel.js +1 -1
- package/widgets/BasemapToggle/BasemapToggleViewModel.js +1 -1
- package/widgets/Editor/UpdateFeaturesWorkflowData.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/view/MapViewAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace.js +1 -1
- package/widgets/Widget.js +1 -1
- package/assets/esri/core/workers/chunks/3f2b1d2102eef7ac29b4.js +0 -1
- package/assets/esri/core/workers/chunks/7532e819d2f4ee4813be.js +0 -1
- package/assets/esri/core/workers/chunks/76f2ce14d0d3001620a9.js +0 -1
- package/assets/esri/core/workers/chunks/ab5c386100b84bc564dd.js +0 -1
- package/views/3d/webgl-engine/lib/ComponentUtils.js +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/core",
|
|
3
|
-
"version": "5.0.0-next.
|
|
3
|
+
"version": "5.0.0-next.29",
|
|
4
4
|
"homepage": "https://js.arcgis.com",
|
|
5
5
|
"description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
|
|
6
6
|
"keywords": [
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"license": "SEE LICENSE IN copyright.txt",
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@amcharts/amcharts5": "~5.14.3",
|
|
22
|
-
"@arcgis/toolkit": "^5.0.0-next.
|
|
22
|
+
"@arcgis/toolkit": "^5.0.0-next.35",
|
|
23
23
|
"@esri/arcgis-html-sanitizer": "~4.1.0",
|
|
24
24
|
"@esri/calcite-components": "^3.3.2",
|
|
25
25
|
"@vaadin/grid": "~24.9.2",
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as
|
|
5
|
+
import{__decorate as e}from"tslib";import{isSome as r}from"../../core/arrayUtils.js";import{ClonableMixin as t}from"../../core/Clonable.js";import{JSONSupport as o}from"../../core/JSONSupport.js";import{property as s,subclass as l}from"../../core/accessorSupport/decorators.js";import{rendererSymbolProperty as i}from"./commonProperties.js";import a from"./UniqueValue.js";let n=class extends(t(o)){constructor(e){super(e),this.description=null,this.label=null,this.symbol=null}get values(){return this._get("values")}set values(e){if(null!=e){const r=typeof(e=Array.isArray(e)?e:[e])[0];e="string"===r||"number"===r?e.map(e=>new a({value:e})):"object"===r?e[0]instanceof a?e:e.map(e=>new a(e)):null}this._set("values",e)}};e([s({type:String,json:{write:!0}})],n.prototype,"description",void 0),e([s({type:String,json:{write:!0}})],n.prototype,"label",void 0),e([s(i)],n.prototype,"symbol",void 0),e([s({json:{type:[[String]],read:{reader:e=>e?e.map(e=>new a({value:e[0],value2:e[1],value3:e[2]})):null},write:{writer:(e,t)=>{const o=[];for(const s of e){const e=[s.value,s.value2,s.value3].filter(r).map(e=>e.toString());o.push(e)}t.values=o}}}})],n.prototype,"values",null),n=e([l("esri.renderers.support.UniqueValueClass")],n);export{n 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{JSONMap as i}from"../../core/jsonMap.js";import s from"../../core/Logger.js";import{property as r,
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{JSONMap as i}from"../../core/jsonMap.js";import s from"../../core/Logger.js";import{property as r,subclass as a}from"../../core/accessorSupport/decorators.js";import n from"./VisualVariable.js";import{castSizeFromStringOrNumber as o}from"./support/castSizeVariable.js";import l from"./support/SizeStop.js";import p from"./support/SizeVariableLegendOptions.js";import{isSizeVariable as u,getInputValueType as m,getTransformationType as h}from"./support/sizeVariableUtils.js";import{viewScaleRE as d}from"./support/visualVariableUtils.js";import{reader as y}from"../../core/accessorSupport/decorators/reader.js";import{writer as c}from"../../core/accessorSupport/decorators/writer.js";var S;const x=new i({width:"width",depth:"depth",height:"height",widthAndDepth:"width-and-depth",all:"all"}),z=new i({unknown:"unknown",inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"});function v(e){if(null!=e)return"string"==typeof e||"number"==typeof e?o(e):"size"===e.type?u(e)?e:(delete(e={...e}).type,new w(e)):void 0}function g(e,t,i){if("object"!=typeof e)return e;const s=new w;return s.read(e,i),s}let w=S=class extends n{constructor(e){super(e),this.axis=null,this.legendOptions=null,this.normalizationField=null,this.scaleBy=null,this.target=null,this.type="size",this.useSymbolValue=null,this.valueExpression=null,this.valueRepresentation=null,this.valueUnit=null}get cache(){return{ipData:this._interpolateData(),hasExpression:!!this.valueExpression,compiledFunc:null,isScaleDriven:null!=this.valueExpression&&d.test(this.valueExpression)}}set index(e){u(this.maxSize)&&(this.maxSize.index=`visualVariables[${e}].maxSize`),u(this.minSize)&&(this.minSize.index=`visualVariables[${e}].minSize`),this._set("index",e)}get inputValueType(){return m(this)}set maxDataValue(e){e&&this.stops&&(s.getLogger(this).warn("cannot set maxDataValue when stops is not null."),e=null),this._set("maxDataValue",e)}get maxSize(){return this._get("maxSize")}set maxSize(e){e&&this.stops&&(s.getLogger(this).warn("cannot set maxSize when stops is not null."),e=null),this._set("maxSize",v(e))}readMaxSize(e,t,i){return g(e,t,i)}set minDataValue(e){e&&this.stops&&(s.getLogger(this).warn("cannot set minDataValue when stops is not null."),e=null),this._set("minDataValue",e)}get minSize(){return this._get("minSize")}set minSize(e){e&&this.stops&&(s.getLogger(this).warn("cannot set minSize when stops is not null."),e=null),this._set("minSize",v(e))}readMinSize(e,t,i){return g(e,t,i)}get arcadeRequired(){return!!this.valueExpression||(null!=this.minSize&&"object"==typeof this.minSize&&this.minSize.arcadeRequired||null!=this.maxSize&&"object"==typeof this.maxSize&&this.maxSize.arcadeRequired)}set stops(e){null==this.minDataValue&&null==this.maxDataValue&&null==this.minSize&&null==this.maxSize?e&&Array.isArray(e)&&(e=e.filter(e=>!!e)).sort((e,t)=>e.value-t.value):e&&(s.getLogger(this).warn("cannot set stops when one of minDataValue, maxDataValue, minSize or maxSize is not null."),e=null),this._set("stops",e)}get transformationType(){return h(this,this.inputValueType)}readValueExpression(e,t){return e||t.expression&&"$view.scale"}writeValueExpressionWebScene(e,i,s,r){if("$view.scale"===e){if(r?.messages){const e=this.index,i="string"==typeof e?e:`visualVariables[${e}]`;r.messages.push(new t("property:unsupported",this.type+"VisualVariable.valueExpression = '$view.scale' is not supported in Web Scene. Please remove this property to save the Web Scene.",{instance:this,propertyName:i+".valueExpression",context:r}))}}else i[s]=e}readValueUnit(e){return e?z.read(e):null}clone(){return new S({axis:this.axis,field:this.field,valueExpression:this.valueExpression,valueExpressionTitle:this.valueExpressionTitle,maxDataValue:this.maxDataValue,maxSize:u(this.maxSize)?this.maxSize.clone():this.maxSize,minDataValue:this.minDataValue,minSize:u(this.minSize)?this.minSize.clone():this.minSize,normalizationField:this.normalizationField,stops:this.stops?.map(e=>e.clone()),target:this.target,useSymbolValue:this.useSymbolValue,valueRepresentation:this.valueRepresentation,valueUnit:this.valueUnit,legendOptions:this.legendOptions?.clone()})}flipSizes(){if("clamped-linear"===this.transformationType){const{minSize:e,maxSize:t}=this;return this.minSize=t,this.maxSize=e,this}if("stops"===this.transformationType){const e=this.stops;if(!e)return this;const t=e.map(e=>e.size).reverse(),i=e.length;for(let s=0;s<i;s++)e[s].size=t[s];return this}return this}getAttributeHash(){return`${super.getAttributeHash()}-${this.target}-${this.normalizationField}`}_interpolateData(){return this.stops?.map(e=>e.value||0)}};e([r({readOnly:!0})],w.prototype,"cache",null),e([r({type:x.apiValues,json:{type:x.jsonValues,origins:{"web-map":{read:!1}},read:x.read,write:x.write}})],w.prototype,"axis",void 0),e([r()],w.prototype,"index",null),e([r({type:String,readOnly:!0})],w.prototype,"inputValueType",null),e([r({type:p,json:{write:!0}})],w.prototype,"legendOptions",void 0),e([r({type:Number,value:null,json:{write:!0}})],w.prototype,"maxDataValue",null),e([r({type:Number,useTypeForAutocast:!1,value:null,json:{write:!0}})],w.prototype,"maxSize",null),e([y("maxSize")],w.prototype,"readMaxSize",null),e([r({type:Number,value:null,json:{write:!0}})],w.prototype,"minDataValue",null),e([r({type:Number,useTypeForAutocast:!1,value:null,json:{write:!0}})],w.prototype,"minSize",null),e([y("minSize")],w.prototype,"readMinSize",null),e([r({type:String,json:{write:!0}})],w.prototype,"normalizationField",void 0),e([r({readOnly:!0})],w.prototype,"arcadeRequired",null),e([r({type:String})],w.prototype,"scaleBy",void 0),e([r({type:[l],value:null,json:{write:!0}})],w.prototype,"stops",null),e([r({type:["outline"],json:{write:!0}})],w.prototype,"target",void 0),e([r({type:String,readOnly:!0})],w.prototype,"transformationType",null),e([r({type:["size"],json:{type:["sizeInfo"]}})],w.prototype,"type",void 0),e([r({type:Boolean,json:{write:!0,origins:{"web-map":{read:!1}}}})],w.prototype,"useSymbolValue",void 0),e([r({type:String,json:{write:!0}})],w.prototype,"valueExpression",void 0),e([y("valueExpression",["valueExpression","expression"])],w.prototype,"readValueExpression",null),e([c("web-scene","valueExpression")],w.prototype,"writeValueExpressionWebScene",null),e([r({type:["radius","diameter","area","width","distance"],json:{write:!0}})],w.prototype,"valueRepresentation",void 0),e([r({type:z.apiValues,json:{write:z.write,origins:{"web-map":{read:!1},"web-scene":{write:!0},"portal-item":{write:!0}}}})],w.prototype,"valueUnit",void 0),e([y("valueUnit")],w.prototype,"readValueUnit",null),w=S=e([a("esri.renderers.visualVariables.SizeVariable")],w);export{w as default};
|
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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
const e="20251028",f="54a4e0094386f62e32bf34d1f4655c0333ecbafb";export{e as buildDate,f 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{disposeMaybe as e}from"../../../../../../../core/maybe.js";import{Technique as t}from"../Technique.js";import{TextureStatisticsTechnique as i}from"../TextureStatisticsTechnique.js";import{getInterpolationDefines as
|
|
5
|
+
import has from"../../../../../../../core/has.js";import{disposeMaybe as e}from"../../../../../../../core/maybe.js";import{Technique as t}from"../Technique.js";import{TextureStatisticsTechnique as i}from"../TextureStatisticsTechnique.js";import{getInterpolationDefines as s}from"./processor/textureUtils.js";import{RasterColorizerLUTShader as o}from"../shaders/raster/RasterColorizerLUTShader.js";import{RasterColorizerShadedReliefShader as r}from"../shaders/raster/RasterColorizerShadedReliefShader.js";import{RasterColorizerStretchShader as n}from"../shaders/raster/RasterColorizerStretchShader.js";import{SizedPixelFormat as a,PixelType as u}from"../../../../../../webgl/enums.js";import{FramebufferObject as c}from"../../../../../../webgl/FramebufferObject.js";import{Texture as m}from"../../../../../../webgl/Texture.js";import{TextureDescriptor as l}from"../../../../../../webgl/TextureDescriptor.js";const h=160,p=new Set(["f32","f64","u16","s16","u32","s32"]);class f extends t{constructor(){super(...arguments),this.name="BrushRasterColorizer",this.type=0,this.shaders={lut:new o,stretch:new n,shadedRelief:new r},this._mosaicFbo=null,this._statisticsTechnique=null,this._draTimer=0}shutdown(t){super.shutdown(t),this._mosaicFbo=e(this._mosaicFbo),this._statisticsTechnique=e(this._statisticsTechnique)}render(t,i){const s=i.bitmaps.some(g);s||(this._mosaicFbo=e(this._mosaicFbo),this._statisticsTechnique=e(this._statisticsTechnique));const o=s?this._computeStatisticsTextures(t,i):void 0;for(const e of i.bitmaps){if(!e.source||e.suspended)continue;t.timeline.begin(this.name);const{painter:i}=t;i.setPipelineState({depth:!1,stencil:{test:{mask:255,compare:514,op:{fail:7680,zFail:7680,zPass:7680}},write:!1},color:{write:[!0,!0,!0,!0],blendMode:"composite"}}),e.updateTexture(t),e.updateProcessedTexture();const{type:s}=e.symbolizerParameters,r="stretch"===s?this._getStretchOptions(e,o):"lut"===s?this._getLutOptions(e):this._getShadedReliefOptions(e);"bilinear"!==e.interpolation||t.context.capabilities.textureFloatLinear||(r.defines.bilinear=!0),i.submitDrawMesh(t.context,r,i.quadMesh,e),t.timeline.end(this.name)}}_computeStatisticsTextures(e,t){this._statisticsTechnique??=new i;const s=this._statisticsTechnique;let o=has("esri-2d-dra-delay");if(null==o){const e=t.bitmaps.find(g),{stretchType:i,bandCount:s}=e.symbolizerParameters,{pixelType:r}=e.source;"minMax"===i&&s>=3&&p.has(r)&&(o=h)}if(o){const i=performance.now();(i-this._draTimer>=o||e.stationary||!s.minValuesTexture)&&(this._mosaic(e,t),s.render(e,{fbo:this._mosaicFbo}),this._draTimer=i)}else this._mosaic(e,t),s.render(e,{fbo:this._mosaicFbo});return{minTexture:s.minValuesTexture,maxTexture:s.maxValuesTexture,meanTexture:s.meanValuesTexture,stddevTexture:s.stdDevValuesTexture}}_mosaic(e,t){const{context:i,painter:s}=e,o=i.getBoundFramebufferObject();if(this._mosaicFbo)this._mosaicFbo.resize(o.width,o.height);else{const e=d(i,o.width,o.height);this._mosaicFbo=new c(i,e)}i.bindFramebuffer(this._mosaicFbo);const r="RasterColorizerMosaic";for(const n of t.bitmaps){if(!g(n))continue;e.timeline.begin(r),s.setPipelineState({depth:!1,stencil:{test:{mask:255,compare:514,op:{fail:7680,zFail:7680,zPass:7680}},write:!1},color:{write:[!0,!0,!0,!0],blendMode:"composite"}});const t=n.interpolation;n.interpolation="nearest",n.updateTexture(e),n.updateProcessedTexture();const i=this._getStretchOptions(n);i.defines.noOp=!0,s.submitDrawMesh(e.context,i,s.quadMesh,n),n.interpolation=t,e.timeline.end(r)}i.bindFramebuffer(o)}_getLutOptions(e){const{config:t,projectionConfig:i,colormapConfig:o,pixelMaskConfig:r,highlightConfig:n,projectionDefines:a}=this._getCommonConfig(e),u=s(e);return{shader:this.shaders.lut,uniforms:{projectionConfig:i,config:t,colormapConfig:o,pixelMaskConfig:r,highlightConfig:n},defines:{...a,...u,applyPixelMask:!!r,applyPixelHighlights:!!n},optionalAttributes:null,useComputeBuffer:!1}}_getStretchOptions(e,t){const i=e.symbolizerParameters,{config:o,projectionConfig:r,colormapConfig:n,pixelMaskConfig:a,highlightConfig:u,projectionDefines:c,textureUnit:m}=this._getCommonConfig(e),l=s(e),h=t?{minTexture:{texture:t.minTexture,unit:m},maxTexture:{texture:t.maxTexture,unit:m+1},meanTexture:{texture:t.meanTexture,unit:m+2},stddevTexture:{texture:t.stddevTexture,unit:m+3},numberOfStandardDeviations:i.numberOfStandardDeviations||2}:void 0,p=t?"standardDeviation"===i.stretchType?2:1:0;return{shader:this.shaders.stretch,uniforms:{projectionConfig:r,config:o,stretchConfig:i,colormapConfig:n,pixelMaskConfig:a,highlightConfig:u,statisticsConfig:h},defines:{...c,...l,isMultiband:i.bandCount>1,applyColormap:!!n,useGamma:i.useGamma,noOp:e.isRendereredSource&&!e.processed,applyPixelMask:!!a,applyPixelHighlights:!!u,draStretchType:p},optionalAttributes:null,useComputeBuffer:!1}}_getShadedReliefOptions(e){const t=e.symbolizerParameters,{config:i,projectionConfig:o,colormapConfig:r,pixelMaskConfig:n,highlightConfig:a,projectionDefines:u}=this._getCommonConfig(e),c=s(e);return{shader:this.shaders.shadedRelief,uniforms:{projectionConfig:o,config:i,hillshadeConfig:t,colormapConfig:r,pixelMaskConfig:n,highlightConfig:a},defines:{...u,...c,isMultidirectional:t.hillshadeType>0,applyColormap:!!r,applyPixelMask:!!n,applyPixelHighlights:!!a},optionalAttributes:null,useComputeBuffer:!1}}_getCommonConfig(e){const{coordScale:t,computedOpacity:i,transforms:s}=e,{names:o,textures:r}=e.getTextures({useProcessedTexture:e.processed}),n=r[o.indexOf("u_image")],a=e.getRasterTextureSize();let u=0;const c={texture:{texture:n,unit:u++},dvsMat3:s.displayViewScreenMat3,coordScale:t,srcImageSize:a,opacity:i},m=r[o.indexOf("u_transformGrid")],{transformGrid:l}=e,h=!(!m||!l),p=h?{transformTexture:{texture:m,unit:u++},targetImageSize:[e.width,e.height],transformSpacing:l.spacing,transformGridSize:l.size}:void 0,f=r[o.indexOf("u_colormap")],{colormap:d,colormapOffset:g}=e.symbolizerParameters,x=f&&d?{colormapTexture:{texture:f,unit:u++},colormapOffset:g??0,colormapMaxIndex:d.length/4-1}:void 0,b=r[o.indexOf("u_mask")],T=b?{maskTexture:{texture:b,unit:u++}}:void 0,{highlightTexture:C}=e;return{config:c,projectionConfig:p,colormapConfig:x,pixelMaskConfig:T,highlightConfig:C?{highlightTexture:{texture:C,unit:u++}}:void 0,projectionDefines:{applyProjection:h,lookupProjection:h&&1===l.spacing[0]},textureUnit:u}}}function d(e,t,i){const s=new l(t,i);return s.internalFormat=a.RGBA32F,s.samplingMode=9728,s.dataType=u.FLOAT,s.wrapMode=33071,new m(e,s)}function g(e){return!e.suspended&&null!=e.source&&!e.isRendereredSource&&"stretch"===e.symbolizerParameters.type&&!!e.symbolizerParameters.dynamicRangeAdjustment}export{f as RasterColorizerTechnique};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as r}from"../../../core/maybe.js";import{initial as s,watch as o,when as n}from"../../../core/reactiveUtils.js";import{schedule as a}from"../../../core/scheduling.js";import{property as l,subclass as c}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as d,invert as h}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as m,IDENTITY as u}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as p}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as f}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{t as g,i as y,a as b,g as _}from"../../../chunks/vec32.js";import{fromArray as w,clone as v,create as j}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as M}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as x}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as O}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as C}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as T}from"../../../geometry/projection/projectVectorToVector.js";import{create as U}from"../../../geometry/support/aaBoundingRect.js";import{BufferViewVec2f as P,BufferViewVec4f as H,BufferViewVec4u8 as E,BufferViewVec4u16 as S,BufferViewVec3f as R,BufferViewVec3u8 as V,BufferViewVec3u16 as A,BufferViewInt16 as k,BufferViewUint32 as I,BufferViewUint16 as F}from"../../../geometry/support/buffer/BufferView.js";import D from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as L}from"../../../support/elevationInfoUtils.js";import{toWasmModification as B}from"./I3SMeshWorkerHandle.js";import{LayerView3D as G}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as N}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as z,removeLayerViewFromWasm as W,getLyr3DWasm as $}from"./Lyr3DWasm.js";import{LayerElevationProvider as q}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as J,alphaModeConversion as K,faceCullingConversion as Q,wrapModeConversion as X,lyr3DTypeToByteSize as Y}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as Z}from"./support/Tiles3DIntersectionHandler.js";import{ElevationRange as ee}from"../support/ElevationRange.js";import{toBoundingRect as te}from"../support/extentUtils.js";import{Obb as ie,compute as re}from"../support/orientedBoundingBox.js";import{ObjectParameters as se}from"../webgl-engine/collections/Component/ObjectParameters.js";import{GeometryParameters as oe,createVertexBufferLayout as ne,SourceGeometry as ae}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as le}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as ce}from"../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as de}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as he}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as me}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as ue}from"../webgl-engine/lib/Normals.js";import{writeAttribute as pe,writeBufferVec2 as fe}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import ge from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as ye,isInEffectiveScaleRange as be}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as _e}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as we}from"../../../webscene/support/AlphaCutoff.js";class ve{constructor(e,t,i,r,s,o,n,a){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=r,this.vboMemoryUsage=s,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.isVisible=!1,this.usedMemory=this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage;const l=j();n?.getCenter(l),this._obbCenter=l,this._obbRadiusSquared=n?n?.radius**2:0}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const i=b(je,this._obbCenter,e),r=_(i,t);return _(i,i)-r*r<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}}const je=j();function Me(e){return Math.round(e/1048.576)/1e3}let xe=class extends(G(ge)){get hasModifications(){return this._modifications&&this._modifications.length>0}constructor(e){super(e),this.type="integrated-mesh-3dtiles",this._compressionTracker=new _e,this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._suspendedHandle=null,this._dbgFlags=new Set,this._memCache=e.view.resourceController.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e))}initialize(){this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),s),!this._canProjectWithoutEngine())throw ye("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=z(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new Z(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),s),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),s),this._elevationProvider=new q({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),e.elevationProvider.register(1,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([o(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e))]),this._suspendedHandle=o(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),s)});this.addResolvingPromise(t),this._replacesTerrain&&this.addHandles(n(()=>this.view.map.ground.opacity,()=>{this._opacityChange()}))}get _replacesTerrain(){return this.layer.replacesTerrain&&!!this.view.map.basemap?.groundLayers.includes(this.layer)}get fullOpacity(){return this._replacesTerrain?this.view.map.ground.opacity:1}get opacity(){return 1}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>{this._collection.getMaterial(t).objectOpacity=e})}intersect(e,t,i,r){this._intersectionHandler.intersect(e,t,i,r,null,!1)}get ready(){return!0}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),W(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._usedMemory=this._cacheMemory=0,this._memCache.destroy(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=r(this._visibleGeometryChangedSchedulerHandle)}_modificationsChanged(){const e=this.layer.spatialReference,t=B(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=U();this._layerClippingArea=te(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=a(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),this.forEachComponentObject(t=>this._collection.getMaterial(t).commonMaterialParameters.hasSlicePlane=e)}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,L(e))}get _wasm(){return $(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return be(this.layer.effectiveScaleRange,this.view.scale)}get performanceInfo(){let e=0,t=0,i=0,r=0,s=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isVisible?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,s++):(i+=n.textureMemoryUsage,r+=n.vboMemoryUsage,o++)}),new N(this.usedMemory,s,o,Me(t),Me(e),Me(r),Me(i))}_canProjectWithoutEngine(){if(2===this.view.state.viewingMode){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return L(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new ee(e.zmin,e.zmax):null}getElevationRange(e){return null}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const i of e)for(const e of i.componentObjects)t(e)}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed){const e=`IntegratedMesh3DTilesLayerView3D[${this.layer?.title}]: createRenderable called on destroyed instance`;throw new Error(e)}let t=0;const{meshData:i}=e;if(null==i.data)throw new Error("meshData.data undefined");if(i.desc=JSON.parse(i.desc),null==i.desc)throw new Error("meshData.desc undefined");const r=w(i.desc.origin),s=new Array,o=this.view.basemapTerrain.spatialReference;let n,a;if("global"===this.view.viewingMode){const e=p();O(x,r,e,o),n=d(m(),e),a=h(m(),n)}else n=u,a=u;const l=v(r),c=j(),f=Ue(i.desc.obb);let y=0,b=0;const _={textureMemoryUsage:0},U=new Map,H=i.desc.prims.length,E=new Array;try{for(let e=0;e<H;e++){const t=i.desc.prims[e];this._dbg(2,JSON.stringify(t));if(null==J[t.ptype]||null==i.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+t.ptype+"). Skipping primitive.");continue}const d=i.desc?.materials&&null!=t.materialId?i.desc.materials[t.materialId]:null,h=null!=d?d.lightingModel:"Unlit",{positionView:m,positionAttr:p,normalsView:w,normalsAttr:v,colorAttr:x,texCoord0Attr:O,indicesView:H}=this.getBufferViews(t,i.data.buffer,n);if(null==p||null==m||null==H)continue;const E=new oe(null!=x,O?1:0,null!=w,this._shadeNormals||this._replacesTerrain,this._applySSAO),S=p.data.length/p.size,R=(e,t)=>!e||e.data.length/e.size===S||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!R(O,"numTexcoord")||!R(x,"numColors")||!R(v,"normals"))continue;const V=ne(E),A=f?.clone()??Te(p,r);if(n!==u)for(let e=0;e<m.count;e++)m.getVec(e,c),g(c,c,n),m.setVec(e,c);const k=V.createBuffer(p.data.length);if(pe("position",p,null,null,k,0),null!=O){const e=k.getField("uv0",P);fe(O,e,0)}null!=x&&pe("color",x,null,null,k,0),null!=v&&pe("normalCompressed",v,null,null,k,0);const I=new Uint32Array([0,H.typedBuffer.length]),F=new ae({data:k.buffer,count:k.byteLength/V.stride,layoutParameters:E},{positions:m.typedBuffer,indices:H.typedBuffer},H.typedBuffer,I);y+=m.count+H.count;const D=this.view.renderSpatialReference,L=j(),B=[1,1,1];C(l,D,B,o)||this._dbg(3,"Unsupported coordinate system for IM overlay"),T(l,D,L,o);let G=()=>{},N=Promise.resolve(He);if(d){const e=e=>this._getTexture(e,i,U,_),t=e(d.baseColorTex),r="Pbr"===h,s=r?e(d.metalTex):null,o=r?e(d.emissiveTex):null,n=r?e(d.occlusionTex):null,a=r?e(d.normalTex):null,l=[t,s,o,n,a].map(e=>e?.loadPromise??null);N=Promise.all(l),G=e=>{e.baseColor=d.baseColorFactor,e.usePBR="Pbr"===h,e.hasParametersFromSource=!1,e.baseColorTexture=t,e.usePBR&&(e.mrrFactors=[d.metallicFactor,d.roughnessFactor,0],e.emissiveBaseColor=d.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=s,e.emissionTexture=o,e.occlusionTexture=n,e.normalTexture=a),e.alphaDiscardMode=K[d.alphaMode],e.objectOpacity=this.fullOpacity,_.textureMemoryUsage+=e.baseColorTexture?.texture?.usedMemory??0,e.usePBR&&(_.textureMemoryUsage+=(e.metallicRoughnessTexture?.texture?.usedMemory??0)+(e.emissionTexture?.texture?.usedMemory??0)+(e.occlusionTexture?.texture?.usedMemory??0)+(e.normalTexture?.texture?.usedMemory??0)),e.commonMaterialParameters.doubleSided=d.isDoubleSided,e.commonMaterialParameters.cullFace=Q[d.faceCulling??"NotSet"],e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=0,e.textureAlphaCutoff=d.alphaCutoff??we,e.alphaDiscardMode=K[d.alphaMode],e.isIntegratedMesh=!0,e.sphereDepthInterpolate=this.layer.hasGoogleUrl,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=de(this.view.spatialReference)}}const z=N.then(()=>()=>{if(this.destroyed){const e="Trying to add object to destroyed layer view";throw this._dbg(3,`${e} !== numPos. Skipping primitive.`),new Error(e)}const e=this._collection.createObject(new se(M(L[0],L[1],B[0],B[1]),new le(l,a),A,F,!1));return this._collection.updateMaterial(e,G),b+=this._collection.getObjectGPUMemoryUsage(e),e});s.push(z)}if(E.push(...await Promise.all(s)),this.destroyed){throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call")}}catch(A){throw U.forEach(e=>this._stage.removeTexture(e)),A}const S=E.map(e=>e()),R=new Array;U.forEach(e=>R.push(e));const V=new ve(e.handle,S,R,y,b,_.textureMemoryUsage,f,e.stableNodeId);return this._lyrHandleToObjects.set(e.handle,V),this._memCache.put(Pe(V.handle),V),t=V.usedMemory,this._cacheMemory+=t,{memUsageBytes:V.usedMemory}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t&&(t.isVisible?(this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e))}freeObject(e){const t=Pe(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){for(let r=0;r<i;++r){const i=t[r];if(!i)continue;const s=e[r],o=this._lyrHandleToObjects.get(s);if(o){if(o.isVisible)continue;this._visibleGeometryChanged(),o.isVisible=!0,this._visibleObjects.add(o),this._usedMemory+=o.usedMemory,this._cacheMemory-=o.usedMemory,o.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,i),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e))}),this._memCache.pop(Pe(s))}}for(let r=0;r<i;++r){const i=e[r],s=t[r];if(s)continue;const o=this._lyrHandleToObjects.get(i);if(o){if(!o.isVisible)continue;this._visibleGeometryChanged(),o.isVisible=!1,this._visibleObjects.delete(o),this._usedMemory-=o.usedMemory,this._cacheMemory+=o.usedMemory,o.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,s),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e))}),this._memCache.put(Pe(i),o)}}}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_getTexture(e,t,i,r){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const o=i.get(s)??this._createTexture(e,t,i,r);return o?new ce(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,r){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!s.mipCount||a>1,c=X[e.wrapMode??"None"];let d=s.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,s.data.byteOffset,s.data.byteCount);let m=null,u=null,p=null;switch(s.format){case"Raw":"R8"===s.pixelFormat?(m=h,d=6403,u=""):"Rgb8"===s.pixelFormat?(m=h,d=6407,u=""):"Rgba8"===s.pixelFormat&&(m=h,d=6408,u="");break;case"Dxt1":m=h,d=6407,u="image/vnd-ms.dds";break;case"Dxt5":m=h,d=6408,u="image/vnd-ms.dds";break;case"Basis":m=h,d=6407,u="image/ktx2";break;case"Png":u="image/png",p=document.createElement("img");break;case"Jpeg":u="image/jpeg",p=document.createElement("img");break;case"Etc2":u="image/ktx",p=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(p&&u){const e=new Blob([h],{type:u});p.src=URL.createObjectURL(e),m=p}if(m&&null!=u){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(r.textureMemoryUsage-=e)}}:void 0,t=new me(m,{mipmap:l,maxAnisotropy:a,encoding:u,wrap:c,pixelFormat:d,compressionOptions:e,noUnpackFlip:!0,width:s.mip0Width,height:s.mip0Height});return this._stage.addTexture(t),i.set(s,t),t}return null}getBufferViews(e,t,i){let r,s,o,n,a,l,c,d=null;for(let m=0;m<e.atrbs.length;m++){const c=e.atrbs[m],u=c.view,p=void 0,f=u.byteOffset+u.byteCount,g=u.byteCount/Y[u.type],y=[...Array(g).keys()].map(e=>e);try{switch(c.sem){case"Position":3!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(r=new R(t,u.byteOffset,p,f),s=new he(r.typedBuffer,y,3));break;case"Normal":if(3!==u.ncomp||"F32"!==u.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new R(t,u.byteOffset,p,f),r=ue(e.typedBuffer,i);a=new k(r.buffer),l=new he(a.typedBuffer,y,2)}break;case"TexCoord":2!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===n&&(n=new he(new P(t,u.byteOffset,p,f).typedBuffer,y,2));break;case"Color":4===u.ncomp?("F32"===u.type&&(d=new H(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new E(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new S(t,u.byteOffset,p,f))):3===u.ncomp&&("F32"===u.type&&(d=new R(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new V(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new A(t,u.byteOffset,p,f))),null==d?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new he(d.typedBuffer,y,u.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+c.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,r=void 0,s=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":c=new F(t,i.byteOffset,r,s);break;case"U32":c=new I(t,i.byteOffset,r,s);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==c&&null!=r){const e=r.count;if(e<65535){const t=new Uint16Array(e);c=new F(t.buffer)}else{const t=new Uint32Array(e);c=new I(t.buffer)}for(let t=0;t<e;t++)c.set(t,t)}return{positionView:r,positionAttr:s,colorAttr:o,texCoord0Attr:n,indicesView:c,normalsView:a,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>this._modifications=e.toArray(),s),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([l()],xe.prototype,"fullOpacity",null),e([l({type:[D]})],xe.prototype,"_modifications",void 0),e([l()],xe.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([l()],xe.prototype,"layer",void 0),e([l({readOnly:!0})],xe.prototype,"visibleAtCurrentScale",null),e([l({readOnly:!0})],xe.prototype,"_collection",null),e([l()],xe.prototype,"elevationOffset",null),xe=e([c("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],xe);const Oe=xe,Ce=j();function Te(e,t){const i=re(e);return y(Ce,i.center,t),i.center=Ce,i}function Ue(e){return e?new ie(e.center,e.halfSize,f(...e.quaternion)):null}function Pe(e){return`${e}`}const He=new Array;export{Oe as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as r}from"../../../core/maybe.js";import{initial as s,watch as o,when as n}from"../../../core/reactiveUtils.js";import{schedule as a}from"../../../core/scheduling.js";import{property as l,subclass as c}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as d,invert as h}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as m,IDENTITY as u}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as p}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as f}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{i as g,b,t as y}from"../../../chunks/vec32.js";import{fromArray as _,clone as w,create as v}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as j}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as x,getReferenceEllipsoid as M}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as C}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as O}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as T}from"../../../geometry/projection/projectVectorToVector.js";import{create as U}from"../../../geometry/support/aaBoundingRect.js";import{BufferViewVec2f as P,BufferViewVec4f as H,BufferViewVec4u8 as E,BufferViewVec4u16 as R,BufferViewVec3f as S,BufferViewVec3u8 as V,BufferViewVec3u16 as A,BufferViewInt16 as I,BufferViewUint32 as k,BufferViewUint16 as F}from"../../../geometry/support/buffer/BufferView.js";import D from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as L}from"../../../support/elevationInfoUtils.js";import{toWasmModification as B}from"./I3SMeshWorkerHandle.js";import{LayerView3D as G}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as N}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as z,removeLayerViewFromWasm as W,getLyr3DWasm as $}from"./Lyr3DWasm.js";import{LayerElevationProvider as q}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as J,alphaModeConversion as K,faceCullingConversion as Q,wrapModeConversion as X,lyr3DTypeToByteSize as Y}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as Z}from"./support/Tiles3DIntersectionHandler.js";import{ElevationRange as ee}from"../support/ElevationRange.js";import{toBoundingRect as te}from"../support/extentUtils.js";import{Obb as ie,compute as re}from"../support/orientedBoundingBox.js";import{ObjectParameters as se}from"../webgl-engine/collections/Component/ObjectParameters.js";import{GeometryParameters as oe,createVertexBufferLayout as ne,SourceGeometry as ae}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as le}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as ce}from"../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as de}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as he}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as me}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as ue}from"../webgl-engine/lib/Normals.js";import{writeAttribute as pe,writeBufferVec2 as fe}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import ge from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as be,isInEffectiveScaleRange as ye}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as _e}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as we}from"../../../webscene/support/AlphaCutoff.js";class ve{constructor(e,t,i,r,s,o,n,a,l){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=r,this.vboMemoryUsage=s,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.elevationRange=l,this.isVisible=!1,this.usedMemory=this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage;const c=v();n?.getCenter(c),this._obbCenter=c,this._obbRadius=n?.radius??0,this._obbRadiusSquared=this._obbRadius**2}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const i=this._obbCenter,r=i[0]-e[0],s=i[1]-e[1],o=i[2]-e[2],n=r*t[0]+s*t[1]+o*t[2];return r*r+s*s+o*o-n*n<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){if(!this.obb)return!0;const t=e.center,i=this._obbCenter,r=i[0]-t[0],s=i[1]-t[1],o=i[2]-t[2];return r*r+s*s+o*o<=(this._obbRadius+e.radius)**2}expandElevationRange(e){e.expandElevationRange(this.elevationRange)}}function je(e){return Math.round(e/1048.576)/1e3}let xe=class extends(G(ge)){get hasModifications(){return this._modifications&&this._modifications.length>0}constructor(e){super(e),this.type="integrated-mesh-3dtiles",this._compressionTracker=new _e,this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._suspendedHandle=null,this._dbgFlags=new Set,this._memCache=e.view.resourceController.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e))}initialize(){this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),s),!this._canProjectWithoutEngine())throw be("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=z(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new Z(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),s),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),s),this._elevationProvider=new q({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),e.elevationProvider.register(1,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([o(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e))]),this._suspendedHandle=o(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),s)});this.addResolvingPromise(t),this._replacesTerrain&&this.addHandles(n(()=>this.view.map.ground.opacity,()=>{this._opacityChange()}))}get _replacesTerrain(){return this.layer.replacesTerrain&&!!this.view.map.basemap?.groundLayers.includes(this.layer)}get fullOpacity(){return this._replacesTerrain?this.view.map.ground.opacity:1}get opacity(){return 1}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateMaterial(t,t=>t.objectOpacity=e))}intersect(e,t,i,r){this._intersectionHandler.intersect(e,t,i,r,null,!1)}get ready(){return!0}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),W(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._usedMemory=this._cacheMemory=0,this._memCache.destroy(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=r(this._visibleGeometryChangedSchedulerHandle)}_modificationsChanged(){const e=this.layer.spatialReference,t=B(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=U();this._layerClippingArea=te(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=a(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),this.forEachComponentObject(t=>this._collection.updateMaterial(t,t=>t.commonMaterialParameters.hasSlicePlane=e))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,L(e))}get _wasm(){return $(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return ye(this.layer.effectiveScaleRange,this.view.scale)}get performanceInfo(){let e=0,t=0,i=0,r=0,s=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isVisible?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,s++):(i+=n.textureMemoryUsage,r+=n.vboMemoryUsage,o++)}),new N(this.usedMemory,s,o,je(t),je(e),je(r),je(i))}_canProjectWithoutEngine(){if(2===this.view.state.viewingMode){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return L(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new ee(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const i of e)for(const e of i.componentObjects)t(e)}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed){const e=`IntegratedMesh3DTilesLayerView3D[${this.layer?.title}]: createRenderable called on destroyed instance`;throw new Error(e)}let t=0;const{meshData:i}=e;if(null==i.data)throw new Error("meshData.data undefined");if(i.desc=JSON.parse(i.desc),null==i.desc)throw new Error("meshData.desc undefined");const r=_(i.desc.origin),s=new Array,o=this.view.basemapTerrain.spatialReference;let n,a;if("global"===this.view.viewingMode){const e=p();C(x,r,e,o),n=d(m(),e),a=h(m(),n)}else n=u,a=u;const l=w(r),c=v(),f=Te(i.desc.obb);let U=0,H=0;const E={textureMemoryUsage:0},R=new Map,S=i.desc.prims.length,V=new Array,A=new ee;try{const e="global"===this.view.viewingMode,t=e?M(this.view.spatialReference).radius:0;for(let d=0;d<S;d++){const h=i.desc.prims[d];this._dbg(2,JSON.stringify(h));if(null==J[h.ptype]||null==i.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+h.ptype+"). Skipping primitive.");continue}const m=i.desc?.materials&&null!=h.materialId?i.desc.materials[h.materialId]:null,p=null!=m?m.lightingModel:"Unlit",{positionView:_,positionAttr:w,normalsView:x,normalsAttr:M,colorAttr:C,texCoord0Attr:S,indicesView:V}=this.getBufferViews(h,i.data.buffer,n);if(null==w||null==_||null==V)continue;const I=new oe(null!=C,S?1:0,null!=x,this._shadeNormals||this._replacesTerrain,this._applySSAO),k=w.data.length/w.size,F=(e,t)=>!e||e.data.length/e.size===k||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!F(S,"numTexcoord")||!F(C,"numColors")||!F(M,"normals"))continue;const D=ne(I);for(let i=0;i<_.count;i++){_.getVec(i,c),g(c,c,r);const s=e?b(c)-t:c[2];A.expandElevationRangeValues(s,s)}const L=f?.clone()??Oe(w,r);if(n!==u)for(let e=0;e<_.count;e++)_.getVec(e,c),y(c,c,n),_.setVec(e,c);const B=D.createBuffer(w.data.length);if(pe("position",w,null,null,B,0),null!=S){const e=B.getField("uv0",P);fe(S,e,0)}null!=C&&pe("color",C,null,null,B,0),null!=M&&pe("normalCompressed",M,null,null,B,0);const G=new Uint32Array([0,V.typedBuffer.length]),N=new ae({data:B.buffer,count:B.byteLength/D.stride,layoutParameters:I},{positions:_.typedBuffer,indices:V.typedBuffer},V.typedBuffer,G);U+=_.count+V.count;const z=this.view.renderSpatialReference,W=v(),$=[1,1,1];O(l,z,$,o)||this._dbg(3,"Unsupported coordinate system for IM overlay"),T(l,z,W,o);let q=()=>{},X=Promise.resolve(Pe);if(m){const e=e=>this._getTexture(e,i,R,E),t=e(m.baseColorTex),r="Pbr"===p,s=r?e(m.metalTex):null,o=r?e(m.emissiveTex):null,n=r?e(m.occlusionTex):null,a=r?e(m.normalTex):null,l=[t,s,o,n,a].map(e=>e?.loadPromise??null);X=Promise.all(l),q=e=>{e.baseColor=m.baseColorFactor,e.usePBR="Pbr"===p,e.hasParametersFromSource=!1,e.baseColorTexture=t,e.usePBR&&(e.mrrFactors=[m.metallicFactor,m.roughnessFactor,0],e.emissiveBaseColor=m.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=s,e.emissionTexture=o,e.occlusionTexture=n,e.normalTexture=a),e.alphaDiscardMode=K[m.alphaMode],e.objectOpacity=this.fullOpacity,E.textureMemoryUsage+=e.baseColorTexture?.texture?.usedMemory??0,e.usePBR&&(E.textureMemoryUsage+=(e.metallicRoughnessTexture?.texture?.usedMemory??0)+(e.emissionTexture?.texture?.usedMemory??0)+(e.occlusionTexture?.texture?.usedMemory??0)+(e.normalTexture?.texture?.usedMemory??0)),e.commonMaterialParameters.doubleSided=m.isDoubleSided,e.commonMaterialParameters.cullFace=Q[m.faceCulling??"NotSet"],e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=0,e.textureAlphaCutoff=m.alphaCutoff??we,e.alphaDiscardMode=K[m.alphaMode],e.isIntegratedMesh=!0,e.sphereDepthInterpolate=this.layer.hasGoogleUrl,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=de(this.view.spatialReference)}}const Y=X.then(()=>()=>{if(this.destroyed){const e="Trying to add object to destroyed layer view";throw this._dbg(3,`${e} !== numPos. Skipping primitive.`),new Error(e)}const e=this._collection.createObject(new se(j(W[0],W[1],$[0],$[1]),new le(l,a),L,N,!1));return this._collection.updateMaterial(e,q),H+=this._collection.getObjectGPUMemoryUsage(e),e});s.push(Y)}if(V.push(...await Promise.all(s)),this.destroyed){throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call")}}catch(D){throw R.forEach(e=>this._stage.removeTexture(e)),D}const I=V.map(e=>e()),k=new Array;R.forEach(e=>k.push(e));const F=new ve(e.handle,I,k,U,H,E.textureMemoryUsage,f,e.stableNodeId,A);return this._lyrHandleToObjects.set(e.handle,F),this._memCache.put(Ue(F.handle),F),t=F.usedMemory,this._cacheMemory+=t,{memUsageBytes:F.usedMemory}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t&&(t.isVisible?(this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e))}freeObject(e){const t=Ue(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){for(let r=0;r<i;++r){const i=t[r];if(!i)continue;const s=e[r],o=this._lyrHandleToObjects.get(s);if(o){if(o.isVisible)continue;this._visibleGeometryChanged(),o.isVisible=!0,this._visibleObjects.add(o),this._usedMemory+=o.usedMemory,this._cacheMemory-=o.usedMemory,o.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,i),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e))}),this._memCache.pop(Ue(s))}}for(let r=0;r<i;++r){const i=e[r],s=t[r];if(s)continue;const o=this._lyrHandleToObjects.get(i);if(o){if(!o.isVisible)continue;this._visibleGeometryChanged(),o.isVisible=!1,this._visibleObjects.delete(o),this._usedMemory-=o.usedMemory,this._cacheMemory+=o.usedMemory,o.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,s),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e))}),this._memCache.put(Ue(i),o)}}}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_getTexture(e,t,i,r){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const o=i.get(s)??this._createTexture(e,t,i,r);return o?new ce(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,r){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!s.mipCount||a>1,c=X[e.wrapMode??"None"];let d=s.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,s.data.byteOffset,s.data.byteCount);let m=null,u=null,p=null;switch(s.format){case"Raw":"R8"===s.pixelFormat?(m=h,d=6403,u=""):"Rgb8"===s.pixelFormat?(m=h,d=6407,u=""):"Rgba8"===s.pixelFormat&&(m=h,d=6408,u="");break;case"Dxt1":m=h,d=6407,u="image/vnd-ms.dds";break;case"Dxt5":m=h,d=6408,u="image/vnd-ms.dds";break;case"Basis":m=h,d=6407,u="image/ktx2";break;case"Png":u="image/png",p=document.createElement("img");break;case"Jpeg":u="image/jpeg",p=document.createElement("img");break;case"Etc2":u="image/ktx",p=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(p&&u){const e=new Blob([h],{type:u});p.src=URL.createObjectURL(e),m=p}if(m&&null!=u){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(r.textureMemoryUsage-=e)}}:void 0,t=new me(m,{mipmap:l,maxAnisotropy:a,encoding:u,wrap:c,pixelFormat:d,compressionOptions:e,noUnpackFlip:!0,width:s.mip0Width,height:s.mip0Height});return this._stage.addTexture(t),i.set(s,t),t}return null}getBufferViews(e,t,i){let r,s,o,n,a,l,c,d=null;for(let m=0;m<e.atrbs.length;m++){const c=e.atrbs[m],{view:u}=c,p=void 0,f=u.byteOffset+u.byteCount,g=u.byteCount/Y[u.type],b=new(He(g))(g);for(let e=0;e<g;++e)b[e]=e;try{switch(c.sem){case"Position":3!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(r=new S(t,u.byteOffset,p,f),s=new he(r.typedBuffer,b,3));break;case"Normal":if(3!==u.ncomp||"F32"!==u.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new S(t,u.byteOffset,p,f),r=ue(e.typedBuffer,i);a=new I(r.buffer),l=new he(a.typedBuffer,b,2)}break;case"TexCoord":2!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===n&&(n=new he(new P(t,u.byteOffset,p,f).typedBuffer,b,2));break;case"Color":4===u.ncomp?("F32"===u.type&&(d=new H(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new E(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new R(t,u.byteOffset,p,f))):3===u.ncomp&&("F32"===u.type&&(d=new S(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new V(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new A(t,u.byteOffset,p,f))),null==d?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new he(d.typedBuffer,b,u.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+c.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,r=void 0,s=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":c=new F(t,i.byteOffset,r,s);break;case"U32":c=new k(t,i.byteOffset,r,s);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==c&&null!=r){const e=r.count;c=c=e<65535?new F(new Uint16Array(e).buffer):new k(new Uint32Array(e).buffer);for(let t=0;t<e;t++)c.set(t,t)}return{positionView:r,positionAttr:s,colorAttr:o,texCoord0Attr:n,indicesView:c,normalsView:a,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>this._modifications=e.toArray(),s),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([l()],xe.prototype,"fullOpacity",null),e([l({type:[D]})],xe.prototype,"_modifications",void 0),e([l()],xe.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([l()],xe.prototype,"layer",void 0),e([l({readOnly:!0})],xe.prototype,"visibleAtCurrentScale",null),e([l({readOnly:!0})],xe.prototype,"_collection",null),e([l()],xe.prototype,"elevationOffset",null),xe=e([c("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],xe);const Me=xe,Ce=v();function Oe(e,t){const i=re(e);return g(Ce,i.center,t),i.center=Ce,i}function Te(e){return e?new ie(e.center,e.halfSize,f(...e.quaternion)):null}function Ue(e){return`${e}`}const Pe=new Array;function He(e){return e<256?Uint8Array:e<65536?Uint16Array:Uint32Array}export{Me 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{validateColorAndOpacity as e,validateColor as r}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{clamp as o}from"../../../../core/mathUtils.js";import{uncompressedFormats as a,compressibleUsages as s}from"./enums.js";import{RenderTexture as t}from"../../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as
|
|
5
|
+
import{validateColorAndOpacity as e,validateColor as r}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{clamp as o}from"../../../../core/mathUtils.js";import{uncompressedFormats as a,compressibleUsages as s}from"./enums.js";import{RenderTexture as t}from"../../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as l}from"../../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{ManagedTexture as n}from"../../webgl-engine/lib/ManagedTexture.js";import{useSchematicPBRI3S as i,useSchematicPBR as u,schematicMRRFactors as c,advancedMRRFactors as m}from"../../webgl-engine/materials/pbrUtils.js";import{alphaCutoff as d}from"../../../../webscene/support/AlphaCutoff.js";function g(r,o,a){const s=new Map,t=(e,r)=>{if(null==e)return-1;const o=s.get(e.id);if(o)return o.usage|=r,o.id;const a=s.size;return s.set(e.id,{id:a,usage:r}),a},l=o.pbrMetallicRoughness,n=l?.baseColorFactor?e(l.baseColorFactor):null,d=o.emissiveFactor,g=a?i({normalTexture:o.normalTexture,emissiveTexture:o.emissiveTexture,emissiveFactor:o.emissiveFactor,occlusionTexture:o.occlusionTexture,metallicRoughnessTexture:l?.metallicRoughnessTexture,metallicFactor:l?.metallicFactor,roughnessFactor:l?.roughnessFactor}):u({normalTexture:o.normalTexture,emissiveTexture:o.emissiveTexture,emissiveFactor:o.emissiveFactor,occlusionTexture:o.occlusionTexture,metallicRoughnessTexture:l?.metallicRoughnessTexture,metallicFactor:l?.metallicFactor,roughnessFactor:l?.roughnessFactor}),h=g?c[0]:l?.metallicFactor??m[0],f=g?c[1]:l?.roughnessFactor??m[1],F="mask"===o.alphaMode?33:1,T={baseColorFactor:n?[n[0],n[1],n[2],n[3]]:[1,1,1,1],baseColorTextureId:t(l?.baseColorTexture,F),metallicRoughnessTextureId:t(l?.metallicRoughnessTexture,2),metallicFactor:h,roughnessFactor:f},b={alphaMode:o.alphaMode,alphaCutoff:o.alphaCutoff,doubleSided:o.doubleSided,cullFace:"none"===o.cullFace?0:"back"===o.cullFace?2:"front"===o.cullFace?1:0,normalTextureId:t(o.normalTexture,4),emissiveTextureId:t(o.emissiveTexture,16),occlusionTextureId:t(o.occlusionTexture,8),emissiveFactor:d?[d[0],d[1],d[2]]:[0,0,0],metallicRoughness:T,wrapTextures:!1,hasParametersFromSource:g},C=[];return s.forEach(({usage:e},o)=>{const a=null!=r&&r[o]&&r[o].formats,s=a?p(a.map(({name:e,format:r})=>({name:e,encoding:x[r]}))):[];C.push({id:o,usage:e,encodings:s})}),{material:b,textures:C}}function p(e){return e.sort((e,r)=>e.encoding-r.encoding)}const x={ktx2:1,basis:2,dds:4,png:8,jpg:16,"ktx-etc2":32},h={"image/ktx2":2,"image/x.basis":2,"image/vnd-ms.dds":4,"image/png":8,"image/jpg":16,"image/jpeg":16,"image/ktx":32};function f(e){const a=e?.materialDefinitions?Object.keys(e.materialDefinitions)[0]:null,s=e?.textureDefinitions?Object.keys(e.textureDefinitions)[0]:null,t=a?e.materialDefinitions?.[a]:null,l=s?e.textureDefinitions?.[s]:null,n=F();if(null!=t){const e=t.params;e.diffuse&&(r(e.diffuse),n.metallicRoughness.baseColorFactor=[e.diffuse[0],e.diffuse[1],e.diffuse[2],1]),null!=e.doubleSided&&(n.doubleSided=e.doubleSided,n.cullFace=e.doubleSided?0:2),"none"!==e.cullFace&&"front"!==e.cullFace&&"back"!==e.cullFace||(n.cullFace="none"===e.cullFace?0:"back"===e.cullFace?2:1),e.transparency&&(n.metallicRoughness.baseColorFactor[3]=o(1-e.transparency,0,1)),(e.useVertexColorAlpha||n.metallicRoughness.baseColorFactor[3]<1)&&(n.alphaMode="blend")}const i=[];if(null!=l){const e=0;!l.wrap||"repeat"!==l.wrap[0]&&"repeat"!==l.wrap[1]||(n.wrapTextures=!0);let r=1;"rgba"===l.channels&&(n.alphaMode="blend",r|=32);const o=l.images.length-1,a=l.images[o],s=e=>e?.split("/").pop(),t=Array.isArray(l.encoding)?p(l.encoding.map((e,r)=>({name:s(a.href[r]),encoding:h[e]||0}))):[{name:s(a.href),encoding:h[l.encoding]||0}];i.push({id:e,usage:r,encodings:t}),n.metallicRoughness.baseColorTextureId=e}return{material:n,textures:i}}const F=()=>({alphaMode:"opaque",alphaCutoff:d,doubleSided:!0,cullFace:0,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[.8,.8,.8,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6},wrapTextures:!1,hasParametersFromSource:!0});function T(e,r,o,a,s,t){if(null==e?.data)return null;const l=e.data,i=a.renderingContext.parameters.maxMaxAnisotropy,u=i>1,c=o||!r.wrapTextures?b:C,m=k(e.encoding),d=1&e.usage?"opaque"===r.alphaMode?6407:6408:6407,g=P(e.encoding,e.usage)?{compressionTracker:s,compressionCallback:t}:void 0;return new n(l,{mipmap:u,maxAnisotropy:i,encoding:m,wrap:c,pixelFormat:d,compressionOptions:g,noUnpackFlip:!0})}const b={s:33071,t:33071},C={s:10497,t:10497};function M(r,o,a,s,n,i){const u=i.rendererTextureUsage,g=e=>v(s,a,e&u),p=e(o.metallicRoughness.baseColorFactor);r.baseColor=[p[0],p[1],p[2],p[3]],r.hasParametersFromSource=!!o.hasParametersFromSource,r.usePBR=i.usePBR,r.mrrFactors=[o.metallicRoughness.metallicFactor,o.metallicRoughness.roughnessFactor,o.hasParametersFromSource?c[2]:m[2]],r.emissiveBaseColor=o.emissiveFactor,r.isIntegratedMesh=i.isIntegratedMesh,r.textureAlphaCutoff="mask"===o.alphaMode?o.alphaCutoff:d,r.alphaDiscardMode="opaque"===o.alphaMode?1:"mask"===o.alphaMode?2:3;const x=[],h=g(33);null!=h&&(r.baseColorTexture=new t(n,h),x.push(r.baseColorTexture.loadPromise));const f=g(2);null!=f&&(r.metallicRoughnessTexture=new t(n,f),x.push(r.metallicRoughnessTexture.loadPromise));const F=g(16);null!=F&&(r.emissionTexture=new t(n,F),x.push(r.emissionTexture.loadPromise));const T=g(8);null!=T&&(r.occlusionTexture=new t(n,T),x.push(r.occlusionTexture.loadPromise));const b=g(4);return null!=b&&(r.normalTexture=new t(n,b),x.push(r.normalTexture.loadPromise)),r.commonMaterialParameters.hasSlicePlane=i.slicePlaneEnabled,r.commonMaterialParameters.doubleSided=o.doubleSided,r.commonMaterialParameters.cullFace=o.cullFace,r.ellipsoidMode=l(i.viewSpatialReference),Promise.all(x)}function R(e){const r=!!e.compressedTextureS3TC,o=!!e.compressedTextureETC,a=has("disable-feature:i3s-basis")?0:3;return 24|(r?4|a:0)|(o?a:0)}function w(e,r){if(null!=r)return e.find(e=>0!==(e.encoding&r))}function v(e,r,o){if(null==e||0===o)return null;for(let a=0;a<e.length;a++){const s=e[a];if(null!=s&&0!==(s.usage&o)){const e=r[a];return null!=e?e.id:null}}return null}function P(e,r){return!!has("enable-feature:esri-compress-IM-textures")&&(0!==(e&a)&&!(r&~s))}function k(e){switch(e){case 1:return"image/ktx2";case 2:return"image/x.basis";case 4:return"image/vnd-ms.dds";case 8:return"image/png";case 16:return"image/jpeg";case 32:return"image/ktx";default:return""}}export{M as configureMaterial,T as createTexture,F as defaultMaterial,g as getMaterialAndTextures,f as getMaterialAndTexturesFromShared,R as getSupportedEncodings,w as selectEncoding};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{a as e,n as i}from"../../../../chunks/vec32.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Tiles3DTarget as
|
|
5
|
+
import{a as e,n as i}from"../../../../chunks/vec32.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Tiles3DTarget as n}from"../i3s/Intersector.js";import{ElevationRange as s}from"../../support/ElevationRange.js";import{IntersectorResult as r}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as o,computeInvDir as l,intersectAabbInvDir as a}from"../../webgl-engine/lib/RayIntersections.js";class c{constructor(e){this.layerView=e,this.type=8,this.slicePlaneEnabled=!1,this.isGround=!0,this.layerViewUid=e.uid}intersect(s,c,d,m,p,f){if(s.options.filteredLayerViewUids.includes(this.layerView.uid))return;const{results:h,tolerance:w}=s,g=2===s.options.store,{componentObjectCollection:b}=this.layerView.view.stage.renderView,y=new o(w,f,s.options.normalRequired),V=l(d,m,u),j=e(t(),m,d),R=i(t(),j),v=(e,i,t)=>{if(i>=0){if(null!=c&&!c(d,m,i))return;const e=e=>{const s=new n(this.layerView.layer.uid);e.set(this.type,s,i,t)};if(this.isGround&&(null==h.ground.distance||i<h.ground.distance)&&e(h.ground),s.options.isFiltered)return;if((null==h.min.distance||i<h.min.distance)&&e(h.min),(null==h.max.distance||i>h.max.distance)&&e(h.max),g){const i=new r(s.ray);e(i),s.results.all.push(i)}}};this.layerView.forEachVisibleTile(e=>{if(!e.boundingVolumeIntersectsRay(d,R))return;const{componentObjects:i}=e;for(const t of i)a(t.aabbInWorldCoordinates,d,V,0)&&b.intersect(t,d,m,null,y,v)})}getElevationRange(e){let i=null;return this.layerView.forEachVisibleTile(t=>{t.boundingVolumeIntersectsSphere(e)&&(i||(i=new s),t.expandElevationRange(i))}),i||(i=new s(0,0)),i}}const u=t();export{c as Tiles3DIntersectionHandler};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{EventEmitter as
|
|
5
|
+
import{__decorate as e}from"tslib";import{prefersReducedMotion as t}from"../../../core/a11yUtils.js";import r from"../../../core/Accessor.js";import{EventEmitter as o}from"../../../core/Evented.js";import{destroyMaybe as a}from"../../../core/maybe.js";import{when as i}from"../../../core/reactiveUtils.js";import{property as n,subclass as s}from"../../../core/accessorSupport/decorators.js";import{afterDispatch as l}from"../../../core/accessorSupport/watch.js";import{fromValues as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import m from"../../ViewAnimation.js";import{viewingModeFromString as h}from"../../ViewingMode.js";import{Constraints as d}from"./Constraints.js";import{AnimationController as u}from"./controllers/AnimationController.js";import g from"../webgl/RenderCamera.js";import{DepthRange as y}from"../webgl-engine/lib/DepthRange.js";import{maximumHighlights as C}from"../../support/HighlightDefaults.js";import{PropertiesPool as f}from"../../support/PropertiesPool.js";let w=class extends r{constructor(e){super(e),this._propertiesPool=new f({camera:()=>new g},this),this._lastSeenCameraProjectionValues=new g,this.mode=0,this._cssCamera=new g,this._camera=new g,this.rasterPixelRatio=1,this.contentPixelRatio=1,this.constraints=new d({state:this}),this.events=new o,this.fading=!1,this._cameraChanged=!1,this._updateQueue=new Array,this._processingUpdates=!1}reset(){this.cameraController=null,this._propertiesPool.destroy(),this._propertiesPool=new f({camera:()=>new g},this)}destroy(){this.cameraController=a(this.cameraController),this._propertiesPool=a(this._propertiesPool)}createInitialCamera(){if(1===this.viewingMode){const e=c(this.spatialReference).radius;this.camera=new g({eye:p(4*e,0,0),center:p(e,0,0),up:p(0,0,1)})}else this.camera=new g({eye:p(0,0,100),center:p(0,0,0),up:p(0,1,0)})}get animation(){return this.cameraController instanceof u&&null!=this.cameraController.viewAnimation?this.cameraController.viewAnimation:null}get cssCamera(){const e=this._cssCamera.copyFrom(this.camera),{height:t,width:r,pixelRatio:o}=this.camera;return e.pixelRatio=1,e.height=Math.round(t/o),e.width=Math.round(r/o),e}get camera(){return this._camera}set camera(e){e!==j&&j.copyFrom(e),j.computeUp(this.viewingMode),this.events.emit("before-camera-change",{camera:j});const t=this._camera;if(_(this._lastSeenCameraProjectionValues,j)&&(this._lastSeenCameraProjectionValues.copyFrom(j),this.events.emit("camera-projection-changed",this._lastSeenCameraProjectionValues)),!t.equals(j)&&(this._camera=this._propertiesPool.get("camera").copyFrom(j),this._cameraChanged=!t.almostEquals(j),this._cameraChanged)){const e=l(()=>{this._cameraChanged=!1,e.remove()})}}get pixelRatio(){return this.camera.pixelRatio}get alignPixelEnabled(){return this.pixelRatio===this.rasterPixelRatio&&2===this.mode}get updating(){return 2!==this.mode}get contentCamera(){return this._contentCamera??this.camera}set contentCamera(e){if(null==e)return void(this._contentCamera=null);const t=e.clone();this.events.emit("before-camera-change",{camera:t,sceneDepthRange:y.Infinite}),this._contentCamera=t}get fixedContentCamera(){return null!=this._contentCamera}get isGlobal(){return 1===this.viewingMode}get isLocal(){return 2===this.viewingMode}get viewingMode(){return h(this.view.viewingMode)}get spatialReference(){return this.view.spatialReference}get highlights(){const e=this.view.highlights.items.slice(0,C);for(let t=0;t<e.length;){const r=e[t],o=e.findIndex(e=>e.name===r.name);o>=0&&t>o?e.splice(t,1):++t}return e}get highlightOrderMap(){return new Map(this.highlights.map(({name:e},t)=>[e,t]))}get animationsEnabled(){return this.view.animationsEnabled&&!t()}get navigating(){return!!this.cameraController?.isInteractive}get stationary(){return!this._cameraChanged&&!this.navigating}get cameraController(){return this._get("cameraController")}set cameraController(e){this.stopActiveCameraController()?(this.removeHandles(x),this.cameraController?.destroy(),e&&(this.addHandles(i(()=>4===e.state||3===e.state,()=>{this.updateCamera(t=>e.onControllerEnd(t)),this.cameraController===e&&(this._set("cameraController",null),e.destroy())},{sync:!0,once:!0}),x),e.onControllerStart(this.camera)),this._set("cameraController",e)):e&&(e.state=1)}switchCameraController(e){this.cameraController=e}stopActiveCameraController(){return!this.cameraController||this.cameraController.stopController()}updateCamera(e){this._updateQueue.push(e),this._processUpdateQueue()}_processUpdateQueue(){if(0===this._updateQueue.length||this._processingUpdates)return;this._processingUpdates=!0;const e=this._updateQueue.shift();j.copyFrom(this.camera),e(j),this.camera=j,this._processingUpdates=!1,this._processUpdateQueue()}static cleanupViewstate(){j=new g}};e([n({constructOnly:!0})],w.prototype,"view",void 0),e([n()],w.prototype,"mode",void 0),e([n({readOnly:!0,type:m})],w.prototype,"animation",null),e([n({type:g})],w.prototype,"cssCamera",null),e([n()],w.prototype,"_cssCamera",void 0),e([n({type:g})],w.prototype,"camera",null),e([n()],w.prototype,"_camera",void 0),e([n({readOnly:!0})],w.prototype,"pixelRatio",null),e([n()],w.prototype,"rasterPixelRatio",void 0),e([n()],w.prototype,"contentPixelRatio",void 0),e([n({readOnly:!0})],w.prototype,"alignPixelEnabled",null),e([n({readOnly:!0})],w.prototype,"updating",null),e([n({})],w.prototype,"_contentCamera",void 0),e([n({type:g})],w.prototype,"contentCamera",null),e([n({readOnly:!0})],w.prototype,"fixedContentCamera",null),e([n({readOnly:!0})],w.prototype,"events",void 0),e([n({readOnly:!0})],w.prototype,"isGlobal",null),e([n({readOnly:!0})],w.prototype,"isLocal",null),e([n({readOnly:!0})],w.prototype,"viewingMode",null),e([n({readOnly:!0})],w.prototype,"highlights",null),e([n({readOnly:!0})],w.prototype,"highlightOrderMap",null),e([n({readOnly:!0})],w.prototype,"navigating",null),e([n()],w.prototype,"fading",void 0),e([n({readOnly:!0})],w.prototype,"stationary",null),e([n()],w.prototype,"_cameraChanged",void 0),e([n()],w.prototype,"cameraController",null),w=e([s("esri.views.3d.state.ViewState")],w);const v=w;function _(e,t){return e.fov!==t.fov||(e.fullViewport[0]!==t.fullViewport[0]||e.fullViewport[1]!==t.fullViewport[1]||e.fullViewport[2]!==t.fullViewport[2]||e.fullViewport[3]!==t.fullViewport[3]||(e.padding[0]!==t.padding[0]||e.padding[1]!==t.padding[1]||e.padding[2]!==t.padding[2]||e.padding[3]!==t.padding[3]))}let j=new g;const x="ViewStateHandles";export{v as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../Camera.js";import i from"../../../Viewpoint.js";import r from"../../../core/Accessor.js";import a from"../../../core/Logger.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{on as n,watch as o,sync as h,when as l}from"../../../core/reactiveUtils.js";import{addFrameTask as c}from"../../../core/scheduling.js";import{createScreenPoint as p}from"../../../core/screenUtils.js";import{property as m,subclass as d}from"../../../core/accessorSupport/decorators.js";import{s as v}from"../../../chunks/vec32.js";import{fromArray as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as w}from"../../../chunks/vec42.js";import{create as g}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import _ from"../../../geometry/Extent.js";import y from"../../../geometry/Point.js";import f from"../../../geometry/Polygon.js";import{isLoadedOrLoadFor as C,requiresLoad as x}from"../../../geometry/projectionUtils.js";import{fromRenderCamera as R,toRenderCamera as P}from"../webgl.js";import{applyAll as S}from"../camera/constraintUtils.js";import{cameraOnContentAlongViewDirection as O,surfaceElevationBelowRenderLocation as b}from"../camera/intersectionUtils.js";import{ConstraintsManager as T}from"./ConstraintsManager.js";import{Frustum as j}from"./Frustum.js";import{GoToOperation as z}from"./GoToOperation.js";import{SurfaceCollisionCorrectionController as M}from"./controllers/SurfaceCollisionCorrectionController.js";import{toArea as I,toExtent as H,applyTiltAdjustToScale as B,scaleToZoom as E,fromExtentSync as L,getObserverForPointAtDistanceSync as V,viewScaleToCameraDistance as A,zoomToScale as U}from"../support/cameraUtils.js";import{fromCamera as k,toCameraSync as D}from"../support/viewpointUtils.js";import F from"../webgl/RenderCamera.js";import{PropertiesPool as N}from"../../support/PropertiesPool.js";import{ensureAttachmentMaxSize as G}from"../../webgl/FramebufferObject.js";let q=class extends r{constructor(e){super(e),this.ready=!1,this._windowDevicePixelRatio=1,this._devicePixelRatioOverride=null,this._idleTimeout=te,this.test={viewStateManager:this,contentCameraResetState:new Map,setDevicePixelRatio:e=>this._devicePixelRatioOverride=e,getDevicePixelRatioOverride:()=>this._devicePixelRatioOverride,renderState:null,get maximumPixelRatio(){return this.viewStateManager.view.qualitySettings.maximumPixelRatio},get updatingIgnoreRenderState(){return null!=this.renderState},get idleTimeoutEnabled(){return this.viewStateManager._idleTimeout>0},set idleTimeoutEnabled(e){this.viewStateManager._idleTimeout=e?te:0}},this._propertiesPool=new N({frustum:()=>new j(null)},this),this._cameraSetByUser=!1,this._gotoOperation=null,this._cameraChangeTime=0,this._tmpCanvasSize=new W}initialize(){this._cameraChangeTime=performance.now(),this.addHandles([n(()=>this.view.state.events,"before-camera-change",({camera:e})=>e&&this._updateElevation(e)),o(()=>this.view.state?.camera,(e,t)=>this._cameraChangedHandler(e,t),h)]),l(()=>this.view.state?.camera,e=>this._updateElevation(e),{once:!0,sync:!0}),this.addHandles([c({prepare:()=>this._prepareFrame()}),o(()=>this.view.state.cameraController,()=>{this._cameraSetByUser=!0,this.removeHandles($)}),n(()=>this.view.state.events,"camera-projection-changed",()=>this.notifyChange("scale"))])}destroy(){this.exit(),this._propertiesPool=s(this._propertiesPool)}get camera(){const e=this._get("camera");if(!this.ready)return e;const t=R(this.view,this.view.state.camera,Q);return t&&e&&t.equals(e)?e:t.clone()}set camera(e){if(this._updatePropertyBeforeReady("camera",e))return;this.view.elevationProvider.enableCache(!0);const t=P(this.view,e);t?this.setStateCamera(t,{applyConstraints:!1})||a.getLogger(this).warnOnce("#camera=","There is a currently active camera controller that has priority."):a.getLogger(this).error("#camera=","Invalid camera",e),this.view.elevationProvider.enableCache(!1)}get contentCamera(){const e=this._get("contentCamera");if(!this.ready)return e;const t=R(this.view,this.view.state.contentCamera,Q);return t&&e&&t.equals(e)?e:t.clone()}set contentCamera(e){if(this._updatePropertyBeforeReady("contentCamera",e))return;const t=P(this.view,e);this.view.state.contentCamera=null!=t?t:null}installContentCameraReset(e){if(this.removeHandles(ee),this.test.contentCameraResetState.clear(),!this.view.state.fixedContentCamera)return!1;const t=this.zoom,i=this.view.state.camera.distance**2,r=u(this.view.state.camera.center),a=e.sticky?this.contentCamera.clone():null;return this.addHandles([o(()=>this.contentCamera,()=>{e.sticky||(this.removeHandles(ee),this.test.contentCameraResetState.clear())}),o(()=>this.zoom,e=>{void 0!==e&&void 0!==t&&(this.test.contentCameraResetState.set("view.zoom",Math.abs(e-t)/2),Math.abs(e-t)>2?this.contentCamera=null:this.view.state.fixedContentCamera||(this.contentCamera=a))}),o(()=>this.view.state.camera,e=>{const t=v(r,e.center);this.test.contentCameraResetState.set("camera.center",t/i),t>i?this.contentCamera=null:this.view.state.fixedContentCamera||(this.contentCamera=a)})],ee),!0}get center(){return this.ready?this.view.pointsOfInterest.centerOnContent.location:this._get("center")}set center(e){this._updatePropertyBeforeReady("center",e)||(e?this.isCompatible(e)?this.setStateCamera(this._centerToCamera(e),{applyConstraints:!0})?this.view.pointsOfInterest.centerOnContent.runTask():a.getLogger(this).error("#center=","Invalid center",e):a.getLogger(this).error("#center=","Center has an incompatible spatial reference (center: "+(e.spatialReference?e.spatialReference.wkid:"none")+", view: "+this.view.spatialReference?.wkid+")",e):a.getLogger(this).error("#center=","Center may not be null or undefined"))}get visibleArea(){if(!this.ready){const e=this._get("extent");return e?f.fromExtent(e):null}return I(this.view,this.view.pointsOfInterest.focus.renderLocation)}get extent(){if(!this.ready)return this._get("extent");const e=this.view,t=H(e,e.state.camera,e.pointsOfInterest.centerOnContent.renderLocation);return null!=t?t:this._get("extent")}set extent(e){this._updatePropertyBeforeReady("extent",e)||(e?this.isCompatible(e)?this.setStateCamera(this._extentToCamera(e),{applyConstraints:!0})||a.getLogger(this).error("#extent=","Invalid extent",e):a.getLogger(this).error("#extent=","Extent has an incompatible spatial reference (extent: "+(e.spatialReference?e.spatialReference.wkid:"none")+", view: "+this.view.spatialReference?.wkid+")",e):a.getLogger(this).error("#extent=","Extent may not be null or undefined"))}get frustum(){const e=this._propertiesPool.get("frustum");return e.renderCoordsHelper=this.view.renderCoordsHelper,e.update(this.view.state.camera),e}get constraintsManager(){return this._constraintsManager}get _initialViewpoint(){const e=this.view.map;return e&&"initialViewProperties"in e?e.initialViewProperties?.viewpoint:void 0}get hasInitialView(){return!!this._initialViewpoint}get scale(){if(!this.ready)return this._get("scale");const e=this.view.basemapTerrain.tilingScheme,t=this.view.pointsOfInterest.cameraOnSurface.scale;return e&&t?B(this.view,t,this.view.state.contentCamera,e):this._get("scale")}set scale(e){this._updatePropertyBeforeReady("scale",e)||this.setStateCamera(this._scaleToCamera(e),{applyConstraints:!0})||a.getLogger(this).error("#scale=","Invalid scale",e)}get padding(){if(!this.ready)return this._get("padding");const e=this.view.state.camera,t=e.padding,i=e.pixelRatio,r=this._get("padding"),a=Math.round(t[0]/i),s=Math.round(t[1]/i),n=Math.round(t[2]/i),o=Math.round(t[3]/i);return null!=r&&r.top===a&&r.right===s&&r.bottom===n&&r.left===o?r:{top:a,right:s,bottom:n,left:o}}set padding(e){this._updatePropertyBeforeReady("padding",e)||(this._paddingToArray(e,this.view.state.camera.pixelRatio,Y),this.view.state.updateCamera(e=>e.padding=Y))}_paddingToArray(e,t,i){e?w(i,e.top||0,e.right||0,e.bottom||0,e.left||0):w(i,0,0,0,0);for(let r=0;r<4;r++)i[r]=Math.round(i[r]*t)}get screenCenter(){const e=this.padding;return p((this.view.width-(e.left+e.right))/2+e.left,(this.view.height-(e.top+e.bottom))/2+e.top)}get viewpoint(){return this.ready?k(this.view,this.camera):this._get("viewpoint")}set viewpoint(e){if(!this._updatePropertyBeforeReady("viewpoint",e))if(e){if(!this.isCompatible(e)){const t=null!=e.camera?e.camera.position:e.targetGeometry,i=null!=t&&t.spatialReference;return void a.getLogger(this).error("#viewpoint=","Viewpoint has an incompatible spatial reference (viewpoint: "+(i?i.wkid:"none")+", view: "+this.view.spatialReference?.wkid+")",e)}this.setStateCamera(this._viewpointToCamera(e),{applyConstraints:!e.camera})||a.getLogger(this).error("#viewpoint=","Invalid viewpoint",e)}else a.getLogger(this).error("#viewpoint=","Viewpoint may not be null or undefined")}get zoom(){return this.ready?E(this.view,this.scale):this._get("zoom")}set zoom(e){this._updatePropertyBeforeReady("zoom",e)||void 0===e||this.setStateCamera(this._zoomToCamera(e),{applyConstraints:!0})||a.getLogger(this).error("#zoom=","Invalid zoom",e)}_computeCanvasSize(){if(this._devicePixelRatioOverride)return this.view.state.contentPixelRatio=this._devicePixelRatioOverride,this._tmpCanvasSize.width=Math.round(this.view.surface.clientWidth*this._devicePixelRatioOverride),this._tmpCanvasSize.height=Math.round(this.view.surface.clientHeight*this._devicePixelRatioOverride),this._tmpCanvasSize.pixelRatio=this._devicePixelRatioOverride,this._tmpCanvasSize;const e=Math.min(this._windowDevicePixelRatio,this.view.qualitySettings.maximumPixelRatio),t=(this._usePhysicalPixelRendering?this._windowDevicePixelRatio:e)*this.view.resolutionScale;this._tmpCanvasSize.width=Math.round(this.view.surface.clientWidth*t),this._tmpCanvasSize.height=Math.round(this.view.surface.clientHeight*t);const i=this.view.stage.renderView.renderingContext?.parameters.maxTextureSize;return i&&G(this._tmpCanvasSize,i),this._tmpCanvasSize.pixelRatio=this._tmpCanvasSize.width>0?this._tmpCanvasSize.width/this.view.surface.clientWidth*.5+this._tmpCanvasSize.height/this.view.surface.clientHeight*.5:t,this.view.state&&(this.view.state.contentPixelRatio=Math.min(this._windowDevicePixelRatio,this.view.qualitySettings.maximumPixelRatio)),this._tmpCanvasSize}get _rasterPixelRatio(){return null!=this._devicePixelRatioOverride?this._devicePixelRatioOverride:this._usePhysicalPixelRenderingAny?this._windowDevicePixelRatio:Math.min(this._windowDevicePixelRatio,this.view.qualitySettings.maximumPixelRatio)}get _usePhysicalPixelRendering(){return this.view?.stage?.renderer.isFeatureEnabled(8)??!1}get _usePhysicalPixelRenderingAny(){const e=this.view?.stage?.renderer;return e&&(e.isFeatureEnabled(8,2)||e.isFeatureEnabled(8,1)||e.isFeatureEnabled(8,0))}preinit(e){return!(this._isOverridden("center")&&!C(this.center.spatialReference,e))&&(!(this._isOverridden("camera")&&!C(this.camera.position.spatialReference,e))&&(!(this._isOverridden("extent")&&!C(this.extent.spatialReference,e))&&!!(!this._isOverridden("viewpoint")||C(this.viewpoint.targetGeometry?.spatialReference,e)&&C(this.viewpoint.camera?.position?.spatialReference,e))))}init(){this._constraintsManager=new T({view:this.view}),this._prepareFrame();const e=this._getInitialProperties();this._cameraSetByUser=!1,this._set("ready",!0);for(const t of e)this.set(t.name,t.value);if(!this._cameraSetByUser){const e=this._initialViewpoint||this.view.initialExtent;e&&this.isCompatible(e)?this._setInitialView(e):2===this.view.state.viewingMode&&this.addHandles(l(()=>this.view.basemapTerrain.ready,()=>{this.removeHandles($),this._setInitialView(this.view.dataExtent)},{once:!0,initial:!0}),$)}}exit(){this._cancelGoToOperation(),this.ready&&(this._override("padding",this.padding),this._set("ready",!1),this._clearOverride("hasInitialView"),this._cameraSetByUser=!1,this.removeHandles($),this._constraintsManager=s(this._constraintsManager))}async goTo(e,t){return t={animate:!0,...t},null!=this._gotoOperation&&this._gotoOperation.abort(t.animate),this._gotoOperation=new z(e,t,this.view),this.view.resourceController.scheduler.stopFrame(),this._gotoOperation.promise}debugSetCameraOnContent(){this.setStateCamera(O(this.view),{applyConstraints:!1})}step(e){const t=this.view.state?.cameraController;t?.stepController&&this.view.state.updateCamera(i=>t.stepController(e,i))}_cancelGoToOperation(){null!=this._gotoOperation&&(this._gotoOperation.abort(),this._gotoOperation=null)}_getInitialProperties(){const e=new Set,t=[];for(const{propertyName:i,overrides:r}of J){const a=e.has(i),s=this._isOverridden(i);!a&&s&&t.push({name:i,value:this._get(i)}),this._clearOverride(i),(a||s)&&r.forEach(t=>e.add(t))}return t}_setInitialView(e){if(null==e||this._cameraSetByUser)return;if(e instanceof t)return void this.setStateCamera(P(this.view,e),{applyConstraints:!1});if(e instanceof i){if(e.targetGeometry instanceof _){const t=L(this.view,e.targetGeometry,0,.5,0);return void(null!=t&&this.setStateCamera(P(this.view,t),{applyConstraints:!0}))}const t={applyConstraints:!e.camera},i=this._viewpointToCamera(e);return void this.setStateCamera(i,t)}const r=L(this.view,e,0,.5,0);null!=r&&this.setStateCamera(P(this.view,r),{applyConstraints:!0})}_updatePropertyBeforeReady(e,t){return!this.ready&&(this._override(e,t),t&&Z.has(e)&&this._override("hasInitialView",!0),!0)}isCompatible(e){return null!=e&&(e instanceof i?e.camera?this.isCompatible(e.camera):this.isCompatible(e.targetGeometry):e instanceof t?this.isCompatible(e.position):e.spatialReference&&!x(e.spatialReference,this.view.spatialReference))}_getPreservingHeadingTilt(e=K){return this._cameraSetByUser?(e.heading=this.camera.heading,e.tilt=this.camera.tilt):(e.heading=0,e.tilt=.5),e}_centerPointAtDistanceToCamera(e,t,i=X){const{heading:r,tilt:a}=this._getPreservingHeadingTilt(),s=V(this.view,r,a,e,t,1);return null==s?null:(i.copyFrom(this.view.state.camera),i.eye=s.eye,i.center=s.center,i.up=s.up,i)}_centerToCamera(e){let t;if(e.hasZ)t=this.view.state.camera.distance;else{const{centerOnContent:e}=this.view.pointsOfInterest;e.runTask(),t=e.distance}return this._centerPointAtDistanceToCamera(e,t)}_extentToCamera(e){const{heading:t,tilt:i}=this._getPreservingHeadingTilt(),r=L(this.view,e,t,i,1,Q);return r?P(this.view,r):null}_scaleToCamera(e){if(null==e)return null;const t=this.view,i=t.pointsOfInterest.centerOnContent;i.runTask();const r=i.renderLocation,a=t.pointsOfInterest.cameraOnSurface.renderLocation,s=A(t,e,r,a);return this._centerPointAtDistanceToCamera(r,s)}_zoomToCamera(e){return this._scaleToCamera(U(this.view,e))}_viewpointToCamera(e){return P(this.view,D(this.view,e))}setStateCamera(e,t){return!(null==e||!this.view.state.stopActiveCameraController())&&(this._cameraSetByUser=!0,t.doNotCancelGoToOperation||this._cancelGoToOperation(),this.view.state.updateCamera(i=>{t.positionAndOrientationOnly?(i.eye=e.eye,i.center=e.center,i.up=e.up,i.fov=e.fov):i.copyFrom(e),t.applyConstraints&&S(this.view,i)}),t.applyConstraints||(this.view.state.cameraController=new M({view:this.view,desiredCamera:e})),!0)}_prepareFrame(){const{surface:e,canvas:t,stage:i}=this.view;if(!e||!t||!i||i.destroyed||i.destroying)return;this._windowDevicePixelRatio=window.devicePixelRatio;const r=this._computeCanvasSize();if(0!==r.width&&0!==r.height&&(t.width===r.width&&t.height===r.height||(t.width=r.width,t.height=r.height),this.view.state)){const e=this.view.state.camera;e.fullWidth===r.width&&e.fullHeight===r.height&&e.pixelRatio===r.pixelRatio||(X.copyFrom(e),X.pixelRatio!==r.pixelRatio&&(this._paddingToArray(this.padding,r.pixelRatio,Y),X.padding=Y),X.fullWidth=r.width,X.fullHeight=r.height,X.pixelRatio=r.pixelRatio,this.view.state.camera=X),this._updateState()}}_updateElevation(e){const t=this.view.renderCoordsHelper?.getAltitude(e.eye)??0,i=this.view.basemapTerrain?.spatialReference,r=i?b(this.view,e.eye):0;e.relativeElevation=t-r}_updateState(){null!=this.test.renderState?this.view.state.mode=this.test.renderState:this.view.animation?this.view.state.mode=0:this.view.interacting?this.view.state.mode=1:(0===this.view.state.mode&&(this._cameraChangeTime=0),performance.now()-this._cameraChangeTime<this._idleTimeout?this.view.state.mode=1:this.view.state.mode=2),this.view.state.rasterPixelRatio=this._rasterPixelRatio}_cameraChangedHandler(e,t){e&&t&&e.almostEquals(t)||(this._cameraChangeTime=performance.now(),this._updateState())}};e([m({type:t,dependsOn:["view.state.camera","ready"]})],q.prototype,"camera",null),e([m({type:t,dependsOn:["view.state.contentCamera","ready"]})],q.prototype,"contentCamera",null),e([m({type:y})],q.prototype,"center",null),e([m()],q.prototype,"visibleArea",null),e([m({type:_})],q.prototype,"extent",null),e([m({readOnly:!0})],q.prototype,"frustum",null),e([m()],q.prototype,"_constraintsManager",void 0),e([m({readOnly:!0})],q.prototype,"constraintsManager",null),e([m()],q.prototype,"_initialViewpoint",null),e([m({readOnly:!0})],q.prototype,"hasInitialView",null),e([m({readOnly:!0,type:Boolean})],q.prototype,"ready",void 0),e([m({type:Number})],q.prototype,"scale",null),e([m()],q.prototype,"padding",null),e([m({readOnly:!0})],q.prototype,"screenCenter",null),e([m({constructOnly:!0})],q.prototype,"view",void 0),e([m({type:i})],q.prototype,"viewpoint",null),e([m({type:Number})],q.prototype,"zoom",null),e([m({readOnly:!0})],q.prototype,"_rasterPixelRatio",null),e([m({readOnly:!0})],q.prototype,"_usePhysicalPixelRendering",null),e([m({readOnly:!0})],q.prototype,"_usePhysicalPixelRenderingAny",null),e([m()],q.prototype,"_windowDevicePixelRatio",void 0),e([m()],q.prototype,"_devicePixelRatioOverride",void 0),q=e([d("esri.views.3d.state.ViewStateManager")],q);class W{constructor(){this.width=0,this.height=0,this.pixelRatio=1}}const Z=new Set(["camera","viewpoint","extent","scale","center","zoom"]),J=[{propertyName:"camera",overrides:["viewpoint"]},{propertyName:"viewpoint",overrides:["extent"]},{propertyName:"extent",overrides:["center","scale"]},{propertyName:"center",overrides:[]},{propertyName:"scale",overrides:["zoom"]},{propertyName:"zoom",overrides:[]},{propertyName:"padding",overrides:[]}],K={heading:0,tilt:0};let Q=new t,X=new F;const Y=g(),$="pending-initial-view",ee="content-camera-reset",te=300,ie=100;function re(){Q=new t,X=new F}export{q as ViewStateManager,re as cleanupViewStateManager,ie as interactingTimeout};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../Camera.js";import i from"../../../Viewpoint.js";import r from"../../../core/Accessor.js";import a from"../../../core/Logger.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{on as n,watch as o,sync as h,when as l}from"../../../core/reactiveUtils.js";import{addFrameTask as c}from"../../../core/scheduling.js";import{createScreenPoint as p}from"../../../core/screenUtils.js";import{property as m,subclass as d}from"../../../core/accessorSupport/decorators.js";import{s as v}from"../../../chunks/vec32.js";import{fromArray as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as w}from"../../../chunks/vec42.js";import{create as g}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import _ from"../../../geometry/Extent.js";import y from"../../../geometry/Point.js";import f from"../../../geometry/Polygon.js";import{isLoadedOrLoadFor as C,requiresLoad as x}from"../../../geometry/projectionUtils.js";import{fromRenderCamera as R,toRenderCamera as P}from"../webgl.js";import{applyAll as S}from"../camera/constraintUtils.js";import{cameraOnContentAlongViewDirection as O,surfaceElevationBelowRenderLocation as b}from"../camera/intersectionUtils.js";import{ConstraintsManager as T}from"./ConstraintsManager.js";import{Frustum as j}from"./Frustum.js";import{GoToOperation as z}from"./GoToOperation.js";import{SurfaceCollisionCorrectionController as M}from"./controllers/SurfaceCollisionCorrectionController.js";import{toArea as I,toExtent as H,applyTiltAdjustToScale as E,scaleToZoom as B,fromExtentSync as L,getObserverForPointAtDistanceSync as V,viewScaleToCameraDistance as A,zoomToScale as U}from"../support/cameraUtils.js";import{fromCamera as k,toCameraSync as D}from"../support/viewpointUtils.js";import F from"../webgl/RenderCamera.js";import{PropertiesPool as N}from"../../support/PropertiesPool.js";import{ensureAttachmentMaxSize as G}from"../../webgl/FramebufferObject.js";let q=class extends r{constructor(e){super(e),this.ready=!1,this._windowDevicePixelRatio=1,this._devicePixelRatioOverride=null,this._idleTimeout=te,this.test={viewStateManager:this,contentCameraResetState:new Map,setDevicePixelRatio:e=>this._devicePixelRatioOverride=e,getDevicePixelRatioOverride:()=>this._devicePixelRatioOverride,renderState:null,get maximumPixelRatio(){return this.viewStateManager.view.qualitySettings.maximumPixelRatio},get updatingIgnoreRenderState(){return null!=this.renderState},get idleTimeoutEnabled(){return this.viewStateManager._idleTimeout>0},set idleTimeoutEnabled(e){this.viewStateManager._idleTimeout=e?te:0}},this._propertiesPool=new N({frustum:()=>new j(null)},this),this._cameraSetByUser=!1,this._gotoOperation=null,this._cameraChangeTime=0,this._tmpCanvasSize=new W}initialize(){this._cameraChangeTime=performance.now(),this.addHandles([n(()=>this.view.state.events,"before-camera-change",({camera:e})=>e&&this._updateElevation(e)),o(()=>this.view.state?.camera,(e,t)=>this._cameraChangedHandler(e,t),h)]),l(()=>this.view.state?.camera,e=>this._updateElevation(e),{once:!0,sync:!0}),this.addHandles([c({prepare:()=>this._prepareFrame()}),o(()=>this.view.state.cameraController,()=>{this._cameraSetByUser=!0,this.removeHandles($)}),n(()=>this.view.state.events,"camera-projection-changed",()=>this.notifyChange("scale"))])}destroy(){this.exit(),this._propertiesPool=s(this._propertiesPool)}get camera(){const e=this._get("camera");if(!this.ready)return e;const t=R(this.view,this.view.state.camera,Q);return t&&e&&t.equals(e)?e:t.clone()}set camera(e){if(this._updatePropertyBeforeReady("camera",e))return;this.view.elevationProvider.enableCache(!0);const t=P(this.view,e);t?this.setStateCamera(t,{applyConstraints:!1})||a.getLogger(this).warnOnce("#camera=","There is a currently active camera controller that has priority."):a.getLogger(this).error("#camera=","Invalid camera",e),this.view.elevationProvider.enableCache(!1)}get contentCamera(){const e=this._get("contentCamera");if(!this.ready)return e;const t=R(this.view,this.view.state.contentCamera,Q);return t&&e&&t.equals(e)?e:t.clone()}set contentCamera(e){if(this._updatePropertyBeforeReady("contentCamera",e))return;const t=P(this.view,e);this.view.state.contentCamera=null!=t?t:null}installContentCameraReset(e){if(this.removeHandles(ee),this.test.contentCameraResetState.clear(),!this.view.state.fixedContentCamera)return!1;const t=this.zoom,i=this.view.state.camera.distance**2,r=u(this.view.state.camera.center),a=e.sticky?this.contentCamera.clone():null;return this.addHandles([o(()=>this.contentCamera,()=>{e.sticky||(this.removeHandles(ee),this.test.contentCameraResetState.clear())}),o(()=>this.zoom,e=>{void 0!==e&&void 0!==t&&(this.test.contentCameraResetState.set("view.zoom",Math.abs(e-t)/2),Math.abs(e-t)>2?this.contentCamera=null:this.view.state.fixedContentCamera||(this.contentCamera=a))}),o(()=>this.view.state.camera,e=>{const t=v(r,e.center);this.test.contentCameraResetState.set("camera.center",t/i),t>i?this.contentCamera=null:this.view.state.fixedContentCamera||(this.contentCamera=a)})],ee),!0}get center(){return this.ready?this.view.pointsOfInterest.centerOnContent.location:this._get("center")}set center(e){this._updatePropertyBeforeReady("center",e)||(e?this.isCompatible(e)?this.setStateCamera(this._centerToCamera(e),{applyConstraints:!0})?this.view.pointsOfInterest.centerOnContent.runTask():a.getLogger(this).error("#center=","Invalid center",e):a.getLogger(this).error("#center=","Center has an incompatible spatial reference (center: "+(e.spatialReference?e.spatialReference.wkid:"none")+", view: "+this.view.spatialReference?.wkid+")",e):a.getLogger(this).error("#center=","Center may not be null or undefined"))}get visibleArea(){if(!this.ready){const e=this._get("extent");return e?f.fromExtent(e):null}return I(this.view,this.view.pointsOfInterest.focus.renderLocation)}get extent(){if(!this.ready)return this._get("extent");const e=this.view,t=H(e,e.state.camera,e.pointsOfInterest.centerOnContent.renderLocation);return null!=t?t:this._get("extent")}set extent(e){this._updatePropertyBeforeReady("extent",e)||(e?this.isCompatible(e)?this.setStateCamera(this._extentToCamera(e),{applyConstraints:!0})||a.getLogger(this).error("#extent=","Invalid extent",e):a.getLogger(this).error("#extent=","Extent has an incompatible spatial reference (extent: "+(e.spatialReference?e.spatialReference.wkid:"none")+", view: "+this.view.spatialReference?.wkid+")",e):a.getLogger(this).error("#extent=","Extent may not be null or undefined"))}get frustum(){const e=this._propertiesPool.get("frustum");return e.renderCoordsHelper=this.view.renderCoordsHelper,e.update(this.view.state.camera),e}get constraintsManager(){return this._constraintsManager}get _initialViewpoint(){const e=this.view.map;return e&&"initialViewProperties"in e?e.initialViewProperties?.viewpoint:void 0}get hasInitialView(){return!!this._initialViewpoint}get scale(){if(!this.ready)return this._get("scale");const e=this.view.basemapTerrain.tilingScheme,t=this.view.pointsOfInterest.cameraOnSurface.scale;return e&&t?E(this.view,t,this.view.state.contentCamera,e):this._get("scale")}set scale(e){this._updatePropertyBeforeReady("scale",e)||this.setStateCamera(this._scaleToCamera(e),{applyConstraints:!0})||a.getLogger(this).error("#scale=","Invalid scale",e)}get padding(){if(!this.ready)return this._get("padding");const e=this.view.state.camera,t=e.padding,i=e.pixelRatio,r=this._get("padding"),a=Math.round(t[0]/i),s=Math.round(t[1]/i),n=Math.round(t[2]/i),o=Math.round(t[3]/i);return null!=r&&r.top===a&&r.right===s&&r.bottom===n&&r.left===o?r:{top:a,right:s,bottom:n,left:o}}set padding(e){this._updatePropertyBeforeReady("padding",e)||(this._paddingToArray(e,this.view.state.camera.pixelRatio,Y),this.view.state.updateCamera(e=>e.padding=Y))}_paddingToArray(e,t,i){e?w(i,e.top||0,e.right||0,e.bottom||0,e.left||0):w(i,0,0,0,0);for(let r=0;r<4;r++)i[r]=Math.round(i[r]*t)}get screenCenter(){const e=this.padding;return p((this.view.width-(e.left+e.right))/2+e.left,(this.view.height-(e.top+e.bottom))/2+e.top)}get viewpoint(){return this.ready?k(this.view,this.camera):this._get("viewpoint")}set viewpoint(e){if(!this._updatePropertyBeforeReady("viewpoint",e))if(e){if(!this.isCompatible(e)){const t=null!=e.camera?e.camera.position:e.targetGeometry,i=null!=t&&t.spatialReference;return void a.getLogger(this).error("#viewpoint=","Viewpoint has an incompatible spatial reference (viewpoint: "+(i?i.wkid:"none")+", view: "+this.view.spatialReference?.wkid+")",e)}this.setStateCamera(this._viewpointToCamera(e),{applyConstraints:!e.camera})||a.getLogger(this).error("#viewpoint=","Invalid viewpoint",e)}else a.getLogger(this).error("#viewpoint=","Viewpoint may not be null or undefined")}get zoom(){return this.ready?B(this.view,this.scale):this._get("zoom")}set zoom(e){this._updatePropertyBeforeReady("zoom",e)||void 0===e||this.setStateCamera(this._zoomToCamera(e),{applyConstraints:!0})||a.getLogger(this).error("#zoom=","Invalid zoom",e)}_computeCanvasSize(){if(this._devicePixelRatioOverride)return this.view.state.contentPixelRatio=this._devicePixelRatioOverride,this._tmpCanvasSize.width=Math.round(this.view.surface.clientWidth*this._devicePixelRatioOverride),this._tmpCanvasSize.height=Math.round(this.view.surface.clientHeight*this._devicePixelRatioOverride),this._tmpCanvasSize.pixelRatio=this._devicePixelRatioOverride,this._tmpCanvasSize;const e=Math.min(this._windowDevicePixelRatio,this.view.qualitySettings.maximumPixelRatio),t=(this._usePhysicalPixelRendering?this._windowDevicePixelRatio:e)*this.view.resolutionScale;this._tmpCanvasSize.width=Math.round(this.view.surface.clientWidth*t),this._tmpCanvasSize.height=Math.round(this.view.surface.clientHeight*t);const i=this.view.stage.renderView.renderingContext?.parameters.maxTextureSize;return i&&G(this._tmpCanvasSize,i),this._tmpCanvasSize.pixelRatio=this._tmpCanvasSize.width>0?this._tmpCanvasSize.width/this.view.surface.clientWidth*.5+this._tmpCanvasSize.height/this.view.surface.clientHeight*.5:t,this.view.state&&(this.view.state.contentPixelRatio=Math.min(this._windowDevicePixelRatio,this.view.qualitySettings.maximumPixelRatio)),this._tmpCanvasSize}get _rasterPixelRatio(){return null!=this._devicePixelRatioOverride?this._devicePixelRatioOverride:this._usePhysicalPixelRenderingAny?this._windowDevicePixelRatio:Math.min(this._windowDevicePixelRatio,this.view.qualitySettings.maximumPixelRatio)}get _usePhysicalPixelRendering(){return this.view?.stage?.renderer.isFeatureEnabled(8)??!1}get _usePhysicalPixelRenderingAny(){const e=this.view?.stage?.renderer;return e&&(e.isFeatureEnabled(8,2)||e.isFeatureEnabled(8,1)||e.isFeatureEnabled(8,0))}preinit(e){return!(this._isOverridden("center")&&!C(this.center.spatialReference,e))&&(!(this._isOverridden("camera")&&!C(this.camera.position.spatialReference,e))&&(!(this._isOverridden("extent")&&!C(this.extent.spatialReference,e))&&!!(!this._isOverridden("viewpoint")||C(this.viewpoint.targetGeometry?.spatialReference,e)&&C(this.viewpoint.camera?.position?.spatialReference,e))))}init(){this._constraintsManager=new T({view:this.view}),this._prepareFrame();const e=this._getInitialProperties();this._cameraSetByUser=!1,this._set("ready",!0);for(const t of e)this.set(t.name,t.value);if(!this._cameraSetByUser){const e=this._initialViewpoint||this.view.initialExtent;e&&this.isCompatible(e)?this._setInitialView(e):2===this.view.state.viewingMode&&this.addHandles(l(()=>this.view.basemapTerrain.ready,()=>{this.removeHandles($),this._setInitialView(this.view.dataExtent)},{once:!0,initial:!0}),$)}}exit(){this._cancelGoToOperation(),this.ready&&(this._override("padding",this.padding),this._set("ready",!1),this._clearOverride("hasInitialView"),this._cameraSetByUser=!1,this.removeHandles($),this._constraintsManager=s(this._constraintsManager))}async goTo(e,t){return t={animate:this.view.state.animationsEnabled,...t},null!=this._gotoOperation&&this._gotoOperation.abort(t.animate),this._gotoOperation=new z(e,t,this.view),this.view.resourceController.scheduler.stopFrame(),this._gotoOperation.promise}debugSetCameraOnContent(){this.setStateCamera(O(this.view),{applyConstraints:!1})}step(e){const t=this.view.state?.cameraController;t?.stepController&&this.view.state.updateCamera(i=>t.stepController(e,i))}_cancelGoToOperation(){null!=this._gotoOperation&&(this._gotoOperation.abort(),this._gotoOperation=null)}_getInitialProperties(){const e=new Set,t=[];for(const{propertyName:i,overrides:r}of J){const a=e.has(i),s=this._isOverridden(i);!a&&s&&t.push({name:i,value:this._get(i)}),this._clearOverride(i),(a||s)&&r.forEach(t=>e.add(t))}return t}_setInitialView(e){if(null==e||this._cameraSetByUser)return;if(e instanceof t)return void this.setStateCamera(P(this.view,e),{applyConstraints:!1});if(e instanceof i){if(e.targetGeometry instanceof _){const t=L(this.view,e.targetGeometry,0,.5,0);return void(null!=t&&this.setStateCamera(P(this.view,t),{applyConstraints:!0}))}const t={applyConstraints:!e.camera},i=this._viewpointToCamera(e);return void this.setStateCamera(i,t)}const r=L(this.view,e,0,.5,0);null!=r&&this.setStateCamera(P(this.view,r),{applyConstraints:!0})}_updatePropertyBeforeReady(e,t){return!this.ready&&(this._override(e,t),t&&Z.has(e)&&this._override("hasInitialView",!0),!0)}isCompatible(e){return null!=e&&(e instanceof i?e.camera?this.isCompatible(e.camera):this.isCompatible(e.targetGeometry):e instanceof t?this.isCompatible(e.position):e.spatialReference&&!x(e.spatialReference,this.view.spatialReference))}_getPreservingHeadingTilt(e=K){return this._cameraSetByUser?(e.heading=this.camera.heading,e.tilt=this.camera.tilt):(e.heading=0,e.tilt=.5),e}_centerPointAtDistanceToCamera(e,t,i=X){const{heading:r,tilt:a}=this._getPreservingHeadingTilt(),s=V(this.view,r,a,e,t,1);return null==s?null:(i.copyFrom(this.view.state.camera),i.eye=s.eye,i.center=s.center,i.up=s.up,i)}_centerToCamera(e){let t;if(e.hasZ)t=this.view.state.camera.distance;else{const{centerOnContent:e}=this.view.pointsOfInterest;e.runTask(),t=e.distance}return this._centerPointAtDistanceToCamera(e,t)}_extentToCamera(e){const{heading:t,tilt:i}=this._getPreservingHeadingTilt(),r=L(this.view,e,t,i,1,Q);return r?P(this.view,r):null}_scaleToCamera(e){if(null==e)return null;const t=this.view,i=t.pointsOfInterest.centerOnContent;i.runTask();const r=i.renderLocation,a=t.pointsOfInterest.cameraOnSurface.renderLocation,s=A(t,e,r,a);return this._centerPointAtDistanceToCamera(r,s)}_zoomToCamera(e){return this._scaleToCamera(U(this.view,e))}_viewpointToCamera(e){return P(this.view,D(this.view,e))}setStateCamera(e,t){return!(null==e||!this.view.state.stopActiveCameraController())&&(this._cameraSetByUser=!0,t.doNotCancelGoToOperation||this._cancelGoToOperation(),this.view.state.updateCamera(i=>{t.positionAndOrientationOnly?(i.eye=e.eye,i.center=e.center,i.up=e.up,i.fov=e.fov):i.copyFrom(e),t.applyConstraints&&S(this.view,i)}),t.applyConstraints||(this.view.state.cameraController=new M({view:this.view,desiredCamera:e})),!0)}_prepareFrame(){const{surface:e,canvas:t,stage:i}=this.view;if(!e||!t||!i||i.destroyed||i.destroying)return;this._windowDevicePixelRatio=window.devicePixelRatio;const r=this._computeCanvasSize();if(0!==r.width&&0!==r.height&&(t.width===r.width&&t.height===r.height||(t.width=r.width,t.height=r.height),this.view.state)){const e=this.view.state.camera;e.fullWidth===r.width&&e.fullHeight===r.height&&e.pixelRatio===r.pixelRatio||(X.copyFrom(e),X.pixelRatio!==r.pixelRatio&&(this._paddingToArray(this.padding,r.pixelRatio,Y),X.padding=Y),X.fullWidth=r.width,X.fullHeight=r.height,X.pixelRatio=r.pixelRatio,this.view.state.camera=X),this._updateState()}}_updateElevation(e){const t=this.view.renderCoordsHelper?.getAltitude(e.eye)??0,i=this.view.basemapTerrain?.spatialReference,r=i?b(this.view,e.eye):0;e.relativeElevation=t-r}_updateState(){null!=this.test.renderState?this.view.state.mode=this.test.renderState:this.view.animation?this.view.state.mode=0:this.view.interacting?this.view.state.mode=1:(0===this.view.state.mode&&(this._cameraChangeTime=0),performance.now()-this._cameraChangeTime<this._idleTimeout?this.view.state.mode=1:this.view.state.mode=2),this.view.state.rasterPixelRatio=this._rasterPixelRatio}_cameraChangedHandler(e,t){e&&t&&e.almostEquals(t)||(this._cameraChangeTime=performance.now(),this._updateState())}};e([m({type:t,dependsOn:["view.state.camera","ready"]})],q.prototype,"camera",null),e([m({type:t,dependsOn:["view.state.contentCamera","ready"]})],q.prototype,"contentCamera",null),e([m({type:y})],q.prototype,"center",null),e([m()],q.prototype,"visibleArea",null),e([m({type:_})],q.prototype,"extent",null),e([m({readOnly:!0})],q.prototype,"frustum",null),e([m()],q.prototype,"_constraintsManager",void 0),e([m({readOnly:!0})],q.prototype,"constraintsManager",null),e([m()],q.prototype,"_initialViewpoint",null),e([m({readOnly:!0})],q.prototype,"hasInitialView",null),e([m({readOnly:!0,type:Boolean})],q.prototype,"ready",void 0),e([m({type:Number})],q.prototype,"scale",null),e([m()],q.prototype,"padding",null),e([m({readOnly:!0})],q.prototype,"screenCenter",null),e([m({constructOnly:!0})],q.prototype,"view",void 0),e([m({type:i})],q.prototype,"viewpoint",null),e([m({type:Number})],q.prototype,"zoom",null),e([m({readOnly:!0})],q.prototype,"_rasterPixelRatio",null),e([m({readOnly:!0})],q.prototype,"_usePhysicalPixelRendering",null),e([m({readOnly:!0})],q.prototype,"_usePhysicalPixelRenderingAny",null),e([m()],q.prototype,"_windowDevicePixelRatio",void 0),e([m()],q.prototype,"_devicePixelRatioOverride",void 0),q=e([d("esri.views.3d.state.ViewStateManager")],q);class W{constructor(){this.width=0,this.height=0,this.pixelRatio=1}}const Z=new Set(["camera","viewpoint","extent","scale","center","zoom"]),J=[{propertyName:"camera",overrides:["viewpoint"]},{propertyName:"viewpoint",overrides:["extent"]},{propertyName:"extent",overrides:["center","scale"]},{propertyName:"center",overrides:[]},{propertyName:"scale",overrides:["zoom"]},{propertyName:"zoom",overrides:[]},{propertyName:"padding",overrides:[]}],K={heading:0,tilt:0};let Q=new t,X=new F;const Y=g(),$="pending-initial-view",ee="content-camera-reset",te=300,ie=100;function re(){Q=new t,X=new F}export{q as ViewStateManager,re as cleanupViewStateManager,ie as interactingTimeout};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import{cyclicalPI as i}from"../../../../core/Cyclical.js";import{deg2rad as e}from"../../../../core/mathUtils.js";import{createScreenPointArray as n,screenPointObjectToArray as s}from"../../../../core/screenUtils.js";import{subclass as o}from"../../../../core/accessorSupport/decorators.js";import{copy as r,distance as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{d as m,q as h,b as c,e as _,n as p,i as u,j as l,g as d}from"../../../../chunks/vec32.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as P}from"../../../../geometry/ellipsoidUtils.js";import{wrapAxisAngle as v}from"../../../../geometry/support/axisAngle.js";import{create as C,fromPositionAndNormal as w,getNormal as M}from"../../../../geometry/support/plane.js";import{Sphere as b}from"../../../../geometry/support/sphere.js";import{pixelDistanceToInteractionFactor as S,applyAll as f}from"../../camera/constraintUtils.js";import{ConstraintOptions as j}from"../../camera/constraintUtils/ConstraintOptions.js";import{ExponentialFalloff as E}from"../../input/util.js";import{InteractiveController as y}from"./InteractiveController.js";import{PanPlanarMomentumController as A}from"./momentum/PanPlanarMomentumController.js";import{PanSphericalMomentumController as O}from"./momentum/PanSphericalMomentumController.js";import{RotationMomentumController as x}from"./momentum/RotationMomentumController.js";import{ZoomPlanarMomentumController as R}from"./momentum/ZoomPlanarMomentumController.js";import{ZoomSphericalMomentumController as k}from"./momentum/ZoomSphericalMomentumController.js";import{pickPointAndInitSphere as z,excludeTerrain as F,inferNavigationMode as H,sphereOrPlanePointFromScreenPoint as D,maxPanDistanceModifier as T,minPinchAndPanCameraHeight as U,pivotSearchAreaSize as G,intersectPlaneFromScreenPointAtEye as I,applyZoomOnSphere as Z,shouldPreserveHeading as q,applyPanSphericalPreserveHeading as V,applyPanSphericalDirectRotation as B,normalizeRotationDelta as J,applyRotation as K,applyPanPlanar as L,applyZoomToPoint as N}from"../utils/navigationUtils.js";import Q from"../../webgl/RenderCamera.js";import{PanPlanarMomentumEstimator as W}from"../../../navigation/PanPlanarMomentumEstimator.js";import{PanSphericalMomentumEstimator as X}from"../../../navigation/PanSphericalMomentumEstimator.js";import{RotationMomentumEstimator as Y}from"../../../navigation/RotationMomentumEstimator.js";import{ZoomMomentumEstimator as $}from"../../../navigation/ZoomMomentumEstimator.js";let tt=class extends y{constructor(){super(...arguments),this._smoothRotation=new E(.05),this._rotationAxis=g(),this._beginAngle=0,this._beginHeading=0,this._panningPlane=C(),this._beginRadius=0,this._smoothScaling=new E(.05),this._zoomCenterScreen=n(),this._zoomMomentumEstimator=new $,this._rotationMomentumEstimator=new Y,this._panSphericalMomentumEstimator=new X,this._panPlanarMomentumEstimator=new W,this._adjustedSphere=new b,this._tmp3d=g(),this._tmpScreenPointArray=n(),this._beginScreenPoint=n(),this._beginScenePoint=g(),this._screenPickPoint=n(),this._scenePickPoint=g(),this._navigationMode=1,this._sphere=new b,this._pointerCount=0,this._tmpInteractionDirection=g(),this._beginCamera=new Q,this._constraintOptions=new j(15,0,0,this._beginCamera)}get _intersectionHelper(){return this.view.sceneIntersectionHelper}begin(t){if(!this.running)return;this._zoomMomentumEstimator.enabled=this._rotationMomentumEstimator.enabled=this._panPlanarMomentumEstimator.enabled=this._panSphericalMomentumEstimator.enabled=this.view.navigation.momentumEnabled,this._beginHeading=-i.normalize(e(this.view.camera.heading)),this._beginRadius=t.radius,this._beginAngle=t.angle,this._pointerCount=t.pointers.size,this._smoothRotation.reset(),s(t.center,this._screenPickPoint),r(this._beginScreenPoint,this._screenPickPoint);const n=z(this._intersectionHelper,this.startCamera,this._screenPickPoint,P(this.view.spatialReference).radius,1,this.view.basemapTerrain.invisible?F:{});null!=n.scenePickPoint&&(this._scenePickPoint=n.scenePickPoint,this._sphere=n.sphere,m(this._beginScenePoint,this._scenePickPoint),this._navigationMode=H(this.startCamera,this._screenPickPoint,this.view.renderCoordsHelper,this.view.viewingMode),0===this._navigationMode&&this._preparePlanarPanMode(t,n.hasGeometryIntersection),this._beginCamera.copyFrom(this.startCamera))}update(t){if(!this.running)return;this.currentCamera.copyFrom(this.startCamera);const i=t.pointers.size>1;1===this._navigationMode?(i&&this._zoomSpherical(t),this._panningSpherical(t),i&&this._rotateSpherical(t)):(i&&this._zoomPlanar(t),this._panningPlanar(t),i&&this._rotatePlanar(t)),this.commitCamera()}end(t){t.pointers.size===this._pointerCount&&this.update(t),this.finishController();const i=this._zoomMomentumEstimator.evaluateMomentum();if(i)return 1===this._navigationMode?new k({view:this.view,momentum:i,screenCenter:this._zoomCenterScreen,sceneCenter:this._beginScenePoint,radius:this._sphere.radius}):new R({view:this.view,momentum:i,zoomCenter:this._beginScenePoint});const e=this._rotationMomentumEstimator.evaluateMomentum();if(e)return new x({view:this.view,momentum:e,center:this._sphere.center,axis:this._rotationAxis});if(1===this._navigationMode){const t=this._panSphericalMomentumEstimator.evaluateMomentum();if(t)return new O({view:this.view,momentum:t})}else{const t=this._panPlanarMomentumEstimator.evaluateMomentum();if(t)return new A({view:this.view,momentum:t})}return null}_preparePlanarPanMode(t,i){const e=h(this._tmp3d,this.startCamera.viewForward);w(this._scenePickPoint,e,this._panningPlane);const o=n(this._screenPickPoint[0],0),r=g(),a=c(this.startCamera.eye);this._adjustedSphere.radius=a<this._sphere.radius?a-100:this._sphere.radius,D(this._adjustedSphere,this.startCamera,o,r);const P=g(),v=g(),C=g();_(P,this._scenePickPoint,this.currentCamera.eye);const b=c(P);p(P,P);const S=T*Math.max(Math.abs(this.view.camera.position.z),U),f=this.view.stage.renderView.getMinimalDepthForArea(null,this._screenPickPoint[0],this._screenPickPoint[1],this.view.state.camera,G);let j=null!=f?f:S;i&&(j=Math.min(j,b)),m(C,u(v,this.currentCamera.eye,l(v,P,j))),this._panningPlane[3]=-d(M(this._panningPlane),C),this.startCamera.center=u(v,this.startCamera.eye,l(v,this.startCamera.viewForward,j));const E=s(t.center,this._tmpScreenPointArray);I(this._panningPlane,this.startCamera,E,this._beginScenePoint)}_zoomSpherical(t){const i=this._beginRadius/t.radius,e=.001875*Math.min(Math.max(t.radius,40),120);this._smoothScaling.gain=e,this._smoothScaling.update(i),Z(this._sphere,this.currentCamera,this._smoothScaling.value),s(t.center,this._zoomCenterScreen),this._zoomMomentumEstimator.add(this._smoothScaling.value,.001*t.timestamp),this._constraintOptions.interactionType=1,this._constraintOptions.interactionFactor=S(t.radius-this._beginRadius),f(this.view,this.currentCamera,this._constraintOptions)}_panningSpherical(t){const i=s(t.center,this._tmpScreenPointArray);D(this._sphere,this.currentCamera,i,this._tmp3d),q(this._beginScenePoint,d(this.currentCamera.up,this._beginScenePoint),this._sphere.radius,this._beginHeading,this.view.camera.tilt,this.startCamera.aboveGround)?(V(this._sphere,this.currentCamera,this._beginScenePoint,this._tmp3d,this._beginHeading,this.view.camera.tilt,!1),this._panSphericalMomentumEstimator.addMomentumPreserveHeading(i,this._tmp3d,.001*t.timestamp,this.startCamera,this._sphere,this._beginHeading,this.view.camera.tilt)):(B(this._sphere,this.currentCamera,this._beginScenePoint,this._tmp3d,this.view.camera.tilt,!1),this._panSphericalMomentumEstimator.addMomentumDirectRotation(i,this._tmp3d,.001*t.timestamp,this.startCamera,this._sphere.radius,this.view.camera.tilt)),this._constraintOptions.interactionType=4,this._constraintOptions.interactionFactor=S(a(this._screenPickPoint,i)),f(this.view,this.currentCamera,this._constraintOptions)}_rotateSpherical(t){p(this._rotationAxis,this._scenePickPoint),this.currentCamera.aboveGround||h(this._rotationAxis,this._rotationAxis);const i=this._smoothRotation.value,e=i+J(t.angle-i),n=.00125*Math.min(Math.max(t.radius,40),120);this._smoothRotation.gain=n,this._smoothRotation.update(e);const s=this._smoothRotation.value-this._beginAngle;this._rotationMomentumEstimator.add(s,.001*t.timestamp),K(this.currentCamera,this._sphere.center,v(this._rotationAxis,s)),this._constraintOptions.interactionType=2,this._constraintOptions.interactionFactor=S(t.radius*e),f(this.view,this.currentCamera,this._constraintOptions)}_panningPlanar(t){const i=s(t.center,this._tmpScreenPointArray);I(this._panningPlane,this.currentCamera,i,this._tmp3d)&&(L(this.currentCamera,this._beginScenePoint,this._tmp3d),this._panPlanarMomentumEstimator.add(i,this._tmp3d,.001*t.timestamp),this._constraintOptions.interactionType=4,this._constraintOptions.interactionFactor=S(a(this._beginScreenPoint,i)),this._constraintOptions.interactionDirection=this.view.renderCoordsHelper.worldUpAtPosition(this.currentCamera.eye,this._tmpInteractionDirection),f(this.view,this.currentCamera,this._constraintOptions),this._constraintOptions.interactionDirection=null)}_zoomPlanar(t){const i=this._beginRadius/t.radius,e=.001875*Math.min(Math.max(t.radius,40),120);this._smoothScaling.gain=e,this._smoothScaling.update(i),this._zoomMomentumEstimator.add(this._smoothScaling.value,.001*t.timestamp),N(this.currentCamera,this._beginScenePoint,this._smoothScaling.value,this.view.state.constraints.minimumPoiDistance),this._constraintOptions.interactionType=1,this._constraintOptions.interactionFactor=S(t.radius-this._beginRadius),f(this.view,this.currentCamera,this._constraintOptions)}_rotatePlanar(t){m(this._rotationAxis,this._beginScenePoint),this.currentCamera.aboveGround||h(this._rotationAxis,this._rotationAxis);const i=this._smoothRotation.value;let e=t.angle-i;e=J(e);const n=i+e,s=.00125*Math.min(Math.max(t.radius,40),120);this._smoothRotation.gain=s,this._smoothRotation.update(n);const o=this._smoothRotation.value-this._beginAngle;this._rotationMomentumEstimator.add(o,.001*t.timestamp),K(this.currentCamera,this._sphere.center,v(this._rotationAxis,o)),this._constraintOptions.interactionType=2,this._constraintOptions.interactionFactor=S(t.radius*o),f(this.view,this.currentCamera,this._constraintOptions)}};tt=t([o("esri.views.3d.state.controllers.PinchAndPanControllerGlobal")],tt);export{tt as PinchAndPanControllerGlobal};
|
|
5
|
+
import{__decorate as t}from"tslib";import{cyclicalPI as i}from"../../../../core/Cyclical.js";import{deg2rad as e}from"../../../../core/mathUtils.js";import{createScreenPointArray as n,screenPointObjectToArray as s}from"../../../../core/screenUtils.js";import{subclass as a}from"../../../../core/accessorSupport/decorators.js";import{copy as o,distance as r}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{d as m,q as h,b as c,e as _,n as p,i as u,j as l,g as d}from"../../../../chunks/vec32.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as P}from"../../../../geometry/ellipsoidUtils.js";import{wrapAxisAngle as v}from"../../../../geometry/support/axisAngle.js";import{create as C,fromPositionAndNormal as w,getNormal as b}from"../../../../geometry/support/plane.js";import{Sphere as M}from"../../../../geometry/support/sphere.js";import{pixelDistanceToInteractionFactor as S,applyAll as f}from"../../camera/constraintUtils.js";import{ConstraintOptions as j}from"../../camera/constraintUtils/ConstraintOptions.js";import{ExponentialFalloff as E}from"../../input/util.js";import{InteractiveController as y}from"./InteractiveController.js";import{PanPlanarMomentumController as A}from"./momentum/PanPlanarMomentumController.js";import{PanSphericalMomentumController as O}from"./momentum/PanSphericalMomentumController.js";import{RotationMomentumController as x}from"./momentum/RotationMomentumController.js";import{ZoomPlanarMomentumController as R}from"./momentum/ZoomPlanarMomentumController.js";import{ZoomSphericalMomentumController as k}from"./momentum/ZoomSphericalMomentumController.js";import{pickPointAndInitSphere as z,excludeTerrain as F,inferNavigationMode as H,sphereOrPlanePointFromScreenPoint as D,maxPanDistanceModifier as T,minPinchAndPanCameraHeight as U,pivotSearchAreaSize as G,intersectPlaneFromScreenPointAtEye as I,applyZoomOnSphere as Z,shouldPreserveHeading as q,applyPanSphericalPreserveHeading as V,applyPanSphericalDirectRotation as B,normalizeRotationDelta as J,applyRotation as K,applyPanPlanar as L,applyZoomToPoint as N}from"../utils/navigationUtils.js";import Q from"../../webgl/RenderCamera.js";import{PanPlanarMomentumEstimator as W}from"../../../navigation/PanPlanarMomentumEstimator.js";import{PanSphericalMomentumEstimator as X}from"../../../navigation/PanSphericalMomentumEstimator.js";import{RotationMomentumEstimator as Y}from"../../../navigation/RotationMomentumEstimator.js";import{ZoomMomentumEstimator as $}from"../../../navigation/ZoomMomentumEstimator.js";let tt=class extends y{constructor(){super(...arguments),this._smoothRotation=new E(.05),this._rotationAxis=g(),this._beginAngle=0,this._beginHeading=0,this._panningPlane=C(),this._beginRadius=0,this._smoothScaling=new E(.05),this._zoomCenterScreen=n(),this._zoomMomentumEstimator=new $,this._rotationMomentumEstimator=new Y,this._panSphericalMomentumEstimator=new X,this._panPlanarMomentumEstimator=new W,this._adjustedSphere=new M,this._tmp3d=g(),this._tmpScreenPointArray=n(),this._beginScreenPoint=n(),this._beginScenePoint=g(),this._screenPickPoint=n(),this._scenePickPoint=g(),this._navigationMode=1,this._sphere=new M,this._pointerCount=0,this._tmpInteractionDirection=g(),this._beginCamera=new Q,this._constraintOptions=new j(15,0,0,this._beginCamera)}get _intersectionHelper(){return this.view.sceneIntersectionHelper}begin(t){if(!this.running)return;this._zoomMomentumEstimator.enabled=this._rotationMomentumEstimator.enabled=this._panPlanarMomentumEstimator.enabled=this._panSphericalMomentumEstimator.enabled=this.view.navigation.momentumEnabled,this._beginHeading=-i.normalize(e(this.view.camera.heading)),this._beginRadius=t.radius,this._beginAngle=t.angle,this._pointerCount=t.pointers.size,this._smoothRotation.reset(),s(t.center,this._screenPickPoint),o(this._beginScreenPoint,this._screenPickPoint);const n=z(this._intersectionHelper,this.startCamera,this._screenPickPoint,P(this.view.spatialReference).radius,1,this.view.basemapTerrain.invisible?F:{});null!=n.scenePickPoint&&(this._scenePickPoint=n.scenePickPoint,this._sphere=n.sphere,m(this._beginScenePoint,this._scenePickPoint),this._navigationMode=H(this.startCamera,this._screenPickPoint,this.view.renderCoordsHelper,this.view.viewingMode),0===this._navigationMode&&this._preparePlanarPanMode(t,n.hasGeometryIntersection),this._beginCamera.copyFrom(this.startCamera))}update(t){if(!this.running)return;this.currentCamera.copyFrom(this.startCamera);const i=t.pointers.size>1;1===this._navigationMode?(i&&this._zoomSpherical(t),this._panningSpherical(t),i&&this._rotateSpherical(t)):(i&&this._zoomPlanar(t),this._panningPlanar(t),i&&this._rotatePlanar(t)),this.commitCamera()}end(t){t.pointers.size===this._pointerCount&&this.update(t),this.finishController();const i=this.view.animationsEnabled&&this._zoomMomentumEstimator.evaluateMomentum();if(i)return 1===this._navigationMode?new k({view:this.view,momentum:i,screenCenter:this._zoomCenterScreen,sceneCenter:this._beginScenePoint,radius:this._sphere.radius}):new R({view:this.view,momentum:i,zoomCenter:this._beginScenePoint});const e=this.view.animationsEnabled&&this._rotationMomentumEstimator.evaluateMomentum();if(e)return new x({view:this.view,momentum:e,center:this._sphere.center,axis:this._rotationAxis});if(1===this._navigationMode){const t=this.view.animationsEnabled&&this._panSphericalMomentumEstimator.evaluateMomentum();if(t)return new O({view:this.view,momentum:t})}else{const t=this.view.animationsEnabled&&this._panPlanarMomentumEstimator.evaluateMomentum();if(t)return new A({view:this.view,momentum:t})}return null}_preparePlanarPanMode(t,i){const e=h(this._tmp3d,this.startCamera.viewForward);w(this._scenePickPoint,e,this._panningPlane);const a=n(this._screenPickPoint[0],0),o=g(),r=c(this.startCamera.eye);this._adjustedSphere.radius=r<this._sphere.radius?r-100:this._sphere.radius,D(this._adjustedSphere,this.startCamera,a,o);const P=g(),v=g(),C=g();_(P,this._scenePickPoint,this.currentCamera.eye);const M=c(P);p(P,P);const S=T*Math.max(Math.abs(this.view.camera.position.z),U),f=this.view.stage.renderView.getMinimalDepthForArea(null,this._screenPickPoint[0],this._screenPickPoint[1],this.view.state.camera,G);let j=null!=f?f:S;i&&(j=Math.min(j,M)),m(C,u(v,this.currentCamera.eye,l(v,P,j))),this._panningPlane[3]=-d(b(this._panningPlane),C),this.startCamera.center=u(v,this.startCamera.eye,l(v,this.startCamera.viewForward,j));const E=s(t.center,this._tmpScreenPointArray);I(this._panningPlane,this.startCamera,E,this._beginScenePoint)}_zoomSpherical(t){const i=this._beginRadius/t.radius,e=.001875*Math.min(Math.max(t.radius,40),120);this._smoothScaling.gain=e,this._smoothScaling.update(i),Z(this._sphere,this.currentCamera,this._smoothScaling.value),s(t.center,this._zoomCenterScreen),this._zoomMomentumEstimator.add(this._smoothScaling.value,.001*t.timestamp),this._constraintOptions.interactionType=1,this._constraintOptions.interactionFactor=S(t.radius-this._beginRadius),f(this.view,this.currentCamera,this._constraintOptions)}_panningSpherical(t){const i=s(t.center,this._tmpScreenPointArray);D(this._sphere,this.currentCamera,i,this._tmp3d),q(this._beginScenePoint,d(this.currentCamera.up,this._beginScenePoint),this._sphere.radius,this._beginHeading,this.view.camera.tilt,this.startCamera.aboveGround)?(V(this._sphere,this.currentCamera,this._beginScenePoint,this._tmp3d,this._beginHeading,this.view.camera.tilt,!1),this._panSphericalMomentumEstimator.addMomentumPreserveHeading(i,this._tmp3d,.001*t.timestamp,this.startCamera,this._sphere,this._beginHeading,this.view.camera.tilt)):(B(this._sphere,this.currentCamera,this._beginScenePoint,this._tmp3d,this.view.camera.tilt,!1),this._panSphericalMomentumEstimator.addMomentumDirectRotation(i,this._tmp3d,.001*t.timestamp,this.startCamera,this._sphere.radius,this.view.camera.tilt)),this._constraintOptions.interactionType=4,this._constraintOptions.interactionFactor=S(r(this._screenPickPoint,i)),f(this.view,this.currentCamera,this._constraintOptions)}_rotateSpherical(t){p(this._rotationAxis,this._scenePickPoint),this.currentCamera.aboveGround||h(this._rotationAxis,this._rotationAxis);const i=this._smoothRotation.value,e=i+J(t.angle-i),n=.00125*Math.min(Math.max(t.radius,40),120);this._smoothRotation.gain=n,this._smoothRotation.update(e);const s=this._smoothRotation.value-this._beginAngle;this._rotationMomentumEstimator.add(s,.001*t.timestamp),K(this.currentCamera,this._sphere.center,v(this._rotationAxis,s)),this._constraintOptions.interactionType=2,this._constraintOptions.interactionFactor=S(t.radius*e),f(this.view,this.currentCamera,this._constraintOptions)}_panningPlanar(t){const i=s(t.center,this._tmpScreenPointArray);I(this._panningPlane,this.currentCamera,i,this._tmp3d)&&(L(this.currentCamera,this._beginScenePoint,this._tmp3d),this._panPlanarMomentumEstimator.add(i,this._tmp3d,.001*t.timestamp),this._constraintOptions.interactionType=4,this._constraintOptions.interactionFactor=S(r(this._beginScreenPoint,i)),this._constraintOptions.interactionDirection=this.view.renderCoordsHelper.worldUpAtPosition(this.currentCamera.eye,this._tmpInteractionDirection),f(this.view,this.currentCamera,this._constraintOptions),this._constraintOptions.interactionDirection=null)}_zoomPlanar(t){const i=this._beginRadius/t.radius,e=.001875*Math.min(Math.max(t.radius,40),120);this._smoothScaling.gain=e,this._smoothScaling.update(i),this._zoomMomentumEstimator.add(this._smoothScaling.value,.001*t.timestamp),N(this.currentCamera,this._beginScenePoint,this._smoothScaling.value,this.view.state.constraints.minimumPoiDistance),this._constraintOptions.interactionType=1,this._constraintOptions.interactionFactor=S(t.radius-this._beginRadius),f(this.view,this.currentCamera,this._constraintOptions)}_rotatePlanar(t){m(this._rotationAxis,this._beginScenePoint),this.currentCamera.aboveGround||h(this._rotationAxis,this._rotationAxis);const i=this._smoothRotation.value;let e=t.angle-i;e=J(e);const n=i+e,s=.00125*Math.min(Math.max(t.radius,40),120);this._smoothRotation.gain=s,this._smoothRotation.update(n);const a=this._smoothRotation.value-this._beginAngle;this._rotationMomentumEstimator.add(a,.001*t.timestamp),K(this.currentCamera,this._sphere.center,v(this._rotationAxis,a)),this._constraintOptions.interactionType=2,this._constraintOptions.interactionFactor=S(t.radius*a),f(this.view,this.currentCamera,this._constraintOptions)}};tt=t([a("esri.views.3d.state.controllers.PinchAndPanControllerGlobal")],tt);export{tt as PinchAndPanControllerGlobal};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import{createScreenPointArray as i,screenPointObjectToArray as e}from"../../../../core/screenUtils.js";import{subclass as n}from"../../../../core/accessorSupport/decorators.js";import{distance as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{q as o,d as a,g as r,e as m,b as h,n as l,j as c,i as p}from"../../../../chunks/vec32.js";import{create as _,fromValues as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{wrapAxisAngle as d}from"../../../../geometry/support/axisAngle.js";import{create as g,fromNormalAndOffset as C,setOffsetFromPoint as v,negate as b,getNormal as w}from"../../../../geometry/support/plane.js";import{pixelDistanceToInteractionFactor as M,applyAll as f}from"../../camera/constraintUtils.js";import{ConstraintOptions as P}from"../../camera/constraintUtils/ConstraintOptions.js";import{ExponentialFalloff as V}from"../../input/util.js";import{getVoxelWasm as z}from"../../layers/VoxelWasm.js";import{InteractiveController as j}from"./InteractiveController.js";import{PanPlanarMomentumController as S}from"./momentum/PanPlanarMomentumController.js";import{RotationMomentumController as E}from"./momentum/RotationMomentumController.js";import{ZoomPlanarMomentumController as H}from"./momentum/ZoomPlanarMomentumController.js";import{excludeTerrain as y,inferNavigationMode as x,getTiltScaleFactor as O,maxPanDistanceModifier as F,minPinchAndPanCameraHeight as R,pivotSearchAreaSize as A,centroid as T,applyZoomToPoint as U,applyPanPlanar as k,normalizeRotationDelta as D,applyRotation as I,intersectPlaneFromScreenPointAtEye as Z}from"../utils/navigationUtils.js";import q from"../../webgl/RenderCamera.js";import{PanPlanarMomentumEstimator as G}from"../../../navigation/PanPlanarMomentumEstimator.js";import{RotationMomentumEstimator as L}from"../../../navigation/RotationMomentumEstimator.js";import{ZoomMomentumEstimator as W}from"../../../navigation/ZoomMomentumEstimator.js";const B=u(0,0,1);let J=class extends j{constructor(){super(...arguments),this._rotationValueSmooth=new V(.05),this._scalingValueSmooth=new V(.05),this._planeHorizontal=g(),this._planeVertical=g(),this._rotationMomentumEstimator=new L,this._panMomentumEstimator=new G(300,12,.9),this._zoomMomentumEstimator=new W,this._beginRadius=0,this._beginCenter=_(),this._beginAngle=0,this._tmpPoints=[],this._navigationMode=1,this._beginCenterScreen=i(),this._tmpCentroid3d=_(),this._tmpCentroid2d=i(),this._tmp2d=i(),this._pointerCount=0,this._beginCamera=new q,this._constraintOptions=new P(15,0,0,this._beginCamera)}begin(t){if(!this.running)return;const i=this.view.navigation.momentumEnabled;this._zoomMomentumEstimator.enabled=i,this._rotationMomentumEstimator.enabled=i,this._panMomentumEstimator.enabled=i,this._beginRadius=t.radius,this._pointerCount=t.pointers.size,this._beginAngle=t.angle,this._rotationValueSmooth.reset(),this._scalingValueSmooth.reset(),e(t.center,this._beginCenterScreen),C(B,0,this._planeHorizontal);const n=_(),s=this._intersectionHelper.intersectScreenFreePointFallback(this._beginCenterScreen,n,this.view.basemapTerrain.invisible?y:{}),u=_();o(u,this.startCamera.viewForward);const d=_();a(d,B);const g=r(u,d);this._navigationMode=x(this.startCamera,this._beginCenterScreen,this.view.renderCoordsHelper,this.view.viewingMode);const M=O(d,this.startCamera.viewForward,F)*Math.max(Math.abs(this.view.camera.position.z),R);v(this._planeHorizontal,this._planeHorizontal,n),this.startCamera.aboveGround||b(this._planeHorizontal,this._planeHorizontal);const f=_(),P=_(),V=_();m(f,n,this.currentCamera.eye);const j=h(f);if(l(f,f),0===this._navigationMode){c(d,d,g),m(w(this._planeVertical),u,d),l(w(this._planeVertical),w(this._planeVertical)),v(this._planeVertical,this._planeVertical,n);const i=this.view.stage.renderView.getMinimalDepthForArea(z(this.view),this._beginCenterScreen[0],this._beginCenterScreen[1],this.view.state.camera,A);let e=null!=i?i:M;s&&(e=Math.min(e,j)),a(V,p(P,this.currentCamera.eye,c(P,f,e))),this._planeVertical[3]=-r(w(this._planeVertical),V),this._computePlanePoints(t.pointers,this._planeVertical,this.startCamera,this._tmpPoints),T(this._tmpPoints,this._beginCenter)}else{const i=s?j:M;a(V,p(P,this.currentCamera.eye,c(P,f,i))),this._planeHorizontal[3]=-r(w(this._planeHorizontal),V),this._computePlanePoints(t.pointers,this._planeHorizontal,this.startCamera,this._tmpPoints),T(this._tmpPoints,this._beginCenter)}this._beginCamera.copyFrom(this.startCamera)}update(t){if(!this.running)return;this.currentCamera.copyFrom(this.startCamera);const i=t.pointers.size>1,n=1===this._navigationMode?this._planeHorizontal:this._planeVertical,o=this._beginCenter;if(i){const i=this._beginRadius/t.radius,e=.001875*Math.min(Math.max(t.radius,40),120);this._scalingValueSmooth.gain=e,this._scalingValueSmooth.update(i),U(this.currentCamera,o,this._scalingValueSmooth.value,this.view.state.constraints.minimumPoiDistance),this._zoomMomentumEstimator.add(this._scalingValueSmooth.value,.001*t.timestamp),this._constraintOptions.interactionType=1,this._constraintOptions.interactionFactor=M(Math.abs(t.radius-this._beginRadius)),f(this.view,this.currentCamera,this._constraintOptions)}if(this._computePlanePoints(t.pointers,n,this.currentCamera,this._tmpPoints),T(this._tmpPoints,this._tmpCentroid3d),e(t.center,this._tmpCentroid2d),k(this.currentCamera,o,this._tmpCentroid3d),this._panMomentumEstimator.add(this._tmpCentroid2d,this._tmpCentroid3d,.001*t.timestamp),this._constraintOptions.interactionType=4,this._constraintOptions.interactionFactor=M(s(this._beginCenterScreen,this._tmpCentroid2d)),f(this.view,this.currentCamera,this._constraintOptions),i){const i=o,e=this._rotationValueSmooth.value,n=e+D(t.angle-e),s=.00125*Math.min(Math.max(t.radius,40),120);this._rotationValueSmooth.gain=s,this._rotationValueSmooth.update(n);const a=this._rotationValueSmooth.value-this._beginAngle;this._rotationMomentumEstimator.add(a,.001*t.timestamp);const r=w(this._planeHorizontal);I(this.currentCamera,i,d(r,a)),this._constraintOptions.interactionType=2,this._constraintOptions.interactionFactor=M(Math.abs(t.radius*a)),f(this.view,this.currentCamera,this._constraintOptions)}this.commitCamera()}end(t){t.pointers.size===this._pointerCount&&this.update(t),this.finishController();const i=this._zoomMomentumEstimator.evaluateMomentum();if(i)return new H({view:this.view,momentum:i,zoomCenter:this._beginCenter});const e=this._rotationMomentumEstimator.evaluateMomentum();if(e)return new E({view:this.view,momentum:e,center:this._beginCenter,axis:w(this._planeHorizontal)});const n=this._panMomentumEstimator.evaluateMomentum();return n?new S({view:this.view,momentum:n}):null}_computePlanePoints(t,i,e,n){n.length=t.size;const s=this._tmp2d;let o=0;return t.forEach(t=>{s[0]=t.x,s[1]=t.y,void 0===n[o]&&(n[o]=_()),Z(i,e,s,n[o]),o+=1}),n}get _intersectionHelper(){return this.view.sceneIntersectionHelper}};J=t([n("esri.views.3d.state.controllers.PinchAndPanControllerLocal")],J);export{J as PinchAndPanControllerLocal};
|
|
5
|
+
import{__decorate as t}from"tslib";import{createScreenPointArray as i,screenPointObjectToArray as e}from"../../../../core/screenUtils.js";import{subclass as n}from"../../../../core/accessorSupport/decorators.js";import{distance as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{q as o,d as a,g as r,e as m,b as h,n as l,j as c,i as p}from"../../../../chunks/vec32.js";import{create as _,fromValues as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{wrapAxisAngle as d}from"../../../../geometry/support/axisAngle.js";import{create as g,fromNormalAndOffset as C,setOffsetFromPoint as v,negate as b,getNormal as w}from"../../../../geometry/support/plane.js";import{pixelDistanceToInteractionFactor as M,applyAll as f}from"../../camera/constraintUtils.js";import{ConstraintOptions as P}from"../../camera/constraintUtils/ConstraintOptions.js";import{ExponentialFalloff as V}from"../../input/util.js";import{getVoxelWasm as z}from"../../layers/VoxelWasm.js";import{InteractiveController as j}from"./InteractiveController.js";import{PanPlanarMomentumController as S}from"./momentum/PanPlanarMomentumController.js";import{RotationMomentumController as E}from"./momentum/RotationMomentumController.js";import{ZoomPlanarMomentumController as H}from"./momentum/ZoomPlanarMomentumController.js";import{excludeTerrain as y,inferNavigationMode as x,getTiltScaleFactor as O,maxPanDistanceModifier as F,minPinchAndPanCameraHeight as R,pivotSearchAreaSize as A,centroid as T,applyZoomToPoint as U,applyPanPlanar as k,normalizeRotationDelta as D,applyRotation as I,intersectPlaneFromScreenPointAtEye as Z}from"../utils/navigationUtils.js";import q from"../../webgl/RenderCamera.js";import{PanPlanarMomentumEstimator as G}from"../../../navigation/PanPlanarMomentumEstimator.js";import{RotationMomentumEstimator as L}from"../../../navigation/RotationMomentumEstimator.js";import{ZoomMomentumEstimator as W}from"../../../navigation/ZoomMomentumEstimator.js";const B=u(0,0,1);let J=class extends j{constructor(){super(...arguments),this._rotationValueSmooth=new V(.05),this._scalingValueSmooth=new V(.05),this._planeHorizontal=g(),this._planeVertical=g(),this._rotationMomentumEstimator=new L,this._panMomentumEstimator=new G(300,12,.9),this._zoomMomentumEstimator=new W,this._beginRadius=0,this._beginCenter=_(),this._beginAngle=0,this._tmpPoints=[],this._navigationMode=1,this._beginCenterScreen=i(),this._tmpCentroid3d=_(),this._tmpCentroid2d=i(),this._tmp2d=i(),this._pointerCount=0,this._beginCamera=new q,this._constraintOptions=new P(15,0,0,this._beginCamera)}begin(t){if(!this.running)return;const i=this.view.navigation.momentumEnabled;this._zoomMomentumEstimator.enabled=i,this._rotationMomentumEstimator.enabled=i,this._panMomentumEstimator.enabled=i,this._beginRadius=t.radius,this._pointerCount=t.pointers.size,this._beginAngle=t.angle,this._rotationValueSmooth.reset(),this._scalingValueSmooth.reset(),e(t.center,this._beginCenterScreen),C(B,0,this._planeHorizontal);const n=_(),s=this._intersectionHelper.intersectScreenFreePointFallback(this._beginCenterScreen,n,this.view.basemapTerrain.invisible?y:{}),u=_();o(u,this.startCamera.viewForward);const d=_();a(d,B);const g=r(u,d);this._navigationMode=x(this.startCamera,this._beginCenterScreen,this.view.renderCoordsHelper,this.view.viewingMode);const M=O(d,this.startCamera.viewForward,F)*Math.max(Math.abs(this.view.camera.position.z),R);v(this._planeHorizontal,this._planeHorizontal,n),this.startCamera.aboveGround||b(this._planeHorizontal,this._planeHorizontal);const f=_(),P=_(),V=_();m(f,n,this.currentCamera.eye);const j=h(f);if(l(f,f),0===this._navigationMode){c(d,d,g),m(w(this._planeVertical),u,d),l(w(this._planeVertical),w(this._planeVertical)),v(this._planeVertical,this._planeVertical,n);const i=this.view.stage.renderView.getMinimalDepthForArea(z(this.view),this._beginCenterScreen[0],this._beginCenterScreen[1],this.view.state.camera,A);let e=null!=i?i:M;s&&(e=Math.min(e,j)),a(V,p(P,this.currentCamera.eye,c(P,f,e))),this._planeVertical[3]=-r(w(this._planeVertical),V),this._computePlanePoints(t.pointers,this._planeVertical,this.startCamera,this._tmpPoints),T(this._tmpPoints,this._beginCenter)}else{const i=s?j:M;a(V,p(P,this.currentCamera.eye,c(P,f,i))),this._planeHorizontal[3]=-r(w(this._planeHorizontal),V),this._computePlanePoints(t.pointers,this._planeHorizontal,this.startCamera,this._tmpPoints),T(this._tmpPoints,this._beginCenter)}this._beginCamera.copyFrom(this.startCamera)}update(t){if(!this.running)return;this.currentCamera.copyFrom(this.startCamera);const i=t.pointers.size>1,n=1===this._navigationMode?this._planeHorizontal:this._planeVertical,o=this._beginCenter;if(i){const i=this._beginRadius/t.radius,e=.001875*Math.min(Math.max(t.radius,40),120);this._scalingValueSmooth.gain=e,this._scalingValueSmooth.update(i),U(this.currentCamera,o,this._scalingValueSmooth.value,this.view.state.constraints.minimumPoiDistance),this._zoomMomentumEstimator.add(this._scalingValueSmooth.value,.001*t.timestamp),this._constraintOptions.interactionType=1,this._constraintOptions.interactionFactor=M(Math.abs(t.radius-this._beginRadius)),f(this.view,this.currentCamera,this._constraintOptions)}if(this._computePlanePoints(t.pointers,n,this.currentCamera,this._tmpPoints),T(this._tmpPoints,this._tmpCentroid3d),e(t.center,this._tmpCentroid2d),k(this.currentCamera,o,this._tmpCentroid3d),this._panMomentumEstimator.add(this._tmpCentroid2d,this._tmpCentroid3d,.001*t.timestamp),this._constraintOptions.interactionType=4,this._constraintOptions.interactionFactor=M(s(this._beginCenterScreen,this._tmpCentroid2d)),f(this.view,this.currentCamera,this._constraintOptions),i){const i=o,e=this._rotationValueSmooth.value,n=e+D(t.angle-e),s=.00125*Math.min(Math.max(t.radius,40),120);this._rotationValueSmooth.gain=s,this._rotationValueSmooth.update(n);const a=this._rotationValueSmooth.value-this._beginAngle;this._rotationMomentumEstimator.add(a,.001*t.timestamp);const r=w(this._planeHorizontal);I(this.currentCamera,i,d(r,a)),this._constraintOptions.interactionType=2,this._constraintOptions.interactionFactor=M(Math.abs(t.radius*a)),f(this.view,this.currentCamera,this._constraintOptions)}this.commitCamera()}end(t){t.pointers.size===this._pointerCount&&this.update(t),this.finishController();const i=this.view.animationsEnabled&&this._zoomMomentumEstimator.evaluateMomentum();if(i)return new H({view:this.view,momentum:i,zoomCenter:this._beginCenter});const e=this.view.animationsEnabled&&this._rotationMomentumEstimator.evaluateMomentum();if(e)return new E({view:this.view,momentum:e,center:this._beginCenter,axis:w(this._planeHorizontal)});const n=this.view.animationsEnabled&&this._panMomentumEstimator.evaluateMomentum();return n?new S({view:this.view,momentum:n}):null}_computePlanePoints(t,i,e,n){n.length=t.size;const s=this._tmp2d;let o=0;return t.forEach(t=>{s[0]=t.x,s[1]=t.y,void 0===n[o]&&(n[o]=_()),Z(i,e,s,n[o]),o+=1}),n}get _intersectionHelper(){return this.view.sceneIntersectionHelper}};J=t([n("esri.views.3d.state.controllers.PinchAndPanControllerLocal")],J);export{J as PinchAndPanControllerLocal};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"../../../core/has.js";import{Milliseconds as e}from"../../../core/time.js";function a(e){return t[e]}function
|
|
5
|
+
import has from"../../../core/has.js";import{Milliseconds as e}from"../../../core/time.js";function a(e){return t[e]}function o(){return has("esri-iPhone")?"low":"medium"}const i={reset(){const e=r();for(const a of Object.keys(e))t[a]=e[a]}},l={IPhone12Pro:120,GalaxyS20:200,FullHD:240,SurfacePro7:300,FullHDRetina:430},t=r();function r(){const a=!!has("esri-mobile"),o=!!has("ios"),i=e(400);return{low:{graphics3D:{maxTotalNumberOfFeatures:5e4,maxNumberOfDrawCalls:8e3,maxTotalNumberOfVertices:255e4,polygonLodFactor:.5,polylineLodFactor:1,snapshotAvailable:!1,skipHighSymbolLods:!0},heatmap:{pixelRatio:.125},sceneService:{objectLoDFactor:.2,pointLoDFactor:1,meshLoDFactor:.6,pointCloudLoDFactor:.5},gaussianSplat:{minimumSplatPixelRadius:2,minimumOpacity:0,maxAllowedVisibleGaussians:4e6},flow:{maxTotalNumberOfStreamlines:25e3,maxTracingResolution:1024},tiledSurface:{lodBias:-1,angledSplitBias:.5,vtlContentZoom:.75,elevationLevelDelta:3,reduceTileLevelDifferences:!0},fadeDuration:e(0),physicallyBasedRenderingEnabled:!1,maxTexturePixels:a?1048576:4194304,memoryLimit:200+l.IPhone12Pro,additionalCacheMemory:0,frameRate:0,maximumPixelRatio:1},medium:{graphics3D:{maxTotalNumberOfFeatures:15e4,maxNumberOfDrawCalls:17e3,maxTotalNumberOfVertices:625e4,polygonLodFactor:a?.8:1,polylineLodFactor:a?1.2:1.5,snapshotAvailable:!o,skipHighSymbolLods:!1},heatmap:{pixelRatio:.25},sceneService:{objectLoDFactor:1,pointLoDFactor:1,meshLoDFactor:1,pointCloudLoDFactor:1},gaussianSplat:{minimumSplatPixelRadius:1,minimumOpacity:1,maxAllowedVisibleGaussians:8e6},flow:{maxTotalNumberOfStreamlines:1e5,maxTracingResolution:2048},tiledSurface:{lodBias:0,angledSplitBias:1,vtlContentZoom:1.5,elevationLevelDelta:3,reduceTileLevelDifferences:!0},fadeDuration:i,physicallyBasedRenderingEnabled:!0,maxTexturePixels:a?4194304:4096**2,memoryLimit:a?600+l.GalaxyS20:750+l.FullHD,additionalCacheMemory:a?-100:150,frameRate:0,maximumPixelRatio:1},high:{graphics3D:{maxTotalNumberOfFeatures:3e5,maxNumberOfDrawCalls:17e3,maxTotalNumberOfVertices:125e5,polygonLodFactor:a?1.2:2,polylineLodFactor:a?1.2:2,snapshotAvailable:!o,skipHighSymbolLods:!1},heatmap:{pixelRatio:.5},sceneService:{objectLoDFactor:1,pointLoDFactor:1,meshLoDFactor:1,pointCloudLoDFactor:1},gaussianSplat:{minimumSplatPixelRadius:.5,minimumOpacity:2,maxAllowedVisibleGaussians:16e6},flow:{maxTotalNumberOfStreamlines:1e5,maxTracingResolution:2048},tiledSurface:{lodBias:0,angledSplitBias:1,vtlContentZoom:1.5,elevationLevelDelta:2,reduceTileLevelDifferences:!0},fadeDuration:i,physicallyBasedRenderingEnabled:!0,maxTexturePixels:a?4096**2:1/0,memoryLimit:a?900+l.SurfacePro7:1500+l.FullHDRetina,additionalCacheMemory:a?-150:0,frameRate:0,maximumPixelRatio:a?1:1/0}}}export{i as QualityProfileTest,o as getDefaultQualityProfileName,a as getQualityProfileSettings};
|