Skip to content

Instantly share code, notes, and snippets.

@cecilemuller
Created January 25, 2012 16:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cecilemuller/1677272 to your computer and use it in GitHub Desktop.
Save cecilemuller/1677272 to your computer and use it in GitHub Desktop.
Add `CTRL + Click` to display the name and tree of object(s) you clicked using `Browser.mouseSelect`
#VRML V2.0 utf8
Inline{url "some_file.wrl"}
DEF mouse MouseSensor {}
DEF script Script {
eventIn SFVec2f position
eventIn SFBool click
directOutput TRUE
url "javascript:
function click(active){
if (active){
if (Browser.isKeyPressed(17)){ //CTRL key
var hit = Browser.mouseSelect(position);
if (hit) {
var offset = '';
var path = hit.hitPath;
for (var i = 0; i < path.length; i++){
var node = path[i];
if (node.getName() == '') trace( offset + node.getType() + '{}' );
else trace( offset + 'DEF ' + node.getName() + ' ' + node.getType() + '{}' );
offset += '..';
}
}
}
}
}
"
}
ROUTE mouse.position TO script.position
ROUTE mouse.lButton TO script.click
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment