Rubix cube icon rotation

Software: Away3D 4.x

Timbo, Newbie
Posted: 28 January 2013 10:59 AM   Total Posts: 1

I have a rubix-like 3d model, with icon on the cube. The problem is, that when you rotate the cube a couple of times, you the text on the icons is upside-down.

What I want is to rotate the icons, accordingly to the rotation of the cube. But I can’t figure out the right formula for the.

Attached is an image which explains the problem. The icons should always face down (like there is gravity).

I’ve tried several things, using scenePosition, inversetransform, calculate angel between Vector3D points, etc. Anyone has an idea how to solve this problem?

var VO:PickingCollisionVO picker.getViewCollision(nativeStage.mouseXnativeStage.mouseYdata.VIEW3D);
   
   if(
VO != null)
   
{
    
var globalPosition1:Vector3D VO.entity.inverseSceneTransform.transformVector(loader.position);
    var 
globalPosition2:Vector3D loader.inverseSceneTransform.transformVector(VO.entity.position);
    var 
globalPosition3:Vector3D loader.inverseSceneTransform.transformVector(VO.entity.scenePosition);
    
    
stageIcon.position loader.inverseSceneTransform.transformVector(VO.entity.scenePosition);
    
    var 
angle:Number Vector3DUtils.getAngle(globalPosition3bol.position);
    
trace(this"angle : " + (angle * (180 Math.PI)));
    
    var 
radians:Number Math.atan2(bol.z-VO.entity.zbol.x-VO.entity.x);
    var 
degrees:Number radians*180/Math.PI;
    
    
VO.entity.rotationX = -degrees;
    
    if(
VO.entity.name.indexOf("icoon") != -1)
    
{
     clickOnMesh
(VO.entity as Mesh);
    
}
   } 

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X