super-three 0.161.0 → 0.162.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 (131) hide show
  1. package/build/three.cjs +490 -393
  2. package/build/three.module.js +490 -391
  3. package/build/three.module.min.js +1 -1
  4. package/examples/jsm/controls/DragControls.js +91 -30
  5. package/examples/jsm/controls/OrbitControls.js +32 -6
  6. package/examples/jsm/controls/TransformControls.js +6 -6
  7. package/examples/jsm/exporters/GLTFExporter.js +11 -1
  8. package/examples/jsm/interactive/InteractiveGroup.js +15 -25
  9. package/examples/jsm/libs/rhino3dm/rhino3dm.js +1 -8723
  10. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +1 -8734
  11. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  12. package/examples/jsm/libs/tween.module.js +32 -14
  13. package/examples/jsm/loaders/3DMLoader.js +13 -21
  14. package/examples/jsm/loaders/VOXLoader.js +9 -2
  15. package/examples/jsm/loaders/VRMLLoader.js +6 -2
  16. package/examples/jsm/misc/ProgressiveLightMap.js +1 -0
  17. package/examples/jsm/nodes/Nodes.js +9 -7
  18. package/examples/jsm/nodes/accessors/AccessorsUtils.js +10 -0
  19. package/examples/jsm/nodes/accessors/ClippingNode.js +144 -0
  20. package/examples/jsm/nodes/accessors/MaterialNode.js +2 -2
  21. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +2 -12
  22. package/examples/jsm/nodes/accessors/MorphNode.js +8 -8
  23. package/examples/jsm/nodes/accessors/ReferenceNode.js +87 -29
  24. package/examples/jsm/nodes/accessors/SkinningNode.js +31 -10
  25. package/examples/jsm/nodes/accessors/StorageBufferNode.js +18 -0
  26. package/examples/jsm/nodes/accessors/TangentNode.js +8 -2
  27. package/examples/jsm/nodes/accessors/TextureNode.js +1 -1
  28. package/examples/jsm/nodes/accessors/UniformsNode.js +140 -0
  29. package/examples/jsm/nodes/code/CodeNode.js +6 -0
  30. package/examples/jsm/nodes/core/AssignNode.js +68 -12
  31. package/examples/jsm/nodes/core/Node.js +14 -4
  32. package/examples/jsm/nodes/core/NodeBuilder.js +3 -9
  33. package/examples/jsm/nodes/core/NodeFrame.js +2 -2
  34. package/examples/jsm/nodes/core/TempNode.js +1 -1
  35. package/examples/jsm/nodes/display/BlendModeNode.js +30 -1
  36. package/examples/jsm/nodes/display/NormalMapNode.js +3 -5
  37. package/examples/jsm/nodes/materials/NodeMaterial.js +37 -6
  38. package/examples/jsm/nodes/math/CondNode.js +42 -7
  39. package/examples/jsm/nodes/math/MathNode.js +20 -0
  40. package/examples/jsm/nodes/utils/ArrayElementNode.js +0 -6
  41. package/examples/jsm/nodes/utils/LoopNode.js +2 -0
  42. package/examples/jsm/nodes/utils/StorageArrayElementNode.js +91 -0
  43. package/examples/jsm/postprocessing/OutputPass.js +2 -0
  44. package/examples/jsm/renderers/common/Background.js +2 -2
  45. package/examples/jsm/renderers/common/ClippingContext.js +165 -0
  46. package/examples/jsm/renderers/common/RenderContext.js +2 -0
  47. package/examples/jsm/renderers/common/RenderContexts.js +2 -13
  48. package/examples/jsm/renderers/common/RenderObject.js +44 -1
  49. package/examples/jsm/renderers/common/RenderObjects.js +3 -1
  50. package/examples/jsm/renderers/common/Renderer.js +94 -37
  51. package/examples/jsm/renderers/common/StorageBufferAttribute.js +2 -2
  52. package/examples/jsm/renderers/common/StorageInstancedBufferAttribute.js +17 -0
  53. package/examples/jsm/renderers/common/Textures.js +3 -13
  54. package/examples/jsm/renderers/common/UniformsGroup.js +6 -4
  55. package/examples/jsm/renderers/common/nodes/NodeStorageBuffer.js +23 -0
  56. package/examples/jsm/renderers/common/nodes/NodeUniformBuffer.js +23 -0
  57. package/examples/jsm/renderers/common/nodes/Nodes.js +1 -0
  58. package/examples/jsm/renderers/webgl/WebGLBackend.js +26 -6
  59. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +135 -10
  60. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +7 -1
  61. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +47 -0
  62. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +1 -0
  63. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +13 -12
  64. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +15 -40
  65. package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +7 -1
  66. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +2 -2
  67. package/examples/jsm/shaders/OutputShader.js +4 -0
  68. package/examples/jsm/utils/SkeletonUtils.js +14 -3
  69. package/examples/jsm/webxr/VRButton.js +13 -5
  70. package/examples/jsm/webxr/XRButton.js +0 -1
  71. package/examples/jsm/webxr/XRControllerModelFactory.js +8 -0
  72. package/package.json +4 -3
  73. package/src/Three.Legacy.js +20 -0
  74. package/src/Three.js +0 -1
  75. package/src/constants.js +2 -5
  76. package/src/core/BufferAttribute.js +0 -11
  77. package/src/core/BufferGeometry.js +23 -29
  78. package/src/core/Object3D.js +11 -0
  79. package/src/core/Raycaster.js +18 -4
  80. package/src/core/RenderTarget.js +44 -21
  81. package/src/extras/PMREMGenerator.js +2 -0
  82. package/src/extras/curves/EllipseCurve.js +2 -2
  83. package/src/helpers/SpotLightHelper.js +18 -1
  84. package/src/loaders/DataTextureLoader.js +0 -4
  85. package/src/loaders/MaterialLoader.js +1 -0
  86. package/src/loaders/ObjectLoader.js +2 -1
  87. package/src/materials/Material.js +2 -1
  88. package/src/materials/MeshBasicMaterial.js +3 -0
  89. package/src/materials/MeshLambertMaterial.js +3 -0
  90. package/src/materials/MeshPhongMaterial.js +3 -0
  91. package/src/materials/MeshStandardMaterial.js +3 -0
  92. package/src/math/Quaternion.js +13 -12
  93. package/src/math/Vector3.js +7 -7
  94. package/src/objects/InstancedMesh.js +53 -0
  95. package/src/objects/Mesh.js +0 -1
  96. package/src/renderers/WebGLCubeRenderTarget.js +1 -10
  97. package/src/renderers/WebGLRenderer.js +15 -22
  98. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -0
  99. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
  100. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +2 -2
  101. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +1 -1
  102. package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +14 -0
  103. package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +11 -2
  104. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +23 -0
  105. package/src/renderers/shaders/ShaderChunk.js +2 -0
  106. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +3 -2
  107. package/src/renderers/shaders/ShaderLib/depth.glsl.js +2 -0
  108. package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +2 -0
  109. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +1 -0
  110. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -0
  111. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +1 -0
  112. package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +1 -0
  113. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -0
  114. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +1 -0
  115. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -0
  116. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +1 -0
  117. package/src/renderers/shaders/ShaderLib/points.glsl.js +1 -0
  118. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
  119. package/src/renderers/shaders/ShaderLib.js +2 -1
  120. package/src/renderers/shaders/UniformsLib.js +1 -0
  121. package/src/renderers/webgl/WebGLBackground.js +18 -0
  122. package/src/renderers/webgl/WebGLMaterials.js +24 -1
  123. package/src/renderers/webgl/WebGLMorphtargets.js +15 -8
  124. package/src/renderers/webgl/WebGLProgram.js +12 -1
  125. package/src/renderers/webgl/WebGLPrograms.js +19 -16
  126. package/src/renderers/webgl/WebGLState.js +11 -21
  127. package/src/renderers/webgl/WebGLTextures.js +80 -50
  128. package/src/scenes/Scene.js +8 -0
  129. package/src/textures/Texture.js +1 -29
  130. package/examples/jsm/nodes/core/ArrayUniformNode.js +0 -26
  131. package/src/renderers/WebGLMultipleRenderTargets.js +0 -82
