pauseLoop_1_00.x3d source
<?xml version="1.0" encoding="UTF-8"?>

<X3D>
<Scene>
<Viewpoint/>
<NavigationInfo
type='"EXAMINE"'
/>

<!-- 赤円錐 -->
<Transform DEF='Cone-Tf'>
<Transform translation='3 0 0'>
<Shape>
<Appearance>
<Material diffuseColor='1 0 0'/>
</Appearance>
<Cone height='0.5' bottomRadius='0.2'/>
</Shape>
</Transform>
</Transform>

<!-- 一時停止ボタン -->
<Group>
<Transform translation='0.2 0 0'>
<Shape DEF='Pause-Sp'>
<Appearance>
<Material diffuseColor='0 0.2 0.8'/>
</Appearance>
<Box size='0.2 0.7 0.05'/>
</Shape>
</Transform>
<Transform translation='-0.2 0 0'>
<Shape USE='Pause-Sp'/>
</Transform>
<TouchSensor DEF='Pause-ThS'/>
</Group>

<!-- タイムセンサー -->
<TimeSensor DEF='TiS' loop='TRUE' cycleInterval='5'/>

<!-- 回転アニメ -->
<OrientationInterpolator DEF='OI'
key='0 0.25 0.5 0.75 1'
keyValue='0 0 1 0
0 0 1 1.5708
0 0 1 3.1416
0 0 1 4.7124
0 0 1 6.2832
'
/>

<!-- 一時停止スクリプト -->
<Script DEF='Sc'>
<field accessType='inputOnly' type='SFTime' name='pause'/>
<field accessType='inputOnly' type='SFFloat' name='set_fraction'/>
<field accessType='outputOnly' type='SFFloat' name='fraction_out'/>
<field accessType='initializeOnly' type='SFBool' name='active' value='TRUE'/>
<field accessType='initializeOnly' type='SFFloat' name='oldF' value='0'/>
<![CDATA[ecmascript:

function pause () {

active = !active;

}

function set_fraction (f) {

var df = f - oldF;
if ( df < 0 ) df++;
oldF = f;

if (active) {

fraction_out += df;
if ( fraction_out > 1 ) fraction_out--;

}

}
]]>
</Script>

<ROUTE fromNode='Pause-ThS' fromField='touchTime' toNode='Sc' toField='pause'/>

<ROUTE fromNode='TiS' fromField='fraction_changed' toNode='Sc' toField='set_fraction'/>
<ROUTE fromNode='Sc' fromField='fraction_out' toNode='OI' toField='set_fraction'/>
<ROUTE fromNode='OI' fromField='value_changed' toNode='Cone-Tf' toField='rotation'/>
</Scene>
</X3D>