|
@@ -387,82 +387,6 @@ var BABYLON;
|
|
|
this._activeTexturesCache = new Array(this._maxTextureChannels);
|
|
|
this._compiledEffects = {};
|
|
|
this._uintIndicesCurrentlySet = false;
|
|
|
- this.createRawCubeTexture = function (url, scene, size, format, type, noMipmap, callback) {
|
|
|
- var _this = this;
|
|
|
- var gl = this._gl;
|
|
|
- var texture = gl.createTexture();
|
|
|
- scene._addPendingData(texture);
|
|
|
- texture.isCube = true;
|
|
|
- texture.references = 1;
|
|
|
- texture.url = url;
|
|
|
- var internalFormat = gl.RGBA;
|
|
|
- switch (format) {
|
|
|
- case Engine.TEXTUREFORMAT_ALPHA:
|
|
|
- internalFormat = gl.ALPHA;
|
|
|
- break;
|
|
|
- case Engine.TEXTUREFORMAT_LUMINANCE:
|
|
|
- internalFormat = gl.LUMINANCE;
|
|
|
- break;
|
|
|
- case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
|
|
|
- internalFormat = gl.LUMINANCE_ALPHA;
|
|
|
- break;
|
|
|
- case Engine.TEXTUREFORMAT_RGB:
|
|
|
- internalFormat = gl.RGB;
|
|
|
- break;
|
|
|
- case Engine.TEXTUREFORMAT_RGBA:
|
|
|
- internalFormat = gl.RGBA;
|
|
|
- break;
|
|
|
- }
|
|
|
- var textureType = gl.UNSIGNED_BYTE;
|
|
|
- if (type === Engine.TEXTURETYPE_FLOAT) {
|
|
|
- textureType = gl.FLOAT;
|
|
|
- }
|
|
|
- var width = size;
|
|
|
- var height = width;
|
|
|
- var isPot = (BABYLON.Tools.IsExponentOfTwo(width) && BABYLON.Tools.IsExponentOfTwo(height));
|
|
|
- texture._width = width;
|
|
|
- texture._height = height;
|
|
|
- var onerror = function () {
|
|
|
- scene._removePendingData(texture);
|
|
|
- };
|
|
|
- var internalCallback = function (data) {
|
|
|
- var rgbeDataArrays = callback(data);
|
|
|
- var facesIndex = [
|
|
|
- gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
|
|
|
- gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
|
|
|
- ];
|
|
|
- gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture);
|
|
|
- gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 0);
|
|
|
- for (var index = 0; index < facesIndex.length; index++) {
|
|
|
- var faceData = rgbeDataArrays[index];
|
|
|
- gl.texImage2D(facesIndex[index], 0, internalFormat, width, height, 0, internalFormat, textureType, faceData);
|
|
|
- }
|
|
|
- if (!noMipmap && isPot) {
|
|
|
- gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
|
|
|
- }
|
|
|
- else {
|
|
|
- noMipmap = true;
|
|
|
- }
|
|
|
- if (textureType == gl.FLOAT && !_this._caps.textureFloatLinearFiltering) {
|
|
|
- gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
|
|
- gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
|
|
- }
|
|
|
- else {
|
|
|
- gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
|
- gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, noMipmap ? gl.LINEAR : gl.LINEAR_MIPMAP_LINEAR);
|
|
|
- }
|
|
|
- gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
|
- gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
|
- gl.bindTexture(gl.TEXTURE_CUBE_MAP, null);
|
|
|
- texture.isReady = true;
|
|
|
- _this.resetTextureCache();
|
|
|
- scene._removePendingData(texture);
|
|
|
- };
|
|
|
- BABYLON.Tools.LoadFile(url, function (data) {
|
|
|
- internalCallback(data);
|
|
|
- }, onerror, scene.database, true);
|
|
|
- return texture;
|
|
|
- };
|
|
|
this._renderingCanvas = canvas;
|
|
|
options = options || {};
|
|
|
options.antialias = antialias;
|