Lighthouse3d.com

[an error occurred while processing this directive] Send me bugs and suggestions, please
VRML Interactive Tutorial
Full list

Script Tutorial

Introduction and Sintax
Defining Fields and Events
Accessing Fields and Events
When are scripts executed
Script Example: Highlight
Browser Script Interface
Appendix: Data types

Browser Interface


The browser object provides a script with means to get information from the browser as well as performing actions which affect your world, or even replace it.

The following table presents a list of the methods available for the browser object ( see data types for an explanation of the return values):

Return value Method name Description
SFString getName() Returns the name of the browser
SFString getVersion() Returns the version
SFFloat getCurrentSpeed() The speed at which the viewpoint is moving in meters per second, 0.0 is returned if this function is not implemented
SFFloat getCurrentFrameRate() The current frame rate in frames per second, 0.0 if not implemented.
SFString getWorldURL() Returns the URL of the root of the current world.
void replaceWorld(MFNode nodes) Replaces the current world with the world represented by the list of nodes passed as an argument.
void loadURL(MFString url,MFString parameters) Loads the url specified with the parameters argument. The paramenters syntax is as defined in the Anchor node. You can load an url into a different frame using the TARGET parameter.
void setDescription(SFString descritpion) Sets the description for the current world. The display of the description is browser dependent.
MFNode createVrmlFromString(SFString vrmlSyntax) This method constructs the nodes described in the string and returns the corresponding VRML scene.
void createVrmlFromURL(MFString url, SFNode node, SFString event) Loads the url and sends the event event to the node specified with the loaded nodes.
void addRoute(SFNode fromNode, SFString eventOut, SFNode toNode, SFString eventIn) Creates the following ROUTE:

ROUTE fromNode.eventOut TO toNode.eventIn
void deleteRoute(SFNode fromNode, SFString eventOut, SFNode toNode, SFString eventIn) Deletes the specified ROUTE:

ROUTE fromNode.eventOut TO toNode.eventIn

Examples using the Browser Script Interface:

Loading More Stuff (source code)
When the user clicks the geometry it replaces the current world using loadUrl
Frame replacement (source code)
Changing the contents of a frame using Proximity Sensors and loadUrl
Configuration (source code)
Uses getName, getVersion, getCurrentSpeed, getCurrentFrameRate,getWorldURL plus a Script to display the information.
Replacing Worlds (source code)

Creating VRML from a string (source code)
When the user presses the geometry nodes are added to the current scene