Sprite3D Registration/Pivot Point code sharing

Software: Away3D 4.x

Avatar
SharpEdge, Member
Posted: 03 September 2013 10:47 AM   Total Posts: 94

Hi i would like to share the code to edit the pivot of a sprite3D
Add this function to Sprite3D class:

private var _regX : Number = .5;
  private var 
_regY : Number = .5;

public function 
moveRegistration(x:Number, y:Number):void
  {
   x 
= Math.max(0, Math.min(1, x)) - .5;
   
y = Math.max(0, Math.min(1, y)) - .5;
   
   if(
_regX == x && _regY == y) return;
   
   
_geometry.updateVertexData(Vector.<Number>([-.5 - x, .5 + y, .0, .5 - x, .5 + y, .0, .5 - x, -.5 + y, .0, -.5 - x, -.5 + y, .0]));
  
} 

Usage:
x and y must be in the range 0-1
0,0 is the top left corner
1,1 is the bottom right corner

   

John Brookes, Moderator
Posted: 03 September 2013 11:33 AM   Total Posts: 732   [ # 1 ]

Or
sprite.pivotPoint = new Vector3D(100,0,0)

   

Avatar
SharpEdge, Member
Posted: 03 September 2013 12:43 PM   Total Posts: 94   [ # 2 ]

oh…really it’s so easy? i thought that it wouldn’t work…

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X