Skip to content

Commit

Permalink
bug fix: horse flickers when loaded after model (google#1859)
Browse files Browse the repository at this point in the history
* add comment

* force a name for materials

* move naming outside of material and to UI
  • Loading branch information
chrismgeorge authored Jan 21, 2021
1 parent de655c2 commit 3e656e1
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export class MaterialPanel extends ConnectedLitElement {
@internalProperty() isNewModel: boolean = true;
@internalProperty() currentGltfUrl: string = '';
@internalProperty() isTesting: boolean = false;
@internalProperty() isInterpolating: boolean = false;

@query('me-color-picker#base-color-picker') baseColorPicker!: ColorPicker;
@query('me-slider-with-input#roughness-factor')
Expand Down Expand Up @@ -170,6 +171,7 @@ export class MaterialPanel extends ConnectedLitElement {

// Logic for interpolating from red emissive factor to the original.
interpolateMaterial() {
this.isInterpolating = true;
const index = this.selectedMaterialId!;
const id = this.selectedMaterialId!;
const originalBaseColor = this.materials[index].baseColorFactor;
Expand Down Expand Up @@ -205,6 +207,7 @@ export class MaterialPanel extends ConnectedLitElement {
const emissiveFactor = originalEmissiveFactor;
reduxStore.dispatch(dispatchSetEmissiveFactor(
getEditsMaterials(reduxStore.getState()), {id, emissiveFactor}));
this.isInterpolating = false;
}
};
requestAnimationFrame(interpolateStep);
Expand All @@ -216,7 +219,8 @@ export class MaterialPanel extends ConnectedLitElement {
this.selectedMaterialId = Number(value);
checkFinite(this.selectedMaterialId);
// Don't interpolate on the initial model load.
if (!this.isNewModel && this.isLegalIndex() && !this.isTesting) {
if (!this.isNewModel && this.isLegalIndex() && !this.isTesting &&
!this.isInterpolating) {
this.interpolateMaterial();
}
this.isNewModel = false;
Expand All @@ -235,7 +239,8 @@ export class MaterialPanel extends ConnectedLitElement {
>${
this.materials.map(
(material, id) => html`<paper-item value="${id}">(${id}) ${
material.name}</paper-item>`)}
material.name ? material.name :
'Unnamed Material'}</paper-item>`)}
</me-dropdown>
</me-expandable-tab>
`;
Expand Down

0 comments on commit 3e656e1

Please sign in to comment.