Local Navigation Systems
Stepán Kment xkment@cslab.felk.cvut.czComputer Graphics Group Czech Technical University Prague, Czech Republic |
HTML pages and connection to VRML
Example: VRML in frames
We discussed animation, interactivity, graphics and so on. But I still have not mentioned user interface, text information and binding the models together.First, create a frameset, name the frames and load the files there (shortened)
<frameset frameborder="0" framespacing="0" border="0"
rows="240,*">
<frame src="fel.wrl" name="VRML" scrolling="no"
noresize marginwidth="0" marginheight="0" border="0">
<frame src="text.htm" name="TEXT" marginwidth="10"
marginheight="10" border="0">
</frameset>
Here we have created two frames with names VRML and TEXT. Now we can load content to the VRML frame from TEXT frame using this script:
<script language="javascript">
function loadframe(data)
{parent.VRML.location.href=data;}
</script>
<a href="javascript:loadframe('asdf.htm')">Click to reload</a>
I believe this code is quite self-explanating with exception of line parent.VRML.location.href - this is a variable created by browser in its dynamic control structure and defines URL of frame called VRML (of course, there exists also structure for TEXT). We can simply use this technique for loading the VRML scene and contents of its paths in one step.
Bad news is that VRML players do not attach themselves to this structure, that is currently under development I was told. That means that you can do amazing things in frames with html contents, but you can not do so simple things such as starting any animation in VRML scene! The user still has to click once for reload of the frames and second time to start the animation in the VRML scene. Communication can be estabilished only in the opposite direction, that means from VRML to HTML, using this trick: create one frame in the frameset 0 pixels wide (that really works, the frame is then completely invisible; suppose it is called DUMMY). Create HTML documents with this content (shortened; create one document per one message, they probably should differ in the code of function sendmessage() ). Let us call this HTML document as mess.htm.
<body onload="sendmessage()" language="javascript">
<script language="javascript">
function sendmessage()
{parent.TEXT.ping('HALLO');}
</script>
</body>
Add this line to the script in VRML, from where you want to send a message. The browser loads a specified document in a specified frame (this can be also used for loading next part of the VRML scene using sensors):
Browser.loadURL (new MFString(mess.htm'), new MFString('target=DUMMY'));
It is complicated, but it should work fine: loadURL makes the browser reload content of invisible frame and document newly loaded calls function "ping" with parameter HALLO somewhere in the script of document loaded in TEXT frame. Anyway, it is slow and lots of documents are needed for this communication.
Example: VRML in frames