How am I supposed to use glMatrix 2.3.2 in a HTML project?

611 Views Asked by At

I am doing a HTML/Javascript project and part of it involves using glMatrix. My problem is that I have no idea how it actually implement it and use it.

I tried doing what you'd usually do to use a Javascript file in a HTML page:

<script type="text/javascript" src="src/lib/gl-matrix.js"></script>

The folder 'lib' being where all the files related to glMatrix is stored. The problem is that if I run this file, I get this:

Uncaught ReferenceError: exports is not defined at gl-matrix.js:29

I have not changed anything in the glMatrix code, so the problem is presumably how I'm using it, but the website gives no documentation or anything that would instruct me on how to actually use this.

So how do I use glMatrix in my projects?

The version I'm using is 2.3.2.

1

There are 1 best solutions below

0
On

You are trying to run CommonJS code in the browser, which needs to be prepared by a transpiler first. You can use Webpack for that, or Browserify.