OpenGL VRML Shockwave 3D
Home Tutorials Books Applications Tools Docs Models Textures

Send me bugs and suggestions, please
VRML Script Tutorial
Full list

VRML Interactive Tutorial

Introduction
VRML File Structure
Drawing: Shape node
Geometry Nodes:
Box
Sphere
Cone
Cylinder
PointSet
IndexedLineSet
IndexedFaceSet
Extrusion
ElevationGrid
Example: Chessboard
Text
FontStyle
Appearance
Material
Textures
Image Texture
Movie Texture
Pixel Texture
Texture Coordinate
Texture Transform
Let there be Light
Directional Light
Point Light
Spot Light
Materials with Colored Lights
Hierarchical Node Structures
Group
Transform
Collision
Anchor
Billboard
Switch
Inlining Files
Defining and Instancing Nodes
Defining Levels of Detail
Events in VRML
Creating Paths between events: ROUTE
Generating Events based on Timers or User Actions
Timers
Touch Sensor
Visibility Sensor
Dragging Sensors
Plane Sensor
Sphere Sensor
Cylinder Sensor
Proximity Sensors
Example: Proximity sensor
Interpolators
Color
Coordinate
Normal
Orientation
Position
Scalar
Example
Let the Music Play
Sound
AudioClip
Bindable Nodes
Who Am I: NavigationInfo
Where Am I: ViewPoint
Adding Realism to the world
Background
Fog
Information about your world
WorldInfo
Definition for Auxiliary Nodes
Coordinate
Color
Normal

TimeSensor Node


The TimeSensor node is a clock which generates events as time goes by. The events can be used to perform animation for instance. This node has the following fields:
  • enabled which specifies the status of the sensor
  • startTime which specifies when the TimeSensor starts to generate events. The value of this field is the number of seconds since midnight, January the first, 1970
  • stopTime which specifies when the TimeSensor stops to generate events. The value of this field is the number of seconds since midnight, January the first, 1970
  • cycleInterval specifies the number of seconds that the TimeSensor will generate events
  • loop specifies if when the cycleInterval is over the TimeSensor should be restarted.
  • Note: In VRML time is counted from midnight, January the first, 1970. Some say that the reason for choosing this date as the beginning of time as to do with the birth of the Unix system.

    When the TimeSensor is enabled it will start ticking when the startTime is achieved (a value of 0 means that the TimeSensor will start generating events as soon as the world is loaded). When enabled the timer will continuously, meaning as often as possible, output an event time, with the current time. After that the TimeSensor will stop generating events when either:
  • The stopTime or
  • startTime + cycleInterval is achieved.
  • In the later case, if loop is TRUE, the TimeSensor will start generating events again.

    If using the cycleInterval, the TimeSensor will output an event fraction_changed . The value of this event is between 0.0 and 1.0 and represents the fraction of the cycleInterval elapsed. If loop is TRUE then when the cycleInterval is over the fraction_changed starts over from 0.0, see Interpolators for examples on using TimeSensors.

    The number of times the events will be generated is dependent on the speed of your machine, your browser, the number of applications you're running, etc.

    TimeSensors output one more event: isActive. This event will have the value TRUE when the clock starts ticking, and FALSE when the clock stops ticking.

    Note that setting loop to FALSE will stop the TimeSensor after startTime + cycleInterval seconds from midnight, January the first, 1970. This implies that you have to compute the number of seconds from that date until the time you want to start your TimeSensor. Hard job, isn't it?

    So how do you set a TimeSensor which will output events for only a cycleInterval, i.e. without using loop, when for instance the user clicks a shape?

    The solution is to send an event set_startTime with the current time to the TimeSensor. The problem with this approach is how to compute the current time. Fortunately all sensors in VRML generate events which output a time value when they become active. So basically all you have to do is to route the event generated by the sensor when it becomes active to the eventIn of the TimeSensor set_startTime.

    See the examples provided with Interpolators and Sensors (see the Index for a complete list).

    All fields are optional, the default values being applied if the field is not specified.

    Syntax:
    TimeSensor {
    cycleInterval 1.0
    enabled TRUE
    loop FALSE
    startTime 0
    stopTime 0
    }




    Site designed and maintained by António Ramires Fernandes
    Your comments, suggestions and references to further material are welcome!

    Lighthouse 3D privacy statement