From 888a454d023f89126860d22b7ae8d53f2f7d7588 Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Mon, 19 Dec 2016 11:43:39 -0500 Subject: [PATCH 01/29] begin adding unary fns --- Source/Scene/Expression.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Source/Scene/Expression.js b/Source/Scene/Expression.js index b88e0f37cf68..499d61e58797 100644 --- a/Source/Scene/Expression.js +++ b/Source/Scene/Expression.js @@ -62,7 +62,16 @@ define([ asin : Math.asin, atan : Math.atan, radians : CesiumMath.toRadians, - degrees : CesiumMath.toDegrees + degrees : CesiumMath.toDegrees, + sign : Math.sign, + floor : Math.floor, + ceil : Math.ceil, + round : Math.round, + exp: Math.exp, + log: Math.log, + exp2 : Math.exp2, + log2: Math.log2, + fract: CesiumMath.fract }; /** From d9fbc91d9d8a3c4d3bcb1acc70a4119940b7daa8 Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Tue, 20 Dec 2016 14:12:21 -0500 Subject: [PATCH 02/29] added fract to CesiumMath library --- Source/Core/Math.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Source/Core/Math.js b/Source/Core/Math.js index 7c9952c522b5..2a253f3ea5be 100644 --- a/Source/Core/Math.js +++ b/Source/Core/Math.js @@ -805,6 +805,22 @@ define([ return 2.0 * radius * Math.sin(angle * 0.5); }; + /** + * Returns the fractional part of a number, i.e. number minus floor(number) + * + * @param {Number} angle The angle between the two points. + * @param {Number} radius The radius of the circle. + * @returns {Number} The chord length. + */ + CesiumMath.fract = function(number) { + //>>includeStart('debug', pragmas.debug); + if (!defined(number)) { + throw new DeveloperError('number is required.'); + } + //>>includeEnd('debug'); + return number - Math.floor(number); + }; + /** * Finds the logarithm of a number to a base. * From a3be0fb7410cac3a221aa6495b8663dc81d9a7ca Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Tue, 20 Dec 2016 14:19:36 -0500 Subject: [PATCH 03/29] added tests for fract to MathSpec --- Specs/Core/MathSpec.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Specs/Core/MathSpec.js b/Specs/Core/MathSpec.js index a52fa67e1bff..db69f5579169 100644 --- a/Specs/Core/MathSpec.js +++ b/Specs/Core/MathSpec.js @@ -420,6 +420,16 @@ defineSuite([ }).toThrowDeveloperError(); }); + it('fract', function() { + expect(CesiumMath.fract(1.25)).toEqual(0.25); + }); + + it('fract throws without number', function() { + expect(function() { + CesiumMath.fract(undefined); + }).toThrowDeveloperError(); + }); + it('logBase', function() { expect(CesiumMath.logBase(64, 4)).toEqual(3); }); From 2d3dd6e45fad09903a852bfc713dc10e8aae9fcc Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Tue, 20 Dec 2016 14:28:44 -0500 Subject: [PATCH 04/29] added tests in expressionspec --- Specs/Scene/ExpressionSpec.js | 162 ++++++++++++++++++++++++++++++++++ 1 file changed, 162 insertions(+) diff --git a/Specs/Scene/ExpressionSpec.js b/Specs/Scene/ExpressionSpec.js index d017c3b4602c..c32e1d354968 100644 --- a/Specs/Scene/ExpressionSpec.js +++ b/Specs/Scene/ExpressionSpec.js @@ -988,6 +988,168 @@ defineSuite([ }).toThrowDeveloperError(); }); + it('evaluates sign function', function() { + var expression = new Expression('sign(5.0)'); + expect(expression.evaluate(frameState, undefined)).toEqual(1.0); + + expression = new Expression('sign(0.0)'); + expect(expression.evaluate(frameState, undefined)).toEqual(0.0); + + expression = new Expression('sign(-5.0)'); + expect(expression.evaluate(frameState, undefined)).toEqual(-1.0); + }); + + it('throws if sign function takes an invalid number of arguments', function() { + expect(function() { + return new Expression('sign()'); + }).toThrowDeveloperError(); + + expect(function() { + return new Expression('sign(1, 2)'); + }).toThrowDeveloperError(); + }); + + it('evaluates floor function', function() { + var expression = new Expression('floor(5.5)'); + expect(expression.evaluate(frameState, undefined)).toEqual(5.0); + + expression = new Expression('floor(0.0)'); + expect(expression.evaluate(frameState, undefined)).toEqual(0.0); + + expression = new Expression('floor(-1.2)'); + expect(expression.evaluate(frameState, undefined)).toEqual(-2.0); + }); + + it('throws if floor function takes an invalid number of arguments', function() { + expect(function() { + return new Expression('floor()'); + }).toThrowDeveloperError(); + + expect(function() { + return new Expression('floor(1, 2)'); + }).toThrowDeveloperError(); + }); + + it('evaluates ceil function', function() { + var expression = new Expression('ceil(5.5)'); + expect(expression.evaluate(frameState, undefined)).toEqual(6.0); + + expression = new Expression('ceil(0.0)'); + expect(expression.evaluate(frameState, undefined)).toEqual(0.0); + + expression = new Expression('ceil(-1.2)'); + expect(expression.evaluate(frameState, undefined)).toEqual(-1.0); + }); + + it('throws if ceil function takes an invalid number of arguments', function() { + expect(function() { + return new Expression('ceil()'); + }).toThrowDeveloperError(); + + expect(function() { + return new Expression('ceil(1, 2)'); + }).toThrowDeveloperError(); + }); + + it('evaluates round function', function() { + var expression = new Expression('round(5.5)'); + expect(expression.evaluate(frameState, undefined)).toEqual(6.0); + + expression = new Expression('round(0.0)'); + expect(expression.evaluate(frameState, undefined)).toEqual(0.0); + + expression = new Expression('round(-1.6)'); + expect(expression.evaluate(frameState, undefined)).toEqual(-2.0); + }); + + it('throws if round function takes an invalid number of arguments', function() { + expect(function() { + return new Expression('round()'); + }).toThrowDeveloperError(); + + expect(function() { + return new Expression('round(1, 2)'); + }).toThrowDeveloperError(); + }); + + it('evaluates exp function', function() { + var expression = new Expression('exp(1.0)'); + expect(expression.evaluate(frameState, undefined)).toEqual(Math.E); + + expression = new Expression('exp(0.0)'); + expect(expression.evaluate(frameState, undefined)).toEqual(1.0); + }); + + it('throws if exp function takes an invalid number of arguments', function() { + expect(function() { + return new Expression('exp()'); + }).toThrowDeveloperError(); + + expect(function() { + return new Expression('exp(1, 2)'); + }).toThrowDeveloperError(); + }); + + it('evaluates exp2 function', function() { + var expression = new Expression('exp2(1.0)'); + expect(expression.evaluate(frameState, undefined)).toEqual(2.0); + + expression = new Expression('exp2(0.0)'); + expect(expression.evaluate(frameState, undefined)).toEqual(1.0); + + expression = new Expression('exp2(2.0)'); + expect(expression.evaluate(frameState, undefined)).toEqual(4.0); + }); + + it('throws if exp2 function takes an invalid number of arguments', function() { + expect(function() { + return new Expression('exp2()'); + }).toThrowDeveloperError(); + + expect(function() { + return new Expression('exp2(1, 2)'); + }).toThrowDeveloperError(); + }); + + it('evaluates log function', function() { + var expression = new Expression('log(1.0)'); + expect(expression.evaluate(frameState, undefined)).toEqual(0.0); + + expression = new Expression('log(Math.E)'); + expect(expression.evaluate(frameState, undefined)).toEqual(1.0); + }); + + it('throws if log function takes an invalid number of arguments', function() { + expect(function() { + return new Expression('log()'); + }).toThrowDeveloperError(); + + expect(function() { + return new Expression('log(1, 2)'); + }).toThrowDeveloperError(); + }); + + it('evaluates log2 function', function() { + var expression = new Expression('log2(1.0)'); + expect(expression.evaluate(frameState, undefined)).toEqual(0.0); + + expression = new Expression('log2(2.0)'); + expect(expression.evaluate(frameState, undefined)).toEqual(1.0); + + expression = new Expression('log2(4.0)'); + expect(expression.evaluate(frameState, undefined)).toEqual(2.0); + }); + + it('throws if log2 function takes an invalid number of arguments', function() { + expect(function() { + return new Expression('log2()'); + }).toThrowDeveloperError(); + + expect(function() { + return new Expression('log2(1, 2)'); + }).toThrowDeveloperError(); + }); + it('evaluates atan2 function', function() { var expression = new Expression('atan2(0,1)'); expect(expression.evaluate(frameState, undefined)).toEqualEpsilon(0.0, CesiumMath.EPSILON10); From 8d7e29df956ed24d3bdd171f91708c731bc341aa Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Tue, 20 Dec 2016 14:34:37 -0500 Subject: [PATCH 05/29] added tests for fract to expressionspec --- Specs/Scene/ExpressionSpec.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Specs/Scene/ExpressionSpec.js b/Specs/Scene/ExpressionSpec.js index c32e1d354968..6cb298b3b012 100644 --- a/Specs/Scene/ExpressionSpec.js +++ b/Specs/Scene/ExpressionSpec.js @@ -1150,6 +1150,27 @@ defineSuite([ }).toThrowDeveloperError(); }); + it('evaluates fract function', function() { + var expression = new Expression('fract(1.0)'); + expect(expression.evaluate(frameState, undefined)).toEqual(0.0); + + expression = new Expression('fract(2.25)'); + expect(expression.evaluate(frameState, undefined)).toEqual(0.25); + + expression = new Expression('fract(-2.25)'); + expect(expression.evaluate(frameState, undefined)).toEqual(0.75); + }); + + it('throws if fract function takes an invalid number of arguments', function() { + expect(function() { + return new Expression('log2()'); + }).toThrowDeveloperError(); + + expect(function() { + return new Expression('log2(1, 2)'); + }).toThrowDeveloperError(); + }); + it('evaluates atan2 function', function() { var expression = new Expression('atan2(0,1)'); expect(expression.evaluate(frameState, undefined)).toEqualEpsilon(0.0, CesiumMath.EPSILON10); From 9591c464055786f1739d045e4aaffbb2ea266cd8 Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Tue, 20 Dec 2016 14:38:07 -0500 Subject: [PATCH 06/29] added shader tests --- Specs/Scene/ExpressionSpec.js | 65 ++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/Specs/Scene/ExpressionSpec.js b/Specs/Scene/ExpressionSpec.js index 6cb298b3b012..8ac520fac3d7 100644 --- a/Specs/Scene/ExpressionSpec.js +++ b/Specs/Scene/ExpressionSpec.js @@ -2020,7 +2020,7 @@ defineSuite([ expect(shaderExpression).toEqual(expected); }); - it('gets shader expression for sin', function() { + it('gets shader expression for sin', function() { var expression = new Expression('sin(0.0)'); var shaderExpression = expression.getShaderExpression('', {}); var expected = 'sin(0.0)'; @@ -2062,6 +2062,69 @@ defineSuite([ expect(shaderExpression).toEqual(expected); }); + it('gets shader expression for sign', function() { + var expression = new Expression('sign(1.0)'); + var shaderExpression = expression.getShaderExpression('', {}); + var expected = 'sign(1.0)'; + expect(shaderExpression).toEqual(expected); + }); + + it('gets shader expression for floor', function() { + var expression = new Expression('floor(1.5)'); + var shaderExpression = expression.getShaderExpression('', {}); + var expected = 'floor(1.5)'; + expect(shaderExpression).toEqual(expected); + }); + + it('gets shader expression for ceil', function() { + var expression = new Expression('ceil(1.2)'); + var shaderExpression = expression.getShaderExpression('', {}); + var expected = 'ceil(1.2)'; + expect(shaderExpression).toEqual(expected); + }); + + it('gets shader expression for round', function() { + var expression = new Expression('round(1.2)'); + var shaderExpression = expression.getShaderExpression('', {}); + var expected = 'round(1.2)'; + expect(shaderExpression).toEqual(expected); + }); + + it('gets shader expression for exp', function() { + var expression = new Expression('exp(1.0)'); + var shaderExpression = expression.getShaderExpression('', {}); + var expected = 'exp(1.0)'; + expect(shaderExpression).toEqual(expected); + }); + + it('gets shader expression for exp2', function() { + var expression = new Expression('exp2(1.0)'); + var shaderExpression = expression.getShaderExpression('', {}); + var expected = 'exp2(1.0)'; + expect(shaderExpression).toEqual(expected); + }); + + it('gets shader expression for log', function() { + var expression = new Expression('log(1.0)'); + var shaderExpression = expression.getShaderExpression('', {}); + var expected = 'log(1.0)'; + expect(shaderExpression).toEqual(expected); + }); + + it('gets shader expression for log2', function() { + var expression = new Expression('log2(1.0)'); + var shaderExpression = expression.getShaderExpression('', {}); + var expected = 'log2(1.0)'; + expect(shaderExpression).toEqual(expected); + }); + + it('gets shader expression for fract', function() { + var expression = new Expression('fract(1.0)'); + var shaderExpression = expression.getShaderExpression('', {}); + var expected = 'fract(1.0)'; + expect(shaderExpression).toEqual(expected); + }); + it('gets shader expression for atan2', function() { var expression = new Expression('atan2(0.0,1.0)'); var shaderExpression = expression.getShaderExpression('', {}); From ba682daad385a44ed995752990ee216bc8e6ef25 Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Tue, 20 Dec 2016 14:42:40 -0500 Subject: [PATCH 07/29] added sandcastle demos --- .../gallery/3D Tiles Point Cloud Styling.html | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Apps/Sandcastle/gallery/3D Tiles Point Cloud Styling.html b/Apps/Sandcastle/gallery/3D Tiles Point Cloud Styling.html index 7d2a15bae834..e3cad457044b 100644 --- a/Apps/Sandcastle/gallery/3D Tiles Point Cloud Styling.html +++ b/Apps/Sandcastle/gallery/3D Tiles Point Cloud Styling.html @@ -124,6 +124,26 @@ pointSize : "5" }); +addStyle('Sign', { + color : "color() * sign(${temperature})", + pointSize : "5" +}); + +addStyle('Rounding Functions', { + color : "rgb(floor(${POSITION}[0]) * 255, ceil(${POSITION}[1]) * 255, round(${POSITION}[2]) * 255)", + pointSize : "5" +}); + +addStyle('Exp and Log Functions', { + color : "rgb(log(${POSITION}[0]) * 255, log2(${POSITION}[1]) * 255 + exp2(${POSITION}[1]) * 255, exp(${POSITION}[2]) * 255)", + pointSize : "5" +}); + +addStyle('Fractional Part', { + color : "color() * fract(${temperature})", + pointSize : "5" +}); + addStyle('Pow', { color : "color() * pow(${temperature}, 3)", pointSize : "5" From d2ac9f39426579139c3144b45fb52a1203282f11 Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Tue, 20 Dec 2016 15:17:08 -0500 Subject: [PATCH 08/29] some updates vertex shader for round still won't compile - not sure why --- Source/Core/Math.js | 20 +++++++++++++++++--- Specs/Core/MathSpec.js | 12 ++++++++++++ Specs/Scene/ExpressionSpec.js | 8 ++++---- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/Source/Core/Math.js b/Source/Core/Math.js index 2a253f3ea5be..c81bca646ec8 100644 --- a/Source/Core/Math.js +++ b/Source/Core/Math.js @@ -808,9 +808,8 @@ define([ /** * Returns the fractional part of a number, i.e. number minus floor(number) * - * @param {Number} angle The angle between the two points. - * @param {Number} radius The radius of the circle. - * @returns {Number} The chord length. + * @param {Number} number The number whose fractional part will be returned. + * @returns {Number} The fractional part. */ CesiumMath.fract = function(number) { //>>includeStart('debug', pragmas.debug); @@ -821,6 +820,21 @@ define([ return number - Math.floor(number); }; + /** + * Returns 2 raised to the power of exponent. + * + * @param {Number} exponent The power to which 2 will be raised. + * @returns {Number} The value of 2 raised to the power of exponent. + */ + CesiumMath.exp2 = function(exponent) { + //>>includeStart('debug', pragmas.debug); + if (!defined(number)) { + throw new DeveloperError('number is required.'); + } + //>>includeEnd('debug'); + return Math.pow(2.0,exponent); + }; + /** * Finds the logarithm of a number to a base. * diff --git a/Specs/Core/MathSpec.js b/Specs/Core/MathSpec.js index db69f5579169..d86f96d33dd7 100644 --- a/Specs/Core/MathSpec.js +++ b/Specs/Core/MathSpec.js @@ -430,6 +430,18 @@ defineSuite([ }).toThrowDeveloperError(); }); + it('exp2', function() { + expect(CesiumMath.exp2(0.0)).toEqual(1.0); + + expect(CesiumMath.exp2(2.0)).toEqual(4.0); + }); + + it('exp2 throws without number', function() { + expect(function() { + CesiumMath.exp2(undefined); + }).toThrowDeveloperError(); + }); + it('logBase', function() { expect(CesiumMath.logBase(64, 4)).toEqual(3); }); diff --git a/Specs/Scene/ExpressionSpec.js b/Specs/Scene/ExpressionSpec.js index 8ac520fac3d7..f8f4fbe8da81 100644 --- a/Specs/Scene/ExpressionSpec.js +++ b/Specs/Scene/ExpressionSpec.js @@ -1053,13 +1053,13 @@ defineSuite([ it('evaluates round function', function() { var expression = new Expression('round(5.5)'); - expect(expression.evaluate(frameState, undefined)).toEqual(6.0); + expect(expression.evaluate(frameState, undefined)).toEqual(6); expression = new Expression('round(0.0)'); - expect(expression.evaluate(frameState, undefined)).toEqual(0.0); + expect(expression.evaluate(frameState, undefined)).toEqual(0); - expression = new Expression('round(-1.6)'); - expect(expression.evaluate(frameState, undefined)).toEqual(-2.0); + expression = new Expression('round(1.2)'); + expect(expression.evaluate(frameState, undefined)).toEqual(1); }); it('throws if round function takes an invalid number of arguments', function() { From cd6b804f5d6b7943af6f3ca059ffde710de57f2b Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Tue, 20 Dec 2016 15:17:29 -0500 Subject: [PATCH 09/29] changed exp2 to CesiumMath JavaScript apparently doesn't have exp2 function? --- Source/Scene/Expression.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/Scene/Expression.js b/Source/Scene/Expression.js index 499d61e58797..83a3b49ebd4a 100644 --- a/Source/Scene/Expression.js +++ b/Source/Scene/Expression.js @@ -67,11 +67,11 @@ define([ floor : Math.floor, ceil : Math.ceil, round : Math.round, - exp: Math.exp, - log: Math.log, - exp2 : Math.exp2, - log2: Math.log2, - fract: CesiumMath.fract + exp : Math.exp, + exp2 : CesiumMath.exp2, + log : Math.log, + log2 : Math.log2, + fract : CesiumMath.fract }; /** From 664bf5cd417a4ce9d36c0308063ef46ccb4153c6 Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Tue, 20 Dec 2016 15:23:29 -0500 Subject: [PATCH 10/29] some updates --- CONTRIBUTORS.md | 2 -- Source/Scene/Batched3DModel3DTileContent.js | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 7504f7b201a6..a2d80248e272 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -68,8 +68,6 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu * [Camptocamp SA](https://www.camptocamp.com/) * [Frédéric Junod](https://github.com/fredj) * [Guillaume Beraudo](https://github.com/gberaudo) -* [Safe Software](https://www.safe.com) - * [Joel Depooter](https://github.com/JDepooter) ## [Individual CLA](http://www.agi.com/licenses/individual-cla-agi-v1.0.txt) diff --git a/Source/Scene/Batched3DModel3DTileContent.js b/Source/Scene/Batched3DModel3DTileContent.js index df452e485ea3..7f7c6201132f 100644 --- a/Source/Scene/Batched3DModel3DTileContent.js +++ b/Source/Scene/Batched3DModel3DTileContent.js @@ -302,8 +302,7 @@ define([ uniformMapLoaded : batchTable.getUniformMapCallback(), pickVertexShaderLoaded : getPickVertexShaderCallback(this), pickFragmentShaderLoaded : batchTable.getPickFragmentShaderCallback(), - pickUniformMapLoaded : batchTable.getPickUniformMapCallback(), - addBatchIdToGeneratedShaders : (batchLength > 0) // If the batch table has values in it, generated shaders will need a batchId attribute + pickUniformMapLoaded : batchTable.getPickUniformMapCallback() }); this._model = model; From bfe278c3cc8d866f75e1fc7c31cf0c27fa0f5ca5 Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Tue, 20 Dec 2016 15:28:38 -0500 Subject: [PATCH 11/29] fixed more conflicts --- Source/Scene/Model.js | 11 +++-------- Source/Scene/modelMaterialsCommon.js | 25 ++++--------------------- 2 files changed, 7 insertions(+), 29 deletions(-) diff --git a/Source/Scene/Model.js b/Source/Scene/Model.js index 901c7ff3e0ad..fcdf3cbc637f 100644 --- a/Source/Scene/Model.js +++ b/Source/Scene/Model.js @@ -231,9 +231,7 @@ define([ // Note that this is a global cache, compared to renderer resources, which // are cached per context. function CachedGltf(options) { - this._gltf = modelMaterialsCommon(gltfDefaults(options.gltf), { - addBatchIdToGeneratedShaders : options.addBatchIdToGeneratedShaders - }); + this._gltf = modelMaterialsCommon(gltfDefaults(options.gltf)); this._bgltf = options.bgltf; this.ready = options.ready; this.modelsToLoad = []; @@ -333,7 +331,6 @@ define([ * @param {HeightReference} [options.heightReference] Determines how the model is drawn relative to terrain. * @param {Scene} [options.scene] Must be passed in for models that use the height reference property. * @param {DistanceDisplayCondition} [options.istanceDisplayCondition] The condition specifying at what distance from the camera that this model will be displayed. - * @param {Boolean} [options.addBatchIdToGeneratedShaders=false] Determines if shaders generated for materials using the KHR_materials_common extension should include a batchId attribute. For models contained in B3DM tiles. * * @exception {DeveloperError} bgltf is not a valid Binary glTF file. * @exception {DeveloperError} Only glTF Binary version 1 is supported. @@ -377,15 +374,13 @@ define([ cachedGltf = new CachedGltf({ gltf : result.glTF, bgltf : gltf, - ready : true, - addBatchIdToGeneratedShaders : options.addBatchIdToGeneratedShaders + ready : true }); } else { // Normal glTF (JSON) cachedGltf = new CachedGltf({ gltf : options.gltf, - ready : true, - addBatchIdToGeneratedShaders : options.addBatchIdToGeneratedShaders + ready : true }); } diff --git a/Source/Scene/modelMaterialsCommon.js b/Source/Scene/modelMaterialsCommon.js index d52131fb56b2..984807fee4bb 100644 --- a/Source/Scene/modelMaterialsCommon.js +++ b/Source/Scene/modelMaterialsCommon.js @@ -167,7 +167,7 @@ define([ var vertexShaderCount = 0; var fragmentShaderCount = 0; var programCount = 0; - function generateTechnique(gltf, khrMaterialsCommon, lightParameters, options) { + function generateTechnique(gltf, khrMaterialsCommon, lightParameters) { var techniques = gltf.techniques; var shaders = gltf.shaders; var programs = gltf.programs; @@ -195,7 +195,7 @@ define([ var techniqueParameters = { // Add matrices modelViewMatrix: { - semantic: options.useCesiumRTCMatrixInShaders ? 'CESIUM_RTC_MODELVIEW' : 'MODELVIEW', + semantic: 'MODELVIEW', type: WebGLConstants.FLOAT_MAT4 }, projectionMatrix: { @@ -349,15 +349,6 @@ define([ vertexShader += 'attribute vec4 a_joint;\n'; vertexShader += 'attribute vec4 a_weight;\n'; } - - if (options.addBatchIdToGeneratedShaders) { - techniqueAttributes.a_batchId = 'batchId'; - techniqueParameters.batchId = { - semantic: 'BATCHID', - type: WebGLConstants.FLOAT - }; - vertexShader += 'attribute float a_batchId;\n'; - } var hasSpecular = hasNormals && ((lightingModel === 'BLINN') || (lightingModel === 'PHONG')) && defined(techniqueParameters.specular) && defined(techniqueParameters.shininess); @@ -692,12 +683,10 @@ define([ * * @private */ - function modelMaterialsCommon(gltf, options) { + function modelMaterialsCommon(gltf) { if (!defined(gltf)) { return undefined; } - - options = defaultValue(options, defaultValue.EMPTY_OBJECT); var hasExtension = false; var extensionsUsed = gltf.extensionsUsed; @@ -724,9 +713,6 @@ define([ } var lightParameters = generateLightParameters(gltf); - - var hasCesiumRTCExtension = defined(gltf.extensions) && defined(gltf.extensions.CESIUM_RTC); - var addBatchIdToGeneratedShaders = defaultValue(options.addBatchIdToGeneratedShaders, false); var techniques = {}; var materials = gltf.materials; @@ -738,10 +724,7 @@ define([ var techniqueKey = getTechniqueKey(khrMaterialsCommon); var technique = techniques[techniqueKey]; if (!defined(technique)) { - technique = generateTechnique(gltf, khrMaterialsCommon, lightParameters, { - addBatchIdToGeneratedShaders : addBatchIdToGeneratedShaders, - useCesiumRTCMatrixInShaders : hasCesiumRTCExtension - }); + technique = generateTechnique(gltf, khrMaterialsCommon, lightParameters); techniques[techniqueKey] = technique; } From e9fd5e11ae8033f73dff397a7ba9cddc51475956 Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Tue, 20 Dec 2016 15:31:23 -0500 Subject: [PATCH 12/29] fixed whitespace --- CONTRIBUTORS.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index a2d80248e272..8f9afa145988 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -69,7 +69,6 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu * [Frédéric Junod](https://github.com/fredj) * [Guillaume Beraudo](https://github.com/gberaudo) - ## [Individual CLA](http://www.agi.com/licenses/individual-cla-agi-v1.0.txt) * [Victor Berchet](https://github.com/vicb) * [Caleb Morse](https://github.com/cmorse) From 59e22095d2dfddd781d3dc3a6c98761dfab91708 Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Tue, 20 Dec 2016 15:36:06 -0500 Subject: [PATCH 13/29] fixed more conflicts --- .../Batched/BatchedWithKHRMaterialsCommon/tileset.json | 2 +- package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Specs/Data/Cesium3DTiles/Batched/BatchedWithKHRMaterialsCommon/tileset.json b/Specs/Data/Cesium3DTiles/Batched/BatchedWithKHRMaterialsCommon/tileset.json index f9fe0ca601fc..f0d7e48a17b5 100644 --- a/Specs/Data/Cesium3DTiles/Batched/BatchedWithKHRMaterialsCommon/tileset.json +++ b/Specs/Data/Cesium3DTiles/Batched/BatchedWithKHRMaterialsCommon/tileset.json @@ -34,4 +34,4 @@ "url": "batchedWithKHRMaterialsCommon.b3dm" } } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 705dc57c13a0..6f3865de7af5 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "karma-electron": "^5.1.1", "karma-firefox-launcher": "^1.0.0", "karma-ie-launcher": "^1.0.0", - "karma-jasmine": "^1.0.2", + "karma-jasmine": "^1.1.0", "karma-requirejs": "^1.1.0", "karma-safari-launcher": "^1.0.0", "karma-spec-reporter": "^0.0.26", @@ -100,4 +100,4 @@ "deploy-status": "gulp deploy-status", "deploy-set-version": "gulp deploy-set-version" } -} +} \ No newline at end of file From 883dc4dcd087ad57f7451c151a2be6a010433bac Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Tue, 20 Dec 2016 15:38:00 -0500 Subject: [PATCH 14/29] more conflicts --- package.json | 73 ++++++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/package.json b/package.json index 6f3865de7af5..b4ae8b44833a 100644 --- a/package.json +++ b/package.json @@ -30,45 +30,44 @@ "email": "cesium-dev@googlegroups.com" }, "dependencies": { - "requirejs": "^2.3.2" + "requirejs": "2.3.2" }, "devDependencies": { - "almond": "^0.3.3", - "aws-sdk": "^2.7.9", - "bluebird": "^3.4.6", - "compressible": "^2.0.9", - "compression": "^1.6.2", - "electron": "^1.4.10", - "event-stream": "^3.3.4", - "express": "^4.14.0", - "globby": "^6.1.0", - "glsl-strip-comments": "^1.0.0", - "gulp": "^3.9.1", - "gulp-insert": "^0.5.0", - "gulp-jshint": "^2.0.4", - "gulp-rename": "^1.2.2", - "gulp-replace": "^0.5.4", - "gulp-tap": "^0.1.3", - "gulp-zip": "^3.2.0", - "jasmine-core": "^2.5.2", - "jsdoc": "^3.4.3", - "jshint": "^2.9.4", - "jshint-stylish": "^2.2.1", - "karma": "^1.3.0", - "karma-chrome-launcher": "^2.0.0", - "karma-detect-browsers": "^2.2.3", - "karma-electron": "^5.1.1", - "karma-firefox-launcher": "^1.0.0", - "karma-ie-launcher": "^1.0.0", - "karma-jasmine": "^1.1.0", - "karma-requirejs": "^1.1.0", - "karma-safari-launcher": "^1.0.0", - "karma-spec-reporter": "^0.0.26", - "mime": "^1.3.4", - "mkdirp": "^0.5.1", - "request": "^2.79.0", - "rimraf": "^2.5.4", - "yargs": "^6.4.0" + "almond": "0.3.3", + "aws-sdk": "2.7.9", + "bluebird": "3.4.6", + "compressible": "2.0.9", + "compression": "1.6.2", + "electron": "1.4.10", + "event-stream": "3.3.4", + "express": "4.14.0", + "globby": "6.1.0", + "gulp": "3.9.1", + "gulp-insert": "0.5.0", + "gulp-jshint": "2.0.3", + "gulp-rename": "1.2.2", + "gulp-replace": "0.5.4", + "gulp-zip": "3.0.2", + "jasmine-core": "2.5.2", + "jsdoc": "3.4.3", + "jshint": "2.9.4", + "jshint-stylish": "2.2.1", + "karma": "1.3.0", + "karma-chrome-launcher": "2.0.0", + "karma-detect-browsers": "2.2.3", + "karma-electron": "5.1.1", + "karma-firefox-launcher": "1.0.0", + "karma-ie-launcher": "1.0.0", + "karma-jasmine": "1.0.2", + "karma-requirejs": "1.1.0", + "karma-safari-launcher": "1.0.0", + "karma-spec-reporter": "0.0.26", + "mime": "1.3.4", + "mkdirp": "0.5.1", + "request": "2.79.0", + "rimraf": "2.5.4", + "strip-comments": "0.3.2", + "yargs": "6.4.0" }, "scripts": { "start": "node server.js", From e6e37accdf76894fb4c519498b310bcbcd2d0005 Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Tue, 20 Dec 2016 15:38:51 -0500 Subject: [PATCH 15/29] package newline? --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b4ae8b44833a..5024601558ae 100644 --- a/package.json +++ b/package.json @@ -99,4 +99,4 @@ "deploy-status": "gulp deploy-status", "deploy-set-version": "gulp deploy-set-version" } -} \ No newline at end of file +} From 7210fbdc5a0128e4bfacc8ede3875a24b09b3698 Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Tue, 20 Dec 2016 15:41:06 -0500 Subject: [PATCH 16/29] final conflicts maybe --- Specs/Scene/ExpressionSpec.js | 2 +- gulpfile.js | 13 ++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/Specs/Scene/ExpressionSpec.js b/Specs/Scene/ExpressionSpec.js index f8f4fbe8da81..71ea6e9190ff 100644 --- a/Specs/Scene/ExpressionSpec.js +++ b/Specs/Scene/ExpressionSpec.js @@ -2020,7 +2020,7 @@ defineSuite([ expect(shaderExpression).toEqual(expected); }); - it('gets shader expression for sin', function() { + it('gets shader expression for sin', function() { var expression = new Expression('sin(0.0)'); var shaderExpression = expression.getShaderExpression('', {}); var expected = 'sin(0.0)'; diff --git a/gulpfile.js b/gulpfile.js index cf6056744c43..1dee79486602 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -12,9 +12,8 @@ var request = require('request'); var globby = require('globby'); var jshint = require('gulp-jshint'); -var gulpTap = require('gulp-tap'); var rimraf = require('rimraf'); -var glslStripComments = require('glsl-strip-comments'); +var stripComments = require('strip-comments'); var mkdirp = require('mkdirp'); var eventStream = require('event-stream'); var gulp = require('gulp'); @@ -289,14 +288,6 @@ gulp.task('makeZipFile', ['release'], function() { var indexSrc = gulp.src('index.release.html').pipe(gulpRename("index.html")); return eventStream.merge(builtSrc, staticSrc, indexSrc) - .pipe(gulpTap(function(file) { - // Work around an issue with gulp-zip where archives generated on Windows do - // not properly have their directory executable mode set. - // see https://github.com/sindresorhus/gulp-zip/issues/64#issuecomment-205324031 - if (file.isDirectory()) { - file.stat.mode = parseInt('40777', 8); - } - })) .pipe(gulpZip('Cesium-' + version + '.zip')) .pipe(gulp.dest('.')); }); @@ -1002,7 +993,7 @@ function glslToJavaScript(minify, minifyStateFilePath) { } if (minify) { - contents = glslStripComments(contents); + contents = stripComments(contents); contents = contents.replace(/\s+$/gm, '').replace(/^\s+/gm, '').replace(/\n+/gm, '\n'); contents += '\n'; } From 7e390eaa924fb8702937ab96ddec2270c06e46ae Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Tue, 20 Dec 2016 15:42:58 -0500 Subject: [PATCH 17/29] last changes to remove extra files --- .../batchedWithKHRMaterialsCommon.b3dm | Bin 12088 -> 0 bytes .../tileset.json | 37 ------------------ .../Scene/Batched3DModel3DTileContentSpec.js | 8 ---- 3 files changed, 45 deletions(-) delete mode 100644 Specs/Data/Cesium3DTiles/Batched/BatchedWithKHRMaterialsCommon/batchedWithKHRMaterialsCommon.b3dm delete mode 100644 Specs/Data/Cesium3DTiles/Batched/BatchedWithKHRMaterialsCommon/tileset.json diff --git a/Specs/Data/Cesium3DTiles/Batched/BatchedWithKHRMaterialsCommon/batchedWithKHRMaterialsCommon.b3dm b/Specs/Data/Cesium3DTiles/Batched/BatchedWithKHRMaterialsCommon/batchedWithKHRMaterialsCommon.b3dm deleted file mode 100644 index fab6cb074ed9f0d772987cae33b3a70cd40a0df6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12088 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 diff --git a/Specs/Data/Cesium3DTiles/Batched/BatchedWithKHRMaterialsCommon/tileset.json b/Specs/Data/Cesium3DTiles/Batched/BatchedWithKHRMaterialsCommon/tileset.json deleted file mode 100644 index f0d7e48a17b5..000000000000 --- a/Specs/Data/Cesium3DTiles/Batched/BatchedWithKHRMaterialsCommon/tileset.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "asset": { - "version": "0.0" - }, - "properties": { - "Longitude": { - "minimum": -1.3196972173766555, - "maximum": -1.3196718547473905 - }, - "Latitude": { - "minimum": 0.6988624606923348, - "maximum": 0.6988888301460953 - }, - "Height": { - "minimum": 6.2074098233133554, - "maximum": 12.83180232718587 - } - }, - "geometricError": 70, - "root": { - "refine": "add", - "boundingVolume": { - "region": [ - -1.3197004795898053, - 0.6988582109, - -1.3196595204101946, - 0.6988897891, - 0, - 20 - ] - }, - "geometricError": 0, - "content": { - "url": "batchedWithKHRMaterialsCommon.b3dm" - } - } -} \ No newline at end of file diff --git a/Specs/Scene/Batched3DModel3DTileContentSpec.js b/Specs/Scene/Batched3DModel3DTileContentSpec.js index e58e55fd101d..ff34b4915793 100644 --- a/Specs/Scene/Batched3DModel3DTileContentSpec.js +++ b/Specs/Scene/Batched3DModel3DTileContentSpec.js @@ -24,7 +24,6 @@ defineSuite([ var withoutBatchTableUrl = './Data/Cesium3DTiles/Batched/BatchedWithoutBatchTable/'; var translucentUrl = './Data/Cesium3DTiles/Batched/BatchedTranslucent/'; var translucentOpaqueMixUrl = './Data/Cesium3DTiles/Batched/BatchedTranslucentOpaqueMix/'; - var withKHRMaterialsCommonUrl = './Data/Cesium3DTiles/Batched/BatchedWithKHRMaterialsCommon/'; var withTransformBoxUrl = './Data/Cesium3DTiles/Batched/BatchedWithTransformBox/'; var withTransformSphereUrl = './Data/Cesium3DTiles/Batched/BatchedWithTransformSphere/'; var withTransformRegionUrl = './Data/Cesium3DTiles/Batched/BatchedWithTransformRegion/'; @@ -144,13 +143,6 @@ defineSuite([ }); }); - it('renders with KHR_materials_common extension', function() { - // Tests that the batchId attribute and CESIUM_RTC extension are handled correctly - return Cesium3DTilesTester.loadTileset(scene, withKHRMaterialsCommonUrl).then(function(tileset) { - Cesium3DTilesTester.expectRenderTileset(scene, tileset); - }); - }); - function expectRenderWithTransform(url) { return Cesium3DTilesTester.loadTileset(scene, url).then(function(tileset) { Cesium3DTilesTester.expectRenderTileset(scene, tileset); From 8cb17a67c629d4064e59e2659a8eae1ef19d7417 Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Fri, 6 Jan 2017 14:11:42 -0500 Subject: [PATCH 18/29] moving fract and exp2 from CesiumMath to Expression --- Source/Core/Math.js | 30 ------------------------------ Source/Scene/Expression.js | 12 ++++++++++-- 2 files changed, 10 insertions(+), 32 deletions(-) diff --git a/Source/Core/Math.js b/Source/Core/Math.js index c81bca646ec8..7c9952c522b5 100644 --- a/Source/Core/Math.js +++ b/Source/Core/Math.js @@ -805,36 +805,6 @@ define([ return 2.0 * radius * Math.sin(angle * 0.5); }; - /** - * Returns the fractional part of a number, i.e. number minus floor(number) - * - * @param {Number} number The number whose fractional part will be returned. - * @returns {Number} The fractional part. - */ - CesiumMath.fract = function(number) { - //>>includeStart('debug', pragmas.debug); - if (!defined(number)) { - throw new DeveloperError('number is required.'); - } - //>>includeEnd('debug'); - return number - Math.floor(number); - }; - - /** - * Returns 2 raised to the power of exponent. - * - * @param {Number} exponent The power to which 2 will be raised. - * @returns {Number} The value of 2 raised to the power of exponent. - */ - CesiumMath.exp2 = function(exponent) { - //>>includeStart('debug', pragmas.debug); - if (!defined(number)) { - throw new DeveloperError('number is required.'); - } - //>>includeEnd('debug'); - return Math.pow(2.0,exponent); - }; - /** * Finds the logarithm of a number to a base. * diff --git a/Source/Scene/Expression.js b/Source/Scene/Expression.js index 83a3b49ebd4a..5b4417d1efba 100644 --- a/Source/Scene/Expression.js +++ b/Source/Scene/Expression.js @@ -68,10 +68,10 @@ define([ ceil : Math.ceil, round : Math.round, exp : Math.exp, - exp2 : CesiumMath.exp2, + exp2 : Expression.exp2, log : Math.log, log2 : Math.log2, - fract : CesiumMath.fract + fract : Expression.fract }; /** @@ -1128,6 +1128,14 @@ define([ return expressions; } + function fract(number) { + return number - Math.floor(number); + } + + function exp2(exponent) { + return Math.pow(2.0,exponent); + } + Node.prototype.getShaderExpression = function(attributePrefix, shaderState) { var color; var left; From 0c1313eafb9b19d9dd73c4af48262f3279a2d791 Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Fri, 6 Jan 2017 14:12:46 -0500 Subject: [PATCH 19/29] removed CesiumMath tests --- Specs/Core/MathSpec.js | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/Specs/Core/MathSpec.js b/Specs/Core/MathSpec.js index d86f96d33dd7..a52fa67e1bff 100644 --- a/Specs/Core/MathSpec.js +++ b/Specs/Core/MathSpec.js @@ -420,28 +420,6 @@ defineSuite([ }).toThrowDeveloperError(); }); - it('fract', function() { - expect(CesiumMath.fract(1.25)).toEqual(0.25); - }); - - it('fract throws without number', function() { - expect(function() { - CesiumMath.fract(undefined); - }).toThrowDeveloperError(); - }); - - it('exp2', function() { - expect(CesiumMath.exp2(0.0)).toEqual(1.0); - - expect(CesiumMath.exp2(2.0)).toEqual(4.0); - }); - - it('exp2 throws without number', function() { - expect(function() { - CesiumMath.exp2(undefined); - }).toThrowDeveloperError(); - }); - it('logBase', function() { expect(CesiumMath.logBase(64, 4)).toEqual(3); }); From c2eb1ec00a640d07768e6a8aaa3ccdb8e6da9493 Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Thu, 12 Jan 2017 11:17:48 -0500 Subject: [PATCH 20/29] trying to fix round --- Source/Scene/Expression.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Source/Scene/Expression.js b/Source/Scene/Expression.js index 5b4417d1efba..10d9c062a9ec 100644 --- a/Source/Scene/Expression.js +++ b/Source/Scene/Expression.js @@ -66,7 +66,6 @@ define([ sign : Math.sign, floor : Math.floor, ceil : Math.ceil, - round : Math.round, exp : Math.exp, exp2 : Expression.exp2, log : Math.log, @@ -371,6 +370,14 @@ define([ } val = createRuntimeAst(expression, args[0]); return new Node(ExpressionNodeType.UNARY, call, val); + } else if (call === 'round') { + //>>includeStart('debug', pragmas.debug); + if (args.length < 1 || args.length > 1) { + throw new DeveloperError('Error: ' + call + ' requires exactly one argument.'); + } + //>>includeEnd('debug'); + val = createRuntimeAst(expression, args[0]); + return new Node(ExpressionNodeType.UNARY, call, val); } else if (defined(unaryFunctions[call])) { //>>includeStart('debug', pragmas.debug); if (args.length < 1 || args.length > 1) { @@ -1201,6 +1208,8 @@ define([ return 'bool(' + left + ')'; } else if (value === 'Number') { return 'float(' + left + ')'; + } else if (value === 'round') { + return 'floor(' + left + '0.5)'; } else if (defined(unaryFunctions[value])) { return value + '(' + left + ')'; } else if (value === 'abs') { From 0635a0644c6218d330fb80885ece4080566015ee Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Thu, 12 Jan 2017 11:24:18 -0500 Subject: [PATCH 21/29] moved exp2 and fract to Expression --- Source/Scene/Expression.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Scene/Expression.js b/Source/Scene/Expression.js index 10d9c062a9ec..9f8d6c571495 100644 --- a/Source/Scene/Expression.js +++ b/Source/Scene/Expression.js @@ -67,10 +67,10 @@ define([ floor : Math.floor, ceil : Math.ceil, exp : Math.exp, - exp2 : Expression.exp2, + exp2 : exp2, log : Math.log, log2 : Math.log2, - fract : Expression.fract + fract : fract }; /** From 7e85fd42753cadbd24ab23b22975f1cdbbb61c97 Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Thu, 12 Jan 2017 11:32:02 -0500 Subject: [PATCH 22/29] resolving merge conflicts --- Source/Scene/Expression.js | 17 ++++++++++++++++- Specs/Scene/ExpressionSpec.js | 12 ++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Source/Scene/Expression.js b/Source/Scene/Expression.js index 9f8d6c571495..ac885d171a44 100644 --- a/Source/Scene/Expression.js +++ b/Source/Scene/Expression.js @@ -378,6 +378,21 @@ define([ //>>includeEnd('debug'); val = createRuntimeAst(expression, args[0]); return new Node(ExpressionNodeType.UNARY, call, val); + } else if (call === 'isExactClass' || call === 'isClass') { + //>>includeStart('debug', pragmas.debug); + if (argsLength < 1 || argsLength > 1) { + throw new DeveloperError('Error: ' + call + ' requires exactly one argument.'); + } + //>>includeEnd('debug'); + val = createRuntimeAst(expression, args[0]); + return new Node(ExpressionNodeType.UNARY, call, val); + } else if (call === 'getExactClassName') { + //>>includeStart('debug', pragmas.debug); + if (argsLength > 0) { + throw new DeveloperError('Error: ' + call + ' does not take any argument.'); + } + //>>includeEnd('debug'); + return new Node(ExpressionNodeType.UNARY, call); } else if (defined(unaryFunctions[call])) { //>>includeStart('debug', pragmas.debug); if (args.length < 1 || args.length > 1) { @@ -1143,7 +1158,7 @@ define([ return Math.pow(2.0,exponent); } - Node.prototype.getShaderExpression = function(attributePrefix, shaderState) { + Node.prototype.getShaderExpression = function(attributePrefix, shaderState, parent) { var color; var left; var right; diff --git a/Specs/Scene/ExpressionSpec.js b/Specs/Scene/ExpressionSpec.js index 71ea6e9190ff..17c39a36009c 100644 --- a/Specs/Scene/ExpressionSpec.js +++ b/Specs/Scene/ExpressionSpec.js @@ -2125,6 +2125,18 @@ defineSuite([ expect(shaderExpression).toEqual(expected); }); + it('gets shader expression for clamp', function() { + var expression = new Expression('clamp(50.0, 0.0, 100.0)'); + var shaderExpression = expression.getShaderExpression('', {}); + var expected = 'clamp(50.0, 0.0, 100.0)'; + expect(shaderExpression).toEqual(expected); + }); + + it('gets shader expression for mix', function() { + var expression = new Expression('mix(0.0, 2.0, 0.5)'); + var shaderExpression = expression.getShaderExpression('', {}); + var expected = 'mix(0.0, 2.0, 0.5)'; + it('gets shader expression for atan2', function() { var expression = new Expression('atan2(0.0,1.0)'); var shaderExpression = expression.getShaderExpression('', {}); From 1bf372e7670e037734a71d4134454422b283a216 Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Thu, 12 Jan 2017 11:36:05 -0500 Subject: [PATCH 23/29] round working --- Source/Scene/Expression.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Scene/Expression.js b/Source/Scene/Expression.js index ac885d171a44..025437f0a472 100644 --- a/Source/Scene/Expression.js +++ b/Source/Scene/Expression.js @@ -1224,7 +1224,7 @@ define([ } else if (value === 'Number') { return 'float(' + left + ')'; } else if (value === 'round') { - return 'floor(' + left + '0.5)'; + return 'floor(' + left + ' + 0.5)'; } else if (defined(unaryFunctions[value])) { return value + '(' + left + ')'; } else if (value === 'abs') { From 034b4f1c2b1624fd26b0760aac55df9c800fc381 Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Thu, 12 Jan 2017 12:24:38 -0500 Subject: [PATCH 24/29] changed round case to only shader area --- Source/Scene/Expression.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Source/Scene/Expression.js b/Source/Scene/Expression.js index 025437f0a472..a5dd1230e257 100644 --- a/Source/Scene/Expression.js +++ b/Source/Scene/Expression.js @@ -66,6 +66,7 @@ define([ sign : Math.sign, floor : Math.floor, ceil : Math.ceil, + round : Math.round, exp : Math.exp, exp2 : exp2, log : Math.log, @@ -370,14 +371,6 @@ define([ } val = createRuntimeAst(expression, args[0]); return new Node(ExpressionNodeType.UNARY, call, val); - } else if (call === 'round') { - //>>includeStart('debug', pragmas.debug); - if (args.length < 1 || args.length > 1) { - throw new DeveloperError('Error: ' + call + ' requires exactly one argument.'); - } - //>>includeEnd('debug'); - val = createRuntimeAst(expression, args[0]); - return new Node(ExpressionNodeType.UNARY, call, val); } else if (call === 'isExactClass' || call === 'isClass') { //>>includeStart('debug', pragmas.debug); if (argsLength < 1 || argsLength > 1) { From eaaa7245c75239b2534c349c4f983545f6b072de Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Thu, 12 Jan 2017 13:26:30 -0500 Subject: [PATCH 25/29] Fix up merge --- CONTRIBUTORS.md | 2 + Source/Scene/Batched3DModel3DTileContent.js | 3 +- Source/Scene/Model.js | 10 +++-- .../batchedWithKHRMaterialsCommon.b3dm | Bin 0 -> 12088 bytes .../tileset.json | 37 ++++++++++++++++++ .../Scene/Batched3DModel3DTileContentSpec.js | 8 ++++ gulpfile.js | 13 +++++- package.json | 2 +- 8 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 Specs/Data/Cesium3DTiles/Batched/BatchedWithKHRMaterialsCommon/batchedWithKHRMaterialsCommon.b3dm create mode 100644 Specs/Data/Cesium3DTiles/Batched/BatchedWithKHRMaterialsCommon/tileset.json diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 56d857621ae0..51d119ca3fd4 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -70,6 +70,8 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu * [Camptocamp SA](https://www.camptocamp.com/) * [Frédéric Junod](https://github.com/fredj) * [Guillaume Beraudo](https://github.com/gberaudo) +* [Safe Software](https://www.safe.com) + * [Joel Depooter](https://github.com/JDepooter) ## [Individual CLA](http://www.agi.com/licenses/individual-cla-agi-v1.0.txt) * [Victor Berchet](https://github.com/vicb) diff --git a/Source/Scene/Batched3DModel3DTileContent.js b/Source/Scene/Batched3DModel3DTileContent.js index e1a648cea073..1fd6ce2dddc2 100644 --- a/Source/Scene/Batched3DModel3DTileContent.js +++ b/Source/Scene/Batched3DModel3DTileContent.js @@ -317,7 +317,8 @@ define([ uniformMapLoaded : batchTable.getUniformMapCallback(), pickVertexShaderLoaded : getPickVertexShaderCallback(this), pickFragmentShaderLoaded : batchTable.getPickFragmentShaderCallback(), - pickUniformMapLoaded : batchTable.getPickUniformMapCallback() + pickUniformMapLoaded : batchTable.getPickUniformMapCallback(), + addBatchIdToGeneratedShaders : (batchLength > 0) // If the batch table has values in it, generated shaders will need a batchId attribute }); this._model = model; diff --git a/Source/Scene/Model.js b/Source/Scene/Model.js index 16deda092c35..0205d33c27a7 100644 --- a/Source/Scene/Model.js +++ b/Source/Scene/Model.js @@ -245,7 +245,9 @@ define([ // Note that this is a global cache, compared to renderer resources, which // are cached per context. function CachedGltf(options) { - this._gltf = modelMaterialsCommon(gltfDefaults(options.gltf)); + this._gltf = modelMaterialsCommon(gltfDefaults(options.gltf), { + addBatchIdToGeneratedShaders : options.addBatchIdToGeneratedShaders + }); this._bgltf = options.bgltf; this.ready = options.ready; this.modelsToLoad = []; @@ -394,13 +396,15 @@ define([ cachedGltf = new CachedGltf({ gltf : result.glTF, bgltf : gltf, - ready : true + ready : true, + addBatchIdToGeneratedShaders : options.addBatchIdToGeneratedShaders }); } else { // Normal glTF (JSON) cachedGltf = new CachedGltf({ gltf : options.gltf, - ready : true + ready : true, + addBatchIdToGeneratedShaders : options.addBatchIdToGeneratedShaders }); } diff --git a/Specs/Data/Cesium3DTiles/Batched/BatchedWithKHRMaterialsCommon/batchedWithKHRMaterialsCommon.b3dm b/Specs/Data/Cesium3DTiles/Batched/BatchedWithKHRMaterialsCommon/batchedWithKHRMaterialsCommon.b3dm new file mode 100644 index 0000000000000000000000000000000000000000..fab6cb074ed9f0d772987cae33b3a70cd40a0df6 GIT binary patch literal 12088 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 literal 0 HcmV?d00001 diff --git a/Specs/Data/Cesium3DTiles/Batched/BatchedWithKHRMaterialsCommon/tileset.json b/Specs/Data/Cesium3DTiles/Batched/BatchedWithKHRMaterialsCommon/tileset.json new file mode 100644 index 000000000000..f9fe0ca601fc --- /dev/null +++ b/Specs/Data/Cesium3DTiles/Batched/BatchedWithKHRMaterialsCommon/tileset.json @@ -0,0 +1,37 @@ +{ + "asset": { + "version": "0.0" + }, + "properties": { + "Longitude": { + "minimum": -1.3196972173766555, + "maximum": -1.3196718547473905 + }, + "Latitude": { + "minimum": 0.6988624606923348, + "maximum": 0.6988888301460953 + }, + "Height": { + "minimum": 6.2074098233133554, + "maximum": 12.83180232718587 + } + }, + "geometricError": 70, + "root": { + "refine": "add", + "boundingVolume": { + "region": [ + -1.3197004795898053, + 0.6988582109, + -1.3196595204101946, + 0.6988897891, + 0, + 20 + ] + }, + "geometricError": 0, + "content": { + "url": "batchedWithKHRMaterialsCommon.b3dm" + } + } +} diff --git a/Specs/Scene/Batched3DModel3DTileContentSpec.js b/Specs/Scene/Batched3DModel3DTileContentSpec.js index 73255ee079eb..23a84361de6c 100644 --- a/Specs/Scene/Batched3DModel3DTileContentSpec.js +++ b/Specs/Scene/Batched3DModel3DTileContentSpec.js @@ -28,6 +28,7 @@ defineSuite([ var withoutBatchTableUrl = './Data/Cesium3DTiles/Batched/BatchedWithoutBatchTable/'; var translucentUrl = './Data/Cesium3DTiles/Batched/BatchedTranslucent/'; var translucentOpaqueMixUrl = './Data/Cesium3DTiles/Batched/BatchedTranslucentOpaqueMix/'; + var withKHRMaterialsCommonUrl = './Data/Cesium3DTiles/Batched/BatchedWithKHRMaterialsCommon/'; var withTransformBoxUrl = './Data/Cesium3DTiles/Batched/BatchedWithTransformBox/'; var withTransformSphereUrl = './Data/Cesium3DTiles/Batched/BatchedWithTransformSphere/'; var withTransformRegionUrl = './Data/Cesium3DTiles/Batched/BatchedWithTransformRegion/'; @@ -156,6 +157,13 @@ defineSuite([ }); }); + it('renders with KHR_materials_common extension', function() { + // Tests that the batchId attribute and CESIUM_RTC extension are handled correctly + return Cesium3DTilesTester.loadTileset(scene, withKHRMaterialsCommonUrl).then(function(tileset) { + Cesium3DTilesTester.expectRenderTileset(scene, tileset); + }); + }); + function expectRenderWithTransform(url) { return Cesium3DTilesTester.loadTileset(scene, url).then(function(tileset) { Cesium3DTilesTester.expectRenderTileset(scene, tileset); diff --git a/gulpfile.js b/gulpfile.js index e821060f9ace..619232965ebf 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -12,8 +12,9 @@ var request = require('request'); var globby = require('globby'); var jshint = require('gulp-jshint'); +var gulpTap = require('gulp-tap'); var rimraf = require('rimraf'); -var stripComments = require('strip-comments'); +var glslStripComments = require('glsl-strip-comments'); var mkdirp = require('mkdirp'); var eventStream = require('event-stream'); var gulp = require('gulp'); @@ -288,6 +289,14 @@ gulp.task('makeZipFile', ['release'], function() { var indexSrc = gulp.src('index.release.html').pipe(gulpRename("index.html")); return eventStream.merge(builtSrc, staticSrc, indexSrc) + .pipe(gulpTap(function(file) { + // Work around an issue with gulp-zip where archives generated on Windows do + // not properly have their directory executable mode set. + // see https://github.com/sindresorhus/gulp-zip/issues/64#issuecomment-205324031 + if (file.isDirectory()) { + file.stat.mode = parseInt('40777', 8); + } + })) .pipe(gulpZip('Cesium-' + version + '.zip')) .pipe(gulp.dest('.')); }); @@ -993,7 +1002,7 @@ function glslToJavaScript(minify, minifyStateFilePath) { } if (minify) { - contents = stripComments(contents); + contents = glslStripComments(contents); contents = contents.replace(/\s+$/gm, '').replace(/^\s+/gm, '').replace(/\n+/gm, '\n'); contents += '\n'; } diff --git a/package.json b/package.json index eb2a53e1a46d..c5df42eebcee 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "email": "cesium-dev@googlegroups.com" }, "dependencies": { - "requirejs": "2.3.2" + "requirejs": "^2.3.2" }, "devDependencies": { "almond": "^0.3.3", From af2704f424bdc7b6b564c2580ded527664520481 Mon Sep 17 00:00:00 2001 From: Leesa Fini Date: Thu, 12 Jan 2017 16:40:37 -0500 Subject: [PATCH 26/29] changes made per reviewed --- .../gallery/3D Tiles Point Cloud Styling.html | 4 ++-- Source/Scene/Expression.js | 24 +++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Apps/Sandcastle/gallery/3D Tiles Point Cloud Styling.html b/Apps/Sandcastle/gallery/3D Tiles Point Cloud Styling.html index bd9fffb83d0f..094c3bd30667 100644 --- a/Apps/Sandcastle/gallery/3D Tiles Point Cloud Styling.html +++ b/Apps/Sandcastle/gallery/3D Tiles Point Cloud Styling.html @@ -125,7 +125,7 @@ }); addStyle('Sign', { - color : "color() * sign(${temperature})", + color : "rgb(sign(${POSITION}[0]) * 255, sign(${POSITION}[1]) * 255, sign(${POSITION}[2]) * 255)", pointSize : "5" }); @@ -140,7 +140,7 @@ }); addStyle('Fractional Part', { - color : "color() * fract(${temperature})", + color : "rgb(fract(${POSITION}[0]) * 255, fract(${POSITION}[1]) * 255, fract(${POSITION}[2]) * 255)", pointSize : "5" }); diff --git a/Source/Scene/Expression.js b/Source/Scene/Expression.js index 24d80a3391dd..f2e7fab7a92a 100644 --- a/Source/Scene/Expression.js +++ b/Source/Scene/Expression.js @@ -105,14 +105,14 @@ define([ atan : Math.atan, radians : CesiumMath.toRadians, degrees : CesiumMath.toDegrees, - sign : Math.sign, + sign : CesiumMath.sign, floor : Math.floor, ceil : Math.ceil, round : Math.round, exp : Math.exp, exp2 : exp2, log : Math.log, - log2 : Math.log2, + log2 : log2, fract : fract }; @@ -121,6 +121,18 @@ define([ mix : CesiumMath.lerp }; + function fract(number) { + return number - Math.floor(number); + } + + function exp2(exponent) { + return Math.pow(2.0,exponent); + } + + function log2(number) { + return CesiumMath.logBase(number, 2.0); + } + /** * Evaluates an expression defined using the * {@link https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/Styling|3D Tiles Styling language}. @@ -1413,14 +1425,6 @@ define([ return expressions; } - function fract(number) { - return number - Math.floor(number); - } - - function exp2(exponent) { - return Math.pow(2.0,exponent); - } - Node.prototype.getShaderExpression = function(attributePrefix, shaderState, parent) { var color; var left; From 9e8ee7609fbde61de30d5a84665e0e83c1854a30 Mon Sep 17 00:00:00 2001 From: LeesaFini Date: Thu, 12 Jan 2017 21:14:56 -0500 Subject: [PATCH 27/29] fixed tests --- Specs/Scene/ExpressionSpec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Specs/Scene/ExpressionSpec.js b/Specs/Scene/ExpressionSpec.js index 2b7633bcdb90..b0bc4010a057 100644 --- a/Specs/Scene/ExpressionSpec.js +++ b/Specs/Scene/ExpressionSpec.js @@ -1599,7 +1599,7 @@ defineSuite([ var expression = new Expression('log(1.0)'); expect(expression.evaluate(frameState, undefined)).toEqual(0.0); - expression = new Expression('log(Math.E)'); + expression = new Expression('log(10.0)'); expect(expression.evaluate(frameState, undefined)).toEqual(1.0); }); @@ -2671,7 +2671,7 @@ defineSuite([ it('gets shader expression for round', function() { var expression = new Expression('round(1.2)'); var shaderExpression = expression.getShaderExpression('', {}); - var expected = 'round(1.2)'; + var expected = 'floor(1.2 + 0.5)'; expect(shaderExpression).toEqual(expected); }); From 7650e3dae3abaa5fbd0f4c1020f7e74b5375ce01 Mon Sep 17 00:00:00 2001 From: LeesaFini Date: Thu, 12 Jan 2017 21:49:28 -0500 Subject: [PATCH 28/29] round test --- Specs/Scene/ExpressionSpec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Specs/Scene/ExpressionSpec.js b/Specs/Scene/ExpressionSpec.js index b0bc4010a057..bc452c756331 100644 --- a/Specs/Scene/ExpressionSpec.js +++ b/Specs/Scene/ExpressionSpec.js @@ -1599,7 +1599,7 @@ defineSuite([ var expression = new Expression('log(1.0)'); expect(expression.evaluate(frameState, undefined)).toEqual(0.0); - expression = new Expression('log(10.0)'); + expression = new Expression('log(Math.E)'); expect(expression.evaluate(frameState, undefined)).toEqual(1.0); }); From 792d2461604051c69f91ee7eac10b1dfb95d13dd Mon Sep 17 00:00:00 2001 From: LeesaFini Date: Thu, 12 Jan 2017 22:02:10 -0500 Subject: [PATCH 29/29] more round testing --- Specs/Scene/ExpressionSpec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Specs/Scene/ExpressionSpec.js b/Specs/Scene/ExpressionSpec.js index bc452c756331..9e8b5e67647e 100644 --- a/Specs/Scene/ExpressionSpec.js +++ b/Specs/Scene/ExpressionSpec.js @@ -1599,8 +1599,8 @@ defineSuite([ var expression = new Expression('log(1.0)'); expect(expression.evaluate(frameState, undefined)).toEqual(0.0); - expression = new Expression('log(Math.E)'); - expect(expression.evaluate(frameState, undefined)).toEqual(1.0); + expression = new Expression('log(10.0)'); + expect(expression.evaluate(frameState, undefined)).toEqual(2.302585092994046); }); it('throws if log function takes an invalid number of arguments', function() {