Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 54 additions & 9 deletions build/three.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7557,6 +7557,15 @@ class Texture extends EventDispatcher {
*/
this.pmremVersion = 0;

/**
* Whether the texture should use one of the 16 bit integer formats which are normalized
* to [0, 1] or [-1, 1] (depending on signed/unsigned) when sampled.
*
* @type {boolean}
* @default false
*/
this.normalized = false;

}

/**
Expand Down Expand Up @@ -7672,6 +7681,7 @@ class Texture extends EventDispatcher {
this.format = source.format;
this.internalFormat = source.internalFormat;
this.type = source.type;
this.normalized = source.normalized;

this.offset.copy( source.offset );
this.repeat.copy( source.repeat );
Expand Down Expand Up @@ -7790,6 +7800,7 @@ class Texture extends EventDispatcher {
format: this.format,
internalFormat: this.internalFormat,
type: this.type,
normalized: this.normalized,
colorSpace: this.colorSpace,

minFilter: this.minFilter,
Expand Down Expand Up @@ -16653,7 +16664,7 @@ let _id$3 = 0;
* When working with vector-like data, the `fromBufferAttribute( attribute, index )`
* helper methods on vector and color class might be helpful. E.g. {@link Vector3#fromBufferAttribute}.
*/
class BufferAttribute {
class BufferAttribute extends EventDispatcher {

/**
* Constructs a new buffer attribute.
Expand All @@ -16664,6 +16675,8 @@ class BufferAttribute {
*/
constructor( array, itemSize, normalized = false ) {

super();

if ( Array.isArray( array ) ) {

throw new TypeError( 'THREE.BufferAttribute: array should be a Typed Array.' );
Expand Down Expand Up @@ -17310,6 +17323,15 @@ class BufferAttribute {

}

/**
* Disposes of the buffer attribute. Available only in {@link WebGPURenderer}.
*/
dispose() {

this.dispatchEvent( { type: 'dispose' } );

}

}

/**
Expand Down Expand Up @@ -24694,7 +24716,7 @@ class InstancedMesh extends Mesh {

/**
* Sets the given local transformation matrix to the defined instance. Make sure you set the `needsUpdate` flag of
* {@link InstancedMesh#instanceMatrix} to `true` after updating all the colors.
* {@link InstancedMesh#instanceMatrix} to `true` after updating all the matrices.
*
* @param {number} index - The instance index.
* @param {Matrix4} matrix - The local transformation.
Expand Down Expand Up @@ -48804,6 +48826,7 @@ class ObjectLoader extends Loader {
if ( data.premultiplyAlpha !== undefined ) texture.premultiplyAlpha = data.premultiplyAlpha;
if ( data.unpackAlignment !== undefined ) texture.unpackAlignment = data.unpackAlignment;
if ( data.compareFunction !== undefined ) texture.compareFunction = data.compareFunction;
if ( data.normalized !== undefined ) texture.normalized = data.normalized;

if ( data.userData !== undefined ) texture.userData = data.userData;

Expand Down Expand Up @@ -55842,7 +55865,7 @@ class Clock {
*/
this.running = false;

warn( 'THREE.Clock: This module has been deprecated. Please use THREE.Timer instead.' ); // @deprecated, r183
warn( 'Clock: This module has been deprecated. Please use THREE.Timer instead.' ); // @deprecated, r183

}

Expand Down Expand Up @@ -70668,7 +70691,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

}

function getInternalFormat( internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false ) {
function getInternalFormat( internalFormatName, glFormat, glType, normalized, colorSpace, forceLinearTransfer = false ) {

if ( internalFormatName !== null ) {

Expand All @@ -70678,13 +70701,29 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

}

let ext_texture_norm16;

if ( normalized ) {

ext_texture_norm16 = extensions.get( 'EXT_texture_norm16' );

if ( ! ext_texture_norm16 ) {

warn( 'WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension' );

}

}

let internalFormat = glFormat;

if ( glFormat === _gl.RED ) {

if ( glType === _gl.FLOAT ) internalFormat = _gl.R32F;
if ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.R16F;
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.R8;
if ( glType === _gl.UNSIGNED_SHORT && ext_texture_norm16 ) internalFormat = ext_texture_norm16.R16_EXT;
if ( glType === _gl.SHORT && ext_texture_norm16 ) internalFormat = ext_texture_norm16.R16_SNORM_EXT;

}

Expand All @@ -70704,6 +70743,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
if ( glType === _gl.FLOAT ) internalFormat = _gl.RG32F;
if ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RG16F;
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RG8;
if ( glType === _gl.UNSIGNED_SHORT && ext_texture_norm16 ) internalFormat = ext_texture_norm16.RG16_EXT;
if ( glType === _gl.SHORT && ext_texture_norm16 ) internalFormat = ext_texture_norm16.RG16_SNORM_EXT;

}

Expand Down Expand Up @@ -70742,6 +70783,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

if ( glFormat === _gl.RGB ) {

if ( glType === _gl.UNSIGNED_SHORT && ext_texture_norm16 ) internalFormat = ext_texture_norm16.RGB16_EXT;
if ( glType === _gl.SHORT && ext_texture_norm16 ) internalFormat = ext_texture_norm16.RGB16_SNORM_EXT;
if ( glType === _gl.UNSIGNED_INT_5_9_9_9_REV ) internalFormat = _gl.RGB9_E5;
if ( glType === _gl.UNSIGNED_INT_10F_11F_11F_REV ) internalFormat = _gl.R11F_G11F_B10F;

Expand All @@ -70754,6 +70797,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
if ( glType === _gl.FLOAT ) internalFormat = _gl.RGBA32F;
if ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RGBA16F;
if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = ( transfer === SRGBTransfer ) ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
if ( glType === _gl.UNSIGNED_SHORT && ext_texture_norm16 ) internalFormat = ext_texture_norm16.RGBA16_EXT;
if ( glType === _gl.SHORT && ext_texture_norm16 ) internalFormat = ext_texture_norm16.RGBA16_SNORM_EXT;
if ( glType === _gl.UNSIGNED_SHORT_4_4_4_4 ) internalFormat = _gl.RGBA4;
if ( glType === _gl.UNSIGNED_SHORT_5_5_5_1 ) internalFormat = _gl.RGB5_A1;

Expand Down Expand Up @@ -71451,7 +71496,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
const glFormat = utils.convert( texture.format, texture.colorSpace );

const glType = utils.convert( texture.type );
let glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace, texture.isVideoTexture );
let glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace, texture.isVideoTexture );

setTextureParameters( textureType, texture );

Expand Down Expand Up @@ -71900,7 +71945,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
const image = cubeImage[ 0 ],
glFormat = utils.convert( texture.format, texture.colorSpace ),
glType = utils.convert( texture.type ),
glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace );

