1

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

FF84
  • 21
  • 3
  • Does this answer your question? [gl-matrix is not included properly in webgl application](https://stackoverflow.com/questions/66147508/gl-matrix-is-not-included-properly-in-webgl-application). Otherwise check the network tab to see if the file is actually found. – LJᛃ Feb 25 '21 at 00:39
  • Did you ever find your answer? – Rylan Schaeffer Jan 19 '22 at 22:08
  • I tried adding – Rylan Schaeffer Jan 19 '22 at 22:13

2 Answers2

0

see this:https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix-min.js I think you should include this file which contain mat4 object.

Muhammad Dyas Yaskur
  • 6,914
  • 10
  • 48
  • 73
  • I tried adding ` – Rylan Schaeffer Jan 19 '22 at 22:13
0

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:

enter image description here

slexov
  • 59
  • 1
  • 7