Skip to content

Transform geometry positions with a 4x4 transformation matrix.

License

Notifications You must be signed in to change notification settings

wwwtyro/geo-3d-transform-mat4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

geo-3d-transform-mat4

Transforms the positions of a few common geometry position formats by a gl-mat4 matrix.

Supported formats are:

  • Flat arrays [1,2,3,4,5,6]
  • Array of arrays [[1,2,3], [4,5,6]]
  • Array of TypedArrays [new Float32Array([1,2,3]), new Float32Array([4,5,6])]
  • TypedArray new Float32Array([1,2,3,4,5,6])
  • ndarray ndarray(new Float32Array([1,2,3,4,5,6]))

Install

npm install geo-3d-transform-mat4

Example

var mat4 = require('gl-mat4');
var tform = require('geo-3d-transform-mat4');

var positions = [
    [1, 0, 0],
    [0, 1, 0],
    [0, 0, 1]
];

var scale = mat4.create();
mat4.scale(scale, scale, [2,2,2]);

var out = tform(positions, scale);

// out = [
//     [2, 0, 0],
//     [0, 2, 0],
//     [0, 0, 2]
// ]

API

var tform = require('geo-3d-transform-mat4');

tform(positions, matrix4)

Returns a copy of positions that has been transformed by matrix4. The output format will be the same as positions was provided in.

About

Transform geometry positions with a 4x4 transformation matrix.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published