|
@@ -289,6 +289,13 @@ class EventDispatcher {
|
|
|
|
|
|
}
|
|
|
|
|
|
+let _seed = 1234567;
|
|
|
+
|
|
|
+const DEG2RAD = Math.PI / 180;
|
|
|
+const RAD2DEG = 180 / Math.PI;
|
|
|
+
|
|
|
+//
|
|
|
+
|
|
|
const _lut = [];
|
|
|
|
|
|
for ( let i = 0; i < 256; i ++ ) {
|
|
@@ -297,14 +304,18 @@ for ( let i = 0; i < 256; i ++ ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
-let _seed = 1234567;
|
|
|
+const hasRandomUUID = typeof crypto !== 'undefined' && 'randomUUID' in crypto;
|
|
|
|
|
|
+function generateUUID() {
|
|
|
|
|
|
-const DEG2RAD = Math.PI / 180;
|
|
|
-const RAD2DEG = 180 / Math.PI;
|
|
|
+ if ( hasRandomUUID ) {
|
|
|
|
|
|
-// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
|
|
|
-function generateUUID() {
|
|
|
+ return crypto.randomUUID().toUpperCase();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // TODO Remove this code when crypto.randomUUID() is available everywhere
|
|
|
+ // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
|
|
|
|
|
|
const d0 = Math.random() * 0xffffffff | 0;
|
|
|
const d1 = Math.random() * 0xffffffff | 0;
|
|
@@ -348,11 +359,11 @@ function inverseLerp( x, y, value ) {
|
|
|
|
|
|
return ( value - x ) / ( y - x );
|
|
|
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -11839,7 +11850,6 @@ class CubeTexture extends Texture {
|
|
|
|
|
|
images = images !== undefined ? images : [];
|
|
|
mapping = mapping !== undefined ? mapping : CubeReflectionMapping;
|
|
|
- format = format !== undefined ? format : RGBFormat;
|
|
|
|
|
|
super( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );
|
|
|
|
|
@@ -15335,6 +15345,20 @@ class PMREMGenerator {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ _setEncoding( uniform, texture ) {
|
|
|
+
|
|
|
+ if ( this._renderer.capabilities.isWebGL2 === true && texture.format === RGBAFormat && texture.type === UnsignedByteType && texture.encoding === sRGBEncoding ) {
|
|
|
+
|
|
|
+ uniform.value = ENCODINGS[ LinearEncoding ];
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ uniform.value = ENCODINGS[ texture.encoding ];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
_textureToCubeUV( texture, cubeUVRenderTarget ) {
|
|
|
|
|
|
const renderer = this._renderer;
|
|
@@ -15370,8 +15394,8 @@ class PMREMGenerator {
|
|
|
|
|
|
}
|
|
|
|
|
|
- uniforms[ 'inputEncoding' ].value = ENCODINGS[ texture.encoding ];
|
|
|
- uniforms[ 'outputEncoding' ].value = ENCODINGS[ cubeUVRenderTarget.texture.encoding ];
|
|
|
+ this._setEncoding( uniforms[ 'inputEncoding' ], texture );
|
|
|
+ this._setEncoding( uniforms[ 'outputEncoding' ], cubeUVRenderTarget.texture );
|
|
|
|
|
|
_setViewport( cubeUVRenderTarget, 0, 0, 3 * SIZE_MAX, 2 * SIZE_MAX );
|
|
|
|
|
@@ -15502,8 +15526,9 @@ class PMREMGenerator {
|
|
|
|
|
|
blurUniforms[ 'dTheta' ].value = radiansPerPixel;
|
|
|
blurUniforms[ 'mipInt' ].value = LOD_MAX - lodIn;
|
|
|
- blurUniforms[ 'inputEncoding' ].value = ENCODINGS[ targetIn.texture.encoding ];
|
|
|
- blurUniforms[ 'outputEncoding' ].value = ENCODINGS[ targetIn.texture.encoding ];
|
|
|
+
|
|
|
+ this._setEncoding( blurUniforms[ 'inputEncoding' ], targetIn.texture );
|
|
|
+ this._setEncoding( blurUniforms[ 'outputEncoding' ], targetIn.texture );
|
|
|
|
|
|
const outputSize = _sizeLods[ lodOut ];
|
|
|
const x = 3 * Math.max( 0, SIZE_MAX - 2 * outputSize );
|
|
@@ -16164,6 +16189,7 @@ function WebGLExtensions( gl ) {
|
|
|
|
|
|
getExtension( 'OES_texture_float_linear' );
|
|
|
getExtension( 'EXT_color_buffer_half_float' );
|
|
|
+ getExtension( 'EXT_multisampled_render_to_texture' );
|
|
|
|
|
|
},
|
|
|
|
|
@@ -18886,6 +18912,12 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
|
|
|
}
|
|
|
|
|
|
+ if ( isWebGL2 && map && map.isTexture && map.format === RGBAFormat && map.type === UnsignedByteType && map.encoding === sRGBEncoding ) {
|
|
|
+
|
|
|
+ encoding = LinearEncoding; // disable inline decode for sRGB textures in WebGL 2
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
return encoding;
|
|
|
|
|
|
}
|
|
@@ -21826,7 +21858,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
}
|
|
|
|
|
|
- function getInternalFormat( internalFormatName, glFormat, glType ) {
|
|
|
+ function getInternalFormat( internalFormatName, glFormat, glType, encoding ) {
|
|
|
|
|
|
if ( isWebGL2 === false ) return glFormat;
|
|
|
|
|
@@ -21860,7 +21892,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
if ( glType === 5126 ) internalFormat = 34836;
|
|
|
if ( glType === 5131 ) internalFormat = 34842;
|
|
|
- if ( glType === 5121 ) internalFormat = 32856;
|
|
|
+ if ( glType === 5121 ) internalFormat = ( encoding === sRGBEncoding ) ? 35907 : 32856;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -22226,7 +22258,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
glFormat = utils.convert( texture.format );
|
|
|
|
|
|
let glType = utils.convert( texture.type ),
|
|
|
- glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType );
|
|
|
+ glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding );
|
|
|
|
|
|
setTextureParameters( textureType, texture, supportsMips );
|
|
|
|
|
@@ -22452,7 +22484,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
supportsMips = isPowerOfTwo$1( image ) || isWebGL2,
|
|
|
glFormat = utils.convert( texture.format ),
|
|
|
glType = utils.convert( texture.type ),
|
|
|
- glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType );
|
|
|
+ glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding );
|
|
|
|
|
|
setTextureParameters( 34067, texture, supportsMips );
|
|
|
|
|
@@ -22551,7 +22583,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
const glFormat = utils.convert( texture.format );
|
|
|
const glType = utils.convert( texture.type );
|
|
|
- const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType );
|
|
|
+ const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding );
|
|
|
|
|
|
if ( textureTarget === 32879 || textureTarget === 35866 ) {
|
|
|
|
|
@@ -22632,7 +22664,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
const glFormat = utils.convert( texture.format );
|
|
|
const glType = utils.convert( texture.type );
|
|
|
- const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType );
|
|
|
+ const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding );
|
|
|
|
|
|
if ( isMultisample ) {
|
|
|
|
|
@@ -22825,7 +22857,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
const glFormat = utils.convert( texture.format );
|
|
|
const glType = utils.convert( texture.type );
|
|
|
- const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType );
|
|
|
+ const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding );
|
|
|
const samples = getRenderTargetSamples( renderTarget );
|
|
|
_gl.renderbufferStorageMultisample( 36161, samples, glInternalFormat, renderTarget.width, renderTarget.height );
|
|
|
|
|
@@ -23626,6 +23658,8 @@ class WebXRManager extends EventDispatcher {
|
|
|
let xrFrame = null;
|
|
|
let depthStyle = null;
|
|
|
let clearStyle = null;
|
|
|
+ const msaartcSupported = renderer.extensions.has( 'EXT_multisampled_render_to_texture' );
|
|
|
+ let msaaExt = null;
|
|
|
|
|
|
const controllers = [];
|
|
|
const inputSourcesMap = new Map();
|
|
@@ -23895,7 +23929,11 @@ class WebXRManager extends EventDispatcher {
|
|
|
|
|
|
session.updateRenderState( { layers: [ glProjLayer ] } );
|
|
|
|
|
|
- if ( isMultisample ) {
|
|
|
+ if ( isMultisample && msaartcSupported ) {
|
|
|
+
|
|
|
+ msaaExt = renderer.extensions.get( 'EXT_multisampled_render_to_texture' );
|
|
|
+
|
|
|
+ } else if ( isMultisample ) {
|
|
|
|
|
|
glMultisampledFramebuffer = gl.createFramebuffer();
|
|
|
glColorRenderbuffer = gl.createRenderbuffer();
|
|
@@ -24216,13 +24254,27 @@ class WebXRManager extends EventDispatcher {
|
|
|
|
|
|
state.bindXRFramebuffer( glFramebuffer );
|
|
|
|
|
|
- if ( glSubImage.depthStencilTexture !== undefined ) {
|
|
|
+ if ( isMultisample && msaartcSupported ) {
|
|
|
|
|
|
- gl.framebufferTexture2D( 36160, depthStyle, 3553, glSubImage.depthStencilTexture, 0 );
|
|
|
+ if ( glSubImage.depthStencilTexture !== undefined ) {
|
|
|
|
|
|
- }
|
|
|
+ msaaExt.framebufferTexture2DMultisampleEXT( 36160, depthStyle, 3553, glSubImage.depthStencilTexture, 0, 4 );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- gl.framebufferTexture2D( 36160, 36064, 3553, glSubImage.colorTexture, 0 );
|
|
|
+ msaaExt.framebufferTexture2DMultisampleEXT( 36160, 36064, 3553, glSubImage.colorTexture, 0, 4 );
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if ( glSubImage.depthStencilTexture !== undefined ) {
|
|
|
+
|
|
|
+ gl.framebufferTexture2D( 36160, depthStyle, 3553, glSubImage.depthStencilTexture, 0 );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ gl.framebufferTexture2D( 36160, 36064, 3553, glSubImage.colorTexture, 0 );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
viewport = glSubImage.viewport;
|
|
|
|
|
@@ -24248,7 +24300,7 @@ class WebXRManager extends EventDispatcher {
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( isMultisample ) {
|
|
|
+ if ( isMultisample && ! msaartcSupported ) {
|
|
|
|
|
|
state.bindXRFramebuffer( glMultisampledFramebuffer );
|
|
|
|
|
@@ -24273,7 +24325,7 @@ class WebXRManager extends EventDispatcher {
|
|
|
|
|
|
if ( onAnimationFrameCallback ) onAnimationFrameCallback( time, frame );
|
|
|
|
|
|
- if ( isMultisample ) {
|
|
|
+ if ( isMultisample && ! msaartcSupported ) {
|
|
|
|
|
|
const width = glProjLayer.textureWidth;
|
|
|
const height = glProjLayer.textureHeight;
|
|
@@ -39408,11 +39460,6 @@ class TextureLoader extends Loader {
|
|
|
loader.load( url, function ( image ) {
|
|
|
|
|
|
texture.image = image;
|
|
|
-
|
|
|
- // JPEGs can't have an alpha channel, so memory can be saved by storing them as RGB.
|
|
|
- const isJPEG = url.search( /\.jpe?g($|\?)/i ) > 0 || url.search( /^data\:image\/jpeg/ ) === 0;
|
|
|
-
|
|
|
- texture.format = isJPEG ? RGBFormat : RGBAFormat;
|
|
|
texture.needsUpdate = true;
|
|
|
|
|
|
if ( onLoad !== undefined ) {
|