<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "https://www.web3d.org/specifications/x3d-3.3.dtd">
<![CDATA[
ecmascript: // REF: http://astronomy.swin.edu.au/pbourke/geometry/rotate/ function initialize () { visibility = 20; depth = 0; pos = (0,0,0); Browser.println ('Position output from ProximitySensor.'); } function get_clock_hit (clock_msg) { run_script = true; } function get_depth ( position ) { pos = position; depth = position[1] - 30; } function set_visibility( rotation ) { if (run_script) { //z coordinate of the default viewpoint direction(0,0,-1) initZ = -1; rX = rotation[0]; // x coordinate of the rotation rY = rotation[1]; // y coordinate of the rotation rZ = rotation[2]; // z coordinate of the rotation theta = rotation[3]; // angle of rotation in radians Browser.println ('theta:' + theta); cosTheta = Math.cos(theta); sinTheta = Math.sin(theta); Browser.println ('cosTheta:' + cosTheta + ' sinTheta:'+ sinTheta); // calculate the y coordinate of the point after rotation /* there are 8 other terms in the full conversion, but 6 are equal to zero because of the choice of a starting point on the z-axis. The other two are not calculated since all we need is the y coordinate */ finalY = ((1 - cosTheta) * rY * rZ - rX * sinTheta) * initZ; Browser.println ('final y:' + finalY); //calculate the elevation/depression angle of the final point location elevation = Math.asin(finalY); Browser.println ('elevation:' + elevation); directionFactor = 1 + 0.2 * (4 * elevation / Math.PI); depthAdjust = (60 + depth)/60 depthFactor = Math.max(depthAdjust,0.05); visibility_changed = 60 * depthFactor * directionFactor; Browser.println ('depth=' + depth + ', elevation=' + elevation + ', visibility_changed=' + visibility_changed); run_script = false; } }
]]>
Event Graph ROUTE Table entries with 4 ROUTE connections total, showing X3D event-model relationships for this scene.
Each row shows an event cascade that may occur during a single timestamp interval between frame renderings, as part of the X3D execution model.
Clock
TimeSensor cycleTime SFTime |
ChangeVisibility
Script get_clock_hit SFTime |
then |
ChangeVisibility
Script visibility_changed SFFloat |
Water
Fog visibilityRange SFFloat |
ChangeVisibility
Script visibility_changed SFFloat |
Water
Fog visibilityRange SFFloat |
ProxSensor
ProximitySensor position_changed SFVec3f |
ChangeVisibility
Script get_depth SFVec3f |
then |
ChangeVisibility
Script visibility_changed SFFloat |
Water
Fog visibilityRange SFFloat |
||
ProxSensor
ProximitySensor orientation_changed SFRotation |
ChangeVisibility
Script set_visibility SFRotation |
then |
ChangeVisibility
Script visibility_changed SFFloat |
Water
Fog visibilityRange SFFloat |
<!--
Online at
https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/KelpForestExhibit/ChangingFogIndex.html
-->
<!--
Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/X3dForWebAuthors/KelpForestExhibit/ChangingFog.x3d
-->
<!--
Color legend: X3D terminology
<X3dNode
DEF='idName' field='value'/>
matches XML terminology
<XmlElement
DEF='idName' attribute='value'/>
(Light-blue background: event-based behavior node or statement)
(Grey background inside box: inserted documentation)
(Magenta background: X3D Extensibility)
-->
<!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints. -->