www.pudn.com > vrmlExample.rar > 8-4-2.wrl


#VRML V2.0 utf8 
 
Viewpoint 
{ 
	position 0 0 15 
	orientation 0 0 1 0 
	fieldOfView 0.8 
} 
 
Background 
{ 
		skyColor	[	0 	0 	0.2, 
					0.1 	0.1 	0.8, 
					0.7 	0.8 	0.9 
				] 
		skyAngle 	[1 	1.57] 
		groundColor 	[	0.0 	0.0 	0.0, 
					0.5 	0.4 	0.3, 
					0.3 	0.3 	0.3 
				] 
		groundAngle 	[1	1.57] 
} 
 
 
DEF  ball Transform  
{ 
	children  
	[ 
		Shape  
		{   
			geometry Sphere{} 
 			appearance Appearance  
			{ 
				material DEF SphereColor1 Material  
				{ 
					diffuseColor 1 0 0  
				}  
			} 
		} 
	] 
} 
 
 
DEF Time TimeSensor 
{ 
	cycleInterval 4 
	loop TRUE 
} 
 
DEF Mover Script 
{ 
	eventIn	SFFloat set_fraction 
	eventOut SFVec3f new_position 
	url "vrmlscript: 
 
	function set_fraction(fraction,eventTime) 
	{ 
		a=(fraction-0.5)*2 
		new_position[0]=10*a; 
		new_position[1]=2*Math.sin(a*6.28); 
		new_position[2]=0; 
	}" 
} 
 
ROUTE Time.fraction_changed TO Mover.set_fraction 
ROUTE Mover.new_position TO  ball.set_translation