Unproject with ortographical lens and view not square

Software: Away3D 4.x

AfKun, Newbie
Posted: 25 April 2013 03:53 PM   Total Posts: 4

Hi,

I’ve some issues with unproject method. Here the code :

view.width 800;
view.height 580;
view.camera = new Camera3D(new OrthographicalLens(_projectionHeight));
[...]
trident
.position view.camera.unproject(-1, -1);
view.scene.addChild(trident); 

I think the problem comes from the fact that my view isn’t square. Does someone knows how to overpass this?

Thank you!

(Sorry english isn’t my native language..)

   

John Brookes, Moderator
Posted: 27 April 2013 10:01 AM   Total Posts: 732   [ # 1 ]

Should be fixed in the DEV branch
https://github.com/away3d/away3d-core-fp11/tree/dev

   

AfKun, Newbie
Posted: 29 April 2013 03:21 PM   Total Posts: 4   [ # 2 ]

Sorry but it still doesn’t work..
the trident doesn’t appear on the upper left corner of my window stage.

Beside, when I project the coordinates of the trident they are not correct :

rect = new Rect();
projection view.camera.project(trident.position)
rect.projection.x
rect
.projection.

the rectangle and the trident do not have the same position.

What am I doing wrong?

thanks for your help!

   

John Brookes, Moderator
Posted: 29 April 2013 05:37 PM   Total Posts: 732   [ # 3 ]

If your view postion is not 0,0 you will need to add it to the result of the projection.

eg

view.40;
view.60;
//...

var pos:vector3D view.project(myMesh.scenePosition);
myRect.pos.view.x;
myRect.pos.view.y

For unproject

eg

//place mesh at mouse location 1000 units into the screen)
myMesh.position view.unproject(view.mouseXview.mouseY1000)

//or normalised screen space TOP LEFT
myMesh.position view.camera.unproject(-1, -11000); 
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X