How to make Collada model double sided in Papervision3D

Well I searched for this for a little while and even tough it is pretty easy, if I didn’t figure it out at first probably other people had the same absence of mind. Also I find it hard to find example of Papervision3D and know which version was used; you find a lot of examples but you never know if the API changed since then so I am going to do a complete example with the version used.

The version used for this example is 2.1.92.

What I wanted to do was to load a Collada model in Flash an animate it. Every thing was going fine with the test models until I used the real models. You see the real models had holes in them that allowed you to see inside the model. Now if your material is single sided, when looking inside, you are going to see through the material and it will look buggy. The solution to this is just to make all material in your model (you can map multiple textures in one loaded Collada model), but that is not as easy as it sound. I tried a couple of options before hitting myself on the face. What did you learn back with ActionScript 2; wait till something is loaded before trying to modify it. This also applies to loaded models. Once loaded I made a little function that would cycle through all materials and make them double side.

Here is the code for the example :

//create all the actors of a Papervision3D scene
var viewport:Viewport3D = new Viewport3D(1000, 800);
var renderer:BasicRenderEngine = new BasicRenderEngine();
var camera:Camera3D = new Camera3D();
var scene:Scene3D = new Scene3D();
//create the DAE/Collada object and load the model
var model:DAE = new DAE(false);
model.addEventListener(FileLoadEvent.LOAD_COMPLETE , daeLoadComplete, false, 0, true);
//finally add the enter frame listener to render the scene
addEventListener(Event.ENTER_FRAME, render, false, 0, true);
function render(event:Event):void{
  renderer.renderScene(scene, camera, viewport);
//this is where the magic happens, we cycle through all the materials of the model and make them double sided
function daeLoadComplete(event:FileLoadEvent):void{
  var matList:MaterialsList;
  var mat:MaterialObject3D;
  matList = model.materials;
  if ( matList ) {
    for each (mat in matList.materialsByName) {
      mat.doubleSided = true;

I didn’t include the import statement because I plainly forgot to send them to myself, but I will update this post to add them. Have fun loading models!

, , ,

  1. #1 by Randy - September 25th, 2009 at 19:31

    I have a silly question. I’m starting a blog and any trying to figure out how you post your ActionScript code as it’s formatted.

    I can’t find the trick.

    Thanks in advance.

  2. #2 by Jan - November 2nd, 2009 at 07:07

    Thank you!!

  3. #3 by miles - May 13th, 2010 at 08:45


    can you help me with my test
    i load collada model and i don’t know why there holes in it
    you can check it
    and here’s code


  4. #4 by Abhishek Saxena - November 30th, 2010 at 09:12

    well, i am facing a different kind of problem..well what i need to do is make a 3d tshirt i make a 3d model from google its dae..applied a bitmapFileMaterial and i got a nice looking 3d i need to do is something extra on you have seen a tshirt had different -2 views..front view..back view..and side view…so can i want to ask is can i have 2 images to render on a single 3d dae on its front side and the other on the back side…?

  5. #5 by Abhishek Saxena - November 30th, 2010 at 09:13

    please if you have any solution regarding this ..please give me by replying to my mail id which is

(will not be published)
Subscribe to comments feed

Parse error: syntax error, unexpected ';' in /homepages/25/d169645162/htdocs/wp-content/themes/fusion/footer.php on line 13