react-globe.gl 2.26.0 → 2.27.1

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.
@@ -1,4 +1,4 @@
1
- // Version 2.26.0 react-globe.gl - https://github.com/vasturiano/react-globe.gl
1
+ // Version 2.27.1 react-globe.gl - https://github.com/vasturiano/react-globe.gl
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react')) :
4
4
  typeof define === 'function' && define.amd ? define(['react'], factory) :
@@ -314,7 +314,7 @@
314
314
  * Copyright 2010-2023 Three.js Authors
315
315
  * SPDX-License-Identifier: MIT
316
316
  */
317
- const REVISION = '157';
317
+ const REVISION = '159';
318
318
 
319
319
  const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
320
320
  const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
@@ -349,6 +349,10 @@
349
349
  const DstColorFactor = 208;
350
350
  const OneMinusDstColorFactor = 209;
351
351
  const SrcAlphaSaturateFactor = 210;
352
+ const ConstantColorFactor = 211;
353
+ const OneMinusConstantColorFactor = 212;
354
+ const ConstantAlphaFactor = 213;
355
+ const OneMinusConstantAlphaFactor = 214;
352
356
  const NeverDepth = 0;
353
357
  const AlwaysDepth = 1;
354
358
  const LessDepth = 2;
@@ -4286,21 +4290,20 @@
4286
4290
 
4287
4291
  applyQuaternion( q ) {
4288
4292
 
4289
- const x = this.x, y = this.y, z = this.z;
4290
- const qx = q.x, qy = q.y, qz = q.z, qw = q.w;
4293
+ // quaternion q is assumed to have unit length
4291
4294
 
4292
- // calculate quat * vector
4293
-
4294
- const ix = qw * x + qy * z - qz * y;
4295
- const iy = qw * y + qz * x - qx * z;
4296
- const iz = qw * z + qx * y - qy * x;
4297
- const iw = - qx * x - qy * y - qz * z;
4295
+ const vx = this.x, vy = this.y, vz = this.z;
4296
+ const qx = q.x, qy = q.y, qz = q.z, qw = q.w;
4298
4297
 
4299
- // calculate result * inverse quat
4298
+ // t = 2 * cross( q.xyz, v );
4299
+ const tx = 2 * ( qy * vz - qz * vy );
4300
+ const ty = 2 * ( qz * vx - qx * vz );
4301
+ const tz = 2 * ( qx * vy - qy * vx );
4300
4302
 
4301
- this.x = ix * qw + iw * - qx + iy * - qz - iz * - qy;
4302
- this.y = iy * qw + iw * - qy + iz * - qx - ix * - qz;
4303
- this.z = iz * qw + iw * - qz + ix * - qy - iy * - qx;
4303
+ // v + q.w * t + cross( q.xyz, t );
4304
+ this.x = vx + qw * tx + qy * tz - qz * ty;
4305
+ this.y = vy + qw * ty + qz * tx - qx * tz;
4306
+ this.z = vz + qw * tz + qx * ty - qy * tx;
4304
4307
 
4305
4308
  return this;
4306
4309
 
@@ -4541,9 +4544,9 @@
4541
4544
 
4542
4545
  projectOnPlane( planeNormal ) {
4543
4546
 
4544
- _vector$b.copy( this ).projectOnVector( planeNormal );
4547
+ _vector$c.copy( this ).projectOnVector( planeNormal );
4545
4548
 
4546
- return this.sub( _vector$b );
4549
+ return this.sub( _vector$c );
4547
4550
 
4548
4551
  }
4549
4552
 
@@ -4552,7 +4555,7 @@
4552
4555
  // reflect incident vector off plane orthogonal to normal
4553
4556
  // normal is assumed to have unit length
4554
4557
 
4555
- return this.sub( _vector$b.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
4558
+ return this.sub( _vector$c.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
4556
4559
 
4557
4560
  }
4558
4561
 
@@ -4754,7 +4757,7 @@
4754
4757
 
4755
4758
  }
4756
4759
 
4757
- const _vector$b = /*@__PURE__*/ new Vector3();
4760
+ const _vector$c = /*@__PURE__*/ new Vector3();
4758
4761
  const _quaternion$4 = /*@__PURE__*/ new Quaternion();
4759
4762
 
4760
4763
  class Box3 {
@@ -4783,7 +4786,7 @@
4783
4786
 
4784
4787
  for ( let i = 0, il = array.length; i < il; i += 3 ) {
4785
4788
 
4786
- this.expandByPoint( _vector$a.fromArray( array, i ) );
4789
+ this.expandByPoint( _vector$b.fromArray( array, i ) );
4787
4790
 
4788
4791
  }
4789
4792
 
@@ -4797,7 +4800,7 @@
4797
4800
 
4798
4801
  for ( let i = 0, il = attribute.count; i < il; i ++ ) {
4799
4802
 
4800
- this.expandByPoint( _vector$a.fromBufferAttribute( attribute, i ) );
4803
+ this.expandByPoint( _vector$b.fromBufferAttribute( attribute, i ) );
4801
4804
 
4802
4805
  }
4803
4806
 
@@ -4821,7 +4824,7 @@
4821
4824
 
4822
4825
  setFromCenterAndSize( center, size ) {
4823
4826
 
4824
- const halfSize = _vector$a.copy( size ).multiplyScalar( 0.5 );
4827
+ const halfSize = _vector$b.copy( size ).multiplyScalar( 0.5 );
4825
4828
 
4826
4829
  this.min.copy( center ).sub( halfSize );
4827
4830
  this.max.copy( center ).add( halfSize );
@@ -4916,50 +4919,67 @@
4916
4919
 
4917
4920
  object.updateWorldMatrix( false, false );
4918
4921
 
4919
- if ( object.boundingBox !== undefined ) {
4922
+ const geometry = object.geometry;
4920
4923
 
4921
- if ( object.boundingBox === null ) {
4924
+ if ( geometry !== undefined ) {
4922
4925
 
4923
- object.computeBoundingBox();
4926
+ const positionAttribute = geometry.getAttribute( 'position' );
4924
4927
 
4925
- }
4928
+ // precise AABB computation based on vertex data requires at least a position attribute.
4929
+ // instancing isn't supported so far and uses the normal (conservative) code path.
4926
4930
 
4927
- _box$3.copy( object.boundingBox );
4928
- _box$3.applyMatrix4( object.matrixWorld );
4931
+ if ( precise === true && positionAttribute !== undefined && object.isInstancedMesh !== true ) {
4929
4932
 
4930
- this.union( _box$3 );
4933
+ for ( let i = 0, l = positionAttribute.count; i < l; i ++ ) {
4931
4934
 
4932
- } else {
4935
+ if ( object.isMesh === true ) {
4933
4936
 
4934
- const geometry = object.geometry;
4937
+ object.getVertexPosition( i, _vector$b );
4938
+
4939
+ } else {
4940
+
4941
+ _vector$b.fromBufferAttribute( positionAttribute, i );
4942
+
4943
+ }
4944
+
4945
+ _vector$b.applyMatrix4( object.matrixWorld );
4946
+ this.expandByPoint( _vector$b );
4947
+
4948
+ }
4949
+
4950
+ } else {
4935
4951
 
4936
- if ( geometry !== undefined ) {
4952
+ if ( object.boundingBox !== undefined ) {
4937
4953
 
4938
- if ( precise && geometry.attributes !== undefined && geometry.attributes.position !== undefined ) {
4954
+ // object-level bounding box
4939
4955
 
4940
- const position = geometry.attributes.position;
4941
- for ( let i = 0, l = position.count; i < l; i ++ ) {
4956
+ if ( object.boundingBox === null ) {
4942
4957
 
4943
- _vector$a.fromBufferAttribute( position, i ).applyMatrix4( object.matrixWorld );
4944
- this.expandByPoint( _vector$a );
4958
+ object.computeBoundingBox();
4945
4959
 
4946
4960
  }
4947
4961
 
4962
+ _box$4.copy( object.boundingBox );
4963
+
4964
+
4948
4965
  } else {
4949
4966
 
4967
+ // geometry-level bounding box
4968
+
4950
4969
  if ( geometry.boundingBox === null ) {
4951
4970
 
4952
4971
  geometry.computeBoundingBox();
4953
4972
 
4954
4973
  }
4955
4974
 
4956
- _box$3.copy( geometry.boundingBox );
4957
- _box$3.applyMatrix4( object.matrixWorld );
4958
-
4959
- this.union( _box$3 );
4975
+ _box$4.copy( geometry.boundingBox );
4960
4976
 
4961
4977
  }
4962
4978
 
4979
+ _box$4.applyMatrix4( object.matrixWorld );
4980
+
4981
+ this.union( _box$4 );
4982
+
4963
4983
  }
4964
4984
 
4965
4985
  }
@@ -5017,10 +5037,10 @@
5017
5037
  intersectsSphere( sphere ) {
5018
5038
 
5019
5039
  // Find the point on the AABB closest to the sphere center.
5020
- this.clampPoint( sphere.center, _vector$a );
5040
+ this.clampPoint( sphere.center, _vector$b );
5021
5041
 
5022
5042
  // If that point is inside the sphere, the AABB and sphere intersect.
5023
- return _vector$a.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius );
5043
+ return _vector$b.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius );
5024
5044
 
5025
5045
  }
5026
5046
 
@@ -5132,7 +5152,7 @@
5132
5152
 
5133
5153
  distanceToPoint( point ) {
5134
5154
 
5135
- return this.clampPoint( point, _vector$a ).distanceTo( point );
5155
+ return this.clampPoint( point, _vector$b ).distanceTo( point );
5136
5156
 
5137
5157
  }
5138
5158
 
@@ -5146,7 +5166,7 @@
5146
5166
 
5147
5167
  this.getCenter( target.center );
5148
5168
 
5149
- target.radius = this.getSize( _vector$a ).length() * 0.5;
5169
+ target.radius = this.getSize( _vector$b ).length() * 0.5;
5150
5170
 
5151
5171
  }
5152
5172
 
@@ -5224,9 +5244,9 @@
5224
5244
  /*@__PURE__*/ new Vector3()
5225
5245
  ];
5226
5246
 
5227
- const _vector$a = /*@__PURE__*/ new Vector3();
5247
+ const _vector$b = /*@__PURE__*/ new Vector3();
5228
5248
 
5229
- const _box$3 = /*@__PURE__*/ new Box3();
5249
+ const _box$4 = /*@__PURE__*/ new Box3();
5230
5250
 
5231
5251
  // triangle centered vertices
5232
5252
 
@@ -5271,7 +5291,7 @@
5271
5291
 
5272
5292
  }
5273
5293
 
5274
- const _box$2 = /*@__PURE__*/ new Box3();
5294
+ const _box$3 = /*@__PURE__*/ new Box3();
5275
5295
  const _v1$6 = /*@__PURE__*/ new Vector3();
5276
5296
  const _v2$3 = /*@__PURE__*/ new Vector3();
5277
5297
 
@@ -5303,7 +5323,7 @@
5303
5323
 
5304
5324
  } else {
5305
5325
 
5306
- _box$2.setFromPoints( points ).getCenter( center );
5326
+ _box$3.setFromPoints( points ).getCenter( center );
5307
5327
 
5308
5328
  }
5309
5329
 
@@ -5510,7 +5530,7 @@
5510
5530
 
5511
5531
  }
5512
5532
 
5513
- const _vector$9 = /*@__PURE__*/ new Vector3();
5533
+ const _vector$a = /*@__PURE__*/ new Vector3();
5514
5534
  const _segCenter = /*@__PURE__*/ new Vector3();
5515
5535
  const _segDir = /*@__PURE__*/ new Vector3();
5516
5536
  const _diff = /*@__PURE__*/ new Vector3();
@@ -5562,7 +5582,7 @@
5562
5582
 
5563
5583
  recast( t ) {
5564
5584
 
5565
- this.origin.copy( this.at( t, _vector$9 ) );
5585
+ this.origin.copy( this.at( t, _vector$a ) );
5566
5586
 
5567
5587
  return this;
5568
5588
 
@@ -5592,7 +5612,7 @@
5592
5612
 
5593
5613
  distanceSqToPoint( point ) {
5594
5614
 
5595
- const directionDistance = _vector$9.subVectors( point, this.origin ).dot( this.direction );
5615
+ const directionDistance = _vector$a.subVectors( point, this.origin ).dot( this.direction );
5596
5616
 
5597
5617
  // point behind the ray
5598
5618
 
@@ -5602,9 +5622,9 @@
5602
5622
 
5603
5623
  }
5604
5624
 
5605
- _vector$9.copy( this.origin ).addScaledVector( this.direction, directionDistance );
5625
+ _vector$a.copy( this.origin ).addScaledVector( this.direction, directionDistance );
5606
5626
 
5607
- return _vector$9.distanceToSquared( point );
5627
+ return _vector$a.distanceToSquared( point );
5608
5628
 
5609
5629
  }
5610
5630
 
@@ -5729,9 +5749,9 @@
5729
5749
 
5730
5750
  intersectSphere( sphere, target ) {
5731
5751
 
5732
- _vector$9.subVectors( sphere.center, this.origin );
5733
- const tca = _vector$9.dot( this.direction );
5734
- const d2 = _vector$9.dot( _vector$9 ) - tca * tca;
5752
+ _vector$a.subVectors( sphere.center, this.origin );
5753
+ const tca = _vector$a.dot( this.direction );
5754
+ const d2 = _vector$a.dot( _vector$a ) - tca * tca;
5735
5755
  const radius2 = sphere.radius * sphere.radius;
5736
5756
 
5737
5757
  if ( d2 > radius2 ) return null;
@@ -5898,7 +5918,7 @@
5898
5918
 
5899
5919
  intersectsBox( box ) {
5900
5920
 
5901
- return this.intersectBox( box, _vector$9 ) !== null;
5921
+ return this.intersectBox( box, _vector$a ) !== null;
5902
5922
 
5903
5923
  }
5904
5924
 
@@ -6911,7 +6931,7 @@
6911
6931
  const _y = /*@__PURE__*/ new Vector3();
6912
6932
  const _z = /*@__PURE__*/ new Vector3();
6913
6933
 
6914
- const _matrix = /*@__PURE__*/ new Matrix4();
6934
+ const _matrix$1 = /*@__PURE__*/ new Matrix4();
6915
6935
  const _quaternion$3 = /*@__PURE__*/ new Quaternion();
6916
6936
 
6917
6937
  class Euler {
@@ -7146,9 +7166,9 @@
7146
7166
 
7147
7167
  setFromQuaternion( q, order, update ) {
7148
7168
 
7149
- _matrix.makeRotationFromQuaternion( q );
7169
+ _matrix$1.makeRotationFromQuaternion( q );
7150
7170
 
7151
- return this.setFromRotationMatrix( _matrix, order, update );
7171
+ return this.setFromRotationMatrix( _matrix$1, order, update );
7152
7172
 
7153
7173
  }
7154
7174
 
@@ -7370,9 +7390,9 @@
7370
7390
  this.matrixWorld = new Matrix4();
7371
7391
 
7372
7392
  this.matrixAutoUpdate = Object3D.DEFAULT_MATRIX_AUTO_UPDATE;
7373
- this.matrixWorldNeedsUpdate = false;
7374
7393
 
7375
7394
  this.matrixWorldAutoUpdate = Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE; // checked by the renderer
7395
+ this.matrixWorldNeedsUpdate = false;
7376
7396
 
7377
7397
  this.layers = new Layers();
7378
7398
  this.visible = true;
@@ -7389,6 +7409,10 @@
7389
7409
 
7390
7410
  }
7391
7411
 
7412
+ onBeforeShadow( /* renderer, object, camera, shadowCamera, geometry, depthMaterial, group */ ) {}
7413
+
7414
+ onAfterShadow( /* renderer, object, camera, shadowCamera, geometry, depthMaterial, group */ ) {}
7415
+
7392
7416
  onBeforeRender( /* renderer, scene, camera, geometry, material, group */ ) {}
7393
7417
 
7394
7418
  onAfterRender( /* renderer, scene, camera, geometry, material, group */ ) {}
@@ -7729,21 +7753,15 @@
7729
7753
 
7730
7754
  }
7731
7755
 
