Scripts are necessary whenever some intelligence is required for an interaction. They are the logic or brain of your Synthetic Environment. Examples of common situations where a script is required include:
We will be working with my pre-written javascripts as programming is beyond the scope of this course, however, feel free to look at the scripts if you want to gain a better understanding of what's going on "behind the scenes". Most of the actual logic is pretty basic ie. there is no heavy maths or complex functions. The biggest hurdle for newbies, or even those familiar with javascript, is understanding how VRML interfaces with javascript.
Don't expect miracles in a day - it's best to get familiar with VRML before you tackle any scripting. If you're keen to learn more about javascript programming for VRML I suggest you take a look at Bob Crispen's Taming VRML Scripts tutorial at VRML Works.
back to top | return to Complex Interations
Download and unzip the following file (using WinZip) into the relevant folder of your working directory.
camera_switched.zip (51.3Kb)
This file contains:
- camera_switched.wrl
scripts.zip (1.2Kb)
This file contains:
- cameraControl_script.wrl
- rollover_script.wrl
back to top | return to Complex Interations
![]() |
|
| Note: as there are now many objects in the scene it may be hard to find what you're looking for in the Outline Editor. The best approach is to either select the object in the viewport and it will be highlighted in the Outline Editor or search By Name... or object type using the drop-down list. | ![]() |
|
Import the file rollover_script.wrl.
|
![]() |
|
This will add rolloverScript and a TouchSensor to the bottom of the scene graph. Select the script in the Outline Editor and the Property Inspector will change to display the script properties. If you want to take a look at the script, click on the Edit Script button but don't make any changes. |
![]() |
|
Drag both the TouchSensor and rolloverScript up the scene graph and drop them under the lensRotationGroup. This attaches the TouchSensor to the object. |
![]() |
| Expand |
![]() |
|
Scroll and drill-down in the scene graph and complete the route by clicking
on the input arrow Preview |
![]() |
|
Try it yourself. Repeat the above steps to add highlights to the other interactive components as per the Finished Project. Note: you will need to go through the above process before you can continue on the the control script below. |
|
|
Import the file cameraControl_script.wrl. Expand Don't be daunted by all the text. The names a quite long in the hope of making them easier to understand. We'll start with the inputs. |
![]() |
|
Find the powerButtonGroup in the Outline Editor and the TouchSensor you attached to it in the previous section. Click on the touchTime output |
![]() |
| Scroll back down to the script and click on set_power input |
![]() |
|
Repeat the above steps to connect the following routes:
|
![]() |
|
Now the outputs. Select modeRotation_changed Repeat to finish the routes:
|
![]() |
|
This completes all the interactions on the camera itself. It's a lot to take in in one session but it's just a matter of being careful and methodical. The repetitive nature of creating the above routes will reinforce the process for you. That's my story and I'm sticking to it ;-) |
|
back to top | return to Complex Interations