From dd03abaea6d0e849aaa132dbce5d91098b52181a Mon Sep 17 00:00:00 2001 From: PP Date: Mon, 17 Sep 2018 17:31:02 +0800 Subject: [PATCH] fix meshBuffer realloac vData (#3258) --- cocos2d/core/renderer/webgl/mesh-buffer.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/renderer/webgl/mesh-buffer.js b/cocos2d/core/renderer/webgl/mesh-buffer.js index 4449c711626..95f9f6627a7 100644 --- a/cocos2d/core/renderer/webgl/mesh-buffer.js +++ b/cocos2d/core/renderer/webgl/mesh-buffer.js @@ -101,15 +101,18 @@ let MeshBuffer = cc.Class({ }, _reallocVData (copyOldData) { - let oldVData = this._vData; + let oldVData; + if (this._vData) { + oldVData = new Uint8Array(oldVData.buffer); + } this._vData = new Float32Array(this._initVDataCount); this._uintVData = new Uint32Array(this._vData.buffer); + let newData = new Uint8Array(this._uintVData.buffer); if (oldVData && copyOldData) { - let vData = this._vData; for (let i = 0, l = oldVData.length; i < l; i++) { - vData[i] = oldVData[i]; + newData[i] = oldVData[i]; } }