簡體   English   中英

Nasa worldwind - 在地球 animation 結束后運行自定義 function

[英]Nasa worldwind - run custom function after the earth animation ends

我正在使用worldwind nasa earth。

我創建了一組位置(每個位置都有不同的坐標),每次地球從一個位置移動到另一個位置時,我都需要運行 function。 function 必須在每次旋轉結束時運行。

問題是在不同地點之間移動的時間不同(例如從意大利到美國,然后到英國)。

我已經取消了 worldwind.js 文件並嘗試在 t.prototype.goTo function 中運行我的 function

(t.prototype.goTo = function (t, e) {
                if (!t) throw new ArgumentError(d.logMessage(d.LEVEL_SEVERE, "GoToAnimator", "goTo", "missingPosition"));
                (this.completionCallback = e),
                    (this.cancelled = !1),
                    (this.targetPosition = new f(t.latitude, t.longitude, t.altitude || this.wwd.navigator.range)),
                    (this.startPosition = new f(this.wwd.navigator.lookAtLocation.latitude, this.wwd.navigator.lookAtLocation.longitude, this.wwd.navigator.range)),
                    (this.startTime = Date.now());
                var i,
                    r = this.travelTime,
                    n = c.greatCircleDistance(this.startPosition, this.targetPosition),
                    o = this.wwd.globe.computePointFromLocation(this.startPosition.latitude, this.startPosition.longitude, new p(0, 0, 0)),
                    s = this.wwd.globe.computePointFromLocation(this.targetPosition.latitude, this.targetPosition.longitude, new p(0, 0, 0));
                this.maxAltitude = o.distanceTo(s);
                var a = (this.wwd.navigator.currentState().pixelSizeAtDistance(this.startPosition.altitude) * this.wwd.canvas.clientWidth) / this.wwd.globe.equatorialRadius;
                n <= 2 * a && (this.maxAltitude = this.startPosition.altitude),
                    (this.maxAltitudeReachedTime = this.maxAltitude <= this.wwd.navigator.range ? Date.now() : null),
                    this.maxAltitude > this.startPosition.altitude
                        ? ((i = Math.max(0, this.maxAltitude - this.startPosition.altitude)), (i += Math.abs(this.targetPosition.altitude - this.maxAltitude)))
                        : (i = Math.abs(this.targetPosition.altitude - this.startPosition.altitude));
                var l = Math.max(n, i / this.wwd.globe.equatorialRadius);
                if (0 !== l) {
                    l < 2 * a && (r = Math.min((l / a) * this.travelTime, this.travelTime)), (r = Math.max(1, r)), (this.panVelocity = n / r), (this.rangeVelocity = i / r);
                    var h = this,
                        u = function () {
                            h.cancelled ? h.completionCallback && h.completionCallback(h) : h.update() ? setTimeout(u, h.animationFrequency) : h.completionCallback && h.completionCallback(h);
                        };
                    setTimeout(u, this.animationFrequency);
                }
                
                $('#searchButton').css('color', '#000');
            })

我用於測試的自定義行是“$('#searchButton').css('color', '#000');”。 它工作正常,但它在地球自轉開始時運行。 我需要它在輪換結束后運行。

知道我怎么能做到這一點嗎?

先感謝您。

最簡單的事情可能是使用超時:

setTimeout(()=>{ $('#searchButton').css('color', '#000');
}, 2000);
            

設置時間值以確保它始終在 animation 完成后運行。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM