From 55a85d88b6c985cc6a10496c48771a789c5e65c5 Mon Sep 17 00:00:00 2001 From: 06wj <06wj@163.com> Date: Mon, 28 May 2018 11:19:21 +0800 Subject: [PATCH 1/2] fix test toBeEqualish bug when has NaN value --- spec/helpers/spec-helper.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/helpers/spec-helper.js b/spec/helpers/spec-helper.js index 3e515d13..33af8622 100644 --- a/spec/helpers/spec-helper.js +++ b/spec/helpers/spec-helper.js @@ -63,7 +63,9 @@ global.expect = function(e) { */ toBeEqualish: function(a) { - if (typeof(e) == 'number') + if (typeof(e) == 'number'){ + if(isNaN(e) !== isNaN(a)) + expected(e, "to be equalish to", a); if(Math.abs(e - a) >= EPSILON) expected(e, "to be equalish to", a); From 9b70a7d07ee18c9891eb6b14316222b6660355bc Mon Sep 17 00:00:00 2001 From: 06wj <06wj@163.com> Date: Mon, 28 May 2018 11:19:32 +0800 Subject: [PATCH 2/2] fix vec4.random bug --- spec/helpers/spec-helper.js | 3 ++- src/gl-matrix/vec4.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/spec/helpers/spec-helper.js b/spec/helpers/spec-helper.js index 33af8622..9cd88752 100644 --- a/spec/helpers/spec-helper.js +++ b/spec/helpers/spec-helper.js @@ -63,11 +63,12 @@ global.expect = function(e) { */ toBeEqualish: function(a) { - if (typeof(e) == 'number'){ + if (typeof(e) == 'number') { if(isNaN(e) !== isNaN(a)) expected(e, "to be equalish to", a); if(Math.abs(e - a) >= EPSILON) expected(e, "to be equalish to", a); + } if (e.length != a.length) assert.fail(e.length, a.length, "length mismatch"); diff --git a/src/gl-matrix/vec4.js b/src/gl-matrix/vec4.js index c04c6aa9..f743b0e9 100644 --- a/src/gl-matrix/vec4.js +++ b/src/gl-matrix/vec4.js @@ -409,8 +409,8 @@ export function lerp(out, a, b, t) { * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned * @returns {vec4} out */ -export function random(out, vectorScale) { - vectorScale = vectorScale || 1.0; +export function random(out, scale) { + scale = scale || 1.0; // Marsaglia, George. Choosing a Point from the Surface of a // Sphere. Ann. Math. Statist. 43 (1972), no. 2, 645--646.