Hi, I downloaded toji-gl-matrix-21b745f.
I copied the file dist/gl-matrix-min.js inside the web-root folder.
In index.html i have:
<script src="gl-matrix-min.js"></script>
<script src="main.js" defer></script>
And inside in main.js i use:
const matrix = mat4.create();
Result is: ReferenceError: mat4 is not defined
I already tried glMatrix.mat4 but result is the same.
I don't understand the error. Can someone help me. Thx in advance
Destructuring only gives you objects but no methods in VS Code intellisense.
I downloaded the source files rather then the dist files, put them in a folder, and imported from the index.js file like:
import { mat2, mat2d, mat3, mat4, quat, quat2, vec2, vec3, vec4, } from "./index.js";
These source files are large so you will want to switch out for "minified" version in production, switch the above for this then:
import "./gl-matrix-min.js";
const { mat2, mat2d, mat4, mat3, quat, quat2, vec2, vec3, vec4 } = glMatrix;
Full code completion hints:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With