Browse Source

Some thin engine reduction

David Catuhe 5 năm trước cách đây
mục cha
commit
6830bf734f

+ 45 - 40
Playground/babylon.d.txt

@@ -28849,7 +28849,7 @@ declare module BABYLON {
         protected _cachedEffectForVertexBuffers: Nullable<Effect>;
         /** @hidden */
private _currentRenderTarget: Nullable<InternalTexture>;
         private _uintIndicesCurrentlySet;
-        private _currentBoundBuffer;
+        protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
         /** @hidden */
         protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
         private _currentBufferPointers;
@@ -29082,13 +29082,6 @@ declare module BABYLON {
          */
         createDynamicVertexBuffer(data: DataArray): DataBuffer;
         /**
-         * Update a dynamic index buffer
-         * @param indexBuffer defines the target index buffer
-         * @param indices defines the data to update
-         * @param offset defines the offset in the target index buffer where update should start
-         */
-        updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
-        /**
          * Updates a dynamic vertex buffer.
          * @param vertexBuffer the vertex buffer to update
          * @param data the data used to update the vertex buffer
@@ -29096,7 +29089,7 @@ declare module BABYLON {
          * @param byteLength the byte length of the data
          */
         updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
-        private _resetIndexBufferBinding;
+        protected _resetIndexBufferBinding(): void;
         /**
          * Creates a new index buffer
          * @param indices defines the content of the index buffer
@@ -29110,7 +29103,7 @@ declare module BABYLON {
          * @param buffer defines the buffer to bind
          */
         bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
-        private bindIndexBuffer;
+        protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
         private bindBuffer;
         /**
          * update the bound buffer with the given data
@@ -29577,12 +29570,6 @@ declare module BABYLON {
          * @returns The texture
          */
         private _createDepthStencilTexture;
-        /**
-         * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
-         * @param renderTarget The render target to set the frame buffer for
-         */
-        setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
-        /** @hidden */
private _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
         /** @hidden */
private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
         /** @hidden */
private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
         /** @hidden */
private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
@@ -29592,6 +29579,7 @@ declare module BABYLON {
          */
private _setCubeMapTextureParams(loadMipmap: boolean): void;
         protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
         private _prepareWebGLTexture;
+        /** @hidden */
private _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
         /** @hidden */
private _releaseFramebufferObjects(texture: InternalTexture): void;
         /** @hidden */
private _releaseTexture(texture: InternalTexture): void;
         protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
@@ -29710,63 +29698,68 @@ declare module BABYLON {
 }
 declare module BABYLON {
     /**
-     * Class used to store data associated with WebGL texture data for the engine
-     * This class should not be used directly
+     * Defines the source of the internal texture
      */
-    export class InternalTexture {
-        /** @hidden */
private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
+    export enum InternalTextureSource {
         /**
          * The source of the texture data is unknown
          */
-        static DATASOURCE_UNKNOWN: number;
+        Unknown = 0,
         /**
-         * Texture data comes from an URL
-         */
-        static DATASOURCE_URL: number;
+        * Texture data comes from an URL
+        */
+        Url = 1,
         /**
          * Texture data is only used for temporary storage
          */
-        static DATASOURCE_TEMP: number;
+        Temp = 2,
         /**
          * Texture data comes from raw data (ArrayBuffer)
          */
-        static DATASOURCE_RAW: number;
+        Raw = 3,
         /**
          * Texture content is dynamic (video or dynamic texture)
          */
-        static DATASOURCE_DYNAMIC: number;
+        Dynamic = 4,
         /**
          * Texture content is generated by rendering to it
          */
-        static DATASOURCE_RENDERTARGET: number;
+        RenderTarget = 5,
         /**
          * Texture content is part of a multi render target process
          */
-        static DATASOURCE_MULTIRENDERTARGET: number;
+        MultiRenderTarget = 6,
         /**
          * Texture data comes from a cube data file
          */
-        static DATASOURCE_CUBE: number;
+        Cube = 7,
         /**
          * Texture data comes from a raw cube data
          */
-        static DATASOURCE_CUBERAW: number;
+        CubeRaw = 8,
         /**
          * Texture data come from a prefiltered cube data file
          */
-        static DATASOURCE_CUBEPREFILTERED: number;
+        CubePrefiltered = 9,
         /**
          * Texture content is raw 3D data
          */
-        static DATASOURCE_RAW3D: number;
+        Raw3D = 10,
         /**
          * Texture content is a depth texture
          */
-        static DATASOURCE_DEPTHTEXTURE: number;
+        Depth = 11,
         /**
          * Texture data comes from a raw cube data encoded with RGBD
          */
-        static DATASOURCE_CUBERAW_RGBD: number;
+        CubeRawRGBD = 12
+    }
+    /**
+     * Class used to store data associated with WebGL texture data for the engine
+     * This class should not be used directly
+     */
+    export class InternalTexture {
+        /** @hidden */
private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
         /**
          * Defines if the texture is ready
          */
@@ -29841,7 +29834,7 @@ declare module BABYLON {
         invertY: boolean;
         /** @hidden */
private _invertVScale: boolean;
         /** @hidden */
private _associatedChannel: number;
-        /** @hidden */
private _dataSource: number;
+        /** @hidden */
private _source: InternalTextureSource;
         /** @hidden */
private _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
         /** @hidden */
private _bufferView: Nullable<ArrayBufferView>;
         /** @hidden */
private _bufferViewArray: Nullable<ArrayBufferView[]>;
@@ -29886,16 +29879,16 @@ declare module BABYLON {
          */
         getEngine(): ThinEngine;
         /**
-         * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
+         * Gets the data source type of the texture
          */
-        readonly dataSource: number;
+        readonly source: InternalTextureSource;
         /**
          * Creates a new InternalTexture
          * @param engine defines the engine to use
-         * @param dataSource defines the type of data that will be used
+         * @param source defines the type of data that will be used
          * @param delayAllocation if the texture allocation should be delayed (default: false)
          */
-        constructor(engine: ThinEngine, dataSource: number, delayAllocation?: boolean);
+        constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
         /**
          * Increments the number of references (ie. the number of Texture that point to it)
          */
@@ -31153,6 +31146,18 @@ declare module BABYLON {
         getDeltaTime(): number;
         private _measureFps;
         /**
+         * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
+         * @param renderTarget The render target to set the frame buffer for
+         */
+        setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
+        /**
+         * Update a dynamic index buffer
+         * @param indexBuffer defines the target index buffer
+         * @param indices defines the data to update
+         * @param offset defines the offset in the target index buffer where update should start
+         */
+        updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
+        /**
          * Creates a new render target texture
          * @param size defines the size of the texture
          * @param options defines the options used to create the texture

+ 2 - 2
Viewer/src/labs/texture.ts

@@ -1,6 +1,6 @@
 import { Scene } from "babylonjs/scene";
 import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
-import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
+import { InternalTexture, InternalTextureSource } from "babylonjs/Materials/Textures/internalTexture";
 import { Scalar } from "babylonjs/Maths/math.scalar";
 import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
 import { Texture } from "babylonjs/Materials/Textures/texture";
@@ -219,7 +219,7 @@ export class TextureUtils {
 
             babylonTexture.gammaSpace = false;
 
-            let internalTexture = new InternalTexture(scene.getEngine(), InternalTexture.DATASOURCE_CUBERAW);
+            let internalTexture = new InternalTexture(scene.getEngine(), InternalTextureSource.CubeRaw);
             let glTexture = internalTexture._webGLTexture;
             //babylon properties
             internalTexture.isCube = true;

+ 47 - 42
dist/preview release/babylon.d.ts

@@ -29378,7 +29378,7 @@ declare module BABYLON {
         /** @hidden */
         _currentRenderTarget: Nullable<InternalTexture>;
         private _uintIndicesCurrentlySet;
-        private _currentBoundBuffer;
+        protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
         /** @hidden */
         protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
         private _currentBufferPointers;
@@ -29620,13 +29620,6 @@ declare module BABYLON {
          */
         createDynamicVertexBuffer(data: DataArray): DataBuffer;
         /**
-         * Update a dynamic index buffer
-         * @param indexBuffer defines the target index buffer
-         * @param indices defines the data to update
-         * @param offset defines the offset in the target index buffer where update should start
-         */
-        updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
-        /**
          * Updates a dynamic vertex buffer.
          * @param vertexBuffer the vertex buffer to update
          * @param data the data used to update the vertex buffer
@@ -29634,7 +29627,7 @@ declare module BABYLON {
          * @param byteLength the byte length of the data
          */
         updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
-        private _resetIndexBufferBinding;
+        protected _resetIndexBufferBinding(): void;
         /**
          * Creates a new index buffer
          * @param indices defines the content of the index buffer
@@ -29648,7 +29641,7 @@ declare module BABYLON {
          * @param buffer defines the buffer to bind
          */
         bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
-        private bindIndexBuffer;
+        protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
         private bindBuffer;
         /**
          * update the bound buffer with the given data
@@ -30127,13 +30120,6 @@ declare module BABYLON {
          * @returns The texture
          */
         private _createDepthStencilTexture;
-        /**
-         * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
-         * @param renderTarget The render target to set the frame buffer for
-         */
-        setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
-        /** @hidden */
-        _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
         /** @hidden */
         _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
         /** @hidden */
@@ -30149,6 +30135,8 @@ declare module BABYLON {
         protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
         private _prepareWebGLTexture;
         /** @hidden */
+        _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
+        /** @hidden */
         _releaseFramebufferObjects(texture: InternalTexture): void;
         /** @hidden */
         _releaseTexture(texture: InternalTexture): void;
@@ -30276,64 +30264,69 @@ declare module BABYLON {
 }
 declare module BABYLON {
     /**
-     * Class used to store data associated with WebGL texture data for the engine
-     * This class should not be used directly
+     * Defines the source of the internal texture
      */
-    export class InternalTexture {
-        /** @hidden */
-        static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
+    export enum InternalTextureSource {
         /**
          * The source of the texture data is unknown
          */
-        static DATASOURCE_UNKNOWN: number;
+        Unknown = 0,
         /**
-         * Texture data comes from an URL
-         */
-        static DATASOURCE_URL: number;
+        * Texture data comes from an URL
+        */
+        Url = 1,
         /**
          * Texture data is only used for temporary storage
          */
-        static DATASOURCE_TEMP: number;
+        Temp = 2,
         /**
          * Texture data comes from raw data (ArrayBuffer)
          */
-        static DATASOURCE_RAW: number;
+        Raw = 3,
         /**
          * Texture content is dynamic (video or dynamic texture)
          */
-        static DATASOURCE_DYNAMIC: number;
+        Dynamic = 4,
         /**
          * Texture content is generated by rendering to it
          */
-        static DATASOURCE_RENDERTARGET: number;
+        RenderTarget = 5,
         /**
          * Texture content is part of a multi render target process
          */
-        static DATASOURCE_MULTIRENDERTARGET: number;
+        MultiRenderTarget = 6,
         /**
          * Texture data comes from a cube data file
          */
-        static DATASOURCE_CUBE: number;
+        Cube = 7,
         /**
          * Texture data comes from a raw cube data
          */
-        static DATASOURCE_CUBERAW: number;
+        CubeRaw = 8,
         /**
          * Texture data come from a prefiltered cube data file
          */
-        static DATASOURCE_CUBEPREFILTERED: number;
+        CubePrefiltered = 9,
         /**
          * Texture content is raw 3D data
          */
-        static DATASOURCE_RAW3D: number;
+        Raw3D = 10,
         /**
          * Texture content is a depth texture
          */
-        static DATASOURCE_DEPTHTEXTURE: number;
+        Depth = 11,
         /**
          * Texture data comes from a raw cube data encoded with RGBD
          */
-        static DATASOURCE_CUBERAW_RGBD: number;
+        CubeRawRGBD = 12
+    }
+    /**
+     * Class used to store data associated with WebGL texture data for the engine
+     * This class should not be used directly
+     */
+    export class InternalTexture {
+        /** @hidden */
+        static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
         /**
          * Defines if the texture is ready
          */
@@ -30411,7 +30404,7 @@ declare module BABYLON {
         /** @hidden */
         _associatedChannel: number;
         /** @hidden */
-        _dataSource: number;
+        _source: InternalTextureSource;
         /** @hidden */
         _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
         /** @hidden */
@@ -30493,16 +30486,16 @@ declare module BABYLON {
          */
         getEngine(): ThinEngine;
         /**
-         * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
+         * Gets the data source type of the texture
          */
-        readonly dataSource: number;
+        readonly source: InternalTextureSource;
         /**
          * Creates a new InternalTexture
          * @param engine defines the engine to use
-         * @param dataSource defines the type of data that will be used
+         * @param source defines the type of data that will be used
          * @param delayAllocation if the texture allocation should be delayed (default: false)
          */
-        constructor(engine: ThinEngine, dataSource: number, delayAllocation?: boolean);
+        constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
         /**
          * Increments the number of references (ie. the number of Texture that point to it)
          */
@@ -31773,6 +31766,18 @@ declare module BABYLON {
         getDeltaTime(): number;
         private _measureFps;
         /**
+         * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
+         * @param renderTarget The render target to set the frame buffer for
+         */
+        setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
+        /**
+         * Update a dynamic index buffer
+         * @param indexBuffer defines the target index buffer
+         * @param indices defines the data to update
+         * @param offset defines the offset in the target index buffer where update should start
+         */
+        updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
+        /**
          * Creates a new render target texture
          * @param size defines the size of the texture
          * @param options defines the options used to create the texture

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 2 - 2
dist/preview release/babylon.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 217 - 202
dist/preview release/babylon.max.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 1
dist/preview release/babylon.max.js.map


+ 96 - 86
dist/preview release/babylon.module.d.ts

@@ -30039,7 +30039,6 @@ declare module "babylonjs/Engines/thinEngine" {
     import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
     import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
     import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
-    import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
     /**
      * Defines the interface used by objects working like Scene
      * @hidden
@@ -30252,7 +30251,7 @@ declare module "babylonjs/Engines/thinEngine" {
         /** @hidden */
         _currentRenderTarget: Nullable<InternalTexture>;
         private _uintIndicesCurrentlySet;
-        private _currentBoundBuffer;
+        protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
         /** @hidden */
         protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
         private _currentBufferPointers;
@@ -30494,13 +30493,6 @@ declare module "babylonjs/Engines/thinEngine" {
          */
         createDynamicVertexBuffer(data: DataArray): DataBuffer;
         /**
-         * Update a dynamic index buffer
-         * @param indexBuffer defines the target index buffer
-         * @param indices defines the data to update
-         * @param offset defines the offset in the target index buffer where update should start
-         */
-        updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
-        /**
          * Updates a dynamic vertex buffer.
          * @param vertexBuffer the vertex buffer to update
          * @param data the data used to update the vertex buffer
@@ -30508,7 +30500,7 @@ declare module "babylonjs/Engines/thinEngine" {
          * @param byteLength the byte length of the data
          */
         updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
-        private _resetIndexBufferBinding;
+        protected _resetIndexBufferBinding(): void;
         /**
          * Creates a new index buffer
          * @param indices defines the content of the index buffer
@@ -30522,7 +30514,7 @@ declare module "babylonjs/Engines/thinEngine" {
          * @param buffer defines the buffer to bind
          */
         bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
-        private bindIndexBuffer;
+        protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
         private bindBuffer;
         /**
          * update the bound buffer with the given data
@@ -31001,13 +30993,6 @@ declare module "babylonjs/Engines/thinEngine" {
          * @returns The texture
          */
         private _createDepthStencilTexture;
-        /**
-         * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
-         * @param renderTarget The render target to set the frame buffer for
-         */
-        setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
-        /** @hidden */
-        _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
         /** @hidden */
         _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
         /** @hidden */
@@ -31023,6 +31008,8 @@ declare module "babylonjs/Engines/thinEngine" {
         protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
         private _prepareWebGLTexture;
         /** @hidden */
+        _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
+        /** @hidden */
         _releaseFramebufferObjects(texture: InternalTexture): void;
         /** @hidden */
         _releaseTexture(texture: InternalTexture): void;
@@ -31155,64 +31142,69 @@ declare module "babylonjs/Materials/Textures/internalTexture" {
     import { ThinEngine } from "babylonjs/Engines/thinEngine";
     import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
     /**
-     * Class used to store data associated with WebGL texture data for the engine
-     * This class should not be used directly
+     * Defines the source of the internal texture
      */
-    export class InternalTexture {
-        /** @hidden */
-        static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
+    export enum InternalTextureSource {
         /**
          * The source of the texture data is unknown
          */
-        static DATASOURCE_UNKNOWN: number;
+        Unknown = 0,
         /**
-         * Texture data comes from an URL
-         */
-        static DATASOURCE_URL: number;
+        * Texture data comes from an URL
+        */
+        Url = 1,
         /**
          * Texture data is only used for temporary storage
          */
-        static DATASOURCE_TEMP: number;
+        Temp = 2,
         /**
          * Texture data comes from raw data (ArrayBuffer)
          */
-        static DATASOURCE_RAW: number;
+        Raw = 3,
         /**
          * Texture content is dynamic (video or dynamic texture)
          */
-        static DATASOURCE_DYNAMIC: number;
+        Dynamic = 4,
         /**
          * Texture content is generated by rendering to it
          */
-        static DATASOURCE_RENDERTARGET: number;
+        RenderTarget = 5,
         /**
          * Texture content is part of a multi render target process
          */
-        static DATASOURCE_MULTIRENDERTARGET: number;
+        MultiRenderTarget = 6,
         /**
          * Texture data comes from a cube data file
          */
-        static DATASOURCE_CUBE: number;
+        Cube = 7,
         /**
          * Texture data comes from a raw cube data
          */
-        static DATASOURCE_CUBERAW: number;
+        CubeRaw = 8,
         /**
          * Texture data come from a prefiltered cube data file
          */
-        static DATASOURCE_CUBEPREFILTERED: number;
+        CubePrefiltered = 9,
         /**
          * Texture content is raw 3D data
          */
-        static DATASOURCE_RAW3D: number;
+        Raw3D = 10,
         /**
          * Texture content is a depth texture
          */
-        static DATASOURCE_DEPTHTEXTURE: number;
+        Depth = 11,
         /**
          * Texture data comes from a raw cube data encoded with RGBD
          */
-        static DATASOURCE_CUBERAW_RGBD: number;
+        CubeRawRGBD = 12
+    }
+    /**
+     * Class used to store data associated with WebGL texture data for the engine
+     * This class should not be used directly
+     */
+    export class InternalTexture {
+        /** @hidden */
+        static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
         /**
          * Defines if the texture is ready
          */
@@ -31290,7 +31282,7 @@ declare module "babylonjs/Materials/Textures/internalTexture" {
         /** @hidden */
         _associatedChannel: number;
         /** @hidden */
-        _dataSource: number;
+        _source: InternalTextureSource;
         /** @hidden */
         _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
         /** @hidden */
@@ -31372,16 +31364,16 @@ declare module "babylonjs/Materials/Textures/internalTexture" {
          */
         getEngine(): ThinEngine;
         /**
-         * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
+         * Gets the data source type of the texture
          */
-        readonly dataSource: number;
+        readonly source: InternalTextureSource;
         /**
          * Creates a new InternalTexture
          * @param engine defines the engine to use
-         * @param dataSource defines the type of data that will be used
+         * @param source defines the type of data that will be used
          * @param delayAllocation if the texture allocation should be delayed (default: false)
          */
-        constructor(engine: ThinEngine, dataSource: number, delayAllocation?: boolean);
+        constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
         /**
          * Increments the number of references (ie. the number of Texture that point to it)
          */
@@ -31865,7 +31857,7 @@ declare module "babylonjs/Misc/performanceMonitor" {
 }
 declare module "babylonjs/Engines/engine" {
     import { Observable } from "babylonjs/Misc/observable";
-    import { Nullable } from "babylonjs/types";
+    import { Nullable, IndicesArray } from "babylonjs/types";
     import { Scene } from "babylonjs/scene";
     import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
     import { IAudioEngine } from "babylonjs/Audio/audioEngine";
@@ -31879,6 +31871,7 @@ declare module "babylonjs/Engines/engine" {
     import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
     import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
     import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
+    import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
     import { Material } from "babylonjs/Materials/material";
     import { PostProcess } from "babylonjs/PostProcesses/postProcess";
     /**
@@ -32674,6 +32667,18 @@ declare module "babylonjs/Engines/engine" {
         getDeltaTime(): number;
         private _measureFps;
         /**
+         * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
+         * @param renderTarget The render target to set the frame buffer for
+         */
+        setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
+        /**
+         * Update a dynamic index buffer
+         * @param indexBuffer defines the target index buffer
+         * @param indices defines the data to update
+         * @param offset defines the offset in the target index buffer where update should start
+         */
+        updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
+        /**
          * Creates a new render target texture
          * @param size defines the size of the texture
          * @param options defines the options used to create the texture
@@ -96128,7 +96133,7 @@ declare module BABYLON {
         /** @hidden */
         _currentRenderTarget: Nullable<InternalTexture>;
         private _uintIndicesCurrentlySet;
-        private _currentBoundBuffer;
+        protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
         /** @hidden */
         protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
         private _currentBufferPointers;
@@ -96370,13 +96375,6 @@ declare module BABYLON {
          */
         createDynamicVertexBuffer(data: DataArray): DataBuffer;
         /**
-         * Update a dynamic index buffer
-         * @param indexBuffer defines the target index buffer
-         * @param indices defines the data to update
-         * @param offset defines the offset in the target index buffer where update should start
-         */
-        updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
-        /**
          * Updates a dynamic vertex buffer.
          * @param vertexBuffer the vertex buffer to update
          * @param data the data used to update the vertex buffer
@@ -96384,7 +96382,7 @@ declare module BABYLON {
          * @param byteLength the byte length of the data
          */
         updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
-        private _resetIndexBufferBinding;
+        protected _resetIndexBufferBinding(): void;
         /**
          * Creates a new index buffer
          * @param indices defines the content of the index buffer
@@ -96398,7 +96396,7 @@ declare module BABYLON {
          * @param buffer defines the buffer to bind
          */
         bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
-        private bindIndexBuffer;
+        protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
         private bindBuffer;
         /**
          * update the bound buffer with the given data
@@ -96877,13 +96875,6 @@ declare module BABYLON {
          * @returns The texture
          */
         private _createDepthStencilTexture;
-        /**
-         * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
-         * @param renderTarget The render target to set the frame buffer for
-         */
-        setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
-        /** @hidden */
-        _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
         /** @hidden */
         _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
         /** @hidden */
@@ -96899,6 +96890,8 @@ declare module BABYLON {
         protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
         private _prepareWebGLTexture;
         /** @hidden */
+        _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
+        /** @hidden */
         _releaseFramebufferObjects(texture: InternalTexture): void;
         /** @hidden */
         _releaseTexture(texture: InternalTexture): void;
@@ -97026,64 +97019,69 @@ declare module BABYLON {
 }
 declare module BABYLON {
     /**
-     * Class used to store data associated with WebGL texture data for the engine
-     * This class should not be used directly
+     * Defines the source of the internal texture
      */
-    export class InternalTexture {
-        /** @hidden */
-        static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
+    export enum InternalTextureSource {
         /**
          * The source of the texture data is unknown
          */
-        static DATASOURCE_UNKNOWN: number;
+        Unknown = 0,
         /**
-         * Texture data comes from an URL
-         */
-        static DATASOURCE_URL: number;
+        * Texture data comes from an URL
+        */
+        Url = 1,
         /**
          * Texture data is only used for temporary storage
          */
-        static DATASOURCE_TEMP: number;
+        Temp = 2,
         /**
          * Texture data comes from raw data (ArrayBuffer)
          */
-        static DATASOURCE_RAW: number;
+        Raw = 3,
         /**
          * Texture content is dynamic (video or dynamic texture)
          */
-        static DATASOURCE_DYNAMIC: number;
+        Dynamic = 4,
         /**
          * Texture content is generated by rendering to it
          */
-        static DATASOURCE_RENDERTARGET: number;
+        RenderTarget = 5,
         /**
          * Texture content is part of a multi render target process
          */
-        static DATASOURCE_MULTIRENDERTARGET: number;
+        MultiRenderTarget = 6,
         /**
          * Texture data comes from a cube data file
          */
-        static DATASOURCE_CUBE: number;
+        Cube = 7,
         /**
          * Texture data comes from a raw cube data
          */
-        static DATASOURCE_CUBERAW: number;
+        CubeRaw = 8,
         /**
          * Texture data come from a prefiltered cube data file
          */
-        static DATASOURCE_CUBEPREFILTERED: number;
+        CubePrefiltered = 9,
         /**
          * Texture content is raw 3D data
          */
-        static DATASOURCE_RAW3D: number;
+        Raw3D = 10,
         /**
          * Texture content is a depth texture
          */
-        static DATASOURCE_DEPTHTEXTURE: number;
+        Depth = 11,
         /**
          * Texture data comes from a raw cube data encoded with RGBD
          */
-        static DATASOURCE_CUBERAW_RGBD: number;
+        CubeRawRGBD = 12
+    }
+    /**
+     * Class used to store data associated with WebGL texture data for the engine
+     * This class should not be used directly
+     */
+    export class InternalTexture {
+        /** @hidden */
+        static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
         /**
          * Defines if the texture is ready
          */
@@ -97161,7 +97159,7 @@ declare module BABYLON {
         /** @hidden */
         _associatedChannel: number;
         /** @hidden */
-        _dataSource: number;
+        _source: InternalTextureSource;
         /** @hidden */
         _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
         /** @hidden */
@@ -97243,16 +97241,16 @@ declare module BABYLON {
          */
         getEngine(): ThinEngine;
         /**
-         * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
+         * Gets the data source type of the texture
          */
-        readonly dataSource: number;
+        readonly source: InternalTextureSource;
         /**
          * Creates a new InternalTexture
          * @param engine defines the engine to use
-         * @param dataSource defines the type of data that will be used
+         * @param source defines the type of data that will be used
          * @param delayAllocation if the texture allocation should be delayed (default: false)
          */
-        constructor(engine: ThinEngine, dataSource: number, delayAllocation?: boolean);
+        constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
         /**
          * Increments the number of references (ie. the number of Texture that point to it)
          */
@@ -98523,6 +98521,18 @@ declare module BABYLON {
         getDeltaTime(): number;
         private _measureFps;
         /**
+         * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
+         * @param renderTarget The render target to set the frame buffer for
+         */
+        setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
+        /**
+         * Update a dynamic index buffer
+         * @param indexBuffer defines the target index buffer
+         * @param indices defines the data to update
+         * @param offset defines the offset in the target index buffer where update should start
+         */
+        updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
+        /**
          * Creates a new render target texture
          * @param size defines the size of the texture
          * @param options defines the options used to create the texture

+ 47 - 42
dist/preview release/documentation.d.ts

@@ -29378,7 +29378,7 @@ declare module BABYLON {
         /** @hidden */
         _currentRenderTarget: Nullable<InternalTexture>;
         private _uintIndicesCurrentlySet;
-        private _currentBoundBuffer;
+        protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
         /** @hidden */
         protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
         private _currentBufferPointers;
@@ -29620,13 +29620,6 @@ declare module BABYLON {
          */
         createDynamicVertexBuffer(data: DataArray): DataBuffer;
         /**
-         * Update a dynamic index buffer
-         * @param indexBuffer defines the target index buffer
-         * @param indices defines the data to update
-         * @param offset defines the offset in the target index buffer where update should start
-         */
-        updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
-        /**
          * Updates a dynamic vertex buffer.
          * @param vertexBuffer the vertex buffer to update
          * @param data the data used to update the vertex buffer
@@ -29634,7 +29627,7 @@ declare module BABYLON {
          * @param byteLength the byte length of the data
          */
         updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
-        private _resetIndexBufferBinding;
+        protected _resetIndexBufferBinding(): void;
         /**
          * Creates a new index buffer
          * @param indices defines the content of the index buffer
@@ -29648,7 +29641,7 @@ declare module BABYLON {
          * @param buffer defines the buffer to bind
          */
         bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
-        private bindIndexBuffer;
+        protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
         private bindBuffer;
         /**
          * update the bound buffer with the given data
@@ -30127,13 +30120,6 @@ declare module BABYLON {
          * @returns The texture
          */
         private _createDepthStencilTexture;
-        /**
-         * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
-         * @param renderTarget The render target to set the frame buffer for
-         */
-        setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
-        /** @hidden */
-        _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
         /** @hidden */
         _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
         /** @hidden */
@@ -30149,6 +30135,8 @@ declare module BABYLON {
         protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
         private _prepareWebGLTexture;
         /** @hidden */
+        _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
+        /** @hidden */
         _releaseFramebufferObjects(texture: InternalTexture): void;
         /** @hidden */
         _releaseTexture(texture: InternalTexture): void;
@@ -30276,64 +30264,69 @@ declare module BABYLON {
 }
 declare module BABYLON {
     /**
-     * Class used to store data associated with WebGL texture data for the engine
-     * This class should not be used directly
+     * Defines the source of the internal texture
      */
-    export class InternalTexture {
-        /** @hidden */
-        static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
+    export enum InternalTextureSource {
         /**
          * The source of the texture data is unknown
          */
-        static DATASOURCE_UNKNOWN: number;
+        Unknown = 0,
         /**
-         * Texture data comes from an URL
-         */
-        static DATASOURCE_URL: number;
+        * Texture data comes from an URL
+        */
+        Url = 1,
         /**
          * Texture data is only used for temporary storage
          */
-        static DATASOURCE_TEMP: number;
+        Temp = 2,
         /**
          * Texture data comes from raw data (ArrayBuffer)
          */
-        static DATASOURCE_RAW: number;
+        Raw = 3,
         /**
          * Texture content is dynamic (video or dynamic texture)
          */
-        static DATASOURCE_DYNAMIC: number;
+        Dynamic = 4,
         /**
          * Texture content is generated by rendering to it
          */
-        static DATASOURCE_RENDERTARGET: number;
+        RenderTarget = 5,
         /**
          * Texture content is part of a multi render target process
          */
-        static DATASOURCE_MULTIRENDERTARGET: number;
+        MultiRenderTarget = 6,
         /**
          * Texture data comes from a cube data file
          */
-        static DATASOURCE_CUBE: number;
+        Cube = 7,
         /**
          * Texture data comes from a raw cube data
          */
-        static DATASOURCE_CUBERAW: number;
+        CubeRaw = 8,
         /**
          * Texture data come from a prefiltered cube data file
          */
-        static DATASOURCE_CUBEPREFILTERED: number;
+        CubePrefiltered = 9,
         /**
          * Texture content is raw 3D data
          */
-        static DATASOURCE_RAW3D: number;
+        Raw3D = 10,
         /**
          * Texture content is a depth texture
          */
-        static DATASOURCE_DEPTHTEXTURE: number;
+        Depth = 11,
         /**
          * Texture data comes from a raw cube data encoded with RGBD
          */
-        static DATASOURCE_CUBERAW_RGBD: number;
+        CubeRawRGBD = 12
+    }
+    /**
+     * Class used to store data associated with WebGL texture data for the engine
+     * This class should not be used directly
+     */
+    export class InternalTexture {
+        /** @hidden */
+        static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
         /**
          * Defines if the texture is ready
          */
@@ -30411,7 +30404,7 @@ declare module BABYLON {
         /** @hidden */
         _associatedChannel: number;
         /** @hidden */
-        _dataSource: number;
+        _source: InternalTextureSource;
         /** @hidden */
         _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
         /** @hidden */
@@ -30493,16 +30486,16 @@ declare module BABYLON {
          */
         getEngine(): ThinEngine;
         /**
-         * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
+         * Gets the data source type of the texture
          */
-        readonly dataSource: number;
+        readonly source: InternalTextureSource;
         /**
          * Creates a new InternalTexture
          * @param engine defines the engine to use
-         * @param dataSource defines the type of data that will be used
+         * @param source defines the type of data that will be used
          * @param delayAllocation if the texture allocation should be delayed (default: false)
          */
-        constructor(engine: ThinEngine, dataSource: number, delayAllocation?: boolean);
+        constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
         /**
          * Increments the number of references (ie. the number of Texture that point to it)
          */
@@ -31773,6 +31766,18 @@ declare module BABYLON {
         getDeltaTime(): number;
         private _measureFps;
         /**
+         * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
+         * @param renderTarget The render target to set the frame buffer for
+         */
+        setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
+        /**
+         * Update a dynamic index buffer
+         * @param indexBuffer defines the target index buffer
+         * @param indices defines the data to update
+         * @param offset defines the offset in the target index buffer where update should start
+         */
+        updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
+        /**
          * Creates a new render target texture
          * @param size defines the size of the texture
          * @param options defines the options used to create the texture

+ 1 - 1
dist/preview release/packagesSizeBaseLine.json

@@ -1 +1 @@
-{"thinEngineOnly":130582,"engineOnly":166444,"sceneOnly":510325,"minGridMaterial":640570,"minStandardMaterial":771729}
+{"thinEngineOnly":129387,"engineOnly":166326,"sceneOnly":510207,"minGridMaterial":640452,"minStandardMaterial":771611}

+ 96 - 86
dist/preview release/viewer/babylon.module.d.ts

@@ -30039,7 +30039,6 @@ declare module "babylonjs/Engines/thinEngine" {
     import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
     import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
     import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
-    import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
     /**
      * Defines the interface used by objects working like Scene
      * @hidden
@@ -30252,7 +30251,7 @@ declare module "babylonjs/Engines/thinEngine" {
         /** @hidden */
         _currentRenderTarget: Nullable<InternalTexture>;
         private _uintIndicesCurrentlySet;
-        private _currentBoundBuffer;
+        protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
         /** @hidden */
         protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
         private _currentBufferPointers;
@@ -30494,13 +30493,6 @@ declare module "babylonjs/Engines/thinEngine" {
          */
         createDynamicVertexBuffer(data: DataArray): DataBuffer;
         /**
-         * Update a dynamic index buffer
-         * @param indexBuffer defines the target index buffer
-         * @param indices defines the data to update
-         * @param offset defines the offset in the target index buffer where update should start
-         */
-        updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
-        /**
          * Updates a dynamic vertex buffer.
          * @param vertexBuffer the vertex buffer to update
          * @param data the data used to update the vertex buffer
@@ -30508,7 +30500,7 @@ declare module "babylonjs/Engines/thinEngine" {
          * @param byteLength the byte length of the data
          */
         updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
-        private _resetIndexBufferBinding;
+        protected _resetIndexBufferBinding(): void;
         /**
          * Creates a new index buffer
          * @param indices defines the content of the index buffer
@@ -30522,7 +30514,7 @@ declare module "babylonjs/Engines/thinEngine" {
          * @param buffer defines the buffer to bind
          */
         bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
-        private bindIndexBuffer;
+        protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
         private bindBuffer;
         /**
          * update the bound buffer with the given data
@@ -31001,13 +30993,6 @@ declare module "babylonjs/Engines/thinEngine" {
          * @returns The texture
          */
         private _createDepthStencilTexture;
-        /**
-         * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
-         * @param renderTarget The render target to set the frame buffer for
-         */
-        setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
-        /** @hidden */
-        _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
         /** @hidden */
         _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
         /** @hidden */
@@ -31023,6 +31008,8 @@ declare module "babylonjs/Engines/thinEngine" {
         protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
         private _prepareWebGLTexture;
         /** @hidden */
+        _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
+        /** @hidden */
         _releaseFramebufferObjects(texture: InternalTexture): void;
         /** @hidden */
         _releaseTexture(texture: InternalTexture): void;
@@ -31155,64 +31142,69 @@ declare module "babylonjs/Materials/Textures/internalTexture" {
     import { ThinEngine } from "babylonjs/Engines/thinEngine";
     import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
     /**
-     * Class used to store data associated with WebGL texture data for the engine
-     * This class should not be used directly
+     * Defines the source of the internal texture
      */
-    export class InternalTexture {
-        /** @hidden */
-        static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
+    export enum InternalTextureSource {
         /**
          * The source of the texture data is unknown
          */
-        static DATASOURCE_UNKNOWN: number;
+        Unknown = 0,
         /**
-         * Texture data comes from an URL
-         */
-        static DATASOURCE_URL: number;
+        * Texture data comes from an URL
+        */
+        Url = 1,
         /**
          * Texture data is only used for temporary storage
          */
-        static DATASOURCE_TEMP: number;
+        Temp = 2,
         /**
          * Texture data comes from raw data (ArrayBuffer)
          */
-        static DATASOURCE_RAW: number;
+        Raw = 3,
         /**
          * Texture content is dynamic (video or dynamic texture)
          */
-        static DATASOURCE_DYNAMIC: number;
+        Dynamic = 4,
         /**
          * Texture content is generated by rendering to it
          */
-        static DATASOURCE_RENDERTARGET: number;
+        RenderTarget = 5,
         /**
          * Texture content is part of a multi render target process
          */
-        static DATASOURCE_MULTIRENDERTARGET: number;
+        MultiRenderTarget = 6,
         /**
          * Texture data comes from a cube data file
          */
-        static DATASOURCE_CUBE: number;
+        Cube = 7,
         /**
          * Texture data comes from a raw cube data
          */
-        static DATASOURCE_CUBERAW: number;
+        CubeRaw = 8,
         /**
          * Texture data come from a prefiltered cube data file
          */
-        static DATASOURCE_CUBEPREFILTERED: number;
+        CubePrefiltered = 9,
         /**
          * Texture content is raw 3D data
          */
-        static DATASOURCE_RAW3D: number;
+        Raw3D = 10,
         /**
          * Texture content is a depth texture
          */
-        static DATASOURCE_DEPTHTEXTURE: number;
+        Depth = 11,
         /**
          * Texture data comes from a raw cube data encoded with RGBD
          */
-        static DATASOURCE_CUBERAW_RGBD: number;
+        CubeRawRGBD = 12
+    }
+    /**
+     * Class used to store data associated with WebGL texture data for the engine
+     * This class should not be used directly
+     */
+    export class InternalTexture {
+        /** @hidden */
+        static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
         /**
          * Defines if the texture is ready
          */
@@ -31290,7 +31282,7 @@ declare module "babylonjs/Materials/Textures/internalTexture" {
         /** @hidden */
         _associatedChannel: number;
         /** @hidden */
-        _dataSource: number;
+        _source: InternalTextureSource;
         /** @hidden */
         _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
         /** @hidden */
@@ -31372,16 +31364,16 @@ declare module "babylonjs/Materials/Textures/internalTexture" {
          */
         getEngine(): ThinEngine;
         /**
-         * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
+         * Gets the data source type of the texture
          */
-        readonly dataSource: number;
+        readonly source: InternalTextureSource;
         /**
          * Creates a new InternalTexture
          * @param engine defines the engine to use
-         * @param dataSource defines the type of data that will be used
+         * @param source defines the type of data that will be used
          * @param delayAllocation if the texture allocation should be delayed (default: false)
          */
-        constructor(engine: ThinEngine, dataSource: number, delayAllocation?: boolean);
+        constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
         /**
          * Increments the number of references (ie. the number of Texture that point to it)
          */
@@ -31865,7 +31857,7 @@ declare module "babylonjs/Misc/performanceMonitor" {
 }
 declare module "babylonjs/Engines/engine" {
     import { Observable } from "babylonjs/Misc/observable";
-    import { Nullable } from "babylonjs/types";
+    import { Nullable, IndicesArray } from "babylonjs/types";
     import { Scene } from "babylonjs/scene";
     import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
     import { IAudioEngine } from "babylonjs/Audio/audioEngine";
@@ -31879,6 +31871,7 @@ declare module "babylonjs/Engines/engine" {
     import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
     import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
     import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
+    import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
     import { Material } from "babylonjs/Materials/material";
     import { PostProcess } from "babylonjs/PostProcesses/postProcess";
     /**
@@ -32674,6 +32667,18 @@ declare module "babylonjs/Engines/engine" {
         getDeltaTime(): number;
         private _measureFps;
         /**
+         * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
+         * @param renderTarget The render target to set the frame buffer for
+         */
+        setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
+        /**
+         * Update a dynamic index buffer
+         * @param indexBuffer defines the target index buffer
+         * @param indices defines the data to update
+         * @param offset defines the offset in the target index buffer where update should start
+         */
+        updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
+        /**
          * Creates a new render target texture
          * @param size defines the size of the texture
          * @param options defines the options used to create the texture
@@ -96128,7 +96133,7 @@ declare module BABYLON {
         /** @hidden */
         _currentRenderTarget: Nullable<InternalTexture>;
         private _uintIndicesCurrentlySet;
-        private _currentBoundBuffer;
+        protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
         /** @hidden */
         protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
         private _currentBufferPointers;
@@ -96370,13 +96375,6 @@ declare module BABYLON {
          */
         createDynamicVertexBuffer(data: DataArray): DataBuffer;
         /**
-         * Update a dynamic index buffer
-         * @param indexBuffer defines the target index buffer
-         * @param indices defines the data to update
-         * @param offset defines the offset in the target index buffer where update should start
-         */
-        updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
-        /**
          * Updates a dynamic vertex buffer.
          * @param vertexBuffer the vertex buffer to update
          * @param data the data used to update the vertex buffer
@@ -96384,7 +96382,7 @@ declare module BABYLON {
          * @param byteLength the byte length of the data
          */
         updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
-        private _resetIndexBufferBinding;
+        protected _resetIndexBufferBinding(): void;
         /**
          * Creates a new index buffer
          * @param indices defines the content of the index buffer
@@ -96398,7 +96396,7 @@ declare module BABYLON {
          * @param buffer defines the buffer to bind
          */
         bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
-        private bindIndexBuffer;
+        protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
         private bindBuffer;
         /**
          * update the bound buffer with the given data
@@ -96877,13 +96875,6 @@ declare module BABYLON {
          * @returns The texture
          */
         private _createDepthStencilTexture;
-        /**
-         * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
-         * @param renderTarget The render target to set the frame buffer for
-         */
-        setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
-        /** @hidden */
-        _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
         /** @hidden */
         _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
         /** @hidden */
@@ -96899,6 +96890,8 @@ declare module BABYLON {
         protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
         private _prepareWebGLTexture;
         /** @hidden */
+        _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
+        /** @hidden */
         _releaseFramebufferObjects(texture: InternalTexture): void;
         /** @hidden */
         _releaseTexture(texture: InternalTexture): void;
@@ -97026,64 +97019,69 @@ declare module BABYLON {
 }
 declare module BABYLON {
     /**
-     * Class used to store data associated with WebGL texture data for the engine
-     * This class should not be used directly
+     * Defines the source of the internal texture
      */
-    export class InternalTexture {
-        /** @hidden */
-        static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
+    export enum InternalTextureSource {
         /**
          * The source of the texture data is unknown
          */
-        static DATASOURCE_UNKNOWN: number;
+        Unknown = 0,
         /**
-         * Texture data comes from an URL
-         */
-        static DATASOURCE_URL: number;
+        * Texture data comes from an URL
+        */
+        Url = 1,
         /**
          * Texture data is only used for temporary storage
          */
-        static DATASOURCE_TEMP: number;
+        Temp = 2,
         /**
          * Texture data comes from raw data (ArrayBuffer)
          */
-        static DATASOURCE_RAW: number;
+        Raw = 3,
         /**
          * Texture content is dynamic (video or dynamic texture)
          */
-        static DATASOURCE_DYNAMIC: number;
+        Dynamic = 4,
         /**
          * Texture content is generated by rendering to it
          */
-        static DATASOURCE_RENDERTARGET: number;
+        RenderTarget = 5,
         /**
          * Texture content is part of a multi render target process
          */
-        static DATASOURCE_MULTIRENDERTARGET: number;
+        MultiRenderTarget = 6,
         /**
          * Texture data comes from a cube data file
          */
-        static DATASOURCE_CUBE: number;
+        Cube = 7,
         /**
          * Texture data comes from a raw cube data
          */
-        static DATASOURCE_CUBERAW: number;
+        CubeRaw = 8,
         /**
          * Texture data come from a prefiltered cube data file
          */
-        static DATASOURCE_CUBEPREFILTERED: number;
+        CubePrefiltered = 9,
         /**
          * Texture content is raw 3D data
          */
-        static DATASOURCE_RAW3D: number;
+        Raw3D = 10,
         /**
          * Texture content is a depth texture
          */
-        static DATASOURCE_DEPTHTEXTURE: number;
+        Depth = 11,
         /**
          * Texture data comes from a raw cube data encoded with RGBD
          */
-        static DATASOURCE_CUBERAW_RGBD: number;
+        CubeRawRGBD = 12
+    }
+    /**
+     * Class used to store data associated with WebGL texture data for the engine
+     * This class should not be used directly
+     */
+    export class InternalTexture {
+        /** @hidden */
+        static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
         /**
          * Defines if the texture is ready
          */
@@ -97161,7 +97159,7 @@ declare module BABYLON {
         /** @hidden */
         _associatedChannel: number;
         /** @hidden */
-        _dataSource: number;
+        _source: InternalTextureSource;
         /** @hidden */
         _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
         /** @hidden */
@@ -97243,16 +97241,16 @@ declare module BABYLON {
          */
         getEngine(): ThinEngine;
         /**
-         * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
+         * Gets the data source type of the texture
          */
-        readonly dataSource: number;
+        readonly source: InternalTextureSource;
         /**
          * Creates a new InternalTexture
          * @param engine defines the engine to use
-         * @param dataSource defines the type of data that will be used
+         * @param source defines the type of data that will be used
          * @param delayAllocation if the texture allocation should be delayed (default: false)
          */
-        constructor(engine: ThinEngine, dataSource: number, delayAllocation?: boolean);
+        constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
         /**
          * Increments the number of references (ie. the number of Texture that point to it)
          */
@@ -98523,6 +98521,18 @@ declare module BABYLON {
         getDeltaTime(): number;
         private _measureFps;
         /**
+         * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
+         * @param renderTarget The render target to set the frame buffer for
+         */
+        setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
+        /**
+         * Update a dynamic index buffer
+         * @param indexBuffer defines the target index buffer
+         * @param indices defines the data to update
+         * @param offset defines the offset in the target index buffer where update should start
+         */
+        updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
+        /**
          * Creates a new render target texture
          * @param size defines the size of the texture
          * @param options defines the options used to create the texture

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 80 - 80
dist/preview release/viewer/babylon.viewer.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 2 - 2
dist/preview release/viewer/babylon.viewer.max.js


+ 2 - 2
src/Cameras/XR/webXRSessionManager.ts

@@ -2,7 +2,7 @@ import { Logger } from "../../Misc/logger";
 import { Observable } from "../../Misc/observable";
 import { Nullable } from "../../types";
 import { IDisposable, Scene } from "../../scene";
-import { InternalTexture } from "../../Materials/Textures/internalTexture";
+import { InternalTexture, InternalTextureSource } from "../../Materials/Textures/internalTexture";
 import { RenderTargetTexture } from "../../Materials/Textures/renderTargetTexture";
 /**
  * Manages an XRSession to work with Babylon's engine
@@ -173,7 +173,7 @@ export class WebXRSessionManager implements IDisposable {
             throw "no layer";
         }
         // Create internal texture
-        var internalTexture = new InternalTexture(scene.getEngine(), InternalTexture.DATASOURCE_UNKNOWN, true);
+        var internalTexture = new InternalTexture(scene.getEngine(), InternalTextureSource.Unknown, true);
         internalTexture.width = baseLayer.framebufferWidth;
         internalTexture.height = baseLayer.framebufferHeight;
         internalTexture._framebuffer = baseLayer.framebuffer;

+ 3 - 3
src/Engines/Extensions/engine.cubeTexture.ts

@@ -1,5 +1,5 @@
 import { ThinEngine } from "../../Engines/thinEngine";
-import { InternalTexture } from '../../Materials/Textures/internalTexture';
+import { InternalTexture, InternalTextureSource } from '../../Materials/Textures/internalTexture';
 import { Logger } from '../../Misc/logger';
 import { Nullable } from '../../types';
 import { Scene } from '../../scene';
@@ -90,7 +90,7 @@ declare module "../../Engines/thinEngine" {
 }
 
 ThinEngine.prototype._createDepthStencilCubeTexture = function(size: number, options: DepthTextureCreationOptions): InternalTexture {
-    var internalTexture = new InternalTexture(this, InternalTexture.DATASOURCE_UNKNOWN);
+    var internalTexture = new InternalTexture(this, InternalTextureSource.Unknown);
     internalTexture.isCube = true;
 
     if (this.webGLVersion === 1) {
@@ -201,7 +201,7 @@ ThinEngine.prototype._partialLoadImg = function(url: string, index: number, load
 ThinEngine.prototype.createCubeTexture = function(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad: Nullable<(data?: any) => void> = null, onError: Nullable<(message?: string, exception?: any) => void> = null, format?: number, forcedExtension: any = null, createPolynomials: boolean = false, lodScale: number = 0, lodOffset: number = 0, fallback: Nullable<InternalTexture> = null, excludeLoaders: Array<IInternalTextureLoader> = []): InternalTexture {
     var gl = this._gl;
 
-    var texture = fallback ? fallback : new InternalTexture(this, InternalTexture.DATASOURCE_CUBE);
+    var texture = fallback ? fallback : new InternalTexture(this, InternalTextureSource.Cube);
     texture.isCube = true;
     texture.url = rootUrl;
     texture.generateMipMaps = !noMipmap;

+ 2 - 2
src/Engines/Extensions/engine.dynamicTexture.ts

@@ -1,5 +1,5 @@
 import { ThinEngine } from "../../Engines/thinEngine";
-import { InternalTexture } from '../../Materials/Textures/internalTexture';
+import { InternalTexture, InternalTextureSource } from '../../Materials/Textures/internalTexture';
 import { Nullable } from '../../types';
 
 declare module "../../Engines/thinEngine" {
@@ -28,7 +28,7 @@ declare module "../../Engines/thinEngine" {
 }
 
 ThinEngine.prototype.createDynamicTexture = function(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture {
-    var texture = new InternalTexture(this, InternalTexture.DATASOURCE_DYNAMIC);
+    var texture = new InternalTexture(this, InternalTextureSource.Dynamic);
     texture.baseWidth = width;
     texture.baseHeight = height;
 

+ 3 - 3
src/Engines/Extensions/engine.multiRender.ts

@@ -1,4 +1,4 @@
-import { InternalTexture } from '../../Materials/Textures/internalTexture';
+import { InternalTexture, InternalTextureSource } from '../../Materials/Textures/internalTexture';
 import { IMultiRenderTargetOptions } from '../../Materials/Textures/multiRenderTarget';
 import { Logger } from '../../Misc/logger';
 import { Nullable } from '../../types';
@@ -153,7 +153,7 @@ ThinEngine.prototype.createMultipleRenderTarget = function(size: any, options: I
             Logger.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
         }
 
-        var texture = new InternalTexture(this, InternalTexture.DATASOURCE_MULTIRENDERTARGET);
+        var texture = new InternalTexture(this, InternalTextureSource.MultiRenderTarget);
         var attachment = (<any>gl)[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
 
         textures.push(texture);
@@ -198,7 +198,7 @@ ThinEngine.prototype.createMultipleRenderTarget = function(size: any, options: I
 
     if (generateDepthTexture && this._caps.depthTextureExtension) {
         // Depth texture
-        var depthTexture = new InternalTexture(this, InternalTexture.DATASOURCE_MULTIRENDERTARGET);
+        var depthTexture = new InternalTexture(this, InternalTextureSource.MultiRenderTarget);
 
         gl.activeTexture(gl.TEXTURE0);
         gl.bindTexture(gl.TEXTURE_2D, depthTexture._webGLTexture);

+ 2 - 2
src/Engines/Extensions/engine.multiview.ts

@@ -1,7 +1,7 @@
 import { Camera } from "../../Cameras/camera";
 import { Engine } from "../../Engines/engine";
 import { Scene } from "../../scene";
-import { InternalTexture } from '../../Materials/Textures/internalTexture';
+import { InternalTexture, InternalTextureSource } from '../../Materials/Textures/internalTexture';
 import { Nullable } from '../../types';
 import { RenderTargetTexture } from '../../Materials/Textures/renderTargetTexture';
 import { Matrix, TmpVectors } from '../../Maths/math.vector';
@@ -34,7 +34,7 @@ Engine.prototype.createMultiviewRenderTargetTexture = function(width: number, he
         throw "Multiview is not supported";
     }
 
-    var internalTexture = new InternalTexture(this, InternalTexture.DATASOURCE_UNKNOWN, true);
+    var internalTexture = new InternalTexture(this, InternalTextureSource.Unknown, true);
     internalTexture.width = width;
     internalTexture.height = height;
     internalTexture._framebuffer = gl.createFramebuffer();

+ 4 - 4
src/Engines/Extensions/engine.rawTexture.ts

@@ -1,6 +1,6 @@
 import { Nullable } from "../../types";
 import { _TimeToken } from "../../Instrumentation/timeToken";
-import { InternalTexture } from '../../Materials/Textures/internalTexture';
+import { InternalTexture, InternalTextureSource } from '../../Materials/Textures/internalTexture';
 import { Logger } from '../../Misc/logger';
 import { Tools } from '../../Misc/tools';
 import { Scene } from '../../scene';
@@ -214,7 +214,7 @@ Engine.prototype.updateRawTexture = function(texture: Nullable<InternalTexture>,
 };
 
 Engine.prototype.createRawTexture = function(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string> = null, type: number = Constants.TEXTURETYPE_UNSIGNED_INT): InternalTexture {
-    var texture = new InternalTexture(this, InternalTexture.DATASOURCE_RAW);
+    var texture = new InternalTexture(this, InternalTextureSource.Raw);
     texture.baseWidth = width;
     texture.baseHeight = height;
     texture.width = width;
@@ -254,7 +254,7 @@ Engine.prototype.createRawCubeTexture = function(data: Nullable<ArrayBufferView[
     generateMipMaps: boolean, invertY: boolean, samplingMode: number,
     compression: Nullable<string> = null): InternalTexture {
     var gl = this._gl;
-    var texture = new InternalTexture(this, InternalTexture.DATASOURCE_CUBERAW);
+    var texture = new InternalTexture(this, InternalTextureSource.CubeRaw);
     texture.isCube = true;
     texture.format = format;
     texture.type = type;
@@ -454,7 +454,7 @@ Engine.prototype.createRawCubeTextureFromUrl = function(url: string, scene: Scen
 };
 
 Engine.prototype.createRawTexture3D = function(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string> = null, textureType: number = Constants.TEXTURETYPE_UNSIGNED_INT): InternalTexture {
-    var texture = new InternalTexture(this, InternalTexture.DATASOURCE_RAW3D);
+    var texture = new InternalTexture(this, InternalTextureSource.Raw3D);
     texture.baseWidth = width;
     texture.baseHeight = height;
     texture.baseDepth = depth;

+ 2 - 2
src/Engines/Extensions/engine.renderTarget.ts

@@ -1,4 +1,4 @@
-import { InternalTexture } from '../../Materials/Textures/internalTexture';
+import { InternalTexture, InternalTextureSource } from '../../Materials/Textures/internalTexture';
 import { Logger } from '../../Misc/logger';
 import { RenderTargetCreationOptions } from '../../Materials/Textures/renderTargetCreationOptions';
 import { Constants } from '../constants';
@@ -38,7 +38,7 @@ ThinEngine.prototype.createRenderTargetCubeTexture = function(size: number, opti
     }
     var gl = this._gl;
 
-    var texture = new InternalTexture(this, InternalTexture.DATASOURCE_RENDERTARGET);
+    var texture = new InternalTexture(this, InternalTextureSource.RenderTarget);
     this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
 
     var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps);

+ 61 - 3
src/Engines/engine.ts

@@ -1,7 +1,7 @@
 import { Observable } from "../Misc/observable";
-import { Nullable } from "../types";
+import { Nullable, IndicesArray } from "../types";
 import { Scene } from "../scene";
-import { InternalTexture } from "../Materials/Textures/internalTexture";
+import { InternalTexture, InternalTextureSource } from "../Materials/Textures/internalTexture";
 import { _TimeToken } from "../Instrumentation/timeToken";
 import { IAudioEngine } from "../Audio/audioEngine";
 import { IOfflineProvider } from "../Offline/IOfflineProvider";
@@ -19,6 +19,7 @@ import { RenderTargetCreationOptions } from '../Materials/Textures/renderTargetC
 import { RenderTargetTexture } from '../Materials/Textures/renderTargetTexture';
 import { PerformanceMonitor } from '../Misc/performanceMonitor';
 import { Logger } from '../Misc/logger';
+import { DataBuffer } from '../Meshes/dataBuffer';
 
 declare type Material = import("../Materials/material").Material;
 declare type PostProcess = import("../PostProcesses/postProcess").PostProcess;
@@ -1694,6 +1695,63 @@ export class Engine extends ThinEngine {
     }
 
     /**
+     * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
+     * @param renderTarget The render target to set the frame buffer for
+     */
+    public setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void {
+        // Create the framebuffer
+        var internalTexture = renderTarget.getInternalTexture();
+        if (!internalTexture || !internalTexture._framebuffer || !renderTarget.depthStencilTexture) {
+            return;
+        }
+
+        var gl = this._gl;
+        var depthStencilTexture = renderTarget.depthStencilTexture;
+
+        this._bindUnboundFramebuffer(internalTexture._framebuffer);
+        if (depthStencilTexture.isCube) {
+            if (depthStencilTexture._generateStencilBuffer) {
+                gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
+            }
+            else {
+                gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
+            }
+        }
+        else {
+            if (depthStencilTexture._generateStencilBuffer) {
+                gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
+            }
+            else {
+                gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
+            }
+        }
+        this._bindUnboundFramebuffer(null);
+    }
+
+    /**
+     * Update a dynamic index buffer
+     * @param indexBuffer defines the target index buffer
+     * @param indices defines the data to update
+     * @param offset defines the offset in the target index buffer where update should start
+     */
+    public updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset: number = 0): void {
+        // Force cache update
+        this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;
+        this.bindIndexBuffer(indexBuffer);
+        var arrayBuffer;
+
+        if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
+            arrayBuffer = indices;
+        } else {
+            arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
+        }
+
+        this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
+
+        this._resetIndexBufferBinding();
+    }
+
+    /**
      * Creates a new render target texture
      * @param size defines the size of the texture
      * @param options defines the options used to create the texture
@@ -1728,7 +1786,7 @@ export class Engine extends ThinEngine {
         }
         var gl = this._gl;
 
-        var texture = new InternalTexture(this, InternalTexture.DATASOURCE_RENDERTARGET);
+        var texture = new InternalTexture(this, InternalTextureSource.RenderTarget);
         this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
 
         var width = (<{ width: number, height: number }>size).width || <number>size;

+ 4 - 4
src/Engines/nativeEngine.ts

@@ -1,7 +1,7 @@
 import { Nullable, IndicesArray, DataArray } from "../types";
 import { Engine } from "../Engines/engine";
 import { VertexBuffer } from "../Meshes/buffer";
-import { InternalTexture } from "../Materials/Textures/internalTexture";
+import { InternalTexture, InternalTextureSource } from "../Materials/Textures/internalTexture";
 import { IInternalTextureLoader } from "../Materials/Textures/internalTextureLoader";
 import { Texture } from "../Materials/Textures/texture";
 import { BaseTexture } from "../Materials/Textures/baseTexture";
@@ -800,7 +800,7 @@ export class NativeEngine extends Engine {
         var fromBlob = url.substr(0, 5) === "blob:";
         var isBase64 = fromData && url.indexOf("base64") !== -1;
 
-        let texture = fallback ? fallback : new InternalTexture(this, InternalTexture.DATASOURCE_URL);
+        let texture = fallback ? fallback : new InternalTexture(this, InternalTextureSource.Url);
 
         // establish the file extension, if possible
         var lastDot = url.lastIndexOf('.');
@@ -988,7 +988,7 @@ export class NativeEngine extends Engine {
         lodOffset: number = 0,
         fallback: Nullable<InternalTexture> = null): InternalTexture
     {
-        var texture = fallback ? fallback : new InternalTexture(this, InternalTexture.DATASOURCE_CUBE);
+        var texture = fallback ? fallback : new InternalTexture(this, InternalTextureSource.Cube);
         texture.isCube = true;
         texture.url = rootUrl;
         texture.generateMipMaps = !noMipmap;
@@ -1131,7 +1131,7 @@ export class NativeEngine extends Engine {
             // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
             fullOptions.samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;
         }
-        var texture = new InternalTexture(this, InternalTexture.DATASOURCE_RENDERTARGET);
+        var texture = new InternalTexture(this, InternalTextureSource.RenderTarget);
 
         var width = (<{ width: number, height: number }>size).width || <number>size;
         var height = (<{ width: number, height: number }>size).height || <number>size;

+ 3 - 3
src/Engines/nullEngine.ts

@@ -4,7 +4,7 @@ import { Scene } from "../scene";
 import { Engine } from "../Engines/engine";
 import { RenderTargetCreationOptions } from "../Materials/Textures/renderTargetCreationOptions";
 import { VertexBuffer } from "../Meshes/buffer";
-import { InternalTexture } from "../Materials/Textures/internalTexture";
+import { InternalTexture, InternalTextureSource } from "../Materials/Textures/internalTexture";
 import { Effect } from "../Materials/effect";
 import { _TimeToken } from "../Instrumentation/timeToken";
 import { Constants } from "./constants";
@@ -565,7 +565,7 @@ export class NullEngine extends Engine {
     public createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,
         onLoad: Nullable<() => void> = null, onError: Nullable<(message: string, exception: any) => void> = null,
         buffer: Nullable<ArrayBuffer | HTMLImageElement> = null, fallBack?: InternalTexture, format?: number): InternalTexture {
-        var texture = new InternalTexture(this, InternalTexture.DATASOURCE_URL);
+        var texture = new InternalTexture(this, InternalTextureSource.Url);
         var url = String(urlArg);
 
         texture.url = url;
@@ -613,7 +613,7 @@ export class NullEngine extends Engine {
             fullOptions.type = Constants.TEXTURETYPE_UNSIGNED_INT;
             fullOptions.samplingMode = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE;
         }
-        var texture = new InternalTexture(this, InternalTexture.DATASOURCE_RENDERTARGET);
+        var texture = new InternalTexture(this, InternalTextureSource.RenderTarget);
 
         var width = size.width || size;
         var height = size.height || size;

+ 42 - 99
src/Engines/thinEngine.ts

@@ -12,7 +12,7 @@ import { DepthCullingState } from '../States/depthCullingState';
 import { StencilState } from '../States/stencilState';
 import { AlphaState } from '../States/alphaCullingState';
 import { Constants } from './constants';
-import { InternalTexture } from '../Materials/Textures/internalTexture';
+import { InternalTexture, InternalTextureSource } from '../Materials/Textures/internalTexture';
 import { IViewportLike, IColor4Like } from '../Maths/math.like';
 import { DataBuffer } from '../Meshes/dataBuffer';
 import { IFileRequest } from '../Misc/fileRequest';
@@ -333,7 +333,7 @@ export class ThinEngine {
     /** @hidden */
     public _currentRenderTarget: Nullable<InternalTexture>;
     private _uintIndicesCurrentlySet = false;
-    private _currentBoundBuffer = new Array<Nullable<WebGLBuffer>>();
+    protected _currentBoundBuffer = new Array<Nullable<WebGLBuffer>>();
     /** @hidden */
     protected _currentFramebuffer: Nullable<WebGLFramebuffer> = null;
     private _currentBufferPointers = new Array<BufferPointer>();
@@ -892,7 +892,7 @@ export class ThinEngine {
      * @returns "Engine" string
      */
     public getClassName(): string {
-        return "Engine";
+        return "ThinEngine";
     }
 
     /**
@@ -1375,29 +1375,6 @@ export class ThinEngine {
     }
 
     /**
-     * Update a dynamic index buffer
-     * @param indexBuffer defines the target index buffer
-     * @param indices defines the data to update
-     * @param offset defines the offset in the target index buffer where update should start
-     */
-    public updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset: number = 0): void {
-        // Force cache update
-        this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;
-        this.bindIndexBuffer(indexBuffer);
-        var arrayBuffer;
-
-        if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
-            arrayBuffer = indices;
-        } else {
-            arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
-        }
-
-        this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
-
-        this._resetIndexBufferBinding();
-    }
-
-    /**
      * Updates a dynamic vertex buffer.
      * @param vertexBuffer the vertex buffer to update
      * @param data the data used to update the vertex buffer
@@ -1434,7 +1411,7 @@ export class ThinEngine {
         this._resetVertexBufferBinding();
     }
 
-    private _resetIndexBufferBinding(): void {
+    protected _resetIndexBufferBinding(): void {
         this.bindIndexBuffer(null);
         this._cachedIndexBuffer = null;
     }
@@ -1514,7 +1491,7 @@ export class ThinEngine {
         this._gl.uniformBlockBinding(program, uniformLocation, index);
     }
 
-    private bindIndexBuffer(buffer: Nullable<DataBuffer>): void {
+    protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void {
         if (!this._vaoRecordInProgress) {
             this._unbindVertexArrayObject();
         }
@@ -2762,7 +2739,7 @@ export class ThinEngine {
         var fromBlob = url.substr(0, 5) === "blob:";
         var isBase64 = fromData && url.indexOf(";base64,") !== -1;
 
-        let texture = fallback ? fallback : new InternalTexture(this, InternalTexture.DATASOURCE_URL);
+        let texture = fallback ? fallback : new InternalTexture(this, InternalTextureSource.Url);
 
         // establish the file extension, if possible
         var lastDot = url.lastIndexOf('.');
@@ -2900,7 +2877,7 @@ export class ThinEngine {
                         return false;
                     } else {
                         // Using shaders when possible to rescale because canvas.drawImage is lossy
-                        let source = new InternalTexture(this, InternalTexture.DATASOURCE_TEMP);
+                        let source = new InternalTexture(this, InternalTextureSource.Temp);
                         this._bindTextureDirectly(gl.TEXTURE_2D, source, true);
                         gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
 
@@ -3149,7 +3126,7 @@ export class ThinEngine {
      * @returns The texture
      */
     private _createDepthStencilTexture(size: number | { width: number, height: number }, options: DepthTextureCreationOptions): InternalTexture {
-        var internalTexture = new InternalTexture(this, InternalTexture.DATASOURCE_DEPTHTEXTURE);
+        var internalTexture = new InternalTexture(this, InternalTextureSource.Depth);
 
         if (!this._caps.depthTextureExtension) {
             Logger.Error("Depth texture is not supported by your browser or hardware.");
@@ -3190,74 +3167,6 @@ export class ThinEngine {
         return internalTexture;
     }
 
-    /**
-     * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
-     * @param renderTarget The render target to set the frame buffer for
-     */
-    public setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void {
-        // Create the framebuffer
-        var internalTexture = renderTarget.getInternalTexture();
-        if (!internalTexture || !internalTexture._framebuffer || !renderTarget.depthStencilTexture) {
-            return;
-        }
-
-        var gl = this._gl;
-        var depthStencilTexture = renderTarget.depthStencilTexture;
-
-        this._bindUnboundFramebuffer(internalTexture._framebuffer);
-        if (depthStencilTexture.isCube) {
-            if (depthStencilTexture._generateStencilBuffer) {
-                gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
-            }
-            else {
-                gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
-            }
-        }
-        else {
-            if (depthStencilTexture._generateStencilBuffer) {
-                gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
-            }
-            else {
-                gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
-            }
-        }
-        this._bindUnboundFramebuffer(null);
-    }
-
-    /** @hidden */
-    public _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples = 1): Nullable<WebGLRenderbuffer> {
-        var depthStencilBuffer: Nullable<WebGLRenderbuffer> = null;
-        var gl = this._gl;
-
-        // Create the depth/stencil buffer
-        if (generateStencilBuffer) {
-            depthStencilBuffer = gl.createRenderbuffer();
-            gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
-
-            if (samples > 1) {
-                gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH24_STENCIL8, width, height);
-            } else {
-                gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
-            }
-
-            gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
-        }
-        else if (generateDepthBuffer) {
-            depthStencilBuffer = gl.createRenderbuffer();
-            gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
-
-            if (samples > 1) {
-                gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH_COMPONENT16, width, height);
-            } else {
-                gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
-            }
-
-            gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
-        }
-
-        return depthStencilBuffer;
-    }
-
     /** @hidden */
     public _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex: number = 0, lod: number = 0) {
         var gl = this._gl;
@@ -3406,6 +3315,40 @@ export class ThinEngine {
     }
 
     /** @hidden */
+    public _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples = 1): Nullable<WebGLRenderbuffer> {
+        var depthStencilBuffer: Nullable<WebGLRenderbuffer> = null;
+        var gl = this._gl;
+
+        // Create the depth/stencil buffer
+        if (generateStencilBuffer) {
+            depthStencilBuffer = gl.createRenderbuffer();
+            gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
+
+            if (samples > 1) {
+                gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH24_STENCIL8, width, height);
+            } else {
+                gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
+            }
+
+            gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
+        }
+        else if (generateDepthBuffer) {
+            depthStencilBuffer = gl.createRenderbuffer();
+            gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
+
+            if (samples > 1) {
+                gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH_COMPONENT16, width, height);
+            } else {
+                gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
+            }
+
+            gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
+        }
+
+        return depthStencilBuffer;
+    }
+
+    /** @hidden */
     public _releaseFramebufferObjects(texture: InternalTexture): void {
         var gl = this._gl;
 

+ 2 - 2
src/Materials/Textures/MultiviewRenderTarget.ts

@@ -1,6 +1,6 @@
 import { RenderTargetTexture } from '../Textures/renderTargetTexture';
 import { Scene } from '../../scene';
-import { InternalTexture } from '../Textures/internalTexture';
+import { InternalTextureSource } from '../Textures/internalTexture';
 
 /**
  * Renders to multiple views with a single draw call
@@ -13,7 +13,7 @@ export class MultiviewRenderTarget extends RenderTargetTexture {
      * @param size the size of the render target (used for each view)
      */
     constructor(scene: Scene, size: number | { width: number, height: number } | { ratio: number } = 512) {
-        super("multiview rtt", size, scene, false, true, InternalTexture.DATASOURCE_UNKNOWN, false, undefined, false, false, true, undefined, true);
+        super("multiview rtt", size, scene, false, true, InternalTextureSource.Unknown, false, undefined, false, false, true, undefined, true);
         var internalTexture = scene.getEngine().createMultiviewRenderTargetTexture(this.getRenderWidth(), this.getRenderHeight());
         internalTexture.isMultiview = true;
         this._texture = internalTexture;

+ 48 - 43
src/Materials/Textures/internalTexture.ts

@@ -11,68 +11,73 @@ declare type ThinEngine = import("../../Engines/thinEngine").ThinEngine;
 declare type BaseTexture = import("../../Materials/Textures/baseTexture").BaseTexture;
 
 /**
- * Class used to store data associated with WebGL texture data for the engine
- * This class should not be used directly
+ * Defines the source of the internal texture
  */
-export class InternalTexture {
-
-    /** @hidden */
-    public static _UpdateRGBDAsync = (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void> => {
-        throw _DevTools.WarnImport("environmentTextureTools");
-    }
-
+export enum InternalTextureSource {
     /**
      * The source of the texture data is unknown
      */
-    public static DATASOURCE_UNKNOWN = 0;
+    Unknown,
     /**
-     * Texture data comes from an URL
-     */
-    public static DATASOURCE_URL = 1;
+    * Texture data comes from an URL
+    */
+    Url,
     /**
      * Texture data is only used for temporary storage
      */
-    public static DATASOURCE_TEMP = 2;
+    Temp,
     /**
      * Texture data comes from raw data (ArrayBuffer)
      */
-    public static DATASOURCE_RAW = 3;
+    Raw,
     /**
      * Texture content is dynamic (video or dynamic texture)
      */
-    public static DATASOURCE_DYNAMIC = 4;
+    Dynamic,
     /**
      * Texture content is generated by rendering to it
      */
-    public static DATASOURCE_RENDERTARGET = 5;
+    RenderTarget,
     /**
      * Texture content is part of a multi render target process
      */
-    public static DATASOURCE_MULTIRENDERTARGET = 6;
+    MultiRenderTarget,
     /**
      * Texture data comes from a cube data file
      */
-    public static DATASOURCE_CUBE = 7;
+    Cube,
     /**
      * Texture data comes from a raw cube data
      */
-    public static DATASOURCE_CUBERAW = 8;
+    CubeRaw,
     /**
      * Texture data come from a prefiltered cube data file
      */
-    public static DATASOURCE_CUBEPREFILTERED = 9;
+    CubePrefiltered,
     /**
      * Texture content is raw 3D data
      */
-    public static DATASOURCE_RAW3D = 10;
+    Raw3D,
     /**
      * Texture content is a depth texture
      */
-    public static DATASOURCE_DEPTHTEXTURE = 11;
+    Depth,
     /**
      * Texture data comes from a raw cube data encoded with RGBD
      */
-    public static DATASOURCE_CUBERAW_RGBD = 12;
+    CubeRawRGBD
+}
+
+/**
+ * Class used to store data associated with WebGL texture data for the engine
+ * This class should not be used directly
+ */
+export class InternalTexture {
+
+    /** @hidden */
+    public static _UpdateRGBDAsync = (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void> => {
+        throw _DevTools.WarnImport("environmentTextureTools");
+    }
 
     /**
      * Defines if the texture is ready
@@ -153,7 +158,7 @@ export class InternalTexture {
     /** @hidden */
     public _associatedChannel = -1;
     /** @hidden */
-    public _dataSource = InternalTexture.DATASOURCE_UNKNOWN;
+    public _source = InternalTextureSource.Unknown;
     /** @hidden */
     public _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob> = null;
     /** @hidden */
@@ -248,21 +253,21 @@ export class InternalTexture {
     }
 
     /**
-     * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
+     * Gets the data source type of the texture
      */
-    public get dataSource(): number {
-        return this._dataSource;
+    public get source(): InternalTextureSource {
+        return this._source;
     }
 
     /**
      * Creates a new InternalTexture
      * @param engine defines the engine to use
-     * @param dataSource defines the type of data that will be used
+     * @param source defines the type of data that will be used
      * @param delayAllocation if the texture allocation should be delayed (default: false)
      */
-    constructor(engine: ThinEngine, dataSource: number, delayAllocation = false) {
+    constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation = false) {
         this._engine = engine;
-        this._dataSource = dataSource;
+        this._source = source;
 
         if (!delayAllocation) {
             this._webGLTexture = engine._createTexture();
@@ -303,18 +308,18 @@ export class InternalTexture {
         this._cachedWrapV = null;
         this._cachedAnisotropicFilteringLevel = null;
 
-        switch (this._dataSource) {
-            case InternalTexture.DATASOURCE_TEMP:
+        switch (this.source) {
+            case InternalTextureSource.Temp:
                 return;
 
-            case InternalTexture.DATASOURCE_URL:
+            case InternalTextureSource.Url:
                 proxy = this._engine.createTexture(this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, () => {
                     proxy._swapAndDie(this);
                     this.isReady = true;
                 }, null, this._buffer, undefined, this.format);
                 return;
 
-            case InternalTexture.DATASOURCE_RAW:
+            case InternalTextureSource.Raw:
                 proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps,
                     this.invertY, this.samplingMode, this._compression);
                 proxy._swapAndDie(this);
@@ -322,7 +327,7 @@ export class InternalTexture {
                 this.isReady = true;
                 return;
 
-            case InternalTexture.DATASOURCE_RAW3D:
+            case InternalTextureSource.Raw3D:
                 proxy = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps,
                     this.invertY, this.samplingMode, this._compression);
                 proxy._swapAndDie(this);
@@ -330,7 +335,7 @@ export class InternalTexture {
                 this.isReady = true;
                 return;
 
-            case InternalTexture.DATASOURCE_DYNAMIC:
+            case InternalTextureSource.Dynamic:
                 proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);
                 proxy._swapAndDie(this);
                 this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas()!, this.invertY, undefined, undefined, true);
@@ -338,7 +343,7 @@ export class InternalTexture {
                 // The engine will make sure to update content so no need to flag it as isReady = true
                 return;
 
-            case InternalTexture.DATASOURCE_RENDERTARGET:
+            case InternalTextureSource.RenderTarget:
                 let options = new RenderTargetCreationOptions();
                 options.generateDepthBuffer = this._generateDepthBuffer;
                 options.generateMipMaps = this.generateMipMaps;
@@ -360,7 +365,7 @@ export class InternalTexture {
 
                 this.isReady = true;
                 return;
-            case InternalTexture.DATASOURCE_DEPTHTEXTURE:
+            case InternalTextureSource.Depth:
                 let depthTextureOptions = {
                     bilinearFiltering: this.samplingMode !== Constants.TEXTURE_BILINEAR_SAMPLINGMODE,
                     comparisonFunction: this._comparisonFunction,
@@ -374,20 +379,20 @@ export class InternalTexture {
                 this.isReady = true;
                 return;
 
-            case InternalTexture.DATASOURCE_CUBE:
+            case InternalTextureSource.Cube:
                 proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, () => {
                     proxy._swapAndDie(this);
                     this.isReady = true;
                 }, null, this.format, this._extension);
                 return;
 
-            case InternalTexture.DATASOURCE_CUBERAW:
+            case InternalTextureSource.CubeRaw:
                 proxy = this._engine.createRawCubeTexture(this._bufferViewArray!, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
                 proxy._swapAndDie(this);
                 this.isReady = true;
                 return;
 
-            case InternalTexture.DATASOURCE_CUBERAW_RGBD:
+            case InternalTextureSource.CubeRawRGBD:
                 proxy = this._engine.createRawCubeTexture(null, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
                 InternalTexture._UpdateRGBDAsync(proxy, this._bufferViewArrayArray!, this._sphericalPolynomial, this._lodGenerationScale, this._lodGenerationOffset).then(() => {
                     proxy._swapAndDie(this);
@@ -395,7 +400,7 @@ export class InternalTexture {
                 });
                 return;
 
-            case InternalTexture.DATASOURCE_CUBEPREFILTERED:
+            case InternalTextureSource.CubePrefiltered:
                 proxy = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, (proxy) => {
                     if (proxy) {
                         proxy._swapAndDie(this);

+ 3 - 3
src/Materials/Textures/rawCubeTexture.ts

@@ -3,7 +3,7 @@ import { EnvironmentTextureTools } from "../../Misc/environmentTextureTools";
 import { Nullable } from "../../types";
 import { Scene } from "../../scene";
 import { SphericalPolynomial } from "../../Maths/sphericalPolynomial";
-import { InternalTexture } from "./internalTexture";
+import { InternalTexture, InternalTextureSource } from "./internalTexture";
 import { CubeTexture } from "./cubeTexture";
 import { Constants } from "../../Engines/constants";
 import "../../Engines/Extensions/engine.rawTexture";
@@ -71,7 +71,7 @@ export class RawCubeTexture extends CubeTexture {
             const texture = new RawCubeTexture(scene, internalTexture._bufferViewArray!, internalTexture.width, internalTexture.format, internalTexture.type,
                 internalTexture.generateMipMaps, internalTexture.invertY, internalTexture.samplingMode, internalTexture._compression);
 
-            if (internalTexture.dataSource === InternalTexture.DATASOURCE_CUBERAW_RGBD) {
+            if (internalTexture.source === InternalTextureSource.CubeRawRGBD) {
                 texture.updateRGBDAsync(internalTexture._bufferViewArrayArray!, internalTexture._sphericalPolynomial, internalTexture._lodGenerationScale, internalTexture._lodGenerationOffset);
             }
 
@@ -81,7 +81,7 @@ export class RawCubeTexture extends CubeTexture {
 
     /** @hidden */
     public static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void> {
-        internalTexture._dataSource = InternalTexture.DATASOURCE_CUBERAW_RGBD;
+        internalTexture._source = InternalTextureSource.CubeRawRGBD;
         internalTexture._bufferViewArrayArray = data;
         internalTexture._lodGenerationScale = lodScale;
         internalTexture._lodGenerationOffset = lodOffset;

+ 2 - 2
src/Misc/basis.ts

@@ -1,7 +1,7 @@
 import { Nullable } from '../types';
 import { Tools } from './tools';
 import { Texture } from '../Materials/Textures/texture';
-import { InternalTexture } from '../Materials/Textures/internalTexture';
+import { InternalTexture, InternalTextureSource } from '../Materials/Textures/internalTexture';
 import { Scalar } from '../Maths/math.scalar';
 import { Constants } from '../Engines/constants';
 import { Engine } from '../Engines/engine';
@@ -192,7 +192,7 @@ export class BasisTools {
 
                 if (engine.webGLVersion < 2 && (Scalar.Log2(rootImage.width) % 1 !== 0 || Scalar.Log2(rootImage.height) % 1 !== 0)) {
                     // Create non power of two texture
-                    let source = new InternalTexture(engine, InternalTexture.DATASOURCE_TEMP);
+                    let source = new InternalTexture(engine, InternalTextureSource.Temp);
 
                     texture._invertVScale = texture.invertY;
                     source.type = Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5;

+ 3 - 3
src/Misc/dds.ts

@@ -1,7 +1,7 @@
 import { Scalar } from "../Maths/math.scalar";
 import { SphericalPolynomial } from "../Maths/sphericalPolynomial";
 import { Constants } from "../Engines/constants";
-import { InternalTexture } from "../Materials/Textures/internalTexture";
+import { InternalTexture, InternalTextureSource } from "../Materials/Textures/internalTexture";
 import { Nullable } from "../types";
 import { Logger } from "../Misc/logger";
 import { CubeMapToSphericalPolynomialTools } from "../Misc/HighDynamicRange/cubemapToSphericalPolynomial";
@@ -717,7 +717,7 @@ ThinEngine.prototype.createPrefilteredCubeTexture = function(rootUrl: string, sc
         else if (loadData.info.sphericalPolynomial) {
             texture._sphericalPolynomial = loadData.info.sphericalPolynomial;
         }
-        texture._dataSource = InternalTexture.DATASOURCE_CUBEPREFILTERED;
+        texture._source = InternalTextureSource.CubePrefiltered;
 
         if (this.getCaps().textureLOD) {
             // Do not add extra process if texture lod is supported.
@@ -747,7 +747,7 @@ ThinEngine.prototype.createPrefilteredCubeTexture = function(rootUrl: string, sc
             let lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
             let mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
 
-            var glTextureFromLod = new InternalTexture(this, InternalTexture.DATASOURCE_TEMP);
+            var glTextureFromLod = new InternalTexture(this, InternalTextureSource.Temp);
             glTextureFromLod.type = texture.type;
             glTextureFromLod.format = texture.format;
             glTextureFromLod.width = Math.pow(2, Math.max(Scalar.Log2(width) - mipmapIndex, 0));

+ 3 - 3
src/Misc/environmentTextureTools.ts

@@ -3,7 +3,7 @@ import { Tools } from "./tools";
 import { Vector3 } from "../Maths/math.vector";
 import { Scalar } from "../Maths/math.scalar";
 import { SphericalPolynomial } from "../Maths/sphericalPolynomial";
-import { InternalTexture } from "../Materials/Textures/internalTexture";
+import { InternalTexture, InternalTextureSource } from "../Materials/Textures/internalTexture";
 import { BaseTexture } from "../Materials/Textures/baseTexture";
 import { CubeTexture } from "../Materials/Textures/cubeTexture";
 import { Constants } from "../Engines/constants";
@@ -465,7 +465,7 @@ export class EnvironmentTextureTools {
                     let lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
                     let mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
 
-                    let glTextureFromLod = new InternalTexture(engine, InternalTexture.DATASOURCE_TEMP);
+                    let glTextureFromLod = new InternalTexture(engine, InternalTextureSource.Temp);
                     glTextureFromLod.isCube = true;
                     glTextureFromLod.invertY = true;
                     glTextureFromLod.generateMipMaps = false;
@@ -634,7 +634,7 @@ export class EnvironmentTextureTools {
 
     /** @hidden */
     public static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void> {
-        internalTexture._dataSource = InternalTexture.DATASOURCE_CUBERAW_RGBD;
+        internalTexture._source = InternalTextureSource.CubeRawRGBD;
         internalTexture._bufferViewArrayArray = data;
         internalTexture._lodGenerationScale = lodScale;
         internalTexture._lodGenerationOffset = lodOffset;