首页 \ 问答 \ Cartesian3.distance - 返回NaN?(Cartesian3.distance - returning NaN?)

Cartesian3.distance - 返回NaN?(Cartesian3.distance - returning NaN?)

我试图找到鼠标点击和最近的一组广告牌之间的距离。 我的代码如下:

var smallestDistance = -1;
var currentDistance = -1;
var nearestPeak;
var peakPosition;
var mousePosition = new Cesium.Cartesian3(ev.clientX, ev.clientY, 0.0);
for (var i = 0; i < peaks.length; i++) {
    peakPosition = peaks[i].position;
    currentDistance = Cesium.Cartesian3.distance(mousePosition, peakPosition);
    console.log( 'CESIUM: Distance to ' + peaks[i].name + ': ' + currentDistance + ' units.' );
    if (currentDistance < smallestDistance) {
        smallestDistance = currentDistance;
        nearestPeak = displayedPeaks[i];
    }
}
console.log( 'CESIUM: nearest peak is peak ' + nearestPeak.peakId );
if (smallestDistance != -1 && smallestDistance < 100000) {
    selectedPeak = nearestPeak;
}

问题出现在第一个console.log语句中,它显示在:

CESIUM: Distance to peak 1: NaN units.

根据铯的文件,它应该返回一个数字。 我可以发誓我在过去的项目中做了类似的事情,并没有这个问题。 我有强烈的怀疑,我失踪和/或忘记了一些非常基本的东西。 任何人都可以建议吗?

编辑:我做了一些进一步的调试,我发现peakPosition.x和peakPosition.y都是未定义的,其中peakPosition = peak [i] .position。 peak [i]仍然在地球上渲染为广告牌,而peakPosition是一个对象。 根据Cesium文档,它应该是Cartesian3类型的对象,它应该有x和y成员。 那么为什么这些成员是不确定的?

编辑2:我试图更换这一行:

peakPosition = peaks[i].position;

有了这个:

peakPosition = new Cesium.Cartesian3(this.peaks[i].position.x, this.peaks[i].position.y, 0.0);

并且它的x,y和z成员总是0,0和0.我无法想象出我的生活。


I'm trying to find the distance between a mouseclick and the nearest of a set of billboards. My code is as follows:

var smallestDistance = -1;
var currentDistance = -1;
var nearestPeak;
var peakPosition;
var mousePosition = new Cesium.Cartesian3(ev.clientX, ev.clientY, 0.0);
for (var i = 0; i < peaks.length; i++) {
    peakPosition = peaks[i].position;
    currentDistance = Cesium.Cartesian3.distance(mousePosition, peakPosition);
    console.log( 'CESIUM: Distance to ' + peaks[i].name + ': ' + currentDistance + ' units.' );
    if (currentDistance < smallestDistance) {
        smallestDistance = currentDistance;
        nearestPeak = displayedPeaks[i];
    }
}
console.log( 'CESIUM: nearest peak is peak ' + nearestPeak.peakId );
if (smallestDistance != -1 && smallestDistance < 100000) {
    selectedPeak = nearestPeak;
}

The issue appears in the first console.log statement, where it displays:

CESIUM: Distance to peak 1: NaN units.

According to Cesium's documentation, it should be returning a number. I could swear I did something similar in a past project and didn't have this issue. I have a strong suspicion that I am missing and/or forgetting something very basic. Can anyone advise?

EDIT: I did some further debugging, and I am finding that peakPosition.x and peakPosition.y are both undefined, where peakPosition = peaks[i].position. peaks[i] is still rendering as a billboard on the globe, and peakPosition is an object. According to the Cesium documentation, it SHOULD be an object of type Cartesian3, which should have x and y members. So why would those members be undefined?

EDIT 2: I tried replacing this line:

peakPosition = peaks[i].position;

with this:

peakPosition = new Cesium.Cartesian3(this.peaks[i].position.x, this.peaks[i].position.y, 0.0);

and its x, y, and z members are always 0, 0, and 0. I can't figure this out for the life of me.


原文:https://stackoverflow.com/questions/46837189
更新时间:2022-09-05 07:09

