copper3d 2.0.7 → 2.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,7 @@
13
13
  * Copyright 2010-2023 Three.js Authors
14
14
  * SPDX-License-Identifier: MIT
15
15
  */
16
- const REVISION$1 = '158';
16
+ const REVISION$1 = '161';
17
17
 
18
18
  const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
19
19
  const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
@@ -69,6 +69,7 @@
69
69
  const CineonToneMapping = 3;
70
70
  const ACESFilmicToneMapping = 4;
71
71
  const CustomToneMapping = 5;
72
+ const AgXToneMapping = 6;
72
73
  const AttachedBindMode = 'attached';
73
74
  const DetachedBindMode = 'detached';
74
75
 
@@ -1585,22 +1586,6 @@
1585
1586
 
1586
1587
  _workingColorSpace: LinearSRGBColorSpace,
1587
1588
 
1588
- get legacyMode() {
1589
-
1590
- console.warn( 'THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150.' );
1591
-
1592
- return ! this.enabled;
1593
-
1594
- },
1595
-
1596
- set legacyMode( legacyMode ) {
1597
-
1598
- console.warn( 'THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150.' );
1599
-
1600
- this.enabled = ! legacyMode;
1601
-
1602
- },
1603
-
1604
1589
  get workingColorSpace() {
1605
1590
 
1606
1591
  return this._workingColorSpace;
@@ -1813,6 +1798,7 @@
1813
1798
  this.uuid = generateUUID();
1814
1799
 
1815
1800
  this.data = data;
1801
+ this.dataReady = true;
1816
1802
 
1817
1803
  this.version = 0;
1818
1804
 
@@ -3269,7 +3255,7 @@
3269
3255
 
3270
3256
  }
3271
3257
 
3272
- setFromEuler( euler, update ) {
3258
+ setFromEuler( euler, update = true ) {
3273
3259
 
3274
3260
  const x = euler._x, y = euler._y, z = euler._z, order = euler._order;
3275
3261
 
@@ -3337,7 +3323,7 @@
3337
3323
 
3338
3324
  }
3339
3325
 
3340
- if ( update !== false ) this._onChangeCallback();
3326
+ if ( update === true ) this._onChangeCallback();
3341
3327
 
3342
3328
  return this;
3343
3329
 
@@ -3632,8 +3618,7 @@
3632
3618
  this._y = s * y + t * this._y;
3633
3619
  this._z = s * z + t * this._z;
3634
3620
 
3635
- this.normalize();
3636
- this._onChangeCallback();
3621
+ this.normalize(); // normalize calls _onChangeCallback()
3637
3622
 
3638
3623
  return this;
3639
3624
 
@@ -3721,6 +3706,8 @@
3721
3706
  this._z = attribute.getZ( index );
3722
3707
  this._w = attribute.getW( index );
3723
3708
 
3709
+ this._onChangeCallback();
3710
+
3724
3711
  return this;
3725
3712
 
3726
3713
  }
@@ -4256,9 +4243,9 @@
4256
4243
 
4257
4244
  projectOnPlane( planeNormal ) {
4258
4245
 
4259
- _vector$b.copy( this ).projectOnVector( planeNormal );
4246
+ _vector$c.copy( this ).projectOnVector( planeNormal );
4260
4247
 
4261
- return this.sub( _vector$b );
4248
+ return this.sub( _vector$c );
4262
4249
 
4263
4250
  }
4264
4251
 
@@ -4267,7 +4254,7 @@
4267
4254
  // reflect incident vector off plane orthogonal to normal
4268
4255
  // normal is assumed to have unit length
4269
4256
 
4270
- return this.sub( _vector$b.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
4257
+ return this.sub( _vector$c.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
4271
4258
 
4272
4259
  }
4273
4260
 
@@ -4469,7 +4456,7 @@
4469
4456
 
4470
4457
  }
4471
4458
 
4472
- const _vector$b = /*@__PURE__*/ new Vector3();
4459
+ const _vector$c = /*@__PURE__*/ new Vector3();
4473
4460
  const _quaternion$4 = /*@__PURE__*/ new Quaternion();
4474
4461
 
4475
4462
  class Box3 {
@@ -4498,7 +4485,7 @@
4498
4485
 
4499
4486
  for ( let i = 0, il = array.length; i < il; i += 3 ) {
4500
4487
 
4501
- this.expandByPoint( _vector$a.fromArray( array, i ) );
4488
+ this.expandByPoint( _vector$b.fromArray( array, i ) );
4502
4489
 
4503
4490
  }
4504
4491
 
@@ -4512,7 +4499,7 @@
4512
4499
 
4513
4500
  for ( let i = 0, il = attribute.count; i < il; i ++ ) {
4514
4501
 
4515
- this.expandByPoint( _vector$a.fromBufferAttribute( attribute, i ) );
4502
+ this.expandByPoint( _vector$b.fromBufferAttribute( attribute, i ) );
4516
4503
 
4517
4504
  }
4518
4505
 
@@ -4536,7 +4523,7 @@
4536
4523
 
4537
4524
  setFromCenterAndSize( center, size ) {
4538
4525
 
4539
- const halfSize = _vector$a.copy( size ).multiplyScalar( 0.5 );
4526
+ const halfSize = _vector$b.copy( size ).multiplyScalar( 0.5 );
4540
4527
 
4541
4528
  this.min.copy( center ).sub( halfSize );
4542
4529
  this.max.copy( center ).add( halfSize );
@@ -4646,16 +4633,16 @@
4646
4633
 
4647
4634
  if ( object.isMesh === true ) {
4648
4635
 
4649
- object.getVertexPosition( i, _vector$a );
4636
+ object.getVertexPosition( i, _vector$b );
4650
4637
 
4651
4638
  } else {
4652
4639
 
4653
- _vector$a.fromBufferAttribute( positionAttribute, i );
4640
+ _vector$b.fromBufferAttribute( positionAttribute, i );
4654
4641
 
4655
4642
  }
4656
4643
 
4657
- _vector$a.applyMatrix4( object.matrixWorld );
4658
- this.expandByPoint( _vector$a );
4644
+ _vector$b.applyMatrix4( object.matrixWorld );
4645
+ this.expandByPoint( _vector$b );
4659
4646
 
4660
4647
  }
4661
4648
 
@@ -4671,7 +4658,7 @@
4671
4658
 
4672
4659
  }
4673
4660
 
4674
- _box$3.copy( object.boundingBox );
4661
+ _box$4.copy( object.boundingBox );
4675
4662
 
4676
4663
 
4677
4664
  } else {
@@ -4684,13 +4671,13 @@
4684
4671
 
4685
4672
  }
4686
4673
 
4687
- _box$3.copy( geometry.boundingBox );
4674
+ _box$4.copy( geometry.boundingBox );
4688
4675
 
4689
4676
  }
4690
4677
 
4691
- _box$3.applyMatrix4( object.matrixWorld );
4678
+ _box$4.applyMatrix4( object.matrixWorld );
4692
4679
 
4693
- this.union( _box$3 );
4680
+ this.union( _box$4 );
4694
4681
 
4695
4682
  }
4696
4683
 
@@ -4749,10 +4736,10 @@
4749
4736
  intersectsSphere( sphere ) {
4750
4737
 
4751
4738
  // Find the point on the AABB closest to the sphere center.
4752
- this.clampPoint( sphere.center, _vector$a );
4739
+ this.clampPoint( sphere.center, _vector$b );
4753
4740
 
4754
4741
  // If that point is inside the sphere, the AABB and sphere intersect.
4755
- return _vector$a.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius );
4742
+ return _vector$b.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius );
4756
4743
 
4757
4744
  }
4758
4745
 
@@ -4864,7 +4851,7 @@
4864
4851
 
4865
4852
  distanceToPoint( point ) {
4866
4853
 
4867
- return this.clampPoint( point, _vector$a ).distanceTo( point );
4854
+ return this.clampPoint( point, _vector$b ).distanceTo( point );
4868
4855
 
4869
4856
  }
4870
4857
 
@@ -4878,7 +4865,7 @@
4878
4865
 
4879
4866
  this.getCenter( target.center );
4880
4867
 
4881
- target.radius = this.getSize( _vector$a ).length() * 0.5;
4868
+ target.radius = this.getSize( _vector$b ).length() * 0.5;
4882
4869
 
4883
4870
  }
4884
4871
 
@@ -4956,9 +4943,9 @@
4956
4943
  /*@__PURE__*/ new Vector3()
4957
4944
  ];
4958
4945
 
4959
- const _vector$a = /*@__PURE__*/ new Vector3();
4946
+ const _vector$b = /*@__PURE__*/ new Vector3();
4960
4947
 
4961
- const _box$3 = /*@__PURE__*/ new Box3();
4948
+ const _box$4 = /*@__PURE__*/ new Box3();
4962
4949
 
4963
4950
  // triangle centered vertices
4964
4951
 
@@ -5003,7 +4990,7 @@
5003
4990
 
5004
4991
  }
5005
4992
 
5006
- const _box$2 = /*@__PURE__*/ new Box3();
4993
+ const _box$3 = /*@__PURE__*/ new Box3();
5007
4994
  const _v1$6 = /*@__PURE__*/ new Vector3();
5008
4995
  const _v2$3 = /*@__PURE__*/ new Vector3();
5009
4996
 
@@ -5011,6 +4998,8 @@
5011
4998
 
5012
4999
  constructor( center = new Vector3(), radius = - 1 ) {
5013
5000
 
5001
+ this.isSphere = true;
5002
+
5014
5003
  this.center = center;
5015
5004
  this.radius = radius;
5016
5005
 
@@ -5035,7 +5024,7 @@
5035
5024
 
5036
5025
  } else {
5037
5026
 
5038
- _box$2.setFromPoints( points ).getCenter( center );
5027
+ _box$3.setFromPoints( points ).getCenter( center );
5039
5028
 
5040
5029
  }
5041
5030
 
@@ -5242,7 +5231,7 @@
5242
5231
 
5243
5232
  }
5244
5233
 
5245
- const _vector$9 = /*@__PURE__*/ new Vector3();
5234
+ const _vector$a = /*@__PURE__*/ new Vector3();
5246
5235
  const _segCenter = /*@__PURE__*/ new Vector3();
5247
5236
  const _segDir = /*@__PURE__*/ new Vector3();
5248
5237
  const _diff = /*@__PURE__*/ new Vector3();
@@ -5294,7 +5283,7 @@
5294
5283
 
5295
5284
  recast( t ) {
5296
5285
 
5297
- this.origin.copy( this.at( t, _vector$9 ) );
5286
+ this.origin.copy( this.at( t, _vector$a ) );
5298
5287
 
5299
5288
  return this;
5300
5289
 
@@ -5324,7 +5313,7 @@
5324
5313
 
5325
5314
  distanceSqToPoint( point ) {
5326
5315
 
5327
- const directionDistance = _vector$9.subVectors( point, this.origin ).dot( this.direction );
5316
+ const directionDistance = _vector$a.subVectors( point, this.origin ).dot( this.direction );
5328
5317
 
5329
5318
  // point behind the ray
5330
5319
 
@@ -5334,9 +5323,9 @@
5334
5323
 
5335
5324
  }
5336
5325
 
5337
- _vector$9.copy( this.origin ).addScaledVector( this.direction, directionDistance );
5326
+ _vector$a.copy( this.origin ).addScaledVector( this.direction, directionDistance );
5338
5327
 
5339
- return _vector$9.distanceToSquared( point );
5328
+ return _vector$a.distanceToSquared( point );
5340
5329
 
5341
5330
  }
5342
5331
 
@@ -5461,9 +5450,9 @@
5461
5450
 
5462
5451
  intersectSphere( sphere, target ) {
5463
5452
 
5464
- _vector$9.subVectors( sphere.center, this.origin );
5465
- const tca = _vector$9.dot( this.direction );
5466
- const d2 = _vector$9.dot( _vector$9 ) - tca * tca;
5453
+ _vector$a.subVectors( sphere.center, this.origin );
5454
+ const tca = _vector$a.dot( this.direction );
5455
+ const d2 = _vector$a.dot( _vector$a ) - tca * tca;
5467
5456
  const radius2 = sphere.radius * sphere.radius;
5468
5457
 
5469
5458
  if ( d2 > radius2 ) return null;
@@ -5630,7 +5619,7 @@
5630
5619
 
5631
5620
  intersectsBox( box ) {
5632
5621
 
5633
- return this.intersectBox( box, _vector$9 ) !== null;
5622
+ return this.intersectBox( box, _vector$a ) !== null;
5634
5623
 
5635
5624
  }
5636
5625
 
@@ -6643,7 +6632,7 @@
6643
6632
  const _y = /*@__PURE__*/ new Vector3();
6644
6633
  const _z = /*@__PURE__*/ new Vector3();
6645
6634
 
6646
- const _matrix = /*@__PURE__*/ new Matrix4();
6635
+ const _matrix$1 = /*@__PURE__*/ new Matrix4();
6647
6636
  const _quaternion$3 = /*@__PURE__*/ new Quaternion();
6648
6637
 
6649
6638
  class Euler {
@@ -6878,9 +6867,9 @@
6878
6867
 
6879
6868
  setFromQuaternion( q, order, update ) {
6880
6869
 
6881
- _matrix.makeRotationFromQuaternion( q );
6870
+ _matrix$1.makeRotationFromQuaternion( q );
6882
6871
 
6883
- return this.setFromRotationMatrix( _matrix, order, update );
6872
+ return this.setFromRotationMatrix( _matrix$1, order, update );
6884
6873
 
6885
6874
  }
6886
6875
 
@@ -7102,9 +7091,9 @@
7102
7091
  this.matrixWorld = new Matrix4();
7103
7092
 
7104
7093
  this.matrixAutoUpdate = Object3D.DEFAULT_MATRIX_AUTO_UPDATE;
7105
- this.matrixWorldNeedsUpdate = false;
7106
7094
 
7107
7095
  this.matrixWorldAutoUpdate = Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE; // checked by the renderer
7096
+ this.matrixWorldNeedsUpdate = false;
7108
7097
 
7109
7098
  this.layers = new Layers();
7110
7099
  this.visible = true;
@@ -7121,6 +7110,10 @@
7121
7110
 
7122
7111
  }
7123
7112
 
7113
+ onBeforeShadow( /* renderer, object, camera, shadowCamera, geometry, depthMaterial, group */ ) {}
7114
+
7115
+ onAfterShadow( /* renderer, object, camera, shadowCamera, geometry, depthMaterial, group */ ) {}
7116
+
7124
7117
  onBeforeRender( /* renderer, scene, camera, geometry, material, group */ ) {}
7125
7118
 
7126
7119
  onAfterRender( /* renderer, scene, camera, geometry, material, group */ ) {}
@@ -7461,21 +7454,15 @@
7461
7454
 
7462
7455
  }
7463
7456
 