7732
- getObjectsByProperty( name, value ) {
7733
-
7734
- let result = [];
7756
+ getObjectsByProperty( name, value, result = [] ) {
7735
7757
 
7736
7758
  if ( this[ name ] === value ) result.push( this );
7737
7759
 
7738
- for ( let i = 0, l = this.children.length; i < l; i ++ ) {
7739
-
7740
- const childResult = this.children[ i ].getObjectsByProperty( name, value );
7741
-
7742
- if ( childResult.length > 0 ) {
7760
+ const children = this.children;
7743
7761
 
7744
- result = result.concat( childResult );
7762
+ for ( let i = 0, l = children.length; i < l; i ++ ) {
7745
7763
 
7746
- }
7764
+ children[ i ].getObjectsByProperty( name, value, result );
7747
7765
 
7748
7766
  }
7749
7767
 
@@ -7991,6 +8009,56 @@
7991
8009
 
7992
8010
  }
7993
8011
 
8012
+ if ( this.isBatchedMesh ) {
8013
+
8014
+ object.type = 'BatchedMesh';
8015
+ object.perObjectFrustumCulled = this.perObjectFrustumCulled;
8016
+ object.sortObjects = this.sortObjects;
8017
+
8018
+ object.drawRanges = this._drawRanges;
8019
+ object.reservedRanges = this._reservedRanges;
8020
+
8021
+ object.visibility = this._visibility;
8022
+ object.active = this._active;
8023
+ object.bounds = this._bounds.map( bound => ( {
8024
+ boxInitialized: bound.boxInitialized,
8025
+ boxMin: bound.box.min.toArray(),
8026
+ boxMax: bound.box.max.toArray(),
8027
+
8028
+ sphereInitialized: bound.sphereInitialized,
8029
+ sphereRadius: bound.sphere.radius,
8030
+ sphereCenter: bound.sphere.center.toArray()
8031
+ } ) );
8032
+
8033
+ object.maxGeometryCount = this._maxGeometryCount;
8034
+ object.maxVertexCount = this._maxVertexCount;
8035
+ object.maxIndexCount = this._maxIndexCount;
8036
+
8037
+ object.geometryInitialized = this._geometryInitialized;
8038
+ object.geometryCount = this._geometryCount;
8039
+
8040
+ object.matricesTexture = this._matricesTexture.toJSON( meta );
8041
+
8042
+ if ( this.boundingSphere !== null ) {
8043
+
8044
+ object.boundingSphere = {
8045
+ center: object.boundingSphere.center.toArray(),
8046
+ radius: object.boundingSphere.radius
8047
+ };
8048
+
8049
+ }
8050
+
8051
+ if ( this.boundingBox !== null ) {
8052
+
8053
+ object.boundingBox = {
8054
+ min: object.boundingBox.min.toArray(),
8055
+ max: object.boundingBox.max.toArray()
8056
+ };
8057
+
8058
+ }
8059
+
8060
+ }
8061
+
7994
8062
  //
7995
8063
 
7996
8064
  function serialize( library, element ) {
@@ -8191,9 +8259,9 @@
8191
8259
  this.matrixWorld.copy( source.matrixWorld );
8192
8260
 
8193
8261
  this.matrixAutoUpdate = source.matrixAutoUpdate;
8194
- this.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate;
8195
8262
 
8196
8263
  this.matrixWorldAutoUpdate = source.matrixWorldAutoUpdate;
8264
+ this.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate;
8197
8265
 
8198
8266
  this.layers.mask = source.layers.mask;
8199
8267
  this.visible = source.visible;
@@ -8555,509 +8623,6 @@
8555
8623
 
8556
8624
  }
8557
8625
 
8558
- let _materialId = 0;
8559
-
8560
- class Material extends EventDispatcher {
8561
-
8562
- constructor() {
8563
-
8564
- super();
8565
-
8566
- this.isMaterial = true;
8567
-
8568
- Object.defineProperty( this, 'id', { value: _materialId ++ } );
8569
-
8570
- this.uuid = generateUUID();
8571
-
8572
- this.name = '';
8573
- this.type = 'Material';
8574
-
8575
- this.blending = NormalBlending;
8576
- this.side = FrontSide;
8577
- this.vertexColors = false;
8578
-
8579
- this.opacity = 1;
8580
- this.transparent = false;
8581
- this.alphaHash = false;
8582
-
8583
- this.blendSrc = SrcAlphaFactor;
8584
- this.blendDst = OneMinusSrcAlphaFactor;
8585
- this.blendEquation = AddEquation;
8586
- this.blendSrcAlpha = null;
8587
- this.blendDstAlpha = null;
8588
- this.blendEquationAlpha = null;
8589
-
8590
- this.depthFunc = LessEqualDepth;
8591
- this.depthTest = true;
8592
- this.depthWrite = true;
8593
-
8594
- this.stencilWriteMask = 0xff;
8595
- this.stencilFunc = AlwaysStencilFunc;
8596
- this.stencilRef = 0;
8597
- this.stencilFuncMask = 0xff;
8598
- this.stencilFail = KeepStencilOp;
8599
- this.stencilZFail = KeepStencilOp;
8600
- this.stencilZPass = KeepStencilOp;
8601
- this.stencilWrite = false;
8602
-
8603
- this.clippingPlanes = null;
8604
- this.clipIntersection = false;
8605
- this.clipShadows = false;
8606
-
8607
- this.shadowSide = null;
8608
-
8609
- this.colorWrite = true;
8610
-
8611
- this.precision = null; // override the renderer's default precision for this material
8612
-
8613
- this.polygonOffset = false;
8614
- this.polygonOffsetFactor = 0;
8615
- this.polygonOffsetUnits = 0;
8616
-
8617
- this.dithering = false;
8618
-
8619
- this.alphaToCoverage = false;
8620
- this.premultipliedAlpha = false;
8621
- this.forceSinglePass = false;
8622
-
8623
- this.visible = true;
8624
-
8625
- this.toneMapped = true;
8626
-
8627
- this.userData = {};
8628
-
8629
- this.version = 0;
8630
-
8631
- this._alphaTest = 0;
8632
-
8633
- }
8634
-
8635
- get alphaTest() {
8636
-
8637
- return this._alphaTest;
8638
-
8639
- }
8640
-
8641
- set alphaTest( value ) {
8642
-
8643
- if ( this._alphaTest > 0 !== value > 0 ) {
8644
-
8645
- this.version ++;
8646
-
8647
- }
8648
-
8649
- this._alphaTest = value;
8650
-
8651
- }
8652
-
8653
- onBuild( /* shaderobject, renderer */ ) {}
8654
-
8655
- onBeforeRender( /* renderer, scene, camera, geometry, object, group */ ) {}
8656
-
8657
- onBeforeCompile( /* shaderobject, renderer */ ) {}
8658
-
8659
- customProgramCacheKey() {
8660
-
8661
- return this.onBeforeCompile.toString();
8662
-
8663
- }
8664
-
8665
- setValues( values ) {
8666
-
8667
- if ( values === undefined ) return;
8668
-
8669
- for ( const key in values ) {
8670
-
8671
- const newValue = values[ key ];
8672
-
8673
- if ( newValue === undefined ) {
8674
-
8675
- console.warn( `THREE.Material: parameter '${ key }' has value of undefined.` );
8676
- continue;
8677
-
8678
- }
8679
-
8680
- const currentValue = this[ key ];
8681
-
8682
- if ( currentValue === undefined ) {
8683
-
8684
- console.warn( `THREE.Material: '${ key }' is not a property of THREE.${ this.type }.` );
8685
- continue;
8686
-
8687
- }
8688
-
8689
- if ( currentValue && currentValue.isColor ) {
8690
-
8691
- currentValue.set( newValue );
8692
-
8693
- } else if ( ( currentValue && currentValue.isVector3 ) && ( newValue && newValue.isVector3 ) ) {
8694
-
8695
- currentValue.copy( newValue );
8696
-
8697
- } else {
8698
-
8699
- this[ key ] = newValue;
8700
-
8701
- }
8702
-
8703
- }
8704
-
8705
- }
8706
-
8707
- toJSON( meta ) {
8708
-
8709
- const isRootObject = ( meta === undefined || typeof meta === 'string' );
8710
-
8711
- if ( isRootObject ) {
8712
-
8713
- meta = {
8714
- textures: {},
8715
- images: {}
8716
- };
8717
-
8718
- }
8719
-
8720
- const data = {
8721
- metadata: {
8722
- version: 4.6,
8723
- type: 'Material',
8724
- generator: 'Material.toJSON'
8725
- }
8726
- };
8727
-
8728
- // standard Material serialization
8729
- data.uuid = this.uuid;
8730
- data.type = this.type;
8731
-
8732
- if ( this.name !== '' ) data.name = this.name;
8733
-
8734
- if ( this.color && this.color.isColor ) data.color = this.color.getHex();
8735
-
8736
- if ( this.roughness !== undefined ) data.roughness = this.roughness;
8737
- if ( this.metalness !== undefined ) data.metalness = this.metalness;
8738
-
8739
- if ( this.sheen !== undefined ) data.sheen = this.sheen;
8740
- if ( this.sheenColor && this.sheenColor.isColor ) data.sheenColor = this.sheenColor.getHex();
8741
- if ( this.sheenRoughness !== undefined ) data.sheenRoughness = this.sheenRoughness;
8742
- if ( this.emissive && this.emissive.isColor ) data.emissive = this.emissive.getHex();
8743
- if ( this.emissiveIntensity && this.emissiveIntensity !== 1 ) data.emissiveIntensity = this.emissiveIntensity;
8744
-
8745
- if ( this.specular && this.specular.isColor ) data.specular = this.specular.getHex();
8746
- if ( this.specularIntensity !== undefined ) data.specularIntensity = this.specularIntensity;
8747
- if ( this.specularColor && this.specularColor.isColor ) data.specularColor = this.specularColor.getHex();
8748
- if ( this.shininess !== undefined ) data.shininess = this.shininess;
8749
- if ( this.clearcoat !== undefined ) data.clearcoat = this.clearcoat;
8750
- if ( this.clearcoatRoughness !== undefined ) data.clearcoatRoughness = this.clearcoatRoughness;
8751
-
8752
- if ( this.clearcoatMap && this.clearcoatMap.isTexture ) {
8753
-
8754
- data.clearcoatMap = this.clearcoatMap.toJSON( meta ).uuid;
8755
-
8756
- }
8757
-
8758
- if ( this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture ) {
8759
-
8760
- data.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON( meta ).uuid;
8761
-
8762
- }
8763
-
8764
- if ( this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture ) {
8765
-
8766
- data.clearcoatNormalMap = this.clearcoatNormalMap.toJSON( meta ).uuid;
8767
- data.clearcoatNormalScale = this.clearcoatNormalScale.toArray();
8768
-
8769
- }
8770
-
8771
- if ( this.iridescence !== undefined ) data.iridescence = this.iridescence;
8772
- if ( this.iridescenceIOR !== undefined ) data.iridescenceIOR = this.iridescenceIOR;
8773
- if ( this.iridescenceThicknessRange !== undefined ) data.iridescenceThicknessRange = this.iridescenceThicknessRange;
8774
-
8775
- if ( this.iridescenceMap && this.iridescenceMap.isTexture ) {
8776
-
8777
- data.iridescenceMap = this.iridescenceMap.toJSON( meta ).uuid;
8778
-
8779
- }
8780
-
8781
- if ( this.iridescenceThicknessMap && this.iridescenceThicknessMap.isTexture ) {
8782
-
8783
- data.iridescenceThicknessMap = this.iridescenceThicknessMap.toJSON( meta ).uuid;
8784
-
8785
- }
8786
-
8787
- if ( this.anisotropy !== undefined ) data.anisotropy = this.anisotropy;
8788
- if ( this.anisotropyRotation !== undefined ) data.anisotropyRotation = this.anisotropyRotation;
8789
-
8790
- if ( this.anisotropyMap && this.anisotropyMap.isTexture ) {
8791
-
8792
- data.anisotropyMap = this.anisotropyMap.toJSON( meta ).uuid;
8793
-
8794
- }
8795
-
8796
- if ( this.map && this.map.isTexture ) data.map = this.map.toJSON( meta ).uuid;
8797
- if ( this.matcap && this.matcap.isTexture ) data.matcap = this.matcap.toJSON( meta ).uuid;
8798
- if ( this.alphaMap && this.alphaMap.isTexture ) data.alphaMap = this.alphaMap.toJSON( meta ).uuid;
8799
-
8800
- if ( this.lightMap && this.lightMap.isTexture ) {
8801
-
8802
- data.lightMap = this.lightMap.toJSON( meta ).uuid;
8803
- data.lightMapIntensity = this.lightMapIntensity;
8804
-
8805
- }
8806
-
8807
- if ( this.aoMap && this.aoMap.isTexture ) {
8808
-
8809
- data.aoMap = this.aoMap.toJSON( meta ).uuid;
8810
- data.aoMapIntensity = this.aoMapIntensity;
8811
-
8812
- }
8813
-
8814
- if ( this.bumpMap && this.bumpMap.isTexture ) {
8815
-
8816
- data.bumpMap = this.bumpMap.toJSON( meta ).uuid;
8817
- data.bumpScale = this.bumpScale;
8818
-
8819
- }
8820
-
8821
- if ( this.normalMap && this.normalMap.isTexture ) {
8822
-
8823
- data.normalMap = this.normalMap.toJSON( meta ).uuid;
8824
- data.normalMapType = this.normalMapType;
8825
- data.normalScale = this.normalScale.toArray();
8826
-
8827
- }
8828
-
8829
- if ( this.displacementMap && this.displacementMap.isTexture ) {
8830
-
8831
- data.displacementMap = this.displacementMap.toJSON( meta ).uuid;
8832
- data.displacementScale = this.displacementScale;
8833
- data.displacementBias = this.displacementBias;
8834
-
8835
- }
8836
-
8837
- if ( this.roughnessMap && this.roughnessMap.isTexture ) data.roughnessMap = this.roughnessMap.toJSON( meta ).uuid;
8838
- if ( this.metalnessMap && this.metalnessMap.isTexture ) data.metalnessMap = this.metalnessMap.toJSON( meta ).uuid;
8839
-
8840
- if ( this.emissiveMap && this.emissiveMap.isTexture ) data.emissiveMap = this.emissiveMap.toJSON( meta ).uuid;
8841
- if ( this.specularMap && this.specularMap.isTexture ) data.specularMap = this.specularMap.toJSON( meta ).uuid;
8842
- if ( this.specularIntensityMap && this.specularIntensityMap.isTexture ) data.specularIntensityMap = this.specularIntensityMap.toJSON( meta ).uuid;
8843
- if ( this.specularColorMap && this.specularColorMap.isTexture ) data.specularColorMap = this.specularColorMap.toJSON( meta ).uuid;
8844
-
8845
- if ( this.envMap && this.envMap.isTexture ) {
8846
-
8847
- data.envMap = this.envMap.toJSON( meta ).uuid;
8848
-
8849
- if ( this.combine !== undefined ) data.combine = this.combine;
8850
-
8851
- }
8852
-
8853
- if ( this.envMapIntensity !== undefined ) data.envMapIntensity = this.envMapIntensity;
8854
- if ( this.reflectivity !== undefined ) data.reflectivity = this.reflectivity;
8855
- if ( this.refractionRatio !== undefined ) data.refractionRatio = this.refractionRatio;
8856
-
8857
- if ( this.gradientMap && this.gradientMap.isTexture ) {
8858
-
8859
- data.gradientMap = this.gradientMap.toJSON( meta ).uuid;
8860
-
8861
- }
8862
-
8863
- if ( this.transmission !== undefined ) data.transmission = this.transmission;
8864
- if ( this.transmissionMap && this.transmissionMap.isTexture ) data.transmissionMap = this.transmissionMap.toJSON( meta ).uuid;
8865
- if ( this.thickness !== undefined ) data.thickness = this.thickness;
8866
- if ( this.thicknessMap && this.thicknessMap.isTexture ) data.thicknessMap = this.thicknessMap.toJSON( meta ).uuid;
8867
- if ( this.attenuationDistance !== undefined && this.attenuationDistance !== Infinity ) data.attenuationDistance = this.attenuationDistance;
8868
- if ( this.attenuationColor !== undefined ) data.attenuationColor = this.attenuationColor.getHex();
8869
-
8870
- if ( this.size !== undefined ) data.size = this.size;
8871
- if ( this.shadowSide !== null ) data.shadowSide = this.shadowSide;
8872
- if ( this.sizeAttenuation !== undefined ) data.sizeAttenuation = this.sizeAttenuation;
8873
-
8874
- if ( this.blending !== NormalBlending ) data.blending = this.blending;
8875
- if ( this.side !== FrontSide ) data.side = this.side;
8876
- if ( this.vertexColors === true ) data.vertexColors = true;
8877
-
8878
- if ( this.opacity < 1 ) data.opacity = this.opacity;
8879
- if ( this.transparent === true ) data.transparent = true;
8880
-
8881
- data.depthFunc = this.depthFunc;
8882
- data.depthTest = this.depthTest;
8883
- data.depthWrite = this.depthWrite;
8884
- data.colorWrite = this.colorWrite;
8885
-
8886
- data.stencilWrite = this.stencilWrite;
8887
- data.stencilWriteMask = this.stencilWriteMask;
8888
- data.stencilFunc = this.stencilFunc;
8889
- data.stencilRef = this.stencilRef;
8890
- data.stencilFuncMask = this.stencilFuncMask;
8891
- data.stencilFail = this.stencilFail;
8892
- data.stencilZFail = this.stencilZFail;
8893
- data.stencilZPass = this.stencilZPass;
8894
-
8895
- // rotation (SpriteMaterial)
8896
- if ( this.rotation !== undefined && this.rotation !== 0 ) data.rotation = this.rotation;
8897
-
8898
- if ( this.polygonOffset === true ) data.polygonOffset = true;
8899
- if ( this.polygonOffsetFactor !== 0 ) data.polygonOffsetFactor = this.polygonOffsetFactor;
8900
- if ( this.polygonOffsetUnits !== 0 ) data.polygonOffsetUnits = this.polygonOffsetUnits;
8901
-
8902
- if ( this.linewidth !== undefined && this.linewidth !== 1 ) data.linewidth = this.linewidth;
8903
- if ( this.dashSize !== undefined ) data.dashSize = this.dashSize;
8904
- if ( this.gapSize !== undefined ) data.gapSize = this.gapSize;
8905
- if ( this.scale !== undefined ) data.scale = this.scale;
8906
-
8907
- if ( this.dithering === true ) data.dithering = true;
8908
-
8909
- if ( this.alphaTest > 0 ) data.alphaTest = this.alphaTest;
8910
- if ( this.alphaHash === true ) data.alphaHash = true;
8911
- if ( this.alphaToCoverage === true ) data.alphaToCoverage = true;
8912
- if ( this.premultipliedAlpha === true ) data.premultipliedAlpha = true;
8913
- if ( this.forceSinglePass === true ) data.forceSinglePass = true;
8914
-
8915
- if ( this.wireframe === true ) data.wireframe = true;
8916
- if ( this.wireframeLinewidth > 1 ) data.wireframeLinewidth = this.wireframeLinewidth;
8917
- if ( this.wireframeLinecap !== 'round' ) data.wireframeLinecap = this.wireframeLinecap;
8918
- if ( this.wireframeLinejoin !== 'round' ) data.wireframeLinejoin = this.wireframeLinejoin;
8919
-
8920
- if ( this.flatShading === true ) data.flatShading = true;
8921
-
8922
- if ( this.visible === false ) data.visible = false;
8923
-
8924
- if ( this.toneMapped === false ) data.toneMapped = false;
8925
-
8926
- if ( this.fog === false ) data.fog = false;
8927
-
8928
- if ( Object.keys( this.userData ).length > 0 ) data.userData = this.userData;
8929
-
8930
- // TODO: Copied from Object3D.toJSON
8931
-
8932
- function extractFromCache( cache ) {
8933
-
8934
- const values = [];
8935
-
8936
- for ( const key in cache ) {
8937
-
8938
- const data = cache[ key ];
8939
- delete data.metadata;
8940
- values.push( data );
8941
-
8942
- }
8943
-
8944
- return values;
8945
-
8946
- }
8947
-
8948
- if ( isRootObject ) {
8949
-
8950
- const textures = extractFromCache( meta.textures );
8951
- const images = extractFromCache( meta.images );
8952
-
8953
- if ( textures.length > 0 ) data.textures = textures;
8954
- if ( images.length > 0 ) data.images = images;
8955
-
8956
- }
8957
-
8958
- return data;
8959
-
8960
- }
8961
-
8962
- clone() {
8963
-
8964
- return new this.constructor().copy( this );
8965
-
8966
- }
8967
-
8968
- copy( source ) {
8969
-
8970
- this.name = source.name;
8971
-
8972
- this.blending = source.blending;
8973
- this.side = source.side;
8974
- this.vertexColors = source.vertexColors;
8975
-
8976
- this.opacity = source.opacity;
8977
- this.transparent = source.transparent;
8978
-
8979
- this.blendSrc = source.blendSrc;
8980
- this.blendDst = source.blendDst;
8981
- this.blendEquation = source.blendEquation;
8982
- this.blendSrcAlpha = source.blendSrcAlpha;
8983
- this.blendDstAlpha = source.blendDstAlpha;
8984
- this.blendEquationAlpha = source.blendEquationAlpha;
8985
-
8986
- this.depthFunc = source.depthFunc;
8987
- this.depthTest = source.depthTest;
8988
- this.depthWrite = source.depthWrite;
8989
-
8990
- this.stencilWriteMask = source.stencilWriteMask;
8991
- this.stencilFunc = source.stencilFunc;
8992
- this.stencilRef = source.stencilRef;
8993
- this.stencilFuncMask = source.stencilFuncMask;
8994
- this.stencilFail = source.stencilFail;
8995
- this.stencilZFail = source.stencilZFail;
8996
- this.stencilZPass = source.stencilZPass;
8997
- this.stencilWrite = source.stencilWrite;
8998
-
8999
- const srcPlanes = source.clippingPlanes;
9000
- let dstPlanes = null;
9001
-
9002
- if ( srcPlanes !== null ) {
9003
-
9004
- const n = srcPlanes.length;
9005
- dstPlanes = new Array( n );
9006
-
9007
- for ( let i = 0; i !== n; ++ i ) {
9008
-
9009
- dstPlanes[ i ] = srcPlanes[ i ].clone();
9010
-
9011
- }
9012
-
9013
- }
9014
-
9015
- this.clippingPlanes = dstPlanes;
9016
- this.clipIntersection = source.clipIntersection;
9017
- this.clipShadows = source.clipShadows;
9018
-
9019
- this.shadowSide = source.shadowSide;
9020
-
9021
- this.colorWrite = source.colorWrite;
9022
-
9023
- this.precision = source.precision;
9024
-
9025
- this.polygonOffset = source.polygonOffset;
9026
- this.polygonOffsetFactor = source.polygonOffsetFactor;
9027
- this.polygonOffsetUnits = source.polygonOffsetUnits;
9028
-
9029
- this.dithering = source.dithering;
9030
-
9031
- this.alphaTest = source.alphaTest;
9032
- this.alphaHash = source.alphaHash;
9033
- this.alphaToCoverage = source.alphaToCoverage;
9034
- this.premultipliedAlpha = source.premultipliedAlpha;
9035
- this.forceSinglePass = source.forceSinglePass;
9036
-
9037
- this.visible = source.visible;
9038
-
9039
- this.toneMapped = source.toneMapped;
9040
-
9041
- this.userData = JSON.parse( JSON.stringify( source.userData ) );
9042
-
9043
- return this;
9044
-
9045
- }
9046
-
9047
- dispose() {
9048
-
9049
- this.dispatchEvent( { type: 'dispose' } );
9050
-
9051
- }
9052
-
9053
- set needsUpdate( value ) {
9054
-
9055
- if ( value === true ) this.version ++;
9056
-
9057
- }
9058
-
9059
- }
9060
-
9061
8626
  const _colorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0x00FFFF, 'aquamarine': 0x7FFFD4, 'azure': 0xF0FFFF,
9062
8627
  'beige': 0xF5F5DC, 'bisque': 0xFFE4C4, 'black': 0x000000, 'blanchedalmond': 0xFFEBCD, 'blue': 0x0000FF, 'blueviolet': 0x8A2BE2,
9063
8628
  'brown': 0xA52A2A, 'burlywood': 0xDEB887, 'cadetblue': 0x5F9EA0, 'chartreuse': 0x7FFF00, 'chocolate': 0xD2691E, 'coral': 0xFF7F50,
@@ -9408,273 +8973,789 @@
9408
8973
 
9409
8974
  getHex( colorSpace = SRGBColorSpace ) {
9410
8975
 
9411
- ColorManagement.fromWorkingColorSpace( _color.copy( this ), colorSpace );
8976
+ ColorManagement.fromWorkingColorSpace( _color.copy( this ), colorSpace );
8977
+
8978
+ return Math.round( clamp( _color.r * 255, 0, 255 ) ) * 65536 + Math.round( clamp( _color.g * 255, 0, 255 ) ) * 256 + Math.round( clamp( _color.b * 255, 0, 255 ) );
8979
+
8980
+ }
8981
+
8982
+ getHexString( colorSpace = SRGBColorSpace ) {
8983
+
8984
+ return ( '000000' + this.getHex( colorSpace ).toString( 16 ) ).slice( - 6 );
8985
+
8986
+ }
8987
+
8988
+ getHSL( target, colorSpace = ColorManagement.workingColorSpace ) {
8989
+
8990
+ // h,s,l ranges are in 0.0 - 1.0
8991
+
8992
+ ColorManagement.fromWorkingColorSpace( _color.copy( this ), colorSpace );
8993
+
8994
+ const r = _color.r, g = _color.g, b = _color.b;
8995
+
8996
+ const max = Math.max( r, g, b );
8997
+ const min = Math.min( r, g, b );
8998
+
8999
+ let hue, saturation;
9000
+ const lightness = ( min + max ) / 2.0;
9001
+
9002
+ if ( min === max ) {
9003
+
9004
+ hue = 0;
9005
+ saturation = 0;
9006
+
9007
+ } else {
9008
+
9009
+ const delta = max - min;
9010
+
9011
+ saturation = lightness <= 0.5 ? delta / ( max + min ) : delta / ( 2 - max - min );
9012
+
9013
+ switch ( max ) {
9014
+
9015
+ case r: hue = ( g - b ) / delta + ( g < b ? 6 : 0 ); break;
9016
+ case g: hue = ( b - r ) / delta + 2; break;
9017
+ case b: hue = ( r - g ) / delta + 4; break;
9018
+
9019
+ }
9020
+
9021
+ hue /= 6;
9022
+
9023
+ }
9024
+
9025
+ target.h = hue;
9026
+ target.s = saturation;
9027
+ target.l = lightness;
9028
+
9029
+ return target;
9030
+
9031
+ }
9032
+
9033
+ getRGB( target, colorSpace = ColorManagement.workingColorSpace ) {
9034
+
9035
+ ColorManagement.fromWorkingColorSpace( _color.copy( this ), colorSpace );
9036
+
9037
+ target.r = _color.r;
9038
+ target.g = _color.g;
9039
+ target.b = _color.b;
9040
+
9041
+ return target;
9042
+
9043
+ }
9044
+
9045
+ getStyle( colorSpace = SRGBColorSpace ) {
9046
+
9047
+ ColorManagement.fromWorkingColorSpace( _color.copy( this ), colorSpace );
9048
+
9049
+ const r = _color.r, g = _color.g, b = _color.b;
9050
+
9051
+ if ( colorSpace !== SRGBColorSpace ) {
9052
+
9053
+ // Requires CSS Color Module Level 4 (https://www.w3.org/TR/css-color-4/).
9054
+ return `color(${ colorSpace } ${ r.toFixed( 3 ) } ${ g.toFixed( 3 ) } ${ b.toFixed( 3 ) })`;
9055
+
9056
+ }
9057
+
9058
+ return `rgb(${ Math.round( r * 255 ) },${ Math.round( g * 255 ) },${ Math.round( b * 255 ) })`;
9059
+
9060
+ }
9061
+
9062
+ offsetHSL( h, s, l ) {
9063
+
9064
+ this.getHSL( _hslA );
9065
+
9066
+ return this.setHSL( _hslA.h + h, _hslA.s + s, _hslA.l + l );
9067
+
9068
+ }
9069
+
9070
+ add( color ) {
9071
+
9072
+ this.r += color.r;
9073
+ this.g += color.g;
9074
+ this.b += color.b;
9075
+
9076
+ return this;
9077
+
9078
+ }
9079
+
9080
+ addColors( color1, color2 ) {
9081
+
9082
+ this.r = color1.r + color2.r;
9083
+ this.g = color1.g + color2.g;
9084
+ this.b = color1.b + color2.b;
9085
+
9086
+ return this;
9087
+
9088
+ }
9089
+
9090
+ addScalar( s ) {
9091
+
9092
+ this.r += s;
9093
+ this.g += s;
9094
+ this.b += s;
9095
+
9096
+ return this;
9097
+
9098
+ }
9099
+
9100
+ sub( color ) {
9101
+
9102
+ this.r = Math.max( 0, this.r - color.r );
9103
+ this.g = Math.max( 0, this.g - color.g );
9104
+ this.b = Math.max( 0, this.b - color.b );
9105
+
9106
+ return this;
9107
+
9108
+ }
9109
+
9110
+ multiply( color ) {
9111
+
9112
+ this.r *= color.r;
9113
+ this.g *= color.g;
9114
+ this.b *= color.b;
9115
+
9116
+ return this;
9117
+
9118
+ }
9119
+
9120
+ multiplyScalar( s ) {
9121
+
9122
+ this.r *= s;
9123
+ this.g *= s;
9124
+ this.b *= s;
9125
+
9126
+ return this;
9127
+
9128
+ }
9129
+
9130
+ lerp( color, alpha ) {
9131
+
9132
+ this.r += ( color.r - this.r ) * alpha;
9133
+ this.g += ( color.g - this.g ) * alpha;
9134
+ this.b += ( color.b - this.b ) * alpha;
9135
+
9136
+ return this;
9137
+
9138
+ }
9139
+
9140
+ lerpColors( color1, color2, alpha ) {
9141
+
9142
+ this.r = color1.r + ( color2.r - color1.r ) * alpha;
9143
+ this.g = color1.g + ( color2.g - color1.g ) * alpha;
9144
+ this.b = color1.b + ( color2.b - color1.b ) * alpha;
9145
+
9146
+ return this;
9147
+
9148
+ }
9149
+
9150
+ lerpHSL( color, alpha ) {
9151
+
9152
+ this.getHSL( _hslA );
9153
+ color.getHSL( _hslB );
9154
+
9155
+ const h = lerp( _hslA.h, _hslB.h, alpha );
9156
+ const s = lerp( _hslA.s, _hslB.s, alpha );
9157
+ const l = lerp( _hslA.l, _hslB.l, alpha );
9158
+
9159
+ this.setHSL( h, s, l );
9160
+
9161
+ return this;
9162
+
9163
+ }
9164
+
9165
+ setFromVector3( v ) {
9166
+
9167
+ this.r = v.x;
9168
+ this.g = v.y;
9169
+ this.b = v.z;
9170
+
9171
+ return this;
9172
+
9173
+ }
9174
+
9175
+ applyMatrix3( m ) {
9176
+
9177
+ const r = this.r, g = this.g, b = this.b;
9178
+ const e = m.elements;
9179
+
9180
+ this.r = e[ 0 ] * r + e[ 3 ] * g + e[ 6 ] * b;
9181
+ this.g = e[ 1 ] * r + e[ 4 ] * g + e[ 7 ] * b;
9182
+ this.b = e[ 2 ] * r + e[ 5 ] * g + e[ 8 ] * b;
9183
+
9184
+ return this;
9185
+
9186
+ }
9187
+
9188
+ equals( c ) {
9189
+
9190
+ return ( c.r === this.r ) && ( c.g === this.g ) && ( c.b === this.b );
9191
+
9192
+ }
9193
+
9194
+ fromArray( array, offset = 0 ) {
9195
+
9196
+ this.r = array[ offset ];
9197
+ this.g = array[ offset + 1 ];
9198
+ this.b = array[ offset + 2 ];
9199
+
9200
+ return this;
9201
+
9202
+ }
9203
+
9204
+ toArray( array = [], offset = 0 ) {
9205
+
9206
+ array[ offset ] = this.r;
9207
+ array[ offset + 1 ] = this.g;
9208
+ array[ offset + 2 ] = this.b;
9209
+
9210
+ return array;
9211
+
9212
+ }
9213
+
9214
+ fromBufferAttribute( attribute, index ) {
9215
+
9216
+ this.r = attribute.getX( index );
9217
+ this.g = attribute.getY( index );
9218
+ this.b = attribute.getZ( index );
9219
+
9220
+ return this;
9221
+
9222
+ }
9223
+
9224
+ toJSON() {
9225
+
9226
+ return this.getHex();
9227
+
9228
+ }
9229
+
9230
+ *[ Symbol.iterator ]() {
9231
+
9232
+ yield this.r;
9233
+ yield this.g;
9234
+ yield this.b;
9235
+
9236
+ }
9237
+
9238
+ };
9239
+
9240
+ const _color = /*@__PURE__*/ new Color$1();
9241
+
9242
+ Color$1.NAMES = _colorKeywords;
9243
+
9244
+ let _materialId = 0;
9245
+
9246
+ class Material extends EventDispatcher {
9247
+
9248
+ constructor() {
9249
+
9250
+ super();
9251
+
9252
+ this.isMaterial = true;
9253
+
9254
+ Object.defineProperty( this, 'id', { value: _materialId ++ } );
9255
+
9256
+ this.uuid = generateUUID();
9257
+
9258
+ this.name = '';
9259
+ this.type = 'Material';
9260
+
9261
+ this.blending = NormalBlending;
9262
+ this.side = FrontSide;
9263
+ this.vertexColors = false;
9264
+
9265
+ this.opacity = 1;
9266
+ this.transparent = false;
9267
+ this.alphaHash = false;
9268
+
9269
+ this.blendSrc = SrcAlphaFactor;
9270
+ this.blendDst = OneMinusSrcAlphaFactor;
9271
+ this.blendEquation = AddEquation;
9272
+ this.blendSrcAlpha = null;
9273
+ this.blendDstAlpha = null;
9274
+ this.blendEquationAlpha = null;
9275
+ this.blendColor = new Color$1( 0, 0, 0 );
9276
+ this.blendAlpha = 0;
9277
+
9278
+ this.depthFunc = LessEqualDepth;
9279
+ this.depthTest = true;
9280
+ this.depthWrite = true;
9281
+
9282
+ this.stencilWriteMask = 0xff;
9283
+ this.stencilFunc = AlwaysStencilFunc;
9284
+ this.stencilRef = 0;
9285
+ this.stencilFuncMask = 0xff;
9286
+ this.stencilFail = KeepStencilOp;
9287
+ this.stencilZFail = KeepStencilOp;
9288
+ this.stencilZPass = KeepStencilOp;
9289
+ this.stencilWrite = false;
9290
+
9291
+ this.clippingPlanes = null;
9292
+ this.clipIntersection = false;
9293
+ this.clipShadows = false;
9294
+
9295
+ this.shadowSide = null;
9296
+
9297
+ this.colorWrite = true;
9298
+
9299
+ this.precision = null; // override the renderer's default precision for this material
9300
+
9301
+ this.polygonOffset = false;
9302
+ this.polygonOffsetFactor = 0;
9303
+ this.polygonOffsetUnits = 0;
9304
+
9305
+ this.dithering = false;
9306
+
9307
+ this.alphaToCoverage = false;
9308
+ this.premultipliedAlpha = false;
9309
+ this.forceSinglePass = false;
9310
+
9311
+ this.visible = true;
9312
+
9313
+ this.toneMapped = true;
9314
+
9315
+ this.userData = {};
9316
+
9317
+ this.version = 0;
9318
+
9319
+ this._alphaTest = 0;
9320
+
9321
+ }
9322
+
9323
+ get alphaTest() {
9324
+
9325
+ return this._alphaTest;
9326
+
9327
+ }
9328
+
9329
+ set alphaTest( value ) {
9330
+
9331
+ if ( this._alphaTest > 0 !== value > 0 ) {
9332
+
9333
+ this.version ++;
9334
+
9335
+ }
9336
+
9337
+ this._alphaTest = value;
9338
+
9339
+ }
9340
+
9341
+ onBuild( /* shaderobject, renderer */ ) {}
9342
+
9343
+ onBeforeRender( /* renderer, scene, camera, geometry, object, group */ ) {}
9344
+
9345
+ onBeforeCompile( /* shaderobject, renderer */ ) {}
9346
+
9347
+ customProgramCacheKey() {
9348
+
9349
+ return this.onBeforeCompile.toString();
9350
+
9351
+ }
9352
+
9353
+ setValues( values ) {
9354
+
9355
+ if ( values === undefined ) return;
9356
+
9357
+ for ( const key in values ) {
9358
+
9359
+ const newValue = values[ key ];
9360
+
9361
+ if ( newValue === undefined ) {
9362
+
9363
+ console.warn( `THREE.Material: parameter '${ key }' has value of undefined.` );
9364
+ continue;
9365
+
9366
+ }
9367
+
9368
+ const currentValue = this[ key ];
9369
+
9370
+ if ( currentValue === undefined ) {
9371
+
9372
+ console.warn( `THREE.Material: '${ key }' is not a property of THREE.${ this.type }.` );
9373
+ continue;
9374
+
9375
+ }
9376
+
9377
+ if ( currentValue && currentValue.isColor ) {
9378
+
9379
+ currentValue.set( newValue );
9380
+
9381
+ } else if ( ( currentValue && currentValue.isVector3 ) && ( newValue && newValue.isVector3 ) ) {
9382
+
9383
+ currentValue.copy( newValue );
9384
+
9385
+ } else {
9386
+
9387
+ this[ key ] = newValue;
9388
+
9389
+ }
9390
+
9391
+ }
9392
+
9393
+ }
9394
+
9395
+ toJSON( meta ) {
9396
+
9397
+ const isRootObject = ( meta === undefined || typeof meta === 'string' );
9398
+
9399
+ if ( isRootObject ) {
9400
+
9401
+ meta = {
9402
+ textures: {},
9403
+ images: {}
9404
+ };
9405
+
9406
+ }
9407
+
9408
+ const data = {
9409
+ metadata: {
9410
+ version: 4.6,
9411
+ type: 'Material',
9412
+ generator: 'Material.toJSON'
9413
+ }
9414
+ };
9415
+
9416
+ // standard Material serialization
9417
+ data.uuid = this.uuid;
9418
+ data.type = this.type;
9419
+
9420
+ if ( this.name !== '' ) data.name = this.name;
9421
+
9422
+ if ( this.color && this.color.isColor ) data.color = this.color.getHex();
9423
+
9424
+ if ( this.roughness !== undefined ) data.roughness = this.roughness;
9425
+ if ( this.metalness !== undefined ) data.metalness = this.metalness;
9426
+
9427
+ if ( this.sheen !== undefined ) data.sheen = this.sheen;
9428
+ if ( this.sheenColor && this.sheenColor.isColor ) data.sheenColor = this.sheenColor.getHex();
9429
+ if ( this.sheenRoughness !== undefined ) data.sheenRoughness = this.sheenRoughness;
9430
+ if ( this.emissive && this.emissive.isColor ) data.emissive = this.emissive.getHex();
9431
+ if ( this.emissiveIntensity && this.emissiveIntensity !== 1 ) data.emissiveIntensity = this.emissiveIntensity;
9432
+
9433
+ if ( this.specular && this.specular.isColor ) data.specular = this.specular.getHex();
9434
+ if ( this.specularIntensity !== undefined ) data.specularIntensity = this.specularIntensity;
9435
+ if ( this.specularColor && this.specularColor.isColor ) data.specularColor = this.specularColor.getHex();
9436
+ if ( this.shininess !== undefined ) data.shininess = this.shininess;
9437
+ if ( this.clearcoat !== undefined ) data.clearcoat = this.clearcoat;
9438
+ if ( this.clearcoatRoughness !== undefined ) data.clearcoatRoughness = this.clearcoatRoughness;
9439
+
9440
+ if ( this.clearcoatMap && this.clearcoatMap.isTexture ) {
9441
+
9442
+ data.clearcoatMap = this.clearcoatMap.toJSON( meta ).uuid;
9443
+
9444
+ }
9412
9445
 
9413
- return Math.round( clamp( _color.r * 255, 0, 255 ) ) * 65536 + Math.round( clamp( _color.g * 255, 0, 255 ) ) * 256 + Math.round( clamp( _color.b * 255, 0, 255 ) );
9446
+ if ( this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture ) {
9414
9447
 
9415
- }
9448
+ data.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON( meta ).uuid;
9416
9449
 
9417
- getHexString( colorSpace = SRGBColorSpace ) {
9450
+ }
9418
9451
 
9419
- return ( '000000' + this.getHex( colorSpace ).toString( 16 ) ).slice( - 6 );
9452
+ if ( this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture ) {
9420
9453
 
9421
- }
9454
+ data.clearcoatNormalMap = this.clearcoatNormalMap.toJSON( meta ).uuid;
9455
+ data.clearcoatNormalScale = this.clearcoatNormalScale.toArray();
9422
9456
 
9423
- getHSL( target, colorSpace = ColorManagement.workingColorSpace ) {
9457
+ }
9424
9458
 
9425
- // h,s,l ranges are in 0.0 - 1.0
9459
+ if ( this.iridescence !== undefined ) data.iridescence = this.iridescence;
9460
+ if ( this.iridescenceIOR !== undefined ) data.iridescenceIOR = this.iridescenceIOR;
9461
+ if ( this.iridescenceThicknessRange !== undefined ) data.iridescenceThicknessRange = this.iridescenceThicknessRange;
9426
9462
 
9427
- ColorManagement.fromWorkingColorSpace( _color.copy( this ), colorSpace );
9463
+ if ( this.iridescenceMap && this.iridescenceMap.isTexture ) {
9428
9464
 
9429
- const r = _color.r, g = _color.g, b = _color.b;
9465
+ data.iridescenceMap = this.iridescenceMap.toJSON( meta ).uuid;
9430
9466
 
9431
- const max = Math.max( r, g, b );
9432
- const min = Math.min( r, g, b );
9467
+ }
9433
9468
 
9434
- let hue, saturation;
9435
- const lightness = ( min + max ) / 2.0;
9469
+ if ( this.iridescenceThicknessMap && this.iridescenceThicknessMap.isTexture ) {
9436
9470
 
9437
- if ( min === max ) {
9471
+ data.iridescenceThicknessMap = this.iridescenceThicknessMap.toJSON( meta ).uuid;
9438
9472
 
9439
- hue = 0;
9440
- saturation = 0;
9473
+ }
9441
9474
 
9442
- } else {
9475
+ if ( this.anisotropy !== undefined ) data.anisotropy = this.anisotropy;
9476
+ if ( this.anisotropyRotation !== undefined ) data.anisotropyRotation = this.anisotropyRotation;
9443
9477
 
9444
- const delta = max - min;
9478
+ if ( this.anisotropyMap && this.anisotropyMap.isTexture ) {
9445
9479
 
9446
- saturation = lightness <= 0.5 ? delta / ( max + min ) : delta / ( 2 - max - min );
9480
+ data.anisotropyMap = this.anisotropyMap.toJSON( meta ).uuid;
9447
9481
 
9448
- switch ( max ) {
9482
+ }
9449
9483
 
9450
- case r: hue = ( g - b ) / delta + ( g < b ? 6 : 0 ); break;
9451
- case g: hue = ( b - r ) / delta + 2; break;
9452
- case b: hue = ( r - g ) / delta + 4; break;
9484
+ if ( this.map && this.map.isTexture ) data.map = this.map.toJSON( meta ).uuid;
9485
+ if ( this.matcap && this.matcap.isTexture ) data.matcap = this.matcap.toJSON( meta ).uuid;
9486
+ if ( this.alphaMap && this.alphaMap.isTexture ) data.alphaMap = this.alphaMap.toJSON( meta ).uuid;
9453
9487
 
9454
- }
9488
+ if ( this.lightMap && this.lightMap.isTexture ) {
9455
9489
 
9456
- hue /= 6;
9490
+ data.lightMap = this.lightMap.toJSON( meta ).uuid;
9491
+ data.lightMapIntensity = this.lightMapIntensity;
9457
9492
 
9458
9493
  }
9459
9494
 
9460
- target.h = hue;
9461
- target.s = saturation;
9462
- target.l = lightness;
9495
+ if ( this.aoMap && this.aoMap.isTexture ) {
9463
9496
 
9464
- return target;
9497
+ data.aoMap = this.aoMap.toJSON( meta ).uuid;
9498
+ data.aoMapIntensity = this.aoMapIntensity;
9465
9499
 
9466
- }
9500
+ }
9467
9501
 
9468
- getRGB( target, colorSpace = ColorManagement.workingColorSpace ) {
9502
+ if ( this.bumpMap && this.bumpMap.isTexture ) {
9469
9503
 
9470
- ColorManagement.fromWorkingColorSpace( _color.copy( this ), colorSpace );
9504
+ data.bumpMap = this.bumpMap.toJSON( meta ).uuid;
9505
+ data.bumpScale = this.bumpScale;
9471
9506
 
9472
- target.r = _color.r;
9473
- target.g = _color.g;
9474
- target.b = _color.b;
9507
+ }
9475
9508
 
9476
- return target;
9509
+ if ( this.normalMap && this.normalMap.isTexture ) {
9477
9510
 
9478
- }
9511
+ data.normalMap = this.normalMap.toJSON( meta ).uuid;
9512
+ data.normalMapType = this.normalMapType;
9513
+ data.normalScale = this.normalScale.toArray();
9479
9514
 
9480
- getStyle( colorSpace = SRGBColorSpace ) {
9515
+ }
9481
9516
 
9482
- ColorManagement.fromWorkingColorSpace( _color.copy( this ), colorSpace );
9517
+ if ( this.displacementMap && this.displacementMap.isTexture ) {
9483
9518
 
9484
- const r = _color.r, g = _color.g, b = _color.b;
9519
+ data.displacementMap = this.displacementMap.toJSON( meta ).uuid;
9520
+ data.displacementScale = this.displacementScale;
9521
+ data.displacementBias = this.displacementBias;
9485
9522
 
9486
- if ( colorSpace !== SRGBColorSpace ) {
9523
+ }
9487
9524
 
9488
- // Requires CSS Color Module Level 4 (https://www.w3.org/TR/css-color-4/).
9489
- return `color(${ colorSpace } ${ r.toFixed( 3 ) } ${ g.toFixed( 3 ) } ${ b.toFixed( 3 ) })`;
9525
+ if ( this.roughnessMap && this.roughnessMap.isTexture ) data.roughnessMap = this.roughnessMap.toJSON( meta ).uuid;
9526
+ if ( this.metalnessMap && this.metalnessMap.isTexture ) data.metalnessMap = this.metalnessMap.toJSON( meta ).uuid;
9490
9527
 
9491
- }
9528
+ if ( this.emissiveMap && this.emissiveMap.isTexture ) data.emissiveMap = this.emissiveMap.toJSON( meta ).uuid;
9529
+ if ( this.specularMap && this.specularMap.isTexture ) data.specularMap = this.specularMap.toJSON( meta ).uuid;
9530
+ if ( this.specularIntensityMap && this.specularIntensityMap.isTexture ) data.specularIntensityMap = this.specularIntensityMap.toJSON( meta ).uuid;
9531
+ if ( this.specularColorMap && this.specularColorMap.isTexture ) data.specularColorMap = this.specularColorMap.toJSON( meta ).uuid;
9492
9532
 
9493
- return `rgb(${ Math.round( r * 255 ) },${ Math.round( g * 255 ) },${ Math.round( b * 255 ) })`;
9533
+ if ( this.envMap && this.envMap.isTexture ) {
9494
9534
 
9495
- }
9535
+ data.envMap = this.envMap.toJSON( meta ).uuid;
9496
9536
 
9497
- offsetHSL( h, s, l ) {
9537
+ if ( this.combine !== undefined ) data.combine = this.combine;
9498
9538
 
9499
- this.getHSL( _hslA );
9539
+ }
9500
9540
 
9501
- return this.setHSL( _hslA.h + h, _hslA.s + s, _hslA.l + l );
9541
+ if ( this.envMapIntensity !== undefined ) data.envMapIntensity = this.envMapIntensity;
9542
+ if ( this.reflectivity !== undefined ) data.reflectivity = this.reflectivity;
9543
+ if ( this.refractionRatio !== undefined ) data.refractionRatio = this.refractionRatio;
9502
9544
 
9503
- }
9545
+ if ( this.gradientMap && this.gradientMap.isTexture ) {
9504
9546
 
9505
- add( color ) {
9547
+ data.gradientMap = this.gradientMap.toJSON( meta ).uuid;
9506
9548
 
9507
- this.r += color.r;
9508
- this.g += color.g;
9509
- this.b += color.b;
9549
+ }
9510
9550
 
9511
- return this;
9551
+ if ( this.transmission !== undefined ) data.transmission = this.transmission;
9552
+ if ( this.transmissionMap && this.transmissionMap.isTexture ) data.transmissionMap = this.transmissionMap.toJSON( meta ).uuid;
9553
+ if ( this.thickness !== undefined ) data.thickness = this.thickness;
9554
+ if ( this.thicknessMap && this.thicknessMap.isTexture ) data.thicknessMap = this.thicknessMap.toJSON( meta ).uuid;
9555
+ if ( this.attenuationDistance !== undefined && this.attenuationDistance !== Infinity ) data.attenuationDistance = this.attenuationDistance;
9556
+ if ( this.attenuationColor !== undefined ) data.attenuationColor = this.attenuationColor.getHex();
9512
9557
 
9513
- }
9558
+ if ( this.size !== undefined ) data.size = this.size;
9559
+ if ( this.shadowSide !== null ) data.shadowSide = this.shadowSide;
9560
+ if ( this.sizeAttenuation !== undefined ) data.sizeAttenuation = this.sizeAttenuation;
9514
9561
 
9515
- addColors( color1, color2 ) {
9562
+ if ( this.blending !== NormalBlending ) data.blending = this.blending;
9563
+ if ( this.side !== FrontSide ) data.side = this.side;
9564
+ if ( this.vertexColors === true ) data.vertexColors = true;
9516
9565
 
9517
- this.r = color1.r + color2.r;
9518
- this.g = color1.g + color2.g;
9519
- this.b = color1.b + color2.b;
9566
+ if ( this.opacity < 1 ) data.opacity = this.opacity;
9567
+ if ( this.transparent === true ) data.transparent = true;
9520
9568
 
9521
- return this;
9569
+ if ( this.blendSrc !== SrcAlphaFactor ) data.blendSrc = this.blendSrc;
9570
+ if ( this.blendDst !== OneMinusSrcAlphaFactor ) data.blendDst = this.blendDst;
9571
+ if ( this.blendEquation !== AddEquation ) data.blendEquation = this.blendEquation;
9572
+ if ( this.blendSrcAlpha !== null ) data.blendSrcAlpha = this.blendSrcAlpha;
9573
+ if ( this.blendDstAlpha !== null ) data.blendDstAlpha = this.blendDstAlpha;
9574
+ if ( this.blendEquationAlpha !== null ) data.blendEquationAlpha = this.blendEquationAlpha;
9575
+ if ( this.blendColor && this.blendColor.isColor ) data.blendColor = this.blendColor.getHex();
9576
+ if ( this.blendAlpha !== 0 ) data.blendAlpha = this.blendAlpha;
9577
+
9578
+ if ( this.depthFunc !== LessEqualDepth ) data.depthFunc = this.depthFunc;
9579
+ if ( this.depthTest === false ) data.depthTest = this.depthTest;
9580
+ if ( this.depthWrite === false ) data.depthWrite = this.depthWrite;
9581
+ if ( this.colorWrite === false ) data.colorWrite = this.colorWrite;
9582
+
9583
+ if ( this.stencilWriteMask !== 0xff ) data.stencilWriteMask = this.stencilWriteMask;
9584
+ if ( this.stencilFunc !== AlwaysStencilFunc ) data.stencilFunc = this.stencilFunc;
9585
+ if ( this.stencilRef !== 0 ) data.stencilRef = this.stencilRef;
9586
+ if ( this.stencilFuncMask !== 0xff ) data.stencilFuncMask = this.stencilFuncMask;
9587
+ if ( this.stencilFail !== KeepStencilOp ) data.stencilFail = this.stencilFail;
9588
+ if ( this.stencilZFail !== KeepStencilOp ) data.stencilZFail = this.stencilZFail;
9589
+ if ( this.stencilZPass !== KeepStencilOp ) data.stencilZPass = this.stencilZPass;
9590
+ if ( this.stencilWrite === true ) data.stencilWrite = this.stencilWrite;
9522
9591
 
9523
- }
9592
+ // rotation (SpriteMaterial)
9593
+ if ( this.rotation !== undefined && this.rotation !== 0 ) data.rotation = this.rotation;
9524
9594
 
9525
- addScalar( s ) {
9595
+ if ( this.polygonOffset === true ) data.polygonOffset = true;
9596
+ if ( this.polygonOffsetFactor !== 0 ) data.polygonOffsetFactor = this.polygonOffsetFactor;
9597
+ if ( this.polygonOffsetUnits !== 0 ) data.polygonOffsetUnits = this.polygonOffsetUnits;
9526
9598
 
9527
- this.r += s;
9528
- this.g += s;
9529
- this.b += s;
9599
+ if ( this.linewidth !== undefined && this.linewidth !== 1 ) data.linewidth = this.linewidth;
9600
+ if ( this.dashSize !== undefined ) data.dashSize = this.dashSize;
9601
+ if ( this.gapSize !== undefined ) data.gapSize = this.gapSize;
9602
+ if ( this.scale !== undefined ) data.scale = this.scale;
9530
9603
 
9531
- return this;
9604
+ if ( this.dithering === true ) data.dithering = true;
9532
9605
 
9533
- }
9606
+ if ( this.alphaTest > 0 ) data.alphaTest = this.alphaTest;
9607
+ if ( this.alphaHash === true ) data.alphaHash = true;
9608
+ if ( this.alphaToCoverage === true ) data.alphaToCoverage = true;
9609
+ if ( this.premultipliedAlpha === true ) data.premultipliedAlpha = true;
9610
+ if ( this.forceSinglePass === true ) data.forceSinglePass = true;
9534
9611
 
9535
- sub( color ) {
9612
+ if ( this.wireframe === true ) data.wireframe = true;
9613
+ if ( this.wireframeLinewidth > 1 ) data.wireframeLinewidth = this.wireframeLinewidth;
9614
+ if ( this.wireframeLinecap !== 'round' ) data.wireframeLinecap = this.wireframeLinecap;
9615
+ if ( this.wireframeLinejoin !== 'round' ) data.wireframeLinejoin = this.wireframeLinejoin;
9536
9616
 
9537
- this.r = Math.max( 0, this.r - color.r );
9538
- this.g = Math.max( 0, this.g - color.g );
9539
- this.b = Math.max( 0, this.b - color.b );
9617
+ if ( this.flatShading === true ) data.flatShading = true;
9540
9618
 
9541
- return this;
9619
+ if ( this.visible === false ) data.visible = false;
9542
9620
 
9543
- }
9621
+ if ( this.toneMapped === false ) data.toneMapped = false;
9544
9622
 
9545
- multiply( color ) {
9623
+ if ( this.fog === false ) data.fog = false;
9546
9624
 
9547
- this.r *= color.r;
9548
- this.g *= color.g;
9549
- this.b *= color.b;
9625
+ if ( Object.keys( this.userData ).length > 0 ) data.userData = this.userData;
9550
9626
 
9551
- return this;
9627
+ // TODO: Copied from Object3D.toJSON
9552
9628
 
9553
- }
9629
+ function extractFromCache( cache ) {
9554
9630
 
9555
- multiplyScalar( s ) {
9631
+ const values = [];
9556
9632
 
9557
- this.r *= s;
9558
- this.g *= s;
9559
- this.b *= s;
9633
+ for ( const key in cache ) {
9560
9634
 
9561
- return this;
9635
+ const data = cache[ key ];
9636
+ delete data.metadata;
9637
+ values.push( data );
9562
9638
 
9563
- }
9639
+ }
9564
9640
 
9565
- lerp( color, alpha ) {
9641
+ return values;
9566
9642
 
9567
- this.r += ( color.r - this.r ) * alpha;
9568
- this.g += ( color.g - this.g ) * alpha;
9569
- this.b += ( color.b - this.b ) * alpha;
9643
+ }
9570
9644
 
9571
- return this;
9645
+ if ( isRootObject ) {
9572
9646
 
9573
- }
9647
+ const textures = extractFromCache( meta.textures );
9648
+ const images = extractFromCache( meta.images );
9574
9649
 
9575
- lerpColors( color1, color2, alpha ) {
9650
+ if ( textures.length > 0 ) data.textures = textures;
9651
+ if ( images.length > 0 ) data.images = images;
9576
9652
 
9577
- this.r = color1.r + ( color2.r - color1.r ) * alpha;
9578
- this.g = color1.g + ( color2.g - color1.g ) * alpha;
9579
- this.b = color1.b + ( color2.b - color1.b ) * alpha;
9653
+ }
9580
9654
 
9581
- return this;
9655
+ return data;
9582
9656
 
9583
9657
  }
9584
9658
 
9585
- lerpHSL( color, alpha ) {
9586
-
9587
- this.getHSL( _hslA );
9588
- color.getHSL( _hslB );
9659
+ clone() {
9589
9660
 
9590
- const h = lerp( _hslA.h, _hslB.h, alpha );
9591
- const s = lerp( _hslA.s, _hslB.s, alpha );
9592
- const l = lerp( _hslA.l, _hslB.l, alpha );
9661
+ return new this.constructor().copy( this );
9593
9662
 
9594
- this.setHSL( h, s, l );
9663
+ }
9595
9664
 
9596
- return this;
9665
+ copy( source ) {
9597
9666
 
9598
- }
9667
+ this.name = source.name;
9599
9668
 
9600
- setFromVector3( v ) {
9669
+ this.blending = source.blending;
9670
+ this.side = source.side;
9671
+ this.vertexColors = source.vertexColors;
9601
9672
 
9602
- this.r = v.x;
9603
- this.g = v.y;
9604
- this.b = v.z;
9673
+ this.opacity = source.opacity;
9674
+ this.transparent = source.transparent;
9605
9675
 
9606
- return this;
9676
+ this.blendSrc = source.blendSrc;
9677
+ this.blendDst = source.blendDst;
9678
+ this.blendEquation = source.blendEquation;
9679
+ this.blendSrcAlpha = source.blendSrcAlpha;
9680
+ this.blendDstAlpha = source.blendDstAlpha;
9681
+ this.blendEquationAlpha = source.blendEquationAlpha;
9682
+ this.blendColor.copy( source.blendColor );
9683
+ this.blendAlpha = source.blendAlpha;
9607
9684
 
9608
- }
9685
+ this.depthFunc = source.depthFunc;
9686
+ this.depthTest = source.depthTest;
9687
+ this.depthWrite = source.depthWrite;
9609
9688
 
9610
- applyMatrix3( m ) {
9689
+ this.stencilWriteMask = source.stencilWriteMask;
9690
+ this.stencilFunc = source.stencilFunc;
9691
+ this.stencilRef = source.stencilRef;
9692
+ this.stencilFuncMask = source.stencilFuncMask;
9693
+ this.stencilFail = source.stencilFail;
9694
+ this.stencilZFail = source.stencilZFail;
9695
+ this.stencilZPass = source.stencilZPass;
9696
+ this.stencilWrite = source.stencilWrite;
9611
9697
 
9612
- const r = this.r, g = this.g, b = this.b;
9613
- const e = m.elements;
9698
+ const srcPlanes = source.clippingPlanes;
9699
+ let dstPlanes = null;
9614
9700
 
9615
- this.r = e[ 0 ] * r + e[ 3 ] * g + e[ 6 ] * b;
9616
- this.g = e[ 1 ] * r + e[ 4 ] * g + e[ 7 ] * b;
9617
- this.b = e[ 2 ] * r + e[ 5 ] * g + e[ 8 ] * b;
9701
+ if ( srcPlanes !== null ) {
9618
9702
 
9619
- return this;
9703
+ const n = srcPlanes.length;
9704
+ dstPlanes = new Array( n );
9620
9705
 
9621
- }
9706
+ for ( let i = 0; i !== n; ++ i ) {
9622
9707
 
9623
- equals( c ) {
9708
+ dstPlanes[ i ] = srcPlanes[ i ].clone();
9624
9709
 
9625
- return ( c.r === this.r ) && ( c.g === this.g ) && ( c.b === this.b );
9710
+ }
9626
9711
 
9627
- }
9712
+ }
9628
9713
 
9629
- fromArray( array, offset = 0 ) {
9714
+ this.clippingPlanes = dstPlanes;
9715
+ this.clipIntersection = source.clipIntersection;
9716
+ this.clipShadows = source.clipShadows;
9630
9717
 
9631
- this.r = array[ offset ];
9632
- this.g = array[ offset + 1 ];
9633
- this.b = array[ offset + 2 ];
9718
+ this.shadowSide = source.shadowSide;
9634
9719
 
9635
- return this;
9720
+ this.colorWrite = source.colorWrite;
9636
9721
 
9637
- }
9722
+ this.precision = source.precision;
9638
9723
 
9639
- toArray( array = [], offset = 0 ) {
9724
+ this.polygonOffset = source.polygonOffset;
9725
+ this.polygonOffsetFactor = source.polygonOffsetFactor;
9726
+ this.polygonOffsetUnits = source.polygonOffsetUnits;
9640
9727
 
9641
- array[ offset ] = this.r;
9642
- array[ offset + 1 ] = this.g;
9643
- array[ offset + 2 ] = this.b;
9728
+ this.dithering = source.dithering;
9644
9729
 
9645
- return array;
9730
+ this.alphaTest = source.alphaTest;
9731
+ this.alphaHash = source.alphaHash;
9732
+ this.alphaToCoverage = source.alphaToCoverage;
9733
+ this.premultipliedAlpha = source.premultipliedAlpha;
9734
+ this.forceSinglePass = source.forceSinglePass;
9646
9735
 
9647
- }
9736
+ this.visible = source.visible;
9648
9737
 
9649
- fromBufferAttribute( attribute, index ) {
9738
+ this.toneMapped = source.toneMapped;
9650
9739
 
9651
- this.r = attribute.getX( index );
9652
- this.g = attribute.getY( index );
9653
- this.b = attribute.getZ( index );
9740
+ this.userData = JSON.parse( JSON.stringify( source.userData ) );
9654
9741
 
9655
9742
  return this;
9656
9743
 
9657
9744
  }
9658
9745
 
9659
- toJSON() {
9746
+ dispose() {
9660
9747
 
9661
- return this.getHex();
9748
+ this.dispatchEvent( { type: 'dispose' } );
9662
9749
 
9663
9750
  }
9664
9751
 
9665
- *[ Symbol.iterator ]() {
9752
+ set needsUpdate( value ) {
9666
9753
 
9667
- yield this.r;
9668
- yield this.g;
9669
- yield this.b;
9754
+ if ( value === true ) this.version ++;
9670
9755
 
9671
9756
  }
9672
9757
 
9673
- };
9674
-
9675
- const _color = /*@__PURE__*/ new Color$1();
9676
-
9677
- Color$1.NAMES = _colorKeywords;
9758
+ }
9678
9759
 
9679
9760
  class MeshBasicMaterial extends Material {
9680
9761
 
@@ -9752,7 +9833,7 @@
9752
9833
 
9753
9834
  }
9754
9835
 
9755
- const _vector$8 = /*@__PURE__*/ new Vector3();
9836
+ const _vector$9 = /*@__PURE__*/ new Vector3();
9756
9837
  const _vector2$1 = /*@__PURE__*/ new Vector2();
9757
9838
 
9758
9839
  class BufferAttribute {
@@ -9775,7 +9856,8 @@
9775
9856
  this.normalized = normalized;
9776
9857
 
9777
9858
  this.usage = StaticDrawUsage;
9778
- this.updateRange = { offset: 0, count: - 1 };
9859
+ this._updateRange = { offset: 0, count: - 1 };
9860
+ this.updateRanges = [];
9779
9861
  this.gpuType = FloatType;
9780
9862
 
9781
9863
  this.version = 0;
@@ -9790,6 +9872,13 @@
9790
9872
 
9791
9873
  }
9792
9874
 
9875
+ get updateRange() {
9876
+
9877
+ console.warn( 'THREE.BufferAttribute: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.' ); // @deprecated, r159
9878
+ return this._updateRange;
9879
+
9880
+ }
9881
+
9793
9882
  setUsage( value ) {
9794
9883
 
9795
9884
  this.usage = value;
@@ -9798,6 +9887,18 @@
9798
9887
 
9799
9888
  }
9800
9889
 
9890
+ addUpdateRange( start, count ) {
9891
+
9892
+ this.updateRanges.push( { start, count } );
9893
+
9894
+ }
9895
+
9896
+ clearUpdateRanges() {
9897
+
9898
+ this.updateRanges.length = 0;
9899
+
9900
+ }
9901
+
9801
9902
  copy( source ) {
9802
9903
 
9803
9904
  this.name = source.name;
@@ -9853,10 +9954,10 @@
9853
9954
 
9854
9955
  for ( let i = 0, l = this.count; i < l; i ++ ) {
9855
9956
 
9856
- _vector$8.fromBufferAttribute( this, i );
9857
- _vector$8.applyMatrix3( m );
9957
+ _vector$9.fromBufferAttribute( this, i );
9958
+ _vector$9.applyMatrix3( m );
9858
9959
 
9859
- this.setXYZ( i, _vector$8.x, _vector$8.y, _vector$8.z );
9960
+ this.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z );
9860
9961
 
9861
9962
  }
9862
9963
 
@@ -9870,11 +9971,11 @@
9870
9971
 
9871
9972
  for ( let i = 0, l = this.count; i < l; i ++ ) {
9872
9973
 
9873
- _vector$8.fromBufferAttribute( this, i );
9974
+ _vector$9.fromBufferAttribute( this, i );
9874
9975
 
9875
- _vector$8.applyMatrix4( m );
9976
+ _vector$9.applyMatrix4( m );
9876
9977
 
9877
- this.setXYZ( i, _vector$8.x, _vector$8.y, _vector$8.z );
9978
+ this.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z );
9878
9979
 
9879
9980
  }
9880
9981
 
@@ -9886,11 +9987,11 @@
9886
9987
 
9887
9988
  for ( let i = 0, l = this.count; i < l; i ++ ) {
9888
9989
 
9889
- _vector$8.fromBufferAttribute( this, i );
9990
+ _vector$9.fromBufferAttribute( this, i );
9890
9991
 
9891
- _vector$8.applyNormalMatrix( m );
9992
+ _vector$9.applyNormalMatrix( m );
9892
9993
 
9893
- this.setXYZ( i, _vector$8.x, _vector$8.y, _vector$8.z );
9994
+ this.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z );
9894
9995
 
9895
9996
  }
9896
9997
 
@@ -9902,11 +10003,11 @@
9902
10003
 
9903
10004
  for ( let i = 0, l = this.count; i < l; i ++ ) {
9904
10005
 
9905
- _vector$8.fromBufferAttribute( this, i );
10006
+ _vector$9.fromBufferAttribute( this, i );
9906
10007
 
9907
- _vector$8.transformDirection( m );
10008
+ _vector$9.transformDirection( m );
9908
10009
 
9909
- this.setXYZ( i, _vector$8.x, _vector$8.y, _vector$8.z );
10010
+ this.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z );
9910
10011
 
9911
10012
  }
9912
10013
 
@@ -10108,7 +10209,6 @@
10108
10209
 
10109
10210
  if ( this.name !== '' ) data.name = this.name;
10110
10211
  if ( this.usage !== StaticDrawUsage ) data.usage = this.usage;
10111
- if ( this.updateRange.offset !== 0 || this.updateRange.count !== - 1 ) data.updateRange = this.updateRange;
10112
10212
 
10113
10213
  return data;
10114
10214
 
@@ -10152,9 +10252,9 @@
10152
10252
  const _m1 = /*@__PURE__*/ new Matrix4();
10153
10253
  const _obj = /*@__PURE__*/ new Object3D();
10154
10254
  const _offset = /*@__PURE__*/ new Vector3();
10155
- const _box$1$1 = /*@__PURE__*/ new Box3();
10255
+ const _box$2 = /*@__PURE__*/ new Box3();
10156
10256
  const _boxMorphTargets = /*@__PURE__*/ new Box3();
10157
- const _vector$7 = /*@__PURE__*/ new Vector3();
10257
+ const _vector$8 = /*@__PURE__*/ new Vector3();
10158
10258
 
10159
10259
  class BufferGeometry extends EventDispatcher {
10160
10260
 
@@ -10459,20 +10559,20 @@
10459
10559
  for ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {
10460
10560
 
10461
10561
  const morphAttribute = morphAttributesPosition[ i ];
10462
- _box$1$1.setFromBufferAttribute( morphAttribute );
10562
+ _box$2.setFromBufferAttribute( morphAttribute );
10463
10563
 
10464
10564
  if ( this.morphTargetsRelative ) {
10465
10565
 
10466
- _vector$7.addVectors( this.boundingBox.min, _box$1$1.min );
10467
- this.boundingBox.expandByPoint( _vector$7 );
10566
+ _vector$8.addVectors( this.boundingBox.min, _box$2.min );
10567
+ this.boundingBox.expandByPoint( _vector$8 );
10468
10568
 
10469
- _vector$7.addVectors( this.boundingBox.max, _box$1$1.max );
10470
- this.boundingBox.expandByPoint( _vector$7 );
10569
+ _vector$8.addVectors( this.boundingBox.max, _box$2.max );
10570
+ this.boundingBox.expandByPoint( _vector$8 );
10471
10571
 
10472
10572
  } else {
10473
10573
 
10474
- this.boundingBox.expandByPoint( _box$1$1.min );
10475
- this.boundingBox.expandByPoint( _box$1$1.max );
10574
+ this.boundingBox.expandByPoint( _box$2.min );
10575
+ this.boundingBox.expandByPoint( _box$2.max );
10476
10576
 
10477
10577
  }
10478
10578
 
@@ -10521,7 +10621,7 @@
10521
10621
 
10522
10622
  const center = this.boundingSphere.center;
10523
10623
 
10524
- _box$1$1.setFromBufferAttribute( position );
10624
+ _box$2.setFromBufferAttribute( position );
10525
10625
 
10526
10626
  // process morph attributes if present
10527
10627
 
@@ -10534,16 +10634,16 @@
10534
10634
 
10535
10635
  if ( this.morphTargetsRelative ) {
10536
10636
 
10537
- _vector$7.addVectors( _box$1$1.min, _boxMorphTargets.min );
10538
- _box$1$1.expandByPoint( _vector$7 );
10637
+ _vector$8.addVectors( _box$2.min, _boxMorphTargets.min );
10638
+ _box$2.expandByPoint( _vector$8 );
10539
10639
 
10540
- _vector$7.addVectors( _box$1$1.max, _boxMorphTargets.max );
10541
- _box$1$1.expandByPoint( _vector$7 );
10640
+ _vector$8.addVectors( _box$2.max, _boxMorphTargets.max );
10641
+ _box$2.expandByPoint( _vector$8 );
10542
10642
 
10543
10643
  } else {
10544
10644
 
10545
- _box$1$1.expandByPoint( _boxMorphTargets.min );
10546
- _box$1$1.expandByPoint( _boxMorphTargets.max );
10645
+ _box$2.expandByPoint( _boxMorphTargets.min );
10646
+ _box$2.expandByPoint( _boxMorphTargets.max );
10547
10647
 
10548
10648
  }
10549
10649
 
@@ -10551,7 +10651,7 @@
10551
10651
 
10552
10652
  }
10553
10653
 
10554
- _box$1$1.getCenter( center );
10654
+ _box$2.getCenter( center );
10555
10655
 
10556
10656
  // second, try to find a boundingSphere with a radius smaller than the
10557
10657
  // boundingSphere of the boundingBox: sqrt(3) smaller in the best case
@@ -10560,9 +10660,9 @@
10560
10660
 
10561
10661
  for ( let i = 0, il = position.count; i < il; i ++ ) {
10562
10662
 
10563
- _vector$7.fromBufferAttribute( position, i );
10663
+ _vector$8.fromBufferAttribute( position, i );
10564
10664
 
10565
- maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$7 ) );
10665
+ maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$8 ) );
10566
10666
 
10567
10667
  }
10568
10668
 
@@ -10577,16 +10677,16 @@
10577
10677
 
10578
10678
  for ( let j = 0, jl = morphAttribute.count; j < jl; j ++ ) {
10579
10679
 
10580
- _vector$7.fromBufferAttribute( morphAttribute, j );
10680
+ _vector$8.fromBufferAttribute( morphAttribute, j );
10581
10681
 
10582
10682
  if ( morphTargetsRelative ) {
10583
10683
 
10584
10684
  _offset.fromBufferAttribute( position, j );
10585
- _vector$7.add( _offset );
10685
+ _vector$8.add( _offset );
10586
10686
 
10587
10687
  }
10588
10688
 
10589
- maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$7 ) );
10689
+ maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$8 ) );
10590
10690
 
10591
10691
  }
10592
10692
 
@@ -10869,11 +10969,11 @@
10869
10969
 
10870
10970
  for ( let i = 0, il = normals.count; i < il; i ++ ) {
10871
10971
 
10872
- _vector$7.fromBufferAttribute( normals, i );
10972
+ _vector$8.fromBufferAttribute( normals, i );
10873
10973
 
10874
- _vector$7.normalize();
10974
+ _vector$8.normalize();
10875
10975
 
10876
- normals.setXYZ( i, _vector$7.x, _vector$7.y, _vector$7.z );
10976
+ normals.setXYZ( i, _vector$8.x, _vector$8.y, _vector$8.z );
10877
10977
 
10878
10978
  }
