This node is another of the shape Nodes. This node provides you with a cuboid aligned with the coordinate axes. The default for the cube node centered it at (0,0,0) and measures two units in each dimension, from -1 to +1.
FILE FORMAT/DEFAULTS
Cube {
width 2 # SFFloat
height 2 # SFFloat
depth 2 # SFFloat
}
You can change the width, height, and depth variables to achieve different sized objects.
As with some of the previously discussed nodes, transformation of the cube node is performed by the scene graph's current cumulative transformation. It is also drawn with the scene graph's current Material and texture.
In the scene graph, if the current material binding is PER_PART, PER_PART_INDEXED, PER_FACE, or PER_FACE_INDEXED, materials will be bound to the individual faces of the cube in the following order: front (+Z), back (-Z), left (-X), right (+X), top (+Y), and bottom (-Y). If you have trouble visualizing this, remember how the left-handed coordinate system works. +Z will be into the screen and -Z will be out of the screen toward you. -X is to the left, +X to the right, +Y toward the top of the screen, and -Y toward the bottom.
In must the same way, textures are applied individually to each face of the cube. Keep in mind that the entire texture will be applied on each face. On the front (-Z), back (+Z), right (+X), and left (-X) sides of the cube, the texture will be applied right side up. On the top (+Y), the texture will appear right side up if you tilt the top of the cube toward your viewpoint. On the bottom (-Y), the texture appears right side up when the top of the cube is tilted toward the -Z axis, or away from your viewpoint. Please keep in mind that these material, texture, and material binding transformations are applied to the object at it's initial 3-D coordinate location.
Example Use
The following code fragment is from one of the many Cube .wrl files available.
Cube { width 3
height 2
depth 1}