@@ -388,7 +388,6 @@ function checkGeometryIntersection( object, material, raycaster, ray, uv, uv1, n
388
388
  _uvC.fromBufferAttribute( uv1, c );
389
389
 
390
390
  intersection.uv1 = Triangle.getInterpolation( _intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2() );
391
- intersection.uv2 = intersection.uv1; // @deprecated, r152
392
391
 
393
392
  }
394
393
 
@@ -1,4 +1,4 @@
1
- import { BackSide, LinearFilter, LinearMipmapLinearFilter, NoBlending, NoColorSpace, SRGBColorSpace, sRGBEncoding } from '../constants.js';
1
+ import { BackSide, LinearFilter, LinearMipmapLinearFilter, NoBlending } from '../constants.js';
2
2
  import { Mesh } from '../objects/Mesh.js';
3
3
  import { BoxGeometry } from '../geometries/BoxGeometry.js';
4
4
  import { ShaderMaterial } from '../materials/ShaderMaterial.js';
@@ -6,7 +6,6 @@ import { cloneUniforms } from './shaders/UniformsUtils.js';
6
6
  import { WebGLRenderTarget } from './WebGLRenderTarget.js';
7
7
  import { CubeCamera } from '../cameras/CubeCamera.js';
8
8
  import { CubeTexture } from '../textures/CubeTexture.js';
