Javascript programming with DevalVR

Javascript events

The events are the way to send orders from DevalVR to Javascript code.

To "catch" this events in a web page, it's needed to define a function in the Javascript code of this web page. This function is the "..._DoDVLCommands" function, and must be defined beginning with the ID of the plugin object.

In this example, the plugin ID is "PLUGIN1":

If the plugin ID of previous code is "PLUGIN1", the events function must be defined with the name: PLUGIN1_DoDVLCommands

This function has two text parameters and must be defined this way:

In addition, it's needed to define a intermediate function for browser Internet Explorer, because this browser manage the plugin events through Visual Basic events. This function is "..._DVLCommands" and must be defined beginning with the ID of the plugin object as well. 

All the code to manage plugin events must be defined into PLUGIN1_DoDVLCommands function.

 

"panorama" event

A predefined event is sent when a panorama is loaded into a script file, this is the "panorama " event. This event can be used to know when the user loads a new panorama in the script, for example with GoToFrame() function. The first parameter of DoDVLCommands function is "panorama" text and second parameter is the name of the object in the script.

For example, if this script is loaded in the viewer:

This Javascript code can be used to know what panorama is shown:

See this example: panoramaevent.zip (2.80 MB)

 

 

JavascriptEvent function

This is a function of internal programming and can be defined into a BUTTON or any other script instruction. This instruction sends a defined text to DoDVLCommands function. When this function is used, the first parameter of DoDVLCommands function will be "event" text, and the second parameter is the text defined in JavascriptEvent function.

For example, you can insert JavascriptEvent function in a SETTIMER instruction into a script:

And you can insert into DoDVLCommands the code to manage this event, for example, to show an alert window: