From f0af3cc72a55b059c9a6fcc84f62a5e50db12a41 Mon Sep 17 00:00:00 2001 From: Aditya Raisinghani Date: Sat, 7 Mar 2015 21:03:37 +0530 Subject: [PATCH 01/35] Add new button to SandCastle that loads Hello World example New Button added to the top toolbar. #1898 --- Apps/Sandcastle/CesiumSandcastle.js | 12 ++++++++++++ Apps/Sandcastle/index.html | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/Apps/Sandcastle/CesiumSandcastle.js b/Apps/Sandcastle/CesiumSandcastle.js index d46b327bc628..c8babd881faa 100644 --- a/Apps/Sandcastle/CesiumSandcastle.js +++ b/Apps/Sandcastle/CesiumSandcastle.js @@ -152,6 +152,7 @@ require({ var searchRegExp; var hintTimer; var currentTab = ''; + var newDemo; var galleryErrorMsg = document.createElement('span'); galleryErrorMsg.className = 'galleryError'; @@ -810,6 +811,14 @@ require({ } } + registry.byId('buttonNew').on('click', function() { + loadFromGallery(newDemo); + var demoSrc = newDemo.name + '.html'; + if (demoSrc !== window.location.search.substring(1)) { + window.history.pushState(newDemo, newDemo.name, '?src=' + demoSrc + '&label=' + currentTab); + } + document.title = newDemo.name + ' - Cesium Sandcastle'; + }); // Clicking the 'Run' button simply reloads the iframe. registry.byId('buttonRun').on('click', function() { CodeMirror.commands.runCesium(jsEditor); @@ -1004,6 +1013,9 @@ require({ demoLink.href = 'gallery/' + encodeURIComponent(demo.name) + '.html'; tab.appendChild(demoLink); + if(demo.name === "Hello World") { + newDemo = demo; + } demoLink.onclick = function(e) { if (mouse.isMiddle(e)) { window.open('gallery/' + demo.name + '.html'); diff --git a/Apps/Sandcastle/index.html b/Apps/Sandcastle/index.html index 85f72869d2c7..81a9135a7bcc 100644 --- a/Apps/Sandcastle/index.html +++ b/Apps/Sandcastle/index.html @@ -37,6 +37,10 @@
+
+ New +
+
Run (F8)
From 15679d5bfd17d8196397de503144efe35da182a0 Mon Sep 17 00:00:00 2001 From: Aditya Raisinghani Date: Tue, 17 Mar 2015 22:36:12 +0530 Subject: [PATCH 02/35] Fix string comparison to push to history stack. --- Apps/Sandcastle/CesiumSandcastle.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Apps/Sandcastle/CesiumSandcastle.js b/Apps/Sandcastle/CesiumSandcastle.js index c8babd881faa..2e990b284daf 100644 --- a/Apps/Sandcastle/CesiumSandcastle.js +++ b/Apps/Sandcastle/CesiumSandcastle.js @@ -814,8 +814,14 @@ require({ registry.byId('buttonNew').on('click', function() { loadFromGallery(newDemo); var demoSrc = newDemo.name + '.html'; - if (demoSrc !== window.location.search.substring(1)) { - window.history.pushState(newDemo, newDemo.name, '?src=' + demoSrc + '&label=' + currentTab); + var queries = window.location.search.substring(1).split('&'); + for(var i = 0; i < queries.length; i++){ + var key = queries.split('=')[0]; + if(key === "src"){ + if (demoSrc !== queries.split('=')[1]) { + window.history.pushState(newDemo, newDemo.name, '?src=' + demoSrc + '&label=' + currentTab); + } + } } document.title = newDemo.name + ' - Cesium Sandcastle'; }); From 5c934ae72ed182d6c3868a72dc987a18aab0de78 Mon Sep 17 00:00:00 2001 From: Aditya Raisinghani Date: Tue, 31 Mar 2015 16:40:42 +0530 Subject: [PATCH 03/35] Add confirmation to new button in Sandcastle. --- Apps/Sandcastle/CesiumSandcastle.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/Apps/Sandcastle/CesiumSandcastle.js b/Apps/Sandcastle/CesiumSandcastle.js index b5fb40fd9ae2..cbcfaf5a9655 100644 --- a/Apps/Sandcastle/CesiumSandcastle.js +++ b/Apps/Sandcastle/CesiumSandcastle.js @@ -823,18 +823,26 @@ require({ } registry.byId('buttonNew').on('click', function() { - loadFromGallery(newDemo); - var demoSrc = newDemo.name + '.html'; - var queries = window.location.search.substring(1).split('&'); - for(var i = 0; i < queries.length; i++){ - var key = queries.split('=')[0]; - if(key === "src"){ - if (demoSrc !== queries.split('=')[1]) { - window.history.pushState(newDemo, newDemo.name, '?src=' + demoSrc + '&label=' + currentTab); + var htmlText = (htmlEditor.getValue()).replace(/\s/g, ''); + var jsText = (jsEditor.getValue()).replace(/\s/g, ''); + var confirmChange = true; + if (demoHtml !== htmlText || demoJs !== jsText) { + confirmChange = window.confirm('You have unsaved changes. Are you sure you want to navigate away from this demo?'); + } + if(confirmChange){ + loadFromGallery(newDemo); + var demoSrc = newDemo.name + '.html'; + var queries = window.location.search.substring(1).split('&'); + for(var i = 0; i < queries.length; i++){ + var key = queries.split('=')[0]; + if(key === "src"){ + if (demoSrc !== queries.split('=')[1]) { + window.history.pushState(newDemo, newDemo.name, '?src=' + demoSrc + '&label=' + currentTab); + } } } + document.title = newDemo.name + ' - Cesium Sandcastle'; } - document.title = newDemo.name + ' - Cesium Sandcastle'; }); // Clicking the 'Run' button simply reloads the iframe. registry.byId('buttonRun').on('click', function() { From 11be717eb7aefb955de18e25ebdda81a333054da Mon Sep 17 00:00:00 2001 From: manujain Date: Wed, 11 Mar 2015 00:21:32 +0530 Subject: [PATCH 04/35] Issue #2287 fixed --- Source/Scene/Primitive.js | 5 +++++ Specs/Scene/PrimitiveSpec.js | 24 ++++++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Source/Scene/Primitive.js b/Source/Scene/Primitive.js index 32cfc0b9fa4e..78d989aa2fb0 100644 --- a/Source/Scene/Primitive.js +++ b/Source/Scene/Primitive.js @@ -706,6 +706,7 @@ define([ * * @exception {DeveloperError} All instance geometries must have the same primitiveType. * @exception {DeveloperError} Appearance and material have a uniform with the same name. + * @exception {DeveloperError} If the model matrix is changed after creation, it only affects primitives with one instance and only in 3D mode. */ Primitive.prototype.update = function(context, frameState, commandList) { if (((!defined(this.geometryInstances)) && (this._va.length === 0)) || @@ -1221,6 +1222,10 @@ define([ modelMatrix = this.modelMatrix; } + if (!Matrix4.equals(this.modelMatrix, Matrix4.IDENTITY) && ((this._numberOfInstances > 1 && !this._validModelMatrix) || (frameState.mode === SceneMode.SCENE2D || frameState.mode === SceneMode.COLUMBUS_VIEW))) { + throw new DeveloperError('If the model matrix is changed after creation, it only affects primitives with one instance and only in 3D mode.'); + } + if (!Matrix4.equals(modelMatrix, this._modelMatrix)) { Matrix4.clone(modelMatrix, this._modelMatrix); length = this._boundingSpheres.length; diff --git a/Specs/Scene/PrimitiveSpec.js b/Specs/Scene/PrimitiveSpec.js index d2bcebf79cac..e119843be5c5 100644 --- a/Specs/Scene/PrimitiveSpec.js +++ b/Specs/Scene/PrimitiveSpec.js @@ -514,7 +514,7 @@ defineSuite([ frameState.scene3DOnly = false; }); - it('does not update model matrix for more than one instance in 3D with different model matrices', function() { + it('update model matrix throws for more than one instance in 3D with different model matrices', function() { var primitive = new Primitive({ geometryInstances : [rectangleInstance1, rectangleInstance2], appearance : new PerInstanceColorAppearance(), @@ -530,14 +530,14 @@ defineSuite([ primitive.modelMatrix = modelMatrix; commands.length = 0; - primitive.update(context, frameState, commands); - expect(commands.length).toEqual(1); - expect(commands[0].modelMatrix).toEqual(Matrix4.IDENTITY); + expect(function() { + primitive.update(context, frameState, commands); + }).toThrowDeveloperError(); primitive = primitive && primitive.destroy(); }); - it('does not update model matrix in Columbus view', function() { + it('update model matrix throws in Columbus view', function() { var primitive = new Primitive({ geometryInstances : [rectangleInstance1, rectangleInstance2], appearance : new PerInstanceColorAppearance(), @@ -555,15 +555,15 @@ defineSuite([ primitive.modelMatrix = modelMatrix; commands.length = 0; - primitive.update(context, frameState, commands); - expect(commands.length).toEqual(1); - expect(commands[0].modelMatrix).toEqual(Matrix4.IDENTITY); + expect(function() { + primitive.update(context, frameState, commands); + }).toThrowDeveloperError(); frameState = createFrameState(); // reset frame state primitive = primitive && primitive.destroy(); }); - it('does not update model matrix in 2D', function() { + it('update model matrix throws in 2D', function() { var primitive = new Primitive({ geometryInstances : [rectangleInstance1, rectangleInstance2], appearance : new PerInstanceColorAppearance(), @@ -581,9 +581,9 @@ defineSuite([ primitive.modelMatrix = modelMatrix; commands.length = 0; - primitive.update(context, frameState, commands); - expect(commands.length).toEqual(1); - expect(commands[0].modelMatrix).toEqual(Matrix4.IDENTITY); + expect(function() { + primitive.update(context, frameState, []); + }).toThrowDeveloperError(); frameState = createFrameState(); // reset frame state primitive = primitive && primitive.destroy(); From 2dd21f0f672f370915fbcec1cdfd695a1e4a4675 Mon Sep 17 00:00:00 2001 From: manujain Date: Tue, 17 Mar 2015 19:58:37 +0530 Subject: [PATCH 05/35] CHANGES.md updated --- CHANGES.md | 1 + Source/Scene/Primitive.js | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index d676279d2c8c..7a0cfa5eb170 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -28,6 +28,7 @@ Change Log * Added new construction options to `CesiumWidget` and `Viewer`, for `skyBox`, `skyAtmosphere`, and `globe`. * Fixed a bug that prevented Cesium from working in browser configurations that explicitly disabled localStorage, such as Safari's private browsing mode. * Cesium is now tested using Jasmine 2.2.0. +* Exception will be thrown on updating Primitive.modelMatrix in 2D or Columbus View or if it has more than one instance. ### 1.7.1 - 2015-03-06 diff --git a/Source/Scene/Primitive.js b/Source/Scene/Primitive.js index 78d989aa2fb0..1ee4c239d257 100644 --- a/Source/Scene/Primitive.js +++ b/Source/Scene/Primitive.js @@ -706,7 +706,7 @@ define([ * * @exception {DeveloperError} All instance geometries must have the same primitiveType. * @exception {DeveloperError} Appearance and material have a uniform with the same name. - * @exception {DeveloperError} If the model matrix is changed after creation, it only affects primitives with one instance and only in 3D mode. + * @exception {DeveloperError} Primitive.modelMatrix is only supported in 3D mode and only for single geometry instances. */ Primitive.prototype.update = function(context, frameState, commandList) { if (((!defined(this.geometryInstances)) && (this._va.length === 0)) || @@ -1222,9 +1222,11 @@ define([ modelMatrix = this.modelMatrix; } - if (!Matrix4.equals(this.modelMatrix, Matrix4.IDENTITY) && ((this._numberOfInstances > 1 && !this._validModelMatrix) || (frameState.mode === SceneMode.SCENE2D || frameState.mode === SceneMode.COLUMBUS_VIEW))) { - throw new DeveloperError('If the model matrix is changed after creation, it only affects primitives with one instance and only in 3D mode.'); + //>>includeStart('debug', pragmas.debug); + if (!Matrix4.equals(this.modelMatrix, Matrix4.IDENTITY) && ((this._numberOfInstances > 1 && !this._validModelMatrix) || frameState.mode !== SceneMode.SCENE3D)) { + throw new DeveloperError('Primitive.modelMatrix is only supported in 3D mode and only for single geometry instances.'); } + //>>includeEnd('debug'); if (!Matrix4.equals(modelMatrix, this._modelMatrix)) { Matrix4.clone(modelMatrix, this._modelMatrix); From 4a25cd76c747da127bc0dc506fc1c56c31cf0bee Mon Sep 17 00:00:00 2001 From: manujain Date: Thu, 2 Apr 2015 01:14:22 +0530 Subject: [PATCH 06/35] Moved to upper IF --- Source/Scene/Primitive.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Source/Scene/Primitive.js b/Source/Scene/Primitive.js index 1ee4c239d257..5bb7e629e018 100644 --- a/Source/Scene/Primitive.js +++ b/Source/Scene/Primitive.js @@ -1218,16 +1218,17 @@ define([ var modelMatrix; if ((this._numberOfInstances > 1 && !this._validModelMatrix) || frameState.mode !== SceneMode.SCENE3D) { modelMatrix = Matrix4.IDENTITY; + + //>>includeStart('debug', pragmas.debug); + if (!Matrix4.equals(this.modelMatrix, Matrix4.IDENTITY)) { + throw new DeveloperError('Primitive.modelMatrix is only supported in 3D mode and only for single geometry instances.'); + } + //>>includeEnd('debug'); + } else { modelMatrix = this.modelMatrix; } - //>>includeStart('debug', pragmas.debug); - if (!Matrix4.equals(this.modelMatrix, Matrix4.IDENTITY) && ((this._numberOfInstances > 1 && !this._validModelMatrix) || frameState.mode !== SceneMode.SCENE3D)) { - throw new DeveloperError('Primitive.modelMatrix is only supported in 3D mode and only for single geometry instances.'); - } - //>>includeEnd('debug'); - if (!Matrix4.equals(modelMatrix, this._modelMatrix)) { Matrix4.clone(modelMatrix, this._modelMatrix); length = this._boundingSpheres.length; From 27ba4e6bd5d1797a76a03d0d05c0834da7ef8502 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Thu, 2 Apr 2015 14:07:51 -0400 Subject: [PATCH 07/35] Fix caching issue with entity geometry If you removed an entity with geometry and then immediately added a new entity with the old entity's id, none of the geometry graphics would ever update because the visualizers had a handle to the old, removed entity. --- Source/DataSources/DataSourceDisplay.js | 2 - Source/DataSources/GeometryVisualizer.js | 27 ++++++--- Specs/DataSources/GeometryVisualizerSpec.js | 63 +++++++++++++++++++++ 3 files changed, 82 insertions(+), 10 deletions(-) diff --git a/Source/DataSources/DataSourceDisplay.js b/Source/DataSources/DataSourceDisplay.js index 9c752da54434..9cdacd9b0590 100644 --- a/Source/DataSources/DataSourceDisplay.js +++ b/Source/DataSources/DataSourceDisplay.js @@ -96,8 +96,6 @@ define([ } var defaultDataSource = new CustomDataSource(); - var visualizers = this._visualizersCallback(this._scene, defaultDataSource); - defaultDataSource._visualizers = visualizers; this._onDataSourceAdded(undefined, defaultDataSource); this._defaultDataSource = defaultDataSource; }; diff --git a/Source/DataSources/GeometryVisualizer.js b/Source/DataSources/GeometryVisualizer.js index d8572dc1306d..bd64c9933aba 100644 --- a/Source/DataSources/GeometryVisualizer.js +++ b/Source/DataSources/GeometryVisualizer.js @@ -178,6 +178,25 @@ define([ var id; var updater; + for (i = changed.length - 1; i > -1; i--) { + entity = changed[i]; + id = entity.id; + updater = this._updaters.get(id); + + //If in a single update, an entity gets removed and a new instance + //re-added with the same id, the updater no longer tracks the + //correct entity, we need to both remove the old one and + //add the new one, which is done by pushing the entity + //onto the removed/added lists. + if (updater.entity === entity) { + removeUpdater(this, updater); + insertUpdaterIntoBatch(this, time, updater); + } else { + removed.push(entity); + added.push(entity); + } + } + for (i = removed.length - 1; i > -1; i--) { entity = removed[i]; id = entity.id; @@ -198,14 +217,6 @@ define([ this._subscriptions.set(id, updater.geometryChanged.addEventListener(GeometryVisualizer._onGeometryChanged, this)); } - for (i = changed.length - 1; i > -1; i--) { - entity = changed[i]; - id = entity.id; - updater = this._updaters.get(id); - removeUpdater(this, updater); - insertUpdaterIntoBatch(this, time, updater); - } - addedObjects.removeAll(); removedObjects.removeAll(); changedObjects.removeAll(); diff --git a/Specs/DataSources/GeometryVisualizerSpec.js b/Specs/DataSources/GeometryVisualizerSpec.js index 77148b0e3ac4..05dd9dbb6894 100644 --- a/Specs/DataSources/GeometryVisualizerSpec.js +++ b/Specs/DataSources/GeometryVisualizerSpec.js @@ -485,4 +485,67 @@ defineSuite([ visualizer.destroy(); }); + + it('Can remove and entity and then add a new new instance with the same id.', function() { + var objects = new EntityCollection(); + var visualizer = new GeometryVisualizer(EllipseGeometryUpdater, scene, objects); + + var entity = new Entity({ + id : 'test', + position : Cartesian3.fromDegrees(0, 0, 0), + ellipse : { + semiMajorAxis : 2, + semiMinorAxis : 1, + material : Color.ORANGE + } + }); + objects.add(entity); + + return pollToPromise(function() { + scene.initializeFrame(); + var isUpdated = visualizer.update(time); + scene.render(time); + return isUpdated; + }).then(function() { + objects.remove(entity); + + var entity2 = new Entity({ + id : 'test', + position : Cartesian3.fromDegrees(0, 0, 0), + ellipse : { + semiMajorAxis : 2, + semiMinorAxis : 1, + material : Color.BLUE + } + }); + objects.add(entity2); + + return pollToPromise(function() { + scene.initializeFrame(); + var isUpdated = visualizer.update(time); + scene.render(time); + return isUpdated; + }).then(function() { + + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity2); + expect(attributes).toBeDefined(); + expect(attributes.show).toEqual(ShowGeometryInstanceAttribute.toValue(true)); + expect(attributes.color).toEqual(ColorGeometryInstanceAttribute.toValue(Color.BLUE)); + expect(primitive.appearance).toBeInstanceOf(EllipseGeometryUpdater.perInstanceColorAppearanceType); + + objects.remove(entity); + + return pollToPromise(function() { + scene.initializeFrame(); + expect(visualizer.update(time)).toBe(true); + scene.render(time); + return scene.primitives.length === 0; + }).then(function() { + visualizer.destroy(); + }); + }); + }); + }); + }, 'WebGL'); From ecddbea721f6ee0c54931f5b539fe213a3339aca Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Thu, 2 Apr 2015 16:01:01 -0400 Subject: [PATCH 08/35] Tweaks to #2569 CHANGES needed to be udpated. Also, after investigating further, I realized our doc has been inconsistent for a long time. We actually do support setting modelMatrix for batched geometry in 3D mode. The number of instances have no affect. --- CHANGES.md | 8 +++++++- Source/Scene/Primitive.js | 21 +++++++-------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 7a0cfa5eb170..643033f77343 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,13 @@ Change Log ========== +### 1.8 -2015-04-01 +* Breaking changes + * +* Deprecated + * +* An exception is now thrown if `Primitive.modelMatrix` is not the identity matrix when in in 2D or Columbus View. + ### 1.8 -2015-04-01 * Breaking changes @@ -28,7 +35,6 @@ Change Log * Added new construction options to `CesiumWidget` and `Viewer`, for `skyBox`, `skyAtmosphere`, and `globe`. * Fixed a bug that prevented Cesium from working in browser configurations that explicitly disabled localStorage, such as Safari's private browsing mode. * Cesium is now tested using Jasmine 2.2.0. -* Exception will be thrown on updating Primitive.modelMatrix in 2D or Columbus View or if it has more than one instance. ### 1.7.1 - 2015-03-06 diff --git a/Source/Scene/Primitive.js b/Source/Scene/Primitive.js index 5bb7e629e018..8b6b42f4f6ac 100644 --- a/Source/Scene/Primitive.js +++ b/Source/Scene/Primitive.js @@ -204,7 +204,7 @@ define([ * by {@link Transforms.eastNorthUpToFixedFrame}. * *

- * If the model matrix is changed after creation, it only affects primitives with one instance and only in 3D mode. + * This property is only supported in 3D mode. *

* * @type Matrix4 @@ -706,7 +706,7 @@ define([ * * @exception {DeveloperError} All instance geometries must have the same primitiveType. * @exception {DeveloperError} Appearance and material have a uniform with the same name. - * @exception {DeveloperError} Primitive.modelMatrix is only supported in 3D mode and only for single geometry instances. + * @exception {DeveloperError} Primitive.modelMatrix is only supported in 3D mode. */ Primitive.prototype.update = function(context, frameState, commandList) { if (((!defined(this.geometryInstances)) && (this._va.length === 0)) || @@ -1215,19 +1215,12 @@ define([ attributes.length = 0; } - var modelMatrix; - if ((this._numberOfInstances > 1 && !this._validModelMatrix) || frameState.mode !== SceneMode.SCENE3D) { - modelMatrix = Matrix4.IDENTITY; - - //>>includeStart('debug', pragmas.debug); - if (!Matrix4.equals(this.modelMatrix, Matrix4.IDENTITY)) { - throw new DeveloperError('Primitive.modelMatrix is only supported in 3D mode and only for single geometry instances.'); - } - //>>includeEnd('debug'); - - } else { - modelMatrix = this.modelMatrix; + var modelMatrix = this.modelMatrix; + //>>includeStart('debug', pragmas.debug); + if (frameState.mode !== SceneMode.SCENE3D && !Matrix4.equals(modelMatrix, Matrix4.IDENTITY)) { + throw new DeveloperError('Primitive.modelMatrix is only supported in 3D mode.'); } + //>>includeEnd('debug'); if (!Matrix4.equals(modelMatrix, this._modelMatrix)) { Matrix4.clone(modelMatrix, this._modelMatrix); From ae372dd47d5565cc3715122cc3a2f1106207deae Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Thu, 2 Apr 2015 16:14:22 -0400 Subject: [PATCH 09/35] Remove now invalid (and failing test). --- Specs/Scene/PrimitiveSpec.js | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/Specs/Scene/PrimitiveSpec.js b/Specs/Scene/PrimitiveSpec.js index e119843be5c5..ea4500b87698 100644 --- a/Specs/Scene/PrimitiveSpec.js +++ b/Specs/Scene/PrimitiveSpec.js @@ -514,29 +514,6 @@ defineSuite([ frameState.scene3DOnly = false; }); - it('update model matrix throws for more than one instance in 3D with different model matrices', function() { - var primitive = new Primitive({ - geometryInstances : [rectangleInstance1, rectangleInstance2], - appearance : new PerInstanceColorAppearance(), - asynchronous : false - }); - - var commands = []; - primitive.update(context, frameState, commands); - expect(commands.length).toEqual(1); - expect(commands[0].modelMatrix).toEqual(Matrix4.IDENTITY); - - var modelMatrix = Matrix4.fromUniformScale(10.0); - primitive.modelMatrix = modelMatrix; - - commands.length = 0; - expect(function() { - primitive.update(context, frameState, commands); - }).toThrowDeveloperError(); - - primitive = primitive && primitive.destroy(); - }); - it('update model matrix throws in Columbus view', function() { var primitive = new Primitive({ geometryInstances : [rectangleInstance1, rectangleInstance2], From 99fbca297869880d5f7f0f14d3b875db670fb283 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Thu, 2 Apr 2015 16:20:26 -0400 Subject: [PATCH 10/35] Fix CHANGES --- CHANGES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 643033f77343..f643ef4c7c81 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,14 +1,14 @@ Change Log ========== -### 1.8 -2015-04-01 +### 1.9 - 2015-05-01 * Breaking changes * * Deprecated * * An exception is now thrown if `Primitive.modelMatrix` is not the identity matrix when in in 2D or Columbus View. -### 1.8 -2015-04-01 +### 1.8 - 2015-04-01 * Breaking changes * Removed the `eye`, `target`, and `up` parameters to `Camera.lookAt` which were deprecated in Cesium 1.6. Use the `target` and `offset`. From 0a9653480f833fbd0438c30447172cf87bef2f64 Mon Sep 17 00:00:00 2001 From: Aditya Raisinghani Date: Tue, 7 Apr 2015 02:20:57 +0530 Subject: [PATCH 11/35] Fixed issue with push history --- Apps/Sandcastle/CesiumSandcastle.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Apps/Sandcastle/CesiumSandcastle.js b/Apps/Sandcastle/CesiumSandcastle.js index cbcfaf5a9655..d03e1bfcebae 100644 --- a/Apps/Sandcastle/CesiumSandcastle.js +++ b/Apps/Sandcastle/CesiumSandcastle.js @@ -834,9 +834,9 @@ require({ var demoSrc = newDemo.name + '.html'; var queries = window.location.search.substring(1).split('&'); for(var i = 0; i < queries.length; i++){ - var key = queries.split('=')[0]; + var key = queries[i].split('=')[0]; if(key === "src"){ - if (demoSrc !== queries.split('=')[1]) { + if (demoSrc !== queries[i].split('=')[1].replace('%20', ' ')) { window.history.pushState(newDemo, newDemo.name, '?src=' + demoSrc + '&label=' + currentTab); } } From b691b8aab75ffbc216dc375d5398af61214f2958 Mon Sep 17 00:00:00 2001 From: Ed Mackey Date: Tue, 7 Apr 2015 10:13:29 -0400 Subject: [PATCH 12/35] Update CONTRIBUTORS.md --- CONTRIBUTORS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 84a89b53ad54..63eec504a400 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -55,5 +55,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu * [Gilles Cébélieu (IGN France)](https://github.com/gcebelieu) * [Guillaume Beraudo](https://github.com/gberaudo) * [Thomas Hirsch](https://github.com/relet) +* [Ayush Khandelwal](https://github.com/ayk115) +* [Aditya Raisinghani](https://github.com/adi2412) Also see [our contributors page](http://cesiumjs.org/contributors.html) for more information. From ace9e602ca1fcf0c8f2445348de66e7a9793fd7f Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Wed, 8 Apr 2015 12:56:30 -0400 Subject: [PATCH 13/35] Fix Corridor Geometry for sharp corners As reported on [the forum](https://groups.google.com/d/msg/cesium-dev/conwnTxfDkk/9Z3I8pdTv2cJ). --- Source/Core/CorridorGeometryLibrary.js | 2 +- Specs/Core/CorridorGeometrySpec.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Source/Core/CorridorGeometryLibrary.js b/Source/Core/CorridorGeometryLibrary.js index d937443a23c1..418fcf3d3573 100644 --- a/Source/Core/CorridorGeometryLibrary.js +++ b/Source/Core/CorridorGeometryLibrary.js @@ -219,7 +219,7 @@ define([ Cartesian3.subtract(backward, backwardProjection, backwardProjection); Cartesian3.normalize(backwardProjection, backwardProjection); - var doCorner = !CesiumMath.equalsEpsilon(Math.abs(Cartesian3.dot(forwardProjection, backwardProjection)), 1.0, CesiumMath.EPSILON1); + var doCorner = !CesiumMath.equalsEpsilon(Math.abs(Cartesian3.dot(forwardProjection, backwardProjection)), 1.0, CesiumMath.EPSILON7); if (doCorner) { cornerDirection = Cartesian3.cross(cornerDirection, normal, cornerDirection); diff --git a/Specs/Core/CorridorGeometrySpec.js b/Specs/Core/CorridorGeometrySpec.js index e531decff19b..58ea955b6a55 100644 --- a/Specs/Core/CorridorGeometrySpec.js +++ b/Specs/Core/CorridorGeometrySpec.js @@ -180,6 +180,24 @@ defineSuite([ expect(m.indices.length).toEqual(3 * 8); }); + it('computes sharp turns', function() { + var m = CorridorGeometry.createGeometry(new CorridorGeometry({ + vertexFormat : VertexFormat.POSITION_ONLY, + positions : Cartesian3.fromDegreesArray([ + 2.00571672577652,52.7781459942399, + 1.99188457974115,52.7764958852886, + 2.01325961458495,52.7674170680511, + 1.98708058340534,52.7733979856253, + 2.00634853946644,52.7650460748473 + ]), + cornerType: CornerType.BEVELED, + width : 100 + })); + + expect(m.attributes.position.values.length).toEqual(3 * 13); + expect(m.indices.length).toEqual(3 * 11); + }); + it('computes straight corridors', function() { var m = CorridorGeometry.createGeometry(new CorridorGeometry({ vertexFormat : VertexFormat.POSITION_ONLY, From 887a573f8d8d7cfe67bd553dcbf9973ae763a951 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Fri, 10 Apr 2015 10:01:57 -0400 Subject: [PATCH 14/35] Fix bad epsilon in PolylineVolumeGeometryLibrary. --- Source/Core/PolylineVolumeGeometryLibrary.js | 2 +- Specs/Core/PolylineVolumeGeometrySpec.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Source/Core/PolylineVolumeGeometryLibrary.js b/Source/Core/PolylineVolumeGeometryLibrary.js index 9df76e151611..39e5733aaeba 100644 --- a/Source/Core/PolylineVolumeGeometryLibrary.js +++ b/Source/Core/PolylineVolumeGeometryLibrary.js @@ -350,7 +350,7 @@ define([ Cartesian3.subtract(backward, backwardProjection, backwardProjection); Cartesian3.normalize(backwardProjection, backwardProjection); - var doCorner = !CesiumMath.equalsEpsilon(Math.abs(Cartesian3.dot(forwardProjection, backwardProjection)), 1.0, CesiumMath.EPSILON1); + var doCorner = !CesiumMath.equalsEpsilon(Math.abs(Cartesian3.dot(forwardProjection, backwardProjection)), 1.0, CesiumMath.EPSILON7); if (doCorner) { cornerDirection = Cartesian3.cross(cornerDirection, surfaceNormal, cornerDirection); diff --git a/Specs/Core/PolylineVolumeGeometrySpec.js b/Specs/Core/PolylineVolumeGeometrySpec.js index de819ab2a7bc..a8cec93e6a27 100644 --- a/Specs/Core/PolylineVolumeGeometrySpec.js +++ b/Specs/Core/PolylineVolumeGeometrySpec.js @@ -169,6 +169,24 @@ defineSuite([ expect(m.indices.length).toEqual(3 * (8 * 2 + 4 * 7 * 2 + 4)); }); + it('computes sharp turns', function() { + var m = PolylineVolumeGeometry.createGeometry(new PolylineVolumeGeometry({ + vertexFormat : VertexFormat.POSITION_ONLY, + polylinePositions : Cartesian3.fromDegreesArrayHeights([ + 2.00571672577652, 52.7781459942399, 500, + 1.99188457974115, 52.7764958852886, 500, + 2.01325961458495, 52.7674170680511, 500, + 1.98708058340534, 52.7733979856253, 500, + 2.00634853946644, 52.7650460748473, 500 + ]), + cornerType: CornerType.BEVELED, + shapePositions: shape + })); + + expect(m.attributes.position.values.length).toEqual(360); + expect(m.indices.length).toEqual(324); + }); + it('computes straight volume', function() { var m = PolylineVolumeGeometry.createGeometry(new PolylineVolumeGeometry({ vertexFormat : VertexFormat.POSITION_ONLY, From ec773abd68a9531d402770b17cfc47d9f22dbc00 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Fri, 10 Apr 2015 14:30:22 -0400 Subject: [PATCH 15/35] Fix crash when adding and removing a billboard before next update. As [reported on the forum](https://groups.google.com/d/msg/cesium-dev/Ti4jLsugBq4/13Qo5_daa68J), adding and then removing a billboard before the collection is updated causes a crash because we don't remove the billboards before trying to recreate the atlas. The new test I added fails in master but passes in this branch. --- Source/Scene/BillboardCollection.js | 3 ++- Specs/Scene/BillboardCollectionSpec.js | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/Scene/BillboardCollection.js b/Source/Scene/BillboardCollection.js index bf87bb75e79c..9a1975acc216 100644 --- a/Source/Scene/BillboardCollection.js +++ b/Source/Scene/BillboardCollection.js @@ -1015,6 +1015,8 @@ define([ * @exception {RuntimeError} image with id must be in the atlas. */ BillboardCollection.prototype.update = function(context, frameState, commandList) { + removeBillboards(this); + var billboards = this._billboards; var billboardsLength = billboards.length; @@ -1036,7 +1038,6 @@ define([ return; } - removeBillboards(this); updateMode(this, frameState); billboards = this._billboards; diff --git a/Specs/Scene/BillboardCollectionSpec.js b/Specs/Scene/BillboardCollectionSpec.js index 9ec937ce6872..a9366ed83db0 100644 --- a/Specs/Scene/BillboardCollectionSpec.js +++ b/Specs/Scene/BillboardCollectionSpec.js @@ -122,6 +122,12 @@ defineSuite([ expect(b.id).not.toBeDefined(); }); + it('can add and remove before first update.', function() { + var b = billboards.add(); + billboards.remove(b); + billboards.update(context, frameState, []); + }); + it('explicitly constructs a billboard', function() { var b = billboards.add({ show : false, From 1df507b8923a8f604dc8713800e474ee7d2f441f Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Tue, 14 Apr 2015 19:40:00 -0400 Subject: [PATCH 16/35] Fix doc and remove bad link. Fixes #2494 --- Source/Core/EllipseGeometry.js | 6 ++---- Source/DataSources/EllipseGraphics.js | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Source/Core/EllipseGeometry.js b/Source/Core/EllipseGeometry.js index ddadf2cf063e..6ce1fe7dbfc7 100644 --- a/Source/Core/EllipseGeometry.js +++ b/Source/Core/EllipseGeometry.js @@ -600,8 +600,8 @@ define([ * @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid the ellipse will be on. * @param {Number} [options.height=0.0] The height above the ellipsoid. * @param {Number} [options.extrudedHeight] The height of the extrusion. - * @param {Number} [options.rotation=0.0] The angle from north (clockwise) in radians. - * @param {Number} [options.stRotation=0.0] The rotation of the texture coordinates, in radians. A positive rotation is counter-clockwise. + * @param {Property} [options.rotation=0.0] The angle of rotation counter-clockwise from north. + * @param {Property} [options.stRotation=0.0] The rotation of the texture coordinates counter-clockwise from north. * @param {Number} [options.granularity=CesiumMath.RADIANS_PER_DEGREE] The angular distance between points on the ellipse in radians. * @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed. * @@ -611,8 +611,6 @@ define([ * * @see EllipseGeometry.createGeometry * - * @demo {@link http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Ellipse.html|Cesium Sandcastle Ellipse Demo} - * * @example * // Create an ellipse. * var ellipse = new Cesium.EllipseGeometry({ diff --git a/Source/DataSources/EllipseGraphics.js b/Source/DataSources/EllipseGraphics.js index 7e1511a8769c..eaa561e7de7a 100644 --- a/Source/DataSources/EllipseGraphics.js +++ b/Source/DataSources/EllipseGraphics.js @@ -38,7 +38,7 @@ define([ * @param {Property} [options.outlineColor=Color.BLACK] A Property specifying the {@link Color} of the outline. * @param {Property} [options.outlineWidth=1.0] A numeric Property specifying the width of the outline. * @param {Property} [options.numberOfVerticalLines=16] A numeric Property specifying the number of vertical lines to draw along the perimeter for the outline. - * @param {Property} [options.rotation=0.0] A numeric property specifying the rotation of the ellipse clockwise from north. + * @param {Property} [options.rotation=0.0] A numeric property specifying the rotation of the ellipse counter-clockwise from north. * @param {Property} [options.stRotation=0.0] A numeric property specifying the rotation of the ellipse texture counter-clockwise from north. * @param {Property} [options.granularity=Cesium.Math.RADIANS_PER_DEGREE] A numeric Property specifying the angular distance between points on the ellipse. * From 33b05fa5494162e557878246ab5a06c7a6913bfd Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Tue, 14 Apr 2015 19:40:57 -0400 Subject: [PATCH 17/35] Fix typo. --- Source/Core/EllipseGeometry.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/EllipseGeometry.js b/Source/Core/EllipseGeometry.js index 6ce1fe7dbfc7..ebc9aace89c1 100644 --- a/Source/Core/EllipseGeometry.js +++ b/Source/Core/EllipseGeometry.js @@ -600,8 +600,8 @@ define([ * @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid the ellipse will be on. * @param {Number} [options.height=0.0] The height above the ellipsoid. * @param {Number} [options.extrudedHeight] The height of the extrusion. - * @param {Property} [options.rotation=0.0] The angle of rotation counter-clockwise from north. - * @param {Property} [options.stRotation=0.0] The rotation of the texture coordinates counter-clockwise from north. + * @param {Number} [options.rotation=0.0] The angle of rotation counter-clockwise from north. + * @param {Number} [options.stRotation=0.0] The rotation of the texture coordinates counter-clockwise from north. * @param {Number} [options.granularity=CesiumMath.RADIANS_PER_DEGREE] The angular distance between points on the ellipse in radians. * @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed. * From e8b10e5025f1dec0f9d0009de60fb5489b81134b Mon Sep 17 00:00:00 2001 From: Ed Mackey Date: Wed, 15 Apr 2015 11:46:06 -0400 Subject: [PATCH 18/35] Make Sandcastle line markers more visible. --- Apps/Sandcastle/CesiumSandcastle.css | 4 ++++ Apps/Sandcastle/CesiumSandcastle.js | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Apps/Sandcastle/CesiumSandcastle.css b/Apps/Sandcastle/CesiumSandcastle.css index 358bc5e9230e..4831a696b26b 100644 --- a/Apps/Sandcastle/CesiumSandcastle.css +++ b/Apps/Sandcastle/CesiumSandcastle.css @@ -202,6 +202,7 @@ a.linkButton:focus, a.linkButton:hover { font-weight: bold; background-color: #F42; border-radius: 3px; + border: none; } .CodeMirror pre.errorLine { @@ -215,6 +216,7 @@ a.linkButton:focus, a.linkButton:hover { font-weight: bold; background-color: #FE2; border-radius: 3px; + border: none; } .CodeMirror pre.hintLine { @@ -228,6 +230,7 @@ a.linkButton:focus, a.linkButton:hover { font-weight: bold; background-color: #2E2; border-radius: 3px; + border: none; } .CodeMirror pre.highlightLine { @@ -241,6 +244,7 @@ a.linkButton:focus, a.linkButton:hover { font-weight: bold; background-color: #CEF; border-radius: 3px; + border: none; } .CodeMirror pre.searchLine { diff --git a/Apps/Sandcastle/CesiumSandcastle.js b/Apps/Sandcastle/CesiumSandcastle.js index d03e1bfcebae..7e5c5a42af01 100644 --- a/Apps/Sandcastle/CesiumSandcastle.js +++ b/Apps/Sandcastle/CesiumSandcastle.js @@ -264,7 +264,16 @@ require({ function makeLineLabel(msg, className) { var element = document.createElement('abbr'); element.className = className; - element.innerHTML = ' '; + switch (className) { + case 'hintMarker': + element.innerHTML = '▲'; + break; + case 'errorMarker': + element.innerHTML = '×'; + break; + default: + element.innerHTML = '▶'; + } element.title = msg; return element; } From e437f309d1bf72ad035dd4d40d1b126c2acb79b7 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Wed, 15 Apr 2015 15:56:29 -0400 Subject: [PATCH 19/35] Fix crash when modifying a translucent entity outline. The code for removing items wasn't covered in the unit tests and we were missing an array indexer. New test crashes in master, passes in this branch. --- .../DataSources/StaticOutlineGeometryBatch.js | 2 +- Specs/DataSources/GeometryVisualizerSpec.js | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/Source/DataSources/StaticOutlineGeometryBatch.js b/Source/DataSources/StaticOutlineGeometryBatch.js index 6b1f0715d419..a335f05ae68a 100644 --- a/Source/DataSources/StaticOutlineGeometryBatch.js +++ b/Source/DataSources/StaticOutlineGeometryBatch.js @@ -253,7 +253,7 @@ define([ var translucentBatches = this._translucentBatches.values; var translucentBatchesLength = translucentBatches.length; for (i = 0; i < translucentBatchesLength; i++) { - if (translucentBatches.remove(updater)) { + if (translucentBatches[i].remove(updater)) { return; } } diff --git a/Specs/DataSources/GeometryVisualizerSpec.js b/Specs/DataSources/GeometryVisualizerSpec.js index 05dd9dbb6894..64691a947b29 100644 --- a/Specs/DataSources/GeometryVisualizerSpec.js +++ b/Specs/DataSources/GeometryVisualizerSpec.js @@ -327,6 +327,53 @@ defineSuite([ }); }); + it('Correctly handles modifying translucent outline color', function() { + var entities = new EntityCollection(); + var visualizer = new GeometryVisualizer(EllipseGeometryUpdater, scene, entities); + + var color = Color.BLUE.withAlpha(0.5); + var entity = entities.add({ + position : new Cartesian3(1234, 5678, 9101112), + ellipse : { + semiMajorAxis : 2, + semiMinorAxis : 1, + fill : false, + outline : true, + outlineColor : color + } + }); + + return pollToPromise(function() { + scene.initializeFrame(); + var isUpdated = visualizer.update(time); + scene.render(time); + return isUpdated; + }).then(function() { + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity); + expect(attributes).toBeDefined(); + expect(attributes.color).toEqual(ColorGeometryInstanceAttribute.toValue(color)); + + color = Color.RED.withAlpha(0.5); + entity.ellipse.outlineColor.setValue(color); + + return pollToPromise(function() { + scene.initializeFrame(); + var isUpdated = visualizer.update(time); + scene.render(time); + return isUpdated; + }); + }).then(function() { + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity); + expect(attributes).toBeDefined(); + expect(attributes.color).toEqual(ColorGeometryInstanceAttribute.toValue(color)); + + entities.remove(entity); + visualizer.destroy(); + }); + }); + it('Creates and removes dynamic geometry', function() { var objects = new EntityCollection(); var visualizer = new GeometryVisualizer(EllipseGeometryUpdater, scene, objects); From ced9b3159ac8e799543b004db08a93f5922a9e60 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Wed, 15 Apr 2015 20:29:58 -0400 Subject: [PATCH 20/35] Fix KML wrapping GroundOverlays Replace `convertLongitudeRange` with `negativePiToPi` as discussed in #2624. Fixes #2624 --- Source/DataSources/KmlDataSource.js | 4 ++-- Specs/DataSources/KmlDataSourceSpec.js | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Source/DataSources/KmlDataSource.js b/Source/DataSources/KmlDataSource.js index a4759abcc3fc..b1986838948f 100644 --- a/Source/DataSources/KmlDataSource.js +++ b/Source/DataSources/KmlDataSource.js @@ -1413,13 +1413,13 @@ define([ var north = queryNumericValue(latLonBox, 'north', namespaces.kml); if (defined(west)) { - west = CesiumMath.convertLongitudeRange(CesiumMath.toRadians(west)); + west = CesiumMath.negativePiToPi(CesiumMath.toRadians(west)); } if (defined(south)) { south = CesiumMath.negativePiToPi(CesiumMath.toRadians(south)); } if (defined(east)) { - east = CesiumMath.convertLongitudeRange(CesiumMath.toRadians(east)); + east = CesiumMath.negativePiToPi(CesiumMath.toRadians(east)); } if (defined(north)) { north = CesiumMath.negativePiToPi(CesiumMath.toRadians(north)); diff --git a/Specs/DataSources/KmlDataSourceSpec.js b/Specs/DataSources/KmlDataSourceSpec.js index 7d16b0f754a7..38d14242165f 100644 --- a/Specs/DataSources/KmlDataSourceSpec.js +++ b/Specs/DataSources/KmlDataSourceSpec.js @@ -668,6 +668,24 @@ defineSuite([ }); }); + it('GroundOverlay: Handles wrapping longitude.', function() { + var kml = '\ + \ + \ + -180\ + -90\ + 180\ + 90\ + \ + '; + + return KmlDataSource.load(parser.parseFromString(kml, "text/xml")).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + expect(entity.polygon).toBeUndefined(); + expect(entity.rectangle.coordinates.getValue()).toEqual(Rectangle.fromDegrees(-180, -90, 180, 90)); + }); + }); + it('GroundOverlay: Sets polygon coordinates for gx:LatLonQuad', function() { var kml = '\ Date: Thu, 16 Apr 2015 10:12:34 -0400 Subject: [PATCH 21/35] Fix entity.show handling for static geometry with dynamic attributes Setting entity.show would have no affect for static geometry if the outlineColor or material was dynamic. This was an bad optimization on my part. Fixed the code and added unit tests to cover it. --- .../DataSources/StaticGeometryColorBatch.js | 10 +- .../StaticGeometryPerMaterialBatch.js | 10 +- .../DataSources/StaticOutlineGeometryBatch.js | 10 +- Specs/DataSources/GeometryVisualizerSpec.js | 134 ++++++++++++++++++ 4 files changed, 146 insertions(+), 18 deletions(-) diff --git a/Source/DataSources/StaticGeometryColorBatch.js b/Source/DataSources/StaticGeometryColorBatch.js index 900fdc81d448..a3c5bf91b381 100644 --- a/Source/DataSources/StaticGeometryColorBatch.js +++ b/Source/DataSources/StaticGeometryColorBatch.js @@ -124,12 +124,10 @@ define([ } } - if (!updater.hasConstantFill) { - var show = updater.entity.isShowing && updater.isFilled(time); - var currentShow = attributes.show[0] === 1; - if (show !== currentShow) { - attributes.show = ShowGeometryInstanceAttribute.toValue(show, attributes.show); - } + var show = updater.entity.isShowing && (updater.hasConstantFill || updater.isFilled(time)); + var currentShow = attributes.show[0] === 1; + if (show !== currentShow) { + attributes.show = ShowGeometryInstanceAttribute.toValue(show, attributes.show); } } diff --git a/Source/DataSources/StaticGeometryPerMaterialBatch.js b/Source/DataSources/StaticGeometryPerMaterialBatch.js index 2f13bb54c524..b30d7b572512 100644 --- a/Source/DataSources/StaticGeometryPerMaterialBatch.js +++ b/Source/DataSources/StaticGeometryPerMaterialBatch.js @@ -136,12 +136,10 @@ define([ this.attributes.set(instance.id.id, attributes); } - if (!updater.hasConstantFill) { - var show = entity.isShowing && updater.isFilled(time); - var currentShow = attributes.show[0] === 1; - if (show !== currentShow) { - attributes.show = ShowGeometryInstanceAttribute.toValue(show, attributes.show); - } + var show = entity.isShowing && (updater.hasConstantFill || updater.isFilled(time)); + var currentShow = attributes.show[0] === 1; + if (show !== currentShow) { + attributes.show = ShowGeometryInstanceAttribute.toValue(show, attributes.show); } } diff --git a/Source/DataSources/StaticOutlineGeometryBatch.js b/Source/DataSources/StaticOutlineGeometryBatch.js index a335f05ae68a..70139f622393 100644 --- a/Source/DataSources/StaticOutlineGeometryBatch.js +++ b/Source/DataSources/StaticOutlineGeometryBatch.js @@ -129,12 +129,10 @@ define([ } } - if (!updater.hasConstantOutline) { - var show = updater.entity.isShowing && updater.isOutlineVisible(time); - var currentShow = attributes.show[0] === 1; - if (show !== currentShow) { - attributes.show = ShowGeometryInstanceAttribute.toValue(show, attributes.show); - } + var show = updater.entity.isShowing && (updater.hasConstantOutline || updater.isOutlineVisible(time)); + var currentShow = attributes.show[0] === 1; + if (show !== currentShow) { + attributes.show = ShowGeometryInstanceAttribute.toValue(show, attributes.show); } } diff --git a/Specs/DataSources/GeometryVisualizerSpec.js b/Specs/DataSources/GeometryVisualizerSpec.js index 64691a947b29..2b884ed42028 100644 --- a/Specs/DataSources/GeometryVisualizerSpec.js +++ b/Specs/DataSources/GeometryVisualizerSpec.js @@ -18,6 +18,7 @@ defineSuite([ 'DataSources/GridMaterialProperty', 'DataSources/SampledProperty', 'DataSources/StaticGeometryPerMaterialBatch', + 'Specs/createDynamicProperty', 'Specs/createScene', 'Specs/pollToPromise' ], function( @@ -39,6 +40,7 @@ defineSuite([ GridMaterialProperty, SampledProperty, StaticGeometryPerMaterialBatch, + createDynamicProperty, createScene, pollToPromise) { "use strict"; @@ -595,4 +597,136 @@ defineSuite([ }); }); + it('Sets static geometry primitive show attribute when using dynamic fill color', function() { + var entities = new EntityCollection(); + var visualizer = new GeometryVisualizer(EllipseGeometryUpdater, scene, entities); + + var entity = entities.add({ + position : new Cartesian3(1234, 5678, 9101112), + ellipse : { + semiMajorAxis : 2, + semiMinorAxis : 1, + material : new ColorMaterialProperty(createDynamicProperty(Color.BLUE)) + } + }); + + return pollToPromise(function() { + scene.initializeFrame(); + var isUpdated = visualizer.update(time); + scene.render(time); + return isUpdated; + }).then(function() { + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity); + expect(attributes).toBeDefined(); + expect(attributes.show).toEqual(ShowGeometryInstanceAttribute.toValue(true)); + + entity.show = false; + + return pollToPromise(function() { + scene.initializeFrame(); + var isUpdated = visualizer.update(time); + scene.render(time); + return isUpdated; + }); + }).then(function() { + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity); + expect(attributes).toBeDefined(); + expect(attributes.show).toEqual(ShowGeometryInstanceAttribute.toValue(false)); + + entities.remove(entity); + visualizer.destroy(); + }); + }); + + it('Sets static geometry primitive show attribute when using dynamic outline color', function() { + var entities = new EntityCollection(); + var visualizer = new GeometryVisualizer(EllipseGeometryUpdater, scene, entities); + + var entity = entities.add({ + position : new Cartesian3(1234, 5678, 9101112), + ellipse : { + semiMajorAxis : 2, + semiMinorAxis : 1, + fill : false, + outline : true, + outlineColor : createDynamicProperty(Color.BLUE) + } + }); + + return pollToPromise(function() { + scene.initializeFrame(); + var isUpdated = visualizer.update(time); + scene.render(time); + return isUpdated; + }).then(function() { + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity); + expect(attributes).toBeDefined(); + expect(attributes.show).toEqual(ShowGeometryInstanceAttribute.toValue(true)); + + entity.show = false; + + return pollToPromise(function() { + scene.initializeFrame(); + var isUpdated = visualizer.update(time); + scene.render(time); + return isUpdated; + }); + }).then(function() { + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity); + expect(attributes).toBeDefined(); + expect(attributes.show).toEqual(ShowGeometryInstanceAttribute.toValue(false)); + + entities.remove(entity); + visualizer.destroy(); + }); + }); + + it('Sets static geometry primitive show attribute when using dynamic fill material', function() { + var entities = new EntityCollection(); + var visualizer = new GeometryVisualizer(EllipseGeometryUpdater, scene, entities); + + var entity = entities.add({ + position : new Cartesian3(1234, 5678, 9101112), + ellipse : { + semiMajorAxis : 2, + semiMinorAxis : 1, + material : new GridMaterialProperty({ + color : createDynamicProperty(Color.BLUE) + }) + } + }); + + return pollToPromise(function() { + scene.initializeFrame(); + var isUpdated = visualizer.update(time); + scene.render(time); + return isUpdated; + }).then(function() { + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity); + expect(attributes).toBeDefined(); + expect(attributes.show).toEqual(ShowGeometryInstanceAttribute.toValue(true)); + + entity.show = false; + + return pollToPromise(function() { + scene.initializeFrame(); + var isUpdated = visualizer.update(time); + scene.render(time); + return isUpdated; + }); + }).then(function() { + var primitive = scene.primitives.get(0); + var attributes = primitive.getGeometryInstanceAttributes(entity); + expect(attributes).toBeDefined(); + expect(attributes.show).toEqual(ShowGeometryInstanceAttribute.toValue(false)); + + entities.remove(entity); + visualizer.destroy(); + }); + }); }, 'WebGL'); From b4d04de262c7cf24be503e15a47c5e07ee72ba20 Mon Sep 17 00:00:00 2001 From: Ed Mackey Date: Thu, 16 Apr 2015 15:57:12 -0400 Subject: [PATCH 22/35] Prevent the overlay list from being doubled. --- Source/Scene/Scene.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index 8612000c6689..c1d6978e5627 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -983,6 +983,7 @@ define([ if (near !== Number.MAX_VALUE && (numFrustums !== numberOfFrustums || (frustumCommandsList.length !== 0 && (near < frustumCommandsList[0].near || far > frustumCommandsList[numberOfFrustums - 1].far)))) { updateFrustums(near, far, farToNearRatio, numFrustums, frustumCommandsList); + overlayList.length = 0; createPotentiallyVisibleSet(scene); } } From eae4873724c7cedb9239c47d1ef5a23e3dd697ae Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Thu, 16 Apr 2015 21:51:43 -0400 Subject: [PATCH 23/35] Update InfoBox title when entity name changes Also clean up the WMS/ArcGIS Server feature picking entity code, which was using deprecated API. --- Source/Widgets/Viewer/Viewer.js | 52 +++++++++++------------------- Specs/Widgets/Viewer/ViewerSpec.js | 33 +++++++++++++++++++ 2 files changed, 51 insertions(+), 34 deletions(-) diff --git a/Source/Widgets/Viewer/Viewer.js b/Source/Widgets/Viewer/Viewer.js index e183da5c0c6f..e5858c40be1e 100644 --- a/Source/Widgets/Viewer/Viewer.js +++ b/Source/Widgets/Viewer/Viewer.js @@ -18,6 +18,7 @@ define([ '../../DataSources/DataSourceDisplay', '../../DataSources/Entity', '../../DataSources/EntityView', + '../../DataSources/Property', '../../Scene/SceneMode', '../../ThirdParty/knockout', '../../ThirdParty/when', @@ -57,6 +58,7 @@ define([ DataSourceDisplay, Entity, EntityView, + Property, SceneMode, knockout, when, @@ -126,12 +128,10 @@ define([ } // Imagery layer feature picking is asynchronous, so put up a message while loading. - var loadingMessage = new Entity('Loading...'); - loadingMessage.description = { - getValue : function() { - return 'Loading feature information...'; - } - }; + var loadingMessage = new Entity({ + id : 'Loading...', + description : 'Loading feature information...' + }); when(imageryLayerFeaturePromise, function(features) { // Has this async pick been superseded by a later one? @@ -147,12 +147,10 @@ define([ // Select the first feature. var feature = features[0]; - var entity = new Entity(feature.name); - entity.description = { - getValue : function() { - return feature.description; - } - }; + var entity = new Entity({ + id : feature.name, + description : feature.description + }); if (defined(feature.position)) { var ecfPosition = viewer.scene.globe.ellipsoid.cartographicToCartesian(feature.position, cartesian3Scratch); @@ -165,14 +163,6 @@ define([ if (viewer.selectedEntity !== loadingMessage) { return; } - - var entity = new Entity('None'); - entity.description = { - getValue : function() { - return 'No features found.'; - } - }; - viewer.selectedEntity = createNoFeaturesEntity(); }); @@ -180,13 +170,10 @@ define([ } function createNoFeaturesEntity() { - var entity = new Entity('None'); - entity.description = { - getValue : function() { - return 'No features found.'; - } - }; - return entity; + return new Entity({ + id : 'None', + description : 'No features found.' + }); } /** @@ -1024,11 +1011,6 @@ Either specify options.terrainProvider instead or set options.baseLayerPicker to this._selectedEntity = value; var selectionIndicatorViewModel = defined(this._selectionIndicator) ? this._selectionIndicator.viewModel : undefined; if (defined(value)) { - var infoBoxViewModel = defined(this._infoBox) ? this._infoBox.viewModel : undefined; - if (defined(infoBoxViewModel)) { - infoBoxViewModel.titleText = defined(value.name) ? value.name : value.id; - } - if (defined(selectionIndicatorViewModel)) { selectionIndicatorViewModel.animateAppear(); } @@ -1336,9 +1318,11 @@ Either specify options.terrainProvider instead or set options.baseLayerPicker to infoBoxViewModel.enableCamera = enableCamera; infoBoxViewModel.isCameraTracking = (this.trackedEntity === this.selectedEntity); - if (showSelection && defined(selectedEntity.description)) { - infoBoxViewModel.description = defaultValue(selectedEntity.description.getValue(time), ''); + if (showSelection) { + infoBoxViewModel.titleText = defaultValue(selectedEntity.name, selectedEntity.id); + infoBoxViewModel.description = Property.getValueOrDefault(selectedEntity.description, time, ''); } else { + infoBoxViewModel.titleText = ''; infoBoxViewModel.description = ''; } } diff --git a/Specs/Widgets/Viewer/ViewerSpec.js b/Specs/Widgets/Viewer/ViewerSpec.js index a89c1fb8642d..3d57ce53e095 100644 --- a/Specs/Widgets/Viewer/ViewerSpec.js +++ b/Specs/Widgets/Viewer/ViewerSpec.js @@ -772,6 +772,39 @@ defineSuite([ viewer.destroy(); }); + it('selectedEntity sets InfoBox properties', function() { + var viewer = new Viewer(container); + + var entity = new Entity(); + + var viewModel = viewer.infoBox.viewModel; + expect(viewModel.showInfo).toBe(false); + + viewer.selectedEntity = entity; + + viewer.clock.tick(); + expect(viewModel.showInfo).toBe(true); + expect(viewModel.titleText).toEqual(entity.id); + expect(viewModel.description).toEqual(''); + + entity.name = 'Yes, this is name.'; + entity.description = 'tubelcane'; + + viewer.clock.tick(); + expect(viewModel.showInfo).toBe(true); + expect(viewModel.titleText).toEqual(entity.name); + expect(viewModel.description).toEqual(entity.description.getValue()); + + viewer.selectedEntity = undefined; + + viewer.clock.tick(); + expect(viewModel.showInfo).toBe(false); + expect(viewModel.titleText).toEqual(''); + expect(viewModel.description).toEqual(''); + + viewer.destroy(); + }); + it('home button resets tracked object', function() { viewer = new Viewer(container); From d7fd0d0a33d303a3fd532d3739c0784f473657a7 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Fri, 17 Apr 2015 10:17:35 -0400 Subject: [PATCH 24/35] Remove deprecated functionality targeted to 1.9 Since I've been lazy on CHANGES lately, I also updated it with info from recent pull requests. There's still one deprecated piece of functionality targeted at 1.9 (PolygonGraphics.positions), but removing it is more involved and I'll eventually open a separate pull for it. --- CHANGES.md | 10 +++++- Source/DataSources/ColorMaterialProperty.js | 20 ----------- .../DataSources/CompositeEntityCollection.js | 16 --------- Source/DataSources/DataSourceDisplay.js | 22 ------------- Source/DataSources/Entity.js | 8 ----- Source/DataSources/EntityCollection.js | 16 --------- .../PolylineArrowMaterialProperty.js | 2 -- Source/Scene/Model.js | 33 ------------------- Source/Scene/ModelAnimationCollection.js | 8 ++--- .../DataSources/ColorMaterialPropertySpec.js | 4 --- Specs/DataSources/DataSourceDisplaySpec.js | 4 --- 11 files changed, 13 insertions(+), 130 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f643ef4c7c81..1841d92f6bdd 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,10 +3,18 @@ Change Log ### 1.9 - 2015-05-01 * Breaking changes - * + * Removed `ColorMaterialProperty.fromColor`. Pass a `Color` directly to the `ColorMaterialProperty` constructor instead. + * Removed `CompositeEntityCollection.entities` and `EntityCollection.entities`. Use `CompositeEntityCollection.values` and `EntityCollection.values` instead. + * Removed `DataSourceDisplay.getScene` and `DataSourceDisplay.getDataSources`. Use `DataSourceDisplay.scene` and `DataSourceDisplay.dataSources` instead. + * `Entity` no longer takes a string id as it's constructor argument. Pass an options object with `id` property instead. + * `Model.readyToRender` was removed. Use `Model.readyPromise` instead. * Deprecated * * An exception is now thrown if `Primitive.modelMatrix` is not the identity matrix when in in 2D or Columbus View. +* The `InfoBox` title is now correctly updated if the name of `viewer.selectedEntity` changes on the fly. [#2644](https://github.com/AnalyticalGraphicsInc/cesium/pull/2644) +* Fixed a bug that caused `Corridor` and `PolylineVolume` geometry to be incorrect for sharp corners [#2626](https://github.com/AnalyticalGraphicsInc/cesium/pull/2626) +* Fixed crash when modifying a translucent entity geometry outline. [#2630](https://github.com/AnalyticalGraphicsInc/cesium/pull/2630) +* Fixed crash when loading KML GroundOverlays that spanned 360 degrees. [#2639](https://github.com/AnalyticalGraphicsInc/cesium/pull/2639) ### 1.8 - 2015-04-01 diff --git a/Source/DataSources/ColorMaterialProperty.js b/Source/DataSources/ColorMaterialProperty.js index 4f45c3632700..48cb68641964 100644 --- a/Source/DataSources/ColorMaterialProperty.js +++ b/Source/DataSources/ColorMaterialProperty.js @@ -3,7 +3,6 @@ define([ '../Core/Color', '../Core/defined', '../Core/defineProperties', - '../Core/deprecationWarning', '../Core/DeveloperError', '../Core/Event', './ConstantProperty', @@ -13,7 +12,6 @@ define([ Color, defined, defineProperties, - deprecationWarning, DeveloperError, Event, ConstantProperty, @@ -36,24 +34,6 @@ define([ this.color = color; }; - /** - * Creates a new instance that represents a constant color. - * - * @param {Color} color The color. - * @returns {ColorMaterialProperty} A new instance configured to represent the provided color. - * @deprecated - */ - ColorMaterialProperty.fromColor = function(color) { - deprecationWarning('ColorMaterialProperty.fromColor', 'ColorMaterialProperty.fromColor was deprecated in Cesium 1.6. It will be removed in 1.9. Use "new ColorMaterialProperty(color)" instead.'); - - //>>includeStart('debug', pragmas.debug); - if (!defined(color)) { - throw new DeveloperError('color is required'); - } - //>>includeEnd('debug'); - return new ColorMaterialProperty(color); - }; - defineProperties(ColorMaterialProperty.prototype, { /** * Gets a value indicating if this property is constant. A property is considered diff --git a/Source/DataSources/CompositeEntityCollection.js b/Source/DataSources/CompositeEntityCollection.js index 27f9f001b9e5..d5d3ca8a0177 100644 --- a/Source/DataSources/CompositeEntityCollection.js +++ b/Source/DataSources/CompositeEntityCollection.js @@ -3,7 +3,6 @@ define([ '../Core/createGuid', '../Core/defined', '../Core/defineProperties', - '../Core/deprecationWarning', '../Core/DeveloperError', '../Core/Math', './Entity', @@ -12,7 +11,6 @@ define([ createGuid, defined, defineProperties, - deprecationWarning, DeveloperError, CesiumMath, Entity, @@ -163,20 +161,6 @@ define([ return this._id; } }, - /** - * Gets the array of Entity instances in the collection. - * This array should not be modified directly. - * @memberof CompositeEntityCollection.prototype - * @readonly - * @type {Entity[]} - * @deprecated - */ - entities : { - get : function() { - deprecationWarning('CompositeEntityCollection.entities', 'EntityCollection.entities has been deprecated and will be removed in Cesium 1.9, use EntityCollection.values instead'); - return this._composite.values; - } - }, /** * Gets the array of Entity instances in the collection. * This array should not be modified directly. diff --git a/Source/DataSources/DataSourceDisplay.js b/Source/DataSources/DataSourceDisplay.js index 9cdacd9b0590..dd4521723338 100644 --- a/Source/DataSources/DataSourceDisplay.js +++ b/Source/DataSources/DataSourceDisplay.js @@ -4,7 +4,6 @@ define([ '../Core/defaultValue', '../Core/defined', '../Core/defineProperties', - '../Core/deprecationWarning', '../Core/destroyObject', '../Core/DeveloperError', '../Core/EventHelper', @@ -31,7 +30,6 @@ define([ defaultValue, defined, defineProperties, - deprecationWarning, destroyObject, DeveloperError, EventHelper, @@ -162,26 +160,6 @@ define([ } }); - /** - * Gets the scene being used for display. - * @deprecated - * @returns {Scene} The scene. - */ - DataSourceDisplay.prototype.getScene = function() { - deprecationWarning('DataSourceDisplay.getScene', 'DataSourceDisplay.getScene was deprecated on Cesium 1.5 and will be removed in Cesium 1.9, used the DataSourceDisplay.scene property instead.'); - return this.scene; - }; - - /** - * Gets the collection of data sources to be displayed. - * @deprecated - * @returns {DataSourceCollection} The collection of data sources. - */ - DataSourceDisplay.prototype.getDataSources = function() { - deprecationWarning('DataSourceDisplay.getDataSources', 'DataSourceDisplay.getDataSources was deprecated on Cesium 1.5 and will be removed in Cesium 1.9, used the DataSourceDisplay.dataSources property instead.'); - return this.dataSources; - }; - /** * Returns true if this object was destroyed; otherwise, false. *

diff --git a/Source/DataSources/Entity.js b/Source/DataSources/Entity.js index 20b00c590ddd..9f0e8488a077 100644 --- a/Source/DataSources/Entity.js +++ b/Source/DataSources/Entity.js @@ -5,7 +5,6 @@ define([ '../Core/defaultValue', '../Core/defined', '../Core/defineProperties', - '../Core/deprecationWarning', '../Core/DeveloperError', '../Core/Event', '../Core/Matrix3', @@ -37,7 +36,6 @@ define([ defaultValue, defined, defineProperties, - deprecationWarning, DeveloperError, Event, Matrix3, @@ -120,12 +118,6 @@ define([ options = defaultValue(options, defaultValue.EMPTY_OBJECT); var id = options.id; - if (typeof options === 'string') { - deprecationWarning('Entity', 'The Entity constructor taking a string was deprecated in Cesium 1.5. It will be removed in 1.9. Use "new Entity({ id : \'id\'})" instead.'); - id = options; - options = defaultValue.EMPTY_OBJECT; - } - if (!defined(id)) { id = createGuid(); } diff --git a/Source/DataSources/EntityCollection.js b/Source/DataSources/EntityCollection.js index a91a751731b0..392fd7481fd1 100644 --- a/Source/DataSources/EntityCollection.js +++ b/Source/DataSources/EntityCollection.js @@ -4,7 +4,6 @@ define([ '../Core/createGuid', '../Core/defined', '../Core/defineProperties', - '../Core/deprecationWarning', '../Core/DeveloperError', '../Core/Event', '../Core/Iso8601', @@ -17,7 +16,6 @@ define([ createGuid, defined, defineProperties, - deprecationWarning, DeveloperError, Event, Iso8601, @@ -127,20 +125,6 @@ define([ return this._id; } }, - /** - * Gets the array of Entity instances in the collection. - * This array should not be modified directly. - * @memberof EntityCollection.prototype - * @readonly - * @type {Entity[]} - * @deprecated - */ - entities : { - get : function() { - deprecationWarning('EntityCollection.entities', 'EntityCollection.entities has been deprecated and will be removed in Cesium 1.9, use EntityCollection.values instead'); - return this._entities.values; - } - }, /** * Gets the array of Entity instances in the collection. * This array should not be modified directly. diff --git a/Source/DataSources/PolylineArrowMaterialProperty.js b/Source/DataSources/PolylineArrowMaterialProperty.js index 46682cf218d1..66cbe10a7e1f 100644 --- a/Source/DataSources/PolylineArrowMaterialProperty.js +++ b/Source/DataSources/PolylineArrowMaterialProperty.js @@ -3,7 +3,6 @@ define([ '../Core/Color', '../Core/defined', '../Core/defineProperties', - '../Core/deprecationWarning', '../Core/DeveloperError', '../Core/Event', './ConstantProperty', @@ -13,7 +12,6 @@ define([ Color, defined, defineProperties, - deprecationWarning, DeveloperError, Event, ConstantProperty, diff --git a/Source/Scene/Model.js b/Source/Scene/Model.js index ef3f9c7eda32..9b6a78197751 100644 --- a/Source/Scene/Model.js +++ b/Source/Scene/Model.js @@ -9,7 +9,6 @@ define([ '../Core/defaultValue', '../Core/defined', '../Core/defineProperties', - '../Core/deprecationWarning', '../Core/destroyObject', '../Core/DeveloperError', '../Core/Event', @@ -51,7 +50,6 @@ define([ defaultValue, defined, defineProperties, - deprecationWarning, destroyObject, DeveloperError, Event, @@ -331,7 +329,6 @@ define([ this._allowPicking = defaultValue(options.allowPicking, true); - this._readyToRender = new Event(); this._ready = false; this._readyPromise = when.defer(); @@ -555,35 +552,6 @@ define([ } }, - /** - * The event fired when this model is ready to render, i.e., when the external binary, image, - * and shader files were downloaded and the WebGL resources were created. - *

- * This event is fired at the end of the frame before the first frame the model is rendered in. - *

- * - * @memberof Model.prototype - * @type {Event} - * @readonly - * - * @example - * // Play all animations at half-speed when the model is ready to render - * model.readyToRender.addEventListener(function(model) { - * model.activeAnimations.addAll({ - * speedup : 0.5 - * }); - * }); - * - * @see Model#ready - * @deprecated - */ - readyToRender : { - get : function() { - deprecationWarning('Model.readyToRender', 'Model.readyToRender was deprecated in Cesium 1.6 and will be removed in Cesium 1.9. Use Model.readyPromise instead.'); - return this._readyToRender; - } - }, - /** * Gets the promise that will be resolved when this model is ready to render, i.e., when the external binary, image, * and shader files were downloaded and the WebGL resources were created. @@ -2661,7 +2629,6 @@ define([ var model = this; frameState.afterRender.push(function() { model._ready = true; - model._readyToRender.raiseEvent(model); model.readyPromise.resolve(model); }); return; diff --git a/Source/Scene/ModelAnimationCollection.js b/Source/Scene/ModelAnimationCollection.js index 5f249ff9fdd2..9cb144e8d34b 100644 --- a/Source/Scene/ModelAnimationCollection.js +++ b/Source/Scene/ModelAnimationCollection.js @@ -100,7 +100,7 @@ define([ * @param {ModelAnimationLoop} [options.loop=ModelAnimationLoop.NONE] Determines if and how the animation is looped. * @returns {ModelAnimation} The animation that was added to the collection. * - * @exception {DeveloperError} Animations are not loaded. Wait for the {@link Model#readyToRender} event. + * @exception {DeveloperError} Animations are not loaded. Wait for the {@link Model#readtPromise} to resolve. * @exception {DeveloperError} options.name must be a valid animation name. * @exception {DeveloperError} options.speedup must be greater than zero. * @@ -143,7 +143,7 @@ define([ //>>includeStart('debug', pragmas.debug); if (!defined(animations)) { - throw new DeveloperError('Animations are not loaded. Wait for the model\'s readyToRender event or ready property.'); + throw new DeveloperError('Animations are not loaded. Wait for the {@link Model#readtPromise} to resolve.'); } //>>includeEnd('debug'); @@ -182,7 +182,7 @@ define([ * @param {ModelAnimationLoop} [options.loop=ModelAnimationLoop.NONE] Determines if and how the animations are looped. * @returns {ModelAnimation[]} An array of {@link ModelAnimation} objects, one for each animation added to the collection. If there are no glTF animations, the array is empty. * - * @exception {DeveloperError} Animations are not loaded. Wait for the {@link Model#readyToRender} event. + * @exception {DeveloperError} Animations are not loaded. Wait for the {@link Model#readtPromise} to resolve. * @exception {DeveloperError} options.speedup must be greater than zero. * * @example @@ -196,7 +196,7 @@ define([ //>>includeStart('debug', pragmas.debug); if (!defined(this._model._runtime.animations)) { - throw new DeveloperError('Animations are not loaded. Wait for the model\'s readyToRender event or ready property.'); + throw new DeveloperError('Animations are not loaded. Wait for the {@link Model#readtPromise} to resolve.'); } if (defined(options.speedup) && (options.speedup <= 0.0)) { diff --git a/Specs/DataSources/ColorMaterialPropertySpec.js b/Specs/DataSources/ColorMaterialPropertySpec.js index 0f683b3cc3e7..84582db6b8fe 100644 --- a/Specs/DataSources/ColorMaterialPropertySpec.js +++ b/Specs/DataSources/ColorMaterialPropertySpec.js @@ -25,10 +25,6 @@ defineSuite([ var result = property.getValue(); expect(result.color).toEqual(Color.WHITE); - property = ColorMaterialProperty.fromColor(Color.BLUE); - expect(property.color).toBeInstanceOf(ConstantProperty); - expect(property.color.getValue()).toEqual(Color.BLUE); - var colorProperty = new ConstantProperty(Color.BLUE); property = new ColorMaterialProperty(colorProperty); expect(property.color).toBe(colorProperty); diff --git a/Specs/DataSources/DataSourceDisplaySpec.js b/Specs/DataSources/DataSourceDisplaySpec.js index 9b543ac14a89..abc290ea7962 100644 --- a/Specs/DataSources/DataSourceDisplaySpec.js +++ b/Specs/DataSources/DataSourceDisplaySpec.js @@ -85,10 +85,6 @@ defineSuite([ expect(display.isDestroyed()).toEqual(false); expect(display.defaultDataSource).toBeDefined(); - //deprecated - expect(display.getScene()).toBe(scene); - expect(display.getDataSources()).toBe(dataSourceCollection); - display.destroy(); }); From d4accd7b993af7a357e4d0eaa76f6f45fd86e33e Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Fri, 17 Apr 2015 11:53:44 -0400 Subject: [PATCH 25/35] Fix `Entity.viewFrom` `Entity.viewFrom` has been broken since 1.6. This fixes the logic so that it gets used again. I also added tests for better coverage. 2 out of the 3 should fail in master without these changes. --- CHANGES.md | 1 + Source/DataSources/EntityView.js | 9 ++++--- Specs/DataSources/EntityViewSpec.js | 40 +++++++++++++++++++++++++++-- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f643ef4c7c81..b10a6544f63c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ Change Log * Deprecated * * An exception is now thrown if `Primitive.modelMatrix` is not the identity matrix when in in 2D or Columbus View. +* Fix a bug which caused `Entity.viewFrom` to be ignored when flying to, zooming to, or tracking an Entity. ### 1.8 - 2015-04-01 diff --git a/Source/DataSources/EntityView.js b/Source/DataSources/EntityView.js index a1a5458c1f48..c44ea77c9d6a 100644 --- a/Source/DataSources/EntityView.js +++ b/Source/DataSources/EntityView.js @@ -220,8 +220,9 @@ define([ this._lastEntity = undefined; this._mode = undefined; - //Re-usable objects to be used for retrieving position. this._lastCartesian = new Cartesian3(); + this._defaultOffset3D = undefined; + this._defaultOffset2D = undefined; this._offset3D = new Cartesian3(); this._offset2D = new HeadingPitchRange(); @@ -294,15 +295,17 @@ define([ var updateLookAt = objectChanged || sceneModeChanged; if (objectChanged) { var viewFromProperty = entity.viewFrom; + var hasViewFrom = defined(viewFromProperty); var sphere = this.boundingSphere; this._boundingSphereOffset = undefined; - if (defined(sphere)) { + + if (!hasViewFrom && defined(sphere)) { var controller = scene.screenSpaceCameraController; controller.minimumZoomDistance = Math.min(controller.minimumZoomDistance, sphere.radius * 0.5); camera.viewBoundingSphere(sphere); this._boundingSphereOffset = Cartesian3.subtract(sphere.center, entity.position.getValue(time), new Cartesian3()); updateLookAt = false; - } else if (!defined(viewFromProperty) || !defined(viewFromProperty.getValue(time, offset3D))) { + } else if (!hasViewFrom || !defined(viewFromProperty.getValue(time, offset3D))) { HeadingPitchRange.clone(EntityView._defaultOffset2D, offset2D); Cartesian3.clone(EntityView._defaultOffset3D, offset3D); } else { diff --git a/Specs/DataSources/EntityViewSpec.js b/Specs/DataSources/EntityViewSpec.js index 9c35b10c5fb7..b3500145badd 100644 --- a/Specs/DataSources/EntityViewSpec.js +++ b/Specs/DataSources/EntityViewSpec.js @@ -1,6 +1,7 @@ /*global defineSuite*/ defineSuite([ 'DataSources/EntityView', + 'Core/BoundingSphere', 'Core/Cartesian3', 'Core/Ellipsoid', 'Core/JulianDate', @@ -9,6 +10,7 @@ defineSuite([ 'Specs/createScene' ], function( EntityView, + BoundingSphere, Cartesian3, Ellipsoid, JulianDate, @@ -19,11 +21,16 @@ defineSuite([ /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var scene; + var defaultOffset = EntityView.defaultOffset3D; beforeAll(function() { scene = createScene(); }); + beforeEach(function() { + EntityView.defaultOffset3D = defaultOffset.clone(); + }); + afterAll(function() { scene.destroyForSpecs(); }); @@ -51,8 +58,37 @@ defineSuite([ entity.position = new ConstantPositionProperty(Cartesian3.fromDegrees(0.0, 0.0)); var view = new EntityView(entity, scene); view.update(JulianDate.now()); - expect(Cartesian3.equalsEpsilon(EntityView.defaultOffset3D, sampleOffset, 1e-10)).toBe(true); - expect(Cartesian3.equalsEpsilon(view.scene.camera.position, sampleOffset, 1e-10)).toBe(true); + expect(EntityView.defaultOffset3D).toEqualEpsilon(sampleOffset, 1e-10); + expect(view.scene.camera.position).toEqualEpsilon(sampleOffset, 1e-10); + }); + + it('uses entity viewFrom', function() { + var sampleOffset = new Cartesian3(1, 2, 3); + var entity = new Entity(); + entity.position = new ConstantPositionProperty(Cartesian3.fromDegrees(0.0, 0.0)); + entity.viewFrom = sampleOffset; + var view = new EntityView(entity, scene); + view.update(JulianDate.now()); + expect(view.scene.camera.position).toEqualEpsilon(sampleOffset, 1e-10); + }); + + it('uses entity bounding sphere', function() { + var sampleOffset = new Cartesian3(-1.3322676295501878e-15, -7.348469228349534, 7.3484692283495345); + var entity = new Entity(); + entity.position = new ConstantPositionProperty(Cartesian3.fromDegrees(0.0, 0.0)); + var view = new EntityView(entity, scene, undefined, new BoundingSphere(new Cartesian3(3, 4, 5), 6)); + view.update(JulianDate.now()); + expect(view.scene.camera.position).toEqualEpsilon(sampleOffset, 1e-10); + }); + + it('uses entity viewFrom if available and boundingsphere is supplied', function() { + var sampleOffset = new Cartesian3(1, 2, 3); + var entity = new Entity(); + entity.position = new ConstantPositionProperty(Cartesian3.fromDegrees(0.0, 0.0)); + entity.viewFrom = sampleOffset; + var view = new EntityView(entity, scene, undefined, new BoundingSphere(new Cartesian3(3, 4, 5), 6)); + view.update(JulianDate.now()); + expect(view.scene.camera.position).toEqualEpsilon(sampleOffset, 1e-10); }); it('update throws without time parameter', function() { From 09be348aba741ce0af9daf9005a21c4b7f0854cd Mon Sep 17 00:00:00 2001 From: Patrick Cozzi Date: Mon, 20 Apr 2015 08:47:27 -0400 Subject: [PATCH 26/35] Tweak overlay list --- Source/Scene/Scene.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index c1d6978e5627..9e7e6649d5cb 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -916,6 +916,7 @@ define([ frustumCommandsList[n].indices[p] = 0; } } + overlayList.length = 0; var near = Number.MAX_VALUE; var far = Number.MIN_VALUE; @@ -983,7 +984,6 @@ define([ if (near !== Number.MAX_VALUE && (numFrustums !== numberOfFrustums || (frustumCommandsList.length !== 0 && (near < frustumCommandsList[0].near || far > frustumCommandsList[numberOfFrustums - 1].far)))) { updateFrustums(near, far, farToNearRatio, numFrustums, frustumCommandsList); - overlayList.length = 0; createPotentiallyVisibleSet(scene); } } From 2488e9e80e7ba4e50c79f8a69a903e3295d2b6ad Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Mon, 20 Apr 2015 10:12:01 -0400 Subject: [PATCH 27/35] Changes after review. --- CHANGES.md | 10 +++++----- Source/Scene/Model.js | 5 ----- Source/Scene/ModelAnimationCollection.js | 8 ++++---- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 1841d92f6bdd..34929377f846 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,11 +3,11 @@ Change Log ### 1.9 - 2015-05-01 * Breaking changes - * Removed `ColorMaterialProperty.fromColor`. Pass a `Color` directly to the `ColorMaterialProperty` constructor instead. - * Removed `CompositeEntityCollection.entities` and `EntityCollection.entities`. Use `CompositeEntityCollection.values` and `EntityCollection.values` instead. - * Removed `DataSourceDisplay.getScene` and `DataSourceDisplay.getDataSources`. Use `DataSourceDisplay.scene` and `DataSourceDisplay.dataSources` instead. - * `Entity` no longer takes a string id as it's constructor argument. Pass an options object with `id` property instead. - * `Model.readyToRender` was removed. Use `Model.readyPromise` instead. + * Removed `ColorMaterialProperty.fromColor`, previously deprecated in 1.6. Pass a `Color` directly to the `ColorMaterialProperty` constructor instead. + * Removed `CompositeEntityCollection.entities` and `EntityCollection.entities`, both previously deprecated in 1.6. Use `CompositeEntityCollection.values` and `EntityCollection.values` instead. + * Removed `DataSourceDisplay.getScene` and `DataSourceDisplay.getDataSources`, both previously deprecated in 1.6. Use `DataSourceDisplay.scene` and `DataSourceDisplay.dataSources` instead. + * `Entity` no longer takes a string id as it's constructor argument. Pass an options object with `id` property instead. This was previously deprecated in 1.6. + * Removed `Model.readyToRender`, previously deprecated in 1.6. Use `Model.readyPromise` instead. * Deprecated * * An exception is now thrown if `Primitive.modelMatrix` is not the identity matrix when in in 2D or Columbus View. diff --git a/Source/Scene/Model.js b/Source/Scene/Model.js index 9b6a78197751..efdf4e8dd7d5 100644 --- a/Source/Scene/Model.js +++ b/Source/Scene/Model.js @@ -218,7 +218,6 @@ define([ * @param {Boolean} [options.debugWireframe=false] For debugging only. Draws the model in wireframe. * * @see Model.fromGltf - * @see Model#readyPromise * * @demo {@link http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=3D%20Models.html|Cesium Sandcastle Models Demo} */ @@ -543,8 +542,6 @@ define([ * @readonly * * @default false - * - * @see Model#readyPromise */ ready : { get : function() { @@ -632,8 +629,6 @@ define([ * @param {Boolean} [options.debugWireframe=false] For debugging only. Draws the model in wireframe. * @returns {Model} The newly created model. * - * @see Model#readyPromise - * * @example * // Example 1. Create a model from a glTF asset * var model = scene.primitives.add(Cesium.Model.fromGltf({ diff --git a/Source/Scene/ModelAnimationCollection.js b/Source/Scene/ModelAnimationCollection.js index 9cb144e8d34b..be73f7f02a2a 100644 --- a/Source/Scene/ModelAnimationCollection.js +++ b/Source/Scene/ModelAnimationCollection.js @@ -100,7 +100,7 @@ define([ * @param {ModelAnimationLoop} [options.loop=ModelAnimationLoop.NONE] Determines if and how the animation is looped. * @returns {ModelAnimation} The animation that was added to the collection. * - * @exception {DeveloperError} Animations are not loaded. Wait for the {@link Model#readtPromise} to resolve. + * @exception {DeveloperError} Animations are not loaded. Wait for the {@link Model#readyPromise} to resolve. * @exception {DeveloperError} options.name must be a valid animation name. * @exception {DeveloperError} options.speedup must be greater than zero. * @@ -143,7 +143,7 @@ define([ //>>includeStart('debug', pragmas.debug); if (!defined(animations)) { - throw new DeveloperError('Animations are not loaded. Wait for the {@link Model#readtPromise} to resolve.'); + throw new DeveloperError('Animations are not loaded. Wait for Model.readyPromise to resolve.'); } //>>includeEnd('debug'); @@ -182,7 +182,7 @@ define([ * @param {ModelAnimationLoop} [options.loop=ModelAnimationLoop.NONE] Determines if and how the animations are looped. * @returns {ModelAnimation[]} An array of {@link ModelAnimation} objects, one for each animation added to the collection. If there are no glTF animations, the array is empty. * - * @exception {DeveloperError} Animations are not loaded. Wait for the {@link Model#readtPromise} to resolve. + * @exception {DeveloperError} Animations are not loaded. Wait for the {@link Model#readyPromise} to resolve. * @exception {DeveloperError} options.speedup must be greater than zero. * * @example @@ -196,7 +196,7 @@ define([ //>>includeStart('debug', pragmas.debug); if (!defined(this._model._runtime.animations)) { - throw new DeveloperError('Animations are not loaded. Wait for the {@link Model#readtPromise} to resolve.'); + throw new DeveloperError('Animations are not loaded. Wait for Model.readyPromise to resolve.'); } if (defined(options.speedup) && (options.speedup <= 0.0)) { From e576ca529f959595ac2cfd2fad0ba6c22c7120ca Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Mon, 20 Apr 2015 23:58:28 -0400 Subject: [PATCH 28/35] Add quantized-mesh MIME type Running our unit tests under IIS would fail because the test terrain tiles could not be served. Fixes #2651 --- web.config | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web.config b/web.config index cc50253f6430..716a012eb500 100644 --- a/web.config +++ b/web.config @@ -24,6 +24,8 @@ + + \ No newline at end of file From 95c18a5875f963b6efa76d80ba914f04f8ed2286 Mon Sep 17 00:00:00 2001 From: Patrick Cozzi Date: Tue, 21 Apr 2015 18:02:04 -0400 Subject: [PATCH 29/35] Fix warnings when running model tests --- Specs/Scene/ModelSpec.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Specs/Scene/ModelSpec.js b/Specs/Scene/ModelSpec.js index 9ebcbf13172a..9a3fe6240c61 100644 --- a/Specs/Scene/ModelSpec.js +++ b/Specs/Scene/ModelSpec.js @@ -985,7 +985,10 @@ defineSuite([ it('should load a model where WebGL shader optimizer removes an attribute (linux)', function() { var url = './Data/Models/test-shader-optimize/test-shader-optimize.gltf'; - var m = loadModel(url); + return loadModel(url).then(function(m) { + expect(m).toBeDefined(); + primitives.remove(m); + }); }); it('releaseGltfJson releases glTFJSON when constructed with fromGltf', function() { From 89ad4e54fbda50422bd19f1b9b24860c2b0c2709 Mon Sep 17 00:00:00 2001 From: Patrick Cozzi Date: Fri, 24 Apr 2015 08:19:20 -0400 Subject: [PATCH 30/35] Trivial cleanup --- Source/Scene/QuadtreePrimitive.js | 4 ++-- Source/Scene/QuadtreeTile.js | 2 +- Specs/Sandcastle/QuadtreePrimitive.html | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Scene/QuadtreePrimitive.js b/Source/Scene/QuadtreePrimitive.js index f82d8c43f29e..2cfd8ab8373e 100644 --- a/Source/Scene/QuadtreePrimitive.js +++ b/Source/Scene/QuadtreePrimitive.js @@ -268,8 +268,8 @@ define([ // We can't render anything before the level zero tiles exist. if (!defined(primitive._levelZeroTiles)) { if (primitive._tileProvider.ready) { - var terrainTilingScheme = primitive._tileProvider.tilingScheme; - primitive._levelZeroTiles = QuadtreeTile.createLevelZeroTiles(terrainTilingScheme); + var tilingScheme = primitive._tileProvider.tilingScheme; + primitive._levelZeroTiles = QuadtreeTile.createLevelZeroTiles(tilingScheme); } else { // Nothing to do until the provider is ready. return; diff --git a/Source/Scene/QuadtreeTile.js b/Source/Scene/QuadtreeTile.js index 283ac5cfb264..0f799f79b007 100644 --- a/Source/Scene/QuadtreeTile.js +++ b/Source/Scene/QuadtreeTile.js @@ -281,7 +281,7 @@ define([ }); /** - * Frees the resources assocated with this tile and returns it to the START + * Frees the resources associated with this tile and returns it to the START * {@link QuadtreeTileLoadState}. If the {@link QuadtreeTile#data} property is defined and it * has a freeResources method, the method will be invoked. * diff --git a/Specs/Sandcastle/QuadtreePrimitive.html b/Specs/Sandcastle/QuadtreePrimitive.html index 56559110b79c..9e61559d9df9 100644 --- a/Specs/Sandcastle/QuadtreePrimitive.html +++ b/Specs/Sandcastle/QuadtreePrimitive.html @@ -33,7 +33,7 @@ function startup(Cesium) { "use strict"; //Sandcastle_Begin -var DemoTileProvider = function DemoTileProvider() { +var DemoTileProvider = function() { this._quadtree = undefined; this._tilingScheme = new Cesium.GeographicTilingScheme(); this._errorEvent = new Cesium.Event(); From ba966033a00aef96516173edd655156f3236298d Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Fri, 24 Apr 2015 11:36:37 -0400 Subject: [PATCH 31/35] Fix Geocoder styling issue in Safari. In order to properly style text input fields in Safari, you need to specify the `-webkit-appearance: none;` style. --- Source/Widgets/Geocoder/Geocoder.css | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Widgets/Geocoder/Geocoder.css b/Source/Widgets/Geocoder/Geocoder.css index cb55fdb507e0..01a96d4d5b83 100644 --- a/Source/Widgets/Geocoder/Geocoder.css +++ b/Source/Widgets/Geocoder/Geocoder.css @@ -15,6 +15,7 @@ -webkit-transition: width ease-in-out 0.25s, background-color 0.2s ease-in-out; -moz-transition: width ease-in-out 0.25s, background-color 0.2s ease-in-out; transition: width ease-in-out 0.25s, background-color 0.2s ease-in-out; + -webkit-appearance: none; } .cesium-viewer-geocoderContainer:hover .cesium-geocoder-input { From 415c7f49999f70518f7b929f3130ba99ec3d7350 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Fri, 24 Apr 2015 11:44:34 -0400 Subject: [PATCH 32/35] Update CHANGES --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 5e73a8d164d0..88fae8d85e66 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -16,6 +16,7 @@ Change Log * Fixed a bug that caused `Corridor` and `PolylineVolume` geometry to be incorrect for sharp corners [#2626](https://github.com/AnalyticalGraphicsInc/cesium/pull/2626) * Fixed crash when modifying a translucent entity geometry outline. [#2630](https://github.com/AnalyticalGraphicsInc/cesium/pull/2630) * Fixed crash when loading KML GroundOverlays that spanned 360 degrees. [#2639](https://github.com/AnalyticalGraphicsInc/cesium/pull/2639) +* Fixed `Geocoder` styling issue in Safari. [#2658](https://github.com/AnalyticalGraphicsInc/cesium/pull/2658). ### 1.8 - 2015-04-01 From 22e48df4966b22867c8fd3dbb1ea61dd7ef529f6 Mon Sep 17 00:00:00 2001 From: Patrick Cozzi Date: Fri, 24 Apr 2015 11:52:19 -0400 Subject: [PATCH 33/35] Added count to shader cache --- Source/Renderer/ShaderCache.js | 13 +++++++++++++ Specs/Renderer/ShaderCacheSpec.js | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/Source/Renderer/ShaderCache.js b/Source/Renderer/ShaderCache.js index 2cf5122ce671..d0978f221ba4 100644 --- a/Source/Renderer/ShaderCache.js +++ b/Source/Renderer/ShaderCache.js @@ -1,11 +1,13 @@ /*global define*/ define([ '../Core/defined', + '../Core/defineProperties', '../Core/destroyObject', './ShaderProgram', './ShaderSource' ], function( defined, + defineProperties, destroyObject, ShaderProgram, ShaderSource) { @@ -17,9 +19,18 @@ define([ var ShaderCache = function(context) { this._context = context; this._shaders = {}; + this._numberOfShaders = 0; this._shadersToRelease = {}; }; + defineProperties(ShaderCache.prototype, { + numberOfShaders : { + get : function() { + return this._numberOfShaders; + } + } + }); + /** * Returns a shader program from the cache, or creates and caches a new shader program, * given the GLSL vertex and fragment shader source and attribute locations. @@ -107,6 +118,7 @@ define([ // A shader can't be in more than one cache. shaderProgram._cachedShader = cachedShader; this._shaders[keyword] = cachedShader; + ++this._numberOfShaders; } ++cachedShader.count; @@ -121,6 +133,7 @@ define([ var cachedShader = shadersToRelease[keyword]; delete this._shaders[cachedShader.keyword]; cachedShader.shaderProgram.finalDestroy(); + --this._numberOfShaders; } } diff --git a/Specs/Renderer/ShaderCacheSpec.js b/Specs/Renderer/ShaderCacheSpec.js index 30f1460bde8b..de994ceb6f95 100644 --- a/Specs/Renderer/ShaderCacheSpec.js +++ b/Specs/Renderer/ShaderCacheSpec.js @@ -27,12 +27,15 @@ defineSuite([ position : 0 }); expect(sp._cachedShader.count).toEqual(1); + expect(cache.numberOfShaders).toEqual(1); cache.releaseShaderProgram(sp); expect(sp.isDestroyed()).toEqual(false); + expect(cache.numberOfShaders).toEqual(1); cache.destroyReleasedShaderPrograms(); expect(sp.isDestroyed()).toEqual(true); + expect(cache.numberOfShaders).toEqual(0); cache.destroy(); }); @@ -70,12 +73,14 @@ defineSuite([ expect(sp).toBe(sp2); expect(sp._cachedShader.count).toEqual(2); + expect(cache.numberOfShaders).toEqual(1); sp.destroy(); sp2.destroy(); cache.destroyReleasedShaderPrograms(); expect(sp.isDestroyed()).toEqual(true); + expect(cache.numberOfShaders).toEqual(0); cache.destroy(); }); From dd264079376be6e80ce1360a6bfc2e41bd692df2 Mon Sep 17 00:00:00 2001 From: Patrick Cozzi Date: Fri, 24 Apr 2015 15:27:49 -0400 Subject: [PATCH 34/35] Added cached shaders to Cesium inspector --- CHANGES.md | 1 + Source/Widgets/CesiumInspector/CesiumInspector.js | 5 +++++ .../CesiumInspector/CesiumInspectorViewModel.js | 11 ++++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 5e73a8d164d0..bc56402cd6b5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -16,6 +16,7 @@ Change Log * Fixed a bug that caused `Corridor` and `PolylineVolume` geometry to be incorrect for sharp corners [#2626](https://github.com/AnalyticalGraphicsInc/cesium/pull/2626) * Fixed crash when modifying a translucent entity geometry outline. [#2630](https://github.com/AnalyticalGraphicsInc/cesium/pull/2630) * Fixed crash when loading KML GroundOverlays that spanned 360 degrees. [#2639](https://github.com/AnalyticalGraphicsInc/cesium/pull/2639) +* Added number of cached shaders to the `CesiumInspector` debugging widget. ### 1.8 - 2015-04-01 diff --git a/Source/Widgets/CesiumInspector/CesiumInspector.js b/Source/Widgets/CesiumInspector/CesiumInspector.js index 849bec646a5d..f88e076f6d8a 100644 --- a/Source/Widgets/CesiumInspector/CesiumInspector.js +++ b/Source/Widgets/CesiumInspector/CesiumInspector.js @@ -101,6 +101,11 @@ define([ performanceContainer.className = 'cesium-cesiumInspector-performanceDisplay'; generalSection.appendChild(performanceContainer); + var shaderCacheDisplay = document.createElement('div'); + shaderCacheDisplay.className = 'cesium-cesiumInspector-shaderCache'; + shaderCacheDisplay.setAttribute('data-bind', 'html: shaderCacheText'); + generalSection.appendChild(shaderCacheDisplay); + // Primitives var prim = document.createElement('div'); prim.className = 'cesium-cesiumInspector-sectionHeader'; diff --git a/Source/Widgets/CesiumInspector/CesiumInspectorViewModel.js b/Source/Widgets/CesiumInspector/CesiumInspectorViewModel.js index 3888f181cfe2..4c88721e0403 100644 --- a/Source/Widgets/CesiumInspector/CesiumInspectorViewModel.js +++ b/Source/Widgets/CesiumInspector/CesiumInspectorViewModel.js @@ -103,6 +103,13 @@ define([ */ this.performance = false; + /** + * Gets or sets the shader cache text. This property is observable. + * @type {String} + * @default '' + */ + this.shaderCacheText = ''; + /** * Gets or sets the show primitive bounding sphere state. This property is observable. * @type {Boolean} @@ -250,7 +257,7 @@ define([ */ this.terrainSwitchText = '+'; - knockout.track(this, ['filterTile', 'suspendUpdates', 'dropDownVisible', 'frustums', + knockout.track(this, ['filterTile', 'suspendUpdates', 'dropDownVisible', 'shaderCacheText', 'frustums', 'frustumStatisticText', 'pickTileActive', 'pickPrimitiveActive', 'hasPickedPrimitive', 'hasPickedTile', 'tileText', 'generalVisible', 'generalSwitchText', 'primitivesVisible', 'primitivesSwitchText', 'terrainVisible', 'terrainSwitchText']); @@ -818,6 +825,8 @@ define([ if (that.primitiveReferenceFrame) { that._modelMatrixPrimitive.modelMatrix = that._primitive.modelMatrix; } + + that.shaderCacheText = 'Cached shaders: ' + that._scene.context.shaderCache.numberOfShaders; }; } } From 0552de127bfb8bec3f513b50b720b9c1a4584873 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Tue, 28 Apr 2015 10:14:04 +1000 Subject: [PATCH 35/35] prepare-cesium in postinstall, if necessary. --- gulpfile.js | 4 +++- package.json | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 73f215fc904e..fc14e4fac36b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -29,8 +29,10 @@ function createExorcistTransform(name) { // Create the build directory, because browserify flips out if the directory that might // contain an existing source map doesn't exist. -if (!fs.existsSync('wwwroot/build')) { +if (!fs.existsSync('wwwroot')) { fs.mkdirSync('wwwroot'); +} +if (!fs.existsSync('wwwroot/build')) { fs.mkdirSync('wwwroot/build'); } diff --git a/package.json b/package.json index e428d51021e9..2ddda25d8514 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,9 @@ "type": "git", "url": "https://github.com/TerriaJS/cesium.git" }, + "directories": { + "lib": "Source" + }, "devDependencies": { "browserify": "^9.0.8", "compression": "1.0.8", @@ -28,8 +31,9 @@ "deamdify": "^0.1.1" }, "scripts": { - "prepublish": "gulp prepare-cesium", - "postpublish": "git tag -a ${npm_package_version} -m \"${npm_package_version}\" && git push origin ${npm_package_version}" + "prepublish": "if [ ! -d \"./wwwroot/build\" ]; then gulp prepare-cesium; fi", + "postpublish": "git tag -a ${npm_package_version} -m \"${npm_package_version}\" && git push origin ${npm_package_version}", + "postinstall": "if [ ! -d \"./wwwroot/build\" ]; then gulp prepare-cesium; fi" }, "browserify": { "transform": [