Controlling detail
prox1.wrl

	

#VRML V2.0 utf8
#
#  prox1.wrl
#  Proximity door
#	by David R. Nadeau
#
#  This world illustrates the use of a ProximitySensor node around a door.
#  When the traveler gets near that door, an animation is triggered
#  that opens the door and plays a sound.  When the traveler
#  leaves the area, the door closes and another sound is played.
#

WorldInfo {
    title "Proximity door"
    info [ "Copyright (c) 1997, David R. Nadeau" ]
}

Viewpoint {
    position 0.0 1.6 7.0
    description "Entry view"
}

NavigationInfo {
    type [ "WALK", "ANY" ]
    headlight FALSE
    avatarSize [ 1.0, 1.6, 0.75 ]
    speed 4.0
}

# Room
Inline { url "droom.wrl" }

# Wall
Transform {
	translation 0.0 0.0 -5.0
	children Inline { url "dwall2.wrl" }
}

# Left and right door panels
Transform {
	translation 0.0 0.0 -4.95
	children [
		DEF LeftDoor Transform {
			children Transform {
				translation -0.75 0.0 0.0
				children DEF Door Inline { url "ddoor.wrl" }
			}
		}
		DEF RightDoor Transform {
			children Transform {
				translation 0.75 0.0 0.0
				children USE Door
			}
		}
	# Proximity sensor
		DEF DoorSense ProximitySensor {
			center 0.0 1.75 0.0
			size 6.0 3.5 8.0
		}
	]
}

# Sounds
Sound {
	source DEF OpenSound AudioClip { url "clunk2.wav" }
	minFront 20.0 minBack 20.0
	maxFront 60.0 maxBack 60.0
}

Sound {
	source DEF CloseSound AudioClip { url "clunk1.wav" }
	minFront 20.0 minBack 20.0
	maxFront 60.0 maxBack 60.0
}

# Animation clocks
DEF OpenClock TimeSensor {
	cycleInterval 0.5
	loop FALSE
	startTime 0.0
	stopTime 1.0
}
DEF CloseClock TimeSensor {
	cycleInterval 0.5
	loop FALSE
	startTime 0.0
	stopTime 1.0
}

# Animation paths for the left and right doors
DEF LeftOpen PositionInterpolator {
	key [ 0.0, 1.0 ]
	keyValue [ 0.0 0.0 0.0, -1.3 0.0 0.0 ]
}
DEF LeftClose PositionInterpolator {
	key [ 0.0, 1.0 ]
	keyValue [ -1.3 0.0 0.0, 0.0 0.0 0.0 ]
}
DEF RightOpen PositionInterpolator {
	key [ 0.0, 1.0 ]
	keyValue [ 0.0 0.0 0.0, 1.3 0.0 0.0 ]
}
DEF RightClose PositionInterpolator {
	key [ 0.0, 1.0 ]
	keyValue [ 1.3 0.0 0.0, 0.0 0.0 0.0 ]
}

ROUTE DoorSense.enterTime         TO OpenSound.set_startTime
ROUTE DoorSense.exitTime          TO OpenSound.set_stopTime
ROUTE DoorSense.enterTime         TO OpenClock.set_startTime
ROUTE DoorSense.exitTime          TO OpenClock.set_stopTime

ROUTE DoorSense.exitTime          TO CloseSound.set_startTime
ROUTE DoorSense.enterTime         TO CloseSound.set_stopTime
ROUTE DoorSense.exitTime          TO CloseClock.set_startTime
ROUTE DoorSense.enterTime         TO CloseClock.set_stopTime

ROUTE OpenClock.fraction_changed  TO LeftOpen.set_fraction
ROUTE OpenClock.fraction_changed  TO RightOpen.set_fraction
ROUTE CloseClock.fraction_changed TO LeftClose.set_fraction
ROUTE CloseClock.fraction_changed TO RightClose.set_fraction

ROUTE LeftOpen.value_changed      TO LeftDoor.set_translation
ROUTE LeftClose.value_changed     TO LeftDoor.set_translation
ROUTE RightOpen.value_changed     TO RightDoor.set_translation
ROUTE RightClose.value_changed    TO RightDoor.set_translation