Hello,
I was planning to use Away3D for iPad games but I’ve got low performance on a simple test I made, so I was wondering if I’m doing something wrong and where is this performance issue comming from.
I have a scene with 100 simple cube meshes with color material and this produces a 11-15 fps rate on my iPad2 (iOS 4.3.3 jailbreaked). Here is my code and I have attached screenshots too.
package {
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.geom.Vector3D;
import away3d.cameras.*;
import away3d.containers.View3D;
import away3d.entities.Mesh;
import away3d.materials.ColorMaterial;
import away3d.primitives.CubeGeometry;
import away3d.controllers.HoverController;
import away3d.debug.AwayStats;
[SWF(width=768, height=1024, frameRate=60)]
public class Main extends Sprite
{
private var m_view : View3D;
private var m_hc : HoverController;
public function Main()
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
m_view = new View3D();
m_view.backgroundColor = 0xff303030;
addChild(m_view);
addChild(new AwayStats(m_view));
// create 10x10 colored cubes
for (var y = -50; y < 50; y+=10)
{
for (var x = -50; x < 50; x+=10)
{
var r:int = (x+50)*2;
var g:int = (y+50)*2;
var b:int = 0;
var color : int = 0xff000000 | (r << 16) | (g << 8) | b;
var cube : Mesh = new Mesh(new CubeGeometry(9, 9, 9), new ColorMaterial(color)); cube.positi Vector3D(x, 0, y);
m_view.scene.addChild(cube);
}
}
m_hc = new HoverController(m_view.camera, null, 150, 10, 200);
this.addEventListener(Event.ENTER_FRAME, Update);
}
private function Update(e:Event):void
{
if (m_hc)
{
m_hc.panAngle = mouseX - 768/2;
m_hc.tiltAngle = mouseY - 1024 / 2;
}
m_view.render();
}
}
}
If I use the same geometry and the same material for all cubes I get about 15 fps. I also observed low performance in other situations related to simple action script code from which I would expected no impact on fps.
The PC build has a steady fps (58-59) and my PC isn’t top class (an old DualCore).
I also wonder why on the iPad the memory graphic (pink) goes in stairs (maybe the garbage collector at work) because on PC it is steady.
The alternative is to continue porting my own engine (C++) but I don’t know much of this performance issue are limitation of iPad, how much of the ActionScript and how much of Away3D engine.
Please help me with some advice.
Alex