Jump to content
  • Advertisement

unirule

  • entries
    21
  • comments
    38
  • views
    19272

Orientation Vector

Sign in to follow this  
Awoken

1492 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:

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.

Screenshot from 2016-12-31 09-57-48.png
The picture above was generated by the code below.

//orientationVector requires the following:
// position Vector , scale , reference plane normal ( if none provided then one is generated )

var startingOrientationVector = new orientationVector( 
    
  // quickRaycaste requires the following:
  // origin vector , destination vector , minimum length , maximum length , mesh to intersect , return index ( if -1 then all indexes )
  quickRaycaste( 
    quickVector( randomNumber() , randomNumber() , randomNumber() ).normalize().multiplyScalar(11) , 
      sphereCenter , 
      0 , 
      10 , 
      targetGeometryGlobalMesh , 
      0 
  ).point.clone() , 
  editorParameters.unitScale 
); 

var nextOrientationVector = [];

nextOrientationVector.push( startingOrientationVector.inheritFrom( startingOrientationVector.front , 100 , 1 , startingOrientationVector.position );
                           
for( var i=0; i<55; i++){ 
  nextOrientationVector.push( nextOrientationVector[i].inheritFrom( nextOrientationVector[i].front , 100 , 1 , nextOrientationVector[i].position );
}


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.


Screenshot from 2016-12-31 09-56-39.png
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:

nextOrientationVector.push( nextOrientationVector[i].inheritFrom( nextOrientationVector[i].front , 100 , 1 , nextOrientationVector[i].position , startingOrientationVector.plane );

The 

Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!