Newer
Older
17001
17002
17003
17004
17005
17006
17007
17008
17009
17010
17011
17012
17013
17014
17015
17016
17017
17018
17019
17020
17021
17022
17023
17024
17025
17026
17027
17028
17029
17030
17031
17032
17033
17034
17035
17036
17037
17038
17039
17040
17041
17042
17043
17044
17045
17046
17047
17048
17049
17050
17051
17052
17053
17054
17055
17056
17057
17058
17059
17060
17061
17062
17063
17064
17065
17066
17067
17068
17069
17070
17071
17072
17073
17074
17075
17076
17077
17078
17079
17080
17081
17082
17083
17084
17085
17086
17087
17088
17089
17090
17091
17092
17093
17094
17095
17096
17097
17098
17099
17100
17101
17102
17103
17104
17105
17106
17107
17108
17109
17110
17111
17112
17113
17114
17115
17116
17117
17118
17119
17120
17121
17122
17123
17124
17125
17126
17127
17128
17129
17130
17131
17132
17133
17134
17135
17136
17137
17138
17139
17140
17141
17142
17143
17144
17145
17146
17147
17148
17149
17150
17151
17152
17153
17154
17155
17156
17157
17158
17159
17160
17161
17162
17163
17164
17165
17166
17167
17168
17169
17170
17171
17172
17173
17174
17175
17176
17177
17178
17179
17180
17181
17182
17183
17184
17185
17186
17187
17188
17189
17190
17191
17192
17193
17194
17195
17196
17197
17198
17199
17200
17201
17202
17203
17204
17205
17206
17207
17208
17209
17210
17211
17212
17213
17214
17215
17216
17217
17218
17219
17220
17221
17222
17223
17224
17225
17226
17227
17228
17229
17230
17231
17232
17233
17234
17235
17236
17237
17238
17239
17240
17241
17242
17243
17244
17245
17246
17247
17248
17249
17250
17251
17252
17253
17254
17255
17256
17257
17258
17259
17260
17261
17262
17263
17264
17265
17266
17267
17268
17269
17270
17271
17272
17273
17274
17275
17276
17277
17278
17279
17280
17281
17282
17283
17284
17285
17286
17287
17288
17289
17290
17291
17292
17293
17294
17295
17296
17297
17298
17299
17300
17301
17302
17303
17304
17305
17306
17307
17308
17309
17310
17311
17312
17313
17314
17315
17316
17317
17318
17319
17320
17321
17322
17323
17324
17325
17326
17327
17328
17329
17330
17331
17332
17333
17334
17335
17336
17337
17338
17339
17340
17341
17342
17343
17344
17345
17346
17347
17348
17349
17350
17351
17352
17353
17354
17355
17356
17357
17358
17359
17360
17361
17362
17363
17364
17365
17366
17367
17368
17369
17370
17371
17372
17373
17374
17375
17376
17377
17378
17379
17380
17381
17382
17383
17384
17385
17386
17387
17388
17389
17390
17391
17392
17393
17394
17395
17396
17397
17398
17399
17400
17401
17402
17403
17404
17405
17406
17407
17408
17409
17410
17411
17412
17413
17414
17415
17416
17417
17418
17419
17420
17421
17422
17423
17424
17425
17426
17427
17428
17429
17430
17431
17432
17433
17434
17435
17436
17437
17438
17439
17440
17441
17442
17443
17444
17445
17446
17447
17448
17449
17450
17451
17452
17453
17454
17455
17456
17457
17458
17459
17460
17461
17462
17463
17464
17465
17466
17467
17468
17469
17470
17471
17472
17473
17474
17475
17476
17477
17478
17479
17480
17481
17482
17483
17484
17485
17486
17487
17488
17489
17490
17491
17492
17493
17494
17495
17496
17497
17498
17499
17500
17501
17502
17503
17504
17505
17506
17507
17508
17509
17510
17511
17512
17513
17514
17515
17516
17517
17518
17519
17520
17521
17522
17523
17524
17525
17526
17527
17528
17529
17530
17531
17532
17533
17534
17535
17536
17537
17538
17539
17540
17541
17542
17543
17544
17545
17546
17547
17548
17549
17550
17551
17552
17553
17554
17555
17556
17557
17558
17559
17560
17561
17562
17563
17564
17565
17566
17567
17568
17569
17570
17571
17572
17573
17574
17575
17576
17577
17578
17579
17580
17581
17582
17583
17584
17585
17586
17587
17588
17589
17590
17591
17592
17593
17594
17595
17596
17597
17598
17599
17600
17601
17602
17603
17604
17605
17606
17607
17608
17609
17610
17611
17612
17613
17614
17615
17616
17617
17618
17619
17620
17621
17622
17623
17624
17625
17626
17627
17628
17629
17630
17631
17632
17633
17634
17635
17636
17637
17638
17639
17640
17641
17642
17643
17644
17645
17646
17647
17648
17649
17650
17651
17652
17653
17654
17655
17656
17657
17658
17659
17660
17661
17662
17663
17664
17665
17666
17667
17668
17669
17670
17671
17672
17673
17674
17675
17676
17677
17678
17679
17680
17681
17682
17683
17684
17685
17686
17687
17688
17689
17690
17691
17692
17693
17694
17695
17696
17697
17698
17699
17700
17701
17702
17703
17704
17705
17706
17707
17708
17709
17710
17711
17712
17713
17714
17715
17716
17717
17718
17719
17720
17721
17722
17723
17724
17725
17726
17727
17728
17729
17730
17731
17732
17733
17734
17735
17736
17737
17738
17739
17740
17741
17742
17743
17744
17745
17746
17747
17748
17749
17750
17751
17752
17753
17754
17755
17756
17757
17758
17759
17760
17761
17762
17763
17764
17765
17766
17767
17768
17769
17770
17771
17772
17773
17774
17775
17776
17777
17778
17779
17780
17781
17782
17783
17784
17785
17786
17787
17788
17789
17790
17791
17792
17793
17794
17795
17796
17797
17798
17799
17800
17801
17802
17803
17804
17805
17806
17807
17808
17809
17810
17811
17812
17813
17814
17815
17816
17817
17818
17819
17820
17821
17822
17823
17824
17825
17826
17827
17828
17829
17830
17831
17832
17833
17834
17835
17836
17837
17838
17839
17840
17841
17842
17843
17844
17845
17846
17847
17848
17849
17850
17851
17852
17853
17854
17855
17856
17857
17858
17859
17860
17861
17862
17863
17864
17865
17866
17867
17868
17869
17870
17871
17872
17873
17874
17875
17876
17877
17878
17879
17880
17881
17882
17883
17884
17885
17886
17887
17888
17889
17890
17891
17892
17893
17894
17895
17896
17897
17898
17899
17900
17901
17902
17903
17904
17905
17906
17907
17908
17909
17910
17911
17912
17913
17914
17915
17916
17917
17918
17919
17920
17921
17922
17923
17924
17925
17926
17927
17928
17929
17930
17931
17932
17933
17934
17935
17936
17937
17938
17939
17940
17941
17942
17943
17944
17945
17946
17947
17948
17949
17950
17951
17952
17953
17954
17955
17956
17957
17958
17959
17960
17961
17962
17963
17964
17965
17966
17967
17968
17969
17970
17971
17972
17973
17974
17975
17976
17977
17978
17979
17980
17981
17982
17983
17984
17985
17986
17987
17988
17989
17990
17991
17992
17993
17994
17995
17996
17997
17998
17999
18000
updateWireframeAttribute( geometry );
}
return wireframeAttributes.get( geometry );
}
return {
get: get,
update: update,
getWireframeAttribute: getWireframeAttribute
};
}
/**
* @author mrdoob / http://mrdoob.com/
*/
function WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) {
const isWebGL2 = capabilities.isWebGL2;
let mode;
function setMode( value ) {
mode = value;
}
let type, bytesPerElement;
function setIndex( value ) {
type = value.type;
bytesPerElement = value.bytesPerElement;
}
function render( start, count ) {
gl.drawElements( mode, count, type, start * bytesPerElement );
info.update( count, mode );
}
function renderInstances( geometry, start, count, primcount ) {
if ( primcount === 0 ) return;
let extension, methodName;
if ( isWebGL2 ) {
extension = gl;
methodName = 'drawElementsInstanced';
} else {
extension = extensions.get( 'ANGLE_instanced_arrays' );
methodName = 'drawElementsInstancedANGLE';
if ( extension === null ) {
console.error( 'THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );
return;
}
}
extension[ methodName ]( mode, count, type, start * bytesPerElement, primcount );
info.update( count, mode, primcount );
}
//
this.setMode = setMode;
this.setIndex = setIndex;
this.render = render;
this.renderInstances = renderInstances;
}
/**
* @author Mugen87 / https://github.com/Mugen87
*/
function WebGLInfo( gl ) {
const memory = {
geometries: 0,
textures: 0
};
const render = {
frame: 0,
calls: 0,
triangles: 0,
points: 0,
lines: 0
};
function update( count, mode, instanceCount ) {
instanceCount = instanceCount || 1;
render.calls ++;
switch ( mode ) {
case 4:
render.triangles += instanceCount * ( count / 3 );
break;
case 1:
render.lines += instanceCount * ( count / 2 );
break;
case 3:
render.lines += instanceCount * ( count - 1 );
break;
case 2:
render.lines += instanceCount * count;
break;
case 0:
render.points += instanceCount * count;
break;
default:
console.error( 'THREE.WebGLInfo: Unknown draw mode:', mode );
break;
}
}
function reset() {
render.frame ++;
render.calls = 0;
render.triangles = 0;
render.points = 0;
render.lines = 0;
}
return {
memory: memory,
render: render,
programs: null,
autoReset: true,
reset: reset,
update: update
};
}
/**
* @author mrdoob / http://mrdoob.com/
*/
function numericalSort( a, b ) {
return a[ 0 ] - b[ 0 ];
}
function absNumericalSort( a, b ) {
return Math.abs( b[ 1 ] ) - Math.abs( a[ 1 ] );
}
function WebGLMorphtargets( gl ) {
const influencesList = {};
const morphInfluences = new Float32Array( 8 );
const workInfluences = [];
for ( let i = 0; i < 8; i ++ ) {
workInfluences[ i ] = [ i, 0 ];
}
function update( object, geometry, material, program ) {
const objectInfluences = object.morphTargetInfluences;
// When object doesn't have morph target influences defined, we treat it as a 0-length array
// This is important to make sure we set up morphTargetBaseInfluence / morphTargetInfluences
const length = objectInfluences === undefined ? 0 : objectInfluences.length;
let influences = influencesList[ geometry.id ];
if ( influences === undefined ) {
// initialise list
influences = [];
for ( let i = 0; i < length; i ++ ) {
influences[ i ] = [ i, 0 ];
}
influencesList[ geometry.id ] = influences;
}
// Collect influences
for ( let i = 0; i < length; i ++ ) {
const influence = influences[ i ];
influence[ 0 ] = i;
influence[ 1 ] = objectInfluences[ i ];
}
influences.sort( absNumericalSort );
for ( let i = 0; i < 8; i ++ ) {
if ( i < length && influences[ i ][ 1 ] ) {
workInfluences[ i ][ 0 ] = influences[ i ][ 0 ];
workInfluences[ i ][ 1 ] = influences[ i ][ 1 ];
} else {
workInfluences[ i ][ 0 ] = Number.MAX_SAFE_INTEGER;
workInfluences[ i ][ 1 ] = 0;
}
}
workInfluences.sort( numericalSort );
const morphTargets = material.morphTargets && geometry.morphAttributes.position;
const morphNormals = material.morphNormals && geometry.morphAttributes.normal;
let morphInfluencesSum = 0;
for ( let i = 0; i < 8; i ++ ) {
const influence = workInfluences[ i ];
const index = influence[ 0 ];
const value = influence[ 1 ];
if ( index !== Number.MAX_SAFE_INTEGER && value ) {
if ( morphTargets && geometry.getAttribute( 'morphTarget' + i ) !== morphTargets[ index ] ) {
geometry.setAttribute( 'morphTarget' + i, morphTargets[ index ] );
}
if ( morphNormals && geometry.getAttribute( 'morphNormal' + i ) !== morphNormals[ index ] ) {
geometry.setAttribute( 'morphNormal' + i, morphNormals[ index ] );
}
morphInfluences[ i ] = value;
morphInfluencesSum += value;
} else {
if ( morphTargets && geometry.getAttribute( 'morphTarget' + i ) !== undefined ) {
geometry.deleteAttribute( 'morphTarget' + i );
}
if ( morphNormals && geometry.getAttribute( 'morphNormal' + i ) !== undefined ) {
geometry.deleteAttribute( 'morphNormal' + i );
}
morphInfluences[ i ] = 0;
}
}
// GLSL shader uses formula baseinfluence * base + sum(target * influence)
// This allows us to switch between absolute morphs and relative morphs without changing shader code
// When baseinfluence = 1 - sum(influence), the above is equivalent to sum((target - base) * influence)
const morphBaseInfluence = geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum;
program.getUniforms().setValue( gl, 'morphTargetBaseInfluence', morphBaseInfluence );
program.getUniforms().setValue( gl, 'morphTargetInfluences', morphInfluences );
}
return {
update: update
};
}
/**
* @author mrdoob / http://mrdoob.com/
*/
function WebGLObjects( gl, geometries, attributes, info ) {
let updateMap = new WeakMap();
function update( object ) {
const frame = info.render.frame;
const geometry = object.geometry;
const buffergeometry = geometries.get( object, geometry );
// Update once per frame
if ( updateMap.get( buffergeometry ) !== frame ) {
if ( geometry.isGeometry ) {
buffergeometry.updateFromObject( object );
}
geometries.update( buffergeometry );
updateMap.set( buffergeometry, frame );
}
if ( object.isInstancedMesh ) {
attributes.update( object.instanceMatrix, 34962 );
}
return buffergeometry;
}
function dispose() {
updateMap = new WeakMap();
}
return {
update: update,
dispose: dispose
};
}
/**
* @author mrdoob / http://mrdoob.com/
*/
function CubeTexture( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) {
images = images !== undefined ? images : [];
mapping = mapping !== undefined ? mapping : CubeReflectionMapping;
format = format !== undefined ? format : RGBFormat;
Texture.call( this, images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );
this.flipY = false;
}
CubeTexture.prototype = Object.create( Texture.prototype );
CubeTexture.prototype.constructor = CubeTexture;
CubeTexture.prototype.isCubeTexture = true;
Object.defineProperty( CubeTexture.prototype, 'images', {
get: function () {
return this.image;
},
set: function ( value ) {
this.image = value;
}
} );
/**
* @author Takahiro https://github.com/takahirox
*/
function DataTexture2DArray( data, width, height, depth ) {
Texture.call( this, null );
this.image = { data: data || null, width: width || 1, height: height || 1, depth: depth || 1 };
this.magFilter = NearestFilter;
this.minFilter = NearestFilter;
this.wrapR = ClampToEdgeWrapping;
this.generateMipmaps = false;
this.flipY = false;
this.needsUpdate = true;
}
DataTexture2DArray.prototype = Object.create( Texture.prototype );
DataTexture2DArray.prototype.constructor = DataTexture2DArray;
DataTexture2DArray.prototype.isDataTexture2DArray = true;
/**
* @author Artur Trzesiok
*/
function DataTexture3D( data, width, height, depth ) {
// We're going to add .setXXX() methods for setting properties later.
// Users can still set in DataTexture3D directly.
//
// const texture = new THREE.DataTexture3D( data, width, height, depth );
// texture.anisotropy = 16;
//
// See #14839
Texture.call( this, null );
this.image = { data: data || null, width: width || 1, height: height || 1, depth: depth || 1 };
this.magFilter = NearestFilter;
this.minFilter = NearestFilter;
this.wrapR = ClampToEdgeWrapping;
this.generateMipmaps = false;
this.flipY = false;
this.needsUpdate = true;
}
DataTexture3D.prototype = Object.create( Texture.prototype );
DataTexture3D.prototype.constructor = DataTexture3D;
DataTexture3D.prototype.isDataTexture3D = true;
/**
* @author tschw
* @author Mugen87 / https://github.com/Mugen87
* @author mrdoob / http://mrdoob.com/
*
* Uniforms of a program.
* Those form a tree structure with a special top-level container for the root,
* which you get by calling 'new WebGLUniforms( gl, program )'.
*
*
* Properties of inner nodes including the top-level container:
*
* .seq - array of nested uniforms
* .map - nested uniforms by name
*
*
* Methods of all nodes except the top-level container:
*
* .setValue( gl, value, [textures] )
*
* uploads a uniform value(s)
* the 'textures' parameter is needed for sampler uniforms
*
*
* Static methods of the top-level container (textures factorizations):
*
* .upload( gl, seq, values, textures )
*
* sets uniforms in 'seq' to 'values[id].value'
*
* .seqWithValue( seq, values ) : filteredSeq
*
* filters 'seq' entries with corresponding entry in values
*
*
* Methods of the top-level container (textures factorizations):
*
* .setValue( gl, name, value, textures )
*
* sets uniform with name 'name' to 'value'
*
* .setOptional( gl, obj, prop )
*
* like .set for an optional property of the object
*
*/
const emptyTexture = new Texture();
const emptyTexture2dArray = new DataTexture2DArray();
const emptyTexture3d = new DataTexture3D();
const emptyCubeTexture = new CubeTexture();
// --- Utilities ---
// Array Caches (provide typed arrays for temporary by size)
const arrayCacheF32 = [];
const arrayCacheI32 = [];
// Float32Array caches used for uploading Matrix uniforms
const mat4array = new Float32Array( 16 );
const mat3array = new Float32Array( 9 );
const mat2array = new Float32Array( 4 );
// Flattening for arrays of vectors and matrices
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
let n = nBlocks * blockSize,
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;
}
function arraysEqual( a, b ) {
if ( a.length !== b.length ) return false;
for ( let i = 0, l = a.length; i < l; i ++ ) {
if ( a[ i ] !== b[ i ] ) return false;
}
return true;
}
function copyArray( a, b ) {
for ( let i = 0, l = b.length; i < l; i ++ ) {
a[ i ] = b[ i ];
}
}
// Texture unit allocation
function allocTexUnits( textures, n ) {
let r = arrayCacheI32[ n ];
if ( r === undefined ) {
r = new Int32Array( n );
arrayCacheI32[ n ] = r;
}
for ( let i = 0; i !== n; ++ i ) {
r[ i ] = textures.allocateTextureUnit();
}
return r;
}
// --- Setters ---
// Note: Defining these methods externally, because they come in a bunch
// and this way their names minify.
// Single scalar
function setValueV1f( gl, v ) {
const cache = this.cache;
if ( cache[ 0 ] === v ) return;
gl.uniform1f( this.addr, v );
cache[ 0 ] = v;
}
// Single float vector (from flat array or THREE.VectorN)
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 );
}
}
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 );
}
}
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 );
}
}
// Single matrix (from flat array or MatrixN)
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 );
}
}
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 );
}
}
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 );
}
}
// Single texture (2D / Cube)
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;
}
textures.safeSetTexture2D( v || emptyTexture, unit );
}
function setValueT2DArray1( gl, v, textures ) {
const cache = this.cache;
const unit = textures.allocateTextureUnit();
if ( cache[ 0 ] !== unit ) {
gl.uniform1i( this.addr, unit );
cache[ 0 ] = unit;
}
textures.setTexture2DArray( v || emptyTexture2dArray, unit );
}
function setValueT3D1( gl, v, textures ) {
const cache = this.cache;
const unit = textures.allocateTextureUnit();
if ( cache[ 0 ] !== unit ) {
gl.uniform1i( this.addr, unit );
cache[ 0 ] = unit;
}
textures.setTexture3D( v || emptyTexture3d, unit );
}
function setValueT6( gl, v, textures ) {
const cache = this.cache;
const unit = textures.allocateTextureUnit();
if ( cache[ 0 ] !== unit ) {
gl.uniform1i( this.addr, unit );
cache[ 0 ] = unit;
}
textures.safeSetTextureCube( v || emptyCubeTexture, unit );
}
// Integer / Boolean vectors or arrays thereof (always flat arrays)
function setValueV1i( gl, v ) {
const cache = this.cache;
if ( cache[ 0 ] === v ) return;
gl.uniform1i( this.addr, v );
cache[ 0 ] = v;
}
function setValueV2i( gl, v ) {
const cache = this.cache;
if ( arraysEqual( cache, v ) ) return;
gl.uniform2iv( this.addr, v );
copyArray( cache, v );
}
function setValueV3i( gl, v ) {
const cache = this.cache;
if ( arraysEqual( cache, v ) ) return;
gl.uniform3iv( this.addr, v );
copyArray( cache, v );
}
function setValueV4i( gl, v ) {
const cache = this.cache;
if ( arraysEqual( cache, v ) ) return;
gl.uniform4iv( this.addr, v );
copyArray( cache, v );
}
// uint
function setValueV1ui( gl, v ) {
const cache = this.cache;
if ( cache[ 0 ] === v ) return;
gl.uniform1ui( this.addr, v );
cache[ 0 ] = v;
}
// Helper to pick the right setter for the singular case
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 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;