123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- module BABYLON {
- export class BaseTexture {
- public name: string;
- public delayLoadState = Engine.DELAYLOADSTATE_NONE;
- public hasAlpha = false;
- public getAlphaFromRGB = false;
- public level = 1;
- public isCube = false;
- public isRenderTarget = false;
- public animations = new Array<Animation>();
- public onDispose: () => void;
- public coordinatesIndex = 0;
- public coordinatesMode = Texture.EXPLICIT_MODE;
- public wrapU = Texture.WRAP_ADDRESSMODE;
- public wrapV = Texture.WRAP_ADDRESSMODE;
- public anisotropicFilteringLevel = 4;
- public _cachedAnisotropicFilteringLevel: number;
- private _scene: Scene;
- public _texture: WebGLTexture;
- constructor(scene: Scene) {
- this._scene = scene;
- this._scene.textures.push(this);
- }
- public getScene(): Scene {
- return this._scene;
- }
- public getTextureMatrix(): Matrix {
- return null;
- }
- public getReflectionTextureMatrix(): Matrix {
- return null;
- }
- public getInternalTexture(): WebGLTexture {
- return this._texture;
- }
- public isReady(): boolean {
- if (this.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) {
- return true;
- }
- if (this._texture) {
- return this._texture.isReady;
- }
- return false;
- }
- public getSize(): ISize {
- if (this._texture._width) {
- return { width: this._texture._width, height: this._texture._height };
- }
- if (this._texture._size) {
- return { width: this._texture._size, height: this._texture._size };
- }
- return { width: 0, height: 0 };
- }
- public getBaseSize(): ISize {
- if (!this.isReady())
- return { width: 0, height: 0 };
- if (this._texture._size) {
- return { width: this._texture._size, height: this._texture._size };
- }
- return { width: this._texture._baseWidth, height: this._texture._baseHeight };
- }
- public scale(ratio: number): void {
- }
- public get canRescale(): boolean {
- return false;
- }
- public _removeFromCache(url: string, noMipmap: boolean): void {
- var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
- for (var index = 0; index < texturesCache.length; index++) {
- var texturesCacheEntry = texturesCache[index];
- if (texturesCacheEntry.url === url && texturesCacheEntry.noMipmap === noMipmap) {
- texturesCache.splice(index, 1);
- return;
- }
- }
- }
- public _getFromCache(url: string, noMipmap: boolean, sampling?: number): WebGLTexture {
- var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
- for (var index = 0; index < texturesCache.length; index++) {
- var texturesCacheEntry = texturesCache[index];
- if (texturesCacheEntry.url === url && texturesCacheEntry.noMipmap === noMipmap) {
- if (!sampling || sampling === texturesCacheEntry.samplingMode) {
- texturesCacheEntry.references++;
- return texturesCacheEntry;
- }
- }
- }
- return null;
- }
- public delayLoad(): void {
- }
- public clone(): BaseTexture {
- return null;
- }
- public releaseInternalTexture(): void {
- if (this._texture) {
- this._scene.getEngine().releaseInternalTexture(this._texture);
- delete this._texture;
- }
- }
- public dispose(): void {
- // Animations
- this.getScene().stopAnimation(this);
- // Remove from scene
- var index = this._scene.textures.indexOf(this);
- if (index >= 0) {
- this._scene.textures.splice(index, 1);
- }
- if (this._texture === undefined) {
- return;
- }
- // Callback
- if (this.onDispose) {
- this.onDispose();
- }
- }
- }
- }
|