7464
- getObjectsByProperty( name, value ) {
7465
-
7466
- let result = [];
7457
+ getObjectsByProperty( name, value, result = [] ) {
7467
7458
 
7468
7459
  if ( this[ name ] === value ) result.push( this );
7469
7460
 
7470
- for ( let i = 0, l = this.children.length; i < l; i ++ ) {
7471
-
7472
- const childResult = this.children[ i ].getObjectsByProperty( name, value );
7461
+ const children = this.children;
7473
7462
 
7474
- if ( childResult.length > 0 ) {
7463
+ for ( let i = 0, l = children.length; i < l; i ++ ) {
7475
7464
 
7476
- result = result.concat( childResult );
7477
-
7478
- }
7465
+ children[ i ].getObjectsByProperty( name, value, result );
7479
7466
 
7480
7467
  }
7481
7468
 
@@ -7723,6 +7710,56 @@
7723
7710
 
7724
7711
  }
7725
7712
 
7713
+ if ( this.isBatchedMesh ) {
7714
+
7715
+ object.type = 'BatchedMesh';
7716
+ object.perObjectFrustumCulled = this.perObjectFrustumCulled;
7717
+ object.sortObjects = this.sortObjects;
7718
+
7719
+ object.drawRanges = this._drawRanges;
7720
+ object.reservedRanges = this._reservedRanges;
7721
+
7722
+ object.visibility = this._visibility;
7723
+ object.active = this._active;
7724
+ object.bounds = this._bounds.map( bound => ( {
7725
+ boxInitialized: bound.boxInitialized,
7726
+ boxMin: bound.box.min.toArray(),
7727
+ boxMax: bound.box.max.toArray(),
7728
+
7729
+ sphereInitialized: bound.sphereInitialized,
7730
+ sphereRadius: bound.sphere.radius,
7731
+ sphereCenter: bound.sphere.center.toArray()
7732
+ } ) );
7733
+
7734
+ object.maxGeometryCount = this._maxGeometryCount;
7735
+ object.maxVertexCount = this._maxVertexCount;
7736
+ object.maxIndexCount = this._maxIndexCount;
7737
+
7738
+ object.geometryInitialized = this._geometryInitialized;
7739
+ object.geometryCount = this._geometryCount;
7740
+
7741
+ object.matricesTexture = this._matricesTexture.toJSON( meta );
7742
+
7743
+ if ( this.boundingSphere !== null ) {
7744
+
7745
+ object.boundingSphere = {
7746
+ center: object.boundingSphere.center.toArray(),
7747
+ radius: object.boundingSphere.radius
7748
+ };
7749
+
7750
+ }
7751
+
7752
+ if ( this.boundingBox !== null ) {
7753
+
7754
+ object.boundingBox = {
7755
+ min: object.boundingBox.min.toArray(),
7756
+ max: object.boundingBox.max.toArray()
7757
+ };
7758
+
7759
+ }
7760
+
7761
+ }
7762
+
7726
7763
  //
7727
7764
 
7728
7765
  function serialize( library, element ) {
@@ -7923,9 +7960,9 @@
7923
7960
  this.matrixWorld.copy( source.matrixWorld );
7924
7961
 
7925
7962
  this.matrixAutoUpdate = source.matrixAutoUpdate;
7926
- this.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate;
7927
7963
 
7928
7964
  this.matrixWorldAutoUpdate = source.matrixWorldAutoUpdate;
7965
+ this.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate;
7929
7966
 
7930
7967
  this.layers.mask = source.layers.mask;
7931
7968
  this.visible = source.visible;
@@ -7964,7 +8001,7 @@
7964
8001
  const _v0$1 = /*@__PURE__*/ new Vector3();
7965
8002
  const _v1$3 = /*@__PURE__*/ new Vector3();
7966
8003
  const _v2$2 = /*@__PURE__*/ new Vector3();
7967
- const _v3$1 = /*@__PURE__*/ new Vector3();
8004
+ const _v3$2 = /*@__PURE__*/ new Vector3();
7968
8005
 
7969
8006
  const _vab = /*@__PURE__*/ new Vector3();
7970
8007
  const _vac = /*@__PURE__*/ new Vector3();
@@ -7973,8 +8010,6 @@
7973
8010
  const _vbp = /*@__PURE__*/ new Vector3();
7974
8011
  const _vcp = /*@__PURE__*/ new Vector3();
7975
8012
 
7976
- let warnedGetUV = false;
7977
-
7978
8013
  class Triangle {
7979
8014
 
7980
8015
  constructor( a = new Vector3(), b = new Vector3(), c = new Vector3() ) {
@@ -8021,9 +8056,8 @@
8021
8056
  // collinear or singular triangle
8022
8057
  if ( denom === 0 ) {
8023
8058
 
8024
- // arbitrary location outside of triangle?
8025
- // not sure if this is the best idea, maybe should be returning undefined
8026
- return target.set( - 2, - 1, - 1 );
8059
+ target.set( 0, 0, 0 );
8060
+ return null;
8027
8061
 
8028
8062
  }
8029
8063
 
@@ -8038,34 +8072,33 @@
8038
8072
 
8039
8073
  static containsPoint( point, a, b, c ) {
8040
8074
 
8041
- this.getBarycoord( point, a, b, c, _v3$1 );
8042
-
8043
- return ( _v3$1.x >= 0 ) && ( _v3$1.y >= 0 ) && ( ( _v3$1.x + _v3$1.y ) <= 1 );
8044
-
8045
- }
8046
-
8047
- static getUV( point, p1, p2, p3, uv1, uv2, uv3, target ) { // @deprecated, r151
8048
-
8049
- if ( warnedGetUV === false ) {
8075
+ // if the triangle is degenerate then we can't contain a point
8076
+ if ( this.getBarycoord( point, a, b, c, _v3$2 ) === null ) {
8050
8077
 
8051
- console.warn( 'THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation().' );
8052
-
8053
- warnedGetUV = true;
8078
+ return false;
8054
8079
 
8055
8080
  }
8056
8081
 
8057
- return this.getInterpolation( point, p1, p2, p3, uv1, uv2, uv3, target );
8082
+ return ( _v3$2.x >= 0 ) && ( _v3$2.y >= 0 ) && ( ( _v3$2.x + _v3$2.y ) <= 1 );
8058
8083
 
8059
8084
  }
8060
8085
 
8061
8086
  static getInterpolation( point, p1, p2, p3, v1, v2, v3, target ) {
8062
8087
 
8063
- this.getBarycoord( point, p1, p2, p3, _v3$1 );
8088
+ if ( this.getBarycoord( point, p1, p2, p3, _v3$2 ) === null ) {
8089
+
8090
+ target.x = 0;
8091
+ target.y = 0;
8092
+ if ( 'z' in target ) target.z = 0;
8093
+ if ( 'w' in target ) target.w = 0;
8094
+ return null;
8095
+
8096
+ }
8064
8097
 
8065
8098
  target.setScalar( 0 );
8066
- target.addScaledVector( v1, _v3$1.x );
8067
- target.addScaledVector( v2, _v3$1.y );
8068
- target.addScaledVector( v3, _v3$1.z );
8099
+ target.addScaledVector( v1, _v3$2.x );
8100
+ target.addScaledVector( v2, _v3$2.y );
8101
+ target.addScaledVector( v3, _v3$2.z );
8069
8102
 
8070
8103
  return target;
8071
8104
 
@@ -8160,20 +8193,6 @@
8160
8193
 
8161
8194
  }
8162
8195
 
8163
- getUV( point, uv1, uv2, uv3, target ) { // @deprecated, r151
8164
-
8165
- if ( warnedGetUV === false ) {
8166
-
8167
- console.warn( 'THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation().' );
8168
-
8169
- warnedGetUV = true;
8170
-
8171
- }
8172
-
8173
- return Triangle.getInterpolation( point, this.a, this.b, this.c, uv1, uv2, uv3, target );
8174
-
8175
- }
8176
-
8177
8196
  getInterpolation( point, v1, v2, v3, target ) {
8178
8197
 
8179
8198
  return Triangle.getInterpolation( point, this.a, this.b, this.c, v1, v2, v3, target );
@@ -9666,7 +9685,7 @@
9666
9685
  fromHalfFloat: fromHalfFloat,
9667
9686
  };
9668
9687
 
9669
- const _vector$8 = /*@__PURE__*/ new Vector3();
9688
+ const _vector$9 = /*@__PURE__*/ new Vector3();
9670
9689
  const _vector2$1 = /*@__PURE__*/ new Vector2();
9671
9690
 
9672
9691
  class BufferAttribute {
@@ -9689,7 +9708,8 @@
9689
9708
  this.normalized = normalized;
9690
9709
 
9691
9710
  this.usage = StaticDrawUsage;
9692
- this.updateRange = { offset: 0, count: - 1 };
9711
+ this._updateRange = { offset: 0, count: - 1 };
9712
+ this.updateRanges = [];
9693
9713
  this.gpuType = FloatType;
9694
9714
 
9695
9715
  this.version = 0;
@@ -9704,6 +9724,13 @@
9704
9724
 
9705
9725
  }
9706
9726
 
9727
+ get updateRange() {
9728
+
9729
+ warnOnce( 'THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead.' ); // @deprecated, r159
9730
+ return this._updateRange;
9731
+
9732
+ }
9733
+
9707
9734
  setUsage( value ) {
9708
9735
 
9709
9736
  this.usage = value;
@@ -9712,6 +9739,18 @@
9712
9739
 
9713
9740
  }
9714
9741
 
9742
+ addUpdateRange( start, count ) {
9743
+
9744
+ this.updateRanges.push( { start, count } );
9745
+
9746
+ }
9747
+
9748
+ clearUpdateRanges() {
9749
+
9750
+ this.updateRanges.length = 0;
9751
+
9752
+ }
9753
+
9715
9754
  copy( source ) {
9716
9755
 
9717
9756
  this.name = source.name;
@@ -9767,10 +9806,10 @@
9767
9806
 
9768
9807
  for ( let i = 0, l = this.count; i < l; i ++ ) {
9769
9808
 
9770
- _vector$8.fromBufferAttribute( this, i );
9771
- _vector$8.applyMatrix3( m );
9809
+ _vector$9.fromBufferAttribute( this, i );
9810
+ _vector$9.applyMatrix3( m );
9772
9811
 
9773
- this.setXYZ( i, _vector$8.x, _vector$8.y, _vector$8.z );
9812
+ this.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z );
9774
9813
 
9775
9814
  }
9776
9815
 
@@ -9784,11 +9823,11 @@
9784
9823
 
9785
9824
  for ( let i = 0, l = this.count; i < l; i ++ ) {
9786
9825
 
9787
- _vector$8.fromBufferAttribute( this, i );
9826
+ _vector$9.fromBufferAttribute( this, i );
9788
9827
 
9789
- _vector$8.applyMatrix4( m );
9828
+ _vector$9.applyMatrix4( m );
9790
9829
 
9791
- this.setXYZ( i, _vector$8.x, _vector$8.y, _vector$8.z );
9830
+ this.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z );
9792
9831
 
9793
9832
  }
9794
9833
 
@@ -9800,11 +9839,11 @@
9800
9839
 
9801
9840
  for ( let i = 0, l = this.count; i < l; i ++ ) {
9802
9841
 
9803
- _vector$8.fromBufferAttribute( this, i );
9842
+ _vector$9.fromBufferAttribute( this, i );
9804
9843
 
9805
- _vector$8.applyNormalMatrix( m );
9844
+ _vector$9.applyNormalMatrix( m );
9806
9845
 
9807
- this.setXYZ( i, _vector$8.x, _vector$8.y, _vector$8.z );
9846
+ this.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z );
9808
9847
 
9809
9848
  }
9810
9849
 
@@ -9816,11 +9855,11 @@
9816
9855
 
9817
9856
  for ( let i = 0, l = this.count; i < l; i ++ ) {
9818
9857
 
9819
- _vector$8.fromBufferAttribute( this, i );
9858
+ _vector$9.fromBufferAttribute( this, i );
9820
9859
 
9821
- _vector$8.transformDirection( m );
9860
+ _vector$9.transformDirection( m );
9822
9861
 
9823
- this.setXYZ( i, _vector$8.x, _vector$8.y, _vector$8.z );
9862
+ this.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z );
9824
9863
 
9825
9864
  }
9826
9865
 
@@ -10022,7 +10061,6 @@
10022
10061
 
10023
10062
  if ( this.name !== '' ) data.name = this.name;
10024
10063
  if ( this.usage !== StaticDrawUsage ) data.usage = this.usage;
10025
- if ( this.updateRange.offset !== 0 || this.updateRange.count !== - 1 ) data.updateRange = this.updateRange;
10026
10064
 
10027
10065
  return data;
10028
10066
 
@@ -10066,9 +10104,9 @@
10066
10104
  const _m1 = /*@__PURE__*/ new Matrix4();
10067
10105
  const _obj = /*@__PURE__*/ new Object3D();
10068
10106
  const _offset = /*@__PURE__*/ new Vector3();
10069
- const _box$1 = /*@__PURE__*/ new Box3();
10107
+ const _box$2 = /*@__PURE__*/ new Box3();
10070
10108
  const _boxMorphTargets = /*@__PURE__*/ new Box3();
10071
- const _vector$7 = /*@__PURE__*/ new Vector3();
10109
+ const _vector$8 = /*@__PURE__*/ new Vector3();
10072
10110
 
10073
10111
  class BufferGeometry extends EventDispatcher {
10074
10112
 
@@ -10373,20 +10411,20 @@
10373
10411
  for ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {
10374
10412
 
10375
10413
  const morphAttribute = morphAttributesPosition[ i ];
10376
- _box$1.setFromBufferAttribute( morphAttribute );
10414
+ _box$2.setFromBufferAttribute( morphAttribute );
10377
10415
 
10378
10416
  if ( this.morphTargetsRelative ) {
10379
10417
 
10380
- _vector$7.addVectors( this.boundingBox.min, _box$1.min );
10381
- this.boundingBox.expandByPoint( _vector$7 );
10418
+ _vector$8.addVectors( this.boundingBox.min, _box$2.min );
10419
+ this.boundingBox.expandByPoint( _vector$8 );
10382
10420
 
10383
- _vector$7.addVectors( this.boundingBox.max, _box$1.max );
10384
- this.boundingBox.expandByPoint( _vector$7 );
10421
+ _vector$8.addVectors( this.boundingBox.max, _box$2.max );
10422
+ this.boundingBox.expandByPoint( _vector$8 );
10385
10423
 
10386
10424
  } else {
10387
10425
 
10388
- this.boundingBox.expandByPoint( _box$1.min );
10389
- this.boundingBox.expandByPoint( _box$1.max );
10426
+ this.boundingBox.expandByPoint( _box$2.min );
10427
+ this.boundingBox.expandByPoint( _box$2.max );
10390
10428
 
10391
10429
  }
10392
10430
 
@@ -10435,7 +10473,7 @@
10435
10473
 
10436
10474
  const center = this.boundingSphere.center;
10437
10475
 
10438
- _box$1.setFromBufferAttribute( position );
10476
+ _box$2.setFromBufferAttribute( position );
10439
10477
 
10440
10478
  // process morph attributes if present
10441
10479
 
@@ -10448,16 +10486,16 @@
10448
10486
 
10449
10487
  if ( this.morphTargetsRelative ) {
10450
10488
 
10451
- _vector$7.addVectors( _box$1.min, _boxMorphTargets.min );
10452
- _box$1.expandByPoint( _vector$7 );
10489
+ _vector$8.addVectors( _box$2.min, _boxMorphTargets.min );
10490
+ _box$2.expandByPoint( _vector$8 );
10453
10491
 
10454
- _vector$7.addVectors( _box$1.max, _boxMorphTargets.max );
10455
- _box$1.expandByPoint( _vector$7 );
10492
+ _vector$8.addVectors( _box$2.max, _boxMorphTargets.max );
10493
+ _box$2.expandByPoint( _vector$8 );
10456
10494
 
10457
10495
  } else {
10458
10496
 
10459
- _box$1.expandByPoint( _boxMorphTargets.min );
10460
- _box$1.expandByPoint( _boxMorphTargets.max );
10497
+ _box$2.expandByPoint( _boxMorphTargets.min );
10498
+ _box$2.expandByPoint( _boxMorphTargets.max );
10461
10499
 
10462
10500
  }
10463
10501
 
@@ -10465,7 +10503,7 @@
10465
10503
 
10466
10504
  }
10467
10505
 
10468
- _box$1.getCenter( center );
10506
+ _box$2.getCenter( center );
10469
10507
 
10470
10508
  // second, try to find a boundingSphere with a radius smaller than the
10471
10509
  // boundingSphere of the boundingBox: sqrt(3) smaller in the best case
@@ -10474,9 +10512,9 @@
10474
10512
 
10475
10513
  for ( let i = 0, il = position.count; i < il; i ++ ) {
10476
10514
 
10477
- _vector$7.fromBufferAttribute( position, i );
10515
+ _vector$8.fromBufferAttribute( position, i );
10478
10516
 
10479
- maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$7 ) );
10517
+ maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$8 ) );
10480
10518
 
10481
10519
  }
10482
10520
 
@@ -10491,16 +10529,16 @@
10491
10529
 
10492
10530
  for ( let j = 0, jl = morphAttribute.count; j < jl; j ++ ) {
10493
10531
 
10494
- _vector$7.fromBufferAttribute( morphAttribute, j );
10532
+ _vector$8.fromBufferAttribute( morphAttribute, j );
10495
10533
 
10496
10534
  if ( morphTargetsRelative ) {
10497
10535
 
10498
10536
  _offset.fromBufferAttribute( position, j );
10499
- _vector$7.add( _offset );
10537
+ _vector$8.add( _offset );
10500
10538
 
10501
10539
  }
10502
10540
 
10503
- maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$7 ) );
10541
+ maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$8 ) );
10504
10542
 
10505
10543
  }
10506
10544
 
@@ -10783,11 +10821,11 @@
10783
10821
 
10784
10822
  for ( let i = 0, il = normals.count; i < il; i ++ ) {
10785
10823
 
10786
- _vector$7.fromBufferAttribute( normals, i );
10824
+ _vector$8.fromBufferAttribute( normals, i );
10787
10825
 
10788
- _vector$7.normalize();
10826
+ _vector$8.normalize();
10789
10827
 
10790
- normals.setXYZ( i, _vector$7.x, _vector$7.y, _vector$7.z );
10828
+ normals.setXYZ( i, _vector$8.x, _vector$8.y, _vector$8.z );
10791
10829
 
10792
10830
  }
10793
10831
 
@@ -11129,7 +11167,7 @@
11129
11167
 
11130
11168
  const _inverseMatrix$3 = /*@__PURE__*/ new Matrix4();
11131
11169
  const _ray$3 = /*@__PURE__*/ new Ray();
11132
- const _sphere$5 = /*@__PURE__*/ new Sphere();
11170
+ const _sphere$6 = /*@__PURE__*/ new Sphere();
11133
11171
  const _sphereHitAt = /*@__PURE__*/ new Vector3();
11134
11172
 
11135
11173
  const _vA$1 = /*@__PURE__*/ new Vector3();
@@ -11277,16 +11315,16 @@
11277
11315
 
11278
11316
  if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
11279
11317
 
11280
- _sphere$5.copy( geometry.boundingSphere );
11281
- _sphere$5.applyMatrix4( matrixWorld );
11318
+ _sphere$6.copy( geometry.boundingSphere );
11319
+ _sphere$6.applyMatrix4( matrixWorld );
11282
11320
 
11283
11321
  // check distance from ray origin to bounding sphere
11284
11322
 
11285
11323
  _ray$3.copy( raycaster.ray ).recast( raycaster.near );
11286
11324
 
11287
- if ( _sphere$5.containsPoint( _ray$3.origin ) === false ) {
11325
+ if ( _sphere$6.containsPoint( _ray$3.origin ) === false ) {
11288
11326
 
11289
- if ( _ray$3.intersectSphere( _sphere$5, _sphereHitAt ) === null ) return;
11327
+ if ( _ray$3.intersectSphere( _sphere$6, _sphereHitAt ) === null ) return;
11290
11328
 
11291
11329
  if ( _ray$3.origin.distanceToSquared( _sphereHitAt ) > ( raycaster.far - raycaster.near ) ** 2 ) return;
11292
11330
 
@@ -11856,7 +11894,9 @@
11856
11894
  derivatives: false, // set to use derivatives
11857
11895
  fragDepth: false, // set to use fragment depth values
11858
11896
  drawBuffers: false, // set to use draw buffers
11859
- shaderTextureLOD: false // set to use shader texture LOD
11897
+ shaderTextureLOD: false, // set to use shader texture LOD
11898
+ clipCullDistance: false, // set to use vertex shader clipping
11899
+ multiDraw: false // set to use vertex shader multi_draw / enable gl_DrawID
11860
11900
  };
11861
11901
 
11862
11902
  // When rendered geometry doesn't include these attributes but the material does,
@@ -12068,6 +12108,11 @@
12068
12108
 
12069
12109
  }
12070
12110
 
12111
+ const _v3$1 = /*@__PURE__*/ new Vector3();
12112
+ const _minTarget = /*@__PURE__*/ new Vector2();
12113
+ const _maxTarget = /*@__PURE__*/ new Vector2();
12114
+
12115
+
12071
12116
  class PerspectiveCamera extends Camera {
12072
12117
 
12073
12118
  constructor( fov = 50, aspect = 1, near = 0.1, far = 2000 ) {
@@ -12166,6 +12211,34 @@
12166
12211
 
12167
12212
  }
12168
12213
 
12214
+ /**
12215
+ * Computes the 2D bounds of the camera's viewable rectangle at a given distance along the viewing direction.
12216
+ * Sets minTarget and maxTarget to the coordinates of the lower-left and upper-right corners of the view rectangle.
12217
+ */
12218
+ getViewBounds( distance, minTarget, maxTarget ) {
12219
+
12220
+ _v3$1.set( - 1, - 1, 0.5 ).applyMatrix4( this.projectionMatrixInverse );
12221
+
12222
+ minTarget.set( _v3$1.x, _v3$1.y ).multiplyScalar( - distance / _v3$1.z );
12223
+
12224
+ _v3$1.set( 1, 1, 0.5 ).applyMatrix4( this.projectionMatrixInverse );
12225
+
12226
+ maxTarget.set( _v3$1.x, _v3$1.y ).multiplyScalar( - distance / _v3$1.z );
12227
+
12228
+ }
12229
+
12230
+ /**
12231
+ * Computes the width and height of the camera's viewable rectangle at a given distance along the viewing direction.
12232
+ * Copies the result into the target Vector2, where x is width and y is height.
12233
+ */
12234
+ getViewSize( distance, target ) {
12235
+
12236
+ this.getViewBounds( distance, _minTarget, _maxTarget );
12237
+
12238
+ return target.subVectors( _maxTarget, _minTarget );
12239
+
12240
+ }
12241
+
12169
12242
  /**
12170
12243
  * Sets an offset in a larger frustum. This is useful for multi-window or
12171
12244
  * multi-monitor/multi-machine setups.
@@ -12839,8 +12912,8 @@
12839
12912
 
12840
12913
  }
12841
12914
 
12842
- const _sphere$4 = /*@__PURE__*/ new Sphere();
12843
- const _vector$6 = /*@__PURE__*/ new Vector3();
12915
+ const _sphere$5 = /*@__PURE__*/ new Sphere();
12916
+ const _vector$7 = /*@__PURE__*/ new Vector3();
12844
12917
 
12845
12918
  class Frustum {
12846
12919
 
@@ -12918,7 +12991,7 @@
12918
12991
 
12919
12992
  if ( object.boundingSphere === null ) object.computeBoundingSphere();
12920
12993
 
12921
- _sphere$4.copy( object.boundingSphere ).applyMatrix4( object.matrixWorld );
12994
+ _sphere$5.copy( object.boundingSphere ).applyMatrix4( object.matrixWorld );
12922
12995
 
12923
12996
  } else {
12924
12997
 
@@ -12926,21 +12999,21 @@
12926
12999
 
12927
13000
  if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
12928
13001
 
12929
- _sphere$4.copy( geometry.boundingSphere ).applyMatrix4( object.matrixWorld );
13002
+ _sphere$5.copy( geometry.boundingSphere ).applyMatrix4( object.matrixWorld );
12930
13003
 
12931
13004
  }
12932
13005
 
12933
- return this.intersectsSphere( _sphere$4 );
13006
+ return this.intersectsSphere( _sphere$5 );
12934
13007
 
12935
13008
  }
