matter-js: decomp.Polygon is not a constructor

When I’m using Bodies.fromVertices, I receive this error:

Uncaught TypeError: decomp.Polygon is not a constructor at Object.n.fromVertices (matter.min.js:49)

I’ve already included decomp.min.js at index.html:

<script src="js/matterjs/decomp.min.js" type="text/javascript"></script>
  <script src="js/matterjs/matter.min.js"></script>

I’m using this code:

Bodies.fromVertices(0, 0, [], {
    isStatic: true
});

What is wrong?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (5 by maintainers)

Most upvoted comments

@Chinafreak the version of Matter.js in the zip file you uploaded above is really old, it’s version 0.10.0. You need 0.13.0. You said you had the latest version from the build folder here, but that is not what is in your zip file, so I think something got mixed up somewhere.

Put the proper version in and you won’t get this error.