Skip to content

wwwtyro/geo-center

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

geo-center

Centers vertices around a point.

Demo

Install

npm install geo-center

Example

var dragon = require('stanford-dragon/3')
var center = require('geo-center')

dragon.positions = center(dragon.positions, {
  center: [0,0,0]
})

API

var center = require('geo-center')

var centeredPositions = center(positions, opts)

Returns a copy of positions centered around opts.center.

positions is the vertex array for your mesh. It can be any of:

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

opts is an object that can have the following properties:

  • center is the point you want your mesh centered upon. Defaults to [0,0,0].

About

Centers vertices around a point.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published