|
@@ -386,6 +386,7 @@
|
|
|
public uintIndices: boolean;
|
|
|
public highPrecisionShaderSupported: boolean;
|
|
|
public fragmentDepthSupported: boolean;
|
|
|
+ public textureFloatLinearFiltering: boolean;
|
|
|
public drawBuffersExtension;
|
|
|
}
|
|
|
|
|
@@ -657,6 +658,7 @@
|
|
|
this._caps.fragmentDepthSupported = this._gl.getExtension('EXT_frag_depth') !== null;
|
|
|
this._caps.highPrecisionShaderSupported = true;
|
|
|
this._caps.drawBuffersExtension = this._gl.getExtension('WEBGL_draw_buffers');
|
|
|
+ this._caps.textureFloatLinearFiltering = this._gl.getExtension('OES_texture_float_linear');
|
|
|
|
|
|
if (this._gl.getShaderPrecisionFormat) {
|
|
|
var highp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
|
|
@@ -683,9 +685,9 @@
|
|
|
// Pointer lock
|
|
|
if (this.isFullscreen && this._pointerLockRequested) {
|
|
|
canvas.requestPointerLock = canvas.requestPointerLock ||
|
|
|
- canvas.msRequestPointerLock ||
|
|
|
- canvas.mozRequestPointerLock ||
|
|
|
- canvas.webkitRequestPointerLock;
|
|
|
+ canvas.msRequestPointerLock ||
|
|
|
+ canvas.mozRequestPointerLock ||
|
|
|
+ canvas.webkitRequestPointerLock;
|
|
|
|
|
|
if (canvas.requestPointerLock) {
|
|
|
canvas.requestPointerLock();
|
|
@@ -1751,7 +1753,7 @@
|
|
|
return texture;
|
|
|
}
|
|
|
|
|
|
- public updateRawTexture(texture: WebGLTexture, data: ArrayBufferView, format: number, invertY: boolean, compression: string = null): void {
|
|
|
+ private _getInternalFormat(format: number): number {
|
|
|
var internalFormat = this._gl.RGBA;
|
|
|
switch (format) {
|
|
|
case Engine.TEXTUREFORMAT_ALPHA:
|
|
@@ -1770,6 +1772,12 @@
|
|
|
internalFormat = this._gl.RGBA;
|
|
|
break;
|
|
|
}
|
|
|
+
|
|
|
+ return internalFormat;
|
|
|
+ }
|
|
|
+
|
|
|
+ public updateRawTexture(texture: WebGLTexture, data: ArrayBufferView, format: number, invertY: boolean, compression: string = null): void {
|
|
|
+ var internalFormat = this._getInternalFormat(format);
|
|
|
this._gl.bindTexture(this._gl.TEXTURE_2D, texture);
|
|
|
this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, invertY === undefined ? 1 : (invertY ? 1 : 0));
|
|
|
|
|
@@ -2149,6 +2157,81 @@
|
|
|
return texture;
|
|
|
}
|
|
|
|
|
|
+ public createRawCubeTexture(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer) => ArrayBufferView[]): WebGLTexture {
|
|
|
+ var gl = this._gl;
|
|
|
+ var texture = gl.createTexture();
|
|
|
+ scene._addPendingData(texture);
|
|
|
+ texture.isCube = true;
|
|
|
+ texture.references = 1;
|
|
|
+ texture.url = url;
|
|
|
+
|
|
|
+ var internalFormat = this._getInternalFormat(format);
|
|
|
+
|
|
|
+ var textureType = gl.UNSIGNED_BYTE;
|
|
|
+ if (type === Engine.TEXTURETYPE_FLOAT) {
|
|
|
+ textureType = gl.FLOAT;
|
|
|
+ }
|
|
|
+
|
|
|
+ var width = size;
|
|
|
+ var height = width;
|
|
|
+ var isPot = (Tools.IsExponentOfTwo(width) && Tools.IsExponentOfTwo(height));
|
|
|
+
|
|
|
+ texture._width = width;
|
|
|
+ texture._height = height;
|
|
|
+
|
|
|
+ var onerror = () => {
|
|
|
+ scene._removePendingData(texture);
|
|
|
+ };
|
|
|
+
|
|
|
+ var internalCallback = (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);
|
|
|
+ };
|
|
|
+
|
|
|
+ Tools.LoadFile(url, data => {
|
|
|
+ internalCallback(data);
|
|
|
+ }, onerror, scene.database, true);
|
|
|
+
|
|
|
+ return texture;
|
|
|
+ };
|
|
|
+
|
|
|
public _releaseTexture(texture: WebGLTexture): void {
|
|
|
var gl = this._gl;
|
|
|
|
|
@@ -2448,3 +2531,4 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|