Popis javascriptov pre model snehuliaka a striedanie dňa a noci.

Snehuliak červenie, kým aktívne cvičí - rastie premenná glow a mení sa jeho emisívna farba do červena. Ak prestane cvičiť, glow začne klesať, rovnako ako emisívna farba. V premennej running_exercises je počet práve prebiehajúcich cvičení (aj viac naraz), až keď je táto premenná nulová, snehuliak začne blednúť, ak je červený.

	DEF	GLOW_ENGINE Script {
		field SFInt32 running_exercises 0
		field SFFloat glow 0
		eventIn	SFBool P_V
		eventIn	SFFloat	glow_up
		eventIn SFFloat	glow_down
		eventOut SFBool	diminish
		eventOut SFColor glow_changed
		url	"javascript:
			function P_V(value)
		    {
				if (value)
				{
					// P, timer started
					diminish = FALSE;
					running_exercises++;
				}
				else
				{
					// V, timer stopped
					running_exercises--;
					if (!running_exercises) diminish = TRUE;
				}
			}
			function glow_up()
			{
				if (glow < 1)
				{
					glow += 0.02;
					glow_changed = new SFColor(0.3 * glow, 0, 0);
				}
			}
			function glow_down()
			{
				if (glow > 0)
				{
					glow -= 0.02;
					if (glow < 0) glow = 0;
					glow_changed = new SFColor(0.3 * glow, 0, 0);
				}
				else diminish = FALSE;
			}
		"
	}

	ROUTE EXERCISE1_TIMER.isActive TO GLOW_ENGINE.P_V
	ROUTE EXERCISE1_TIMER.fraction_changed TO GLOW_ENGINE.glow_up
	ROUTE EXERCISE2_TIMER.isActive TO GLOW_ENGINE.P_V
	ROUTE EXERCISE2_TIMER.fraction_changed TO GLOW_ENGINE.glow_up
	ROUTE EXERCISE3_TIMER.isActive TO GLOW_ENGINE.P_V
	ROUTE EXERCISE3_TIMER.fraction_changed TO GLOW_ENGINE.glow_up

	ROUTE GLOW_ENGINE.glow_changed TO SNOW_MAT_M.emissiveColor

	ROUTE GLOW_ENGINE.diminish TO DIMINISH_TIMER.enabled
	ROUTE DIMINISH_TIMER.fraction_changed TO GLOW_ENGINE.glow_down

Striedanie dňa a noci je jednoduchá interpolácia troch trojprvkových vektorov obsahujúcich farby v backgrounde. Zároveň sa mení intenzita zdroja denného svetla.

	DEF	DAYNIGHT_ENGINE Script {
	field SFTime now 0
	eventIn	SFFloat	daylight
	eventOut SFTime set_day_time
	eventOut MFColor set_background
	url	"javascript:
		function initialize()
		{
			set_day_time = (new Date()).getTime();
		}
		function daylight(value)
		{
			if (value < 0.4)
			{
				t = value / 0.4;
				it = 1 - t;
				set_background = new MFColor();
				set_background[0] = new SFColor(.12*t+.1*it, .2*t+.15*it, .3*t+.2*it);
				set_background[1] = new SFColor(.4*t+.1*it, .1*t+.15*it, .5*t+.2*it);
		    	set_background[2] = new SFColor(.7*t+.12*it, .5*t+.2*it, .2*t+.3*it);
			}
			else
			{
				t = (value - 0.4) / 0.6;
				it = 1 - t;
				set_background = new MFColor();
				set_background[0] = new SFColor(.25*t+.12*it, .48*t+.2*it, .7*t+.3*it);
				set_background[1] = new SFColor(.5*t+.4*it, .7*t+.1*it, .8*t+.5*it);
		    	set_background[2] = new SFColor(.9*t+.7*it, .98*t+.5*it, 1*t+.2*it);
			}
		}
	"
}

ROUTE DAYNIGHT_ENGINE.set_day_time TO SUN_TIMER.startTime

ROUTE SUN_TIMER.fraction_changed TO	SUNLIGHT_SCINT.set_fraction
ROUTE SUNLIGHT_SCINT.value_changed TO SUNLIGHT.intensity
ROUTE SUNLIGHT_SCINT.value_changed TO SUNLIGHT.ambientIntensity
ROUTE SUNLIGHT_SCINT.value_changed TO DAYNIGHT_ENGINE.daylight
ROUTE DAYNIGHT_ENGINE.set_background TO BACKGROUND.skyColor

Update: J. Semančík a F. Vůjtěch, 17. 12. 2002