View3D scaling mysteries

Software: Away3D 4.x

ralphB, Newbie
Posted: 24 September 2015 07:51 PM   Total Posts: 9

Has anyone solved a problem like how to get a View3D instance which is sitting in a traditional 2D swf to scale in size and position correctly, when the swf is loaded into another swf, in which the loader is resized (for example by border drags), and the overall swf is resized by user corner dragging?

If I use stage.scaleMode = StageScaleMode.NO_SCALE then everything works as expected except that the View3D stays at a constant size on the screen, regardless of user resizing actions.  I could change the position and width of the View3D but cannot find a way to tell where symbols on the 2D stage are in the the same frame of reference so I can compute how to scale the View3D.  Apparently localToGlobal() does not work when you use swfloader, btw.

Any experience or suggestions on this topic?  Should I be looking at Stage3DProxy? (And if so, can anyone point me to a getting started tutorial for Stage3DManager and Stage3DProxy?)

Thank you! Ralph

   

ralphB, Newbie
Posted: 25 September 2015 12:01 AM   Total Posts: 9   [ # 1 ]

As always happens… right after I post a question I am totally stuck on, I find the answer…

Apparently the scaleX property of the loader seems to follow whatever scaling is driving the swf.  The View3D x property does follow properly, but its width and height do not.  So the solution I found was:
- Capture the initial View3d width and height at initialization time.
- On a resize event, or simply every frame, force the View3D width and height properties to their values at init, multiplied by the scaleX property of the loader.  In my case the loader is this.parent.parent.
- By using only the scaleX value for both width and height, the aspect ratio stays constant.

   

Missing Socks Co., Newbie
Posted: 22 March 2016 06:44 PM   Total Posts: 3   [ # 2 ]

var _view:View3D = new View3D();
_view.width = 2000;
_view.height = 1520;
addChild(_view);


stage.addEventListener(Event.RESIZE, res);
function res(e:Event):void
{
_view.width = stage.stageWidth;
_view.height = stage.stageWidth * (1520/2000);
}

res(null);

   

Missing Socks Co., Newbie
Posted: 22 March 2016 06:45 PM   Total Posts: 3   [ # 3 ]

Post based on forum payback time.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X