It's All In Motion

PositionInterpolator • Attributes

A sphere "bouncing" up and down off a square floor. The floor changes color depending on where the sphere is located.

Timing events are being routed from a TimeSensor to Color and Position interpolators. The interpolators route events to their respective output destinations.

TimeSensor, Route

 

Rotate the vrignette to view the geometry.

<x3d>

<scene>

<worldInfo title="X3D PositionInterpolator Example">
</worldInfo>

<navigationInfo headlight="true">
</navigationInfo>

<viewpoint position="0.0 1.5 20.0">
</viewpoint>

<pointlight location="0.0 20.0 0.0" radius="50" color="0.90 0.90 0.90" intensity="0.5" global="true">
</pointlight>

<!-- Shapes -->
<transform DEF="sphereMover" translation="">
<shape>
<appearance>
<material diffuseColor="0.0 0.5 1.0" specularColor="0.1 0.1 0.1" shininess="0.05">
</material>
</appearance>
<sphere DEF="sphereDemo" radius="1.5" solid="true">
</sphere>
</shape>
</transform>

<transform translation="0.0 -1.5 0.0">
<shape>
<appearance>
<material DEF="boxDemoColor" diffuseColor="0.75 0.0 0.75">
</material>
</appearance>
<box DEF="boxDemo" size="10.0 0.10 10.0" solid="true">
</box>
</shape>
</transform>

<!-- Sensors/Interpolators -->
<timeSensor DEF="motionTimer" cycleInterval="3.0" enabled="true" loop="true">
</timeSensor>
<positionInterpolator DEF="positionTracker" key="0.0 0.25 0.50 0.75 1.0" keyValue="0.0 0.0 0.0, 0.0 2.5 0.0, 0.0 5.0 0.0, 0.0 2.5 0.0, 0.0 0.0 0.0">
</positionInterpolator>
<colorInterpolator DEF="colorTracker" key="0.0 1.0" keyValue="0.75 0.0 0.75, 1.0 1.0 1.0">
</colorInterpolator>

<!-- Route Time To Interpolator -->
<route fromNode="motionTimer" fromField="fraction_changed" toNode="positionTracker" toField="set_fraction">
</route>
<route fromNode="motionTimer" fromField="fraction_changed" toNode="colorTracker" toField="set_fraction">
</route>

<!-- Route Interpolator To Shape -->
<route fromNode="positionTracker" fromField="value_changed" toNode="sphereMover" toField="translation">
</route>
<route fromNode="colorTracker" fromField="value_changed" toNode="boxDemoColor" toField="diffuseColor">
</route>

<background skyColor="0.90 0.90 0.90" groundColor="0.15 0.15 0.15">
</background>

</scene>

</x3d>