10879
10979
 
@@ -11215,7 +11315,7 @@
11215
11315
 
11216
11316
  const _inverseMatrix$3 = /*@__PURE__*/ new Matrix4();
11217
11317
  const _ray$3 = /*@__PURE__*/ new Ray();
11218
- const _sphere$5 = /*@__PURE__*/ new Sphere();
11318
+ const _sphere$6 = /*@__PURE__*/ new Sphere();
11219
11319
  const _sphereHitAt = /*@__PURE__*/ new Vector3();
11220
11320
 
11221
11321
  const _vA$1 = /*@__PURE__*/ new Vector3();
@@ -11363,16 +11463,16 @@
11363
11463
 
11364
11464
  if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
11365
11465
 
11366
- _sphere$5.copy( geometry.boundingSphere );
11367
- _sphere$5.applyMatrix4( matrixWorld );
11466
+ _sphere$6.copy( geometry.boundingSphere );
11467
+ _sphere$6.applyMatrix4( matrixWorld );
11368
11468
 
11369
11469
  // check distance from ray origin to bounding sphere
11370
11470
 
11371
11471
  _ray$3.copy( raycaster.ray ).recast( raycaster.near );
11372
11472
 
11373
- if ( _sphere$5.containsPoint( _ray$3.origin ) === false ) {
11473
+ if ( _sphere$6.containsPoint( _ray$3.origin ) === false ) {
11374
11474
 
11375
- if ( _ray$3.intersectSphere( _sphere$5, _sphereHitAt ) === null ) return;
11475
+ if ( _ray$3.intersectSphere( _sphere$6, _sphereHitAt ) === null ) return;
11376
11476
 
11377
11477
  if ( _ray$3.origin.distanceToSquared( _sphereHitAt ) > ( raycaster.far - raycaster.near ) ** 2 ) return;
11378
11478
 
@@ -12925,8 +13025,8 @@
12925
13025
 
12926
13026
  }
12927
13027
 
12928
- const _sphere$4 = /*@__PURE__*/ new Sphere();
12929
- const _vector$6 = /*@__PURE__*/ new Vector3();
13028
+ const _sphere$5 = /*@__PURE__*/ new Sphere();
13029
+ const _vector$7 = /*@__PURE__*/ new Vector3();
12930
13030
 
12931
13031
  class Frustum {
12932
13032
 
@@ -13004,7 +13104,7 @@
13004
13104
 
13005
13105
  if ( object.boundingSphere === null ) object.computeBoundingSphere();
13006
13106
 
13007
- _sphere$4.copy( object.boundingSphere ).applyMatrix4( object.matrixWorld );
13107
+ _sphere$5.copy( object.boundingSphere ).applyMatrix4( object.matrixWorld );
13008
13108
 
13009
13109
  } else {
13010
13110
 
@@ -13012,21 +13112,21 @@
13012
13112
 
13013
13113
  if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
13014
13114
 
13015
- _sphere$4.copy( geometry.boundingSphere ).applyMatrix4( object.matrixWorld );
13115
+ _sphere$5.copy( geometry.boundingSphere ).applyMatrix4( object.matrixWorld );
13016
13116
 
13017
13117
  }
13018
13118
 
13019
- return this.intersectsSphere( _sphere$4 );
13119
+ return this.intersectsSphere( _sphere$5 );
13020
13120
 
13021
13121
  }
