super-three 0.136.1 → 0.137.0

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.
Files changed (100) hide show
  1. package/README.md +1 -1
  2. package/build/three.cjs +37132 -0
  3. package/build/three.js +71 -53
  4. package/build/three.min.js +2 -2
  5. package/build/three.module.js +80 -47
  6. package/examples/js/animation/MMDAnimationHelper.js +3 -1
  7. package/examples/js/controls/experimental/CameraControls.js +6 -2
  8. package/examples/js/exporters/GLTFExporter.js +82 -39
  9. package/examples/js/geometries/TextGeometry.js +12 -10
  10. package/examples/js/interactive/HTMLMesh.js +14 -2
  11. package/examples/js/loaders/EXRLoader.js +20 -9
  12. package/examples/js/loaders/GLTFLoader.js +1 -1
  13. package/examples/js/loaders/LDrawLoader.js +541 -425
  14. package/examples/js/loaders/MD2Loader.js +5 -5
  15. package/examples/js/loaders/MTLLoader.js +10 -3
  16. package/examples/js/loaders/PCDLoader.js +2 -2
  17. package/examples/js/loaders/STLLoader.js +1 -1
  18. package/examples/js/loaders/SVGLoader.js +3 -2
  19. package/examples/js/modifiers/EdgeSplitModifier.js +0 -6
  20. package/examples/js/modifiers/SimplifyModifier.js +0 -10
  21. package/examples/js/objects/Lensflare.js +2 -2
  22. package/examples/js/postprocessing/OutlinePass.js +1 -5
  23. package/examples/js/renderers/CSS2DRenderer.js +25 -19
  24. package/examples/js/renderers/CSS3DRenderer.js +37 -32
  25. package/examples/js/utils/LDrawUtils.js +182 -0
  26. package/examples/jsm/exporters/GLTFExporter.js +80 -12
  27. package/examples/jsm/geometries/TextGeometry.js +13 -13
  28. package/examples/jsm/interactive/HTMLMesh.js +16 -2
  29. package/examples/jsm/libs/flow.module.js +930 -169
  30. package/examples/jsm/loaders/EXRLoader.js +19 -9
  31. package/examples/jsm/loaders/GLTFLoader.js +1 -1
  32. package/examples/jsm/loaders/LDrawLoader.js +534 -442
  33. package/examples/jsm/loaders/MD2Loader.js +5 -5
  34. package/examples/jsm/loaders/MTLLoader.js +11 -4
  35. package/examples/jsm/loaders/PCDLoader.js +2 -2
  36. package/examples/jsm/loaders/STLLoader.js +1 -1
  37. package/examples/jsm/loaders/SVGLoader.js +3 -1
  38. package/examples/jsm/loaders/VRMLLoader.js +0 -1
  39. package/examples/jsm/modifiers/EdgeSplitModifier.js +0 -6
  40. package/examples/jsm/modifiers/SimplifyModifier.js +0 -10
  41. package/examples/jsm/node-editor/NodeEditor.js +435 -181
  42. package/examples/jsm/node-editor/accessors/NormalEditor.js +8 -8
  43. package/examples/jsm/node-editor/accessors/PositionEditor.js +8 -8
  44. package/examples/jsm/node-editor/accessors/UVEditor.js +6 -7
  45. package/examples/jsm/node-editor/core/BaseNode.js +83 -0
  46. package/examples/jsm/node-editor/display/BlendEditor.js +7 -6
  47. package/examples/jsm/node-editor/examples/animate-uv.json +1 -1
  48. package/examples/jsm/node-editor/examples/fake-top-light.json +1 -1
  49. package/examples/jsm/node-editor/examples/oscillator-color.json +1 -1
  50. package/examples/jsm/node-editor/examples/rim.json +1 -1
  51. package/examples/jsm/node-editor/inputs/ColorEditor.js +14 -10
  52. package/examples/jsm/node-editor/inputs/FloatEditor.js +6 -7
  53. package/examples/jsm/node-editor/inputs/SliderEditor.js +4 -5
  54. package/examples/jsm/node-editor/inputs/Vector2Editor.js +6 -7
  55. package/examples/jsm/node-editor/inputs/Vector3Editor.js +8 -9
  56. package/examples/jsm/node-editor/inputs/Vector4Editor.js +9 -10
  57. package/examples/jsm/node-editor/materials/BasicMaterialEditor.js +87 -0
  58. package/examples/jsm/node-editor/materials/PointsMaterialEditor.js +97 -0
  59. package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +20 -17
  60. package/examples/jsm/node-editor/math/AngleEditor.js +39 -0
  61. package/examples/jsm/node-editor/math/DotEditor.js +6 -7
  62. package/examples/jsm/node-editor/math/InvertEditor.js +4 -3
  63. package/examples/jsm/node-editor/math/LimiterEditor.js +11 -10
  64. package/examples/jsm/node-editor/math/NormalizeEditor.js +6 -5
  65. package/examples/jsm/node-editor/math/OperatorEditor.js +12 -11
  66. package/examples/jsm/node-editor/math/PowerEditor.js +6 -5
  67. package/examples/jsm/node-editor/math/TrigonometryEditor.js +12 -7
  68. package/examples/jsm/node-editor/procedural/CheckerEditor.js +4 -3
  69. package/examples/jsm/node-editor/scene/MeshEditor.js +99 -0
  70. package/examples/jsm/node-editor/scene/Object3DEditor.js +160 -0
  71. package/examples/jsm/node-editor/scene/PointsEditor.js +99 -0
  72. package/examples/jsm/node-editor/utils/JoinEditor.js +58 -0
  73. package/examples/jsm/node-editor/utils/OscillatorEditor.js +7 -6
  74. package/examples/jsm/node-editor/utils/SplitEditor.js +39 -0
  75. package/examples/jsm/node-editor/utils/TimerEditor.js +6 -5
  76. package/examples/jsm/postprocessing/OutlinePass.js +1 -4
  77. package/examples/jsm/renderers/CSS2DRenderer.js +24 -19
  78. package/examples/jsm/renderers/CSS3DRenderer.js +36 -30
  79. package/examples/jsm/renderers/nodes/accessors/UVNode.js +4 -4
  80. package/examples/jsm/renderers/nodes/core/NodeBuilder.js +2 -1
  81. package/examples/jsm/renderers/nodes/utils/SplitNode.js +19 -4
  82. package/examples/jsm/utils/LDrawUtils.js +18 -11
  83. package/package.json +16 -9
  84. package/src/constants.js +1 -3
  85. package/src/core/BufferGeometry.js +2 -2
  86. package/src/geometries/LatheGeometry.js +1 -1
  87. package/src/loaders/FileLoader.js +20 -3
  88. package/src/math/Box3.js +24 -10
  89. package/src/renderers/WebGLRenderTarget.js +4 -1
  90. package/src/renderers/WebGLRenderer.js +3 -3
  91. package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +1 -1
  92. package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +2 -2
  93. package/src/renderers/webgl/WebGLBackground.js +2 -2
  94. package/src/renderers/webgl/WebGLGeometries.js +2 -2
  95. package/src/renderers/webgl/WebGLPrograms.js +2 -2
  96. package/src/renderers/webgl/WebGLState.js +2 -2
  97. package/src/renderers/webgl/WebGLTextures.js +9 -6
  98. package/src/renderers/webgl/WebGLUtils.js +1 -3
  99. package/src/renderers/webxr/WebXRManager.js +2 -0
  100. package/src/utils.js +15 -1
