<?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 initialize() { Browser.print ('groundColorSunrise length=' + groundColorSunrise.length + ' ' + groundColorSunrise.toString() + '\n'); Browser.print ('groundColorNoon length=' + groundColorNoon.length + ' ' + groundColorNoon.toString() + '\n'); Browser.print ('groundColorSunset length=' + groundColorSunset.length + ' ' + groundColorSunset.toString() + '\n'); Browser.print ('groundColorNight length=' + groundColorNight.length + ' ' + groundColorNight.toString() + '\n'); Browser.print ('skyColorSunrise length=' + skyColorSunrise.length + ' ' + skyColorSunrise.toString() + '\n'); Browser.print ('skyColorNoon length=' + skyColorNoon.length + ' ' + skyColorNoon.toString() + '\n'); Browser.print ('skyColorSunset length=' + skyColorSunset.length + ' ' + skyColorSunset.toString() + '\n'); Browser.print ('skyColorNight length=' + skyColorNight.length + ' ' + skyColorNight.toString() + '\n'); } function set_fraction (fraction) // fraction is input value sent by TimeSensor clock { // Sunrise to Noon, fraction 0.0 to 0.25, interval=0.25 if (fraction < 0.25) { groundColor_changed = interpolate (groundColorSunrise, groundColorNoon, fraction, 0.00, 0.25); skyColor_changed = interpolate ( skyColorSunrise, skyColorNoon, fraction, 0.00, 0.25); } // Noon to Evening, fraction 0.25 to 0.5, interval=0.25 else if (fraction < 0.5) { groundColor_changed = interpolate (groundColorNoon, groundColorSunset, fraction, 0.25, 0.25); skyColor_changed = interpolate ( skyColorNoon, skyColorSunset, fraction, 0.25, 0.25); } // Evening to Night, fraction 0.5 to 0.6, interval=0.1 else if (fraction < 0.6) { groundColor_changed = interpolate (groundColorSunset, groundColorNight, fraction, 0.5, 0.1); skyColor_changed = interpolate ( skyColorSunset, skyColorNight, fraction, 0.5, 0.1); } // Night (unchanging), fraction 0.6 to 0.95, interval=0.35 else if (fraction < 0.95) { groundColor_changed = groundColorNight; skyColor_changed = skyColorNight; } // Night to Sunrise, fraction 0.95 to 1.0, interval=0.05 else // (fraction < 1.0) { groundColor_changed = interpolate (groundColorNight, groundColorSunrise, fraction, 0.95, 0.05); skyColor_changed = interpolate ( skyColorNight, skyColorSunrise, fraction, 0.95, 0.05); } // Browser.print ('groundColor_changed=' + groundColor_changed.toString() + '\n'); // Browser.print (' skyColor_changed=' + skyColor_changed.toString() + '\n'); } function interpolate (firstColorArray, secondColorArray, fraction, initialFraction, interval) { f = (fraction - initialFraction) / interval; // f should range from 0 to 1 // Browser.print ('initialFraction=' + initialFraction + ', fraction=' + fraction + ', f=' + f + '\n'); color0 = firstColorArray[0] + (secondColorArray[0] - firstColorArray[0]) * f; color1 = firstColorArray[1] + (secondColorArray[1] - firstColorArray[1]) * f; color2 = firstColorArray[2] + (secondColorArray[2] - firstColorArray[2]) * f; color3 = firstColorArray[3] + (secondColorArray[3] - firstColorArray[3]) * f; color4 = firstColorArray[4] + (secondColorArray[4] - firstColorArray[4]) * f; return new MFColor (color0, color1, color2, color3, color4); }
]]>
<!--
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. -->