BS Contact J : JS-API : FieldObserver

Let's have a look at the example below. Imagine a furniture scenario. You would like to present a table, which is available with different tops and legs. Instead of displaying each of the different tables in a separate image, you want to let the user decide the appearance of the table interactively.

Sorry, your browser doesn't support Java.

 

The two drop-down lists below the applet realize this functionality; the user can choose his favorite appearance. The javascript function 'setTable' receives the selected choices and updates the 3D model of the table. This is done by setting the whichChoice field of a switch node containing all possible appearances.

Here is the code snippet responsible for the appearance change:

document.blaxxun3D.setNodeField("plateSwitch","whichChoice",plate);

where document is the reference to the HTML document and BS Contact J the reference to the BS Contact J applet. BS Contact J is the name of the BS Contact J applet specified in the applet tag.


"plateSwitch" is the DEFed name of the switch node to be connected to.

"whichChoice" is the node field to be manipulated, and plate is the variable containing the value to be set. Note that the node name must be exactly the same as in the DEF tag of the VRML file.

 

 

A lot of other interactions are possible: starting and stopping animations (by manipulating timeSensors), implementing viewpoint animations, moving objects (through setting their transform coordinates), etc.