The browser controls the passage of time in
a world by causing TimeSensors to generate events as time passes. Specialized
browsers or authoring applications may cause time to pass more quickly
or slowly than in the real world, but typically the times generated
by TimeSensors will roughly correspond to "real" time. A world's
creator should make no assumptions about how often a TimeSensor will
generate events but can safely assume that each time event generated
will be greater than any previous time event.
design note
The sampling of time is controlled by the VRML
browser. This makes it much easier for the world creators, since they
don't have to worry about synchronization of events, writing a "main
loop," and so on. It also makes it much easier to create VRML
authoring systems. If VRML had a model of time where independent applets
each ran in a separate thread and made asynchronous changes to the
world, then it would be very difficult for the user to "freeze
time" and make necessary adjustments to the virtual world. Because
time events all come from a single place TimeSensor nodesit
is easy for a world creation system to control time during the authoring
process.
Time (0.0) is equivalent to 00:00:00 GMT January
1, 1970. Absolute times are specified in SFTime or MFTime fields as
double-precision floating point numbers. Negative absolute times are
interpreted as happening before 1970.
Processing an event with timestamp t
may only result in generating events with timestamps greater than or
equal to t.
design note
Defining an absolute origin for time isn't
really necessary for proper functioning of VRML worlds. Absolute times
are very rare in VRML files; they are almost always calculated during
execution of the world relative to the occurrence of some event ("start
this animation 2.3 seconds after the viewer walks into this room").
If you know where in the real world the VRML
file will be viewed, then the absolute origin for time allows you
to synchronize the real world and the virtual world. For example,
if you know that your world will be viewed in California, then you
can create a day-to-night animation that is driven by a TimeSensor
and will match the sunrises and sunsets in California. VRML does not
include a RealWorldPositionSensor that outputs the real-world position
of the real-world VRML viewer, but if it did (perhaps when every computer
includes a Global Positioning System satellite receiver, . . .) many
very interesting applications merging the virtual and real worlds
would become possible.
A frequently asked question is how can something
be scheduled to start some amount of time "after the world is
loaded." If time were defined to start "when the world is
loaded," then this would be easythe world creator would
just give a TimeSensor an appropriate absolute startTime. One problem
with this is defining precisely what is meant by "when the world
is loaded." VRML browsers may load different parts of the world
at different times or may preload parts of the world before they're
actually needed. If the browser decides to preload part of the world
because it knows that the user is traveling at a certain speed in
a certain direction and will arrive there in 20 seconds, the world
creator probably doesn't want a 5-second welcome animation to be performed
before the user is anywhere near that part of the world. In this case,
it is better for the world creator to use a ProximitySensor or a VisibilitySensor
to generate an event that can then be used as the basis for starting
animations, sounds, and so forth. Instead of thinking in terms of
"when the world is loaded," it is better to think of "when
the user enters my world" (ProximitySensor) or "when the
user first sees . . ." (VisibilitySensor). Worlds created this
way will be composable with other worlds, allowing the creation of
the potentially infinite cyberspace of the future.
design note
The rule that "events in the past cannot
be generated" means that browsers are not responsible for simulating
anything that occurred before the VRML file was loaded. The mental
model is that a VRML file expresses the complete state of a virtual
world at a given point in time. If the VRML browser knows exactly
when the VRML file was written, then it could theoretically simulate
all of the events that occurred between when the file was written
and when it was read back into memory, just as if it had been simulating
the world all along. However, VRML files do not record the time the
world was written, and it is not always possible or convenient for
the VRML browser to retrieve that information from the underlying
operating system or transport mechanism. In addition, requiring the
VRML browser to simulate the passage of an arbitrary amount of time
after reading in every VRML file would be an unnecessary burden.
VRML does not distinguish between discrete events
(such as those generated by a TouchSensor) and events that are the result
of sampling a conceptually continuous set of changes (such as the fraction
events generated by a TimeSensor). An ideal VRML implementation would
generate an infinite number of samples for continuous changes, each
of which would be processed infinitely quickly.
Before processing a discrete event, all continuous
changes that are occurring at the discrete event's timestamp shall behave
as if they generate events at that same timestamp.
design note
This follows from the premise that an ideal
implementation would be continuously generating events for continuous
changes. A simple implementation can guarantee this by generating
events for all active TimeSensors whenever a discrete event occurs.
More sophisticated implementations can optimize this by noting dependencies
and ensuring that if a node depends on both a discrete event and a
continuous event, then it will always receive a continuous event along
with the discrete event.
Beyond the requirements that continuous changes
be up-to-date during the processing of discrete changes, the sampling
frequency of continuous changes is implementation dependent. Typically
a TimeSensor affecting a visible (or otherwise perceptible) portion
of the world will generate events once per frame, where a frame
is a single rendering of the world or one time-step in a simulation.
design note
Thinking in terms of the ideal VRML implementation
is a useful exercise and can resolve many situations that may at first
seem ambiguous. It is impossible to implement the ideal, of course,
but for well-behaved worlds the results of a well-implemented browser
will be identical to the theoretical results of the ideal implementation.
"Well behaved" means that the world creator didn't rely
on any undefined behavior, such as assuming that TimeSensors would
generate 30 events per second because that happened to be how quickly
a particular browser could render their world on a particular type
of machine.
In its quest to be machine- and implementation-neutral,
the VRML specification tries to avoid any notion of rendering frames,
pixels, or screen resolution. It is hoped that by avoiding such hardware-specific
notions the VRML world description will be appropriate for many different
rendering architectures, both present and future.