Create a WebEngine to add an interactive website or html content to a VRED scene. The content streams into a material texture channel in real-time and uses the properties of the material for display.
The environment is reflected in this texture.
In raytracing, the material emits light into the scene when Use as Light Source is activated.
This texture is used when the properties of incandescence and an alpha channel, that is only available in diffuse, are needed.
HTML example code to set the background of a webpage transparent (alpha):
<style>
body{
background-color: rgba(0, 0, 0, 0);
}
</style>
Interaction between VRED and HTML5 is a two-way communication. Here is an example of VRED to HTML5.
Executing the Variant Set (Home_Button) with an associated python script (sendToWebEngine), triggers a specific WebEngine (Webengine_A) and sends an html event (VRED_HOME_Btn) to the web page. The web page must have an Event Listener to receive the message.
The following is an example of HTML code to receive a message:
<script>
document.addEventListener("VRED_HOME_Btn", Icon_HomeClick);
</script>
An img element and a URL can be used to send python commands from the webpage to VRED using the webserver. For example, src = "http://localhost:8888?..... The webserver must be enabled in the preferences.
HTML code to set the Switch Material to choice 0:
<script>
function r(){
var i = document.createElement("img");
i.src = "http://localhost:8888/python?value=setSwitchMaterialChoice('SwitchColor', 0)";
};
</script>
HTML code to trigger a VarianSet named Icon_Anim:
<script>
Icon_Click = function(event) {
var i = document.createElement("img");
i.src = "http://localhost:8888/variants?value=selectVariantSet('Icon_Anim')";
};
</script>