1.1.1 • Published 3 years ago

@anderpang/matrix4.js v1.1.1

Weekly downloads
5
License
ISC
Repository
-
Last release
3 years ago

Matrix4.js

JavaScript(Typescript) 3D matrix 4x4 library

Installation

$ npm i @anderpang/matrix4.js
 import Matrix4 from "@anderpang/matrix4.js";

or

<script src="./Matrix4.js"></script>

Usage

var projectionMatrix = Matrix4.perspective(45, width/height, 0.1, 100);

var modeMatrix = Matrix4.rotateX(0.1).translate(5, 0, 5).scale(2, 2, 2);

gl.uniformMatrix4fv(loc, false, modeMatrix.data);

METHODS

static identity(): Matrix4;

static translate(tx: number, ty: number, tz: number): Matrix4;

static rotateX(rad: number): Matrix4;

static rotateY(rad: number): Matrix4;

static rotateZ(rad: number): Matrix4;

static scale(sx: number,sy:number,sz:number): Matrix4;

static perspective(fovy:nubmer, aspect:number, n:number, f:number): Matrix4;

static ortho(width:number,height:number,depth:number): Matrix4;

static lookAt(eye:Array<number>, target:Array<number>, up:Array<number>): Matrix4;


constructor(data?: number | Array<number>);

data: Float32Array;

zero():Matrix4;

identity():Matrix4;

copy():Matrix4;

copyFrom(from:Matrix4):Matrix4;

multiply(t:Matrix4):Matrix4;

translate(tx: number, ty: number, tz: number):Matrix4;

rotateX(rad: number):Matrix4;

rotateY(rad: number):Matrix4;

rotateZ(rad: number):Matrix4;

scale(sx: number,sy:number,sz:number):Matrix4;

invert():Matrix4;

transpose():Matrix4;