From 144752870648a275bd8b9039b0e3e0acec7b6889 Mon Sep 17 00:00:00 2001 From: Peter Date: Sat, 24 Dec 2016 11:59:09 +0800 Subject: [PATCH 1/3] optimizer performance when normal and tangent are not necessory --- Source/Core/RectangleGeometry.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Source/Core/RectangleGeometry.js b/Source/Core/RectangleGeometry.js index f69cd251fe5c..179a258763ba 100644 --- a/Source/Core/RectangleGeometry.js +++ b/Source/Core/RectangleGeometry.js @@ -108,12 +108,13 @@ define([ var binormal = binormalScratch; var tangent = tangentScratch; var normal = normalScratch; - for (var i = 0; i < length; i += 3) { - var p = Cartesian3.fromArray(positions, i, positionScratch); - var attrIndex1 = attrIndex + 1; - var attrIndex2 = attrIndex + 2; - if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.binormal) { + if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.binormal) { + for (var i = 0; i < length; i += 3) { + var p = Cartesian3.fromArray(positions, i, positionScratch); + var attrIndex1 = attrIndex + 1; + var attrIndex2 = attrIndex + 2; + normal = ellipsoid.geodeticSurfaceNormal(p, normal); if (vertexFormat.tangent || vertexFormat.binormal) { Cartesian3.cross(Cartesian3.UNIT_Z, normal, tangent); @@ -140,8 +141,9 @@ define([ binormals[attrIndex1] = binormal.y; binormals[attrIndex2] = binormal.z; } + + attrIndex += 3; } - attrIndex += 3; } return createAttributes(vertexFormat, { positions : positions, From 27cc5d97d66a2939893ef9eadbd58235a6ed30df Mon Sep 17 00:00:00 2001 From: Peter Date: Sat, 24 Dec 2016 13:56:43 +0800 Subject: [PATCH 2/3] optimize performance when normal and tangent are not necessary --- Source/Core/RectangleGeometry.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Core/RectangleGeometry.js b/Source/Core/RectangleGeometry.js index 179a258763ba..b08d2406a8a3 100644 --- a/Source/Core/RectangleGeometry.js +++ b/Source/Core/RectangleGeometry.js @@ -170,10 +170,11 @@ define([ var binormal = binormalScratch; var tangent = tangentScratch; var normal = normalScratch; - for (var i = 0; i < length; i += 6) { - var p = Cartesian3.fromArray(positions, i, positionScratch); + if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.binormal) { + for (var i = 0; i < length; i += 6) { + var p = Cartesian3.fromArray(positions, i, positionScratch); - if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.binormal) { + var p1 = Cartesian3.fromArray(positions, (i + 6) % length, v1Scratch); if (recomputeNormal) { var p2 = Cartesian3.fromArray(positions, (i + 3) % length, v2Scratch); From 316656277dc93153c07eb62790df83aa239db442 Mon Sep 17 00:00:00 2001 From: Peter Date: Thu, 29 Dec 2016 09:01:04 +0800 Subject: [PATCH 3/3] add name to CONTRIBUTORS.md --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index c26bab9ad46c..1e72eb8c5f03 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -113,3 +113,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu * [Tom Payne](https://github.com/twpayne) * [Leesa Fini](https://github.com/leesafini) * [Victor Malaret](https://github.com/malaretv) +* [Peter Lu](https://github.com/pasu) \ No newline at end of file