From 56118065f0b11b298aab41356688758d79b75f7b Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 29 Sep 2017 10:21:39 +0800 Subject: [PATCH 1/2] Return Uint8Array in BinaryLoader (keep consistency) --- cocos2d/core/utils/BinaryLoader.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/utils/BinaryLoader.js b/cocos2d/core/utils/BinaryLoader.js index 01e5c6194b..67f1a4ccff 100644 --- a/cocos2d/core/utils/BinaryLoader.js +++ b/cocos2d/core/utils/BinaryLoader.js @@ -50,7 +50,7 @@ cc.loader.loadBinary = function (url, cb) { } else { if (xhr.overrideMimeType) xhr.overrideMimeType("text\/plain; charset=x-user-defined"); xhr.onload = function () { - xhr.readyState === 4 && xhr.status === 200 ? cb(null, xhr.response) : cb(errInfo); + xhr.readyState === 4 && xhr.status === 200 ? cb(null, new Uint8Array(xhr.response)) : cb(errInfo); }; } xhr.send(null); @@ -104,7 +104,7 @@ cc.loader.loadBinarySync = function (url) { return null; } - arrayInfo = req.response; + arrayInfo = new Uint8Array(req.response); } return arrayInfo; }; From f63c49d0cef6cbefef5304a831b22670e6901a2f Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 29 Sep 2017 12:47:23 +0800 Subject: [PATCH 2/2] Fix matrix array not being updated in gl program issue (fix cocos2d/cocos2d-html5/3511) --- cocos2d/shaders/CCGLProgram.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos2d/shaders/CCGLProgram.js b/cocos2d/shaders/CCGLProgram.js index 4e8301d50b..0cf9f4702d 100644 --- a/cocos2d/shaders/CCGLProgram.js +++ b/cocos2d/shaders/CCGLProgram.js @@ -63,7 +63,8 @@ cc.GLProgram = cc.Class.extend(/** @lends cc.GLProgram# */{ updated = true; } else { for (var i = 0; i < args.length; i += 1) { - if (args[i] !== element[i]) { + // Array and Typed Array inner values could be changed, so we must update them + if (args[i] !== element[i] || typeof args[i] === 'object') { element[i] = args[i]; updated = true; }