Skip to content

Instantly share code, notes, and snippets.

@mflux
Created September 26, 2014 01:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mflux/13fce63dc307cbdfb68c to your computer and use it in GitHub Desktop.
Save mflux/13fce63dc307cbdfb68c to your computer and use it in GitHub Desktop.
TWO.js center group on objects
function fixGroupToShapes( g ){
var bb = g.getBoundingClientRect();
var cx = bb.width * 0.5 + bb.left;
var cy = bb.height * 0.5 + bb.top;
g.center();
g.translation.x = cx;
g.translation.y = cy;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment