Another Papervision3D Proximity Grid Example

Here is another experiment in proximity with Papervision3D. This is essentially the exact reverse of the previous example. This time I am using the new Adobe AIR logo by way of a BitmapAssetMaterial. Now the planes are aligned properly unless your mouse gets too close. Happy Thanksgiving!

Actionscript:

  1. import org.papervision3d.scenes.*;
  2. import org.papervision3d.cameras.*;
  3. import org.papervision3d.objects.*;
  4. import org.papervision3d.materials.*;
  5. import caurina.transitions.*;
  6.  
  7. // Create the container sprite
  8. var con:Sprite = new Sprite();
  9. con.x = stage.stageWidth * 0.5 - 250;
  10. con.y = stage.stageHeight * 0.5 + 250;
  11. addChild(con);
  12.  
  13. // Setup the scene
  14. var scene:Scene3D = new Scene3D(con);
  15. var cam:Camera3D = new Camera3D();
  16. cam.zoom = 11;
  17.  
  18. // Create the planes
  19. var pa:Array = new Array();
  20. for(var i:uint=0; i<10; i++)
  21. {
  22.     for(var j:uint=0; j<10; j++)
  23.     {
  24.         var cm:BitmapAssetMaterial = new BitmapAssetMaterial("air");
  25.         cm.oneSide = false;
  26.         var p:Plane = new Plane(cm, 50, 50);
  27.         p.x = j * 50 + 25;
  28.         p.y = i * 50 + 25;
  29.         scene.addChild(p);
  30.         pa.push({pl:p, rotY:Math.random() * 360, rotZ:Math.random() * 360, z:Math.random() * 30000});
  31.         p.rotationY = pa[i].rotY;
  32.         p.rotationZ = pa[i].rotZ;
  33.         p.z = pa[i].z;
  34.     }
  35. }
  36.  
  37. // Create the render loop
  38. addEventListener(Event.ENTER_FRAME, render);
  39.  
  40. function render(e:Event):void
  41. {
  42.     for(var i:uint; i<pa .length; i++)
  43.     {
  44.         if(checkDist(pa[i].pl))
  45.         {
  46.             Tweener.addTween(pa[i].pl, {rotationY:0, rotationZ:0, z:0, time:0.3});
  47.         }
  48.         else
  49.         {
  50.             Tweener.addTween(pa[i].pl, {rotationY:pa[i].rotY, rotationZ:pa[i].rotZ, z:pa[i].z, time:3});
  51.         }
  52.     }
  53.     scene.renderCamera(cam);
  54. }
  55.  
  56. function checkDist(p:Plane):Boolean
  57. {
  58.     var p1:Point = new Point(p.x, p.y);
  59.     var p2:Point = new Point(con.mouseX, -con.mouseY);
  60.     if(Point.distance(p1, p2)> 150)
  61.     {
  62.         return true;
  63.     }
  64.     else return false;
  65. }


flex version:

Flex-App:
http://labs.vizar.de/papergrid/

Source:
http://labs.vizar.de/papergrid/srcview/

Share

0 条评论

留下评论