12936
13009
 
12937
13010
  intersectsSprite( sprite ) {
12938
13011
 
12939
- _sphere$4.center.set( 0, 0, 0 );
12940
- _sphere$4.radius = 0.7071067811865476;
12941
- _sphere$4.applyMatrix4( sprite.matrixWorld );
13012
+ _sphere$5.center.set( 0, 0, 0 );
13013
+ _sphere$5.radius = 0.7071067811865476;
13014
+ _sphere$5.applyMatrix4( sprite.matrixWorld );
12942
13015
 
12943
- return this.intersectsSphere( _sphere$4 );
13016
+ return this.intersectsSphere( _sphere$5 );
12944
13017
 
12945
13018
  }
12946
13019
 
@@ -12976,11 +13049,11 @@
12976
13049
 
12977
13050
  // corner at max distance
12978
13051
 
12979
- _vector$6.x = plane.normal.x > 0 ? box.max.x : box.min.x;
12980
- _vector$6.y = plane.normal.y > 0 ? box.max.y : box.min.y;
12981
- _vector$6.z = plane.normal.z > 0 ? box.max.z : box.min.z;
13052
+ _vector$7.x = plane.normal.x > 0 ? box.max.x : box.min.x;
13053
+ _vector$7.y = plane.normal.y > 0 ? box.max.y : box.min.y;
13054
+ _vector$7.z = plane.normal.z > 0 ? box.max.z : box.min.z;
12982
13055
 
12983
- if ( plane.distanceToPoint( _vector$6 ) < 0 ) {
13056
+ if ( plane.distanceToPoint( _vector$7 ) < 0 ) {
12984
13057
 
12985
13058
  return false;
12986
13059
 
@@ -13080,6 +13153,7 @@
13080
13153
 
13081
13154
  const array = attribute.array;
13082
13155
  const usage = attribute.usage;
13156
+ const size = array.byteLength;
13083
13157
 
13084
13158
  const buffer = gl.createBuffer();
13085
13159
 
@@ -13148,7 +13222,8 @@
13148
13222
  buffer: buffer,
13149
13223
  type: type,
13150
13224
  bytesPerElement: array.BYTES_PER_ELEMENT,
13151
- version: attribute.version
13225
+ version: attribute.version,
13226
+ size: size
13152
13227
  };
13153
13228
 
13154
13229
  }