const useTexStorage = ( texture.isVideoTexture !== true );
const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
Expand Down Expand Up @@ -72096,7 +72141,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

const glFormat = utils.convert( texture.format, texture.colorSpace );
const glType = utils.convert( texture.type );
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace );
const renderTargetProperties = properties.get( renderTarget );
const textureProperties = properties.get( texture );

Expand Down Expand Up @@ -72175,7 +72220,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

const glFormat = utils.convert( texture.format, texture.colorSpace );
const glType = utils.convert( texture.type );
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace );

if ( useMultisampledRTT( renderTarget ) ) {

Expand Down Expand Up @@ -72565,7 +72610,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

const glFormat = utils.convert( texture.format, texture.colorSpace );
const glType = utils.convert( texture.type );
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace, renderTarget.isXRRenderTarget === true );
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace, renderTarget.isXRRenderTarget === true );
const samples = getRenderTargetSamples( renderTarget );
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );

Expand Down
29 changes: 26 additions & 3 deletions build/three.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -7577,6 +7577,15 @@ class Texture extends EventDispatcher {
*/
this.pmremVersion = 0;

/**
* Whether the texture should use one of the 16 bit integer formats which are normalized
* to [0, 1] or [-1, 1] (depending on signed/unsigned) when sampled.
*
* @type {boolean}
* @default false
*/
this.normalized = false;

}

/**
Expand Down Expand Up @@ -7692,6 +7701,7 @@ class Texture extends EventDispatcher {
this.format = source.format;
this.internalFormat = source.internalFormat;
this.type = source.type;
this.normalized = source.normalized;

this.offset.copy( source.offset );
this.repeat.copy( source.repeat );
Expand Down Expand Up @@ -7810,6 +7820,7 @@ class Texture extends EventDispatcher {
format: this.format,
internalFormat: this.internalFormat,
type: this.type,
normalized: this.normalized,
colorSpace: this.colorSpace,

minFilter: this.minFilter,
Expand Down Expand Up @@ -16673,7 +16684,7 @@ let _id$2 = 0;
* When working with vector-like data, the `fromBufferAttribute( attribute, index )`
* helper methods on vector and color class might be helpful. E.g. {@link Vector3#fromBufferAttribute}.
*/
class BufferAttribute {
class BufferAttribute extends EventDispatcher {

/**
* Constructs a new buffer attribute.
Expand All @@ -16684,6 +16695,8 @@ class BufferAttribute {
*/
constructor( array, itemSize, normalized = false ) {

super();

if ( Array.isArray( array ) ) {

throw new TypeError( 'THREE.BufferAttribute: array should be a Typed Array.' );
Expand Down Expand Up @@ -17330,6 +17343,15 @@ class BufferAttribute {

}

/**
* Disposes of the buffer attribute. Available only in {@link WebGPURenderer}.
*/
dispose() {

this.dispatchEvent( { type: 'dispose' } );

}

}

/**
Expand Down Expand Up @@ -24714,7 +24736,7 @@ class InstancedMesh extends Mesh {

/**
* Sets the given local transformation matrix to the defined instance. Make sure you set the `needsUpdate` flag of
* {@link InstancedMesh#instanceMatrix} to `true` after updating all the colors.
* {@link InstancedMesh#instanceMatrix} to `true` after updating all the matrices.
*
* @param {number} index - The instance index.
* @param {Matrix4} matrix - The local transformation.
Expand Down Expand Up @@ -48824,6 +48846,7 @@ class ObjectLoader extends Loader {
if ( data.premultiplyAlpha !== undefined ) texture.premultiplyAlpha = data.premultiplyAlpha;
if ( data.unpackAlignment !== undefined ) texture.unpackAlignment = data.unpackAlignment;
if ( data.compareFunction !== undefined ) texture.compareFunction = data.compareFunction;
if ( data.normalized !== undefined ) texture.normalized = data.normalized;

if ( data.userData !== undefined ) texture.userData = data.userData;

Expand Down Expand Up @@ -55862,7 +55885,7 @@ class Clock {
*/
this.running = false;

warn( 'THREE.Clock: This module has been deprecated. Please use THREE.Timer instead.' ); // @deprecated, r183
warn( 'Clock: This module has been deprecated. Please use THREE.Timer instead.' ); // @deprecated, r183

}

Expand Down
2 changes: 1 addition & 1 deletion build/three.core.min.js

Large diffs are not rendered by default.

Loading
Loading