Error 404 - Not Found
Sorry, the page that you are looking for does not exist.
VRML Script Tutorial Full list VRML Interactive Tutorial
Introduction
Hierarchical Node Structures
Defining and Instancing Nodes Defining Levels of Detail Events in VRML
|
Lighthouse3d.comMostly about 3D graphics
Error 404 - Not FoundSorry, the page that you are looking for does not exist.
|
|
DEF ga Group { children [ DEF sa Shape ... DEF ta TouchSensor {} DEF gb Group { children [ DEF sb Shape ... DEF tb TouchSensor {} ] } ] }
Example of a TouchSensor to play a sound:
The following source code describes a group with a Shape, a TouchSensor, and a Sound.
#VRML V2.0 utf8 Group { children [ DEF ts TouchSensor { } Sound { source DEF ac AudioClip { loop FALSE url "sfx.mid" } } Shape { appearance Appearance { material Material {} } geometry Sphere{} } ] }
The sound will play once because the loop field of the AudioClip is set to FALSE.
Another possibility is to have the sound playing whenever the mouse is over the shape. This can be achieved by the following route:
This will cause loop to become TRUE when the TouchSensor output an isOver event with the value TRUE. When the user is no longer over the shape the isOver event from the TouchSensor will output FALSE therefore stopping the sound as soon as the sound's duration/pitch or stopTime are achieved.