<?xml version="1.0" encoding="UTF-8"?>
<X3D>
<Scene>
<Viewpoint description='"initial"' position='0 1.6 0'/>
<NavigationInfo headlight='FALSE' speed='3'
type='"WALK"'
/>
<DirectionalLight direction='-1 -2 -1'/>
<!-- 背景 -->
<Background
skyColor='0 0.3 1
0.7 1 1
'
skyAngle='1.57'
/>
<!-- 地面 -->
<Transform DEF='Ground-Tf' translation='0 -0.05 0'>
<Shape>
<Appearance>
<Material/>
<ImageTexture DEF='Map-IT' repeatS='FALSE' repeatT='FALSE'
url='"map.gif"'
/>
</Appearance>
<Box size='100 0.1 100'/>
</Shape>
</Transform>
<!-- 地図 -->
<Transform DEF='Console-Tf'>
<Transform DEF='Map-Tf' translation='1 0.5 -3'>
<Transform rotation='1 0 0 1.5708'>
<Shape>
<Appearance>
<ImageTexture USE='Map-IT'/>
<TextureTransform DEF='Map-TT' scale='0.3 0.3'/>
</Appearance>
<Cylinder radius='0.5' height='0.02' side='FALSE' bottom='FALSE'/>
</Shape>
<Shape>
<Appearance>
<Material transparency='0.5'/>
</Appearance>
<Cylinder radius='0.52' height='0.01' side='FALSE' bottom='FALSE'/>
</Shape>
</Transform>
<!-- 赤球 -->
<Shape>
<Appearance>
<Material emissiveColor='1 0 0'/>
</Appearance>
<Sphere radius='0.05'/>
</Shape>
</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' directOutput='TRUE'>
<field accessType='inputOnly' type='SFVec3f' name='set_position'/>
<field accessType='inputOnly' type='SFRotation' name='set_rotation'/>
<field accessType='initializeOnly' type='SFNode' name='MapTT'>
<TextureTransform USE='Map-TT'/>
</field>
<field accessType='initializeOnly' type='SFFloat' name='groundSize' value='100'/>
<field accessType='initializeOnly' type='SFFloat' name='mapSize' value='1'/>
<field accessType='initializeOnly' type='SFFloat' name='rate' value='0.01'/>
<field accessType='initializeOnly' type='SFVec2f' name='offset' value='-0.5 -0.5'/>
<field accessType='initializeOnly' type='SFVec3f' name='initViewDirection' value='0 0 -1'/>
<![CDATA[ecmascript:
function initialize () {
rate = mapSize / groundSize;
}
function set_position (vec) {
var c = new SFVec2f ( -vec.x, vec.z );
c = c.multiply( rate ).add( offset );
MapTT.center = c;
MapTT.translation[0] = -0.5 - c.x;
MapTT.translation[1] = -0.5 - c.y;
}
function set_rotation (rot) {
var v = rot.multVec( initViewDirection );
v.y = 0;
var rt = new SFRotation ( initViewDirection, v );
var r = rt.angle;
if ( rt.y < 0 ) r = 2 * Math.PI - r;
MapTT.rotation = r;
}
]]>
</Script>
<ROUTE fromNode='PrS' fromField='position_changed' toNode='Sc' toField='set_position'/>
<ROUTE fromNode='PrS' fromField='orientation_changed' toNode='Sc' toField='set_rotation'/>
</Scene>
</X3D>