The Annotated VRML 97 Reference

1 Intro     Concepts     3 Nodes     4 Fields/Events    Conformance
A Grammar     B Java     C JavaScript     D Examples     E Related Info    References
Quick Java         Quick JavaScript         Quick Nodes   
 

  About the Book
  
Help
  Copyright © 1997-99
  Purchase the book from Amazon.com

Chapter 3:
Node Reference


Intro
Anchor
Appearance
AudioClip
Background
Billboard
Box
Collision
Color
ColorInterpolator
Cone
Coordinate
CoordinateInterpolator
Cylinder
CylinderSensor
DirectionalLight
ElevationGrid
Extrusion
Fog
FontStyle
Group
ImageTexture
IndexedFaceSet
IndexedLineSet
Inline
LOD
Material
MovieTexture
NavigationInfo
Normal
NormalInterpolator
OrientationInterpolator
PixelTexture
PlaneSensor
PointLight
PointSet
PositionInterpolator
ProximitySensor
ScalarInterpolator
Script
Shape
Sound
Sphere
SphereSensor
SpotLight
Switch
Text
TextureCoordinate
TextureTransform
TimeSensor
TouchSensor
Transform
Viewpoint
VisibilitySensor
WorldInfo

+3.21 Group

Group { 
  eventIn      MFNode  addChildren
  eventIn      MFNode  removeChildren
  exposedField MFNode  children   []
  field        SFVec3f bboxCenter 0 0 0    # (-INF,INF)
  field        SFVec3f bboxSize   -1 -1 -1 # (0,INF)
                                           # or -1,-1,-1
}

A Group node contains children nodes without introducing a new transformation. It is equivalent to a Transform node without the transformation fields.

A description of the children, addChildren, and removeChildren fields and eventIns may be found in "2.6.5 Grouping and children nodes."

The bboxCenter and bboxSize fields specify a bounding box that encloses the Group node's children. This is a hint that may be used for optimization purposes. If the specified bounding box is smaller than the actual bounding box of the children at any time, the results are undefined. A default bboxSize value, (-1, -1, -1), implies that the bounding box is not specified and, if needed, is calculated by the browser. A description of the bboxCenter and bboxSize fields is contained in "2.6.4 Bounding boxes."

TIP: Group nodes are a good choice as the root (first) node of the VRML file.

TECHNICAL NOTE: Group is equivalent to a simplified Transform node; it could be prototyped as:

     PROTO Group [
       eventIn MFNode addChildren
       eventIn MFNode removeChildren
       exposedField MFNode children  [ ]
       field SFVec3f bboxCenter 0 0 0
       field SFVec3f bboxSize  -1 -1 -1 ]
     {
       Transform {
         addChildren IS addChildren
         removeChildren IS removeChildren
         children IS children
         bboxCenter IS bboxCenter
         bboxSize IS bboxSize
       }
     }

Group is a standard node in the VRML specification because implementations can represent a Group more efficiently than the more general Transform, saving memory and slightly increasing rendering performance when the user wants only grouping and not transformation functionality.

The most difficult design decision for Group was what it should be named. VRML 1.0 also has a Group node, with similar but not identical functionality. It was feared that having a VRML 2.0 node with the same name but slightly different semantics might be confusing; the VRML 2.0 Group is semantically more like the VRML 1.0 Separator node. After a long debate, it was decided that naming decisions should not be influenced by the VRML 1.0 node names. It is expected that the number of people using VRML 2.0 will be much greater than the number of people who ever used VRML 1.0. Therefore, easy-to-learn and easy-to-understand names were chosen in favor of easing the transition from 1.0 to 2.0.


EXAMPLE (click to run): The following example illustrates use of the Group node. The first Group node contains two children and shows typical use of the root Group as a container for the entire scene. The second Group node contains three Shapes and is instanced later as the second child of the root Group node:

#VRML V2.0 utf8
Group {            # Root Group node
  children [
    DEF G1 Group { # Group containing box, sphere, & cone
      children [
        Transform {
          translation -3 0 0
          children Shape { geometry Box {} }
        }
        Transform {
          children Shape { geometry Sphere {} }
        }
        Transform {
          translation 3 0 0
          children Shape { geometry Cone {} }
        }
      ]
    }
    Transform {
      translation 0 -3 0
      children USE G1     # Instance of G1 group
    }
  ]
}