13022
13122
 
13023
13123
  intersectsSprite( sprite ) {
13024
13124
 
13025
- _sphere$4.center.set( 0, 0, 0 );
13026
- _sphere$4.radius = 0.7071067811865476;
13027
- _sphere$4.applyMatrix4( sprite.matrixWorld );
13125
+ _sphere$5.center.set( 0, 0, 0 );
13126
+ _sphere$5.radius = 0.7071067811865476;
13127
+ _sphere$5.applyMatrix4( sprite.matrixWorld );
13028
13128
 
13029
- return this.intersectsSphere( _sphere$4 );
13129
+ return this.intersectsSphere( _sphere$5 );
13030
13130
 
13031
13131
  }
13032
13132
 
@@ -13062,11 +13162,11 @@
13062
13162
 
13063
13163
  // corner at max distance
13064
13164
 
13065
- _vector$6.x = plane.normal.x > 0 ? box.max.x : box.min.x;
13066
- _vector$6.y = plane.normal.y > 0 ? box.max.y : box.min.y;
13067
- _vector$6.z = plane.normal.z > 0 ? box.max.z : box.min.z;
13165
+ _vector$7.x = plane.normal.x > 0 ? box.max.x : box.min.x;
13166
+ _vector$7.y = plane.normal.y > 0 ? box.max.y : box.min.y;
13167
+ _vector$7.z = plane.normal.z > 0 ? box.max.z : box.min.z;
13068
13168
 
13069
- if ( plane.distanceToPoint( _vector$6 ) < 0 ) {
13169
+ if ( plane.distanceToPoint( _vector$7 ) < 0 ) {
13070
13170
 
13071
13171
  return false;
13072
13172
 
@@ -13166,6 +13266,7 @@
13166
13266
 
13167
13267
  const array = attribute.array;
13168
13268
  const usage = attribute.usage;
13269
+ const size = array.byteLength;
13169
13270
 
13170
13271
  const buffer = gl.createBuffer();
13171
13272
 
@@ -13234,7 +13335,8 @@
13234
13335
  buffer: buffer,
13235
13336
  type: type,
13236
13337
  bytesPerElement: array.BYTES_PER_ELEMENT,
13237
- version: attribute.version
13338
+ version: attribute.version,
13339
+ size: size
13238
13340
  };
13239
13341
 
13240
13342
  }
@@ -13242,17 +13344,43 @@
13242
13344
  function updateBuffer( buffer, attribute, bufferType ) {
13243
13345
 
13244
13346
  const array = attribute.array;
13245
- const updateRange = attribute.updateRange;
13347
+ const updateRange = attribute._updateRange; // deprecated
13348
+ const updateRanges = attribute.updateRanges;
13246
13349
 
13247
13350
  gl.bindBuffer( bufferType, buffer );
13248
13351
 
13249
- if ( updateRange.count === - 1 ) {
13352
+ if ( updateRange.count === - 1 && updateRanges.length === 0 ) {
13250
13353
 
13251
13354
  // Not using update ranges
13252
-
13253
13355
  gl.bufferSubData( bufferType, 0, array );
13254
13356
 
13255
- } else {
13357
+ }
13358
+
13359
+ if ( updateRanges.length !== 0 ) {
13360
+
13361
+ for ( let i = 0, l = updateRanges.length; i < l; i ++ ) {
13362
+
13363
+ const range = updateRanges[ i ];
13364
+ if ( isWebGL2 ) {
13365
+
13366
+ gl.bufferSubData( bufferType, range.start * array.BYTES_PER_ELEMENT,
13367
+ array, range.start, range.count );
13368
+
13369
+ } else {
13370
+
13371
+ gl.bufferSubData( bufferType, range.start * array.BYTES_PER_ELEMENT,
13372
+ array.subarray( range.start, range.start + range.count ) );
13373
+
13374
+ }
13375
+
13376
+ }
13377
+
13378
+ attribute.clearUpdateRanges();
13379
+
13380
+ }
13381
+
13382
+ // deprecated
13383
+ if ( updateRange.count !== - 1 ) {
13256
13384
 
13257
13385
  if ( isWebGL2 ) {
13258
13386
 
@@ -13331,6 +13459,12 @@
13331
13459
 
13332
13460
  } else if ( data.version < attribute.version ) {
13333
13461
 
13462
+ if ( data.size !== attribute.array.byteLength ) {
13463
+
13464
+ 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.' );
13465
+
13466
+ }
13467
+
13334
13468
  updateBuffer( data.buffer, attribute, bufferType );
13335
13469
 
13336
13470
  data.version = attribute.version;
@@ -13455,10 +13589,14 @@
13455
13589
 
13456
13590
  var alphatest_pars_fragment = "#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif";
13457
13591
 
13458
- var aomap_fragment = "#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif";
13592
+ var aomap_fragment = "#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif";
13459
13593
 
13460
13594
  var aomap_pars_fragment = "#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif";
13461
13595
 
13596
+ 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";
13597
+
13598
+ var batching_vertex = "#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( batchId );\n#endif";
13599
+
13462
13600
  var begin_vertex = "vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif";
13463
13601
 
13464
13602
  var beginnormal_vertex = "vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif";
@@ -13467,7 +13605,7 @@
13467
13605
 
13468
13606
  var iridescence_fragment = "#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif";
13469
13607
 
13470
- 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 = dFdx( surf_pos.xyz );\n\t\tvec3 vSigmaY = 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";
13608
+ 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";
13471
13609
 
13472
13610
  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";
13473
13611
 
@@ -13489,7 +13627,7 @@
13489
13627
 
13490
13628
  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";
13491
13629
 
13492
- 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";
13630
+ 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";
13493
13631
 
13494
13632
  var displacementmap_pars_vertex = "#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif";
13495
13633
 
@@ -13543,11 +13681,11 @@
13543
13681
 
13544
13682
  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";
13545
13683
 
13546
- 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";
13684
+ 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";
13547
13685
 
13548
- 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 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = 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\tclearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += 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\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += 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}";
13686
+ 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}";
13549
13687
 
13550
- var lights_fragment_begin = "\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal;\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif";
13688
+ var lights_fragment_begin = "\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif";
13551
13689
 
13552
13690
  var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif";
13553
13691
 
@@ -13607,7 +13745,7 @@
13607
13745
 
13608
13746
  var premultiplied_alpha_fragment = "#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif";
13609
13747
 
13610
- 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;";
13748
+ 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;";
13611
13749
 
13612
13750
  var dithering_fragment = "#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif";
13613
13751
 
@@ -13627,7 +13765,7 @@
13627
13765
 
13628
13766
  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";
13629
13767
 
13630
- 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";
13768
+ 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";
13631
13769
 
13632
13770
  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";
13633
13771
 
@@ -13651,7 +13789,7 @@
13651
13789
 
13652
13790
  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";
13653
13791
 
13654
- 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";
13792
+ 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";
13655
13793
 
13656
13794
  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}";
13657
13795
 
@@ -13665,11 +13803,11 @@
13665
13803
 
13666
13804
  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}";
13667
13805
 
13668
- 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}";
13806
+ 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}";
13669
13807
 
13670
13808
  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}";
13671
13809
 
13672
- 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}";
13810
+ 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}";
13673
13811
 
13674
13812
  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}";
13675
13813
 
@@ -13681,31 +13819,31 @@
13681
13819
 
13682
13820
  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}";
13683
13821
 
13684
- 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}";
13822
+ 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}";
13685
13823
 
13686
13824
  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}";
13687
13825
 
13688
- 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}";
13826
+ 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}";
13689
13827
 
13690
13828
  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}";
13691
13829
 
13692
- 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}";
13830
+ 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}";
13693
13831
 
13694
13832
  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}";
13695
13833
 
13696
- 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}";
13834
+ 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}";
13697
13835
 
13698
13836
  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}";
13699
13837
 
13700
- 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}";
13838
+ 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}";
13701
13839
 
13702
13840
  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}";
13703
13841
 
13704
- 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}";
13842
+ 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}";
13705
13843
 
13706
- 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 + sheenSpecular;\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 ) + clearcoatSpecular * 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}";
13844
+ 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}";
13707
13845
 
13708
- 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}";
13846
+ 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}";
13709
13847
 
13710
13848
  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}";
13711
13849
 
@@ -13713,7 +13851,7 @@
13713
13851
 
13714
13852
  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}";
13715
13853
 
13716
- 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}";
13854
+ 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}";
13717
13855
 
13718
13856
  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}";
13719
13857
 
@@ -13730,6 +13868,8 @@
13730
13868
  alphatest_pars_fragment: alphatest_pars_fragment,
13731
13869
  aomap_fragment: aomap_fragment,
13732
13870
  aomap_pars_fragment: aomap_pars_fragment,
13871
+ batching_pars_vertex: batching_pars_vertex,
13872
+ batching_vertex: batching_vertex,
13733
13873
  begin_vertex: begin_vertex,
13734
13874
  beginnormal_vertex: beginnormal_vertex,
13735
13875
  bsdfs: bsdfs,
@@ -15343,11 +15483,42 @@
15343
15483
 
15344
15484
  }
15345
15485
 
15486
+ function renderMultiDraw( starts, counts, drawCount ) {
15487
+
15488
+ if ( drawCount === 0 ) return;
15489
+
15490
+ const extension = extensions.get( 'WEBGL_multi_draw' );
15491
+ if ( extension === null ) {
15492
+
15493
+ for ( let i = 0; i < drawCount; i ++ ) {
15494
+
15495
+ this.render( starts[ i ], counts[ i ] );
15496
+
15497
+ }
15498
+
15499
+ } else {
15500
+
15501
+ extension.multiDrawArraysWEBGL( mode, starts, 0, counts, 0, drawCount );
15502
+
15503
+ let elementCount = 0;
15504
+ for ( let i = 0; i < drawCount; i ++ ) {
15505
+
15506
+ elementCount += counts[ i ];
15507
+
15508
+ }
15509
+
15510
+ info.update( elementCount, mode, 1 );
15511
+
15512
+ }
15513
+
15514
+ }
15515
+
15346
15516
  //
15347
15517
 
15348
15518
  this.setMode = setMode;
15349
15519
  this.render = render;
15350
15520
  this.renderInstances = renderInstances;
15521
+ this.renderMultiDraw = renderMultiDraw;
15351
15522
 
15352
15523
  }
15353
15524
 
@@ -15657,7 +15828,7 @@
15657
15828
 
15658
15829
  function get( texture ) {
15659
15830
 
15660
- if ( texture && texture.isTexture && texture.isRenderTargetTexture === false ) {
15831
+ if ( texture && texture.isTexture ) {
15661
15832
 
15662
15833
  const mapping = texture.mapping;
15663
15834
 
@@ -15878,6 +16049,8 @@
15878
16049
  const _flatCamera = /*@__PURE__*/ new OrthographicCamera();
15879
16050
  const _clearColor = /*@__PURE__*/ new Color$1();
15880
16051
  let _oldTarget = null;
16052
+ let _oldActiveCubeFace = 0;
16053
+ let _oldActiveMipmapLevel = 0;
15881
16054
 
15882
16055
  // Golden Ratio
15883
16056
  const PHI = ( 1 + Math.sqrt( 5 ) ) / 2;
@@ -15943,6 +16116,8 @@
15943
16116
  fromScene( scene, sigma = 0, near = 0.1, far = 100 ) {
15944
16117
 
15945
16118
  _oldTarget = this._renderer.getRenderTarget();
16119
+ _oldActiveCubeFace = this._renderer.getActiveCubeFace();
16120
+ _oldActiveMipmapLevel = this._renderer.getActiveMipmapLevel();
15946
16121
 
15947
16122
  this._setSize( 256 );
15948
16123
 
@@ -16055,7 +16230,7 @@
16055
16230
 
16056
16231
  _cleanup( outputTarget ) {
16057
16232
 
16058
- this._renderer.setRenderTarget( _oldTarget );
16233
+ this._renderer.setRenderTarget( _oldTarget, _oldActiveCubeFace, _oldActiveMipmapLevel );
16059
16234
  outputTarget.scissorTest = false;
16060
16235
  _setViewport( outputTarget, 0, 0, outputTarget.width, outputTarget.height );
16061
16236
 
@@ -16074,6 +16249,8 @@
16074
16249
  }
16075
16250
 
16076
16251
  _oldTarget = this._renderer.getRenderTarget();
16252
+ _oldActiveCubeFace = this._renderer.getActiveCubeFace();
16253
+ _oldActiveMipmapLevel = this._renderer.getActiveMipmapLevel();
16077
16254
 
16078
16255
  const cubeUVRenderTarget = renderTarget || this._allocateTargets();
16079
16256
  this._textureToCubeUV( texture, cubeUVRenderTarget );
@@ -17223,12 +17400,43 @@
17223
17400
 
17224
17401
  }
17225
17402
 
17403
+ function renderMultiDraw( starts, counts, drawCount ) {
17404
+
17405
+ if ( drawCount === 0 ) return;
17406
+
17407
+ const extension = extensions.get( 'WEBGL_multi_draw' );
17408
+ if ( extension === null ) {
17409
+
17410
+ for ( let i = 0; i < drawCount; i ++ ) {
17411
+
17412
+ this.render( starts[ i ] / bytesPerElement, counts[ i ] );
17413
+
17414
+ }
17415
+
17416
+ } else {
17417
+
17418
+ extension.multiDrawElementsWEBGL( mode, counts, 0, type, starts, 0, drawCount );
17419
+
17420
+ let elementCount = 0;
17421
+ for ( let i = 0; i < drawCount; i ++ ) {
17422
+
17423
+ elementCount += counts[ i ];
17424
+
17425
+ }
17426
+
17427
+ info.update( elementCount, mode, 1 );
17428
+
17429
+ }
17430
+
17431
+ }
17432
+
17226
17433
  //
17227
17434
 
17228
17435
  this.setMode = setMode;
17229
17436
  this.setIndex = setIndex;
17230
17437
  this.render = render;
17231
17438
  this.renderInstances = renderInstances;
17439
+ this.renderMultiDraw = renderMultiDraw;
17232
17440
 
17233
17441
  }
17234
17442
 
@@ -17684,6 +17892,60 @@
17684
17892
 
17685
17893
  }
17686
17894
 
17895
+ class DepthTexture extends Texture {
17896
+
17897
+ constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format ) {
17898
+
17899
+ format = format !== undefined ? format : DepthFormat;
17900
+
17901
+ if ( format !== DepthFormat && format !== DepthStencilFormat ) {
17902
+
17903
+ throw new Error( 'DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat' );
17904
+
17905
+ }
17906
+
17907
+ if ( type === undefined && format === DepthFormat ) type = UnsignedIntType;
17908
+ if ( type === undefined && format === DepthStencilFormat ) type = UnsignedInt248Type;
17909
+
17910
+ super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
17911
+
17912
+ this.isDepthTexture = true;
17913
+
17914
+ this.image = { width: width, height: height };
17915
+
17916
+ this.magFilter = magFilter !== undefined ? magFilter : NearestFilter;
17917
+ this.minFilter = minFilter !== undefined ? minFilter : NearestFilter;
17918
+
17919
+ this.flipY = false;
17920
+ this.generateMipmaps = false;
17921
+
17922
+ this.compareFunction = null;
17923
+
17924
+ }
17925
+
17926
+
17927
+ copy( source ) {
17928
+
17929
+ super.copy( source );
17930
+
17931
+ this.compareFunction = source.compareFunction;
17932
+
17933
+ return this;
17934
+
17935
+ }
17936
+
17937
+ toJSON( meta ) {
17938
+
17939
+ const data = super.toJSON( meta );
17940
+
17941
+ if ( this.compareFunction !== null ) data.compareFunction = this.compareFunction;
17942
+
17943
+ return data;
17944
+
17945
+ }
17946
+
17947
+ }
17948
+
17687
17949
  /**
17688
17950
  * Uniforms of a program.
17689
17951
  * Those form a tree structure with a special top-level container for the root,
@@ -17729,6 +17991,10 @@
17729
17991
 
17730
17992
 
17731
17993
  const emptyTexture = /*@__PURE__*/ new Texture();
17994
+
17995
+ const emptyShadowTexture = /*@__PURE__*/ new DepthTexture( 1, 1 );
17996
+ emptyShadowTexture.compareFunction = LessEqualCompare;
17997
+
17732
17998
  const emptyArrayTexture = /*@__PURE__*/ new DataArrayTexture();
17733
17999
  const empty3dTexture = /*@__PURE__*/ new Data3DTexture();
17734
18000
  const emptyCubeTexture = /*@__PURE__*/ new CubeTexture();
@@ -18245,7 +18511,9 @@
18245
18511
 
18246
18512
  }
18247
18513
 
18248
- textures.setTexture2D( v || emptyTexture, unit );
18514
+ const emptyTexture2D = ( this.type === gl.SAMPLER_2D_SHADOW ) ? emptyShadowTexture : emptyTexture;
18515
+
18516
+ textures.setTexture2D( v || emptyTexture2D, unit );
18249
18517
 
18250
18518
  }
18251
18519
 
@@ -18629,6 +18897,7 @@
18629
18897
  this.id = id;
18630
18898
  this.addr = addr;
18631
18899
  this.cache = [];
18900
+ this.type = activeInfo.type;
18632
18901
  this.setValue = getSingularSetter( activeInfo.type );
18633
18902
 
18634
18903
  // this.path = activeInfo.name; // DEBUG
@@ -18644,6 +18913,7 @@
18644
18913
  this.id = id;
18645
18914
  this.addr = addr;
18646
18915
  this.cache = [];
18916
+ this.type = activeInfo.type;
18647
18917
  this.size = activeInfo.size;
