avocado-old/packages/physics/index.js
2019-04-12 23:51:40 -05:00

35 lines
705 B
JavaScript

export {BodyView} from './body-view';
import {PolygonShape} from './polygon';
export {PolygonShape};
import {CircleShape} from './circle';
export {CircleShape};
import {RectangleShape} from './rectangle';
export {RectangleShape};
import {ShapeList} from './list';
export {ShapeList};
export {ShapeView} from './shape-view';
export function shapeFromJSON(json) {
let shape;
switch (json.type) {
case 'circle':
shape = new CircleShape();
break;
case 'list':
shape = new ShapeList();
break;
case 'polygon':
shape = new PolygonShape();
break;
case 'rectangle':
shape = new RectangleShape();
break;
}
return shape.fromJSON(json);
}