【问题标题】:jQuery Dialog not working in three.jsjQuery 对话框在three.js 中不起作用
【发布时间】:2016-02-19 05:49:24
【问题描述】:

在 three.js 中使用时,jQuery 对话框不起作用。我正在尝试使用 jQuery 在 Circle(使用 Circle Geometry)上实现单击事件。但它不支持。这是我的代码:

function onDocumentMouseDown(event) {
    event.preventDefault();

    var vector = new THREE.Vector3((event.clientX / window.innerWidth) * 2 - 1, -(event.clientY / window.innerHeight) * 2 + 1, 0.5);
    vector = vector.unproject(camera);

    var raycaster = new THREE.Raycaster(camera.position, vector.sub(camera.position).normalize());
    var intersects = raycaster.intersectObjects(sphereMesh.children, true);

    if (intersects.length > 0) {
        console.log(intersects[0]);
        if (intersects[0].object.name == "mesh") {
            contactus();
        }
    }

}

function contactus() {
    $("#dialog-message").dialog({
        draggable: true,
        show: {
            effect: "blind",
            duration: 1000
        },
        hide: {
            effect: "explode",
            duration: 1000
        }
    });
 }

我无法看到对话框中的内容。但我可以看到带有“关闭”按钮的对话框。并且鼠标单击在对话框上不起作用。

【问题讨论】:

  • 你需要 document.addEventListener('mousedown', onDocumentMouseDown, false );这篇文章可能会进一步帮助stackoverflow.com/questions/7984471/…
  • 是的,我以前做过..
  • 谢谢你,Anil.. 我已经看到了那个链接...我没有遇到 raycaster 或任何 mousedown 事件的问题.. 我遇到了 jQuery 对话框的问题

标签: javascript jquery three.js


【解决方案1】:

内容与 jQuery 对话框无关,您可以通过添加任何硬编码常量来尝试它,要使事件起作用,您需要将这些与按钮绑定,例如,

$( #dialog-message" ).dialog({
  dialogClass: "no-close",
  buttons: [
    {
      text: "OK",
      click: function() {
        $( this ).dialog( "close" );
      }
    }
  ]
});

另外你可以参考api,https://api.jqueryui.com/dialog/

【讨论】:

  • 那么请标记为答案,也可以投票。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-01-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多