Skip to content

Commit

Permalink
Merge pull request #6216 from AnalyticalGraphicsInc/primitive-image-r…
Browse files Browse the repository at this point in the history
…esource

We weren't allowing primitive materials to have an image be a Resource
  • Loading branch information
mramato authored Feb 15, 2018
2 parents d0a70e7 + 6689d2b commit 4ae2ef0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 3 additions & 5 deletions Source/Scene/Material.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -967,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) {
Expand Down
15 changes: 15 additions & 0 deletions Specs/Scene/MaterialSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ defineSuite([
'Core/GeometryInstance',
'Core/Rectangle',
'Core/RectangleGeometry',
'Core/Resource',
'Scene/MaterialAppearance',
'Scene/PolylineCollection',
'Scene/Primitive',
Expand All @@ -23,6 +24,7 @@ defineSuite([
GeometryInstance,
Rectangle,
RectangleGeometry,
Resource,
MaterialAppearance,
PolylineCollection,
Primitive,
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 4ae2ef0

Please sign in to comment.