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

<X3D>
<Scene>
<Viewpoint description='"initial"' position='0 1.6 10'/>
<NavigationInfo headlight='FALSE' speed='3'
type='"WALK"'
/>
<DirectionalLight direction='-1 -1 -1'/>

<!-- 背景 -->
<Background
skyColor='0 0.3 1
0.7 1 1
'
skyAngle='1.57'
/>

<!-- 地面 -->
<Transform translation='0 -0.05 0'>
<Shape>
<Appearance>
<Material diffuseColor='0 0.8 0'/>
<ImageTexture
url='"green.jpg"'
/>
<TextureTransform scale='50 50'/>
</Appearance>
<Box size='50 0.1 50'/>
</Shape>
</Transform>

<!-- コンソール -->
<Transform DEF='Console-Tf'>
<Transform translation='0 -1 -3'>
<Shape>
<Appearance>
<Material transparency='0.5'/>
</Appearance>
<Cylinder radius='0.5' height='0.2'/>
</Shape>
<Shape>
<Appearance>
<Material diffuseColor='0 1 0'/>
</Appearance>
<Cylinder radius='0.02' height='0.2'/>
</Shape>

<!-- コンパスの針 -->
<Transform DEF='Compass-Tf'>
<Transform rotation='1 0 0 -1.5708' translation='0 0 -0.35'>
<Shape>
<Appearance DEF='Compass-Ap'>
<Material diffuseColor='1 0.5 0'/>
</Appearance>
<Cone bottomRadius='0.1' height='0.2'/>
</Shape>
</Transform>
<Transform rotation='1 0 0 -1.5708'>
<Shape>
<Appearance USE='Compass-Ap'/>
<Cylinder radius='0.02' height='0.8'/>
</Shape>
</Transform>
</Transform>
</Transform>
</Transform>
<ProximitySensor DEF='PrS' size='1000 1000 1000'/>
<ROUTE fromNode='PrS' fromField='position_changed' toNode='Console-Tf' toField='set_translation'/>
<ROUTE fromNode='PrS' fromField='orientation_changed' toNode='Console-Tf' toField='set_rotation'/>

<!-- スクリプト -->
<Script DEF='Sc'>
<field accessType='inputOnly' type='SFRotation' name='set_orientation'/>
<field accessType='outputOnly' type='SFRotation' name='compassRotation'/>
<![CDATA[ecmascript:
function set_orientation (viewerOrientation) {

compassRotation = viewerOrientation.inverse();

}
]]>
</Script>
<ROUTE fromNode='PrS' fromField='orientation_changed' toNode='Sc' toField='set_orientation'/>
<ROUTE fromNode='Sc' fromField='compassRotation' toNode='Compass-Tf' toField='rotation'/>
</Scene>
</X3D>