Re: [away3d] Re: Cube fitting View

2011-11-16 Thread John Brookes
You can get the fov by doing a single render, but..
Just tried it and the above doesn't work for 3.
So don't really know :/

A hcky way would be to do pixel perfect type thang with the default camera.

set the cubes width and depth to the stageWidth, and height to stageHeight
and
set the camera.z to -900-stagewidth/2

That would give you a cube that fills the stage.


On 16 November 2011 15:31, Miroku miroku...@yahoo.it wrote:

 Problem is that camera.fov always returns 0 to me =\

 On 16 Nov, 11:07, John Brookes jbp...@googlemail.com wrote:
  I think its the same. Just replace with camera.fov
 
  eg camera at defualt 0,0,-1000 a plane at 0,0,0
 
  var maxheight:Number = Math.tan((view.camera.fov * 0.5) * Math.PI / 180)
 *
  1000 * 2;
  var maxWidth:Number = maxheight * (stage.stageWidth / stage.stageHeight);
 
  plane = new Plane({material:material, width:maxWidth, height:maxheight,
  yUp:false, bothsides:true});
  scene.addChild(plane);
 
  On 15 November 2011 22:30, Andrea Silvestri 
 andrea.silvestr...@gmail.comwrote:
 
 
 
 
 
 
 
   Any solution for away 3? =\
 
   Il 15/11/2011 23:14, John Brookes ha scritto:
 
ahh no, thats for away 4



Re: [away3d] Re: Cube fitting View

2011-11-15 Thread John Brookes
var maxheight:Number =
Math.tan((PerspectiveLens(view.camera.lens).fieldOfView * 0.5) * Math.PI /
180) * distanceFromCamera * 2;
var maxWidth:Number = maxheight * (view.width / view.height);

remember distance from camera would be the distance to the face you looking
at. Not the objects center.


Re: [away3d] Re: Cube fitting View

2011-11-15 Thread Andrea Silvestri

Thank you for answering, John =)

Since the thing I need is exactly distanceFromCamera you mean I should 
do this:
var distanceFromCamera = cube.width / 
(Math.tan((PerspectiveLens(view.camera.lens).fieldOfView * 0.5) * 
Math.PI / 180) *  2)

?

and then
camera.position = new Vector3D(0,0,distanceFromCamera)
?

Anyway I tried the code you posted but (despite that I imported the 
PerspectiveLens package) I keep getting this error:
Main_VideoCubeAway3D.as, Line 341119: Access of possibly undefined 
property fieldOfView through a reference with static type 
away3d.cameras.lenses:PerspectiveLens.

If it helps I'm using a TargetCamera3D and Away3D version 3


Il 15/11/2011 15:18, John Brookes ha scritto:
var maxheight:Number = 
Math.tan((PerspectiveLens(view.camera.lens).fieldOfView * 0.5) * 
Math.PI / 180) * distanceFromCamera * 2;

var maxWidth:Number = maxheight * (view.width / view.height);

remember distance from camera would be the distance to the face you 
looking at. Not the objects center.


Re: [away3d] Re: Cube fitting View

2011-11-15 Thread John Brookes
ahh no, thats for away 4


Re: [away3d] Re: Cube fitting View

2011-11-15 Thread Andrea Silvestri

Any solution for away 3? =\

Il 15/11/2011 23:14, John Brookes ha scritto:

ahh no, thats for away 4