"Finishing Up" >Page 1, 2
Let's put it all together in a single file. Now our masterpiece button cube file looks like:
#VRML V2.0 utf8 Background { #note that this Background example is copied from VRML 2.0 Source book a great VRML reference skyColor [ 0.0 0.2 0.7, 0.0 0.5 1.0, 1.0 1.0 1.0 ] skyAngle [1.309, 1.571 ] groundColor [ 0.1 0.1 0.0, 0.4 0.25 0.2, 0.6 0.6 0.6 ] groundAngle [ 1.309, 1.571 ] } Transform { translation 0 0 -4 children [ DEF ELMO TouchSensor {} Shape { appearance Appearance { material DEF WHITE Material { diffuseColor 1 1 1 } } geometry Box { } } ] } DEF LIGHT PointLight { location 3 0 0 color 1 0 0 on FALSE } DEF ToggleScript Script { field SFBool value FALSE eventIn SFBool set_boolean eventOut SFBool value_changed url "javascript: function set_boolean( bool, eventTime ) { if (bool == false ) { return; } if (value == true ) { value = false; } else { value = true; } value_changed = value; }" } ROUTE ELMO.isActive TO ToggleScript.set_boolean ROUTE ToggleScript.value_changed TO LIGHT.set_on
Next week we're going to actually make this thing look like and act like a switch!
Previous Page Toggle Switch >Page 1,2