Created
January 25, 2012 16:56
-
-
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`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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