@@ -13156,17 +13231,43 @@
13156
13231
  function updateBuffer( buffer, attribute, bufferType ) {
13157
13232
 
13158
13233
  const array = attribute.array;
13159
- const updateRange = attribute.updateRange;
13234
+ const updateRange = attribute._updateRange; // @deprecated, r159
13235
+ const updateRanges = attribute.updateRanges;
13160
13236
 
13161
13237
  gl.bindBuffer( bufferType, buffer );
13162
13238
 
13163
- if ( updateRange.count === - 1 ) {
13239
+ if ( updateRange.count === - 1 && updateRanges.length === 0 ) {
13164
13240
 
13165
13241
  // Not using update ranges
13166
-
13167
13242
  gl.bufferSubData( bufferType, 0, array );
13168
13243
 
13169
- } else {
13244
+ }
13245
+
13246
+ if ( updateRanges.length !== 0 ) {
13247
+
13248
+ for ( let i = 0, l = updateRanges.length; i < l; i ++ ) {
13249
+
13250
+ const range = updateRanges[ i ];
13251
+ if ( isWebGL2 ) {
13252
+
13253
+ gl.bufferSubData( bufferType, range.start * array.BYTES_PER_ELEMENT,
13254
+ array, range.start, range.count );
13255
+
13256
+ } else {
13257
+
13258
+ gl.bufferSubData( bufferType, range.start * array.BYTES_PER_ELEMENT,
13259
+ array.subarray( range.start, range.start + range.count ) );
13260
+
13261
+ }
13262
+
13263
+ }
13264
+
13265
+ attribute.clearUpdateRanges();
13266
+
13267
+ }
13268
+
13269
+ // @deprecated, r159
13270
+ if ( updateRange.count !== - 1 ) {
13170
13271
 
13171
13272
  if ( isWebGL2 ) {
13172
13273
 
@@ -13245,6 +13346,12 @@
13245
13346
 
13246
13347
  } else if ( data.version < attribute.version ) {
13247
13348
 
13349
+ if ( data.size !== attribute.array.byteLength ) {
13350
+
13351
+ throw new Error( 'THREE.WebGLAttributes: The size of the buffer attribute\'s array buffer does not match the original size. Resizing buffer attributes is not supported.' );
13352
+
13353
+ }
13354
+
13248
13355
  updateBuffer( data.buffer, attribute, bufferType );
13249
13356
 
13250
13357
  data.version = attribute.version;
@@ -13365,7 +13472,7 @@
13365
13472
 
13366
13473
  var alphamap_pars_fragment = "#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif";
13367
13474
 
13368
- var alphatest_fragment = "#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif";
13475
+ var alphatest_fragment = "#ifdef USE_ALPHATEST\n\t#ifdef ALPHA_TO_COVERAGE\n\tdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\tif ( diffuseColor.a < alphaTest ) discard;\n\t#endif\n#endif";
13369
13476
 
13370
13477
  var alphatest_pars_fragment = "#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif";
13371
13478
 
@@ -13373,6 +13480,10 @@
13373
13480
 
13374
13481
  var aomap_pars_fragment = "#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif";
13375
13482
 
13483
+ var batching_pars_vertex = "#ifdef USE_BATCHING\n\tattribute float batchId;\n\tuniform highp sampler2D batchingTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif";
13484
+
13485
+ var batching_vertex = "#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( batchId );\n#endif";
13486
+
13376
13487
  var begin_vertex = "vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif";
13377
13488
 
13378
13489
  var beginnormal_vertex = "vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif";
@@ -13383,7 +13494,7 @@
13383
13494
 
13384
13495
  var bumpmap_pars_fragment = "#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif";
13385
13496
 
13386
- var clipping_planes_fragment = "#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif";
13497
+ var clipping_planes_fragment = "#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif";
13387
13498
 
13388
13499
  var clipping_planes_pars_fragment = "#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif";
13389
13500
 
@@ -13401,9 +13512,9 @@
13401
13512
 
13402
13513
  var common = "#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated";
13403
13514
 
13404
- var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_v0 0.339\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_v1 0.276\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_v4 0.046\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_v5 0.016\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_v6 0.0038\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif";
13515
+ var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif";
13405
13516
 
13406
- var defaultnormal_vertex = "vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif";
13517
+ var defaultnormal_vertex = "vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif";
13407
13518
 
13408
13519
  var displacementmap_pars_vertex = "#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif";
13409
13520
 
@@ -13457,7 +13568,7 @@
13457
13568
 
13458
13569
  var lights_phong_pars_fragment = "varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong";
13459
13570
 
13460
- var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tanisotropyV /= material.anisotropy;\n\tmaterial.anisotropy = saturate( material.anisotropy );\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y;\n#endif";
13571
+ var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif";
13461
13572
 
13462
13573
  var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
13463
13574
 
@@ -13521,7 +13632,7 @@
13521
13632
 
13522
13633
  var premultiplied_alpha_fragment = "#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif";
13523
13634
 
13524
- var project_vertex = "vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;";
13635
+ var project_vertex = "vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;";
13525
13636
 
13526
13637
  var dithering_fragment = "#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif";
13527
13638
 
@@ -13541,7 +13652,7 @@
13541
13652
 
13542
13653
  var skinbase_vertex = "#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif";
13543
13654
 
13544
- var skinning_pars_vertex = "#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tuniform int boneTextureSize;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tfloat j = i * 4.0;\n\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\ty = dy * ( y + 0.5 );\n\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\treturn bone;\n\t}\n#endif";
13655
+ var skinning_pars_vertex = "#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif";
13545
13656
 
13546
13657
  var skinning_vertex = "#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif";
13547
13658
 
@@ -13553,7 +13664,7 @@
13553
13664
 
13554
13665
  var tonemapping_fragment = "#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif";
13555
13666
 
13556
- var tonemapping_pars_fragment = "#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }";
13667
+ var tonemapping_pars_fragment = "#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }";
13557
13668
 
13558
13669
  var transmission_fragment = "#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif";
13559
13670
 
@@ -13565,7 +13676,7 @@
13565
13676
 
13566
13677
  var uv_vertex = "#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif";
13567
13678
 
13568
- var worldpos_vertex = "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif";
13679
+ var worldpos_vertex = "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif";
13569
13680
 
13570
13681
  const vertex$h = "varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}";
13571
13682
 
@@ -13579,13 +13690,13 @@
13579
13690
 
13580
13691
  const fragment$f = "uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}";
13581
13692
 
13582
- const vertex$e = "#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}";
13693
+ const vertex$e = "#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}";
13583
13694
 
13584
- const fragment$e = "#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}";
13695
+ const fragment$e = "#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}";
13585
13696
 
13586
- const vertex$d = "#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}";
13697
+ const vertex$d = "#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}";
13587
13698
 
13588
- const fragment$d = "#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}";
13699
+ const fragment$d = "#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}";
13589
13700
 
13590
13701
  const vertex$c = "varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}";
13591
13702
 
@@ -13593,47 +13704,47 @@
13593
13704
 
13594
13705
  const vertex$b = "uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}";
13595
13706
 
13596
- const fragment$b = "uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}";
13707
+ const fragment$b = "uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}";
13597
13708
 
13598
- const vertex$a = "#include <common>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}";
13709
+ const vertex$a = "#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}";
13599
13710
 
13600
- const fragment$a = "uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
13711
+ const fragment$a = "uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
13601
13712
 
13602
- const vertex$9 = "#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}";
13713
+ const vertex$9 = "#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}";
13603
13714
 
13604
- const fragment$9 = "#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
13715
+ const fragment$9 = "#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
13605
13716
 
13606
- const vertex$8 = "#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}";
13717
+ const vertex$8 = "#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}";
13607
13718
 
13608
- const fragment$8 = "#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
13719
+ const fragment$8 = "#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
13609
13720
 
13610
- const vertex$7 = "#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}";
13721
+ const vertex$7 = "#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}";
13611
13722
 
13612
- const fragment$7 = "#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}";
13723
+ const fragment$7 = "#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}";
13613
13724
 
13614
- const vertex$6 = "#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}";
13725
+ const vertex$6 = "#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}";
13615
13726
 
13616
- const fragment$6 = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
13727
+ const fragment$6 = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
13617
13728
 
13618
- const vertex$5 = "#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}";
13729
+ const vertex$5 = "#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}";
13619
13730
 
13620
- const fragment$5 = "#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
13731
+ const fragment$5 = "#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
13621
13732
 
13622
- const vertex$4 = "#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}";
13733
+ const vertex$4 = "#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}";
13623
13734
 
13624
- const fragment$4 = "#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
13735
+ const fragment$4 = "#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
13625
13736
 
13626
13737
  const vertex$3 = "uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}";
13627
13738
 
13628
- const fragment$3 = "uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}";
13739
+ const fragment$3 = "uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}";
13629
13740
 
13630
- const vertex$2 = "#include <common>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}";
13741
+ const vertex$2 = "#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}";
13631
13742
 
13632
13743
  const fragment$2 = "uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}";
13633
13744
 
13634
13745
  const vertex$1 = "uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}";
13635
13746
 
13636
- const fragment$1 = "uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}";
13747
+ const fragment$1 = "uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}";
13637
13748
 
13638
13749
  const ShaderChunk = {
13639
13750
  alphahash_fragment: alphahash_fragment,
@@ -13644,6 +13755,8 @@
13644
13755
  alphatest_pars_fragment: alphatest_pars_fragment,
13645
13756
  aomap_fragment: aomap_fragment,
13646
13757
  aomap_pars_fragment: aomap_pars_fragment,
13758
+ batching_pars_vertex: batching_pars_vertex,
13759
+ batching_vertex: batching_vertex,
13647
13760
  begin_vertex: begin_vertex,
13648
13761
  beginnormal_vertex: beginnormal_vertex,
13649
13762
  bsdfs: bsdfs,
@@ -15257,11 +15370,42 @@
15257
15370
 
15258
15371
  }
15259
15372
 
15373
+ function renderMultiDraw( starts, counts, drawCount ) {
15374
+
15375
+ if ( drawCount === 0 ) return;
15376
+
15377
+ const extension = extensions.get( 'WEBGL_multi_draw' );
15378
+ if ( extension === null ) {
15379
+
15380
+ for ( let i = 0; i < drawCount; i ++ ) {
15381
+
15382
+ this.render( starts[ i ], counts[ i ] );
15383
+
15384
+ }
15385
+
15386
+ } else {
15387
+
15388
+ extension.multiDrawArraysWEBGL( mode, starts, 0, counts, 0, drawCount );
15389
+
15390
+ let elementCount = 0;
15391
+ for ( let i = 0; i < drawCount; i ++ ) {
15392
+
15393
+ elementCount += counts[ i ];
15394
+
15395
+ }
15396
+
15397
+ info.update( elementCount, mode, 1 );
15398
+
15399
+ }
15400
+
15401
+ }
15402
+
15260
15403
  //
15261
15404
 
15262
15405
  this.setMode = setMode;
15263
15406
  this.render = render;
15264
15407
  this.renderInstances = renderInstances;
15408
+ this.renderMultiDraw = renderMultiDraw;
15265
15409
 
15266
15410
  }
15267
15411
 
@@ -15571,7 +15715,7 @@
15571
15715
 
15572
15716
  function get( texture ) {
15573
15717
 
15574
- if ( texture && texture.isTexture && texture.isRenderTargetTexture === false ) {
15718
+ if ( texture && texture.isTexture ) {
15575
15719
 
15576
15720
  const mapping = texture.mapping;
15577
15721
 
@@ -15588,7 +15732,7 @@
15588
15732
 
15589
15733
  if ( image && image.height > 0 ) {
15590
15734
 
15591
- const renderTarget = new WebGLCubeRenderTarget( image.height / 2 );
15735
+ const renderTarget = new WebGLCubeRenderTarget( image.height );
15592
15736
  renderTarget.fromEquirectangularTexture( renderer, texture );
15593
15737
  cubemaps.set( texture, renderTarget );
15594
15738
 
@@ -16839,6 +16983,7 @@
16839
16983
  if ( capabilities.isWebGL2 ) {
16840
16984
 
16841
16985
  getExtension( 'EXT_color_buffer_float' );
16986
+ getExtension( 'WEBGL_clip_cull_distance' );
16842
16987
 
16843
16988
  } else {
16844
16989
 
@@ -17143,12 +17288,43 @@
17143
17288
 
17144
17289
  }
17145
17290
 
17291
+ function renderMultiDraw( starts, counts, drawCount ) {
17292
+
17293
+ if ( drawCount === 0 ) return;
17294
+
17295
+ const extension = extensions.get( 'WEBGL_multi_draw' );
17296
+ if ( extension === null ) {
17297
+
17298
+ for ( let i = 0; i < drawCount; i ++ ) {
17299
+
17300
+ this.render( starts[ i ] / bytesPerElement, counts[ i ] );
17301
+
17302
+ }
17303
+
17304
+ } else {
17305
+
17306
+ extension.multiDrawElementsWEBGL( mode, counts, 0, type, starts, 0, drawCount );
17307
+
17308
+ let elementCount = 0;
17309
+ for ( let i = 0; i < drawCount; i ++ ) {
17310
+
17311
+ elementCount += counts[ i ];
17312
+
17313
+ }
17314
+
17315
+ info.update( elementCount, mode, 1 );
17316
+
17317
+ }
17318
+
17319
+ }
17320
+
17146
17321
  //
17147
17322
 
17148
17323
  this.setMode = setMode;
17149
17324
  this.setIndex = setIndex;
17150
17325
  this.render = render;
17151
17326
  this.renderInstances = renderInstances;
17327
+ this.renderMultiDraw = renderMultiDraw;
17152
17328
 
17153
17329
  }
17154
17330
 
@@ -17604,6 +17780,60 @@
17604
17780
 
17605
17781
  }
17606
17782
 
17783
+ class DepthTexture extends Texture {
17784
+
17785
+ constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format ) {
17786
+
17787
+ format = format !== undefined ? format : DepthFormat;
17788
+
17789
+ if ( format !== DepthFormat && format !== DepthStencilFormat ) {
17790
+
17791
+ throw new Error( 'DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat' );
17792
+
17793
+ }
17794
+
17795
+ if ( type === undefined && format === DepthFormat ) type = UnsignedIntType;
17796
+ if ( type === undefined && format === DepthStencilFormat ) type = UnsignedInt248Type;
17797
+
17798
+ super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
17799
+
17800
+ this.isDepthTexture = true;
17801
+
17802
+ this.image = { width: width, height: height };
17803
+
17804
+ this.magFilter = magFilter !== undefined ? magFilter : NearestFilter;
17805
+ this.minFilter = minFilter !== undefined ? minFilter : NearestFilter;
17806
+
17807
+ this.flipY = false;
17808
+ this.generateMipmaps = false;
17809
+
17810
+ this.compareFunction = null;
17811
+
17812
+ }
17813
+
17814
+
17815
+ copy( source ) {
17816
+
17817
+ super.copy( source );
17818
+
17819
+ this.compareFunction = source.compareFunction;
17820
+
17821
+ return this;
17822
+
17823
+ }
17824
+
17825
+ toJSON( meta ) {
17826
+
17827
+ const data = super.toJSON( meta );
17828
+
17829
+ if ( this.compareFunction !== null ) data.compareFunction = this.compareFunction;
17830
+
17831
+ return data;
17832
+
17833
+ }
17834
+
17835
+ }
17836
+
17607
17837
  /**
17608
17838
  * Uniforms of a program.
17609
17839
  * Those form a tree structure with a special top-level container for the root,
@@ -17649,6 +17879,10 @@
17649
17879
 
17650
17880
 
17651
17881
  const emptyTexture = /*@__PURE__*/ new Texture();
17882
+
17883
+ const emptyShadowTexture = /*@__PURE__*/ new DepthTexture( 1, 1 );
17884
+ emptyShadowTexture.compareFunction = LessEqualCompare;
17885
+
17652
17886
  const emptyArrayTexture = /*@__PURE__*/ new DataArrayTexture();
17653
17887
  const empty3dTexture = /*@__PURE__*/ new Data3DTexture();
17654
17888
  const emptyCubeTexture = /*@__PURE__*/ new CubeTexture();
@@ -18165,7 +18399,9 @@
18165
18399
 
18166
18400
  }
18167
18401
 
18168
- textures.setTexture2D( v || emptyTexture, unit );
18402
+ const emptyTexture2D = ( this.type === gl.SAMPLER_2D_SHADOW ) ? emptyShadowTexture : emptyTexture;
18403
+
18404
+ textures.setTexture2D( v || emptyTexture2D, unit );
18169
18405
 
18170
18406
  }
18171
18407
 
@@ -18549,6 +18785,7 @@
18549
18785
  this.id = id;
18550
18786
  this.addr = addr;
18551
18787
  this.cache = [];
18788
+ this.type = activeInfo.type;
18552
18789
  this.setValue = getSingularSetter( activeInfo.type );
18553
18790
 
18554
18791
  // this.path = activeInfo.name; // DEBUG
@@ -18564,6 +18801,7 @@
18564
18801
  this.id = id;
18565
18802
  this.addr = addr;
18566
18803
  this.cache = [];
18804
+ this.type = activeInfo.type;
18567
18805
  this.size = activeInfo.size;
18568
18806
  this.setValue = getPureArraySetter( activeInfo.type );
18569
18807
 
@@ -18872,6 +19110,10 @@
18872
19110
  toneMappingName = 'ACESFilmic';
18873
19111
  break;
18874
19112
 
19113
+ case AgXToneMapping:
19114
+ toneMappingName = 'AgX';
19115
+ break;
19116
+
18875
19117
  case CustomToneMapping:
18876
19118
  toneMappingName = 'Custom';
18877
19119
  break;
@@ -18889,7 +19131,7 @@
18889
19131
  function generateExtensions( parameters ) {
18890
19132
 
18891
19133
  const chunks = [
18892
- ( parameters.extensionDerivatives || !! parameters.envMapCubeUVHeight || parameters.bumpMap || parameters.normalMapTangentSpace || parameters.clearcoatNormalMap || parameters.flatShading || parameters.shaderID === 'physical' ) ? '#extension GL_OES_standard_derivatives : enable' : '',
19134
+ ( parameters.extensionDerivatives || !! parameters.envMapCubeUVHeight || parameters.bumpMap || parameters.normalMapTangentSpace || parameters.clearcoatNormalMap || parameters.flatShading || parameters.alphaToCoverage || parameters.shaderID === 'physical' ) ? '#extension GL_OES_standard_derivatives : enable' : '',
18893
19135
  ( parameters.extensionFragDepth || parameters.logarithmicDepthBuffer ) && parameters.rendererExtensionFragDepth ? '#extension GL_EXT_frag_depth : enable' : '',
18894
19136
  ( parameters.extensionDrawBuffers && parameters.rendererExtensionDrawBuffers ) ? '#extension GL_EXT_draw_buffers : require' : '',
18895
19137
  ( parameters.extensionShaderTextureLOD || parameters.envMap || parameters.transmission ) && parameters.rendererExtensionShaderTextureLod ? '#extension GL_EXT_shader_texture_lod : enable' : ''
@@ -18899,6 +19141,17 @@
18899
19141
 
18900
19142
  }
18901
19143
 
19144
+ function generateVertexExtensions( parameters ) {
19145
+
19146
+ const chunks = [
19147
+ parameters.extensionClipCullDistance ? '#extension GL_ANGLE_clip_cull_distance : require' : '',
19148
+ parameters.extensionMultiDraw ? '#extension GL_ANGLE_multi_draw : require' : '',
19149
+ ];
19150
+
19151
+ return chunks.filter( filterEmptyLine ).join( '\n' );
19152
+
19153
+ }
19154
+
18902
19155
  function generateDefines( defines ) {
18903
19156
 
18904
19157
  const chunks = [];
@@ -19051,7 +19304,30 @@
19051
19304
 
19052
19305
  function generatePrecision( parameters ) {
19053
19306
 
19054
- let precisionstring = 'precision ' + parameters.precision + ' float;\nprecision ' + parameters.precision + ' int;';
19307
+ let precisionstring = `precision ${parameters.precision} float;
19308
+ precision ${parameters.precision} int;
19309
+ precision ${parameters.precision} sampler2D;
19310
+ precision ${parameters.precision} samplerCube;
19311
+ `;
19312
+
19313
+ if ( parameters.isWebGL2 ) {
19314
+
19315
+ precisionstring += `precision ${parameters.precision} sampler3D;
19316
+ precision ${parameters.precision} sampler2DArray;
19317
+ precision ${parameters.precision} sampler2DShadow;
19318
+ precision ${parameters.precision} samplerCubeShadow;
19319
+ precision ${parameters.precision} sampler2DArrayShadow;
19320
+ precision ${parameters.precision} isampler2D;
19321
+ precision ${parameters.precision} isampler3D;
19322
+ precision ${parameters.precision} isamplerCube;
19323
+ precision ${parameters.precision} isampler2DArray;
19324
+ precision ${parameters.precision} usampler2D;
19325
+ precision ${parameters.precision} usampler3D;
19326
+ precision ${parameters.precision} usamplerCube;
19327
+ precision ${parameters.precision} usampler2DArray;
19328
+ `;
19329
+
19330
+ }
19055
19331
 
19056
19332
  if ( parameters.precision === 'highp' ) {
19057
19333
 
@@ -19203,6 +19479,8 @@
19203
19479
 
19204
19480
  const customExtensions = parameters.isWebGL2 ? '' : generateExtensions( parameters );
19205
19481
 
19482
+ const customVertexExtensions = generateVertexExtensions( parameters );
19483
+
19206
19484
  const customDefines = generateDefines( defines );
19207
19485
 
19208
19486
  const program = gl.createProgram();
@@ -19255,6 +19533,8 @@
19255
19533
 
19256
19534
  customDefines,
19257
19535
 
19536
+ parameters.extensionClipCullDistance ? '#define USE_CLIP_DISTANCE' : '',
19537
+ parameters.batching ? '#define USE_BATCHING' : '',
19258
19538
  parameters.instancing ? '#define USE_INSTANCING' : '',
19259
19539
  parameters.instancingColor ? '#define USE_INSTANCING_COLOR' : '',
19260
19540
 
@@ -19476,6 +19756,7 @@
19476
19756
  parameters.useFog && parameters.fog ? '#define USE_FOG' : '',
19477
19757
  parameters.useFog && parameters.fogExp2 ? '#define FOG_EXP2' : '',
19478
19758
 
19759
+ parameters.alphaToCoverage ? '#define ALPHA_TO_COVERAGE' : '',
19479
19760
  parameters.map ? '#define USE_MAP' : '',
19480
19761
  parameters.matcap ? '#define USE_MATCAP' : '',
19481
19762
  parameters.envMap ? '#define USE_ENVMAP' : '',
@@ -19594,6 +19875,7 @@
19594
19875
  versionString = '#version 300 es\n';
19595
19876
 
19596
19877
  prefixVertex = [
19878
+ customVertexExtensions,
19597
19879
  'precision mediump sampler2DArray;',
19598
19880
  '#define attribute in',
19599
19881
  '#define varying out',
@@ -19676,6 +19958,8 @@
19676
19958
  console.error(
19677
19959
  'THREE.WebGLProgram: Shader Error ' + gl.getError() + ' - ' +
19678
19960
  'VALIDATE_STATUS ' + gl.getProgramParameter( program, gl.VALIDATE_STATUS ) + '\n\n' +
19961
+ 'Material Name: ' + self.name + '\n' +
19962
+ 'Material Type: ' + self.type + '\n\n' +
19679
19963
  'Program Info Log: ' + programLog + '\n' +
19680
19964
  vertexErrors + '\n' +
19681
19965
  fragmentErrors
@@ -19939,6 +20223,7 @@
19939
20223
 
19940
20224
  const _programLayers = new Layers();
19941
20225
  const _customShaders = new WebGLShaderCache();
20226
+ const _activeChannels = new Set();
19942
20227
  const programs = [];
19943
20228
 
19944
20229
  const IS_WEBGL2 = capabilities.isWebGL2;
@@ -19967,6 +20252,8 @@
19967
20252
 
19968
20253
  function getChannel( value ) {
19969
20254
 
20255
+ _activeChannels.add( value );
20256
+
19970
20257
  if ( value === 0 ) return 'uv';
19971
20258
 
19972
20259
  return `uv${ value }`;
@@ -20037,6 +20324,7 @@
20037
20324
  const currentRenderTarget = renderer.getRenderTarget();
20038
20325
 
20039
20326
  const IS_INSTANCEDMESH = object.isInstancedMesh === true;
20327
+ const IS_BATCHEDMESH = object.isBatchedMesh === true;
20040
20328
 
20041
20329
  const HAS_MAP = !! material.map;
20042
20330
  const HAS_MATCAP = !! material.matcap;
@@ -20086,10 +20374,6 @@
20086
20374
 
20087
20375
  const HAS_EXTENSIONS = !! material.extensions;
20088
20376
 
20089
- const HAS_ATTRIBUTE_UV1 = !! geometry.attributes.uv1;
20090
- const HAS_ATTRIBUTE_UV2 = !! geometry.attributes.uv2;
20091
- const HAS_ATTRIBUTE_UV3 = !! geometry.attributes.uv3;
20092
-
20093
20377
  let toneMapping = NoToneMapping;
20094
20378
 
20095
20379
  if ( material.toneMapped ) {
@@ -20122,11 +20406,13 @@
20122
20406
 
20123
20407
  precision: precision,
20124
20408
 
20409
+ batching: IS_BATCHEDMESH,
20125
20410
  instancing: IS_INSTANCEDMESH,
20126
20411
  instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
20127
20412
 
20128
20413
  supportsVertexTextures: SUPPORTS_VERTEX_TEXTURES,
20129
20414
  outputColorSpace: ( currentRenderTarget === null ) ? renderer.outputColorSpace : ( currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace ),
20415
+ alphaToCoverage: !! material.alphaToCoverage,
20130
20416
 
20131
20417
  map: HAS_MAP,
20132
20418
  matcap: HAS_MATCAP,
@@ -20172,7 +20458,7 @@
20172
20458
 
20173
20459
  gradientMap: HAS_GRADIENTMAP,
20174
20460
 
20175
- opaque: material.transparent === false && material.blending === NormalBlending,
20461
+ opaque: material.transparent === false && material.blending === NormalBlending && material.alphaToCoverage === false,
20176
20462
 
20177
20463
  alphaMap: HAS_ALPHAMAP,
20178
20464
  alphaTest: HAS_ALPHATEST,
@@ -20219,15 +20505,12 @@
20219
20505
  vertexTangents: !! geometry.attributes.tangent && ( HAS_NORMALMAP || HAS_ANISOTROPY ),
20220
20506
  vertexColors: material.vertexColors,
20221
20507
  vertexAlphas: material.vertexColors === true && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4,
20222
- vertexUv1s: HAS_ATTRIBUTE_UV1,
20223
- vertexUv2s: HAS_ATTRIBUTE_UV2,
20224
- vertexUv3s: HAS_ATTRIBUTE_UV3,
20225
20508
 
20226
20509
  pointsUvs: object.isPoints === true && !! geometry.attributes.uv && ( HAS_MAP || HAS_ALPHAMAP ),
20227
20510
 
20228
20511
  fog: !! fog,
20229
20512
  useFog: material.fog === true,
20230
- fogExp2: ( fog && fog.isFogExp2 ),
20513
+ fogExp2: ( !! fog && fog.isFogExp2 ),
20231
20514
 
20232
20515
  flatShading: material.flatShading === true,
20233
20516
 
@@ -20283,6 +20566,8 @@
20283
20566
  extensionFragDepth: HAS_EXTENSIONS && material.extensions.fragDepth === true,
20284
20567
  extensionDrawBuffers: HAS_EXTENSIONS && material.extensions.drawBuffers === true,
20285
20568
  extensionShaderTextureLOD: HAS_EXTENSIONS && material.extensions.shaderTextureLOD === true,
20569
+ extensionClipCullDistance: HAS_EXTENSIONS && material.extensions.clipCullDistance === true && extensions.has( 'WEBGL_clip_cull_distance' ),
20570
+ extensionMultiDraw: HAS_EXTENSIONS && material.extensions.multiDraw === true && extensions.has( 'WEBGL_multi_draw' ),
20286
20571
 
20287
20572
  rendererExtensionFragDepth: IS_WEBGL2 || extensions.has( 'EXT_frag_depth' ),
20288
20573
  rendererExtensionDrawBuffers: IS_WEBGL2 || extensions.has( 'WEBGL_draw_buffers' ),
@@ -20293,6 +20578,14 @@
20293
20578
 
20294
20579
  };
20295
20580
 
20581
+ // the usage of getChannel() determines the active texture channels for this shader
20582
+
20583
+ parameters.vertexUv1s = _activeChannels.has( 1 );
20584
+ parameters.vertexUv2s = _activeChannels.has( 2 );
20585
+ parameters.vertexUv3s = _activeChannels.has( 3 );
20586
+
20587
+ _activeChannels.clear();
20588
+
20296
20589
  return parameters;
20297
20590
 
20298
20591
  }
@@ -20432,6 +20725,8 @@
20432
20725
  _programLayers.enable( 17 );
20433
20726
  if ( parameters.alphaHash )
20434
20727
  _programLayers.enable( 18 );
20728
+ if ( parameters.batching )
20729
+ _programLayers.enable( 19 );
20435
20730
 
20436
20731
  array.push( _programLayers.mask );
20437
20732
  _programLayers.disableAll();
@@ -20476,6 +20771,8 @@
20476
20771
  _programLayers.enable( 18 );
20477
20772
  if ( parameters.decodeVideoTexture )
20478
20773
  _programLayers.enable( 19 );
20774
+ if ( parameters.alphaToCoverage )
20775
+ _programLayers.enable( 20 );
20479
20776
 
20480
20777
  array.push( _programLayers.mask );
20481
20778
 
@@ -21255,8 +21552,17 @@
21255
21552
 
21256
21553
  // WebGL 2
21257
21554
 
21258
- state.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1;
21259
- state.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2;
21555
+ if ( extensions.has( 'OES_texture_float_linear' ) === true ) {
21556
+
21557
+ state.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1;
21558
+ state.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2;
21559
+
21560
+ } else {
21561
+
21562
+ state.rectAreaLTC1 = UniformsLib.LTC_HALF_1;
21563
+ state.rectAreaLTC2 = UniformsLib.LTC_HALF_2;
21564
+
21565
+ }
21260
21566
 
21261
21567
  } else {
21262
21568
 
@@ -21893,6 +22199,7 @@
21893
22199
 
21894
22200
  cachedMaterial = result.clone();
21895
22201
  materialsForVariant[ keyB ] = cachedMaterial;
22202
+ material.addEventListener( 'dispose', onMaterialDispose );
21896
22203
 
21897
22204
  }
21898
22205
 
@@ -21969,8 +22276,12 @@
21969
22276
 
21970
22277
  const depthMaterial = getDepthMaterial( object, groupMaterial, light, type );
21971
22278
 
22279
+ object.onBeforeShadow( _renderer, object, camera, shadowCamera, geometry, depthMaterial, group );
22280
+
21972
22281
  _renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, group );
21973
22282
 
22283
+ object.onAfterShadow( _renderer, object, camera, shadowCamera, geometry, depthMaterial, group );
22284
+
21974
22285
  }
21975
22286
 
21976
22287
  }
@@ -21979,8 +22290,12 @@
21979
22290
 
21980
22291
  const depthMaterial = getDepthMaterial( object, material, light, type );
21981
22292
 
22293
+ object.onBeforeShadow( _renderer, object, camera, shadowCamera, geometry, depthMaterial, null );
22294
+
21982
22295
  _renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, null );
21983
22296
 
22297
+ object.onAfterShadow( _renderer, object, camera, shadowCamera, geometry, depthMaterial, null );
22298
+
21984
22299
  }
21985
22300
 
21986
22301
  }
@@ -21997,6 +22312,32 @@
21997
22312
 
21998
22313
  }
21999
22314
 
22315
+ function onMaterialDispose( event ) {
22316
+
22317
+ const material = event.target;
22318
+
22319
+ material.removeEventListener( 'dispose', onMaterialDispose );
22320
+
22321
+ // make sure to remove the unique distance/depth materials used for shadow map rendering
22322
+
22323
+ for ( const id in _materialCache ) {
22324
+
22325
+ const cache = _materialCache[ id ];
22326
+
22327
+ const uuid = event.target.uuid;
22328
+
22329
+ if ( uuid in cache ) {
22330
+
22331
+ const shadowMaterial = cache[ uuid ];
22332
+ shadowMaterial.dispose();
22333
+ delete cache[ uuid ];
22334
+
22335
+ }
22336
+
22337
+ }
22338
+
22339
+ }
22340
+
22000
22341
  }
22001
22342
 
