#VRML V2.0 utf8 # #
## # event types : # # mousedown = 1 # mousemove = 1 << 1 # mouseout = 1 << 2 # mouseover = 1 << 3 # mouseup = 1 << 4 # keydown = 1 << 5 # keyup = 1 << 6 # keypress = 1 << 7 # click = 1 << 8 # dblclick = 1 << 9 # # # mouse button : # # 1 = left button # 2 = right button # 4 = middle button # # # Event fields : # # Event { # eventOut SFString type # event name # eventOut SFBool cancelBubble # to parent # eventOut SFBool returnValue # execute default actions # # eventOut SFVec2f screen # relative to origin screen coordinate system # eventOut SFVec2f client # relative to origin client area # eventOut SFVec2f position # relative to normalized client area # # eventOut SFBool altKey # 0 or 1 # eventOut SFBool ctrlKey # 0 or 1 # eventOut SFBool shiftKey # 0 or 1 # ? eventOut SFBool resize # 0 or 1, resize event # # eventOut SFInt32 keyCode # key code if key event # eventOut SFInt32 button # 1 (left), 2 (right), 4 (middle) # } # # BC 3D 4.4 remark : Java in Script nodes is not supported. # DEF inputHandler Script { field SFInt32 i 0 field SFInt32 size 0 field MFInt32 line [] field MFInt32 temp [] field MFInt32 voidText [] eventIn SFNode onEvent eventOut SFInt32 textSize eventOut MFInt32 textLine url "javascript: function onEvent (e, t) { // Event Examples : if (e.type == 'keyup') { if (e.keyCode == 8 || e.keyCode == 46) { // backspace or delete if (size > 0) { size = size - 1; } } else if (e.keyCode == 13) { // newline for(i=0; i < size; ++i) { line[i] = temp[i]; } textSize = size; textLine = line; line = voidText; temp = voidText; size = 0; } else { temp [size] = e.keyCode; size = size + 1; // print ('keyCode = ' +e.keyCode+ ', shiftKey = ' +e.shiftKey); // print ('ctrlKey = ' +e.ctrlKey+ ', altKey = '+e.altKey); } } // mouse move, no button pressed : if (e.type == 'mousemove' && e.button == 0) { return; // too many event prints } // mouse move : if (e.type == 'mousemove') { print ('Event type = ' +e.type+ ', button = ' +e.button+ ', time = ' +t); print ('mouse position = ' +e.position+ ', keyCode = ' +e.keyCode); } if (e.type == 'mouseup' && e.button == 2) { // handle rbutton menu e.returnValue = 0; } }" } DEF startInputHandler Script { field SFNode inputHandler USE inputHandler field SFInt32 oldMask 0 url "javascript: function initialize() { // get current mask : m = Browser.eventMask; oldMask = m; // new mask examples // m = m | (1<<4) | 1; // mouse up & down m = m | (1 << 6); // keyup Browser.eventMask = m; Browser.addRoute (Browser, 'event_changed', inputHandler, 'onEvent'); } function shutdown() { Browser.eventMask = oldMask; Browser.deleteRoute(Browser, 'event_changed',inputHandler, 'onEvent'); }" } DEF CAM1 Viewpoint { position 2 1 15 description "Camera 1" } DEF CAM2 Viewpoint { position 2 1 10 description "Camera 2" } EXTERNPROTO BoxTransform [ exposedField SFRotation rotation exposedField SFVec3f translation exposedField SFFloat ambientIntensity exposedField SFColor diffuseColor exposedField SFColor emissiveColor exposedField SFFloat shininess exposedField SFColor specularColor exposedField SFFloat transparency exposedField SFVec3f size ] "protos.wrl" PROTO BoardTransform [ exposedField MFString string [ "Please", "wait" ] exposedField SFRotation rotation 0 0 0 0.0 exposedField SFVec3f translation 0 0 0 ] { Transform { rotation IS rotation translation IS translation children [ Billboard { axisOfRotation 0 1 0 children [ BoxTransform { diffuseColor 0.8 0.8 0.0 translation 0.0 0.0 -0.2 size 6 5 0.1 } Shape { appearance Appearance { material Material { diffuseColor 1.0 1.0 1.0 } } geometry Text { string IS string fontStyle FontStyle { family "SERIF" style "BOLD" justify "MIDDLE" } } } ] } ] } } Transform { children [ DEF board BoardTransform { } ] } ## #