• entries
21
39
• views
18702

# Orientation Vector

1399 views

The past couple weeks I've been working on a custom class which I call an Ovector, or Orientation Vector. It's builds off of the THREE.js Vector3() class.

With the Ovector Class I can identify any three dimensional position in the scene, and then orientate it by giving it a direction to face, and an up axis so it orientates itself accordingly. The beauty of this class is that it has an internal InheritFrom function that acts a lot like lego blocks. Each new Ovector builds off of a previous Ovector.

The inheritFrom function asks for the following:[code=js:1]inheritFrom( x , distance , rotation , F1 , F2 , plane )// x: is the direction GP vector for the next position// F1: is the origin GP vector for the next pointAt vector// F2: is the direction GP vecotr for the next pointAt vector// this.position and x draw a line, so do F1 and F2.
In the following pictures each Ovector is displayed with Arrows, Blue for Up, Red for Front, White for Right.

The picture above was generated by the code below.[code=js:1]var vv = new Ovector( $m.rO($m.v( $m.rN() ,$m.rN() , $m.rN() ).normalize().multiplyScalar(11) ,$m.v() , 0 , 10 , TGglobalMesh , 0 ).point.clone() , editorParameters.unitScale /*, undefined , zz */ );var ww = vv.inheritFrom( vv.up , 50 , 0 , vv.front , vv.topFront , vv.normal );var yy = []; yy[0] = ww.inheritFrom( ww.front , 100 , 0 , ww.position , ww.front );for( var i=1; i<55; i++){ yy = yy[i-1].inheritFrom( yy[i-1].front , 100 , (i*i /100)+1 , yy[i-1].position , yy[i-1].front );}
The newly created Ovectors do not inherit an orientation Plane to align themselves to, so they align to the surface to of the sphere instead.

In the picture above the same Ovectors are given a plane which to fix themselves to.
All that is added to the code is the following:[code=js:8] yy = yy[i-1].inheritFrom( yy[i-1].front , 100 , (i*i /100)+1 , yy[i-1].position , yy[i-1].front , vv.plane );
This custom class will greatly speed up my dynamic Asset creating component and will also make it easy to construct stuff.

There are no comments to display.

## Create an account

Register a new account