我无法在一帧中的gltf模型中捕获“click”事件。这是代码。 A帧文档显示仅支持两个事件。即“模型加载”和“模型错误”。我们如何支持其他活动,如“点击”和“鼠标中心”?
AFRAME.registerComponent('material-displacement', {
/**
*/
init: function () {
this.material = new THREE.MeshStandardMaterial({color: "green"});
this.el.addEventListener('model-loaded', () => { this.update(); });
},
/**
* Apply the material to the current entity.
*/
update: function () {
const mesh = this.el.getObject3D('mesh');
if (mesh) {
mesh.traverse((node) => {
if (node.isMesh) node.material = this.material;
});
}
},
});
答案 0 :(得分:0)
您可以像您认为的那样实施它们。而不是让事件监听器监听模型加载的事件,而是让它监听点击或鼠标中心事件。
所以改变这一行
var resp_val = jQuery(".resp_val_div").find("input");
var dados = {
"name": jQuery("#name").val(),
"email": jQuery("#email").val(),
"hospital": jQuery(".answer_hospital").val(),
'answered_questions_attributes':[]
};
resp_val.each(function(index, el) {
d = {"value":parseInt(el.value), "question_id":el.name};
dados.answered_questions_attributes.push(d);
});
console.log(dados);
"answer"=>{
"name"=>"Test",
"email"=>"test@test.com",
"hospital"=>"Hospital Test",
"answered_questions_attributes"=>[
{
"value"=>1,
"question_id"=>"1"
},
{
"value"=>0,
"question_id"=>"2"
},
{
"value"=>1,
"question_id"=>"3"
}
]
}
到这一行
this.el.addEventListener('model-loaded', () => { this.update(); });