This Part of the Shaders Tutorial series will show you how to add Phong vshader to either a dae imported object or to a basic primitive.

If you are a novice, it is advised that you follow this tutorial from the initial section that can be found here, which explains how to set up the files and the scene. Otherwise please read on.

For those following on the shaders tutorial series, i will be calling this .as file phongMat

package phongMat {
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFormat;

	import org.papervision3d.cameras.CameraType;
	import org.papervision3d.lights.PointLight3D;
	import org.papervision3d.materials.shadematerials.PhongMaterial;
	import org.papervision3d.materials.utils.MaterialsList;
	import org.papervision3d.objects.primitives.Sphere;
	import org.papervision3d.render.BasicRenderEngine;
	import org.papervision3d.view.BasicView;
	import org.papervision3d.objects.parsers.DAE;
        import org.papervision3d.objects.DisplayObject3D;

	public class phongMat extends Sprite

		private var view:BasicView;
		private var phong:PhongMaterial;
		private var light:PointLight3D;
		private var sphere:Sphere;
		private var angle:Number = new Number(0);

		private var tf:TextField;
		private var format:TextFormat;

		private var dae:DAE;
                private var daeFile:String;
                private var daeMaterialName:String;		

		private var statsview:StatsView;

		public function phongMat()
		view = new BasicView(300, 300, false, false, CameraType.FREE);
		view.renderer = new BasicRenderEngine();

		light = new PointLight3D(true);
                light.z = -800; light.y = 300;
		phong = new PhongMaterial(light, 0xFFFFFF, 0xEEC900, 80);
		daeFile = "YourDAEfileName.dae";
		dae = new DAE();
                dae.load(daeFile, new MaterialsList ( { all:phong} ));
                //dae.scale = 100; //You may need to scale and rotate your object

		format = new TextFormat("Arial", 10, 0xFFFFFF);
		tf = new TextField(); tf.width = 200;
                tf.text = "Phong Material Shader";
		tf.x = 10; tf.y = 10; tf.setTextFormat(format);

		addEventListener(Event.ENTER_FRAME, onRenderViewport);

		private function onRenderViewport(e:Event):void
//Either rotate your object, or the light source or both

		private function animateLight():void
			angle += 4 * (Math.PI/180);
			light.x = Math.cos(angle) * 800;
			light.z = Math.sin(angle) * 800;

If you have been following this tutorial series from the beginning, you will want to add the following code to your file that you created, in order to run your movie.

package {
	import org.papervision3d.render.BasicRenderEngine;
	import org.papervision3d.view.BasicView;

	import phongMat.phongMat;
	[SWF (width="800", height="600", framerate="25", backgroundColor="0x333333")];

	public class MainShader extends Sprite {
		private var phong:phongMat;

		public function MainShader() {

			phong = new phongMat(); phong.x = 500; phong.y = 300;


If you like this tutorial, why not sign up to our RSS feeds and recieve the latest updates straight to your inbox/reader!
OR spread the word using the Social buttons bellow – Thanks!
Feel free to leave a comment if you require an help/suggestions, and I will get back to you ASAP.

Be Sociable, Share!

2 Responses to “Phong Material Shader on DAE objects”

  • FelipeNo Gravatar says:


    Why when applying the shades to a Collada file, the color of the collada desapear and only keeps the shades?


  • adminNo Gravatar says:

    When you apply a shader, you are overwriting the original colour of the collada file
    If you want to mix both materials together it is a more detailed process..

Leave a Reply

This site is using OpenAvatar based on

Follow me on Twitter
free counters
PayPal Donation
If you like this blog and the help it has given you, why not donate for this good cause? Click on the button below to pay Safely and Securely through PayPal.