@iwer/devui 0.2.0 → 0.2.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.
@@ -5828,7 +5828,7 @@ const HeaderUI = ({ xrDevice, inputLayer, keyMapOpen, setKeyMapOpen, fovSettingO
5828
5828
  * Copyright 2010-2024 Three.js Authors
5829
5829
  * SPDX-License-Identifier: MIT
5830
5830
  */
5831
- const REVISION = '169';
5831
+ const REVISION = '168';
5832
5832
  const CullFaceNone = 0;
5833
5833
  const CullFaceBack = 1;
5834
5834
  const CullFaceFront = 2;
@@ -7133,38 +7133,6 @@ function probeAsync( gl, sync, interval ) {
7133
7133
 
7134
7134
  }
7135
7135
 
7136
- function toNormalizedProjectionMatrix( projectionMatrix ) {
7137
-
7138
- const m = projectionMatrix.elements;
7139
-
7140
- // Convert [-1, 1] to [0, 1] projection matrix
7141
- m[ 2 ] = 0.5 * m[ 2 ] + 0.5 * m[ 3 ];
7142
- m[ 6 ] = 0.5 * m[ 6 ] + 0.5 * m[ 7 ];
7143
- m[ 10 ] = 0.5 * m[ 10 ] + 0.5 * m[ 11 ];
7144
- m[ 14 ] = 0.5 * m[ 14 ] + 0.5 * m[ 15 ];
7145
-
7146
- }
7147
-
7148
- function toReversedProjectionMatrix( projectionMatrix ) {
7149
-
7150
- const m = projectionMatrix.elements;
7151
- const isPerspectiveMatrix = m[ 11 ] === - 1;
7152
-
7153
- // Reverse [0, 1] projection matrix
7154
- if ( isPerspectiveMatrix ) {
7155
-
7156
- m[ 10 ] = - m[ 10 ] - 1;
7157
- m[ 14 ] = - m[ 14 ];
7158
-
7159
- } else {
7160
-
7161
- m[ 10 ] = - m[ 10 ];
7162
- m[ 14 ] = - m[ 14 ] + 1;
7163
-
7164
- }
7165
-
7166
- }
7167
-
7168
7136
  /**
7169
7137
  * Matrices converting P3 <-> Rec. 709 primaries, without gamut mapping
7170
7138
  * or clipping. Based on W3C specifications for sRGB and Display P3,
@@ -13724,10 +13692,6 @@ const _vap = /*@__PURE__*/ new Vector3();
13724
13692
  const _vbp = /*@__PURE__*/ new Vector3();
13725
13693
  const _vcp = /*@__PURE__*/ new Vector3();
13726
13694
 
13727
- const _v40 = /*@__PURE__*/ new Vector4();
13728
- const _v41 = /*@__PURE__*/ new Vector4();
13729
- const _v42 = /*@__PURE__*/ new Vector4();
13730
-
13731
13695
  class Triangle {
13732
13696
 
13733
13697
  constructor( a = new Vector3(), b = new Vector3(), c = new Vector3() ) {
@@ -13822,25 +13786,6 @@ class Triangle {
13822
13786
 
13823
13787
  }
13824
13788
 
13825
- static getInterpolatedAttribute( attr, i1, i2, i3, barycoord, target ) {
13826
-
13827
- _v40.setScalar( 0 );
13828
- _v41.setScalar( 0 );
13829
- _v42.setScalar( 0 );
13830
-
13831
- _v40.fromBufferAttribute( attr, i1 );
13832
- _v41.fromBufferAttribute( attr, i2 );
13833
- _v42.fromBufferAttribute( attr, i3 );
13834
-
13835
- target.setScalar( 0 );
13836
- target.addScaledVector( _v40, barycoord.x );
13837
- target.addScaledVector( _v41, barycoord.y );
13838
- target.addScaledVector( _v42, barycoord.z );
13839
-
13840
- return target;
13841
-
13842
- }
13843
-
13844
13789
  static isFrontFacing( a, b, c, direction ) {
13845
13790
 
13846
13791
  _v0$2.subVectors( c, b );
@@ -15287,6 +15232,7 @@ class BufferAttribute {
15287
15232
  this.normalized = normalized;
15288
15233
 
15289
15234
  this.usage = StaticDrawUsage;
15235
+ this._updateRange = { offset: 0, count: - 1 };
15290
15236
  this.updateRanges = [];
15291
15237
  this.gpuType = FloatType;
15292
15238
 
@@ -15302,6 +15248,13 @@ class BufferAttribute {
15302
15248
 
15303
15249
  }
15304
15250
 
15251
+ get updateRange() {
15252
+
15253
+ warnOnce( 'THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead.' ); // @deprecated, r159
15254
+ return this._updateRange;
15255
+
15256
+ }
15257
+
15305
15258
  setUsage( value ) {
15306
15259
 
15307
15260
  this.usage = value;
@@ -16742,6 +16695,14 @@ const _vC$1 = /*@__PURE__*/ new Vector3();
16742
16695
  const _tempA = /*@__PURE__*/ new Vector3();
16743
16696
  const _morphA = /*@__PURE__*/ new Vector3();
16744
16697
 
16698
+ const _uvA$1 = /*@__PURE__*/ new Vector2();
16699
+ const _uvB$1 = /*@__PURE__*/ new Vector2();
16700
+ const _uvC$1 = /*@__PURE__*/ new Vector2();
16701
+
16702
+ const _normalA = /*@__PURE__*/ new Vector3();
16703
+ const _normalB = /*@__PURE__*/ new Vector3();
16704
+ const _normalC = /*@__PURE__*/ new Vector3();
16705
+
16745
16706
  const _intersectionPoint = /*@__PURE__*/ new Vector3();
16746
16707
  const _intersectionPointWorld = /*@__PURE__*/ new Vector3();
16747
16708
 
@@ -17084,24 +17045,33 @@ function checkGeometryIntersection( object, material, raycaster, ray, uv, uv1, n
17084
17045
 
17085
17046
  if ( intersection ) {
17086
17047
 
17087
- const barycoord = new Vector3();
17088
- Triangle.getBarycoord( _intersectionPoint, _vA$1, _vB$1, _vC$1, barycoord );
17089
-
17090
17048
  if ( uv ) {
17091
17049
 
17092
- intersection.uv = Triangle.getInterpolatedAttribute( uv, a, b, c, barycoord, new Vector2() );
17050
+ _uvA$1.fromBufferAttribute( uv, a );
17051
+ _uvB$1.fromBufferAttribute( uv, b );
17052
+ _uvC$1.fromBufferAttribute( uv, c );
17053
+
17054
+ intersection.uv = Triangle.getInterpolation( _intersectionPoint, _vA$1, _vB$1, _vC$1, _uvA$1, _uvB$1, _uvC$1, new Vector2() );
17093
17055
 
17094
17056
  }
17095
17057
 
17096
17058
  if ( uv1 ) {
17097
17059
 
17098
- intersection.uv1 = Triangle.getInterpolatedAttribute( uv1, a, b, c, barycoord, new Vector2() );
17060
+ _uvA$1.fromBufferAttribute( uv1, a );
17061
+ _uvB$1.fromBufferAttribute( uv1, b );
17062
+ _uvC$1.fromBufferAttribute( uv1, c );
17063
+
17064
+ intersection.uv1 = Triangle.getInterpolation( _intersectionPoint, _vA$1, _vB$1, _vC$1, _uvA$1, _uvB$1, _uvC$1, new Vector2() );
17099
17065
 
17100
17066
  }
17101
17067
 
17102
17068
  if ( normal ) {
17103
17069
 
17104
- intersection.normal = Triangle.getInterpolatedAttribute( normal, a, b, c, barycoord, new Vector3() );
17070
+ _normalA.fromBufferAttribute( normal, a );
17071
+ _normalB.fromBufferAttribute( normal, b );
17072
+ _normalC.fromBufferAttribute( normal, c );
17073
+
17074
+ intersection.normal = Triangle.getInterpolation( _intersectionPoint, _vA$1, _vB$1, _vC$1, _normalA, _normalB, _normalC, new Vector3() );
17105
17075
 
17106
17076
  if ( intersection.normal.dot( ray.direction ) > 0 ) {
17107
17077
 
@@ -17122,7 +17092,6 @@ function checkGeometryIntersection( object, material, raycaster, ray, uv, uv1, n
17122
17092
  Triangle.getNormal( _vA$1, _vB$1, _vC$1, face.normal );
17123
17093
 
17124
17094
  intersection.face = face;
17125
- intersection.barycoord = barycoord;
17126
17095
 
17127
17096
  }
17128
17097
 
@@ -18766,60 +18735,19 @@ function WebGLAttributes( gl ) {
18766
18735
  function updateBuffer( buffer, attribute, bufferType ) {
18767
18736
 
18768
18737
  const array = attribute.array;
18738
+ const updateRange = attribute._updateRange; // @deprecated, r159
18769
18739
  const updateRanges = attribute.updateRanges;
18770
18740
 
18771
18741
  gl.bindBuffer( bufferType, buffer );
18772
18742
 
18773
- if ( updateRanges.length === 0 ) {
18743
+ if ( updateRange.count === - 1 && updateRanges.length === 0 ) {
18774
18744
 
18775
18745
  // Not using update ranges
18776
18746
  gl.bufferSubData( bufferType, 0, array );
18777
18747
 
18778
- } else {
18779
-
18780
- // Before applying update ranges, we merge any adjacent / overlapping
18781
- // ranges to reduce load on `gl.bufferSubData`. Empirically, this has led
18782
- // to performance improvements for applications which make heavy use of
18783
- // update ranges. Likely due to GPU command overhead.
18784
- //
18785
- // Note that to reduce garbage collection between frames, we merge the
18786
- // update ranges in-place. This is safe because this method will clear the
18787
- // update ranges once updated.
18788
-
18789
- updateRanges.sort( ( a, b ) => a.start - b.start );
18790
-
18791
- // To merge the update ranges in-place, we work from left to right in the
18792
- // existing updateRanges array, merging ranges. This may result in a final
18793
- // array which is smaller than the original. This index tracks the last
18794
- // index representing a merged range, any data after this index can be
18795
- // trimmed once the merge algorithm is completed.
18796
- let mergeIndex = 0;
18797
-
18798
- for ( let i = 1; i < updateRanges.length; i ++ ) {
18799
-
18800
- const previousRange = updateRanges[ mergeIndex ];
18801
- const range = updateRanges[ i ];
18802
-
18803
- // We add one here to merge adjacent ranges. This is safe because ranges
18804
- // operate over positive integers.
18805
- if ( range.start <= previousRange.start + previousRange.count + 1 ) {
18806
-
18807
- previousRange.count = Math.max(
18808
- previousRange.count,
18809
- range.start + range.count - previousRange.start
18810
- );
18811
-
18812
- } else {
18813
-
18814
- ++ mergeIndex;
18815
- updateRanges[ mergeIndex ] = range;
18816
-
18817
- }
18818
-
18819
- }
18748
+ }
18820
18749
 
18821
- // Trim the array to only contain the merged ranges.
18822
- updateRanges.length = mergeIndex + 1;
18750
+ if ( updateRanges.length !== 0 ) {
18823
18751
 
18824
18752
  for ( let i = 0, l = updateRanges.length; i < l; i ++ ) {
18825
18753
 
@@ -18834,6 +18762,16 @@ function WebGLAttributes( gl ) {
18834
18762
 
18835
18763
  }
18836
18764
 
18765
+ // @deprecated, r159
18766
+ if ( updateRange.count !== - 1 ) {
18767
+
18768
+ gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,
18769
+ array, updateRange.offset, updateRange.count );
18770
+
18771
+ updateRange.count = - 1; // reset range
18772
+
18773
+ }
18774
+
18837
18775
  attribute.onUploadCallback();
18838
18776
 
18839
18777
  }
@@ -19291,7 +19229,7 @@ const vertex$2 = "#include <common>\n#include <batching_pars_vertex>\n#include <
19291
19229
 
19292
19230
  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}";
19293
19231
 
19294
- const vertex$1 = "uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}";
19232
+ const vertex$1 = "uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}";
19295
19233
 
19296
19234
  const fragment$1 = "uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}";
19297
19235
 
@@ -21057,14 +20995,6 @@ function WebGLCapabilities( gl, extensions, parameters, utils ) {
21057
20995
  }
21058
20996
 
21059
20997
  const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
21060
- const reverseDepthBuffer = parameters.reverseDepthBuffer === true && extensions.has( 'EXT_clip_control' );
21061
-
21062
- if ( reverseDepthBuffer === true ) {
21063
-
21064
- const ext = extensions.get( 'EXT_clip_control' );
21065
- ext.clipControlEXT( ext.LOWER_LEFT_EXT, ext.ZERO_TO_ONE_EXT );
21066
-
21067
- }
21068
20998
 
21069
20999
  const maxTextures = gl.getParameter( gl.MAX_TEXTURE_IMAGE_UNITS );
21070
21000
  const maxVertexTextures = gl.getParameter( gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS );
@@ -21092,7 +21022,6 @@ function WebGLCapabilities( gl, extensions, parameters, utils ) {
21092
21022
 
21093
21023
  precision: precision,
21094
21024
  logarithmicDepthBuffer: logarithmicDepthBuffer,
21095
- reverseDepthBuffer: reverseDepthBuffer,
21096
21025
 
21097
21026
  maxTextures: maxTextures,
21098
21027
  maxVertexTextures: maxVertexTextures,
@@ -25110,7 +25039,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
25110
25039
  parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
25111
25040
 
25112
25041
  parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
25113
- parameters.reverseDepthBuffer ? '#define USE_REVERSEDEPTHBUF' : '',
25114
25042
 
25115
25043
  'uniform mat4 modelMatrix;',
25116
25044
  'uniform mat4 modelViewMatrix;',
@@ -25276,7 +25204,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
25276
25204
  parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
25277
25205
 
25278
25206
  parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
25279
- parameters.reverseDepthBuffer ? '#define USE_REVERSEDEPTHBUF' : '',
25280
25207
 
25281
25208
  'uniform mat4 viewMatrix;',
25282
25209
  'uniform vec3 cameraPosition;',
@@ -25669,7 +25596,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
25669
25596
  const programs = [];
25670
25597
 
25671
25598
  const logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;
25672
- const reverseDepthBuffer = capabilities.reverseDepthBuffer;
25673
25599
  const SUPPORTS_VERTEX_TEXTURES = capabilities.vertexTextures;
25674
25600
 
25675
25601
  let precision = capabilities.precision;
@@ -25961,7 +25887,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
25961
25887
 
25962
25888
  sizeAttenuation: material.sizeAttenuation === true,
25963
25889
  logarithmicDepthBuffer: logarithmicDepthBuffer,
25964
- reverseDepthBuffer: reverseDepthBuffer,
25965
25890
 
25966
25891
  skinning: object.isSkinnedMesh === true,
25967
25892
 
@@ -26181,40 +26106,38 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
26181
26106
  _programLayers.enable( 2 );
26182
26107
  if ( parameters.logarithmicDepthBuffer )
26183
26108
  _programLayers.enable( 3 );
26184
- if ( parameters.reverseDepthBuffer )
26185
- _programLayers.enable( 4 );
26186
26109
  if ( parameters.skinning )
26187
- _programLayers.enable( 5 );
26110
+ _programLayers.enable( 4 );
26188
26111
  if ( parameters.morphTargets )
26189
- _programLayers.enable( 6 );
26112
+ _programLayers.enable( 5 );
26190
26113
  if ( parameters.morphNormals )
26191
- _programLayers.enable( 7 );
26114
+ _programLayers.enable( 6 );
26192
26115
  if ( parameters.morphColors )
26193
- _programLayers.enable( 8 );
26116
+ _programLayers.enable( 7 );
26194
26117
  if ( parameters.premultipliedAlpha )
26195
- _programLayers.enable( 9 );
26118
+ _programLayers.enable( 8 );
26196
26119
  if ( parameters.shadowMapEnabled )
26197
- _programLayers.enable( 10 );
26120
+ _programLayers.enable( 9 );
26198
26121
  if ( parameters.doubleSided )
26199
- _programLayers.enable( 11 );
26122
+ _programLayers.enable( 10 );
26200
26123
  if ( parameters.flipSided )
26201
- _programLayers.enable( 12 );
26124
+ _programLayers.enable( 11 );
26202
26125
  if ( parameters.useDepthPacking )
26203
- _programLayers.enable( 13 );
26126
+ _programLayers.enable( 12 );
26204
26127
  if ( parameters.dithering )
26205
- _programLayers.enable( 14 );
26128
+ _programLayers.enable( 13 );
26206
26129
  if ( parameters.transmission )
26207
- _programLayers.enable( 15 );
26130
+ _programLayers.enable( 14 );
26208
26131
  if ( parameters.sheen )
26209
- _programLayers.enable( 16 );
26132
+ _programLayers.enable( 15 );
26210
26133
  if ( parameters.opaque )
26211
- _programLayers.enable( 17 );
26134
+ _programLayers.enable( 16 );
26212
26135
  if ( parameters.pointsUvs )
26213
- _programLayers.enable( 18 );
26136
+ _programLayers.enable( 17 );
26214
26137
  if ( parameters.decodeVideoTexture )
26215
- _programLayers.enable( 19 );
26138
+ _programLayers.enable( 18 );
26216
26139
  if ( parameters.alphaToCoverage )
26217
- _programLayers.enable( 20 );
26140
+ _programLayers.enable( 19 );
26218
26141
 
26219
26142
  array.push( _programLayers.mask );
26220
26143
 
@@ -27772,18 +27695,6 @@ function WebGLShadowMap( renderer, objects, capabilities ) {
27772
27695
 
27773
27696
  }
27774
27697
 
27775
- const reversedFuncs = {
27776
- [ NeverDepth ]: AlwaysDepth,
27777
- [ LessDepth ]: GreaterDepth,
27778
- [ EqualDepth ]: NotEqualDepth,
27779
- [ LessEqualDepth ]: GreaterEqualDepth,
27780
-
27781
- [ AlwaysDepth ]: NeverDepth,
27782
- [ GreaterDepth ]: LessDepth,
27783
- [ NotEqualDepth ]: EqualDepth,
27784
- [ GreaterEqualDepth ]: LessEqualDepth,
27785
- };
27786
-
27787
27698
  function WebGLState( gl ) {
27788
27699
 
27789
27700
  function ColorBuffer() {
@@ -27848,7 +27759,6 @@ function WebGLState( gl ) {
27848
27759
  function DepthBuffer() {
27849
27760
 
27850
27761
  let locked = false;
27851
- let reversed = false;
27852
27762
 
27853
27763
  let currentDepthMask = null;
27854
27764
  let currentDepthFunc = null;
@@ -27856,12 +27766,6 @@ function WebGLState( gl ) {
27856
27766
 
27857
27767
  return {
27858
27768
 
27859
- setReversed: function ( value ) {
27860
-
27861
- reversed = value;
27862
-
27863
- },
27864
-
27865
27769
  setTest: function ( depthTest ) {
27866
27770
 
27867
27771
  if ( depthTest ) {
@@ -27889,8 +27793,6 @@ function WebGLState( gl ) {
27889
27793
 
27890
27794
  setFunc: function ( depthFunc ) {
27891
27795
 
27892
- if ( reversed ) depthFunc = reversedFuncs[ depthFunc ];
27893
-
27894
27796
  if ( currentDepthFunc !== depthFunc ) {
27895
27797
 
27896
27798
  switch ( depthFunc ) {
@@ -29361,28 +29263,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
29361
29263
 
29362
29264
  }
29363
29265
 
29364
- if ( glFormat === _gl.RGB_INTEGER ) {
29365
-
29366
- if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RGB8UI;
29367
- if ( glType === _gl.UNSIGNED_SHORT ) internalFormat = _gl.RGB16UI;
29368
- if ( glType === _gl.UNSIGNED_INT ) internalFormat = _gl.RGB32UI;
29369
- if ( glType === _gl.BYTE ) internalFormat = _gl.RGB8I;
29370
- if ( glType === _gl.SHORT ) internalFormat = _gl.RGB16I;
29371
- if ( glType === _gl.INT ) internalFormat = _gl.RGB32I;
29372
-
29373
- }
29374
-
29375
- if ( glFormat === _gl.RGBA_INTEGER ) {
29376
-
29377
- if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RGBA8UI;
29378
- if ( glType === _gl.UNSIGNED_SHORT ) internalFormat = _gl.RGBA16UI;
29379
- if ( glType === _gl.UNSIGNED_INT ) internalFormat = _gl.RGBA32UI;
29380
- if ( glType === _gl.BYTE ) internalFormat = _gl.RGBA8I;
29381
- if ( glType === _gl.SHORT ) internalFormat = _gl.RGBA16I;
29382
- if ( glType === _gl.INT ) internalFormat = _gl.RGBA32I;
29383
-
29384
- }
29385
-
29386
29266
  if ( glFormat === _gl.RGB ) {
29387
29267
 
29388
29268
  if ( glType === _gl.UNSIGNED_INT_5_9_9_9_REV ) internalFormat = _gl.RGB9_E5;
@@ -33976,7 +33856,6 @@ class WebGLRenderer {
33976
33856
 
33977
33857
  // camera matrices cache
33978
33858
 
33979
- const _currentProjectionMatrix = new Matrix4();
33980
33859
  const _projScreenMatrix = new Matrix4();
33981
33860
 
33982
33861
  const _vector3 = new Vector3();
@@ -34072,8 +33951,6 @@ class WebGLRenderer {
34072
33951
 
34073
33952
  state = new WebGLState( _gl );
34074
33953
 
34075
- if ( capabilities.reverseDepthBuffer ) state.buffers.depth.setReversed( true );
34076
-
34077
33954
  info = new WebGLInfo( _gl );
34078
33955
  properties = new WebGLProperties();
34079
33956
  textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );
@@ -34373,13 +34250,7 @@ class WebGLRenderer {
34373
34250
 
34374
34251
  }
34375
34252
 
34376
- if ( depth ) {
34377
-
34378
- bits |= _gl.DEPTH_BUFFER_BIT;
34379
- _gl.clearDepth( this.capabilities.reverseDepthBuffer ? 0 : 1 );
34380
-
34381
- }
34382
-
34253
+ if ( depth ) bits |= _gl.DEPTH_BUFFER_BIT;
34383
34254
  if ( stencil ) {
34384
34255
 
34385
34256
  bits |= _gl.STENCIL_BUFFER_BIT;
@@ -34768,12 +34639,6 @@ class WebGLRenderer {
34768
34639
 
34769
34640
  scene.traverse( function ( object ) {
34770
34641
 
34771
- if ( ! ( object.isMesh || object.isPoints || object.isLine || object.isSprite ) ) {
34772
-
34773
- return;
34774
-
34775
- }
34776
-
34777
34642
  const material = object.material;
34778
34643
 
34779
34644
  if ( material ) {
@@ -35760,21 +35625,7 @@ class WebGLRenderer {
35760
35625
 
35761
35626
  // common camera uniforms
35762
35627
 
35763
- if ( capabilities.reverseDepthBuffer ) {
35764
-
35765
- _currentProjectionMatrix.copy( camera.projectionMatrix );
35766
-
35767
- toNormalizedProjectionMatrix( _currentProjectionMatrix );
35768
- toReversedProjectionMatrix( _currentProjectionMatrix );
35769
-
35770
- p_uniforms.setValue( _gl, 'projectionMatrix', _currentProjectionMatrix );
35771
-
35772
- } else {
35773
-
35774
- p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
35775
-
35776
- }
35777
-
35628
+ p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
35778
35629
  p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
35779
35630
 
35780
35631
  const uCamPos = p_uniforms.map.cameraPosition;
@@ -36255,55 +36106,61 @@ class WebGLRenderer {
36255
36106
 
36256
36107
  if ( framebuffer ) {
36257
36108
 
36258
- const texture = renderTarget.texture;
36259
- const textureFormat = texture.format;
36260
- const textureType = texture.type;
36109
+ state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
36261
36110
 
36262
- if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
36111
+ try {
36263
36112
 
36264
- throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' );
36113
+ const texture = renderTarget.texture;
36114
+ const textureFormat = texture.format;
36115
+ const textureType = texture.type;
36265
36116
 
36266
- }
36117
+ if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
36267
36118
 
36268
- if ( ! capabilities.textureTypeReadable( textureType ) ) {
36119
+ throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' );
36269
36120
 
36270
- throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.' );
36121
+ }
36271
36122
 
36272
- }
36123
+ if ( ! capabilities.textureTypeReadable( textureType ) ) {
36273
36124
 
36274
- // the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)
36275
- if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
36125
+ throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.' );
36276
36126
 
36277
- // set the active frame buffer to the one we want to read
36278
- state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
36127
+ }
36279
36128
 
36280
- const glBuffer = _gl.createBuffer();
36281
- _gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
36282
- _gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
36283
- _gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), 0 );
36129
+ // the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)
36130
+ if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
36284
36131
 
36285
- // reset the frame buffer to the currently set buffer before waiting
36286
- const currFramebuffer = _currentRenderTarget !== null ? properties.get( _currentRenderTarget ).__webglFramebuffer : null;
36287
- state.bindFramebuffer( _gl.FRAMEBUFFER, currFramebuffer );
36132
+ const glBuffer = _gl.createBuffer();
36133
+ _gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
36134
+ _gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
36135
+ _gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), 0 );
36136
+ _gl.flush();
36288
36137
 
36289
- // check if the commands have finished every 8 ms
36290
- const sync = _gl.fenceSync( _gl.SYNC_GPU_COMMANDS_COMPLETE, 0 );
36138
+ // check if the commands have finished every 8 ms
36139
+ const sync = _gl.fenceSync( _gl.SYNC_GPU_COMMANDS_COMPLETE, 0 );
36140
+ await probeAsync( _gl, sync, 4 );
36291
36141
 
36292
- _gl.flush();
36142
+ try {
36293
36143
 
36294
- await probeAsync( _gl, sync, 4 );
36144
+ _gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
36145
+ _gl.getBufferSubData( _gl.PIXEL_PACK_BUFFER, 0, buffer );
36295
36146
 
36296
- // read the data and delete the buffer
36297
- _gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
36298
- _gl.getBufferSubData( _gl.PIXEL_PACK_BUFFER, 0, buffer );
36299
- _gl.deleteBuffer( glBuffer );
36300
- _gl.deleteSync( sync );
36147
+ } finally {
36301
36148
 
36302
- return buffer;
36149
+ _gl.deleteBuffer( glBuffer );
36150
+ _gl.deleteSync( sync );
36303
36151
 
36304
- } else {
36152
+ }
36153
+
36154
+ return buffer;
36155
+
36156
+ }
36157
+
36158
+ } finally {
36305
36159
 
36306
- throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.' );
36160
+ // restore framebuffer of current render target if necessary
36161
+
36162
+ const framebuffer = ( _currentRenderTarget !== null ) ? properties.get( _currentRenderTarget ).__webglFramebuffer : null;
36163
+ state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
36307
36164
 
36308
36165
  }
36309
36166
 
@@ -36985,7 +36842,6 @@ function checkIntersection( object, raycaster, ray, thresholdSq, a, b ) {
36985
36842
  index: a,
36986
36843
  face: null,
36987
36844
  faceIndex: null,
36988
- barycoord: null,
36989
36845
  object: object
36990
36846
 
36991
36847
  };
@@ -37122,19 +36978,12 @@ class CylinderGeometry extends BufferGeometry {
37122
36978
 
37123
36979
  // faces
37124
36980
 
37125
- if ( radiusTop > 0 ) {
37126
-
37127
- indices.push( a, b, d );
37128
- groupCount += 3;
37129
-
37130
- }
37131
-
37132
- if ( radiusBottom > 0 ) {
36981
+ indices.push( a, b, d );
36982
+ indices.push( b, c, d );
37133
36983
 
37134
- indices.push( b, c, d );
37135
- groupCount += 3;
36984
+ // update group counter
37136
36985
 
37137
- }
36986
+ groupCount += 6;
37138
36987
 
37139
36988
  }
37140
36989
 
@@ -38116,35 +37965,6 @@ function intersect( object, raycaster, intersects, recursive ) {
38116
37965
 
38117
37966
  }
38118
37967
 
38119
- class Controls extends EventDispatcher {
38120
-
38121
- constructor( object, domElement = null ) {
38122
-
38123
- super();
38124
-
38125
- this.object = object;
38126
- this.domElement = domElement;
38127
-
38128
- this.enabled = true;
38129
-
38130
- this.state = - 1;
38131
-
38132
- this.keys = {};
38133
- this.mouseButtons = { LEFT: null, MIDDLE: null, RIGHT: null };
38134
- this.touches = { ONE: null, TWO: null };
38135
-
38136
- }
38137
-
38138
- connect() {}
38139
-
38140
- disconnect() {}
38141
-
38142
- dispose() {}
38143
-
38144
- update( /* delta */ ) {}
38145
-
38146
- }
38147
-
38148
37968
  if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
38149
37969
 
38150
37970
  __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'register', { detail: {
@@ -38183,22 +38003,32 @@ const _mouseDownEvent = { type: 'mouseDown', mode: null };
38183
38003
  const _mouseUpEvent = { type: 'mouseUp', mode: null };
38184
38004
  const _objectChangeEvent = { type: 'objectChange' };
38185
38005
 
38186
- class TransformControls extends Controls {
38006
+ class TransformControls extends Object3D {
38007
+
38008
+ constructor( camera, domElement ) {
38009
+
38010
+ super();
38011
+
38012
+ if ( domElement === undefined ) {
38187
38013
 
38188
- constructor( camera, domElement = null ) {
38014
+ console.warn( 'THREE.TransformControls: The second parameter "domElement" is now mandatory.' );
38015
+ domElement = document;
38189
38016
 
38190
- super( undefined, domElement );
38017
+ }
38018
+
38019
+ this.isTransformControls = true;
38191
38020
 
38192
- const root = new TransformControlsRoot( this );
38193
- this._root = root;
38021
+ this.visible = false;
38022
+ this.domElement = domElement;
38023
+ this.domElement.style.touchAction = 'none'; // disable touch scroll
38194
38024
 
38195
- const gizmo = new TransformControlsGizmo();
38196
- this._gizmo = gizmo;
38197
- root.add( gizmo );
38025
+ const _gizmo = new TransformControlsGizmo();
38026
+ this._gizmo = _gizmo;
38027
+ this.add( _gizmo );
38198
38028
 
38199
- const plane = new TransformControlsPlane();
38200
- this._plane = plane;
38201
- root.add( plane );
38029
+ const _plane = new TransformControlsPlane();
38030
+ this._plane = _plane;
38031
+ this.add( _plane );
38202
38032
 
38203
38033
  const scope = this;
38204
38034
 
@@ -38220,8 +38050,8 @@ class TransformControls extends Controls {
38220
38050
  if ( propValue !== value ) {
38221
38051
 
38222
38052
  propValue = value;
38223
- plane[ propName ] = value;
38224
- gizmo[ propName ] = value;
38053
+ _plane[ propName ] = value;
38054
+ _gizmo[ propName ] = value;
38225
38055
 
38226
38056
  scope.dispatchEvent( { type: propName + '-changed', value: value } );
38227
38057
  scope.dispatchEvent( _changeEvent );
@@ -38233,8 +38063,8 @@ class TransformControls extends Controls {
38233
38063
  } );
38234
38064
 
38235
38065
  scope[ propName ] = defaultValue;
38236
- plane[ propName ] = defaultValue;
38237
- gizmo[ propName ] = defaultValue;
38066
+ _plane[ propName ] = defaultValue;
38067
+ _gizmo[ propName ] = defaultValue;
38238
38068
 
38239
38069
  }
38240
38070
 
@@ -38309,38 +38139,50 @@ class TransformControls extends Controls {
38309
38139
  this._onPointerMove = onPointerMove.bind( this );
38310
38140
  this._onPointerUp = onPointerUp.bind( this );
38311
38141
 
38312
- if ( domElement !== null ) {
38142
+ this.domElement.addEventListener( 'pointerdown', this._onPointerDown );
38143
+ this.domElement.addEventListener( 'pointermove', this._onPointerHover );
38144
+ this.domElement.addEventListener( 'pointerup', this._onPointerUp );
38313
38145
 
38314
- this.connect();
38146
+ }
38315
38147
 
38316
- }
38148
+ // updateMatrixWorld updates key transformation variables
38149
+ updateMatrixWorld( force ) {
38317
38150
 
38318
- }
38151
+ if ( this.object !== undefined ) {
38319
38152
 
38320
- connect() {
38153
+ this.object.updateMatrixWorld();
38321
38154
 
38322
- this.domElement.addEventListener( 'pointerdown', this._onPointerDown );
38323
- this.domElement.addEventListener( 'pointermove', this._onPointerHover );
38324
- this.domElement.addEventListener( 'pointerup', this._onPointerUp );
38155
+ if ( this.object.parent === null ) {
38325
38156
 
38326
- this.domElement.style.touchAction = 'none'; // disable touch scroll
38157
+ console.error( 'TransformControls: The attached 3D object must be a part of the scene graph.' );
38327
38158
 
38328
- }
38159
+ } else {
38329
38160
 
38330
- disconnect() {
38161
+ this.object.parent.matrixWorld.decompose( this._parentPosition, this._parentQuaternion, this._parentScale );
38331
38162
 
38332
- this.domElement.removeEventListener( 'pointerdown', this._onPointerDown );
38333
- this.domElement.removeEventListener( 'pointermove', this._onPointerHover );
38334
- this.domElement.removeEventListener( 'pointermove', this._onPointerMove );
38335
- this.domElement.removeEventListener( 'pointerup', this._onPointerUp );
38163
+ }
38336
38164
 
38337
- this.domElement.style.touchAction = 'auto';
38165
+ this.object.matrixWorld.decompose( this.worldPosition, this.worldQuaternion, this._worldScale );
38338
38166
 
38339
- }
38167
+ this._parentQuaternionInv.copy( this._parentQuaternion ).invert();
38168
+ this._worldQuaternionInv.copy( this.worldQuaternion ).invert();
38169
+
38170
+ }
38171
+
38172
+ this.camera.updateMatrixWorld();
38173
+ this.camera.matrixWorld.decompose( this.cameraPosition, this.cameraQuaternion, this._cameraScale );
38174
+
38175
+ if ( this.camera.isOrthographicCamera ) {
38176
+
38177
+ this.camera.getWorldDirection( this.eye ).negate();
38178
+
38179
+ } else {
38180
+
38181
+ this.eye.copy( this.cameraPosition ).sub( this.worldPosition ).normalize();
38340
38182
 
38341
- getHelper() {
38183
+ }
38342
38184
 
38343
- return this._root;
38185
+ super.updateMatrixWorld( force );
38344
38186
 
38345
38187
  }
38346
38188
 
@@ -38680,7 +38522,10 @@ class TransformControls extends Controls {
38680
38522
 
38681
38523
  dispose() {
38682
38524
 
38683
- this.disconnect();
38525
+ this.domElement.removeEventListener( 'pointerdown', this._onPointerDown );
38526
+ this.domElement.removeEventListener( 'pointermove', this._onPointerHover );
38527
+ this.domElement.removeEventListener( 'pointermove', this._onPointerMove );
38528
+ this.domElement.removeEventListener( 'pointerup', this._onPointerUp );
38684
38529
 
38685
38530
  this.traverse( function ( child ) {
38686
38531
 
@@ -38695,7 +38540,7 @@ class TransformControls extends Controls {
38695
38540
  attach( object ) {
38696
38541
 
38697
38542
  this.object = object;
38698
- this._root.visible = true;
38543
+ this.visible = true;
38699
38544
 
38700
38545
  return this;
38701
38546
 
@@ -38705,10 +38550,9 @@ class TransformControls extends Controls {
38705
38550
  detach() {
38706
38551
 
38707
38552
  this.object = undefined;
38553
+ this.visible = false;
38708
38554
  this.axis = null;
38709
38555
 
38710
- this._root.visible = false;
38711
-
38712
38556
  return this;
38713
38557
 
38714
38558
  }
@@ -38901,64 +38745,6 @@ const _v1 = new Vector3();
38901
38745
  const _v2 = new Vector3();
38902
38746
  const _v3 = new Vector3();
38903
38747
 
38904
- class TransformControlsRoot extends Object3D {
38905
-
38906
- constructor( controls ) {
38907
-
38908
- super();
38909
-
38910
- this.isTransformControlsRoot = true;
38911
-
38912
- this.controls = controls;
38913
- this.visible = false;
38914
-
38915
- }
38916
-
38917
- // updateMatrixWorld updates key transformation variables
38918
- updateMatrixWorld( force ) {
38919
-
38920
- const controls = this.controls;
38921
-
38922
- if ( controls.object !== undefined ) {
38923
-
38924
- controls.object.updateMatrixWorld();
38925
-
38926
- if ( controls.object.parent === null ) {
38927
-
38928
- console.error( 'TransformControls: The attached 3D object must be a part of the scene graph.' );
38929
-
38930
- } else {
38931
-
38932
- controls.object.parent.matrixWorld.decompose( controls._parentPosition, controls._parentQuaternion, controls._parentScale );
38933
-
38934
- }
38935
-
38936
- controls.object.matrixWorld.decompose( controls.worldPosition, controls.worldQuaternion, controls._worldScale );
38937
-
38938
- controls._parentQuaternionInv.copy( controls._parentQuaternion ).invert();
38939
- controls._worldQuaternionInv.copy( controls.worldQuaternion ).invert();
38940
-
38941
- }
38942
-
38943
- controls.camera.updateMatrixWorld();
38944
- controls.camera.matrixWorld.decompose( controls.cameraPosition, controls.cameraQuaternion, controls._cameraScale );
38945
-
38946
- if ( controls.camera.isOrthographicCamera ) {
38947
-
38948
- controls.camera.getWorldDirection( controls.eye ).negate();
38949
-
38950
- } else {
38951
-
38952
- controls.eye.copy( controls.cameraPosition ).sub( controls.worldPosition ).normalize();
38953
-
38954
- }
38955
-
38956
- super.updateMatrixWorld( force );
38957
-
38958
- }
38959
-
38960
- }
38961
-
38962
38748
  class TransformControlsGizmo extends Object3D {
38963
38749
 
38964
38750
  constructor() {