Is there an easy way to do this? Check out this quick prototype:
http://www.nickbee.com/away3d/ I would like the material on the back of the cube to be flipped vertically so that it views properly. Below is the code I'm using. I have an external class to load and slice up my image. I'm using the resulting array for my front and back materials. I figure I either have to flip the bitmap data in the array or how the material is viewed on on the cube. Some direction either way would be great!!!! package { import away3d.cameras.*; import away3d.containers.*; import away3d.materials.*; import away3d.primitives.*; import away3d.primitives.data.*; import away3d.core.utils.*; import away3d.core.clip.*; import flash.display.*; import flash.events.*; import com.SliceBitmap; public class away3D16 extends Sprite { //engine variables private var scene:Scene3D; private var camera:Camera3D; private var view:View3D; //cube vars private var _cubePosX:Array = new Array(-160, -160, -160, 0, 0, 0, 160, 160, 160); private var _cubePosY:Array = new Array(160, 0, -160, 160, 0, -160, 160, 0, -160); private var _cubeFrontMat:Array = new Array(); private var _cubeBackMat:Array = new Array(); private var _cubeMatData:Array = new Array(); private var _cubes:Array = new Array(); //general vars var _sliceBitmap:SliceBitmap; var numCubes:uint = 9; /** * Constructor */ public function away3D16() { init(); } private function init():void { initEngine(); sliceImage(); } private function initEngine():void { scene = new Scene3D(); //camera = new Camera3D({z:-1000}); camera = new Camera3D(); camera.z = -910; //view = new View3D({scene:scene, camera:camera}); view = new View3D(); view.x = 240; view.y = 240; view.scene = scene; view.camera = camera; //add view to stage addChild(view); } /** * Silce Image */ private function sliceImage():void { _sliceBitmap = new SliceBitmap("images/dart.jpg", 3, 3) _sliceBitmap.addEventListener("doneSlicingImage", doneSlicingImage); } /** * Done Silcing Image */ private function doneSlicingImage(evt:Event):void { trace("Done Slicing Image"); _sliceBitmap.removeEventListener("doneSlicingImage", doneSlicingImage); //copy sliced bitmap to local arrays _cubeFrontMat = _sliceBitmap._bitmapGrid.concat(); _cubeBackMat = _sliceBitmap._bitmapGrid.concat(); initMaterials(); } /** * Initialise the materials */ private function initMaterials():void { for (var i:int=0 ; i<numCubes ; ++i) { var sideMat:ColorMaterial = new ColorMaterial(0x333333); var frontMat:BitmapMaterial = new BitmapMaterial(Cast.bitmap(_cubeFrontMat[i])); var backMat:BitmapMaterial = new BitmapMaterial(Cast.bitmap(_cubeBackMat[i])); var CubeMat:CubeMaterialsData = new CubeMaterialsData(); CubeMat.front = frontMat; CubeMat.back = backMat; CubeMat.bottom = sideMat; CubeMat.top = sideMat; CubeMat.left = sideMat; CubeMat.right = sideMat; _cubeMatData.push(CubeMat); } initObjects(); } /** * Initialise the scene objects */ private function initObjects():void { for (var i:int=0 ; i<numCubes ; ++i) { var cube:Cube = new Cube() cube.cubeMaterials = _cubeMatData[i]; cube.x = _cubePosX[i]; cube.y = _cubePosY[i]; cube.width = 160; cube.height = 160; cube.depth = 20; cube.segmentsW = 5; cube.segmentsH = 5; cube.segmentsD = 5; _cubes.push(cube); scene.addChild(cube); } initListeners(); } /** * Initialise the listeners */ private function initListeners():void { addEventListener(Event.ENTER_FRAME, onEnterFrame); } /** * Navigation and render loop */ private function onEnterFrame( e:Event ):void { _cubes[4].rotationX += 2; view.render(); } }//closes class }//closes package
