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

Cesium 3dtiles inspector refactor #5217

Merged
merged 6 commits into from
Apr 19, 2017
Merged

Conversation

hpinkos
Copy link
Contributor

@hpinkos hpinkos commented Apr 18, 2017

The knockout usage in Cesium3dTilesInspector was not correct. There was an incorrect separation of the view and viewmodel. I also cleaned up the code because there were a ton of unnecessary subscriptions and bad use of private properties. No functionality changed, but I apparently changed so much of the code that GitHub can't do a proper diff.

@austinEng can you test to make sure all of the functionality is there?
@mramato do you want to do a code review?

@mramato
Copy link
Contributor

mramato commented Apr 18, 2017

No functionality changed, but I apparently changed so much of the code that GitHub can't do a proper diff.

The problem isn't the amount of code that changed or GitHub, it's that Git did not pick up the rename automatically (which is a weakness of Git in general). In either case, I can code review it as if it's new since you changed a bunch of stuff and I haven't looked to closely at this yet anyway.

Any other testing @austinEng or any of the other 3D Tiles team can provide is greatly appreciated.

set : function(value) {
dynamicSSEDensity(value);
if (that._tileset) {
that._tileset.dynamicScreenSpaceErrorDensity = Math.pow(value, 6);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the only change I wasn't 100% sure on. This value was previously being set in the view
Is there any significance to the exponent of 6?

@austinEng

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe I just copied whatever the default value was for a tileset, which is also somewhat arbitrary

Copy link
Contributor

@lilleyse lilleyse Apr 18, 2017

Choose a reason for hiding this comment

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

This was to make an exponential slider since sse values tend to be a lot closer to 0 than 1. This code looks fine, may just need a comment.

@lilleyse
Copy link
Contributor

I tested a little bit and it seems to work like normal.
👍

* @type {Number}
* @default 16
*/
this.maximumSSE = 16;
Copy link
Contributor

Choose a reason for hiding this comment

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

Any public methods and properties should spell out ScreenSpaceError instead of abbreviating to SSE. (I know you it was already like this, but this is a refactor of something that isn't even in master yet so we should fix it).

Cesium3DTilesInspectorViewModel.prototype.compileStyle = function() {
if (defined(this._style)) {
if (this.styleString !== JSON.stringify(this._style.style)) {
if (defined(this._tileset)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Invert and combine some of these statements to avoid 3 levels of if nesting. A bunch of this properties are accessed multiple times in this function, break them out into locals.

get : function() {
return this._tileset;
},

Copy link
Contributor

Choose a reason for hiding this comment

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

Whitespace (also run the auto-formatter on this file).

that._properties(t.properties);
});


Copy link
Contributor

Choose a reason for hiding this comment

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

More whitespace

var that = this;
tileset.readyPromise.then(function(t) {
that._properties(t.properties);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this handle failure somehow? What actually happens if ready is never fired or fails?

CC @lilleyse @austinEng

if (defined(tileset)) {
var that = this;
tileset.readyPromise.then(function(t) {
that._properties(t.properties);
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 a race condition. If the viewModel is destroyed before the tileset is ready, this will throw. Check that.isDestroyed() first.

* Handles key press events on the style editor
*/
Cesium3DTilesInspectorViewModel.prototype.styleEditorKeyPress = function(sender, event) {
if (event.keyCode === 9) { //tab
Copy link
Contributor

Choose a reason for hiding this comment

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

This block is crying for a real editor, like CodeMirror, but I guess there's nothing stopping someone from putting CodeMirror on top of this view model and ignoring this function.

@mramato
Copy link
Contributor

mramato commented Apr 19, 2017

Great work here @hpinkos! Thanks for cleaning this up. That's all I have.

@hpinkos
Copy link
Contributor Author

hpinkos commented Apr 19, 2017

@mramato ready

@mramato
Copy link
Contributor

mramato commented Apr 19, 2017

Thanks again @hpinkos, good work here.

@mramato mramato merged commit 5854e68 into 3d-tiles Apr 19, 2017
@mramato mramato deleted the 3dtiles-inspector-refactor branch April 19, 2017 15:20
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.

None yet

4 participants