<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "http://www.web3d.org/specifications/x3d-3.0.dtd">
<![CDATA[
ecmascript: var maxValue; function initialize() { maxValue = 0; } function setTextValues(values, timeEvent) { var precision = 2; RangeText.string[0] ='Range ' + roundOff(values[0], precision); if(values[1] > maxValue) { maxValue = roundOff(values[1], precision); Browser.print ('maximum' + maxValue); } Browser.print ('values' + values[1]); HeightText.string[0] ='Max Height ' + maxValue; } function reset(bool, eventTime) { maxValue = 0; } //A function to round the values regarding to given precision. function roundOff(value, precision) { var result; var isNegative = false; var wholeInt = Math.round(value * Math.pow(10, precision)); //Negative numbers creates exceptional condition, therefor they are converted //to positive values. if(wholeInt < 0) { wholeInt = -wholeInt; isNegative = true; } var whole = wholeInt.toString(); var decPoint = whole.length - precision; //Exception when precision is bigger than the string length if(decPoint < 0) { i = -decPoint; for(i; i > 0; i--) { whole ='0' + whole; } //Calculate decPoint according to new string expanded with 0s decPoint = whole.length - precision; } if(whole !='0') { //Put the decimal point on the appropriate place result = whole.substring(0, decPoint); result +='.'; result += whole.substring(decPoint, whole.length); } else { //If the string is'0', then result is'0' result = whole; } //Negative numbers are altered. if(isNegative) { result ='-' + result; } //Convert the String value to Float. resultFloat = parseFloat(result); return resultFloat; }
]]>
<![CDATA[
ecmascript: function initialize() { } function setTime(inputTime, timeEvent) { TimerNode.cycleInterval = inputTime; }
]]>
<!-- Tag color codes (X3D, XML terminology): <Node DEF='idName' field='value'/> <Element DEF='idName' attribute='value'/> <Prototype name='ProtoName'> <field name='fieldName'/> </Prototype> -->