Sunday, 21 October 2012

Multi texture cube with Away3D 4

I wrote a post about adding a different texture to the faces of a cube with Away3DLite back in January. I came across a similar post the other day. The author has written a class that adds a different texture to each face of the cube in Away3D 4. Here is a quick example:

 import away3d.cameras.Camera3D;
 import away3d.containers.Scene3D;
 import away3d.containers.View3D;
 import away3d.entities.Mesh;
 import away3d.materials.ColorMaterial;
 import away3d.materials.TextureMaterial;
 import away3d.primitives.PlaneGeometry;
 import away3d.textures.VideoTexture;
 import flash.display.*;

 [SWF(backgroundColor="#ffffff", frameRate="60", quality="HIGH", width="800", height="600")]

 public class MultMaterialCubeTest extends Sprite
  private var scene:Scene3D;
  private var camera:Camera3D;
  private var view:View3D;
  private var newMultiCube: multiMatCube; 
  public function MultMaterialCubeTest()
   if (stage)init();
   else addEventListener(Event.ADDED_TO_STAGE, init);
  private function init(e:Event = null):void
   removeEventListener(Event.ADDED_TO_STAGE, init);
   stage.scaleMode = StageScaleMode.NO_SCALE;
   stage.align = StageAlign.TOP_LEFT;
  private function createView():void
   scene = new Scene3D();
   camera = new Camera3D();
   camera.z = -800;
   view = new View3D();
   view.scene = scene; = camera;
   view.backgroundColor = 0xffffff;
   view.antiAlias = 4;
   addEventListener(Event.ENTER_FRAME, ef);
  private function createScene():void
   newMultiCube = new multiMatCube (100, 100, 100,  
            new ColorMaterial(0xff0000), 
            new ColorMaterial(0x00ff00), 
            new ColorMaterial(0x0000ff), 
            new ColorMaterial(0xff0000), 
            new ColorMaterial(0x00ff00), 
            new ColorMaterial(0x0000ff));
  private function ef(e:Event):void
   newMultiCube.rotationY += 3;
   newMultiCube.rotationX += 3;



  COPYRIGHT © 2014 · ILIKE2FLASH · Theme by Ourblogtemplates

Back to TOP