Skip to content

Conversation

elalish
Copy link
Contributor

@elalish elalish commented Aug 18, 2021

Follow-on to the big refactor that removed material state from the editor (relying instead on model-viewer's own state), this smaller refactor removes the camera state from Redux as its information was already contained in the model-viewer config state in Redux. It also fixes a number of async bugs related to updating the UI, especially noticeable with the camera target.

@elalish elalish self-assigned this Aug 18, 2021
@elalish elalish requested review from a user, chrismgeorge and samaneh-kazemi August 18, 2021 17:07
const currentOrbit = cameraState.orbit;
this.cameraOrbitEditor.yawInput.value = currentOrbit.thetaDeg;
this.cameraOrbitEditor.pitchInput.value = currentOrbit.phiDeg;
this.cameraOrbitEditor.style.display = '';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Question: what is the difference of having display set to none vs ''?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

setting an attribute to '' mean unset, so it now just inherits its behavior from its parent HTML elements. I could set it to 'block', but this is safer, since I don't have to worry about what it's originally computed style was. In this context, '' means show.

@query('#limit-enabled') enabledInput?: HTMLInputElement;
@query('#minimum') minimumInput!: SliderWithInputElement;
@query('#maximum') maximumInput!: SliderWithInputElement;
@query('#limit-enabled') enabledInput!: HTMLInputElement;
Copy link
Collaborator

Choose a reason for hiding this comment

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

What was the reasoning behind the original design?
It looks like previously it was ok for any of these variables to be undefined, and now we are saying it shouldn't?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I've been slowly updating this style across the editor. Before when a panel was disabled, they replaced the html wholesale with nothing, while now I'm preferring to set display: 'none'. In this way the elements always exist and a lot of checking can be removed. In some cases, they had ? even if they already always existed, probably because this is the TS default.

this.cameraSnippet = getCamera(state);
const config = getConfig(state);
this.poster = config.poster;
this.initialCamera = config.cameraOrbit ?? 'auto auto auto';
Copy link
Collaborator

Choose a reason for hiding this comment

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

In js world they love to use all the possible signs lol ?? == === !=== =D

samaneh-kazemi
samaneh-kazemi previously approved these changes Aug 18, 2021
// changes to the <model-viewer> element in case they need to be queried by
// subsequent components. Keep in mind that those will still have to await
// updateComplete since rendering is async in Lit Element.
import './components/model_viewer_preview/model_viewer_preview.js';
Copy link

Choose a reason for hiding this comment

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

Does the model_viewer_preview actually expose API to make changes to the model? Just trying to understand why it's called preview but its applying changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The preview is where the model-viewer instance lives, so yes, it effectively exposes the whole MV API to the editor features.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Other components only use getters on the MV element. The preview is the one place where the config Redux state is applied to the MV element, which happens when its render method is called.

<me-draggable-input
id="pitch"
innerLabel="pitch"
value=${this.orbit.phiDeg}
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that you're removing these values. Will they be wrong when the model is initially loaded, and only be correct once you start dragging?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, they aren't shown initially and I decided it quite a bit simpler to make them just sync one way. There are edge cases where you can update the snippet and it won't show in the UI, but I think this still overall has fewer bugs than where we were.

return {
...state, poster: action.payload
}
return {...state, poster: action.payload};
Copy link

Choose a reason for hiding this comment

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

I like the expansion syntax, not sure if this was a thing the last time got into javascript.

ghost
ghost previously approved these changes Aug 18, 2021
}
}

/** Use when the user wants to load a new config (probably from a snippet). */
Copy link
Contributor

Choose a reason for hiding this comment

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

This reminds me, something we don't have a test for is ensuring the flow of when a user loads a model, then goes to edit the snippet manually, and then saves that. Just wanted to make sure that functionality was still preserved and caught somewhere.

@elalish elalish dismissed stale reviews from ghost and samaneh-kazemi via a431a3c August 18, 2021 18:57
@elalish elalish merged commit ce32fc8 into master Aug 20, 2021
@elalish elalish deleted the editorUXbugs branch August 20, 2021 17:02
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.

3 participants