9
- import { warnOnce } from '../utils.js';
10
9
 
11
10
  class WebGLCubeRenderTarget extends WebGLRenderTarget {
12
11
 
@@ -19,14 +18,6 @@ class WebGLCubeRenderTarget extends WebGLRenderTarget {
19
18
  const image = { width: size, height: size, depth: 1 };
20
19
  const images = [ image, image, image, image, image, image ];
21
20
 
22
- if ( options.encoding !== undefined ) {
23
-
24
- // @deprecated, r152
25
- warnOnce( 'THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace.' );
26
- options.colorSpace = options.encoding === sRGBEncoding ? SRGBColorSpace : NoColorSpace;
27
-
28
- }
29
-
30
21
  this.texture = new CubeTexture( images, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.colorSpace );
31
22
 
32
23
  // By convention -- likely based on the RenderMan spec from the 1990's -- cube maps are specified by WebGL (and three.js)
@@ -11,8 +11,6 @@ import {
11
11
  LinearMipmapLinearFilter,
12
12
  SRGBColorSpace,
13
13
  LinearSRGBColorSpace,
14
- sRGBEncoding,
15
- LinearEncoding,
16
14
  RGBAIntegerFormat,
17
15
  RGIntegerFormat,
18
16
  RedIntegerFormat,
@@ -496,7 +494,7 @@ class WebGLRenderer {
496
494
 
497
495
  }
498
496
 
499
- state.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor() );
497
+ state.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).round() );
500
498
 
501
499
  };
502
500
 
@@ -518,7 +516,7 @@ class WebGLRenderer {
518
516
 
519
517
  }
520
518
 
521
- state.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor() );
519
+ state.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).round() );
522
520
 
523
521
  };
524
522
 
@@ -1636,6 +1634,7 @@ class WebGLRenderer {
1636
1634
  materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null;
1637
1635
  materialProperties.fog = scene.fog;
1638
1636
  materialProperties.envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || materialProperties.environment );
1637
+ materialProperties.envMapRotation = ( materialProperties.environment !== null && material.envMap === null ) ? scene.environmentRotation : material.envMapRotation;
1639
1638
 
