Home | Pictures of 3D objects |
You can light a scene with distant lights (which act like point-like lamps far from the scene) and/or local lights (point-like lamps near the scene). For a distant light you specify its direction from the origin. For a local light you specify its location in the scene. There is a list of all distant and local light
objects, scene.lights. By default, scene.lights is this list: [distant_light( You can get rid of these default lights by setting the list to empty with scene.lights = []. To change the color of the first light to cyan, do this: scene.lights[0].color = color.cyan You can turn a light on or off by setting visible to True or False. In addition to these default distant lights, there is default ambient lighting in the form of scene.ambient=color.gray(0.2). The color of light objects and the amount of scene.ambient must be specified with some care, because if the total lighting intensity exceeds 1 anywhere in the scene the results are unpredictable. The following statement creates a local yellow light whose position is at (x,y,z), and if you continually update lamp.pos, the light will move. You may wish to place a sphere or box at the same location, with emissive set to True, n so that the lamp acts like a glowing lamp. lamp=local_light( pos:vec(x,y,z), A distant red light located in the direction (x,y,z) from the origin is created like this: DL = distant_light( direction:vec(x,y,z), 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. |