Heilan X3D Browser





This node implements a simple damped mass spring model. When it receives a set_position event, it will move towards that position, oscillating around it according to its mass, stiffness and damping attributes. It constantly outputs its current position as events, so you can route it to other nodes to create more interesting (and slightly more familiar from real life) motions.


position SFFloat (input) Use this to trigger the node into motion - this is the centre point around which the mass will oscillate.

massPosition SFFloat (input) An output-only attribute, this is the actual position of the mass, centred on position.

stiffness SFFloat (input) The spring stiffness of the simulation, affects how the mass moves.

mass SFFloat (input) The mass used in the simulation, affects how the mass moves.

damping SFFloat (input) How much damping is applied to the mass' motion.

massPosition SFFloat (output) The current position of the mass with respect to its centre.

Example Use

<?xml version="1.0" encoding="utf-8"?>
<X3D profile="Full">
		<NavigationInfo type="ANY" headlight="FALSE"/>

		<Transform DEF="bob" translation="0 0 -32">

		<TimeSensor DEF="timer" cycleInterval="10" loop="FALSE"/>
		<ScalarInterpolator DEF="massPositioner" key="0 0.25 0.75 1" keyValue="1 2 2 1"/>
		<MassSpringDamper DEF="mass" mass="1" damping="0.5"/>
		<PositionInterpolator DEF="bobPosition" key="0 3" keyValue="-4 0 -16		4 0 -16"/>

		<ROUTE fromNode="timer" fromField="fraction_changed" toNode="massPositioner" toField="set_fraction"/>
		<ROUTE fromNode="massPositioner" fromField="value_changed" toNode="mass" toField="set_position"/>
		<ROUTE fromNode="mass" fromField="massPosition" toNode="bobPosition" toField="set_fraction"/>
		<ROUTE fromNode="bobPosition" fromField="value_changed" toNode="bob" toField="translation"/>