You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
12 KiB
26 lines
12 KiB
// All material copyright Esri, All Rights Reserved, unless otherwise specified. |
|
// See https://js.arcgis.com/4.30/esri/copyright.txt for details. |
|
//>>built |
|
define("exports ../../../chunks/tslib.es6 ../../../geometry ../../../core/Evented ../../../core/has ../../../core/maybe ../../../core/promiseUtils ../../../core/quantityUtils ../../../core/reactiveUtils ../../../core/accessorSupport/decorators/property ../../../core/Logger ../../../core/RandomLCG ../../../core/accessorSupport/decorators/subclass ../../../chunks/vec32 ../../../core/libs/gl-matrix-2/factories/vec3f64 ../../../geometry/projection ../../../geometry/projection/projectPointToVector ../../../geometry/support/spatialReferenceUtils ../../ViewingMode ./EnvironmentRenderer ../support/earthUtils ../support/sunUtils ../webgl-engine/lib/Update ../webgl-engine/lighting/Lightsources ../../support/euclideanLengthMeasurementUtils ../../../geometry/SpatialReference".split(" "), |
|
function(g,h,M,z,N,A,u,B,e,l,O,P,C,m,p,v,D,w,E,F,x,n,q,r,G,t){g.SceneViewEnvironmentManager=class extends z.EventedAccessor{constructor(){super();this._referencePointUpdateDelay=200;this._referencePointUpdateInterval=3E3;this._referencePointUpdateDistThreshold=1E6;this._referencePosMapCoordsRequested=this._referencePosUpdateQuery=null;this._viewHandlesKey="viewHandles";this._referencePosResetPreserveAbsoluteTime=this._trackingEnabled=this._preserveAbsoluteDateTime=!1;this._referencePosMapCoords=this._referencePosUpdateTimer= |
|
null;this._mainLight=new r.MainLight;this._ambientLight=new r.AmbientLight;this._moonLight=new r.FillLight;this._disableWeather=this.disableQueries=!1;this._referencePositionGeographic=this._renderer=null;this._resetReferencePosition()}destroy(){this.disconnectView()}get _view(){return this._renderer?.view}get updating(){return!((this.disableQueries||!this._referencePosUpdateQuery&&!this._referencePosMapCoordsRequested)&&!this._renderer?.updating)}get weatherEnabled(){return this._view?.environment.atmosphereEnabled&& |
|
!this._disableWeather&&this._view?.state?.viewingMode===E.ViewingMode.Global&&w.isEarth(this._view.spatialReference)}get weatherVisible(){return this.weatherEnabled&&this._renderer?.weatherVisible}get referencePositionGeographic(){return this._referencePositionGeographic}connectView(a){if(!this._renderer){this._renderer=new F.EnvironmentRenderer({view:a});var c=()=>this._updateRenderParameters(),b=()=>this._cameraHandler();this.addHandles([e.watch(()=>a.environment.lighting,d=>this._updateLightingHandler(d), |
|
e.sync),e.watch(()=>"virtual"!==a.environment.lighting.type?a.environment.lighting.date:null,d=>this._lightingDateHandler(d),e.sync),e.watch(()=>a.stationary,()=>this._interactingStationaryHandler()),e.watch(()=>a.environment.lighting.directShadowsEnabled,c,e.sync),e.watch(()=>a.qualitySettings.ambientOcclusion,c,e.sync),e.watch(()=>a.qualitySettings.reflections,c,e.sync),e.watch(()=>a.spatialReference,()=>this._resetReferencePosition(!0),e.sync),e.watch(()=>a.environment.weather.type,()=>this._updateLighting(null, |
|
q.Update.Faded),e.sync),e.watch(()=>this.weatherEnabled,()=>this._updateLighting(null,q.Update.Faded),e.sync),e.watch(()=>a.viewingMode,()=>this._resetReferencePosition(!0),e.syncAndInitial),e.watch(()=>"virtual"!==a.environment.lighting.type?a.environment.lighting.cameraTrackingEnabled:!1,d=>this._updateCameraTracking(d),e.syncAndInitial),e.watch(()=>a.state.camera,b,e.syncAndInitial),e.watch(()=>this.disableQueries,b)],this._viewHandlesKey);this._updateRenderParameters();this._updateLighting(); |
|
this._cameraHandler();this.notifyChange("updating")}}disconnectView(){this.removeHandles(this._viewHandlesKey);this._resetReferencePosition();this._renderer=A.destroyMaybe(this._renderer)}_updateLightingHandler(a){this._updateCameraTracking("virtual"!==a.type?a.cameraTrackingEnabled:!1);this._lightingDateHandler("virtual"!==a.type?a.date:null);this._updateRenderParameters()}_updateCameraTracking(a){(this._trackingEnabled=a)?this._cameraHandler():(a=this._view.environment.lighting,"virtual"!==a?.type&& |
|
(a.positionTimezoneInfo.autoUpdated=!1))}_lightingDateHandler(a){const c=this._view.environment.lighting;if("virtual"===c?.type)this._updateLighting();else if(a){if(!c.positionTimezoneInfo.autoUpdated){this._preserveAbsoluteDateTime=!0;if(!v.canProjectWithoutEngine(this._view.spatialReference,t.WGS84)){var b=this._view.camera.position;if(!this._referencePosMapCoords||!this._referencePosMapCoords.equals(b)){this._requestReferencePositionUpdate(b);return}}this._preupdateTracking(a);null!=this._referencePositionGeographic&& |
|
(b=x.positionToTimezoneInfo(this._referencePositionGeographic,y),null!=b&&(c.autoUpdate(null,b),this._trackingEnabled&&(c.positionTimezoneInfo.autoUpdated=!0)))}this._updateLighting(a)}}_preupdateTracking(a){!this._trackingEnabled&&"virtual"!==this._view.environment.lighting.type&&this._view.environment.lighting.cameraTrackingEnabled&&this._cameraHandler(a)}_cameraHandler(a=null){var c=this._view;c.ready&&(c=c.stateManager.camera)&&(this._cameraHandlerClientSide(c,a)||this._cameraHandlerServerSide(c))}_cameraHandlerClientSide(a, |
|
c){const b=w.isEarth(this._view.spatialReference);if(b&&!v.canProjectWithoutEngine(this._view.spatialReference,t.WGS84))return"virtual"===this._view.environment.lighting.type&&this._updateLighting(),!1;a=a.position;this._referencePositionGeographic??(this._referencePositionGeographic=p.create());b?D.projectPointToVector(a,this._referencePositionGeographic,t.WGS84):m.set(this._referencePositionGeographic,a.longitude??0,a.latitude??0,a.z??0);this.notifyChange("referencePositionGeographic");this._autoUpdateTimezone(this._referencePositionGeographic, |
|
c)||this._updateLighting(c);return!0}_cameraHandlerServerSide(a){a=a.position;(!this._referencePosMapCoords||this._referencePosMapCoordsRequested||this._exceedsReferencePosDistThreshold(a))&&this._requestReferencePositionUpdate(a,!0);this._view.mapCoordsHelper&&this._referencePositionGeographic&&(this._referencePositionGeographic[2]=(a.z??0)*this._view.mapCoordsHelper.unitInMeters,this._referencePosChanged())}_interactingStationaryHandler(){this._view.stationary&&this._executePendingReferencePositionUpdate()}_updateLighting(a, |
|
c=q.Update.Immediate){var b=this._view;a=a||("virtual"===b.environment.lighting.type?null:b.environment.lighting.date);var d=this._referencePositionGeographic;const f=d?H:I;var k=this.weatherVisible?b.environment.weather.type:"disabled";null!=d?n.computeColorAndIntensity(a,d,b.state.viewingMode,k,b.state.camera,f):"virtual"===b.environment.lighting.type&&n.computeVirtualLightDirection(b.state.camera,b.state.viewingMode,f.direct.directionToLightSource);a=this._mainLight;b=f.direct;m.scale(a.intensity, |
|
b.color,b.intensity*Math.PI);m.copy(a.direction,b.directionToLightSource);a.specularStrength=f.specularStrength;a.environmentStrength=f.environmentStrength;d=this._ambientLight;m.scale(d.intensity,f.ambient.color,f.ambient.intensity);k=this._moonLight;m.lerp(k.intensity,J,K,f.globalFactor);m.scale(k.intensity,k.intensity,(1-.5*f.globalFactor)*(1-.4*f.noonFactor*(1-f.globalFactor)));m.copy(k.direction,b.directionToLightSource);this._renderer.updateLightSources([a,d,k],f.noonFactor,f.globalFactor,c); |
|
this._updateRenderParameters()}_autoUpdateTimezone(a,c=null){if("virtual"===this._view.environment.lighting.type||!this._view.environment.lighting.cameraTrackingEnabled||null==a)return!1;const b=L;b.setTime((c||this._view.environment.lighting.date).getTime());a=x.positionToTimezoneInfo(a,y);if(null==a)return!1;var d=this._view.environment.lighting.positionTimezoneInfo;if(!d.autoUpdated)d=a;else if(d.hours===a.hours&&d.minutes===a.minutes&&d.seconds===a.seconds)return!1;const f=b.getUTCHours()-(a.hours- |
|
d.hours),k=b.getUTCMinutes()-(a.minutes-d.minutes);d=b.getUTCSeconds()-(a.seconds-d.seconds);b.setUTCHours(f);b.setUTCMinutes(k);b.setUTCSeconds(d);return c?!1:this._view.environment.lighting.autoUpdate(b,a)}_updateRenderParameters(){const a=this._view._stage;if(a){var c=null==this._referencePositionGeographic||n.computeShadowsEnabled(this._referencePositionGeographic[2],this._view.state.viewingMode);a.renderer.setParameters({shadowMap:this._view.environment.lighting.directShadowsEnabled&&c,environment:this._view.environment, |
|
weatherVisible:this._view.environmentManager.weatherVisible,qualitySettings:this._view.qualitySettings})}}_resetReferencePosition(a=!1){this._cancelReferencePosUpdates();this._referencePositionGeographic=this._referencePosResetPreserveAbsoluteTime=this._referencePosMapCoordsRequested=this._referencePosMapCoords=null;this.notifyChange("updating");a&&this._cameraHandler()}_requestReferencePositionUpdate(a,c=!1){if(!this.disableQueries&&(this._referencePosMapCoordsRequested?this._referencePosMapCoordsRequested.copy(a): |
|
this._referencePosMapCoordsRequested=a.clone(),this._referencePosResetPreserveAbsoluteTime=!!c,!this._referencePosUpdateQuery&&!this._referencePosUpdateTimer&&this._view.stationary)){const b=this._referencePosUpdateQuery=u.after(this._referencePointUpdateDelay).then(()=>{if(this._referencePosUpdateQuery===b)return this._doReferencePositionUpdateQuery(()=>this._referencePosUpdateQuery!==b)}).catch(f=>{"mapcoordshelper:missing-geometry-service"===f.name&&(this.disableQueries=!0)}).then(()=>{this._referencePosUpdateQuery=== |
|
b&&(this._referencePosUpdateQuery=null,this._referencePosUpdateTimer||this._executePendingReferencePositionUpdate(),this.notifyChange("updating"))}),d=this._referencePosUpdateTimer=u.after(this._referencePointUpdateInterval).then(()=>{this._referencePosUpdateTimer===d&&(this._referencePosUpdateTimer=null,this._referencePosUpdateQuery||this._executePendingReferencePositionUpdate())});this.notifyChange("updating")}}async _doReferencePositionUpdateQuery(a){this._referencePosResetPreserveAbsoluteTime&& |
|
(this._preserveAbsoluteDateTime=!1);this._referencePosMapCoords?this._referencePosMapCoords.copy(this._referencePosMapCoordsRequested):this._referencePosMapCoords=this._referencePosMapCoordsRequested.clone();this._referencePosMapCoordsRequested=this._referencePosResetPreserveAbsoluteTime=null;const c=await this._view.mapCoordsHelper.toGeographic(this._referencePosMapCoords);a()||isNaN(c[0])||isNaN(c[1])||(a=(this._referencePosMapCoords.z??0)*this._view.mapCoordsHelper.unitInMeters,this._referencePositionGeographic? |
|
m.set(this._referencePositionGeographic,c[0],c[1],a):this._referencePositionGeographic=p.fromValues(c[0],c[1],a),this._referencePosChanged())}_executePendingReferencePositionUpdate(){const a=this._referencePosMapCoordsRequested;a&&this._requestReferencePositionUpdate(a,this._referencePosResetPreserveAbsoluteTime)}_referencePosChanged(){this._preserveAbsoluteDateTime?this._updateLighting():this._autoUpdateTimezone(this._referencePositionGeographic)||this._updateLighting();this.notifyChange("referencePositionGeographic")}_exceedsReferencePosDistThreshold(a){const c= |
|
this._referencePosMapCoords;if(null==c)return!0;a=G.euclideanDirectDistanceBetweenPoints(c,a);return null==a?!0:B.toUnit(a,"meters").value>this._referencePointUpdateDistThreshold}_cancelReferencePosUpdates(){const a=!!this._referencePosUpdateQuery;this._referencePosUpdateTimer=this._referencePosUpdateQuery=null;return a}get test(){}};h.__decorate([l.property({type:Boolean,readOnly:!0})],g.SceneViewEnvironmentManager.prototype,"updating",null);h.__decorate([l.property()],g.SceneViewEnvironmentManager.prototype, |
|
"disableQueries",void 0);h.__decorate([l.property()],g.SceneViewEnvironmentManager.prototype,"_disableWeather",void 0);h.__decorate([l.property()],g.SceneViewEnvironmentManager.prototype,"weatherEnabled",null);h.__decorate([l.property()],g.SceneViewEnvironmentManager.prototype,"weatherVisible",null);h.__decorate([l.property()],g.SceneViewEnvironmentManager.prototype,"referencePositionGeographic",null);h.__decorate([l.property()],g.SceneViewEnvironmentManager.prototype,"_renderer",void 0);h.__decorate([l.property()], |
|
g.SceneViewEnvironmentManager.prototype,"_referencePositionGeographic",void 0);g.SceneViewEnvironmentManager=h.__decorate([C.subclass("esri.views.3d.environment.SceneViewEnvironmentManager")],g.SceneViewEnvironmentManager);const H=new n.ColorAndIntensity,I=new n.ColorAndIntensity,L=new Date,y={hours:0,minutes:0,seconds:0},J=p.fromValues(.22,.22,.33),K=p.fromValues(.22,.22,.22);Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}); |