Skip to content

Commit

Permalink
feature: vec3OrthoNormalize does its job without input tangent
Browse files Browse the repository at this point in the history
  • Loading branch information
0b5vr committed Jan 30, 2022
1 parent a7872da commit 6b94628
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/math/vec3/tests/vec3OrthoNormalize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import { vec3OrthoNormalize } from '../vec3OrthoNormalize';
import type { RawVector3 } from '../RawVector3';

describe( 'vec3OrthoNormalize', () => {
it( 'returns a orthogonal tangent, without the input tangent', () => {
const normal: RawVector3 = [ 0.0, 0.0, 5.0 ];
const subject = vec3OrthoNormalize( normal );

expect( subject.normal ).toBeCloseToArray( [ 0.0, 0.0, 1.0 ] );
expect( subject.tangent ).toBeCloseToArray( [ 0.0, 1.0, 0.0 ] );
expect( subject.binormal ).toBeCloseToArray( [ -1.0, 0.0, 0.0 ] );
} );

it( 'returns a orthogonal tangent', () => {
const normal: RawVector3 = [ 0.0, 0.0, 5.0 ];
const tangent: RawVector3 = [ 1.0, 1.0, 1.0 ];
Expand Down
2 changes: 1 addition & 1 deletion src/math/vec3/vec3OrthoNormalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { RawVector3 } from './RawVector3';
*/
export function vec3OrthoNormalize(
normal: RawVector3,
tangent: RawVector3,
tangent: RawVector3 = [ 0.0, 1.0, 0.0 ],
binormal?: RawVector3,
): {
normal: RawVector3,
Expand Down

0 comments on commit 6b94628

Please sign in to comment.