How does one automatically roam or walk in a specified path in the VRML/X3D environment? And if the control only goes through?
I checked a lot of information today and concluded that this is a relatively simple solution.
It mainly uses timesensor, touchsensor, positioninterpolator, and orientationinterpolator.
Example:
Def PI positioninterpolator {
Key [0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
]
KeyValue [
9 1.5 2,
9 1.5 4,
20 1.5 15,
22 1.5 15,
23 1.5 16,
42 1.5 16,
43 1.5 17,
43 1.5 31,
42 1.5 32,
42 1.5 38,
41 1.5 39,
]
}
Def oi orientationinterpolator {
Key [0 0.05 0.25 0.3 0.35 0.55 0.6 0.75 0.8 0.95 1]
KeyValue [
0 1 0 3.14,
0 1 0 4,
0 1 0-1.57,
0 1 0-1.57,
0 1 0-1.57,
0 1 0-2.8,
0 1 0 3.14,
0 1 0 3.14,
0 1 0 3.14,
0 1 0 3.14,
0 1 0 3.14]
}
Def ts timesensor {
Cycleinterval 33
Loop false
}
Def TCT touchsensor {}
Route TCT. touchtime to ts. starttime
Route ts. fraction_changed to Pi. set_fraction
# Route pi. value_changed to tr. set_translation
Route pi. value_changed to CVP. set_position
Route ts. fraction_changed to Oi. set_fraction
Route Oi. value_changed to CVP. set_orientation
When the loop is false, you need to start timesensor by yourself. At this time, touchsensor is used to transmit the starttime of ts for start.
In this way, an animation (that is, a path walk) is triggered every time an object is clicked in a scene ).
If you set the loop to true, you do not need touchsensor to start it. It starts automatically and keeps repeating.