Archived
Private
Public Access
1
0
This repository has been archived on 2026-02-04. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
ProjectBackup/C#/TSEngine/Core/Graphics/material.ts
2022-09-04 12:45:01 +02:00

41 lines
1.4 KiB
TypeScript

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;
}
}
}