From d022534a71572148357b37c8e4b9b8ec4d8b5f37 Mon Sep 17 00:00:00 2001 From: Nikolay Babanov Date: Sun, 20 Aug 2017 12:49:27 +0300 Subject: [PATCH 1/2] Added glMatrix utilities definition --- types/gl-matrix/gl-matrix-tests.ts | 23 ++++++++++++++- types/gl-matrix/index.d.ts | 46 +++++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/types/gl-matrix/gl-matrix-tests.ts b/types/gl-matrix/gl-matrix-tests.ts index 3642cca521..d758dad739 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; @@ -349,7 +349,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'); @@ -697,3 +708,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 89f28934b8..87636056b2 100644 --- a/types/gl-matrix/index.d.ts +++ b/types/gl-matrix/index.d.ts @@ -1,9 +1,48 @@ -// 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 +// Definitions by: Nikolay Babanov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module 'gl-matrix' { + // Global Utilities + export class glMatrix { + // Configuration constants + static EPSILON: number; + static ARRAY_TYPE: any; + static RANDOM(): number; + static ENABLE_SIMD: boolean; + + // Compatibility detection + static SIMD_AVAILABLE: boolean; + 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 + */ + static setMatrixArrayType(type: any): void; + + /** + * Convert Degree To Radian + * + * @param {number} a - Angle in Degrees + */ + 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. + */ + static equals(a: number, b: number): boolean; + } + // vec2 export class vec2 extends Float32Array { private typeVec2: number; @@ -3045,6 +3084,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; From e11b3fc131e9064d915d89e17aa61bc456b0bb2c Mon Sep 17 00:00:00 2001 From: Nikolay Babanov Date: Sun, 20 Aug 2017 13:08:33 +0300 Subject: [PATCH 2/2] Fixed definitions header --- types/gl-matrix/index.d.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/types/gl-matrix/index.d.ts b/types/gl-matrix/index.d.ts index 87636056b2..a9ff87b9a3 100644 --- a/types/gl-matrix/index.d.ts +++ b/types/gl-matrix/index.d.ts @@ -1,35 +1,35 @@ // Type definitions for gl-matrix 2.3.2 // Project: https://github.com/toji/gl-matrix // Definitions by: Mattijs Kneppers , based on definitions by Tat -// Definitions by: Nikolay Babanov +// Nikolay Babanov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module 'gl-matrix' { // Global Utilities export class glMatrix { // Configuration constants - static EPSILON: number; - static ARRAY_TYPE: any; - static RANDOM(): number; - static ENABLE_SIMD: boolean; + public static EPSILON: number; + public static ARRAY_TYPE: any; + public static RANDOM(): number; + public static ENABLE_SIMD: boolean; // Compatibility detection - static SIMD_AVAILABLE: boolean; - static USE_SIMD: boolean; + 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 */ - static setMatrixArrayType(type: any): void; + public static setMatrixArrayType(type: any): void; /** * Convert Degree To Radian * * @param {number} a - Angle in Degrees */ - static toRadian(a: number): number; + public static toRadian(a: number): number; /** * Tests whether or not the arguments have approximately the same value, within an absolute @@ -40,7 +40,7 @@ declare module 'gl-matrix' { * @param {number} b - The second number to test. * @returns {boolean} True if the numbers are approximately equal, false otherwise. */ - static equals(a: number, b: number): boolean; + public static equals(a: number, b: number): boolean; } // vec2