Render a cube.

This function draws a cube with its corner at the origin (0,0,0) and its sides extending in the positive x, y, and z-directions. The center of the cube is at the point (sx/2, sy/2, sz/2).

To draw a cube centered at the origin use the batch rendering method at.

Calling cube with a single value will render a cube with all sides of equal length. A more generic box shape can be rendered by specifying all three sides independently.

syntax

cube(size)       # single float value
cube(sx, sy, sz) # multiple float values

paramaters

size size of the cube in all directions
sx size of the cube in x-direction
sy size of the cube in y-direction
sz size of the cube in z-direction

optional arguments

style rendering style: "wireframe" (default) or "solid"
texture Texture object(s)

examples

draw a wireframe cube

def display():
   lighting(False)
   color(1.0, 1.0, 1.0)
   cube(4.0)

draw a solid cube

def display():
   lighting(True)
   material(1.0, 1.0, 1.0)
   cube(4.0, style='solid')

draw a texture-mapped cube

def gl_init():
   Global.texture = Texture.from_file("data/crate.png")

def display():
    cube(4.0, texture=Global.texture)

draw a cube centered at the origin

def display():
   lighting(False)
   size = 4.0

   color(white)
   cube(size)

   color(green)
   draw(cube, size).at([-size/2, -size/2, -size/2])