File tree Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -146,8 +146,7 @@ olcs.OLCesium = function(map, opt_target) {
146146 this . cesiumRenderingDelay_ = new goog . async . AnimationDelay ( function ( time ) {
147147 this . scene_ . initializeFrame ( ) ;
148148 this . scene_ . render ( ) ;
149- this . camera_ . checkCameraChange ( ) ;
150-
149+ this . enabled_ && this . camera_ . checkCameraChange ( ) ;
151150 this . cesiumRenderingDelay_ . start ( ) ;
152151 } , undefined , this ) ;
153152} ;
@@ -244,3 +243,30 @@ olcs.OLCesium.prototype.setEnabled = function(opt_enable) {
244243 this . cesiumRenderingDelay_ . stop ( ) ;
245244 }
246245} ;
246+
247+
248+ /**
249+ * Preload Cesium so that it is ready when transitioning from 2D to 3D.
250+ * @param {number } height Target height of the camera
251+ * @param {number } timeout Milliseconds after which the warming will stop
252+ * @api
253+ */
254+ olcs . OLCesium . prototype . warmUp = function ( height , timeout ) {
255+ if ( this . enabled_ ) {
256+ // already enabled
257+ return ;
258+ }
259+ this . camera_ . readFromView ( ) ;
260+ var ellipsoid = this . globe_ . ellipsoid ;
261+ var csCamera = this . scene_ . camera ;
262+ var position = ellipsoid . cartesianToCartographic ( csCamera . position ) ;
263+ if ( position . height < height ) {
264+ position . height = height ;
265+ csCamera . position = ellipsoid . cartographicToCartesian ( position ) ;
266+ }
267+ this . cesiumRenderingDelay_ . start ( ) ;
268+ var that = this ;
269+ setTimeout (
270+ function ( ) { ! that . enabled_ && that . cesiumRenderingDelay_ . stop ( ) ; } ,
271+ timeout ) ;
272+ } ;
You can’t perform that action at this time.
0 commit comments