Check this out:
http://away3d.com/pete/ClosestFace.swf

I'm just making the faces bigger depending on distanceTo(), here's the code,
hope it helps you out

-Pete


package {
 import flash.display.*;
 import flash.events.*;
 import away3d.core.base.*;
 import away3d.core.math.*;
 import away3d.containers.*;
 import away3d.primitives.*;
 import away3d.cameras.*;
 import away3d.core.render.*;
 import away3d.materials.*;
 import away3d.core.utils.*;
 public class ClosestFace extends Sprite {
  var view:View3D;
  var mySphere;
  var myCube;
  var myNull;
  var cubeContainer;
  var face1;
  var face2;
  var face3;
  var face4;
  var face5;
  var face6;

  function ClosestFace() {
   stage.frameRate=30;
   away3dcreate();
   addEventListener(Event.ENTER_FRAME,away3dloop);
  }
  function away3dcreate():void {
   addChild(view=new View3D({x:300, y:200}));
   //
   mySphere=new Sphere({material:new WireColorMaterial()});
   myCube=new Cube({width:250,height:250,depth:250});
   myNull=new Object3D;
   //
   face1=new Sphere({z:150});
   face2=new Sphere({z:-150});
   face3=new Sphere({x:150});
   face4=new Sphere({x:-150});
   face5=new Sphere({y:150});
   face6=new Sphere({y:-150});
   //
   cubeContainer=new ObjectContainer3D;
   cubeContainer.addChildren(myCube,face1,face2,face3,face4,face5,face6);
   //
   view.scene.addChild(mySphere);
   view.scene.addChild(cubeContainer);
  }
  function away3dloop(event:Event):void {
   mySphere.x=600-(mouseX*2);
   mySphere.y=400-(mouseY*2);
   for (var i:int = 1; i< 7; i++){
    myNull.moveTo(this["face"+i].scenePosition.x,
this["face"+i].scenePosition.y, this["face"+i].scenePosition.z);
    var dist=400-(mySphere.distanceTo(this["face"+i])/2);

    this["face"+i].scaleX=(dist)/(this["face"+i].maxX-this["face"+i].minX);
    this["face"+i].scaleY=(dist)/(this["face"+i].maxY-this["face"+i].minY);
    this["face"+i].scaleZ=(dist)/(this["face"+i].maxZ-this["face"+i].minZ);
   }
   view.camera.moveTo(myCube.x,myCube.y,myCube.z);
   view.camera.moveBackward(2500);
   cubeContainer.rotationY+=1;
   cubeContainer.rotationX+=2;
   view.render();
  }
 }
}



On Sun, Dec 7, 2008 at 8:15 PM, cellis <[EMAIL PROTECTED]> wrote:

>
> Hello all,
>
> how could i find the distance to , for instance, the back xy face of a
> cube?




-- 
___________________

Actionscript 3.0 Flash 3D Graphics Engine

HTTP://AWAY3D.COM

Reply via email to