Render view to BitMap

Software: Away3D 4.x

Romanzo Criminale, Newbie
Posted: 22 July 2013 01:20 AM   Total Posts: 4

Hi everyone,

I’m pretty new with Away3D (using 4.1) and flash and I’m trying to save a bitmap of a basic scene containing a cube.
i’m using the following code but nothing get draw on my bitmap when i want to save it.

var image:BitmapData = new BitmapData(stage.stageWidthstage.stageHeighttrue0x000000);
view.render();
view.renderer.queueSnapshot(image)

//save bitmap image
var jpg:JPGEncoder = new JPGEncoder(100);
var 
byteArray:ByteArray jpg.encode(image);
var 
fileReference:FileReference=new FileReference();
fileReference.save(byteArray"image.jpg"); 

And here is my view settings

//setting the view
view = new View3D();
scene = new Scene3D();
camera = new Camera3D();
view.scene scene;
view.camera camera;
view.camera.= -600;
view.camera.500;
view.camera.lookAt(new Vector3D());
addChild(view);

//adding a cube
cube = new Mesh(new CubeGeometry(cubeWidthcubeHeightcubeDepth111false),  new TextureMaterial(Cast.bitmapTexture(TrinketDiffuse)));
cube.0;
cube.100;
cube.0;
scene.addChild(cube); 

I don’t really see what I am doing wrong so if someone could help me it would be most appreciate!
Thanks!

   

Limouse-Lee, Newbie
Posted: 23 July 2013 04:34 AM   Total Posts: 10   [ # 1 ]

write like this:

view.renderer.queueSnapshot(image);
view.render();

then,save it.you will see what you want;

i found that, after snapshot,we must render() once(one time).
i don’t know why we have to do like that.maybe context3D need to clear the buffer.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X