#VRML V2.0 utf8 # Define the basic scene structure Transform { children [ Shape { appearance Appearance { material Material { diffuseColor 1 1 1 # Default white color } } geometry Box { size 1 1 1 } # Cube with a size of 1x1x1 } ] } # TimeSensor to control the timing of the animations DEF Clock TimeSensor { cycleInterval 5.0 # 5-second loop loop TRUE # Continuous loop } # PositionInterpolator to move the cube DEF MoveCube PositionInterpolator { key [0.0, 0.5, 1.0] keyValue [0 0 0, 5 5 0, 0 0 0] # Move to (5, 5, 0) and back to (0, 0, 0) } # OrientationInterpolator to rotate the cube DEF RotateCube OrientationInterpolator { key [0.0, 0.5, 1.0] keyValue [ 0 1 0 0, # No rotation 0 1 0 3.14159, # Rotate 180 degrees around Y axis 0 1 0 6.28318 # Rotate 360 degrees around Y axis (back to start) ] } # ScalarInterpolator to scale the cube DEF ScaleCube ScalarInterpolator { key [0.0, 0.5, 1.0] keyValue [1, 2, 1] # Scale from 1 to 2 and back to 1 } # ColorInterpolator to change the color of the cube DEF ColorCube ColorInterpolator { key [0.0, 0.5, 1.0] keyValue [ 1 0 0, # Red 0 1 0, # Green 0 0 1 # Blue ] } # CoordinateInterpolator for vertex animation (example of moving vertices) DEF CoordCube CoordinateInterpolator { key [0.0, 0.5, 1.0] keyValue [ 0 0 0, 1 0 0, 1 1 0, 0 1 0, 0 0 1, 1 0 1, 1 1 1, 0 1 1, # Default Box 0 0 0, 2 0 0, 2 2 0, 0 2 0, 0 0 2, 2 0 2, 2 2 2, 0 2 2, # Expanded Box 0 0 0, 1 0 0, 1 1 0, 0 1 0, 0 0 1, 1 0 1, 1 1 1, 0 1 1 # Back to Default ] } # NormalInterpolator to animate normals (lighting effects) DEF NormalCube NormalInterpolator { key [0.0, 0.5, 1.0] keyValue [ 0 0 1, 0 1 0, 1 0 0, # Changing normal directions 0 1 0, 1 0 0, 0 0 1, # Different normals 0 0 1, 0 1 0, 1 0 0 # Back to original normals ] } # ROUTE statements to connect interpolators to the cube's properties ROUTE Clock.fraction_changed TO MoveCube.set_fraction ROUTE MoveCube.value_changed TO Transform.set_translation ROUTE Clock.fraction_changed TO RotateCube.set_fraction ROUTE RotateCube.value_changed TO Transform.set_rotation ROUTE Clock.fraction_changed TO ScaleCube.set_fraction ROUTE ScaleCube.value_changed TO Transform.set_scale ROUTE Clock.fraction_changed TO ColorCube.set_fraction ROUTE ColorCube.value_changed TO Appearance.material.set_diffuseColor ROUTE Clock.fraction_changed TO CoordCube.set_fraction ROUTE CoordCube.value_changed TO Shape.geometry.set_coord ROUTE Clock.fraction_changed TO NormalCube.set_fraction ROUTE NormalCube.value_changed TO Shape.geometry.set_normal