function Execute() |
Top Previous Next |
Execute function is called when all parameters on the stack have been processed successfully. After the Execute() function the system will call ModelBuilder( lod ) ( if the function exists within the script )
Example:
/* Note: We are running as a command so this object is a BK_CommandScriptable SetRefFrame(pos,xDir,yDir); function is part of the BK_DataScriptable interface, the command will route to the underlining BK_DataScriptable object the function call */
function Execute() { var pos = this.GetPoint( 0 ); var vec = this.GetNormal( 0 );
if( vec ) { var eps = 1.0e-6; var yDir = new Vector3d( 0,0,1.0 ); // up vector var xDir = yDir.cross_product(vec);
if( xDir.length()< eps ) //normal and z vector are parallel { xDir = new Vector3d( 1.0,0,0 ); yDir = new Vector3d( 0.0,1.0,0 ); }else { xDir = xDir.unit_vector(); yDir = vec.cross_product(xDir); } this.SetRefFrame(pos,xDir,yDir); }else this.SetRefFrame(pos,new Vector3d(1,0,0),new Vector3d(0,1,0)); }
|