Scaling the view propotional to the Stage Size. Possible?

Software: Away3D 3.x

Laurid, Newbie
Posted: 22 October 2011 04:46 PM   Total Posts: 5

Hi,
I’m using the latest Away3D 3.6 for FlashPlayer 10 from the svn-trunk.
I’m trying to resize the view to the same size like the stage. What I want is for example when my Stage is 100x100 and I see a cube which is 20px width and I resize the stage to 1000x1000 the cube should be 200px width. I know I can set the stageScale of the whole movie, but for my application this is no choice. I have to set the stageScale to “noscale”, so I first tried to set a RectangleClipping.

var width3D:Number=stage.stageWidth;
var 
height3D:Number=stage.stageHeight;
view.clipping=new RectangleClipping({minX:-(width3D/2),minY:-(height3D/2),maxX:(width3D/2),maxY:(height3D/2)});
view.width3D 2;
view.height3D 2

But this is only cropping the View. It is not resizing.
Afterward I tried to work with the height and width properties of the view.

var width3D:Number=stage.stageWidth;
var 
height3D:Number=stage.stageHeight;
view.width=width3D;
view.height=height3D;
view.width3D 2;
view.height3D 2

But my 3Dscene always gets smaller when I resize my window until I can’t see it anymore.

So I tried a combination with the RecangleClipping

var width3D:Number=stage.stageWidth;
var 
height3D:Number=stage.stageHeight;
view.clipping=new RectangleClipping({minX:-(width3D/2),minY:-(height3D/2),maxX:(width3D/2),maxY:(height3D/2)});
view.width=width3D;
view.height=height3D;
view.width3D 2;
view.height3D 2

Now it is almost working, but It seems like the height Property is sometimes working the other-way-around. When it should get bigger it gets smaller and vice versa.
I also tried the scale properties with no luck. Sometimes it looks like another class resets my settings. Is that possible?
I also tried putting the view in a Sprite Container, with the same strange results.

This is really frustrating! The Problem can’t be so hard to solve. So, what is the best way of doing this?

   

Laurid, Newbie
Posted: 23 October 2011 08:08 AM   Total Posts: 5   [ # 1 ]

Okay after a sleepless night I figured out that this works:

private function onResize(e:Event):void{
var width3D:Number=stage.stageWidth;
var 
height3D:Number=stage.stageHeight;
view.x=width3D/2;
view.y=height3D/2;
var 
aspectRatio:Number=view.width/view.height;
view.width=width3D;
view.height=view.width/aspectRatio;

My Scene has the same size on a stage with 100x100px like on a stage with 1000x1000px.
BUT, when I change the width3D and the height3D to the following:

var width3D:Number=stage.stageWidth/2;
var 
height3D:Number=stage.stageHeight/2

Everything should be half the size of the stage. But the strange thing that happens is that evertime I resize the stage my scene is getting smaller, while the width and height of my view have the correct values. This looks definately like a bug.
The above example ONLY works when using the whole stage for (stageWidth and stageHeight). If you use any other value, like a constant your scene is getting smaller and smaller. This is really anoying. Because I have a Menu on the left and top, so I can’t use the full stage. Does somebody knows a work around on this?

   

kornwaretm, Newbie
Posted: 24 October 2011 06:04 AM   Total Posts: 21   [ # 2 ]

use

_view3D.stage3DProxy.context3D.configureBackBuffer(width3D, height3D, 0, true);

remamber the 3rd parameter is anti aliasing 0 = no no anti aliasing;

   

Laurid, Newbie
Posted: 24 October 2011 09:05 AM   Total Posts: 5   [ # 3 ]

Thanks for your answer, but I’m using Away3D 3.6, so this woun’t work for me.
Thanks anyway.

BTW: In Away3D 4 you can also use the view.width and view.height properties. It does the same thing that you mentonied, but might be a little bit easier.

   

kornwaretm, Newbie
Posted: 24 October 2011 01:28 PM   Total Posts: 21   [ # 4 ]

red face aw sorry.

   

0L4F, Newbie
Posted: 05 April 2012 01:33 PM   Total Posts: 15   [ # 5 ]

I know that this is an old thread, but I ran into this issue as well.

Why not use view.scaleX / view.scaleY?

I solved it like this:

view.width3D >> 1;
view.height3D >> 1;
    
view.scaleX width3D 1000// 1000 being your original scale
view.scaleY view.scaleX
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X