Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8261 - Avoid including Cesium3DTileSet in Picking.js #8532

Merged
merged 9 commits into from
Jan 13, 2020

Conversation

Samulus
Copy link
Contributor

@Samulus Samulus commented Jan 13, 2020

Fixes #8261

@cesium-concierge
Copy link

Thank you so much for the pull request @Samulus! I noticed this is your first pull request and I wanted to say welcome to the Cesium community!

The Pull Request Guidelines is a handy reference for making sure your PR gets accepted quickly, so make sure to skim that.

  • ❌ Missing CONTRIBUTORS.md entry.
  • ✔️ Signed CLA found.
  • CHANGES.md was not updated.
    • If this change updates the public API in any way, please add a bullet point to CHANGES.md.
  • ❔ Unit tests were not updated.
    • Make sure you've updated tests to reflect your changes, added tests for any new code, and ran the code coverage tool.

Reviewers, don't forget to make sure that:

  • Cesium Viewer works.
  • Works in 2D/CV.
  • Works (or fails gracefully) in IE11.

@hpinkos
Copy link
Contributor

hpinkos commented Jan 13, 2020

Can we do something similar to avoid sucking in Cesium3DTileFeature too?

@lilleyse
Copy link
Contributor

@hpinkos Cesium3DTileFeature doesn't have too many imports and will unlikely have more. It might be ok to skip it.

import Color from '../Core/Color.js';
import defined from '../Core/defined.js';
import defineProperties from '../Core/defineProperties.js';

Copy link
Contributor

@lilleyse lilleyse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few minor style things.

I'm going to verify that this actually reduces the build size and then it should be good to go.

@@ -879,6 +879,19 @@ import TileOrientedBoundingBox from './TileOrientedBoundingBox.js';
}

defineProperties(Cesium3DTileset.prototype, {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: remove empty line

Source/Scene/Cesium3DTileset.js Outdated Show resolved Hide resolved

/**
* NOTE: This getter exists so that `Picking.js` can differentiate between
* PrimitiveCollections and Cesium3DTileset objects without inflating
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* PrimitiveCollections and Cesium3DTileset objects without inflating
* PrimitiveCollection and Cesium3DTileset objects without inflating

/**
* NOTE: This getter exists so that `Picking.js` can differentiate between
* PrimitiveCollections and Cesium3DTileset objects without inflating
* the size of the module via `instance of Cesium3DTileset`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* the size of the module via `instance of Cesium3DTileset`
* the size of the module via `instanceof Cesium3DTileset`

* the size of the module via `instance of Cesium3DTileset`
*/

isCesium3DTileset: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style:

Suggested change
isCesium3DTileset: {
isCesium3DTileset : {

*/

isCesium3DTileset: {
get: function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style:

Suggested change
get: function() {
get : function() {

get: function() {
return true;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is why CI is failing. You can run npm run eslint locally which will also catch this.

Suggested change
}
},

@lilleyse
Copy link
Contributor

Also - add an entry to CHANGES.md.

@Samulus
Copy link
Contributor Author

Samulus commented Jan 13, 2020

@lilleyse fixed

@lilleyse
Copy link
Contributor

lilleyse commented Jan 13, 2020

Can confirm this fix reduces the build size. For future reference these were the steps @mramato suggested to verify this:

  • Switch to master
  • Edit CesiumViewer.js to create a minimal demo:
    window.CESIUM_BASE_URL = '../../Source/';

    import {
        CesiumWidget
    } from '../../Source/Cesium.js';

    function main() {
        var widget = new CesiumWidget('cesiumContainer');
    }

    main();
  • Run npm run makeZipFile
  • Run npm run buildApps
  • Check size of Build/Apps/CesiumViewer/CesiumViewer.js
  • Do the steps above on this branch

With fix: CesiumViewer.js is 1.3 MB
Without fix: CesiumViewer.js is 1.8 MB

@lilleyse
Copy link
Contributor

@Samulus there's one style comment that you missed: https://github.com/AnalyticalGraphicsInc/cesium/pull/8532/files#r365949948

After that's fixed I'll go ahead and merge.

* PrimitiveCollection and Cesium3DTileset objects without inflating
* the size of the module via `instanceof Cesium3DTileset`
*/
isCesium3DTileset : {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake for not noticing this in the initial review - the getter should be marked as @private.

@Samulus
Copy link
Contributor Author

Samulus commented Jan 13, 2020

@lilleyse rebased and annotation added

@Samulus Samulus merged commit dffefca into master Jan 13, 2020
@Samulus Samulus deleted the 8261/instance_of_picking branch January 13, 2020 21:56
@lilleyse
Copy link
Contributor

Little bit of offline miscommunication on my part, I should have been the one to merge the PR. That said, the changes do look good and I was about to merge 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid importing Cesium3DTileset in Picking.js
4 participants