Home | Pictures of 3D objects

label |
With the label object you can display text in a box, and the label always faces forward, even if you rotate the scene (for 3D text, see the text object). Here is a simple example: label( pos=vec(0,0.25,0), text='Hello!' )
There are many additional label options. In the diagram to the right, an object located at "obj.pos" has an associated label with the text "Early" in a box, connected to the object. L = label(pos=obj.pos, text='Early', xoffset=20, yoffset=50, space=30, height=16, border=4, font='sans') A unique feature of the label object is that several attributes are given in terms of screen pixels instead of the usual "world-space" coordinates. For example, the height of the text is given in pixels, with the result that the text remains readable even when the sphere object is moved far away. Other pixel-oriented attributes include xoffset, yoffset, and border. Here are the label attributes: |
pos The point in world space being labeled. pixel_pos If True, pos is the position in terms of pixels, with vec(0,0,0) in the lower left corner. align Specify 'left', 'right', or 'center'. When you specify 'center', which is the default, the center of the topmost line of text is at the location given by pos. When you specify 'left', the start of the topmost line of text is at the location given by pos. When you specify 'right', the right end of the topmost line of text is at the location given by pos. xoffset, yoffset The x and y components of the line, in pixels (see diagram). Unless you specify a value for align, text above or below pos is centered, text to the left of pos is right-adjusted, and text to the right of pos is left-adjusted. text The text to be displayed, such as 'Earth'. You can give a number or numerical expression; it will be converted to a string. Multiple lines can be displayed by inserting line breaks: "Three\nlines\nof text". font Name of the desired font; 'sans' or 'serif'' or 'monospace' (fixed-width), or a specific font name height Height of the font in pixels; default is 15 pixels color Color of the text; default is white unless scene.background is white, in which case the default is black background Color of the background of the box; default is scene.background opacity Opacity of the background of the box, default 0.66 (0 transparent, 1 opaque, for objects behind the box) border Distance in pixels from the text to the surrounding box; default is 5 pixels box True if the box should be drawn (default), else False line true if the line from the box to pos should be drawn (default), else false linecolor Color of the line and box; default is white unless scene.background is white, in which case the default is black; if the label's color is specified, the default linecolor is the same linewidth The width in pixels of the line and box space Radius in real-world coordinates of a sphere surrounding pos, into which the connecting line does not go. visible Label is not displayed if False When you run a program, for convenience GlowScript creates a canvas on the web page and names it scene. canvas.selected. JavaScript See the cylinder documentation for how to create an object in JavaScript.

Top of page