Skip to content

Commit

Permalink
Move check for WebGL1 into isEnabled setter
Browse files Browse the repository at this point in the history
  • Loading branch information
alexchuber committed Jul 18, 2023
1 parent 045ad04 commit edb2e43
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions packages/dev/core/src/Materials/meshDebugPluginMaterial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,12 @@ export class MeshDebugPluginMaterial extends MaterialPluginBase {
@serializeAsColor3()
private _materialColor: Color3;

private _isEnabled = true;
/**
* Whether the mesh debug plugin is enabled in the material.
* Defaults to true.
* Defaults to true in constructor.
*/
@serialize()
@expandToProperty("_markAllDefinesAsDirty")
public isEnabled = true;
private _isEnabled = false;

private _mode: MeshDebugMode = MeshDebugMode.NONE;
/**
Expand Down Expand Up @@ -397,10 +395,7 @@ export class MeshDebugPluginMaterial extends MaterialPluginBase {
this._multiply = defines.DBG_MULTIPLY;
this._options = { ...defaults, ...options };
this._materialColor = MeshDebugPluginMaterial.MaterialColors[MeshDebugPluginMaterial._PluginCount++ % MeshDebugPluginMaterial.MaterialColors.length];

if (material.getScene().getEngine().webGLVersion == 1) {
Logger.Error("MeshDebugPluginMaterial is not supported on WebGL 1.0.");
}
this.isEnabled = true;
}

/**
Expand All @@ -411,6 +406,29 @@ export class MeshDebugPluginMaterial extends MaterialPluginBase {
return "MeshDebugPluginMaterial";
}

/**
* Gets whether the mesh debug plugin is enabled in the material.
*/
public get isEnabled(): boolean {
return this._isEnabled;
}
/**
* Sets whether the mesh debug plugin is enabled in the material.
* @param value enabled
*/
public set isEnabled(value: boolean) {
if (this._isEnabled === value) {
return;
}
if (this._material.getScene().getEngine().webGLVersion == 1) {
Logger.Error("MeshDebugPluginMaterial is not supported on WebGL 1.0.");
this._isEnabled = false;
return;
}
this._isEnabled = value;
this._markAllDefinesAsDirty();
}

/**
* Prepare the defines
* @param defines Mesh debug defines
Expand Down

0 comments on commit edb2e43

Please sign in to comment.