From d07985cdd5a351b30417bb4a4c4deb5a4cbea7a0 Mon Sep 17 00:00:00 2001 From: ggetz Date: Mon, 30 Apr 2018 10:28:35 -0400 Subject: [PATCH 1/3] Limit replacing variable names in shader --- Source/Scene/ModelUtility.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Source/Scene/ModelUtility.js b/Source/Scene/ModelUtility.js index 4b5384773e7f..fd2b5858dccb 100644 --- a/Source/Scene/ModelUtility.js +++ b/Source/Scene/ModelUtility.js @@ -167,9 +167,18 @@ define([ } }; + function regexIndexOf(text, regex, i) { + var indexInSuffix = text.slice(i).search(regex); + return indexInSuffix < 0 ? indexInSuffix : indexInSuffix + i; + } + function replaceAllButFirstInString(string, find, replace) { - var index = string.indexOf(find); - return string.replace(new RegExp(find, 'g'), function(match, offset) { + // Limit search to strings that are not a subset of other tokens. + find += '(?![a-zA-Z_$])'; + find = new RegExp(find, 'g'); + + var index = regexIndexOf(string, find, 0); + return string.replace(find, function(match, offset) { return index === offset ? match : replace; }); } From 9a74dcd0c420c68f1fb3b78fec7d0118e4ba8756 Mon Sep 17 00:00:00 2001 From: ggetz Date: Mon, 30 Apr 2018 10:33:04 -0400 Subject: [PATCH 2/3] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 71951006b6d7..2e842fd16947 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -54,6 +54,7 @@ Change Log * Fixed a bug causing Cesium 3D Tilesets to not clip properly when tiles were unloaded and reloaded. [#6484](https://github.com/AnalyticalGraphicsInc/cesium/issues/6484) * Improved rendering of glTF models that don't contain normals with a temporary unlit shader workaround. [#6501](https://github.com/AnalyticalGraphicsInc/cesium/pull/6501) * Fixed rendering of glTF models with emissive-only materials. [#6501](https://github.com/AnalyticalGraphicsInc/cesium/pull/6501) +* Fixed a bug in shader modification for glTF 1.0 quantized attributes and Draco quantized attributes. [#6523](https://github.com/AnalyticalGraphicsInc/cesium/pull/6523) ### 1.44 - 2018-04-02 From 39f97f03b8b2faaeae0ac723d1af6f1308df37d2 Mon Sep 17 00:00:00 2001 From: ggetz Date: Mon, 30 Apr 2018 12:04:30 -0400 Subject: [PATCH 3/3] Fix regex expression --- Source/Scene/ModelUtility.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Source/Scene/ModelUtility.js b/Source/Scene/ModelUtility.js index fd2b5858dccb..9e7524ef3f05 100644 --- a/Source/Scene/ModelUtility.js +++ b/Source/Scene/ModelUtility.js @@ -167,17 +167,12 @@ define([ } }; - function regexIndexOf(text, regex, i) { - var indexInSuffix = text.slice(i).search(regex); - return indexInSuffix < 0 ? indexInSuffix : indexInSuffix + i; - } - function replaceAllButFirstInString(string, find, replace) { // Limit search to strings that are not a subset of other tokens. - find += '(?![a-zA-Z_$])'; + find += '(?!\\w)'; find = new RegExp(find, 'g'); - var index = regexIndexOf(string, find, 0); + var index = string.search(find); return string.replace(find, function(match, offset) { return index === offset ? match : replace; });