📄 WebGLUniforms.js
¶
📊 Analysis Summary¶
Metric | Count |
---|---|
🔧 Functions | 51 |
🧱 Classes | 4 |
📦 Imports | 6 |
📊 Variables & Constants | 62 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 src/renderers/webgl/WebGLUniforms.js
📦 Imports¶
Name | Source |
---|---|
CubeTexture |
../../textures/CubeTexture.js |
Texture |
../../textures/Texture.js |
DataArrayTexture |
../../textures/DataArrayTexture.js |
Data3DTexture |
../../textures/Data3DTexture.js |
DepthTexture |
../../textures/DepthTexture.js |
LessEqualCompare |
../../constants.js |
Variables & Constants¶
Name | Type | Kind | Value | Exported |
---|---|---|---|---|
emptyTexture |
Texture |
let/var | new Texture() |
✗ |
emptyShadowTexture |
DepthTexture |
let/var | new DepthTexture( 1, 1 ) |
✗ |
emptyArrayTexture |
DataArrayTexture |
let/var | new DataArrayTexture() |
✗ |
empty3dTexture |
Data3DTexture |
let/var | new Data3DTexture() |
✗ |
emptyCubeTexture |
CubeTexture |
let/var | new CubeTexture() |
✗ |
arrayCacheF32 |
any[] |
let/var | [] |
✗ |
arrayCacheI32 |
any[] |
let/var | [] |
✗ |
mat4array |
Float32Array<ArrayBuffer> |
let/var | new Float32Array( 16 ) |
✗ |
mat3array |
Float32Array<ArrayBuffer> |
let/var | new Float32Array( 9 ) |
✗ |
mat2array |
Float32Array<ArrayBuffer> |
let/var | new Float32Array( 4 ) |
✗ |
firstElem |
any |
let/var | array[ 0 ] |
✗ |
n |
number |
let/var | nBlocks * blockSize |
✗ |
r |
any |
let/var | arrayCacheF32[ n ] |
✗ |
r |
any |
let/var | arrayCacheI32[ n ] |
✗ |
cache |
any |
let/var | this.cache |
✗ |
cache |
any |
let/var | this.cache |
✗ |
cache |
any |
let/var | this.cache |
✗ |
cache |
any |
let/var | this.cache |
✗ |
cache |
any |
let/var | this.cache |
✗ |
elements |
any |
let/var | v.elements |
✗ |
cache |
any |
let/var | this.cache |
✗ |
elements |
any |
let/var | v.elements |
✗ |
cache |
any |
let/var | this.cache |
✗ |
elements |
any |
let/var | v.elements |
✗ |
cache |
any |
let/var | this.cache |
✗ |
cache |
any |
let/var | this.cache |
✗ |
cache |
any |
let/var | this.cache |
✗ |
cache |
any |
let/var | this.cache |
✗ |
cache |
any |
let/var | this.cache |
✗ |
cache |
any |
let/var | this.cache |
✗ |
cache |
any |
let/var | this.cache |
✗ |
cache |
any |
let/var | this.cache |
✗ |
cache |
any |
let/var | this.cache |
✗ |
emptyTexture2D |
any |
let/var | *not shown* |
✗ |
cache |
any |
let/var | this.cache |
✗ |
cache |
any |
let/var | this.cache |
✗ |
cache |
any |
let/var | this.cache |
✗ |
cache |
any |
let/var | this.cache |
✗ |
n |
any |
let/var | v.length |
✗ |
cache |
any |
let/var | this.cache |
✗ |
n |
any |
let/var | v.length |
✗ |
cache |
any |
let/var | this.cache |
✗ |
n |
any |
let/var | v.length |
✗ |
cache |
any |
let/var | this.cache |
✗ |
n |
any |
let/var | v.length |
✗ |
seq |
any[] |
let/var | this.seq |
✗ |
u |
any |
let/var | seq[ i ] |
✗ |
RePathPart |
RegExp |
let/var | /(\w+)(\])?(\[\|\.)?/g |
✗ |
path |
any |
let/var | activeInfo.name |
✗ |
pathLength |
any |
let/var | path.length |
✗ |
matchEnd |
number |
let/var | RePathPart.lastIndex |
✗ |
id |
string |
let/var | match[ 1 ] |
✗ |
idIsIndex |
boolean |
let/var | match[ 2 ] === ']' |
✗ |
subscript |
string |
let/var | match[ 3 ] |
✗ |
map |
any |
let/var | container.map |
✗ |
next |
any |
let/var | map[ id ] |
✗ |
u |
any |
let/var | this.map[ name ] |
✗ |
v |
any |
let/var | object[ name ] |
✗ |
u |
any |
let/var | seq[ i ] |
✗ |
v |
any |
let/var | values[ u.id ] |
✗ |
r |
any[] |
let/var | [] |
✗ |
u |
any |
let/var | seq[ i ] |
✗ |
Functions¶
flatten(array: any, nBlocks: any, blockSize: any): any
¶
Parameters:
array
any
nBlocks
any
blockSize
any
Returns: any
Calls:
firstElem.toArray
array[ i ].toArray
Internal Comments:
Code
function flatten( array, nBlocks, blockSize ) {
const firstElem = array[ 0 ];
if ( firstElem <= 0 || firstElem > 0 ) return array;
// unoptimized: ! isNaN( firstElem )
// see http://jacksondunstan.com/articles/983
const n = nBlocks * blockSize;
let r = arrayCacheF32[ n ];
if ( r === undefined ) {
r = new Float32Array( n );
arrayCacheF32[ n ] = r;
}
if ( nBlocks !== 0 ) {
firstElem.toArray( r, 0 );
for ( let i = 1, offset = 0; i !== nBlocks; ++ i ) {
offset += blockSize;
array[ i ].toArray( r, offset );
}
}
return r;
}
arraysEqual(a: any, b: any): boolean
¶
Parameters:
a
any
b
any
Returns: boolean
Code
copyArray(a: any, b: any): void
¶
Parameters:
a
any
b
any
Returns: void
Code
allocTexUnits(textures: any, n: any): any
¶
Parameters:
textures
any
n
any
Returns: any
Calls:
textures.allocateTextureUnit
Code
setValueV1f(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
gl.uniform1f
Code
setValueV2f(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
gl.uniform2f
arraysEqual
gl.uniform2fv
copyArray
Code
function setValueV2f( gl, v ) {
const cache = this.cache;
if ( v.x !== undefined ) {
if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y ) {
gl.uniform2f( this.addr, v.x, v.y );
cache[ 0 ] = v.x;
cache[ 1 ] = v.y;
}
} else {
if ( arraysEqual( cache, v ) ) return;
gl.uniform2fv( this.addr, v );
copyArray( cache, v );
}
}
setValueV3f(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
gl.uniform3f
arraysEqual
gl.uniform3fv
copyArray
Code
function setValueV3f( gl, v ) {
const cache = this.cache;
if ( v.x !== undefined ) {
if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z ) {
gl.uniform3f( this.addr, v.x, v.y, v.z );
cache[ 0 ] = v.x;
cache[ 1 ] = v.y;
cache[ 2 ] = v.z;
}
} else if ( v.r !== undefined ) {
if ( cache[ 0 ] !== v.r || cache[ 1 ] !== v.g || cache[ 2 ] !== v.b ) {
gl.uniform3f( this.addr, v.r, v.g, v.b );
cache[ 0 ] = v.r;
cache[ 1 ] = v.g;
cache[ 2 ] = v.b;
}
} else {
if ( arraysEqual( cache, v ) ) return;
gl.uniform3fv( this.addr, v );
copyArray( cache, v );
}
}
setValueV4f(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
gl.uniform4f
arraysEqual
gl.uniform4fv
copyArray
Code
function setValueV4f( gl, v ) {
const cache = this.cache;
if ( v.x !== undefined ) {
if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z || cache[ 3 ] !== v.w ) {
gl.uniform4f( this.addr, v.x, v.y, v.z, v.w );
cache[ 0 ] = v.x;
cache[ 1 ] = v.y;
cache[ 2 ] = v.z;
cache[ 3 ] = v.w;
}
} else {
if ( arraysEqual( cache, v ) ) return;
gl.uniform4fv( this.addr, v );
copyArray( cache, v );
}
}
setValueM2(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
arraysEqual
gl.uniformMatrix2fv
copyArray
mat2array.set
Code
function setValueM2( gl, v ) {
const cache = this.cache;
const elements = v.elements;
if ( elements === undefined ) {
if ( arraysEqual( cache, v ) ) return;
gl.uniformMatrix2fv( this.addr, false, v );
copyArray( cache, v );
} else {
if ( arraysEqual( cache, elements ) ) return;
mat2array.set( elements );
gl.uniformMatrix2fv( this.addr, false, mat2array );
copyArray( cache, elements );
}
}
setValueM3(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
arraysEqual
gl.uniformMatrix3fv
copyArray
mat3array.set
Code
function setValueM3( gl, v ) {
const cache = this.cache;
const elements = v.elements;
if ( elements === undefined ) {
if ( arraysEqual( cache, v ) ) return;
gl.uniformMatrix3fv( this.addr, false, v );
copyArray( cache, v );
} else {
if ( arraysEqual( cache, elements ) ) return;
mat3array.set( elements );
gl.uniformMatrix3fv( this.addr, false, mat3array );
copyArray( cache, elements );
}
}
setValueM4(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
arraysEqual
gl.uniformMatrix4fv
copyArray
mat4array.set
Code
function setValueM4( gl, v ) {
const cache = this.cache;
const elements = v.elements;
if ( elements === undefined ) {
if ( arraysEqual( cache, v ) ) return;
gl.uniformMatrix4fv( this.addr, false, v );
copyArray( cache, v );
} else {
if ( arraysEqual( cache, elements ) ) return;
mat4array.set( elements );
gl.uniformMatrix4fv( this.addr, false, mat4array );
copyArray( cache, elements );
}
}
setValueV1i(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
gl.uniform1i
Code
setValueV2i(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
gl.uniform2i
arraysEqual
gl.uniform2iv
copyArray
Code
function setValueV2i( gl, v ) {
const cache = this.cache;
if ( v.x !== undefined ) {
if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y ) {
gl.uniform2i( this.addr, v.x, v.y );
cache[ 0 ] = v.x;
cache[ 1 ] = v.y;
}
} else {
if ( arraysEqual( cache, v ) ) return;
gl.uniform2iv( this.addr, v );
copyArray( cache, v );
}
}
setValueV3i(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
gl.uniform3i
arraysEqual
gl.uniform3iv
copyArray
Code
function setValueV3i( gl, v ) {
const cache = this.cache;
if ( v.x !== undefined ) {
if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z ) {
gl.uniform3i( this.addr, v.x, v.y, v.z );
cache[ 0 ] = v.x;
cache[ 1 ] = v.y;
cache[ 2 ] = v.z;
}
} else {
if ( arraysEqual( cache, v ) ) return;
gl.uniform3iv( this.addr, v );
copyArray( cache, v );
}
}
setValueV4i(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
gl.uniform4i
arraysEqual
gl.uniform4iv
copyArray
Code
function setValueV4i( gl, v ) {
const cache = this.cache;
if ( v.x !== undefined ) {
if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z || cache[ 3 ] !== v.w ) {
gl.uniform4i( this.addr, v.x, v.y, v.z, v.w );
cache[ 0 ] = v.x;
cache[ 1 ] = v.y;
cache[ 2 ] = v.z;
cache[ 3 ] = v.w;
}
} else {
if ( arraysEqual( cache, v ) ) return;
gl.uniform4iv( this.addr, v );
copyArray( cache, v );
}
}
setValueV1ui(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
gl.uniform1ui
Code
setValueV2ui(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
gl.uniform2ui
arraysEqual
gl.uniform2uiv
copyArray
Code
function setValueV2ui( gl, v ) {
const cache = this.cache;
if ( v.x !== undefined ) {
if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y ) {
gl.uniform2ui( this.addr, v.x, v.y );
cache[ 0 ] = v.x;
cache[ 1 ] = v.y;
}
} else {
if ( arraysEqual( cache, v ) ) return;
gl.uniform2uiv( this.addr, v );
copyArray( cache, v );
}
}
setValueV3ui(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
gl.uniform3ui
arraysEqual
gl.uniform3uiv
copyArray
Code
function setValueV3ui( gl, v ) {
const cache = this.cache;
if ( v.x !== undefined ) {
if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z ) {
gl.uniform3ui( this.addr, v.x, v.y, v.z );
cache[ 0 ] = v.x;
cache[ 1 ] = v.y;
cache[ 2 ] = v.z;
}
} else {
if ( arraysEqual( cache, v ) ) return;
gl.uniform3uiv( this.addr, v );
copyArray( cache, v );
}
}
setValueV4ui(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
gl.uniform4ui
arraysEqual
gl.uniform4uiv
copyArray
Code
function setValueV4ui( gl, v ) {
const cache = this.cache;
if ( v.x !== undefined ) {
if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z || cache[ 3 ] !== v.w ) {
gl.uniform4ui( this.addr, v.x, v.y, v.z, v.w );
cache[ 0 ] = v.x;
cache[ 1 ] = v.y;
cache[ 2 ] = v.z;
cache[ 3 ] = v.w;
}
} else {
if ( arraysEqual( cache, v ) ) return;
gl.uniform4uiv( this.addr, v );
copyArray( cache, v );
}
}
setValueT1(gl: any, v: any, textures: any): void
¶
Parameters:
gl
any
v
any
textures
any
Returns: void
Calls:
textures.allocateTextureUnit
gl.uniform1i
textures.setTexture2D
Code
function setValueT1( gl, v, textures ) {
const cache = this.cache;
const unit = textures.allocateTextureUnit();
if ( cache[ 0 ] !== unit ) {
gl.uniform1i( this.addr, unit );
cache[ 0 ] = unit;
}
let emptyTexture2D;
if ( this.type === gl.SAMPLER_2D_SHADOW ) {
emptyShadowTexture.compareFunction = LessEqualCompare; // #28670
emptyTexture2D = emptyShadowTexture;
} else {
emptyTexture2D = emptyTexture;
}
textures.setTexture2D( v || emptyTexture2D, unit );
}
setValueT3D1(gl: any, v: any, textures: any): void
¶
Parameters:
gl
any
v
any
textures
any
Returns: void
Calls:
textures.allocateTextureUnit
gl.uniform1i
textures.setTexture3D
Code
setValueT6(gl: any, v: any, textures: any): void
¶
Parameters:
gl
any
v
any
textures
any
Returns: void
Calls:
textures.allocateTextureUnit
gl.uniform1i
textures.setTextureCube
Code
setValueT2DArray1(gl: any, v: any, textures: any): void
¶
Parameters:
gl
any
v
any
textures
any
Returns: void
Calls:
textures.allocateTextureUnit
gl.uniform1i
textures.setTexture2DArray
Code
getSingularSetter(type: any): (gl: any, v: any, textures: any) => void
¶
Parameters:
type
any
Returns: (gl: any, v: any, textures: any) => void
Code
function getSingularSetter( type ) {
switch ( type ) {
case 0x1406: return setValueV1f; // FLOAT
case 0x8b50: return setValueV2f; // _VEC2
case 0x8b51: return setValueV3f; // _VEC3
case 0x8b52: return setValueV4f; // _VEC4
case 0x8b5a: return setValueM2; // _MAT2
case 0x8b5b: return setValueM3; // _MAT3
case 0x8b5c: return setValueM4; // _MAT4
case 0x1404: case 0x8b56: return setValueV1i; // INT, BOOL
case 0x8b53: case 0x8b57: return setValueV2i; // _VEC2
case 0x8b54: case 0x8b58: return setValueV3i; // _VEC3
case 0x8b55: case 0x8b59: return setValueV4i; // _VEC4
case 0x1405: return setValueV1ui; // UINT
case 0x8dc6: return setValueV2ui; // _VEC2
case 0x8dc7: return setValueV3ui; // _VEC3
case 0x8dc8: return setValueV4ui; // _VEC4
case 0x8b5e: // SAMPLER_2D
case 0x8d66: // SAMPLER_EXTERNAL_OES
case 0x8dca: // INT_SAMPLER_2D
case 0x8dd2: // UNSIGNED_INT_SAMPLER_2D
case 0x8b62: // SAMPLER_2D_SHADOW
return setValueT1;
case 0x8b5f: // SAMPLER_3D
case 0x8dcb: // INT_SAMPLER_3D
case 0x8dd3: // UNSIGNED_INT_SAMPLER_3D
return setValueT3D1;
case 0x8b60: // SAMPLER_CUBE
case 0x8dcc: // INT_SAMPLER_CUBE
case 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE
case 0x8dc5: // SAMPLER_CUBE_SHADOW
return setValueT6;
case 0x8dc1: // SAMPLER_2D_ARRAY
case 0x8dcf: // INT_SAMPLER_2D_ARRAY
case 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY
case 0x8dc4: // SAMPLER_2D_ARRAY_SHADOW
return setValueT2DArray1;
}
}
setValueV1fArray(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
gl.uniform1fv
setValueV2fArray(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
flatten
gl.uniform2fv
Code
setValueV3fArray(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
flatten
gl.uniform3fv
Code
setValueV4fArray(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
flatten
gl.uniform4fv
Code
setValueM2Array(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
flatten
gl.uniformMatrix2fv
Code
setValueM3Array(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
flatten
gl.uniformMatrix3fv
Code
setValueM4Array(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
flatten
gl.uniformMatrix4fv
Code
setValueV1iArray(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
gl.uniform1iv
setValueV2iArray(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
gl.uniform2iv
setValueV3iArray(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
gl.uniform3iv
setValueV4iArray(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
gl.uniform4iv
setValueV1uiArray(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
gl.uniform1uiv
setValueV2uiArray(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
gl.uniform2uiv
setValueV3uiArray(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
gl.uniform3uiv
setValueV4uiArray(gl: any, v: any): void
¶
Parameters:
gl
any
v
any
Returns: void
Calls:
gl.uniform4uiv
setValueT1Array(gl: any, v: any, textures: any): void
¶
Parameters:
gl
any
v
any
textures
any
Returns: void
Calls:
allocTexUnits
arraysEqual
gl.uniform1iv
copyArray
textures.setTexture2D
Code
function setValueT1Array( gl, v, textures ) {
const cache = this.cache;
const n = v.length;
const units = allocTexUnits( textures, n );
if ( ! arraysEqual( cache, units ) ) {
gl.uniform1iv( this.addr, units );
copyArray( cache, units );
}
for ( let i = 0; i !== n; ++ i ) {
textures.setTexture2D( v[ i ] || emptyTexture, units[ i ] );
}
}
setValueT3DArray(gl: any, v: any, textures: any): void
¶
Parameters:
gl
any
v
any
textures
any
Returns: void
Calls:
allocTexUnits
arraysEqual
gl.uniform1iv
copyArray
textures.setTexture3D
Code
function setValueT3DArray( gl, v, textures ) {
const cache = this.cache;
const n = v.length;
const units = allocTexUnits( textures, n );
if ( ! arraysEqual( cache, units ) ) {
gl.uniform1iv( this.addr, units );
copyArray( cache, units );
}
for ( let i = 0; i !== n; ++ i ) {
textures.setTexture3D( v[ i ] || empty3dTexture, units[ i ] );
}
}
setValueT6Array(gl: any, v: any, textures: any): void
¶
Parameters:
gl
any
v
any
textures
any
Returns: void
Calls:
allocTexUnits
arraysEqual
gl.uniform1iv
copyArray
textures.setTextureCube
Code
function setValueT6Array( gl, v, textures ) {
const cache = this.cache;
const n = v.length;
const units = allocTexUnits( textures, n );
if ( ! arraysEqual( cache, units ) ) {
gl.uniform1iv( this.addr, units );
copyArray( cache, units );
}
for ( let i = 0; i !== n; ++ i ) {
textures.setTextureCube( v[ i ] || emptyCubeTexture, units[ i ] );
}
}
setValueT2DArrayArray(gl: any, v: any, textures: any): void
¶
Parameters:
gl
any
v
any
textures
any
Returns: void
Calls:
allocTexUnits
arraysEqual
gl.uniform1iv
copyArray
textures.setTexture2DArray
Code
function setValueT2DArrayArray( gl, v, textures ) {
const cache = this.cache;
const n = v.length;
const units = allocTexUnits( textures, n );
if ( ! arraysEqual( cache, units ) ) {
gl.uniform1iv( this.addr, units );
copyArray( cache, units );
}
for ( let i = 0; i !== n; ++ i ) {
textures.setTexture2DArray( v[ i ] || emptyArrayTexture, units[ i ] );
}
}
getPureArraySetter(type: any): (gl: any, v: any, textures: any) => void
¶
Parameters:
type
any
Returns: (gl: any, v: any, textures: any) => void
Code
function getPureArraySetter( type ) {
switch ( type ) {
case 0x1406: return setValueV1fArray; // FLOAT
case 0x8b50: return setValueV2fArray; // _VEC2
case 0x8b51: return setValueV3fArray; // _VEC3
case 0x8b52: return setValueV4fArray; // _VEC4
case 0x8b5a: return setValueM2Array; // _MAT2
case 0x8b5b: return setValueM3Array; // _MAT3
case 0x8b5c: return setValueM4Array; // _MAT4
case 0x1404: case 0x8b56: return setValueV1iArray; // INT, BOOL
case 0x8b53: case 0x8b57: return setValueV2iArray; // _VEC2
case 0x8b54: case 0x8b58: return setValueV3iArray; // _VEC3
case 0x8b55: case 0x8b59: return setValueV4iArray; // _VEC4
case 0x1405: return setValueV1uiArray; // UINT
case 0x8dc6: return setValueV2uiArray; // _VEC2
case 0x8dc7: return setValueV3uiArray; // _VEC3
case 0x8dc8: return setValueV4uiArray; // _VEC4
case 0x8b5e: // SAMPLER_2D
case 0x8d66: // SAMPLER_EXTERNAL_OES
case 0x8dca: // INT_SAMPLER_2D
case 0x8dd2: // UNSIGNED_INT_SAMPLER_2D
case 0x8b62: // SAMPLER_2D_SHADOW
return setValueT1Array;
case 0x8b5f: // SAMPLER_3D
case 0x8dcb: // INT_SAMPLER_3D
case 0x8dd3: // UNSIGNED_INT_SAMPLER_3D
return setValueT3DArray;
case 0x8b60: // SAMPLER_CUBE
case 0x8dcc: // INT_SAMPLER_CUBE
case 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE
case 0x8dc5: // SAMPLER_CUBE_SHADOW
return setValueT6Array;
case 0x8dc1: // SAMPLER_2D_ARRAY
case 0x8dcf: // INT_SAMPLER_2D_ARRAY
case 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY
case 0x8dc4: // SAMPLER_2D_ARRAY_SHADOW
return setValueT2DArrayArray;
}
}
StructuredUniform.setValue(gl: any, value: any, textures: any): void
¶
Parameters:
gl
any
value
any
textures
any
Returns: void
Calls:
u.setValue
Code
addUniform(container: any, uniformObject: any): void
¶
Parameters:
container
any
uniformObject
any
Returns: void
Calls:
container.seq.push
Code
parseUniform(activeInfo: any, addr: any, container: any): void
¶
Parameters:
activeInfo
any
addr
any
container
any
Returns: void
Calls:
RePathPart.exec
addUniform
Internal Comments:
// reset RegExp object, because of the early exit of a previous run (x4)
// bare name or "pure" bottom-level array "[0]" suffix (x3)
// step into inner node / create it in case it doesn't exist (x2)
Code
function parseUniform( activeInfo, addr, container ) {
const path = activeInfo.name,
pathLength = path.length;
// reset RegExp object, because of the early exit of a previous run
RePathPart.lastIndex = 0;
while ( true ) {
const match = RePathPart.exec( path ),
matchEnd = RePathPart.lastIndex;
let id = match[ 1 ];
const idIsIndex = match[ 2 ] === ']',
subscript = match[ 3 ];
if ( idIsIndex ) id = id | 0; // convert to integer
if ( subscript === undefined || subscript === '[' && matchEnd + 2 === pathLength ) {
// bare name or "pure" bottom-level array "[0]" suffix
addUniform( container, subscript === undefined ?
new SingleUniform( id, activeInfo, addr ) :
new PureArrayUniform( id, activeInfo, addr ) );
break;
} else {
// step into inner node / create it in case it doesn't exist
const map = container.map;
let next = map[ id ];
if ( next === undefined ) {
next = new StructuredUniform( id );
addUniform( container, next );
}
container = next;
}
}
}
WebGLUniforms.setValue(gl: any, name: any, value: any, textures: any): void
¶
Parameters:
gl
any
name
any
value
any
textures
any
Returns: void
Calls:
u.setValue
Code
WebGLUniforms.setOptional(gl: any, object: any, name: any): void
¶
Parameters:
gl
any
object
any
name
any
Returns: void
Calls:
this.setValue
Code
WebGLUniforms.upload(gl: any, seq: any, values: any, textures: any): void
¶
Parameters:
gl
any
seq
any
values
any
textures
any
Returns: void
Calls:
u.setValue
Internal Comments:
Code
WebGLUniforms.seqWithValue(seq: any, values: any): any[]
¶
Parameters:
seq
any
values
any
Returns: any[]
Calls:
r.push
Code
Classes¶
SingleUniform
¶
Class Code
PureArrayUniform
¶
Class Code
StructuredUniform
¶
Class Code
Methods¶
setValue(gl: any, value: any, textures: any): void
¶
Code
WebGLUniforms
¶
Class Code
class WebGLUniforms {
constructor( gl, program ) {
this.seq = [];
this.map = {};
const n = gl.getProgramParameter( program, gl.ACTIVE_UNIFORMS );
for ( let i = 0; i < n; ++ i ) {
const info = gl.getActiveUniform( program, i ),
addr = gl.getUniformLocation( program, info.name );
parseUniform( info, addr, this );
}
}
setValue( gl, name, value, textures ) {
const u = this.map[ name ];
if ( u !== undefined ) u.setValue( gl, value, textures );
}
setOptional( gl, object, name ) {
const v = object[ name ];
if ( v !== undefined ) this.setValue( gl, name, v );
}
static upload( gl, seq, values, textures ) {
for ( let i = 0, n = seq.length; i !== n; ++ i ) {
const u = seq[ i ],
v = values[ u.id ];
if ( v.needsUpdate !== false ) {
// note: always updating when .needsUpdate is undefined
u.setValue( gl, v.value, textures );
}
}
}
static seqWithValue( seq, values ) {
const r = [];
for ( let i = 0, n = seq.length; i !== n; ++ i ) {
const u = seq[ i ];
if ( u.id in values ) r.push( u );
}
return r;
}
}