# Papervision 2.0 reaally slow?

**URL:** https://forum.kirupa.com/t/papervision-2-0-reaally-slow/264084
**Category:** Uncategorized
**Created:** [June 23, 2008, 2:07am UTC](https://forum.kirupa.com/t/papervision-2-0-reaally-slow/264084 "2008-06-23T02:07:09Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Ayman](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Ayman](https://forum.kirupa.com/u/Ayman)
#### Post date: [June 23, 2008, 2:07am UTC](https://forum.kirupa.com/t/papervision-2-0-reaally-slow/264084/1 "2008-06-23T02:07:09Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Ayman](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Ayman](https://forum.kirupa.com/u/Ayman)
#### Post date: [July 2, 2008, 9:56pm UTC](https://forum.kirupa.com/t/papervision-2-0-reaally-slow/264084/2 "2008-07-02T21:56:14Z")

</div>

anybody?

---

<div class="post-metadata">

### Author: ![Pier25](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@Pier25](https://forum.kirupa.com/u/Pier25)
#### Post date: [July 2, 2008, 10:05pm UTC](https://forum.kirupa.com/t/papervision-2-0-reaally-slow/264084/3 "2008-07-02T22:05:31Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![Anogar](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@Anogar](https://forum.kirupa.com/u/Anogar)
#### Post date: [July 2, 2008, 10:59pm UTC](https://forum.kirupa.com/t/papervision-2-0-reaally-slow/264084/4 "2008-07-02T22:59:20Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Ayman](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Ayman](https://forum.kirupa.com/u/Ayman)
#### Post date: [July 3, 2008, 11:40am UTC](https://forum.kirupa.com/t/papervision-2-0-reaally-slow/264084/5 "2008-07-03T11:40:15Z")

</div>

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

```auto

   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;
  }

```

---

<div class="post-metadata">

### Author: ![nikefido](https://avatars.discourse-cdn.com/v4/letter/n/ed8c4c/32.png) [@nikefido](https://forum.kirupa.com/u/nikefido)
#### Post date: [July 4, 2008, 12:59am UTC](https://forum.kirupa.com/t/papervision-2-0-reaally-slow/264084/6 "2008-07-04T00:59:55Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)
#### Post date: [July 4, 2008, 1:26am UTC](https://forum.kirupa.com/t/papervision-2-0-reaally-slow/264084/7 "2008-07-04T01:26:18Z")

</div>

[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.

---

<div class="post-metadata">

### Author: ![Ayman](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Ayman](https://forum.kirupa.com/u/Ayman)
#### Post date: [July 4, 2008, 7:16am UTC](https://forum.kirupa.com/t/papervision-2-0-reaally-slow/264084/8 "2008-07-04T07:16:32Z")

</div>

wow, a compliment from the canadian 😉 this means a lot to me 😃

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!!
