|
@@ -7896,7 +7896,7 @@ class Object3D extends EventDispatcher {
|
|
|
sphereCenter: bound.sphere.center.toArray()
|
|
|
} ) );
|
|
|
|
|
|
- object.maxGeometryCount = this._maxGeometryCount;
|
|
|
+ object.maxInstanceCount = this._maxInstanceCount;
|
|
|
object.maxVertexCount = this._maxVertexCount;
|
|
|
object.maxIndexCount = this._maxIndexCount;
|
|
|
|
|
@@ -9188,10 +9188,6 @@ class Material extends EventDispatcher {
|
|
|
|
|
|
}
|
|
|
|
|
|
- onBuild( /* shaderobject, renderer */ ) {}
|
|
|
-
|
|
|
- onBeforeRender( /* renderer, scene, camera, geometry, object, group */ ) {}
|
|
|
-
|
|
|
onBeforeCompile( /* shaderobject, renderer */ ) {}
|
|
|
|
|
|
customProgramCacheKey() {
|
|
@@ -9608,6 +9604,19 @@ class Material extends EventDispatcher {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ onBuild( /* shaderobject, renderer */ ) {
|
|
|
+
|
|
|
+ console.warn( 'Material: onBuild() has been removed.' ); // @deprecated, r166
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ onBeforeRender( /* renderer, scene, camera, geometry, object, group */ ) {
|
|
|
+
|
|
|
+ console.warn( 'Material: onBeforeRender() has been removed.' ); // @deprecated, r166
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
class MeshBasicMaterial extends Material {
|
|
@@ -18116,7 +18125,6 @@ class DepthTexture extends Texture {
|
|
|
const emptyTexture = /*@__PURE__*/ new Texture();
|
|
|
|
|
|
const emptyShadowTexture = /*@__PURE__*/ new DepthTexture( 1, 1 );
|
|
|
-emptyShadowTexture.compareFunction = LessEqualCompare;
|
|
|
|
|
|
const emptyArrayTexture = /*@__PURE__*/ new DataArrayTexture();
|
|
|
const empty3dTexture = /*@__PURE__*/ new Data3DTexture();
|
|
@@ -18634,7 +18642,18 @@ function setValueT1( gl, v, textures ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- const emptyTexture2D = ( this.type === gl.SAMPLER_2D_SHADOW ) ? emptyShadowTexture : emptyTexture;
|
|
|
+ let emptyTexture2D;
|
|
|
+
|
|
|
+ if ( this.type === gl.SAMPLER_2D_SHADOW ) {
|
|
|
+
|
|
|
+ emptyShadowTexture.compareFunction = LessEqualCompare; // #28670
|
|
|
+ emptyTexture2D = emptyShadowTexture;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ emptyTexture2D = emptyTexture;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
textures.setTexture2D( v || emptyTexture2D, unit );
|
|
|
|
|
@@ -23774,6 +23793,144 @@ function WebGLState( gl ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Given the width, height, format, and type of a texture. Determines how many
|
|
|
+ * bytes must be used to represent the texture.
|
|
|
+ */
|
|
|
+function getByteLength( width, height, format, type ) {
|
|
|
+
|
|
|
+ const typeByteLength = getTextureTypeByteLength( type );
|
|
|
+
|
|
|
+ switch ( format ) {
|
|
|
+
|
|
|
+ // https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml
|
|
|
+ case AlphaFormat:
|
|
|
+ return width * height;
|
|
|
+ case LuminanceFormat:
|
|
|
+ return width * height;
|
|
|
+ case LuminanceAlphaFormat:
|
|
|
+ return width * height * 2;
|
|
|
+ case RedFormat:
|
|
|
+ return ( ( width * height ) / typeByteLength.components ) * typeByteLength.byteLength;
|
|
|
+ case RedIntegerFormat:
|
|
|
+ return ( ( width * height ) / typeByteLength.components ) * typeByteLength.byteLength;
|
|
|
+ case RGFormat:
|
|
|
+ return ( ( width * height * 2 ) / typeByteLength.components ) * typeByteLength.byteLength;
|
|
|
+ case RGIntegerFormat:
|
|
|
+ return ( ( width * height * 2 ) / typeByteLength.components ) * typeByteLength.byteLength;
|
|
|
+ case RGBFormat:
|
|
|
+ return ( ( width * height * 3 ) / typeByteLength.components ) * typeByteLength.byteLength;
|
|
|
+ case RGBAFormat:
|
|
|
+ return ( ( width * height * 4 ) / typeByteLength.components ) * typeByteLength.byteLength;
|
|
|
+ case RGBAIntegerFormat:
|
|
|
+ return ( ( width * height * 4 ) / typeByteLength.components ) * typeByteLength.byteLength;
|
|
|
+
|
|
|
+ // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_s3tc_srgb/
|
|
|
+ case RGB_S3TC_DXT1_Format:
|
|
|
+ case RGBA_S3TC_DXT1_Format:
|
|
|
+ return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 8;
|
|
|
+ case RGBA_S3TC_DXT3_Format:
|
|
|
+ case RGBA_S3TC_DXT5_Format:
|
|
|
+ return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 16;
|
|
|
+
|
|
|
+ // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_pvrtc/
|
|
|
+ case RGB_PVRTC_2BPPV1_Format:
|
|
|
+ case RGBA_PVRTC_2BPPV1_Format:
|
|
|
+ return ( Math.max( width, 16 ) * Math.max( height, 8 ) ) / 4;
|
|
|
+ case RGB_PVRTC_4BPPV1_Format:
|
|
|
+ case RGBA_PVRTC_4BPPV1_Format:
|
|
|
+ return ( Math.max( width, 8 ) * Math.max( height, 8 ) ) / 2;
|
|
|
+
|
|
|
+ // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_etc/
|
|
|
+ case RGB_ETC1_Format:
|
|
|
+ case RGB_ETC2_Format:
|
|
|
+ return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 8;
|
|
|
+ case RGBA_ETC2_EAC_Format:
|
|
|
+ return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 16;
|
|
|
+
|
|
|
+ // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_astc/
|
|
|
+ case RGBA_ASTC_4x4_Format:
|
|
|
+ return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 16;
|
|
|
+ case RGBA_ASTC_5x4_Format:
|
|
|
+ return Math.floor( ( width + 4 ) / 5 ) * Math.floor( ( height + 3 ) / 4 ) * 16;
|
|
|
+ case RGBA_ASTC_5x5_Format:
|
|
|
+ return Math.floor( ( width + 4 ) / 5 ) * Math.floor( ( height + 4 ) / 5 ) * 16;
|
|
|
+ case RGBA_ASTC_6x5_Format:
|
|
|
+ return Math.floor( ( width + 5 ) / 6 ) * Math.floor( ( height + 4 ) / 5 ) * 16;
|
|
|
+ case RGBA_ASTC_6x6_Format:
|
|
|
+ return Math.floor( ( width + 5 ) / 6 ) * Math.floor( ( height + 5 ) / 6 ) * 16;
|
|
|
+ case RGBA_ASTC_8x5_Format:
|
|
|
+ return Math.floor( ( width + 7 ) / 8 ) * Math.floor( ( height + 4 ) / 5 ) * 16;
|
|
|
+ case RGBA_ASTC_8x6_Format:
|
|
|
+ return Math.floor( ( width + 7 ) / 8 ) * Math.floor( ( height + 5 ) / 6 ) * 16;
|
|
|
+ case RGBA_ASTC_8x8_Format:
|
|
|
+ return Math.floor( ( width + 7 ) / 8 ) * Math.floor( ( height + 7 ) / 8 ) * 16;
|
|
|
+ case RGBA_ASTC_10x5_Format:
|
|
|
+ return Math.floor( ( width + 9 ) / 10 ) * Math.floor( ( height + 4 ) / 5 ) * 16;
|
|
|
+ case RGBA_ASTC_10x6_Format:
|
|
|
+ return Math.floor( ( width + 9 ) / 10 ) * Math.floor( ( height + 5 ) / 6 ) * 16;
|
|
|
+ case RGBA_ASTC_10x8_Format:
|
|
|
+ return Math.floor( ( width + 9 ) / 10 ) * Math.floor( ( height + 7 ) / 8 ) * 16;
|
|
|
+ case RGBA_ASTC_10x10_Format:
|
|
|
+ return Math.floor( ( width + 9 ) / 10 ) * Math.floor( ( height + 9 ) / 10 ) * 16;
|
|
|
+ case RGBA_ASTC_12x10_Format:
|
|
|
+ return Math.floor( ( width + 11 ) / 12 ) * Math.floor( ( height + 9 ) / 10 ) * 16;
|
|
|
+ case RGBA_ASTC_12x12_Format:
|
|
|
+ return Math.floor( ( width + 11 ) / 12 ) * Math.floor( ( height + 11 ) / 12 ) * 16;
|
|
|
+
|
|
|
+ // https://registry.khronos.org/webgl/extensions/EXT_texture_compression_bptc/
|
|
|
+ case RGBA_BPTC_Format:
|
|
|
+ case RGB_BPTC_SIGNED_Format:
|
|
|
+ case RGB_BPTC_UNSIGNED_Format:
|
|
|
+ return Math.ceil( width / 4 ) * Math.ceil( height / 4 ) * 16;
|
|
|
+
|
|
|
+ // https://registry.khronos.org/webgl/extensions/EXT_texture_compression_rgtc/
|
|
|
+ case RED_RGTC1_Format:
|
|
|
+ case SIGNED_RED_RGTC1_Format:
|
|
|
+ return Math.ceil( width / 4 ) * Math.ceil( height / 4 ) * 8;
|
|
|
+ case RED_GREEN_RGTC2_Format:
|
|
|
+ case SIGNED_RED_GREEN_RGTC2_Format:
|
|
|
+ return Math.ceil( width / 4 ) * Math.ceil( height / 4 ) * 16;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ throw new Error(
|
|
|
+ `Unable to determine texture byte length for ${format} format.`,
|
|
|
+ );
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+function getTextureTypeByteLength( type ) {
|
|
|
+
|
|
|
+ switch ( type ) {
|
|
|
+
|
|
|
+ case UnsignedByteType:
|
|
|
+ case ByteType:
|
|
|
+ return { byteLength: 1, components: 1 };
|
|
|
+ case UnsignedShortType:
|
|
|
+ case ShortType:
|
|
|
+ case HalfFloatType:
|
|
|
+ return { byteLength: 2, components: 1 };
|
|
|
+ case UnsignedShort4444Type:
|
|
|
+ case UnsignedShort5551Type:
|
|
|
+ return { byteLength: 2, components: 4 };
|
|
|
+ case UnsignedIntType:
|
|
|
+ case IntType:
|
|
|
+ case FloatType:
|
|
|
+ return { byteLength: 4, components: 1 };
|
|
|
+ case UnsignedInt5999Type:
|
|
|
+ return { byteLength: 4, components: 3 };
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ throw new Error( `Unknown texture type ${type}.` );
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+const TextureUtils = {
|
|
|
+ getByteLength,
|
|
|
+};
|
|
|
+
|
|
|
function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {
|
|
|
|
|
|
const multisampledRTTExt = extensions.has( 'WEBGL_multisampled_render_to_texture' ) ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : null;
|
|
@@ -24625,10 +24782,15 @@ 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 );
|
|
|
+
|
|
|
for ( const layerIndex of texture.layerUpdates ) {
|
|
|
|
|
|
- const layerSize = mipmap.width * mipmap.height;
|
|
|
- state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, layerIndex, mipmap.width, mipmap.height, 1, glFormat, mipmap.data.slice( layerSize * layerIndex, layerSize * ( layerIndex + 1 ) ), 0, 0 );
|
|
|
+ const layerData = mipmap.data.subarray(
|
|
|
+ layerIndex * layerByteLength / mipmap.data.BYTES_PER_ELEMENT,
|
|
|
+ ( layerIndex + 1 ) * layerByteLength / mipmap.data.BYTES_PER_ELEMENT
|
|
|
+ );
|
|
|
+ state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, layerIndex, mipmap.width, mipmap.height, 1, glFormat, layerData, 0, 0 );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -24746,60 +24908,15 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
if ( texture.layerUpdates.size > 0 ) {
|
|
|
|
|
|
- // When type is GL_UNSIGNED_BYTE, each of these bytes is
|
|
|
- // interpreted as one color component, depending on format. When
|
|
|
- // type is one of GL_UNSIGNED_SHORT_5_6_5,
|
|
|
- // GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_5_5_5_1, each
|
|
|
- // unsigned value is interpreted as containing all the components
|
|
|
- // for a single pixel, with the color components arranged
|
|
|
- // according to format.
|
|
|
- //
|
|
|
- // See https://registry.khronos.org/OpenGL-Refpages/es1.1/xhtml/glTexImage2D.xml
|
|
|
- let texelSize;
|
|
|
- switch ( glType ) {
|
|
|
-
|
|
|
- case _gl.UNSIGNED_BYTE:
|
|
|
- switch ( glFormat ) {
|
|
|
-
|
|
|
- case _gl.ALPHA:
|
|
|
- texelSize = 1;
|
|
|
- break;
|
|
|
- case _gl.LUMINANCE:
|
|
|
- texelSize = 1;
|
|
|
- break;
|
|
|
- case _gl.LUMINANCE_ALPHA:
|
|
|
- texelSize = 2;
|
|
|
- break;
|
|
|
- case _gl.RGB:
|
|
|
- texelSize = 3;
|
|
|
- break;
|
|
|
- case _gl.RGBA:
|
|
|
- texelSize = 4;
|
|
|
- break;
|
|
|
-
|
|
|
- default:
|
|
|
- throw new Error( `Unknown texel size for format ${glFormat}.` );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- break;
|
|
|
-
|
|
|
- case _gl.UNSIGNED_SHORT_4_4_4_4:
|
|
|
- case _gl.UNSIGNED_SHORT_5_5_5_1:
|
|
|
- case _gl.UNSIGNED_SHORT_5_6_5:
|
|
|
- texelSize = 1;
|
|
|
- break;
|
|
|
-
|
|
|
- default:
|
|
|
- throw new Error( `Unknown texel size for type ${glType}.` );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- const layerSize = image.width * image.height * texelSize;
|
|
|
+ const layerByteLength = TextureUtils.getByteLength( image.width, image.height, texture.format, texture.type );
|
|
|
|
|
|
for ( const layerIndex of texture.layerUpdates ) {
|
|
|
|
|
|
- state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, 0, 0, 0, layerIndex, image.width, image.height, 1, glFormat, glType, image.data.slice( layerSize * layerIndex, layerSize * ( layerIndex + 1 ) ) );
|
|
|
+ const layerData = image.data.subarray(
|
|
|
+ layerIndex * layerByteLength / image.data.BYTES_PER_ELEMENT,
|
|
|
+ ( layerIndex + 1 ) * layerByteLength / image.data.BYTES_PER_ELEMENT
|
|
|
+ );
|
|
|
+ state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, 0, 0, 0, layerIndex, image.width, image.height, 1, glFormat, glType, layerData );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -29909,8 +30026,6 @@ class WebGLRenderer {
|
|
|
object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );
|
|
|
object.normalMatrix.getNormalMatrix( object.modelViewMatrix );
|
|
|
|
|
|
- material.onBeforeRender( _this, scene, camera, geometry, object, group );
|
|
|
-
|
|
|
if ( material.transparent === true && material.side === DoubleSide && material.forceSinglePass === false ) {
|
|
|
|
|
|
material.side = BackSide;
|
|
@@ -29985,8 +30100,6 @@ class WebGLRenderer {
|
|
|
|
|
|
parameters.uniforms = programCache.getUniforms( material );
|
|
|
|
|
|
- material.onBuild( object, parameters, _this );
|
|
|
-
|
|
|
material.onBeforeCompile( parameters, _this );
|
|
|
|
|
|
program = programCache.acquireProgram( parameters, programCacheKey );
|
|
@@ -30914,7 +31027,7 @@ class WebGLRenderer {
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, glFormat, glType, image );
|
|
|
+ _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -33283,7 +33396,8 @@ class BatchedMesh extends Mesh {
|
|
|
|
|
|
if ( reference.getIndex() !== null ) {
|
|
|
|
|
|
- const indexArray = maxVertexCount > 65536
|
|
|
+ // Reserve last u16 index for primitive restart.
|
|
|
+ const indexArray = maxVertexCount > 65535
|
|
|
? new Uint32Array( maxIndexCount )
|
|
|
: new Uint16Array( maxIndexCount );
|
|
|
|
|
@@ -34809,7 +34923,7 @@ class CompressedArrayTexture extends CompressedTexture {
|
|
|
|
|
|
}
|
|
|
|
|
|
- addLayerUpdates( layerIndex ) {
|
|
|
+ addLayerUpdate( layerIndex ) {
|
|
|
|
|
|
this.layerUpdates.add( layerIndex );
|
|
|
|
|
@@ -44616,6 +44730,7 @@ class Light extends Object3D {
|
|
|
if ( this.penumbra !== undefined ) data.object.penumbra = this.penumbra;
|
|
|
|
|
|
if ( this.shadow !== undefined ) data.object.shadow = this.shadow.toJSON();
|
|
|
+ if ( this.target !== undefined ) data.object.target = this.target.uuid;
|
|
|
|
|
|
return data;
|
|
|
|
|
@@ -46211,6 +46326,7 @@ class ObjectLoader extends Loader {
|
|
|
const skeletons = this.parseSkeletons( json.skeletons, object );
|
|
|
|
|
|
this.bindSkeletons( object, skeletons );
|
|
|
+ this.bindLightTargets( object );
|
|
|
|
|
|
//
|
|
|
|
|
@@ -46881,6 +46997,7 @@ class ObjectLoader extends Loader {
|
|
|
case 'DirectionalLight':
|
|
|
|
|
|
object = new DirectionalLight( data.color, data.intensity );
|
|
|
+ object.target = data.target || '';
|
|
|
|
|
|
break;
|
|
|
|
|
@@ -46899,6 +47016,7 @@ class ObjectLoader extends Loader {
|
|
|
case 'SpotLight':
|
|
|
|
|
|
object = new SpotLight( data.color, data.intensity, data.distance, data.angle, data.penumbra, data.decay );
|
|
|
+ object.target = data.target || '';
|
|
|
|
|
|
break;
|
|
|
|
|
@@ -46955,7 +47073,7 @@ class ObjectLoader extends Loader {
|
|
|
geometry = getGeometry( data.geometry );
|
|
|
material = getMaterial( data.material );
|
|
|
|
|
|
- object = new BatchedMesh( data.maxGeometryCount, data.maxVertexCount, data.maxIndexCount, material );
|
|
|
+ object = new BatchedMesh( data.maxInstanceCount, data.maxVertexCount, data.maxIndexCount, material );
|
|
|
object.geometry = geometry;
|
|
|
object.perObjectFrustumCulled = data.perObjectFrustumCulled;
|
|
|
object.sortObjects = data.sortObjects;
|
|
@@ -46985,7 +47103,7 @@ class ObjectLoader extends Loader {
|
|
|
|
|
|
} );
|
|
|
|
|
|
- object._maxGeometryCount = data.maxGeometryCount;
|
|
|
+ object._maxInstanceCount = data.maxInstanceCount;
|
|
|
object._maxVertexCount = data.maxVertexCount;
|
|
|
object._maxIndexCount = data.maxIndexCount;
|
|
|
|
|
@@ -47171,6 +47289,32 @@ class ObjectLoader extends Loader {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ bindLightTargets( object ) {
|
|
|
+
|
|
|
+ object.traverse( function ( child ) {
|
|
|
+
|
|
|
+ if ( child.isDirectionalLight || child.isSpotLight ) {
|
|
|
+
|
|
|
+ const uuid = child.target;
|
|
|
+
|
|
|
+ const target = object.getObjectByProperty( 'uuid', uuid );
|
|
|
+
|
|
|
+ if ( target !== undefined ) {
|
|
|
+
|
|
|
+ child.target = target;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ child.target = new Object3D();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
const TEXTURE_MAPPING = {
|
|
@@ -53865,6 +54009,7 @@ exports.TangentSpaceNormalMap = TangentSpaceNormalMap;
|
|
|
exports.TetrahedronGeometry = TetrahedronGeometry;
|
|
|
exports.Texture = Texture;
|
|
|
exports.TextureLoader = TextureLoader;
|
|
|
+exports.TextureUtils = TextureUtils;
|
|
|
exports.TorusGeometry = TorusGeometry;
|
|
|
exports.TorusKnotGeometry = TorusKnotGeometry;
|
|
|
exports.Triangle = Triangle;
|