• entries
21
38
• views
19272

# Orientation Vector

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.



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.

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

There are no comments to display.

## Create an account

Register a new account