简体   繁体   English

Nasa worldwind - 在地球 animation 结束后运行自定义 function

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

I am using the worldwind nasa earth.我正在使用worldwind nasa earth。

I have created a set of locations (each location has different coordinations) and I need to run a function each time the earth moves from one location to another.我创建了一组位置(每个位置都有不同的坐标),每次地球从一个位置移动到另一个位置时,我都需要运行 function。 The function has to run in the end of each rotation. function 必须在每次旋转结束时运行。

The problem is that the time to move between the locations is different (eg from Italy to USA and then to England).问题是在不同地点之间移动的时间不同(例如从意大利到美国,然后到英国)。

I have unminified the worldwind.js file and tried to run my function inside the t.prototype.goTo 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');
            })

The custom line I am using for testing is the "$('#searchButton').css('color', '#000');".我用于测试的自定义行是“$('#searchButton').css('color', '#000');”。 It works correctly but it runs in the beginning on the earth rotation.它工作正常,但它在地球自转开始时运行。 I need it to run after the rotation ends.我需要它在轮换结束后运行。

Any idea how I could make this happen?知道我怎么能做到这一点吗?

Thank you in advance.先感谢您。

The simplest thing is probably to use a timeout:最简单的事情可能是使用超时:

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

set the time value to make sure that it always runs after the animation completes.设置时间值以确保它始终在 animation 完成后运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM