<?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: function set_translation (eventValue) { x = eventValue.x; if (tracePrint) { Browser.println ("========================"); Browser.println (' x=' + x); } // clamp values to prevent overrun/underrun, in case minPosition/maxPosition fail if (x > 3.0) x = 3.0; if (x < -3.0) x = -3.0; translation_changed = eventValue; angle = Math.round(x * 90.0 / 3.0); rotation_changed = new SFRotation (0, 1, 0, angle * Math.PI / 180.0); var angleString = angle.toString() + ' degrees'; // JavaScript string // angleMFString_changed = new MFString (new SFString(angleString)); // only works in InstantReality angleMFString_changed = new MFString (angleString); // works in several players but not all // angleMFString_changed = [ angleString ]; // Use JavaScript string array instead of MFString doesn't work if (tracePrint) { Browser.println (' clamped x=' + x); Browser.println (" set_translation=" + eventValue); Browser.println ("translation_changed=" + translation_changed.toString() + ", rotation_changed=" + rotation_changed.toString()); Browser.println ("angle=" + angle + ", angleString=" + angleString + ", angleMFString_changed=" + angleMFString_changed.toString()); } /* example console excerpt: ======================== x=-0.05248255282640457 clamped x=-0.05248255282640457 set_translation=-0.05248255282640457 0 0 translation_changed=-0.05248255282640457 0 0, rotation_changed=0 1 0 -0.03490658503988659 angle=-2, angleString=-2 degrees, angleMFString_changed="-2 degrees" ======================== */ }
]]>
<!--
Color key:
<X3dNode
DEF='idName' field='value'/>
matches
<XmlElement
DEF='idName' attribute='value'/>
(Light blue background: behavior node) (Grey background: inserted documentation) (Magenta background: X3D Extensibility)
-->
<!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources and X3D Scene Authoring Hints. -->