From 2bcdee7eb5118b118e421b8e6b8062d2ae7cd23b Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Thu, 8 Mar 2018 19:21:35 -0500 Subject: [PATCH 1/2] Fix generating shaders for case where material is not used by a primitive --- .../processModelMaterialsCommon.js | 24 ++++++++++++------- .../processPbrMetallicRoughness.js | 13 +++++++--- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/Source/ThirdParty/GltfPipeline/processModelMaterialsCommon.js b/Source/ThirdParty/GltfPipeline/processModelMaterialsCommon.js index 8420675e78e2..bcf942379723 100644 --- a/Source/ThirdParty/GltfPipeline/processModelMaterialsCommon.js +++ b/Source/ThirdParty/GltfPipeline/processModelMaterialsCommon.js @@ -247,11 +247,17 @@ define([ parameterValues.doubleSided = khrMaterialsCommon.doubleSided; } var jointCount = defaultValue(khrMaterialsCommon.jointCount, 0); - - var hasSkinning = jointCount > 0; var primitiveInfo = khrMaterialsCommon.extras._pipeline.primitive; - var skinningInfo = primitiveInfo.skinning; - var hasVertexColors = primitiveInfo.hasVertexColors; + + var skinningInfo; + var hasSkinning = false; + var hasVertexColors = false; + + if (defined(primitiveInfo)) { + skinningInfo = primitiveInfo.skinning; + hasSkinning = skinningInfo.skinned; + hasVertexColors = primitiveInfo.hasVertexColors; + } var vertexShader = 'precision highp float;\n'; var fragmentShader = 'precision highp float;\n'; @@ -788,11 +794,13 @@ define([ var jointCount = defaultValue(khrMaterialsCommon.jointCount, 0); techniqueKey += jointCount.toString() + ';'; var primitiveInfo = khrMaterialsCommon.extras._pipeline.primitive; - var skinningInfo = primitiveInfo.skinning; - if (jointCount > 0) { - techniqueKey += skinningInfo.type + ';'; + if (defined(primitiveInfo)) { + var skinningInfo = primitiveInfo.skinning; + if (jointCount > 0) { + techniqueKey += skinningInfo.type + ';'; + } + techniqueKey += primitiveInfo.hasVertexColors; } - techniqueKey += primitiveInfo.hasVertexColors; return techniqueKey; } diff --git a/Source/ThirdParty/GltfPipeline/processPbrMetallicRoughness.js b/Source/ThirdParty/GltfPipeline/processPbrMetallicRoughness.js index d24d710051e0..e297f3d78748 100644 --- a/Source/ThirdParty/GltfPipeline/processPbrMetallicRoughness.js +++ b/Source/ThirdParty/GltfPipeline/processPbrMetallicRoughness.js @@ -94,9 +94,16 @@ define([ var joints = (defined(skin)) ? skin.joints : []; var jointCount = joints.length; var primitiveInfo = material.extras._pipeline.primitive; - var skinningInfo = primitiveInfo.skinning; - var hasSkinning = skinningInfo.skinned; - var hasVertexColors = primitiveInfo.hasVertexColors; + + var skinningInfo; + var hasSkinning = false; + var hasVertexColors = false; + + if (defined(primitiveInfo)) { + skinningInfo = primitiveInfo.skinning; + hasSkinning = skinningInfo.skinned; + hasVertexColors = primitiveInfo.hasVertexColors; + } var hasNormals = true; var hasTangents = false; From 34338c11ed167e9a2de9bf4d6498d7b55024ab43 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Mon, 12 Mar 2018 18:58:22 -0400 Subject: [PATCH 2/2] Updated CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 9bbaa229c836..ada7ebfa448b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -19,6 +19,7 @@ Change Log ##### Fixes :wrench: * Fixed support of glTF-supplied tangent vectors. [#6302](https://github.com/AnalyticalGraphicsInc/cesium/pull/6302) * Fixed improper zoom during model load failure. [#6305](https://github.com/AnalyticalGraphicsInc/cesium/pull/6305) +* Fixed model loading failure when containing unused materials. [6315](https://github.com/AnalyticalGraphicsInc/cesium/pull/6315) ### 1.43 - 2018-03-01