UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 5.47 kB
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import r from"../../../core/Evented.js";import{isSome as o,unwrapOr as a}from"../../../core/maybe.js";import{when as i}from"../../../core/reactiveUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{afterDispatch as l}from"../../../core/accessorSupport/watch.js";import{f as p}from"../../../chunks/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import m from"../../ViewAnimation.js";import{ViewingMode as d}from"../../ViewingMode.js";import{Constraints as h}from"./Constraints.js";import{AnimationController as u}from"./controllers/AnimationController.js";import{State as g}from"./controllers/CameraController.js";import{PropertiesPool as C}from"../support/PropertiesPool.js";import{Camera as y,PaddingSide as f}from"../webgl-engine/lib/Camera.js";import{RenderState as _}from"../../support/RenderState.js";let v=class extends t{constructor(){super(...arguments),this._propertiesPool=new C({camera:y},this),this._lastSeenCameraProjectionValues=new y,this.mode=_.ANIMATING,this.rasterPixelRatio=1,this.contentPixelRatio=1,this.events=new r,this.viewingMode=d.Global,this._cameraChanged=!1,this._updateQueue=new Array,this._processingUpdates=!1}init(e,t){this._set("viewingMode",e),this._set("spatialReference",t),this._set("constraints",new h({mode:this.viewingMode}))}exit(){this.cameraController=null,this._propertiesPool.destroy(),this._propertiesPool=new C({camera:y},this)}createInitialCamera(){if(this.viewingMode===d.Global){const e=c(this.spatialReference).radius;this.camera=new y({eye:p(4*e,0,0),center:p(e,0,0),up:p(0,0,1)})}else this.camera=new y({eye:p(0,0,100),center:p(0,0,0),up:p(0,1,0)})}get animation(){return this.cameraController instanceof u&&o(this.cameraController.viewAnimation)?this.cameraController.viewAnimation:null}get camera(){return this._get("camera")}set camera(e){e!==j&&j.copyFrom(e),j.computeUp(this.viewingMode),this.events.emit("before-camera-change",j);const t=this._get("camera");if(this._cameraProjectionChanged(this._lastSeenCameraProjectionValues,j)&&(this._lastSeenCameraProjectionValues.copyFrom(j),this.events.emit("camera-projection-changed",this._lastSeenCameraProjectionValues)),(!t||!t.equals(j))&&(this._set("camera",this._propertiesPool.get("camera").copyFrom(j)),this._cameraChanged=!t||!t.almostEquals(j),this._cameraChanged)){const e=l((()=>{this._cameraChanged=!1,e.remove()}))}}get pixelRatio(){return this.camera.pixelRatio}get contentCamera(){return a(this._contentCamera,this.camera)}set contentCamera(e){this._contentCamera=o(e)?e.clone():null}get fixedContentCamera(){return o(this._contentCamera)}get isGlobal(){return this.viewingMode===d.Global}get isLocal(){return this.viewingMode===d.Local}get navigating(){return!(!this.cameraController||!this.cameraController.isInteractive)}get stationary(){return!this._cameraChanged&&!this.navigating}get cameraController(){return this._get("cameraController")}set cameraController(e){this.stopActiveCameraController()?(e&&(this.removeHandles(P),this.addHandles(i((()=>e.state===g.Finished||e.state===g.Stopped),(()=>{this._set("cameraController",null),this.updateCamera((t=>e.onControllerEnd(t)))}),{sync:!0,once:!0}),P),e.onControllerStart(this.camera)),this._set("cameraController",e)):e&&(e.state=g.Rejected)}switchCameraController(e){return this.cameraController=e,e.state!==g.Rejected}stopActiveCameraController(){return!(this.cameraController&&!this.cameraController.stopController())}updateCamera(e){this._updateQueue.push(e),this._processUpdateQueue()}_processUpdateQueue(){if(0===this._updateQueue.length||this._processingUpdates)return;this._processingUpdates=!0;const e=this._updateQueue.shift();j.copyFrom(this._get("camera")),e(j),this.camera=j,this._processingUpdates=!1,this._processUpdateQueue()}_cameraProjectionChanged(e,t){return e.fov!==t.fov||(e.fullViewport[0]!==t.fullViewport[0]||e.fullViewport[1]!==t.fullViewport[1]||e.fullViewport[2]!==t.fullViewport[2]||e.fullViewport[3]!==t.fullViewport[3]||(e.padding[f.TOP]!==t.padding[f.TOP]||e.padding[f.RIGHT]!==t.padding[f.RIGHT]||e.padding[f.BOTTOM]!==t.padding[f.BOTTOM]||e.padding[f.LEFT]!==t.padding[f.LEFT]))}};e([s()],v.prototype,"mode",void 0),e([s({readOnly:!0,type:m})],v.prototype,"animation",null),e([s({type:y})],v.prototype,"camera",null),e([s({readOnly:!0})],v.prototype,"pixelRatio",null),e([s()],v.prototype,"rasterPixelRatio",void 0),e([s()],v.prototype,"contentPixelRatio",void 0),e([s({})],v.prototype,"_contentCamera",void 0),e([s({type:y})],v.prototype,"contentCamera",null),e([s({readOnly:!0})],v.prototype,"fixedContentCamera",null),e([s({readOnly:!0})],v.prototype,"constraints",void 0),e([s({readOnly:!0})],v.prototype,"events",void 0),e([s({readOnly:!0})],v.prototype,"isGlobal",null),e([s({readOnly:!0})],v.prototype,"isLocal",null),e([s({readOnly:!0})],v.prototype,"viewingMode",void 0),e([s({readOnly:!0})],v.prototype,"spatialReference",void 0),e([s()],v.prototype,"navigating",null),e([s()],v.prototype,"stationary",null),e([s()],v.prototype,"_cameraChanged",void 0),e([s()],v.prototype,"cameraController",null),v=e([n("esri.views.3d.state.ViewState")],v);const w=v,j=new y,P="ViewStateHandles";export{w as default};