Next, create a light source, and place it at position 500,500 on the X and Y axes. The PointLight3D class is a simple light source that shines light in all directions.
var light:PointLight3D=new PointLight3D(true); light.x=500; light.y=500;
Next, create a material for the sphere. In this example we'll use a FlatShadeMaterial, which will show all the facets that make up the sphere shape (as seen in the example at the start of the tutorial). The 3 parameters specify the instance name of the light that will affect the material, and the two colours for the highlight and shadow in Hexadecimal format.
var sphereMaterial:MaterialObject3D=new FlatShadeMaterial(light, 0xFF0000, 0x330000);
Next we create the sphere, and apply the material.
var ball=new Sphere(sphereMaterial,200,10,10);
Finally, add all of the necessary objects to the stage and scene, and render.
addChild(viewport); scene.addChild(ball); renderer.renderScene(scene, camera, viewport);
Test your Movie (Control-Test Movie or Ctrl-Enter) and you should see the image below.
The sphere appears in the in the centre, and because the point light is towards the top and right, the shadow appears at the bottom left of the sphere.
Next we'll look at applying the different shading effects.