@@ -239,57 +239,63 @@ class CSS3DRenderer {
239
239
 
240
240
  if ( object.isCSS3DObject ) {
241
241
 
242
- object.onBeforeRender( _this, scene, camera );
242
+ const visible = object.visible && object.layers.test( camera.layers );
243
+ object.element.style.display = visible ? '' : 'none';
243
244
 
244
- let style;
245
+ // only getObjectCSSMatrix when object.visible
246
+ if ( visible ) {
245
247
 
246
- if ( object.isCSS3DSprite ) {
248
+ object.onBeforeRender( _this, scene, camera );
247
249
 
248
- // http://swiftcoder.wordpress.com/2008/11/25/constructing-a-billboard-matrix/
250
+ let style;
249
251
 
250
- _matrix.copy( camera.matrixWorldInverse );
251
- _matrix.transpose();
252
+ if ( object.isCSS3DSprite ) {
252
253
 
253
- if ( object.rotation2D !== 0 ) _matrix.multiply( _matrix2.makeRotationZ( object.rotation2D ) );
254
+ // http://swiftcoder.wordpress.com/2008/11/25/constructing-a-billboard-matrix/
254
255
 
255
- object.matrixWorld.decompose( _position, _quaternion, _scale );
256
- _matrix.setPosition( _position );
257
- _matrix.scale( _scale );
256
+ _matrix.copy( camera.matrixWorldInverse );
257
+ _matrix.transpose();
258
258
 
259
- _matrix.elements[ 3 ] = 0;
260
- _matrix.elements[ 7 ] = 0;
261
- _matrix.elements[ 11 ] = 0;
262
- _matrix.elements[ 15 ] = 1;
259
+ if ( object.rotation2D !== 0 ) _matrix.multiply( _matrix2.makeRotationZ( object.rotation2D ) );
263
260
 
264
- style = getObjectCSSMatrix( _matrix );
261
+ object.matrixWorld.decompose( _position, _quaternion, _scale );
262
+ _matrix.setPosition( _position );
263
+ _matrix.scale( _scale );
265
264
 
266
- } else {
265
+ _matrix.elements[ 3 ] = 0;
266
+ _matrix.elements[ 7 ] = 0;
267
+ _matrix.elements[ 11 ] = 0;
268
+ _matrix.elements[ 15 ] = 1;
267
269
 
268
- style = getObjectCSSMatrix( object.matrixWorld );
270
+ style = getObjectCSSMatrix( _matrix );
269
271
 
270
- }
272
+ } else {
271
273
 
272
- const element = object.element;
273
- const cachedObject = cache.objects.get( object );
274
+ style = getObjectCSSMatrix( object.matrixWorld );
274
275
 
275
- if ( cachedObject === undefined || cachedObject.style !== style ) {
276
+ }
276
277
 
277
- element.style.transform = style;
278
+ const element = object.element;
279
+ const cachedObject = cache.objects.get( object );
278
280
 
279
- const objectData = { style: style };
280
- cache.objects.set( object, objectData );
281
+ if ( cachedObject === undefined || cachedObject.style !== style ) {
281
282
 
282
- }
283
+ element.style.transform = style;
283
284
 
284
- element.style.display = object.visible ? '' : 'none';
285
+ const objectData = { style: style };
286
+ cache.objects.set( object, objectData );
285
287
 
286
- if ( element.parentNode !== cameraElement ) {
288
+ }
287
289
 
288
- cameraElement.appendChild( element );
290
+ if ( element.parentNode !== cameraElement ) {
289
291
 
290
- }
292
+ cameraElement.appendChild( element );
291
293
 
292
- object.onAfterRender( _this, scene, camera );
294
+ }
295
+
296
+ object.onAfterRender( _this, scene, camera );
297
+
298
+ }
293
299
 
294
300
  }
295
301
 
@@ -2,19 +2,19 @@ import AttributeNode from '../core/AttributeNode.js';
2
2
 
3
3
  class UVNode extends AttributeNode {
4
4
 
5
- constructor( value = 0 ) {
5
+ constructor( index = 0 ) {
6
6
 
7
7
  super( null, 'vec2' );
8
8
 
9
- this.value = value;
9
+ this.index = index;
10
10
 
11
11
  }
12
12
 
13
13
  getAttributeName( /*builder*/ ) {
14
14
 
15
- const value = this.value;
15
+ const index = this.index;
16
16
 
17
- return 'uv' + ( value > 0 ? value + 1 : '' );
17
+ return 'uv' + ( index > 0 ? index + 1 : '' );
18
18
 
19
19
  }
20
20
 
@@ -8,7 +8,8 @@ import { NodeUpdateType } from './constants.js';
8
8
 
9
9
  import { REVISION, LinearEncoding } from 'three';
10
10
 
11
- const shaderStages = [ 'fragment', 'vertex' ];
11
+ export const shaderStages = [ 'fragment', 'vertex' ];
12
+ export const vector = [ 'x', 'y', 'z', 'w' ];
12
13
 
13
14
  class NodeBuilder {
14
15
 
@@ -1,4 +1,5 @@
1
1
  import Node from '../core/Node.js';
2
+ import { vector } from '../core/NodeBuilder.js';
2
3
 
3
4
  class SplitNode extends Node {
4
5
 
@@ -11,6 +12,20 @@ class SplitNode extends Node {
11
12
 
12
13
  }
13
14
 
15
+ getVectorLength() {
16
+
17
+ let vectorLength = this.components.length;
18
+
19
+ for ( const c of this.components ) {
20
+
21
+ vectorLength = Math.max( vector.indexOf( c ) + 1, vectorLength );
22
+
23
+ }
24
+
25
+ return vectorLength;
26
+
27
+ }
28
+
14
29
  getNodeType( builder ) {
15
30
 
16
31
  return builder.getTypeFromLength( this.components.length );
@@ -24,15 +39,15 @@ class SplitNode extends Node {
24
39
 
25
40
  if ( nodeTypeLength > 1 ) {
26
41
 
27
- const components = this.components;
28
-
29
42
  let type = null;
30
43
 
31
- if ( components.length >= nodeTypeLength ) {
44
+ const componentsLength = this.getVectorLength();
45
+
46
+ if ( componentsLength >= nodeTypeLength ) {
32
47
 
33
48
  // need expand the input node
34
49
 
35
- type = this.getNodeType( builder );
50
+ type = builder.getTypeFromLength( this.getVectorLength() );
36
51
 
37
52
  }
38
53
 
@@ -62,8 +62,11 @@ class LDrawUtils {
62
62
  arr: [ geometry ]
63
63
  };
64
64
 
65
+ } else {
66
+
67
+ geoms.arr.push( geometry );
68
+
65
69
  }
66
- else geoms.arr.push( geometry );
67
70
 
68
71
  }
69
72
 
@@ -111,22 +114,23 @@ class LDrawUtils {
111
114
 
112
115
  const elemSize = c.isMesh ? 3 : 2;
113
116
 
117
+ const geometry = c.geometry.clone();
114
118
  const matrixIsInverted = c.matrixWorld.determinant() < 0;
115
119
  if ( matrixIsInverted ) {
116
120
 
117
- permuteAttribute( c.geometry.attributes.position, elemSize );
118
- permuteAttribute( c.geometry.attributes.normal, elemSize );
121
+ permuteAttribute( geometry.attributes.position, elemSize );
122
+ permuteAttribute( geometry.attributes.normal, elemSize );
119
123
 
120
124
  }
121
125
 
122
- c.geometry.applyMatrix4( c.matrixWorld );
126
+ geometry.applyMatrix4( c.matrixWorld );
123
127
 
124
128
  if ( c.isConditionalLine ) {
125
129
 
126
- c.geometry.attributes.control0.applyMatrix4( c.matrixWorld );
127
- c.geometry.attributes.control1.applyMatrix4( c.matrixWorld );
130
+ geometry.attributes.control0.applyMatrix4( c.matrixWorld );
131
+ geometry.attributes.control1.applyMatrix4( c.matrixWorld );
128
132
  normalMatrix.getNormalMatrix( c.matrixWorld );
129
- c.geometry.attributes.direction.applyNormalMatrix( normalMatrix );
133
+ geometry.attributes.direction.applyNormalMatrix( normalMatrix );
130
134
 
131
135
  }
132
136
 
@@ -134,17 +138,20 @@ class LDrawUtils {
134
138
 
135
139
  if ( Array.isArray( c.material ) ) {
136
140
 
137
- for ( const groupIndex in c.geometry.groups ) {
141
+ for ( const groupIndex in geometry.groups ) {
138
142
 
139
- const group = c.geometry.groups[ groupIndex ];
143
+ const group = geometry.groups[ groupIndex ];
140
144
  const mat = c.material[ group.materialIndex ];
141
- const newGeometry = extractGroup( c.geometry, group, elemSize, c.isConditionalLine );
145
+ const newGeometry = extractGroup( geometry, group, elemSize, c.isConditionalLine );
142
146
  addGeometry( mat, newGeometry, geometries );
143
147
 
144
148
  }
145
149
 
150
+ } else {
151
+
152
+ addGeometry( c.material, geometry, geometries );
153
+
146
154
  }
147
- else addGeometry( c.material, c.geometry, geometries );
148
155
 
149
156
  }
150
157
 
package/package.json CHANGED
@@ -1,9 +1,18 @@
1
1
  {
2
2
  "name": "super-three",
3
- "version": "0.136.1",
3
+ "version": "0.137.0",
4
4
  "description": "JavaScript 3D library",
5
- "main": "build/three.js",
6
- "module": "build/three.module.js",
5
+ "type": "module",
6
+ "main": "./build/three.js",
7
+ "module": "./build/three.module.js",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./build/three.module.js",
11
+ "require": "./build/three.cjs"
12
+ },
13
+ "./examples/jsm/*": "./examples/jsm/*.js",
14
+ "./src/*": "./src/*.js"
15
+ },
7
16
  "repository": {
8
17
  "type": "git",
9
18
  "url": "supermedium/three.js"
@@ -11,6 +20,7 @@
11
20
  "sideEffects": false,
12
21
  "files": [
13
22
  "build/three.js",
23
+ "build/three.cjs",
14
24
  "build/three.min.js",
15
25
  "build/three.module.js",
16
26
  "examples/js",
@@ -41,7 +51,6 @@
41
51
  "globals": {
42
52
  "__THREE_DEVTOOLS__": "readonly",
43
53
  "WebGL2ComputeRenderingContext": "readonly",
44
-
45
54
  "potpack": "readonly",
46
55
  "fflate": "readonly",
47
56
  "bodymovin": "readonly",
@@ -49,10 +58,10 @@
49
58
  "Stats": "readonly",
50
59
  "XRWebGLBinding": "readonly",
51
60
  "XRWebGLLayer": "readonly",
52
-
53
61
  "GPUShaderStage": "readonly",
54
62
  "GPUBufferUsage": "readonly",
55
- "GPUTextureUsage": "readonly"
63
+ "GPUTextureUsage": "readonly",
64
+ "QUnit": "readonly"
56
65
  },
57
66
  "rules": {
58
67
  "no-throw-literal": [
@@ -87,8 +96,7 @@
87
96
  "test-e2e": "node test/e2e/puppeteer.js",
88
97
  "test-e2e-cov": "node test/e2e/check-coverage.js",
89
98
  "test-treeshake": "rollup -c test/rollup.treeshake.config.js",
90
- "make-screenshot": "node test/e2e/puppeteer.js --make",
91
- "prepublishOnly": "node utils/prepublish.js"
99
+ "make-screenshot": "node test/e2e/puppeteer.js --make"
92
100
  },
93
101
  "keywords": [
94
102
  "three",
@@ -124,7 +132,6 @@
124
132
  "eslint": "^7.32.0",
125
133
  "eslint-config-mdcs": "^5.0.0",
126
134
  "eslint-plugin-html": "^6.2.0",
127
- "glob": "^7.2.0",
128
135
  "rollup": "^2.57.0",
129
136
  "rollup-plugin-filesize": "^9.1.1",
130
137
  "rollup-plugin-terser": "^7.0.2",
package/src/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- export const REVISION = '137dev';
1
+ export const REVISION = '137';
2
2
  export const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
3
3
  export const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
4
4
  export const CullFaceNone = 0;
@@ -84,7 +84,6 @@ export const FloatType = 1015;
84
84
  export const HalfFloatType = 1016;
85
85
  export const UnsignedShort4444Type = 1017;
86
86
  export const UnsignedShort5551Type = 1018;
87
- export const UnsignedShort565Type = 1019;
88
87
  export const UnsignedInt248Type = 1020;
89
88
  export const AlphaFormat = 1021;
90
89
  export const RGBAFormat = 1023;
@@ -96,7 +95,6 @@ export const RedFormat = 1028;
96
95
  export const RedIntegerFormat = 1029;
97
96
  export const RGFormat = 1030;
98
97
  export const RGIntegerFormat = 1031;
99
- export const RGBIntegerFormat = 1032;
100
98
  export const RGBAIntegerFormat = 1033;
101
99
 
102
100
  export const RGB_S3TC_DXT1_Format = 33776;
@@ -8,7 +8,7 @@ import { Object3D } from './Object3D.js';
8
8
  import { Matrix4 } from '../math/Matrix4.js';
9
9
  import { Matrix3 } from '../math/Matrix3.js';
10
10
  import * as MathUtils from '../math/MathUtils.js';
11
- import { arrayMax } from '../utils.js';
11
+ import { arrayNeedsUint32 } from '../utils.js';
12
12
 
13
13
  let _id = 0;
14
14
 
@@ -59,7 +59,7 @@ class BufferGeometry extends EventDispatcher {
59
59
 
60
60
  if ( Array.isArray( index ) ) {
61
61
 
62
- this.index = new ( arrayMax( index ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( index, 1 );
62
+ this.index = new ( arrayNeedsUint32( index ) ? Uint32BufferAttribute : Uint16BufferAttribute )( index, 1 );
63
63
 
64
64
  } else {
65
65
 
@@ -152,7 +152,7 @@ class LatheGeometry extends BufferGeometry {
152
152
  // faces
153
153
 
154
154
  indices.push( a, b, d );
155
- indices.push( b, c, d );
155
+ indices.push( c, d, b );
156
156
 
157
157
  }
158
158
 
@@ -69,6 +69,10 @@ class FileLoader extends Loader {
69
69
  // An abort controller could be added within a future PR
70
70
  } );
71
71
 
72
+ // record states ( avoid data race )
73
+ const mimeType = this.mimeType;
74
+ const responseType = this.responseType;
75
+
72
76
  // start the fetch
73
77
  fetch( req )
74
78
  .then( response => {
@@ -147,7 +151,7 @@ class FileLoader extends Loader {
147
151
  } )
148
152
  .then( response => {
149
153
 
150
- switch ( this.responseType ) {
154
+ switch ( responseType ) {
151
155
 
152
156
  case 'arraybuffer':
153
157
 
@@ -163,7 +167,7 @@ class FileLoader extends Loader {
163
167
  .then( text => {
164
168
 
165
169
  const parser = new DOMParser();
166
- return parser.parseFromString( text, this.mimeType );
170
+ return parser.parseFromString( text, mimeType );
167
171
 
168
172
  } );
169
173
 
@@ -173,7 +177,20 @@ class FileLoader extends Loader {
173
177
 
174
178
  default:
175
179
 
176
- return response.text();
180
+ if ( mimeType === undefined ) {
181
+
182
+ return response.text();
183
+
184
+ } else {
185
+
186
+ // sniff encoding
187
+ const re = /charset="?([^;"\s]*)"?/i;
188
+ const exec = re.exec( mimeType );
189
+ const label = exec && exec[ 1 ] ? exec[ 1 ].toLowerCase() : undefined;
190
+ const decoder = new TextDecoder( label );
191
+ return response.arrayBuffer().then( ab => decoder.decode( ab ) );
192
+
193
+ }
177
194
 
178
195
  }
179
196
 
package/src/math/Box3.js CHANGED
@@ -109,11 +109,11 @@ class Box3 {
109
109
 
110
110
  }
111
111
 
112
- setFromObject( object ) {
112
+ setFromObject( object, precise = false ) {
113
113
 
114
114
  this.makeEmpty();
115
115
 
116
- return this.expandByObject( object );
116
+ return this.expandByObject( object, precise );
117
117
 
118
118
  }
119
119
 
@@ -188,7 +188,7 @@ class Box3 {
188
188
 
189
189
  }
190
190
 
191
- expandByObject( object ) {
191
+ expandByObject( object, precise = false ) {
192
192
 
193
193
  // Computes the world-axis-aligned bounding box of an object (including its children),
194
194
  // accounting for both the object's, and children's, world transforms
@@ -199,16 +199,30 @@ class Box3 {
199
199
 
200
200
  if ( geometry !== undefined ) {
201
201
 
202
- if ( geometry.boundingBox === null ) {
202
+ if ( precise && geometry.attributes != undefined && geometry.attributes.position !== undefined ) {
203
203
 
204
- geometry.computeBoundingBox();
204
+ const position = geometry.attributes.position;
205
+ for ( let i = 0, l = position.count; i < l; i ++ ) {
205
206
 
206
- }
207
+ _vector.fromBufferAttribute( position, i ).applyMatrix4( object.matrixWorld );
208
+ this.expandByPoint( _vector );
209
+
210
+ }
211
+
212
+ } else {
213
+
214
+ if ( geometry.boundingBox === null ) {
207
215
 
208
- _box.copy( geometry.boundingBox );
209
- _box.applyMatrix4( object.matrixWorld );
216
+ geometry.computeBoundingBox();
210
217
 
211
- this.union( _box );
218
+ }
219
+
220
+ _box.copy( geometry.boundingBox );
221
+ _box.applyMatrix4( object.matrixWorld );
222
+
223
+ this.union( _box );
224
+
225
+ }
212
226
 
213
227
  }
214
228
 
@@ -216,7 +230,7 @@ class Box3 {
216
230
 
217
231
  for ( let i = 0, l = children.length; i < l; i ++ ) {
218
232
 
219
- this.expandByObject( children[ i ] );
233
+ this.expandByObject( children[ i ], precise );
220
234
 
221
235
  }
222
236
 
@@ -86,7 +86,10 @@ class WebGLRenderTarget extends EventDispatcher {
86
86
  this.viewport.copy( source.viewport );
87
87
 
88
88
  this.texture = source.texture.clone();
89
- this.texture.image = { ...this.texture.image }; // See #20328.
89
+
90
+ // ensure image object is not shared, see #20328
91
+
92
+ this.texture.image = Object.assign( {}, source.texture.image );
90
93
 
91
94
  this.depthBuffer = source.depthBuffer;
92
95
  this.stencilBuffer = source.stencilBuffer;
@@ -202,7 +202,7 @@ function WebGLRenderer( parameters = {} ) {
202
202
  try {
203
203
 
204
204
  const contextAttributes = {
205
- alpha: _alpha,
205
+ alpha: true,
206
206
  depth: _depth,
207
207
  stencil: _stencil,
208
208
  antialias: _antialias,
@@ -301,7 +301,7 @@ function WebGLRenderer( parameters = {} ) {
301
301
  materials = new WebGLMaterials( properties );
302
302
  renderLists = new WebGLRenderLists();
303
303
  renderStates = new WebGLRenderStates( extensions, capabilities );
304
- background = new WebGLBackground( _this, cubemaps, state, objects, _premultipliedAlpha );
304
+ background = new WebGLBackground( _this, cubemaps, state, objects, _alpha, _premultipliedAlpha );
305
305
  shadowMap = new WebGLShadowMap( _this, objects, capabilities );
306
306
 
307
307
  bufferRenderer = new WebGLBufferRenderer( _gl, extensions, info, capabilities );
@@ -1420,7 +1420,7 @@ function WebGLRenderer( parameters = {} ) {
1420
1420
 
1421
1421
  const fog = scene.fog;
1422
1422
  const environment = material.isMeshStandardMaterial ? scene.environment : null;
1423
- const encoding = ( _currentRenderTarget === null ) ? _this.outputEncoding : _currentRenderTarget.texture.encoding;
1423
+ const encoding = ( _currentRenderTarget === null ) ? _this.outputEncoding : ( _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.encoding : LinearEncoding );
1424
1424
  const envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || environment );
1425
1425
  const vertexAlphas = material.vertexColors === true && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4;
1426
1426
  const vertexTangents = !! material.normalMap && !! geometry.attributes.tangent;
@@ -10,7 +10,7 @@ export default /* glsl */`
10
10
 
11
11
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
12
12
 
13
- if ( morphTargetInfluences[ i ] > 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1, 2 ) * morphTargetInfluences[ i ];
13
+ if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1, 2 ) * morphTargetInfluences[ i ];
14
14
 
15
15
  }
16
16
 
@@ -12,11 +12,11 @@ export default /* glsl */`
12
12
 
13
13
  #ifndef USE_MORPHNORMALS
14
14
 
15
- if ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 1 ) * morphTargetInfluences[ i ];
15
+ if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 1 ) * morphTargetInfluences[ i ];
16
16
 
17
17
  #else
18
18
 
19
- if ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 2 ) * morphTargetInfluences[ i ];
19
+ if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 2 ) * morphTargetInfluences[ i ];
20
20
 
21
21
  #endif
22
22
 
@@ -7,10 +7,10 @@ import { Mesh } from '../../objects/Mesh.js';
7
7
  import { ShaderLib } from '../shaders/ShaderLib.js';
8
8
  import { cloneUniforms } from '../shaders/UniformsUtils.js';
9
9
 
10
- function WebGLBackground( renderer, cubemaps, state, objects, premultipliedAlpha ) {
10
+ function WebGLBackground( renderer, cubemaps, state, objects, alpha, premultipliedAlpha ) {
11
11
 
12
12
  const clearColor = new Color( 0x000000 );
13
- let clearAlpha = 0;
13
+ let clearAlpha = alpha === true ? 0 : 1;
14
14
 
15
15
  let planeMesh;
16
16
  let boxMesh;
@@ -1,5 +1,5 @@
1
1
  import { Uint16BufferAttribute, Uint32BufferAttribute } from '../../core/BufferAttribute.js';
2
- import { arrayMax } from '../../utils.js';
2
+ import { arrayNeedsUint32 } from '../../utils.js';
3
3
 
4
4
  function WebGLGeometries( gl, attributes, info, bindingStates ) {
5
5
 
@@ -133,7 +133,7 @@ function WebGLGeometries( gl, attributes, info, bindingStates ) {
133
133
 
134
134
  }
135
135
 
136
- const attribute = new ( arrayMax( indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 );
136
+ const attribute = new ( arrayNeedsUint32( indices ) ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 );
137
137
  attribute.version = version;
138
138
 
139
139
  // Updating index buffer in VAO now. See WebGLBindingStates
@@ -1,4 +1,4 @@
1
- import { BackSide, DoubleSide, CubeUVRefractionMapping, CubeUVReflectionMapping, ObjectSpaceNormalMap, TangentSpaceNormalMap, NoToneMapping, sRGBEncoding } from '../../constants.js';
1
+ import { BackSide, DoubleSide, CubeUVRefractionMapping, CubeUVReflectionMapping, ObjectSpaceNormalMap, TangentSpaceNormalMap, NoToneMapping, LinearEncoding, sRGBEncoding } from '../../constants.js';
2
2
  import { Layers } from '../../core/Layers.js';
3
3
  import { WebGLProgram } from './WebGLProgram.js';
4
4
  import { WebGLShaderCache } from './WebGLShaderCache.js';
@@ -148,7 +148,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
148
148
  instancingColor: object.isInstancedMesh === true && object.instanceColor !== null,
149
149
 
150
150
  supportsVertexTextures: vertexTextures,
151
- outputEncoding: ( currentRenderTarget !== null ) ? currentRenderTarget.texture.encoding : renderer.outputEncoding,
151
+ outputEncoding: ( currentRenderTarget === null ) ? renderer.outputEncoding : ( currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.encoding : LinearEncoding ),
152
152
  map: !! material.map,
153
153
  matcap: !! material.matcap,
154
154
  envMap: !! envMap,
@@ -641,7 +641,7 @@ function WebGLState( gl, extensions, capabilities ) {
641
641
  break;
642
642
 
643
643
  case SubtractiveBlending:
644
- gl.blendFuncSeparate( gl.ZERO, gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ONE_MINUS_SRC_ALPHA );
644
+ gl.blendFuncSeparate( gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ZERO, gl.ONE );
645
645
  break;
646
646
 
647
647
  case MultiplyBlending:
@@ -667,7 +667,7 @@ function WebGLState( gl, extensions, capabilities ) {
667
667
  break;
668
668
 
669
669
  case SubtractiveBlending:
670
- gl.blendFunc( gl.ZERO, gl.ONE_MINUS_SRC_COLOR );
670
+ gl.blendFuncSeparate( gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ZERO, gl.ONE );
671
671
  break;
672
672
 
673
673
  case MultiplyBlending:
@@ -153,11 +153,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
153
153
 
154
154
  }
155
155
 
156
- if ( glFormat === _gl.RGB ) {
156
+ if ( glFormat === _gl.RG ) {
157
157
 
158
- if ( glType === _gl.FLOAT ) internalFormat = _gl.RGB32F;
159
- if ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RGB16F;
160
- if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RGB8;
158
+ if ( glType === _gl.FLOAT ) internalFormat = _gl.RG32F;
159
+ if ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RG16F;
160
+ if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RG8;
161
161
 
162
162
  }
163
163
 
@@ -166,10 +166,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
166
166
  if ( glType === _gl.FLOAT ) internalFormat = _gl.RGBA32F;
167
167
  if ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RGBA16F;
168
168
  if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = ( encoding === sRGBEncoding && isVideoTexture === false ) ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
169
+ if ( glType === _gl.UNSIGNED_SHORT_4_4_4_4 ) internalFormat = _gl.RGBA4;
170
+ if ( glType === _gl.UNSIGNED_SHORT_5_5_5_1 ) internalFormat = _gl.RGB5_A1;
169
171
 
170
172
  }
171
173
 
172
174
  if ( internalFormat === _gl.R16F || internalFormat === _gl.R32F ||
175
+ internalFormat === _gl.RG16F || internalFormat === _gl.RG32F ||
173
176
  internalFormat === _gl.RGBA16F || internalFormat === _gl.RGBA32F ) {
174
177
 
175
178
  extensions.get( 'EXT_color_buffer_float' );
@@ -1631,13 +1634,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
1631
1634
  const format = texture.format;
1632
1635
  const type = texture.type;
1633
1636
 
1634
- if ( texture.isCompressedTexture === true || texture.format === _SRGBAFormat ) return image;
1637
+ if ( texture.isCompressedTexture === true || texture.isVideoTexture === true || texture.format === _SRGBAFormat ) return image;
1635
1638
 
1636
1639
  if ( encoding !== LinearEncoding ) {
1637
1640
 
1638
1641
  // sRGB
1639
1642
 
1640
- if ( encoding === sRGBEncoding && texture.isVideoTexture !== true ) {
1643
+ if ( encoding === sRGBEncoding ) {
1641
1644
 
1642
1645
  if ( isWebGL2 === false ) {
1643
1646