
First, let's talk about getting your world on the web. Then we'll talk about linking to other resources on the web.
Some modelers have an "upload" feature, but I usually use an ordinary FTP program to transfer the
files that make up my world to my Internet Service Provider. Out of consideration for my ISP's disk space, I use
gzip to compress the .wrl files (image files and audio
files that work with VRML are already compressed, and you shouldn't gzip them). Nearly all VRML browsers
will read gzipped files, but other compression formats (e.g., formats created by pkzip,
Wikzip, or stuffit) won't work. I sometimes transfer the files over uncompressed and use my
ISP's version of gzip. I'll bet your ISP has one too.
Because of a bug in some versions of Microsoft Internet Explorer, I always rename the gzipped worlds from e.g.,
foo.wrl.gz to foo.wrl. All known VRML browsers are smart enough to figure out that the
worlds are really gzipped.
If you have Win9x/NT/2k, I've got a free, open source program called Win-GZ that takes care of both gzipping/gunzipping and renaming in one operation, so you really don't have any excuse not to gzip your worlds and save your guests some download time.
It might happen that your VRML worlds will display as text instead of VRML when you try to view them from your web server. It's much less common nowadays, but it used to happen a lot.
What you should do is ask your ISP (nicely, please) to add the MIME type
model/vrml wrl
to the MIME types for their Web server (or HTTP daemon). They'll generally need to shut down and restart their daemon, and you'll need to clear your cache before you reload the world. They'll sometimes ask you to wait until the next time they shut down the daemon.
If your ISP refuses to add the MIME type (it's been known to happen) or if your ISP is running a server that's
so lame that it can't return the proper MIME type, you can still show your worlds on the net. What you need to
do is make a shell script for each of your worlds. Say you've got a VRML world called myworld.wrl.
Call your script myworld.cgi and put it in the same directory as your VRML file. That script file
should contain the following (for Unix hosts only -- no idea what you do if they're running some other operating
system):
#!/bin/sh
echo 'Content-type: model/vrml'
echo ''
cat myworld.wrl
The name of your actual world should be in the last line in that script. Make the script executable in your shell:
% chmod 755 myworld.cgi
Now, on your web page that links to that world, change the link from myworld.wrl to myworld.cgi.
It's involved, but it'll get your world on the web despite your ISP.
Not long ago, a friend wrote me to say that her ISP didn't believe that model/vrml was the right
type. If this happens to you, refer them to http://www.isi.edu/in-notes/iana/assignments/media-types/model/vrml.
If you feel like rubbing salt in their wounds, you might remind them if they got Apache,
the world's most popular web server, and updated it more frequently than every ice age, they'd have model/vrml
in their default configuration file, and you wouldn't have had to bother them.
Once your world is on the web, you can link to it like anything else on the web, e.g., http://my.isp.com/~me/my.wrl.
But that's not the only way you can present your world to your guests. Even the cheapest restaurants don't serve
your order in the cans it came in. They take a little time and trouble to put it in a nice dish, and maybe they
even serve some parsley or crackers on the side. If your world is worth less than a 99-cent bowl of chili,
just link to it. But if it's worth more, read on.
There are two ways to have both 2D text and graphics and a 3D VRML world on the same page: using the world as a frame and embedding it in a web page.
In the first case, you use the <frame> element inside the <frameset> container.
The grammar and attributes of the <frame> element can be found at the HTML
Compendium and in the HTML specifications at the World Wide Web Consortium.
Example: <frame src="my.wrl" name="vrmlframe">
In the second case you use the <embed> element. The grammar and attributes of the <embed>
element can be found in the same places. Although the <embed> element is deprecated in favor
of the <object> element in HTML 4.0, the current state of web browsers (Netscape 4.7 and MSIE
5.0) is that they support the <embed> element and sometimes misbehave on the <object>
element.
Example: <embed src="my.wrl" width="500" height="280">
You can use both, of course. You can embed your world in a web page that lives in a frame.
Note that the (current) External Authoring Interface enables a Java applet to control a VRML world only when it's embedded in the same frame (or in the same web page, if the web page has no frames).
You can make your VRML worlds pop up in their own window instead of loading into a webpage if you use a script in the web page that links to them:
<script language="JavaScript">
<!-- Hide script from older browsers
function newWindow(width, height, world) {
window.open(world,'vrmlWindow','width='+width+',height='+height);
}
// -->
</script>
Then, instead of writing a direct link to your world, as in:
Click <a href="my.wrl">here</a>
you write the following:
Click <a target="_self" href="javascript:newWindow(300,200,'my.wrl')">here</a>
If you have a target attribute, e.g., in a <base> element in your <head>
container, you will need the target attribute in the anchor, as in the example just above, otherwise
your web browser won't be able to find your script.
Some guests at your web site will have JavaScript disabled, and others will be running de-clutter programs like WebWasher. Always have an alternate direct link so that these guests won't miss your worlds.
There's one very, very important adventage to embedding your world in a web page or a frame or putting it in a pop-up window: you control the size of the VRML window. The smaller the window, the less detail (that's sometimes a negative) but the faster it renders and animates (that's always a huge plus). And, as movie makers, camera makers, and the people who built the monitor you're looking at right now know, it's usually better to have an image wider than it is tall.
Now let's think about all the different ways you can link out of your world, so that when your guests click on an object in your world, they see a web page, another VRML world, or whatever.
Everybody (well, everybody who's read the spec) knows the simple way to load a new web page, VRML world, or whatever whenever your guest clicks on an object in your VRML world:
Anchor {
url "a_web_page.html"
children [ ...
When they do that, the new page will replace your VRML world in their browser. But sometimes you want to keep the world around. For example, if your world is a navigation tool like my conetree, you don't want people to have to keep on loading it over and over again.
There are three easy solutions to this problem. First, you can have a frames window, like we talked about above, and have the VRML world in one of the frames. When you click on an object in the VRML world, you can make the other HTML or VRML (or whatever) page appear in the other frame like this:
Anchor {
url "http://my.isp.net/~me/a_directory/a_web_page.html"
parameter "target=theOtherFrame"
children [ ...
where "theOtherFrame" is the name you've given the other frame in your web page. In this
example I showed a fully specified URL, and in the example just above it I showed a relative URL. Either will work.
This is a wonderful thing to do if you're trying to tell a story. Suppose you have a model of London in 1895. When your visitors click on 221B Baker Street, you could display "Home of Sherlock Holmes" in the other frame.
Or if you want to be especially tricky, you could write a script that calls:
Browser.loadUrl("my.wrl", "target=theOtherFrame");
and activate it from a ProximitySensor.
Second, if you use the following code:
Anchor {
url "a_web_page.html"
parameter "target=newpage"
children [ ...
where "newpage" is a randomly chosen name that isn't the name of a frame, your
web browser will create a new browser window, give it the name newpage, and display the other page
in that window, leaving your original browser window in place. The fact that it named that window newpage
can be useful. If you use the same name, newpage (or whatever, so long as the name is the same) in
each of your target fields, your web browser will use the same new page it created to display other
pages, so your guest's desktop isn't littered with browser windows.
But suppose you don't want to load the new page (world, etc.) in your regular browser window, or in a frame, or on a new web page. Suppose you want a little popup window. Well, there's a way to do that too:
Anchor {
url "javascript:function popup(){window.open('a_web_page.html',
'newpage','width=200,height=80');};popup();"
children [ ...
Note that simply executing the JavaScript code won't do it. Your web browser will replace your VRML world with a blank page to receive the results of the JavaScript. The trick is declaring the JavaScript code as a function and then calling the function in the same line.
Paul Hoffman uses a different method for popups. He embeds his world in a web page and puts a script inside the web page:
<head>
<script language="JavaScript">
<!--
function popup() {
window.open('a_web_page.html', 'newpage','width=200,height=80');
}
// -->
</script>
Then in his VRML world he has the Anchor node call that script by name:
Anchor {
url "javascript:popup()"
children [ ...
Roland Praehofer took this one step farther, and wrote some code that lets you generate VRML on the fly in a popup window:
Anchor {
url "javascript:
function popup(){
myvrml = '#VRML V2.0 utf8 \n'+
'Transform{children[Shape{geometry Sphere{}}]}';
vrml = open('','newpage',
'width=300,height=200,toolbar=yes,resizable=yes,menubar=yes');
vrml.document.open('model/vrml');
vrml.document.write(myvrml);
vrml.document.close();
}
popup();
"
children [ ...
Now that's extremely cool, and, though it doesn't work on Microsoft Internet Explorer (which has a well known problem with MIME types), it gives you a new way to think about interfacing between your web page and your VRML world.
Try some of these techniques, and you should have plenty of ways to link into your world and our of your world to other resources on the Web.
![]()
Did I leave anything out about putting your world on the Web that you need to know? Let me know.
-- Bob Crispen