@@ -7557,6 +7557,15 @@ class Texture extends EventDispatcher {
75577557 */
75587558 this.pmremVersion = 0;
75597559
7560+ /**
7561+ * Whether the texture should use one of the 16 bit integer formats which are normalized
7562+ * to [0, 1] or [-1, 1] (depending on signed/unsigned) when sampled.
7563+ *
7564+ * @type {boolean}
7565+ * @default false
7566+ */
7567+ this.normalized = false;
7568+
75607569 }
75617570
75627571 /**
@@ -7672,6 +7681,7 @@ class Texture extends EventDispatcher {
76727681 this.format = source.format;
76737682 this.internalFormat = source.internalFormat;
76747683 this.type = source.type;
7684+ this.normalized = source.normalized;
76757685
76767686 this.offset.copy( source.offset );
76777687 this.repeat.copy( source.repeat );
@@ -7790,6 +7800,7 @@ class Texture extends EventDispatcher {
77907800 format: this.format,
77917801 internalFormat: this.internalFormat,
77927802 type: this.type,
7803+ normalized: this.normalized,
77937804 colorSpace: this.colorSpace,
77947805
77957806 minFilter: this.minFilter,
@@ -16653,7 +16664,7 @@ let _id$3 = 0;
1665316664 * When working with vector-like data, the `fromBufferAttribute( attribute, index )`
1665416665 * helper methods on vector and color class might be helpful. E.g. {@link Vector3#fromBufferAttribute}.
1665516666 */
16656- class BufferAttribute {
16667+ class BufferAttribute extends EventDispatcher {
1665716668
1665816669 /**
1665916670 * Constructs a new buffer attribute.
@@ -16664,6 +16675,8 @@ class BufferAttribute {
1666416675 */
1666516676 constructor( array, itemSize, normalized = false ) {
1666616677
16678+ super();
16679+
1666716680 if ( Array.isArray( array ) ) {
1666816681
1666916682 throw new TypeError( 'THREE.BufferAttribute: array should be a Typed Array.' );
@@ -17310,6 +17323,15 @@ class BufferAttribute {
1731017323
1731117324 }
1731217325
17326+ /**
17327+ * Disposes of the buffer attribute. Available only in {@link WebGPURenderer}.
17328+ */
17329+ dispose() {
17330+
17331+ this.dispatchEvent( { type: 'dispose' } );
17332+
17333+ }
17334+
1731317335}
1731417336
1731517337/**
@@ -24694,7 +24716,7 @@ class InstancedMesh extends Mesh {
2469424716
2469524717 /**
2469624718 * Sets the given local transformation matrix to the defined instance. Make sure you set the `needsUpdate` flag of
24697- * {@link InstancedMesh#instanceMatrix} to `true` after updating all the colors .
24719+ * {@link InstancedMesh#instanceMatrix} to `true` after updating all the matrices .
2469824720 *
2469924721 * @param {number} index - The instance index.
2470024722 * @param {Matrix4} matrix - The local transformation.
@@ -48804,6 +48826,7 @@ class ObjectLoader extends Loader {
4880448826 if ( data.premultiplyAlpha !== undefined ) texture.premultiplyAlpha = data.premultiplyAlpha;
4880548827 if ( data.unpackAlignment !== undefined ) texture.unpackAlignment = data.unpackAlignment;
4880648828 if ( data.compareFunction !== undefined ) texture.compareFunction = data.compareFunction;
48829+ if ( data.normalized !== undefined ) texture.normalized = data.normalized;
4880748830
4880848831 if ( data.userData !== undefined ) texture.userData = data.userData;
4880948832
@@ -55842,7 +55865,7 @@ class Clock {
5584255865 */
5584355866 this.running = false;
5584455867
55845- warn( 'THREE. Clock: This module has been deprecated. Please use THREE.Timer instead.' ); // @deprecated, r183
55868+ warn( 'Clock: This module has been deprecated. Please use THREE.Timer instead.' ); // @deprecated, r183
5584655869
5584755870 }
5584855871
@@ -70668,7 +70691,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
7066870691
7066970692 }
7067070693
70671- function getInternalFormat( internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false ) {
70694+ function getInternalFormat( internalFormatName, glFormat, glType, normalized, colorSpace, forceLinearTransfer = false ) {
7067270695
7067370696 if ( internalFormatName !== null ) {
7067470697
@@ -70678,13 +70701,29 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
7067870701
7067970702 }
7068070703
70704+ let ext_texture_norm16;
70705+
70706+ if ( normalized ) {
70707+
70708+ ext_texture_norm16 = extensions.get( 'EXT_texture_norm16' );
70709+
70710+ if ( ! ext_texture_norm16 ) {
70711+
70712+ warn( 'WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension' );
70713+
70714+ }
70715+
70716+ }
70717+
7068170718 let internalFormat = glFormat;
7068270719
7068370720 if ( glFormat === _gl.RED ) {
7068470721
7068570722 if ( glType === _gl.FLOAT ) internalFormat = _gl.R32F;
7068670723 if ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.R16F;
7068770724 if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.R8;
70725+ if ( glType === _gl.UNSIGNED_SHORT && ext_texture_norm16 ) internalFormat = ext_texture_norm16.R16_EXT;
70726+ if ( glType === _gl.SHORT && ext_texture_norm16 ) internalFormat = ext_texture_norm16.R16_SNORM_EXT;
7068870727
7068970728 }
7069070729
@@ -70704,6 +70743,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
7070470743 if ( glType === _gl.FLOAT ) internalFormat = _gl.RG32F;
7070570744 if ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RG16F;
7070670745 if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RG8;
70746+ if ( glType === _gl.UNSIGNED_SHORT && ext_texture_norm16 ) internalFormat = ext_texture_norm16.RG16_EXT;
70747+ if ( glType === _gl.SHORT && ext_texture_norm16 ) internalFormat = ext_texture_norm16.RG16_SNORM_EXT;
7070770748
7070870749 }
7070970750
@@ -70742,6 +70783,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
7074270783
7074370784 if ( glFormat === _gl.RGB ) {
7074470785
70786+ if ( glType === _gl.UNSIGNED_SHORT && ext_texture_norm16 ) internalFormat = ext_texture_norm16.RGB16_EXT;
70787+ if ( glType === _gl.SHORT && ext_texture_norm16 ) internalFormat = ext_texture_norm16.RGB16_SNORM_EXT;
7074570788 if ( glType === _gl.UNSIGNED_INT_5_9_9_9_REV ) internalFormat = _gl.RGB9_E5;
7074670789 if ( glType === _gl.UNSIGNED_INT_10F_11F_11F_REV ) internalFormat = _gl.R11F_G11F_B10F;
7074770790
@@ -70754,6 +70797,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
7075470797 if ( glType === _gl.FLOAT ) internalFormat = _gl.RGBA32F;
7075570798 if ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RGBA16F;
7075670799 if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = ( transfer === SRGBTransfer ) ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
70800+ if ( glType === _gl.UNSIGNED_SHORT && ext_texture_norm16 ) internalFormat = ext_texture_norm16.RGBA16_EXT;
70801+ if ( glType === _gl.SHORT && ext_texture_norm16 ) internalFormat = ext_texture_norm16.RGBA16_SNORM_EXT;
7075770802 if ( glType === _gl.UNSIGNED_SHORT_4_4_4_4 ) internalFormat = _gl.RGBA4;
7075870803 if ( glType === _gl.UNSIGNED_SHORT_5_5_5_1 ) internalFormat = _gl.RGB5_A1;
7075970804
@@ -71451,7 +71496,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
7145171496 const glFormat = utils.convert( texture.format, texture.colorSpace );
7145271497
7145371498 const glType = utils.convert( texture.type );
71454- let glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace, texture.isVideoTexture );
71499+ let glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.normalized, texture. colorSpace, texture.isVideoTexture );
7145571500
7145671501 setTextureParameters( textureType, texture );
7145771502
@@ -71900,7 +71945,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
7190071945 const image = cubeImage[ 0 ],
7190171946 glFormat = utils.convert( texture.format, texture.colorSpace ),
7190271947 glType = utils.convert( texture.type ),
71903- glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
71948+ glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.normalized, texture. colorSpace );
7190471949
7190571950 const useTexStorage = ( texture.isVideoTexture !== true );
7190671951 const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
@@ -72096,7 +72141,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
7209672141
7209772142 const glFormat = utils.convert( texture.format, texture.colorSpace );
7209872143 const glType = utils.convert( texture.type );
72099- const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
72144+ const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.normalized, texture. colorSpace );
7210072145 const renderTargetProperties = properties.get( renderTarget );
7210172146 const textureProperties = properties.get( texture );
7210272147
@@ -72175,7 +72220,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
7217572220
7217672221 const glFormat = utils.convert( texture.format, texture.colorSpace );
7217772222 const glType = utils.convert( texture.type );
72178- const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
72223+ const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.normalized, texture. colorSpace );
7217972224
7218072225 if ( useMultisampledRTT( renderTarget ) ) {
7218172226
@@ -72565,7 +72610,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
7256572610
7256672611 const glFormat = utils.convert( texture.format, texture.colorSpace );
7256772612 const glType = utils.convert( texture.type );
72568- const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace, renderTarget.isXRRenderTarget === true );
72613+ const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.normalized, texture. colorSpace, renderTarget.isXRRenderTarget === true );
7256972614 const samples = getRenderTargetSamples( renderTarget );
7257072615 _gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
7257172616
0 commit comments