#VRML V2.0 utf8
Viewpoint {
description "initial"
position 0 1.6 0
}
NavigationInfo {
type "WALK"
headlight FALSE
speed 3
}
DirectionalLight {
direction -1 -2 -1
}
# 背景
Background {
skyColor [ 0 0.3 1, 0.7 1 1 ]
skyAngle 1.57
}
# 地面
DEF Ground-Tf Transform {
translation 0 -0.05 0
children [
Shape {
appearance Appearance {
material Material {}
texture DEF Map-IT ImageTexture {
url "map.gif"
repeatS FALSE
repeatT FALSE
}
}
geometry Box {
size 100 0.1 100
}
}
]
}
# 地図
DEF Console-Tf Transform {
children [
DEF Map-Tf Transform {
translation 1 0.5 -3
children [
Shape {
appearance Appearance {
texture USE Map-IT
textureTransform DEF Map-TT TextureTransform {
scale 0.3 0.3
}
}
geometry Box {
size 1 1 0.02
}
}
Shape {
appearance Appearance {
material Material {
transparency 0.5
}
}
geometry Box {
size 1.05 1.05 0.01
}
}
# 赤球
Shape {
appearance Appearance {
material Material {
emissiveColor 1 0 0
}
}
geometry Sphere {
radius 0.05
}
}
]
}
]
}
# ビューア位置と向き検出用近接度センサー
DEF PrS ProximitySensor {
size 1000 1000 1000
}
ROUTE PrS.position_changed TO Console-Tf.set_translation
ROUTE PrS.orientation_changed TO Console-Tf.set_rotation
#マップ表示域指定スクリプト
DEF Sc Script {
eventIn SFVec3f set_position
eventIn SFRotation set_rotation
field SFNode MapTT USE Map-TT
field SFFloat groundSize 100 # 地面の1辺の長さ
field SFFloat mapSize 1 # 地図の1辺の長さ
field SFFloat rate 0.01
field SFVec2f offset -0.5 -0.5
directOutput TRUE
url "javascript:
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 r = rot.angle;
if ( rot.y < 0 ) r = 2 * Math.PI - r;
MapTT.rotation = r;
}
"
}
ROUTE PrS.position_changed TO Sc.set_position
ROUTE PrS.orientation_changed TO Sc.set_rotation