This is a technical article explaining how to code a light source into your Papervision 3D scene. Papervision is an open source 3d library for the Flash platform.

Lighting in Papervision is a very useful tool. It helps add realism to your 3D project. Often times, you will have a scene or 3D objects that have textures on them using bitmaps. You can easily add lighting effects to these textures.
First you’ll need to add the following import statements:
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.materials.shaders.PhongShader;
import org.papervision3d.materials.shaders.ShadedMaterial;
Phong Shading is a set of 3D rendering techniques which includes a model for reflecting light onto surfaces. It was invented by Bui Tuong Phong at the University of Utah, who published them in his 1973 Ph.D. dissertation.
Where you set up your scene, just create a light source
light = new PointLight3D();
In the part where you create your 3D objects that you want to light, you will create a PhongShader based on the light source and a ShadedMaterial based on your BitmapMaterial and your PhongShader. Please note that it HAS to be a BitmapMaterial and not a BitmapFileMaterial.
var earthBitmap:Bitmap = new earthAsset() as Bitmap;
var mat:BitmapMaterial = new BitmapMaterial(earthBitmap.bitmapData, true);
// create a shader using the light source
var phongShader:PhongShader = new PhongShader(light, 0xFFFFFF, 0x000000, 10);
// create the material based on the Phong shader
var phongShaderMat:ShadedMaterial = new ShadedMaterial(mat, phongShader);
globe = new Sphere(phongShaderMat, 200, 20, 20);
view.scene.addChild( globe );
The project source code is available for download here.
Pek Pongpaet is an internet entrepreneur. Pongpaet’s expertise ranges from product design and development, user experience, and martial arts. Pongpaet worked at Accenture Technology Labs in the research department coming up with next generation user interfaces. At Roundarch, a technology and strategy consulting firm, Pongpaet’s work included envisioning and designing the dashboard of the future for the Tesla Model S electric car. He has given talks at Northwestern University, DePaul University, and University of Chicago on topics such as Design, Innovation, Technology, and Entrepreneurship.







My name is Pek Pongpaet and I'm an entrepreneur, developer, designer, tech geek, martial artist, mac enthusiast, tinkerer, foodie, and blogger.












Great article. This actually was the solution I was looking for. But I do have a question for you. I applied the same technique to a plane. I made the phongShaderMat double sided. Created a EnterFrame event and just rotated the Plane on its y axis. When the plane flips over the lighting that was applied goes flat until it flips back over again. Any reason you can think of for this?
Thanks,