我有一个包含多个touchsensor节点的x3d场景。当我点击一个特定的触摸传感器节点时,我需要获取有关所选节点的详细信息。请给我任何帮助。谢谢。
答案 0 :(得分:0)
为每个TouchSensor提供不同的 DEF 名称,然后您可以 ROUTE 指向不同的事件,以区分事件来自哪个。
完整示例:multiple_touchsensors.x3dv
摘录:
[...]
DEF touchsensor_1 TouchSensor {}
[...]
DEF touchsensor_2 TouchSensor {}
[...]
DEF a_script Script {
eventIn SFTime obj_1_clicked
eventIn SFTime obj_2_clicked
directOutput TRUE
url "javascript:
function obj_1_clicked(){
trace('The Box was clicked');
}
function obj_2_clicked(){
trace('The Sphere was clicked');
}
"
}
ROUTE touchsensor_1.touchTime TO a_script.obj_1_clicked
ROUTE touchsensor_2.touchTime TO a_script.obj_2_clicked