Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I include gl-matrix?

What I did:

Downloaded master branch from here: https://github.com/toji/gl-matrix Put src folder into my project's folder. Included gl-matrix-manifest.js from there. Tried this:

var mvMatrix = mat4.create();

Result:

var mvMatrix = mat4.create();
ReferenceError: mat4 is not defined

Okay, let's indlude mat4 directly. Included. Result:

var out = new GLMAT_ARRAY_TYPE(16);
ReferenceError: GLMAT_ARRAY_TYPE is not defined

Okay, maybe it needs common.js:

var x = axis[0], y = axis[1], z = axis[2],
TypeError: axis is undefined

WTF, included all other files from src folder (common, vectors,matrices,quat):

var x = axis[0], y = axis[1], z = axis[2],
TypeError: axis is undefined

(same)

How do I include propertly? In particular I need mat4 and vec4.

like image 827
Dmitry Avatar asked Apr 10 '13 16:04

Dmitry


4 Answers

Once the source is specified correctly, I still couldn't directly call mat4.

I had to type "glMatrix.mat4" instead.

like image 139
Alon Granot Avatar answered Nov 18 '22 00:11

Alon Granot


  1. Download from here
  2. Extract and take gl-matrix-min.js
  3. In your index.html file <script src="gl-matrix-min.js"></script>
  4. Now try var mvMatrix = glMatrix.mat4.create();
like image 22
MD SHAYON Avatar answered Sep 28 '22 23:09

MD SHAYON


Just include /dist/gl-matrix-min.js or /dist/gl-matrix.js :)

like image 7
lukyer Avatar answered Nov 18 '22 01:11

lukyer


Add this cdn link in head

<script src="https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix-min.js"
        integrity="sha512-zhHQR0/H5SEBL3Wn6yYSaTTZej12z0hVZKOv3TwCUXT1z5qeqGcXJLLrbERYRScEDDpYIJhPC1fk31gqR783iQ=="
        crossorigin="anonymous" defer>
</script>
like image 3
Zuhair Naqi Avatar answered Nov 18 '22 02:11

Zuhair Naqi