1640
1639
  if ( programs === undefined ) {
1641
1640
 
@@ -1748,6 +1747,7 @@ class WebGLRenderer {
1748
1747
  materialProperties.batching = parameters.batching;
1749
1748
  materialProperties.instancing = parameters.instancing;
1750
1749
  materialProperties.instancingColor = parameters.instancingColor;
1750
+ materialProperties.instancingMorph = parameters.instancingMorph;
1751
1751
  materialProperties.skinning = parameters.skinning;
1752
1752
  materialProperties.morphTargets = parameters.morphTargets;
1753
1753
  materialProperties.morphNormals = parameters.morphNormals;
@@ -1861,6 +1861,14 @@ class WebGLRenderer {
1861
1861
 
1862
1862
  needsProgramChange = true;
1863
1863
 
1864
+ } else if ( object.isInstancedMesh && materialProperties.instancingMorph === true && object.morphTexture === null ) {
1865
+
1866
+ needsProgramChange = true;
1867
+
1868
+ } else if ( object.isInstancedMesh && materialProperties.instancingMorph === false && object.morphTexture !== null ) {
1869
+
1870
+ needsProgramChange = true;
1871
+
1864
1872
  } else if ( materialProperties.envMap !== envMap ) {
1865
1873
 
1866
1874
  needsProgramChange = true;
@@ -2506,8 +2514,8 @@ class WebGLRenderer {
2506
2514
 
2507
2515
  }
2508
2516
 
2509
- const width = sourceBox.max.x - sourceBox.min.x + 1;
2510
- const height = sourceBox.max.y - sourceBox.min.y + 1;
2517
+ const width = Math.round( sourceBox.max.x - sourceBox.min.x );
2518
+ const height = Math.round( sourceBox.max.y - sourceBox.min.y );
2511
2519
  const depth = sourceBox.max.z - sourceBox.min.z + 1;
2512
2520
  const glFormat = utils.convert( dstTexture.format );
2513
2521
  const glType = utils.convert( dstTexture.type );
@@ -2554,9 +2562,8 @@ class WebGLRenderer {
2554
2562
 
2555
2563
  } else {
2556
2564
 
2557
- if ( srcTexture.isCompressedArrayTexture ) {
2565
+ if ( dstTexture.isCompressedArrayTexture ) {
2558
2566
 
2559
- console.warn( 'THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture.' );
2560
2567
  _gl.compressedTexSubImage3D( glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, image.data );
2561
2568
 
2562
2569
  } else {
@@ -2645,20 +2652,6 @@ class WebGLRenderer {
2645
2652
 
2646
2653
  }
2647
2654
 
2648
- get outputEncoding() { // @deprecated, r152
2649
-
2650
- console.warn( 'THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead.' );
2651
- return this.outputColorSpace === SRGBColorSpace ? sRGBEncoding : LinearEncoding;
2652
-
2653
- }
2654
-
2655
- set outputEncoding( encoding ) { // @deprecated, r152
2656
-
2657
- console.warn( 'THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead.' );
2658
- this.outputColorSpace = encoding === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace;
2659
-
2660
- }
2661
-
2662
2655
  get useLegacyLights() { // @deprecated, r155
2663
2656
 
2664
2657
  console.warn( 'THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733.' );
@@ -3,6 +3,7 @@ export default /* glsl */`
3
3
 
4
4
  uniform float envMapIntensity;
5
5
  uniform float flipEnvMap;
6
+ uniform mat3 envMapRotation;
6
7
 
7
8
  #ifdef ENVMAP_TYPE_CUBE
8
9
  uniform samplerCube envMap;
@@ -36,7 +36,7 @@ export default /* glsl */`
36
36
 
37
37
  #ifdef ENVMAP_TYPE_CUBE
38
38
 
39
- vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
39
+ vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
40
40
 
41
41
  #else
42
42
 
@@ -7,7 +7,7 @@ export default /* glsl */`
7
7
 
8
8
  vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
9
9
 
10
- vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
10
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
11
11
 
12
12
  return PI * envMapColor.rgb * envMapIntensity;
13
13
 
@@ -30,7 +30,7 @@ export default /* glsl */`
30
30
 
31
31
  reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
32
32
 
33
- vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
33
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
34
34
 
35
35
  return envMapColor.rgb * envMapIntensity;
36
36
 
@@ -5,7 +5,7 @@ export default /* glsl */`
5
5
 
6
6
  #ifdef DECODE_VIDEO_TEXTURE
7
7
 
8
- // use inline sRGB decode until browsers properly support SRGB8_APLHA8 with video textures
8
+ // use inline sRGB decode until browsers properly support SRGB8_ALPHA8 with video textures (#26516)
9
9
 
10
10
  sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
11
11
 
@@ -0,0 +1,14 @@
1
+ export default /* glsl */`
2
+ #ifdef USE_INSTANCING_MORPH
3
+
4
+ float morphTargetInfluences[MORPHTARGETS_COUNT];
5
+
6
+ float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
7
+
8
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
9
+
10
+ morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
11
+
12
+ }
13
+ #endif
14
+ `;
@@ -1,11 +1,20 @@
1
1
  export default /* glsl */`
2
2
  #ifdef USE_MORPHTARGETS
3
3
 
4
- uniform float morphTargetBaseInfluence;
4
+ #ifndef USE_INSTANCING_MORPH
5
+
6
+ uniform float morphTargetBaseInfluence;
7
+
8
+ #endif
5
9
 
6
10
  #ifdef MORPHTARGETS_TEXTURE
7
11
 
8
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
12
+ #ifndef USE_INSTANCING_MORPH
13
+
14
+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
15
+
16
+ #endif
17
+
9
18
  uniform sampler2DArray morphTargetsTexture;
10
19
  uniform ivec2 morphTargetsTextureSize;
11
20
 
@@ -165,5 +165,28 @@ vec3 AgXToneMapping( vec3 color ) {
165
165
 
166
166
  }
167
167
 
168
+ // https://modelviewer.dev/examples/tone-mapping
169
+
170
+ vec3 NeutralToneMapping( vec3 color ) {
171
+ float startCompression = 0.8 - 0.04;
172
+ float desaturation = 0.15;
173
+
174
+ color *= toneMappingExposure;
175
+
176
+ float x = min(color.r, min(color.g, color.b));
177
+ float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
178
+ color -= offset;
179
+
180
+ float peak = max(color.r, max(color.g, color.b));
181
+ if (peak < startCompression) return color;
182
+
183
+ float d = 1. - startCompression;
184
+ float newPeak = 1. - d * d / (peak + d - startCompression);
185
+ color *= newPeak / peak;
186
+
187
+ float g = 1. - 1. / (desaturation * (peak - newPeak) + 1.);
188
+ return mix(color, vec3(1, 1, 1), g);
189
+ }
190
+
168
191
  vec3 CustomToneMapping( vec3 color ) { return color; }
169
192
  `;
@@ -65,6 +65,7 @@ import map_particle_fragment from './ShaderChunk/map_particle_fragment.glsl.js';
65
65
  import map_particle_pars_fragment from './ShaderChunk/map_particle_pars_fragment.glsl.js';
66
66
  import metalnessmap_fragment from './ShaderChunk/metalnessmap_fragment.glsl.js';
67
67
  import metalnessmap_pars_fragment from './ShaderChunk/metalnessmap_pars_fragment.glsl.js';
68
+ import morphinstance_vertex from './ShaderChunk/morphinstance_vertex.glsl.js';
68
69
  import morphcolor_vertex from './ShaderChunk/morphcolor_vertex.glsl.js';
69
70
  import morphnormal_vertex from './ShaderChunk/morphnormal_vertex.glsl.js';
70
71
  import morphtarget_pars_vertex from './ShaderChunk/morphtarget_pars_vertex.glsl.js';
@@ -192,6 +193,7 @@ export const ShaderChunk = {
192
193
  map_particle_pars_fragment: map_particle_pars_fragment,
193
194
  metalnessmap_fragment: metalnessmap_fragment,
194
195
  metalnessmap_pars_fragment: metalnessmap_pars_fragment,
196
+ morphinstance_vertex: morphinstance_vertex,
195
197
  morphcolor_vertex: morphcolor_vertex,
196
198
  morphnormal_vertex: morphnormal_vertex,
197
199
  morphtarget_pars_vertex: morphtarget_pars_vertex,
@@ -30,6 +30,7 @@ export const fragment = /* glsl */`
30
30
  uniform float flipEnvMap;
31
31
  uniform float backgroundBlurriness;
32
32
  uniform float backgroundIntensity;
33
+ uniform mat3 backgroundRotation;
33
34
 
34
35
  varying vec3 vWorldDirection;
35
36
 
@@ -39,11 +40,11 @@ void main() {
39
40
 
40
41
  #ifdef ENVMAP_TYPE_CUBE
41
42
 
42
- vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
43
+ vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
43
44
 
44
45
  #elif defined( ENVMAP_TYPE_CUBE_UV )
45
46
 
46
- vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
47
+ vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
47
48
 
48
49
  #else
49
50
 
@@ -20,6 +20,8 @@ void main() {
20
20
  #include <batching_vertex>
21
21
  #include <skinbase_vertex>
22
22
 
23
+ #include <morphinstance_vertex>
24
+
23
25
  #ifdef USE_DISPLACEMENTMAP
24
26
 
25
27
  #include <beginnormal_vertex>
@@ -18,6 +18,8 @@ void main() {
18
18
  #include <batching_vertex>
19
19
  #include <skinbase_vertex>
20
20
 
21
+ #include <morphinstance_vertex>
22
+
21
23
  #ifdef USE_DISPLACEMENTMAP
22
24
 
23
25
  #include <beginnormal_vertex>
@@ -18,6 +18,7 @@ void main() {
18
18
 
19
19
  #include <uv_vertex>
20
20
  #include <color_vertex>
21
+ #include <morphinstance_vertex>
21
22
  #include <morphcolor_vertex>
22
23
  #include <begin_vertex>
23
24
  #include <morphtarget_vertex>
@@ -14,6 +14,7 @@ void main() {
14
14
 
15
15
  #include <uv_vertex>
16
16
  #include <color_vertex>
17
+ #include <morphinstance_vertex>
17
18
  #include <morphcolor_vertex>
18
19
  #include <batching_vertex>
19
20
 
@@ -21,6 +21,7 @@ void main() {
21
21
 
22
22
  #include <uv_vertex>
23
23
  #include <color_vertex>
24
+ #include <morphinstance_vertex>
24
25
  #include <morphcolor_vertex>
25
26
  #include <batching_vertex>
26
27
 
@@ -20,6 +20,7 @@ void main() {
20
20
 
21
21
  #include <uv_vertex>
22
22
  #include <color_vertex>
23
+ #include <morphinstance_vertex>
23
24
  #include <morphcolor_vertex>
24
25
  #include <batching_vertex>
25
26
 
@@ -23,6 +23,7 @@ void main() {
23
23
  #include <batching_vertex>
24
24
 
25
25
  #include <beginnormal_vertex>
26
+ #include <morphinstance_vertex>
26
27
  #include <morphnormal_vertex>
27
28
  #include <skinbase_vertex>
28
29
  #include <skinnormal_vertex>
@@ -25,6 +25,7 @@ void main() {
25
25
  #include <batching_vertex>
26
26
 
27
27
  #include <beginnormal_vertex>
28
+ #include <morphinstance_vertex>
28
29
  #include <morphnormal_vertex>
29
30
  #include <skinbase_vertex>
30
31
  #include <skinnormal_vertex>
@@ -26,6 +26,7 @@ void main() {
26
26
 
27
27
  #include <uv_vertex>
28
28
  #include <color_vertex>
29
+ #include <morphinstance_vertex>
29
30
  #include <morphcolor_vertex>
30
31
  #include <batching_vertex>
31
32
 
@@ -20,6 +20,7 @@ void main() {
20
20
 
21
21
  #include <uv_vertex>
22
22
  #include <color_vertex>
23
+ #include <morphinstance_vertex>
23
24
  #include <morphcolor_vertex>
24
25
  #include <batching_vertex>
25
26
 
@@ -25,6 +25,7 @@ void main() {
25
25
  #endif
26
26
 
27
27
  #include <color_vertex>
28
+ #include <morphinstance_vertex>
28
29
  #include <morphcolor_vertex>
29
30
  #include <begin_vertex>
30
31
  #include <morphtarget_vertex>
@@ -12,6 +12,7 @@ void main() {
12
12
  #include <batching_vertex>
13
13
 
14
14
  #include <beginnormal_vertex>
15
+ #include <morphinstance_vertex>
15
16
  #include <morphnormal_vertex>
16
17
  #include <skinbase_vertex>
17
18
  #include <skinnormal_vertex>
@@ -232,7 +232,8 @@ const ShaderLib = {
232
232
  envMap: { value: null },
233
233
  flipEnvMap: { value: - 1 },
234
234
  backgroundBlurriness: { value: 0 },
235
- backgroundIntensity: { value: 1 }
235
+ backgroundIntensity: { value: 1 },
236
+ backgroundRotation: { value: /*@__PURE__*/ new Matrix3() }
236
237
  },
237
238
 
238
239
  vertexShader: ShaderChunk.backgroundCube_vert,
@@ -33,6 +33,7 @@ const UniformsLib = {
33
33
  envmap: {
34
34
 
35
35
  envMap: { value: null },
36
+ envMapRotation: { value: /*@__PURE__*/ new Matrix3() },
36
37
  flipEnvMap: { value: - 1 },
37
38
  reflectivity: { value: 1.0 }, // basic, lambert, phong
38
39
  ior: { value: 1.5 }, // physical
@@ -4,11 +4,15 @@ import { PlaneGeometry } from '../../geometries/PlaneGeometry.js';
4
4
  import { ShaderMaterial } from '../../materials/ShaderMaterial.js';
5
5
  import { Color } from '../../math/Color.js';
6
6
  import { ColorManagement } from '../../math/ColorManagement.js';
7
+ import { Euler } from '../../math/Euler.js';
8
+ import { Matrix4 } from '../../math/Matrix4.js';
7
9
  import { Mesh } from '../../objects/Mesh.js';
8
10
  import { ShaderLib } from '../shaders/ShaderLib.js';
9
11
  import { cloneUniforms, getUnlitUniformColorSpace } from '../shaders/UniformsUtils.js';
10
12
 
11
13
  const _rgb = { r: 0, b: 0, g: 0 };
14
+ const _e1 = /*@__PURE__*/ new Euler();
15
+ const _m1 = /*@__PURE__*/ new Matrix4();
12
16
 
13
17
  function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha, premultipliedAlpha ) {
14
18
 
@@ -105,10 +109,24 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
105
109
 
106
110
  }
107
111
 
112
+ _e1.copy( scene.backgroundRotation );
113
+
114
+ // accommodate left-handed frame
115
+ _e1.x *= - 1; _e1.y *= - 1; _e1.z *= - 1;
116
+
117
+ if ( background.isCubeTexture && background.isRenderTargetTexture === false ) {
118
+
119
+ // environment maps which are not cube render targets or PMREMs follow a different convention
120
+ _e1.y *= - 1;
121
+ _e1.z *= - 1;
122
+
123
+ }
124
+
108
125
  boxMesh.material.uniforms.envMap.value = background;
109
126
  boxMesh.material.uniforms.flipEnvMap.value = ( background.isCubeTexture && background.isRenderTargetTexture === false ) ? - 1 : 1;
110
127
  boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
111
128
  boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
129
+ boxMesh.material.uniforms.backgroundRotation.value.setFromMatrix4( _m1.makeRotationFromEuler( _e1 ) );
112
130
  boxMesh.material.toneMapped = ColorManagement.getTransfer( background.colorSpace ) !== SRGBTransfer;
113
131
 
114
132
  if ( currentBackground !== background ||
@@ -1,5 +1,10 @@
1
1
  import { BackSide } from '../../constants.js';
2
2
  import { getUnlitUniformColorSpace } from '../shaders/UniformsUtils.js';
3
+ import { Euler } from '../../math/Euler.js';
4
+ import { Matrix4 } from '../../math/Matrix4.js';
5
+
6
+ const _e1 = /*@__PURE__*/ new Euler();
7
+ const _m1 = /*@__PURE__*/ new Matrix4();
3
8
 
4
9
  function WebGLMaterials( renderer, properties ) {
5
10
 
@@ -209,12 +214,30 @@ function WebGLMaterials( renderer, properties ) {
209
214
 
210
215
  }
211
216
 
212
- const envMap = properties.get( material ).envMap;
217
+ const materialProperties = properties.get( material );
218
+
219
+ const envMap = materialProperties.envMap;
220
+ const envMapRotation = materialProperties.envMapRotation;
213
221
 
214
222
  if ( envMap ) {
215
223
 
216
224
  uniforms.envMap.value = envMap;
217
225
 
226
+ _e1.copy( envMapRotation );
227
+
228
+ // accommodate left-handed frame
229
+ _e1.x *= - 1; _e1.y *= - 1; _e1.z *= - 1;
230
+
231
+ if ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) {
232
+
233
+ // environment maps which are not cube render targets or PMREMs follow a different convention
234
+ _e1.y *= - 1;
235
+ _e1.z *= - 1;
236
+
237
+ }
238
+
239
+ uniforms.envMapRotation.value.setFromMatrix4( _m1.makeRotationFromEuler( _e1 ) );
240
+
218
241
  uniforms.flipEnvMap.value = ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) ? - 1 : 1;
219
242
 
220
243
  uniforms.reflectivity.value = material.reflectivity;
@@ -154,24 +154,31 @@ function WebGLMorphtargets( gl, capabilities, textures ) {
154
154
  }
155
155
 
156
156
  //
157
+ if ( object.isInstancedMesh === true && object.morphTexture !== null ) {
157
158
 
158
- let morphInfluencesSum = 0;
159
+ program.getUniforms().setValue( gl, 'morphTexture', object.morphTexture, textures );
159
160
 
160
- for ( let i = 0; i < objectInfluences.length; i ++ ) {
161
+ } else {
161
162
 
162
- morphInfluencesSum += objectInfluences[ i ];
163
+ let morphInfluencesSum = 0;
163
164
 
164
- }
165
+ for ( let i = 0; i < objectInfluences.length; i ++ ) {
165
166
 
166
- const morphBaseInfluence = geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum;
167
+ morphInfluencesSum += objectInfluences[ i ];
167
168
 
168
- program.getUniforms().setValue( gl, 'morphTargetBaseInfluence', morphBaseInfluence );
169
- program.getUniforms().setValue( gl, 'morphTargetInfluences', objectInfluences );
169
+ }
170
+
171
+ const morphBaseInfluence = geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum;
172
+
173
+
174
+ program.getUniforms().setValue( gl, 'morphTargetBaseInfluence', morphBaseInfluence );
175
+ program.getUniforms().setValue( gl, 'morphTargetInfluences', objectInfluences );
176
+
177
+ }
170
178
 
171
179
  program.getUniforms().setValue( gl, 'morphTargetsTexture', entry.texture, textures );
172
180
  program.getUniforms().setValue( gl, 'morphTargetsTextureSize', entry.size );
173
181
 
174
-
175
182
  } else {
176
183
 
177
184
  // When object doesn't have morph target influences defined, we treat it as a 0-length array
@@ -1,7 +1,7 @@
1
1
  import { WebGLUniforms } from './WebGLUniforms.js';
2
2
  import { WebGLShader } from './WebGLShader.js';
3
3
  import { ShaderChunk } from '../shaders/ShaderChunk.js';
4
- import { NoToneMapping, AddOperation, MixOperation, MultiplyOperation, CubeRefractionMapping, CubeUVReflectionMapping, CubeReflectionMapping, PCFSoftShadowMap, PCFShadowMap, VSMShadowMap, AgXToneMapping, ACESFilmicToneMapping, CineonToneMapping, CustomToneMapping, ReinhardToneMapping, LinearToneMapping, GLSL3, LinearSRGBColorSpace, SRGBColorSpace, LinearDisplayP3ColorSpace, DisplayP3ColorSpace, P3Primaries, Rec709Primaries } from '../../constants.js';
4
+ import { NoToneMapping, AddOperation, MixOperation, MultiplyOperation, CubeRefractionMapping, CubeUVReflectionMapping, CubeReflectionMapping, PCFSoftShadowMap, PCFShadowMap, VSMShadowMap, AgXToneMapping, ACESFilmicToneMapping, NeutralToneMapping, CineonToneMapping, CustomToneMapping, ReinhardToneMapping, LinearToneMapping, GLSL3, LinearSRGBColorSpace, SRGBColorSpace, LinearDisplayP3ColorSpace, DisplayP3ColorSpace, P3Primaries, Rec709Primaries } from '../../constants.js';
5
5
  import { ColorManagement } from '../../math/ColorManagement.js';
6
6
 
7
7
  // From https://www.khronos.org/registry/webgl/extensions/KHR_parallel_shader_compile/
@@ -124,6 +124,10 @@ function getToneMappingFunction( functionName, toneMapping ) {
124
124
  toneMappingName = 'AgX';
125
125
  break;
126
126
 
127
+ case NeutralToneMapping:
128
+ toneMappingName = 'Neutral';
129
+ break;
130
+
127
131
  case CustomToneMapping:
128
132
  toneMappingName = 'Custom';
129
133
  break;
@@ -549,6 +553,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
549
553
  parameters.batching ? '#define USE_BATCHING' : '',
550
554
  parameters.instancing ? '#define USE_INSTANCING' : '',
551
555
  parameters.instancingColor ? '#define USE_INSTANCING_COLOR' : '',
556
+ parameters.instancingMorph ? '#define USE_INSTANCING_MORPH' : '',
552
557
 
553
558
  parameters.useFog && parameters.fog ? '#define USE_FOG' : '',
554
559
  parameters.useFog && parameters.fogExp2 ? '#define FOG_EXP2' : '',
@@ -680,6 +685,12 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
680
685
 
681
686
  '#endif',
682
687
 
688
+ '#ifdef USE_INSTANCING_MORPH',
689
+
690
+ ' uniform sampler2D morphTexture;',
691
+
692
+ '#endif',
693
+
683
694
  'attribute vec3 position;',
684
695
  'attribute vec3 normal;',
685
696
  'attribute vec2 uv;',
@@ -198,6 +198,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
198
198
  batching: IS_BATCHEDMESH,
199
199
  instancing: IS_INSTANCEDMESH,
200
200
  instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
201
+ instancingMorph: IS_INSTANCEDMESH && object.morphTexture !== null,
201
202
 
202
203
  supportsVertexTextures: SUPPORTS_VERTEX_TEXTURES,
203
204
  numMultiviewViews: numMultiviewViews,
@@ -485,38 +486,40 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
485
486
  _programLayers.enable( 2 );
486
487
  if ( parameters.instancingColor )
487
488
  _programLayers.enable( 3 );
488
- if ( parameters.matcap )
489
+ if ( parameters.instancingMorph )
489
490
  _programLayers.enable( 4 );
490
- if ( parameters.envMap )
491
+ if ( parameters.matcap )
491
492
  _programLayers.enable( 5 );
492
- if ( parameters.normalMapObjectSpace )
493
+ if ( parameters.envMap )
493
494
  _programLayers.enable( 6 );
494
- if ( parameters.normalMapTangentSpace )
495
+ if ( parameters.normalMapObjectSpace )
495
496
  _programLayers.enable( 7 );
496
- if ( parameters.clearcoat )
497
+ if ( parameters.normalMapTangentSpace )
497
498
  _programLayers.enable( 8 );
498
- if ( parameters.iridescence )
499
+ if ( parameters.clearcoat )
499
500
  _programLayers.enable( 9 );
500
- if ( parameters.alphaTest )
501
+ if ( parameters.iridescence )
501
502
  _programLayers.enable( 10 );
502
- if ( parameters.vertexColors )
503
+ if ( parameters.alphaTest )
503
504
  _programLayers.enable( 11 );
504
- if ( parameters.vertexAlphas )
505
+ if ( parameters.vertexColors )
505
506
  _programLayers.enable( 12 );
506
- if ( parameters.vertexUv1s )
507
+ if ( parameters.vertexAlphas )
507
508
  _programLayers.enable( 13 );
508
- if ( parameters.vertexUv2s )
509
+ if ( parameters.vertexUv1s )
509
510
  _programLayers.enable( 14 );
510
- if ( parameters.vertexUv3s )
511
+ if ( parameters.vertexUv2s )
511
512
  _programLayers.enable( 15 );
512
- if ( parameters.vertexTangents )
513
+ if ( parameters.vertexUv3s )
513
514
  _programLayers.enable( 16 );
514
- if ( parameters.anisotropy )
515
+ if ( parameters.vertexTangents )
515
516
  _programLayers.enable( 17 );
516
- if ( parameters.alphaHash )
517
+ if ( parameters.anisotropy )
517
518
  _programLayers.enable( 18 );
518
- if ( parameters.batching )
519
+ if ( parameters.alphaHash )
519
520
  _programLayers.enable( 19 );
521
+ if ( parameters.batching )
522
+ _programLayers.enable( 20 );
520
523
 
521
524
  array.push( _programLayers.mask );
522
525
  _programLayers.disableAll();