【发布时间】: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