0

I have an x3d scene that contains multiple touchsensor nodes.When i click a particular touchsensor node i need to get the details about the selected node.Please give me any kind of help.Thanks in advance.

user1471194
  • 23
  • 1
  • 5

1 Answers1

0

Give a different DEF name to each TouchSensor, then you can ROUTE to different events to distinguish which one the event comes from.


Full example: multiple_touchsensors.x3dv

Excerpt:

[...]
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
wildpeaks
  • 7,273
  • 2
  • 30
  • 35
  • I was unable to add the DEF field t the touchsensor node.and i all need to write this event handling in the javascript. – user1471194 Jun 11 '13 at 08:49