@arcgis/core 4.24.1 → 4.24.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/config.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import"./core/has.js";import{deepMerge as e}from"./core/object.js";const r={apiKey:void 0,applicationUrl:globalThis.location?.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",portalUrl:"https://www.arcgis.com",routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{crossOriginNoCorsDomains:null,httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],maxUrlLength:2e3,priority:"high",proxyRules:[],proxyUrl:null,timeout:6e4,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(r,globalThis.esriConfig,!0),delete r.has),!r.assetsPath){const e="4.24.1";r.assetsPath=`https://js.arcgis.com/${e.slice(0,-2)}/@arcgis/core/assets`}r.baseUrl&&console.warn("[esri.config]","baseUrl has been replaced by assetsPath"),Object.defineProperty(r,"baseUrl",{set(){console.warn("[esri.config]","baseUrl has been replaced by assetsPath")}}),r.request.corsEnabledServers=[],r.request.corsEnabledServers.push=function(){return console.warn("[esri.config]","request.corsEnabledServers is not supported and will be removed in a future release. See http://esriurl.com/cors8664"),0};export{r as default};
5
+ import"./core/has.js";import{deepMerge as e}from"./core/object.js";const r={apiKey:void 0,applicationUrl:globalThis.location?.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",portalUrl:"https://www.arcgis.com",routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{crossOriginNoCorsDomains:null,httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],maxUrlLength:2e3,priority:"high",proxyRules:[],proxyUrl:null,timeout:6e4,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(r,globalThis.esriConfig,!0),delete r.has),!r.assetsPath){const e="4.24.2";r.assetsPath=`https://js.arcgis.com/${e.slice(0,-2)}/@arcgis/core/assets`}r.baseUrl&&console.warn("[esri.config]","baseUrl has been replaced by assetsPath"),Object.defineProperty(r,"baseUrl",{set(){console.warn("[esri.config]","baseUrl has been replaced by assetsPath")}}),r.request.corsEnabledServers=[],r.request.corsEnabledServers.push=function(){return console.warn("[esri.config]","request.corsEnabledServers is not supported and will be removed in a future release. See http://esriurl.com/cors8664"),0};export{r as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.24.1",
3
+ "version": "4.24.2",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS API for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- const b="20220623",c="8e53b079c0bc89b3df424a4c52ba69e6403a5507";export{b as buildDate,c as commitHash};
5
+ const b="20220624",c="7915c1c020ba03688ff44b4994b3ae7405550d5d";export{b as buildDate,c as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../analysis/SlicePlane.js";import{clock as i}from"../../../../core/clock.js";import a from"../../../../core/Handles.js";import{releaseMaybe as s,destroyMaybe as n,isSome as r,isNone as l,removeMaybe as o}from"../../../../core/maybe.js";import{watch as h,sync as p,syncAndInitial as u}from"../../../../core/reactiveUtils.js";import{addFrameTask as c}from"../../../../core/scheduling.js";import{createScreenPoint as d,screenPointObjectToArray as _,createScreenPointArray as v}from"../../../../core/screenUtils.js";import{property as P}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as y}from"../../../../core/accessorSupport/decorators/subclass.js";import{d as m,u as g,m as w}from"../../../../chunks/mat4.js";import{e as f,l as M,c as D,g as T,a as V,m as b,n as k,s as E}from"../../../../chunks/vec3.js";import{a as S,c as H}from"../../../../chunks/vec3f64.js";import{c as x,a as I,n as R,f as j}from"../../../../chunks/boundedPlane.js";import{signedDistance as O,create as C,intersectRay as z,normal as G}from"../../../../geometry/support/plane.js";import{create as U}from"../../../../geometry/support/ray.js";import{sv3d as L,sm4d as K,sv2d as A}from"../../../../geometry/support/vectorStacks.js";import{POINTER_MOVE_TIMER_MS as B,PLANE_PREVIEW_OUTLINE_WIDTH as F,forceVerticalModifier as N,forceHorizontalModifier as q,PREVIEW_FADE_DURATION_SECONDS as Z,PLANE_OUTLINE_COLOR as J,PLANE_BACKGROUND_COLOR as Q,PREVIEW_FADE_DOT_THRESHOLD as W,INITIAL_DEPTH_OFFSET_FRAC as X}from"./sliceToolConfig.js";import{createShiftManipulator as Y,createRotateManipulator as $,createResizeManipulator as tt,createGridVisualElement as et,createOutlineVisualElement as it,planeToShape as at,createRotatePlane as st,RotationAxis as nt,resizePlane as rt,calculatePlaneHalfSize as lt,SliceOrientation as ot,createPlane as ht,DidPointerMoveRecentlyFlag as pt,calculateBoundedPlaneTranslateRotate as ut,updateShiftRestartHandle as ct,updateRotateHeadingHandle as dt,updateRotateTiltHandle as _t,updateResizeHandle as vt,createShiftPlane as Pt}from"./sliceToolUtils.js";import{getRotateHeadingTexture as yt,getTiltRotateTexture as mt}from"./images/Factory.js";import{calculateInputRotationTransform as gt}from"../../interactive/manipulatorUtils.js";import{screenToRenderPlane as wt}from"../../interactive/editingTools/dragEventPipeline3D.js";import{fromScreen as ft}from"../../support/geometryUtils/ray.js";import{newIntersector as Mt}from"../../webgl-engine/lib/Intersector.js";import{StoreResults as Dt}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{AnalysisToolBase as Tt}from"../../../interactive/AnalysisToolBase.js";import{createManipulatorDragEventPipeline as Vt}from"../../../interactive/dragEventPipeline.js";import{createScreenPointFromEvent as bt}from"../../../support/screenUtils.js";var kt;let Et=kt=class extends Tt{constructor(t){super(t),this.clock=i,this._previewPlaneOpacity=1,this.removeIncompleteOnCancel=!1,this.layersMode="none",this.shiftManipulator=null,this.rotateHeadingManipulator=null,this.rotateTiltManipulator=null,this.resizeManipulators=null,this._handles=new a,this._viewHandles=new a,this._frameTask=null,this._pointerMoveTimerMs=B,this._prevPointerMoveTimeout=null,this._previewPlaneGridVisualElement=null,this._previewPlaneOutlineVisualElement=null,this._startPlane=x(),this._previewPlane=null,this._activeKeyModifiers={},this._lastCursorPosition=d(),this._resizeHandles=[{direction:[1,0]},{direction:[1,1]},{direction:[0,1]},{direction:[-1,1]},{direction:[-1,0]},{direction:[-1,-1]},{direction:[0,-1]},{direction:[1,-1]}],this._intersector=Mt(t.view.state.viewingMode),this._intersector.options.store=Dt.MIN}initialize(){if(null==this.analysis)throw new Error("SliceTool requires valid analysis, but null was provided.");this.rotateHeadingImage=yt(this.view.toolViewManager.textures),this.rotateTiltImage=mt(this.view.toolViewManager.textures);const t=t=>{this._updateManipulatorsInteractive(t),t.grabbing||(r(this.analysisViewData.plane)&&I(this.analysisViewData.plane,this._startPlane),this.inputState=null)};this.shiftManipulator=Y(this.view),this.manipulators.add(this.shiftManipulator),this.shiftManipulator.events.on("grab-changed",(e=>{this._onShiftGrab(e),t(this.shiftManipulator)})),this._handles.add(this._createShiftDragPipeline(this.shiftManipulator)),this.rotateHeadingManipulator=$(this.view,this.rotateHeadingImage.texture),this.manipulators.add(this.rotateHeadingManipulator),this.rotateHeadingManipulator.events.on("grab-changed",(e=>{this._onRotateHeadingGrab(e),t(this.rotateHeadingManipulator)})),this._handles.add(this._createRotateHeadingDragPipeline(this.rotateHeadingManipulator)),this.rotateTiltManipulator=$(this.view,this.rotateTiltImage.texture),this.manipulators.add(this.rotateTiltManipulator),this.rotateTiltManipulator.events.on("grab-changed",(e=>{this._onRotateTiltGrab(e),t(this.rotateTiltManipulator)})),this._handles.add(this._createRotateTiltDragPipeline(this.rotateTiltManipulator)),this.resizeManipulators=this._resizeHandles.map(((e,i)=>{const a=tt(this.view,e);return a.events.on("grab-changed",(e=>{this._onResizeGrab(e,i),t(a)})),this._handles.add(this._createResizeDragPipeline(a)),a})),this.manipulators.addMany(this.resizeManipulators),this._previewPlaneGridVisualElement=et(this.view),this._previewPlaneOutlineVisualElement=it(this.view),this._previewPlaneOutlineVisualElement.width=F,this._handles.add(h((()=>this.analysisViewData.plane),(()=>this._updateManipulators()),p));const e=h((()=>this.state),(t=>{"sliced"===t&&this.finishToolCreation()}),u);this._handles.add([e,h((()=>this.view.state.camera),(()=>this._onCameraChange()))])}destroy(){this.rotateHeadingImage=s(this.rotateHeadingImage),this.rotateTiltImage=s(this.rotateTiltImage),this._handles=n(this._handles),this._viewHandles=n(this._viewHandles),this._removeFrameTask(),this._clearPointerMoveTimeout(),this._previewPlaneOutlineVisualElement=n(this._previewPlaneOutlineVisualElement),this._previewPlaneGridVisualElement=n(this._previewPlaneGridVisualElement)}get state(){const t=!!this.analysisViewData.plane,e=!!this.inputState;return t?t&&e?"slicing":t&&!e?"sliced":"ready":"ready"}get cursor(){return this._isPlacingSlicePlane||"exclude"===this.layersMode?"crosshair":r(this._creatingPointerId)?"grabbing":null}set analysis(t){if(null==t)throw new Error("SliceTool requires valid analysis, but null was provided.");this._handles.remove("analysis"),this._set("analysis",t)}get inputState(){return this._get("inputState")}set inputState(t){this._set("inputState",t),this.analysisViewData.showGrid=r(t)&&"resize"===t.type,this._updateMaterials()}get _isPlacingSlicePlane(){return!this.inputState&&!this.analysisViewData.plane&&this.active}get _creatingPointerId(){return r(this.inputState)&&"shift"===this.inputState.type?this.inputState.creatingPointerId:null}enterExcludeLayerMode(){l(this.analysisViewData.plane)||(this._set("layersMode","exclude"),this.active||(this.view.activeTool=this))}exitExcludeLayerMode(){l(this.analysisViewData.plane)||(this._set("layersMode","none"),this.active&&(this.view.activeTool=null))}onDeactivate(){this._set("layersMode","none"),this._updatePreviewPlane(null)}onShow(){this._updateVisibility(!0)}onHide(){this._updateVisibility(!1)}_updateVisibility(t){this.shiftManipulator&&(this._updateManipulators(),t||this._clearPointerMoveTimeout())}onInputEvent(t){switch(t.type){case"pointer-drag":if(!Ht(t))return;this._isPlacingSlicePlane?this._onClickPlacePlane(t)&&t.stopPropagation():this._onPointerDrag(t)&&t.stopPropagation();break;case"pointer-move":this._onPointerMove(t);break;case"pointer-up":this._onPointerUp(t)&&t.stopPropagation();break;case"immediate-click":if(!Ht(t))return;this._onClickPlacePlane(t)&&t.stopPropagation();break;case"click":if(!Ht(t))return;this._onClickExcludeLayer(t)&&t.stopPropagation();break;case"drag":this.inputState&&t.stopPropagation();break;case"key-down":this._onKeyDown(t)&&t.stopPropagation();break;case"key-up":this._onKeyUp(t)&&t.stopPropagation()}}onEditableChange(){this.analysisViewData.editable=this.editable}_onPointerDrag(t){const e=this.inputState;if(t.pointerId===this._creatingPointerId&&r(e)&&"shift"===e.type){const i=bt(t);return this.shiftManipulator.events.emit("drag",{action:e.hasBeenDragged?"update":"start",pointerType:t.pointerType,start:i,screenPoint:i}),e.hasBeenDragged=!0,!0}return!1}_onPointerMove(t){this._lastCursorPosition.x=t.x,this._lastCursorPosition.y=t.y,this._resetPointerMoveTimeout(),"touch"!==t.pointerType&&this._updatePreviewPlane(bt(t),this._activeKeyModifiers)}_onCameraChange(){this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),this._updateManipulators()}_onPointerUp(t){if(t.pointerId===this._creatingPointerId&&r(this.analysisViewData.plane)){const e=bt(t);return this.shiftManipulator.events.emit("drag",{action:"end",start:e,screenPoint:e}),I(this.analysisViewData.plane,this._startPlane),this.inputState=null,!0}return!1}_onClickPlacePlane(t){if("exclude"===this.layersMode)return!1;if(this._isPlacingSlicePlane){const i=bt(t),a=x();if(this._pickPlane(i,!1,this._activeKeyModifiers,a)){if(I(a,this._startPlane),this.analysis.shape=at(a,this.view,this.view.spatialReference,new e),"pointer-drag"===t.type){const e=this._calculatePickRay(i);this.inputState=St(e,t.pointerId,a.origin,a)}return!0}}return!1}_onClickExcludeLayer(t){return!("exclude"!==this.layersMode||!this.created)&&(this.view.hitTest(bt(t)).then((t=>{if(t.results.length){const e=t.results[0],i="graphic"===e?.type&&e.graphic;if(i){const t=i.sourceLayer||i.layer;t&&this.analysis.excludedLayers.push(t)}}else t.ground.layer?this.analysis.excludedLayers.push(t.ground.layer):this.analysis.excludeGroundSurface=!0})),this._set("layersMode","none"),this.active&&(this.view.activeTool=null),!0)}_onKeyDown(t){return(t.key===N||t.key===q)&&(this._activeKeyModifiers[t.key]=!0,r(this._previewPlane)&&this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),!0)}_onKeyUp(t){return!(t.key!==N&&t.key!==q||!this._activeKeyModifiers[t.key])&&(delete this._activeKeyModifiers[t.key],r(this._previewPlane)&&this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),!0)}_onShiftGrab(t){if("start"!==t.action||l(this.analysisViewData.plane))return;const e=this._calculatePickRay(t.screenPoint);I(this.analysisViewData.plane,this._startPlane),this.inputState=St(e,null,this.shiftManipulator.renderLocation,this.analysisViewData.plane)}_createShiftDragPipeline(t){return Vt(t,((t,e,i)=>{const a=this.inputState;if(l(a)||"shift"!==a.type)return;const s=r(this.analysisViewData.plane)?I(this.analysisViewData.plane,x()):null;e.next(wt(this.view,a.shiftPlane)).next(this._shiftDragAdjustSensitivity(a)).next(this._shiftDragUpdatePlane(a)),i.next((()=>{r(s)&&this._updateBoundedPlane(s)}))}))}_shiftDragAdjustSensitivity(t){return e=>{if(l(this.analysisViewData.plane))return null;const i=.001,a=Math.min((1-Math.abs(f(R(this.analysisViewData.plane),e.ray.direction)/M(e.ray.direction)))/i,1),s=-O(this._startPlane.plane,e.renderEnd),n=-O(this._startPlane.plane,t.startPoint);return t.depth=t.depth*(1-a)+s*a-n,e}}_shiftDragUpdatePlane(t){return()=>{if(l(this.analysisViewData.plane))return;const e=D(L.get(),this._startPlane.origin),i=D(L.get(),R(this._startPlane));T(i,i,-t.depth),V(i,i,e);const a=j(i,this.analysisViewData.plane.basis1,this.analysisViewData.plane.basis2,x());this._updateBoundedPlane(a)}}_onRotateHeadingGrab(t){if("start"!==t.action||l(this.analysisViewData.plane))return;const e=st(this.analysisViewData.plane,this.view.renderCoordsHelper,nt.HEADING,C()),i=this._calculatePickRay(t.screenPoint),a=H();z(e,i,a)&&(I(this.analysisViewData.plane,this._startPlane),this.inputState={type:"rotate",rotatePlane:e,startPoint:a})}_createRotateHeadingDragPipeline(t){return Vt(t,((t,e,i)=>{const a=this.inputState;if(l(a)||"rotate"!==a.type)return;const s=r(this.analysisViewData.plane)?I(this.analysisViewData.plane,x()):null;e.next(wt(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdatePlaneFromRotate()),i.next((()=>{r(s)&&this._updateBoundedPlane(s)}))}))}_onRotateTiltGrab(t){if("start"!==t.action||l(this.analysisViewData.plane))return;const e=st(this.analysisViewData.plane,this.view.renderCoordsHelper,nt.TILT,C()),i=this._calculatePickRay(t.screenPoint),a=H();z(e,i,a)&&(I(this.analysisViewData.plane,this._startPlane),this.inputState={type:"rotate",rotatePlane:e,startPoint:a})}_createRotateTiltDragPipeline(t){return Vt(t,((t,e,i)=>{const a=this.inputState;if(l(a)||"rotate"!==a.type)return;const s=r(this.analysisViewData.plane)?I(this.analysisViewData.plane,x()):null;e.next(wt(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdatePlaneFromRotate()),i.next((()=>{r(s)&&this._updateBoundedPlane(s)}))}))}_rotateDragRenderPlaneToRotate(t){return e=>{if(l(this.analysisViewData.plane))return null;const i=G(t.rotatePlane),a=gt(t.startPoint,e.renderEnd,this.analysisViewData.plane.origin,i);return{...e,rotateAxis:i,rotateAngle:a}}}_rotateDragUpdatePlaneFromRotate(){return t=>{if(l(this.analysisViewData.plane))return;const e=m(K.get(),t.rotateAngle,t.rotateAxis),i=b(L.get(),this._startPlane.basis1,e),a=b(L.get(),this._startPlane.basis2,e),s=j(this.analysisViewData.plane.origin,i,a,x());this._updateBoundedPlane(s)}}_onResizeGrab(t,e){if("start"!==t.action||l(this.analysisViewData.plane))return;const i=this._calculatePickRay(t.screenPoint),a=L.get();z(this.analysisViewData.plane.plane,i,a)&&(I(this.analysisViewData.plane,this._startPlane),this.inputState={type:"resize",activeHandleIdx:e,startPoint:S(a)})}_createResizeDragPipeline(t){return Vt(t,((t,e,i)=>{const a=this.inputState;if(l(a)||"resize"!==a.type||l(this.analysisViewData.plane))return;const s=I(this.analysisViewData.plane,x());e.next(wt(this.view,this.analysisViewData.plane.plane)).next(this._resizeDragUpdatePlane(a)),i.next((()=>{this._updateBoundedPlane(s)}))}))}_resizeDragUpdatePlane(t){return e=>{if(l(this.analysisViewData.plane))return;const i=this._resizeHandles[t.activeHandleIdx],a=rt(i,t.startPoint,e.renderEnd,this.view.state.camera,this._startPlane,I(this.analysisViewData.plane));this._updateBoundedPlane(a)}}_updateBoundedPlane(t){const e=this.analysisViewData;if(!r(e))throw new Error("valid internal object expected");e.plane=t}_updatePreviewPlane(t,e={}){let i=this._previewPlane;if(this._previewPlane=null,l(t))return this._removeFrameTask(),void this._updateManipulators();if(!this.analysisViewData.plane&&this.active){const a=r(i)?i:x();if(i=r(i)?I(i,xt):null,this._pickPlane(t,!0,e,a)){const t=W;let e=!1;r(i)&&(e=f(i.plane,a.plane)<t||f(k(L.get(),i.basis1),k(L.get(),a.basis1))<t),e&&(this._previewPlaneOpacity=0),this._previewPlane=a}}r(this._previewPlane)&&l(this._frameTask)&&0===this._previewPlaneOpacity?this._frameTask=c({update:({deltaTime:t})=>{this._previewPlaneOpacity=Math.min(this._previewPlaneOpacity+t/(1e3*Z),1),this._updateManipulators(),1===this._previewPlaneOpacity&&this._removeFrameTask()}}):l(this._previewPlane)&&r(this._frameTask)?this._removeFrameTask():r(this._previewPlane)&&this._updateManipulators()}_removeFrameTask(){this._frameTask=o(this._frameTask)}_calculatePickRay(t){const e=U(),i=_(t,It);return ft(this.view.state.camera,i,e),k(e.direction,e.direction),e}_pickMinResult(t){const e=_(t,A.get());return this.view.sceneIntersectionHelper.intersectToolIntersectorScreen(e,this._intersector),this._intersector.results.min}_pickPlane(t,e,i,a){const s=this._pickMinResult(t),n=L.get();if(!s.getIntersectionPoint(n))return!1;const r=s.getTransformedNormal(L.get()),l=this.view.state.camera;f(r,l.viewForward)>0&&T(r,r,-1);const o=lt(n,l),h=(e?1:-1)*o*X,p=T(L.get(),r,h);V(p,p,n);const u=this.analysis.tiltEnabled?ot.TILTED:ot.HORIZONTAL_OR_VERTICAL,c=i[N]?ot.VERTICAL:i[q]?ot.HORIZONTAL:u;return ht(p,r,o,o,l,c,this.view.renderCoordsHelper,a),!0}_clearPointerMoveTimeout(){this._prevPointerMoveTimeout=o(this._prevPointerMoveTimeout)}_resetPointerMoveTimeout(){this._clearPointerMoveTimeout(),this.shiftManipulator.state|=pt,this.rotateHeadingManipulator.state|=pt,this.rotateTiltManipulator.state|=pt,this._prevPointerMoveTimeout=this.clock.setTimeout((()=>{this.shiftManipulator.state&=~pt,this.rotateHeadingManipulator.state&=~pt,this.rotateTiltManipulator.state&=~pt}),this._pointerMoveTimerMs)}_updateManipulators(){if(kt.disableEngineLayers)return;let t=null,e=!1;if(r(this.analysisViewData.plane))t=this.analysisViewData.plane,e=!1;else{if(!r(this._previewPlane))return this.shiftManipulator.available=!1,this.rotateHeadingManipulator.available=!1,this.rotateTiltManipulator.available=!1,this.resizeManipulators.forEach((t=>t.available=!1)),this._previewPlaneOutlineVisualElement.visible=!1,void(this._previewPlaneGridVisualElement.visible=!1);t=this._previewPlane,e=!0}const i=ut(t,K.get());e?(this.shiftManipulator.available=!1,this.rotateHeadingManipulator.available=!1,this.rotateTiltManipulator.available=!1,this.resizeManipulators.forEach((t=>t.available=!1)),this._previewPlaneOutlineVisualElement.visible=!0,this._previewPlaneGridVisualElement.visible=!0):(this.shiftManipulator.available=!0,this.rotateHeadingManipulator.available=!0,this.rotateTiltManipulator.available=this.analysis.tiltEnabled,this.resizeManipulators.forEach((t=>t.available=!0)),ct(this.shiftManipulator,i,t,this.view.state.camera),dt(this.rotateHeadingManipulator,i,t,this.view.renderCoordsHelper),_t(this.rotateTiltManipulator,i,t),this.resizeManipulators.forEach(((e,a)=>vt(e,this._resizeHandles[a],i,t))),this._previewPlaneOutlineVisualElement.visible=!1,this._previewPlaneGridVisualElement.visible=!1);const a=E(L.get(),M(t.basis1),M(t.basis2),1),s=g(K.get(),a),n=w(s,i,s);this._previewPlaneOutlineVisualElement.transform=n,this._previewPlaneGridVisualElement.transform=n,this._updateMaterials()}_updateMaterials(){const t=[J[0],J[1],J[2],J[3]*this._previewPlaneOpacity];this._previewPlaneOutlineVisualElement.color=t;const e=[Q[0],Q[1],Q[2],Q[3]*this._previewPlaneOpacity],i=[0,0,0,0];this._previewPlaneGridVisualElement.backgroundColor=e,this._previewPlaneGridVisualElement.gridColor=i}_updateManipulatorsInteractive(t){if(!t.grabbing)return this.shiftManipulator.interactive=!0,this.rotateHeadingManipulator.interactive=!0,this.rotateTiltManipulator.interactive=!0,void this.resizeManipulators.forEach((t=>{t.interactive=!0}));this.shiftManipulator.interactive=this.shiftManipulator===t,this.rotateHeadingManipulator.interactive=this.rotateHeadingManipulator===t,this.rotateTiltManipulator.interactive=this.rotateTiltManipulator===t,this.resizeManipulators.forEach((e=>{e.interactive=e===t}))}testData(){return{plane:this.analysisViewData.plane,setPointerMoveTimerMs:t=>{this._pointerMoveTimerMs=t}}}};function St(t,e,i,a){const s=Pt(i,R(a),t.direction,C()),n=H();return z(s,t,n)?{type:"shift",creatingPointerId:e,hasBeenDragged:!1,shiftPlane:s,depth:0,startPoint:n}:null}function Ht(t){return"mouse"!==t.pointerType||0===t.button}Et.disableEngineLayers=!1,t([P()],Et.prototype,"clock",void 0),t([P({constructOnly:!0})],Et.prototype,"view",void 0),t([P()],Et.prototype,"analysisViewData",void 0),t([P({readOnly:!0})],Et.prototype,"state",null),t([P({readOnly:!0})],Et.prototype,"cursor",null),t([P()],Et.prototype,"analysis",null),t([P()],Et.prototype,"removeIncompleteOnCancel",void 0),t([P({readOnly:!0})],Et.prototype,"layersMode",void 0),t([P({value:null})],Et.prototype,"inputState",null),t([P()],Et.prototype,"_isPlacingSlicePlane",null),t([P()],Et.prototype,"_creatingPointerId",null),Et=kt=t([y("esri.views.3d.analysis.Slice.SliceTool")],Et);const xt=x(),It=v(),Rt=Et;export{Rt as default};
5
+ import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../analysis/SlicePlane.js";import{clock as i}from"../../../../core/clock.js";import a from"../../../../core/Handles.js";import{releaseMaybe as s,destroyMaybe as n,isSome as r,isNone as l,removeMaybe as o}from"../../../../core/maybe.js";import{watch as h,sync as p,syncAndInitial as u}from"../../../../core/reactiveUtils.js";import{addFrameTask as c}from"../../../../core/scheduling.js";import{createScreenPoint as d,screenPointObjectToArray as _,createScreenPointArray as v}from"../../../../core/screenUtils.js";import{property as P}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as y}from"../../../../core/accessorSupport/decorators/subclass.js";import{d as m,u as g,m as w}from"../../../../chunks/mat4.js";import{e as f,l as M,c as D,g as T,a as V,m as b,n as k,s as E}from"../../../../chunks/vec3.js";import{a as S,c as H}from"../../../../chunks/vec3f64.js";import{c as x,a as I,n as R,f as j}from"../../../../chunks/boundedPlane.js";import{signedDistance as O,create as C,intersectRay as z,normal as G}from"../../../../geometry/support/plane.js";import{create as U}from"../../../../geometry/support/ray.js";import{sv3d as L,sm4d as K,sv2d as A}from"../../../../geometry/support/vectorStacks.js";import{POINTER_MOVE_TIMER_MS as B,PLANE_PREVIEW_OUTLINE_WIDTH as F,forceVerticalModifier as N,forceHorizontalModifier as q,PREVIEW_FADE_DURATION_SECONDS as Z,PLANE_OUTLINE_COLOR as J,PLANE_BACKGROUND_COLOR as Q,PREVIEW_FADE_DOT_THRESHOLD as W,INITIAL_DEPTH_OFFSET_FRAC as X}from"./sliceToolConfig.js";import{createShiftManipulator as Y,createRotateManipulator as $,createResizeManipulator as tt,createGridVisualElement as et,createOutlineVisualElement as it,planeToShape as at,createRotatePlane as st,RotationAxis as nt,resizePlane as rt,calculatePlaneHalfSize as lt,SliceOrientation as ot,createPlane as ht,DidPointerMoveRecentlyFlag as pt,calculateBoundedPlaneTranslateRotate as ut,updateShiftRestartHandle as ct,updateRotateHeadingHandle as dt,updateRotateTiltHandle as _t,updateResizeHandle as vt,createShiftPlane as Pt}from"./sliceToolUtils.js";import{getRotateHeadingTexture as yt,getTiltRotateTexture as mt}from"./images/Factory.js";import{calculateInputRotationTransform as gt}from"../../interactive/manipulatorUtils.js";import{screenToRenderPlane as wt}from"../../interactive/editingTools/dragEventPipeline3D.js";import{fromScreen as ft}from"../../support/geometryUtils/ray.js";import{newIntersector as Mt}from"../../webgl-engine/lib/Intersector.js";import{StoreResults as Dt}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{AnalysisToolBase as Tt}from"../../../interactive/AnalysisToolBase.js";import{createManipulatorDragEventPipeline as Vt}from"../../../interactive/dragEventPipeline.js";import{createScreenPointFromEvent as bt}from"../../../support/screenUtils.js";var kt;let Et=kt=class extends Tt{constructor(t){super(t),this.clock=i,this._previewPlaneOpacity=1,this.removeIncompleteOnCancel=!1,this.layersMode="none",this.shiftManipulator=null,this.rotateHeadingManipulator=null,this.rotateTiltManipulator=null,this.resizeManipulators=null,this._handles=new a,this._viewHandles=new a,this._frameTask=null,this._pointerMoveTimerMs=B,this._prevPointerMoveTimeout=null,this._previewPlaneGridVisualElement=null,this._previewPlaneOutlineVisualElement=null,this._startPlane=x(),this._previewPlane=null,this._activeKeyModifiers={},this._lastCursorPosition=d(),this._resizeHandles=[{direction:[1,0]},{direction:[1,1]},{direction:[0,1]},{direction:[-1,1]},{direction:[-1,0]},{direction:[-1,-1]},{direction:[0,-1]},{direction:[1,-1]}],this._intersector=Mt(t.view.state.viewingMode),this._intersector.options.store=Dt.MIN}initialize(){if(null==this.analysis)throw new Error("SliceTool requires valid analysis, but null was provided.");this.rotateHeadingImage=yt(this.view.toolViewManager.textures),this.rotateTiltImage=mt(this.view.toolViewManager.textures);const t=t=>{this._updateManipulatorsInteractive(t),t.grabbing||(r(this.analysisViewData.plane)&&I(this.analysisViewData.plane,this._startPlane),this.inputState=null)};this.shiftManipulator=Y(this.view),this.manipulators.add(this.shiftManipulator),this.shiftManipulator.events.on("grab-changed",(e=>{this._onShiftGrab(e),t(this.shiftManipulator)})),this._handles.add(this._createShiftDragPipeline(this.shiftManipulator)),this.rotateHeadingManipulator=$(this.view,this.rotateHeadingImage.texture),this.manipulators.add(this.rotateHeadingManipulator),this.rotateHeadingManipulator.events.on("grab-changed",(e=>{this._onRotateHeadingGrab(e),t(this.rotateHeadingManipulator)})),this._handles.add(this._createRotateHeadingDragPipeline(this.rotateHeadingManipulator)),this.rotateTiltManipulator=$(this.view,this.rotateTiltImage.texture),this.manipulators.add(this.rotateTiltManipulator),this.rotateTiltManipulator.events.on("grab-changed",(e=>{this._onRotateTiltGrab(e),t(this.rotateTiltManipulator)})),this._handles.add(this._createRotateTiltDragPipeline(this.rotateTiltManipulator)),this.resizeManipulators=this._resizeHandles.map(((e,i)=>{const a=tt(this.view,e);return a.events.on("grab-changed",(e=>{this._onResizeGrab(e,i),t(a)})),this._handles.add(this._createResizeDragPipeline(a)),a})),this.manipulators.addMany(this.resizeManipulators),this._previewPlaneGridVisualElement=et(this.view),this._previewPlaneOutlineVisualElement=it(this.view),this._previewPlaneOutlineVisualElement.width=F,this._handles.add(h((()=>this.analysisViewData.plane),(()=>this._updateManipulators()),p));const e=h((()=>this.state),(t=>{"sliced"===t&&this.finishToolCreation()}),u);this._handles.add([e,h((()=>this.view.state.camera),(()=>this._onCameraChange()))])}destroy(){this.rotateHeadingImage=s(this.rotateHeadingImage),this.rotateTiltImage=s(this.rotateTiltImage),this._handles=n(this._handles),this._viewHandles=n(this._viewHandles),this._removeFrameTask(),this._clearPointerMoveTimeout(),this._previewPlaneOutlineVisualElement=n(this._previewPlaneOutlineVisualElement),this._previewPlaneGridVisualElement=n(this._previewPlaneGridVisualElement)}get state(){const t=!!this.analysisViewData.plane,e=!!this.inputState;return t?t&&e?"slicing":t&&!e?"sliced":"ready":"ready"}get cursor(){return this._isPlacingSlicePlane||"exclude"===this.layersMode?"crosshair":r(this._creatingPointerId)?"grabbing":null}set analysis(t){if(null==t)throw new Error("SliceTool requires valid analysis, but null was provided.");this._handles.remove("analysis"),this._set("analysis",t)}get inputState(){return this._get("inputState")}set inputState(t){this._set("inputState",t),this.analysisViewData.showGrid=r(t)&&"resize"===t.type,this._updateMaterials()}get _isPlacingSlicePlane(){return!this.inputState&&!this.analysisViewData.plane&&this.active}get _creatingPointerId(){return r(this.inputState)&&"shift"===this.inputState.type?this.inputState.creatingPointerId:null}enterExcludeLayerMode(){l(this.analysisViewData.plane)||(this._set("layersMode","exclude"),this.active||(this.view.activeTool=this))}exitExcludeLayerMode(){l(this.analysisViewData.plane)||(this._set("layersMode","none"),this.active&&(this.view.activeTool=null))}onDeactivate(){this._set("layersMode","none"),this._updatePreviewPlane(null)}onShow(){this._updateVisibility(!0)}onHide(){this._updateVisibility(!1)}_updateVisibility(t){this.shiftManipulator&&(this._updateManipulators(),t||this._clearPointerMoveTimeout())}onInputEvent(t){switch(t.type){case"pointer-drag":if(!Ht(t))return;this._isPlacingSlicePlane?this._onClickPlacePlane(t)&&t.stopPropagation():this._onPointerDrag(t)&&t.stopPropagation();break;case"pointer-move":this._onPointerMove(t);break;case"pointer-up":this._onPointerUp(t)&&t.stopPropagation();break;case"immediate-click":if(!Ht(t))return;this._onClickPlacePlane(t)&&t.stopPropagation();break;case"click":if(!Ht(t))return;this._onClickExcludeLayer(t)&&t.stopPropagation();break;case"drag":this.inputState&&t.stopPropagation();break;case"key-down":this._onKeyDown(t)&&t.stopPropagation();break;case"key-up":this._onKeyUp(t)&&t.stopPropagation()}}onEditableChange(){this.analysisViewData.editable=this.editable}_onPointerDrag(t){const e=this.inputState;if(t.pointerId===this._creatingPointerId&&r(e)&&"shift"===e.type){const i=bt(t);return this.shiftManipulator.events.emit("drag",{action:e.hasBeenDragged?"update":"start",pointerType:t.pointerType,start:i,screenPoint:i}),e.hasBeenDragged=!0,!0}return!1}_onPointerMove(t){this._lastCursorPosition.x=t.x,this._lastCursorPosition.y=t.y,this._resetPointerMoveTimeout(),"touch"!==t.pointerType&&this._updatePreviewPlane(bt(t),this._activeKeyModifiers)}_onCameraChange(){this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),this._updateManipulators()}_onPointerUp(t){if(t.pointerId===this._creatingPointerId&&r(this.analysisViewData.plane)){const e=bt(t);return this.shiftManipulator.events.emit("drag",{action:"end",start:e,screenPoint:e}),I(this.analysisViewData.plane,this._startPlane),this.inputState=null,!0}return!1}_onClickPlacePlane(t){if("exclude"===this.layersMode)return!1;if(this._isPlacingSlicePlane){const i=bt(t),a=x();if(this._pickPlane(i,!1,this._activeKeyModifiers,a)){if(I(a,this._startPlane),this.analysis.shape=at(a,this.view,this.view.spatialReference,new e),"pointer-drag"===t.type){const e=this._calculatePickRay(i);this.inputState=St(e,t.pointerId,a.origin,a)}return!0}}return!1}_onClickExcludeLayer(t){return!("exclude"!==this.layersMode||!this.created)&&(this.view.hitTest(bt(t)).then((t=>{if(t.results.length){const e=t.results[0],i="graphic"===e?.type&&e.graphic;if(i){const t=i.sourceLayer||i.layer;t&&this.analysis.excludedLayers.push(t)}}else t.ground.layer?this.analysis.excludedLayers.push(t.ground.layer):this.analysis.excludeGroundSurface=!0})),this._set("layersMode","none"),this.active&&(this.view.activeTool=null),!0)}_onKeyDown(t){return(t.key===N||t.key===q)&&(this._activeKeyModifiers[t.key]=!0,r(this._previewPlane)&&this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),!0)}_onKeyUp(t){return!(t.key!==N&&t.key!==q||!this._activeKeyModifiers[t.key])&&(delete this._activeKeyModifiers[t.key],r(this._previewPlane)&&this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),!0)}_onShiftGrab(t){if("start"!==t.action||l(this.analysisViewData.plane))return;const e=this._calculatePickRay(t.screenPoint);I(this.analysisViewData.plane,this._startPlane),this.inputState=St(e,null,this.shiftManipulator.renderLocation,this.analysisViewData.plane)}_createShiftDragPipeline(t){return Vt(t,((t,e,i)=>{const a=this.inputState;if(l(a)||"shift"!==a.type)return;const s=r(this.analysisViewData.plane)?I(this.analysisViewData.plane,x()):null;e.next(wt(this.view,a.shiftPlane)).next(this._shiftDragAdjustSensitivity(a)).next(this._shiftDragUpdatePlane(a)),i.next((()=>{r(s)&&this._updateBoundedPlane(s)}))}))}_shiftDragAdjustSensitivity(t){return e=>{if(l(this.analysisViewData.plane))return null;const i=.001,a=Math.min((1-Math.abs(f(R(this.analysisViewData.plane),e.ray.direction)/M(e.ray.direction)))/i,1),s=-O(this._startPlane.plane,e.renderEnd),n=-O(this._startPlane.plane,t.startPoint);return t.depth=t.depth*(1-a)+s*a-n,e}}_shiftDragUpdatePlane(t){return()=>{if(l(this.analysisViewData.plane))return;const e=D(L.get(),this._startPlane.origin),i=D(L.get(),R(this._startPlane));T(i,i,-t.depth),V(i,i,e);const a=j(i,this.analysisViewData.plane.basis1,this.analysisViewData.plane.basis2,x());this._updateBoundedPlane(a)}}_onRotateHeadingGrab(t){if("start"!==t.action||l(this.analysisViewData.plane))return;const e=st(this.analysisViewData.plane,this.view.renderCoordsHelper,nt.HEADING,C()),i=this._calculatePickRay(t.screenPoint),a=H();z(e,i,a)&&(I(this.analysisViewData.plane,this._startPlane),this.inputState={type:"rotate",rotatePlane:e,startPoint:a})}_createRotateHeadingDragPipeline(t){return Vt(t,((t,e,i)=>{const a=this.inputState;if(l(a)||"rotate"!==a.type)return;const s=r(this.analysisViewData.plane)?I(this.analysisViewData.plane,x()):null;e.next(wt(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdatePlaneFromRotate()),i.next((()=>{r(s)&&this._updateBoundedPlane(s)}))}))}_onRotateTiltGrab(t){if("start"!==t.action||l(this.analysisViewData.plane))return;const e=st(this.analysisViewData.plane,this.view.renderCoordsHelper,nt.TILT,C()),i=this._calculatePickRay(t.screenPoint),a=H();z(e,i,a)&&(I(this.analysisViewData.plane,this._startPlane),this.inputState={type:"rotate",rotatePlane:e,startPoint:a})}_createRotateTiltDragPipeline(t){return Vt(t,((t,e,i)=>{const a=this.inputState;if(l(a)||"rotate"!==a.type)return;const s=r(this.analysisViewData.plane)?I(this.analysisViewData.plane,x()):null;e.next(wt(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdatePlaneFromRotate()),i.next((()=>{r(s)&&this._updateBoundedPlane(s)}))}))}_rotateDragRenderPlaneToRotate(t){return e=>{if(l(this.analysisViewData.plane))return null;const i=G(t.rotatePlane),a=gt(t.startPoint,e.renderEnd,this.analysisViewData.plane.origin,i);return{...e,rotateAxis:i,rotateAngle:a}}}_rotateDragUpdatePlaneFromRotate(){return t=>{if(l(this.analysisViewData.plane))return;const e=m(K.get(),t.rotateAngle,t.rotateAxis);if(l(e))return;const i=b(L.get(),this._startPlane.basis1,e),a=b(L.get(),this._startPlane.basis2,e),s=j(this.analysisViewData.plane.origin,i,a,x());this._updateBoundedPlane(s)}}_onResizeGrab(t,e){if("start"!==t.action||l(this.analysisViewData.plane))return;const i=this._calculatePickRay(t.screenPoint),a=L.get();z(this.analysisViewData.plane.plane,i,a)&&(I(this.analysisViewData.plane,this._startPlane),this.inputState={type:"resize",activeHandleIdx:e,startPoint:S(a)})}_createResizeDragPipeline(t){return Vt(t,((t,e,i)=>{const a=this.inputState;if(l(a)||"resize"!==a.type||l(this.analysisViewData.plane))return;const s=I(this.analysisViewData.plane,x());e.next(wt(this.view,this.analysisViewData.plane.plane)).next(this._resizeDragUpdatePlane(a)),i.next((()=>{this._updateBoundedPlane(s)}))}))}_resizeDragUpdatePlane(t){return e=>{if(l(this.analysisViewData.plane))return;const i=this._resizeHandles[t.activeHandleIdx],a=rt(i,t.startPoint,e.renderEnd,this.view.state.camera,this._startPlane,I(this.analysisViewData.plane));this._updateBoundedPlane(a)}}_updateBoundedPlane(t){const e=this.analysisViewData;if(!r(e))throw new Error("valid internal object expected");e.plane=t}_updatePreviewPlane(t,e={}){let i=this._previewPlane;if(this._previewPlane=null,l(t))return this._removeFrameTask(),void this._updateManipulators();if(!this.analysisViewData.plane&&this.active){const a=r(i)?i:x();if(i=r(i)?I(i,xt):null,this._pickPlane(t,!0,e,a)){const t=W;let e=!1;r(i)&&(e=f(i.plane,a.plane)<t||f(k(L.get(),i.basis1),k(L.get(),a.basis1))<t),e&&(this._previewPlaneOpacity=0),this._previewPlane=a}}r(this._previewPlane)&&l(this._frameTask)&&0===this._previewPlaneOpacity?this._frameTask=c({update:({deltaTime:t})=>{this._previewPlaneOpacity=Math.min(this._previewPlaneOpacity+t/(1e3*Z),1),this._updateManipulators(),1===this._previewPlaneOpacity&&this._removeFrameTask()}}):l(this._previewPlane)&&r(this._frameTask)?this._removeFrameTask():r(this._previewPlane)&&this._updateManipulators()}_removeFrameTask(){this._frameTask=o(this._frameTask)}_calculatePickRay(t){const e=U(),i=_(t,It);return ft(this.view.state.camera,i,e),k(e.direction,e.direction),e}_pickMinResult(t){const e=_(t,A.get());return this.view.sceneIntersectionHelper.intersectToolIntersectorScreen(e,this._intersector),this._intersector.results.min}_pickPlane(t,e,i,a){const s=this._pickMinResult(t),n=L.get();if(!s.getIntersectionPoint(n))return!1;const r=s.getTransformedNormal(L.get()),l=this.view.state.camera;f(r,l.viewForward)>0&&T(r,r,-1);const o=lt(n,l),h=(e?1:-1)*o*X,p=T(L.get(),r,h);V(p,p,n);const u=this.analysis.tiltEnabled?ot.TILTED:ot.HORIZONTAL_OR_VERTICAL,c=i[N]?ot.VERTICAL:i[q]?ot.HORIZONTAL:u;return ht(p,r,o,o,l,c,this.view.renderCoordsHelper,a),!0}_clearPointerMoveTimeout(){this._prevPointerMoveTimeout=o(this._prevPointerMoveTimeout)}_resetPointerMoveTimeout(){this._clearPointerMoveTimeout(),this.shiftManipulator.state|=pt,this.rotateHeadingManipulator.state|=pt,this.rotateTiltManipulator.state|=pt,this._prevPointerMoveTimeout=this.clock.setTimeout((()=>{this.shiftManipulator.state&=~pt,this.rotateHeadingManipulator.state&=~pt,this.rotateTiltManipulator.state&=~pt}),this._pointerMoveTimerMs)}_updateManipulators(){if(kt.disableEngineLayers)return;let t=null,e=!1;if(r(this.analysisViewData.plane))t=this.analysisViewData.plane,e=!1;else{if(!r(this._previewPlane))return this.shiftManipulator.available=!1,this.rotateHeadingManipulator.available=!1,this.rotateTiltManipulator.available=!1,this.resizeManipulators.forEach((t=>t.available=!1)),this._previewPlaneOutlineVisualElement.visible=!1,void(this._previewPlaneGridVisualElement.visible=!1);t=this._previewPlane,e=!0}const i=ut(t,K.get());e?(this.shiftManipulator.available=!1,this.rotateHeadingManipulator.available=!1,this.rotateTiltManipulator.available=!1,this.resizeManipulators.forEach((t=>t.available=!1)),this._previewPlaneOutlineVisualElement.visible=!0,this._previewPlaneGridVisualElement.visible=!0):(this.shiftManipulator.available=!0,this.rotateHeadingManipulator.available=!0,this.rotateTiltManipulator.available=this.analysis.tiltEnabled,this.resizeManipulators.forEach((t=>t.available=!0)),ct(this.shiftManipulator,i,t,this.view.state.camera),dt(this.rotateHeadingManipulator,i,t,this.view.renderCoordsHelper),_t(this.rotateTiltManipulator,i,t),this.resizeManipulators.forEach(((e,a)=>vt(e,this._resizeHandles[a],i,t))),this._previewPlaneOutlineVisualElement.visible=!1,this._previewPlaneGridVisualElement.visible=!1);const a=E(L.get(),M(t.basis1),M(t.basis2),1),s=g(K.get(),a),n=w(s,i,s);this._previewPlaneOutlineVisualElement.transform=n,this._previewPlaneGridVisualElement.transform=n,this._updateMaterials()}_updateMaterials(){const t=[J[0],J[1],J[2],J[3]*this._previewPlaneOpacity];this._previewPlaneOutlineVisualElement.color=t;const e=[Q[0],Q[1],Q[2],Q[3]*this._previewPlaneOpacity],i=[0,0,0,0];this._previewPlaneGridVisualElement.backgroundColor=e,this._previewPlaneGridVisualElement.gridColor=i}_updateManipulatorsInteractive(t){if(!t.grabbing)return this.shiftManipulator.interactive=!0,this.rotateHeadingManipulator.interactive=!0,this.rotateTiltManipulator.interactive=!0,void this.resizeManipulators.forEach((t=>{t.interactive=!0}));this.shiftManipulator.interactive=this.shiftManipulator===t,this.rotateHeadingManipulator.interactive=this.rotateHeadingManipulator===t,this.rotateTiltManipulator.interactive=this.rotateTiltManipulator===t,this.resizeManipulators.forEach((e=>{e.interactive=e===t}))}testData(){return{plane:this.analysisViewData.plane,setPointerMoveTimerMs:t=>{this._pointerMoveTimerMs=t}}}};function St(t,e,i,a){const s=Pt(i,R(a),t.direction,C()),n=H();return z(s,t,n)?{type:"shift",creatingPointerId:e,hasBeenDragged:!1,shiftPlane:s,depth:0,startPoint:n}:null}function Ht(t){return"mouse"!==t.pointerType||0===t.button}Et.disableEngineLayers=!1,t([P()],Et.prototype,"clock",void 0),t([P({constructOnly:!0})],Et.prototype,"view",void 0),t([P()],Et.prototype,"analysisViewData",void 0),t([P({readOnly:!0})],Et.prototype,"state",null),t([P({readOnly:!0})],Et.prototype,"cursor",null),t([P()],Et.prototype,"analysis",null),t([P()],Et.prototype,"removeIncompleteOnCancel",void 0),t([P({readOnly:!0})],Et.prototype,"layersMode",void 0),t([P({value:null})],Et.prototype,"inputState",null),t([P()],Et.prototype,"_isPlacingSlicePlane",null),t([P()],Et.prototype,"_creatingPointerId",null),Et=kt=t([y("esri.views.3d.analysis.Slice.SliceTool")],Et);const xt=x(),It=v(),Rt=Et;export{Rt as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../../../Color.js";import a from"../../../../../core/Evented.js";import r from"../../../../../core/Handles.js";import{handlesGroup as e}from"../../../../../core/handleUtils.js";import{destroyMaybe as i,unwrap as o}from"../../../../../core/maybe.js";import{f as s,b as n,m as l,d as p,u}from"../../../../../chunks/mat4.js";import{c as h}from"../../../../../chunks/mat4f64.js";import{s as m}from"../../../../../chunks/vec3.js";import{f as c}from"../../../../../chunks/vec3f64.js";import{sv3d as f,sm4d as d}from"../../../../../geometry/support/vectorStacks.js";import{getGraphicEffectiveElevationInfo as _}from"../../../../../support/elevationInfoUtils.js";import{Manipulator3D as g}from"../../Manipulator3D.js";import{screenToMapXYAtLocation as M}from"../dragEventPipeline3D.js";import{ManipulatorType as w}from"../ManipulatorType.js";import{colors as v}from"../settings.js";import{DISC_RADIUS as j,DISC_HEIGHT as y,DISC_TRANSLATE_ARROW_OFFSET as A,DISC_TRANSLATE_ARROW_SIZE as I}from"./config.js";import{Manipulation as T}from"./Manipulation.js";import{createGraphicMoveDragPipeline as b}from"./moveUtils.js";import{CullFaceOptions as D}from"../../../webgl-engine/lib/basicInterfaces.js";import E from"../../../webgl-engine/lib/GeometryUtil.js";import{RenderOccludedFlag as S}from"../../../webgl-engine/lib/Material.js";import{ColorMaterial as k}from"../../../webgl-engine/materials/ColorMaterial.js";import{createManipulatorDragEventPipeline as x,dragAtLocation as P,constrainToMapAxis as U,addScreenDelta as R}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateFlags as L}from"../../../../interactive/interfaces.js";class O extends T{constructor(t){super(),this._handles=new r,this._arrowManipulatorInfos=new Array,this._opaqueMaterial=this._createMaterial(),this._transparentMaterial=this._createMaterial(.5),this._angle=0,this._scale=1,this._radius=j,this._updateAfterDrag=!1,this.events=new a,this._tool=t.tool,this._view=t.view,null!=t.radius&&(this._radius=t.radius),this._createManipulators(),this.forEachManipulator((t=>this._tool.manipulators.add(t)))}set orthogonalAvailable(t){this._arrowManipulatorInfos[1].manipulator.available=t,this._arrowManipulatorInfos[3].manipulator.available=t}destroy(){this.forEachManipulator((t=>{this._tool.manipulators.remove(t),t.destroy()})),this._handles=i(this._handles),this._tool=null,this._view=null,this._arrowManipulatorInfos.length=0}forEachManipulator(t){for(const{manipulator:a}of this._arrowManipulatorInfos)t(a,w.TRANSLATE_XY)}createGraphicDragPipeline(t,a,r){const e=a.graphic,i=_(e),s=o(e.geometry).spatialReference;return b(a,r,(a=>this.createDragPipeline(((r,e,i,o,s)=>a(r,t(r,e,i,o,s),i)),i,s,e)),this._view.state.viewingMode)}createDragPipeline(t,a,r,i){return e(this._arrowManipulatorInfos.map((({manipulator:e},o)=>x(e,((e,s,n,l,p)=>{const u=s.next((t=>({...t,manipulatorType:w.TRANSLATE_XY}))).next(P(this._view,e.elevationAlignedLocation)).next(M(this._view,e.elevationAlignedLocation,a,r,i)).next(U(e.location,this.angle+(o+1)*Math.PI*.5)).next(R());t(e,u,n,l,p)})))))}get angle(){return this._angle}set angle(t){this._angle=t,this.dragging?this._updateAfterDrag=!0:this._updateManipulatorTransform()}get displayScale(){return this._scale}set displayScale(t){this._scale=t,this._updateManipulatorTransform()}get radius(){return this._radius}set radius(t){this._radius!==t&&(this._radius=t,this._updateManipulators())}_updateManipulators(){for(let t=0;t<this._arrowManipulatorInfos.length;t++)this._updateArrowManipulator(this._arrowManipulatorInfos[t],t);this._updateManipulatorTransform()}_updateArrowManipulator({manipulator:t,transform:a},r){const e=this._radius/j,i=I*e,o=i*Math.sqrt(3)/2,p=E.createExtrudedTriangle(o,i/2,i/2,y);E.transformInPlace(p,s(d.get(),m(f.get(),0,-o/3,0))),t.renderObjects=[{geometry:p,material:this._opaqueMaterial,stateMask:L.Focused},{geometry:p,material:this._transparentMaterial,stateMask:L.Unfocused}],t.radius=o/3*2*1.2;const u=n(d.get(),r*Math.PI/2),h=s(d.get(),m(f.get(),0,A*e,0));l(a,u,h)}_createManipulators(){for(let t=0;t<4;t++){const a=this._createArrowManipulator(t);this._arrowManipulatorInfos.push(a)}this._updateManipulatorTransform()}_updateManipulatorTransform(){const t=this.angle,a=p(d.get(),t,c(0,0,1)),r=u(d.get(),m(f.get(),this.displayScale,this.displayScale,this.displayScale)),e=l(d.get(),r,a);for(const i of this._arrowManipulatorInfos){const t=l(d.get(),e,i.transform);i.manipulator.modelTransform=t}}_createArrowManipulator(t){const a=new g({view:this._view,autoScaleRenderObjects:!1,worldOriented:!0,focusMultiplier:1,touchMultiplier:1,collisionType:{type:"disc",direction:c(0,0,1)}}),r={manipulator:a,transform:h()};return this._updateArrowManipulator(r,t),this._handles.add(a.events.on("drag",(t=>{this._updateAfterDrag&&"end"===t.action&&!this.dragging&&(this._updateManipulatorTransform(),this._updateAfterDrag=!1)}))),r}_createMaterial(a=1){const r=t.toUnitRGBA(v.main);return r[3]*=a,new k({color:r,transparent:1!==a,cullFace:D.Back,renderOccluded:S.Transparent})}get test(){return{arrowManipulators:this._arrowManipulatorInfos.map((({manipulator:t})=>t))}}}export{O as MoveXYAxisManipulation};
5
+ import t from"../../../../../Color.js";import a from"../../../../../core/Evented.js";import r from"../../../../../core/Handles.js";import{handlesGroup as e}from"../../../../../core/handleUtils.js";import{destroyMaybe as i,unwrap as o,isNone as s}from"../../../../../core/maybe.js";import{f as n,b as l,m as p,d as u,u as h}from"../../../../../chunks/mat4.js";import{c as m}from"../../../../../chunks/mat4f64.js";import{s as c}from"../../../../../chunks/vec3.js";import{f}from"../../../../../chunks/vec3f64.js";import{sv3d as d,sm4d as _}from"../../../../../geometry/support/vectorStacks.js";import{getGraphicEffectiveElevationInfo as g}from"../../../../../support/elevationInfoUtils.js";import{Manipulator3D as M}from"../../Manipulator3D.js";import{screenToMapXYAtLocation as w}from"../dragEventPipeline3D.js";import{ManipulatorType as v}from"../ManipulatorType.js";import{colors as j}from"../settings.js";import{DISC_RADIUS as y,DISC_HEIGHT as A,DISC_TRANSLATE_ARROW_OFFSET as I,DISC_TRANSLATE_ARROW_SIZE as T}from"./config.js";import{Manipulation as b}from"./Manipulation.js";import{createGraphicMoveDragPipeline as D}from"./moveUtils.js";import{CullFaceOptions as E}from"../../../webgl-engine/lib/basicInterfaces.js";import S from"../../../webgl-engine/lib/GeometryUtil.js";import{RenderOccludedFlag as k}from"../../../webgl-engine/lib/Material.js";import{ColorMaterial as x}from"../../../webgl-engine/materials/ColorMaterial.js";import{createManipulatorDragEventPipeline as P,dragAtLocation as U,constrainToMapAxis as R,addScreenDelta as L}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateFlags as O}from"../../../../interactive/interfaces.js";class q extends b{constructor(t){super(),this._handles=new r,this._arrowManipulatorInfos=new Array,this._opaqueMaterial=this._createMaterial(),this._transparentMaterial=this._createMaterial(.5),this._angle=0,this._scale=1,this._radius=y,this._updateAfterDrag=!1,this.events=new a,this._tool=t.tool,this._view=t.view,null!=t.radius&&(this._radius=t.radius),this._createManipulators(),this.forEachManipulator((t=>this._tool.manipulators.add(t)))}set orthogonalAvailable(t){this._arrowManipulatorInfos[1].manipulator.available=t,this._arrowManipulatorInfos[3].manipulator.available=t}destroy(){this.forEachManipulator((t=>{this._tool.manipulators.remove(t),t.destroy()})),this._handles=i(this._handles),this._tool=null,this._view=null,this._arrowManipulatorInfos.length=0}forEachManipulator(t){for(const{manipulator:a}of this._arrowManipulatorInfos)t(a,v.TRANSLATE_XY)}createGraphicDragPipeline(t,a,r){const e=a.graphic,i=g(e),s=o(e.geometry).spatialReference;return D(a,r,(a=>this.createDragPipeline(((r,e,i,o,s)=>a(r,t(r,e,i,o,s),i)),i,s,e)),this._view.state.viewingMode)}createDragPipeline(t,a,r,i){return e(this._arrowManipulatorInfos.map((({manipulator:e},o)=>P(e,((e,s,n,l,p)=>{const u=s.next((t=>({...t,manipulatorType:v.TRANSLATE_XY}))).next(U(this._view,e.elevationAlignedLocation)).next(w(this._view,e.elevationAlignedLocation,a,r,i)).next(R(e.location,this.angle+(o+1)*Math.PI*.5)).next(L());t(e,u,n,l,p)})))))}get angle(){return this._angle}set angle(t){this._angle=t,this.dragging?this._updateAfterDrag=!0:this._updateManipulatorTransform()}get displayScale(){return this._scale}set displayScale(t){this._scale=t,this._updateManipulatorTransform()}get radius(){return this._radius}set radius(t){this._radius!==t&&(this._radius=t,this._updateManipulators())}_updateManipulators(){for(let t=0;t<this._arrowManipulatorInfos.length;t++)this._updateArrowManipulator(this._arrowManipulatorInfos[t],t);this._updateManipulatorTransform()}_updateArrowManipulator({manipulator:t,transform:a},r){const e=this._radius/y,i=T*e,o=i*Math.sqrt(3)/2,s=S.createExtrudedTriangle(o,i/2,i/2,A);S.transformInPlace(s,n(_.get(),c(d.get(),0,-o/3,0))),t.renderObjects=[{geometry:s,material:this._opaqueMaterial,stateMask:O.Focused},{geometry:s,material:this._transparentMaterial,stateMask:O.Unfocused}],t.radius=o/3*2*1.2;const u=l(_.get(),r*Math.PI/2),h=n(_.get(),c(d.get(),0,I*e,0));p(a,u,h)}_createManipulators(){for(let t=0;t<4;t++){const a=this._createArrowManipulator(t);this._arrowManipulatorInfos.push(a)}this._updateManipulatorTransform()}_updateManipulatorTransform(){const t=this.angle,a=u(_.get(),t,f(0,0,1));if(s(a))return;const r=h(_.get(),c(d.get(),this.displayScale,this.displayScale,this.displayScale)),e=p(_.get(),r,a);for(const i of this._arrowManipulatorInfos){const t=p(_.get(),e,i.transform);i.manipulator.modelTransform=t}}_createArrowManipulator(t){const a=new M({view:this._view,autoScaleRenderObjects:!1,worldOriented:!0,focusMultiplier:1,touchMultiplier:1,collisionType:{type:"disc",direction:f(0,0,1)}}),r={manipulator:a,transform:m()};return this._updateArrowManipulator(r,t),this._handles.add(a.events.on("drag",(t=>{this._updateAfterDrag&&"end"===t.action&&!this.dragging&&(this._updateManipulatorTransform(),this._updateAfterDrag=!1)}))),r}_createMaterial(a=1){const r=t.toUnitRGBA(j.main);return r[3]*=a,new x({color:r,transparent:1!==a,cullFace:E.Back,renderOccluded:k.Transparent})}get test(){return{arrowManipulators:this._arrowManipulatorInfos.map((({manipulator:t})=>t))}}}export{q as MoveXYAxisManipulation};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{cyclicalPI as t}from"../../../../../core/Cyclical.js";import e from"../../../../../core/Evented.js";import a from"../../../../../core/Handles.js";import{clamp as i,rad2deg as o}from"../../../../../core/mathUtils.js";import{isSome as s,destroyMaybe as r,unwrapOr as n}from"../../../../../core/maybe.js";import{createAngle as l,createLength as c}from"../../../../../core/quantityUtils.js";import{when as h,initial as p,watch as u}from"../../../../../core/reactiveUtils.js";import{addFrameTask as d}from"../../../../../core/scheduling.js";import{createScreenPointArray as g}from"../../../../../core/screenUtils.js";import{d as m,u as _,m as f,h as M,e as D}from"../../../../../chunks/mat4.js";import{c as S}from"../../../../../chunks/mat4f64.js";import{s as v,b as y,l as b,d as T,f as R,a as j}from"../../../../../chunks/vec3.js";import{a as k,f as w}from"../../../../../chunks/vec3f64.js";import{b as O}from"../../../../../chunks/vec4f64.js";import{fromPositionAndNormal as A,create as I,normal as P}from"../../../../../geometry/support/plane.js";import{wrap as E,distance2 as F}from"../../../../../geometry/support/ray.js";import{sv3d as C,sm4d as U}from"../../../../../geometry/support/vectorStacks.js";import{getGraphicEffectiveElevationInfo as x}from"../../../../../support/elevationInfoUtils.js";import{Manipulator3D as z}from"../../Manipulator3D.js";import{calculateInputRotationTransform as L}from"../../manipulatorUtils.js";import{screenToRenderPlane as N}from"../dragEventPipeline3D.js";import{ManipulatorType as G}from"../ManipulatorType.js";import{ROTATE_INDICATOR_DIRECTION_BUFFER as H,SCALE_INDICATOR_DIRECTION_BUFFER as V,RING_HEIGHT as q,ROTATE_INDICATOR_ARROW_PLACEMENT_PERCENTAGE as B,ROTATE_INDICATOR_ARROW_TIP_LENGTH as J,ROTATE_INDICATOR_ARROW_TIP_RADIUS as K,RING_THICKNESS as Q,HANDLE_COLOR as W,DRAG_THRESHOLD_PX as X,RING_INDICATOR_DELAY_MS as Y,RING_RADIUS as Z,INNER_INDICATOR_RADIUS as $,INDICATOR_THICKNESS as tt,OUTER_INDICATOR_RADIUS as et,SCALE_INDICATOR_OFFSET1 as at,SCALE_INDICATOR_OFFSET2 as it,RING_RESET_ANIMATION_SPEED_FACTOR as ot,GEOMETRY_SEGMENTS as st,ROTATE_INDICATOR_ARC_LENGTH as rt,SCALE_INDICATOR_ARC_LENGTH as nt}from"../manipulations/config.js";import{CullFaceOptions as lt}from"../../../webgl-engine/lib/basicInterfaces.js";import ct from"../../../webgl-engine/lib/GeometryUtil.js";import{RenderOccludedFlag as ht}from"../../../webgl-engine/lib/Material.js";import{ColorMaterial as pt}from"../../../webgl-engine/materials/ColorMaterial.js";import{createManipulatorDragEventPipeline as ut}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateCustomFlags as dt,ManipulatorStateFlags as gt}from"../../../../interactive/interfaces.js";import{Tooltip as mt}from"../../../../interactive/tooltip/Tooltip.js";import{TransformRotateTooltipInfo as _t,TransformScaleTooltipInfo as ft,TransformAbsoluteTooltipInfo as Mt}from"../../../../interactive/tooltip/TransformTooltipInfos.js";var Dt,St;!function(t){t.ScaleIn=dt.Custom2,t.ScaleOut=dt.Custom3,t.RotateLeft=dt.Custom4,t.RotateRight=dt.Custom5,t.Unlocked=dt.Custom7,t.DelayedFocused=dt.Custom8,t.TouchInput=dt.Custom12}(Dt||(Dt={}));class vt{constructor({adapter:t,tooltipOptions:i,mode:o,tool:r}){this.mode=null,this._handles=new a,this._scaleRotateDragData=null,this._activeAnimation=null,this.events=new e,this.getFocused=()=>this._ringManipulator.focused,this.getScale=()=>s(this._scaleRotateDragData)&&"scale"===this._scaleRotateDragData.mode?this.adapter.scale:1,this.tool=r,this.mode=o,this.adapter=t,this._tooltipOptions=i,this._tooltip=new mt({view:r.view}),this._createManipulator(),this._updateDragState(),this._updateManipulatorTransform(),this._handles.add(h((()=>!this._tooltipOptions.enabled),(()=>this._tooltip.clear()),p))}get angle(){return this.adapter.angle}get scale(){return this.adapter.scale}set location(t){this._ringManipulator.location=t}set elevationAlignedLocation(t){this._ringManipulator.elevationAlignedLocation=t}get grabbing(){return this._ringManipulator.grabbing}set interactive(t){this._ringManipulator.interactive=t}destroy(){s(this._activeAnimation)&&(this._activeAnimation.frameTask.remove(),this._activeAnimation=null),this._handles=r(this._handles),this.tool.manipulators.remove(this._ringManipulator),this._ringManipulator=null,this._tooltip=r(this._tooltip)}startAnimation(t){this.cancelActiveAnimation(),t.start();const e=d({update:({deltaTime:e})=>{t.update(e)&&this.cancelActiveAnimation()}});this._activeAnimation={...t,frameTask:e}}cancelActiveAnimation(){s(this._activeAnimation)&&(this._activeAnimation.frameTask.remove(),this._activeAnimation=r(this._activeAnimation))}forEachManipulator(t){t(this._ringManipulator,G.SCALE_ROTATE)}_createManipulator(){const e=this._createRingManipulator();this._ringManipulator=e,this.tool.manipulators.add(e);const a=this.tool.graphicState.graphic,r=ut(e,((e,r,n)=>{this._scaleRotateDragData=null;const l=this.adapter.startInteraction(),c={mode:"none",origin:k(e.renderLocation),initialAngle:this.adapter.angle,angle:0,angleDir:0,scaleDir:0};this._scaleRotateDragData=c,this._updateDragState();const h=C.get();this.tool.view.renderCoordsHelper.worldUpAtPosition(e.renderLocation,h),r.next(N(this.tool.view,A(e.renderLocation,h,I()))).next((e=>{const r=P(e.plane),n=L(e.renderStart,e.renderEnd,c.origin,r),h=t.shortestSignedDiff(c.angle,n);c.angleDir=i(c.angleDir+h,-H,H),c.angle=n;const p=yt(c,e),u=p-this.adapter.scale;if(c.scaleDir=i(c.scaleDir+u,-V,V),this._onScaleChanged(),"none"===c.mode){const t=this.mode||bt(e,e.plane,c.origin,this.tool.view.state.camera);if(s(t)){switch(t){case"rotate":this.tool.emit("graphic-rotate-start",{graphic:a,angle:0}),this.tool.emit("record-undo",{record:this.adapter.createUndoRecord()});break;case"scale":this.tool.emit("graphic-scale-start",{graphic:a,xScale:1,yScale:1}),this.tool.emit("record-undo",{record:this.adapter.createUndoRecord()})}c.mode=t}}switch(c.mode){case"rotate":l.state.angle=c.initialAngle+n;break;case"scale":l.state.scale=p,this._onScaleChanged()}switch(this._updateDragState(),this._updateManipulatorTransform(),e.action){case"start":case"update":switch(c.mode){case"rotate":this.tool.emit("graphic-rotate",{graphic:a,angle:o(c.angle)});break;case"scale":this.tool.emit("graphic-scale",{graphic:a,xScale:p,yScale:p})}break;case"end":switch(c.mode){case"rotate":this.tool.emit("graphic-rotate-stop",{graphic:a,angle:o(c.angle)});break;case"scale":this.tool.emit("graphic-scale-stop",{graphic:a,xScale:p,yScale:p})}}return"end"===e.action&&(this.startAnimation(Rt(this,(()=>this._onScaleChanged()))),this._scaleRotateDragData=null,this._updateDragState(),l.done()),e})).next(this._updateTooltipPipelineStep(c)),n.next((()=>{if(l.cancel(),s(this._scaleRotateDragData)){switch(this._scaleRotateDragData.mode){case"none":break;case"rotate":this.tool.emit("graphic-rotate-stop",{graphic:a,angle:0});break;case"scale":this.tool.emit("graphic-scale-stop",{graphic:a,xScale:1,yScale:1})}this.startAnimation(Rt(this,(()=>this._onScaleChanged()))),this._scaleRotateDragData=null,this._updateDragState()}this._updateFocusTooltip()}))}));this._handles.add([r,e.events.on("focus-changed",(t=>{"focus"===t.action?this.startAnimation(jt(this,(()=>this._updateDelayedFocusedState()))):this._updateDelayedFocusedState()})),e.events.on("immediate-click",(t=>{t.stopPropagation()})),u((()=>this.tool.graphicState?.displaying),(t=>this._ringManipulator.available=t),p)])}_updateTooltipPipelineStep(t){return e=>{const a=this._tooltipOptions;if(!a.enabled)return e;if("end"===e.action)return this._updateFocusTooltip(),e;const i=this._tooltip,o=this._tooltipOptions.visualVariables,r=s(o)?o.size:null,h=s(o)?o.rotation:null;switch(t.mode){case"scale":i.info=new ft({tooltipOptions:a,scale:{value:this.adapter.scale},size:c(n(this.adapter.size,-1),"meters"),sizeUnit:s(r)?r.unit:null,sizePrecision:s(r)?kt(r.valueType):null});break;case"rotate":{const t=s(h)?kt(h.valueType):null,e=s(h)?h.rotationType:"geographic";i.info=new _t({tooltipOptions:a,rotation:l(n(-this.adapter.relativeAngle,0),"radians","geographic"),rotationPrecision:t,orientation:l(-this.adapter.angle,"radians","geographic"),orientationPrecision:t,rotationType:e})}}return e}}_updateFocusTooltip(){if(!this._tooltipOptions.enabled)return;if(this.getFocused()){const t=this._tooltipOptions.visualVariables,e=s(t)?t.rotation:null,a=s(t)?t.size:null;this._tooltip.info=new Mt({tooltipOptions:this._tooltipOptions,orientation:l(-this.adapter.angle,"radians","geographic"),orientationEnabled:null==this.mode||"rotate"===this.mode,orientationPrecision:s(e)?kt(e.valueType):null,rotationType:s(e)?e.rotationType:"geographic",size:c(n(this.adapter.size,-1),"meters"),sizeUnit:s(a)?a.unit:null,sizeEnabled:null==this.mode||"scale"===this.mode,sizePrecision:s(a)?kt(a.valueType):null})}else this._tooltip.clear()}_onScaleChanged(){this.events.emit("scale-changed"),this._updateManipulatorTransform()}_updateDelayedFocusedState(){this._ringManipulator.updateStateEnabled(Dt.DelayedFocused,this.getFocused()),this._updateFocusTooltip()}_updateDragState(){if(this._ringManipulator.updateStateEnabled(Dt.Unlocked,!(s(this._scaleRotateDragData)&&"none"!==this._scaleRotateDragData.mode)),s(this._scaleRotateDragData))switch(this._scaleRotateDragData.mode){case"rotate":this._ringManipulator.updateStateEnabled(Dt.ScaleIn|Dt.ScaleOut,!1),this._ringManipulator.updateStateEnabled(Dt.RotateLeft,this._scaleRotateDragData.angleDir<0),this._ringManipulator.updateStateEnabled(Dt.RotateRight,this._scaleRotateDragData.angleDir>=0);break;case"scale":this._ringManipulator.updateStateEnabled(Dt.RotateLeft|Dt.RotateRight,!1),this._ringManipulator.updateStateEnabled(Dt.ScaleIn,this._scaleRotateDragData.scaleDir<0),this._ringManipulator.updateStateEnabled(Dt.ScaleOut,this._scaleRotateDragData.scaleDir>=0)}else this._ringManipulator.updateStateEnabled(Dt.ScaleIn|Dt.ScaleOut|Dt.RotateLeft|Dt.RotateRight,!1)}_updateManipulatorTransform(){const t=m(U.get(),this.adapter.angle,w(0,0,1)),e=this.getScale(),a=_(U.get(),v(C.get(),e,e,e));this._ringManipulator.modelTransform=f(U.get(),a,t)}_createRingManipulator(){const t=(t,e,a)=>{const i=[],o=Math.ceil(st*(e-t)/(2*Math.PI));for(let s=0;s<o+1;s++){const r=t+s*(e-t)/o;i.push(w(a*Math.cos(r),a*Math.sin(r),0))}return i},e=e=>t(0,2*Math.PI,e),a=t=>[[-t/2,0],[t/2,0],[t/2,q/2],[-t/2,q/2]],i=(t,e)=>ct.createPathExtrusionGeometry(a(e),t,[],[],!1),o=e(Z),s=i(o,Q),r={left:[],right:[]},n=[];for(let j=0;j<2;j++){const e=j*Math.PI-Math.PI/4,a=Math.PI/2-rt,o=e+a,s=e+Math.PI/2-a,l=t(o,s,$),c=i(l,tt);n.push(l),n.push(t(o,s,et-Q/2)),r.left.push(c),r.right.push(c);for(let t=0;t<2;t++){const e=0===t,a=S();if(e){M(a,a,[1,-1,1]),D(a,a,-o,[0,0,1]);const t=Math.round(B*(l.length-1));a[12]=l[t][0],a[13]=l[t][1],a[14]=l[t][2]}else{D(a,a,s,[0,0,1]);const t=Math.round((1-B)*(l.length-1));a[12]=l[t][0],a[13]=l[t][1],a[14]=l[t][2]}const i=ct.createExtrudedTriangle(J,0,K,q);ct.transformInPlace(i,a),(e?r.left:r.right).push(i)}}const l=[];for(let M=0;M<2;M++){const e=M*Math.PI-Math.PI/4,a=Math.PI/2-nt,o=e+a,s=e+Math.PI/2-a,r=t(o,s,et);l.push(i(r,tt))}const c=e(Z+at),h=e(Z+it),p=i(c,tt),u=i(h,tt),d=e(Z-at),g=e(Z-it),m=i(d,tt),_=i(g,tt),f=this._createMaterial(),v=this._createMaterial(.66),y=this._createMaterial(.5),b=this._createMaterial(.33);let T=[{geometry:s,material:f,stateMask:Dt.DelayedFocused},{geometry:s,material:y,stateMask:gt.None}];this.mode&&"scale"!==this.mode||(T=T.concat([{geometry:l,material:f,stateMask:Dt.DelayedFocused|Dt.Unlocked},{geometry:p,material:v,stateMask:Dt.DelayedFocused|Dt.ScaleIn},{geometry:u,material:b,stateMask:Dt.DelayedFocused|Dt.ScaleIn},{geometry:m,material:v,stateMask:Dt.DelayedFocused|Dt.ScaleOut},{geometry:_,material:b,stateMask:Dt.DelayedFocused|Dt.ScaleOut}])),this.mode&&"rotate"!==this.mode||(T=T.concat([{geometry:r.right,material:f,stateMask:Dt.DelayedFocused|Dt.Unlocked},{geometry:r.left,material:f,stateMask:Dt.DelayedFocused|Dt.RotateLeft},{geometry:r.right,material:f,stateMask:Dt.DelayedFocused|Dt.RotateRight}]));const R=[o,...n];return new z({view:this.tool.view,renderObjects:T,autoScaleRenderObjects:!1,worldOriented:!0,radius:Q,focusMultiplier:1,touchMultiplier:1.5,elevationInfo:x(this.tool.graphicState.graphic),collisionType:{type:"ribbon",paths:R,direction:w(0,0,1)}})}_createMaterial(t=1){const e=O([...W,t]);return new pt({color:e,transparent:1!==t,cullFace:lt.Back,renderOccluded:ht.Transparent})}get test(){return{ringManipulator:this._ringManipulator,tooltip:this._tooltip}}}function yt(t,e){const a=y(C.get(),e.renderStart,t.origin),i=y(C.get(),e.renderEnd,t.origin),o=b(a),s=b(i);return 0===o?0:s/o}function bt(t,e,a,i){const{renderStart:o,renderEnd:s}=t,r=Tt(o,i,C.get()),n=Tt(s,i,C.get());if(T(r,n)<X*X)return null;const l=y(C.get(),o,a),c=R(C.get(),l,P(e)),h=o,p=j(C.get(),h,c),u=Tt(a,i,C.get()),d=r,g=Tt(p,i,C.get()),m=y(C.get(),g,d),_=y(C.get(),r,u),f=E(d,m),M=E(u,_);return F(f,n)<F(M,n)?"rotate":"scale"}function Tt(t,e,a){return e.projectToScreen(t,wt),v(a,wt[0],wt[1],0)}function Rt(t,e){let a=null,i=1;const o=()=>i;return{start:()=>{i=t.getScale(),a=t.getScale,t.getScale=o,e()},update:t=>(i+=((i+1)/2-i)*Math.min(t*ot,1),e(),Math.abs(i-1)<.01?St.STOP:St.CONTINUE),destroy:()=>{t.getScale=a,e()}}}function jt(t,e){let a=0,i=null;const o=()=>!1;return{start:()=>{i=t.getFocused,t.getFocused=o,a=0,e()},update:t=>(a+=t,!i()||a>Y?St.STOP:St.CONTINUE),destroy:()=>{t.getFocused=i,e()}}}function kt(t){switch(t){case"integer":case"long":return 0;default:return null}}!function(t){t[t.CONTINUE=0]="CONTINUE",t[t.STOP=1]="STOP"}(St||(St={}));const wt=g();export{vt as GraphicScaleRotateTransform};
5
+ import{cyclicalPI as t}from"../../../../../core/Cyclical.js";import e from"../../../../../core/Evented.js";import a from"../../../../../core/Handles.js";import{clamp as i,rad2deg as o}from"../../../../../core/mathUtils.js";import{isSome as s,destroyMaybe as r,unwrapOr as n,isNone as l}from"../../../../../core/maybe.js";import{createAngle as c,createLength as h}from"../../../../../core/quantityUtils.js";import{when as p,initial as u,watch as d}from"../../../../../core/reactiveUtils.js";import{addFrameTask as g}from"../../../../../core/scheduling.js";import{createScreenPointArray as m}from"../../../../../core/screenUtils.js";import{d as _,u as f,m as M,h as D,e as S}from"../../../../../chunks/mat4.js";import{c as v}from"../../../../../chunks/mat4f64.js";import{s as y,b,l as T,d as R,f as j,a as k}from"../../../../../chunks/vec3.js";import{a as w,f as O}from"../../../../../chunks/vec3f64.js";import{b as A}from"../../../../../chunks/vec4f64.js";import{fromPositionAndNormal as I,create as P,normal as E}from"../../../../../geometry/support/plane.js";import{wrap as F,distance2 as C}from"../../../../../geometry/support/ray.js";import{sv3d as U,sm4d as x}from"../../../../../geometry/support/vectorStacks.js";import{getGraphicEffectiveElevationInfo as z}from"../../../../../support/elevationInfoUtils.js";import{Manipulator3D as L}from"../../Manipulator3D.js";import{calculateInputRotationTransform as N}from"../../manipulatorUtils.js";import{screenToRenderPlane as G}from"../dragEventPipeline3D.js";import{ManipulatorType as H}from"../ManipulatorType.js";import{ROTATE_INDICATOR_DIRECTION_BUFFER as V,SCALE_INDICATOR_DIRECTION_BUFFER as q,RING_HEIGHT as B,ROTATE_INDICATOR_ARROW_PLACEMENT_PERCENTAGE as J,ROTATE_INDICATOR_ARROW_TIP_LENGTH as K,ROTATE_INDICATOR_ARROW_TIP_RADIUS as Q,RING_THICKNESS as W,HANDLE_COLOR as X,DRAG_THRESHOLD_PX as Y,RING_INDICATOR_DELAY_MS as Z,RING_RADIUS as $,INNER_INDICATOR_RADIUS as tt,INDICATOR_THICKNESS as et,OUTER_INDICATOR_RADIUS as at,SCALE_INDICATOR_OFFSET1 as it,SCALE_INDICATOR_OFFSET2 as ot,RING_RESET_ANIMATION_SPEED_FACTOR as st,GEOMETRY_SEGMENTS as rt,ROTATE_INDICATOR_ARC_LENGTH as nt,SCALE_INDICATOR_ARC_LENGTH as lt}from"../manipulations/config.js";import{CullFaceOptions as ct}from"../../../webgl-engine/lib/basicInterfaces.js";import ht from"../../../webgl-engine/lib/GeometryUtil.js";import{RenderOccludedFlag as pt}from"../../../webgl-engine/lib/Material.js";import{ColorMaterial as ut}from"../../../webgl-engine/materials/ColorMaterial.js";import{createManipulatorDragEventPipeline as dt}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateCustomFlags as gt,ManipulatorStateFlags as mt}from"../../../../interactive/interfaces.js";import{Tooltip as _t}from"../../../../interactive/tooltip/Tooltip.js";import{TransformRotateTooltipInfo as ft,TransformScaleTooltipInfo as Mt,TransformAbsoluteTooltipInfo as Dt}from"../../../../interactive/tooltip/TransformTooltipInfos.js";var St,vt;!function(t){t.ScaleIn=gt.Custom2,t.ScaleOut=gt.Custom3,t.RotateLeft=gt.Custom4,t.RotateRight=gt.Custom5,t.Unlocked=gt.Custom7,t.DelayedFocused=gt.Custom8,t.TouchInput=gt.Custom12}(St||(St={}));class yt{constructor({adapter:t,tooltipOptions:i,mode:o,tool:r}){this.mode=null,this._handles=new a,this._scaleRotateDragData=null,this._activeAnimation=null,this.events=new e,this.getFocused=()=>this._ringManipulator.focused,this.getScale=()=>s(this._scaleRotateDragData)&&"scale"===this._scaleRotateDragData.mode?this.adapter.scale:1,this.tool=r,this.mode=o,this.adapter=t,this._tooltipOptions=i,this._tooltip=new _t({view:r.view}),this._createManipulator(),this._updateDragState(),this._updateManipulatorTransform(),this._handles.add(p((()=>!this._tooltipOptions.enabled),(()=>this._tooltip.clear()),u))}get angle(){return this.adapter.angle}get scale(){return this.adapter.scale}set location(t){this._ringManipulator.location=t}set elevationAlignedLocation(t){this._ringManipulator.elevationAlignedLocation=t}get grabbing(){return this._ringManipulator.grabbing}set interactive(t){this._ringManipulator.interactive=t}destroy(){s(this._activeAnimation)&&(this._activeAnimation.frameTask.remove(),this._activeAnimation=null),this._handles=r(this._handles),this.tool.manipulators.remove(this._ringManipulator),this._ringManipulator=null,this._tooltip=r(this._tooltip)}startAnimation(t){this.cancelActiveAnimation(),t.start();const e=g({update:({deltaTime:e})=>{t.update(e)&&this.cancelActiveAnimation()}});this._activeAnimation={...t,frameTask:e}}cancelActiveAnimation(){s(this._activeAnimation)&&(this._activeAnimation.frameTask.remove(),this._activeAnimation=r(this._activeAnimation))}forEachManipulator(t){t(this._ringManipulator,H.SCALE_ROTATE)}_createManipulator(){const e=this._createRingManipulator();this._ringManipulator=e,this.tool.manipulators.add(e);const a=this.tool.graphicState.graphic,r=dt(e,((e,r,n)=>{this._scaleRotateDragData=null;const l=this.adapter.startInteraction(),c={mode:"none",origin:w(e.renderLocation),initialAngle:this.adapter.angle,angle:0,angleDir:0,scaleDir:0};this._scaleRotateDragData=c,this._updateDragState();const h=U.get();this.tool.view.renderCoordsHelper.worldUpAtPosition(e.renderLocation,h),r.next(G(this.tool.view,I(e.renderLocation,h,P()))).next((e=>{const r=E(e.plane),n=N(e.renderStart,e.renderEnd,c.origin,r),h=t.shortestSignedDiff(c.angle,n);c.angleDir=i(c.angleDir+h,-V,V),c.angle=n;const p=bt(c,e),u=p-this.adapter.scale;if(c.scaleDir=i(c.scaleDir+u,-q,q),this._onScaleChanged(),"none"===c.mode){const t=this.mode||Tt(e,e.plane,c.origin,this.tool.view.state.camera);if(s(t)){switch(t){case"rotate":this.tool.emit("graphic-rotate-start",{graphic:a,angle:0}),this.tool.emit("record-undo",{record:this.adapter.createUndoRecord()});break;case"scale":this.tool.emit("graphic-scale-start",{graphic:a,xScale:1,yScale:1}),this.tool.emit("record-undo",{record:this.adapter.createUndoRecord()})}c.mode=t}}switch(c.mode){case"rotate":l.state.angle=c.initialAngle+n;break;case"scale":l.state.scale=p,this._onScaleChanged()}switch(this._updateDragState(),this._updateManipulatorTransform(),e.action){case"start":case"update":switch(c.mode){case"rotate":this.tool.emit("graphic-rotate",{graphic:a,angle:o(c.angle)});break;case"scale":this.tool.emit("graphic-scale",{graphic:a,xScale:p,yScale:p})}break;case"end":switch(c.mode){case"rotate":this.tool.emit("graphic-rotate-stop",{graphic:a,angle:o(c.angle)});break;case"scale":this.tool.emit("graphic-scale-stop",{graphic:a,xScale:p,yScale:p})}}return"end"===e.action&&(this.startAnimation(jt(this,(()=>this._onScaleChanged()))),this._scaleRotateDragData=null,this._updateDragState(),l.done()),e})).next(this._updateTooltipPipelineStep(c)),n.next((()=>{if(l.cancel(),s(this._scaleRotateDragData)){switch(this._scaleRotateDragData.mode){case"none":break;case"rotate":this.tool.emit("graphic-rotate-stop",{graphic:a,angle:0});break;case"scale":this.tool.emit("graphic-scale-stop",{graphic:a,xScale:1,yScale:1})}this.startAnimation(jt(this,(()=>this._onScaleChanged()))),this._scaleRotateDragData=null,this._updateDragState()}this._updateFocusTooltip()}))}));this._handles.add([r,e.events.on("focus-changed",(t=>{"focus"===t.action?this.startAnimation(kt(this,(()=>this._updateDelayedFocusedState()))):this._updateDelayedFocusedState()})),e.events.on("immediate-click",(t=>{t.stopPropagation()})),d((()=>this.tool.graphicState?.displaying),(t=>this._ringManipulator.available=t),u)])}_updateTooltipPipelineStep(t){return e=>{const a=this._tooltipOptions;if(!a.enabled)return e;if("end"===e.action)return this._updateFocusTooltip(),e;const i=this._tooltip,o=this._tooltipOptions.visualVariables,r=s(o)?o.size:null,l=s(o)?o.rotation:null;switch(t.mode){case"scale":i.info=new Mt({tooltipOptions:a,scale:{value:this.adapter.scale},size:h(n(this.adapter.size,-1),"meters"),sizeUnit:s(r)?r.unit:null,sizePrecision:s(r)?wt(r.valueType):null});break;case"rotate":{const t=s(l)?wt(l.valueType):null,e=s(l)?l.rotationType:"geographic";i.info=new ft({tooltipOptions:a,rotation:c(n(-this.adapter.relativeAngle,0),"radians","geographic"),rotationPrecision:t,orientation:c(-this.adapter.angle,"radians","geographic"),orientationPrecision:t,rotationType:e})}}return e}}_updateFocusTooltip(){if(!this._tooltipOptions.enabled)return;if(this.getFocused()){const t=this._tooltipOptions.visualVariables,e=s(t)?t.rotation:null,a=s(t)?t.size:null;this._tooltip.info=new Dt({tooltipOptions:this._tooltipOptions,orientation:c(-this.adapter.angle,"radians","geographic"),orientationEnabled:null==this.mode||"rotate"===this.mode,orientationPrecision:s(e)?wt(e.valueType):null,rotationType:s(e)?e.rotationType:"geographic",size:h(n(this.adapter.size,-1),"meters"),sizeUnit:s(a)?a.unit:null,sizeEnabled:null==this.mode||"scale"===this.mode,sizePrecision:s(a)?wt(a.valueType):null})}else this._tooltip.clear()}_onScaleChanged(){this.events.emit("scale-changed"),this._updateManipulatorTransform()}_updateDelayedFocusedState(){this._ringManipulator.updateStateEnabled(St.DelayedFocused,this.getFocused()),this._updateFocusTooltip()}_updateDragState(){if(this._ringManipulator.updateStateEnabled(St.Unlocked,!(s(this._scaleRotateDragData)&&"none"!==this._scaleRotateDragData.mode)),s(this._scaleRotateDragData))switch(this._scaleRotateDragData.mode){case"rotate":this._ringManipulator.updateStateEnabled(St.ScaleIn|St.ScaleOut,!1),this._ringManipulator.updateStateEnabled(St.RotateLeft,this._scaleRotateDragData.angleDir<0),this._ringManipulator.updateStateEnabled(St.RotateRight,this._scaleRotateDragData.angleDir>=0);break;case"scale":this._ringManipulator.updateStateEnabled(St.RotateLeft|St.RotateRight,!1),this._ringManipulator.updateStateEnabled(St.ScaleIn,this._scaleRotateDragData.scaleDir<0),this._ringManipulator.updateStateEnabled(St.ScaleOut,this._scaleRotateDragData.scaleDir>=0)}else this._ringManipulator.updateStateEnabled(St.ScaleIn|St.ScaleOut|St.RotateLeft|St.RotateRight,!1)}_updateManipulatorTransform(){const t=_(x.get(),this.adapter.angle,O(0,0,1));if(l(t))return;const e=this.getScale(),a=f(x.get(),y(U.get(),e,e,e));this._ringManipulator.modelTransform=M(x.get(),a,t)}_createRingManipulator(){const t=(t,e,a)=>{const i=[],o=Math.ceil(rt*(e-t)/(2*Math.PI));for(let s=0;s<o+1;s++){const r=t+s*(e-t)/o;i.push(O(a*Math.cos(r),a*Math.sin(r),0))}return i},e=e=>t(0,2*Math.PI,e),a=t=>[[-t/2,0],[t/2,0],[t/2,B/2],[-t/2,B/2]],i=(t,e)=>ht.createPathExtrusionGeometry(a(e),t,[],[],!1),o=e($),s=i(o,W),r={left:[],right:[]},n=[];for(let j=0;j<2;j++){const e=j*Math.PI-Math.PI/4,a=Math.PI/2-nt,o=e+a,s=e+Math.PI/2-a,l=t(o,s,tt),c=i(l,et);n.push(l),n.push(t(o,s,at-W/2)),r.left.push(c),r.right.push(c);for(let t=0;t<2;t++){const e=0===t,a=v();if(e){D(a,a,[1,-1,1]),S(a,a,-o,[0,0,1]);const t=Math.round(J*(l.length-1));a[12]=l[t][0],a[13]=l[t][1],a[14]=l[t][2]}else{S(a,a,s,[0,0,1]);const t=Math.round((1-J)*(l.length-1));a[12]=l[t][0],a[13]=l[t][1],a[14]=l[t][2]}const i=ht.createExtrudedTriangle(K,0,Q,B);ht.transformInPlace(i,a),(e?r.left:r.right).push(i)}}const l=[];for(let D=0;D<2;D++){const e=D*Math.PI-Math.PI/4,a=Math.PI/2-lt,o=e+a,s=e+Math.PI/2-a,r=t(o,s,at);l.push(i(r,et))}const c=e($+it),h=e($+ot),p=i(c,et),u=i(h,et),d=e($-it),g=e($-ot),m=i(d,et),_=i(g,et),f=this._createMaterial(),M=this._createMaterial(.66),y=this._createMaterial(.5),b=this._createMaterial(.33);let T=[{geometry:s,material:f,stateMask:St.DelayedFocused},{geometry:s,material:y,stateMask:mt.None}];this.mode&&"scale"!==this.mode||(T=T.concat([{geometry:l,material:f,stateMask:St.DelayedFocused|St.Unlocked},{geometry:p,material:M,stateMask:St.DelayedFocused|St.ScaleIn},{geometry:u,material:b,stateMask:St.DelayedFocused|St.ScaleIn},{geometry:m,material:M,stateMask:St.DelayedFocused|St.ScaleOut},{geometry:_,material:b,stateMask:St.DelayedFocused|St.ScaleOut}])),this.mode&&"rotate"!==this.mode||(T=T.concat([{geometry:r.right,material:f,stateMask:St.DelayedFocused|St.Unlocked},{geometry:r.left,material:f,stateMask:St.DelayedFocused|St.RotateLeft},{geometry:r.right,material:f,stateMask:St.DelayedFocused|St.RotateRight}]));const R=[o,...n];return new L({view:this.tool.view,renderObjects:T,autoScaleRenderObjects:!1,worldOriented:!0,radius:W,focusMultiplier:1,touchMultiplier:1.5,elevationInfo:z(this.tool.graphicState.graphic),collisionType:{type:"ribbon",paths:R,direction:O(0,0,1)}})}_createMaterial(t=1){const e=A([...X,t]);return new ut({color:e,transparent:1!==t,cullFace:ct.Back,renderOccluded:pt.Transparent})}get test(){return{ringManipulator:this._ringManipulator,tooltip:this._tooltip}}}function bt(t,e){const a=b(U.get(),e.renderStart,t.origin),i=b(U.get(),e.renderEnd,t.origin),o=T(a),s=T(i);return 0===o?0:s/o}function Tt(t,e,a,i){const{renderStart:o,renderEnd:s}=t,r=Rt(o,i,U.get()),n=Rt(s,i,U.get());if(R(r,n)<Y*Y)return null;const l=b(U.get(),o,a),c=j(U.get(),l,E(e)),h=o,p=k(U.get(),h,c),u=Rt(a,i,U.get()),d=r,g=Rt(p,i,U.get()),m=b(U.get(),g,d),_=b(U.get(),r,u),f=F(d,m),M=F(u,_);return C(f,n)<C(M,n)?"rotate":"scale"}function Rt(t,e,a){return e.projectToScreen(t,Ot),y(a,Ot[0],Ot[1],0)}function jt(t,e){let a=null,i=1;const o=()=>i;return{start:()=>{i=t.getScale(),a=t.getScale,t.getScale=o,e()},update:t=>(i+=((i+1)/2-i)*Math.min(t*st,1),e(),Math.abs(i-1)<.01?vt.STOP:vt.CONTINUE),destroy:()=>{t.getScale=a,e()}}}function kt(t,e){let a=0,i=null;const o=()=>!1;return{start:()=>{i=t.getFocused,t.getFocused=o,a=0,e()},update:t=>(a+=t,!i()||a>Z?vt.STOP:vt.CONTINUE),destroy:()=>{t.getFocused=i,e()}}}function wt(t){switch(t){case"integer":case"long":return 0;default:return null}}!function(t){t[t.CONTINUE=0]="CONTINUE",t[t.STOP=1]="STOP"}(vt||(vt={}));const Ot=m();export{yt as GraphicScaleRotateTransform};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{cyclicalPI as t}from"../../../../core/Cyclical.js";import{deg2rad as e,clamp as n,acosClamped as o}from"../../../../core/mathUtils.js";import{isNone as r}from"../../../../core/maybe.js";import{createScreenPointArray as a}from"../../../../core/screenUtils.js";import{d as i,m as s,e as c}from"../../../../chunks/mat4.js";import{c as m}from"../../../../chunks/mat4f64.js";import{a as u}from"../../../../chunks/vec2.js";import{a as l}from"../../../../chunks/vec2f64.js";import{c as p,e as f,g as h,b as M,n as y,f as g,m as d,a as b,l as j,h as v,s as z,d as x}from"../../../../chunks/vec3.js";import{c as P}from"../../../../chunks/vec3f64.js";import{create as k,axis as I,fromPoints as w,wrapAxisAngle as E}from"../../../../geometry/support/axisAngle.js";import{coordinateSystemFromOneAxisAndNormalVector as S,vectorCoordinates as A}from"../../../../geometry/support/coordinateSystem.js";import{create as H,intersectRay as G,fromNormalAndOffset as U}from"../../../../geometry/support/plane.js";import{j as V,h as q,c as C}from"../../../../chunks/sphere.js";import{angle as F}from"../../../../geometry/support/vector.js";import{sv3d as R,sm4d as T}from"../../../../geometry/support/vectorStacks.js";import{fromScreen as W,fromScreenAtEye as B}from"../../support/geometryUtils/ray.js";import{intersectScreen as D}from"../../support/geometryUtils/sphere.js";import{Camera as J}from"../../webgl-engine/lib/Camera.js";var K;!function(t){t[t.Ellipsoid=0]="Ellipsoid",t[t.Silhouette=1]="Silhouette"}(K||(K={}));const L=30,N=[1,3e8],O=70;function Q(t,e,n){return n[0]=e[0]/(t.fullWidth/t.pixelRatio),n[1]=e[1]/(t.fullHeight/t.pixelRatio),n}function X(t,e,n){const o=R.get(),r=R.get(),a=R.get();p(r,t),p(a,e);const i=f(r,n),s=f(a,n);h(o,n,i),M(r,r,o),y(r,r),h(o,n,s),M(a,a,o),y(a,a);const c=f(r,a);g(o,n,r);const m=f(a,o);return Math.atan2(m,c)}function Y(t){for(;t>Math.PI;)t-=2*Math.PI;for(;t<-Math.PI;)t+=2*Math.PI;return t}function Z(t,e,n){const o=i(T.get(),n[3],I(n));M(Ot,t.eye,e),d(Ot,Ot,o),t.eye=b(Ot,Ot,e),M(Ot,t.center,e),d(Ot,Ot,o),t.center=b(Ot,Ot,e),t.up=d(Ot,t.up,o)}function $(t,e,n,o){return G(t,W(e,n,$t),o)}function _(t,e,n,o){return G(t,B(e,n,$t),o)}function tt(t,e,n,o){const r=R.get();let a=1-n;M(r,e,t.eye);const i=j(r);let s=i*(1-a);a>=0&&s<o&&(s=o,a=-(s-i)/i),Math.abs(i-s)<1e-6||(h(r,r,a),t.eye=b(Ot,t.eye,r),t.center=v(Ot,t.center,e,a))}function et(t,e,n){e.getScreenCenter(nt),D(t,e,nt,Ot)&&(e.center=Ot);const o=e.distance,r=o*n;if(Math.abs(o-r)<1e-6)return;const a=h(R.get(),e.viewForward,r);e.eye=M(Ot,e.center,a)}const nt=a();function ot(t,e,n){rt(e,n),y(n,n),h(n,n,t)}function rt(t,e){z(e,0,0,0);for(const n of t)b(e,e,n);h(e,e,1/t.length)}function at(t,e,n,o){return Math.sin(t/j(e))*(n+o.radius)}function it(t,e,n,o){return at(Math.PI/2,e,n,o)+(t-Math.PI/2)}var st;!function(t){t[t.Vertical=0]="Vertical",t[t.Horizontal=1]="Horizontal"}(st||(st={}));const ct={Elevation:3e4,Angle:e(6)},mt={Pole:.95,Angle:e(18),Tilt:45},ut=e(80);function lt(t,e,n,o,r,a){const i=P(),s=C();let c=!0,m=!0;return t.intersectScreen(n,i,a)?s[3]=j(i):(m=!1,e.aboveGround&&r!==K.Ellipsoid?s[3]=Math.max(j(e.center),.9*o.radius):s[3]=j(e.eye)-e.relativeElevation,r===K.Silhouette?Mt(s,e,n,i):c=D(s,e,n,i)),{sphere:s,scenePickPoint:c?i:null,hasGeometryIntersection:m}}function pt(t,e,n,o){if(j(t.eye)-o.radius>ct.Elevation)return st.Horizontal;if(!n)return st.Vertical;B(t,e,_t);return-Math.sign(t.relativeElevation)*(.5*Math.PI+F(t.eye,_t.direction))<ct.Angle?st.Vertical:st.Horizontal}function ft(t,e,n){M(ht,n,e),t.eye=M(Ot,t.eye,ht),t.center=M(Ot,t.center,ht)}const ht=P();function Mt(t,e,n,o){const a=B(e,n,$t);return!r(a)&&(V(t,a,yt),q(t,a,o)?!(x(yt,a.origin)<x(o,a.origin))||(p(o,yt),!1):(M(gt,e.eye,e.center),y(gt,gt),U(gt,-f(y(gt,gt),yt),dt),G(dt,a,o),!1))}const yt=P(),gt=P(),dt=H();function bt(r,a,i,s,c,m){let u;if(g(Yt,r,a),M(Qt,r,a),j(r)<=c||!s.aboveGround){g(i,Qt,s.eye);const l=f(r,a)/(j(r)*j(a)),p=Math.cos(n(t.normalize(e(m)),0,ut));u=-o(l)-Math.max(0,j(a)-c)/(p*c)}else M(jt,s.eye,s.center),g(i,Qt,jt),u=-j(Qt)/c;return y(i,i),h(i,i,j(Yt)),u}const jt=P();function vt(r,a,i,s){let c,m;const u=Math.cos(n(t.normalize(e(s)),0,ut));return c=a>i?-(a-i)/(u*i):a<-i?Math.PI-(a+i)/(u*i):o(a/i),m=r>i?-(r-i)/(u*i):r<-i?Math.PI-(r+i)/(u*i):o(r/i),(m-c)*i}function zt(t,e,n,o,r,a,i,s,c,m){const l=vt(t[2],e[2],i[3],c),p=m?vt(t[0],e[0],i[3],180):e[0]-t[0],h=Math.sin(s)*p-Math.cos(s)*l,M=Math.cos(s)*p+Math.sin(s)*l;y(Ot,r);const g=m?h/Math.sqrt(Math.abs(i[3]**2-f(n,Ot)**2)):h/i[3],d=M/Math.sqrt(Math.abs(i[3]**2-f(n,o)**2));u(a,g,d)}function xt(t,e,n,o,r,a,i,s,c,m){g(Yt,t,e),S(a.up,a.eye,Ct,Ft,Rt),S([0,0,1],a.eye,Ut,Vt,qt),p(n,Vt),p(o,Ut),y(n,n),h(n,n,j(Yt)),A(t,y(Ft,Ft),y(Rt,Rt),y(Ct,Ct),Tt),A(e,Ft,Rt,Ct,Wt),zt(Tt,Wt,t,Ut,Vt,r,i,s,c,m)}function Pt(t,e,n,o,r,a,c){i(Jt,r,o),i(Kt,c,a),s(Lt,Jt,Kt),M(e,t,n),d(e,e,Lt),b(e,e,n)}function kt(t,e,n,o,r,a){i(Jt,o,n),i(Kt,a,r),s(Lt,Jt,Kt),M(Ot,t.eye,e),d(Ot,Ot,Lt),t.eye=b(Ot,Ot,e),M(Ot,t.center,e),d(Ot,Ot,Lt),t.center=b(Ot,Ot,e),M(Ot,t.up,e),d(Ot,Ot,Lt),t.up=b(Ot,Ot,e)}function It(t,e,n,o,r,a,i=mt.Pole,s=mt.Angle){const c=Math.abs(o)>Math.PI-s||Math.abs(o)<s,m=Math.abs(t[2])<n*i||Math.abs(e)>n;return!!(c&&m&&a.aboveGround&&r<mt.Tilt)}function wt(t,e,n,o,r,a){if(a)w(n,o,Dt),Z(e,t,Dt);else{const a=bt(n,o,Zt,e,t[3],r);Z(e,t,E(Zt,a))}}function Et(t,e,n,o,r,a,i){const s=i?20:1,c=1e-12;let m,u;p(Nt,o),Xt.copyFrom(e);for(let l=0;l<s&&x(n,Nt)>c&&(m=x(n,Nt),xt(n,Nt,Vt,Ut,Bt,Xt,t,r,a,i),kt(Xt,t,Ut,Bt[1],Vt,Bt[0]),Pt(Nt,Nt,t,Ut,Bt[1],Vt,Bt[0]),u=x(n,Nt),u<m||0===l);l++)e.copyFrom(Xt)}function St(n,o,r,a,i,s,c){It(r,f(o.up,r),n[3],-t.normalize(e(i)),s,o,mt.Pole,mt.Angle)?Et(n,o,r,a,-t.normalize(e(i)),s,c):wt(n,o,r,a,s,c)}function At(t,e,n,o,r,a){const{eye:i}=t;S([0,0,1],i,Ut,Vt,qt);const s=e.translation[0]*n.pan,m="zoom"===r.mode?0:e.translation[1]*n.pan,u=Math.max(Math.sqrt(Math.abs(1-f(t.center,Ut)**2/j(t.center)**2)),.5),l=(Math.sin(a)*m+Math.cos(a)*s)/u,p=-Math.cos(a)*m+Math.sin(a)*s;switch(c(o.pan.matrix,o.pan.matrix,l,Ut),o.pan.enabled=!0,r.mode){case"pan":c(o.pan.matrix,o.pan.matrix,p,Vt),o.pan.enabled=!0;break;case"zoom":o.zoom=-e.translation[1]*n.zoom}}function Ht(t,e,n,o,r){const{eye:a,viewRight:i}=t,s=g(R.get(),i,a),m=e.translation[0]*n.pan;switch(0!==m&&(c(o.pan.matrix,o.pan.matrix,-m,s),o.pan.enabled=!0),r.mode){case"pan":{const t=e.translation[1]*n.pan;0!==t&&(c(o.pan.matrix,o.pan.matrix,t,i),o.pan.enabled=!0);break}case"zoom":o.zoom=-e.translation[1]*n.zoom}}function Gt(n,o,r,a,i,s,c,m,u){It(n.center,f(n.up,n.center),j(n.center),-t.normalize(e(s)),c,o)?At(o,r,a,m,u,-t.normalize(e(i))):Ht(o,r,a,m,u)}const Ut=P(),Vt=P(),qt=P(),Ct=P(),Ft=P(),Rt=P(),Tt=P(),Wt=P(),Bt=l(),Dt=k(),Jt=m(),Kt=m(),Lt=m(),Nt=P(),Ot=P(),Qt=P(),Xt=new J,Yt=P(),Zt=P(),$t={origin:P(),direction:P()},_t={origin:P(),direction:P()};export{N as DISTANCE_CLAMP_VALUES,st as NavigationMode,L as PIVOT_DISTANCE_MODIFIER,mt as PreservingHeadingThreshold,O as SCREEN_PIXEL_AREA,K as SpherePickPointFallback,ut as TiltThresholdPanningSpeed,ct as VerticalPanTresholds,ft as applyPanPlanar,wt as applyPanSphericalDirectRotation,Et as applyPanSphericalPreserveHeading,Z as applyRotation,kt as applyRotationWithTwoAxes,et as applyZoomOnSphere,tt as applyZoomToPoint,rt as centroid,ot as centroidOnSphere,pt as decideNavigationMode,$ as intersectPlaneFromScreenPoint,_ as intersectPlaneFromScreenPointAtEye,vt as lengthFromPoints,Q as normalizeCoordinate,Y as normalizeRotationDelta,it as offSurfaceTiltToEyeTiltGlobal,at as onSurfaceTiltToEyeTiltGlobal,Gt as panMotionToRotationMatrix,St as panToPosition,lt as pickPointAndInitSphere,It as preserveHeadingThreshold,Pt as rotatePointAroundTwoAxes,bt as rotationAngleAndAxisDirectRotation,xt as rotationAnglesAndAxesHeadingPreserving,zt as rotationAnglesHeadingPreserving,X as rotationFromPointsAroundAxis,Mt as sphereOrPlanePointFromScreenPoint};
5
+ import{cyclicalPI as t}from"../../../../core/Cyclical.js";import{deg2rad as e,clamp as n,acosClamped as o}from"../../../../core/mathUtils.js";import{isNone as r}from"../../../../core/maybe.js";import{createScreenPointArray as a}from"../../../../core/screenUtils.js";import{d as i,m as s,e as c}from"../../../../chunks/mat4.js";import{c as m}from"../../../../chunks/mat4f64.js";import{a as u}from"../../../../chunks/vec2.js";import{a as l}from"../../../../chunks/vec2f64.js";import{c as p,e as f,g as h,b as M,n as y,f as g,m as d,a as b,l as j,h as v,s as z,d as x}from"../../../../chunks/vec3.js";import{c as P}from"../../../../chunks/vec3f64.js";import{create as k,axis as I,fromPoints as w,wrapAxisAngle as E}from"../../../../geometry/support/axisAngle.js";import{coordinateSystemFromOneAxisAndNormalVector as S,vectorCoordinates as A}from"../../../../geometry/support/coordinateSystem.js";import{create as H,intersectRay as G,fromNormalAndOffset as U}from"../../../../geometry/support/plane.js";import{j as V,h as q,c as C}from"../../../../chunks/sphere.js";import{angle as F}from"../../../../geometry/support/vector.js";import{sv3d as R,sm4d as T}from"../../../../geometry/support/vectorStacks.js";import{fromScreen as W,fromScreenAtEye as B}from"../../support/geometryUtils/ray.js";import{intersectScreen as D}from"../../support/geometryUtils/sphere.js";import{Camera as J}from"../../webgl-engine/lib/Camera.js";var K;!function(t){t[t.Ellipsoid=0]="Ellipsoid",t[t.Silhouette=1]="Silhouette"}(K||(K={}));const L=30,N=[1,3e8],O=70;function Q(t,e,n){return n[0]=e[0]/(t.fullWidth/t.pixelRatio),n[1]=e[1]/(t.fullHeight/t.pixelRatio),n}function X(t,e,n){const o=R.get(),r=R.get(),a=R.get();p(r,t),p(a,e);const i=f(r,n),s=f(a,n);h(o,n,i),M(r,r,o),y(r,r),h(o,n,s),M(a,a,o),y(a,a);const c=f(r,a);g(o,n,r);const m=f(a,o);return Math.atan2(m,c)}function Y(t){for(;t>Math.PI;)t-=2*Math.PI;for(;t<-Math.PI;)t+=2*Math.PI;return t}function Z(t,e,n){const o=i(T.get(),n[3],I(n));r(o)||(M(Ot,t.eye,e),d(Ot,Ot,o),t.eye=b(Ot,Ot,e),M(Ot,t.center,e),d(Ot,Ot,o),t.center=b(Ot,Ot,e),t.up=d(Ot,t.up,o))}function $(t,e,n,o){return G(t,W(e,n,$t),o)}function _(t,e,n,o){return G(t,B(e,n,$t),o)}function tt(t,e,n,o){const r=R.get();let a=1-n;M(r,e,t.eye);const i=j(r);let s=i*(1-a);a>=0&&s<o&&(s=o,a=-(s-i)/i),Math.abs(i-s)<1e-6||(h(r,r,a),t.eye=b(Ot,t.eye,r),t.center=v(Ot,t.center,e,a))}function et(t,e,n){e.getScreenCenter(nt),D(t,e,nt,Ot)&&(e.center=Ot);const o=e.distance,r=o*n;if(Math.abs(o-r)<1e-6)return;const a=h(R.get(),e.viewForward,r);e.eye=M(Ot,e.center,a)}const nt=a();function ot(t,e,n){rt(e,n),y(n,n),h(n,n,t)}function rt(t,e){z(e,0,0,0);for(const n of t)b(e,e,n);h(e,e,1/t.length)}function at(t,e,n,o){return Math.sin(t/j(e))*(n+o.radius)}function it(t,e,n,o){return at(Math.PI/2,e,n,o)+(t-Math.PI/2)}var st;!function(t){t[t.Vertical=0]="Vertical",t[t.Horizontal=1]="Horizontal"}(st||(st={}));const ct={Elevation:3e4,Angle:e(6)},mt={Pole:.95,Angle:e(18),Tilt:45},ut=e(80);function lt(t,e,n,o,r,a){const i=P(),s=C();let c=!0,m=!0;return t.intersectScreen(n,i,a)?s[3]=j(i):(m=!1,e.aboveGround&&r!==K.Ellipsoid?s[3]=Math.max(j(e.center),.9*o.radius):s[3]=j(e.eye)-e.relativeElevation,r===K.Silhouette?Mt(s,e,n,i):c=D(s,e,n,i)),{sphere:s,scenePickPoint:c?i:null,hasGeometryIntersection:m}}function pt(t,e,n,o){if(j(t.eye)-o.radius>ct.Elevation)return st.Horizontal;if(!n)return st.Vertical;B(t,e,_t);return-Math.sign(t.relativeElevation)*(.5*Math.PI+F(t.eye,_t.direction))<ct.Angle?st.Vertical:st.Horizontal}function ft(t,e,n){M(ht,n,e),t.eye=M(Ot,t.eye,ht),t.center=M(Ot,t.center,ht)}const ht=P();function Mt(t,e,n,o){const a=B(e,n,$t);return!r(a)&&(V(t,a,yt),q(t,a,o)?!(x(yt,a.origin)<x(o,a.origin))||(p(o,yt),!1):(M(gt,e.eye,e.center),y(gt,gt),U(gt,-f(y(gt,gt),yt),dt),G(dt,a,o),!1))}const yt=P(),gt=P(),dt=H();function bt(r,a,i,s,c,m){let u;if(g(Yt,r,a),M(Qt,r,a),j(r)<=c||!s.aboveGround){g(i,Qt,s.eye);const l=f(r,a)/(j(r)*j(a)),p=Math.cos(n(t.normalize(e(m)),0,ut));u=-o(l)-Math.max(0,j(a)-c)/(p*c)}else M(jt,s.eye,s.center),g(i,Qt,jt),u=-j(Qt)/c;return y(i,i),h(i,i,j(Yt)),u}const jt=P();function vt(r,a,i,s){let c,m;const u=Math.cos(n(t.normalize(e(s)),0,ut));return c=a>i?-(a-i)/(u*i):a<-i?Math.PI-(a+i)/(u*i):o(a/i),m=r>i?-(r-i)/(u*i):r<-i?Math.PI-(r+i)/(u*i):o(r/i),(m-c)*i}function zt(t,e,n,o,r,a,i,s,c,m){const l=vt(t[2],e[2],i[3],c),p=m?vt(t[0],e[0],i[3],180):e[0]-t[0],h=Math.sin(s)*p-Math.cos(s)*l,M=Math.cos(s)*p+Math.sin(s)*l;y(Ot,r);const g=m?h/Math.sqrt(Math.abs(i[3]**2-f(n,Ot)**2)):h/i[3],d=M/Math.sqrt(Math.abs(i[3]**2-f(n,o)**2));u(a,g,d)}function xt(t,e,n,o,r,a,i,s,c,m){g(Yt,t,e),S(a.up,a.eye,Ct,Ft,Rt),S([0,0,1],a.eye,Ut,Vt,qt),p(n,Vt),p(o,Ut),y(n,n),h(n,n,j(Yt)),A(t,y(Ft,Ft),y(Rt,Rt),y(Ct,Ct),Tt),A(e,Ft,Rt,Ct,Wt),zt(Tt,Wt,t,Ut,Vt,r,i,s,c,m)}function Pt(t,e,n,o,r,a,c){i(Jt,r,o),i(Kt,c,a),s(Lt,Jt,Kt),M(e,t,n),d(e,e,Lt),b(e,e,n)}function kt(t,e,n,o,r,a){i(Jt,o,n),i(Kt,a,r),s(Lt,Jt,Kt),M(Ot,t.eye,e),d(Ot,Ot,Lt),t.eye=b(Ot,Ot,e),M(Ot,t.center,e),d(Ot,Ot,Lt),t.center=b(Ot,Ot,e),M(Ot,t.up,e),d(Ot,Ot,Lt),t.up=b(Ot,Ot,e)}function It(t,e,n,o,r,a,i=mt.Pole,s=mt.Angle){const c=Math.abs(o)>Math.PI-s||Math.abs(o)<s,m=Math.abs(t[2])<n*i||Math.abs(e)>n;return!!(c&&m&&a.aboveGround&&r<mt.Tilt)}function wt(t,e,n,o,r,a){if(a)w(n,o,Dt),Z(e,t,Dt);else{const a=bt(n,o,Zt,e,t[3],r);Z(e,t,E(Zt,a))}}function Et(t,e,n,o,r,a,i){const s=i?20:1,c=1e-12;let m,u;p(Nt,o),Xt.copyFrom(e);for(let l=0;l<s&&x(n,Nt)>c&&(m=x(n,Nt),xt(n,Nt,Vt,Ut,Bt,Xt,t,r,a,i),kt(Xt,t,Ut,Bt[1],Vt,Bt[0]),Pt(Nt,Nt,t,Ut,Bt[1],Vt,Bt[0]),u=x(n,Nt),u<m||0===l);l++)e.copyFrom(Xt)}function St(n,o,r,a,i,s,c){It(r,f(o.up,r),n[3],-t.normalize(e(i)),s,o,mt.Pole,mt.Angle)?Et(n,o,r,a,-t.normalize(e(i)),s,c):wt(n,o,r,a,s,c)}function At(t,e,n,o,r,a){const{eye:i}=t;S([0,0,1],i,Ut,Vt,qt);const s=e.translation[0]*n.pan,m="zoom"===r.mode?0:e.translation[1]*n.pan,u=Math.max(Math.sqrt(Math.abs(1-f(t.center,Ut)**2/j(t.center)**2)),.5),l=(Math.sin(a)*m+Math.cos(a)*s)/u,p=-Math.cos(a)*m+Math.sin(a)*s;switch(c(o.pan.matrix,o.pan.matrix,l,Ut),o.pan.enabled=!0,r.mode){case"pan":c(o.pan.matrix,o.pan.matrix,p,Vt),o.pan.enabled=!0;break;case"zoom":o.zoom=-e.translation[1]*n.zoom}}function Ht(t,e,n,o,r){const{eye:a,viewRight:i}=t,s=g(R.get(),i,a),m=e.translation[0]*n.pan;switch(0!==m&&(c(o.pan.matrix,o.pan.matrix,-m,s),o.pan.enabled=!0),r.mode){case"pan":{const t=e.translation[1]*n.pan;0!==t&&(c(o.pan.matrix,o.pan.matrix,t,i),o.pan.enabled=!0);break}case"zoom":o.zoom=-e.translation[1]*n.zoom}}function Gt(n,o,r,a,i,s,c,m,u){It(n.center,f(n.up,n.center),j(n.center),-t.normalize(e(s)),c,o)?At(o,r,a,m,u,-t.normalize(e(i))):Ht(o,r,a,m,u)}const Ut=P(),Vt=P(),qt=P(),Ct=P(),Ft=P(),Rt=P(),Tt=P(),Wt=P(),Bt=l(),Dt=k(),Jt=m(),Kt=m(),Lt=m(),Nt=P(),Ot=P(),Qt=P(),Xt=new J,Yt=P(),Zt=P(),$t={origin:P(),direction:P()},_t={origin:P(),direction:P()};export{N as DISTANCE_CLAMP_VALUES,st as NavigationMode,L as PIVOT_DISTANCE_MODIFIER,mt as PreservingHeadingThreshold,O as SCREEN_PIXEL_AREA,K as SpherePickPointFallback,ut as TiltThresholdPanningSpeed,ct as VerticalPanTresholds,ft as applyPanPlanar,wt as applyPanSphericalDirectRotation,Et as applyPanSphericalPreserveHeading,Z as applyRotation,kt as applyRotationWithTwoAxes,et as applyZoomOnSphere,tt as applyZoomToPoint,rt as centroid,ot as centroidOnSphere,pt as decideNavigationMode,$ as intersectPlaneFromScreenPoint,_ as intersectPlaneFromScreenPointAtEye,vt as lengthFromPoints,Q as normalizeCoordinate,Y as normalizeRotationDelta,it as offSurfaceTiltToEyeTiltGlobal,at as onSurfaceTiltToEyeTiltGlobal,Gt as panMotionToRotationMatrix,St as panToPosition,lt as pickPointAndInitSphere,It as preserveHeadingThreshold,Pt as rotatePointAroundTwoAxes,bt as rotationAngleAndAxisDirectRotation,xt as rotationAnglesAndAxesHeadingPreserving,zt as rotationAnglesHeadingPreserving,X as rotationFromPointsAroundAxis,Mt as sphereOrPlanePointFromScreenPoint};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{clamp as e}from"../../../core/mathUtils.js";import{isNone as t,isSome as i,abortMaybe as s}from"../../../core/maybe.js";import n from"../../../core/ObjectPool.js";import{c as r,a}from"../../../chunks/vec2.js";import{a as o}from"../../../chunks/vec2f64.js";import{b as h,p as l,e as d,g as u,a as c,l as g}from"../../../chunks/vec3.js";import{c as f,u as p}from"../../../chunks/vec3f64.js";import{E as m}from"../../../chunks/common.js";import{getReferenceEllipsoid as _}from"../../../geometry/projectionEllipsoid.js";import{create as A,equals as y}from"../../../geometry/support/aaBoundingRect.js";import{c as E}from"../../../chunks/sphere.js";import{VectorTile as v}from"../../2d/engine/vectorTiles/VectorTile.js";import{ImageWithType as T}from"../support/StreamDataLoader.js";import{ElevationBounds as L}from"./ElevationBounds.js";import{ElevationTileAgent as M}from"./ElevationTileAgent.js";import{LODSnapping as I,TextureUpdate as D,NeighborIndex as N}from"./interfaces.js";import{LayerClass as b,LayerClasses as S}from"./LayerClass.js";import{MapTileAgent as x}from"./MapTileAgent.js";import{RasterTile as j}from"./RasterTile.js";import{MAX_PATCH_TESSELATION as O,getElevationDesiredResolutionLevel as U}from"./TerrainConst.js";import{weakAssert as C,getLayerWithExtentRange as R,isBlendableLayerView as P,oppositeCorner as B,neighborCornerIndices as G,neighborEdgeIndices as V,oppositeEdge as W,internalAssert as w,isNorth as q,isSouth as H,isWest as F,isEast as k,ENABLE_WATERPROOFNESS_TESTS as X,isWestCorner as z,isNorthCorner as J}from"./terrainUtils.js";import{TILE_AGENT_DONE as Y}from"./TileAgent.js";import{TilePerLayerInfo as $}from"./TilePerLayerInfo.js";import Q from"./TileTexture.js";import{TileUpdate as K}from"./TileUpdate.js";import{fallsWithinLayer as Z}from"./tileUtils.js";import{getGpuMemoryUsage as ee}from"../../webgl/Util.js";const te=f(),ie=f(),se=f(),ne=.1;class re{constructor(){this.fovX=0,this.fovY=0,this.relativeWidthLimit=0,this.relativeHeightLimit=0,this.maxLod=0,this.angledSplitBias=0,this.aboveGround=!0}}class ae{constructor(){this.lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this._dirty=!0,this._previouslyRendered=!1,this.extent=A(),this._elevationBounds=o(),this.layerInfo=[[],[]],this.extentInRadians=A(),this.centerAtSeaLevel=f(),this._center=[f(),E(),f()],this.up=p(),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=null,this._mapTileMemory=0,this._mapDataRefCount=0,this._screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0}static prune(){le.prune(0),de.prune(0),$.prune()}get usedMemory(){return t(this._usedMemory)&&this._updateMemoryUsed(),i(this._usedMemory)?this._usedMemory:0+(this.isCached?0:this.mapTileMemory)}get cachedMemory(){return this.isCached?this.mapTileMemory:0}get mapTileMemory(){t(this._usedMemory)&&this._updateMemoryUsed();let e=this._mapTileMemory;for(const{data:t}of this.layerInfo[b.MAP])t instanceof v&&(e+=t.memoryUsage);return e}get isCached(){return!this.shouldLoad&&this._mapDataRefCount<=0}get maxTesselation(){return this._maxTesselation}get isWithinClippingArea(){return this._isWithinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBounds(){return this._elevationBounds}get level(){return this.lij[0]}get key(){return`${this.lij[0]}/${this.lij[1]}/${this.lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[ce.MIDDLE][3]}get screenDepth(){return this._screenDepth}get visible(){return this._dirty&&this.computeVisibility(),this._visible}computeVisibility(){this._dirty=!1;const e=this._intersectsClippingArea&&this._isVisible(this.surface.frustum);return e!==this._visible&&(this._visible=e,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setNeedsRender(),this.updateAgentSuspension()),this._visible}get loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setNeedsRender()),e}get shouldLoad(){if(this._surface.lodSnapping===I.ON){const e=this.level-this._surface.snapLevel;if(0===e)return!0;if(1===e)return!1}return this.isLeaf}init(e,t,i){this.lij[0]=e[0],this.lij[1]=e[1],this.lij[2]=e[2],this.ellipsoid=_(i.tilingScheme.spatialReference),i.tilingScheme.getExtent(e[0],e[1],e[2],this.extent),i.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,i.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[ce.MIDDLE][3]=0,this.vlevel=e?e[0]:0,t&&t.elevationBounds?r(this._elevationBounds,t.elevationBounds):a(this._elevationBounds,0,0),this._pendingUpdates=0,this.renderData=null,this._screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=t,this.unsetChildren(),this._surface=i,this.updateVisibility();for(const s of S){const e=i.numLayers(s),t=this.layerInfo[s];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=$.acquire(this._surface.upsampleInfoPool),s===b.ELEVATION&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(i.tilingScheme.pixelSize,O)}release(){C(!this.renderData,"tile.renderData was not unloaded"),this._surface.upsampleMapCache.pop(this.key);for(const e of S){for(const t of this.layerInfo[e])t.release();this.layerInfo[e].length=0}this._parent=null,this._surface=null,this._usedMemory=null}refMapData(){++this._mapDataRefCount,this.isCached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){if(--this._mapDataRefCount,this.isCached){const e=this.cachedMemory;e>0&&(this._surface.upsampleMapCache.put(this.key,this,e),this.setMemoryDirty())}}setMemoryDirty(){this._usedMemory=null}get cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_updateMemoryUsed(){this._usedMemory=0,this._mapTileMemory=0;const e=this.layerInfo[b.MAP];for(let i=0;i<e.length;i++)this._mapTileMemory+=this.getUsedMemoryForLayer(b.MAP,i);const t=this.cpuImageMemorySize;for(const i of this.layerInfo[b.ELEVATION])this._usedMemory+=i.data?t:0;this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._mapTileMemory+=ee(this.renderData.textureDescriptor)),this.isCached&&this._surface.upsampleMapCache.updateSize(this.key,this,this.cachedMemory)}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];if(!i||!i.data)return 0;if(e!==b.MAP||this.isCached){if(e===b.ELEVATION)return this.cpuImageMemorySize}else{const e=i.data;if(e instanceof Q)return ee(e.texture);if(e instanceof HTMLImageElement||e instanceof T)return this.cpuImageMemorySize;if(e instanceof v||e instanceof j)return e.memoryUsage}return 0}updateScreenDepth(e){const t=this._center[ce.MIDDLE],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this._screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,t,s){if(i(e.frustum)&&(!this._intersectsClippingArea||!this._isVisible(e.frustum)))return K.NONE;const n=this.level;h(te,this._center[ce.MIDDLE],t);let r=l(te),a=ce.MIDDLE;h(ie,this._center[ce.TOP],t);const o=l(ie);o<r&&(r=o,a=ce.TOP),h(ie,this._center[ce.BOTTOM],t);const f=l(ie);if(f<r&&(r=f,a=ce.BOTTOM),this._edgeLen2>r&&n<e.maxLod)return K.SPLIT;const p=Math.sqrt(r),m=e.fovX*p*2,_=this._edgeLen/m,A=()=>{const t=n+Math.ceil(-Math.log2(e.relativeWidthLimit/_));return t!==this.vlevel?(this.vlevel=t,K.VSPLITMERGE):K.NONE_HIT_MAXLOD};if(s===I.ON){if(1===this._surface.snapLevel-n)return n>=e.maxLod?A():K.SPLIT}const y=d(this.up,te),E=this._elevationBounds[1]-this._elevationBounds[0],v=E/this.edgeLen;if(e.aboveGround&&y>0&&v<.001){if(y/p-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-v>0)return K.NONE}if(_<e.relativeWidthLimit)return this.vlevel!==this.level?(this.vlevel=this.level,K.VSPLITMERGE):K.NONE;if(n>=e.maxLod)return A();if(n>6){h(ie,this._center[a],t),u(se,this.up,y),h(se,se,ie);const i=l(se);if(i>this.radius*this.radius){u(se,se,this.radius/Math.sqrt(i)),c(se,se,this._center[a]),h(se,t,se);const s=Math.min(1,(Math.abs(d(se,this.up))+.5*E+this._curvatureHeight)/g(se)),n=ne/e.angledSplitBias,r=e.fovY*p*2;if(s*(this._edgeLen/r)<n*e.relativeHeightLimit)return K.NONE}}return K.SPLIT}setChildren(e,t,i,s){C(!!(e&&t&&i&&s),"Null child passed"),this._children[0]=e,this._children[1]=t,this._children[2]=i,this._children[3]=s}unsetChildren(){this._children[0]=null,this._children[1]=null,this._children[2]=null,this._children[3]=null}get isLoaded(){return this.renderData?.hasGeometry??!1}prepareToLoad(e){this.refMapData();for(const t of S)this._createOrUpdateAgents(0,t);e.updateTileGeometryState(this)}load(e){this.prepareToLoad(e),this.loadPrepared(e)}loadPrepared(e){e.loadTile(this)}unload(e){e.unloadTile(this);for(const t of S){const e=this.layerInfo[t];for(const t of e)t.loadingAgent&&t.loadingAgent!==Y&&(he(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0}this.resetPendingUpdate(K.GEOMETRY),this.resetPendingUpdate(K.TEXTURE_NOFADING),this.resetPendingUpdate(K.TEXTURE_FADING),this.unrefMapData()}unloadMapData(){const e=this.layerInfo[b.MAP];for(const t of e)t.loadingAgent&&t.loadingAgent!==Y&&(he(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0;this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(y(e,this._clippingArea))return!1;const t=this._intersectsClippingArea,s=this._isWithinClippingArea;i(e)?(this._intersectsClippingArea=this.intersectsExtent(e),this._isWithinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._isWithinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const n=s&&this._isWithinClippingArea,r=!(s||t||this._isWithinClippingArea||this._intersectsClippingArea);return!this.renderData||n||r||this.setPendingUpdate(K.GEOMETRY),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i||!i.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of S){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==Y&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(K.SPLIT)||e!==b.ELEVATION&&!this.loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){this._pendingUpdates|=e,e===K.SPLIT||e===K.MERGE?this._surface.setTileTreeDirty():this._surface.requestUpdate()}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,t,i){const n=this.layerInfo[t][e];if(n.waitingAgents.has(i))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this.lij.toString(),i.tile.lij.toString(),t,e),!0;if(n.waitingAgents.push(i),n.data&&!n.dataInvalidated)return console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this.lij.toString(),i.tile.lij.toString(),t,e),i.dataArrived(this),!0;if(n.requestPromise)return!0;s(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,t,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get isLeaf(){return null==this._children[0]}hasLij(e){return this.lij[0]===e[0]&&this.lij[1]===e[1]&&this.lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;if(this.isLeaf)return null;const t=this._children[0].findByLij(e)||this._children[1].findByLij(e)||this._children[2].findByLij(e)||this._children[3].findByLij(e);return t||null}distanceToSquared(e){return l(h(se,this._center[ce.MIDDLE],e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);C(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this._updateMemoryUsed())}dataArrived(e,t,i){const s=this.layerInfo[t][e];s.data=i,s.dataInvalidated=!1,s.waitingAgents.forAll((e=>e.dataArrived(this))),s.waitingAgents.clear(),this._updateMemoryUsed()}dataMissing(e,t,i){i.notInTilemap||console.error(`Tile ${this.lij.toString()} layer ${t}/${e} error ${i}`);const s=this.layerInfo[t][e];s.dataMissing=!0,s.waitingAgents.forAll((e=>e.dataMissing())),s.waitingAgents.clear(),this._updateMemoryUsed()}updateRenderData(e,t){switch(e){case b.MAP:return this._updateTexture(t);case b.ELEVATION:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(e===D.FADING?K.TEXTURE_NOFADING:K.TEXTURE_FADING),this.setPendingUpdate(e===D.FADING?K.TEXTURE_FADING:K.TEXTURE_NOFADING))}_updateGeometry(){this.setPendingUpdate(K.GEOMETRY);for(const e of this.layerInfo[b.ELEVATION])e.pendingUpdates|=K.GEOMETRY}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBounds;a(e,Number.MAX_VALUE,-Number.MAX_VALUE);const t=this.layerInfo[b.ELEVATION];let s=!0;for(const n of t)i(n.elevationBounds)&&(e[0]=Math.min(e[0],n.elevationBounds.min),e[1]=Math.max(e[1],n.elevationBounds.max),n.elevationBounds.hasNoDataValues||(s=!1));s&&(e[0]=Math.min(e[0],0),e[1]=Math.max(e[1],0)),this.updateRadiusAndCenter(),this._surface.setTileTreeDirty()}_updateCenter(){const e=this._elevationBounds,t=.5*(e[0]+e[1]);u(se,this.up,t),c(this._center[ce.MIDDLE],this.centerAtSeaLevel,se),u(se,this.up,e[0]),c(this._center[ce.TOP],this.centerAtSeaLevel,se),u(se,this.up,e[1]),c(this._center[ce.BOTTOM],this.centerAtSeaLevel,se)}findElevationBoundsForLayer(e,s){const n=this.layerInfo[b.ELEVATION][e];if(i(n.elevationBounds)&&n.elevationBounds.level>=s)return;const r=this._surface.layerViewByIndex(e,b.ELEVATION),a=R(r);if(!Z(this,a,!1))return;const o=ue;let h=!1;if(n.data){const e=n.data;o.min=e.bounds[0],o.max=e.bounds[1],o.hasNoDataValues=e.hasNoDataValues,o.level=this.level,h=!0}else{let t,i,s=0;for(let n=this._parent;n&&(!i||s<U(this.level))&&(s=this.vlevel-n.level,t=i||t,i=n.layerInfo[b.ELEVATION][e].data,!(!i&&t&&s>=U(this.level)));n=n.parent);i=i||t,i&&(i.computeMinMaxValue(this.lij[0],this.lij[1],this.lij[2],o),o.min!==1/0&&(o.level=i.level,h=!0))}h&&(t(n.elevationBounds)&&(n.elevationBounds=new L),n.elevationBounds.copyFrom(o))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==Y&&(he(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:$.acquire(this._surface.upsampleInfoPool)}this._updateMemoryUsed()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,D.FADING))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===Y&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of S){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==Y&&(i.loadingAgent.setSuspension(t),i.loadingAgent===Y&&this.updateRenderData(e,D.FADING))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==Y&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,i){const s=this.layerInfo[i][e];s.loadingAgent=Y,!s.data&&t(s.upsampleInfo)&&this._createOrUpdateAgents(e+1,i)}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=(()=>{for(let s=e;s<i.length;++s){const e=this._surface.layerViewByIndex(s,t);if(P(e)&&"normal"!==e.layer.blendMode)return!0}return!1})(),n=this._isSuspended(t);for(let r=e;r<i.length;++r){const e=i[r];let a=!1;const o=this._surface.layerViewByIndex(r,t),h=R(o);if(e.loadingAgent?Z(this,h,!1)?(e.loadingAgent!==Y&&e.loadingAgent.setSuspension(n),e.loadingAgent!==Y&&(a=e.loadingAgent.update())):e.dispose():Z(this,h,!1)&&(e.loadingAgent=oe(this,r,t,n),a=e.loadingAgent.startLoading(),a?e.loadingAgent===Y&&this.setPendingUpdate(K.GEOMETRY):(he(e.loadingAgent),e.loadingAgent=Y)),e.loadingAgent===Y&&this.updateRenderData(t,D.FADING),!s&&a&&o.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationBasedVerticesPerSide(t){const i=this.vlevel-this.level,s=Math.max(this.level-t,U(this.level)-i);return e(1+(this.maxTesselation>>s),2,this.maxTesselation+1)}get test(){return{cachedMemory:this.cachedMemory}}_findLIJ(e,t){if(!e)return null;const s=this.surface.rootTiles;if(i(s))for(const i of s)if(ge(i,e)){let s=i,n=e[0]-s.level-1;for(;n>=0&&!s.isLeaf&&!t(s);){const t=e[1]>>n&1,i=e[2]>>n&1;s=s.children[2*t+i],n--}return t(s)?s:null}return null}findNeighborTile(e,t){const i=this.lij,s=this.getNeighborLIJ(i,e);return s?fe(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=e===N.NORTH_EAST?1:e===N.NORTH_WEST?0:e===N.SOUTH_WEST?2:3;let s=this;for(;!(s.isLeaf||t&&t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,(e=>t(e)||e.level===this.level))?.findCorner(B(e),t)}forAllSubtreeOnSide(e,t){const i=e===N.NORTH?[0,1]:e===N.NORTH_EAST?[1]:e===N.EAST?[1,3]:e===N.SOUTH_EAST?[3]:e===N.SOUTH?[2,3]:e===N.SOUTH_WEST?[2]:e===N.WEST?[0,2]:[0],s=e=>{t(e)||e.isLeaf||i.forEach((t=>s(e.children[t])))};s(this)}forallNeighbors(e){G.forEach((t=>this.findNeighborCornerTileExact(t,e))),V.forEach((t=>this.findNeighborTile(t,(t=>t.level===this.level||e(t)))?.forAllSubtreeOnSide(W(t),e)))}getNeighborEdgeStartVertexIndex(e,t){const i=t??this.findNeighborTile(V[e],(e=>e.isLoaded));if(!i||!this.isLoaded||!i.isLoaded)return 0;const s=this.level-i.level;if(0===s)return 0;const n=2**s,r=1==(1&e),a=r?0:1,o=i.lij[a+1]*n,h=this.lij[a+1]-o;return r?n-1-h:h}_updateNeighborsWithChangedEdgeResolution(){for(let e=0;e<4;++e)if(this.renderData.geometryState.neighborData.modifiedEdgeResolutions[e]){const t=V[e],i=this.findNeighborTile(t,(e=>e.isLoaded||e.level===this.level));if(!i)continue;if(!i.isLoaded){w(!i.isLeaf);const s=(e+2)%4,n=W(t);i.forAllSubtreeOnSide(n,(e=>e.isLoaded?(e.updateEdgeAfterResolutionChange(s),!0):(w(!e.isLeaf),!1)))}this.renderData.geometryState.neighborData.modifiedEdgeResolutions[e]=!1}}updateNeighborDataAndGeometryIfNeeded(){this.isLoaded&&this.renderData.updateNeighborDataAndGeometryIfNeeded()}updateNeighborsAfterGeometryChange(e=this.level){this.forEachLoadedNeighbor((e=>this._updateNeighbor(e))),V.forEach((t=>{this.findNeighborTile(t,(t=>t.isLoaded&&t.level<e))?.updateNeighborsWithChangedEdgeResolution()}))}updateNeighborsWithChangedEdgeResolution(){this.isLoaded&&this._updateNeighborsWithChangedEdgeResolution()}updateEdgeAfterResolutionChange(e){this.renderData.updateEdgeAfterResolutionChange(e)}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.isLoaded;V.forEach(((t,s)=>{const n=this.findNeighborTile(t,i);null!=n&&n!==this&&n.forAllSubtreeOnSide(W(t),(t=>!!t.isLoaded&&(e(t),!0)));const r=this.renderData?.geometryState?.neighborData;r&&(r.modifiedEdgeResolutions[s]=!1)})),G.forEach((t=>{const s=this.findNeighborTile(t,i)?.findCorner(B(t),(e=>e.isLoaded));w(!s||_e(this,s,t)),s?.isLoaded&&e(s)}))}_updateNeighbor(e){e?.isLoaded&&e.updateNeighborDataAndGeometryIfNeeded()}getNeighborLIJ(e,t){const i=q(t)?-1:H(t)?1:0,s=F(t)?-1:k(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this.wrapLIJ(n):n[2]<0?null:n}wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}get westNeighborWestExtent(){return this.extent[0]*(this.isWestEnd?-1:1)}get eastNeighborEastExtent(){return this.extent[2]*(this.isEastEnd?-1:1)}get isEastEnd(){return this.lij[2]===this.surface.lijEastEnd(this.level)-1}get isWestEnd(){return 0===this.lij[2]}get isNorthEnd(){return 0===this.lij[1]}get isSouthEnd(){return this.extent[1]+m>=this.surface.extent[1]}compareLIJs(e){const t=this.lij,i=t[0],s=e[0];if(i===s)return[t,e];const n=i-s;if(n<0){const i=2**-n;return[[s,t[1]*i,t[2]*i],e]}{const s=2**n;return[t,[i,e[1]*s,e[2]*s]]}}checkGeometryWaterproofness(){X&&(w(this.isLoaded),this.renderData.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(q(e)&&t[3]+s>=i[3])return!1;if(H(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&F(e)&&t[0]-s<=i[0])&&!(!n&&k(e)&&t[2]+s>=i[2])}}function oe(e,t,i,s){const n=i===b.ELEVATION?de.acquire():le.acquire();return n.init(e,t,i,s),n}function he(e){e.dispose(),e instanceof M?de.release(e):e instanceof x&&le.release(e)}const le=new n(x),de=new n(M),ue=new L;var ce;function ge(e,t){const i=e.level,s=t[0];if(i>s)return!1;const n=s-i,r=Math.floor(t[1]/2**n),a=Math.floor(t[2]/2**n);return r===e.lij[1]&&a===e.lij[2]}function fe(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function pe(e,t,i){return Math.abs(e-t)<=i}function me(e,i,s){if(t(e)||t(i))return!1;if(0===e.level&&0===i.level){if(e.isEastEnd&&i.isWestEnd&&s===N.EAST)return!0;if(e.isWestEnd&&i.isEastEnd&&s===N.WEST)return!0}const n=1e-6*(e.extent[2]-e.extent[0]);switch(s){case N.NORTH:return pe(e.extent[3],i.extent[1],n);case N.SOUTH:return pe(e.extent[1],i.extent[3],n);case N.EAST:return pe(e.extent[2],i.extent[0],n)||pe(e.extent[2],-i.extent[0],n);case N.WEST:return pe(e.extent[0],i.extent[2],n)||pe(e.extent[0],-i.extent[2],n)}}function _e(e,i,s){return!t(e)&&!t(i)&&i!==e&&(e.level>=i.level?Ae(e,i,s):Ae(i,e,B(s)))}function Ae(e,t,i){w(e.level>=t.level);const s=z(i),n=J(i),r=e.extent,a=t.extent,o=[s?r[0]:r[2],n?r[3]:r[1]],h=[s?a[2]:a[0],n?a[1]:a[3]],l=1e-5*(r[2]-r[0]),d=pe(o[0],h[0],l)||e.surface.isGlobal&&pe(o[0],-h[0],l),u=pe(o[1],h[1],l);if(d&&u)return!0;if(e.level===t.level)return!1;if(!d&&!u)return!1;return d?ye(a[1],a[3],r[1],r[3],l):ye(a[0],a[2],r[0],r[2],l)}function ye(e,t,i,s,n=m){return e-n<=i&&i<=s&&s<=t+n}!function(e){e[e.TOP=0]="TOP",e[e.MIDDLE=1]="MIDDLE",e[e.BOTTOM=2]="BOTTOM"}(ce||(ce={}));export{ce as CenterPosition,re as SplitLimits,ae as Tile,pe as almostEquals,_e as isCornerNeighbor,me as isEdgeNeighbor};
5
+ import{clamp as e}from"../../../core/mathUtils.js";import{isSome as t,abortMaybe as i,isNone as s}from"../../../core/maybe.js";import n from"../../../core/ObjectPool.js";import{c as r,a}from"../../../chunks/vec2.js";import{a as o}from"../../../chunks/vec2f64.js";import{b as h,p as l,e as d,g as u,a as c,l as g}from"../../../chunks/vec3.js";import{c as f,u as p}from"../../../chunks/vec3f64.js";import{E as m}from"../../../chunks/common.js";import{getReferenceEllipsoid as _}from"../../../geometry/projectionEllipsoid.js";import{create as y,equals as A}from"../../../geometry/support/aaBoundingRect.js";import{c as E}from"../../../chunks/sphere.js";import{VectorTile as T}from"../../2d/engine/vectorTiles/VectorTile.js";import{ImageWithType as v}from"../support/StreamDataLoader.js";import{ElevationBounds as L}from"./ElevationBounds.js";import{ElevationTileAgent as M}from"./ElevationTileAgent.js";import{TextureUpdate as D,LODSnapping as I,NeighborIndex as N}from"./interfaces.js";import{LayerClasses as b,LayerClass as S}from"./LayerClass.js";import{MapTileAgent as x}from"./MapTileAgent.js";import{RasterTile as j}from"./RasterTile.js";import{MAX_PATCH_TESSELATION as O,getElevationDesiredResolutionLevel as C}from"./TerrainConst.js";import{weakAssert as U,getLayerWithExtentRange as R,isBlendableLayerView as P,oppositeCorner as B,neighborCornerIndices as G,neighborEdgeIndices as V,oppositeEdge as W,internalAssert as w,isNorth as q,isSouth as H,isWest as F,isEast as k,ENABLE_WATERPROOFNESS_TESTS as X,isWestCorner as z,isNorthCorner as J}from"./terrainUtils.js";import{TILE_AGENT_DONE as Y}from"./TileAgent.js";import{TilePerLayerInfo as $}from"./TilePerLayerInfo.js";import Q from"./TileTexture.js";import{TileUpdate as K}from"./TileUpdate.js";import{fallsWithinLayer as Z}from"./tileUtils.js";import{getGpuMemoryUsage as ee}from"../../webgl/Util.js";const te=f(),ie=f(),se=f(),ne=.1;class re{constructor(){this.fovX=0,this.fovY=0,this.relativeWidthLimit=0,this.relativeHeightLimit=0,this.maxLod=0,this.angledSplitBias=0,this.aboveGround=!0}}class ae{constructor(){this.lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this._dirty=!0,this._previouslyRendered=!1,this.extent=y(),this._elevationBounds=o(),this.layerInfo=[[],[]],this.extentInRadians=y(),this.centerAtSeaLevel=f(),this._center=[f(),E(),f()],this.up=p(),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=null,this._mapTileMemory=0,this._mapDataRefCount=0,this._screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0}static prune(){le.prune(0),de.prune(0),$.prune()}get isCached(){return!this.shouldLoad&&this._mapDataRefCount<=0}get maxTesselation(){return this._maxTesselation}get isWithinClippingArea(){return this._isWithinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBounds(){return this._elevationBounds}get level(){return this.lij[0]}get key(){return`${this.lij[0]}/${this.lij[1]}/${this.lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[ce.MIDDLE][3]}get screenDepth(){return this._screenDepth}get visible(){return this._dirty&&this.computeVisibility(),this._visible}computeVisibility(){this._dirty=!1;const e=this._intersectsClippingArea&&this._isVisible(this.surface.frustum);return e!==this._visible&&(this._visible=e,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setNeedsRender(),this._updateTexture(e?D.FADING:D.UNFADED),this.updateAgentSuspension()),this._visible}get loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setNeedsRender()),e}get shouldLoad(){if(this._surface.lodSnapping===I.ON){const e=this.level-this._surface.snapLevel;if(0===e)return!0;if(1===e)return!1}return this.isLeaf}init(e,t,i){this.lij[0]=e[0],this.lij[1]=e[1],this.lij[2]=e[2],this.ellipsoid=_(i.tilingScheme.spatialReference),i.tilingScheme.getExtent(e[0],e[1],e[2],this.extent),i.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,i.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[ce.MIDDLE][3]=0,this.vlevel=e?e[0]:0,t&&t.elevationBounds?r(this._elevationBounds,t.elevationBounds):a(this._elevationBounds,0,0),this._pendingUpdates=0,this.renderData=null,this._screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=t,this.unsetChildren(),this._surface=i,this.updateVisibility();for(const s of b){const e=i.numLayers(s),t=this.layerInfo[s];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=$.acquire(this._surface.upsampleInfoPool),s===S.ELEVATION&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(i.tilingScheme.pixelSize,O)}release(){U(!this.renderData,"tile.renderData was not unloaded"),this._surface.upsampleMapCache.pop(this.key);for(const e of b){for(const t of this.layerInfo[e])t.release();this.layerInfo[e].length=0}this._parent=null,this._surface=null,this.setMemoryDirty()}refMapData(){++this._mapDataRefCount,this.isCached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){if(--this._mapDataRefCount,this.isCached){this.setMemoryDirty();const e=this.cachedMemory;e>0&&this._surface.upsampleMapCache.put(this.key,this,e)}}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this._ensureUsedMemory()+(this.isCached?0:this._mapTileMemory)}get cachedMemory(){return this.isCached?this.mapTileMemory:0}get mapTileMemory(){return this._ensureUsedMemory(),this.layerInfo[S.MAP].reduce(((e,t)=>e+(t instanceof T?t.memoryUsage:0)),this._mapTileMemory)}get cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_ensureUsedMemory(){if(t(this._usedMemory))return this._usedMemory;this._usedMemory=0,this._mapTileMemory=0;let e=0;for(const{data:t}of this.layerInfo[S.MAP])t instanceof T?e+=this._getTerrainDataMemory(t):this._mapTileMemory+=this._getTerrainDataMemory(t);const i=this.cpuImageMemorySize;for(const t of this.layerInfo[S.ELEVATION])this._usedMemory+=t.data?i:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._mapTileMemory+=ee(this.renderData.textureDescriptor)),this.isCached&&this._surface.upsampleMapCache.updateSize(this.key,this,this._mapTileMemory+e),this._usedMemory}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];return i?.data?e===S.MAP?this.isCached?0:this._getTerrainDataMemory(i.data):e===S.ELEVATION?this.cpuImageMemorySize:0:0}_getTerrainDataMemory(e){return e instanceof Q?ee(e.texture):e instanceof HTMLImageElement||e instanceof v?this.cpuImageMemorySize:e instanceof T||e instanceof j?e.memoryUsage:0}updateScreenDepth(e){const t=this._center[ce.MIDDLE],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this._screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,i,s){if(t(e.frustum)&&(!this._intersectsClippingArea||!this._isVisible(e.frustum)))return K.NONE;const n=this.level;h(te,this._center[ce.MIDDLE],i);let r=l(te),a=ce.MIDDLE;h(ie,this._center[ce.TOP],i);const o=l(ie);o<r&&(r=o,a=ce.TOP),h(ie,this._center[ce.BOTTOM],i);const f=l(ie);if(f<r&&(r=f,a=ce.BOTTOM),this._edgeLen2>r&&n<e.maxLod)return K.SPLIT;const p=Math.sqrt(r),m=e.fovX*p*2,_=this._edgeLen/m,y=()=>{const t=n+Math.ceil(-Math.log2(e.relativeWidthLimit/_));return t!==this.vlevel?(this.vlevel=t,K.VSPLITMERGE):K.NONE_HIT_MAXLOD};if(s===I.ON){if(1===this._surface.snapLevel-n)return n>=e.maxLod?y():K.SPLIT}const A=d(this.up,te),E=this._elevationBounds[1]-this._elevationBounds[0],T=E/this.edgeLen;if(e.aboveGround&&A>0&&T<.001){if(A/p-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-T>0)return K.NONE}if(_<e.relativeWidthLimit)return this.vlevel!==this.level?(this.vlevel=this.level,K.VSPLITMERGE):K.NONE;if(n>=e.maxLod)return y();if(n>6){h(ie,this._center[a],i),u(se,this.up,A),h(se,se,ie);const t=l(se);if(t>this.radius*this.radius){u(se,se,this.radius/Math.sqrt(t)),c(se,se,this._center[a]),h(se,i,se);const s=Math.min(1,(Math.abs(d(se,this.up))+.5*E+this._curvatureHeight)/g(se)),n=ne/e.angledSplitBias,r=e.fovY*p*2;if(s*(this._edgeLen/r)<n*e.relativeHeightLimit)return K.NONE}}return K.SPLIT}setChildren(e,t,i,s){U(!!(e&&t&&i&&s),"Null child passed"),this._children[0]=e,this._children[1]=t,this._children[2]=i,this._children[3]=s}unsetChildren(){this._children[0]=null,this._children[1]=null,this._children[2]=null,this._children[3]=null}get isLoaded(){return this.renderData?.hasGeometry??!1}prepareToLoad(e){this.refMapData();for(const t of b)this._createOrUpdateAgents(0,t);e.updateTileGeometryState(this)}load(e){this.prepareToLoad(e),this.loadPrepared(e)}loadPrepared(e){e.loadTile(this)}unload(e){e.unloadTile(this);for(const t of b){const e=this.layerInfo[t];for(const t of e)t.loadingAgent&&t.loadingAgent!==Y&&(he(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0}this.resetPendingUpdate(K.GEOMETRY),this.resetPendingUpdate(K.TEXTURE_NOFADING),this.resetPendingUpdate(K.TEXTURE_FADING),this.unrefMapData()}unloadMapData(){const e=this.layerInfo[S.MAP];for(const t of e)t.loadingAgent&&t.loadingAgent!==Y&&(he(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0;this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(A(e,this._clippingArea))return!1;const i=this._intersectsClippingArea,s=this._isWithinClippingArea;t(e)?(this._intersectsClippingArea=this.intersectsExtent(e),this._isWithinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._isWithinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const n=s&&this._isWithinClippingArea,r=!(s||i||this._isWithinClippingArea||this._intersectsClippingArea);return!this.renderData||n||r||this.setPendingUpdate(K.GEOMETRY),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i||!i.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of b){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==Y&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(K.SPLIT)||e!==S.ELEVATION&&!this.loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){this._pendingUpdates|=e,e===K.SPLIT||e===K.MERGE?this._surface.setTileTreeDirty():this._surface.requestUpdate()}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,t,s){const n=this.layerInfo[t][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this.lij.toString(),s.tile.lij.toString(),t,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated)return console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this.lij.toString(),s.tile.lij.toString(),t,e),s.dataArrived(this),!0;if(n.requestPromise)return!0;i(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,t,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get isLeaf(){return null==this._children[0]}hasLij(e){return this.lij[0]===e[0]&&this.lij[1]===e[1]&&this.lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;if(this.isLeaf)return null;const t=this._children[0].findByLij(e)||this._children[1].findByLij(e)||this._children[2].findByLij(e)||this._children[3].findByLij(e);return t||null}distanceToSquared(e){return l(h(se,this._center[ce.MIDDLE],e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);U(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=this.layerInfo[t][e];s.data=i,s.dataInvalidated=!1,s.waitingAgents.forAll((e=>e.dataArrived(this))),s.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t,i){i.notInTilemap||console.error(`Tile ${this.lij.toString()} layer ${t}/${e} error ${i}`);const s=this.layerInfo[t][e];s.dataMissing=!0,s.waitingAgents.forAll((e=>e.dataMissing())),s.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t){switch(e){case S.MAP:return this._updateTexture(t);case S.ELEVATION:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(e===D.FADING?K.TEXTURE_NOFADING:K.TEXTURE_FADING),this.setPendingUpdate(e===D.FADING?K.TEXTURE_FADING:K.TEXTURE_NOFADING))}_updateGeometry(){this.setPendingUpdate(K.GEOMETRY);for(const e of this.layerInfo[S.ELEVATION])e.pendingUpdates|=K.GEOMETRY}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBounds;a(e,Number.MAX_VALUE,-Number.MAX_VALUE);const i=this.layerInfo[S.ELEVATION];let s=!0;for(const n of i)t(n.elevationBounds)&&(e[0]=Math.min(e[0],n.elevationBounds.min),e[1]=Math.max(e[1],n.elevationBounds.max),n.elevationBounds.hasNoDataValues||(s=!1));s&&(e[0]=Math.min(e[0],0),e[1]=Math.max(e[1],0)),this.updateRadiusAndCenter(),this._surface.setTileTreeDirty()}_updateCenter(){const e=this._elevationBounds,t=.5*(e[0]+e[1]);u(se,this.up,t),c(this._center[ce.MIDDLE],this.centerAtSeaLevel,se),u(se,this.up,e[0]),c(this._center[ce.TOP],this.centerAtSeaLevel,se),u(se,this.up,e[1]),c(this._center[ce.BOTTOM],this.centerAtSeaLevel,se)}findElevationBoundsForLayer(e,i){const n=this.layerInfo[S.ELEVATION][e];if(t(n.elevationBounds)&&n.elevationBounds.level>=i)return;const r=this._surface.layerViewByIndex(e,S.ELEVATION),a=R(r);if(!Z(this,a,!1))return;const o=ue;let h=!1;if(n.data){const e=n.data;o.min=e.bounds[0],o.max=e.bounds[1],o.hasNoDataValues=e.hasNoDataValues,o.level=this.level,h=!0}else{let t,i,s=0;for(let n=this._parent;n&&(!i||s<C(this.level))&&(s=this.vlevel-n.level,t=i||t,i=n.layerInfo[S.ELEVATION][e].data,!(!i&&t&&s>=C(this.level)));n=n.parent);i=i||t,i&&(i.computeMinMaxValue(this.lij[0],this.lij[1],this.lij[2],o),o.min!==1/0&&(o.level=i.level,h=!0))}h&&(s(n.elevationBounds)&&(n.elevationBounds=new L),n.elevationBounds.copyFrom(o))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==Y&&(he(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:$.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,D.FADING))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===Y&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of b){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==Y&&(i.loadingAgent.setSuspension(t),i.loadingAgent===Y&&this.updateRenderData(e,D.FADING))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==Y&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=Y,!i.data&&s(i.upsampleInfo)&&this._createOrUpdateAgents(e+1,t)}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=(()=>{for(let s=e;s<i.length;++s){const e=this._surface.layerViewByIndex(s,t);if(P(e)&&"normal"!==e.layer.blendMode)return!0}return!1})(),n=this._isSuspended(t);for(let r=e;r<i.length;++r){const e=i[r];let a=!1;const o=this._surface.layerViewByIndex(r,t),h=R(o);if(e.loadingAgent?Z(this,h,!1)?(e.loadingAgent!==Y&&e.loadingAgent.setSuspension(n),e.loadingAgent!==Y&&(a=e.loadingAgent.update())):e.dispose():Z(this,h,!1)&&(e.loadingAgent=oe(this,r,t,n),a=e.loadingAgent.startLoading(),a?e.loadingAgent===Y&&this.setPendingUpdate(K.GEOMETRY):(he(e.loadingAgent),e.loadingAgent=Y)),e.loadingAgent===Y&&this.updateRenderData(t,D.FADING),!s&&a&&o.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationBasedVerticesPerSide(t){const i=this.vlevel-this.level,s=Math.max(this.level-t,C(this.level)-i);return e(1+(this.maxTesselation>>s),2,this.maxTesselation+1)}get test(){return{cachedMemory:this.cachedMemory}}_findLIJ(e,i){if(!e)return null;const s=this.surface.rootTiles;if(t(s))for(const t of s)if(ge(t,e)){let s=t,n=e[0]-s.level-1;for(;n>=0&&!s.isLeaf&&!i(s);){const t=e[1]>>n&1,i=e[2]>>n&1;s=s.children[2*t+i],n--}return i(s)?s:null}return null}findNeighborTile(e,t){const i=this.lij,s=this.getNeighborLIJ(i,e);return s?fe(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=e===N.NORTH_EAST?1:e===N.NORTH_WEST?0:e===N.SOUTH_WEST?2:3;let s=this;for(;!(s.isLeaf||t&&t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,(e=>t(e)||e.level===this.level))?.findCorner(B(e),t)}forAllSubtreeOnSide(e,t){const i=e===N.NORTH?[0,1]:e===N.NORTH_EAST?[1]:e===N.EAST?[1,3]:e===N.SOUTH_EAST?[3]:e===N.SOUTH?[2,3]:e===N.SOUTH_WEST?[2]:e===N.WEST?[0,2]:[0],s=e=>{t(e)||e.isLeaf||i.forEach((t=>s(e.children[t])))};s(this)}forallNeighbors(e){G.forEach((t=>this.findNeighborCornerTileExact(t,e))),V.forEach((t=>this.findNeighborTile(t,(t=>t.level===this.level||e(t)))?.forAllSubtreeOnSide(W(t),e)))}getNeighborEdgeStartVertexIndex(e,t){const i=t??this.findNeighborTile(V[e],(e=>e.isLoaded));if(!i||!this.isLoaded||!i.isLoaded)return 0;const s=this.level-i.level;if(0===s)return 0;const n=2**s,r=1==(1&e),a=r?0:1,o=i.lij[a+1]*n,h=this.lij[a+1]-o;return r?n-1-h:h}_updateNeighborsWithChangedEdgeResolution(){for(let e=0;e<4;++e)if(this.renderData.geometryState.neighborData.modifiedEdgeResolutions[e]){const t=V[e],i=this.findNeighborTile(t,(e=>e.isLoaded||e.level===this.level));if(!i)continue;if(!i.isLoaded){w(!i.isLeaf);const s=(e+2)%4,n=W(t);i.forAllSubtreeOnSide(n,(e=>e.isLoaded?(e.updateEdgeAfterResolutionChange(s),!0):(w(!e.isLeaf),!1)))}this.renderData.geometryState.neighborData.modifiedEdgeResolutions[e]=!1}}updateNeighborDataAndGeometryIfNeeded(){this.isLoaded&&this.renderData.updateNeighborDataAndGeometryIfNeeded()}updateNeighborsAfterGeometryChange(e=this.level){this.forEachLoadedNeighbor((e=>this._updateNeighbor(e))),V.forEach((t=>{this.findNeighborTile(t,(t=>t.isLoaded&&t.level<e))?.updateNeighborsWithChangedEdgeResolution()}))}updateNeighborsWithChangedEdgeResolution(){this.isLoaded&&this._updateNeighborsWithChangedEdgeResolution()}updateEdgeAfterResolutionChange(e){this.renderData.updateEdgeAfterResolutionChange(e)}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.isLoaded;V.forEach(((t,s)=>{const n=this.findNeighborTile(t,i);null!=n&&n!==this&&n.forAllSubtreeOnSide(W(t),(t=>!!t.isLoaded&&(e(t),!0)));const r=this.renderData?.geometryState?.neighborData;r&&(r.modifiedEdgeResolutions[s]=!1)})),G.forEach((t=>{const s=this.findNeighborTile(t,i)?.findCorner(B(t),(e=>e.isLoaded));w(!s||_e(this,s,t)),s?.isLoaded&&e(s)}))}_updateNeighbor(e){e?.isLoaded&&e.updateNeighborDataAndGeometryIfNeeded()}getNeighborLIJ(e,t){const i=q(t)?-1:H(t)?1:0,s=F(t)?-1:k(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this.wrapLIJ(n):n[2]<0?null:n}wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}get westNeighborWestExtent(){return this.extent[0]*(this.isWestEnd?-1:1)}get eastNeighborEastExtent(){return this.extent[2]*(this.isEastEnd?-1:1)}get isEastEnd(){return this.lij[2]===this.surface.lijEastEnd(this.level)-1}get isWestEnd(){return 0===this.lij[2]}get isNorthEnd(){return 0===this.lij[1]}get isSouthEnd(){return this.extent[1]+m>=this.surface.extent[1]}compareLIJs(e){const t=this.lij,i=t[0],s=e[0];if(i===s)return[t,e];const n=i-s;if(n<0){const i=2**-n;return[[s,t[1]*i,t[2]*i],e]}{const s=2**n;return[t,[i,e[1]*s,e[2]*s]]}}checkGeometryWaterproofness(){X&&(w(this.isLoaded),this.renderData.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(q(e)&&t[3]+s>=i[3])return!1;if(H(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&F(e)&&t[0]-s<=i[0])&&!(!n&&k(e)&&t[2]+s>=i[2])}}function oe(e,t,i,s){const n=i===S.ELEVATION?de.acquire():le.acquire();return n.init(e,t,i,s),n}function he(e){e.dispose(),e instanceof M?de.release(e):e instanceof x&&le.release(e)}const le=new n(x),de=new n(M),ue=new L;var ce;function ge(e,t){const i=e.level,s=t[0];if(i>s)return!1;const n=s-i,r=Math.floor(t[1]/2**n),a=Math.floor(t[2]/2**n);return r===e.lij[1]&&a===e.lij[2]}function fe(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function pe(e,t,i){return Math.abs(e-t)<=i}function me(e,t,i){if(s(e)||s(t))return!1;if(0===e.level&&0===t.level){if(e.isEastEnd&&t.isWestEnd&&i===N.EAST)return!0;if(e.isWestEnd&&t.isEastEnd&&i===N.WEST)return!0}const n=1e-6*(e.extent[2]-e.extent[0]);switch(i){case N.NORTH:return pe(e.extent[3],t.extent[1],n);case N.SOUTH:return pe(e.extent[1],t.extent[3],n);case N.EAST:return pe(e.extent[2],t.extent[0],n)||pe(e.extent[2],-t.extent[0],n);case N.WEST:return pe(e.extent[0],t.extent[2],n)||pe(e.extent[0],-t.extent[2],n)}}function _e(e,t,i){return!s(e)&&!s(t)&&t!==e&&(e.level>=t.level?ye(e,t,i):ye(t,e,B(i)))}function ye(e,t,i){w(e.level>=t.level);const s=z(i),n=J(i),r=e.extent,a=t.extent,o=[s?r[0]:r[2],n?r[3]:r[1]],h=[s?a[2]:a[0],n?a[1]:a[3]],l=1e-5*(r[2]-r[0]),d=pe(o[0],h[0],l)||e.surface.isGlobal&&pe(o[0],-h[0],l),u=pe(o[1],h[1],l);if(d&&u)return!0;if(e.level===t.level)return!1;if(!d&&!u)return!1;return d?Ae(a[1],a[3],r[1],r[3],l):Ae(a[0],a[2],r[0],r[2],l)}function Ae(e,t,i,s,n=m){return e-n<=i&&i<=s&&s<=t+n}!function(e){e[e.TOP=0]="TOP",e[e.MIDDLE=1]="MIDDLE",e[e.BOTTOM=2]="BOTTOM"}(ce||(ce={}));export{ce as CenterPosition,re as SplitLimits,ae as Tile,pe as almostEquals,_e as isCornerNeighbor,me as isEdgeNeighbor};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{nextHighestPowerOfTwo as e}from"../../../core/mathUtils.js";import{disposeMaybe as t,releaseMaybe as r,isNone as s,isSome as o}from"../../../core/maybe.js";import{a,c as i}from"../../../chunks/vec2.js";import{Z as n}from"../../../chunks/vec2f64.js";import{isBaseLayer as u}from"../../../layers/support/layerUtils.js";import{ImageWithType as c}from"../support/StreamDataLoader.js";import{BlendLayersPassParameters as l}from"./BlendLayersTechnique.js";import{TextureUpdate as p}from"./interfaces.js";import{LayerClass as d}from"./LayerClass.js";import{isBlendableLayerView as h,isGroupLayer as m,isVectorTileLayerView as _,isVectorTileRenderInfo as T,isImageryTileRenderInfo as f,isRasterTileRenderInfo as x,isTextureTileRenderInfo as y}from"./terrainUtils.js";import{ActivationTime as g}from"./TextureFader.js";import{TextureReference as b}from"./TextureReference.js";import{TileCompositor as k}from"./TileCompositor.js";import I from"./TileTexture.js";import{TileUpdate as P}from"./TileUpdate.js";import{LayerBlendMode as D,blendModeFromString as w}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{B as L}from"../../../chunks/BlendLayers.glsl.js";import{createColorTexture as A,createEmptyTexture as E}from"../webgl-engine/lib/glUtil3D.js";import{TextureSamplingMode as R,TextureType as M,PixelFormat as j,PixelType as O,TextureWrapMode as N}from"../../webgl/enums.js";import{Texture as U}from"../../webgl/Texture.js";class C{constructor(e,t,r){this._rctx=e,this.tileSize=t,this._techniqueRepository=r,this._passParameters=new l,this._backgroundTexture=null,this._backgroundColor=null,this._backgroundDirty=!1,this._blackTex=null,this._numTexturedLayer=0,this._maxAnisotropy=this._rctx.parameters.maxMaxAnisotropy,this._composition=new k(this._rctx,this._techniqueRepository),this._blackTex=new I(A(this._rctx,[0,0,0,1])),this._ensureBackgroundTexture(this.tileSize)}dispose(){this._composition=t(this._composition),this._backgroundTexture=r(this._backgroundTexture),this._blackTex=r(this._blackTex)}get backgroundIsGrid(){return s(this._backgroundColor)}get backgroundColor(){return this._backgroundColor}updateTileTexture(e,t){if(!e.renderData)return;const r=e.surface,s=r.baseOpacity;this._numTexturedLayer=0;let o=0,a=this.tileSize,i=!1;const n=r.view.state.pixelRatio;let c=!1;const l=e.layerInfo[d.MAP];let p=l.length,T=0;for(;T<l.length;T++){const t=r.layerViewByIndex(T,d.MAP),f=t.fullOpacity;if(G[T]=f,u(t.layer)&&p>=l.length&&(p=T),0===f){l[T].pendingUpdates&=~(P.TEXTURE_NOFADING&P.TEXTURE_FADING);continue}++o;const x=F(e,T);if(x){if(l[T].pendingUpdates&=~(P.TEXTURE_NOFADING&P.TEXTURE_FADING),h(t)){const e=m(t.layer.parent)?"normal":t.layer.blendMode;S[T]=e;const r="normal"!==e;r&&(c=r,i=!1)}_(t)?a=Math.max(a,this.tileSize*n):1===s&&1===f&&(t.isOpaque||this._dataToTexture(x)&&x.sourceLayerInfo.data.descriptor.isOpaque)&&(i=!0),++this._numTexturedLayer}}this._composition.cleanupFBOPool(n,l.length),a=B(a);const f=a/this.tileSize,x=T-1;this._ensureBackgroundTexture(this.tileSize),0!==this._numTexturedLayer?1===this._numTexturedLayer&&!c&&this._useLayerTexture(e,x,p,G[x])||this._composeMapLayers(e,t,x,p,G,S,a,f,!i||c):this._useBackgroundTexture(e,o)}_ensureBackgroundTexture(e){s(this._backgroundTexture)&&(this._backgroundTexture=this._buildTexture(e),this._backgroundDirty=!0),this._backgroundDirty&&(this._composition.bindPool(0,e),this._passParameters.offset=n,this._passParameters.scale=1,this._passParameters.opacity=1,this._passParameters.blendMode=D.Normal,o(this.backgroundColor)&&(this._passParameters.backgroundColor=this.backgroundColor),this._composition.drawBackground(this._passParameters,o(this.backgroundColor)?L.ColorOnly:L.GridOnly),this._composition.copyFBOToTexture(this._backgroundTexture),this._composition.releasePool(),this._backgroundDirty=!1)}_useBackgroundTexture(e,t){let r=g.Immediate;(e.surface.view.layerViewManager.updating||t>0)&&(r=g.Delayed),this._backgroundTexture&&s(e.renderData.textureReference)&&(r=g.Immediate),e.renderData.setTextureReference(o(this._backgroundTexture)?new b(this._backgroundTexture,p.FADING,z,e.surface.baseOpacity,1,0):null,r)}_useLayerTexture(e,t,r,s){const o=t<r,a=o?1:e.surface.baseOpacity,i=o?e.surface.baseOpacity:1,n=F(e,t);return!!this._dataToTexture(n)&&(e.renderData.setTextureReference(new b(n.sourceLayerInfo.data,p.FADING,n,a,s,i)),!0)}_composeMapLayers(e,t,r,s,o,a,i,n,u){this._composition.bindPool(0,i);const c=e.surface.baseOpacity;let l=!1,p=R.LINEAR_MIPMAP_LINEAR,d=!1,h=0;for(let _=r;_>=0;_--){const t=F(e,_);if(!t)continue;if(0===o[_])continue;const r=_<s&&c<1&&!l;this._passParameters.baseOpacity=r?c:1,r&&(l=!0);const m=0===h,x=u&&m?this.backgroundIsGrid?L.GridComposite:L.ColorComposite:L.Composite;T(t)?(this._passParameters.opacity=o[_],this._passParameters.blendMode=w[a[_]],d=this._composition.drawVectorData(this._passParameters,t,n,this.tileSize,i,d,x)):f(t)?(this._passParameters.opacity=o[_],this._passParameters.blendMode=w[a[_]],this._composition.drawImageryTileData(t,x,this._passParameters),this._hasNearestInterpolation(t)&&(p=R.NEAREST)):this._dataToTexture(t)&&(this._passParameters.texture=t.sourceLayerInfo.data.texture,this._passParameters.offset=t.offset,this._passParameters.scale=t.scale,this._passParameters.opacity=o[_],this._passParameters.blendMode=w[a[_]],this._composition.drawRasterData(x,this._passParameters)),h++}const m=e.renderData.ensureTexture(i,(()=>this._buildTexture(i,p)));this._composition.copyFBOToTexture(m),this._composition.releasePool(),e.renderData.setTextureReference(new b(m,t,z,l?1:c,1,0))}_hasNearestInterpolation(e){const t=e.sourceLayerInfo.data;return!!t.source&&"nearest"===t.interpolation}_dataToTexture(e){return x(e)&&this._rasterDataToTexture(e),y(e)}_rasterDataToTexture(e){const t=e.sourceLayerInfo;t.data=this._buildTexture(t.data),e.tile.setMemoryDirty()}setBackground(e){this._backgroundColor!==e&&(this._backgroundColor=e,this._backgroundDirty=!0)}_buildTexture(e,t=R.LINEAR_MIPMAP_LINEAR){if(s(e))return null;const r={target:M.TEXTURE_2D,pixelFormat:j.RGBA,dataType:O.UNSIGNED_BYTE,wrapMode:N.CLAMP_TO_EDGE,samplingMode:t,maxAnisotropy:this._maxAnisotropy,flipped:!0,hasMipmap:!0},o=this._rctx;let a;if("number"==typeof e)r.width=r.height=e,a=new I(new U(o,r));else if(e instanceof c)r.isOpaque=e.isOpaque,a=new I(new U(o,r,e.image)),e.release();else try{a=new I(new U(o,r,e))}catch(n){a=new I(E(o)),console.warn("TileRenderer: failed to execute 'texImage2D', cross-origin image may not be loaded.")}const i=o.bindTexture(a.texture,U.TEXTURE_UNIT_FOR_UPDATES);return a.generateMipmap(),o.bindTexture(i,U.TEXTURE_UNIT_FOR_UPDATES),a}get test(){return{backgroundTexture:this._backgroundTexture}}}function B(t){const r=e(t),s=r*r,o=t*t;if(s===o)return t;const a=r/2;return s-o<o-a*a?r:a}function F(e,t){q.layerIndex=t;const r=e.layerInfo[d.MAP][t];if(o(r.data))return a(q.offset,0,0),q.tile=e,q.scale=1,q.sourceLod=e.lij,q.sourceLayerInfo=r,q;const s=r.upsampleInfo;if(o(s)){const e=s.tile.layerInfo[d.MAP][t];return q.tile=s.tile,i(q.offset,s.offset),q.scale=s.scale,q.sourceLod=s.tile.lij,q.sourceLayerInfo=e,q}return null}const G=new Array,S=new Array,q={tile:null,sourceLayerInfo:null,sourceLod:null,offset:[0,0],scale:1,layerIndex:0},z={offset:[0,0],scale:1};export{C as TileRenderer};
5
+ import{nextHighestPowerOfTwo as e}from"../../../core/mathUtils.js";import{disposeMaybe as t,releaseMaybe as r,isNone as s,isSome as o}from"../../../core/maybe.js";import{a,c as i}from"../../../chunks/vec2.js";import{Z as n}from"../../../chunks/vec2f64.js";import{isBaseLayer as u}from"../../../layers/support/layerUtils.js";import{ImageWithType as c}from"../support/StreamDataLoader.js";import{BlendLayersPassParameters as l}from"./BlendLayersTechnique.js";import{TextureUpdate as p}from"./interfaces.js";import{LayerClass as d}from"./LayerClass.js";import{isBlendableLayerView as h,isGroupLayer as m,isVectorTileLayerView as _,isVectorTileRenderInfo as f,isImageryTileRenderInfo as T,isRasterTileRenderInfo as x,isTextureTileRenderInfo as y}from"./terrainUtils.js";import{ActivationTime as g}from"./TextureFader.js";import{TextureReference as b}from"./TextureReference.js";import{TileCompositor as k}from"./TileCompositor.js";import I from"./TileTexture.js";import{TileUpdate as P}from"./TileUpdate.js";import{LayerBlendMode as D,blendModeFromString as w}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{B as A}from"../../../chunks/BlendLayers.glsl.js";import{createColorTexture as E,createEmptyTexture as L}from"../webgl-engine/lib/glUtil3D.js";import{TextureSamplingMode as R,TextureType as M,PixelFormat as j,PixelType as O,TextureWrapMode as N}from"../../webgl/enums.js";import{Texture as U}from"../../webgl/Texture.js";class C{constructor(e,t,r){this._rctx=e,this.tileSize=t,this._techniqueRepository=r,this._passParameters=new l,this._backgroundTexture=null,this._backgroundColor=null,this._backgroundDirty=!1,this._blackTex=null,this._maxAnisotropy=this._rctx.parameters.maxMaxAnisotropy,this._composition=new k(this._rctx,this._techniqueRepository),this._blackTex=new I(E(this._rctx,[0,0,0,1])),this._ensureBackgroundTexture(this.tileSize)}dispose(){this._composition=t(this._composition),this._backgroundTexture=r(this._backgroundTexture),this._blackTex=r(this._blackTex)}get backgroundIsGrid(){return s(this._backgroundColor)}get backgroundColor(){return this._backgroundColor}updateTileTexture(e,t){if(!e.renderData)return;const r=e.surface,s=r.baseOpacity;let o=0,a=0,i=this.tileSize,n=!1;const c=r.view.state.pixelRatio;let l=!1;const p=e.layerInfo[d.MAP];let f=p.length,T=0;for(;T<p.length;T++){const t=r.layerViewByIndex(T,d.MAP),x=t.fullOpacity;if(G[T]=x,u(t.layer)&&f>=p.length&&(f=T),0===x){p[T].pendingUpdates&=~(P.TEXTURE_NOFADING&P.TEXTURE_FADING);continue}++a;const y=F(e,T);if(y){if(p[T].pendingUpdates&=~(P.TEXTURE_NOFADING&P.TEXTURE_FADING),h(t)){const e=m(t.layer.parent)?"normal":t.layer.blendMode;S[T]=e;const r="normal"!==e;r&&(l=r,n=!1)}_(t)?i=Math.max(i,this.tileSize*c):1===s&&1===x&&(t.isOpaque||this._dataToTexture(y)&&y.sourceLayerInfo.data.descriptor.isOpaque)&&(n=!0),++o}}this._composition.cleanupFBOPool(c,p.length),i=B(i);const x=i/this.tileSize,y=T-1;this._ensureBackgroundTexture(this.tileSize),e.visible||(o=a=0),0!==o?1===o&&!l&&this._useLayerTexture(e,y,f,G[y])||this._composeMapLayers(e,t,y,f,G,S,i,x,!n||l):this._useBackgroundTexture(e,a)}_ensureBackgroundTexture(e){s(this._backgroundTexture)&&(this._backgroundTexture=this._buildTexture(e),this._backgroundDirty=!0),this._backgroundDirty&&(this._composition.bindPool(0,e),this._passParameters.offset=n,this._passParameters.scale=1,this._passParameters.opacity=1,this._passParameters.blendMode=D.Normal,o(this.backgroundColor)&&(this._passParameters.backgroundColor=this.backgroundColor),this._composition.drawBackground(this._passParameters,o(this.backgroundColor)?A.ColorOnly:A.GridOnly),this._composition.copyFBOToTexture(this._backgroundTexture),this._composition.releasePool(),this._backgroundDirty=!1)}_useBackgroundTexture(e,t){let r=g.Immediate;(e.surface.view.layerViewManager.updating||t>0)&&(r=g.Delayed),this._backgroundTexture&&s(e.renderData.textureReference)&&(r=g.Immediate),e.renderData.setTextureReference(o(this._backgroundTexture)?new b(this._backgroundTexture,p.FADING,z,e.surface.baseOpacity,1,0):null,r)}_useLayerTexture(e,t,r,s){const o=t<r,a=o?1:e.surface.baseOpacity,i=o?e.surface.baseOpacity:1,n=F(e,t);return!!this._dataToTexture(n)&&(e.renderData.setTextureReference(new b(n.sourceLayerInfo.data,p.FADING,n,a,s,i)),!0)}_composeMapLayers(e,t,r,s,o,a,i,n,u){this._composition.bindPool(0,i);const c=e.surface.baseOpacity;let l=!1,p=R.LINEAR_MIPMAP_LINEAR,d=!1,h=0;for(let _=r;_>=0;_--){const t=F(e,_);if(!t)continue;if(0===o[_])continue;const r=_<s&&c<1&&!l;this._passParameters.baseOpacity=r?c:1,r&&(l=!0);const m=0===h,x=u&&m?this.backgroundIsGrid?A.GridComposite:A.ColorComposite:A.Composite;f(t)?(this._passParameters.opacity=o[_],this._passParameters.blendMode=w[a[_]],d=this._composition.drawVectorData(this._passParameters,t,n,this.tileSize,i,d,x)):T(t)?(this._passParameters.opacity=o[_],this._passParameters.blendMode=w[a[_]],this._composition.drawImageryTileData(t,x,this._passParameters),this._hasNearestInterpolation(t)&&(p=R.NEAREST)):this._dataToTexture(t)&&(this._passParameters.texture=t.sourceLayerInfo.data.texture,this._passParameters.offset=t.offset,this._passParameters.scale=t.scale,this._passParameters.opacity=o[_],this._passParameters.blendMode=w[a[_]],this._composition.drawRasterData(x,this._passParameters)),h++}const m=e.renderData.ensureTexture(i,(()=>this._buildTexture(i,p)));this._composition.copyFBOToTexture(m),this._composition.releasePool(),e.renderData.setTextureReference(new b(m,t,z,l?1:c,1,0))}_hasNearestInterpolation(e){const t=e.sourceLayerInfo.data;return!!t.source&&"nearest"===t.interpolation}_dataToTexture(e){return x(e)&&this._rasterDataToTexture(e),y(e)}_rasterDataToTexture(e){const t=e.sourceLayerInfo;t.data=this._buildTexture(t.data),e.tile.setMemoryDirty()}setBackground(e){this._backgroundColor!==e&&(this._backgroundColor=e,this._backgroundDirty=!0)}_buildTexture(e,t=R.LINEAR_MIPMAP_LINEAR){if(s(e))return null;const r={target:M.TEXTURE_2D,pixelFormat:j.RGBA,dataType:O.UNSIGNED_BYTE,wrapMode:N.CLAMP_TO_EDGE,samplingMode:t,maxAnisotropy:this._maxAnisotropy,flipped:!0,hasMipmap:!0},o=this._rctx;let a;if("number"==typeof e)r.width=r.height=e,a=new I(new U(o,r));else if(e instanceof c)r.isOpaque=e.isOpaque,a=new I(new U(o,r,e.image)),e.release();else try{a=new I(new U(o,r,e))}catch(n){a=new I(L(o)),console.warn("TileRenderer: failed to execute 'texImage2D', cross-origin image may not be loaded.")}const i=o.bindTexture(a.texture,U.TEXTURE_UNIT_FOR_UPDATES);return a.generateMipmap(),o.bindTexture(i,U.TEXTURE_UNIT_FOR_UPDATES),a}get test(){return{backgroundTexture:this._backgroundTexture}}}function B(t){const r=e(t),s=r*r,o=t*t;if(s===o)return t;const a=r/2;return s-o<o-a*a?r:a}function F(e,t){q.layerIndex=t;const r=e.layerInfo[d.MAP][t];if(o(r.data))return a(q.offset,0,0),q.tile=e,q.scale=1,q.sourceLod=e.lij,q.sourceLayerInfo=r,q;const s=r.upsampleInfo;if(o(s)){const e=s.tile.layerInfo[d.MAP][t];return q.tile=s.tile,i(q.offset,s.offset),q.scale=s.scale,q.sourceLod=s.tile.lij,q.sourceLayerInfo=e,q}return null}const G=new Array,S=new Array,q={tile:null,sourceLayerInfo:null,sourceLod:null,offset:[0,0],scale:1,layerIndex:0},z={offset:[0,0],scale:1};export{C as TileRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../core/has.js";import{isSome as t,isNone as r}from"../../core/maybe.js";var o;function n(e,r,o={}){const n=i(e);for(;n.length>1;){const e=l(r,n.shift(),o);if(t(e))return e}return c(r,n.shift(),o)}function i(t){const r=e("esri-force-webgl");if(r===o.WEBGL1||r===o.WEBGL2)return[r];switch(t){case"2d":return e("mac")?[o.WEBGL1,o.WEBGL2]:[o.WEBGL2,o.WEBGL1];case"3d":return[o.WEBGL2,o.WEBGL1]}}function c(e,t,o={}){if(!window.WebGLRenderingContext)return a(e,s),null;const n=l(e,t,o);return r(n)&&a(e,u),n}function l(e,t,r={}){const n=t===o.WEBGL1?["webgl","experimental-webgl","webkit-3d","moz-webgl"]:["webgl2"];let i=null;for(const o of n){try{i=e.getContext(o,r)}catch(c){}if(i)break}return i}function a(e,t){const r=e.parentNode;r&&(r.innerHTML='<table style="background-color: #8CE; width: 100%; height: 100%;"><tr><td align="center"><div style="display: table-cell; vertical-align: middle;"><div style="">'+t+"</div></div></td></tr></table>")}!function(e){e[e.WEBGL1=1]="WEBGL1",e[e.WEBGL2=2]="WEBGL2"}(o||(o={}));const s='This page requires a browser that supports WebGL.<br/><a href="http://get.webgl.org">Click here to upgrade your browser.</a>',u='It doesn\'t appear your computer can support WebGL.<br/><a href="http://get.webgl.org/troubleshooting/">Click here for more information.</a>';export{o as ContextType,l as createContext,n as createContextOrErrorHTML,i as getContextTypes};
5
+ import e from"../../core/has.js";import{isSome as t,isNone as r}from"../../core/maybe.js";var o;function n(e,r,o={}){const n=i(e);for(;n.length>1;){const e=l(r,n.shift(),o);if(t(e))return e}return c(r,n.shift(),o)}function i(t){const r=e("esri-force-webgl");if(r===o.WEBGL1||r===o.WEBGL2)return[r];switch(t){case"2d":return e("mac")&&e("chrome")?[o.WEBGL1,o.WEBGL2]:[o.WEBGL2,o.WEBGL1];case"3d":return[o.WEBGL2,o.WEBGL1]}}function c(e,t,o={}){if(!window.WebGLRenderingContext)return a(e,s),null;const n=l(e,t,o);return r(n)&&a(e,u),n}function l(e,t,r={}){const n=t===o.WEBGL1?["webgl","experimental-webgl","webkit-3d","moz-webgl"]:["webgl2"];let i=null;for(const o of n){try{i=e.getContext(o,r)}catch(c){}if(i)break}return i}function a(e,t){const r=e.parentNode;r&&(r.innerHTML='<table style="background-color: #8CE; width: 100%; height: 100%;"><tr><td align="center"><div style="display: table-cell; vertical-align: middle;"><div style="">'+t+"</div></div></td></tr></table>")}!function(e){e[e.WEBGL1=1]="WEBGL1",e[e.WEBGL2=2]="WEBGL2"}(o||(o={}));const s='This page requires a browser that supports WebGL.<br/><a href="http://get.webgl.org">Click here to upgrade your browser.</a>',u='It doesn\'t appear your computer can support WebGL.<br/><a href="http://get.webgl.org/troubleshooting/">Click here for more information.</a>';export{o as ContextType,l as createContext,n as createContextOrErrorHTML,i as getContextTypes};