This proposal is intended to catch the 80% set of trivial behaviors, allowing the remaining 20% to be covered by more complex behavior nodes, as described in vrml-behaviors.html.
RegionSensor {
bboxCenter # as per WWWInline, defines spatial target region
bboxSize
target NODENAME # or reference geometry to be used as spatial target
sense NODENAME # node whose position is checked; default is camera
isIn # TRUE while camera position remains inside region
# This field is a READ interface, allowing it to be
# tested elsewhere.
{} # child geometry is traversed for rendering
}
PickSensor {
target "" # SFString - node name reference to geometry to be picked
picked FALSE # SFBool - true when picked
prePick FALSE # True when mouse over this sensor (but not clicked)
{} # child geometry is traversed for rendering
}
Connection {
from "" # SFString Field Name of field to be tested
to "" # SFString field name of field to update
}
for instance, to hook up a door which opens when you walk over the doormat:
DEF DoorPad RegionSensor {
bbox ~~~~~~ # define a volume above the doormat for sensing
Separator {
# draw a picture of the doormat here
}
}
DEF MyDoor SwingDoor {
# draw door frame here
isA Separator
fields [ SFBool READWRITE doorOpen ]
doorOpen FALSE
Switch {
whichChild USE MyDoor.doorOpen
Separator {
RotationXYZ { axis Y angle 0 }
DEF DoorBody Separator { # Draw door here }
}
Separator {
RotationXYZ { axis Y angle 1.5708 }
USE DoorBody
}
}
}
Connection {
from DoorPad.isIn # connect value of isIn field
to MyDoor.doorOpen
}
Note of course, that the above example could be written with "whichChild USE DoorPad.isIn" but writing connections that way will not always be possible, especially if the parts are in different WWWInlines.
Trigger couples an event (e.g. a sensor event) with an action
Trigger {
condition "" # SFString - Fieldname to watch
action "" # MFString
}
DEF MyAnchor PickSensor {
sense USE Door
}
Trigger {
condition MyAnchor.picked
action "open http://~~~~" # open new .wrl
}
Trigger {
condition "DoorPad.isIn"
action "set MyDoor.doorOpen = 1"
}
Trigger {
condition "DoorPad.isIn && keyLock.isIn"
action "set MyDoor.doorOpen = 1"
}
A first cut would allow the trigger to:
"set MyDoor.doorOpen = 1"
"load http://foo.com/newroom.wrl"
"set MyDoor.openbehavior.running = 1"