18648
18918
  this.setValue = getPureArraySetter( activeInfo.type );
18649
18919
 
@@ -18836,6 +19106,9 @@
18836
19106
 
18837
19107
  }
18838
19108
 
19109
+ // From https://www.khronos.org/registry/webgl/extensions/KHR_parallel_shader_compile/
19110
+ const COMPLETION_STATUS_KHR = 0x91B1;
19111
+
18839
19112
  let programIdCount = 0;
18840
19113
 
18841
19114
  function handleSource( string, errorLine ) {
@@ -19332,6 +19605,7 @@
19332
19605
 
19333
19606
  customDefines,
19334
19607
 
19608
+ parameters.batching ? '#define USE_BATCHING' : '',
19335
19609
  parameters.instancing ? '#define USE_INSTANCING' : '',
19336
19610
  parameters.instancingColor ? '#define USE_INSTANCING_COLOR' : '',
19337
19611
 
@@ -19678,6 +19952,7 @@
19678
19952
  ].join( '\n' ) + '\n' + prefixVertex;
19679
19953
 
19680
19954
  prefixFragment = [
19955
+ 'precision mediump sampler2DArray;',
19681
19956
  '#define varying in',
19682
19957
  ( parameters.glslVersion === GLSL3 ) ? '' : 'layout(location = 0) out highp vec4 pc_fragColor;',
19683
19958
  ( parameters.glslVersion === GLSL3 ) ? '' : '#define gl_FragColor pc_fragColor',
@@ -19722,87 +19997,94 @@
19722
19997
 
19723
19998
  gl.linkProgram( program );
19724
19999
 
19725
- // check for link errors
19726
- if ( renderer.debug.checkShaderErrors ) {
20000
+ function onFirstUse( self ) {
19727
20001
 
19728
- const programLog = gl.getProgramInfoLog( program ).trim();
19729
- const vertexLog = gl.getShaderInfoLog( glVertexShader ).trim();
19730
- const fragmentLog = gl.getShaderInfoLog( glFragmentShader ).trim();
20002
+ // check for link errors
20003
+ if ( renderer.debug.checkShaderErrors ) {
19731
20004
 
19732
- let runnable = true;
19733
- let haveDiagnostics = true;
20005
+ const programLog = gl.getProgramInfoLog( program ).trim();
20006
+ const vertexLog = gl.getShaderInfoLog( glVertexShader ).trim();
20007
+ const fragmentLog = gl.getShaderInfoLog( glFragmentShader ).trim();
19734
20008
 
19735
- if ( gl.getProgramParameter( program, gl.LINK_STATUS ) === false ) {
20009
+ let runnable = true;
20010
+ let haveDiagnostics = true;
19736
20011
 
19737
- runnable = false;
20012
+ if ( gl.getProgramParameter( program, gl.LINK_STATUS ) === false ) {
19738
20013
 
19739
- if ( typeof renderer.debug.onShaderError === 'function' ) {
20014
+ runnable = false;
19740
20015
 
19741
- renderer.debug.onShaderError( gl, program, glVertexShader, glFragmentShader );
20016
+ if ( typeof renderer.debug.onShaderError === 'function' ) {
19742
20017
 
19743
- } else {
20018
+ renderer.debug.onShaderError( gl, program, glVertexShader, glFragmentShader );
19744
20019
 
19745
- // default error reporting
20020
+ } else {
19746
20021
 
19747
- const vertexErrors = getShaderErrors( gl, glVertexShader, 'vertex' );
19748
- const fragmentErrors = getShaderErrors( gl, glFragmentShader, 'fragment' );
20022
+ // default error reporting
19749
20023
 
19750
- console.error(
19751
- 'THREE.WebGLProgram: Shader Error ' + gl.getError() + ' - ' +
19752
- 'VALIDATE_STATUS ' + gl.getProgramParameter( program, gl.VALIDATE_STATUS ) + '\n\n' +
19753
- 'Program Info Log: ' + programLog + '\n' +
19754
- vertexErrors + '\n' +
19755
- fragmentErrors
19756
- );
20024
+ const vertexErrors = getShaderErrors( gl, glVertexShader, 'vertex' );
20025
+ const fragmentErrors = getShaderErrors( gl, glFragmentShader, 'fragment' );
19757
20026
 
19758
- }
20027
+ console.error(
20028
+ 'THREE.WebGLProgram: Shader Error ' + gl.getError() + ' - ' +
20029
+ 'VALIDATE_STATUS ' + gl.getProgramParameter( program, gl.VALIDATE_STATUS ) + '\n\n' +
20030
+ 'Program Info Log: ' + programLog + '\n' +
20031
+ vertexErrors + '\n' +
20032
+ fragmentErrors
20033
+ );
20034
+
20035
+ }
19759
20036
 
19760
- } else if ( programLog !== '' ) {
20037
+ } else if ( programLog !== '' ) {
19761
20038
 
19762
- console.warn( 'THREE.WebGLProgram: Program Info Log:', programLog );
20039
+ console.warn( 'THREE.WebGLProgram: Program Info Log:', programLog );
19763
20040
 
19764
- } else if ( vertexLog === '' || fragmentLog === '' ) {
20041
+ } else if ( vertexLog === '' || fragmentLog === '' ) {
19765
20042
 
19766
- haveDiagnostics = false;
20043
+ haveDiagnostics = false;
19767
20044
 
19768
- }
20045
+ }
19769
20046
 
19770
- if ( haveDiagnostics ) {
20047
+ if ( haveDiagnostics ) {
19771
20048
 
19772
- this.diagnostics = {
20049
+ self.diagnostics = {
19773
20050
 
19774
- runnable: runnable,
20051
+ runnable: runnable,
19775
20052
 
19776
- programLog: programLog,
20053
+ programLog: programLog,
19777
20054
 
19778
- vertexShader: {
20055
+ vertexShader: {
19779
20056
 
19780
- log: vertexLog,
19781
- prefix: prefixVertex
20057
+ log: vertexLog,
20058
+ prefix: prefixVertex
19782
20059
 
19783
- },
20060
+ },
19784
20061
 
19785
- fragmentShader: {
20062
+ fragmentShader: {
19786
20063
 
19787
- log: fragmentLog,
19788
- prefix: prefixFragment
20064
+ log: fragmentLog,
20065
+ prefix: prefixFragment
19789
20066
 
19790
- }
20067
+ }
19791
20068
 
19792
- };
20069
+ };
20070
+
20071
+ }
19793
20072
 
19794
20073
  }
19795
20074
 
19796
- }
20075
+ // Clean up
19797
20076
 
19798
- // Clean up
20077
+ // Crashes in iOS9 and iOS10. #18402
20078
+ // gl.detachShader( program, glVertexShader );
20079
+ // gl.detachShader( program, glFragmentShader );
19799
20080
 
19800
- // Crashes in iOS9 and iOS10. #18402
19801
- // gl.detachShader( program, glVertexShader );
19802
- // gl.detachShader( program, glFragmentShader );
20081
+ gl.deleteShader( glVertexShader );
20082
+ gl.deleteShader( glFragmentShader );
19803
20083
 
19804
- gl.deleteShader( glVertexShader );
19805
- gl.deleteShader( glFragmentShader );
20084
+ cachedUniforms = new WebGLUniforms( gl, program );
20085
+ cachedAttributes = fetchAttributeLocations( gl, program );
20086
+
20087
+ }
19806
20088
 
19807
20089
  // set up caching for uniform locations
19808
20090
 
@@ -19812,7 +20094,8 @@
19812
20094
 
19813
20095
  if ( cachedUniforms === undefined ) {
19814
20096
 
19815
- cachedUniforms = new WebGLUniforms( gl, program );
20097
+ // Populates cachedUniforms and cachedAttributes
20098
+ onFirstUse( this );
19816
20099
 
19817
20100
  }
19818
20101
 
@@ -19828,7 +20111,8 @@
19828
20111
 
19829
20112
  if ( cachedAttributes === undefined ) {
19830
20113
 
19831
- cachedAttributes = fetchAttributeLocations( gl, program );
20114
+ // Populates cachedAttributes and cachedUniforms
20115
+ onFirstUse( this );
19832
20116
 
19833
20117
  }
19834
20118
 
@@ -19836,6 +20120,23 @@
19836
20120
 
19837
20121
  };
19838
20122
 
20123
+ // indicate when the program is ready to be used. if the KHR_parallel_shader_compile extension isn't supported,
20124
+ // flag the program as ready immediately. It may cause a stall when it's first used.
20125
+
20126
+ let programReady = ( parameters.rendererExtensionParallelShaderCompile === false );
20127
+
20128
+ this.isReady = function () {
20129
+
20130
+ if ( programReady === false ) {
20131
+
20132
+ programReady = gl.getProgramParameter( program, COMPLETION_STATUS_KHR );
20133
+
20134
+ }
20135
+
20136
+ return programReady;
20137
+
20138
+ };
20139
+
19839
20140
  // free resource
19840
20141
 
19841
20142
  this.destroy = function () {
@@ -20087,6 +20388,7 @@
20087
20388
  const currentRenderTarget = renderer.getRenderTarget();
20088
20389
 
20089
20390
  const IS_INSTANCEDMESH = object.isInstancedMesh === true;
20391
+ const IS_BATCHEDMESH = object.isBatchedMesh === true;
20090
20392
 
20091
20393
  const HAS_MAP = !! material.map;
20092
20394
  const HAS_MATCAP = !! material.matcap;
@@ -20172,6 +20474,7 @@
20172
20474
 
20173
20475
  precision: precision,
20174
20476
 
20477
+ batching: IS_BATCHEDMESH,
20175
20478
  instancing: IS_INSTANCEDMESH,
20176
20479
  instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
20177
20480
 
@@ -20337,6 +20640,7 @@
20337
20640
  rendererExtensionFragDepth: IS_WEBGL2 || extensions.has( 'EXT_frag_depth' ),
20338
20641
  rendererExtensionDrawBuffers: IS_WEBGL2 || extensions.has( 'WEBGL_draw_buffers' ),
20339
20642
  rendererExtensionShaderTextureLod: IS_WEBGL2 || extensions.has( 'EXT_shader_texture_lod' ),
20643
+ rendererExtensionParallelShaderCompile: extensions.has( 'KHR_parallel_shader_compile' ),
20340
20644
 
20341
20645
  customProgramCacheKey: material.customProgramCacheKey()
20342
20646
 
@@ -20479,6 +20783,10 @@
20479
20783
  _programLayers.enable( 16 );
20480
20784
  if ( parameters.anisotropy )
20481
20785
  _programLayers.enable( 17 );
20786
+ if ( parameters.alphaHash )
20787
+ _programLayers.enable( 18 );
20788
+ if ( parameters.batching )
20789
+ _programLayers.enable( 19 );
20482
20790
 
20483
20791
  array.push( _programLayers.mask );
20484
20792
  _programLayers.disableAll();
@@ -22016,8 +22324,12 @@
22016
22324
 
22017
22325
  const depthMaterial = getDepthMaterial( object, groupMaterial, light, type );
22018
22326
 
22327
+ object.onBeforeShadow( _renderer, object, camera, shadowCamera, geometry, depthMaterial, group );
22328
+
22019
22329
  _renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, group );
22020
22330
 
22331
+ object.onAfterShadow( _renderer, object, camera, shadowCamera, geometry, depthMaterial, group );
22332
+
22021
22333
  }
22022
22334
 
22023
22335
  }
@@ -22026,8 +22338,12 @@
22026
22338
 
22027
22339
  const depthMaterial = getDepthMaterial( object, material, light, type );
22028
22340
 
22341
+ object.onBeforeShadow( _renderer, object, camera, shadowCamera, geometry, depthMaterial, null );
22342
+
22029
22343
  _renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, null );
22030
22344
 
22345
+ object.onAfterShadow( _renderer, object, camera, shadowCamera, geometry, depthMaterial, null );
22346
+
22031
22347
  }
22032
22348
 
22033
22349
  }
@@ -22370,6 +22686,8 @@
22370
22686
  let currentBlendEquationAlpha = null;
22371
22687
  let currentBlendSrcAlpha = null;
22372
22688
  let currentBlendDstAlpha = null;
22689
+ let currentBlendColor = new Color$1( 0, 0, 0 );
22690
+ let currentBlendAlpha = 0;
22373
22691
  let currentPremultipledAlpha = false;
22374
22692
 
22375
22693
  let currentFlipSided = null;
@@ -22645,10 +22963,14 @@
22645
22963
  [ OneMinusSrcColorFactor ]: gl.ONE_MINUS_SRC_COLOR,
22646
22964
  [ OneMinusSrcAlphaFactor ]: gl.ONE_MINUS_SRC_ALPHA,
22647
22965
  [ OneMinusDstColorFactor ]: gl.ONE_MINUS_DST_COLOR,
22648
- [ OneMinusDstAlphaFactor ]: gl.ONE_MINUS_DST_ALPHA
22966
+ [ OneMinusDstAlphaFactor ]: gl.ONE_MINUS_DST_ALPHA,
22967
+ [ ConstantColorFactor ]: gl.CONSTANT_COLOR,
22968
+ [ OneMinusConstantColorFactor ]: gl.ONE_MINUS_CONSTANT_COLOR,
22969
+ [ ConstantAlphaFactor ]: gl.CONSTANT_ALPHA,
22970
+ [ OneMinusConstantAlphaFactor ]: gl.ONE_MINUS_CONSTANT_ALPHA
22649
22971
  };
22650
22972
 
22651
- function setBlending( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, premultipliedAlpha ) {
22973
+ function setBlending( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, blendColor, blendAlpha, premultipliedAlpha ) {
22652
22974
 
22653
22975
  if ( blending === NoBlending ) {
22654
22976
 
@@ -22741,6 +23063,8 @@
22741
23063
  currentBlendDst = null;
22742
23064
  currentBlendSrcAlpha = null;
22743
23065
  currentBlendDstAlpha = null;
23066
+ currentBlendColor.set( 0, 0, 0 );
23067
+ currentBlendAlpha = 0;
22744
23068
 
22745
23069
  currentBlending = blending;
22746
23070
  currentPremultipledAlpha = premultipliedAlpha;
@@ -22777,6 +23101,15 @@
22777
23101
 
22778
23102
  }
22779
23103
 
23104
+ if ( blendColor.equals( currentBlendColor ) === false || blendAlpha !== currentBlendAlpha ) {
23105
+
23106
+ gl.blendColor( blendColor.r, blendColor.g, blendColor.b, blendAlpha );
23107
+
23108
+ currentBlendColor.copy( blendColor );
23109
+ currentBlendAlpha = blendAlpha;
23110
+
23111
+ }
23112
+
22780
23113
  currentBlending = blending;
22781
23114
  currentPremultipledAlpha = false;
22782
23115
 
@@ -22795,7 +23128,7 @@
22795
23128
 
22796
23129
  ( material.blending === NormalBlending && material.transparent === false )
22797
23130
  ? setBlending( NoBlending )
22798
- : setBlending( material.blending, material.blendEquation, material.blendSrc, material.blendDst, material.blendEquationAlpha, material.blendSrcAlpha, material.blendDstAlpha, material.premultipliedAlpha );
23131
+ : setBlending( material.blending, material.blendEquation, material.blendSrc, material.blendDst, material.blendEquationAlpha, material.blendSrcAlpha, material.blendDstAlpha, material.blendColor, material.blendAlpha, material.premultipliedAlpha );
22799
23132
 
22800
23133
  depthBuffer.setFunc( material.depthFunc );
22801
23134
  depthBuffer.setTest( material.depthTest );
@@ -23219,6 +23552,7 @@
23219
23552
  gl.blendEquation( gl.FUNC_ADD );
23220
23553
  gl.blendFunc( gl.ONE, gl.ZERO );
23221
23554
  gl.blendFuncSeparate( gl.ONE, gl.ZERO, gl.ONE, gl.ZERO );
23555
+ gl.blendColor( 0, 0, 0, 0 );
23222
23556
 
23223
23557
  gl.colorMask( true, true, true, true );
23224
23558
  gl.clearColor( 0, 0, 0, 0 );
@@ -23276,6 +23610,8 @@
23276
23610
  currentBlendEquationAlpha = null;
23277
23611
  currentBlendSrcAlpha = null;
23278
23612
  currentBlendDstAlpha = null;
23613
+ currentBlendColor = new Color$1( 0, 0, 0 );
23614
+ currentBlendAlpha = 0;
23279
23615
  currentPremultipledAlpha = false;
23280
23616
 
23281
23617
  currentFlipSided = null;
@@ -24107,7 +24443,7 @@
24107
24443
  let mipmap;
24108
24444
  const mipmaps = texture.mipmaps;
24109
24445
 
24110
- const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true );
24446
+ const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true && glInternalFormat !== RGB_ETC1_Format );
24111
24447
  const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
24112
24448
  const levels = getMipLevels( texture, image, supportsMips );
24113
24449
 
@@ -26099,60 +26435,6 @@
26099
26435
 
26100
26436
  }
26101
26437
 
26102
- class DepthTexture extends Texture {
26103
-
26104
- constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format ) {
26105
-
26106
- format = format !== undefined ? format : DepthFormat;
26107
-
26108
- if ( format !== DepthFormat && format !== DepthStencilFormat ) {
26109
-
26110
- throw new Error( 'DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat' );
26111
-
26112
- }
26113
-
26114
- if ( type === undefined && format === DepthFormat ) type = UnsignedIntType;
26115
- if ( type === undefined && format === DepthStencilFormat ) type = UnsignedInt248Type;
26116
-
26117
- super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
26118
-
26119
- this.isDepthTexture = true;
26120
-
26121
- this.image = { width: width, height: height };
26122
-
26123
- this.magFilter = magFilter !== undefined ? magFilter : NearestFilter;
26124
- this.minFilter = minFilter !== undefined ? minFilter : NearestFilter;
26125
-
26126
- this.flipY = false;
26127
- this.generateMipmaps = false;
26128
-
26129
- this.compareFunction = null;
26130
-
26131
- }
26132
-
26133
-
26134
- copy( source ) {
26135
-
26136
- super.copy( source );
26137
-
26138
- this.compareFunction = source.compareFunction;
26139
-
26140
- return this;
26141
-
26142
- }
26143
-
26144
- toJSON( meta ) {
26145
-
26146
- const data = super.toJSON( meta );
26147
-
26148
- if ( this.compareFunction !== null ) data.compareFunction = this.compareFunction;
26149
-
26150
- return data;
26151
-
26152
- }
26153
-
26154
- }
26155
-
26156
26438
  class WebXRManager extends EventDispatcher {
26157
26439
 
26158
26440
  constructor( renderer, gl ) {
@@ -26183,6 +26465,9 @@
26183
26465
  const controllers = [];
26184
26466
  const controllerInputSources = [];
26185
26467
 
26468
+ const currentSize = new Vector2();
26469
+ let currentPixelRatio = null;
26470
+
26186
26471
  //
26187
26472
 
26188
26473
  const cameraL = new PerspectiveCamera();
@@ -26319,6 +26604,9 @@
26319
26604
 
26320
26605
  scope.isPresenting = false;
26321
26606
 
26607
+ renderer.setPixelRatio( currentPixelRatio );
26608
+ renderer.setSize( currentSize.width, currentSize.height, false );
26609
+
26322
26610
  scope.dispatchEvent( { type: 'sessionend' } );
26323
26611
 
26324
26612
  }
@@ -26406,6 +26694,9 @@
26406
26694
 
26407
26695
  }
26408
26696
 