最满意答案

jplayer在全屏时为div添加了一类jp-video-full

您可以将该选择器用于您想要实现的任何目标。

if ($("#jp_container_1").hasClass("jp-video-full")) {
    //do something
} else {
   //do something else
}

ok, this is how i had to go:

  $("a.jp-full-screen").click(function(){

  if($(this).attr("title")=="full screen"){
         $(".hover, ul#navigation").hide()
  }
  })


  $("a.jp-restore-screen").click(function(){
     if($(this).attr("title")=="restore screen"){
         $(".hover, ul#navigation").show()
  }
 })

相关问答

更多
  • 在iframe上使用iframeclass使它们彼此重叠,然后使用jQuery将z-index设置为显示哪个“在顶部” .iframeclass { position: absolute; top: 0; left: 0; width:100%; height:100%; } 注意:为了高度:100%; 为了工作,PARENT对象必须设置高度。 即: body { height:100%; } 第二个注意事项,请注意,虽然这回答你的问题,但它不是我如何推荐做我认为 ...
  • 可以使用JavaScript 。 var elem = document.getElementById("myvideo"); if (elem.requestFullscreen) { elem.requestFullscreen(); } else if (elem.msRequestFullscreen) { elem.msRequestFullscreen(); } else if (elem.mozRequestFullScreen) { elem.mozRequestFullScre ...
  • 只需将WindowState设置为“ Maximized ,将“ WindowStyle为“ None 。 Just set the WindowState to Maximized, and the WindowStyle to None.
  • Grooveshark有时会做的一件事就是把歌曲的当前长度除以加载的百分比。 除了可能的VBR文件之外,这将为您提供对文件实际持续时间的良好估计。 您也可以尝试查看ID3标签。 One thing you can do, which Grooveshark does sometimes, is take the current length of the song and divide it by the percentage loaded. This will give you a good estima ...
  • jplayer在全屏时为div添加了一类jp-video-full 。 您可以将该选择器用于您想要实现的任何目标。 if ($("#jp_container_1").hasClass("jp-video-full")) { //do something } else { //do something else } ok, this is how i had to go: $("a.jp-full-screen").click(function(){ if($(this).attr( ...
  • 天啊。 我正在将玩家加载到错误的div中。 它现在正在运作: $(function() { $("a.jwVideo").click(function() { var myVideo = this.href; // Dont forget about 'this' $.fancybox({ padding : 0, content: '
    Loading the play ...
  • 试着用这个 jQuery(document).ready(function(){ $('#jQuery_jPlayer1').jPlayer({ ready: function () { $(this).jPlayer("setMedia", { m4v: "/Users/itsme/Desktop/sample_video.m4v" }); }, supplied: "m4v" }); }); I guess, it's cau ...
  • 您正在使用来自文档的jPlayer的播放列表插件 : 第三个参数是用于定义jPlayer选项和jPlayerPlaylist选项的对象。 该对象传递给jPlayer(...) 在这里,您可以看到jPlayer的可用事件列表。 对您的问题有用的一个是: $ .jPlayer.event.play *播放媒体时发生。 因此,在您的代码中,您可以添加最后一个参数来覆盖jPlayer的play事件。 在那里,您可以访问当时正在播放的歌曲的标题: play: function(e) { console.log ...
  • 尝试win.state('zoomed') ,其中win是你的Tk窗口实例。 编辑: 尝试这样的事情。 简单地将此类视为Tk窗口类。 class Void (tk.Tk) : def __init__ (self, color='black') : tk.Tk.__init__(self) self.wm_state('zoomed') self.config(bg=color) self.overrideredirect(True) ...
  • 视图没有调整大小,因为您的代码永远不会告诉它。 如果希望它在旋转时调整大小,则需要在容器视图因旋转而发生更改时调整MPMoviePlayerController的视图大小。 (在viewWillLayoutSubviews设置框架或使用autolayout将MPMoviePlayerController的视图约束到呈现控制器的视图。) 您也可以使用MPMoviePlayerViewController而不是MPMoviePlayerController 。 来自文档: 与MPMoviePlayerContr ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)