|
@@ -23793,6 +23793,72 @@ function WebGLState( gl ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+function contain( texture, aspect ) {
|
|
|
+
|
|
|
+ const imageAspect = ( texture.image && texture.image.width ) ? texture.image.width / texture.image.height : 1;
|
|
|
+
|
|
|
+ if ( imageAspect > aspect ) {
|
|
|
+
|
|
|
+ texture.repeat.x = 1;
|
|
|
+ texture.repeat.y = imageAspect / aspect;
|
|
|
+
|
|
|
+ texture.offset.x = 0;
|
|
|
+ texture.offset.y = ( 1 - texture.repeat.y ) / 2;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ texture.repeat.x = aspect / imageAspect;
|
|
|
+ texture.repeat.y = 1;
|
|
|
+
|
|
|
+ texture.offset.x = ( 1 - texture.repeat.x ) / 2;
|
|
|
+ texture.offset.y = 0;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return texture;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+function cover( texture, aspect ) {
|
|
|
+
|
|
|
+ const imageAspect = ( texture.image && texture.image.width ) ? texture.image.width / texture.image.height : 1;
|
|
|
+
|
|
|
+ if ( imageAspect > aspect ) {
|
|
|
+
|
|
|
+ texture.repeat.x = aspect / imageAspect;
|
|
|
+ texture.repeat.y = 1;
|
|
|
+
|
|
|
+ texture.offset.x = ( 1 - texture.repeat.x ) / 2;
|
|
|
+ texture.offset.y = 0;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ texture.repeat.x = 1;
|
|
|
+ texture.repeat.y = imageAspect / aspect;
|
|
|
+
|
|
|
+ texture.offset.x = 0;
|
|
|
+ texture.offset.y = ( 1 - texture.repeat.y ) / 2;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return texture;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+function fill( texture ) {
|
|
|
+
|
|
|
+ texture.repeat.x = 1;
|
|
|
+ texture.repeat.y = 1;
|
|
|
+
|
|
|
+ texture.offset.x = 0;
|
|
|
+ texture.offset.y = 0;
|
|
|
+
|
|
|
+ return texture;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* Given the width, height, format, and type of a texture. Determines how many
|
|
|
* bytes must be used to represent the texture.
|
|
@@ -23928,7 +23994,10 @@ function getTextureTypeByteLength( type ) {
|
|
|
}
|
|
|
|
|
|
const TextureUtils = {
|
|
|
- getByteLength,
|
|
|
+ contain,
|
|
|
+ cover,
|
|
|
+ fill,
|
|
|
+ getByteLength
|
|
|
};
|
|
|
|
|
|
function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {
|
|
@@ -24782,7 +24851,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
if ( texture.layerUpdates.size > 0 ) {
|
|
|
|
|
|
- const layerByteLength = TextureUtils.getByteLength( mipmap.width, mipmap.height, texture.format, texture.type );
|
|
|
+ const layerByteLength = getByteLength( mipmap.width, mipmap.height, texture.format, texture.type );
|
|
|
|
|
|
for ( const layerIndex of texture.layerUpdates ) {
|
|
|
|
|
@@ -24908,7 +24977,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
if ( texture.layerUpdates.size > 0 ) {
|
|
|
|
|
|
- const layerByteLength = TextureUtils.getByteLength( image.width, image.height, texture.format, texture.type );
|
|
|
+ const layerByteLength = getByteLength( image.width, image.height, texture.format, texture.type );
|
|
|
|
|
|
for ( const layerIndex of texture.layerUpdates ) {
|
|
|
|