UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

3 lines (2 loc) 5.15 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */ import{__decorate as t}from"tslib";import e from"../../../../../core/Accessor.js";import{rad2deg as i,deg2rad as l}from"../../../../../core/mathUtils.js";import{when as n,sync as o}from"../../../../../core/reactiveUtils.js";import{property as r,subclass as s}from"../../../../../core/accessorSupport/decorators.js";import{isObjectSymbol3DLayer as a}from"../../../layers/support/layerUtils.js";let h=class extends e{constructor(t){super(t),this.sizeAxis=null,this._interactionState=null}initialize(){this.addHandles(n(()=>null!=this._interactionState?this._interactionState.state:null,t=>{this._updateSymbol(t)},o))}get initialAngle(){return this._interactionState?.initialAngle??0}get angle(){return null!=this._interactionState?this._interactionState.angle:null!=this._orientationReferenceSymbolLayer?c(this._orientationReferenceSymbolLayer.heading??0):0}get angleClockwise(){return-this.angle}get orientation(){return this.angle}get orientationClockwise(){return this.angleClockwise}get relativeAngle(){return this.angle-this.initialAngle}get relativeAngleClockwise(){return-this.relativeAngle}get scale(){return this._interactionState?.scale??1}get size(){const t=this._sizeReferenceSymbolLayer;if(null==t)return null;const e=this.findLayerView(),i=this._graphicSymbol;if(null==e||null==i||"point-3d"!==i.type)return null;const l=e.getSymbolLayerSize(i,t);if("size"in l&&null!=l.size)return l.size;const n=this.sizeAxis;return!("width"in l)||null==l.width||null!=n&&"width"!==n&&"all"!==n&&"width-and-depth"!==n?!("depth"in l)||null==t.depth||null!=n&&"depth"!==n&&"all"!==n&&"width-and-depth"!==n?!("height"in l)||null==t.height||null!=n&&"height"!==n&&"all"!==n?null:l.height:l.depth:l.width}get _sizeReferenceSymbolLayer(){const t=this._graphicSymbol;return null==t||0===t.symbolLayers.length?null:t.symbolLayers.find(t=>a(t))}get _orientationReferenceSymbolLayer(){const t=this._graphicSymbol;return null==t||0===t.symbolLayers.length?null:t.symbolLayers.find(t=>a(t)&&null!=t.heading)}get _graphicSymbol(){return null!=this.graphic?.symbol&&"point-3d"===this.graphic.symbol.type?this.graphic.symbol:null}set _graphicSymbol(t){this.graphic.symbol=t}startInteraction(){const t=this._graphicSymbol,e=this.findLayerView();if(null!=this._interactionState||null==t||null==e)return y;const i=t.symbolLayers.map(i=>a(i)?e.getSymbolLayerSize(t,i):null).toArray(),l=t.clone(),n=this.angle,o=new p({originalSymbol:l,angle:n,initialSizes:i});this._interactionState=o;const r=()=>{this._interactionState=null};return{state:o,done:r,cancel:()=>{this._graphicSymbol=l,r()}}}createUndoRecord(){let t=this.graphic.symbol,e=null;return{undo:i=>{e=i.symbol,i.symbol=t},redo:i=>{t=i.symbol,i.symbol=e}}}_updateSymbol({scale:t,angle:e,originalSymbol:l,initialSizes:n}){const o=this._graphicSymbol;if(null==o||"point-3d"!==o.type)return;const r=o.clone(),s=-i(e-this.initialAngle);let a=!1;this._forEachObjectSymbolLayerPair(l,r,(e,i,l)=>{const o=(e.heading??0)+s;i.heading!==o&&(i.heading=o,a=!0);const r=n[l];if(null!=r&&"width"in r){r.width=this.sizeFilter(r.width),r.height=this.sizeFilter(r.height),r.depth=this.sizeFilter(r.depth);const e=r.width*t;i.width!==e&&(i.width=e,a=!0);const l=r.depth*t;i.depth!==l&&(i.depth=l,a=!0);const n=r.height*t;i.height!==n&&(i.height=n,a=!0)}}),a&&(this._graphicSymbol=r)}_forEachObjectSymbolLayerPair(t,e,i){t.symbolLayers.forEach((t,l)=>{const n=e.symbolLayers.at(l);a(t)&&a(n)&&i(t,n,l)})}};function c(t){return-l(t)}t([r()],h.prototype,"initialAngle",null),t([r()],h.prototype,"angle",null),t([r()],h.prototype,"angleClockwise",null),t([r()],h.prototype,"orientation",null),t([r()],h.prototype,"orientationClockwise",null),t([r()],h.prototype,"relativeAngle",null),t([r()],h.prototype,"relativeAngleClockwise",null),t([r()],h.prototype,"scale",null),t([r()],h.prototype,"size",null),t([r()],h.prototype,"sizeAxis",void 0),t([r({constructOnly:!0})],h.prototype,"graphic",void 0),t([r()],h.prototype,"_interactionState",void 0),t([r({constructOnly:!0})],h.prototype,"findLayerView",void 0),t([r({constructOnly:!0})],h.prototype,"sizeFilter",void 0),t([r()],h.prototype,"_sizeReferenceSymbolLayer",null),t([r()],h.prototype,"_orientationReferenceSymbolLayer",null),t([r()],h.prototype,"_graphicSymbol",null),h=t([s("esri.views.3d.interactive.editingTools.transform.ScaleRotateObjectSymbol3DAdapter")],h);const y={state:{angle:0,scale:0},done:()=>{},cancel:()=>{}};let p=class extends e{get state(){const{originalSymbol:t,angle:e,initialAngle:i,scale:l,initialSizes:n}=this;return{originalSymbol:t,angle:e,initialAngle:i,scale:l,initialSizes:n}}constructor(t){super(t),this.angle=0,this.initialAngle=0,this.scale=1,this.initialAngle=t.angle}};t([r()],p.prototype,"originalSymbol",void 0),t([r()],p.prototype,"angle",void 0),t([r()],p.prototype,"initialAngle",void 0),t([r()],p.prototype,"initialSizes",void 0),t([r()],p.prototype,"scale",void 0),t([r()],p.prototype,"state",null),p=t([s("esri.views.3d.interactive.editingTools.transform.ScaleRotateObjectSymbol3DAdapter.InteractionState")],p);export{h as ScaleRotateObjectSymbol3DAdapter,c as headingToAngle};