0

我有一个包含多个触摸传感器节点的 x3d 场景。当我单击特定的触摸传感器节点时,我需要获取有关所选节点的详细信息。请给我任何帮助。提前致谢。

4

1 回答 1

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
于 2013-06-06T10:06:06.297 回答