From a18cf162638dc0451f1519f967aed2b6f6f3a49a Mon Sep 17 00:00:00 2001 From: Dan Bagnell Date: Tue, 11 Oct 2016 16:22:57 -0400 Subject: [PATCH 1/9] Fix rendering primitives that have geometry attributes and indices that are not typed arrays. --- Source/Scene/Primitive.js | 6 +++- Specs/Scene/GeometryRenderingSpec.js | 49 ++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/Source/Scene/Primitive.js b/Source/Scene/Primitive.js index 29f69c199c36..4aa6975e3c51 100644 --- a/Source/Scene/Primitive.js +++ b/Source/Scene/Primitive.js @@ -683,7 +683,11 @@ define([ var indices; if (defined(geometry.indices)) { var sourceValues = geometry.indices; - indices = new sourceValues.constructor(sourceValues); + if (isArray(sourceValues)) { + indices = sourceValues.slice(0); + } else { + indices = new sourceValues.constructor(sourceValues); + } } return new Geometry({ diff --git a/Specs/Scene/GeometryRenderingSpec.js b/Specs/Scene/GeometryRenderingSpec.js index 03106a12ed14..e732ef84f9d6 100644 --- a/Specs/Scene/GeometryRenderingSpec.js +++ b/Specs/Scene/GeometryRenderingSpec.js @@ -1603,6 +1603,55 @@ defineSuite([ pickGeometry(instance); }); }, 'WebGL'); + + describe('with native arrays as attributes and indices', function() { + var instance; + beforeAll(function() { + instance = new GeometryInstance({ + geometry : new Geometry({ + attributes : { + position : new GeometryAttribute({ + componentDatatype : ComponentDatatype.DOUBLE, + componentsPerAttribute : 3, + values : [ + 1000000.0, 0.0, 0.0, + 1000000.0, 1000000.0, 0.0, + 1000000.0, 0.0, 1000000.0, + 1000000.0, 1000000.0, 1000000.0 + ] + }) + }, + indices : [0, 1, 2, 2, 1, 3], + primitiveType : PrimitiveType.TRIANGLES + }), + modelMatrix : Matrix4.multiplyByTranslation(Transforms.eastNorthUpToFixedFrame( + Cartesian3.fromDegrees(0,0)), new Cartesian3(0.0, 0.0, 10000.0), new Matrix4()), + id : 'customWithIndices', + attributes : { + color : new ColorGeometryInstanceAttribute(1.0, 1.0, 1.0, 1.0) + } + }); + geometry = instance.geometry; + geometry.boundingSphere = BoundingSphere.fromVertices(instance.geometry.attributes.position.values); + geometry.boundingSphereWC = BoundingSphere.transform(geometry.boundingSphere, instance.modelMatrix); + }); + + it('3D', function() { + render3D(instance); + }); + + it('Columbus view', function() { + renderCV(instance); + }); + + it('2D', function() { + render2D(instance); + }); + + it('pick', function() { + pickGeometry(instance); + }); + }, 'WebGL'); }); }, 'WebGL'); From 9ea49d2cc4fcf731e45a9fe1aaf956c7a704ecb4 Mon Sep 17 00:00:00 2001 From: Tom Fili Date: Wed, 12 Oct 2016 17:39:34 -0400 Subject: [PATCH 2/9] Added tweak to getSpecular shader. The result of pow is undefined if specular and shininess are both 0. We were encountering models with a shininess of 0 which would cause the models to turn black depending on the angle. --- Source/Shaders/Builtin/Functions/getSpecular.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Shaders/Builtin/Functions/getSpecular.glsl b/Source/Shaders/Builtin/Functions/getSpecular.glsl index 57998b693cd9..3680c55762b5 100644 --- a/Source/Shaders/Builtin/Functions/getSpecular.glsl +++ b/Source/Shaders/Builtin/Functions/getSpecular.glsl @@ -22,5 +22,5 @@ float czm_getSpecular(vec3 lightDirectionEC, vec3 toEyeEC, vec3 normalEC, float { vec3 toReflectedLight = reflect(-lightDirectionEC, normalEC); float specular = max(dot(toReflectedLight, toEyeEC), 0.0); - return pow(specular, shininess); + return pow(specular, max(shininess, 0.01)); } \ No newline at end of file From 11d370db8454a0b3decc041a27016dacbd1d6982 Mon Sep 17 00:00:00 2001 From: Tom Fili Date: Wed, 12 Oct 2016 21:56:06 -0400 Subject: [PATCH 3/9] Tweaks from PR suggestions. --- Source/Shaders/Builtin/Functions/getSpecular.glsl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Shaders/Builtin/Functions/getSpecular.glsl b/Source/Shaders/Builtin/Functions/getSpecular.glsl index 3680c55762b5..7849670041ac 100644 --- a/Source/Shaders/Builtin/Functions/getSpecular.glsl +++ b/Source/Shaders/Builtin/Functions/getSpecular.glsl @@ -22,5 +22,8 @@ float czm_getSpecular(vec3 lightDirectionEC, vec3 toEyeEC, vec3 normalEC, float { vec3 toReflectedLight = reflect(-lightDirectionEC, normalEC); float specular = max(dot(toReflectedLight, toEyeEC), 0.0); - return pow(specular, max(shininess, 0.01)); + + // pow has undefined behavior if both parameters <= 0. + // Prevent this by making sure shininess is at least czm_epsilon2. + return pow(specular, max(shininess, czm_epsilon2)); } \ No newline at end of file From 19d746ad650cccbc443c96722d06e02a17e9fbce Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Thu, 13 Oct 2016 15:46:48 -0400 Subject: [PATCH 4/9] chore(package): update aws-sdk to version 2.6.9 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2393d1589afa..57d537175fdc 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ }, "devDependencies": { "almond": "0.3.3", - "aws-sdk": "2.6.7", + "aws-sdk": "2.6.9", "bluebird": "3.4.6", "compressible": "2.0.8", "compression": "1.6.2", From 0c948c306ef8033dc60f9bbe46915d6f5f8304e5 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Fri, 14 Oct 2016 20:29:46 -0400 Subject: [PATCH 5/9] Load funcSeparate in the correct order --- Source/Scene/Model.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Scene/Model.js b/Source/Scene/Model.js index a47091a90048..845812c6638f 100644 --- a/Source/Scene/Model.js +++ b/Source/Scene/Model.js @@ -2273,9 +2273,9 @@ define([ WebGLConstants.FUNC_ADD, WebGLConstants.FUNC_ADD]); var blendFuncSeparate = defaultValue(statesFunctions.blendFuncSeparate, [ - WebGLConstants.ONE, WebGLConstants.ONE, WebGLConstants.ZERO, + WebGLConstants.ONE, WebGLConstants.ZERO]); var colorMask = defaultValue(statesFunctions.colorMask, [true, true, true, true]); var depthRange = defaultValue(statesFunctions.depthRange, [0.0, 1.0]); @@ -2329,8 +2329,8 @@ define([ equationRgb : blendEquationSeparate[0], equationAlpha : blendEquationSeparate[1], functionSourceRgb : blendFuncSeparate[0], - functionSourceAlpha : blendFuncSeparate[1], - functionDestinationRgb : blendFuncSeparate[2], + functionDestinationRgb : blendFuncSeparate[1], + functionSourceAlpha : blendFuncSeparate[2], functionDestinationAlpha : blendFuncSeparate[3] } }); From 973ee6ada07bf3957fcfee9a8a29ca73a859de69 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Fri, 14 Oct 2016 20:41:16 -0400 Subject: [PATCH 6/9] Updated CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index ebca07449f14..3b789581d573 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,6 +9,7 @@ Change Log * * Fixed a crash that would occur when using dynamic `distanceDisplayCondition` properties. [#4403](https://github.com/AnalyticalGraphicsInc/cesium/pull/4403) * Fixed a bug affected models with multiple meshes without indices. [#4237](https://github.com/AnalyticalGraphicsInc/cesium/issues/4237) +* Fixed a transparency bug where `blendFuncSeparate` parameters were loaded in the wrong order. [#4435](https://github.com/AnalyticalGraphicsInc/cesium/pull/4435) ### 1.26 - 2016-10-03 From 7ed36c646d4816d3ce83482346c9f36dbe07ad3f Mon Sep 17 00:00:00 2001 From: Patrick Cozzi Date: Sat, 15 Oct 2016 11:29:59 -0400 Subject: [PATCH 7/9] Tweak README.md --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 3b789581d573..ccea7a4fa878 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,7 +9,7 @@ Change Log * * Fixed a crash that would occur when using dynamic `distanceDisplayCondition` properties. [#4403](https://github.com/AnalyticalGraphicsInc/cesium/pull/4403) * Fixed a bug affected models with multiple meshes without indices. [#4237](https://github.com/AnalyticalGraphicsInc/cesium/issues/4237) -* Fixed a transparency bug where `blendFuncSeparate` parameters were loaded in the wrong order. [#4435](https://github.com/AnalyticalGraphicsInc/cesium/pull/4435) +* Fixed a glTF transparency bug where `blendFuncSeparate` parameters were loaded in the wrong order. [#4435](https://github.com/AnalyticalGraphicsInc/cesium/pull/4435) ### 1.26 - 2016-10-03 From 17dbc7640accc6fe89f4d6d893f1fdfeac890405 Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Sun, 16 Oct 2016 20:47:20 -0400 Subject: [PATCH 8/9] chore(package): update yargs to version 6.2.0 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2393d1589afa..ef057f336a37 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "request": "2.75.0", "rimraf": "2.5.4", "strip-comments": "0.3.2", - "yargs": "6.0.0" + "yargs": "6.2.0" }, "scripts": { "start": "node server.js", From e0cceb0be0da5c0d9a14f2b5d548d5533056d074 Mon Sep 17 00:00:00 2001 From: Dan Bagnell Date: Mon, 17 Oct 2016 14:21:51 -0400 Subject: [PATCH 9/9] Update CHANGES.md. --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index ccea7a4fa878..98b7c68a93d3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,7 @@ Change Log * Fixed a crash that would occur when using dynamic `distanceDisplayCondition` properties. [#4403](https://github.com/AnalyticalGraphicsInc/cesium/pull/4403) * Fixed a bug affected models with multiple meshes without indices. [#4237](https://github.com/AnalyticalGraphicsInc/cesium/issues/4237) * Fixed a glTF transparency bug where `blendFuncSeparate` parameters were loaded in the wrong order. [#4435](https://github.com/AnalyticalGraphicsInc/cesium/pull/4435) +* Fixed a bug where creating a custom geometry with attributes and indices that have values that are not a typed array would cause a crash. [#4419](https://github.com/AnalyticalGraphicsInc/cesium/pull/4419) ### 1.26 - 2016-10-03