|
jscamposcr, Newbie
Posted: 10 July 2012 05:30 PM Total Posts: 20
Hi guys,
This is the situation, im loading an object and placing it in the stage and when I click on it I want to animate the camera to zoom into the object but i cant get the position of it all I get is 0,0,0, I have used scenePosition, position, x, y, z and all i get is 0…, does Away3D give the pivot point of everything as Vector3D(0,0,0)? if so how can I get the actual position of the object so I can move the camera to it?
Thanks!
Jose Campos
|
Richard Olsson, Administrator
Posted: 11 July 2012 07:39 AM Total Posts: 1192
[ # 1 ]
Are you sure the position isn’t 0,0,0 though? What are you expecting the position to be?
If you use scenePosition, and that returns 0,0,0, that means that the object’s pivot is actually in the origin of the scene coordinate system (i.e. “the center” of the scene.) If the geometry still appears to be offset, that’s probably because of how the model was created. You might be able to verify an issue like that by querying the bounds property of the mesh (the minimums should be roughly equivalent in magnitude to the maximums.)
Note that the camera starts at 0,0,-1000 by default.
|
jscamposcr, Newbie
Posted: 11 July 2012 07:29 PM Total Posts: 20
[ # 2 ]
Yeah that is what I suspected but now my question is, is there a way to center the pivot into the object bounds? or the solution of this problem is in the 3D modeler?
|
Richard Olsson, Administrator
Posted: 11 July 2012 07:38 PM Total Posts: 1192
[ # 3 ]
You can use the MeshHelper.recenter() function, but if you are sure that the problem is related to the center of the geometry being in the wrong position, I would definitely take that up with the modeler and have them change that once and for all, instead of having every user’s machine change it at runtime.
|
jscamposcr, Newbie
Posted: 11 July 2012 07:43 PM Total Posts: 20
[ # 4 ]
Yeah I think I will move it up to the developer but just out of curiosity, what it did is that it center the object into the pivot, is there a way to center the pivot in the object?
|
Richard Olsson, Administrator
Posted: 11 July 2012 07:49 PM Total Posts: 1192
[ # 5 ]
No, but you should be able to implement that yourself by doing exactly what MeshHelper.recenter() does, but with an additional translation on X, Y, and Z the opposite amount that the applyPosition() gets invoked with.
|
jscamposcr, Newbie
Posted: 11 July 2012 07:51 PM Total Posts: 20
[ # 6 ]
Yeah I already start to do that, thanks!
|