@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 5.45 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{_ as t}from"../../../../../chunks/tslib.es6.js";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}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as s}from"../../../../../core/accessorSupport/decorators/subclass.js";let a=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=>"object"===t.type))}get _orientationReferenceSymbolLayer(){const t=this._graphicSymbol;return null==t||0===t.symbolLayers.length?null:t.symbolLayers.find((t=>"object"===t.type&&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 h;const i=t.symbolLayers.map((i=>"object"===i.type?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);"object"===t.type&&"object"===n.type&&i(t,n,l)}))}};function c(t){return-l(t)}t([r()],a.prototype,"initialAngle",null),t([r()],a.prototype,"angle",null),t([r()],a.prototype,"angleClockwise",null),t([r()],a.prototype,"orientation",null),t([r()],a.prototype,"orientationClockwise",null),t([r()],a.prototype,"relativeAngle",null),t([r()],a.prototype,"relativeAngleClockwise",null),t([r()],a.prototype,"scale",null),t([r()],a.prototype,"size",null),t([r()],a.prototype,"sizeAxis",void 0),t([r({constructOnly:!0})],a.prototype,"graphic",void 0),t([r()],a.prototype,"_interactionState",void 0),t([r({constructOnly:!0})],a.prototype,"findLayerView",void 0),t([r({constructOnly:!0})],a.prototype,"sizeFilter",void 0),t([r()],a.prototype,"_sizeReferenceSymbolLayer",null),t([r()],a.prototype,"_orientationReferenceSymbolLayer",null),t([r()],a.prototype,"_graphicSymbol",null),a=t([s("esri.views.3d.interactive.editingTools.transform.ScaleRotateObjectSymbol3DAdapter")],a);const h={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{a as ScaleRotateObjectSymbol3DAdapter,c as headingToAngle};