PV3D – Changing Cube Materials at runtime

Posted on January 21, 2009
Filed Under Actionscript 3.0, experiments, Opensource, Papervision | 3 Comments

A little demo illustrating how to change cube materials at runtime. In this demo you can click to go to the next side of the cube. Or just use your left and right arrow keys,

  1. _sidesLeftToRight = ["back", "right", "front", "left"];
  2. _currpageID = 0;
  3.  
  4. private function updateSkin():void
  5. {
  6.  var faceName:String = _sidesLeftToRight[(_currpageID % _sidesLeftToRight.length)];
  7.  var material:MovieAssetMaterial = new MovieAssetMaterial(_list[_currpageID], true, true, true, true);
  8.  material.animated = true;
  9.  material.doubleSided = true;
  10.  _cube.replaceMaterialByName(material, faceName);
  11. }

Where _list is an array with all the linkId’s to library assets. And _currPageID is updated by using the arrow keys (left & right) or mouse.

Will commit it to codexperience at googlecode soon

Comments

3 Responses to “PV3D – Changing Cube Materials at runtime”

  1. Michael Ypes on March 11th, 2009 5:43 pm

    Hey,

    Thats pretty much what I am doing but I am a noob to papervision although an experienced as3 developer. I am trying to find documentation on camera.zoom and camera.focus so that it stays the right size. Followed Lee Brimelows tutorial and he said

    var camera:Camera3D = new Camera3D();
    camera.zoom = 7;
    camera.focus = 100;

    Keeps it the same size although it doesn’t, it magnifies it. Do you know what the default settings are in order to keep the same size as the original mc. Also would love to have a peak at your code to see how you approach it.

    Cheers

    M

  2. Jan Willem on March 12th, 2009 12:05 pm

    @Micheal: Thats also stuff I need to figure out (focus and zoom) but maybe the documentation about the CameraObject3D might help? http://papervision3d.googlecode.com/svn/trunk/as3/trunk/docs/index.html

  3. jorge on May 17th, 2009 6:53 am

    when is is going to be at googlecode.. You have this message like 5 months before…

-->