22002
22343
  function WebGLState( gl, extensions, capabilities ) {
@@ -23325,10 +23666,6 @@
23325
23666
  function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {
23326
23667
 
23327
23668
  const isWebGL2 = capabilities.isWebGL2;
23328
- const maxTextures = capabilities.maxTextures;
23329
- const maxCubemapSize = capabilities.maxCubemapSize;
23330
- const maxTextureSize = capabilities.maxTextureSize;
23331
- const maxSamples = capabilities.maxSamples;
23332
23669
  const multisampledRTTExt = extensions.has( 'WEBGL_multisampled_render_to_texture' ) ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : null;
23333
23670
  const supportsInvalidateFramebuffer = typeof navigator === 'undefined' ? false : /OculusBrowser/g.test( navigator.userAgent );
23334
23671
 
@@ -23747,9 +24084,9 @@
23747
24084
 
23748
24085
  const textureUnit = textureUnits;
23749
24086
 
23750
- if ( textureUnit >= maxTextures ) {
24087
+ if ( textureUnit >= capabilities.maxTextures ) {
23751
24088
 
23752
- console.warn( 'THREE.WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + maxTextures );
24089
+ console.warn( 'THREE.WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + capabilities.maxTextures );
23753
24090
 
23754
24091
  }
23755
24092
 
@@ -23889,6 +24226,14 @@
23889
24226
 
23890
24227
  function setTextureParameters( textureType, texture, supportsMips ) {
23891
24228
 
24229
+ if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false &&
24230
+ ( texture.magFilter === LinearFilter || texture.magFilter === LinearMipmapNearestFilter || texture.magFilter === NearestMipmapLinearFilter || texture.magFilter === LinearMipmapLinearFilter ||
24231
+ texture.minFilter === LinearFilter || texture.minFilter === LinearMipmapNearestFilter || texture.minFilter === NearestMipmapLinearFilter || texture.minFilter === LinearMipmapLinearFilter ) ) {
24232
+
24233
+ console.warn( 'THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.' );
24234
+
24235
+ }
24236
+
23892
24237
  if ( supportsMips ) {
23893
24238
 
23894
24239
  _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );
@@ -24066,7 +24411,7 @@
24066
24411
  _gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );
24067
24412
 
24068
24413
  const needsPowerOfTwo = textureNeedsPowerOfTwo( texture ) && isPowerOfTwo$1( texture.image ) === false;
24069
- let image = resizeImage( texture.image, needsPowerOfTwo, false, maxTextureSize );
24414
+ let image = resizeImage( texture.image, needsPowerOfTwo, false, capabilities.maxTextureSize );
24070
24415
  image = verifyColorSpace( texture, image );
24071
24416
 
24072
24417
  const supportsMips = isPowerOfTwo$1( image ) || isWebGL2,
@@ -24080,8 +24425,9 @@
24080
24425
  let mipmap;
24081
24426
  const mipmaps = texture.mipmaps;
24082
24427
 
24083
- const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true );
24428
+ const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true && glInternalFormat !== RGB_ETC1_Format );
24084
24429
  const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
24430
+ const dataReady = source.dataReady;
24085
24431
  const levels = getMipLevels( texture, image, supportsMips );
24086
24432
 
24087
24433
  if ( texture.isDepthTexture ) {
@@ -24194,7 +24540,11 @@
24194
24540
 
24195
24541
  if ( useTexStorage ) {
24196
24542
 
24197
- state.texSubImage2D( _gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
24543
+ if ( dataReady ) {
24544
+
24545
+ state.texSubImage2D( _gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
24546
+
24547
+ }
24198
24548
 
24199
24549
  } else {
24200
24550
 
@@ -24216,7 +24566,11 @@
24216
24566
 
24217
24567
  }
24218
24568
 
24219
- state.texSubImage2D( _gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, glFormat, glType, image.data );
24569
+ if ( dataReady ) {
24570
+
24571
+ state.texSubImage2D( _gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, glFormat, glType, image.data );
24572
+
24573
+ }
24220
24574
 
24221
24575
  } else {
24222
24576
 
@@ -24246,7 +24600,11 @@
24246
24600
 
24247
24601
  if ( useTexStorage ) {
24248
24602
 
24249
- state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, mipmap.data, 0, 0 );
24603
+ if ( dataReady ) {
24604
+
24605
+ state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, mipmap.data, 0, 0 );
24606
+
24607
+ }
24250
24608
 
24251
24609
  } else {
24252
24610
 
@@ -24264,7 +24622,11 @@
24264
24622
 
24265
24623
  if ( useTexStorage ) {
24266
24624
 
24267
- state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, glType, mipmap.data );
24625
+ if ( dataReady ) {
24626
+
24627
+ state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, glType, mipmap.data );
24628
+
24629
+ }
24268
24630
 
24269
24631
  } else {
24270
24632
 
@@ -24294,7 +24656,11 @@
24294
24656
 
24295
24657
  if ( useTexStorage ) {
24296
24658
 
24297
- state.compressedTexSubImage2D( _gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data );
24659
+ if ( dataReady ) {
24660
+
24661
+ state.compressedTexSubImage2D( _gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data );
24662
+
24663
+ }
24298
24664
 
24299
24665
  } else {
24300
24666
 
@@ -24312,7 +24678,11 @@
24312
24678
 
24313
24679
  if ( useTexStorage ) {
24314
24680
 
24315
- state.texSubImage2D( _gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
24681
+ if ( dataReady ) {
24682
+
24683
+ state.texSubImage2D( _gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
24684
+
24685
+ }
24316
24686
 
24317
24687
  } else {
24318
24688
 
@@ -24336,7 +24706,11 @@
24336
24706
 
24337
24707
  }
24338
24708
 
24339
- state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
24709
+ if ( dataReady ) {
24710
+
24711
+ state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
24712
+
24713
+ }
24340
24714
 
24341
24715
  } else {
24342
24716
 
@@ -24354,7 +24728,11 @@
24354
24728
 
24355
24729
  }
24356
24730
 
24357
- state.texSubImage3D( _gl.TEXTURE_3D, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
24731
+ if ( dataReady ) {
24732
+
24733
+ state.texSubImage3D( _gl.TEXTURE_3D, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
24734
+
24735
+ }
24358
24736
 
24359
24737
  } else {
24360
24738
 
@@ -24409,7 +24787,11 @@
24409
24787
 
24410
24788
  if ( useTexStorage ) {
24411
24789
 
24412
- state.texSubImage2D( _gl.TEXTURE_2D, i, 0, 0, glFormat, glType, mipmap );
24790
+ if ( dataReady ) {
24791
+
24792
+ state.texSubImage2D( _gl.TEXTURE_2D, i, 0, 0, glFormat, glType, mipmap );
24793
+
24794
+ }
24413
24795
 
24414
24796
  } else {
24415
24797
 
@@ -24431,7 +24813,11 @@
24431
24813
 
24432
24814
  }
24433
24815
 
24434
- state.texSubImage2D( _gl.TEXTURE_2D, 0, 0, 0, glFormat, glType, image );
24816
+ if ( dataReady ) {
24817
+
24818
+ state.texSubImage2D( _gl.TEXTURE_2D, 0, 0, 0, glFormat, glType, image );
24819
+
24820
+ }
24435
24821
 
24436
24822
  } else {
24437
24823
 
@@ -24492,7 +24878,7 @@
24492
24878
 
24493
24879
  if ( ! isCompressed && ! isDataTexture ) {
24494
24880
 
24495
- cubeImage[ i ] = resizeImage( texture.image[ i ], false, true, maxCubemapSize );
24881
+ cubeImage[ i ] = resizeImage( texture.image[ i ], false, true, capabilities.maxCubemapSize );
24496
24882
 
24497
24883
  } else {
24498
24884
 
@@ -24512,6 +24898,7 @@
24512
24898
 
24513
24899
  const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true );
24514
24900
  const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
24901
+ const dataReady = source.dataReady;
24515
24902
  let levels = getMipLevels( texture, image, supportsMips );
24516
24903
 
24517
24904
  setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, supportsMips );
@@ -24540,7 +24927,11 @@
24540
24927
 
24541
24928
  if ( useTexStorage ) {
24542
24929
 
24543
- state.compressedTexSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data );
24930
+ if ( dataReady ) {
24931
+
24932
+ state.compressedTexSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data );
24933
+
24934
+ }
24544
24935
 
24545
24936
  } else {
24546
24937
 
@@ -24558,7 +24949,11 @@
24558
24949
 
24559
24950
  if ( useTexStorage ) {
24560
24951
 
24561
- state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
24952
+ if ( dataReady ) {
24953
+
24954
+ state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
24955
+
24956
+ }
24562
24957
 
24563
24958
  } else {
24564
24959
 
@@ -24594,7 +24989,11 @@
24594
24989
 
24595
24990
  if ( useTexStorage ) {
24596
24991
 
24597
- state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, cubeImage[ i ].width, cubeImage[ i ].height, glFormat, glType, cubeImage[ i ].data );
24992
+ if ( dataReady ) {
24993
+
24994
+ state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, cubeImage[ i ].width, cubeImage[ i ].height, glFormat, glType, cubeImage[ i ].data );
24995
+
24996
+ }
24598
24997
 
24599
24998
  } else {
24600
24999
 
@@ -24609,7 +25008,11 @@
24609
25008
 
24610
25009
  if ( useTexStorage ) {
24611
25010
 
24612
- state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, 0, 0, mipmapImage.width, mipmapImage.height, glFormat, glType, mipmapImage.data );
25011
+ if ( dataReady ) {
25012
+
25013
+ state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, 0, 0, mipmapImage.width, mipmapImage.height, glFormat, glType, mipmapImage.data );
25014
+
25015
+ }
24613
25016
 
24614
25017
  } else {
24615
25018
 
@@ -24623,7 +25026,11 @@
24623
25026
 
24624
25027
  if ( useTexStorage ) {
24625
25028
 
24626
- state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, glFormat, glType, cubeImage[ i ] );
25029
+ if ( dataReady ) {
25030
+
25031
+ state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, glFormat, glType, cubeImage[ i ] );
25032
+
25033
+ }
24627
25034
 
24628
25035
  } else {
24629
25036
 
@@ -24637,7 +25044,11 @@
24637
25044
 
24638
25045
  if ( useTexStorage ) {
24639
25046
 
24640
- state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, 0, 0, glFormat, glType, mipmap.image[ i ] );
25047
+ if ( dataReady ) {
25048
+
25049
+ state.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, 0, 0, glFormat, glType, mipmap.image[ i ] );
25050
+
25051
+ }
24641
25052
 
24642
25053
  } else {
24643
25054
 
@@ -25323,7 +25734,7 @@
25323
25734
 
25324
25735
  function getRenderTargetSamples( renderTarget ) {
25325
25736
 
25326
- return Math.min( maxSamples, renderTarget.samples );
25737
+ return Math.min( capabilities.maxSamples, renderTarget.samples );
25327
25738
 
25328
25739
  }
25329
25740
 
@@ -26072,55 +26483,100 @@
26072
26483
 
26073
26484
  }
26074
26485
 
26075
- class DepthTexture extends Texture {
26486
+ const _occlusion_vertex = `
26487
+ void main() {
26076
26488
 
26077
- constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format ) {
26489
+ gl_Position = vec4( position, 1.0 );
26078
26490
 
26079
- format = format !== undefined ? format : DepthFormat;
26491
+ }`;
26080
26492
 
26081
- if ( format !== DepthFormat && format !== DepthStencilFormat ) {
26493
+ const _occlusion_fragment = `
26494
+ uniform sampler2DArray depthColor;
26495
+ uniform float depthWidth;
26496
+ uniform float depthHeight;
26082
26497
 
26083
- throw new Error( 'DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat' );
26498
+ void main() {
26084
26499
 
26085
- }
26500
+ vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
26086
26501
 
26087
- if ( type === undefined && format === DepthFormat ) type = UnsignedIntType;
26088
- if ( type === undefined && format === DepthStencilFormat ) type = UnsignedInt248Type;
26502
+ if ( coord.x >= 1.0 ) {
26089
26503
 
26090
- super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
26504
+ gl_FragDepthEXT = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
26091
26505
 
26092
- this.isDepthTexture = true;
26506
+ } else {
26093
26507
 
26094
- this.image = { width: width, height: height };
26508
+ gl_FragDepthEXT = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
26095
26509
 
26096
- this.magFilter = magFilter !== undefined ? magFilter : NearestFilter;
26097
- this.minFilter = minFilter !== undefined ? minFilter : NearestFilter;
26510
+ }
26098
26511
 
26099
- this.flipY = false;
26100
- this.generateMipmaps = false;
26512
+ }`;
26101
26513
 
26102
- this.compareFunction = null;
26514
+ class WebXRDepthSensing {
26515
+
26516
+ constructor() {
26517
+
26518
+ this.texture = null;
26519
+ this.mesh = null;
26520
+
26521
+ this.depthNear = 0;
26522
+ this.depthFar = 0;
26103
26523
 
26104
26524
  }
26105
26525
 
26526
+ init( renderer, depthData, renderState ) {
26106
26527
 
26107
- copy( source ) {
26528
+ if ( this.texture === null ) {
26108
26529
 
26109
- super.copy( source );
26530
+ const texture = new Texture();
26110
26531
 
26111
- this.compareFunction = source.compareFunction;
26532
+ const texProps = renderer.properties.get( texture );
26533
+ texProps.__webglTexture = depthData.texture;
26112
26534
 
26113
- return this;
26535
+ if ( ( depthData.depthNear != renderState.depthNear ) || ( depthData.depthFar != renderState.depthFar ) ) {
26536
+
26537
+ this.depthNear = depthData.depthNear;
26538
+ this.depthFar = depthData.depthFar;
26539
+
26540
+ }
26541
+
26542
+ this.texture = texture;
26543
+
26544
+ }
26114
26545
 
26115
26546
  }
26116
26547
 
26117
- toJSON( meta ) {
26548
+ render( renderer, cameraXR ) {
26118
26549
 
26119
- const data = super.toJSON( meta );
26550
+ if ( this.texture !== null ) {
26120
26551
 
26121
- if ( this.compareFunction !== null ) data.compareFunction = this.compareFunction;
26552
+ if ( this.mesh === null ) {
26122
26553
 
26123
- return data;
26554
+ const viewport = cameraXR.cameras[ 0 ].viewport;
26555
+ const material = new ShaderMaterial( {
26556
+ extensions: { fragDepth: true },
26557
+ vertexShader: _occlusion_vertex,
26558
+ fragmentShader: _occlusion_fragment,
26559
+ uniforms: {
26560
+ depthColor: { value: this.texture },
26561
+ depthWidth: { value: viewport.z },
26562
+ depthHeight: { value: viewport.w }
26563
+ }
26564
+ } );
26565
+
26566
+ this.mesh = new Mesh( new PlaneGeometry( 20, 20 ), material );
26567
+
26568
+ }
26569
+
26570
+ renderer.render( this.mesh, cameraXR );
26571
+
26572
+ }
26573
+
26574
+ }
26575
+
26576
+ reset() {
26577
+
26578
+ this.texture = null;
26579
+ this.mesh = null;
26124
26580
 
26125
26581
  }
26126
26582
 
@@ -26149,13 +26605,19 @@
26149
26605
  let glProjLayer = null;
26150
26606
  let glBaseLayer = null;
26151
26607
  let xrFrame = null;
26608
+
26609
+ const depthSensing = new WebXRDepthSensing();
26152
26610
  const attributes = gl.getContextAttributes();
26611
+
26153
26612
  let initialRenderTarget = null;
26154
26613
  let newRenderTarget = null;
26155
26614
 
26156
26615
  const controllers = [];
26157
26616
  const controllerInputSources = [];
26158
26617
 
26618
+ const currentSize = new Vector2();
26619
+ let currentPixelRatio = null;
26620
+
26159
26621
  //
26160
26622
 
26161
26623
  const cameraL = new PerspectiveCamera();
@@ -26276,6 +26738,8 @@
26276
26738
  _currentDepthNear = null;
26277
26739
  _currentDepthFar = null;
26278
26740
 
26741
+ depthSensing.reset();
26742
+
26279
26743
  // restore framebuffer/rendering state
26280
26744
 
26281
26745
  renderer.setRenderTarget( initialRenderTarget );
@@ -26292,6 +26756,9 @@
26292
26756
 
26293
26757
  scope.isPresenting = false;
26294
26758
 
26759
+ renderer.setPixelRatio( currentPixelRatio );
26760
+ renderer.setSize( currentSize.width, currentSize.height, false );
26761
+
26295
26762
  scope.dispatchEvent( { type: 'sessionend' } );
26296
26763
 
26297
26764
  }
@@ -26379,6 +26846,9 @@
26379
26846
 
26380
26847
  }
26381
26848
 
26849
+ currentPixelRatio = renderer.getPixelRatio();
26850
+ renderer.getSize( currentSize );
26851
+
26382
26852
  if ( ( session.renderState.layers === undefined ) || ( renderer.capabilities.isWebGL2 === false ) ) {
26383
26853
 
26384
26854
  const layerInit = {
@@ -26393,6 +26863,9 @@
26393
26863
 
26394
26864
  session.updateRenderState( { baseLayer: glBaseLayer } );
26395
26865
 
26866
+ renderer.setPixelRatio( 1 );
26867
+ renderer.setSize( glBaseLayer.framebufferWidth, glBaseLayer.framebufferHeight, false );
26868
+
26396
26869
  newRenderTarget = new WebGLRenderTarget(
26397
26870
  glBaseLayer.framebufferWidth,
26398
26871
  glBaseLayer.framebufferHeight,
@@ -26430,6 +26903,9 @@
26430
26903
 
26431
26904
  session.updateRenderState( { layers: [ glProjLayer ] } );
26432
26905
 
26906
+ renderer.setPixelRatio( 1 );
26907
+ renderer.setSize( glProjLayer.textureWidth, glProjLayer.textureHeight, false );
26908
+
26433
26909
  newRenderTarget = new WebGLRenderTarget(
26434
26910
  glProjLayer.textureWidth,
26435
26911
  glProjLayer.textureHeight,
@@ -26622,6 +27098,13 @@
26622
27098
 
26623
27099
  if ( session === null ) return;
26624
27100
 
27101
+ if ( depthSensing.texture !== null ) {
27102
+
27103
+ camera.near = depthSensing.depthNear;
27104
+ camera.far = depthSensing.depthFar;
27105
+
27106
+ }
27107
+
26625
27108
  cameraXR.near = cameraR.near = cameraL.near = camera.near;
26626
27109
  cameraXR.far = cameraR.far = cameraL.far = camera.far;
26627
27110
 
@@ -26637,6 +27120,15 @@
26637
27120
  _currentDepthNear = cameraXR.near;
26638
27121
  _currentDepthFar = cameraXR.far;
26639
27122
 
27123
+ cameraL.near = _currentDepthNear;
27124
+ cameraL.far = _currentDepthFar;
27125
+ cameraR.near = _currentDepthNear;
27126
+ cameraR.far = _currentDepthFar;
27127
+
27128
+ cameraL.updateProjectionMatrix();
27129
+ cameraR.updateProjectionMatrix();
27130
+ camera.updateProjectionMatrix();
27131
+
26640
27132
  }
26641
27133
 
26642
27134
  const parent = camera.parent;
@@ -26738,6 +27230,12 @@
26738
27230
 
26739
27231
  };
26740
27232
 
27233
+ this.hasDepthSensing = function () {
27234
+
27235
+ return depthSensing.texture !== null;
27236
+
27237
+ };
27238
+
26741
27239
  // Animation Loop
26742
27240
 
26743
27241
  let onAnimationFrameCallback = null;
@@ -26830,6 +27328,22 @@
26830
27328
 
26831
27329
  }
26832
27330
 
27331
+ //
27332
+
27333
+ const enabledFeatures = session.enabledFeatures;
27334
+
27335
+ if ( enabledFeatures && enabledFeatures.includes( 'depth-sensing' ) ) {
27336
+
27337
+ const depthData = glBinding.getDepthInformation( views[ 0 ] );
27338
+
27339
+ if ( depthData && depthData.isValid && depthData.texture ) {
27340
+
27341
+ depthSensing.init( renderer, depthData, session.renderState );
27342
+
27343
+ }
27344
+
27345
+ }
27346
+
26833
27347
  }
26834
27348
 
26835
27349
  //
@@ -26847,6 +27361,8 @@
26847
27361
 
26848
27362
  }
26849
27363
 
27364
+ depthSensing.render( renderer, cameraXR );
27365
+
26850
27366
  if ( onAnimationFrameCallback ) onAnimationFrameCallback( time, frame );
26851
27367
 
26852
27368
  if ( frame.detectedPlanes ) {
@@ -27536,57 +28052,62 @@
27536
28052
 
27537
28053
  for ( let i = 0, il = uniforms.length; i < il; i ++ ) {
27538
28054
 
27539
- const uniform = uniforms[ i ];
28055
+ const uniformArray = Array.isArray( uniforms[ i ] ) ? uniforms[ i ] : [ uniforms[ i ] ];
27540
28056
 
27541
- // partly update the buffer if necessary
28057
+ for ( let j = 0, jl = uniformArray.length; j < jl; j ++ ) {
27542
28058
 
27543
- if ( hasUniformChanged( uniform, i, cache ) === true ) {
28059
+ const uniform = uniformArray[ j ];
27544
28060
 
27545
- const offset = uniform.__offset;
28061
+ if ( hasUniformChanged( uniform, i, j, cache ) === true ) {
27546
28062
 
27547
- const values = Array.isArray( uniform.value ) ? uniform.value : [ uniform.value ];
28063
+ const offset = uniform.__offset;
27548
28064
 
27549
- let arrayOffset = 0;
28065
+ const values = Array.isArray( uniform.value ) ? uniform.value : [ uniform.value ];
27550
28066
 
27551
- for ( let i = 0; i < values.length; i ++ ) {
28067
+ let arrayOffset = 0;
27552
28068
 
27553
- const value = values[ i ];
28069
+ for ( let k = 0; k < values.length; k ++ ) {
27554
28070
 
27555
- const info = getUniformSize( value );
28071
+ const value = values[ k ];
27556
28072
 
27557
- if ( typeof value === 'number' ) {
28073
+ const info = getUniformSize( value );
27558
28074
 
27559
- uniform.__data[ 0 ] = value;
27560
- gl.bufferSubData( gl.UNIFORM_BUFFER, offset + arrayOffset, uniform.__data );
28075
+ // TODO add integer and struct support
28076
+ if ( typeof value === 'number' || typeof value === 'boolean' ) {
27561
28077
 
27562
- } else if ( value.isMatrix3 ) {
28078
+ uniform.__data[ 0 ] = value;
28079
+ gl.bufferSubData( gl.UNIFORM_BUFFER, offset + arrayOffset, uniform.__data );
27563
28080
 
27564
- // manually converting 3x3 to 3x4
28081
+ } else if ( value.isMatrix3 ) {
27565
28082
 
27566
- uniform.__data[ 0 ] = value.elements[ 0 ];
27567
- uniform.__data[ 1 ] = value.elements[ 1 ];
27568
- uniform.__data[ 2 ] = value.elements[ 2 ];
27569
- uniform.__data[ 3 ] = value.elements[ 0 ];
27570
- uniform.__data[ 4 ] = value.elements[ 3 ];
27571
- uniform.__data[ 5 ] = value.elements[ 4 ];
27572
- uniform.__data[ 6 ] = value.elements[ 5 ];
27573
- uniform.__data[ 7 ] = value.elements[ 0 ];
27574
- uniform.__data[ 8 ] = value.elements[ 6 ];
27575
- uniform.__data[ 9 ] = value.elements[ 7 ];
27576
- uniform.__data[ 10 ] = value.elements[ 8 ];
27577
- uniform.__data[ 11 ] = value.elements[ 0 ];
28083
+ // manually converting 3x3 to 3x4
27578
28084
 
27579
- } else {
28085
+ uniform.__data[ 0 ] = value.elements[ 0 ];
28086
+ uniform.__data[ 1 ] = value.elements[ 1 ];
28087
+ uniform.__data[ 2 ] = value.elements[ 2 ];
28088
+ uniform.__data[ 3 ] = 0;
28089
+ uniform.__data[ 4 ] = value.elements[ 3 ];
28090
+ uniform.__data[ 5 ] = value.elements[ 4 ];
28091
+ uniform.__data[ 6 ] = value.elements[ 5 ];
28092
+ uniform.__data[ 7 ] = 0;
28093
+ uniform.__data[ 8 ] = value.elements[ 6 ];
28094
+ uniform.__data[ 9 ] = value.elements[ 7 ];
28095
+ uniform.__data[ 10 ] = value.elements[ 8 ];
28096
+ uniform.__data[ 11 ] = 0;
27580
28097
 
27581
- value.toArray( uniform.__data, arrayOffset );
28098
+ } else {
28099
+
28100
+ value.toArray( uniform.__data, arrayOffset );
27582
28101
 
27583
- arrayOffset += info.storage / Float32Array.BYTES_PER_ELEMENT;
28102
+ arrayOffset += info.storage / Float32Array.BYTES_PER_ELEMENT;
28103
+
28104
+ }
27584
28105
 
27585
28106
  }
27586
28107
 
27587
- }
28108
+ gl.bufferSubData( gl.UNIFORM_BUFFER, offset, uniform.__data );
27588
28109
 
27589
- gl.bufferSubData( gl.UNIFORM_BUFFER, offset, uniform.__data );
28110
+ }
27590
28111
 
27591
28112
  }
27592
28113
 
@@ -27596,31 +28117,22 @@
27596
28117
 
27597
28118
  }
27598
28119
 
27599
- function hasUniformChanged( uniform, index, cache ) {
28120
+ function hasUniformChanged( uniform, index, indexArray, cache ) {
27600
28121
 
27601
28122
  const value = uniform.value;
28123
+ const indexString = index + '_' + indexArray;
27602
28124
 
27603
- if ( cache[ index ] === undefined ) {
28125
+ if ( cache[ indexString ] === undefined ) {
27604
28126
 
27605
28127
  // cache entry does not exist so far
27606
28128
 
27607
- if ( typeof value === 'number' ) {
28129
+ if ( typeof value === 'number' || typeof value === 'boolean' ) {
27608
28130
 
27609
- cache[ index ] = value;
28131
+ cache[ indexString ] = value;
27610
28132
 
27611
28133
  } else {
27612
28134
 
27613
- const values = Array.isArray( value ) ? value : [ value ];
27614
-
27615
- const tempValues = [];
27616
-
27617
- for ( let i = 0; i < values.length; i ++ ) {
27618
-
27619
- tempValues.push( values[ i ].clone() );
27620
-
27621
- }
27622
-
27623
- cache[ index ] = tempValues;
28135
+ cache[ indexString ] = value.clone();
27624
28136
 
27625
28137
  }
27626
28138
 
@@ -27628,32 +28140,25 @@
27628
28140
 
27629
28141
  } else {
27630
28142
 
28143
+ const cachedObject = cache[ indexString ];
28144
+
27631
28145
  // compare current value with cached entry
27632
28146
 
27633
- if ( typeof value === 'number' ) {
28147
+ if ( typeof value === 'number' || typeof value === 'boolean' ) {
27634
28148
 
27635
- if ( cache[ index ] !== value ) {
28149
+ if ( cachedObject !== value ) {
27636
28150
 
27637
- cache[ index ] = value;
28151
+ cache[ indexString ] = value;
27638
28152
  return true;
27639
28153
 
27640
28154
  }
27641
28155
 
27642
28156
  } else {
27643
28157
 
27644
- const cachedObjects = Array.isArray( cache[ index ] ) ? cache[ index ] : [ cache[ index ] ];
27645
- const values = Array.isArray( value ) ? value : [ value ];
27646
-
27647
- for ( let i = 0; i < cachedObjects.length; i ++ ) {
27648
-
27649
- const cachedObject = cachedObjects[ i ];
28158
+ if ( cachedObject.equals( value ) === false ) {
27650
28159
 
27651
- if ( cachedObject.equals( values[ i ] ) === false ) {
27652
-
27653
- cachedObject.copy( values[ i ] );
27654
- return true;
27655
-
27656
- }
28160
+ cachedObject.copy( value );
28161
+ return true;
27657
28162
 
27658
28163
  }
27659
28164
 
@@ -27674,63 +28179,53 @@
27674
28179
 
27675
28180
  let offset = 0; // global buffer offset in bytes
27676
28181
  const chunkSize = 16; // size of a chunk in bytes
27677
- let chunkOffset = 0; // offset within a single chunk in bytes
27678
28182
 
27679
28183
  for ( let i = 0, l = uniforms.length; i < l; i ++ ) {
27680
28184
 
27681
- const uniform = uniforms[ i ];
27682
-
27683
- const infos = {
27684
- boundary: 0, // bytes
27685
- storage: 0 // bytes
27686
- };
27687
-
27688
- const values = Array.isArray( uniform.value ) ? uniform.value : [ uniform.value ];
28185
+ const uniformArray = Array.isArray( uniforms[ i ] ) ? uniforms[ i ] : [ uniforms[ i ] ];
27689
28186
 
27690
- for ( let j = 0, jl = values.length; j < jl; j ++ ) {
28187
+ for ( let j = 0, jl = uniformArray.length; j < jl; j ++ ) {
27691
28188
 
27692
- const value = values[ j ];
28189
+ const uniform = uniformArray[ j ];
27693
28190
 
27694
- const info = getUniformSize( value );
28191
+ const values = Array.isArray( uniform.value ) ? uniform.value : [ uniform.value ];
27695
28192
 
27696
- infos.boundary += info.boundary;
27697
- infos.storage += info.storage;
28193
+ for ( let k = 0, kl = values.length; k < kl; k ++ ) {
27698
28194
 
27699
- }
28195
+ const value = values[ k ];
27700
28196
 
27701
- // the following two properties will be used for partial buffer updates
28197
+ const info = getUniformSize( value );
27702
28198
 
27703
- uniform.__data = new Float32Array( infos.storage / Float32Array.BYTES_PER_ELEMENT );
27704
- uniform.__offset = offset;
28199
+ // Calculate the chunk offset
28200
+ const chunkOffsetUniform = offset % chunkSize;
27705
28201
 
27706
- //
28202
+ // Check for chunk overflow
28203
+ if ( chunkOffsetUniform !== 0 && ( chunkSize - chunkOffsetUniform ) < info.boundary ) {
27707
28204
 
27708
- if ( i > 0 ) {
28205
+ // Add padding and adjust offset
28206
+ offset += ( chunkSize - chunkOffsetUniform );
27709
28207
 
27710
- chunkOffset = offset % chunkSize;
28208
+ }
27711
28209
 
27712
- const remainingSizeInChunk = chunkSize - chunkOffset;
28210
+ // the following two properties will be used for partial buffer updates
27713
28211
 
27714
- // check for chunk overflow
28212
+ uniform.__data = new Float32Array( info.storage / Float32Array.BYTES_PER_ELEMENT );
28213
+ uniform.__offset = offset;
27715
28214
 
27716
- if ( chunkOffset !== 0 && ( remainingSizeInChunk - infos.boundary ) < 0 ) {
27717
28215
 
27718
- // add padding and adjust offset
28216
+ // Update the global offset
28217
+ offset += info.storage;
27719
28218
 
27720
- offset += ( chunkSize - chunkOffset );
27721
- uniform.__offset = offset;
27722
28219
 
27723
28220
  }
27724
28221
 
27725
28222
  }
27726
28223
 
27727
- offset += infos.storage;
27728
-
27729
28224
  }
27730
28225
 
27731
28226
  // ensure correct final padding
27732
28227
 
27733
- chunkOffset = offset % chunkSize;
28228
+ const chunkOffset = offset % chunkSize;
27734
28229
 
27735
28230
  if ( chunkOffset > 0 ) offset += ( chunkSize - chunkOffset );
27736
28231
 
@@ -27752,9 +28247,9 @@
27752
28247
 
27753
28248
  // determine sizes according to STD140
27754
28249
 
27755
- if ( typeof value === 'number' ) {
28250
+ if ( typeof value === 'number' || typeof value === 'boolean' ) {
27756
28251
 
27757
- // float/int
28252
+ // float/int/bool
27758
28253
 
27759
28254
  info.boundary = 4;
27760
28255
  info.storage = 4;
@@ -28682,7 +29177,11 @@
28682
29177
 
28683
29178
  }
28684
29179
 
28685
- if ( object.isInstancedMesh ) {
29180
+ if ( object.isBatchedMesh ) {
29181
+
29182
+ renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
29183
+
29184
+ } else if ( object.isInstancedMesh ) {
28686
29185
 
28687
29186
  renderer.renderInstances( drawStart, drawCount, object.count );
28688
29187
 
@@ -28991,7 +29490,11 @@
28991
29490
 
28992
29491
  //
28993
29492
 
28994
- background.render( currentRenderList, scene );
29493
+ if ( xr.enabled === false || xr.isPresenting === false || xr.hasDepthSensing() === false ) {
29494
+
29495
+ background.render( currentRenderList, scene );
29496
+
29497
+ }
28995
29498
 
28996
29499
  // render scene
28997
29500
 
@@ -29501,6 +30004,7 @@
29501
30004
  const materialProperties = properties.get( material );
29502
30005
 
29503
30006
  materialProperties.outputColorSpace = parameters.outputColorSpace;
30007
+ materialProperties.batching = parameters.batching;
29504
30008
  materialProperties.instancing = parameters.instancing;
29505
30009
  materialProperties.instancingColor = parameters.instancingColor;
29506
30010
  materialProperties.skinning = parameters.skinning;
@@ -29581,6 +30085,14 @@
29581
30085
 
29582
30086
  needsProgramChange = true;
29583
30087
 
30088
+ } else if ( object.isBatchedMesh && materialProperties.batching === false ) {
30089
+
30090
+ needsProgramChange = true;
30091
+
30092
+ } else if ( ! object.isBatchedMesh && materialProperties.batching === true ) {
30093
+
30094
+ needsProgramChange = true;
30095
+
29584
30096
  } else if ( object.isInstancedMesh && materialProperties.instancing === false ) {
29585
30097
 
29586
30098
  needsProgramChange = true;
@@ -29757,7 +30269,6 @@
29757
30269
  if ( skeleton.boneTexture === null ) skeleton.computeBoneTexture();
29758
30270
 
29759
30271
  p_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture, textures );
29760
- p_uniforms.setValue( _gl, 'boneTextureSize', skeleton.boneTextureSize );
29761
30272
 
29762
30273
  } else {
29763
30274
 
@@ -29769,6 +30280,13 @@
29769
30280
 
29770
30281
  }
29771
30282
 
30283
+ if ( object.isBatchedMesh ) {
30284
+
30285
+ p_uniforms.setOptional( _gl, object, 'batchingTexture' );
30286
+ p_uniforms.setValue( _gl, 'batchingTexture', object._matricesTexture, textures );
30287
+
30288
+ }
30289
+
29772
30290
  const morphAttributes = geometry.morphAttributes;
29773
30291
 
29774
30292
  if ( morphAttributes.position !== undefined || morphAttributes.normal !== undefined || ( morphAttributes.color !== undefined && capabilities.isWebGL2 === true ) ) {
@@ -30212,7 +30730,7 @@
30212
30730
  textures.setTexture3D( dstTexture, 0 );
30213
30731
  glTarget = _gl.TEXTURE_3D;
30214
30732
 
30215
- } else if ( dstTexture.isDataArrayTexture ) {
30733
+ } else if ( dstTexture.isDataArrayTexture || dstTexture.isCompressedArrayTexture ) {
30216
30734
 
30217
30735
  textures.setTexture2DArray( dstTexture, 0 );
30218
30736
  glTarget = _gl.TEXTURE_2D_ARRAY;
@@ -30234,7 +30752,7 @@
30234
30752
  const unpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
30235
30753
  const unpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
30236
30754
 
30237
- const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ 0 ] : srcTexture.image;
30755
+ const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
30238
30756
 
30239
30757
  _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
30240
30758
  _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
@@ -30339,20 +30857,6 @@
30339
30857
 
30340
30858
  }
30341
30859
 
30342
- get physicallyCorrectLights() { // @deprecated, r150
30343
-
30344
- console.warn( 'THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.' );
30345
- return ! this.useLegacyLights;
30346
-
30347
- }
30348
-
30349
- set physicallyCorrectLights( value ) { // @deprecated, r150
30350
-
30351
- console.warn( 'THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.' );
30352
- this.useLegacyLights = ! value;
30353
-
30354
- }
30355
-
30356
30860
  get outputEncoding() { // @deprecated, r152
30357
30861
 
30358
30862
  console.warn( 'THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead.' );
@@ -30458,7 +30962,8 @@
30458
30962
  this.count = array !== undefined ? array.length / stride : 0;
30459
30963
 
30460
30964
  this.usage = StaticDrawUsage;
30461
- this.updateRange = { offset: 0, count: - 1 };
30965
+ this._updateRange = { offset: 0, count: - 1 };
30966
+ this.updateRanges = [];
30462
30967
 
30463
30968
  this.version = 0;
30464
30969
 
@@ -30474,6 +30979,13 @@
30474
30979
 
30475
30980
  }
30476
30981
 
30982
+ get updateRange() {
30983
+
30984
+ warnOnce( 'THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead.' ); // @deprecated, r159
30985
+ return this._updateRange;
30986
+
30987
+ }
30988
+
30477
30989
  setUsage( value ) {
30478
30990
 
30479
30991
  this.usage = value;
@@ -30482,6 +30994,18 @@
30482
30994
 
30483
30995
  }
30484
30996
 
30997
+ addUpdateRange( start, count ) {
30998
+
30999
+ this.updateRanges.push( { start, count } );
31000
+
31001
+ }
31002
+
31003
+ clearUpdateRanges() {
31004
+
31005
+ this.updateRanges.length = 0;
31006
+
31007
+ }
31008
+
30485
31009
  copy( source ) {
30486
31010
 
30487
31011
  this.array = new source.array.constructor( source.array );
@@ -30588,7 +31112,7 @@
30588
31112
 
30589
31113
  }
30590
31114
 
30591
- const _vector$5 = /*@__PURE__*/ new Vector3();
31115
+ const _vector$6 = /*@__PURE__*/ new Vector3();
30592
31116
 
30593
31117
  class InterleavedBufferAttribute {
30594
31118
 
@@ -30628,11 +31152,11 @@
30628
31152
 
30629
31153
  for ( let i = 0, l = this.data.count; i < l; i ++ ) {
30630
31154
 
30631
- _vector$5.fromBufferAttribute( this, i );
31155
+ _vector$6.fromBufferAttribute( this, i );
30632
31156
 
30633
- _vector$5.applyMatrix4( m );
31157
+ _vector$6.applyMatrix4( m );
30634
31158
 
30635
- this.setXYZ( i, _vector$5.x, _vector$5.y, _vector$5.z );
31159
+ this.setXYZ( i, _vector$6.x, _vector$6.y, _vector$6.z );
30636
31160
 
30637
31161
  }
30638
31162
 
@@ -30644,11 +31168,11 @@
30644
31168
 
30645
31169
  for ( let i = 0, l = this.count; i < l; i ++ ) {
30646
31170
 
30647
- _vector$5.fromBufferAttribute( this, i );
31171
+ _vector$6.fromBufferAttribute( this, i );
30648
31172
 
30649
- _vector$5.applyNormalMatrix( m );
31173
+ _vector$6.applyNormalMatrix( m );
30650
31174
 
30651
- this.setXYZ( i, _vector$5.x, _vector$5.y, _vector$5.z );
31175
+ this.setXYZ( i, _vector$6.x, _vector$6.y, _vector$6.z );
30652
31176
 
30653
31177
  }
30654
31178
 
@@ -30660,11 +31184,11 @@
30660
31184
 
30661
31185
  for ( let i = 0, l = this.count; i < l; i ++ ) {
30662
31186
 
30663
- _vector$5.fromBufferAttribute( this, i );
31187
+ _vector$6.fromBufferAttribute( this, i );
30664
31188
 
30665
- _vector$5.transformDirection( m );
31189
+ _vector$6.transformDirection( m );
30666
31190
 
30667
- this.setXYZ( i, _vector$5.x, _vector$5.y, _vector$5.z );
31191
+ this.setXYZ( i, _vector$6.x, _vector$6.y, _vector$6.z );
30668
31192
 
30669
31193
  }
30670
31194
 
@@ -30672,6 +31196,26 @@
30672
31196
 
30673
31197
  }
30674
31198
 
31199
+ getComponent( index, component ) {
31200
+
31201
+ let value = this.array[ index * this.data.stride + this.offset + component ];
31202
+
31203
+ if ( this.normalized ) value = denormalize( value, this.array );
31204
+
31205
+ return value;
31206
+
31207
+ }
31208
+
31209
+ setComponent( index, component, value ) {
31210
+
31211
+ if ( this.normalized ) value = normalize( value, this.array );
31212
+
31213
+ this.data.array[ index * this.data.stride + this.offset + component ] = value;
31214
+
31215
+ return this;
31216
+
31217
+ }
31218
+
30675
31219
  setX( index, x ) {
30676
31220
 
30677
31221
  if ( this.normalized ) x = normalize( x, this.array );
@@ -31142,7 +31686,7 @@
31142
31686
  const _matrix4 = /*@__PURE__*/ new Matrix4();
31143
31687
  const _vertex = /*@__PURE__*/ new Vector3();
31144
31688
 
31145
- const _sphere$3 = /*@__PURE__*/ new Sphere();
31689
+ const _sphere$4 = /*@__PURE__*/ new Sphere();
31146
31690
  const _inverseMatrix$2 = /*@__PURE__*/ new Matrix4();
31147
31691
  const _ray$2 = /*@__PURE__*/ new Ray();
31148
31692
 
@@ -31239,10 +31783,10 @@
31239
31783
 
31240
31784
  if ( this.boundingSphere === null ) this.computeBoundingSphere();
31241
31785
 
31242
- _sphere$3.copy( this.boundingSphere );
31243
- _sphere$3.applyMatrix4( matrixWorld );
31786
+ _sphere$4.copy( this.boundingSphere );
31787
+ _sphere$4.applyMatrix4( matrixWorld );
31244
31788
 
31245
- if ( raycaster.ray.intersectsSphere( _sphere$3 ) === false ) return;
31789
+ if ( raycaster.ray.intersectsSphere( _sphere$4 ) === false ) return;
31246
31790
 
31247
31791
  // convert ray to local space of skinned mesh
31248
31792
 
@@ -31378,14 +31922,6 @@
31378
31922
 
31379
31923
  }
31380
31924
 
31381
- boneTransform( index, vector ) { // @deprecated, r151
31382
-
31383
- console.warn( 'THREE.SkinnedMesh: .boneTransform() was renamed to .applyBoneTransform() in r151.' );
31384
- return this.applyBoneTransform( index, vector );
31385
-
31386
- }
31387
-
31388
-
31389
31925
  }
31390
31926
 
31391
31927
  class Bone extends Object3D {
@@ -31434,7 +31970,6 @@
31434
31970
  this.boneMatrices = null;
31435
31971
 
31436
31972
  this.boneTexture = null;
31437
- this.boneTextureSize = 0;
31438
31973
 
31439
31974
  this.init();
31440
31975
 
@@ -31582,7 +32117,7 @@
31582
32117
  // 64x64 pixel texture max 1024 bones * 4 pixels = (64 * 64)
31583
32118
 
31584
32119
  let size = Math.sqrt( this.bones.length * 4 ); // 4 pixels needed for 1 matrix
31585
- size = ceilPowerOfTwo( size );
32120
+ size = Math.ceil( size / 4 ) * 4;
31586
32121
  size = Math.max( size, 4 );
31587
32122
 
31588
32123
  const boneMatrices = new Float32Array( size * size * 4 ); // 4 floats per RGBA pixel
@@ -31593,7 +32128,6 @@
31593
32128
 
31594
32129
  this.boneMatrices = boneMatrices;
31595
32130
  this.boneTexture = boneTexture;
31596
- this.boneTextureSize = size;
31597
32131
 
31598
32132
  return this;
31599
32133
 
@@ -31732,8 +32266,8 @@
31732
32266
 
31733
32267
  const _box3 = /*@__PURE__*/ new Box3();
31734
32268
  const _identity = /*@__PURE__*/ new Matrix4();
31735
- const _mesh = /*@__PURE__*/ new Mesh();
31736
- const _sphere$2 = /*@__PURE__*/ new Sphere();
32269
+ const _mesh$1 = /*@__PURE__*/ new Mesh();
32270
+ const _sphere$3 = /*@__PURE__*/ new Sphere();
31737
32271
 
31738
32272
  class InstancedMesh extends Mesh {
31739
32273
 
@@ -31813,9 +32347,9 @@
31813
32347
 
31814
32348
  this.getMatrixAt( i, _instanceLocalMatrix );
31815
32349
 
31816
- _sphere$2.copy( geometry.boundingSphere ).applyMatrix4( _instanceLocalMatrix );
32350
+ _sphere$3.copy( geometry.boundingSphere ).applyMatrix4( _instanceLocalMatrix );
31817
32351
 
31818
- this.boundingSphere.union( _sphere$2 );
32352
+ this.boundingSphere.union( _sphere$3 );
31819
32353
 
31820
32354
  }
31821
32355
 
@@ -31855,19 +32389,19 @@
31855
32389
  const matrixWorld = this.matrixWorld;
31856
32390
  const raycastTimes = this.count;
31857
32391
 
31858
- _mesh.geometry = this.geometry;
31859
- _mesh.material = this.material;
32392
+ _mesh$1.geometry = this.geometry;
32393
+ _mesh$1.material = this.material;
31860
32394
 
31861
- if ( _mesh.material === undefined ) return;
32395
+ if ( _mesh$1.material === undefined ) return;
31862
32396
 
31863
32397
  // test with bounding sphere first
31864
32398
 
31865
32399
  if ( this.boundingSphere === null ) this.computeBoundingSphere();
31866
32400
 
31867
- _sphere$2.copy( this.boundingSphere );
31868
- _sphere$2.applyMatrix4( matrixWorld );
32401
+ _sphere$3.copy( this.boundingSphere );
32402
+ _sphere$3.applyMatrix4( matrixWorld );
31869
32403
 
31870
- if ( raycaster.ray.intersectsSphere( _sphere$2 ) === false ) return;
32404
+ if ( raycaster.ray.intersectsSphere( _sphere$3 ) === false ) return;
31871
32405
 
31872
32406
  // now test each instance
31873
32407
 
@@ -31881,9 +32415,9 @@
31881
32415
 
31882
32416
  // the mesh represents this single instance
31883
32417
 
31884
- _mesh.matrixWorld = _instanceWorldMatrix;
32418
+ _mesh$1.matrixWorld = _instanceWorldMatrix;
31885
32419
 
31886
- _mesh.raycast( raycaster, _instanceIntersects );
32420
+ _mesh$1.raycast( raycaster, _instanceIntersects );
31887
32421
 
31888
32422
  // process the result of raycast
31889
32423
 
@@ -36121,6 +36655,25 @@
36121
36655
 
36122
36656
  scope.manager.itemStart( url );
36123
36657
 
36658
+ // If cached is a promise, wait for it to resolve
36659
+ if ( cached.then ) {
36660
+
36661
+ cached.then( imageBitmap => {
36662
+
36663
+ if ( onLoad ) onLoad( imageBitmap );
36664
+
36665
+ scope.manager.itemEnd( url );
36666
+
36667
+ } ).catch( e => {
36668
+
36669
+ if ( onError ) onError( e );
36670
+
36671
+ } );
36672
+ return;
36673
+
36674
+ }
36675
+
36676
+ // If cached is not a promise (i.e., it's already an imageBitmap)
36124
36677
  setTimeout( function () {
36125
36678
 
36126
36679
  if ( onLoad ) onLoad( cached );
@@ -36137,7 +36690,7 @@
36137
36690
  fetchOptions.credentials = ( this.crossOrigin === 'anonymous' ) ? 'same-origin' : 'include';
36138
36691
  fetchOptions.headers = this.requestHeader;
36139
36692
 
36140
- fetch( url, fetchOptions ).then( function ( res ) {
36693
+ const promise = fetch( url, fetchOptions ).then( function ( res ) {
36141
36694
 
36142
36695
  return res.blob();
36143
36696
 
@@ -36153,15 +36706,20 @@
36153
36706
 
36154
36707
  scope.manager.itemEnd( url );
36155
36708
 
36709
+ return imageBitmap;
36710
+
36156
36711
  } ).catch( function ( e ) {
36157
36712
 
36158
36713
  if ( onError ) onError( e );
36159
36714
 
36715
+ Cache.remove( url );
36716
+
36160
36717
  scope.manager.itemError( url );
36161
36718
  scope.manager.itemEnd( url );
36162
36719
 
36163
36720
  } );
36164
36721
 
36722
+ Cache.add( url, promise );
36165
36723
  scope.manager.itemStart( url );
36166
36724
 
36167
36725
  }
@@ -41429,12 +41987,6 @@
41429
41987
 
41430
41988
  function scan( type, chunks ) {
41431
41989
 
41432
- if ( chunks === undefined || chunks === null ) {
41433
-
41434
- chunks = 1;
41435
-
41436
- }
41437
-
41438
41990
  let _chunkSize = 1;
41439
41991
  let _array_type = Uint8Array;
41440
41992
 
@@ -41491,13 +42043,6 @@
41491
42043
 
41492
42044
  }
41493
42045
 
41494
- if ( chunks == 1 ) {
41495
-
41496
- // if only one chunk was requested, just return one value
41497
- return _bytes[ 0 ];
41498
-
41499
- }
41500
-
41501
42046
  // return the byte array
41502
42047
  return _bytes;
41503
42048
 
@@ -47106,9 +47651,14 @@
47106
47651
 
47107
47652
  } else if ( scope.object.isOrthographicCamera ) {
47108
47653
 
47109
- scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom / scale ) );
47110
- scope.object.updateProjectionMatrix();
47111
- zoomChanged = true;
47654
+ zoomChanged = scale !== 1;
47655
+
47656
+ if ( zoomChanged ) {
47657
+
47658
+ scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom / scale ) );
47659
+ scope.object.updateProjectionMatrix();
47660
+
47661
+ }
47112
47662
 
47113
47663
  }
47114
47664
 
@@ -47130,8 +47680,6 @@
47130
47680
  lastQuaternion.copy( scope.object.quaternion );
47131
47681
  lastTargetPosition.copy( scope.target );
47132
47682
 
47133
- zoomChanged = false;
47134
-
47135
47683
  return true;
47136
47684
 
47137
47685
  }
@@ -47212,6 +47760,8 @@
47212
47760
  const pointers = [];
47213
47761
  const pointerPositions = {};
47214
47762
 
47763
+ let controlActive = false;
47764
+
47215
47765
  function getAutoRotationAngle( deltaTime ) {
47216
47766
 
47217
47767
  if ( deltaTime !== null ) {
@@ -47226,9 +47776,10 @@
47226
47776
 
47227
47777
  }
47228
47778
 
47229
- function getZoomScale() {
47779
+ function getZoomScale( delta ) {
47230
47780
 
47231
- return Math.pow( 0.95, scope.zoomSpeed );
47781
+ const normalizedDelta = Math.abs( delta * 0.01 );
47782
+ return Math.pow( 0.95, scope.zoomSpeed * normalizedDelta );
47232
47783
 
47233
47784
  }
47234
47785
 
@@ -47355,7 +47906,7 @@
47355
47906
 
47356
47907
  }
47357
47908
 
47358
- function updateMouseParameters( event ) {
47909
+ function updateZoomParameters( x, y ) {
47359
47910
 
47360
47911
  if ( ! scope.zoomToCursor ) {
47361
47912
 
@@ -47366,13 +47917,13 @@
47366
47917
  performCursorZoom = true;
47367
47918
 
47368
47919
  const rect = scope.domElement.getBoundingClientRect();
47369
- const x = event.clientX - rect.left;
47370
- const y = event.clientY - rect.top;
47920
+ const dx = x - rect.left;
47921
+ const dy = y - rect.top;
47371
47922
  const w = rect.width;
47372
47923
  const h = rect.height;
47373
47924
 
47374
- mouse.x = ( x / w ) * 2 - 1;
47375
- mouse.y = - ( y / h ) * 2 + 1;
47925
+ mouse.x = ( dx / w ) * 2 - 1;
47926
+ mouse.y = - ( dy / h ) * 2 + 1;
47376
47927
 
47377
47928
  dollyDirection.set( mouse.x, mouse.y, 1 ).unproject( scope.object ).sub( scope.object.position ).normalize();
47378
47929
 
@@ -47396,7 +47947,7 @@
47396
47947
 
47397
47948
  function handleMouseDownDolly( event ) {
47398
47949
 
47399
- updateMouseParameters( event );
47950
+ updateZoomParameters( event.clientX, event.clientX );
47400
47951
  dollyStart.set( event.clientX, event.clientY );
47401
47952
 
47402
47953
  }
@@ -47433,11 +47984,11 @@
47433
47984
 
47434
47985
  if ( dollyDelta.y > 0 ) {
47435
47986
 
47436
- dollyOut( getZoomScale() );
47987
+ dollyOut( getZoomScale( dollyDelta.y ) );
47437
47988
 
47438
47989
  } else if ( dollyDelta.y < 0 ) {
47439
47990
 
47440
- dollyIn( getZoomScale() );
47991
+ dollyIn( getZoomScale( dollyDelta.y ) );
47441
47992
 
47442
47993
  }
47443
47994
 
@@ -47463,15 +48014,15 @@
47463
48014
 
47464
48015
  function handleMouseWheel( event ) {
47465
48016
 
47466
- updateMouseParameters( event );
48017
+ updateZoomParameters( event.clientX, event.clientY );
47467
48018
 
47468
48019
  if ( event.deltaY < 0 ) {
47469
48020
 
47470
- dollyIn( getZoomScale() );
48021
+ dollyIn( getZoomScale( event.deltaY ) );
47471
48022
 
47472
48023
  } else if ( event.deltaY > 0 ) {
47473
48024
 
47474
- dollyOut( getZoomScale() );
48025
+ dollyOut( getZoomScale( event.deltaY ) );
47475
48026
 
47476
48027
  }
47477
48028
 
@@ -47559,16 +48110,18 @@
47559
48110
 
47560
48111
  }
47561
48112
 
47562
- function handleTouchStartRotate() {
48113
+ function handleTouchStartRotate( event ) {
47563
48114
 
47564
48115
  if ( pointers.length === 1 ) {
47565
48116
 
47566
- rotateStart.set( pointers[ 0 ].pageX, pointers[ 0 ].pageY );
48117
+ rotateStart.set( event.pageX, event.pageY );
47567
48118
 
47568
48119
  } else {
47569
48120
 
47570
- const x = 0.5 * ( pointers[ 0 ].pageX + pointers[ 1 ].pageX );
47571
- const y = 0.5 * ( pointers[ 0 ].pageY + pointers[ 1 ].pageY );
48121
+ const position = getSecondPointerPosition( event );
48122
+
48123
+ const x = 0.5 * ( event.pageX + position.x );
48124
+ const y = 0.5 * ( event.pageY + position.y );
47572
48125
 
47573
48126
  rotateStart.set( x, y );
47574
48127
 
@@ -47576,16 +48129,18 @@
47576
48129
 
47577
48130
  }
47578
48131
 
47579
- function handleTouchStartPan() {
48132
+ function handleTouchStartPan( event ) {
47580
48133
 
47581
48134
  if ( pointers.length === 1 ) {
47582
48135
 
47583
- panStart.set( pointers[ 0 ].pageX, pointers[ 0 ].pageY );
48136
+ panStart.set( event.pageX, event.pageY );
47584
48137
 
47585
48138
  } else {
47586
48139
 
47587
- const x = 0.5 * ( pointers[ 0 ].pageX + pointers[ 1 ].pageX );
47588
- const y = 0.5 * ( pointers[ 0 ].pageY + pointers[ 1 ].pageY );
48140
+ const position = getSecondPointerPosition( event );
48141
+
48142
+ const x = 0.5 * ( event.pageX + position.x );
48143
+ const y = 0.5 * ( event.pageY + position.y );
47589
48144
 
47590
48145
  panStart.set( x, y );
47591
48146
 
@@ -47593,10 +48148,12 @@
47593
48148
 
47594
48149
  }
47595
48150
 
47596
- function handleTouchStartDolly() {
48151
+ function handleTouchStartDolly( event ) {
48152
+
48153
+ const position = getSecondPointerPosition( event );
47597
48154
 
47598
- const dx = pointers[ 0 ].pageX - pointers[ 1 ].pageX;
47599
- const dy = pointers[ 0 ].pageY - pointers[ 1 ].pageY;
48155
+ const dx = event.pageX - position.x;
48156
+ const dy = event.pageY - position.y;
47600
48157
 
47601
48158
  const distance = Math.sqrt( dx * dx + dy * dy );
47602
48159
 
@@ -47604,19 +48161,19 @@
47604
48161
 
47605
48162
  }
47606
48163
 
47607
- function handleTouchStartDollyPan() {
48164
+ function handleTouchStartDollyPan( event ) {
47608
48165
 
47609
- if ( scope.enableZoom ) handleTouchStartDolly();
48166
+ if ( scope.enableZoom ) handleTouchStartDolly( event );
47610
48167
 
47611
- if ( scope.enablePan ) handleTouchStartPan();
48168
+ if ( scope.enablePan ) handleTouchStartPan( event );
47612
48169
 
47613
48170
  }
47614
48171
 
47615
- function handleTouchStartDollyRotate() {
48172
+ function handleTouchStartDollyRotate( event ) {
47616
48173
 
47617
- if ( scope.enableZoom ) handleTouchStartDolly();
48174
+ if ( scope.enableZoom ) handleTouchStartDolly( event );
47618
48175
 
47619
- if ( scope.enableRotate ) handleTouchStartRotate();
48176
+ if ( scope.enableRotate ) handleTouchStartRotate( event );
47620
48177
 
47621
48178
  }
47622
48179
 
@@ -47691,6 +48248,11 @@
47691
48248
 
47692
48249
  dollyStart.copy( dollyEnd );
47693
48250
 
48251
+ const centerX = ( event.pageX + position.x ) * 0.5;
48252
+ const centerY = ( event.pageY + position.y ) * 0.5;
48253
+
48254
+ updateZoomParameters( centerX, centerY );
48255
+
47694
48256
  }
47695
48257
 
47696
48258
  function handleTouchMoveDollyPan( event ) {
@@ -47762,18 +48324,32 @@
47762
48324
 
47763
48325
  removePointer( event );
47764
48326
 
47765
- if ( pointers.length === 0 ) {
48327
+ switch ( pointers.length ) {
47766
48328
 
47767
- scope.domElement.releasePointerCapture( event.pointerId );
48329
+ case 0:
47768
48330
 
47769
- scope.domElement.removeEventListener( 'pointermove', onPointerMove );
47770
- scope.domElement.removeEventListener( 'pointerup', onPointerUp );
48331
+ scope.domElement.releasePointerCapture( event.pointerId );
47771
48332
 
47772
- }
48333
+ scope.domElement.removeEventListener( 'pointermove', onPointerMove );
48334
+ scope.domElement.removeEventListener( 'pointerup', onPointerUp );
47773
48335
 
47774
- scope.dispatchEvent( _endEvent$1 );
48336
+ scope.dispatchEvent( _endEvent$1 );
47775
48337
 
47776
- state = STATE.NONE;
48338
+ state = STATE.NONE;
48339
+
48340
+ break;
48341
+
48342
+ case 1:
48343
+
48344
+ const pointerId = pointers[ 0 ];
48345
+ const position = pointerPositions[ pointerId ];
48346
+
48347
+ // minimal placeholder event - allows state correction on pointer-up
48348
+ onTouchStart( { pointerId: pointerId, pageX: position.x, pageY: position.y } );
48349
+
48350
+ break;
48351
+
48352
+ }
47777
48353
 
47778
48354
  }
47779
48355
 
@@ -47914,12 +48490,76 @@
47914
48490
 
47915
48491
  scope.dispatchEvent( _startEvent$1 );
47916
48492
 
47917
- handleMouseWheel( event );
48493
+ handleMouseWheel( customWheelEvent( event ) );
47918
48494
 
47919
48495
  scope.dispatchEvent( _endEvent$1 );
47920
48496
 
47921
48497
  }
47922
48498
 
48499
+ function customWheelEvent( event ) {
48500
+
48501
+ const mode = event.deltaMode;
48502
+
48503
+ // minimal wheel event altered to meet delta-zoom demand
48504
+ const newEvent = {
48505
+ clientX: event.clientX,
48506
+ clientY: event.clientY,
48507
+ deltaY: event.deltaY,
48508
+ };
48509
+
48510
+ switch ( mode ) {
48511
+
48512
+ case 1: // LINE_MODE
48513
+ newEvent.deltaY *= 16;
48514
+ break;
48515
+
48516
+ case 2: // PAGE_MODE
48517
+ newEvent.deltaY *= 100;
48518
+ break;
48519
+
48520
+ }
48521
+
48522
+ // detect if event was triggered by pinching
48523
+ if ( event.ctrlKey && ! controlActive ) {
48524
+
48525
+ newEvent.deltaY *= 10;
48526
+
48527
+ }
48528
+
48529
+ return newEvent;
48530
+
48531
+ }
48532
+
48533
+ function interceptControlDown( event ) {
48534
+
48535
+ if ( event.key === 'Control' ) {
48536
+
48537
+ controlActive = true;
48538
+
48539
+
48540
+ const document = scope.domElement.getRootNode(); // offscreen canvas compatibility
48541
+
48542
+ document.addEventListener( 'keyup', interceptControlUp, { passive: true, capture: true } );
48543
+
48544
+ }
48545
+
48546
+ }
48547
+
48548
+ function interceptControlUp( event ) {
48549
+
48550
+ if ( event.key === 'Control' ) {
48551
+
48552
+ controlActive = false;
48553
+
48554
+
48555
+ const document = scope.domElement.getRootNode(); // offscreen canvas compatibility
48556
+
48557
+ document.removeEventListener( 'keyup', interceptControlUp, { passive: true, capture: true } );
48558
+
48559
+ }
48560
+
48561
+ }
48562
+
47923
48563
  function onKeyDown( event ) {
47924
48564
 
47925
48565
  if ( scope.enabled === false || scope.enablePan === false ) return;
@@ -47942,7 +48582,7 @@
47942
48582
 
47943
48583
  if ( scope.enableRotate === false ) return;
47944
48584
 
47945
- handleTouchStartRotate();
48585
+ handleTouchStartRotate( event );
47946
48586
 
47947
48587
  state = STATE.TOUCH_ROTATE;
47948
48588
 
@@ -47952,7 +48592,7 @@
47952
48592
 
47953
48593
  if ( scope.enablePan === false ) return;
47954
48594
 
47955
- handleTouchStartPan();
48595
+ handleTouchStartPan( event );
47956
48596
 
47957
48597
  state = STATE.TOUCH_PAN;
47958
48598
 
@@ -47974,7 +48614,7 @@
47974
48614
 
47975
48615
  if ( scope.enableZoom === false && scope.enablePan === false ) return;
47976
48616
 
47977
- handleTouchStartDollyPan();
48617
+ handleTouchStartDollyPan( event );
47978
48618
 
47979
48619
  state = STATE.TOUCH_DOLLY_PAN;
47980
48620
 
@@ -47984,7 +48624,7 @@
47984
48624
 
47985
48625
  if ( scope.enableZoom === false && scope.enableRotate === false ) return;
47986
48626
 
47987
- handleTouchStartDollyRotate();
48627
+ handleTouchStartDollyRotate( event );
47988
48628
 
47989
48629
  state = STATE.TOUCH_DOLLY_ROTATE;
47990
48630
 
@@ -48076,7 +48716,7 @@
48076
48716
 
48077
48717
  function addPointer( event ) {
48078
48718
 
48079
- pointers.push( event );
48719
+ pointers.push( event.pointerId );
48080
48720
 
48081
48721
  }
48082
48722
 
@@ -48086,7 +48726,7 @@
48086
48726
 
48087
48727
  for ( let i = 0; i < pointers.length; i ++ ) {
48088
48728
 
48089
- if ( pointers[ i ].pointerId == event.pointerId ) {
48729
+ if ( pointers[ i ] == event.pointerId ) {
48090
48730
 
48091
48731
  pointers.splice( i, 1 );
48092
48732
  return;
@@ -48114,9 +48754,9 @@
48114
48754
 
48115
48755
  function getSecondPointerPosition( event ) {
48116
48756
 
48117
- const pointer = ( event.pointerId === pointers[ 0 ].pointerId ) ? pointers[ 1 ] : pointers[ 0 ];
48757
+ const pointerId = ( event.pointerId === pointers[ 0 ] ) ? pointers[ 1 ] : pointers[ 0 ];
48118
48758
 
48119
- return pointerPositions[ pointer.pointerId ];
48759
+ return pointerPositions[ pointerId ];
48120
48760
 
48121
48761
  }
48122
48762
 
@@ -48128,6 +48768,10 @@
48128
48768
  scope.domElement.addEventListener( 'pointercancel', onPointerUp );
48129
48769
  scope.domElement.addEventListener( 'wheel', onMouseWheel, { passive: false } );
48130
48770
 
48771
+ const document = scope.domElement.getRootNode(); // offscreen canvas compatibility
48772
+
48773
+ document.addEventListener( 'keydown', interceptControlDown, { passive: true, capture: true } );
48774
+
48131
48775
  // force an update at start
48132
48776
 
48133
48777
  this.update();
@@ -49607,6 +50251,12 @@
49607
50251
 
49608
50252
  } );
49609
50253
 
50254
+ this.register( function ( parser ) {
50255
+
50256
+ return new GLTFMaterialsBumpExtension( parser );
50257
+
50258
+ } );
50259
+
49610
50260
  this.register( function ( parser ) {
49611
50261
 
49612
50262
  return new GLTFLightsExtension( parser );
@@ -49639,7 +50289,13 @@
49639
50289
 
49640
50290
  } else if ( this.path !== '' ) {
49641
50291
 
49642
- resourcePath = this.path;
50292
+ // If a base path is set, resources will be relative paths from that plus the relative path of the gltf file
50293
+ // Example path = 'https://my-cnd-server.com/', url = 'assets/models/model.gltf'
50294
+ // resourcePath = 'https://my-cnd-server.com/assets/models/'
50295
+ // referenced resource 'model.bin' will be loaded from 'https://my-cnd-server.com/assets/models/model.bin'
50296
+ // referenced resource '../textures/texture.png' will be loaded from 'https://my-cnd-server.com/assets/textures/texture.png'
50297
+ const relativeUrl = LoaderUtils.extractUrlBase( url );
50298
+ resourcePath = LoaderUtils.resolveURL( relativeUrl, this.path );
49643
50299
 
49644
50300
  } else {
49645
50301
 
@@ -49947,6 +50603,7 @@
49947
50603
  KHR_TEXTURE_TRANSFORM: 'KHR_texture_transform',
49948
50604
  KHR_MESH_QUANTIZATION: 'KHR_mesh_quantization',
49949
50605
  KHR_MATERIALS_EMISSIVE_STRENGTH: 'KHR_materials_emissive_strength',
50606
+ EXT_MATERIALS_BUMP: 'EXT_materials_bump',
49950
50607
  EXT_TEXTURE_WEBP: 'EXT_texture_webp',
49951
50608
  EXT_TEXTURE_AVIF: 'EXT_texture_avif',
49952
50609
  EXT_MESHOPT_COMPRESSION: 'EXT_meshopt_compression',
@@ -50657,6 +51314,61 @@
50657
51314
 
50658
51315
  }
50659
51316
 
51317
+
51318
+ /**
51319
+ * Materials bump Extension
51320
+ *
51321
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/EXT_materials_bump
51322
+ */
51323
+ class GLTFMaterialsBumpExtension {
51324
+
51325
+ constructor( parser ) {
51326
+
51327
+ this.parser = parser;
51328
+ this.name = EXTENSIONS.EXT_MATERIALS_BUMP;
51329
+
51330
+ }
51331
+
51332
+ getMaterialType( materialIndex ) {
51333
+
51334
+ const parser = this.parser;
51335
+ const materialDef = parser.json.materials[ materialIndex ];
51336
+
51337
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
51338
+
51339
+ return MeshPhysicalMaterial;
51340
+
51341
+ }
51342
+
51343
+ extendMaterialParams( materialIndex, materialParams ) {
51344
+
51345
+ const parser = this.parser;
51346
+ const materialDef = parser.json.materials[ materialIndex ];
51347
+
51348
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
51349
+
51350
+ return Promise.resolve();
51351
+
51352
+ }
51353
+
51354
+ const pending = [];
51355
+
51356
+ const extension = materialDef.extensions[ this.name ];
51357
+
51358
+ materialParams.bumpScale = extension.bumpFactor !== undefined ? extension.bumpFactor : 1.0;
51359
+
51360
+ if ( extension.bumpTexture !== undefined ) {
51361
+
51362
+ pending.push( parser.assignTexture( materialParams, 'bumpMap', extension.bumpTexture ) );
51363
+
51364
+ }
51365
+
51366
+ return Promise.all( pending );
51367
+
51368
+ }
51369
+
51370
+ }
51371
+
50660
51372
  /**
50661
51373
  * Materials anisotropy Extension
50662
51374
  *
@@ -51311,7 +52023,7 @@
51311
52023
 
51312
52024
  return parser.getDependency( 'bufferView', bufferViewIndex ).then( function ( bufferView ) {
51313
52025
 
51314
- return new Promise( function ( resolve ) {
52026
+ return new Promise( function ( resolve, reject ) {
51315
52027
 
51316
52028
  dracoLoader.decodeDracoFile( bufferView, function ( geometry ) {
51317
52029
 
@@ -51326,7 +52038,7 @@
51326
52038
 
51327
52039
  resolve( geometry );
51328
52040
 
51329
- }, threeAttributeMap, attributeTypeMap );
52041
+ }, threeAttributeMap, attributeTypeMap, LinearSRGBColorSpace, reject );
51330
52042
 
51331
52043
  } );
51332
52044
 
@@ -54217,17 +54929,32 @@
54217
54929
 
54218
54930
  }
54219
54931
 
54932
+ async detectSupportAsync( renderer ) {
54933
+
54934
+ this.workerConfig = {
54935
+ astcSupported: await renderer.hasFeatureAsync( 'texture-compression-astc' ),
54936
+ etc1Supported: await renderer.hasFeatureAsync( 'texture-compression-etc1' ),
54937
+ etc2Supported: await renderer.hasFeatureAsync( 'texture-compression-etc2' ),
54938
+ dxtSupported: await renderer.hasFeatureAsync( 'texture-compression-bc' ),
54939
+ bptcSupported: await renderer.hasFeatureAsync( 'texture-compression-bptc' ),
54940
+ pvrtcSupported: await renderer.hasFeatureAsync( 'texture-compression-pvrtc' )
54941
+ };
54942
+
54943
+ return this;
54944
+
54945
+ }
54946
+
54220
54947
  detectSupport( renderer ) {
54221
54948
 
54222
54949
  if ( renderer.isWebGPURenderer === true ) {
54223
54950
 
54224
54951
  this.workerConfig = {
54225
54952
  astcSupported: renderer.hasFeature( 'texture-compression-astc' ),
54226
- etc1Supported: false,
54953
+ etc1Supported: renderer.hasFeature( 'texture-compression-etc1' ),
54227
54954
  etc2Supported: renderer.hasFeature( 'texture-compression-etc2' ),
54228
54955
  dxtSupported: renderer.hasFeature( 'texture-compression-bc' ),
54229
- bptcSupported: false,
54230
- pvrtcSupported: false
54956
+ bptcSupported: renderer.hasFeature( 'texture-compression-bptc' ),
54957
+ pvrtcSupported: renderer.hasFeature( 'texture-compression-pvrtc' )
54231
54958
  };
54232
54959
 
54233
54960
  } else {
@@ -54962,8 +55689,8 @@
54962
55689
  if ( UNCOMPRESSED_FORMATS.has( FORMAT_MAP[ vkFormat ] ) ) {
54963
55690
 
54964
55691
  texture = container.pixelDepth === 0
54965
- ? new DataTexture( mipmaps[ 0 ].data, container.pixelWidth, container.pixelHeight )
54966
- : new Data3DTexture( mipmaps[ 0 ].data, container.pixelWidth, container.pixelHeight, container.pixelDepth );
55692
+ ? new DataTexture( mipmaps[ 0 ].data, container.pixelWidth, container.pixelHeight )
55693
+ : new Data3DTexture( mipmaps[ 0 ].data, container.pixelWidth, container.pixelHeight, container.pixelDepth );
54967
55694
 
54968
55695
  } else {
54969
55696
 
@@ -55085,13 +55812,14 @@
55085
55812
 
55086
55813
  }
55087
55814
 
55088
- parse( buffer, onLoad, onError ) {
55815
+
55816
+ parse( buffer, onLoad, onError = ()=>{} ) {
55089
55817
 
55090
55818
  this.decodeDracoFile( buffer, onLoad, null, null, SRGBColorSpace ).catch( onError );
55091
55819
 
55092
55820
  }
55093
55821
 
55094
- decodeDracoFile( buffer, callback, attributeIDs, attributeTypes, vertexColorSpace = LinearSRGBColorSpace ) {
55822
+ decodeDracoFile( buffer, callback, attributeIDs, attributeTypes, vertexColorSpace = LinearSRGBColorSpace, onError = () => {} ) {
55095
55823
 
55096
55824
  const taskConfig = {
55097
55825
  attributeIDs: attributeIDs || this.defaultAttributeIDs,
@@ -55100,7 +55828,7 @@
55100
55828
  vertexColorSpace: vertexColorSpace,
55101
55829
  };
55102
55830
 
55103
- return this.decodeGeometry( buffer, taskConfig ).then( callback );
55831
+ return this.decodeGeometry( buffer, taskConfig ).then( callback ).catch( onError );
55104
55832
 
55105
55833
  }
55106
55834
 
@@ -69393,7 +70121,12 @@
69393
70121
  if (ev.key === "Shift") {
69394
70122
  this.removeDragMode();
69395
70123
  }
70124
+ });
70125
+ this.container.addEventListener("keyup", (ev) => {
69396
70126
  if (ev.key === 'Control' || ev.key === 'Meta') {
70127
+ /**
70128
+ * if ctrl pressed remove the drag mode
70129
+ */
69397
70130
  if (this.protectedData.Is_Ctrl_Pressed) {
69398
70131
  this.removeDragMode();
69399
70132
  }
@@ -69401,8 +70134,6 @@
69401
70134
  this.configDragMode();
69402
70135
  }
69403
70136
  }
69404
- });
69405
- this.container.addEventListener("keyup", (ev) => {
69406
70137
  if (ev.key === "Shift" && !this.gui_states.sphere) {
69407
70138
  if (this.protectedData.Is_Ctrl_Pressed) {
69408
70139
  return;
@@ -69876,6 +70607,7 @@
69876
70607
  this.initDrawToolCore();
69877
70608
  }
69878
70609
  initDrawToolCore() {
70610
+ let undoFlag = false;
69879
70611
  this.container.addEventListener("keydown", (ev) => {
69880
70612
  if (ev.key === "Shift" && !this.gui_states.sphere) {
69881
70613
  if (this.protectedData.Is_Ctrl_Pressed) {
@@ -69885,7 +70617,23 @@
69885
70617
  this.protectedData.Is_Shift_Pressed = true;
69886
70618
  this.nrrd_states.enableCursorChoose = false;
69887
70619
  }
70620
+ if (ev.key === "s") {
70621
+ this.protectedData.Is_Draw = false;
70622
+ this.nrrd_states.enableCursorChoose =
70623
+ !this.nrrd_states.enableCursorChoose;
70624
+ }
70625
+ if ((ev.ctrlKey || ev.metaKey) && ev.code === "KeyZ") {
70626
+ undoFlag = true;
70627
+ this.undoLastPainting();
70628
+ }
70629
+ });
70630
+ this.container.addEventListener("keyup", (ev) => {
69888
70631
  if (ev.key === 'Control' || ev.key === 'Meta') {
70632
+ if (undoFlag) {
70633
+ this.gui_states.readyToUpdate = true;
70634
+ undoFlag = false;
70635
+ return;
70636
+ }
69889
70637
  // Ctrl key pressed on either Windows or macOS
69890
70638
  this.protectedData.Is_Shift_Pressed = false;
69891
70639
  this.protectedData.Is_Ctrl_Pressed = !this.protectedData.Is_Ctrl_Pressed;
@@ -69894,15 +70642,9 @@
69894
70642
  }
69895
70643
  else {
69896
70644
  this.removeContrastDragMode();
70645
+ this.gui_states.readyToUpdate = true;
69897
70646
  }
69898
70647
  }
69899
- if (ev.key === "s") {
69900
- this.protectedData.Is_Draw = false;
69901
- this.nrrd_states.enableCursorChoose =
69902
- !this.nrrd_states.enableCursorChoose;
69903
- }
69904
- });
69905
- this.container.addEventListener("keyup", (ev) => {
69906
70648
  if (ev.key === "Shift") {
69907
70649
  this.protectedData.Is_Shift_Pressed = false;
69908
70650
  }
@@ -70291,11 +71033,6 @@
70291
71033
  this.redrawDisplayCanvas();
70292
71034
  }
70293
71035
  };
70294
- document.addEventListener("keydown", (e) => {
70295
- if ((e.ctrlKey || e.metaKey) && e.code === "KeyZ") {
70296
- this.undoLastPainting();
70297
- }
70298
- });
70299
71036
  }
70300
71037
  drawLinesOnLayer(ctx, x, y) {
70301
71038
  ctx.beginPath();
@@ -72179,8 +72916,8 @@
72179
72916
  }
72180
72917
 
72181
72918
  // import * as kiwrious from "copper3d_plugin_heart_k";
72182
- const REVISION = "v2.0.7";
72183
- console.log("%cCopper3D Visualisation %cBeta:v2.0.7", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
72919
+ const REVISION = "v2.0.9";
72920
+ console.log("%cCopper3D Visualisation %cBeta:v2.0.9", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
72184
72921
 
72185
72922
  exports.CameraViewPoint = CameraViewPoint;
72186
72923
  exports.Copper3dTrackballControls = Copper3dTrackballControls;