26697
+ currentPixelRatio = renderer.getPixelRatio();
26698
+ renderer.getSize( currentSize );
26699
+
26409
26700
  if ( ( session.renderState.layers === undefined ) || ( renderer.capabilities.isWebGL2 === false ) ) {
26410
26701
 
26411
26702
  const layerInit = {
@@ -26420,6 +26711,9 @@
26420
26711
 
26421
26712
  session.updateRenderState( { baseLayer: glBaseLayer } );
26422
26713
 
26714
+ renderer.setPixelRatio( 1 );
26715
+ renderer.setSize( glBaseLayer.framebufferWidth, glBaseLayer.framebufferHeight, false );
26716
+
26423
26717
  newRenderTarget = new WebGLRenderTarget(
26424
26718
  glBaseLayer.framebufferWidth,
26425
26719
  glBaseLayer.framebufferHeight,
@@ -26457,6 +26751,9 @@
26457
26751
 
26458
26752
  session.updateRenderState( { layers: [ glProjLayer ] } );
26459
26753
 
26754
+ renderer.setPixelRatio( 1 );
26755
+ renderer.setSize( glProjLayer.textureWidth, glProjLayer.textureHeight, false );
26756
+
26460
26757
  newRenderTarget = new WebGLRenderTarget(
26461
26758
  glProjLayer.textureWidth,
26462
26759
  glProjLayer.textureHeight,
@@ -28442,7 +28739,12 @@
28442
28739
  }
28443
28740
 
28444
28741
  if ( depth ) bits |= _gl.DEPTH_BUFFER_BIT;
28445
- if ( stencil ) bits |= _gl.STENCIL_BUFFER_BIT;
28742
+ if ( stencil ) {
28743
+
28744
+ bits |= _gl.STENCIL_BUFFER_BIT;
28745
+ this.state.buffers.stencil.setMask( 0xffffffff );
28746
+
28747
+ }
28446
28748
 
28447
28749
  _gl.clear( bits );
28448
28750
 
@@ -28704,7 +29006,11 @@
28704
29006
 
28705
29007
  }
28706
29008
 
28707
- if ( object.isInstancedMesh ) {
29009
+ if ( object.isBatchedMesh ) {
29010
+
29011
+ renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
29012
+
29013
+ } else if ( object.isInstancedMesh ) {
28708
29014
 
28709
29015
  renderer.renderInstances( drawStart, drawCount, object.count );
28710
29016
 
@@ -28725,36 +29031,40 @@
28725
29031
 
28726
29032
  // Compile
28727
29033
 
28728
- this.compile = function ( scene, camera ) {
29034
+ function prepareMaterial( material, scene, object ) {
28729
29035
 
28730
- function prepare( material, scene, object ) {
29036
+ if ( material.transparent === true && material.side === DoubleSide && material.forceSinglePass === false ) {
28731
29037
 
28732
- if ( material.transparent === true && material.side === DoubleSide && material.forceSinglePass === false ) {
29038
+ material.side = BackSide;
29039
+ material.needsUpdate = true;
29040
+ getProgram( material, scene, object );
28733
29041
 
28734
- material.side = BackSide;
28735
- material.needsUpdate = true;
28736
- getProgram( material, scene, object );
29042
+ material.side = FrontSide;
29043
+ material.needsUpdate = true;
29044
+ getProgram( material, scene, object );
28737
29045
 
28738
- material.side = FrontSide;
28739
- material.needsUpdate = true;
28740
- getProgram( material, scene, object );
29046
+ material.side = DoubleSide;
28741
29047
 
28742
- material.side = DoubleSide;
29048
+ } else {
28743
29049
 
28744
- } else {
29050
+ getProgram( material, scene, object );
28745
29051
 
28746
- getProgram( material, scene, object );
29052
+ }
28747
29053
 
28748
- }
29054
+ }
28749
29055
 
28750
- }
29056
+ this.compile = function ( scene, camera, targetScene = null ) {
28751
29057
 
28752
- currentRenderState = renderStates.get( scene );
29058
+ if ( targetScene === null ) targetScene = scene;
29059
+
29060
+ currentRenderState = renderStates.get( targetScene );
28753
29061
  currentRenderState.init();
28754
29062
 
28755
29063
  renderStateStack.push( currentRenderState );
28756
29064
 
28757
- scene.traverseVisible( function ( object ) {
29065
+ // gather lights from both the target scene and the new object that will be added to the scene.
29066
+
29067
+ targetScene.traverseVisible( function ( object ) {
28758
29068
 
28759
29069
  if ( object.isLight && object.layers.test( camera.layers ) ) {
28760
29070
 
@@ -28770,8 +29080,32 @@
28770
29080
 
28771
29081
  } );
28772
29082
 
29083
+ if ( scene !== targetScene ) {
29084
+
29085
+ scene.traverseVisible( function ( object ) {
29086
+
29087
+ if ( object.isLight && object.layers.test( camera.layers ) ) {
29088
+
29089
+ currentRenderState.pushLight( object );
29090
+
29091
+ if ( object.castShadow ) {
29092
+
29093
+ currentRenderState.pushShadow( object );
29094
+
29095
+ }
29096
+
29097
+ }
29098
+
29099
+ } );
29100
+
29101
+ }
29102
+
28773
29103
  currentRenderState.setupLights( _this._useLegacyLights );
28774
29104
 
29105
+ // Only initialize materials in the new scene, not the targetScene.
29106
+
29107
+ const materials = new Set();
29108
+
28775
29109
  scene.traverse( function ( object ) {
28776
29110
 
28777
29111
  const material = object.material;
@@ -28784,13 +29118,15 @@
28784
29118
 
28785
29119
  const material2 = material[ i ];
28786
29120
 
28787
- prepare( material2, scene, object );
29121
+ prepareMaterial( material2, targetScene, object );
29122
+ materials.add( material2 );
28788
29123
 
28789
29124
  }
28790
29125
 
28791
29126
  } else {
28792
29127
 
28793
- prepare( material, scene, object );
29128
+ prepareMaterial( material, targetScene, object );
29129
+ materials.add( material );
28794
29130
 
28795
29131
  }
28796
29132
 
@@ -28801,6 +29137,70 @@
28801
29137
  renderStateStack.pop();
28802
29138
  currentRenderState = null;
28803
29139
 
29140
+ return materials;
29141
+
29142
+ };
29143
+
29144
+ // compileAsync
29145
+
29146
+ this.compileAsync = function ( scene, camera, targetScene = null ) {
29147
+
29148
+ const materials = this.compile( scene, camera, targetScene );
29149
+
29150
+ // Wait for all the materials in the new object to indicate that they're
29151
+ // ready to be used before resolving the promise.
29152
+
29153
+ return new Promise( ( resolve ) => {
29154
+
29155
+ function checkMaterialsReady() {
29156
+
29157
+ materials.forEach( function ( material ) {
29158
+
29159
+ const materialProperties = properties.get( material );
29160
+ const program = materialProperties.currentProgram;
29161
+
29162
+ if ( program.isReady() ) {
29163
+
29164
+ // remove any programs that report they're ready to use from the list
29165
+ materials.delete( material );
29166
+
29167
+ }
29168
+
29169
+ } );
29170
+
29171
+ // once the list of compiling materials is empty, call the callback
29172
+
29173
+ if ( materials.size === 0 ) {
29174
+
29175
+ resolve( scene );
29176
+ return;
29177
+
29178
+ }
29179
+
29180
+ // if some materials are still not ready, wait a bit and check again
29181
+
29182
+ setTimeout( checkMaterialsReady, 10 );
29183
+
29184
+ }
29185
+
29186
+ if ( extensions.get( 'KHR_parallel_shader_compile' ) !== null ) {
29187
+
29188
+ // If we can check the compilation status of the materials without
29189
+ // blocking then do so right away.
29190
+
29191
+ checkMaterialsReady();
29192
+
29193
+ } else {
29194
+
29195
+ // Otherwise start by waiting a bit to give the materials we just
29196
+ // initialized a chance to finish.
29197
+
29198
+ setTimeout( checkMaterialsReady, 10 );
29199
+
29200
+ }
29201
+
29202
+ } );
29203
+
28804
29204
  };
28805
29205
 
28806
29206
  // Animation Loop
@@ -29137,6 +29537,14 @@
29137
29537
 
29138
29538
  function renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera ) {
29139
29539
 
29540
+ const overrideMaterial = scene.isScene === true ? scene.overrideMaterial : null;
29541
+
29542
+ if ( overrideMaterial !== null ) {
29543
+
29544
+ return;
29545
+
29546
+ }
29547
+
29140
29548
  const isWebGL2 = capabilities.isWebGL2;
29141
29549
 
29142
29550
  if ( _transmissionRenderTarget === null ) {
@@ -29396,21 +29804,32 @@
29396
29804
 
29397
29805
  }
29398
29806
 
29399
- const progUniforms = program.getUniforms();
29400
- const uniformsList = WebGLUniforms.seqWithValue( progUniforms.seq, uniforms );
29401
-
29402
29807
  materialProperties.currentProgram = program;
29403
- materialProperties.uniformsList = uniformsList;
29808
+ materialProperties.uniformsList = null;
29404
29809
 
29405
29810
  return program;
29406
29811
 
29407
29812
  }
29408
29813
 
29814
+ function getUniformList( materialProperties ) {
29815
+
29816
+ if ( materialProperties.uniformsList === null ) {
29817
+
29818
+ const progUniforms = materialProperties.currentProgram.getUniforms();
29819
+ materialProperties.uniformsList = WebGLUniforms.seqWithValue( progUniforms.seq, materialProperties.uniforms );
29820
+
29821
+ }
29822
+
29823
+ return materialProperties.uniformsList;
29824
+
29825
+ }
29826
+
29409
29827
  function updateCommonMaterialProperties( material, parameters ) {
29410
29828
 
29411
29829
  const materialProperties = properties.get( material );
29412
29830
 
29413
29831
  materialProperties.outputColorSpace = parameters.outputColorSpace;
29832
+ materialProperties.batching = parameters.batching;
29414
29833
  materialProperties.instancing = parameters.instancing;
29415
29834
  materialProperties.instancingColor = parameters.instancingColor;
29416
29835
  materialProperties.skinning = parameters.skinning;
@@ -29491,6 +29910,14 @@
29491
29910
 
29492
29911
  needsProgramChange = true;
29493
29912
 
29913
+ } else if ( object.isBatchedMesh && materialProperties.batching === false ) {
29914
+
29915
+ needsProgramChange = true;
29916
+
29917
+ } else if ( ! object.isBatchedMesh && materialProperties.batching === true ) {
29918
+
29919
+ needsProgramChange = true;
29920
+
29494
29921
  } else if ( object.isInstancedMesh && materialProperties.instancing === false ) {
29495
29922
 
29496
29923
  needsProgramChange = true;
@@ -29667,7 +30094,6 @@
29667
30094
  if ( skeleton.boneTexture === null ) skeleton.computeBoneTexture();
29668
30095
 
29669
30096
  p_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture, textures );
29670
- p_uniforms.setValue( _gl, 'boneTextureSize', skeleton.boneTextureSize );
29671
30097
 
29672
30098
  } else {
29673
30099
 
@@ -29679,6 +30105,13 @@
29679
30105
 
29680
30106
  }
29681
30107
 
30108
+ if ( object.isBatchedMesh ) {
30109
+
30110
+ p_uniforms.setOptional( _gl, object, 'batchingTexture' );
30111
+ p_uniforms.setValue( _gl, 'batchingTexture', object._matricesTexture, textures );
30112
+
30113
+ }
30114
+
29682
30115
  const morphAttributes = geometry.morphAttributes;
29683
30116
 
29684
30117
  if ( morphAttributes.position !== undefined || morphAttributes.normal !== undefined || ( morphAttributes.color !== undefined && capabilities.isWebGL2 === true ) ) {
@@ -29733,13 +30166,13 @@
29733
30166
 
29734
30167
  materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height, _transmissionRenderTarget );
29735
30168
 
29736
- WebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures );
30169
+ WebGLUniforms.upload( _gl, getUniformList( materialProperties ), m_uniforms, textures );
29737
30170
 
29738
30171
  }
29739
30172
 
29740
30173
  if ( material.isShaderMaterial && material.uniformsNeedUpdate === true ) {
29741
30174
 
29742
- WebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures );
30175
+ WebGLUniforms.upload( _gl, getUniformList( materialProperties ), m_uniforms, textures );
29743
30176
  material.uniformsNeedUpdate = false;
29744
30177
 
29745
30178
  }
@@ -30368,7 +30801,8 @@
30368
30801
  this.count = array !== undefined ? array.length / stride : 0;
30369
30802
 
30370
30803
  this.usage = StaticDrawUsage;
30371
- this.updateRange = { offset: 0, count: - 1 };
30804
+ this._updateRange = { offset: 0, count: - 1 };
30805
+ this.updateRanges = [];
30372
30806
 
30373
30807
  this.version = 0;
30374
30808
 
@@ -30384,6 +30818,13 @@
30384
30818
 
30385
30819
  }
30386
30820
 
30821
+ get updateRange() {
30822
+
30823
+ console.warn( 'THREE.InterleavedBuffer: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.' ); // @deprecated, r159
30824
+ return this._updateRange;
30825
+
30826
+ }
30827
+
30387
30828
  setUsage( value ) {
30388
30829
 
30389
30830
  this.usage = value;
@@ -30392,6 +30833,18 @@
30392
30833
 
30393
30834
  }
30394
30835
 
30836
+ addUpdateRange( start, count ) {
30837
+
30838
+ this.updateRanges.push( { start, count } );
30839
+
30840
+ }
30841
+
30842
+ clearUpdateRanges() {
30843
+
30844
+ this.updateRanges.length = 0;
30845
+
30846
+ }
30847
+
30395
30848
  copy( source ) {
30396
30849
 
30397
30850
  this.array = new source.array.constructor( source.array );
@@ -30498,7 +30951,7 @@
30498
30951
 
30499
30952
  }
30500
30953
 
30501
- const _vector$5 = /*@__PURE__*/ new Vector3();
30954
+ const _vector$6 = /*@__PURE__*/ new Vector3();
30502
30955
 
30503
30956
  class InterleavedBufferAttribute {
30504
30957
 
@@ -30538,11 +30991,11 @@
30538
30991
 
30539
30992
  for ( let i = 0, l = this.data.count; i < l; i ++ ) {
30540
30993
 
30541
- _vector$5.fromBufferAttribute( this, i );
30994
+ _vector$6.fromBufferAttribute( this, i );
30542
30995
 
30543
- _vector$5.applyMatrix4( m );
30996
+ _vector$6.applyMatrix4( m );
30544
30997
 
30545
- this.setXYZ( i, _vector$5.x, _vector$5.y, _vector$5.z );
30998
+ this.setXYZ( i, _vector$6.x, _vector$6.y, _vector$6.z );
30546
30999
 
30547
31000
  }
30548
31001
 
@@ -30554,11 +31007,11 @@
30554
31007
 
30555
31008
  for ( let i = 0, l = this.count; i < l; i ++ ) {
30556
31009
 
30557
- _vector$5.fromBufferAttribute( this, i );
31010
+ _vector$6.fromBufferAttribute( this, i );
30558
31011
 
30559
- _vector$5.applyNormalMatrix( m );
31012
+ _vector$6.applyNormalMatrix( m );
30560
31013
 
30561
- this.setXYZ( i, _vector$5.x, _vector$5.y, _vector$5.z );
31014
+ this.setXYZ( i, _vector$6.x, _vector$6.y, _vector$6.z );
30562
31015
 
30563
31016
  }
30564
31017
 
@@ -30570,11 +31023,11 @@
30570
31023
 
30571
31024
  for ( let i = 0, l = this.count; i < l; i ++ ) {
30572
31025
 
30573
- _vector$5.fromBufferAttribute( this, i );
31026
+ _vector$6.fromBufferAttribute( this, i );
30574
31027
 
30575
- _vector$5.transformDirection( m );
31028
+ _vector$6.transformDirection( m );
30576
31029
 
30577
- this.setXYZ( i, _vector$5.x, _vector$5.y, _vector$5.z );
31030
+ this.setXYZ( i, _vector$6.x, _vector$6.y, _vector$6.z );
30578
31031
 
30579
31032
  }
30580
31033
 
@@ -32258,7 +32711,95 @@
32258
32711
 
32259
32712
  }
32260
32713
 
32261
- getTangent( t, optionalTarget = new Vector2() ) {
32714
+ getTangent( t, optionalTarget = new Vector2() ) {
32715
+
32716
+ return optionalTarget.subVectors( this.v2, this.v1 ).normalize();
32717
+
32718
+ }
32719
+
32720
+ getTangentAt( u, optionalTarget ) {
32721
+
32722
+ return this.getTangent( u, optionalTarget );
32723
+
32724
+ }
32725
+
32726
+ copy( source ) {
32727
+
32728
+ super.copy( source );
32729
+
32730
+ this.v1.copy( source.v1 );
32731
+ this.v2.copy( source.v2 );
32732
+
32733
+ return this;
32734
+
32735
+ }
32736
+
32737
+ toJSON() {
32738
+
32739
+ const data = super.toJSON();
32740
+
32741
+ data.v1 = this.v1.toArray();
32742
+ data.v2 = this.v2.toArray();
32743
+
32744
+ return data;
32745
+
32746
+ }
32747
+
32748
+ fromJSON( json ) {
32749
+
32750
+ super.fromJSON( json );
32751
+
32752
+ this.v1.fromArray( json.v1 );
32753
+ this.v2.fromArray( json.v2 );
32754
+
32755
+ return this;
32756
+
32757
+ }
32758
+
32759
+ }
32760
+
32761
+ class LineCurve3 extends Curve {
32762
+
32763
+ constructor( v1 = new Vector3(), v2 = new Vector3() ) {
32764
+
32765
+ super();
32766
+
32767
+ this.isLineCurve3 = true;
32768
+
32769
+ this.type = 'LineCurve3';
32770
+
32771
+ this.v1 = v1;
32772
+ this.v2 = v2;
32773
+
32774
+ }
32775
+
32776
+ getPoint( t, optionalTarget = new Vector3() ) {
32777
+
32778
+ const point = optionalTarget;
32779
+
32780
+ if ( t === 1 ) {
32781
+
32782
+ point.copy( this.v2 );
32783
+
32784
+ } else {
32785
+
32786
+ point.copy( this.v2 ).sub( this.v1 );
32787
+ point.multiplyScalar( t ).add( this.v1 );
32788
+
32789
+ }
32790
+
32791
+ return point;
32792
+
32793
+ }
32794
+
32795
+ // Line curve is linear, so we can overwrite default getPointAt
32796
+ getPointAt( u, optionalTarget ) {
32797
+
32798
+ return this.getPoint( u, optionalTarget );
32799
+
32800
+ }
32801
+
32802
+ getTangent( t, optionalTarget = new Vector3() ) {
32262
32803
 
32263
32804
  return optionalTarget.subVectors( this.v2, this.v1 ).normalize();
32264
32805
 
@@ -32305,90 +32846,6 @@
32305
32846
 
32306
32847
  }
32307
32848
 
32308
- class LineCurve3 extends Curve {
32309
-
32310
- constructor( v1 = new Vector3(), v2 = new Vector3() ) {
32311
-
32312
- super();
32313
-
32314
- this.isLineCurve3 = true;
32315
-
32316
- this.type = 'LineCurve3';
32317
-
32318
- this.v1 = v1;
32319
- this.v2 = v2;
32320
-
32321
- }
32322
- getPoint( t, optionalTarget = new Vector3() ) {
32323
-
32324
- const point = optionalTarget;
32325
-
32326
- if ( t === 1 ) {
32327
-
32328
- point.copy( this.v2 );
32329
-
32330
- } else {
32331
-
32332
- point.copy( this.v2 ).sub( this.v1 );
32333
- point.multiplyScalar( t ).add( this.v1 );
32334
-
32335
- }
32336
-
32337
- return point;
32338
-
32339
- }
32340
- // Line curve is linear, so we can overwrite default getPointAt
32341
- getPointAt( u, optionalTarget ) {
32342
-
32343
- return this.getPoint( u, optionalTarget );
32344
-
32345
- }
32346
-
32347
- getTangent( t, optionalTarget = new Vector3() ) {
32348
-
32349
- return optionalTarget.subVectors( this.v2, this.v1 ).normalize();
32350
-
32351
- }
32352
-
32353
- getTangentAt( u, optionalTarget ) {
32354
-
32355
- return this.getTangent( u, optionalTarget );
32356
-
32357
- }
32358
-
32359
- copy( source ) {
32360
-
32361
- super.copy( source );
32362
-
32363
- this.v1.copy( source.v1 );
32364
- this.v2.copy( source.v2 );
32365
-
32366
- return this;
32367
-
32368
- }
32369
- toJSON() {
32370
-
32371
- const data = super.toJSON();
32372
-
32373
- data.v1 = this.v1.toArray();
32374
- data.v2 = this.v2.toArray();
32375
-
32376
- return data;
32377
-
32378
- }
32379
- fromJSON( json ) {
32380
-
32381
- super.fromJSON( json );
32382
-
32383
- this.v1.fromArray( json.v1 );
32384
- this.v2.fromArray( json.v2 );
32385
-
32386
- return this;
32387
-
32388
- }
32389
-
32390
- }
32391
-
32392
32849
  class QuadraticBezierCurve extends Curve {
32393
32850
 
32394
32851
  constructor( v0 = new Vector2(), v1 = new Vector2(), v2 = new Vector2() ) {
@@ -37511,163 +37968,70 @@
37511
37968
 
37512
37969
  }
37513
37970
 
37514
- /** Detect free variable `global` from Node.js. */
37515
- var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
37516
-
37517
- var freeGlobal$1 = freeGlobal;
37518
-
37519
- /** Detect free variable `self`. */
37520
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
37521
-
37522
- /** Used as a reference to the global object. */
37523
- var root = freeGlobal$1 || freeSelf || Function('return this')();
37524
-
37525
- var root$1 = root;
37526
-
37527
- /** Built-in value references. */
37528
- var Symbol$1 = root$1.Symbol;
37529
-
37530
- var Symbol$2 = Symbol$1;
37531
-
37532
- /** Used for built-in method references. */
37533
- var objectProto$1 = Object.prototype;
37534
-
37535
- /** Used to check objects for own properties. */
37536
- var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
37537
-
37538
- /**
37539
- * Used to resolve the
37540
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
37541
- * of values.
37542
- */
37543
- var nativeObjectToString$1 = objectProto$1.toString;
37544
-
37545
- /** Built-in value references. */
37546
- var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : undefined;
37547
-
37548
37971
  /**
37549
- * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
37550
- *
37551
- * @private
37552
- * @param {*} value The value to query.
37553
- * @returns {string} Returns the raw `toStringTag`.
37554
- */
37555
- function getRawTag(value) {
37556
- var isOwn = hasOwnProperty$1.call(value, symToStringTag$1),
37557
- tag = value[symToStringTag$1];
37558
-
37559
- try {
37560
- value[symToStringTag$1] = undefined;
37561
- var unmasked = true;
37562
- } catch (e) {}
37563
-
37564
- var result = nativeObjectToString$1.call(value);
37565
- if (unmasked) {
37566
- if (isOwn) {
37567
- value[symToStringTag$1] = tag;
37568
- } else {
37569
- delete value[symToStringTag$1];
37570
- }
37571
- }
37572
- return result;
37573
- }
37574
-
37575
- /** Used for built-in method references. */
37576
- var objectProto = Object.prototype;
37577
-
37578
- /**
37579
- * Used to resolve the
37580
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
37581
- * of values.
37582
- */
37583
- var nativeObjectToString = objectProto.toString;
37584
-
37585
- /**
37586
- * Converts `value` to a string using `Object.prototype.toString`.
37587
- *
37588
- * @private
37589
- * @param {*} value The value to convert.
37590
- * @returns {string} Returns the converted string.
37591
- */
37592
- function objectToString(value) {
37593
- return nativeObjectToString.call(value);
37594
- }
37595
-
37596
- /** `Object#toString` result references. */
37597
- var nullTag = '[object Null]',
37598
- undefinedTag = '[object Undefined]';
37599
-
37600
- /** Built-in value references. */
37601
- var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : undefined;
37602
-
37603
- /**
37604
- * The base implementation of `getTag` without fallbacks for buggy environments.
37605
- *
37606
- * @private
37607
- * @param {*} value The value to query.
37608
- * @returns {string} Returns the `toStringTag`.
37609
- */
37610
- function baseGetTag(value) {
37611
- if (value == null) {
37612
- return value === undefined ? undefinedTag : nullTag;
37613
- }
37614
- return (symToStringTag && symToStringTag in Object(value))
37615
- ? getRawTag(value)
37616
- : objectToString(value);
37617
- }
37618
-
37619
- /**
37620
- * Checks if `value` is object-like. A value is object-like if it's not `null`
37621
- * and has a `typeof` result of "object".
37972
+ * Checks if `value` is the
37973
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
37974
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
37622
37975
  *
37623
37976
  * @static
37624
37977
  * @memberOf _
37625
- * @since 4.0.0
37978
+ * @since 0.1.0
37626
37979
  * @category Lang
37627
37980
  * @param {*} value The value to check.
37628
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
37981
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
37629
37982
  * @example
37630
37983
  *
37631
- * _.isObjectLike({});
37984
+ * _.isObject({});
37632
37985
  * // => true
37633
37986
  *
37634
- * _.isObjectLike([1, 2, 3]);
37987
+ * _.isObject([1, 2, 3]);
37635
37988
  * // => true
37636
37989
  *
37637
- * _.isObjectLike(_.noop);
37638
- * // => false
37990
+ * _.isObject(_.noop);
37991
+ * // => true
37639
37992
  *
37640
- * _.isObjectLike(null);
37993
+ * _.isObject(null);
37641
37994
  * // => false
37642
37995
  */
37643
- function isObjectLike(value) {
37644
- return value != null && typeof value == 'object';
37996
+ function isObject(value) {
37997
+ var type = typeof value;
37998
+ return value != null && (type == 'object' || type == 'function');
37645
37999
  }
37646
38000
 
37647
- /** `Object#toString` result references. */
37648
- var symbolTag = '[object Symbol]';
38001
+ /** Detect free variable `global` from Node.js. */
38002
+ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
38003
+
38004
+ var freeGlobal$1 = freeGlobal;
38005
+
38006
+ /** Detect free variable `self`. */
38007
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
38008
+
38009
+ /** Used as a reference to the global object. */
38010
+ var root = freeGlobal$1 || freeSelf || Function('return this')();
38011
+
38012
+ var root$1 = root;
37649
38013
 
37650
38014
  /**
37651
- * Checks if `value` is classified as a `Symbol` primitive or object.
38015
+ * Gets the timestamp of the number of milliseconds that have elapsed since
38016
+ * the Unix epoch (1 January 1970 00:00:00 UTC).
37652
38017
  *
37653
38018
  * @static
37654
38019
  * @memberOf _
37655
- * @since 4.0.0
37656
- * @category Lang
37657
- * @param {*} value The value to check.
37658
- * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
38020
+ * @since 2.4.0
38021
+ * @category Date
38022
+ * @returns {number} Returns the timestamp.
37659
38023
  * @example
37660
38024
  *
37661
- * _.isSymbol(Symbol.iterator);
37662
- * // => true
37663
- *
37664
- * _.isSymbol('abc');
37665
- * // => false
38025
+ * _.defer(function(stamp) {
38026
+ * console.log(_.now() - stamp);
38027
+ * }, _.now());
38028
+ * // => Logs the number of milliseconds it took for the deferred invocation.
37666
38029
  */
37667
- function isSymbol(value) {
37668
- return typeof value == 'symbol' ||
37669
- (isObjectLike(value) && baseGetTag(value) == symbolTag);
37670
- }
38030
+ var now$1 = function() {
38031
+ return root$1.Date.now();
38032
+ };
38033
+
38034
+ var now$2 = now$1;
37671
38035
 
37672
38036
  /** Used to match a single whitespace character. */
37673
38037
  var reWhitespace = /\s/;
@@ -37703,34 +38067,149 @@
37703
38067
  : string;
37704
38068
  }
37705
38069
 
38070
+ /** Built-in value references. */
38071
+ var Symbol$1 = root$1.Symbol;
38072
+
38073
+ var Symbol$2 = Symbol$1;
38074
+
38075
+ /** Used for built-in method references. */
38076
+ var objectProto$1 = Object.prototype;
38077
+
38078
+ /** Used to check objects for own properties. */
38079
+ var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
38080
+
37706
38081
  /**
37707
- * Checks if `value` is the
37708
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
37709
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
38082
+ * Used to resolve the
38083
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
38084
+ * of values.
38085
+ */
38086
+ var nativeObjectToString$1 = objectProto$1.toString;
38087
+
38088
+ /** Built-in value references. */
38089
+ var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : undefined;
38090
+
38091
+ /**
38092
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
38093
+ *
38094
+ * @private
38095
+ * @param {*} value The value to query.
38096
+ * @returns {string} Returns the raw `toStringTag`.
38097
+ */
38098
+ function getRawTag(value) {
38099
+ var isOwn = hasOwnProperty$1.call(value, symToStringTag$1),
38100
+ tag = value[symToStringTag$1];
38101
+
38102
+ try {
38103
+ value[symToStringTag$1] = undefined;
38104
+ var unmasked = true;
38105
+ } catch (e) {}
38106
+
38107
+ var result = nativeObjectToString$1.call(value);
38108
+ if (unmasked) {
38109
+ if (isOwn) {
38110
+ value[symToStringTag$1] = tag;
38111
+ } else {
38112
+ delete value[symToStringTag$1];
38113
+ }
38114
+ }
38115
+ return result;
38116
+ }
38117
+
38118
+ /** Used for built-in method references. */
38119
+ var objectProto = Object.prototype;
38120
+
38121
+ /**
38122
+ * Used to resolve the
38123
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
38124
+ * of values.
38125
+ */
38126
+ var nativeObjectToString = objectProto.toString;
38127
+
38128
+ /**
38129
+ * Converts `value` to a string using `Object.prototype.toString`.
38130
+ *
38131
+ * @private
38132
+ * @param {*} value The value to convert.
38133
+ * @returns {string} Returns the converted string.
38134
+ */
38135
+ function objectToString(value) {
38136
+ return nativeObjectToString.call(value);
38137
+ }
38138
+
38139
+ /** `Object#toString` result references. */
38140
+ var nullTag = '[object Null]',
38141
+ undefinedTag = '[object Undefined]';
38142
+
38143
+ /** Built-in value references. */
38144
+ var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : undefined;
38145
+
38146
+ /**
38147
+ * The base implementation of `getTag` without fallbacks for buggy environments.
38148
+ *
38149
+ * @private
38150
+ * @param {*} value The value to query.
38151
+ * @returns {string} Returns the `toStringTag`.
38152
+ */
38153
+ function baseGetTag(value) {
38154
+ if (value == null) {
38155
+ return value === undefined ? undefinedTag : nullTag;
38156
+ }
38157
+ return (symToStringTag && symToStringTag in Object(value))
38158
+ ? getRawTag(value)
38159
+ : objectToString(value);
38160
+ }
38161
+
38162
+ /**
38163
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
38164
+ * and has a `typeof` result of "object".
37710
38165
  *
37711
38166
  * @static
37712
38167
  * @memberOf _
37713
- * @since 0.1.0
38168
+ * @since 4.0.0
37714
38169
  * @category Lang
37715
38170
  * @param {*} value The value to check.
37716
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
38171
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
37717
38172
  * @example
37718
38173
  *
37719
- * _.isObject({});
38174
+ * _.isObjectLike({});
37720
38175
  * // => true
37721
38176
  *
37722
- * _.isObject([1, 2, 3]);
38177
+ * _.isObjectLike([1, 2, 3]);
37723
38178
  * // => true
37724
38179
  *
37725
- * _.isObject(_.noop);
38180
+ * _.isObjectLike(_.noop);
38181
+ * // => false
38182
+ *
38183
+ * _.isObjectLike(null);
38184
+ * // => false
38185
+ */
38186
+ function isObjectLike(value) {
38187
+ return value != null && typeof value == 'object';
38188
+ }
38189
+
38190
+ /** `Object#toString` result references. */
38191
+ var symbolTag = '[object Symbol]';
38192
+
38193
+ /**
38194
+ * Checks if `value` is classified as a `Symbol` primitive or object.
38195
+ *
38196
+ * @static
38197
+ * @memberOf _
38198
+ * @since 4.0.0
38199
+ * @category Lang
38200
+ * @param {*} value The value to check.
38201
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
38202
+ * @example
38203
+ *
38204
+ * _.isSymbol(Symbol.iterator);
37726
38205
  * // => true
37727
38206
  *
37728
- * _.isObject(null);
38207
+ * _.isSymbol('abc');
37729
38208
  * // => false
37730
38209
  */
37731
- function isObject(value) {
37732
- var type = typeof value;
37733
- return value != null && (type == 'object' || type == 'function');
38210
+ function isSymbol(value) {
38211
+ return typeof value == 'symbol' ||
38212
+ (isObjectLike(value) && baseGetTag(value) == symbolTag);
37734
38213
  }
37735
38214
 
37736
38215
  /** Used as references for various `Number` constants. */
@@ -37792,28 +38271,6 @@
37792
38271
  : (reIsBadHex.test(value) ? NAN : +value);
37793
38272
  }
37794
38273
 
37795
- /**
37796
- * Gets the timestamp of the number of milliseconds that have elapsed since
37797
- * the Unix epoch (1 January 1970 00:00:00 UTC).
37798
- *
37799
- * @static
37800
- * @memberOf _
37801
- * @since 2.4.0
37802
- * @category Date
37803
- * @returns {number} Returns the timestamp.
37804
- * @example
37805
- *
37806
- * _.defer(function(stamp) {
37807
- * console.log(_.now() - stamp);
37808
- * }, _.now());
37809
- * // => Logs the number of milliseconds it took for the deferred invocation.
37810
- */
37811
- var now$1 = function() {
37812
- return root$1.Date.now();
37813
- };
37814
-
37815
- var now$2 = now$1;
37816
-
37817
38274
  /** Error message constants. */
37818
38275
  var FUNC_ERROR_TEXT = 'Expected a function';
37819
38276
 
@@ -38000,31 +38457,31 @@
38000
38457
  return debounced;
38001
38458
  }
38002
38459
 
38003
- function _iterableToArrayLimit$6(arr, i) {
38004
- var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
38005
- if (null != _i) {
38006
- var _s,
38007
- _e,
38008
- _x,
38009
- _r,
38010
- _arr = [],
38011
- _n = !0,
38012
- _d = !1;
38460
+ function _iterableToArrayLimit$6(r, l) {
38461
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
38462
+ if (null != t) {
38463
+ var e,
38464
+ n,
38465
+ i,
38466
+ u,
38467
+ a = [],
38468
+ f = !0,
38469
+ o = !1;
38013
38470
  try {
38014
- if (_x = (_i = _i.call(arr)).next, 0 === i) {
38015
- if (Object(_i) !== _i) return;
38016
- _n = !1;
38017
- } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
38018
- } catch (err) {
38019
- _d = !0, _e = err;
38471
+ if (i = (t = t.call(r)).next, 0 === l) {
38472
+ if (Object(t) !== t) return;
38473
+ f = !1;
38474
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
38475
+ } catch (r) {
38476
+ o = !0, n = r;
38020
38477
  } finally {
38021
38478
  try {
38022
- if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
38479
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
38023
38480
  } finally {
38024
- if (_d) throw _e;
38481
+ if (o) throw n;
38025
38482
  }
38026
38483
  }
38027
- return _arr;
38484
+ return a;
38028
38485
  }
38029
38486
  }
38030
38487
  function _classCallCheck$3(instance, Constructor) {
@@ -70535,6 +70992,9 @@
70535
70992
  // "target" sets the location of focus, where the object orbits around
70536
70993
  this.target = new Vector3();
70537
70994
 
70995
+ // Sets the 3D cursor (similar to Blender), from which the maxTargetRadius takes effect
70996
+ this.cursor = new Vector3();
70997
+
70538
70998
  // How far you can dolly in and out ( PerspectiveCamera only )
70539
70999
  this.minDistance = 0;
70540
71000
  this.maxDistance = Infinity;
@@ -70543,6 +71003,10 @@
70543
71003
  this.minZoom = 0;
70544
71004
  this.maxZoom = Infinity;
70545
71005
 
71006
+ // Limit camera target within a spherical area around the cursor
71007
+ this.minTargetRadius = 0;
71008
+ this.maxTargetRadius = Infinity;
71009
+
70546
71010
  // How far you can orbit vertically, upper and lower limits.
70547
71011
  // Range is 0 to Math.PI radians.
70548
71012
  this.minPolarAngle = 0; // radians
@@ -70743,6 +71207,11 @@
70743
71207
 
70744
71208
  }
70745
71209
 
71210
+ // Limit the target distance from the cursor to create a sphere around the center of interest
71211
+ scope.target.sub( scope.cursor );
71212
+ scope.target.clampLength( scope.minTargetRadius, scope.maxTargetRadius );
71213
+ scope.target.add( scope.cursor );
71214
+
70746
71215
  // adjust the camera position based on zoom only if we're not zooming to the cursor or if it's an ortho camera
70747
71216
  // we adjust zoom later in these cases
70748
71217
  if ( scope.zoomToCursor && performCursorZoom || scope.object.isOrthographicCamera ) {
@@ -70755,7 +71224,6 @@
70755
71224
 
70756
71225
  }
70757
71226
 
70758
-
70759
71227
  offset.setFromSpherical( spherical );
70760
71228
 
70761
71229
  // rotate offset back to "camera-up-vector-is-up" space
@@ -70881,8 +71349,6 @@
70881
71349
  lastQuaternion.copy( scope.object.quaternion );
70882
71350
  lastTargetPosition.copy( scope.target );
70883
71351
 
70884
- zoomChanged = false;
70885
-
70886
71352
  return true;
70887
71353
 
70888
71354
  }
@@ -72069,6 +72535,29 @@
72069
72535
 
72070
72536
  };
72071
72537
 
72538
+ this.pointercancel = function () {
72539
+
72540
+ if ( this.enabled === false ) return;
72541
+
72542
+ if ( this.dragToLook ) {
72543
+
72544
+ this.status = 0;
72545
+
72546
+ this.moveState.yawLeft = this.moveState.pitchDown = 0;
72547
+
72548
+ } else {
72549
+
72550
+ this.moveState.forward = 0;
72551
+ this.moveState.back = 0;
72552
+
72553
+ this.updateMovementVector();
72554
+
72555
+ }
72556
+
72557
+ this.updateRotationVector();
72558
+
72559
+ };
72560
+
72072
72561
  this.contextMenu = function ( event ) {
72073
72562
 
72074
72563
  if ( this.enabled === false ) return;
@@ -72152,6 +72641,7 @@
72152
72641
  this.domElement.removeEventListener( 'pointerdown', _pointerdown );
72153
72642
  this.domElement.removeEventListener( 'pointermove', _pointermove );
72154
72643
  this.domElement.removeEventListener( 'pointerup', _pointerup );
72644
+ this.domElement.removeEventListener( 'pointercancel', _pointercancel );
72155
72645
 
72156
72646
  window.removeEventListener( 'keydown', _keydown );
72157
72647
  window.removeEventListener( 'keyup', _keyup );
@@ -72162,6 +72652,7 @@
72162
72652
  const _pointermove = this.pointermove.bind( this );
72163
72653
  const _pointerdown = this.pointerdown.bind( this );
72164
72654
  const _pointerup = this.pointerup.bind( this );
72655
+ const _pointercancel = this.pointercancel.bind( this );
72165
72656
  const _keydown = this.keydown.bind( this );
72166
72657
  const _keyup = this.keyup.bind( this );
72167
72658
 
@@ -72169,6 +72660,7 @@
72169
72660
  this.domElement.addEventListener( 'pointerdown', _pointerdown );
72170
72661
  this.domElement.addEventListener( 'pointermove', _pointermove );
72171
72662
  this.domElement.addEventListener( 'pointerup', _pointerup );
72663
+ this.domElement.addEventListener( 'pointercancel', _pointercancel );
72172
72664
 
72173
72665
  window.addEventListener( 'keydown', _keydown );
72174
72666
  window.addEventListener( 'keyup', _keyup );
@@ -72262,9 +72754,20 @@
72262
72754
 
72263
72755
  // https://github.com/mrdoob/three.js/pull/21358
72264
72756
 
72265
- const _geometry = new BufferGeometry();
72266
- _geometry.setAttribute( 'position', new Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );
72267
- _geometry.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );
72757
+ class FullscreenTriangleGeometry extends BufferGeometry {
72758
+
72759
+ constructor() {
72760
+
72761
+ super();
72762
+
72763
+ this.setAttribute( 'position', new Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );
72764
+ this.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );
72765
+
72766
+ }
72767
+
72768
+ }
72769
+
72770
+ const _geometry = new FullscreenTriangleGeometry();
72268
72771
 
72269
72772
  class FullScreenQuad {
72270
72773
 
@@ -73566,31 +74069,31 @@
73566
74069
  var css_248z$1 = ".scene-nav-info {\n bottom: 5px;\n width: 100%;\n text-align: center;\n color: slategrey;\n opacity: 0.7;\n font-size: 10px;\n}\n\n.scene-tooltip {\n top: 0;\n color: lavender;\n font-size: 15px;\n}\n\n.scene-nav-info, .scene-tooltip {\n position: absolute;\n font-family: sans-serif;\n pointer-events: none;\n user-select: none;\n}\n\n.scene-container canvas:focus {\n outline: none;\n}";
73567
74070
  styleInject$1(css_248z$1);
73568
74071
 
73569
- function _iterableToArrayLimit(arr, i) {
73570
- var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
73571
- if (null != _i) {
73572
- var _s,
73573
- _e,
73574
- _x,
73575
- _r,
73576
- _arr = [],
73577
- _n = !0,
73578
- _d = !1;
74072
+ function _iterableToArrayLimit(r, l) {
74073
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
74074
+ if (null != t) {
74075
+ var e,
74076
+ n,
74077
+ i,
74078
+ u,
74079
+ a = [],
74080
+ f = !0,
74081
+ o = !1;
73579
74082
  try {
73580
- if (_x = (_i = _i.call(arr)).next, 0 === i) {
73581
- if (Object(_i) !== _i) return;
73582
- _n = !1;
73583
- } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
73584
- } catch (err) {
73585
- _d = !0, _e = err;
74083
+ if (i = (t = t.call(r)).next, 0 === l) {
74084
+ if (Object(t) !== t) return;
74085
+ f = !1;
74086
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
74087
+ } catch (r) {
74088
+ o = !0, n = r;
73586
74089
  } finally {
73587
74090
  try {
73588
- if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
74091
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
73589
74092
  } finally {
73590
- if (_d) throw _e;
74093
+ if (o) throw n;
73591
74094
  }
73592
74095
  }
73593
- return _arr;
74096
+ return a;
73594
74097
  }
73595
74098
  }
73596
74099
  function _defineProperty$1(obj, key, value) {
@@ -73706,6 +74209,9 @@
73706
74209
  objects: {
73707
74210
  "default": []
73708
74211
  },
74212
+ lights: {
74213
+ "default": []
74214
+ },
73709
74215
  enablePointerInteraction: {
73710
74216
  "default": true,
73711
74217
  onChange: function onChange(_, state) {
@@ -74166,6 +74672,15 @@
74166
74672
  }
74167
74673
  }
74168
74674
  changedProps.hasOwnProperty('showNavInfo') && (state.navInfo.style.display = state.showNavInfo ? null : 'none');
74675
+ if (changedProps.hasOwnProperty('lights')) {
74676
+ (changedProps.lights || []).forEach(function (light) {
74677
+ return state.scene.remove(light);
74678
+ }); // Clear the place
74679
+ state.lights.forEach(function (light) {
74680
+ return state.scene.add(light);
74681
+ }); // Add to scene
74682
+ }
74683
+
74169
74684
  if (changedProps.hasOwnProperty('objects')) {
74170
74685
  (changedProps.objects || []).forEach(function (obj) {
74171
74686
  return state.scene.remove(obj);
@@ -74368,7 +74883,7 @@
74368
74883
  var linkedRenderObjsProps = Object.assign.apply(Object, _toConsumableArray(['width', 'height', 'backgroundColor', 'backgroundImageUrl', 'enablePointerInteraction'].map(function (p) {
74369
74884
  return _defineProperty({}, p, bindRenderObjs.linkProp(p));
74370
74885
  })));
74371
- var linkedRenderObjsMethods = Object.assign.apply(Object, _toConsumableArray(['postProcessingComposer'].map(function (p) {
74886
+ var linkedRenderObjsMethods = Object.assign.apply(Object, _toConsumableArray(['lights', 'postProcessingComposer'].map(function (p) {
74372
74887
  return _defineProperty({}, p, bindRenderObjs.linkMethod(p));
74373
74888
  })));
74374
74889
 
@@ -74672,7 +75187,8 @@
74672
75187
  rendererConfig: rendererConfig,
74673
75188
  waitForLoadComplete: waitForGlobeReady,
74674
75189
  extraRenderers: [new THREE.CSS2DRenderer()] // Used in HTML elements layer
74675
- }).skyRadius(globe.getGlobeRadius() * 500).showNavInfo(false)
75190
+ }).skyRadius(globe.getGlobeRadius() * 500).showNavInfo(false).objects([globe]) // Populate scene
75191
+ .lights([new THREE.AmbientLight(0xcccccc, Math.PI), new THREE.DirectionalLight(0xffffff, 0.6 * Math.PI)])
74676
75192
  };
74677
75193
  },
74678
75194
  init: function init(domNode, state) {
@@ -74763,9 +75279,7 @@
74763
75279
  }
74764
75280
  };
74765
75281
  state.renderObjs.renderer().useLegacyLights = false; // force behavior of three < 155
74766
- state.renderObjs.objects([
74767
- // Populate scene
74768
- new THREE.AmbientLight(0xcccccc, Math.PI), new THREE.DirectionalLight(0xffffff, 0.6 * Math.PI), state.globe]).hoverOrderComparator(function (a, b) {
75282
+ state.renderObjs.hoverOrderComparator(function (a, b) {
74769
75283
  var aObj = getGlobeObj(a);
74770
75284
  var bObj = getGlobeObj(b);
74771
75285
 
@@ -76151,7 +76665,7 @@
76151
76665
  var Globe = index$3(globe, {
76152
76666
  methodNames: [
76153
76667
  // bind methods
76154
- 'pauseAnimation', 'resumeAnimation', 'pointOfView', 'scene', 'camera', 'renderer', 'postProcessingComposer', 'controls', 'getGlobeRadius', 'getCoords', 'getScreenCoords', 'toGeoCoords', 'toGlobeCoords'],
76668
+ 'pauseAnimation', 'resumeAnimation', 'pointOfView', 'lights', 'scene', 'camera', 'renderer', 'postProcessingComposer', 'controls', 'getGlobeRadius', 'getCoords', 'getScreenCoords', 'toGeoCoords', 'toGlobeCoords'],
76155
76669
  initPropNames: ['animateIn', 'waitForGlobeReady', 'rendererConfig']
76156
76670
  });
76157
76671
  Globe.displayName = 'Globe';