Home>

A library called glMatrix is ​​used for vector operations in javaScript.
Create objects v01 and v02 for 3D vectors as a trial,
I want to calculate the dot product.

However, when executed, all the elements of vectors v01 and v02 will be 0.
I would like to know if there are any points to keep in mind when creating objects for 3D vectors.

Error message

When verified with the Google Chrome developer tools,
Processing with a javaScript file is as follows.

Because the elements of v01 and v02 are 0, the inner product calculation result ans on the 35th line is also 0.

There is no error for vec3 objects, so
I think the glMatrix library is recognized.

In the html header tag, the library is specified as follows.

<script src = "https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.7.1/gl-matrix-min.js"></script>
Supplemental information (FW/tool version etc.)
  • glMatrix 2.7.1
  • Answer # 1

    After reading the documentation,.create ()

      

    Creates a new, empty vec3

    It looks like

    is mentioned.
    If you want to make it based on the value, I think it is .fromValues.

    Since I haven't used it, it's just knowledge of browsing documents.

    If you want to use the library, you should read the entire documentation first.