Home | Pictures of 3D objects

sphere |
Here is an example of how to make a sphere: ball=sphere( pos=vec(1,2,1), size=3*vec(1,1,1) ) This produces a sphere centered at location (1,2,1) with diameter = 3. If you specify unequal values for the components of size, you get an ellipsoid. Here is a full list of attributes for a sphere. All 3D objects have all of these attributes, other than arrow and curve: pos Position: the center of the sphere; default = vec(0,0,0). size The length, width, and height of the sphere; default = vec(1,1,1). axis The axis points in the direction of the length of the sphere, default = vec(1,0,0). Only the direction of the axis is meaningful, not its magnitude. The length of the sphere is size.x, not the magnitude of the axis. color Color of object, as a red-green-blue (RGB) triple: vec(1,0,0) is the same as color.red, default = vec(1,1,1), which is color.white. opacity Opacity of object, default = 1 (fully opaque); 0 is completely transparent. shininess 0 to 1, default 0.6; governs the amount of specular reflections. emissive If True, local and distant lights are ignored, and the brightness is governed by the object's own color. An example of its use is to put an emissive sphere at the location of a local_light, which looks like a glowing lamp. The default for emissive is False. up Which side of the sphere is "up"; this has only a subtle effect on the 3D appearance of a sphere unless the cross section is not circular or a texture is applied; default = vec(0,1,0). visible If False, object is not displayed; e.g. ball.visible = False Use ball.visible = True to make the object visible again. texture You can specify a texture to apply to the object's surface. See the Textures documentation. End vs center: The pos attribute for arrow, cone, cylinder, helix, and pyramid corresponds to one end of the object, whereas for a box, ring, or sphere it corresponds to the center of the object. To display a trail or an arrow along the path of a moving object, see Attach a trail or arrow. See Rotating an Object for an easy way to change the orientation of an object. When you run a program, for convenience GlowScript creates a canvas on the web page and names it scene. Objects that you create are drawn on this canvas. If you have more than one canvas, you can specify in which canvas to place a new object, as in box(canvas=myscene); in JavaScript this would be box( {canvas:myscene} ). If you don't specify a canvas, the new object goes into the most recently created canvas, or the most recently selected canvas as specified by setting canvas.selected. JavaScript See the cylinder documentation for how to create an object in JavaScript.

Top of page