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!

[AS]import org.papervision3d.scenes.*;
import org.papervision3d.cameras.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
import caurina.transitions.*;

// Create the container sprite
var con:Sprite = new Sprite();
con.x = stage.stageWidth * 0.5 – 250;
con.y = stage.stageHeight * 0.5 + 250;
addChild(con);

// Setup the scene
var scene:Scene3D = new Scene3D(con);
var cam:Camera3D = new Camera3D();
cam.zoom = 11;

// Create the planes
var pa:Array = new Array();
for(var i:uint=0; i<10; i++)
{
for(var j:uint=0; j<10; j++)
{
var cm:BitmapAssetMaterial = new BitmapAssetMaterial(“air”);
cm.oneSide = false;
var p:Plane = new Plane(cm, 50, 50);
p.x = j * 50 + 25;
p.y = i * 50 + 25;
scene.addChild(p);
pa.push({pl:p, rotY:Math.random() * 360, rotZ:Math.random() * 360, z:Math.random() * 30000});
p.rotationY = pa[i].rotY;
p.rotationZ = pa[i].rotZ;
p.z = pa[i].z;
}
}

// Create the render loop
addEventListener(Event.ENTER_FRAME, render);

function render(e:Event):void
{
for(var i:uint; i {
if(checkDist(pa[i].pl))
{
Tweener.addTween(pa[i].pl, {rotationY:0, rotationZ:0, z:0, time:0.3});
}
else
{
Tweener.addTween(pa[i].pl, {rotationY:pa[i].rotY, rotationZ:pa[i].rotZ, z:pa[i].z, time:3});
}
}
scene.renderCamera(cam);
}

function checkDist(p:Plane):Boolean
{
var p1:Point = new Point(p.x, p.y);
var p2:Point = new Point(con.mouseX, -con.mouseY);
if(Point.distance(p1, p2) > 150)
{
return true;
}
else return false;
}

[/as]


Commentary

  1. Ben says:

    very nice !

  2. Nice one fellow…
    When can we expect to see yet another great tutorial from you?

    Happy Thanks Giving from little Denmark

  3. Rémi says:

    Can’t you get the good mouseX value of an rotated scene ?

  4. Zeh says:

    Incredible stuff, Lee. Thanks for sharing with us this and the previous example.

  5. Keith Peters says:

    Needs rotation.

    … and flames.

    yeah. flames.

    :)

  6. KL says:

    Thats Mint.

  7. Boris says:

    Hi Lee,
    incredible stuff again Lee, thumbs up – but every time when to rebuilt your demos with flex builder i got an huge amount of errors – would it be possible to rebuilt this code in flex

  8. Boris says:

    Hi Lee,
    i’ve rebuilt your example with flex – check it out here

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

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

  9. Jonathan says:

    Hiya Lee,

    Thanks for the example.
    I have a little problem when i test the movie, i get the following error:

    Papervision3D Beta RC1.1 (18.06.07)

    DisplayObject3D: null

    The bitmap i’m using is dispalyed correctly only once, the rest are just bigger versions masked under the planes, any explanation?

    thanks in advance.

  10. Jonathan says:

    Hiya Lee,

    I figured out the problem!
    i took the following code out of the for loop:

    var cm:BitmapAssetMaterial = new BitmapAssetMaterial(“air”);
    cm.oneSide = false;

    and now it works fine!

  11. Rhye says:

    simple and nice, thanks for the example

  12. fadi says:

    great work, I tried it and it worked fine except that the pictures are shown blurry and broken. is there any thing i forgot to do???

  13. Stan says:

    I’m new to playing with code. Would I just copy and past the above code. Changed bitmap image and it should work???

  14. dual says:

    Hi many tx for your great tutorials!!
    I want to use spiral_carousel
    but i would like to had a picture in the middle of the stage, but i dont want this picture rotate when the mouse move, i want the menu rotate around the picture and when the menu goes back to the image the menu is mask by the picture. Do u have any idea on how i can do that…
    thx by advance
    dual

  15. Can anyone post the .fla for this so I can dissect it? I am trying to take some 3D letterforms and ad a simple mouse sensitive three-dimensional type treatments, anyone seen anything like that?

    Example: http://theovenreinvented.com/

    CLICK ON EXPLORE, I just want to make some 3D type elements move like this. Thoughts?

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

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

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

Leave a Comment