From 34c4ff9f0083aee58052429c4763f56f348c4811 Mon Sep 17 00:00:00 2001 From: Tom Fili Date: Tue, 13 Feb 2018 17:56:30 -0500 Subject: [PATCH 1/3] Fixes issue where we had a Resource as a URL for a material image --- Source/Scene/Material.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Source/Scene/Material.js b/Source/Scene/Material.js index 6d7dd1d1456b..87d761ad3568 100644 --- a/Source/Scene/Material.js +++ b/Source/Scene/Material.js @@ -791,10 +791,8 @@ define([ } if (uniformValue !== material._texturePaths[uniformId]) { - if (typeof uniformValue === 'string') { - var resource = new Resource({ - url: uniformValue - }); + if (typeof uniformValue === 'string' || uniformValue instanceof Resource) { + var resource = Resource.createIfNeeded(uniformValue); var promise; if (ktxRegex.test(uniformValue)) { promise = loadKTX(resource); From 6ee5f610507d3a2d4439bd102193890d3741813b Mon Sep 17 00:00:00 2001 From: Tom Fili Date: Tue, 13 Feb 2018 18:12:43 -0500 Subject: [PATCH 2/3] Fixed primitive materials not working with resources. --- Source/Scene/Material.js | 2 +- Specs/Scene/MaterialSpec.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Source/Scene/Material.js b/Source/Scene/Material.js index 87d761ad3568..830a3a7acf0f 100644 --- a/Source/Scene/Material.js +++ b/Source/Scene/Material.js @@ -965,7 +965,7 @@ define([ uniformType = 'float'; } else if (type === 'boolean') { uniformType = 'bool'; - } else if (type === 'string' || uniformValue instanceof HTMLCanvasElement) { + } else if (type === 'string' || uniformValue instanceof Resource ||uniformValue instanceof HTMLCanvasElement) { if (/^([rgba]){1,4}$/i.test(uniformValue)) { uniformType = 'channels'; } else if (uniformValue === Material.DefaultCubeMapId) { diff --git a/Specs/Scene/MaterialSpec.js b/Specs/Scene/MaterialSpec.js index e23d901e0b73..5085391c19f0 100644 --- a/Specs/Scene/MaterialSpec.js +++ b/Specs/Scene/MaterialSpec.js @@ -8,6 +8,7 @@ defineSuite([ 'Core/GeometryInstance', 'Core/Rectangle', 'Core/RectangleGeometry', + 'Core/Resource', 'Scene/MaterialAppearance', 'Scene/PolylineCollection', 'Scene/Primitive', @@ -23,6 +24,7 @@ defineSuite([ GeometryInstance, Rectangle, RectangleGeometry, + Resource, MaterialAppearance, PolylineCollection, Primitive, @@ -334,6 +336,19 @@ defineSuite([ renderMaterial(material); }); + it('creates a material with an image resource uniform', function () { + var material = new Material({ + strict : true, + fabric : { + type : 'DiffuseMap', + uniforms : { + image : new Resource('./Data/Images/Blue.png') + } + } + }); + renderMaterial(material); + }); + it('creates a material with an image canvas uniform', function() { var canvas = document.createElement('canvas'); var context2D = canvas.getContext('2d'); From 6689d2bc8d4b6e3c3e412243444be6e81b1d00ae Mon Sep 17 00:00:00 2001 From: Tom Fili Date: Wed, 14 Feb 2018 22:24:26 -0500 Subject: [PATCH 3/3] Updated CHANGES. --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index c182989bf614..2b7aa135195b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -19,6 +19,7 @@ Change Log * Fixed `Resource.fetch` when called with no arguments [#6206](https://github.com/AnalyticalGraphicsInc/cesium/issues/6206) * Fixed `Resource.clone` to clone the `Request` object, so resource can be used in parallel. [#6208](https://github.com/AnalyticalGraphicsInc/cesium/issues/6208) * Fixed bug where 3D Tiles Point Clouds would fail in Internet Explorer. [#6220](https://github.com/AnalyticalGraphicsInc/cesium/pull/6220) +* Fixed `Material` so it can now take a `Resource` object as an image. [#6199](https://github.com/AnalyticalGraphicsInc/cesium/issues/6199) ##### Additions :tada: * Enable terrain in the `CesiumViewer` demo application [#6198](https://github.com/AnalyticalGraphicsInc/cesium/pull/6198)