3DVIA Studio is a real-time 3D authoring solution for developing playable, online interactive experiences (e.g., training simulations, games, etc.).
This article deals with the process of establishing communication between a 3DVIA Studio experience and its embedded Web page (on 3DVIA.com, a blog or wherever). Read on to learn both sides of communication: the experience to the Web page and vice versa. Some baseline knowledge of 3DVIA Studio is recommended; we encourage you to read through the scripts as they are introduced and to study their working mechanisms.
Make sure you download the project file supporting this tutorial on 3DVIA here.
- 3DVIA Studio User Interface
You should be familiar with the key 3DVIA Studio interface elements, such as the views (property view, project view, editors).
- Scripting Basics
We assume that you already have a grasp of basic scripting principles.
- Proper 3DVIA Account
From the experience to the Web page…
This is the first direction of the communication process where you must execute a simple JS function, or a JS function the Web page can access. Since this JS function is available from the Web page embedding the player, you can call it from the experience. In this direction (from experience to Web page), we will use the Web Manager (vkWebManager*), which can be seen as a set of functions or a toolkit. The Web Manager deals with the integration of a 3DVIA Studio experience in a Web environment.
To see an example of how to implement this functionality, click here.
The following piece of code is an example of what you may write:
// Definition of the function JS_VSLLauncher
// Call a JS function from the experience, in the web page, using VSL
vkWebManager* wman = vkWebManager::InstancePtr();
vkString strCommand("alert(‘You clicked on the VSL Button’)");
…and from the Web page to the experience
A 3DVIA Studio experience embedded in a Web page can easily be controlled from this page. If we deal with the Web manager, it’s fully transparent and the mechanism is slightly different …
Create a new proper event type
Set a mechanism to catch the event
Once this type exists, a mechanism is needed to catch the event when it’s transferred by the player to the experience. The mechanism may be:
- a function trigger
- a WaitEvent BB in a task
Send Info from the Web Page to Experience
- JSBehavior is the name of the behavior in which the event type you’ve just created above is defined
- vkJSEvent is the name of the event type
Here is a simple example of what the HTML code should be/could be:
Remember this project corresponds to the current Web page, which contains the input field and the ‘sender’ link. You’ll need to use the same items in your setup to retrieve the same behaviors.
First, launch the experience, then enter the name you wish to display in the experience by entering it in the text field and clicking the link below.