Papervision 2.0 reaally slow?

I am using papervision 2.0, to create 3 cubes, using the Cube() function, and then putting them all into one displayObject3D instance.

I am rotating this displayObject3D around the x axis; what’s surprising is that it’s soo ■■■■ SLOW!! Even when I set the quality to low, it’s not smooth, but somethings hangs a bit on some angles.

Did anyone face such a problem? And any idea why it’s slow in my case? Maybe it’ll be faster if I move around the camera instead of rotating the entire object?

Thanks

anybody?

how many fps are you getting?

I’m uing away3d instead of papervision but I don’t think moving the camera instead of the object will give you less calculations…

Maybe you’re putting too many polygons on those cubes?

There’s so many things that contribute to performance, you really need to post your code.

Thanks Guys for willing to help. Here is my code. Note that I have skipped all the imports, just to save some room.


   var viewport:Viewport3D = new Viewport3D(0, 0, true, true);
   container.addChild(viewport);
 
   var renderer:BasicRenderEngine = new BasicRenderEngine();
 
   var scene:Scene3D = new Scene3D();
 
   var camera:Camera3D = new Camera3D();
   camera.zoom = 11;
   camera.focus = 100;                 
   book = new DisplayObject3D();
   var scale = 0.7
   var bookWidth = 100;
   var bookHeight = 200;
   var bookThickness = 40;
   var bookAngle = 45;
 
   var currentPage = 1;
   var face = Params.rootPath.pages[currentPage];
 
   var faces = new Object()
   faces[0] = sideImg;
   faces[1] = sideImg;
   faces[2] = backImg;
   faces[3] = rightImg;
   faces[4] = sideImg;
   faces[5] = face;
   var cube1 = createCube(faces, bookThickness, bookWidth, bookHeight, -bookThickness/2,bookWidth/2, 0)
   cube1.rotationZ = bookAngle;
   faces = new Object()
   faces[0] = sideImg;
   faces[1] = sideImg;
   faces[2] = backImg;
   faces[3] = rightImg;
   faces[4] = sideImg;
   faces[5] = face;
 
var cube2 = createCube(faces,bookThickness,bookWidth,bookHeight,bookThickness/2,bookWidth/2,0)
   cube2.rotationZ = -bookAngle;
   faces = new Object()
   faces[0] = sideImg;
   faces[1] = sideImg;
   faces[2] = backImg;
   faces[3] = coverImg;
   faces[4] = sideImg;
   faces[5] = spineImg;
   var cube3 = createCube(faces,1,1,bookHeight,0,-0.5,0)
   cube3.scaleY = bookThickness*Math.sin(bookAngle*Math.PI/180)
   cube3.scaleX = 2*bookThickness*Math.cos(bookAngle*Math.PI/180)
   book.addChild(cube1);
   book.addChild(cube2);
   book.addChild(cube3);
   scene.addChild(book)
 
renderer.renderScene(scene, camera, viewport);
   var rotator = new Sprite()
   rotator.addEventListener(Event.ENTER_FRAME, rotate);
   function rotate(e:Event):void
   {
 
    book.rotationY += 5
    book.rotationX += 1
    book.rotationY = book.rotationY % 360;
    book.rotationX = book.rotationX % 360;
    renderer.renderScene(scene, camera, viewport);
   }
   // Render the 3D scene
 
 
public function createCube(faces,xWidth,zWidth,yWidth,x,y,z)
  {
   var materialList = new Object();
   var displayOb = new DisplayObject3D();
   for(var i=0;i<6;i++) {
    materialList* = new MovieMaterial(faces*)
    materialList*.smooth = true;
    materialList*.animated = true;  
   }
   var materialsList = new MaterialsList({front:materialList[0], back:materialList[1], left:materialList[2], right:materialList[3],top:materialList[4], bottom:materialList[5]});
   var cube = new Cube(materialsList, xWidth, yWidth, zWidth, 2, 2, 2);
   cube.name = "cube"
   displayOb.addChild(cube,"cube");
   cube.x = x
   cube.y = y
   cube.z = z
   return displayOb;
  }

a) you are putting an ENTER_FRAME event on on object you never use (rotator) - you can just as easily add it to stage
b) You aren’t data typing your variables which causes slower performance (var cube:Cube = new Cube(…))
c) you are rotating book, and not the individual cubes - you want that, correct?
d) you are assigning book.rotationY and book.rotationX twice on each enter_frame - why not just do something like “book.rotationY += 5 % 360” - modulus tends to be a slow operation also
f) You create ‘faces’ as an object but then use it like an array (this might not necessarily decrease performance)
g) is your frame rate set high?

The code is generally sloppy (sry, don’t mean to sound like an ***). I’m not sure if it’s all leading to slow performance, but it’s not helping - there might be a major bottle neck I’m missing, but I’m not sure.

[QUOTE=nikefido;2353407]f) You create ‘faces’ as an object but then use it like an array (this might not necessarily decrease performance)[/QUOTE]
If anything that would increase performance.

wow, a compliment from the canadian :wink: this means a lot to me :smiley:

My frame rate is set to 30 fps, and even while having the flash quality set to MEDIUM, it’s still quite slow. I feel the reason is cuz Im rotating book (which consists of several primitive cubes). Can the reason be that these cubes are colliding (overlapping) with each other?

You know what. I think the reason (that just came to my head now), is that the movieclips Im using as materials, contain alpha gradients (on a top layer). I dont know how papervision internally works, but if it doesnt create a bitmap data object of those faces, then that’s most probably what’s causing it to be slow. You guys think that could be the reason?

I’ll try it and let you know. Thanks!!