diff --git a/types/gl-matrix/gl-matrix-tests.ts b/types/gl-matrix/gl-matrix-tests.ts index 3a9c3175c8..505bbcbb26 100644 --- a/types/gl-matrix/gl-matrix-tests.ts +++ b/types/gl-matrix/gl-matrix-tests.ts @@ -1,5 +1,5 @@ // common -import { vec2, mat2, mat3, mat4, vec3, vec4, mat2d, quat } from "gl-matrix"; +import { glMatrix, vec2, mat2, mat3, mat4, vec3, vec4, mat2d, quat } from "gl-matrix"; var outVal: number; var outBool: boolean; @@ -350,7 +350,18 @@ outQuat = quat.calculateW(outQuat, quatA); outBool = quat.exactEquals(quatA, quatB); outBool = quat.equals(quatA, quatB); +// glMatrix +outVal = glMatrix.RANDOM(); +outVal = glMatrix.EPSILON; +outBool = glMatrix.ENABLE_SIMD; +outBool = glMatrix.SIMD_AVAILABLE; +outBool = glMatrix.USE_SIMD; +outBool = glMatrix.equals(1, 1); +outBool = glMatrix.equals(1, -1); +outVal = glMatrix.toRadian(10); + // common +import _glMatrix = require('gl-matrix/src/gl-matrix/common'); import _vec2 = require('gl-matrix/src/gl-matrix/vec2'); import _vec3 = require('gl-matrix/src/gl-matrix/vec3'); import _vec4 = require('gl-matrix/src/gl-matrix/vec4'); @@ -699,3 +710,13 @@ outQuat = _quat.fromMat3(outQuat, mat3A); outQuat = _quat.calculateW(outQuat, quatA); outBool = _quat.exactEquals(quatA, quatB); outBool = _quat.equals(quatA, quatB); + +// glMatrix common +outVal = _glMatrix.RANDOM(); +outVal = _glMatrix.EPSILON; +outBool = _glMatrix.ENABLE_SIMD; +outBool = _glMatrix.SIMD_AVAILABLE; +outBool = _glMatrix.USE_SIMD; +outBool = _glMatrix.equals(1, 1); +outBool = _glMatrix.equals(1, -1); +outVal = _glMatrix.toRadian(10); diff --git a/types/gl-matrix/index.d.ts b/types/gl-matrix/index.d.ts index 1e6d310ed6..d39496e20d 100644 --- a/types/gl-matrix/index.d.ts +++ b/types/gl-matrix/index.d.ts @@ -1,10 +1,49 @@ -// Type definitions for gl-matrix 2.2.2 +// Type definitions for gl-matrix 2.3.2 // Project: https://github.com/toji/gl-matrix // Definitions by: Mattijs Kneppers , based on definitions by Tat +// Nikolay Babanov // Austin Martin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module 'gl-matrix' { + // Global Utilities + export class glMatrix { + // Configuration constants + public static EPSILON: number; + public static ARRAY_TYPE: any; + public static RANDOM(): number; + public static ENABLE_SIMD: boolean; + + // Compatibility detection + public static SIMD_AVAILABLE: boolean; + public static USE_SIMD: boolean; + + /** + * Sets the type of array used when creating new vectors and matrices + * + * @param {any} type - Array type, such as Float32Array or Array + */ + public static setMatrixArrayType(type: any): void; + + /** + * Convert Degree To Radian + * + * @param {number} a - Angle in Degrees + */ + public static toRadian(a: number): number; + + /** + * Tests whether or not the arguments have approximately the same value, within an absolute + * or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less + * than or equal to 1.0, and a relative tolerance is used for larger values) + * + * @param {number} a - The first number to test. + * @param {number} b - The second number to test. + * @returns {boolean} True if the numbers are approximately equal, false otherwise. + */ + public static equals(a: number, b: number): boolean; + } + // vec2 export class vec2 extends Float32Array { private typeVec2: number; @@ -3057,6 +3096,11 @@ declare module 'gl-matrix' { } } +declare module 'gl-matrix/src/gl-matrix/common' { + import { glMatrix } from 'gl-matrix'; + export = glMatrix; +} + declare module 'gl-matrix/src/gl-matrix/vec2' { import { vec2 } from 'gl-matrix'; export = vec2;