Implementation

Single Node
You place the sound node exactly as you would place a cone or a sphere. The location is relative to your scene graph. For example, if you place a location of 0 0 0 inside a Transform with a translation of 5 5 5, then the sound will originate at 0 0 0.

In the example below, the sound is triggered when you drive up and click on the sphere.



Here's the code:

#VRML V2.0 utf8

DEF MyForm Transform {

        children [

        DEF Mouse TouchSensor {},

        DEF Timer TimeSensor {

        cycleInterval 3

        },

        Shape {

                geometry Sphere {}

                }

        Sound { source DEF MySound AudioClip {

                url "../wav/twang.wav"}

        }

        ]

}

ROUTE Mouse.touchTime TO Timer.set_startTime
ROUTE Timer.cycleTime TO MySound.set_startTime
< < < < < _ > > >