Initial commit
This commit is contained in:
41
C#/TSEngine/Core/Graphics/material.ts
Normal file
41
C#/TSEngine/Core/Graphics/material.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
namespace TSE {
|
||||
|
||||
export class Material {
|
||||
|
||||
private _name: string;
|
||||
private _diffuseTextureName: string;
|
||||
|
||||
private _diffuseTexture: Texture;
|
||||
private _tint: Color;
|
||||
|
||||
public constructor(name: string, diffuseTextureName: string, tint: Color = Color.white) {
|
||||
this._name = name;
|
||||
this._diffuseTextureName = diffuseTextureName;
|
||||
this._tint = tint;
|
||||
|
||||
if (this._diffuseTextureName !== undefined)
|
||||
this._diffuseTexture = TextureManager.getTexture(this._diffuseTextureName);
|
||||
}
|
||||
|
||||
public get name(): string { return this._name; }
|
||||
public get diffuseTextureName(): string { return this._diffuseTextureName; }
|
||||
public get diffuseTexture(): Texture { return this._diffuseTexture; }
|
||||
public get tint(): Color { return this._tint; }
|
||||
|
||||
public set diffuseTextureName(value: string) {
|
||||
if (this._diffuseTexture !== undefined)
|
||||
TextureManager.releaseTexture(this._diffuseTextureName);
|
||||
|
||||
if (value === undefined) return;
|
||||
this.diffuseTextureName = value;
|
||||
this._diffuseTexture = TextureManager.getTexture(this._diffuseTextureName);
|
||||
}
|
||||
|
||||
public destroy(): void {
|
||||
TextureManager.releaseTexture(this._diffuseTextureName);
|
||||
this._diffuseTexture = undefined;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user