jQuery 对话框在 three.js 中不起作用
jQuery Dialog not working in three.js
jQuery 在 three.js 中使用时对话框不工作。我正在尝试使用 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
}
});
}
我看不到对话框中的内容。但是我可以看到带有 "close" 按钮的对话框。鼠标点击在对话框上不起作用。
内容与 jQuery 对话框无关,您可以通过添加任何硬编码常量来尝试它,要使事件起作用,您需要将它们与
等按钮绑定
$( #dialog-message" ).dialog({
dialogClass: "no-close",
buttons: [
{
text: "OK",
click: function() {
$( this ).dialog( "close" );
}
}
]
});
进一步可以参考api,https://api.jqueryui.com/dialog/
jQuery 在 three.js 中使用时对话框不工作。我正在尝试使用 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
}
});
}
我看不到对话框中的内容。但是我可以看到带有 "close" 按钮的对话框。鼠标点击在对话框上不起作用。
内容与 jQuery 对话框无关,您可以通过添加任何硬编码常量来尝试它,要使事件起作用,您需要将它们与
等按钮绑定$( #dialog-message" ).dialog({
dialogClass: "no-close",
buttons: [
{
text: "OK",
click: function() {
$( this ).dialog( "close" );
}
}
]
});
进一步可以参考api,https://api.jqueryui.com/dialog/